@zayne-labs/callapi 1.12.5 → 1.13.0

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.
@@ -1,89 +1,11 @@
1
1
  //#region src/constants/common.d.ts
2
2
  declare const fetchSpecificKeys: readonly (keyof RequestInit | "duplex" | "extraFetchOptions")[];
3
3
  //#endregion
4
- //#region src/types/type-helpers.d.ts
5
- type AnyString = string & NonNullable<unknown>;
6
- type AnyNumber = number & NonNullable<unknown>;
7
- type AnyFunction<TResult = unknown> = (...args: any[]) => TResult;
8
- type Prettify<TObject> = NonNullable<unknown> & { [Key in keyof TObject]: TObject[Key] };
9
- type WriteableLevel = "deep" | "shallow";
10
- /**
11
- * Makes all properties in an object type writeable (removes readonly modifiers).
12
- * Supports both shallow and deep modes, and handles special cases like arrays, tuples, and unions.
13
- * @template TObject - The object type to make writeable
14
- * @template TVariant - The level of writeable transformation ("shallow" | "deep")
15
- */
16
- type ArrayOrObject = Record<number | string | symbol, unknown> | unknown[] | readonly unknown[];
17
- 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;
18
- type UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : never) extends ((param: infer TParam) => void) ? TParam : never;
19
- type UnmaskType<TValue> = {
20
- value: TValue;
21
- }["value"];
22
- /**
23
- * @description Userland implementation of NoInfer intrinsic type, but this one doesn't show up on hover like the intrinsic one
24
- *
25
- * Prevents TypeScript from inferring `TGeneric` at this position by creating a circular dependency.
26
- * The tuple index `[TGeneric extends unknown ? 0 : never]` depends on `TGeneric`, forcing TS to
27
- * skip this site for inference and use other arguments or defaults instead.
28
- */
29
- type NoInferUnMasked<TGeneric> = [TGeneric][TGeneric extends unknown ? 0 : never];
30
- type RemoveSlashImpl<TUrl extends string, TDirection extends "leading" | "trailing"> = TDirection extends "leading" ? TUrl extends `/${infer TWithoutLeadingSlash}` ? TWithoutLeadingSlash : TUrl : TDirection extends "trailing" ? TUrl extends `${infer TWithoutTailingSlash}/` ? TWithoutTailingSlash : TUrl : never;
31
- type RemoveTrailingSlash<TUrl extends string> = RemoveSlashImpl<TUrl, "trailing">;
32
- type RemoveLeadingSlash<TUrl extends string> = RemoveSlashImpl<TUrl, "leading">;
33
- type Awaitable<TValue> = Promise<TValue> | TValue;
34
- type Satisfies<TActualType extends TExpectedTypeShape, TExpectedTypeShape> = { [Key in keyof TActualType]: Key extends keyof TExpectedTypeShape ? TActualType[Key] : never };
35
- type DistributiveOmit<TObject, TKeysToOmit extends keyof TObject> = TObject extends unknown ? Omit<TObject, TKeysToOmit> : never;
36
- 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;
37
- type CommonAuthorizationHeaders = `${"Basic" | "Bearer" | "Token"} ${string}`;
38
- 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;
39
- //#endregion
40
- //#region src/auth.d.ts
41
- type PossibleAuthValue = Awaitable<string | null | undefined>;
42
- type PossibleAuthValueOrGetter = PossibleAuthValue | (() => PossibleAuthValue);
43
- type BearerAuth = {
44
- type: "Bearer";
45
- value: PossibleAuthValueOrGetter;
46
- };
47
- type TokenAuth = {
48
- type: "Token";
49
- value: PossibleAuthValueOrGetter;
50
- };
51
- type BasicAuth = {
52
- type: "Basic";
53
- username: PossibleAuthValueOrGetter;
54
- password: PossibleAuthValueOrGetter;
55
- };
56
- /**
57
- * Custom auth
58
- *
59
- * @param prefix - prefix of the header
60
- * @param authValue - value of the header
61
- *
62
- * @example
63
- * ```ts
64
- * {
65
- * type: "Custom",
66
- * prefix: "Token",
67
- * authValue: "token"
68
- * }
69
- * ```
70
- */
71
- type CustomAuth = {
72
- type: "Custom";
73
- prefix: PossibleAuthValueOrGetter;
74
- value: PossibleAuthValueOrGetter;
75
- };
76
- type AuthOption = PossibleAuthValueOrGetter | BearerAuth | TokenAuth | BasicAuth | CustomAuth;
77
- //#endregion
78
4
  //#region src/constants/validation.d.ts
79
5
  declare const fallBackRouteSchemaKey = "@default";
80
6
  type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
81
7
  //#endregion
82
8
  //#region src/types/standard-schema.d.ts
83
- /**
84
- * The Standard Schema interface.
85
- * @see https://github.com/standard-schema/standard-schema
86
- */
87
9
  /** The Standard Typed interface. This is a base type extended by other specs. */
88
10
  interface StandardTypedV1<Input = unknown, Output = Input> {
89
11
  /** The Standard properties. */
@@ -153,113 +75,48 @@ declare namespace StandardSchemaV1 {
153
75
  readonly key: PropertyKey;
154
76
  }
155
77
  /** The Standard types interface. */
156
- type Types<Input = unknown, Output = Input> = StandardTypedV1.Types<Input, Output>;
78
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
157
79
  /** Infers the input type of a Standard. */
158
80
  type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
159
81
  /** Infers the output type of a Standard. */
160
82
  type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
161
83
  }
162
84
  //#endregion
