@zayne-labs/callapi-plugins 4.0.28 → 4.0.30

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