Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlubos committed Jan 12, 2025
1 parent 14d3c4c commit be2a6e1
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from 'zod';

export const zFoo = z.object({
bar: z.number().int().optional(),
foo: z.bigint(),
foo: z.coerce.bigint(),
id: z.string()
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from 'zod';

export const zFoo = z.object({
bar: z.number().int().optional(),
foo: z.bigint(),
foo: z.coerce.bigint(),
id: z.string()
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from 'zod';

export const zFoo = z.object({
bar: z.number().int().optional(),
foo: z.bigint(),
foo: z.coerce.bigint(),
id: z.string()
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export const zFoo = z.object({
z.literal(true)
]).optional(),
corge: z.object({}).optional(),
garply: z.bigint().optional()
garply: z.coerce.bigint().optional()
});
Original file line number Diff line number Diff line change
Expand Up @@ -135,46 +135,46 @@ export interface RequestOptions<
}

export type RequestResult<
Data = unknown,
TData = unknown,
TError = unknown,
ThrowOnError extends boolean = boolean,
> = ThrowOnError extends true
? Promise<AxiosResponse<Data>>
? Promise<AxiosResponse<TData>>
: Promise<
| (AxiosResponse<Data> & { error: undefined })
| (AxiosResponse<TData> & { error: undefined })
| (AxiosError<TError> & { data: undefined; error: TError })
>;

type MethodFn = <
Data = unknown,
TData = unknown,
TError = unknown,
ThrowOnError extends boolean = false,
>(
options: Omit<RequestOptions<ThrowOnError>, 'method'>,
) => RequestResult<Data, TError, ThrowOnError>;
) => RequestResult<TData, TError, ThrowOnError>;

type RequestFn = <
Data = unknown,
TData = unknown,
TError = unknown,
ThrowOnError extends boolean = false,
>(
options: Omit<RequestOptions<ThrowOnError>, 'method'> &
Pick<Required<RequestOptions<ThrowOnError>>, 'method'>,
) => RequestResult<Data, TError, ThrowOnError>;
) => RequestResult<TData, TError, ThrowOnError>;

export interface Client {
/**
* Returns the final request URL. This method works only with experimental parser.
*/
buildUrl: <
Data extends {
TData extends {
body?: unknown;
path?: Record<string, unknown>;
query?: Record<string, unknown>;
url: string;
},
>(
options: Pick<Data, 'url'> & Omit<Options<Data>, 'axios'>,
options: Pick<TData, 'url'> & Omit<Options<TData>, 'axios'>,
) => string;
delete: MethodFn;
get: MethodFn;
Expand All @@ -198,22 +198,22 @@ interface DataShape {
}

export type Options<
Data extends DataShape = DataShape,
TData extends DataShape = DataShape,
ThrowOnError extends boolean = boolean,
> = OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'path' | 'query' | 'url'> &
Omit<Data, 'url'>;
Omit<TData, 'url'>;

export type OptionsLegacyParser<
Data = unknown,
TData = unknown,
ThrowOnError extends boolean = boolean,
> = Data extends { body?: any }
? Data extends { headers?: any }
? OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'headers' | 'url'> & Data
> = TData extends { body?: any }
? TData extends { headers?: any }
? OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'headers' | 'url'> & TData
: OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'url'> &
Data &
TData &
Pick<RequestOptions<ThrowOnError>, 'headers'>
: Data extends { headers?: any }
: TData extends { headers?: any }
? OmitKeys<RequestOptions<ThrowOnError>, 'headers' | 'url'> &
Data &
TData &
Pick<RequestOptions<ThrowOnError>, 'body'>
: OmitKeys<RequestOptions<ThrowOnError>, 'url'> & Data;
: OmitKeys<RequestOptions<ThrowOnError>, 'url'> & TData;
Original file line number Diff line number Diff line change
Expand Up @@ -135,46 +135,46 @@ export interface RequestOptions<
}

export type RequestResult<
Data = unknown,
TData = unknown,
TError = unknown,
ThrowOnError extends boolean = boolean,
> = ThrowOnError extends true
? Promise<AxiosResponse<Data>>
? Promise<AxiosResponse<TData>>
: Promise<
| (AxiosResponse<Data> & { error: undefined })
| (AxiosResponse<TData> & { error: undefined })
| (AxiosError<TError> & { data: undefined; error: TError })
>;

type MethodFn = <
Data = unknown,
TData = unknown,
TError = unknown,
ThrowOnError extends boolean = false,
>(
options: Omit<RequestOptions<ThrowOnError>, 'method'>,
) => RequestResult<Data, TError, ThrowOnError>;
) => RequestResult<TData, TError, ThrowOnError>;

type RequestFn = <
Data = unknown,
TData = unknown,
TError = unknown,
ThrowOnError extends boolean = false,
>(
options: Omit<RequestOptions<ThrowOnError>, 'method'> &
Pick<Required<RequestOptions<ThrowOnError>>, 'method'>,
) => RequestResult<Data, TError, ThrowOnError>;
) => RequestResult<TData, TError, ThrowOnError>;

export interface Client {
/**
* Returns the final request URL. This method works only with experimental parser.
*/
buildUrl: <
Data extends {
TData extends {
body?: unknown;
path?: Record<string, unknown>;
query?: Record<string, unknown>;
url: string;
},
>(
options: Pick<Data, 'url'> & Omit<Options<Data>, 'axios'>,
options: Pick<TData, 'url'> & Omit<Options<TData>, 'axios'>,
) => string;
delete: MethodFn;
get: MethodFn;
Expand All @@ -198,22 +198,22 @@ interface DataShape {
}

export type Options<
Data extends DataShape = DataShape,
TData extends DataShape = DataShape,
ThrowOnError extends boolean = boolean,
> = OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'path' | 'query' | 'url'> &
Omit<Data, 'url'>;
Omit<TData, 'url'>;

export type OptionsLegacyParser<
Data = unknown,
TData = unknown,
ThrowOnError extends boolean = boolean,
> = Data extends { body?: any }
? Data extends { headers?: any }
? OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'headers' | 'url'> & Data
> = TData extends { body?: any }
? TData extends { headers?: any }
? OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'headers' | 'url'> & TData
: OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'url'> &
Data &
TData &
Pick<RequestOptions<ThrowOnError>, 'headers'>
: Data extends { headers?: any }
: TData extends { headers?: any }
? OmitKeys<RequestOptions<ThrowOnError>, 'headers' | 'url'> &
Data &
TData &
Pick<RequestOptions<ThrowOnError>, 'body'>
: OmitKeys<RequestOptions<ThrowOnError>, 'url'> & Data;
: OmitKeys<RequestOptions<ThrowOnError>, 'url'> & TData;

0 comments on commit be2a6e1

Please sign in to comment.