@zayne-labs/callapi-plugins 4.0.28 → 4.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1854 @@
1
+ import { AnyFunction } from "@zayne-labs/toolkit-type-helpers";
2
+
3
+ //#region ../callapi/dist/validation-Do6HBp6Z.d.ts
4
+ //#region src/constants/common.d.ts
5
+ declare const fetchSpecificKeys: readonly (keyof RequestInit | "duplex")[];
6
+ //#endregion
7
+ //#region src/constants/validation.d.ts
8
+ declare const fallBackRouteSchemaKey = "@default";
9
+ type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
10
+ //#endregion
11
+ //#endregion
12
+ //#region ../callapi/dist/index-CrJL7qOL.d.ts
13
+ //#region src/types/type-helpers.d.ts
14
+ type AnyString = string & NonNullable<unknown>;
15
+ type AnyNumber = number & NonNullable<unknown>;
16
+ type AnyFunction$1<TResult$1 = unknown> = (...args: any[]) => TResult$1;
17
+ type Prettify<TObject> = NonNullable<unknown> & { [Key in keyof TObject]: TObject[Key] };
18
+ type WriteableLevel = "deep" | "shallow";
19
+ /**
20
+ * Makes all properties in an object type writeable (removes readonly modifiers).
21
+ * Supports both shallow and deep modes, and handles special cases like arrays, tuples, and unions.
22
+ * @template TObject - The object type to make writeable
23
+ * @template TVariant - The level of writeable transformation ("shallow" | "deep")
24
+ */
25
+ type ArrayOrObject = Record<number | string | symbol, unknown> | unknown[] | readonly unknown[];
26
+ type Writeable<TObject, TLevel extends WriteableLevel = "shallow"> = TObject extends ArrayOrObject ? { -readonly [Key in keyof TObject]: TLevel extends "deep" ? NonNullable<TObject[Key]> extends ArrayOrObject ? Writeable<TObject[Key], "deep"> : TObject[Key] : TObject[Key] } : TObject;
27
+ type UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : never) extends ((param: infer TParam) => void) ? TParam : never;
28
+ type UnmaskType<TValue> = {
29
+ _: TValue;
30
+ }["_"];
31
+ type RemovePrefix<TPrefix extends "dedupe" | "retry", TKey extends string> = TKey extends `${TPrefix}${infer TRest}` ? Uncapitalize<TRest> : TKey;
32
+ type Awaitable<TValue> = Promise<TValue> | TValue;
33
+ type DistributiveOmit<TObject, TKeysToOmit extends keyof TObject> = TObject extends unknown ? Omit<TObject, TKeysToOmit> : never;
34
+ type CommonRequestHeaders = "Access-Control-Allow-Credentials" | "Access-Control-Allow-Headers" | "Access-Control-Allow-Methods" | "Access-Control-Allow-Origin" | "Access-Control-Expose-Headers" | "Access-Control-Max-Age" | "Age" | "Allow" | "Cache-Control" | "Clear-Site-Data" | "Content-Disposition" | "Content-Encoding" | "Content-Language" | "Content-Length" | "Content-Location" | "Content-Range" | "Content-Security-Policy-Report-Only" | "Content-Security-Policy" | "Cookie" | "Cross-Origin-Embedder-Policy" | "Cross-Origin-Opener-Policy" | "Cross-Origin-Resource-Policy" | "Date" | "ETag" | "Expires" | "Last-Modified" | "Location" | "Permissions-Policy" | "Pragma" | "Retry-After" | "Save-Data" | "Sec-CH-Prefers-Color-Scheme" | "Sec-CH-Prefers-Reduced-Motion" | "Sec-CH-UA-Arch" | "Sec-CH-UA-Bitness" | "Sec-CH-UA-Form-Factor" | "Sec-CH-UA-Full-Version-List" | "Sec-CH-UA-Full-Version" | "Sec-CH-UA-Mobile" | "Sec-CH-UA-Model" | "Sec-CH-UA-Platform-Version" | "Sec-CH-UA-Platform" | "Sec-CH-UA-WoW64" | "Sec-CH-UA" | "Sec-Fetch-Dest" | "Sec-Fetch-Mode" | "Sec-Fetch-Site" | "Sec-Fetch-User" | "Sec-GPC" | "Server-Timing" | "Server" | "Service-Worker-Navigation-Preload" | "Set-Cookie" | "Strict-Transport-Security" | "Timing-Allow-Origin" | "Trailer" | "Transfer-Encoding" | "Upgrade" | "Vary" | "Warning" | "WWW-Authenticate" | "X-Content-Type-Options" | "X-DNS-Prefetch-Control" | "X-Frame-Options" | "X-Permitted-Cross-Domain-Policies" | "X-Powered-By" | "X-Robots-Tag" | "X-XSS-Protection" | AnyString;
35
+ type CommonAuthorizationHeaders = `${"Basic" | "Bearer" | "Token"} ${string}`;
36
+ type CommonContentTypes = "application/epub+zip" | "application/gzip" | "application/json" | "application/ld+json" | "application/octet-stream" | "application/ogg" | "application/pdf" | "application/rtf" | "application/vnd.ms-fontobject" | "application/wasm" | "application/xhtml+xml" | "application/xml" | "application/zip" | "audio/aac" | "audio/mpeg" | "audio/ogg" | "audio/opus" | "audio/webm" | "audio/x-midi" | "font/otf" | "font/ttf" | "font/woff" | "font/woff2" | "image/avif" | "image/bmp" | "image/gif" | "image/jpeg" | "image/png" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/x-icon" | "model/gltf-binary" | "model/gltf+json" | "text/calendar" | "text/css" | "text/csv" | "text/html" | "text/javascript" | "text/plain" | "video/3gpp" | "video/3gpp2" | "video/av1" | "video/mp2t" | "video/mp4" | "video/mpeg" | "video/ogg" | "video/webm" | "video/x-msvideo" | AnyString;
37
+ //#endregion
38
+ //#region src/auth.d.ts
39
+ type PossibleAuthValue = Awaitable<string | null | undefined>;
40
+ type PossibleAuthValueOrGetter = PossibleAuthValue | (() => PossibleAuthValue);
41
+ type BearerOrTokenAuth = {
42
+ type?: "Bearer";
43
+ bearer?: PossibleAuthValueOrGetter;
44
+ token?: never;
45
+ } | {
46
+ type?: "Token";
47
+ bearer?: never;
48
+ token?: PossibleAuthValueOrGetter;
49
+ };
50
+ type BasicAuth = {
51
+ type: "Basic";
52
+ username: PossibleAuthValueOrGetter;
53
+ password: PossibleAuthValueOrGetter;
54
+ };
55
+ /**
56
+ * Custom auth
57
+ *
58
+ * @param prefix - prefix of the header
59
+ * @param authValue - value of the header
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * {
64
+ * type: "Custom",
65
+ * prefix: "Token",
66
+ * authValue: "token"
67
+ * }
68
+ * ```
69
+ */
70
+ type CustomAuth = {
71
+ type: "Custom";
72
+ prefix: PossibleAuthValueOrGetter;
73
+ value: PossibleAuthValueOrGetter;
74
+ };
75
+ type Auth = PossibleAuthValueOrGetter | BearerOrTokenAuth | BasicAuth | CustomAuth;
76
+ //#endregion
77
+ //#region src/stream.d.ts
78
+ type StreamProgressEvent = {
79
+ /**
80
+ * Current chunk of data being streamed
81
+ */
82
+ chunk: Uint8Array;
83
+ /**
84
+ * Progress in percentage
85
+ */
86
+ progress: number;
87
+ /**
88
+ * Total size of data in bytes
89
+ */
90
+ totalBytes: number;
91
+ /**
92
+ * Amount of data transferred so far
93
+ */
94
+ transferredBytes: number;
95
+ };
96
+ declare global {
97
+ interface ReadableStream<R$1 = any> {
98
+ [Symbol.asyncIterator]: () => AsyncIterableIterator<R$1>;
99
+ }
100
+ }
101
+ //#endregion
102
+ //#region src/middlewares.d.ts
103
+ type FetchImpl = UnmaskType<(input: string | Request | URL, init?: RequestInit) => Promise<Response>>;
104
+ interface Middlewares<TCallApiContext extends CallApiContext = DefaultCallApiContext> {
105
+ /**
106
+ * Wraps the fetch implementation to intercept requests at the network layer.
107
+ *
108
+ * Takes a context object containing the current fetch function and returns a new fetch function.
109
+ * Use it to cache responses, add logging, handle offline mode, or short-circuit requests etc.
110
+ * Multiple middleware compose in order: plugins → base config → per-request.
111
+ *
112
+ * Unlike `customFetchImpl`, middleware can call through to the original fetch.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * // Cache responses
117
+ * const cache = new Map();
118
+ *
119
+ * fetchMiddleware: (ctx) => async (input, init) => {
120
+ * const key = input.toString();
121
+ * if (cache.has(key)) return cache.get(key).clone();
122
+ *
123
+ * const response = await ctx.fetchImpl(input, init);
124
+ * cache.set(key, response.clone());
125
+ * return response;
126
+ * }
127
+ *
128
+ * // Handle offline
129
+ * fetchMiddleware: (ctx) => async (input, init) => {
130
+ * if (!navigator.onLine) {
131
+ * return new Response('{"error": "offline"}', { status: 503 });
132
+ * }
133
+ * return ctx.fetchImpl(input, init);
134
+ * }
135
+ * ```
136
+ */
137
+ fetchMiddleware?: (context: RequestContext<TCallApiContext> & {
138
+ fetchImpl: FetchImpl;
139
+ }) => FetchImpl;
140
+ }
141
+ //#endregion
142
+ //#region src/types/conditional-types.d.ts
143
+ /**
144
+ * @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
145
+ */
146
+ type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaOutput<TSchemaOption, undefined> ? TObject : Required<TObject>;
147
+ type ApplyURLBasedConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["prefix"] extends string ? `${TSchemaConfig["prefix"]}${TSchemaRouteKeys}` : TSchemaConfig["baseURL"] extends string ? `${TSchemaConfig["baseURL"]}${TSchemaRouteKeys}` : TSchemaRouteKeys;
148
+ type ApplyStrictConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["strict"] extends true ? TSchemaRouteKeys :
149
+ // eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
150
+ TSchemaRouteKeys | Exclude<InitURLOrURLObject, RouteKeyMethodsURLUnion>;
151
+ type ApplySchemaConfiguration<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, TSchemaRouteKeys>>;
152
+ type InferAllRouteKeys<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = ApplySchemaConfiguration<TSchemaConfig, Exclude<Extract<keyof TBaseSchemaRoutes, string>, FallBackRouteSchemaKey>>;
153
+ type InferInitURL<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes extends never ? InitURLOrURLObject : InferAllRouteKeys<TBaseSchemaRoutes, TSchemaConfig>;
154
+ type GetCurrentRouteSchema<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TComputedFallBackRouteSchema = TBaseSchemaRoutes[FallBackRouteSchemaKey], TComputedCurrentRouteSchema = TBaseSchemaRoutes[TCurrentRouteSchemaKey], TComputedRouteSchema extends CallApiSchema = NonNullable<Omit<TComputedFallBackRouteSchema, keyof TComputedCurrentRouteSchema> & TComputedCurrentRouteSchema>> = TComputedRouteSchema extends CallApiSchema ? Writeable<TComputedRouteSchema, "deep"> : CallApiSchema;
155
+ type JsonPrimitive = boolean | number | string | null | undefined;
156
+ type SerializableObject = Record<PropertyKey, unknown>;
157
+ type SerializableArray = Array<JsonPrimitive | SerializableObject> | ReadonlyArray<JsonPrimitive | SerializableObject>;
158
+ type Body = UnmaskType<Exclude<RequestInit["body"], undefined> | SerializableArray | SerializableObject>;
159
+ type InferBodyOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["body"], {
160
+ /**
161
+ * Body of the request, can be a object or any other supported body type.
162
+ */
163
+ body?: InferSchemaOutput<TSchema["body"], Body>;
164
+ }>;
165
+ type MethodUnion = UnmaskType<"CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" | AnyString>;
166
+ type InferMethodFromURL<TInitURL> = string extends TInitURL ? MethodUnion : TInitURL extends `@${infer TMethod extends RouteKeyMethods}/${string}` ? Uppercase<TMethod> : MethodUnion;
167
+ type InferMethodOption<TSchema extends CallApiSchema, TInitURL> = MakeSchemaOptionRequiredIfDefined<TSchema["method"], {
168
+ /**
169
+ * HTTP method for the request.
170
+ * @default "GET"
171
+ */
172
+ method?: InferSchemaOutput<TSchema["method"], InferMethodFromURL<TInitURL>>;
173
+ }>;
174
+ type HeadersOption = UnmaskType<Record<"Authorization", CommonAuthorizationHeaders | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | Array<[string, string]>>;
175
+ type InferHeadersOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["headers"], {
176
+ /**
177
+ * Headers to be used in the request.
178
+ */
179
+ headers?: InferSchemaOutput<TSchema["headers"], HeadersOption> | ((context: {
180
+ baseHeaders: NonNullable<HeadersOption>;
181
+ }) => InferSchemaOutput<TSchema["headers"], HeadersOption>);
182
+ }>;
183
+ type InferRequestOptions<TSchema extends CallApiSchema, TInitURL extends InferInitURL<BaseCallApiSchemaRoutes, CallApiSchemaConfig>> = InferBodyOption<TSchema> & InferHeadersOption<TSchema> & InferMethodOption<TSchema, TInitURL>;
184
+ type InferMetaOption<TSchema extends CallApiSchema, TCallApiContext extends CallApiContext> = MakeSchemaOptionRequiredIfDefined<TSchema["meta"], {
185
+ /**
186
+ * - An optional field you can fill with additional information,
187
+ * to associate with the request, typically used for logging or tracing.
188
+ *
189
+ * - A good use case for this, would be to use the info to handle specific cases in any of the shared interceptors.
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * const callMainApi = callApi.create({
194
+ * baseURL: "https://main-api.com",
195
+ * onResponseError: ({ response, options }) => {
196
+ * if (options.meta?.userId) {
197
+ * console.error(`User ${options.meta.userId} made an error`);
198
+ * }
199
+ * },
200
+ * });
201
+ *
202
+ * const response = await callMainApi({
203
+ * url: "https://example.com/api/data",
204
+ * meta: { userId: "123" },
205
+ * });
206
+ * ```
207
+ */
208
+ meta?: InferSchemaOutput<TSchema["meta"], TCallApiContext["Meta"]>;
209
+ }>;
210
+ type InferQueryOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["query"], {
211
+ /**
212
+ * Parameters to be appended to the URL (i.e: /:id)
213
+ */
214
+ query?: InferSchemaOutput<TSchema["query"], Query>;
215
+ }>;
216
+ type EmptyString = "";
217
+ type EmptyTuple = readonly [];
218
+ type StringTuple = readonly string[];
219
+ type PossibleParamNamePatterns = `${string}:${string}` | `${string}{${string}}${"" | AnyString}`;
220
+ type ExtractRouteParamNames<TCurrentRoute$1, TParamNamesAccumulator extends StringTuple = EmptyTuple> = TCurrentRoute$1 extends PossibleParamNamePatterns ? TCurrentRoute$1 extends `${infer TRoutePrefix}:${infer TParamAndRemainingRoute}` ? TParamAndRemainingRoute extends `${infer TCurrentParam}/${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}/${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}/${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamAndRemainingRoute extends `${infer TCurrentParam}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<TRoutePrefix, TParamNamesAccumulator> : ExtractRouteParamNames<TRoutePrefix, [...TParamNamesAccumulator, TCurrentParam]> : ExtractRouteParamNames<TRoutePrefix, TParamNamesAccumulator> : TCurrentRoute$1 extends `${infer TRoutePrefix}{${infer TCurrentParam}}${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamNamesAccumulator : TParamNamesAccumulator;
221
+ type ConvertParamNamesToRecord<TParamNames extends StringTuple> = Prettify<TParamNames extends (readonly [infer TFirstParamName extends string, ...infer TRemainingParamNames extends StringTuple]) ? Record<TFirstParamName, AllowedQueryParamValues> & ConvertParamNamesToRecord<TRemainingParamNames> : NonNullable<unknown>>;
222
+ type ConvertParamNamesToTuple<TParamNames extends StringTuple> = TParamNames extends readonly [string, ...infer TRemainingParamNames extends StringTuple] ? [AllowedQueryParamValues, ...ConvertParamNamesToTuple<TRemainingParamNames>] : [];
223
+ type InferParamsFromRoute<TCurrentRoute$1> = ExtractRouteParamNames<TCurrentRoute$1> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute$1> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute$1>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute$1>> : Params;
224
+ type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes, TCurrentRouteSchemaKey> ? undefined extends InferSchemaOutput<TParamsSchemaOption, null> ? TObject : Required<TObject> : TObject>;
225
+ type InferParamsOption<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema["params"], TBaseSchemaRoutes, TCurrentRouteSchemaKey, {
226
+ /**
227
+ * Parameters to be appended to the URL (i.e: /:id)
228
+ */
229
+ params?: InferSchemaOutput<TSchema["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
230
+ }>;
231
+ type InferExtraOptions<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TCallApiContext extends CallApiContext> = InferMetaOption<TSchema, TCallApiContext> & InferParamsOption<TSchema, TBaseSchemaRoutes, TCurrentRouteSchemaKey> & InferQueryOption<TSchema>;
232
+ type InferPluginExtraOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction$1<infer TReturnedSchema> ? InferSchemaOutput<TReturnedSchema> : never : never : never>;
233
+ type ResultModeOption<TErrorData, TResultMode extends ResultModeType> = TErrorData extends false ? {
234
+ resultMode: "onlyData";
235
+ } : TErrorData extends false | undefined ? {
236
+ resultMode?: "onlyData";
237
+ } : {
238
+ resultMode?: TResultMode;
239
+ };
240
+ type ThrowOnErrorUnion = boolean;
241
+ type ThrowOnErrorType<TErrorData, TThrowOnError extends ThrowOnErrorUnion> = TThrowOnError | ((context: ErrorContext<{
242
+ ErrorData: TErrorData;
243
+ }>) => TThrowOnError);
244
+ type ThrowOnErrorOption<TErrorData, TThrowOnError extends ThrowOnErrorUnion> = TErrorData extends false ? {
245
+ throwOnError: true;
246
+ } : TErrorData extends false | undefined ? {
247
+ throwOnError?: true;
248
+ } : {
249
+ throwOnError?: ThrowOnErrorType<TErrorData, TThrowOnError>;
250
+ };
251
+ //#endregion
252
+ //#region src/types/standard-schema.d.ts
253
+ /**
254
+ * The Standard Schema interface.
255
+ * @see https://github.com/standard-schema/standard-schema
256
+ */
257
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
258
+ /**
259
+ * The Standard Schema properties.
260
+ */
261
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
262
+ }
263
+ declare namespace StandardSchemaV1 {
264
+ /**
265
+ * The Standard Schema properties interface.
266
+ */
267
+ interface Props<Input = unknown, Output = Input> {
268
+ /**
269
+ * Inferred types associated with the schema.
270
+ */
271
+ readonly types?: Types<Input, Output> | undefined;
272
+ /**
273
+ * Validates unknown input values.
274
+ */
275
+ readonly validate: (value: unknown) => Promise<Result<Output>> | Result<Output>;
276
+ /**
277
+ * The vendor name of the schema library.
278
+ */
279
+ readonly vendor: string;
280
+ /**
281
+ * The version number of the standard.
282
+ */
283
+ readonly version: 1;
284
+ }
285
+ /**
286
+ * The result interface of the validate function.
287
+ */
288
+ type Result<Output> = FailureResult | SuccessResult<Output>;
289
+ /**
290
+ * The result interface if validation succeeds.
291
+ */
292
+ interface SuccessResult<Output> {
293
+ /**
294
+ * The non-existent issues.
295
+ */
296
+ readonly issues?: undefined;
297
+ /**
298
+ * The typed output value.
299
+ */
300
+ readonly value: Output;
301
+ }
302
+ /**
303
+ * The result interface if validation fails.
304
+ */
305
+ interface FailureResult {
306
+ /**
307
+ * The issues of failed validation.
308
+ */
309
+ readonly issues: readonly Issue[];
310
+ }
311
+ /**
312
+ * The issue interface of the failure output.
313
+ */
314
+ interface Issue {
315
+ /**
316
+ * The error message of the issue.
317
+ */
318
+ readonly message: string;
319
+ /**
320
+ * The path of the issue, if any.
321
+ */
322
+ readonly path?: ReadonlyArray<PathSegment | PropertyKey> | undefined;
323
+ }
324
+ /**
325
+ * The path segment interface of the issue.
326
+ */
327
+ interface PathSegment {
328
+ /**
329
+ * The key representing a path segment.
330
+ */
331
+ readonly key: PropertyKey;
332
+ }
333
+ /**
334
+ * The Standard Schema types interface.
335
+ */
336
+ interface Types<Input = unknown, Output = Input> {
337
+ /** The input type of the schema. */
338
+ readonly input: Input;
339
+ /** The output type of the schema. */
340
+ readonly output: Output;
341
+ }
342
+ /**
343
+ * Infers the input type of a Standard Schema.
344
+ */
345
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
346
+ /**
347
+ * Infers the output type of a Standard Schema.
348
+ */
349
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
350
+ }
351
+ //#endregion
352
+ //#region src/validation.d.ts
353
+ type ResultVariant = "infer-input" | "infer-output";
354
+ type InferSchemaResult<TSchema, TFallbackResult, TResultVariant extends ResultVariant> = undefined extends TSchema ? TFallbackResult : TSchema extends StandardSchemaV1 ? TResultVariant extends "infer-input" ? StandardSchemaV1.InferInput<TSchema> : StandardSchemaV1.InferOutput<TSchema> : TSchema extends AnyFunction$1<infer TResult> ? Awaited<TResult> : TFallbackResult;
355
+ type InferSchemaOutput<TSchema, TFallbackResult = unknown> = InferSchemaResult<TSchema, TFallbackResult, "infer-output">;
356
+ interface CallApiSchemaConfig {
357
+ /**
358
+ * The base url of the schema. By default it's the baseURL of the callApi instance.
359
+ */
360
+ baseURL?: string;
361
+ /**
362
+ * Disables runtime validation for the schema.
363
+ */
364
+ disableRuntimeValidation?: boolean;
365
+ /**
366
+ * If `true`, the original input value will be used instead of the transformed/validated output.
367
+ *
368
+ * This is useful when you want to validate the input but don't want any transformations
369
+ * applied by the validation schema (e.g., type coercion, default values, etc).
370
+ */
371
+ disableValidationOutputApplication?: boolean;
372
+ /**
373
+ * Optional url prefix that will be substituted for the `baseURL` of the schemaConfig at runtime.
374
+ *
375
+ * This allows you to reuse the same schema against different base URLs (for example,
376
+ * swapping between `/api/v1` and `/api/v2`) without redefining the entire schema.
377
+ */
378
+ prefix?: string;
379
+ /**
380
+ * Controls the strictness of API route validation.
381
+ *
382
+ * When true:
383
+ * - Only routes explicitly defined in the schema will be considered valid to typescript and the runtime.
384
+ * - Attempting to call routes not defined in the schema will result in both type errors and runtime validation errors.
385
+ * - Useful for ensuring API calls conform exactly to your schema definition
386
+ *
387
+ * When false or undefined (default):
388
+ * - All routes will be allowed, whether they are defined in the schema or not
389
+ */
390
+ strict?: boolean;
391
+ }
392
+ interface CallApiSchema {
393
+ /**
394
+ * The schema to use for validating the request body.
395
+ */
396
+ body?: StandardSchemaV1<Body | undefined> | ((body: Body) => Awaitable<Body | undefined>);
397
+ /**
398
+ * The schema to use for validating the response data.
399
+ */
400
+ data?: StandardSchemaV1 | ((data: unknown) => unknown);
401
+ /**
402
+ * The schema to use for validating the response error data.
403
+ */
404
+ errorData?: StandardSchemaV1 | ((errorData: unknown) => unknown);
405
+ /**
406
+ * The schema to use for validating the request headers.
407
+ */
408
+ headers?: StandardSchemaV1<HeadersOption | undefined> | ((headers: HeadersOption) => Awaitable<HeadersOption | undefined>);
409
+ /**
410
+ * The schema to use for validating the meta option.
411
+ */
412
+ meta?: StandardSchemaV1<GlobalMeta | undefined> | ((meta: GlobalMeta) => Awaitable<GlobalMeta | undefined>);
413
+ /**
414
+ * The schema to use for validating the request method.
415
+ */
416
+ method?: StandardSchemaV1<MethodUnion | undefined> | ((method: MethodUnion) => Awaitable<MethodUnion | undefined>);
417
+ /**
418
+ * The schema to use for validating the request url parameters.
419
+ */
420
+ params?: StandardSchemaV1<Params | undefined> | ((params: Params) => Awaitable<Params | undefined>);
421
+ /**
422
+ * The schema to use for validating the request url queries.
423
+ */
424
+ query?: StandardSchemaV1<Query | undefined> | ((query: Query) => Awaitable<Query | undefined>);
425
+ }
426
+ declare const routeKeyMethods: readonly ["delete", "get", "patch", "post", "put"];
427
+ type RouteKeyMethods = (typeof routeKeyMethods)[number];
428
+ type RouteKeyMethodsURLUnion = `@${RouteKeyMethods}/`;
429
+ type BaseSchemaRouteKeyPrefixes = FallBackRouteSchemaKey | RouteKeyMethodsURLUnion;
430
+ type BaseCallApiSchemaRoutes = Partial<Record<AnyString | BaseSchemaRouteKeyPrefixes, CallApiSchema>>;
431
+ type BaseCallApiSchemaAndConfig = {
432
+ config?: CallApiSchemaConfig;
433
+ routes: BaseCallApiSchemaRoutes;
434
+ };
435
+ //#endregion
436
+ //#region src/url.d.ts
437
+ type AllowedQueryParamValues = UnmaskType<boolean | number | string>;
438
+ type RecordStyleParams = UnmaskType<Record<string, AllowedQueryParamValues>>;
439
+ type TupleStyleParams = UnmaskType<AllowedQueryParamValues[]>;
440
+ type Params = UnmaskType<RecordStyleParams | TupleStyleParams>;
441
+ type Query = UnmaskType<Record<string, AllowedQueryParamValues>>;
442
+ type InitURLOrURLObject = AnyString | RouteKeyMethodsURLUnion | URL;
443
+ interface URLOptions {
444
+ /**
445
+ * Base URL for all API requests. Will only be prepended to relative URLs.
446
+ *
447
+ * Absolute URLs (starting with http/https) will not be prepended by the baseURL.
448
+ *
449
+ * @example
450
+ * ```ts
451
+ * // Set base URL for all requests
452
+ * baseURL: "https://api.example.com/v1"
453
+ *
454
+ * // Then use relative URLs in requests
455
+ * callApi("/users") // → https://api.example.com/v1/users
456
+ * callApi("/posts/123") // → https://api.example.com/v1/posts/123
457
+ *
458
+ * // Environment-specific base URLs
459
+ * baseURL: process.env.NODE_ENV === "production"
460
+ * ? "https://api.example.com"
461
+ * : "http://localhost:3000/api"
462
+ * ```
463
+ */
464
+ baseURL?: string;
465
+ /**
466
+ * Resolved request URL after processing baseURL, parameters, and query strings (readonly)
467
+ *
468
+ * This is the final URL that will be used for the HTTP request, computed from
469
+ * baseURL, initURL, params, and query parameters.
470
+ *
471
+ */
472
+ readonly fullURL?: string;
473
+ /**
474
+ * The original URL string passed to the callApi instance (readonly)
475
+ *
476
+ * This preserves the original URL as provided, including any method modifiers like "@get/" or "@post/".
477
+ *
478
+ */
479
+ readonly initURL?: string;
480
+ /**
481
+ * The URL string after normalization, with method modifiers removed(readonly)
482
+ *
483
+ * Method modifiers like "@get/", "@post/" are stripped to create a clean URL
484
+ * for parameter substitution and final URL construction.
485
+ *
486
+ */
487
+ readonly initURLNormalized?: string;
488
+ /**
489
+ * Parameters to be substituted into URL path segments.
490
+ *
491
+ * Supports both object-style (named parameters) and array-style (positional parameters)
492
+ * for flexible URL parameter substitution.
493
+ *
494
+ * @example
495
+ * ```typescript
496
+ * // Object-style parameters (recommended)
497
+ * const namedParams: URLOptions = {
498
+ * initURL: "/users/:userId/posts/:postId",
499
+ * params: { userId: "123", postId: "456" }
500
+ * };
501
+ * // Results in: /users/123/posts/456
502
+ *
503
+ * // Array-style parameters (positional)
504
+ * const positionalParams: URLOptions = {
505
+ * initURL: "/users/:userId/posts/:postId",
506
+ * params: ["123", "456"] // Maps in order: userId=123, postId=456
507
+ * };
508
+ * // Results in: /users/123/posts/456
509
+ *
510
+ * // Single parameter
511
+ * const singleParam: URLOptions = {
512
+ * initURL: "/users/:id",
513
+ * params: { id: "user-123" }
514
+ * };
515
+ * // Results in: /users/user-123
516
+ * ```
517
+ */
518
+ params?: Params;
519
+ /**
520
+ * Query parameters to append to the URL as search parameters.
521
+ *
522
+ * These will be serialized into the URL query string using standard
523
+ * URL encoding practices.
524
+ *
525
+ * @example
526
+ * ```typescript
527
+ * // Basic query parameters
528
+ * const queryOptions: URLOptions = {
529
+ * initURL: "/users",
530
+ * query: {
531
+ * page: 1,
532
+ * limit: 10,
533
+ * search: "john doe",
534
+ * active: true
535
+ * }
536
+ * };
537
+ * // Results in: /users?page=1&limit=10&search=john%20doe&active=true
538
+ *
539
+ * // Filtering and sorting
540
+ * const filterOptions: URLOptions = {
541
+ * initURL: "/products",
542
+ * query: {
543
+ * category: "electronics",
544
+ * minPrice: 100,
545
+ * maxPrice: 500,
546
+ * sortBy: "price",
547
+ * order: "asc"
548
+ * }
549
+ * };
550
+ * // Results in: /products?category=electronics&minPrice=100&maxPrice=500&sortBy=price&order=asc
551
+ * ```
552
+ */
553
+ query?: Query;
554
+ }
555
+ //#endregion
556
+ //#region src/plugins.d.ts
557
+ type PluginSetupContext<TCallApiContext extends CallApiContext = DefaultCallApiContext> = RequestContext<TCallApiContext> & {
558
+ initURL: string;
559
+ };
560
+ type PluginInitResult<TCallApiContext extends CallApiContext = DefaultCallApiContext> = Partial<Omit<PluginSetupContext<TCallApiContext>, "initURL" | "request"> & {
561
+ initURL: InitURLOrURLObject;
562
+ request: CallApiRequestOptions;
563
+ }>;
564
+ type PluginHooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> = HooksOrHooksArray<OverrideCallApiContext<TCallApiContext, {
565
+ Data: DefaultDataType extends TCallApiContext["Data"] ? never : TCallApiContext["Data"];
566
+ ErrorData: DefaultDataType extends TCallApiContext["ErrorData"] ? never : TCallApiContext["ErrorData"];
567
+ }>>;
568
+ interface CallApiPlugin<TCallApiContext extends CallApiContext = DefaultCallApiContext> {
569
+ /**
570
+ * Defines additional options that can be passed to callApi
571
+ */
572
+ defineExtraOptions?: (...params: never[]) => unknown;
573
+ /**
574
+ * A description for the plugin
575
+ */
576
+ description?: string;
577
+ /**
578
+ * Hooks for the plugin
579
+ */
580
+ hooks?: PluginHooks<TCallApiContext> | ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginHooks<TCallApiContext>>);
581
+ /**
582
+ * A unique id for the plugin
583
+ */
584
+ id: string;
585
+ /**
586
+ * Middlewares that for the plugin
587
+ */
588
+ middlewares?: Middlewares<TCallApiContext> | ((context: PluginSetupContext<TCallApiContext>) => Awaitable<Middlewares<TCallApiContext>>);
589
+ /**
590
+ * A name for the plugin
591
+ */
592
+ name: string;
593
+ /**
594
+ * Base schema for the client.
595
+ */
596
+ schema?: BaseCallApiSchemaAndConfig;
597
+ /**
598
+ * A function that will be called when the plugin is initialized. This will be called before the any of the other internal functions.
599
+ */
600
+ setup?: (context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginInitResult<TCallApiContext>> | Awaitable<void>;
601
+ /**
602
+ * A version for the plugin
603
+ */
604
+ version?: string;
605
+ }
606
+ //#endregion
607
+ //#region src/types/default-types.d.ts
608
+ type DefaultDataType = unknown;
609
+ type DefaultPluginArray = CallApiPlugin[];
610
+ type DefaultThrowOnError = boolean;
611
+ type DefaultMetaObject = Record<string, unknown>;
612
+ type DefaultCallApiContext = Omit<Required<CallApiContext>, "Meta"> & {
613
+ Meta: GlobalMeta;
614
+ };
615
+ //#endregion
616
+ //#region src/hooks.d.ts
617
+ interface Hooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> {
618
+ /**
619
+ * Hook called when any error occurs within the request/response lifecycle.
620
+ *
621
+ * This is a unified error handler that catches both request errors (network failures,
622
+ * timeouts, etc.) and response errors (HTTP error status codes). It's essentially
623
+ * a combination of `onRequestError` and `onResponseError` hooks.
624
+ *
625
+ * @param context - Error context containing error details, request info, and response (if available)
626
+ * @returns Promise or void - Hook can be async or sync
627
+ */
628
+ onError?: (context: ErrorContext<TCallApiContext>) => Awaitable<unknown>;
629
+ /**
630
+ * Hook called before the HTTP request is sent and before any internal processing of the request object begins.
631
+ *
632
+ * This is the ideal place to modify request headers, add authentication,
633
+ * implement request logging, or perform any setup before the network call.
634
+ *
635
+ * @param context - Request context with mutable request object and configuration
636
+ * @returns Promise or void - Hook can be async or sync
637
+ *
638
+ */
639
+ onRequest?: (context: RequestContext<TCallApiContext>) => Awaitable<unknown>;
640
+ /**
641
+ * Hook called when an error occurs during the fetch request itself.
642
+ *
643
+ * This handles network-level errors like connection failures, timeouts,
644
+ * DNS resolution errors, or other issues that prevent getting an HTTP response.
645
+ * Note that HTTP error status codes (4xx, 5xx) are handled by `onResponseError`.
646
+ *
647
+ * @param context - Request error context with error details and null response
648
+ * @returns Promise or void - Hook can be async or sync
649
+ */
650
+ onRequestError?: (context: RequestErrorContext<TCallApiContext>) => Awaitable<unknown>;
651
+ /**
652
+ * Hook called just before the HTTP request is sent and after the request has been processed.
653
+ *
654
+ * @param context - Request context with mutable request object and configuration
655
+ */
656
+ onRequestReady?: (context: RequestContext<TCallApiContext>) => Awaitable<unknown>;
657
+ /**
658
+ * Hook called during upload stream progress tracking.
659
+ *
660
+ * This hook is triggered when uploading data (like file uploads) and provides
661
+ * progress information about the upload. Useful for implementing progress bars
662
+ * or upload status indicators.
663
+ *
664
+ * @param context - Request stream context with progress event and request instance
665
+ * @returns Promise or void - Hook can be async or sync
666
+ *
667
+ */
668
+ onRequestStream?: (context: RequestStreamContext<TCallApiContext>) => Awaitable<unknown>;
669
+ /**
670
+ * Hook called when any HTTP response is received from the API.
671
+ *
672
+ * This hook is triggered for both successful (2xx) and error (4xx, 5xx) responses.
673
+ * It's useful for response logging, metrics collection, or any processing that
674
+ * should happen regardless of response status.
675
+ *
676
+ * @param context - Response context with either success data or error information
677
+ * @returns Promise or void - Hook can be async or sync
678
+ *
679
+ */
680
+ onResponse?: (context: ResponseContext<TCallApiContext>) => Awaitable<unknown>;
681
+ /**
682
+ * Hook called when an HTTP error response (4xx, 5xx) is received from the API.
683
+ *
684
+ * This handles server-side errors where an HTTP response was successfully received
685
+ * but indicates an error condition. Different from `onRequestError` which handles
686
+ * network-level failures.
687
+ *
688
+ * @param context - Response error context with HTTP error details and response
689
+ * @returns Promise or void - Hook can be async or sync
690
+ */
691
+ onResponseError?: (context: ResponseErrorContext<TCallApiContext>) => Awaitable<unknown>;
692
+ /**
693
+ * Hook called during download stream progress tracking.
694
+ *
695
+ * This hook is triggered when downloading data (like file downloads) and provides
696
+ * progress information about the download. Useful for implementing progress bars
697
+ * or download status indicators.
698
+ *
699
+ * @param context - Response stream context with progress event and response
700
+ * @returns Promise or void - Hook can be async or sync
701
+ *
702
+ */
703
+ onResponseStream?: (context: ResponseStreamContext<TCallApiContext>) => Awaitable<unknown>;
704
+ /**
705
+ * Hook called when a request is being retried.
706
+ *
707
+ * This hook is triggered before each retry attempt, providing information about
708
+ * the previous failure and the current retry attempt number. Useful for implementing
709
+ * custom retry logic, exponential backoff, or retry logging.
710
+ *
711
+ * @param context - Retry context with error details and retry attempt count
712
+ * @returns Promise or void - Hook can be async or sync
713
+ *
714
+ */
715
+ onRetry?: (response: RetryContext<TCallApiContext>) => Awaitable<unknown>;
716
+ /**
717
+ * Hook called when a successful response (2xx status) is received from the API.
718
+ *
719
+ * This hook is triggered only for successful responses and provides access to
720
+ * the parsed response data. Ideal for success logging, caching, or post-processing
721
+ * of successful API responses.
722
+ *
723
+ * @param context - Success context with parsed response data and response object
724
+ * @returns Promise or void - Hook can be async or sync
725
+ *
726
+ */
727
+ onSuccess?: (context: SuccessContext<TCallApiContext>) => Awaitable<unknown>;
728
+ /**
729
+ * Hook called when a validation error occurs.
730
+ *
731
+ * This hook is triggered when request or response data fails validation against
732
+ * a defined schema. It provides access to the validation error details and can
733
+ * be used for custom error handling, logging, or fallback behavior.
734
+ *
735
+ * @param context - Validation error context with error details and response (if available)
736
+ * @returns Promise or void - Hook can be async or sync
737
+ *
738
+ */
739
+ onValidationError?: (context: ValidationErrorContext<TCallApiContext>) => Awaitable<unknown>;
740
+ }
741
+ type HooksOrHooksArray<TCallApiContext extends CallApiContext = DefaultCallApiContext> = { [Key in keyof Hooks<TCallApiContext>]: Hooks<TCallApiContext>[Key] | Array<Hooks<TCallApiContext>[Key]> };
742
+ interface HookConfigOptions {
743
+ /**
744
+ * Controls the execution mode of all composed hooks (main + plugin hooks).
745
+ *
746
+ * - **"parallel"**: All hooks execute simultaneously via Promise.all() for better performance
747
+ * - **"sequential"**: All hooks execute one by one in registration order via await in a loop
748
+ *
749
+ * This affects how ALL hooks execute together, regardless of their source (main or plugin).
750
+ *
751
+ * @default "parallel"
752
+ */
753
+ hooksExecutionMode?: "parallel" | "sequential";
754
+ }
755
+ type RequestContext<TCallApiContext extends Pick<CallApiContext, "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = {
756
+ /**
757
+ * Base configuration object passed to createFetchClient.
758
+ *
759
+ * Contains the foundational configuration that applies to all requests
760
+ * made by this client instance, such as baseURL, default headers, and
761
+ * global options.
762
+ */
763
+ baseConfig: Exclude<BaseCallApiConfig, AnyFunction$1>;
764
+ /**
765
+ * Instance-specific configuration object passed to the callApi instance.
766
+ *
767
+ * Contains configuration specific to this particular API call, which
768
+ * can override or extend the base configuration.
769
+ */
770
+ config: CallApiConfig;
771
+ /**
772
+ * Merged options combining base config, instance config, and default options.
773
+ *
774
+ * This is the final resolved configuration that will be used for the request,
775
+ * with proper precedence applied (instance > base > defaults).
776
+ */
777
+ options: CallApiExtraOptionsForHooks<TCallApiContext>;
778
+ /**
779
+ * Merged request object ready to be sent.
780
+ *
781
+ * Contains the final request configuration including URL, method, headers,
782
+ * body, and other fetch options. This object can be modified in onRequest
783
+ * hooks to customize the outgoing request.
784
+ */
785
+ request: CallApiRequestOptionsForHooks;
786
+ };
787
+ type ValidationErrorContext<TCallApiContext extends Pick<CallApiContext, "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = RequestContext<TCallApiContext> & {
788
+ error: PossibleValidationError;
789
+ response: Response | null;
790
+ };
791
+ type SuccessContext<TCallApiContext extends Pick<CallApiContext, "Data" | "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = RequestContext<TCallApiContext> & {
792
+ data: NoInfer<TCallApiContext["Data"]>;
793
+ response: Response;
794
+ };
795
+ type ResponseContext<TCallApiContext extends Pick<CallApiContext, "Data" | "ErrorData" | "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = RequestContext<TCallApiContext> & (Prettify<CallApiResultSuccessVariant<TCallApiContext["Data"]>> | Prettify<Extract<CallApiResultErrorVariant<TCallApiContext["ErrorData"]>, {
796
+ error: PossibleHTTPError<TCallApiContext["ErrorData"]>;
797
+ }>>);
798
+ type RequestErrorContext<TCallApiContext extends Pick<CallApiContext, "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = RequestContext<TCallApiContext> & {
799
+ error: PossibleJavaScriptError;
800
+ response: null;
801
+ };
802
+ type ErrorContext<TCallApiContext extends Pick<CallApiContext, "ErrorData" | "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = RequestContext<TCallApiContext> & ({
803
+ error: PossibleHTTPError<TCallApiContext["ErrorData"]>;
804
+ response: Response;
805
+ } | {
806
+ error: PossibleJavaScriptOrValidationError;
807
+ response: Response | null;
808
+ });
809
+ type ResponseErrorContext<TCallApiContext extends Pick<CallApiContext, "ErrorData" | "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = Extract<ErrorContext<TCallApiContext>, {
810
+ error: PossibleHTTPError<TCallApiContext["ErrorData"]>;
811
+ }> & RequestContext<TCallApiContext>;
812
+ type RetryContext<TCallApiContext extends Pick<CallApiContext, "ErrorData" | "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = ErrorContext<TCallApiContext> & {
813
+ retryAttemptCount: number;
814
+ };
815
+ type RequestStreamContext<TCallApiContext extends Pick<CallApiContext, "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = RequestContext<TCallApiContext> & {
816
+ event: StreamProgressEvent;
817
+ requestInstance: Request;
818
+ };
819
+ type ResponseStreamContext<TCallApiContext extends Pick<CallApiContext, "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = RequestContext<TCallApiContext> & {
820
+ event: StreamProgressEvent;
821
+ response: Response;
822
+ };
823
+ //#endregion
824
+ //#region src/dedupe.d.ts
825
+ type DedupeStrategyUnion = UnmaskType<"cancel" | "defer" | "none">;
826
+ type DedupeOptionKeys = Exclude<keyof DedupeOptions, "dedupe">;
827
+ type InnerDedupeOptions = { [Key in DedupeOptionKeys as RemovePrefix<"dedupe", Key>]?: DedupeOptions[Key] };
828
+ type DedupeOptions = {
829
+ /**
830
+ * All dedupe options in a single object instead of separate properties
831
+ */
832
+ dedupe?: InnerDedupeOptions;
833
+ /**
834
+ * Controls the scope of request deduplication caching.
835
+ *
836
+ * - `"global"`: Shares deduplication cache across all `createFetchClient` instances with the same `dedupeCacheScopeKey`.
837
+ * Useful for applications with multiple API clients that should share deduplication state.
838
+ * - `"local"`: Limits deduplication to requests within the same `createFetchClient` instance.
839
+ * Provides better isolation and is recommended for most use cases.
840
+ *
841
+ *
842
+ * **Real-world Scenarios:**
843
+ * - Use `"global"` when you have multiple API clients (user service, auth service, etc.) that might make overlapping requests
844
+ * - Use `"local"` (default) for single-purpose clients or when you want strict isolation between different parts of your app
845
+ *
846
+ * @example
847
+ * ```ts
848
+ * // Local scope - each client has its own deduplication cache
849
+ * const userClient = createFetchClient({ baseURL: "/api/users" });
850
+ * const postClient = createFetchClient({ baseURL: "/api/posts" });
851
+ * // These clients won't share deduplication state
852
+ *
853
+ * // Global scope - share cache across related clients
854
+ * const userClient = createFetchClient({
855
+ * baseURL: "/api/users",
856
+ * dedupeCacheScope: "global",
857
+ * });
858
+ * const postClient = createFetchClient({
859
+ * baseURL: "/api/posts",
860
+ * dedupeCacheScope: "global",
861
+ * });
862
+ * // These clients will share deduplication state
863
+ * ```
864
+ *
865
+ * @default "local"
866
+ */
867
+ dedupeCacheScope?: "global" | "local";
868
+ /**
869
+ * Unique namespace for the global deduplication cache when using `dedupeCacheScope: "global"`.
870
+ *
871
+ * This creates logical groupings of deduplication caches. All instances with the same key
872
+ * will share the same cache namespace, allowing fine-grained control over which clients
873
+ * share deduplication state.
874
+ *
875
+ * **Best Practices:**
876
+ * - Use descriptive names that reflect the logical grouping (e.g., "user-service", "analytics-api")
877
+ * - Keep scope keys consistent across related API clients
878
+ * - Consider using different scope keys for different environments (dev, staging, prod)
879
+ * - Avoid overly broad scope keys that might cause unintended cache sharing
880
+ *
881
+ * **Cache Management:**
882
+ * - Each scope key maintains its own independent cache
883
+ * - Caches are automatically cleaned up when no references remain
884
+ * - Consider the memory implications of multiple global scopes
885
+ *
886
+ * @example
887
+ * ```ts
888
+ * // Group related API clients together
889
+ * const userClient = createFetchClient({
890
+ * baseURL: "/api/users",
891
+ * dedupeCacheScope: "global",
892
+ * dedupeCacheScopeKey: "user-service"
893
+ * });
894
+ * const profileClient = createFetchClient({
895
+ * baseURL: "/api/profiles",
896
+ * dedupeCacheScope: "global",
897
+ * dedupeCacheScopeKey: "user-service" // Same scope - will share cache
898
+ * });
899
+ *
900
+ * // Separate analytics client with its own cache
901
+ * const analyticsClient = createFetchClient({
902
+ * baseURL: "/api/analytics",
903
+ * dedupeCacheScope: "global",
904
+ * dedupeCacheScopeKey: "analytics-service" // Different scope
905
+ * });
906
+ *
907
+ * // Environment-specific scoping
908
+ * const apiClient = createFetchClient({
909
+ * dedupeCacheScope: "global",
910
+ * dedupeCacheScopeKey: `api-${process.env.NODE_ENV}` // "api-development", "api-production", etc.
911
+ * });
912
+ * ```
913
+ *
914
+ * @default "default"
915
+ */
916
+ dedupeCacheScopeKey?: "default" | AnyString | ((context: RequestContext) => string | undefined);
917
+ /**
918
+ * Custom key generator for request deduplication.
919
+ *
920
+ * Override the default key generation strategy to control exactly which requests
921
+ * are considered duplicates. The default key combines URL, method, body, and
922
+ * relevant headers (excluding volatile ones like 'Date', 'Authorization', etc.).
923
+ *
924
+ * **Default Key Generation:**
925
+ * The auto-generated key includes:
926
+ * - Full request URL (including query parameters)
927
+ * - HTTP method (GET, POST, etc.)
928
+ * - Request body (for POST/PUT/PATCH requests)
929
+ * - Stable headers (excludes Date, Authorization, User-Agent, etc.)
930
+ *
931
+ * **Custom Key Best Practices:**
932
+ * - Include only the parts of the request that should affect deduplication
933
+ * - Avoid including volatile data (timestamps, random IDs, etc.)
934
+ * - Consider performance - simpler keys are faster to compute and compare
935
+ * - Ensure keys are deterministic for the same logical request
936
+ * - Use consistent key formats across your application
937
+ *
938
+ * **Performance Considerations:**
939
+ * - Function-based keys are computed on every request - keep them lightweight
940
+ * - String keys are fastest but least flexible
941
+ * - Consider caching expensive key computations if needed
942
+ *
943
+ * @example
944
+ * ```ts
945
+ * import { callApi } from "@zayne-labs/callapi";
946
+ *
947
+ * // Simple static key - useful for singleton requests
948
+ * const config = callApi("/api/config", {
949
+ * dedupeKey: "app-config",
950
+ * dedupeStrategy: "defer" // Share the same config across all requests
951
+ * });
952
+ *
953
+ * // URL and method only - ignore headers and body
954
+ * const userData = callApi("/api/user/123", {
955
+ * dedupeKey: (context) => `${context.options.method}:${context.options.fullURL}`
956
+ * });
957
+ *
958
+ * // Include specific headers in deduplication
959
+ * const apiCall = callApi("/api/data", {
960
+ * dedupeKey: (context) => {
961
+ * const authHeader = context.request.headers.get("Authorization");
962
+ * return `${context.options.fullURL}-${authHeader}`;
963
+ * }
964
+ * });
965
+ *
966
+ * // User-specific deduplication
967
+ * const userSpecificCall = callApi("/api/dashboard", {
968
+ * dedupeKey: (context) => {
969
+ * const userId = context.options.fullURL.match(/user\/(\d+)/)?.[1];
970
+ * return `dashboard-${userId}`;
971
+ * }
972
+ * });
973
+ *
974
+ * // Ignore certain query parameters
975
+ * const searchCall = callApi("/api/search?q=test&timestamp=123456", {
976
+ * dedupeKey: (context) => {
977
+ * const url = new URL(context.options.fullURL);
978
+ * url.searchParams.delete("timestamp"); // Remove volatile param
979
+ * return `search:${url.toString()}`;
980
+ * }
981
+ * });
982
+ * ```
983
+ *
984
+ * @default Auto-generated from request details
985
+ */
986
+ dedupeKey?: string | ((context: RequestContext) => string | undefined);
987
+ /**
988
+ * Strategy for handling duplicate requests. Can be a static string or callback function.
989
+ *
990
+ * **Available Strategies:**
991
+ * - `"cancel"`: Cancel previous request when new one starts (good for search)
992
+ * - `"defer"`: Share response between duplicate requests (good for config loading)
993
+ * - `"none"`: No deduplication, all requests execute independently
994
+ *
995
+ * @example
996
+ * ```ts
997
+ * // Static strategies
998
+ * const searchClient = createFetchClient({
999
+ * dedupeStrategy: "cancel" // Cancel previous searches
1000
+ * });
1001
+ *
1002
+ * const configClient = createFetchClient({
1003
+ * dedupeStrategy: "defer" // Share config across components
1004
+ * });
1005
+ *
1006
+ * // Dynamic strategy based on request
1007
+ * const smartClient = createFetchClient({
1008
+ * dedupeStrategy: (context) => {
1009
+ * return context.options.method === "GET" ? "defer" : "cancel";
1010
+ * }
1011
+ * });
1012
+ *
1013
+ * // Search-as-you-type with cancel strategy
1014
+ * const handleSearch = async (query: string) => {
1015
+ * try {
1016
+ * const { data } = await callApi("/api/search", {
1017
+ * method: "POST",
1018
+ * body: { query },
1019
+ * dedupeStrategy: "cancel",
1020
+ * dedupeKey: "search" // Cancel previous searches, only latest one goes through
1021
+ * });
1022
+ *
1023
+ * updateSearchResults(data);
1024
+ * } catch (error) {
1025
+ * if (error.name === "AbortError") {
1026
+ * // Previous search cancelled - (expected behavior)
1027
+ * return;
1028
+ * }
1029
+ * console.error("Search failed:", error);
1030
+ * }
1031
+ * };
1032
+ *
1033
+ * ```
1034
+ *
1035
+ * @default "cancel"
1036
+ */
1037
+ dedupeStrategy?: DedupeStrategyUnion | ((context: RequestContext) => DedupeStrategyUnion);
1038
+ };
1039
+ //#endregion
1040
+ //#region src/retry.d.ts
1041
+ declare const defaultRetryStatusCodesLookup: () => Readonly<{
1042
+ 408: "Request Timeout";
1043
+ 409: "Conflict";
1044
+ 425: "Too Early";
1045
+ 429: "Too Many Requests";
1046
+ 500: "Internal Server Error";
1047
+ 502: "Bad Gateway";
1048
+ 503: "Service Unavailable";
1049
+ 504: "Gateway Timeout";
1050
+ }>;
1051
+ type RetryStatusCodes = UnmaskType<AnyNumber | keyof ReturnType<typeof defaultRetryStatusCodesLookup>>;
1052
+ type RetryCondition<TErrorData> = (context: ErrorContext<{
1053
+ ErrorData: TErrorData;
1054
+ }>) => Awaitable<boolean>;
1055
+ type RetryOptionKeys<TErrorData> = Exclude<keyof RetryOptions<TErrorData>, "~retryAttemptCount" | "retry">;
1056
+ type InnerRetryOptions<TErrorData> = { [Key in RetryOptionKeys<TErrorData> as RemovePrefix<"retry", Key>]?: RetryOptions<TErrorData>[Key] };
1057
+ interface RetryOptions<TErrorData> {
1058
+ /**
1059
+ * Keeps track of the number of times the request has already been retried
1060
+ * @internal
1061
+ * @deprecated **NOTE**: This property is used internally to track retries. Please abstain from modifying it.
1062
+ */
1063
+ readonly ["~retryAttemptCount"]?: number;
1064
+ /**
1065
+ * All retry options in a single object instead of separate properties
1066
+ */
1067
+ retry?: InnerRetryOptions<TErrorData>;
1068
+ /**
1069
+ * Number of allowed retry attempts on HTTP errors
1070
+ * @default 0
1071
+ */
1072
+ retryAttempts?: number;
1073
+ /**
1074
+ * Callback whose return value determines if a request should be retried or not
1075
+ */
1076
+ retryCondition?: RetryCondition<TErrorData>;
1077
+ /**
1078
+ * Delay between retries in milliseconds
1079
+ * @default 1000
1080
+ */
1081
+ retryDelay?: number | ((currentAttemptCount: number) => number);
1082
+ /**
1083
+ * Maximum delay in milliseconds. Only applies to exponential strategy
1084
+ * @default 10000
1085
+ */
1086
+ retryMaxDelay?: number;
1087
+ /**
1088
+ * HTTP methods that are allowed to retry
1089
+ * @default ["GET", "POST"]
1090
+ */
1091
+ retryMethods?: MethodUnion[];
1092
+ /**
1093
+ * HTTP status codes that trigger a retry
1094
+ */
1095
+ retryStatusCodes?: RetryStatusCodes[];
1096
+ /**
1097
+ * Strategy to use when retrying
1098
+ * @default "linear"
1099
+ */
1100
+ retryStrategy?: "exponential" | "linear";
1101
+ }
1102
+ //#endregion
1103
+ //#region src/utils/external/error.d.ts
1104
+ type HTTPErrorDetails<TErrorData> = Pick<CallApiExtraOptions, "defaultHTTPErrorMessage"> & {
1105
+ errorData: TErrorData;
1106
+ response: Response;
1107
+ };
1108
+ declare class HTTPError<TErrorData = Record<string, unknown>> extends Error {
1109
+ errorData: HTTPErrorDetails<TErrorData>["errorData"];
1110
+ readonly httpErrorSymbol: symbol;
1111
+ name: "HTTPError";
1112
+ response: HTTPErrorDetails<TErrorData>["response"];
1113
+ constructor(errorDetails: HTTPErrorDetails<TErrorData>, errorOptions?: ErrorOptions);
1114
+ /**
1115
+ * @description Checks if the given error is an instance of HTTPError
1116
+ * @param error - The error to check
1117
+ * @returns true if the error is an instance of HTTPError, false otherwise
1118
+ */
1119
+ static isError<TErrorData>(error: unknown): error is HTTPError<TErrorData>;
1120
+ }
1121
+ type SafeExtract<TUnion, TKey extends TUnion> = Extract<TUnion, TKey>;
1122
+ type ValidationErrorDetails = {
1123
+ /**
1124
+ * The cause of the validation error.
1125
+ *
1126
+ * It's either the name the schema for which validation failed, or the name of the schema config option that led to the validation error.
1127
+ */
1128
+ issueCause: "unknown" | `schemaConfig-(${SafeExtract<keyof CallApiSchemaConfig, "strict">})` | keyof CallApiSchema;
1129
+ /**
1130
+ * The issues that caused the validation error.
1131
+ */
1132
+ issues: readonly StandardSchemaV1.Issue[];
1133
+ /**
1134
+ * The response from server, if any.
1135
+ */
1136
+ response: Response | null;
1137
+ };
1138
+ declare class ValidationError extends Error {
1139
+ errorData: ValidationErrorDetails["issues"];
1140
+ issueCause: ValidationErrorDetails["issueCause"];
1141
+ name: "ValidationError";
1142
+ response: ValidationErrorDetails["response"];
1143
+ readonly validationErrorSymbol: symbol;
1144
+ constructor(details: ValidationErrorDetails, errorOptions?: ErrorOptions);
1145
+ /**
1146
+ * @description Checks if the given error is an instance of ValidationError
1147
+ * @param error - The error to check
1148
+ * @returns true if the error is an instance of ValidationError, false otherwise
1149
+ */
1150
+ static isError(error: unknown): error is ValidationError;
1151
+ }
1152
+ //#endregion
1153
+ //#region src/types/common.d.ts
1154
+ interface Register {}
1155
+ type GlobalMeta = Register extends {
1156
+ meta?: infer TMeta extends DefaultMetaObject;
1157
+ } ? TMeta : DefaultMetaObject;
1158
+ type CallApiContext = {
1159
+ Data?: DefaultDataType;
1160
+ ErrorData?: DefaultDataType;
1161
+ InferredExtraOptions?: unknown;
1162
+ Meta?: DefaultMetaObject;
1163
+ ResultMode?: ResultModeType;
1164
+ };
1165
+ type OverrideCallApiContext<TFullCallApiContext extends CallApiContext, TOverrideCallApiContext extends CallApiContext> = Omit<TFullCallApiContext, keyof TOverrideCallApiContext> & TOverrideCallApiContext;
1166
+ type FetchSpecificKeysUnion = Exclude<(typeof fetchSpecificKeys)[number], "body" | "headers" | "method">;
1167
+ type ModifiedRequestInit = RequestInit & {
1168
+ duplex?: "half";
1169
+ };
1170
+ type CallApiRequestOptions = Prettify<{
1171
+ /**
1172
+ * Body of the request, can be a object or any other supported body type.
1173
+ */
1174
+ body?: Body;
1175
+ /**
1176
+ * Headers to be used in the request.
1177
+ */
1178
+ headers?: HeadersOption;
1179
+ /**
1180
+ * HTTP method for the request.
1181
+ * @default "GET"
1182
+ */
1183
+ method?: MethodUnion;
1184
+ } & Pick<ModifiedRequestInit, FetchSpecificKeysUnion>>;
1185
+ type CallApiRequestOptionsForHooks = Omit<CallApiRequestOptions, "headers"> & {
1186
+ headers: Record<string, string | undefined>;
1187
+ };
1188
+ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedMergedPluginExtraOptions = Partial<InferPluginExtraOptions<TPluginArray> & TCallApiContext["InferredExtraOptions"]>, TComputedCallApiContext extends CallApiContext = OverrideCallApiContext<TCallApiContext, {
1189
+ Data: TData;
1190
+ ErrorData: TErrorData;
1191
+ InferredExtraOptions: TComputedMergedPluginExtraOptions;
1192
+ ResultMode: TResultMode;
1193
+ }>> = DedupeOptions & HookConfigOptions & HooksOrHooksArray<TComputedCallApiContext> & Middlewares<TComputedCallApiContext> & ResultModeOption<TErrorData, TResultMode> & RetryOptions<TErrorData> & TComputedMergedPluginExtraOptions & ThrowOnErrorOption<TErrorData, TThrowOnError> & URLOptions & {
1194
+ /**
1195
+ * Automatically add an Authorization header value.
1196
+ *
1197
+ * Supports multiple authentication patterns:
1198
+ * - String: Direct authorization header value
1199
+ * - Auth object: Structured authentication configuration
1200
+ *
1201
+ * ```
1202
+ */
1203
+ auth?: Auth;
1204
+ /**
1205
+ * Custom function to serialize request body objects into strings.
1206
+ *
1207
+ * Useful for custom serialization formats or when the default JSON
1208
+ * serialization doesn't meet your needs.
1209
+ *
1210
+ * @example
1211
+ * ```ts
1212
+ * // Custom form data serialization
1213
+ * bodySerializer: (data) => {
1214
+ * const formData = new URLSearchParams();
1215
+ * Object.entries(data).forEach(([key, value]) => {
1216
+ * formData.append(key, String(value));
1217
+ * });
1218
+ * return formData.toString();
1219
+ * }
1220
+ *
1221
+ * // XML serialization
1222
+ * bodySerializer: (data) => {
1223
+ * return `<request>${Object.entries(data)
1224
+ * .map(([key, value]) => `<${key}>${value}</${key}>`)
1225
+ * .join('')}</request>`;
1226
+ * }
1227
+ *
1228
+ * // Custom JSON with specific formatting
1229
+ * bodySerializer: (data) => JSON.stringify(data, null, 2)
1230
+ * ```
1231
+ */
1232
+ bodySerializer?: (bodyData: Record<string, unknown>) => string;
1233
+ /**
1234
+ * Whether to clone the response so it can be read multiple times.
1235
+ *
1236
+ * By default, response streams can only be consumed once. Enable this when you need
1237
+ * to read the response in multiple places (e.g., in hooks and main code).
1238
+ *
1239
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Response/clone
1240
+ * @default false
1241
+ */
1242
+ cloneResponse?: boolean;
1243
+ /**
1244
+ * Custom fetch implementation to replace the default fetch function.
1245
+ *
1246
+ * Useful for testing, adding custom behavior, or using alternative HTTP clients
1247
+ * that implement the fetch API interface.
1248
+ *
1249
+ * @example
1250
+ * ```ts
1251
+ * // Use node-fetch in Node.js environments
1252
+ * import fetch from 'node-fetch';
1253
+ *
1254
+ * // Mock fetch for testing
1255
+ * customFetchImpl: async (url, init) => {
1256
+ * return new Response(JSON.stringify({ mocked: true }), {
1257
+ * status: 200,
1258
+ * headers: { 'Content-Type': 'application/json' }
1259
+ * });
1260
+ * }
1261
+ *
1262
+ * // Add custom logging to all requests
1263
+ * customFetchImpl: async (url, init) => {
1264
+ * console.log(`Fetching: ${url}`);
1265
+ * const response = await fetch(url, init);
1266
+ * console.log(`Response: ${response.status}`);
1267
+ * return response;
1268
+ * }
1269
+ *
1270
+ * // Use with custom HTTP client
1271
+ * customFetchImpl: async (url, init) => {
1272
+ * // Convert to your preferred HTTP client format
1273
+ * return await customHttpClient.request({
1274
+ * url: url.toString(),
1275
+ * method: init?.method || 'GET',
1276
+ * headers: init?.headers,
1277
+ * body: init?.body
1278
+ * });
1279
+ * }
1280
+ * ```
1281
+ */
1282
+ customFetchImpl?: FetchImpl;
1283
+ /**
1284
+ * Default HTTP error message when server doesn't provide one.
1285
+ *
1286
+ * Can be a static string or a function that receives error context
1287
+ * to generate dynamic error messages based on the response.
1288
+ *
1289
+ * @default "Failed to fetch data from server!"
1290
+ *
1291
+ * @example
1292
+ * ```ts
1293
+ * // Static error message
1294
+ * defaultHTTPErrorMessage: "API request failed. Please try again."
1295
+ *
1296
+ * // Dynamic error message based on status code
1297
+ * defaultHTTPErrorMessage: ({ response }) => {
1298
+ * switch (response.status) {
1299
+ * case 401: return "Authentication required. Please log in.";
1300
+ * case 403: return "Access denied. Insufficient permissions.";
1301
+ * case 404: return "Resource not found.";
1302
+ * case 429: return "Too many requests. Please wait and try again.";
1303
+ * case 500: return "Server error. Please contact support.";
1304
+ * default: return `Request failed with status ${response.status}`;
1305
+ * }
1306
+ * }
1307
+ *
1308
+ * // Include error data in message
1309
+ * defaultHTTPErrorMessage: ({ errorData, response }) => {
1310
+ * const userMessage = errorData?.message || "Unknown error occurred";
1311
+ * return `${userMessage} (Status: ${response.status})`;
1312
+ * }
1313
+ * ```
1314
+ */
1315
+ defaultHTTPErrorMessage?: string | ((context: Pick<HTTPError<TErrorData>, "errorData" | "response">) => string);
1316
+ /**
1317
+ * Forces calculation of total byte size from request/response body streams.
1318
+ *
1319
+ * Useful when the Content-Length header is missing or incorrect, and you need
1320
+ * accurate size information for progress tracking or bandwidth monitoring.
1321
+ *
1322
+ * @default false
1323
+ *
1324
+ */
1325
+ forcefullyCalculateStreamSize?: boolean | {
1326
+ request?: boolean;
1327
+ response?: boolean;
1328
+ };
1329
+ /**
1330
+ * Optional metadata field for associating additional information with requests.
1331
+ *
1332
+ * Useful for logging, tracing, or handling specific cases in shared interceptors.
1333
+ * The meta object is passed through to all hooks and can be accessed in error handlers.
1334
+ *
1335
+ * @example
1336
+ * ```ts
1337
+ * const callMainApi = callApi.create({
1338
+ * baseURL: "https://main-api.com",
1339
+ * onResponseError: ({ response, options }) => {
1340
+ * if (options.meta?.userId) {
1341
+ * console.error(`User ${options.meta.userId} made an error`);
1342
+ * }
1343
+ * },
1344
+ * });
1345
+ *
1346
+ * const response = await callMainApi({
1347
+ * url: "https://example.com/api/data",
1348
+ * meta: { userId: "123" },
1349
+ * });
1350
+ *
1351
+ * // Use case: Request tracking
1352
+ * const result = await callMainApi({
1353
+ * url: "https://example.com/api/data",
1354
+ * meta: {
1355
+ * requestId: generateId(),
1356
+ * source: "user-dashboard",
1357
+ * priority: "high"
1358
+ * }
1359
+ * });
1360
+ *
1361
+ * // Use case: Feature flags
1362
+ * const client = callApi.create({
1363
+ * baseURL: "https://api.example.com",
1364
+ * meta: {
1365
+ * features: ["newUI", "betaFeature"],
1366
+ * experiment: "variantA"
1367
+ * }
1368
+ * });
1369
+ * ```
1370
+ */
1371
+ meta?: TCallApiContext["Meta"] extends DefaultMetaObject ? TCallApiContext["Meta"] : DefaultCallApiContext["Meta"];
1372
+ /**
1373
+ * Custom function to parse response strings into actual value instead of the default response.json().
1374
+ *
1375
+ * Useful when you need custom parsing logic for specific response formats.
1376
+ *
1377
+ * @example
1378
+ * ```ts
1379
+ * responseParser: (responseString) => {
1380
+ * return JSON.parse(responseString);
1381
+ * }
1382
+ *
1383
+ * // Parse XML responses
1384
+ * responseParser: (responseString) => {
1385
+ * const parser = new DOMParser();
1386
+ * const doc = parser.parseFromString(responseString, "text/xml");
1387
+ * return xmlToObject(doc);
1388
+ * }
1389
+ *
1390
+ * // Parse CSV responses
1391
+ * responseParser: (responseString) => {
1392
+ * const lines = responseString.split('\n');
1393
+ * const headers = lines[0].split(',');
1394
+ * const data = lines.slice(1).map(line => {
1395
+ * const values = line.split(',');
1396
+ * return headers.reduce((obj, header, index) => {
1397
+ * obj[header] = values[index];
1398
+ * return obj;
1399
+ * }, {});
1400
+ * });
1401
+ * return data;
1402
+ * }
1403
+ *
1404
+ * ```
1405
+ */
1406
+ responseParser?: (responseString: string) => Awaitable<TData>;
1407
+ /**
1408
+ * Expected response type, determines how the response body is parsed.
1409
+ *
1410
+ * Different response types trigger different parsing methods:
1411
+ * - **"json"**: Parses as JSON using response.json()
1412
+ * - **"text"**: Returns as plain text using response.text()
1413
+ * - **"blob"**: Returns as Blob using response.blob()
1414
+ * - **"arrayBuffer"**: Returns as ArrayBuffer using response.arrayBuffer()
1415
+ * - **"stream"**: Returns the response body stream directly
1416
+ *
1417
+ * @default "json"
1418
+ *
1419
+ * @example
1420
+ * ```ts
1421
+ * // JSON API responses (default)
1422
+ * responseType: "json"
1423
+ *
1424
+ * // Plain text responses
1425
+ * responseType: "text"
1426
+ * // Usage: const csvData = await callApi("/export.csv", { responseType: "text" });
1427
+ *
1428
+ * // File downloads
1429
+ * responseType: "blob"
1430
+ * // Usage: const file = await callApi("/download/file.pdf", { responseType: "blob" });
1431
+ *
1432
+ * // Binary data
1433
+ * responseType: "arrayBuffer"
1434
+ * // Usage: const buffer = await callApi("/binary-data", { responseType: "arrayBuffer" });
1435
+ *
1436
+ * // Streaming responses
1437
+ * responseType: "stream"
1438
+ * // Usage: const stream = await callApi("/large-dataset", { responseType: "stream" });
1439
+ * ```
1440
+ */
1441
+ responseType?: TResponseType;
1442
+ /**
1443
+ * Controls what data is included in the returned result object.
1444
+ *
1445
+ * Different modes return different combinations of data, error, and response:
1446
+ * - **"all"**: Returns { data, error, response } - complete result information
1447
+ * - **"onlyData"**: Returns only data (null for errors)
1448
+ *
1449
+ * When combined with throwOnError: true, null/error variants are automatically removed:
1450
+ * - **"all" + throwOnError: true**: Returns { data, error: null, response } (error property is null, throws instead)
1451
+ * - **"onlyData" + throwOnError: true**: Returns data (never null, throws on error)
1452
+ *
1453
+ * @default "all"
1454
+ *
1455
+ * @example
1456
+ * ```ts
1457
+ * // Complete result with all information (default)
1458
+ * const { data, error, response } = await callApi("/users", { resultMode: "all" });
1459
+ * if (error) {
1460
+ * console.error("Request failed:", error);
1461
+ * } else {
1462
+ * console.log("Users:", data);
1463
+ * }
1464
+ *
1465
+ * // Complete result but throws on errors (throwOnError removes error from type)
1466
+ * try {
1467
+ * const { data, response } = await callApi("/users", {
1468
+ * resultMode: "all",
1469
+ * throwOnError: true
1470
+ * });
1471
+ * console.log("Users:", data); // data is never null here
1472
+ * } catch (error) {
1473
+ * console.error("Request failed:", error);
1474
+ * }
1475
+ *
1476
+ * // Only data, returns null on errors
1477
+ * const users = await callApi("/users", { resultMode: "onlyData" });
1478
+ * if (users) {
1479
+ * console.log("Users:", users);
1480
+ * } else {
1481
+ * console.log("Request failed");
1482
+ * }
1483
+ *
1484
+ * // Only data, throws on errors (throwOnError removes null from type)
1485
+ * try {
1486
+ * const users = await callApi("/users", {
1487
+ * resultMode: "onlyData",
1488
+ * throwOnError: true
1489
+ * });
1490
+ * console.log("Users:", users); // users is never null here
1491
+ * } catch (error) {
1492
+ * console.error("Request failed:", error);
1493
+ * }
1494
+ * ```
1495
+ */
1496
+ resultMode?: TResultMode;
1497
+ /**
1498
+ * Controls whether errors are thrown as exceptions or returned in the result.
1499
+ *
1500
+ * Can be a boolean or a function that receives the error and decides whether to throw.
1501
+ * When true, errors are thrown as exceptions instead of being returned in the result object.
1502
+ *
1503
+ * @default false
1504
+ *
1505
+ * @example
1506
+ * ```ts
1507
+ * // Always throw errors
1508
+ * throwOnError: true
1509
+ * try {
1510
+ * const data = await callApi("/users");
1511
+ * console.log("Users:", data);
1512
+ * } catch (error) {
1513
+ * console.error("Request failed:", error);
1514
+ * }
1515
+ *
1516
+ * // Never throw errors (default)
1517
+ * throwOnError: false
1518
+ * const { data, error } = await callApi("/users");
1519
+ * if (error) {
1520
+ * console.error("Request failed:", error);
1521
+ * }
1522
+ *
1523
+ * // Conditionally throw based on error type
1524
+ * throwOnError: (error) => {
1525
+ * // Throw on client errors (4xx) but not server errors (5xx)
1526
+ * return error.response?.status >= 400 && error.response?.status < 500;
1527
+ * }
1528
+ *
1529
+ * // Throw only on specific status codes
1530
+ * throwOnError: (error) => {
1531
+ * const criticalErrors = [401, 403, 404];
1532
+ * return criticalErrors.includes(error.response?.status);
1533
+ * }
1534
+ *
1535
+ * // Throw on validation errors but not network errors
1536
+ * throwOnError: (error) => {
1537
+ * return error.type === "validation";
1538
+ * }
1539
+ * ```
1540
+ */
1541
+ throwOnError?: ThrowOnErrorType<TErrorData, TThrowOnError>;
1542
+ /**
1543
+ * Request timeout in milliseconds. Request will be aborted if it takes longer.
1544
+ *
1545
+ * Useful for preventing requests from hanging indefinitely and providing
1546
+ * better user experience with predictable response times.
1547
+ *
1548
+ * @example
1549
+ * ```ts
1550
+ * // 5 second timeout
1551
+ * timeout: 5000
1552
+ *
1553
+ * // Different timeouts for different endpoints
1554
+ * const quickApi = createFetchClient({ timeout: 3000 }); // 3s for fast endpoints
1555
+ * const slowApi = createFetchClient({ timeout: 30000 }); // 30s for slow operations
1556
+ *
1557
+ * // Per-request timeout override
1558
+ * await callApi("/quick-data", { timeout: 1000 });
1559
+ * await callApi("/slow-report", { timeout: 60000 });
1560
+ *
1561
+ * // No timeout (use with caution)
1562
+ * timeout: 0
1563
+ * ```
1564
+ */
1565
+ timeout?: number;
1566
+ };
1567
+ type BaseCallApiExtraOptions<TBaseCallApiContext extends CallApiContext = DefaultCallApiContext, TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeType = ResultModeType, TBaseThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TBaseResponseType extends ResponseTypeType = ResponseTypeType, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig> = SharedExtraOptions<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray> & {
1568
+ /**
1569
+ * Array of base CallApi plugins to extend library functionality.
1570
+ *
1571
+ * Base plugins are applied to all instances created from this base configuration
1572
+ * and provide foundational functionality like authentication, logging, or caching.
1573
+ *
1574
+ * @example
1575
+ * ```ts
1576
+ * // Add logging plugin
1577
+ *
1578
+ * // Create base client with common plugins
1579
+ * const callApi = createFetchClient({
1580
+ * baseURL: "https://api.example.com",
1581
+ * plugins: [loggerPlugin({ enabled: true })]
1582
+ * });
1583
+ *
1584
+ * // All requests inherit base plugins
1585
+ * await callApi("/users");
1586
+ * await callApi("/posts");
1587
+ *
1588
+ * ```
1589
+ */
1590
+ plugins?: TBasePluginArray;
1591
+ /**
1592
+ * Base validation schemas for the client configuration.
1593
+ *
1594
+ * Defines validation rules for requests and responses that apply to all
1595
+ * instances created from this base configuration. Provides type safety
1596
+ * and runtime validation for API interactions.
1597
+ */
1598
+ schema?: TBaseSchemaAndConfig;
1599
+ /**
1600
+ * Controls which configuration parts skip automatic merging between base and instance configs.
1601
+ *
1602
+ * By default, CallApi automatically merges base configuration with instance configuration.
1603
+ * This option allows you to disable automatic merging for specific parts when you need
1604
+ * manual control over how configurations are combined.
1605
+ *
1606
+ * @enum
1607
+ * - **"all"**: Disables automatic merging for both request options and extra options
1608
+ * - **"options"**: Disables automatic merging of extra options only (hooks, plugins, etc.)
1609
+ * - **"request"**: Disables automatic merging of request options only (headers, body, etc.)
1610
+ *
1611
+ * @example
1612
+ * ```ts
1613
+ * // Skip all automatic merging - full manual control
1614
+ * const client = callApi.create((ctx) => ({
1615
+ * skipAutoMergeFor: "all",
1616
+ *
1617
+ * // Manually decide what to merge
1618
+ * baseURL: ctx.options.baseURL, // Keep base URL
1619
+ * timeout: 5000, // Override timeout
1620
+ * headers: {
1621
+ * ...ctx.request.headers, // Merge headers manually
1622
+ * "X-Custom": "value" // Add custom header
1623
+ * }
1624
+ * }));
1625
+ *
1626
+ * // Skip options merging - manual plugin/hook control
1627
+ * const client = callApi.create((ctx) => ({
1628
+ * skipAutoMergeFor: "options",
1629
+ *
1630
+ * // Manually control which plugins to use
1631
+ * plugins: [
1632
+ * ...ctx.options.plugins?.filter(p => p.name !== "unwanted") || [],
1633
+ * customPlugin
1634
+ * ],
1635
+ *
1636
+ * // Request options still auto-merge
1637
+ * method: "POST"
1638
+ * }));
1639
+ *
1640
+ * // Skip request merging - manual request control
1641
+ * const client = callApi.create((ctx) => ({
1642
+ * skipAutoMergeFor: "request",
1643
+ *
1644
+ * // Extra options still auto-merge (plugins, hooks, etc.)
1645
+ *
1646
+ * // Manually control request options
1647
+ * headers: {
1648
+ * "Content-Type": "application/json",
1649
+ * // Don't merge base headers
1650
+ * },
1651
+ * method: ctx.request.method || "GET"
1652
+ * }));
1653
+ *
1654
+ * // Use case: Conditional merging based on request
1655
+ * const client = createFetchClient((ctx) => ({
1656
+ * skipAutoMergeFor: "options",
1657
+ *
1658
+ * // Only use auth plugin for protected routes
1659
+ * plugins: ctx.initURL.includes("/protected/")
1660
+ * ? [...(ctx.options.plugins || []), authPlugin]
1661
+ * : ctx.options.plugins?.filter(p => p.name !== "auth") || []
1662
+ * }));
1663
+ * ```
1664
+ */
1665
+ skipAutoMergeFor?: "all" | "options" | "request";
1666
+ };
1667
+ type InferExtendSchemaContext<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = {
1668
+ baseSchemaRoutes: TBaseSchemaRoutes;
1669
+ currentRouteSchema: GetCurrentRouteSchema<TBaseSchemaRoutes, TCurrentRouteSchemaKey>;
1670
+ };
1671
+ type GetExtendSchemaConfigContext<TBaseSchemaConfig extends CallApiSchemaConfig> = {
1672
+ baseSchemaConfig: TBaseSchemaConfig;
1673
+ };
1674
+ type InferExtendPluginContext<TBasePluginArray extends CallApiPlugin[]> = {
1675
+ basePlugins: TBasePluginArray;
1676
+ };
1677
+ type CallApiExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TCurrentRouteSchemaKey extends string = string, TComputedPluginContext = InferExtendPluginContext<TBasePluginArray>, TComputedSchemaContext = InferExtendSchemaContext<TBaseSchemaRoutes, TCurrentRouteSchemaKey>, TComputedSchemaConfigContext = GetExtendSchemaConfigContext<TBaseSchemaConfig>> = SharedExtraOptions<TCallApiContext, TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray> & {
1678
+ /**
1679
+ * Array of instance-specific CallApi plugins or a function to configure plugins.
1680
+ *
1681
+ * Instance plugins are added to the base plugins and provide functionality
1682
+ * specific to this particular API instance. Can be a static array or a function
1683
+ * that receives base plugins and returns the instance plugins.
1684
+ *
1685
+ */
1686
+ plugins?: TPluginArray | ((context: TComputedPluginContext) => TPluginArray);
1687
+ /**
1688
+ * For instance-specific validation schemas
1689
+ *
1690
+ * Defines validation rules specific to this API instance, extending or overriding the base schema.
1691
+ *
1692
+ * Can be a static schema object or a function that receives base schema context and returns instance schemas.
1693
+ *
1694
+ */
1695
+ schema?: TSchema | ((context: TComputedSchemaContext) => TSchema);
1696
+ /**
1697
+ * Instance-specific schema configuration or a function to configure schema behavior.
1698
+ *
1699
+ * Controls how validation schemas are applied and behave for this specific API instance.
1700
+ * Can override base schema configuration or extend it with instance-specific validation rules.
1701
+ *
1702
+ */
1703
+ schemaConfig?: TSchemaConfig | ((context: TComputedSchemaConfigContext) => TSchemaConfig);
1704
+ };
1705
+ type CallApiExtraOptionsForHooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> = Hooks & Omit<CallApiExtraOptions<TCallApiContext>, keyof Hooks>;
1706
+ type InstanceContext = {
1707
+ initURL: string;
1708
+ options: CallApiExtraOptions;
1709
+ request: CallApiRequestOptions;
1710
+ };
1711
+ type BaseCallApiConfig<TBaseCallApiContext extends CallApiContext = DefaultCallApiContext, TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeType = ResultModeType, TBaseThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TBaseResponseType extends ResponseTypeType = ResponseTypeType, TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedBaseConfig = BaseCallApiExtraOptions<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemaAndConfig>> = (CallApiRequestOptions & TComputedBaseConfig) | ((context: InstanceContext) => CallApiRequestOptions & TComputedBaseConfig);
1712
+ type CallApiConfig<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InitURLOrURLObject = InitURLOrURLObject, TCurrentRouteSchemaKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = InferExtraOptions<TSchema, TBaseSchemaRoutes, TCurrentRouteSchemaKey, TCallApiContext> & InferRequestOptions<TSchema, TInitURL> & Omit<CallApiExtraOptions<TCallApiContext, TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TBasePluginArray, TPluginArray, TBaseSchemaRoutes, TSchema, TBaseSchemaConfig, TSchemaConfig, TCurrentRouteSchemaKey>, keyof InferExtraOptions<CallApiSchema, BaseCallApiSchemaRoutes, string, CallApiContext>> & Omit<CallApiRequestOptions, keyof InferRequestOptions<CallApiSchema, string>>;
1713
+ //#endregion
1714
+ //#region src/result.d.ts
1715
+ type Parser<TData> = (responseString: string) => Awaitable<TData>;
1716
+ declare const getResponseType: <TResponse>(response: Response, parser: Parser<TResponse>) => {
1717
+ arrayBuffer: () => Promise<ArrayBuffer>;
1718
+ blob: () => Promise<Blob>;
1719
+ formData: () => Promise<FormData>;
1720
+ json: () => Promise<TResponse>;
1721
+ stream: () => ReadableStream<Uint8Array<ArrayBuffer>> | null;
1722
+ text: () => Promise<string>;
1723
+ };
1724
+ type InitResponseTypeMap<TResponse = unknown> = ReturnType<typeof getResponseType<TResponse>>;
1725
+ type ResponseTypeUnion = keyof InitResponseTypeMap;
1726
+ type ResponseTypePlaceholder = null;
1727
+ type ResponseTypeType = ResponseTypePlaceholder | ResponseTypeUnion;
1728
+ type CallApiResultSuccessVariant<TData> = {
1729
+ data: NoInfer<TData>;
1730
+ error: null;
1731
+ response: Response;
1732
+ };
1733
+ type PossibleJavaScriptError = UnmaskType<{
1734
+ errorData: false;
1735
+ message: string;
1736
+ name: "AbortError" | "Error" | "SyntaxError" | "TimeoutError" | "TypeError" | AnyString;
1737
+ originalError: DOMException | Error | SyntaxError | TypeError;
1738
+ }>;
1739
+ type PossibleHTTPError<TErrorData> = UnmaskType<{
1740
+ errorData: NoInfer<TErrorData>;
1741
+ message: string;
1742
+ name: "HTTPError";
1743
+ originalError: HTTPError;
1744
+ }>;
1745
+ type PossibleValidationError = UnmaskType<{
1746
+ errorData: ValidationError["errorData"];
1747
+ issueCause: ValidationError["issueCause"];
1748
+ message: string;
1749
+ name: "ValidationError";
1750
+ originalError: ValidationError;
1751
+ }>;
1752
+ type PossibleJavaScriptOrValidationError = UnmaskType<PossibleJavaScriptError | PossibleValidationError>;
1753
+ type CallApiResultErrorVariant<TErrorData> = {
1754
+ data: null;
1755
+ error: PossibleHTTPError<TErrorData>;
1756
+ response: Response;
1757
+ } | {
1758
+ data: null;
1759
+ error: PossibleJavaScriptOrValidationError;
1760
+ response: Response | null;
1761
+ };
1762
+ type CallApiSuccessOrErrorVariant<TData, TError> = CallApiResultErrorVariant<TError> | CallApiResultSuccessVariant<TData>;
1763
+ type ResultModeMapWithoutException<TData, TErrorData, TComputedResult extends CallApiSuccessOrErrorVariant<TData, TErrorData> = CallApiSuccessOrErrorVariant<TData, TErrorData>> = UnmaskType<{
1764
+ all: TComputedResult;
1765
+ onlyData: TComputedResult["data"];
1766
+ onlyResponse: TComputedResult["response"];
1767
+ withoutResponse: DistributiveOmit<TComputedResult, "response">;
1768
+ }>;
1769
+ type ResultModeMapWithException<TData, TComputedResult extends CallApiResultSuccessVariant<TData> = CallApiResultSuccessVariant<TData>> = {
1770
+ all: TComputedResult;
1771
+ onlyData: TComputedResult["data"];
1772
+ onlyResponse: TComputedResult["response"];
1773
+ withoutResponse: DistributiveOmit<TComputedResult, "response">;
1774
+ };
1775
+ type ResultModeMap<TData = DefaultDataType, TErrorData = DefaultDataType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError> = TThrowOnError extends true ? ResultModeMapWithException<TData> : ResultModeMapWithoutException<TData, TErrorData>;
1776
+ type ResultModePlaceholder = null;
1777
+ type ResultModeUnion = keyof ResultModeMap;
1778
+ type ResultModeType = ResultModePlaceholder | ResultModeUnion;
1779
+ //#endregion
1780
+ //#region src/plugins/logger/logger.d.ts
1781
+ type ConsoleLikeObject = {
1782
+ error: AnyFunction<void>;
1783
+ fail?: AnyFunction<void>;
1784
+ log: AnyFunction<void>;
1785
+ success?: AnyFunction<void>;
1786
+ warn?: AnyFunction<void>;
1787
+ };
1788
+ type LoggerOptions = {
1789
+ /**
1790
+ * Custom console object
1791
+ */
1792
+ consoleObject?: ConsoleLikeObject;
1793
+ /**
1794
+ * Enable or disable the logger
1795
+ * @default true
1796
+ */
1797
+ enabled?: boolean | {
1798
+ onError?: boolean;
1799
+ onRequest?: boolean;
1800
+ onRequestError?: boolean;
1801
+ onResponse?: boolean;
1802
+ onResponseError?: boolean;
1803
+ onRetry?: boolean;
1804
+ onSuccess?: boolean;
1805
+ onValidationError?: boolean;
1806
+ };
1807
+ /**
1808
+ * Enable or disable verbose mode
1809
+ */
1810
+ mode?: "basic" | "verbose";
1811
+ };
1812
+ declare const defaultConsoleObject: ConsoleLikeObject;
1813
+ declare const loggerPlugin: (options?: LoggerOptions) => {
1814
+ id: "logger";
1815
+ name: "Logger";
1816
+ version: "1.1.0";
1817
+ hooks: {
1818
+ onRequest: (ctx: RequestContext<Omit<DefaultCallApiContext, "Data" | "ErrorData"> & {
1819
+ Data: never;
1820
+ ErrorData: never;
1821
+ }>) => void;
1822
+ onRequestError: (ctx: RequestContext<Omit<DefaultCallApiContext, "Data" | "ErrorData"> & {
1823
+ Data: never;
1824
+ ErrorData: never;
1825
+ }> & {
1826
+ error: PossibleJavaScriptError;
1827
+ response: null;
1828
+ }) => void;
1829
+ onResponseError: (ctx: ResponseErrorContext<Omit<DefaultCallApiContext, "Data" | "ErrorData"> & {
1830
+ Data: never;
1831
+ ErrorData: never;
1832
+ }>) => void;
1833
+ onRetry: (ctx: ErrorContext<Omit<DefaultCallApiContext, "Data" | "ErrorData"> & {
1834
+ Data: never;
1835
+ ErrorData: never;
1836
+ }> & {
1837
+ retryAttemptCount: number;
1838
+ }) => void;
1839
+ onSuccess: (ctx: SuccessContext<Omit<DefaultCallApiContext, "Data" | "ErrorData"> & {
1840
+ Data: never;
1841
+ ErrorData: never;
1842
+ }>) => void;
1843
+ onValidationError: (ctx: RequestContext<Omit<DefaultCallApiContext, "Data" | "ErrorData"> & {
1844
+ Data: never;
1845
+ ErrorData: never;
1846
+ }> & {
1847
+ error: PossibleValidationError;
1848
+ response: Response | null;
1849
+ }) => void;
1850
+ };
1851
+ };
1852
+ //#endregion
1853
+ export { defaultConsoleObject as n, loggerPlugin as r, LoggerOptions as t };
1854
+ //# sourceMappingURL=index-BiLuTHUF.d.ts.map