163
- //#region src/validation.d.ts
164
- type ResultVariant = "infer-input" | "infer-output";
165
- 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<infer TResult> ? Awaited<TResult> : TFallbackResult;
166
- type InferSchemaOutput<TSchema, TFallbackResult = unknown> = InferSchemaResult<TSchema, TFallbackResult, "infer-output">;
167
- type InferSchemaInput<TSchema, TFallbackResult = unknown> = InferSchemaResult<TSchema, TFallbackResult, "infer-input">;
168
- type BooleanObject = { [Key in keyof CallApiSchema]: boolean };
169
- interface CallApiSchemaConfig {
170
- /**
171
- * The base url of the schema. By default it's the baseURL of the callApi instance.
172
- */
173
- baseURL?: "" | AnyString;
174
- /**
175
- * Disables runtime validation for the schema.
176
- */
177
- disableRuntimeValidation?: boolean | BooleanObject;
178
- /**
179
- * If `true`, the original input value will be used instead of the transformed/validated output.
180
- *
181
- * When true, the original input is returned unchanged after validation, ignoring any schema-level
182
- * transformations such as type coercion, default values, or field mapping. Only the validation
183
- * step is executed; the resulting value is discarded in favor of the raw input.
184
- */
185
- disableRuntimeValidationTransform?: boolean | BooleanObject;
186
- /**
187
- * Optional url prefix that will be substituted for the `baseURL` of the schemaConfig at runtime.
188
- *
189
- * Enables a short, stable prefix for routes while keeping the full `baseURL` centralized in config.
190
- * Keeps route definitions concise and shields them from changes to the underlying base URL.
191
- */
192
- prefix?: "" | AnyString;
193
- /**
194
- * Controls the strictness of API route validation.
195
- *
196
- * When true:
197
- * - Only routes explicitly defined in the schema will be considered valid to typescript and the runtime.
198
- * - Attempting to call routes not defined in the schema will result in both type errors and runtime validation errors.
199
- * - Useful for ensuring API calls conform exactly to your schema definition
200
- *
201
- * When false or undefined (default):
202
- * - All routes will be allowed, whether they are defined in the schema or not
203
- */
204
- strict?: boolean;
205
- }
206
- type CallApiSchemaType<TInput> = StandardSchemaV1<TInput | undefined> | ((value: TInput) => Awaitable<TInput | undefined>);
207
- interface CallApiSchema {
208
- auth?: CallApiSchemaType<AuthOption>;
209
- /**
210
- * The schema to use for validating the request body.
211
- */
212
- body?: CallApiSchemaType<Body>;
213
- /**
214
- * The schema to use for validating the response data.
215
- */
216
- data?: CallApiSchemaType<unknown>;
217
- /**
218
- * The schema to use for validating the response error data.
219
- */
220
- errorData?: CallApiSchemaType<unknown>;
221
- /**
222
- * The schema to use for validating the request headers.
223
- */
224
- headers?: CallApiSchemaType<HeadersOption>;
225
- /**
226
- * The schema to use for validating the meta option.
227
- */
228
- meta?: CallApiSchemaType<GlobalMeta>;
229
- /**
230
- * The schema to use for validating the request method.
231
- */
232
- method?: CallApiSchemaType<MethodUnion>;
233
- /**
234
- * The schema to use for validating the request url parameters.
235
- */
236
- params?: CallApiSchemaType<Params>;
237
- /**
238
- * The schema to use for validating the request url queries.
239
- */
240
- query?: CallApiSchemaType<Query>;
241
- }
242
- declare const routeKeyMethods: readonly ["delete", "get", "patch", "post", "put"];
243
- type RouteKeyMethods = (typeof routeKeyMethods)[number];
244
- type RouteKeyMethodsURLUnion = `${AtSymbol}${RouteKeyMethods}/`;
245
- type BaseSchemaRouteKeyPrefixes = FallBackRouteSchemaKey | RouteKeyMethodsURLUnion;
246
- type BaseCallApiSchemaRoutes = Partial<Record<AnyString | BaseSchemaRouteKeyPrefixes, CallApiSchema>>;
247
- type BaseCallApiSchemaAndConfig = {
248
- config?: CallApiSchemaConfig;
249
- routes: BaseCallApiSchemaRoutes;
250
- };
251
- type GetResolvedSchemaContext = {
252
- baseExtraOptions: BaseCallApiExtraOptions;
253
- currentRouteSchemaKey: string;
254
- extraOptions: CallApiExtraOptions;
255
- };
256
- declare const getCurrentRouteSchemaKeyAndMainInitURL: (context: Pick<GetResolvedSchemaContext, "baseExtraOptions" | "extraOptions"> & {
257
- initURL: string;
258
- }) => {
259
- currentRouteSchemaKey: string;
260
- initURL: string;
261
- mainInitURL: string;
262
- };
85
+ //#region src/types/type-helpers.d.ts
86
+ type AnyString = string & NonNullable<unknown>;
87
+ type AnyNumber = number & NonNullable<unknown>;
88
+ type AnyFunction<TResult = unknown> = (...args: any[]) => TResult;
89
+ type Prettify<TObject> = NonNullable<unknown> & { [Key in keyof TObject]: TObject[Key] };
90
+ type WriteableLevel = "deep" | "shallow";
91
+ /**
92
+ * Makes all properties in an object type writeable (removes readonly modifiers).
93
+ * Supports both shallow and deep modes, and handles special cases like arrays, tuples, and unions.
94
+ * @template TObject - The object type to make writeable
95
+ * @template TVariant - The level of writeable transformation ("shallow" | "deep")
96
+ */
97
+ type ArrayOrObject = Record<number | string | symbol, unknown> | unknown[] | readonly unknown[];
98
+ 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;
99
+ type UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : never) extends ((param: infer TParam) => void) ? TParam : never;
100
+ type UnmaskType<TValue> = {
101
+ value: TValue;
102
+ }["value"];
103
+ /**
104
+ * @description Userland implementation of NoInfer intrinsic type, but this one doesn't show up on hover like the intrinsic one
105
+ *
106
+ * Prevents TypeScript from inferring `TGeneric` at this position by creating a circular dependency.
107
+ * The tuple index `[TGeneric extends unknown ? 0 : never]` depends on `TGeneric`, forcing TS to
108
+ * skip this site for inference and use other arguments or defaults instead.
109
+ */
110
+ type NoInferUnMasked<TGeneric> = [TGeneric][TGeneric extends unknown ? 0 : never];
111
+ type RemoveSlashImpl<TUrl extends string, TDirection extends "leading" | "trailing"> = TDirection extends "leading" ? TUrl extends `/${infer TWithoutLeadingSlash}` ? TWithoutLeadingSlash : TUrl : TDirection extends "trailing" ? TUrl extends `${infer TWithoutTailingSlash}/` ? TWithoutTailingSlash : TUrl : never;
112
+ type RemoveTrailingSlash<TUrl extends string> = RemoveSlashImpl<TUrl, "trailing">;
113
+ type RemoveLeadingSlash<TUrl extends string> = RemoveSlashImpl<TUrl, "leading">;
114
+ type Awaitable<TValue> = Promise<TValue> | TValue;
115
+ type Satisfies<TActualType extends TExpectedTypeShape, TExpectedTypeShape> = { [Key in keyof TActualType]: Key extends keyof TExpectedTypeShape ? TActualType[Key] : never };
116
+ type DistributiveOmit<TObject, TKeysToOmit extends keyof TObject> = TObject extends unknown ? Omit<TObject, TKeysToOmit> : never;
117
+ 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;
118
+ type CommonAuthorizationHeaders = `${"Basic" | "Bearer" | "Token"} ${string}`;
119
+ 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;
263
120
  //#endregion
264
121
  //#region src/url.d.ts
265
122
  declare const atSymbol = "@";
@@ -383,164 +240,226 @@ interface URLOptions {
383
240
  query?: Query;
384
241
  }
385
242
  //#endregion
