···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+import type { Auth, AuthToken } from './auth';
22+import type {
33+ BodySerializer,
44+ QuerySerializer,
55+ QuerySerializerOptions,
66+} from './bodySerializer';
77+88+export interface Client<
99+ RequestFn = never,
1010+ Config = unknown,
1111+ MethodFn = never,
1212+ BuildUrlFn = never,
1313+> {
1414+ /**
1515+ * Returns the final request URL.
1616+ */
1717+ buildUrl: BuildUrlFn;
1818+ connect: MethodFn;
1919+ delete: MethodFn;
2020+ get: MethodFn;
2121+ getConfig: () => Config;
2222+ head: MethodFn;
2323+ options: MethodFn;
2424+ patch: MethodFn;
2525+ post: MethodFn;
2626+ put: MethodFn;
2727+ request: RequestFn;
2828+ setConfig: (config: Config) => Config;
2929+ trace: MethodFn;
3030+}
3131+3232+export interface Config {
3333+ /**
3434+ * Auth token or a function returning auth token. The resolved value will be
3535+ * added to the request payload as defined by its `security` array.
3636+ */
3737+ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
3838+ /**
3939+ * A function for serializing request body parameter. By default,
4040+ * {@link JSON.stringify()} will be used.
4141+ */
4242+ bodySerializer?: BodySerializer | null;
4343+ /**
4444+ * An object containing any HTTP headers that you want to pre-populate your
4545+ * `Headers` object with.
4646+ *
4747+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
4848+ */
4949+ headers?:
5050+ | RequestInit['headers']
5151+ | Record<
5252+ string,
5353+ | string
5454+ | number
5555+ | boolean
5656+ | (string | number | boolean)[]
5757+ | null
5858+ | undefined
5959+ | unknown
6060+ >;
6161+ /**
6262+ * The request method.
6363+ *
6464+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
6565+ */
6666+ method?:
6767+ | 'CONNECT'
6868+ | 'DELETE'
6969+ | 'GET'
7070+ | 'HEAD'
7171+ | 'OPTIONS'
7272+ | 'PATCH'
7373+ | 'POST'
7474+ | 'PUT'
7575+ | 'TRACE';
7676+ /**
7777+ * A function for serializing request query parameters. By default, arrays
7878+ * will be exploded in form style, objects will be exploded in deepObject
7979+ * style, and reserved characters are percent-encoded.
8080+ *
8181+ * This method will have no effect if the native `paramsSerializer()` Axios
8282+ * API function is used.
8383+ *
8484+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
8585+ */
8686+ querySerializer?: QuerySerializer | QuerySerializerOptions;
8787+ /**
8888+ * A function transforming response data before it's returned. This is useful
8989+ * for post-processing data, e.g. converting ISO strings into Date objects.
9090+ */
9191+ responseTransformer?: (data: unknown) => Promise<unknown>;
9292+ /**
9393+ * A function validating response data. This is useful if you want to ensure
9494+ * the response conforms to the desired shape, so it can be safely passed to
9595+ * the transformers and returned to the user.
9696+ */
9797+ responseValidator?: (data: unknown) => Promise<unknown>;
9898+}
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { Options as ClientOptions, TDataShape, Client } from './client';
44+import type { GetFooData, GetFooResponses } from './types.gen';
55+import { client as _heyApiClient } from './client.gen';
66+77+export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
88+ /**
99+ * You can provide a client instance returned by `createClient()` instead of
1010+ * individual options. This might be also useful if you want to implement a
1111+ * custom client.
1212+ */
1313+ client?: Client;
1414+ /**
1515+ * You can pass arbitrary values through the `meta` object. This can be
1616+ * used to access values that aren't defined as part of the SDK function.
1717+ */
1818+ meta?: Record<string, unknown>;
1919+};
2020+2121+export const getFoo = <ThrowOnError extends boolean = false>(options?: Options<GetFooData, ThrowOnError>) => {
2222+ return (options?.client ?? _heyApiClient).get<GetFooResponses, unknown, ThrowOnError>({
2323+ responseType: 'json',
2424+ url: '/foo',
2525+ ...options
2626+ });
2727+};
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { ClientOptions } from './types.gen';
44+import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client';
55+66+/**
77+ * The `createClientConfig()` function will be called on client initialization
88+ * and the returned object will become the client's initial configuration.
99+ *
1010+ * You may want to initialize your client this way instead of calling
1111+ * `setConfig()`. This is useful for example if you're using Next.js
1212+ * to ensure your client always has the correct values.
1313+ */
1414+export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
1515+1616+export const client = createClient(createConfig<ClientOptions>());
···11+import type { Auth, AuthToken } from './auth';
22+import type {
33+ BodySerializer,
44+ QuerySerializer,
55+ QuerySerializerOptions,
66+} from './bodySerializer';
77+88+export interface Client<
99+ RequestFn = never,
1010+ Config = unknown,
1111+ MethodFn = never,
1212+ BuildUrlFn = never,
1313+> {
1414+ /**
1515+ * Returns the final request URL.
1616+ */
1717+ buildUrl: BuildUrlFn;
1818+ connect: MethodFn;
1919+ delete: MethodFn;
2020+ get: MethodFn;
2121+ getConfig: () => Config;
2222+ head: MethodFn;
2323+ options: MethodFn;
2424+ patch: MethodFn;
2525+ post: MethodFn;
2626+ put: MethodFn;
2727+ request: RequestFn;
2828+ setConfig: (config: Config) => Config;
2929+ trace: MethodFn;
3030+}
3131+3232+export interface Config {
3333+ /**
3434+ * Auth token or a function returning auth token. The resolved value will be
3535+ * added to the request payload as defined by its `security` array.
3636+ */
3737+ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
3838+ /**
3939+ * A function for serializing request body parameter. By default,
4040+ * {@link JSON.stringify()} will be used.
4141+ */
4242+ bodySerializer?: BodySerializer | null;
4343+ /**
4444+ * An object containing any HTTP headers that you want to pre-populate your
4545+ * `Headers` object with.
4646+ *
4747+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
4848+ */
4949+ headers?:
5050+ | RequestInit['headers']
5151+ | Record<
5252+ string,
5353+ | string
5454+ | number
5555+ | boolean
5656+ | (string | number | boolean)[]
5757+ | null
5858+ | undefined
5959+ | unknown
6060+ >;
6161+ /**
6262+ * The request method.
6363+ *
6464+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
6565+ */
6666+ method?:
6767+ | 'CONNECT'
6868+ | 'DELETE'
6969+ | 'GET'
7070+ | 'HEAD'
7171+ | 'OPTIONS'
7272+ | 'PATCH'
7373+ | 'POST'
7474+ | 'PUT'
7575+ | 'TRACE';
7676+ /**
7777+ * A function for serializing request query parameters. By default, arrays
7878+ * will be exploded in form style, objects will be exploded in deepObject
7979+ * style, and reserved characters are percent-encoded.
8080+ *
8181+ * This method will have no effect if the native `paramsSerializer()` Axios
8282+ * API function is used.
8383+ *
8484+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
8585+ */
8686+ querySerializer?: QuerySerializer | QuerySerializerOptions;
8787+ /**
8888+ * A function transforming response data before it's returned. This is useful
8989+ * for post-processing data, e.g. converting ISO strings into Date objects.
9090+ */
9191+ responseTransformer?: (data: unknown) => Promise<unknown>;
9292+ /**
9393+ * A function validating response data. This is useful if you want to ensure
9494+ * the response conforms to the desired shape, so it can be safely passed to
9595+ * the transformers and returned to the user.
9696+ */
9797+ responseValidator?: (data: unknown) => Promise<unknown>;
9898+}
···11+// This file is auto-generated by @hey-api/openapi-ts
22+33+import type { Options as ClientOptions, TDataShape, Client } from './client';
44+import type { GetFooData, GetFooResponses } from './types.gen';
55+import { client as _heyApiClient } from './client.gen';
66+77+export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
88+ /**
99+ * You can provide a client instance returned by `createClient()` instead of
1010+ * individual options. This might be also useful if you want to implement a
1111+ * custom client.
1212+ */
1313+ client?: Client;
1414+ /**
1515+ * You can pass arbitrary values through the `meta` object. This can be
1616+ * used to access values that aren't defined as part of the SDK function.
1717+ */
1818+ meta?: Record<string, unknown>;
1919+};
2020+2121+export const getFoo = <ThrowOnError extends boolean = false>(options?: Options<GetFooData, ThrowOnError>) => {
2222+ return (options?.client ?? _heyApiClient).get<GetFooResponses, unknown, ThrowOnError>({
2323+ responseType: 'json',
2424+ url: '/foo',
2525+ ...options
2626+ });
2727+};