@zayne-labs/callapi 1.12.6 → 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,51 +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
4
  //#region src/constants/validation.d.ts
41
5
  declare const fallBackRouteSchemaKey = "@default";
42
6
  type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
43
7
  //#endregion
44
8
  //#region src/types/standard-schema.d.ts
45
- /**
46
- * The Standard Schema interface.
47
- * @see https://github.com/standard-schema/standard-schema
48
- */
49
9
  /** The Standard Typed interface. This is a base type extended by other specs. */
50
10
  interface StandardTypedV1<Input = unknown, Output = Input> {
51
11
  /** The Standard properties. */
@@ -115,113 +75,48 @@ declare namespace StandardSchemaV1 {
115
75
  readonly key: PropertyKey;
116
76
  }
117
77
  /** The Standard types interface. */
118
- type Types<Input = unknown, Output = Input> = StandardTypedV1.Types<Input, Output>;
78
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
119
79
  /** Infers the input type of a Standard. */
120
80
  type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
121
81
  /** Infers the output type of a Standard. */
122
82
  type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
123
83
  }
124
84
  //#endregion
125
- //#region src/validation.d.ts
126
- type ResultVariant = "infer-input" | "infer-output";
127
- 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;
128
- type InferSchemaOutput<TSchema, TFallbackResult = unknown> = InferSchemaResult<TSchema, TFallbackResult, "infer-output">;
129
- type InferSchemaInput<TSchema, TFallbackResult = unknown> = InferSchemaResult<TSchema, TFallbackResult, "infer-input">;
130
- type BooleanObject = { [Key in keyof CallApiSchema]: boolean };
131
- interface CallApiSchemaConfig {
132
- /**
133
- * The base url of the schema. By default it's the baseURL of the callApi instance.
134
- */
135
- baseURL?: "" | AnyString;
136
- /**
137
- * Disables runtime validation for the schema.
138
- */
139
- disableRuntimeValidation?: boolean | BooleanObject;
140
- /**
141
- * If `true`, the original input value will be used instead of the transformed/validated output.
142
- *
143
- * When true, the original input is returned unchanged after validation, ignoring any schema-level
144
- * transformations such as type coercion, default values, or field mapping. Only the validation
145
- * step is executed; the resulting value is discarded in favor of the raw input.
146
- */
147
- disableRuntimeValidationTransform?: boolean | BooleanObject;
148
- /**
149
- * Optional url prefix that will be substituted for the `baseURL` of the schemaConfig at runtime.
150
- *
151
- * Enables a short, stable prefix for routes while keeping the full `baseURL` centralized in config.
152
- * Keeps route definitions concise and shields them from changes to the underlying base URL.
153
- */
154
- prefix?: "" | AnyString;
155
- /**
156
- * Controls the strictness of API route validation.
157
- *
158
- * When true:
159
- * - Only routes explicitly defined in the schema will be considered valid to typescript and the runtime.
160
- * - Attempting to call routes not defined in the schema will result in both type errors and runtime validation errors.
161
- * - Useful for ensuring API calls conform exactly to your schema definition
162
- *
163
- * When false or undefined (default):
164
- * - All routes will be allowed, whether they are defined in the schema or not
165
- */
166
- strict?: boolean;
167
- }
168
- type CallApiSchemaType<TInput> = StandardSchemaV1<TInput | undefined> | ((value: TInput) => Awaitable<TInput | undefined>);
169
- interface CallApiSchema {
170
- auth?: CallApiSchemaType<AuthOption>;
171
- /**
172
- * The schema to use for validating the request body.
173
- */
174
- body?: CallApiSchemaType<Body>;
175
- /**
176
- * The schema to use for validating the response data.
177
- */
178
- data?: CallApiSchemaType<unknown>;
179
- /**
180
- * The schema to use for validating the response error data.
181
- */
182
- errorData?: CallApiSchemaType<unknown>;
183
- /**
184
- * The schema to use for validating the request headers.
185
- */
186
- headers?: CallApiSchemaType<HeadersOption>;
187
- /**
188
- * The schema to use for validating the meta option.
189
- */
190
- meta?: CallApiSchemaType<GlobalMeta>;
191
- /**
192
- * The schema to use for validating the request method.
193
- */
194
- method?: CallApiSchemaType<MethodUnion>;
195
- /**
196
- * The schema to use for validating the request url parameters.
197
- */
198
- params?: CallApiSchemaType<Params>;
199
- /**
200
- * The schema to use for validating the request url queries.
201
- */
202
- query?: CallApiSchemaType<Query>;
203
- }
204
- declare const routeKeyMethods: readonly ["delete", "get", "patch", "post", "put"];
205
- type RouteKeyMethods = (typeof routeKeyMethods)[number];
206
- type RouteKeyMethodsURLUnion = `${AtSymbol}${RouteKeyMethods}/`;
207
- type BaseSchemaRouteKeyPrefixes = FallBackRouteSchemaKey | RouteKeyMethodsURLUnion;
208
- type BaseCallApiSchemaRoutes = Partial<Record<AnyString | BaseSchemaRouteKeyPrefixes, CallApiSchema>>;
209
- type BaseCallApiSchemaAndConfig = {
210
- config?: CallApiSchemaConfig;
211
- routes: BaseCallApiSchemaRoutes;
212
- };
213
- type GetResolvedSchemaContext = {
214
- baseExtraOptions: BaseCallApiExtraOptions;
215
- currentRouteSchemaKey: string;
216
- extraOptions: CallApiExtraOptions;
217
- };
218
- declare const getCurrentRouteSchemaKeyAndMainInitURL: (context: Pick<GetResolvedSchemaContext, "baseExtraOptions" | "extraOptions"> & {
219
- initURL: string;
220
- }) => {
221
- currentRouteSchemaKey: string;
222
- initURL: string;
223
- mainInitURL: string;
224
- };
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;
225
120
  //#endregion