386
- //#region src/types/conditional-types.d.ts
387
- /**
388
- * @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
389
- */
390
- type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaOutput<TSchemaOption, undefined> ? TObject : Required<TObject>;
391
- type MergeBaseWithRouteKey<TBaseURLOrPrefix extends string | undefined, TRouteKey extends string> = TBaseURLOrPrefix extends string ? TRouteKey extends `${AtSymbol}${infer TMethod extends RouteKeyMethods}/${infer TRestOfRoutKey}` ? `${AtSymbol}${TMethod}/${RemoveLeadingSlash<RemoveTrailingSlash<TBaseURLOrPrefix>>}/${RemoveLeadingSlash<TRestOfRoutKey>}` : `${TBaseURLOrPrefix}${TRouteKey}` : TRouteKey;
392
- type ApplyURLBasedConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["prefix"] extends string ? MergeBaseWithRouteKey<TSchemaConfig["prefix"], TSchemaRouteKeys> : TSchemaConfig["baseURL"] extends string ? MergeBaseWithRouteKey<TSchemaConfig["baseURL"], TSchemaRouteKeys> : TSchemaRouteKeys;
393
- type ApplyStrictConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["strict"] extends true ? TSchemaRouteKeys : // eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
394
- TSchemaRouteKeys | Exclude<InitURLOrURLObject, RouteKeyMethodsURLUnion>;
395
- type ApplySchemaConfiguration<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, TSchemaRouteKeys>>;
396
- type InferAllMainRoutes<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes> = Omit<TBaseSchemaRoutes, FallBackRouteSchemaKey>;
397
- type InferAllMainRouteKeys<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = ApplySchemaConfiguration<TSchemaConfig, Extract<keyof InferAllMainRoutes<TBaseSchemaRoutes>, string>>;
398
- type InferInitURL<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes extends never ? InitURLOrURLObject : InferAllMainRouteKeys<TBaseSchemaRoutes, TSchemaConfig>;
399
- type GetCurrentRouteSchemaKey<TSchemaConfig extends CallApiSchemaConfig, TPath> = TPath extends URL ? string : TSchemaConfig["prefix"] extends string ? TPath extends (`${AtSymbol}${infer TMethod extends RouteKeyMethods}/${RemoveLeadingSlash<TSchemaConfig["prefix"]>}${infer TCurrentRoute}`) ? `${AtSymbol}${TMethod}/${RemoveLeadingSlash<TCurrentRoute>}` : TPath extends `${TSchemaConfig["prefix"]}${infer TCurrentRoute}` ? TCurrentRoute : string : TSchemaConfig["baseURL"] extends string ? TPath extends (`${AtSymbol}${infer TMethod extends RouteKeyMethods}/${TSchemaConfig["baseURL"]}${infer TCurrentRoute}`) ? `${AtSymbol}${TMethod}/${RemoveLeadingSlash<TCurrentRoute>}` : TPath extends `${TSchemaConfig["baseURL"]}${infer TCurrentRoute}` ? TCurrentRoute : string : TPath;
400
- 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;
401
- type JsonPrimitive = boolean | number | string | null | undefined;
402
- type SerializableObject = Record<PropertyKey, unknown>;
403
- type SerializableArray = Array<JsonPrimitive | SerializableObject> | ReadonlyArray<JsonPrimitive | SerializableObject>;
404
- type Body = UnmaskType<Exclude<RequestInit["body"], undefined> | SerializableArray | SerializableObject>;
405
- type InferBodyOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["body"], {
243
+ //#region src/validation.d.ts
244
+ type ResultVariant = "infer-input" | "infer-output";
245
+ 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<infer TResult> ? Awaited<TResult> : TFallbackResult;
246
+ type InferSchemaOutput<TSchema, TFallbackResult = unknown> = InferSchemaResult<TSchema, TFallbackResult, "infer-output">;
247
+ type InferSchemaInput<TSchema, TFallbackResult = unknown> = InferSchemaResult<TSchema, TFallbackResult, "infer-input">;
248
+ type BooleanObject = { [Key in keyof CallApiSchema]: boolean };
249
+ interface CallApiSchemaConfig {
406
250
  /**
407
- * Body of the request, can be a object or any other supported body type.
251
+ * The base url of the schema. By default it's the baseURL of the callApi instance.
408
252
  */
409
- body?: InferSchemaOutput<TSchema["body"], Body>;
410
- }>;
411
- type MethodUnion = UnmaskType<"CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" | AnyString>;
412
- type ExtractMethodFromURL<TInitURL> = string extends TInitURL ? MethodUnion : TInitURL extends `${AtSymbol}${infer TMethod extends RouteKeyMethods}/${string}` ? Uppercase<TMethod> : MethodUnion;
413
- type InferMethodOption<TSchema extends CallApiSchema, TInitURL extends InitURLOrURLObject> = MakeSchemaOptionRequiredIfDefined<TSchema["method"], {
253
+ baseURL?: "" | AnyString;
414
254
  /**
415
- * HTTP method for the request.
416
- * @default "GET"
255
+ * Disables runtime validation for the schema.
417
256
  */
418
- method?: InferSchemaOutput<TSchema["method"], ExtractMethodFromURL<TInitURL>>;
419
- }>;
420
- type HeadersOption = UnmaskType<Headers | Record<"Authorization", CommonAuthorizationHeaders | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | Array<[string, string]>>;
421
- type InferHeadersOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["headers"], {
257
+ disableRuntimeValidation?: boolean | BooleanObject;
422
258
  /**
423
- * Headers to be used in the request.
259
+ * If `true`, the original input value will be used instead of the transformed/validated output.
260
+ *
261
+ * When true, the original input is returned unchanged after validation, ignoring any schema-level
262
+ * transformations such as type coercion, default values, or field mapping. Only the validation
263
+ * step is executed; the resulting value is discarded in favor of the raw input.
424
264
  */
425
- headers?: InferSchemaOutput<TSchema["headers"], HeadersOption> | ((context: {
426
- baseHeaders: Extract<HeadersOption, Record<string, unknown>>;
427
- }) => InferSchemaOutput<TSchema["headers"], HeadersOption>);
428
- }>;
429
- type InferRequestOptions<TSchema extends CallApiSchema, TInitURL extends InferInitURL<BaseCallApiSchemaRoutes, CallApiSchemaConfig>> = InferBodyOption<TSchema> & InferHeadersOption<TSchema> & InferMethodOption<TSchema, TInitURL>;
430
- type InferMetaOption<TSchema extends CallApiSchema, TCallApiContext extends CallApiContext> = MakeSchemaOptionRequiredIfDefined<TSchema["meta"], {
265
+ disableRuntimeValidationTransform?: boolean | BooleanObject;
431
266
  /**
432
- * - An optional field you can fill with additional information,
433
- * to associate with the request, typically used for logging or tracing.
434
- *
435
- * - A good use case for this, would be to use the info to handle specific cases in any of the shared interceptors.
436
- *
437
- * @example
438
- * ```ts
439
- * const callMainApi = callApi.create({
440
- * baseURL: "https://main-api.com",
441
- * onResponseError: ({ response, options }) => {
442
- * if (options.meta?.userId) {
443
- * console.error(`User ${options.meta.userId} made an error`);
444
- * }
445
- * },
446
- * });
267
+ * Optional url prefix that will be substituted for the `baseURL` of the schemaConfig at runtime.
447
268
  *
448
- * const response = await callMainApi({
449
- * url: "https://example.com/api/data",
450
- * meta: { userId: "123" },
451
- * });
452
- * ```
269
+ * Enables a short, stable prefix for routes while keeping the full `baseURL` centralized in config.
270
+ * Keeps route definitions concise and shields them from changes to the underlying base URL.
453
271
  */
454
- meta?: InferSchemaOutput<TSchema["meta"], TCallApiContext["Meta"]>;
455
- }>;
456
- type InferAuthOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["auth"], {
272
+ prefix?: "" | AnyString;
457
273
  /**
458
- * Automatically add an Authorization header value.
459
- *
460
- * Supports multiple authentication patterns:
461
- * - String: Direct authorization header value
462
- * - Auth object: Structured authentication configuration
463
- *
464
- * @example
465
- * ```ts
466
- * // Bearer auth
467
- * const response = await callMainApi({
468
- * url: "https://example.com/api/data",
469
- * auth: "123456",
470
- * });
471
- *
472
- * // Bearer auth
473
- * const response = await callMainApi({
474
- * url: "https://example.com/api/data",
475
- * auth: {
476
- * type: "Bearer",
477
- * value: "123456",
478
- * },
479
- })
480
- *
481
- * // Token auth
482
- * const response = await callMainApi({
483
- * url: "https://example.com/api/data",
484
- * auth: {
485
- * type: "Token",
486
- * value: "123456",
487
- * },
488
- * });
274
+ * Controls the strictness of API route validation.
489
275
  *
490
- * // Basic auth
491
- * const response = await callMainApi({
492
- * url: "https://example.com/api/data",
493
- * auth: {
494
- * type: "Basic",
495
- * username: "username",
496
- * password: "password",
497
- * },
498
- * });
276
+ * When true:
277
+ * - Only routes explicitly defined in the schema will be considered valid to typescript and the runtime.
278
+ * - Attempting to call routes not defined in the schema will result in both type errors and runtime validation errors.
279
+ * - Useful for ensuring API calls conform exactly to your schema definition
499
280
  *
500
- * ```
281
+ * When false or undefined (default):
282
+ * - All routes will be allowed, whether they are defined in the schema or not
501
283
  */
502
- auth?: InferSchemaOutput<TSchema["auth"], AuthOption>;
503
- }>;
504
- type InferQueryOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["query"], {
284
+ strict?: boolean;
285
+ }
286
+ type CallApiSchemaType<TInput> = StandardSchemaV1<TInput | undefined> | ((value: TInput) => Awaitable<TInput | undefined>);
287
+ interface CallApiSchema {
288
+ auth?: CallApiSchemaType<AuthOption>;
505
289
  /**
506
- * Parameters to be appended to the URL (i.e: /:id)
290
+ * The schema to use for validating the request body.
507
291
  */
508
- query?: InferSchemaOutput<TSchema["query"], Query>;
509
- }>;
510
- type EmptyString = "";
511
- type EmptyTuple = readonly [];
512
- type StringTuple = readonly string[];
513
- type PossibleParamNamePatterns = `${string}:${string}` | `${string}{${string}}${"" | AnyString}`;
514
- type ExtractRouteParamNames<TCurrentRoute, TParamNamesAccumulator extends StringTuple = EmptyTuple> = TCurrentRoute extends PossibleParamNamePatterns ? TCurrentRoute 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 extends `${infer TRoutePrefix}{${infer TCurrentParam}}${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamNamesAccumulator : TParamNamesAccumulator;
515
- type ConvertParamNamesToRecord<TParamNames extends StringTuple> = Prettify<TParamNames extends (readonly [infer TFirstParamName extends string, ...infer TRemainingParamNames extends StringTuple]) ? Record<TFirstParamName, AllowedQueryParamValues> & ConvertParamNamesToRecord<TRemainingParamNames> : NonNullable<unknown>>;
516
- type ConvertParamNamesToTuple<TParamNames extends StringTuple> = TParamNames extends readonly [string, ...infer TRemainingParamNames extends StringTuple] ? [AllowedQueryParamValues, ...ConvertParamNamesToTuple<TRemainingParamNames>] : [];
517
- type InferParamsFromRoute<TCurrentRoute> = ExtractRouteParamNames<TCurrentRoute> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute>> : Params;
518
- 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>;
519
- type InferParamsOption<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema["params"], TBaseSchemaRoutes, TCurrentRouteSchemaKey, {
292
+ body?: CallApiSchemaType<Body>;
520
293
  /**
521
- * Parameters to be appended to the URL (i.e: /:id)
294
+ * The schema to use for validating the response data.
522
295
  */
523
- params?: InferSchemaOutput<TSchema["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
524
- }>;
525
- type InferExtraOptions<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TCallApiContext extends CallApiContext> = InferAuthOption<TSchema> & InferMetaOption<TSchema, TCallApiContext> & InferParamsOption<TSchema, TBaseSchemaRoutes, TCurrentRouteSchemaKey> & InferQueryOption<TSchema>;
526
- type ResultModeOption<TErrorData, TResultMode extends ResultModeType> = TErrorData extends false ? {
527
- resultMode: "onlyData";
528
- } : TErrorData extends false | undefined ? {
529
- resultMode?: "onlyData";
530
- } : {
531
- resultMode?: TResultMode;
296
+ data?: CallApiSchemaType<unknown>;
297
+ /**
298
+ * The schema to use for validating the response error data.
299
+ */
300
+ errorData?: CallApiSchemaType<unknown>;
301
+ /**
302
+ * The schema to use for validating the request headers.
303
+ */
304
+ headers?: CallApiSchemaType<HeadersOption>;
305
+ /**
306
+ * The schema to use for validating the meta option.
307
+ */
308
+ meta?: CallApiSchemaType<GlobalMeta>;
309
+ /**
310
+ * The schema to use for validating the request method.
311
+ */
312
+ method?: CallApiSchemaType<MethodUnion>;
313
+ /**
314
+ * The schema to use for validating the request url parameters.
315
+ */
316
+ params?: CallApiSchemaType<Params>;
317
+ /**
318
+ * The schema to use for validating the request url queries.
319
+ */
320
+ query?: CallApiSchemaType<Query>;
321
+ }
322
+ declare const routeKeyMethods: readonly ["delete", "get", "patch", "post", "put"];
323
+ type RouteKeyMethods = (typeof routeKeyMethods)[number];
324
+ type RouteKeyMethodsURLUnion = `${AtSymbol}${RouteKeyMethods}/`;
325
+ type BaseSchemaRouteKeyPrefixes = FallBackRouteSchemaKey | RouteKeyMethodsURLUnion;
326
+ type BaseCallApiSchemaRoutes = Partial<Record<AnyString | BaseSchemaRouteKeyPrefixes, CallApiSchema>>;
327
+ type BaseCallApiSchemaAndConfig = {
328
+ config?: CallApiSchemaConfig;
329
+ routes: BaseCallApiSchemaRoutes;
532
330
  };
533
- type ThrowOnErrorBoolean = boolean;
534
- type ThrowOnErrorType<TErrorData, TThrowOnError extends ThrowOnErrorBoolean> = TThrowOnError | ((context: ErrorContext<{
535
- ErrorData: TErrorData;
536
- }>) => TThrowOnError);
537
- type ThrowOnErrorOption<TErrorData, TThrowOnError extends ThrowOnErrorBoolean> = TErrorData extends false ? {
538
- throwOnError: true;
539
- } : TErrorData extends false | undefined ? {
540
- throwOnError?: true;
541
- } : {
542
- throwOnError?: ThrowOnErrorType<TErrorData, TThrowOnError>;
331
+ type GetResolvedSchemaContext = {
332
+ baseExtraOptions: BaseCallApiExtraOptions;
333
+ currentRouteSchemaKey: string;
334
+ extraOptions: CallApiExtraOptions;
335
+ };
336
+ declare const getCurrentRouteSchemaKeyAndMainInitURL: (context: Pick<GetResolvedSchemaContext, "baseExtraOptions" | "extraOptions"> & {
337
+ initURL: string;
338
+ }) => {
339
+ currentRouteSchemaKey: string;
340
+ initURL: string;
341
+ mainInitURL: string;
342
+ };
343
+ //#endregion
344
+ //#region src/utils/external/body.d.ts
345
+ type BodyType = NonNullable<CallApiRequestOptions["body"]>;
346
+ declare const toSearchParams: <TSchema extends CallApiSchemaType<BodyType>>(data: InferSchemaOutput<TSchema>, schema?: TSchema) => URLSearchParams;
347
+ declare const toQueryString: <TSchema extends CallApiSchemaType<BodyType>>(...parameters: Parameters<typeof toSearchParams<TSchema>>) => string;
348
+ /**
349
+ * @description Converts a plain object to FormData.
350
+ *
351
+ * Handles various data types:
352
+ * - **Primitives** (string, number, boolean): Converted to strings
353
+ * - **Blobs/Files**: Added directly to FormData
354
+ * - **Arrays**: Each item is appended (allows multiple values for same key)
355
+ * - **Objects**: JSON stringified before adding to FormData
356
+ *
357
+ * @example
358
+ * ```ts
359
+ * // Basic usage
360
+ * const formData = toFormData({
361
+ * name: "John",
362
+ * age: 30,
363
+ * active: true
364
+ * });
365
+ *
366
+ * // With arrays
367
+ * const formData = toFormData({
368
+ * tags: ["javascript", "typescript"],
369
+ * name: "John"
370
+ * });
371
+ *
372
+ * // With files
373
+ * const formData = toFormData({
374
+ * avatar: fileBlob,
375
+ * name: "John"
376
+ * });
377
+ *
378
+ * // With nested objects (one level only)
379
+ * const formData = toFormData({
380
+ * user: { name: "John", age: 30 },
381
+ * settings: { theme: "dark" }
382
+ * });
383
+ */
384
+ declare const toFormData: <TSchema extends CallApiSchemaType<BodyType>>(data: InferSchemaOutput<TSchema>, schema?: TSchema) => FormData;
385
+ //#endregion
386
+ //#region src/utils/external/define.d.ts
387
+ declare const defineSchema: <const TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, const TSchemaConfig extends CallApiSchemaConfig>(routes: TBaseSchemaRoutes, config?: Satisfies<TSchemaConfig, CallApiSchemaConfig>) => {
388
+ config: Writeable<Satisfies<TSchemaConfig, CallApiSchemaConfig>, "deep">;
389
+ routes: Writeable<TBaseSchemaRoutes, "deep">;
390
+ };
391
+ declare const defineSchemaRoutes: <const TSchemaRoutes extends BaseCallApiSchemaRoutes>(routes: TSchemaRoutes) => Writeable<typeof routes, "deep">;
392
+ declare const defineMainSchema: <const TSchema extends CallApiSchema>(mainSchema: Satisfies<TSchema, CallApiSchema>) => Writeable<typeof mainSchema, "deep">;
393
+ declare const defineSchemaConfig: <const TSchemaConfig extends CallApiSchemaConfig>(config: Satisfies<TSchemaConfig, CallApiSchemaConfig>) => Writeable<typeof config, "deep">;
394
+ declare const definePlugin: <const TPlugin extends CallApiPlugin>(plugin: TPlugin) => Writeable<typeof plugin, "deep">;
395
+ type BaseConfigObject = Exclude<BaseCallApiConfig, AnyFunction>;
396
+ type BaseConfigFn = Extract<BaseCallApiConfig, AnyFunction>;
397
+ type DefineBaseConfig = {
398
+ <const TBaseConfig extends BaseConfigObject>(baseConfig: Satisfies<TBaseConfig, BaseConfigObject>): Writeable<typeof baseConfig, "deep">;
399
+ <const TBaseConfig extends BaseConfigObject>(baseConfig: (...parameters: Parameters<BaseConfigFn>) => Writeable<TBaseConfig, "deep">): typeof baseConfig;
543
400
  };
401
+ declare const defineBaseConfig: DefineBaseConfig;
402
+ declare const defineInstanceConfig: <const TInstanceConfig extends CallApiConfig>(config: TInstanceConfig) => Writeable<typeof config, "deep">;
403
+ //#endregion
404
+ //#region src/utils/external/error.d.ts
405
+ type HTTPErrorDetails<TErrorData> = Pick<CallApiExtraOptions, "defaultHTTPErrorMessage"> & {
406
+ errorData: TErrorData;
407
+ response: Response;
408
+ };
409
+ declare class HTTPError<TErrorData = Record<string, unknown>> extends Error {
410
+ errorData: HTTPErrorDetails<TErrorData>["errorData"];
411
+ readonly httpErrorSymbol: symbol;
412
+ name: "HTTPError";
413
+ response: HTTPErrorDetails<TErrorData>["response"];
414
+ constructor(errorDetails: HTTPErrorDetails<TErrorData>, errorOptions?: ErrorOptions);
415
+ /**
416
+ * @description Checks if the given error is an instance of HTTPError
417
+ * @param error - The error to check
418
+ * @returns true if the error is an instance of HTTPError, false otherwise
419
+ */
420
+ static isError<TErrorData>(error: unknown): error is HTTPError<TErrorData>;
421
+ }
422
+ type SafeExtract<TUnion, TKey extends TUnion> = Extract<TUnion, TKey>;
423
+ type ValidationErrorDetails = {
424
+ /**
425
+ * The cause of the validation error.
426
+ *
427
+ * 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.
428
+ */
429
+ issueCause: "toFormData" | "toQueryString" | "unknown" | `schemaConfig-(${SafeExtract<keyof CallApiSchemaConfig, "strict">})` | keyof CallApiSchema;
430
+ /**
431
+ * The issues that caused the validation error.
432
+ */
433
+ issues: readonly StandardSchemaV1.Issue[];
434
+ /**
435
+ * The response from server, if any.
436
+ */
437
+ response: Response | null;
438
+ };
439
+ declare class ValidationError extends Error {
440
+ errorData: ValidationErrorDetails["issues"];
441
+ issueCause: ValidationErrorDetails["issueCause"];
442
+ name: "ValidationError";
443
+ response: ValidationErrorDetails["response"];
444
+ readonly validationErrorSymbol: symbol;
445
+ constructor(details: ValidationErrorDetails, errorOptions?: ErrorOptions);
446
+ /**
447
+ * @description Checks if the given error is an instance of ValidationError
448
+ * @param error - The error to check
449
+ * @returns true if the error is an instance of ValidationError, false otherwise
450
+ */
451
+ static isError(error: unknown): error is ValidationError;
452
+ }
453
+ //#endregion
454
+ //#region src/utils/external/guards.d.ts
455
+ declare const isHTTPError: <TErrorData>(error: CallApiResultErrorVariant<TErrorData>["error"] | null) => error is PossibleHTTPError<TErrorData>;
456
+ declare const isHTTPErrorInstance: <TErrorData>(error: unknown) => error is HTTPError<TErrorData>;
457
+ declare const isValidationError: (error: CallApiResultErrorVariant<unknown>["error"] | null) => error is PossibleValidationError;
458
+ declare const isValidationErrorInstance: (error: unknown) => error is ValidationError;
459
+ declare const isJavascriptError: (error: CallApiResultErrorVariant<unknown>["error"] | null) => error is PossibleJavaScriptError;
460
+ //#endregion
461
+ //#region src/utils/external/headers.d.ts
462
+ declare const objectifyHeaders: (headers: CallApiRequestOptions["headers"]) => Record<string, string>;
544
463
  //#endregion
545
464
  //#region src/retry.d.ts
546
465
  declare const defaultRetryStatusCodesLookup: () => Readonly<{
@@ -557,9 +476,10 @@ type RetryStatusCodes = UnmaskType<AnyNumber | keyof ReturnType<typeof defaultRe
557
476
  type RetryCondition<TErrorData> = (context: ErrorContext<{
558
477
  ErrorData: TErrorData;
559
478
  }>) => Awaitable<boolean>;
479
+ type CallApiLooseImpl = (initURL: InitURLOrURLObject, init?: CallApiConfig) => Promise<CallApiResultLoose<unknown, unknown>>;
560
480
  interface RetryOptions<TErrorData> {
561
481
  /**
562
- * Keeps track of the number of times the request has already been retried internally
482
+ * Tracks the number of times the request has already been retried internally
563
483
  * @internal
564
484
  * @deprecated **WARNING**: This property is used internally to track retries. Please abstain from reading or modifying it.
565
485
  */
@@ -598,41 +518,37 @@ interface RetryOptions<TErrorData> {
598
518
  */
599
519
  retryStrategy?: "exponential" | "linear";
600
520
  }
521
+ type RetryManagerContext = {
522
+ callApi: CallApiLooseImpl;
523
+ callApiArgs: {
524
+ config: CallApiConfig;
525
+ initURL: InitURLOrURLObject;
526
+ };
527
+ error: unknown;
528
+ errorContext: ErrorContext;
529
+ hookInfo: ExecuteHookInfo;
530
+ removeDedupeCacheEntry: () => void;
531
+ };
601
532
  //#endregion
602
533
  //#region src/refetch.d.ts
534
+ declare const shouldAttemptRefetchSymbol: unique symbol;
603
535
  interface RefetchOptions {
604
536
  /**
605
- * Tracks the number of times the request has been refetched internally
537
+ * Tracks if the refetching of the request should be attempted
606
538
  * @internal
607
- * @deprecated **WARNING**: This property is used internally to track refetch calls. Please abstain from reading or modifying it.
608
- */
609
- readonly ["~refetchCount"]?: number;
610
- /**
611
- * Maximum number of times refetch can be called from error hooks.
612
- *
613
- * Prevents infinite loops when refetch is called repeatedly in error hooks.
614
- * When the limit is reached, refetch will throw an error instead of retrying.
615
- *
616
- * @default 1
617
- *
618
- * @example
619
- * ```ts
620
- * // Allow up to 5 refetch attempts
621
- * refetchAttempts: 5
622
- *
623
- * // Disable refetch limit
624
- * refetchAttempts: Infinity
625
- *
626
- * // Strict limit of 1 refetch
627
- * refetchAttempts: 1
628
- * ```
539
+ * @deprecated **WARNING**: This property is used internally to track retries. Please abstain from reading or modifying it.
629
540
  */
630
- refetchAttempts?: number;
541
+ [shouldAttemptRefetchSymbol]?: boolean;
631
542
  }
632
- type RefetchFn = (overrides?: Pick<RefetchOptions, "refetchAttempts">) => Promise<CallApiResultLoose<unknown, unknown> | null>;
633
- interface RefetchFnOption {
543
+ type RefetchFn = () => void;
544
+ type RefetchManagerResult = {
545
+ handleRefetch: () => Promise<CallApiResultLoose<unknown, unknown>> | null;
634
546
  refetch: RefetchFn;
635
- }
547
+ };
548
+ declare const createRefetchManager: (ctx: Pick<RetryManagerContext, "callApi" | "callApiArgs" | "removeDedupeCacheEntry"> & {
549
+ options: CallApiExtraOptions;
550
+ }) => RefetchManagerResult;
551
+ type RefetchFnOption = Pick<ReturnType<typeof createRefetchManager>, "refetch">;
636
552
  //#endregion
637
553
  //#region src/stream.d.ts
638
554
  type StreamProgressEvent = {
@@ -660,7 +576,7 @@ type StreamProgressEvent = {
660
576
  type CallApiRequestOptionsForHooks = Omit<CallApiRequestOptions, "headers"> & {
661
577
  headers: Partial<Record<"Authorization" | "Content-Type" | CommonRequestHeaders, string>>;
662
578
  };
663
- type CallApiExtraOptionsForHooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> = Hooks & Omit<CallApiExtraOptions<TCallApiContext>, keyof Hooks> & RefetchFnOption;
579
+ type CallApiExtraOptionsForHooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> = Hooks & Omit<CallApiExtraOptions<TCallApiContext>, keyof Hooks> & Pick<RefetchFnOption, "refetch">;
664
580
  interface Hooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> {
665
581
  /**
666
582
  * Hook called when any error occurs within the request/response lifecycle.
@@ -856,6 +772,10 @@ type ResponseErrorContext<TCallApiContext extends Pick<CallApiContext, "ErrorDat
856
772
  type RetryContext<TCallApiContext extends Pick<CallApiContext, "ErrorData" | "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = ErrorContext<TCallApiContext> & {
857
773
  retryAttemptCount: number;
858
774
  };
775
+ type ExecuteHookInfo = {
776
+ errorInfoOptions: ErrorInfoOptions;
777
+ shouldThrowOnError: boolean | undefined;
778
+ };
859
779
  //#endregion
860
780
  //#region src/dedupe.d.ts
861
781
  type DedupeStrategyUnion = UnmaskType<"cancel" | "defer" | "none">;
@@ -1115,57 +1035,7 @@ interface Middlewares<TCallApiContext extends NoInfer<CallApiContext> = DefaultC
1115
1035
  fetchMiddleware?: (context: FetchMiddlewareContext<TCallApiContext>) => FetchImpl;
1116
1036
  }
1117
1037
  //#endregion
1118
- //#region src/utils/external/error.d.ts
1119
- type HTTPErrorDetails<TErrorData> = Pick<CallApiExtraOptions, "defaultHTTPErrorMessage"> & {
1120
- errorData: TErrorData;
1121
- response: Response;
1122
- };
1123
- declare class HTTPError<TErrorData = Record<string, unknown>> extends Error {
1124
- errorData: HTTPErrorDetails<TErrorData>["errorData"];
1125
- readonly httpErrorSymbol: symbol;
1126
- name: "HTTPError";
1127
- response: HTTPErrorDetails<TErrorData>["response"];
1128
- constructor(errorDetails: HTTPErrorDetails<TErrorData>, errorOptions?: ErrorOptions);
1129
- /**
1130
- * @description Checks if the given error is an instance of HTTPError
1131
- * @param error - The error to check
1132
- * @returns true if the error is an instance of HTTPError, false otherwise
1133
- */
1134
- static isError<TErrorData>(error: unknown): error is HTTPError<TErrorData>;
1135
- }
1136
- type SafeExtract<TUnion, TKey extends TUnion> = Extract<TUnion, TKey>;
1137
- type ValidationErrorDetails = {
1138
- /**
1139
- * The cause of the validation error.
1140
- *
1141
- * 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.
1142
- */
1143
- issueCause: "toFormData" | "toQueryString" | "unknown" | `schemaConfig-(${SafeExtract<keyof CallApiSchemaConfig, "strict">})` | keyof CallApiSchema;
1144
- /**
1145
- * The issues that caused the validation error.
1146
- */
1147
- issues: readonly StandardSchemaV1.Issue[];
1148
- /**
1149
- * The response from server, if any.
1150
- */
1151
- response: Response | null;
1152
- };
1153
- declare class ValidationError extends Error {
1154
- errorData: ValidationErrorDetails["issues"];
1155
- issueCause: ValidationErrorDetails["issueCause"];
1156
- name: "ValidationError";
1157
- response: ValidationErrorDetails["response"];
1158
- readonly validationErrorSymbol: symbol;
1159
- constructor(details: ValidationErrorDetails, errorOptions?: ErrorOptions);
1160
- /**
1161
- * @description Checks if the given error is an instance of ValidationError
1162
- * @param error - The error to check
1163
- * @returns true if the error is an instance of ValidationError, false otherwise
1164
- */
1165
- static isError(error: unknown): error is ValidationError;
1166
- }
1167
- //#endregion
1168
- //#region src/types/common.d.ts
1038
+ //#region src/types/options-types.d.ts
1169
1039
  interface Register {}
1170
1040
  type GlobalMeta = Register extends {
1171
1041
  meta?: infer TMeta extends DefaultMetaObject;
@@ -1300,6 +1170,12 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
1300
1170
  * ```
1301
1171
  */
1302
1172
  customFetchImpl?: FetchImpl;
1173
+ /**
1174
+ * Enable debug mode for the request.
1175
+ *
1176
+ * @default true
1177
+ */
1178
+ debugMode?: boolean;
1303
1179
  /**
1304
1180
  * Default HTTP error message when server doesn't provide one.
1305
1181
  *
@@ -1688,6 +1564,203 @@ type CallApiParameters<TData = DefaultDataType, TErrorData = DefaultDataType, TR
1688
1564
  type CallApiResult<TData, TErrorData, TResultMode extends ResultModeType, TThrowOnError extends ThrowOnErrorBoolean> = InferCallApiResult<TData, TErrorData, TResultMode, TThrowOnError>;
1689
1565
  type CallApiResultLoose<TData, TErrorData, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorBoolean = ThrowOnErrorBoolean> = InferCallApiResult<TData, TErrorData, TResultMode, TThrowOnError>;
1690
1566
  //#endregion
1567
+ //#region src/auth.d.ts
1568
+ type PossibleAuthValue = Awaitable<string | null | undefined>;
1569
+ type PossibleAuthValueOrGetter = PossibleAuthValue | (() => PossibleAuthValue);
1570
+ type BearerAuth = {
1571
+ type: "Bearer";
1572
+ value: PossibleAuthValueOrGetter;
1573
+ };
1574
+ type TokenAuth = {
1575
+ type: "Token";
1576
+ value: PossibleAuthValueOrGetter;
1577
+ };
1578
+ type BasicAuth = {
1579
+ type: "Basic";
1580
+ username: PossibleAuthValueOrGetter;
1581
+ password: PossibleAuthValueOrGetter;
1582
+ };
1583
+ /**
1584
+ * Custom auth
1585
+ *
1586
+ * @param prefix - prefix of the header
1587
+ * @param authValue - value of the header
1588
+ *
1589
+ * @example
1590
+ * ```ts
1591
+ * {
1592
+ * type: "Custom",
1593
+ * prefix: "Token",
1594
+ * authValue: "token"
1595
+ * }
1596
+ * ```
1597
+ */
1598
+ type CustomAuth = {
1599
+ type: "Custom";
1600
+ prefix: PossibleAuthValueOrGetter;
1601
+ value: PossibleAuthValueOrGetter;
1602
+ };
1603
+ type AuthOption = PossibleAuthValueOrGetter | BearerAuth | TokenAuth | BasicAuth | CustomAuth;
1604
+ //#endregion
1605
+ //#region src/types/conditional-types.d.ts
1606
+ /**
1607
+ * @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
1608
+ */
1609
+ type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaOutput<TSchemaOption, undefined> ? TObject : Required<TObject>;
1610
+ type MergeBaseWithRouteKey<TBaseURLOrPrefix extends string | undefined, TRouteKey extends string> = TBaseURLOrPrefix extends string ? TRouteKey extends `${AtSymbol}${infer TMethod extends RouteKeyMethods}/${infer TRestOfRoutKey}` ? `${AtSymbol}${TMethod}/${RemoveLeadingSlash<RemoveTrailingSlash<TBaseURLOrPrefix>>}/${RemoveLeadingSlash<TRestOfRoutKey>}` : `${TBaseURLOrPrefix}${TRouteKey}` : TRouteKey;
1611
+ type ApplyURLBasedConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["prefix"] extends string ? MergeBaseWithRouteKey<TSchemaConfig["prefix"], TSchemaRouteKeys> : TSchemaConfig["baseURL"] extends string ? MergeBaseWithRouteKey<TSchemaConfig["baseURL"], TSchemaRouteKeys> : TSchemaRouteKeys;
1612
+ type ApplyStrictConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["strict"] extends true ? TSchemaRouteKeys : // eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
1613
+ TSchemaRouteKeys | Exclude<InitURLOrURLObject, RouteKeyMethodsURLUnion>;
1614
+ type ApplySchemaConfiguration<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, TSchemaRouteKeys>>;
1615
+ type InferAllMainRoutes<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes> = Omit<TBaseSchemaRoutes, FallBackRouteSchemaKey>;
1616
+ type InferAllMainRouteKeys<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = ApplySchemaConfiguration<TSchemaConfig, Extract<keyof InferAllMainRoutes<TBaseSchemaRoutes>, string>>;
1617
+ type InferInitURL<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes extends never ? InitURLOrURLObject : InferAllMainRouteKeys<TBaseSchemaRoutes, TSchemaConfig>;
1618
+ type GetCurrentRouteSchemaKey<TSchemaConfig extends CallApiSchemaConfig, TPath> = TPath extends URL ? string : TSchemaConfig["prefix"] extends string ? TPath extends (`${AtSymbol}${infer TMethod extends RouteKeyMethods}/${RemoveLeadingSlash<TSchemaConfig["prefix"]>}${infer TCurrentRoute}`) ? `${AtSymbol}${TMethod}/${RemoveLeadingSlash<TCurrentRoute>}` : TPath extends `${TSchemaConfig["prefix"]}${infer TCurrentRoute}` ? TCurrentRoute : string : TSchemaConfig["baseURL"] extends string ? TPath extends (`${AtSymbol}${infer TMethod extends RouteKeyMethods}/${TSchemaConfig["baseURL"]}${infer TCurrentRoute}`) ? `${AtSymbol}${TMethod}/${RemoveLeadingSlash<TCurrentRoute>}` : TPath extends `${TSchemaConfig["baseURL"]}${infer TCurrentRoute}` ? TCurrentRoute : string : TPath;
1619
+ 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;
1620
+ type JsonPrimitive = boolean | number | string | null | undefined;
1621
+ type SerializableObject = Record<PropertyKey, unknown>;
1622
+ type SerializableArray = Array<JsonPrimitive | SerializableObject> | ReadonlyArray<JsonPrimitive | SerializableObject>;
1623
+ type Body = UnmaskType<Exclude<RequestInit["body"], undefined> | SerializableArray | SerializableObject>;
1624
+ type InferBodyOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["body"], {
1625
+ /**
1626
+ * Body of the request, can be a object or any other supported body type.
1627
+ */
1628
+ body?: InferSchemaOutput<TSchema["body"], Body>;
1629
+ }>;
1630
+ type MethodUnion = UnmaskType<"CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" | AnyString>;
1631
+ type ExtractMethodFromURL<TInitURL> = string extends TInitURL ? MethodUnion : TInitURL extends `${AtSymbol}${infer TMethod extends RouteKeyMethods}/${string}` ? Uppercase<TMethod> : MethodUnion;
1632
+ type InferMethodOption<TSchema extends CallApiSchema, TInitURL extends InitURLOrURLObject> = MakeSchemaOptionRequiredIfDefined<TSchema["method"], {
1633
+ /**
1634
+ * HTTP method for the request.
1635
+ * @default "GET"
1636
+ */
1637
+ method?: InferSchemaOutput<TSchema["method"], ExtractMethodFromURL<TInitURL>>;
1638
+ }>;
1639
+ type HeadersOption = UnmaskType<Headers | Record<"Authorization", CommonAuthorizationHeaders | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | Array<[string, string]>>;
1640
+ type InferHeadersOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["headers"], {
1641
+ /**
1642
+ * Headers to be used in the request.
1643
+ */
1644
+ headers?: InferSchemaOutput<TSchema["headers"], HeadersOption> | ((context: {
1645
+ baseHeaders: Extract<HeadersOption, Record<string, unknown>>;
1646
+ }) => InferSchemaOutput<TSchema["headers"], HeadersOption>);
1647
+ }>;
1648
+ type InferRequestOptions<TSchema extends CallApiSchema, TInitURL extends InferInitURL<BaseCallApiSchemaRoutes, CallApiSchemaConfig>> = InferBodyOption<TSchema> & InferHeadersOption<TSchema> & InferMethodOption<TSchema, TInitURL>;
1649
+ type InferMetaOption<TSchema extends CallApiSchema, TCallApiContext extends CallApiContext> = MakeSchemaOptionRequiredIfDefined<TSchema["meta"], {
1650
+ /**
1651
+ * - An optional field you can fill with additional information,
1652
+ * to associate with the request, typically used for logging or tracing.
1653
+ *
1654
+ * - A good use case for this, would be to use the info to handle specific cases in any of the shared interceptors.
1655
+ *
1656
+ * @example
1657
+ * ```ts
1658
+ * const callMainApi = callApi.create({
1659
+ * baseURL: "https://main-api.com",
1660
+ * onResponseError: ({ response, options }) => {
1661
+ * if (options.meta?.userId) {
1662
+ * console.error(`User ${options.meta.userId} made an error`);
1663
+ * }
1664
+ * },
1665
+ * });
1666
+ *
1667
+ * const response = await callMainApi({
1668
+ * url: "https://example.com/api/data",
1669
+ * meta: { userId: "123" },
1670
+ * });
1671
+ * ```
1672
+ */
1673
+ meta?: InferSchemaOutput<TSchema["meta"], TCallApiContext["Meta"]>;
1674
+ }>;
1675
+ type InferAuthOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["auth"], {
1676
+ /**
1677
+ * Automatically add an Authorization header value.
1678
+ *
1679
+ * Supports multiple authentication patterns:
1680
+ * - String: Direct authorization header value
1681
+ * - Auth object: Structured authentication configuration
1682
+ *
1683
+ * @example
1684
+ * ```ts
1685
+ * // Bearer auth
1686
+ * const response = await callMainApi({
1687
+ * url: "https://example.com/api/data",
1688
+ * auth: "123456",
1689
+ * });
1690
+ *
1691
+ * // Bearer auth
1692
+ * const response = await callMainApi({
1693
+ * url: "https://example.com/api/data",
1694
+ * auth: {
1695
+ * type: "Bearer",
1696
+ * value: "123456",
1697
+ * },
1698
+ })
1699
+ *
1700
+ * // Token auth
1701
+ * const response = await callMainApi({
1702
+ * url: "https://example.com/api/data",
1703
+ * auth: {
1704
+ * type: "Token",
1705
+ * value: "123456",
1706
+ * },
1707
+ * });
1708
+ *
1709
+ * // Basic auth
1710
+ * const response = await callMainApi({
1711
+ * url: "https://example.com/api/data",
1712
+ * auth: {
1713
+ * type: "Basic",
1714
+ * username: "username",
1715
+ * password: "password",
1716
+ * },
1717
+ * });
1718
+ *
1719
+ * ```
1720
+ */
1721
+ auth?: InferSchemaOutput<TSchema["auth"], AuthOption>;
1722
+ }>;
1723
+ type InferQueryOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["query"], {
1724
+ /**
1725
+ * Parameters to be appended to the URL (i.e: /:id)
1726
+ */
1727
+ query?: InferSchemaOutput<TSchema["query"], Query>;
1728
+ }>;
1729
+ type EmptyString = "";
1730
+ type EmptyTuple = readonly [];
1731
+ type StringTuple = readonly string[];
1732
+ type PossibleParamNamePatterns = `${string}:${string}` | `${string}{${string}}${"" | AnyString}`;
1733
+ type ExtractRouteParamNames<TCurrentRoute, TParamNamesAccumulator extends StringTuple = EmptyTuple> = TCurrentRoute extends PossibleParamNamePatterns ? TCurrentRoute 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 extends `${infer TRoutePrefix}{${infer TCurrentParam}}${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamNamesAccumulator : TParamNamesAccumulator;
1734
+ type ConvertParamNamesToRecord<TParamNames extends StringTuple> = Prettify<TParamNames extends (readonly [infer TFirstParamName extends string, ...infer TRemainingParamNames extends StringTuple]) ? Record<TFirstParamName, AllowedQueryParamValues> & ConvertParamNamesToRecord<TRemainingParamNames> : NonNullable<unknown>>;
1735
+ type ConvertParamNamesToTuple<TParamNames extends StringTuple> = TParamNames extends readonly [string, ...infer TRemainingParamNames extends StringTuple] ? [AllowedQueryParamValues, ...ConvertParamNamesToTuple<TRemainingParamNames>] : [];
1736
+ type InferParamsFromRoute<TCurrentRoute> = ExtractRouteParamNames<TCurrentRoute> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute>> : Params;
1737
+ 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>;
1738
+ type InferParamsOption<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema["params"], TBaseSchemaRoutes, TCurrentRouteSchemaKey, {
1739
+ /**
1740
+ * Parameters to be appended to the URL (i.e: /:id)
1741
+ */
1742
+ params?: InferSchemaOutput<TSchema["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
1743
+ }>;
1744
+ type InferExtraOptions<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TCallApiContext extends CallApiContext> = InferAuthOption<TSchema> & InferMetaOption<TSchema, TCallApiContext> & InferParamsOption<TSchema, TBaseSchemaRoutes, TCurrentRouteSchemaKey> & InferQueryOption<TSchema>;
1745
+ type ResultModeOption<TErrorData, TResultMode extends ResultModeType> = TErrorData extends false ? {
1746
+ resultMode: "onlyData";
1747
+ } : TErrorData extends false | undefined ? {
1748
+ resultMode?: "onlyData";
1749
+ } : {
1750
+ resultMode?: TResultMode;
1751
+ };
1752
+ type ThrowOnErrorBoolean = boolean;
1753
+ type ThrowOnErrorType<TErrorData, TThrowOnError extends ThrowOnErrorBoolean> = TThrowOnError | ((context: ErrorContext<{
1754
+ ErrorData: TErrorData;
1755
+ }>) => TThrowOnError);
1756
+ type ThrowOnErrorOption<TErrorData, TThrowOnError extends ThrowOnErrorBoolean> = TErrorData extends false ? {
1757
+ throwOnError: true;
1758
+ } : TErrorData extends false | undefined ? {
1759
+ throwOnError?: true;
1760
+ } : {
1761
+ throwOnError?: ThrowOnErrorType<TErrorData, TThrowOnError>;
1762
+ };
1763
+ //#endregion
1691
1764
  //#region src/result.d.ts
1692
1765
  type ResponseParser<TData> = (text: string) => Awaitable<TData>;
1693
1766
  declare const getResponseType: <TData>(response: Response, responseParser: ResponseParser<TData>) => {
@@ -1754,6 +1827,9 @@ type ResultModePlaceholder = null;
1754
1827
  type ResultModeUnion = keyof ResultModeMap;
1755
1828
  type ResultModeType = ResultModePlaceholder | ResultModeUnion;
1756
1829
  type InferCallApiResult<TData, TErrorData, TResultMode extends ResultModeType, TThrowOnError extends ThrowOnErrorBoolean, TComputedResultModeMapWithException extends ResultModeMap<TData, TErrorData, true> = ResultModeMap<TData, TErrorData, true>, TComputedResultModeMapWithoutException extends ResultModeMap<TData, TErrorData, TThrowOnError> = ResultModeMap<TData, TErrorData, TThrowOnError>> = TErrorData extends false ? TComputedResultModeMapWithException["onlyData"] : TErrorData extends false | undefined ? TComputedResultModeMapWithException["onlyData"] : ResultModePlaceholder extends TResultMode ? TComputedResultModeMapWithoutException["all"] : TResultMode extends ResultModeUnion ? TComputedResultModeMapWithoutException[TResultMode] : never;
1830
+ type ErrorInfoOptions = Pick<CallApiExtraOptions, "cloneResponse" | "resultMode"> & {
1831
+ message?: string;
1832
+ };
1757
1833
  //#endregion
1758
1834
  //#region src/plugins.d.ts
1759
1835
  type PluginSetupContext<TCallApiContext extends CallApiContext = DefaultCallApiContext> = RequestContext<TCallApiContext> & ReturnType<typeof getCurrentRouteSchemaKeyAndMainInitURL>;
@@ -1819,5 +1895,5 @@ type DefaultCallApiContext = Prettify<OverrideCallApiContext<Required<CallApiCon
1819
1895
  Meta: GlobalMeta;
1820
1896
  }>>;
1821
1897
  //#endregion
1822
- export { RetryOptions as $, GetCallApiContext as A, DedupeOptions as B, CallApiExtraOptions as C, DistributiveOmit as Ct, CallApiResultLoose as D, fetchSpecificKeys as Dt, CallApiResult as E, Writeable as Et, HTTPError as F, HooksOrHooksArray as G, CallApiRequestOptionsForHooks as H, ValidationError as I, ResponseContext as J, RequestContext as K, FetchImpl as L, GlobalMeta as M, InstanceContext as N, GetBaseSchemaConfig as O, Register as P, RefetchOptions as Q, FetchMiddlewareContext as R, CallApiContext as S, AnyString as St, CallApiRequestOptions as T, Satisfies as Tt, ErrorContext as U, CallApiExtraOptionsForHooks as V, Hooks as W, ResponseStreamContext as X, ResponseErrorContext as Y, SuccessContext as Z, ResponseTypeType as _, InferSchemaOutput as _t, PluginHooks as a, InferAllMainRoutes as at, BaseCallApiExtraOptions as b, fallBackRouteSchemaKey as bt, CallApiResultErrorVariant as c, ThrowOnErrorBoolean as ct, GetResponseType as d, BaseCallApiSchemaRoutes as dt, ApplyStrictConfig as et, InferCallApiResult as f, BaseSchemaRouteKeyPrefixes as ft, ResponseTypeMap as g, InferSchemaInput as gt, PossibleValidationError as h, CallApiSchemaType as ht, CallApiPlugin as i, InferAllMainRouteKeys as it, GetCallApiContextRequired as j, GetBaseSchemaRoutes as k, CallApiResultSuccessOrErrorVariant as l, URLOptions as lt, PossibleJavaScriptError as m, CallApiSchemaConfig as mt, DefaultDataType as n, GetCurrentRouteSchema as nt, PluginMiddlewares as o, InferInitURL as ot, PossibleHTTPError as p, CallApiSchema as pt, RequestStreamContext as q, DefaultPluginArray as r, GetCurrentRouteSchemaKey as rt, PluginSetupContext as s, InferParamsFromRoute as st, DefaultCallApiContext as t, ApplyURLBasedConfig as tt, CallApiResultSuccessVariant as u, BaseCallApiSchemaAndConfig as ut, ResultModeType as v, InferSchemaResult as vt, CallApiParameters as w, NoInferUnMasked as wt, CallApiConfig as x, AnyFunction as xt, BaseCallApiConfig as y, FallBackRouteSchemaKey as yt, Middlewares as z };
1823
- //# sourceMappingURL=default-types-CswfU2bI.d.ts.map
1898
+ export { RequestContext as $, CallApiConfig as A, InferSchemaInput as At, GetCallApiContextRequired as B, fetchSpecificKeys as Bt, InferAllMainRouteKeys as C, toQueryString as Ct, ThrowOnErrorBoolean as D, BaseSchemaRouteKeyPrefixes as Dt, InferParamsFromRoute as E, BaseCallApiSchemaRoutes as Et, CallApiResult as F, DistributiveOmit as Ft, FetchMiddlewareContext as G, InstanceContext as H, CallApiResultLoose as I, NoInferUnMasked as It, CallApiExtraOptionsForHooks as J, Middlewares as K, GetBaseSchemaConfig as L, Writeable as Lt, CallApiExtraOptions as M, InferSchemaResult as Mt, CallApiParameters as N, URLOptions as Nt, BaseCallApiConfig as O, CallApiSchema as Ot, CallApiRequestOptions as P, AnyString as Pt, HooksOrHooksArray as Q, GetBaseSchemaRoutes as R, FallBackRouteSchemaKey as Rt, GetCurrentRouteSchemaKey as S, toFormData as St, InferInitURL as T, BaseCallApiSchemaAndConfig as Tt, Register as U, GlobalMeta as V, FetchImpl as W, ErrorContext as X, CallApiRequestOptionsForHooks as Y, Hooks as Z, ResponseTypeType as _, defineMainSchema as _t, PluginHooks as a, RefetchOptions as at, ApplyURLBasedConfig as b, defineSchemaConfig as bt, CallApiResultErrorVariant as c, isHTTPError as ct, GetResponseType as d, isValidationError as dt, RequestStreamContext as et, InferCallApiResult as f, isValidationErrorInstance as ft, ResponseTypeMap as g, defineInstanceConfig as gt, PossibleValidationError as h, defineBaseConfig as ht, CallApiPlugin as i, SuccessContext as it, CallApiContext as j, InferSchemaOutput as jt, BaseCallApiExtraOptions as k, CallApiSchemaConfig as kt, CallApiResultSuccessOrErrorVariant as l, isHTTPErrorInstance as lt, PossibleJavaScriptError as m, ValidationError as mt, DefaultDataType as n, ResponseErrorContext as nt, PluginMiddlewares as o, RetryOptions as ot, PossibleHTTPError as p, HTTPError as pt, DedupeOptions as q, DefaultPluginArray as r, ResponseStreamContext as rt, PluginSetupContext as s, objectifyHeaders as st, DefaultCallApiContext as t, ResponseContext as tt, CallApiResultSuccessVariant as u, isJavascriptError as ut, ResultModeType as v, definePlugin as vt, InferAllMainRoutes as w, toSearchParams as wt, GetCurrentRouteSchema as x, defineSchemaRoutes as xt, ApplyStrictConfig as y, defineSchema as yt, GetCallApiContext as z, fallBackRouteSchemaKey as zt };
1899
+ //# sourceMappingURL=default-types-Cn2QRN13.d.ts.map