226
121
  //#region src/url.d.ts
227
122
  declare const atSymbol = "@";
@@ -345,6 +240,227 @@ interface URLOptions {
345
240
  query?: Query;
346
241
  }
347
242
  //#endregion
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 {
250
+ /**
251
+ * The base url of the schema. By default it's the baseURL of the callApi instance.
252
+ */
253
+ baseURL?: "" | AnyString;
254
+ /**
255
+ * Disables runtime validation for the schema.
256
+ */
257
+ disableRuntimeValidation?: boolean | BooleanObject;
258
+ /**
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.
264
+ */
265
+ disableRuntimeValidationTransform?: boolean | BooleanObject;
266
+ /**
267
+ * Optional url prefix that will be substituted for the `baseURL` of the schemaConfig at runtime.
268
+ *
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.
271
+ */
272
+ prefix?: "" | AnyString;
273
+ /**
274
+ * Controls the strictness of API route validation.
275
+ *
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
280
+ *
281
+ * When false or undefined (default):
282
+ * - All routes will be allowed, whether they are defined in the schema or not
283
+ */
284
+ strict?: boolean;
285
+ }
286
+ type CallApiSchemaType<TInput> = StandardSchemaV1<TInput | undefined> | ((value: TInput) => Awaitable<TInput | undefined>);
287
+ interface CallApiSchema {
288
+ auth?: CallApiSchemaType<AuthOption>;
289
+ /**
290
+ * The schema to use for validating the request body.
291
+ */
292
+ body?: CallApiSchemaType<Body>;
293
+ /**
294
+ * The schema to use for validating the response data.
295
+ */
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;
330
+ };
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;
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>;
463
+ //#endregion
348
464
  //#region src/retry.d.ts
349
465
  declare const defaultRetryStatusCodesLookup: () => Readonly<{
350
466
  408: "Request Timeout";
@@ -360,9 +476,10 @@ type RetryStatusCodes = UnmaskType<AnyNumber | keyof ReturnType<typeof defaultRe
360
476
  type RetryCondition<TErrorData> = (context: ErrorContext<{
361
477
  ErrorData: TErrorData;
362
478
  }>) => Awaitable<boolean>;
479
+ type CallApiLooseImpl = (initURL: InitURLOrURLObject, init?: CallApiConfig) => Promise<CallApiResultLoose<unknown, unknown>>;
363
480
  interface RetryOptions<TErrorData> {
364
481
  /**
365
- * 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
366
483
  * @internal
367
484
  * @deprecated **WARNING**: This property is used internally to track retries. Please abstain from reading or modifying it.
368
485
  */
@@ -401,41 +518,37 @@ interface RetryOptions<TErrorData> {
401
518
  */
402
519
  retryStrategy?: "exponential" | "linear";
403
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
+ };
404
532
  //#endregion
405
533
  //#region src/refetch.d.ts
534
+ declare const shouldAttemptRefetchSymbol: unique symbol;
406
535
  interface RefetchOptions {
407
536
  /**
408
- * Tracks the number of times the request has been refetched internally
537
+ * Tracks if the refetching of the request should be attempted
409
538
  * @internal
410
- * @deprecated **WARNING**: This property is used internally to track refetch calls. Please abstain from reading or modifying it.
411
- */
412
- readonly ["~refetchCount"]?: number;
413
- /**
414
- * Maximum number of times refetch can be called from error hooks.
415
- *
416
- * Prevents infinite loops when refetch is called repeatedly in error hooks.
417
- * When the limit is reached, refetch will throw an error instead of retrying.
418
- *
419
- * @default 1
420
- *
421
- * @example
422
- * ```ts
423
- * // Allow up to 5 refetch attempts
424
- * refetchAttempts: 5
425
- *
426
- * // Disable refetch limit
427
- * refetchAttempts: Infinity
428
- *
429
- * // Strict limit of 1 refetch
430
- * refetchAttempts: 1
431
- * ```
539
+ * @deprecated **WARNING**: This property is used internally to track retries. Please abstain from reading or modifying it.
432
540
  */
433
- refetchAttempts?: number;
541
+ [shouldAttemptRefetchSymbol]?: boolean;
434
542
  }
435
- type RefetchFn = (overrides?: Pick<RefetchOptions, "refetchAttempts">) => Promise<CallApiResultLoose<unknown, unknown> | null>;
436
- interface RefetchFnOption {
543
+ type RefetchFn = () => void;
544
+ type RefetchManagerResult = {
545
+ handleRefetch: () => Promise<CallApiResultLoose<unknown, unknown>> | null;
437
546
  refetch: RefetchFn;
438
- }
547
+ };
548
+ declare const createRefetchManager: (ctx: Pick<RetryManagerContext, "callApi" | "callApiArgs" | "removeDedupeCacheEntry"> & {
549
+ options: CallApiExtraOptions;
550
+ }) => RefetchManagerResult;
551
+ type RefetchFnOption = Pick<ReturnType<typeof createRefetchManager>, "refetch">;
439
552
  //#endregion
440
553
  //#region src/stream.d.ts
441
554
  type StreamProgressEvent = {
@@ -463,7 +576,7 @@ type StreamProgressEvent = {
463
576
  type CallApiRequestOptionsForHooks = Omit<CallApiRequestOptions, "headers"> & {
464
577
  headers: Partial<Record<"Authorization" | "Content-Type" | CommonRequestHeaders, string>>;
465
578
  };
466
- 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">;
467
580
  interface Hooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> {
468
581
  /**
469
582
  * Hook called when any error occurs within the request/response lifecycle.
@@ -659,6 +772,10 @@ type ResponseErrorContext<TCallApiContext extends Pick<CallApiContext, "ErrorDat
659
772
  type RetryContext<TCallApiContext extends Pick<CallApiContext, "ErrorData" | "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = ErrorContext<TCallApiContext> & {
660
773
  retryAttemptCount: number;
661
774
  };
775
+ type ExecuteHookInfo = {
776
+ errorInfoOptions: ErrorInfoOptions;
777
+ shouldThrowOnError: boolean | undefined;
778
+ };
662
779
  //#endregion
663
780
  //#region src/dedupe.d.ts
664
781
  type DedupeStrategyUnion = UnmaskType<"cancel" | "defer" | "none">;
@@ -918,56 +1035,6 @@ interface Middlewares<TCallApiContext extends NoInfer<CallApiContext> = DefaultC
918
1035
  fetchMiddleware?: (context: FetchMiddlewareContext<TCallApiContext>) => FetchImpl;
919
1036
  }
920
1037
  //#endregion
921
- //#region src/utils/external/error.d.ts
922
- type HTTPErrorDetails<TErrorData> = Pick<CallApiExtraOptions, "defaultHTTPErrorMessage"> & {
923
- errorData: TErrorData;
924
- response: Response;
925
- };
926
- declare class HTTPError<TErrorData = Record<string, unknown>> extends Error {
927
- errorData: HTTPErrorDetails<TErrorData>["errorData"];
928
- readonly httpErrorSymbol: symbol;
929
- name: "HTTPError";
930
- response: HTTPErrorDetails<TErrorData>["response"];
931
- constructor(errorDetails: HTTPErrorDetails<TErrorData>, errorOptions?: ErrorOptions);
932
- /**
933
- * @description Checks if the given error is an instance of HTTPError
934
- * @param error - The error to check
935
- * @returns true if the error is an instance of HTTPError, false otherwise
936
- */
937
- static isError<TErrorData>(error: unknown): error is HTTPError<TErrorData>;
938
- }
939
- type SafeExtract<TUnion, TKey extends TUnion> = Extract<TUnion, TKey>;
940
- type ValidationErrorDetails = {
941
- /**
942
- * The cause of the validation error.
943
- *
944
- * 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.
945
- */
946
- issueCause: "toFormData" | "toQueryString" | "unknown" | `schemaConfig-(${SafeExtract<keyof CallApiSchemaConfig, "strict">})` | keyof CallApiSchema;
947
- /**
948
- * The issues that caused the validation error.
949
- */
950
- issues: readonly StandardSchemaV1.Issue[];
951
- /**
952
- * The response from server, if any.
953
- */
954
- response: Response | null;
955
- };
956
- declare class ValidationError extends Error {
957
- errorData: ValidationErrorDetails["issues"];
958
- issueCause: ValidationErrorDetails["issueCause"];
959
- name: "ValidationError";
960
- response: ValidationErrorDetails["response"];
961
- readonly validationErrorSymbol: symbol;
962
- constructor(details: ValidationErrorDetails, errorOptions?: ErrorOptions);
963
- /**
964
- * @description Checks if the given error is an instance of ValidationError
965
- * @param error - The error to check
966
- * @returns true if the error is an instance of ValidationError, false otherwise
967
- */
968
- static isError(error: unknown): error is ValidationError;
969
- }
970
- //#endregion
971
1038
  //#region src/types/options-types.d.ts
972
1039
  interface Register {}
973
1040
  type GlobalMeta = Register extends {
@@ -1760,6 +1827,9 @@ type ResultModePlaceholder = null;
1760
1827
  type ResultModeUnion = keyof ResultModeMap;
1761
1828
  type ResultModeType = ResultModePlaceholder | ResultModeUnion;
1762
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
+ };
1763
1833
  //#endregion
1764
1834
  //#region src/plugins.d.ts
1765
1835
  type PluginSetupContext<TCallApiContext extends CallApiContext = DefaultCallApiContext> = RequestContext<TCallApiContext> & ReturnType<typeof getCurrentRouteSchemaKeyAndMainInitURL>;
@@ -1825,5 +1895,5 @@ type DefaultCallApiContext = Prettify<OverrideCallApiContext<Required<CallApiCon
1825
1895
  Meta: GlobalMeta;
1826
1896
  }>>;
1827
1897
  //#endregion
1828
- export { Hooks as $, CallApiConfig as A, GetCallApiContextRequired as B, InferAllMainRouteKeys as C, DistributiveOmit as Ct, ThrowOnErrorBoolean as D, fetchSpecificKeys as Dt, InferParamsFromRoute as E, Writeable as Et, CallApiResult as F, ValidationError as G, InstanceContext as H, CallApiResultLoose as I, Middlewares as J, FetchImpl as K, GetBaseSchemaConfig as L, CallApiExtraOptions as M, CallApiParameters as N, BaseCallApiConfig as O, CallApiRequestOptions as P, ErrorContext as Q, GetBaseSchemaRoutes as R, GetCurrentRouteSchemaKey as S, AnyString as St, InferInitURL as T, Satisfies as Tt, Register as U, GlobalMeta as V, HTTPError as W, CallApiExtraOptionsForHooks as X, DedupeOptions as Y, CallApiRequestOptionsForHooks as Z, ResponseTypeType as _, InferSchemaOutput as _t, PluginHooks as a, ResponseStreamContext as at, ApplyURLBasedConfig as b, fallBackRouteSchemaKey as bt, CallApiResultErrorVariant as c, RetryOptions as ct, GetResponseType as d, BaseCallApiSchemaRoutes as dt, HooksOrHooksArray as et, InferCallApiResult as f, BaseSchemaRouteKeyPrefixes as ft, ResponseTypeMap as g, InferSchemaInput as gt, PossibleValidationError as h, CallApiSchemaType as ht, CallApiPlugin as i, ResponseErrorContext as it, CallApiContext as j, BaseCallApiExtraOptions as k, CallApiResultSuccessOrErrorVariant as l, URLOptions as lt, PossibleJavaScriptError as m, CallApiSchemaConfig as mt, DefaultDataType as n, RequestStreamContext as nt, PluginMiddlewares as o, SuccessContext as ot, PossibleHTTPError as p, CallApiSchema as pt, FetchMiddlewareContext as q, DefaultPluginArray as r, ResponseContext as rt, PluginSetupContext as s, RefetchOptions as st, DefaultCallApiContext as t, RequestContext as tt, CallApiResultSuccessVariant as u, BaseCallApiSchemaAndConfig as ut, ResultModeType as v, InferSchemaResult as vt, InferAllMainRoutes as w, NoInferUnMasked as wt, GetCurrentRouteSchema as x, AnyFunction as xt, ApplyStrictConfig as y, FallBackRouteSchemaKey as yt, GetCallApiContext as z };
1829
- //# sourceMappingURL=default-types-CyPF_5eh.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