@zayne-labs/callapi 1.8.4 → 1.8.5
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.
@@ -212,6 +212,38 @@ declare class ValidationError extends Error {
|
|
212
212
|
static isError(error: unknown): error is ValidationError;
|
213
213
|
}
|
214
214
|
//#endregion
|
215
|
+
//#region src/url.d.ts
|
216
|
+
type AllowedQueryParamValues = UnmaskType<boolean | number | string>;
|
217
|
+
type Params = UnmaskType<Record<string, AllowedQueryParamValues> | AllowedQueryParamValues[]>;
|
218
|
+
type Query = UnmaskType<Record<string, AllowedQueryParamValues>>;
|
219
|
+
type InitURLOrURLObject = string | URL;
|
220
|
+
interface URLOptions {
|
221
|
+
/**
|
222
|
+
* Base URL to be prepended to all request URLs
|
223
|
+
*/
|
224
|
+
baseURL?: string;
|
225
|
+
/**
|
226
|
+
* Resolved request URL
|
227
|
+
*/
|
228
|
+
readonly fullURL?: string;
|
229
|
+
/**
|
230
|
+
* The url string passed to the callApi instance
|
231
|
+
*/
|
232
|
+
readonly initURL?: string;
|
233
|
+
/**
|
234
|
+
* The URL string passed to the callApi instance, but normalized (removed any method modifiers etc)
|
235
|
+
*/
|
236
|
+
readonly initURLNormalized?: string;
|
237
|
+
/**
|
238
|
+
* Parameters to be appended to the URL (i.e: /:id)
|
239
|
+
*/
|
240
|
+
params?: Params;
|
241
|
+
/**
|
242
|
+
* Query parameters to append to the URL.
|
243
|
+
*/
|
244
|
+
query?: Query;
|
245
|
+
}
|
246
|
+
//#endregion
|
215
247
|
//#region src/validation.d.ts
|
216
248
|
type InferSchemaResult<TSchema, TFallbackResult = NonNullable<unknown>> = undefined extends TSchema ? TFallbackResult : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TSchema extends AnyFunction<infer TResult> ? Awaited<TResult> : TFallbackResult;
|
217
249
|
interface CallApiSchemaConfig {
|
@@ -294,38 +326,6 @@ type PossibleRouteKey = `@${RouteKeyMethods}/` | AnyString;
|
|
294
326
|
type BaseCallApiSchema = { [Key in PossibleRouteKey]?: CallApiSchema };
|
295
327
|
declare const defineSchema: <const TBaseSchema extends BaseCallApiSchema>(baseSchema: TBaseSchema) => Writeable<typeof baseSchema, "deep">;
|
296
328
|
//#endregion
|
297
|
-
//#region src/url.d.ts
|
298
|
-
type AllowedQueryParamValues = UnmaskType<boolean | number | string>;
|
299
|
-
type Params = UnmaskType<Record<string, AllowedQueryParamValues> | AllowedQueryParamValues[]>;
|
300
|
-
type Query = UnmaskType<Record<string, AllowedQueryParamValues>>;
|
301
|
-
type InitURLOrURLObject = string | URL;
|
302
|
-
interface URLOptions {
|
303
|
-
/**
|
304
|
-
* Base URL to be prepended to all request URLs
|
305
|
-
*/
|
306
|
-
baseURL?: string;
|
307
|
-
/**
|
308
|
-
* Resolved request URL
|
309
|
-
*/
|
310
|
-
readonly fullURL?: string;
|
311
|
-
/**
|
312
|
-
* The url string passed to the callApi instance
|
313
|
-
*/
|
314
|
-
readonly initURL?: string;
|
315
|
-
/**
|
316
|
-
* The URL string passed to the callApi instance, but normalized (removed any method modifiers etc)
|
317
|
-
*/
|
318
|
-
readonly initURLNormalized?: string;
|
319
|
-
/**
|
320
|
-
* Parameters to be appended to the URL (i.e: /:id)
|
321
|
-
*/
|
322
|
-
params?: Params;
|
323
|
-
/**
|
324
|
-
* Query parameters to append to the URL.
|
325
|
-
*/
|
326
|
-
query?: Query;
|
327
|
-
}
|
328
|
-
//#endregion
|
329
329
|
//#region src/plugins.d.ts
|
330
330
|
type PluginInitContext<TPluginExtraOptions = unknown> = RequestContext & PluginExtraOptions<TPluginExtraOptions> & {
|
331
331
|
initURL: string;
|
@@ -334,8 +334,8 @@ type PluginInitResult = Partial<Omit<PluginInitContext, "initURL" | "request"> &
|
|
334
334
|
initURL: InitURLOrURLObject;
|
335
335
|
request: CallApiRequestOptions;
|
336
336
|
}>;
|
337
|
-
type PluginHooksWithMoreOptions<TMoreOptions = unknown> = HooksOrHooksArray<never, never,
|
338
|
-
type PluginHooks<TData = never, TErrorData = never, TMoreOptions = unknown> = HooksOrHooksArray<TData, TErrorData,
|
337
|
+
type PluginHooksWithMoreOptions<TMoreOptions = unknown> = HooksOrHooksArray<never, never, TMoreOptions>;
|
338
|
+
type PluginHooks<TData = never, TErrorData = never, TMoreOptions = unknown> = HooksOrHooksArray<TData, TErrorData, TMoreOptions>;
|
339
339
|
interface CallApiPlugin {
|
340
340
|
/**
|
341
341
|
* Defines additional options that can be passed to callApi
|
@@ -458,51 +458,51 @@ declare global {
|
|
458
458
|
type PluginExtraOptions<TPluginOptions = unknown> = {
|
459
459
|
options: Partial<TPluginOptions>;
|
460
460
|
};
|
461
|
-
interface Hooks<TData = DefaultDataType, TErrorData = DefaultDataType, TPluginOptions = unknown
|
461
|
+
interface Hooks<TData = DefaultDataType, TErrorData = DefaultDataType, TPluginOptions = unknown> {
|
462
462
|
/**
|
463
463
|
* Hook that will be called when any error occurs within the request/response lifecycle, regardless of whether the error is from the api or not.
|
464
464
|
* It is basically a combination of `onRequestError` and `onResponseError` hooks
|
465
465
|
*/
|
466
|
-
onError?: (context: ErrorContext<TErrorData> &
|
466
|
+
onError?: (context: ErrorContext<TErrorData> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
467
467
|
/**
|
468
468
|
* Hook that will be called just before the request is being made.
|
469
469
|
*/
|
470
|
-
onRequest?: (context: RequestContext
|
470
|
+
onRequest?: (context: RequestContext & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
471
471
|
/**
|
472
472
|
* Hook that will be called when an error occurs during the fetch request.
|
473
473
|
*/
|
474
|
-
onRequestError?: (context: RequestErrorContext &
|
474
|
+
onRequestError?: (context: RequestErrorContext & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
475
475
|
/**
|
476
476
|
* Hook that will be called when upload stream progress is tracked
|
477
477
|
*/
|
478
|
-
onRequestStream?: (context: RequestStreamContext &
|
478
|
+
onRequestStream?: (context: RequestStreamContext & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
479
479
|
/**
|
480
480
|
* Hook that will be called when any response is received from the api, whether successful or not
|
481
481
|
*/
|
482
|
-
onResponse?: (context: ResponseContext<TData, TErrorData> &
|
482
|
+
onResponse?: (context: ResponseContext<TData, TErrorData> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
483
483
|
/**
|
484
484
|
* Hook that will be called when an error response is received from the api.
|
485
485
|
*/
|
486
|
-
onResponseError?: (context: ResponseErrorContext<TErrorData> &
|
486
|
+
onResponseError?: (context: ResponseErrorContext<TErrorData> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
487
487
|
/**
|
488
488
|
* Hook that will be called when download stream progress is tracked
|
489
489
|
*/
|
490
|
-
onResponseStream?: (context: ResponseStreamContext &
|
490
|
+
onResponseStream?: (context: ResponseStreamContext & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
491
491
|
/**
|
492
492
|
* Hook that will be called when a request is retried.
|
493
493
|
*/
|
494
|
-
onRetry?: (response: RetryContext<TErrorData> &
|
494
|
+
onRetry?: (response: RetryContext<TErrorData> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
495
495
|
/**
|
496
496
|
* Hook that will be called when a successful response is received from the api.
|
497
497
|
*/
|
498
|
-
onSuccess?: (context: SuccessContext<TData> &
|
498
|
+
onSuccess?: (context: SuccessContext<TData> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
499
499
|
/**
|
500
500
|
* Hook that will be called when a validation error occurs.
|
501
501
|
*/
|
502
|
-
onValidationError?: (context: ValidationErrorContext &
|
502
|
+
onValidationError?: (context: ValidationErrorContext & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
503
503
|
}
|
504
|
-
type HooksOrHooksArray<TData = DefaultDataType, TErrorData = DefaultDataType,
|
505
|
-
type RequestContext
|
504
|
+
type HooksOrHooksArray<TData = DefaultDataType, TErrorData = DefaultDataType, TMoreOptions = unknown> = { [Key in keyof Hooks<TData, TErrorData, TMoreOptions>]: Hooks<TData, TErrorData, TMoreOptions>[Key] | Array<Hooks<TData, TErrorData, TMoreOptions>[Key]> };
|
505
|
+
type RequestContext = {
|
506
506
|
/**
|
507
507
|
* Config object passed to createFetchClient
|
508
508
|
*/
|
@@ -515,13 +515,13 @@ type RequestContext<TSchema extends CallApiSchema = CallApiSchema, TCurrentRoute
|
|
515
515
|
* Merged options consisting of extra options from createFetchClient, the callApi instance and default options.
|
516
516
|
*
|
517
517
|
*/
|
518
|
-
options:
|
518
|
+
options: CallApiExtraOptionsForHooks;
|
519
519
|
/**
|
520
520
|
* Merged request consisting of request options from createFetchClient, the callApi instance and default request options.
|
521
521
|
*/
|
522
|
-
request:
|
522
|
+
request: CallApiRequestOptionsForHooks;
|
523
523
|
};
|
524
|
-
type ResponseContext<TData, TErrorData> = {
|
524
|
+
type ResponseContext<TData, TErrorData> = RequestContext & ({
|
525
525
|
data: null;
|
526
526
|
error: PossibleHTTPError<TErrorData>;
|
527
527
|
response: Response;
|
@@ -533,40 +533,40 @@ type ResponseContext<TData, TErrorData> = {
|
|
533
533
|
data: TData;
|
534
534
|
error: null;
|
535
535
|
response: Response;
|
536
|
-
};
|
537
|
-
type ValidationErrorContext = {
|
536
|
+
});
|
537
|
+
type ValidationErrorContext = RequestContext & {
|
538
538
|
error: ValidationError;
|
539
539
|
response: Response | null;
|
540
540
|
};
|
541
|
-
type SuccessContext<TData> = {
|
541
|
+
type SuccessContext<TData> = RequestContext & {
|
542
542
|
data: TData;
|
543
543
|
response: Response;
|
544
544
|
};
|
545
|
-
type RequestErrorContext = {
|
545
|
+
type RequestErrorContext = UnmaskType<RequestContext & {
|
546
546
|
error: PossibleJavaScriptOrValidationError;
|
547
547
|
response: null;
|
548
|
-
};
|
549
|
-
type ResponseErrorContext<TErrorData> = Extract<ErrorContext<TErrorData>, {
|
550
|
-
error: PossibleHTTPError<TErrorData>;
|
551
548
|
}>;
|
552
|
-
type
|
549
|
+
type ResponseErrorContext<TErrorData> = UnmaskType<Extract<ErrorContext<TErrorData>, {
|
550
|
+
error: PossibleHTTPError<TErrorData>;
|
551
|
+
}> & RequestContext>;
|
552
|
+
type RetryContext<TErrorData> = UnmaskType<ErrorContext<TErrorData> & {
|
553
553
|
retryAttemptCount: number;
|
554
|
-
}
|
555
|
-
type ErrorContext<TErrorData> = {
|
554
|
+
}>;
|
555
|
+
type ErrorContext<TErrorData> = UnmaskType<RequestContext & ({
|
556
556
|
error: PossibleHTTPError<TErrorData>;
|
557
557
|
response: Response;
|
558
558
|
} | {
|
559
559
|
error: PossibleJavaScriptOrValidationError;
|
560
560
|
response: Response | null;
|
561
|
-
}
|
562
|
-
type RequestStreamContext = {
|
561
|
+
})>;
|
562
|
+
type RequestStreamContext = UnmaskType<RequestContext & {
|
563
563
|
event: StreamProgressEvent;
|
564
564
|
requestInstance: Request;
|
565
|
-
}
|
566
|
-
type ResponseStreamContext = {
|
565
|
+
}>;
|
566
|
+
type ResponseStreamContext = UnmaskType<RequestContext & {
|
567
567
|
event: StreamProgressEvent;
|
568
568
|
response: Response;
|
569
|
-
}
|
569
|
+
}>;
|
570
570
|
//#endregion
|
571
571
|
//#region src/dedupe.d.ts
|
572
572
|
type DedupeOptions = {
|
@@ -752,7 +752,7 @@ type CallApiRequestOptionsForHooks = Omit<CallApiRequestOptions, "headers"> & {
|
|
752
752
|
headers: Record<string, string | undefined>;
|
753
753
|
};
|
754
754
|
type FetchImpl = UnmaskType<(input: string | Request | URL, init?: RequestInit) => Promise<Response>>;
|
755
|
-
type SharedExtraOptions<TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion> = DedupeOptions & URLOptions & {
|
755
|
+
type SharedExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = DedupeOptions & HooksOrHooksArray<TData, TErrorData, Partial<InferPluginOptions<TPluginArray>>> & Partial<InferPluginOptions<TPluginArray>> & ResultModeOption<TErrorData, TResultMode> & RetryOptions<TErrorData> & ThrowOnErrorOption<TErrorData, TThrowOnError> & URLOptions & {
|
756
756
|
/**
|
757
757
|
* Authorization header value.
|
758
758
|
*/
|
@@ -850,7 +850,7 @@ type SharedExtraOptions<TResultMode extends ResultModeUnion = ResultModeUnion, T
|
|
850
850
|
*/
|
851
851
|
timeout?: number;
|
852
852
|
};
|
853
|
-
type BaseCallApiExtraOptions<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchema extends BaseCallApiSchema = BaseCallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig> = SharedExtraOptions<TBaseResultMode, TBaseThrowOnError, TBaseResponseType> & {
|
853
|
+
type BaseCallApiExtraOptions<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchema extends BaseCallApiSchema = BaseCallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig> = SharedExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray> & {
|
854
854
|
/**
|
855
855
|
* An array of base callApi plugins. It allows you to extend the behavior of the library.
|
856
856
|
*/
|
@@ -884,8 +884,8 @@ type BaseCallApiExtraOptions<TBaseData = DefaultDataType, TBaseErrorData = Defau
|
|
884
884
|
* ```
|
885
885
|
*/
|
886
886
|
skipAutoMergeFor?: "all" | "options" | "request";
|
887
|
-
}
|
888
|
-
type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchema extends BaseCallApiSchema = BaseCallApiSchema, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TCurrentRouteKey extends string = string> = SharedExtraOptions<TResultMode, TThrowOnError, TResponseType> & {
|
887
|
+
};
|
888
|
+
type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchema extends BaseCallApiSchema = BaseCallApiSchema, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TCurrentRouteKey extends string = string> = SharedExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray> & {
|
889
889
|
/**
|
890
890
|
* An array of instance CallApi plugins. It allows you to extend the behavior of the library.
|
891
891
|
*/
|
@@ -905,8 +905,8 @@ type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType,
|
|
905
905
|
schemaConfig?: Writeable<TSchemaConfig, "deep"> | ((context: {
|
906
906
|
baseSchemaConfig: NonNullable<Writeable<TBaseSchemaConfig, "deep">>;
|
907
907
|
}) => Writeable<TSchemaConfig, "deep">);
|
908
|
-
}
|
909
|
-
|
908
|
+
};
|
909
|
+
type CallApiExtraOptionsForHooks = Hooks & Omit<CallApiExtraOptions, keyof Hooks>;
|
910
910
|
type BaseCallApiConfig<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchema extends BaseCallApiSchema = BaseCallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray> = (CallApiRequestOptions & BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchema, TBaseSchemaConfig>) | ((context: {
|
911
911
|
initURL: string;
|
912
912
|
options: CallApiExtraOptions;
|
@@ -916,5 +916,5 @@ type CallApiConfig<TData = DefaultDataType, TErrorData = DefaultDataType, TResul
|
|
916
916
|
type CallApiParameters<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchema extends BaseCallApiSchema = BaseCallApiSchema, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InferInitURL<BaseCallApiSchema, TSchemaConfig> = InferInitURL<BaseCallApiSchema, TSchemaConfig>, TCurrentRouteKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = [initURL: TInitURL, config?: CallApiConfig<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TBaseSchema, TSchema, TBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteKey, TBasePluginArray, TPluginArray>];
|
917
917
|
type CallApiResult<TData, TErrorData, TResultMode extends ResultModeUnion, TThrowOnError extends boolean, TResponseType extends ResponseTypeUnion> = Promise<GetCallApiResult<TData, TErrorData, TResultMode, TThrowOnError, TResponseType>>;
|
918
918
|
//#endregion
|
919
|
-
export { BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchema, CallApiConfig, CallApiExtraOptions, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig,
|
920
|
-
//# sourceMappingURL=common-
|
919
|
+
export { BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchema, CallApiConfig, CallApiExtraOptions, CallApiExtraOptionsForHooks, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig, DedupeOptions, DefaultDataType, DefaultPluginArray, DefaultThrowOnError, ErrorContext, GetCurrentRouteKey, HTTPError, Hooks, HooksOrHooksArray, InferInitURL, InferParamFromRoute, InferSchemaResult, PluginHooks, PluginHooksWithMoreOptions, PluginInitContext, PossibleHTTPError, PossibleJavaScriptError, PossibleValidationError, Register, RequestContext, RequestStreamContext, ResponseContext, ResponseErrorContext, ResponseStreamContext, ResponseTypeUnion, ResultModeUnion, RetryOptions, SuccessContext, URLOptions, ValidationError, definePlugin, defineSchema };
|
920
|
+
//# sourceMappingURL=common-Ib2vb30V.d.ts.map
|
package/dist/esm/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchema, CallApiConfig, CallApiExtraOptions, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig,
|
1
|
+
import { BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchema, CallApiConfig, CallApiExtraOptions, CallApiExtraOptionsForHooks, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig, DedupeOptions, DefaultDataType, DefaultPluginArray, DefaultThrowOnError, ErrorContext, GetCurrentRouteKey, HTTPError, Hooks, HooksOrHooksArray, InferInitURL, InferParamFromRoute, InferSchemaResult, PluginHooks, PluginHooksWithMoreOptions, PluginInitContext, PossibleHTTPError, PossibleJavaScriptError, PossibleValidationError, Register, RequestContext, RequestStreamContext, ResponseContext, ResponseErrorContext, ResponseStreamContext, ResponseTypeUnion, ResultModeUnion, RetryOptions, SuccessContext, URLOptions, ValidationError, definePlugin, defineSchema } from "./common-Ib2vb30V.js";
|
2
2
|
|
3
3
|
//#region src/createFetchClient.d.ts
|
4
4
|
|
@@ -8,5 +8,5 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
|
|
8
8
|
//#region src/defineParameters.d.ts
|
9
9
|
declare const defineParameters: <TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchema extends BaseCallApiSchema = BaseCallApiSchema, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InferInitURL<BaseCallApiSchema, TSchemaConfig> = InferInitURL<BaseCallApiSchema, TSchemaConfig>, TCurrentRouteKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray>(...parameters: CallApiParameters<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TBaseSchema, TSchema, TBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteKey, TBasePluginArray, TPluginArray>) => CallApiParameters<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TBaseSchema, TSchema, TBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteKey, TBasePluginArray, TPluginArray>;
|
10
10
|
//#endregion
|
11
|
-
export { BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchema, CallApiConfig, CallApiExtraOptions, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig,
|
11
|
+
export { BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchema, CallApiConfig, CallApiExtraOptions, CallApiExtraOptionsForHooks, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig, DedupeOptions, ErrorContext, HTTPError, Hooks, HooksOrHooksArray, InferParamFromRoute, InferSchemaResult, PluginHooks, PluginHooksWithMoreOptions, PluginInitContext, PossibleHTTPError, PossibleJavaScriptError, PossibleValidationError, Register, RequestContext, RequestStreamContext, ResponseContext, ResponseErrorContext, ResponseStreamContext, ResponseTypeUnion, ResultModeUnion, RetryOptions, SuccessContext, URLOptions, ValidationError, callApi, createFetchClient, defineParameters, definePlugin, defineSchema };
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":["response: Response","parser: Parser","responseType?: ResponseTypeUnion","parser?: Parser","details: CallApiResultErrorVariant<unknown> | CallApiResultSuccessVariant<unknown>","data: unknown","info: SuccessInfo","error: unknown","info: ErrorInfo","errorResult: ErrorResult","customErrorInfo: { message: string | undefined }","hooks: Array<AnyFunction | undefined>","mergedHooksExecutionMode: CombinedCallApiExtraOptions[\"mergedHooksExecutionMode\"]","ctx: unknown","hookResultsOrPromise: Array<Awaitable<unknown>>","hookInfo: ExecuteHookInfo","options: {\n\tchunk: Uint8Array;\n\ttotalBytes: number;\n\ttransferredBytes: number;\n}","requestBody: Request[\"body\"] | null","existingTotalBytes: number","context: ToStreamableRequestContext","context: StreamableResponseContext","dedupeKey: DedupeOptions[\"dedupeKey\"]","fullURL: DedupeContext[\"options\"][\"fullURL\"]","context: DedupeContext","$GlobalRequestInfoCache","deferContext: {\n\t\toptions: DedupeContext[\"options\"];\n\t\trequest: DedupeContext[\"request\"];\n\t}","plugin: TPlugin","plugins: CallApiExtraOptions[\"plugins\"] | undefined","basePlugins: BaseCallApiExtraOptions[\"plugins\"] | undefined","context: PluginInitContext","pluginHooks: Required<CallApiPlugin>[\"hooks\"]","pluginInit: CallApiPlugin[\"init\"]","resolvedHooks: Hooks","currentAttemptCount: number","options: RetryOptions<unknown>","ctx: ErrorContext<unknown> & RequestContext","validator: Extract<CallApiSchema[keyof CallApiSchema], AnyFunction>","inputData: TInput","schema: TSchema","inputData: InferSchemaInput<TSchema>","response?: Response | null","baseSchema: TBaseSchema","schema: TSchema | undefined","validationOptions: ValidationOptions<TSchema>","validationOptions: ExtraOptionsValidationOptions","validatedResultObject: Prettify<\n\t\tPick<CallApiExtraOptions, (typeof extraOptionsToBeValidated)[number]>\n\t>","validationOptions: RequestOptionsValidationOptions","validatedResultObject: Prettify<\n\t\tPick<CallApiRequestOptions, (typeof requestOptionsToBeValidated)[number]>\n\t>","validationOptions: ExtraOptionsValidationOptions & RequestOptionsValidationOptions","url: string","params: CallApiExtraOptions[\"params\"]","query: CallApiExtraOptions[\"query\"]","schemaConfig: CallApiSchemaConfig | undefined","initURL: string | undefined","options: GetMethodOptions","initURL: string","options: GetFullURLOptions","$GlobalRequestInfoCache: RequestInfoCache","initBaseConfig: BaseCallApiConfig<\n\t\tTBaseData,\n\t\tTBaseErrorData,\n\t\tTBaseResultMode,\n\t\tTBaseThrowOnError,\n\t\tTBaseResponseType,\n\t\tTBaseSchema,\n\t\tTBaseSchemaConfig,\n\t\tTBasePluginArray\n\t>","$LocalRequestInfoCache: RequestInfoCache","callApi","hookError","message: string | undefined"],"sources":["../../src/result.ts","../../src/hooks.ts","../../src/stream.ts","../../src/dedupe.ts","../../src/plugins.ts","../../src/retry.ts","../../src/validation.ts","../../src/url.ts","../../src/createFetchClient.ts","../../src/defineParameters.ts"],"sourcesContent":["import { commonDefaults, responseDefaults } from \"./constants/default-options\";\nimport type { HTTPError, ValidationError } from \"./error\";\nimport type { CallApiExtraOptions } from \"./types\";\nimport type { DefaultDataType } from \"./types/default-types\";\nimport type { Awaitable, Prettify, UnmaskType } from \"./types/type-helpers\";\nimport { isHTTPErrorInstance, isValidationErrorInstance } from \"./utils/guards\";\n\ntype Parser = (responseString: string) => Awaitable<Record<string, unknown>>;\n\nexport const getResponseType = <TResponse>(response: Response, parser: Parser) => ({\n\tarrayBuffer: () => response.arrayBuffer(),\n\tblob: () => response.blob(),\n\tformData: () => response.formData(),\n\tjson: async () => {\n\t\tconst text = await response.text();\n\t\treturn parser(text) as TResponse;\n\t},\n\tstream: () => response.body,\n\ttext: () => response.text(),\n});\n\ntype InitResponseTypeMap<TResponse = unknown> = ReturnType<typeof getResponseType<TResponse>>;\n\nexport type ResponseTypeUnion = keyof InitResponseTypeMap | null;\n\nexport type ResponseTypeMap<TResponse> = {\n\t[Key in keyof InitResponseTypeMap<TResponse>]: Awaited<ReturnType<InitResponseTypeMap<TResponse>[Key]>>;\n};\n\nexport type GetResponseType<\n\tTResponse,\n\tTResponseType extends ResponseTypeUnion,\n\tTComputedResponseTypeMap extends ResponseTypeMap<TResponse> = ResponseTypeMap<TResponse>,\n> = null extends TResponseType\n\t? TComputedResponseTypeMap[\"json\"]\n\t: TResponseType extends NonNullable<ResponseTypeUnion>\n\t\t? TComputedResponseTypeMap[TResponseType]\n\t\t: never;\n\nexport const resolveResponseData = <TResponse>(\n\tresponse: Response,\n\tresponseType?: ResponseTypeUnion,\n\tparser?: Parser\n) => {\n\tconst selectedParser = parser ?? responseDefaults.responseParser;\n\tconst selectedResponseType = responseType ?? responseDefaults.responseType;\n\n\tconst RESPONSE_TYPE_LOOKUP = getResponseType<TResponse>(response, selectedParser);\n\n\tif (!Object.hasOwn(RESPONSE_TYPE_LOOKUP, selectedResponseType)) {\n\t\tthrow new Error(`Invalid response type: ${responseType}`);\n\t}\n\n\treturn RESPONSE_TYPE_LOOKUP[selectedResponseType]();\n};\n\nexport type CallApiResultSuccessVariant<TData> = {\n\tdata: TData;\n\terror: null;\n\tresponse: Response;\n};\n\nexport type PossibleJavaScriptError = UnmaskType<{\n\terrorData: PossibleJavaScriptError[\"originalError\"];\n\tmessage: string;\n\tname: \"AbortError\" | \"Error\" | \"SyntaxError\" | \"TimeoutError\" | \"TypeError\" | (`${string}Error` & {});\n\toriginalError: DOMException | Error | SyntaxError | TypeError;\n}>;\n\nexport type PossibleHTTPError<TErrorData> = Prettify<\n\tUnmaskType<{\n\t\terrorData: TErrorData;\n\t\tmessage: string;\n\t\tname: \"HTTPError\";\n\t\toriginalError: HTTPError;\n\t}>\n>;\n\nexport type PossibleValidationError = Prettify<\n\tUnmaskType<{\n\t\terrorData: ValidationError[\"errorData\"];\n\t\tmessage: string;\n\t\tname: \"ValidationError\";\n\t\toriginalError: ValidationError;\n\t}>\n>;\n\nexport type PossibleJavaScriptOrValidationError = UnmaskType<\n\tPossibleJavaScriptError | PossibleValidationError\n>;\n\nexport type CallApiResultErrorVariant<TErrorData> =\n\t| {\n\t\t\tdata: null;\n\t\t\terror: PossibleHTTPError<TErrorData>;\n\t\t\tresponse: Response;\n\t }\n\t| {\n\t\t\tdata: null;\n\t\t\terror: PossibleJavaScriptOrValidationError;\n\t\t\tresponse: Response | null;\n\t };\n\nexport type ResultModeMap<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tTComputedData = GetResponseType<TData, TResponseType>,\n\tTComputedErrorData = GetResponseType<TErrorData, TResponseType>,\n> = UnmaskType<{\n\t/* eslint-disable perfectionist/sort-union-types -- I need the first one to be first */\n\tall: CallApiResultSuccessVariant<TComputedData> | CallApiResultErrorVariant<TComputedErrorData>;\n\n\tallWithException: CallApiResultSuccessVariant<TComputedData>;\n\n\tonlySuccess:\n\t\t| CallApiResultErrorVariant<TComputedErrorData>[\"data\"]\n\t\t| CallApiResultSuccessVariant<TComputedData>[\"data\"];\n\n\tonlySuccessWithException: CallApiResultSuccessVariant<TComputedData>[\"data\"];\n\t/* eslint-enable perfectionist/sort-union-types -- I need the first one to be first */\n}>;\n\nexport type ResultModeUnion = keyof ResultModeMap | null;\n\nexport type GetCallApiResult<\n\tTData,\n\tTErrorData,\n\tTResultMode extends ResultModeUnion,\n\tTThrowOnError extends boolean,\n\tTResponseType extends ResponseTypeUnion,\n> = TErrorData extends false\n\t? ResultModeMap<TData, TErrorData, TResponseType>[\"onlySuccessWithException\"]\n\t: TErrorData extends false | undefined\n\t\t? ResultModeMap<TData, TErrorData, TResponseType>[\"onlySuccessWithException\"]\n\t\t: TErrorData extends false | null\n\t\t\t? ResultModeMap<TData, TErrorData, TResponseType>[\"onlySuccess\"]\n\t\t\t: null extends TResultMode\n\t\t\t\t? TThrowOnError extends true\n\t\t\t\t\t? ResultModeMap<TData, TErrorData, TResponseType>[\"allWithException\"]\n\t\t\t\t\t: ResultModeMap<TData, TErrorData, TResponseType>[\"all\"]\n\t\t\t\t: TResultMode extends NonNullable<ResultModeUnion>\n\t\t\t\t\t? ResultModeMap<TData, TErrorData, TResponseType>[TResultMode]\n\t\t\t\t\t: never;\n\ntype SuccessInfo = {\n\tresponse: Response;\n\tresultMode: CallApiExtraOptions[\"resultMode\"];\n};\n\ntype LazyResultModeMap = {\n\t[key in keyof ResultModeMap]: () => ResultModeMap[key];\n};\n\nconst getResultModeMap = (\n\tdetails: CallApiResultErrorVariant<unknown> | CallApiResultSuccessVariant<unknown>\n) => {\n\tconst resultModeMap = {\n\t\tall: () => details,\n\t\tallWithException: () => resultModeMap.all() as never,\n\t\tonlySuccess: () => details.data,\n\t\tonlySuccessWithException: () => resultModeMap.onlySuccess(),\n\t} satisfies LazyResultModeMap as LazyResultModeMap;\n\n\treturn resultModeMap;\n};\n\ntype SuccessResult = CallApiResultSuccessVariant<unknown> | null;\n\n// == The CallApiResult type is used to cast all return statements due to a design limitation in ts.\n// LINK - See https://www.zhenghao.io/posts/type-functions for more info\nexport const resolveSuccessResult = (data: unknown, info: SuccessInfo): SuccessResult => {\n\tconst { response, resultMode } = info;\n\n\tconst details = {\n\t\tdata,\n\t\terror: null,\n\t\tresponse,\n\t} satisfies CallApiResultSuccessVariant<unknown>;\n\n\tconst resultModeMap = getResultModeMap(details);\n\n\tconst successResult = resultModeMap[resultMode ?? \"all\"]();\n\n\treturn successResult as SuccessResult;\n};\n\nexport type ErrorInfo = {\n\tcloneResponse: CallApiExtraOptions[\"cloneResponse\"];\n\tdefaultErrorMessage: CallApiExtraOptions[\"defaultErrorMessage\"];\n\tmessage?: string;\n\tresultMode: CallApiExtraOptions[\"resultMode\"];\n};\n\ntype ErrorResult = CallApiResultErrorVariant<unknown> | null;\n\nexport const resolveErrorResult = (error: unknown, info: ErrorInfo): ErrorResult => {\n\tconst { cloneResponse, defaultErrorMessage, message: customErrorMessage, resultMode } = info;\n\n\tlet details = {\n\t\tdata: null,\n\t\terror: {\n\t\t\terrorData: error as Error,\n\t\t\tmessage: customErrorMessage ?? (error as Error).message,\n\t\t\tname: (error as Error).name as PossibleJavaScriptError[\"name\"],\n\t\t\toriginalError: error as Error,\n\t\t},\n\t\tresponse: null,\n\t} satisfies CallApiResultErrorVariant<unknown> as CallApiResultErrorVariant<unknown>;\n\n\tif (isValidationErrorInstance(error)) {\n\t\tconst { errorData, message, response } = error;\n\n\t\tdetails = {\n\t\t\tdata: null,\n\t\t\terror: {\n\t\t\t\terrorData,\n\t\t\t\tmessage,\n\t\t\t\tname: \"ValidationError\",\n\t\t\t\toriginalError: error,\n\t\t\t},\n\t\t\tresponse,\n\t\t};\n\t}\n\n\tif (isHTTPErrorInstance<never>(error)) {\n\t\tconst selectedDefaultErrorMessage = defaultErrorMessage ?? commonDefaults.defaultErrorMessage;\n\n\t\tconst { errorData, message = selectedDefaultErrorMessage, name, response } = error;\n\n\t\tdetails = {\n\t\t\tdata: null,\n\t\t\terror: {\n\t\t\t\terrorData,\n\t\t\t\tmessage,\n\t\t\t\tname,\n\t\t\t\toriginalError: error,\n\t\t\t},\n\t\t\tresponse: cloneResponse ? response.clone() : response,\n\t\t};\n\t}\n\n\tconst resultModeMap = getResultModeMap(details);\n\n\tconst errorResult = resultModeMap[resultMode ?? \"all\"]();\n\n\treturn errorResult as ErrorResult;\n};\n\nexport const getCustomizedErrorResult = (\n\terrorResult: ErrorResult,\n\tcustomErrorInfo: { message: string | undefined }\n): ErrorResult => {\n\tif (!errorResult) {\n\t\treturn null;\n\t}\n\n\tconst { message = errorResult.error.message } = customErrorInfo;\n\n\treturn {\n\t\t...errorResult,\n\t\terror: {\n\t\t\t...errorResult.error,\n\t\t\tmessage,\n\t\t} satisfies NonNullable<ErrorResult>[\"error\"] as never,\n\t};\n};\n","import type { ValidationError } from \"./error\";\nimport {\n\ttype ErrorInfo,\n\ttype PossibleHTTPError,\n\ttype PossibleJavaScriptOrValidationError,\n\tresolveErrorResult,\n} from \"./result\";\nimport type { StreamProgressEvent } from \"./stream\";\nimport type { InferExtraOptions, InferRequestOptions } from \"./types\";\nimport type {\n\tBaseCallApiExtraOptions,\n\tCallApiExtraOptions,\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n\tCombinedCallApiExtraOptions,\n} from \"./types/common\";\nimport type { DefaultDataType } from \"./types/default-types\";\nimport type { AnyFunction, Awaitable } from \"./types/type-helpers\";\nimport type { CallApiSchema, CallApiSchemaConfig } from \"./validation\";\n\nexport type PluginExtraOptions<TPluginOptions = unknown> = {\n\toptions: Partial<TPluginOptions>;\n};\n\n/* eslint-disable perfectionist/sort-intersection-types -- Plugin options should come last */\nexport interface Hooks<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTPluginOptions = unknown,\n\tTSchema extends CallApiSchema = CallApiSchema,\n\tTCurrentRouteKey extends string = string,\n> {\n\t/**\n\t * Hook that will be called when any error occurs within the request/response lifecycle, regardless of whether the error is from the api or not.\n\t * It is basically a combination of `onRequestError` and `onResponseError` hooks\n\t */\n\tonError?: (\n\t\tcontext: ErrorContext<TErrorData>\n\t\t\t& RequestContext<TSchema, TCurrentRouteKey>\n\t\t\t& PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called just before the request is being made.\n\t */\n\tonRequest?: (\n\t\tcontext: RequestContext<TSchema, TCurrentRouteKey> & PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when an error occurs during the fetch request.\n\t */\n\tonRequestError?: (\n\t\tcontext: RequestErrorContext\n\t\t\t& RequestContext<TSchema, TCurrentRouteKey>\n\t\t\t& PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when upload stream progress is tracked\n\t */\n\tonRequestStream?: (\n\t\tcontext: RequestStreamContext\n\t\t\t& RequestContext<TSchema, TCurrentRouteKey>\n\t\t\t& PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when any response is received from the api, whether successful or not\n\t */\n\tonResponse?: (\n\t\tcontext: ResponseContext<TData, TErrorData>\n\t\t\t& RequestContext<TSchema, TCurrentRouteKey>\n\t\t\t& PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when an error response is received from the api.\n\t */\n\tonResponseError?: (\n\t\tcontext: ResponseErrorContext<TErrorData>\n\t\t\t& RequestContext<TSchema, TCurrentRouteKey>\n\t\t\t& PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when download stream progress is tracked\n\t */\n\tonResponseStream?: (\n\t\tcontext: ResponseStreamContext\n\t\t\t& RequestContext<TSchema, TCurrentRouteKey>\n\t\t\t& PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when a request is retried.\n\t */\n\tonRetry?: (\n\t\tresponse: RetryContext<TErrorData>\n\t\t\t& RequestContext<TSchema, TCurrentRouteKey>\n\t\t\t& PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when a successful response is received from the api.\n\t */\n\tonSuccess?: (\n\t\tcontext: SuccessContext<TData>\n\t\t\t& RequestContext<TSchema, TCurrentRouteKey>\n\t\t\t& PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when a validation error occurs.\n\t */\n\tonValidationError?: (\n\t\tcontext: ValidationErrorContext\n\t\t\t& RequestContext<TSchema, TCurrentRouteKey>\n\t\t\t& PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n}\n/* eslint-enable perfectionist/sort-intersection-types -- Plugin options should come last */\n\nexport type HooksOrHooksArray<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTSchema extends CallApiSchema = CallApiSchema,\n\tTCurrentRouteKey extends string = string,\n\tTMoreOptions = unknown,\n> = {\n\t[Key in keyof Hooks<TData, TErrorData, TMoreOptions, TSchema, TCurrentRouteKey>]:\n\t\t| Hooks<TData, TErrorData, TMoreOptions, TSchema, TCurrentRouteKey>[Key]\n\t\t// eslint-disable-next-line perfectionist/sort-union-types -- I need arrays to be last\n\t\t| Array<Hooks<TData, TErrorData, TMoreOptions, TSchema, TCurrentRouteKey>[Key]>;\n};\n\nexport type RequestContext<\n\tTSchema extends CallApiSchema = CallApiSchema,\n\tTCurrentRouteKey extends string = string,\n> = {\n\t/**\n\t * Config object passed to createFetchClient\n\t */\n\tbaseConfig: BaseCallApiExtraOptions & CallApiRequestOptions;\n\t/**\n\t * Config object passed to the callApi instance\n\t */\n\tconfig: CallApiExtraOptions & CallApiRequestOptions;\n\t/**\n\t * Merged options consisting of extra options from createFetchClient, the callApi instance and default options.\n\t *\n\t */\n\toptions: InferExtraOptions<TSchema, TCurrentRouteKey>\n\t\t& Omit<CombinedCallApiExtraOptions, keyof InferExtraOptions<CallApiSchema, string>>;\n\t/**\n\t * Merged request consisting of request options from createFetchClient, the callApi instance and default request options.\n\t */\n\trequest: Omit<\n\t\tCallApiRequestOptionsForHooks,\n\t\tkeyof Omit<InferRequestOptions<TSchema, CallApiSchemaConfig, string>, \"headers\">\n\t>\n\t\t& Omit<InferRequestOptions<TSchema, CallApiSchemaConfig, string>, \"headers\">;\n};\n\nexport type ResponseContext<TData, TErrorData> =\n\t| {\n\t\t\tdata: null;\n\t\t\terror: PossibleHTTPError<TErrorData>;\n\t\t\tresponse: Response;\n\t }\n\t| {\n\t\t\tdata: null;\n\t\t\terror: PossibleJavaScriptOrValidationError;\n\t\t\tresponse: Response | null;\n\t }\n\t| {\n\t\t\tdata: TData;\n\t\t\terror: null;\n\t\t\tresponse: Response;\n\t };\n\nexport type ValidationErrorContext = {\n\terror: ValidationError;\n\tresponse: Response | null;\n};\n\nexport type SuccessContext<TData> = {\n\tdata: TData;\n\tresponse: Response;\n};\n\nexport type RequestErrorContext = {\n\terror: PossibleJavaScriptOrValidationError;\n\tresponse: null;\n};\n\nexport type ResponseErrorContext<TErrorData> = Extract<\n\tErrorContext<TErrorData>,\n\t{ error: PossibleHTTPError<TErrorData> }\n>;\n\nexport type RetryContext<TErrorData> = ErrorContext<TErrorData> & { retryAttemptCount: number };\n\nexport type ErrorContext<TErrorData> =\n\t| {\n\t\t\terror: PossibleHTTPError<TErrorData>;\n\t\t\tresponse: Response;\n\t }\n\t| {\n\t\t\terror: PossibleJavaScriptOrValidationError;\n\t\t\tresponse: Response | null;\n\t };\n\nexport type RequestStreamContext = {\n\tevent: StreamProgressEvent;\n\trequestInstance: Request;\n};\n\nexport type ResponseStreamContext = {\n\tevent: StreamProgressEvent;\n\tresponse: Response;\n};\n\ntype HookRegistries = Required<{\n\t[Key in keyof Hooks]: Set<Hooks[Key]>;\n}>;\n\nexport const hookRegistries = {\n\tonError: new Set(),\n\tonRequest: new Set(),\n\tonRequestError: new Set(),\n\tonRequestStream: new Set(),\n\tonResponse: new Set(),\n\tonResponseError: new Set(),\n\tonResponseStream: new Set(),\n\tonRetry: new Set(),\n\tonSuccess: new Set(),\n\tonValidationError: new Set(),\n} satisfies HookRegistries;\n\nexport const composeTwoHooks = (\n\thooks: Array<AnyFunction | undefined>,\n\tmergedHooksExecutionMode: CombinedCallApiExtraOptions[\"mergedHooksExecutionMode\"]\n) => {\n\tif (hooks.length === 0) return;\n\n\tconst mergedHook = async (ctx: unknown) => {\n\t\tif (mergedHooksExecutionMode === \"sequential\") {\n\t\t\tfor (const hook of hooks) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop -- This is necessary in this case\n\t\t\t\tawait hook?.(ctx);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (mergedHooksExecutionMode === \"parallel\") {\n\t\t\tconst hookArray = [...hooks];\n\n\t\t\tawait Promise.all(hookArray.map((uniqueHook) => uniqueHook?.(ctx)));\n\t\t}\n\t};\n\n\treturn mergedHook;\n};\n\nexport const executeHooksInTryBlock = async (...hookResultsOrPromise: Array<Awaitable<unknown>>) => {\n\tawait Promise.all(hookResultsOrPromise);\n};\n\nexport type ExecuteHookInfo = {\n\terrorInfo: ErrorInfo;\n\tshouldThrowOnError: boolean | undefined;\n};\n\nexport const executeHooksInCatchBlock = async (\n\thookResultsOrPromise: Array<Awaitable<unknown>>,\n\thookInfo: ExecuteHookInfo\n) => {\n\tconst { errorInfo, shouldThrowOnError } = hookInfo;\n\n\ttry {\n\t\tawait Promise.all(hookResultsOrPromise);\n\n\t\treturn null;\n\t} catch (hookError) {\n\t\tconst hookErrorResult = resolveErrorResult(hookError, errorInfo);\n\n\t\tif (shouldThrowOnError) {\n\t\t\tthrow hookError;\n\t\t}\n\n\t\treturn hookErrorResult;\n\t}\n};\n","import { type RequestContext, executeHooksInTryBlock } from \"./hooks\";\nimport { isObject } from \"./utils/guards\";\n\nexport type StreamProgressEvent = {\n\t/**\n\t * Current chunk of data being streamed\n\t */\n\tchunk: Uint8Array;\n\t/**\n\t * Progress in percentage\n\t */\n\tprogress: number;\n\t/**\n\t * Total size of data in bytes\n\t */\n\ttotalBytes: number;\n\t/**\n\t * Amount of data transferred so far\n\t */\n\ttransferredBytes: number;\n};\n\ndeclare global {\n\tinterface ReadableStream<R> {\n\t\t[Symbol.asyncIterator]: () => AsyncIterableIterator<R>;\n\t}\n}\n\nconst createProgressEvent = (options: {\n\tchunk: Uint8Array;\n\ttotalBytes: number;\n\ttransferredBytes: number;\n}): StreamProgressEvent => {\n\tconst { chunk, totalBytes, transferredBytes } = options;\n\n\treturn {\n\t\tchunk,\n\t\tprogress: Math.round((transferredBytes / totalBytes) * 100) || 0,\n\t\ttotalBytes,\n\t\ttransferredBytes,\n\t};\n};\n\nconst calculateTotalBytesFromBody = async (\n\trequestBody: Request[\"body\"] | null,\n\texistingTotalBytes: number\n) => {\n\tlet totalBytes = existingTotalBytes;\n\n\tif (!requestBody) {\n\t\treturn totalBytes;\n\t}\n\n\tfor await (const chunk of requestBody) {\n\t\ttotalBytes += chunk.byteLength;\n\t}\n\n\treturn totalBytes;\n};\n\ntype ToStreamableRequestContext = RequestContext & { requestInstance: Request };\n\nexport const toStreamableRequest = async (context: ToStreamableRequestContext) => {\n\tconst { baseConfig, config, options, request, requestInstance } = context;\n\n\tif (!options.onRequestStream || !requestInstance.body) return;\n\n\tconst contentLength =\n\t\trequestInstance.headers.get(\"content-length\")\n\t\t?? new Headers(request.headers as HeadersInit).get(\"content-length\")\n\t\t?? (request.body as Blob | null)?.size;\n\n\tlet totalBytes = Number(contentLength ?? 0);\n\n\tconst shouldForceContentLengthCalc = isObject(options.forceCalculateStreamSize)\n\t\t? options.forceCalculateStreamSize.request\n\t\t: options.forceCalculateStreamSize;\n\n\t// If no content length is present, we read the total bytes from the body\n\tif (!contentLength && shouldForceContentLengthCalc) {\n\t\ttotalBytes = await calculateTotalBytesFromBody(requestInstance.clone().body, totalBytes);\n\t}\n\n\tlet transferredBytes = 0;\n\n\tawait executeHooksInTryBlock(\n\t\toptions.onRequestStream({\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\tevent: createProgressEvent({ chunk: new Uint8Array(), totalBytes, transferredBytes }),\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestInstance,\n\t\t})\n\t);\n\n\tconst body = requestInstance.body as ReadableStream<Uint8Array> | null;\n\n\tvoid new ReadableStream({\n\t\tstart: async (controller) => {\n\t\t\tif (!body) return;\n\n\t\t\tfor await (const chunk of body) {\n\t\t\t\ttransferredBytes += chunk.byteLength;\n\n\t\t\t\ttotalBytes = Math.max(totalBytes, transferredBytes);\n\n\t\t\t\tawait executeHooksInTryBlock(\n\t\t\t\t\toptions.onRequestStream?.({\n\t\t\t\t\t\tbaseConfig,\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tevent: createProgressEvent({ chunk, totalBytes, transferredBytes }),\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\trequest,\n\t\t\t\t\t\trequestInstance,\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t}\n\t\t\tcontroller.close();\n\t\t},\n\t});\n};\n\ntype StreamableResponseContext = RequestContext & { response: Response };\nexport const toStreamableResponse = async (context: StreamableResponseContext): Promise<Response> => {\n\tconst { baseConfig, config, options, request, response } = context;\n\n\tif (!options.onResponseStream || !response.body) {\n\t\treturn response;\n\t}\n\n\tconst contentLength = response.headers.get(\"content-length\");\n\n\tlet totalBytes = Number(contentLength ?? 0);\n\n\tconst shouldForceContentLengthCalc = isObject(options.forceCalculateStreamSize)\n\t\t? options.forceCalculateStreamSize.response\n\t\t: options.forceCalculateStreamSize;\n\n\t// If no content length is present and `forceContentLengthCalculation` is enabled, we read the total bytes from the body\n\tif (!contentLength && shouldForceContentLengthCalc) {\n\t\ttotalBytes = await calculateTotalBytesFromBody(response.clone().body, totalBytes);\n\t}\n\n\tlet transferredBytes = 0;\n\n\tawait executeHooksInTryBlock(\n\t\toptions.onResponseStream({\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\tevent: createProgressEvent({ chunk: new Uint8Array(), totalBytes, transferredBytes }),\n\t\t\toptions,\n\t\t\trequest,\n\t\t\tresponse,\n\t\t})\n\t);\n\n\tconst body = response.body as ReadableStream<Uint8Array> | null;\n\n\tconst stream = new ReadableStream({\n\t\tstart: async (controller) => {\n\t\t\tif (!body) return;\n\n\t\t\tfor await (const chunk of body) {\n\t\t\t\ttransferredBytes += chunk.byteLength;\n\n\t\t\t\ttotalBytes = Math.max(totalBytes, transferredBytes);\n\n\t\t\t\tawait executeHooksInTryBlock(\n\t\t\t\t\toptions.onResponseStream?.({\n\t\t\t\t\t\tbaseConfig,\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tevent: createProgressEvent({ chunk, totalBytes, transferredBytes }),\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\trequest,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t}\n\n\t\t\tcontroller.close();\n\t\t},\n\t});\n\n\treturn new Response(stream, response);\n};\n","import { dedupeDefaults } from \"./constants/default-options\";\nimport type { RequestContext } from \"./hooks\";\nimport { toStreamableRequest, toStreamableResponse } from \"./stream\";\nimport { getFetchImpl, waitFor } from \"./utils/common\";\nimport { isReadableStream } from \"./utils/guards\";\n\ntype RequestInfo = {\n\tcontroller: AbortController;\n\tresponsePromise: Promise<Response>;\n};\n\nexport type RequestInfoCache = Map<string | null, RequestInfo>;\n\ntype DedupeContext = RequestContext & {\n\t$GlobalRequestInfoCache: RequestInfoCache;\n\t$LocalRequestInfoCache: RequestInfoCache;\n\tnewFetchController: AbortController;\n};\n\nexport const getAbortErrorMessage = (\n\tdedupeKey: DedupeOptions[\"dedupeKey\"],\n\tfullURL: DedupeContext[\"options\"][\"fullURL\"]\n) => {\n\treturn dedupeKey\n\t\t? `Duplicate request detected - Aborting previous request with key '${dedupeKey}' as a new request was initiated`\n\t\t: `Duplicate request detected - Aborting previous request to '${fullURL}' as a new request with identical options was initiated`;\n};\n\nexport const createDedupeStrategy = async (context: DedupeContext) => {\n\tconst {\n\t\t$GlobalRequestInfoCache,\n\t\t$LocalRequestInfoCache,\n\t\tbaseConfig,\n\t\tconfig,\n\t\tnewFetchController,\n\t\toptions: globalOptions,\n\t\trequest: globalRequest,\n\t} = context;\n\n\tconst dedupeStrategy = globalOptions.dedupeStrategy ?? dedupeDefaults.dedupeStrategy;\n\n\tconst generateDedupeKey = () => {\n\t\tconst shouldHaveDedupeKey = dedupeStrategy === \"cancel\" || dedupeStrategy === \"defer\";\n\n\t\tif (!shouldHaveDedupeKey) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn `${globalOptions.fullURL}-${JSON.stringify({ options: globalOptions, request: globalRequest })}`;\n\t};\n\n\tconst dedupeKey = globalOptions.dedupeKey ?? generateDedupeKey();\n\n\tconst dedupeCacheScope = globalOptions.dedupeCacheScope ?? dedupeDefaults.dedupeCacheScope;\n\n\tconst $RequestInfoCache = (\n\t\t{\n\t\t\tglobal: $GlobalRequestInfoCache,\n\t\t\tlocal: $LocalRequestInfoCache,\n\t\t} satisfies Record<NonNullable<DedupeOptions[\"dedupeCacheScope\"]>, RequestInfoCache>\n\t)[dedupeCacheScope];\n\n\t// == This is to ensure cache operations only occur when key is available\n\tconst $RequestInfoCacheOrNull = dedupeKey !== null ? $RequestInfoCache : null;\n\n\t/******\n\t * == Add a small delay to the execution to ensure proper request deduplication when multiple requests with the same key start simultaneously.\n\t * == This gives time for the cache to be updated with the previous request info before the next request checks it.\n\t ******/\n\tif (dedupeKey !== null) {\n\t\tawait waitFor(0.1);\n\t}\n\n\tconst prevRequestInfo = $RequestInfoCacheOrNull?.get(dedupeKey);\n\n\tconst handleRequestCancelStrategy = () => {\n\t\tconst shouldCancelRequest = prevRequestInfo && dedupeStrategy === \"cancel\";\n\n\t\tif (!shouldCancelRequest) return;\n\n\t\tconst message = getAbortErrorMessage(globalOptions.dedupeKey, globalOptions.fullURL);\n\n\t\tconst reason = new DOMException(message, \"AbortError\");\n\n\t\tprevRequestInfo.controller.abort(reason);\n\n\t\t// == Adding this just so that eslint forces me put await when calling the function (it looks better that way tbh)\n\t\treturn Promise.resolve();\n\t};\n\n\tconst handleRequestDeferStrategy = async (deferContext: {\n\t\toptions: DedupeContext[\"options\"];\n\t\trequest: DedupeContext[\"request\"];\n\t}) => {\n\t\t// == Local options and request are needed so that transformations are applied can be applied to both from call site\n\t\tconst { options: localOptions, request: localRequest } = deferContext;\n\n\t\tconst fetchApi = getFetchImpl(localOptions.customFetchImpl);\n\n\t\tconst shouldUsePromiseFromCache = prevRequestInfo && dedupeStrategy === \"defer\";\n\n\t\tconst requestObjectForStream = isReadableStream(localRequest.body)\n\t\t\t? { ...localRequest, duplex: localRequest.duplex ?? \"half\" }\n\t\t\t: localRequest;\n\n\t\tconst requestInstance = new Request(\n\t\t\tlocalOptions.fullURL as NonNullable<typeof localOptions.fullURL>,\n\t\t\trequestObjectForStream as RequestInit\n\t\t);\n\n\t\tawait toStreamableRequest({\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\toptions: localOptions,\n\t\t\trequest: localRequest,\n\t\t\trequestInstance: requestInstance.clone(),\n\t\t});\n\n\t\tconst getFetchApiPromise = () => {\n\t\t\tif (isReadableStream(localRequest.body)) {\n\t\t\t\treturn fetchApi(requestInstance.clone());\n\t\t\t}\n\n\t\t\treturn fetchApi(\n\t\t\t\tlocalOptions.fullURL as NonNullable<typeof localOptions.fullURL>,\n\t\t\t\tlocalRequest as RequestInit\n\t\t\t);\n\t\t};\n\n\t\tconst responsePromise = shouldUsePromiseFromCache\n\t\t\t? prevRequestInfo.responsePromise\n\t\t\t: getFetchApiPromise();\n\n\t\t$RequestInfoCacheOrNull?.set(dedupeKey, { controller: newFetchController, responsePromise });\n\n\t\tconst streamableResponse = toStreamableResponse({\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\toptions: localOptions,\n\t\t\trequest: localRequest,\n\t\t\tresponse: await responsePromise,\n\t\t});\n\n\t\treturn streamableResponse;\n\t};\n\n\tconst removeDedupeKeyFromCache = () => {\n\t\t$RequestInfoCacheOrNull?.delete(dedupeKey);\n\t};\n\n\treturn {\n\t\tdedupeStrategy,\n\t\thandleRequestCancelStrategy,\n\t\thandleRequestDeferStrategy,\n\t\tremoveDedupeKeyFromCache,\n\t};\n};\n\nexport type DedupeOptions = {\n\t/**\n\t * Defines the scope of the deduplication cache, can be set to \"global\" | \"local\".\n\t * - If set to \"global\", the deduplication cache will be shared across all requests, regardless of whether they shared the same `createFetchClient` or not.\n\t * - If set to \"local\", the deduplication cache will be scoped to the current request.\n\t * @default \"local\"\n\t */\n\tdedupeCacheScope?: \"global\" | \"local\";\n\n\t/**\n\t * Custom request key to be used to identify a request in the fetch deduplication strategy.\n\t * @default the full request url + string formed from the request options\n\t */\n\tdedupeKey?: string;\n\n\t/**\n\t * Defines the deduplication strategy for the request, can be set to \"none\" | \"defer\" | \"cancel\".\n\t * - If set to \"cancel\", the previous pending request with the same request key will be cancelled and lets the new request through.\n\t * - If set to \"defer\", all new request with the same request key will be share the same response, until the previous one is completed.\n\t * - If set to \"none\", deduplication is disabled.\n\t * @default \"cancel\"\n\t */\n\tdedupeStrategy?: \"cancel\" | \"defer\" | \"none\";\n};\n","import { hookDefaults } from \"./constants/default-options\";\nimport {\n\ttype Hooks,\n\ttype HooksOrHooksArray,\n\ttype PluginExtraOptions,\n\ttype RequestContext,\n\tcomposeTwoHooks,\n\thookRegistries,\n} from \"./hooks\";\nimport type {\n\tBaseCallApiExtraOptions,\n\tCallApiExtraOptions,\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n} from \"./types/common\";\nimport type { AnyFunction, Awaitable } from \"./types/type-helpers\";\nimport type { InitURLOrURLObject } from \"./url\";\nimport { isArray, isFunction, isPlainObject, isString } from \"./utils/guards\";\nimport type { CallApiSchema } from \"./validation\";\n\nexport type PluginInitContext<TPluginExtraOptions = unknown> = RequestContext // eslint-disable-next-line perfectionist/sort-intersection-types -- Allow\n\t& PluginExtraOptions<TPluginExtraOptions> & { initURL: string };\n\nexport type PluginInitResult = Partial<\n\tOmit<PluginInitContext, \"initURL\" | \"request\"> & {\n\t\tinitURL: InitURLOrURLObject;\n\t\trequest: CallApiRequestOptions;\n\t}\n>;\n\nexport type PluginHooksWithMoreOptions<TMoreOptions = unknown> = HooksOrHooksArray<\n\tnever,\n\tnever,\n\tCallApiSchema,\n\tstring,\n\tTMoreOptions\n>;\n\nexport type PluginHooks<TData = never, TErrorData = never, TMoreOptions = unknown> = HooksOrHooksArray<\n\tTData,\n\tTErrorData,\n\tCallApiSchema,\n\tstring,\n\tTMoreOptions\n>;\n\nexport interface CallApiPlugin {\n\t/**\n\t * Defines additional options that can be passed to callApi\n\t */\n\tdefineExtraOptions?: (...params: never[]) => unknown;\n\n\t/**\n\t * A description for the plugin\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Hooks / Interceptors for the plugin\n\t */\n\thooks?: PluginHooks;\n\n\t/**\n\t * A unique id for the plugin\n\t */\n\tid: string;\n\n\t/**\n\t * A function that will be called when the plugin is initialized. This will be called before the any of the other internal functions.\n\t */\n\tinit?: (context: PluginInitContext) => Awaitable<PluginInitResult> | Awaitable<void>;\n\n\t/**\n\t * A name for the plugin\n\t */\n\tname: string;\n\n\t/**\n\t * A version for the plugin\n\t */\n\tversion?: string;\n}\n\nexport const definePlugin = <\n\t// eslint-disable-next-line perfectionist/sort-union-types -- Let the first one be first\n\tTPlugin extends CallApiPlugin | AnyFunction<CallApiPlugin>,\n>(\n\tplugin: TPlugin\n) => {\n\treturn plugin;\n};\n\nconst resolvePluginArray = (\n\tplugins: CallApiExtraOptions[\"plugins\"] | undefined,\n\tbasePlugins: BaseCallApiExtraOptions[\"plugins\"] | undefined\n) => {\n\tif (!plugins) {\n\t\treturn [];\n\t}\n\n\tif (isFunction(plugins)) {\n\t\treturn plugins({ basePlugins: basePlugins ?? [] });\n\t}\n\n\treturn plugins;\n};\n\nexport const initializePlugins = async (context: PluginInitContext) => {\n\tconst { baseConfig, config, initURL, options, request } = context;\n\n\tconst clonedHookRegistries = structuredClone(hookRegistries);\n\n\tconst addMainHooks = () => {\n\t\tfor (const key of Object.keys(clonedHookRegistries) as Array<keyof Hooks>) {\n\t\t\tconst baseHook = baseConfig;\n\t\t\tconst instanceHook = config[key];\n\n\t\t\tconst overriddenHook = options[key] as HooksOrHooksArray[typeof key];\n\n\t\t\t// If the base hook is an array and instance hook is defined, we need to compose it with the overridden hook\n\t\t\tconst mainHook =\n\t\t\t\tisArray(baseHook) && Boolean(instanceHook) ? [baseHook, instanceHook].flat() : overriddenHook;\n\n\t\t\tif (!mainHook) continue;\n\n\t\t\tclonedHookRegistries[key].add(mainHook as never);\n\t\t}\n\t};\n\n\tconst addPluginHooks = (pluginHooks: Required<CallApiPlugin>[\"hooks\"]) => {\n\t\tfor (const key of Object.keys(clonedHookRegistries) as Array<keyof Hooks>) {\n\t\t\tconst pluginHook = pluginHooks[key];\n\n\t\t\tif (!pluginHook) continue;\n\n\t\t\tclonedHookRegistries[key].add(pluginHook as never);\n\t\t}\n\t};\n\n\tconst mergedHooksExecutionOrder =\n\t\toptions.mergedHooksExecutionOrder ?? hookDefaults.mergedHooksExecutionOrder;\n\n\tif (mergedHooksExecutionOrder === \"mainHooksBeforePlugins\") {\n\t\taddMainHooks();\n\t}\n\n\tconst resolvedPlugins = resolvePluginArray(options.plugins, baseConfig.plugins);\n\n\tlet resolvedInitURL = initURL;\n\tlet resolvedOptions = options;\n\tlet resolvedRequestOptions = request;\n\n\tconst executePluginInit = async (pluginInit: CallApiPlugin[\"init\"]) => {\n\t\tif (!pluginInit) return;\n\n\t\tconst initResult = await pluginInit({\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\tinitURL,\n\t\t\toptions,\n\t\t\trequest,\n\t\t});\n\n\t\tif (!isPlainObject(initResult)) return;\n\n\t\tconst urlString = initResult.initURL?.toString();\n\n\t\tif (isString(urlString)) {\n\t\t\tresolvedInitURL = urlString;\n\t\t}\n\n\t\tif (isPlainObject(initResult.request)) {\n\t\t\tresolvedRequestOptions = initResult.request as CallApiRequestOptionsForHooks;\n\t\t}\n\n\t\tif (isPlainObject(initResult.options)) {\n\t\t\tresolvedOptions = initResult.options;\n\t\t}\n\t};\n\n\tfor (const plugin of resolvedPlugins) {\n\t\t// eslint-disable-next-line no-await-in-loop -- Await is necessary in this case.\n\t\tawait executePluginInit(plugin.init);\n\n\t\tif (!plugin.hooks) continue;\n\n\t\taddPluginHooks(plugin.hooks);\n\t}\n\n\tif (mergedHooksExecutionOrder === \"mainHooksAfterPlugins\") {\n\t\taddMainHooks();\n\t}\n\n\tconst resolvedHooks: Hooks = {};\n\n\tfor (const [key, hookRegistry] of Object.entries(clonedHookRegistries)) {\n\t\tconst flattenedHookArray = [...hookRegistry].flat();\n\n\t\tconst mergedHooksExecutionMode =\n\t\t\toptions.mergedHooksExecutionMode ?? hookDefaults.mergedHooksExecutionMode;\n\n\t\tconst composedHook = composeTwoHooks(flattenedHookArray, mergedHooksExecutionMode);\n\n\t\tcomposedHook && (resolvedHooks[key as keyof Hooks] = composedHook);\n\t}\n\n\treturn {\n\t\tresolvedHooks,\n\t\tresolvedInitURL: resolvedInitURL.toString(),\n\t\tresolvedOptions,\n\t\tresolvedRequestOptions: resolvedRequestOptions as CallApiRequestOptionsForHooks,\n\t};\n};\n","import { requestOptionDefaults, retryDefaults } from \"./constants/default-options\";\nimport type { ErrorContext, RequestContext } from \"./hooks\";\nimport type { MethodUnion } from \"./types\";\nimport type { Awaitable } from \"./types/type-helpers\";\nimport { isFunction, isHTTPError } from \"./utils/guards\";\n\ntype RetryCondition<TErrorData> = (context: ErrorContext<TErrorData>) => Awaitable<boolean>;\n\ntype InnerRetryKeys<TErrorData> = Exclude<keyof RetryOptions<TErrorData>, \"~retryAttemptCount\" | \"retry\">;\n\ntype InnerRetryOptions<TErrorData> = {\n\t[Key in InnerRetryKeys<TErrorData> as Key extends `retry${infer TRest}`\n\t\t? Uncapitalize<TRest> extends \"attempts\"\n\t\t\t? never\n\t\t\t: Uncapitalize<TRest>\n\t\t: Key]?: RetryOptions<TErrorData>[Key];\n} & {\n\tattempts: NonNullable<RetryOptions<TErrorData>[\"retryAttempts\"]>;\n};\n\nexport interface RetryOptions<TErrorData> {\n\t/**\n\t * Keeps track of the number of times the request has already been retried\n\t *\n\t * @deprecated **NOTE**: This property is used internally to track retries. Please abstain from modifying it.\n\t */\n\treadonly [\"~retryAttemptCount\"]?: number;\n\n\t/**\n\t * All retry options in a single object instead of separate properties\n\t */\n\tretry?: InnerRetryOptions<TErrorData>;\n\n\t/**\n\t * Number of allowed retry attempts on HTTP errors\n\t * @default 0\n\t */\n\tretryAttempts?: number;\n\n\t/**\n\t * Callback whose return value determines if a request should be retried or not\n\t */\n\tretryCondition?: RetryCondition<TErrorData>;\n\n\t/**\n\t * Delay between retries in milliseconds\n\t * @default 1000\n\t */\n\tretryDelay?: number | ((currentAttemptCount: number) => number);\n\n\t/**\n\t * Maximum delay in milliseconds. Only applies to exponential strategy\n\t * @default 10000\n\t */\n\tretryMaxDelay?: number;\n\n\t/**\n\t * HTTP methods that are allowed to retry\n\t * @default [\"GET\", \"POST\"]\n\t */\n\tretryMethods?: MethodUnion[];\n\n\t/**\n\t * HTTP status codes that trigger a retry\n\t */\n\tretryStatusCodes?: number[];\n\n\t/**\n\t * Strategy to use when retrying\n\t * @default \"linear\"\n\t */\n\tretryStrategy?: \"exponential\" | \"linear\";\n}\n\nconst getLinearDelay = (currentAttemptCount: number, options: RetryOptions<unknown>) => {\n\tconst retryDelay = options.retryDelay ?? options.retry?.delay;\n\n\tconst resolveRetryDelay =\n\t\t(isFunction(retryDelay) ? retryDelay(currentAttemptCount) : retryDelay) ?? retryDefaults.delay;\n\n\treturn resolveRetryDelay;\n};\n\nconst getExponentialDelay = (currentAttemptCount: number, options: RetryOptions<unknown>) => {\n\tconst retryDelay = options.retryDelay ?? options.retry?.delay ?? retryDefaults.delay;\n\n\tconst resolvedRetryDelay = Number(\n\t\tisFunction(retryDelay) ? retryDelay(currentAttemptCount) : retryDelay\n\t);\n\n\tconst maxDelay = Number(options.retryMaxDelay ?? options.retry?.maxDelay ?? retryDefaults.maxDelay);\n\n\tconst exponentialDelay = resolvedRetryDelay * 2 ** currentAttemptCount;\n\n\treturn Math.min(exponentialDelay, maxDelay);\n};\n\nexport const createRetryStrategy = (ctx: ErrorContext<unknown> & RequestContext) => {\n\tconst { options } = ctx;\n\n\t// eslint-disable-next-line ts-eslint/no-deprecated -- Allowed for internal use\n\tconst currentAttemptCount = options[\"~retryAttemptCount\"] ?? 1;\n\n\tconst retryStrategy = options.retryStrategy ?? options.retry?.strategy ?? retryDefaults.strategy;\n\n\tconst getDelay = () => {\n\t\tswitch (retryStrategy) {\n\t\t\tcase \"exponential\": {\n\t\t\t\treturn getExponentialDelay(currentAttemptCount, options);\n\t\t\t}\n\t\t\tcase \"linear\": {\n\t\t\t\treturn getLinearDelay(currentAttemptCount, options);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Invalid retry strategy: ${String(retryStrategy)}`);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst shouldAttemptRetry = async () => {\n\t\tconst retryCondition = options.retryCondition ?? options.retry?.condition ?? retryDefaults.condition;\n\n\t\tconst maximumRetryAttempts =\n\t\t\toptions.retryAttempts ?? options.retry?.attempts ?? retryDefaults.attempts;\n\n\t\tconst customRetryCondition = await retryCondition(ctx);\n\n\t\tconst baseShouldRetry = maximumRetryAttempts >= currentAttemptCount && customRetryCondition;\n\n\t\tif (!baseShouldRetry) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// == If error is not an HTTP error, just return true since at this point we know it's a retryable error\n\t\tif (!isHTTPError(ctx.error)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst selectedMethodArray = options.retryMethods ?? options.retry?.methods ?? retryDefaults.methods;\n\n\t\tconst retryMethods = new Set(selectedMethodArray);\n\n\t\tconst method = ctx.request.method ?? requestOptionDefaults.method;\n\n\t\tconst includesMethod = Boolean(method) && retryMethods.has(method);\n\n\t\tconst selectedStatusCodeArray = options.retryStatusCodes ?? options.retry?.statusCodes;\n\n\t\tconst retryStatusCodes = selectedStatusCodeArray ? new Set(selectedStatusCodeArray) : null;\n\n\t\tconst includesStatusCodes =\n\t\t\tBoolean(ctx.response?.status) && (retryStatusCodes?.has(ctx.response.status) ?? true);\n\n\t\tconst shouldRetry = includesMethod && includesStatusCodes;\n\n\t\treturn shouldRetry;\n\t};\n\n\treturn {\n\t\tcurrentAttemptCount,\n\t\tgetDelay,\n\t\tshouldAttemptRetry,\n\t};\n};\n","import { ValidationError } from \"./error\";\nimport type {\n\tBody,\n\tCallApiExtraOptions,\n\tCallApiRequestOptions,\n\tGlobalMeta,\n\tHeadersOption,\n\tMethodUnion,\n} from \"./types\";\nimport type { StandardSchemaV1 } from \"./types/standard-schema\";\nimport {\n\ttype AnyFunction,\n\ttype AnyString,\n\ttype Awaitable,\n\ttype Prettify,\n\ttype UnionToIntersection,\n\ttype Writeable,\n\tdefineEnum,\n} from \"./types/type-helpers\";\nimport type { Params, Query } from \"./url\";\nimport { isFunction } from \"./utils/guards\";\n\ntype InferSchemaInput<TSchema extends CallApiSchema[keyof CallApiSchema]> =\n\tTSchema extends StandardSchemaV1\n\t\t? StandardSchemaV1.InferInput<TSchema>\n\t\t: TSchema extends (value: infer TInput) => unknown\n\t\t\t? TInput\n\t\t\t: never;\n\nexport type InferSchemaResult<TSchema, TFallbackResult = NonNullable<unknown>> = undefined extends TSchema\n\t? TFallbackResult\n\t: TSchema extends StandardSchemaV1\n\t\t? StandardSchemaV1.InferOutput<TSchema>\n\t\t: TSchema extends AnyFunction<infer TResult>\n\t\t\t? Awaited<TResult>\n\t\t\t: TFallbackResult;\n\nconst handleValidatorFunction = async <TInput>(\n\tvalidator: Extract<CallApiSchema[keyof CallApiSchema], AnyFunction>,\n\tinputData: TInput\n): Promise<StandardSchemaV1.Result<TInput>> => {\n\ttry {\n\t\tconst result = await validator(inputData as never);\n\n\t\treturn { issues: undefined, value: result as never };\n\t} catch (error) {\n\t\treturn { issues: error as never, value: undefined };\n\t}\n};\n\nexport const standardSchemaParser = async <\n\tTSchema extends NonNullable<CallApiSchema[keyof CallApiSchema]>,\n>(\n\tschema: TSchema,\n\tinputData: InferSchemaInput<TSchema>,\n\tresponse?: Response | null\n): Promise<InferSchemaResult<TSchema>> => {\n\tconst result = isFunction(schema)\n\t\t? await handleValidatorFunction(schema, inputData)\n\t\t: await schema[\"~standard\"].validate(inputData);\n\n\t// == If the `issues` field exists, it means the validation failed\n\tif (result.issues) {\n\t\tthrow new ValidationError(\n\t\t\t{ issues: result.issues, response: response ?? null },\n\t\t\t{ cause: result.issues }\n\t\t);\n\t}\n\n\treturn result.value as never;\n};\n\nexport interface CallApiSchemaConfig {\n\t/**\n\t * The base url of the schema. By default it's the baseURL of the fetch instance.\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Disables runtime validation for the schema.\n\t */\n\tdisableRuntimeValidation?: boolean;\n\n\t/**\n\t * If `true`, the original input value will be used instead of the transformed/validated output.\n\t *\n\t * This is useful when you want to validate the input but don't want any transformations\n\t * applied by the validation schema (e.g., type coercion, default values, etc).\n\t */\n\tdisableValidationOutputApplication?: boolean;\n\n\t/**\n\t * Controls the inference of the method option based on the route modifiers (`@get/`, `@post/`, `@put/`, `@patch/`, `@delete/`).\n\t *\n\t * - When `true`, the method option is made required on the type level and is not automatically added to the request options.\n\t * - When `false` or `undefined` (default), the method option is not required on the type level, and is automatically added to the request options.\n\t *\n\t */\n\trequireHttpMethodProvision?: boolean;\n\n\t/**\n\t * Controls the strictness of API route validation.\n\t *\n\t * When true:\n\t * - Only routes explicitly defined in the schema will be considered valid to typescript\n\t * - Attempting to call undefined routes will result in type errors\n\t * - Useful for ensuring API calls conform exactly to your schema definition\n\t *\n\t * When false or undefined (default):\n\t * - All routes will be allowed, whether they are defined in the schema or not\n\t * - Provides more flexibility but less type safety\n\t *\n\t * @default false\n\t */\n\tstrict?: boolean;\n}\n\nexport interface CallApiSchema {\n\t/**\n\t * The schema to use for validating the request body.\n\t */\n\tbody?: StandardSchemaV1<Body> | ((body: Body) => Awaitable<Body>);\n\n\t/**\n\t * The schema to use for validating the response data.\n\t */\n\tdata?: StandardSchemaV1 | ((data: unknown) => unknown);\n\n\t/**\n\t * The schema to use for validating the response error data.\n\t */\n\terrorData?: StandardSchemaV1 | ((errorData: unknown) => unknown);\n\n\t/**\n\t * The schema to use for validating the request headers.\n\t */\n\theaders?:\n\t\t| StandardSchemaV1<HeadersOption | undefined>\n\t\t| ((headers: HeadersOption) => Awaitable<HeadersOption>);\n\n\t/**\n\t * The schema to use for validating the meta option.\n\t */\n\tmeta?: StandardSchemaV1<GlobalMeta | undefined> | ((meta: GlobalMeta) => Awaitable<GlobalMeta>);\n\n\t/**\n\t * The schema to use for validating the request method.\n\t */\n\tmethod?: StandardSchemaV1<MethodUnion | undefined> | ((method: MethodUnion) => Awaitable<MethodUnion>);\n\n\t/**\n\t * The schema to use for validating the request url parameters.\n\t */\n\tparams?: StandardSchemaV1<Params | undefined> | ((params: Params) => Awaitable<Params>);\n\n\t/**\n\t * The schema to use for validating the request url queries.\n\t */\n\tquery?: StandardSchemaV1<Query | undefined> | ((query: Query) => Awaitable<Query>);\n}\n\nexport const routeKeyMethods = defineEnum([\"delete\", \"get\", \"patch\", \"post\", \"put\"]);\n\nexport type RouteKeyMethods = (typeof routeKeyMethods)[number];\n\ntype PossibleRouteKey = `@${RouteKeyMethods}/` | AnyString;\n\nexport type BaseCallApiSchema = {\n\t[Key in PossibleRouteKey]?: CallApiSchema;\n};\n\nexport const defineSchema = <const TBaseSchema extends BaseCallApiSchema>(baseSchema: TBaseSchema) => {\n\treturn baseSchema as Writeable<typeof baseSchema, \"deep\">;\n};\n\ntype ValidationOptions<\n\tTSchema extends CallApiSchema[keyof CallApiSchema] = CallApiSchema[keyof CallApiSchema],\n> = {\n\tinputValue: InferSchemaInput<TSchema>;\n\tresponse?: Response | null;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nexport const handleValidation = async <TSchema extends CallApiSchema[keyof CallApiSchema]>(\n\tschema: TSchema | undefined,\n\tvalidationOptions: ValidationOptions<TSchema>\n): Promise<InferSchemaResult<TSchema>> => {\n\tconst { inputValue, response, schemaConfig } = validationOptions;\n\n\tif (!schema || schemaConfig?.disableRuntimeValidation) {\n\t\treturn inputValue as never;\n\t}\n\n\tconst validResult = await standardSchemaParser(schema, inputValue, response);\n\n\treturn validResult as never;\n};\n\ntype LastOf<TValue> =\n\tUnionToIntersection<TValue extends unknown ? () => TValue : never> extends () => infer R ? R : never;\n\ntype Push<TArray extends unknown[], TArrayItem> = [...TArray, TArrayItem];\n\ntype UnionToTuple<\n\tTUnion,\n\tTComputedLastUnion = LastOf<TUnion>,\n\tTComputedIsUnionEqualToNever = [TUnion] extends [never] ? true : false,\n> = true extends TComputedIsUnionEqualToNever\n\t? []\n\t: Push<UnionToTuple<Exclude<TUnion, TComputedLastUnion>>, TComputedLastUnion>;\n\nexport type Tuple<\n\tTTuple,\n\tTArray extends TTuple[] = [],\n> = UnionToTuple<TTuple>[\"length\"] extends TArray[\"length\"]\n\t? [...TArray]\n\t: Tuple<TTuple, [TTuple, ...TArray]>;\n\nconst extraOptionsToBeValidated = [\"meta\", \"params\", \"query\"] satisfies Tuple<\n\tExtract<keyof CallApiSchema, keyof CallApiExtraOptions>\n>;\n\ntype ExtraOptionsValidationOptions = {\n\textraOptions: CallApiExtraOptions;\n\tschema: CallApiSchema | undefined;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nconst handleExtraOptionsValidation = async (validationOptions: ExtraOptionsValidationOptions) => {\n\tconst { extraOptions, schema, schemaConfig } = validationOptions;\n\n\tconst validationResultArray = await Promise.all(\n\t\textraOptionsToBeValidated.map((propertyKey) =>\n\t\t\thandleValidation(schema?.[propertyKey], {\n\t\t\t\tinputValue: extraOptions[propertyKey],\n\t\t\t\tschemaConfig,\n\t\t\t})\n\t\t)\n\t);\n\n\tconst validatedResultObject: Prettify<\n\t\tPick<CallApiExtraOptions, (typeof extraOptionsToBeValidated)[number]>\n\t> = {};\n\n\tfor (const [index, propertyKey] of extraOptionsToBeValidated.entries()) {\n\t\tconst validationResult = validationResultArray[index];\n\n\t\tif (validationResult === undefined) continue;\n\n\t\tvalidatedResultObject[propertyKey] = validationResult as never;\n\t}\n\n\treturn validatedResultObject;\n};\n\nconst requestOptionsToBeValidated = [\"body\", \"headers\", \"method\"] satisfies Tuple<\n\tExtract<keyof CallApiSchema, keyof CallApiRequestOptions>\n>;\n\ntype RequestOptionsValidationOptions = {\n\trequestOptions: CallApiRequestOptions;\n\tschema: CallApiSchema | undefined;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nconst handleRequestOptionsValidation = async (validationOptions: RequestOptionsValidationOptions) => {\n\tconst { requestOptions, schema, schemaConfig } = validationOptions;\n\n\tconst validationResultArray = await Promise.all(\n\t\trequestOptionsToBeValidated.map((propertyKey) =>\n\t\t\thandleValidation(schema?.[propertyKey], {\n\t\t\t\tinputValue: requestOptions[propertyKey],\n\t\t\t\tschemaConfig,\n\t\t\t})\n\t\t)\n\t);\n\n\tconst validatedResultObject: Prettify<\n\t\tPick<CallApiRequestOptions, (typeof requestOptionsToBeValidated)[number]>\n\t> = {};\n\n\tfor (const [index, propertyKey] of requestOptionsToBeValidated.entries()) {\n\t\tconst validationResult = validationResultArray[index];\n\n\t\tif (validationResult === undefined) continue;\n\n\t\tvalidatedResultObject[propertyKey] = validationResult as never;\n\t}\n\n\treturn validatedResultObject;\n};\n\nexport const handleOptionsValidation = async (\n\tvalidationOptions: ExtraOptionsValidationOptions & RequestOptionsValidationOptions\n) => {\n\tconst { extraOptions, requestOptions, schema, schemaConfig } = validationOptions;\n\n\tif (schemaConfig?.disableRuntimeValidation) {\n\t\treturn {\n\t\t\textraOptionsValidationResult: null,\n\t\t\trequestOptionsValidationResult: null,\n\t\t};\n\t}\n\n\tconst [extraOptionsValidationResult, requestOptionsValidationResult] = await Promise.all([\n\t\thandleExtraOptionsValidation({ extraOptions, schema, schemaConfig }),\n\t\thandleRequestOptionsValidation({ requestOptions, schema, schemaConfig }),\n\t]);\n\n\treturn { extraOptionsValidationResult, requestOptionsValidationResult };\n};\n","import { requestOptionDefaults } from \"./constants/default-options\";\nimport type { CallApiExtraOptions, CallApiRequestOptions } from \"./types/common\";\nimport type { UnmaskType } from \"./types/type-helpers\";\nimport { toQueryString } from \"./utils\";\nimport { isArray } from \"./utils/guards\";\nimport { type CallApiSchemaConfig, routeKeyMethods } from \"./validation\";\n\nconst slash = \"/\";\nconst column = \":\";\nconst mergeUrlWithParams = (url: string, params: CallApiExtraOptions[\"params\"]) => {\n\tif (!params) {\n\t\treturn url;\n\t}\n\n\tlet newUrl = url;\n\n\tif (isArray(params)) {\n\t\tconst matchedParamArray = newUrl.split(slash).filter((param) => param.startsWith(column));\n\n\t\tfor (const [index, matchedParam] of matchedParamArray.entries()) {\n\t\t\tconst realParam = params[index] as string;\n\t\t\tnewUrl = newUrl.replace(matchedParam, realParam);\n\t\t}\n\n\t\treturn newUrl;\n\t}\n\n\tfor (const [key, value] of Object.entries(params)) {\n\t\tnewUrl = newUrl.replace(`${column}${key}`, String(value));\n\t}\n\n\treturn newUrl;\n};\n\nconst questionMark = \"?\";\nconst ampersand = \"&\";\nconst mergeUrlWithQuery = (url: string, query: CallApiExtraOptions[\"query\"]): string => {\n\tif (!query) {\n\t\treturn url;\n\t}\n\n\tconst queryString = toQueryString(query);\n\n\tif (queryString?.length === 0) {\n\t\treturn url;\n\t}\n\n\tif (url.endsWith(questionMark)) {\n\t\treturn `${url}${queryString}`;\n\t}\n\n\tif (url.includes(questionMark)) {\n\t\treturn `${url}${ampersand}${queryString}`;\n\t}\n\n\treturn `${url}${questionMark}${queryString}`;\n};\n\nexport const getCurrentRouteKey = (url: string, schemaConfig: CallApiSchemaConfig | undefined) => {\n\tlet currentRouteKey = url;\n\n\tif (schemaConfig?.baseURL && currentRouteKey.startsWith(schemaConfig.baseURL)) {\n\t\tcurrentRouteKey = currentRouteKey.replace(schemaConfig.baseURL, \"\");\n\t}\n\n\treturn currentRouteKey;\n};\n\n/**\n * @description\n * Extracts the method from the URL if it is a schema modifier.\n *\n * @param initURL - The URL to extract the method from.\n * @returns The method if it is a schema modifier, otherwise undefined.\n */\nexport const extractMethodFromURL = (initURL: string | undefined) => {\n\tif (!initURL?.startsWith(\"@\")) return;\n\n\tconst method = initURL.split(\"@\")[1]?.split(\"/\")[0];\n\n\tif (!method || !routeKeyMethods.includes(method)) return;\n\n\treturn method;\n};\n\nexport type GetMethodOptions = {\n\tinitURL: string | undefined;\n\tmethod: CallApiRequestOptions[\"method\"];\n\tschemaConfig?: CallApiSchemaConfig;\n};\n\nexport const getMethod = (options: GetMethodOptions) => {\n\tconst { initURL, method, schemaConfig } = options;\n\n\tif (schemaConfig?.requireHttpMethodProvision === true) {\n\t\treturn method?.toUpperCase() ?? requestOptionDefaults.method;\n\t}\n\n\treturn (\n\t\tmethod?.toUpperCase() ?? extractMethodFromURL(initURL)?.toUpperCase() ?? requestOptionDefaults.method\n\t);\n};\n\nexport const normalizeURL = (initURL: string) => {\n\tconst methodFromURL = extractMethodFromURL(initURL);\n\n\tif (!methodFromURL) {\n\t\treturn initURL;\n\t}\n\n\tconst normalizedURL = initURL.replace(`@${methodFromURL}/`, \"/\");\n\n\treturn normalizedURL;\n};\n\ntype GetFullURLOptions = {\n\tbaseURL: string | undefined;\n\tinitURL: string;\n\tparams: CallApiExtraOptions[\"params\"];\n\tquery: CallApiExtraOptions[\"query\"];\n};\n\nexport const getFullURL = (options: GetFullURLOptions) => {\n\tconst { baseURL, initURL, params, query } = options;\n\n\tconst normalizedURL = normalizeURL(initURL);\n\n\tconst urlWithMergedParams = mergeUrlWithParams(normalizedURL, params);\n\n\tconst urlWithMergedQueryAndParams = mergeUrlWithQuery(urlWithMergedParams, query);\n\n\tif (urlWithMergedQueryAndParams.startsWith(\"http\") || !baseURL) {\n\t\treturn urlWithMergedQueryAndParams;\n\t}\n\n\treturn `${baseURL}${urlWithMergedQueryAndParams}`;\n};\n\nexport type AllowedQueryParamValues = UnmaskType<boolean | number | string>;\n\nexport type Params = UnmaskType<\n\t// eslint-disable-next-line perfectionist/sort-union-types -- I need the Record to be first\n\tRecord<string, AllowedQueryParamValues> | AllowedQueryParamValues[]\n>;\n\nexport type Query = UnmaskType<Record<string, AllowedQueryParamValues>>;\n\nexport type InitURLOrURLObject = string | URL;\n\nexport interface URLOptions {\n\t/**\n\t * Base URL to be prepended to all request URLs\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Resolved request URL\n\t */\n\treadonly fullURL?: string;\n\n\t/**\n\t * The url string passed to the callApi instance\n\t */\n\treadonly initURL?: string;\n\n\t/**\n\t * The URL string passed to the callApi instance, but normalized (removed any method modifiers etc)\n\t */\n\treadonly initURLNormalized?: string;\n\n\t/**\n\t * Parameters to be appended to the URL (i.e: /:id)\n\t */\n\tparams?: Params;\n\n\t/**\n\t * Query parameters to append to the URL.\n\t */\n\tquery?: Query;\n}\n","import { type RequestInfoCache, createDedupeStrategy, getAbortErrorMessage } from \"./dedupe\";\nimport { HTTPError } from \"./error\";\nimport {\n\ttype ErrorContext,\n\ttype ExecuteHookInfo,\n\ttype RequestContext,\n\ttype RetryContext,\n\ttype SuccessContext,\n\texecuteHooksInCatchBlock,\n\texecuteHooksInTryBlock,\n} from \"./hooks\";\nimport { type CallApiPlugin, initializePlugins } from \"./plugins\";\nimport {\n\ttype ErrorInfo,\n\ttype ResponseTypeUnion,\n\ttype ResultModeUnion,\n\tgetCustomizedErrorResult,\n\tresolveErrorResult,\n\tresolveResponseData,\n\tresolveSuccessResult,\n} from \"./result\";\nimport { createRetryStrategy } from \"./retry\";\nimport type { GetCurrentRouteKey, InferHeadersOption, InferInitURL } from \"./types\";\nimport type {\n\tBaseCallApiConfig,\n\tBaseCallApiExtraOptions,\n\tCallApiExtraOptions,\n\tCallApiParameters,\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n\tCallApiResult,\n\tCombinedCallApiExtraOptions,\n} from \"./types/common\";\nimport type { DefaultDataType, DefaultPluginArray, DefaultThrowOnError } from \"./types/default-types\";\nimport type { AnyFunction } from \"./types/type-helpers\";\nimport { getCurrentRouteKey, getFullURL, getMethod, normalizeURL } from \"./url\";\nimport {\n\tcreateCombinedSignal,\n\tcreateTimeoutSignal,\n\tgetBody,\n\tgetHeaders,\n\tsplitBaseConfig,\n\tsplitConfig,\n\twaitFor,\n} from \"./utils/common\";\nimport { isFunction, isHTTPErrorInstance, isValidationErrorInstance } from \"./utils/guards\";\nimport {\n\ttype BaseCallApiSchema,\n\ttype CallApiSchema,\n\ttype CallApiSchemaConfig,\n\ttype InferSchemaResult,\n\thandleOptionsValidation,\n\thandleValidation,\n} from \"./validation\";\n\nconst $GlobalRequestInfoCache: RequestInfoCache = new Map();\n\nexport const createFetchClient = <\n\tTBaseData = DefaultDataType,\n\tTBaseErrorData = DefaultDataType,\n\tTBaseResultMode extends ResultModeUnion = ResultModeUnion,\n\tTBaseThrowOnError extends boolean = DefaultThrowOnError,\n\tTBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tconst TBaseSchema extends BaseCallApiSchema = BaseCallApiSchema,\n\tconst TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig,\n\tTBasePluginArray extends CallApiPlugin[] = DefaultPluginArray,\n>(\n\tinitBaseConfig: BaseCallApiConfig<\n\t\tTBaseData,\n\t\tTBaseErrorData,\n\t\tTBaseResultMode,\n\t\tTBaseThrowOnError,\n\t\tTBaseResponseType,\n\t\tTBaseSchema,\n\t\tTBaseSchemaConfig,\n\t\tTBasePluginArray\n\t> = {} as never\n) => {\n\tconst $LocalRequestInfoCache: RequestInfoCache = new Map();\n\n\tconst callApi = async <\n\t\tTData = TBaseData,\n\t\tTErrorData = TBaseErrorData,\n\t\tTResultMode extends ResultModeUnion = TBaseResultMode,\n\t\tTThrowOnError extends boolean = TBaseThrowOnError,\n\t\tTResponseType extends ResponseTypeUnion = TBaseResponseType,\n\t\tTSchemaConfig extends CallApiSchemaConfig = TBaseSchemaConfig,\n\t\tTInitURL extends InferInitURL<TBaseSchema, TSchemaConfig> = InferInitURL<TBaseSchema, TSchemaConfig>,\n\t\tTCurrentRouteKey extends GetCurrentRouteKey<TSchemaConfig, TInitURL> = GetCurrentRouteKey<\n\t\t\tTSchemaConfig,\n\t\t\tTInitURL\n\t\t>,\n\t\tTSchema extends CallApiSchema = NonNullable<TBaseSchema[TCurrentRouteKey]>,\n\t\tTPluginArray extends CallApiPlugin[] = TBasePluginArray,\n\t>(\n\t\t...parameters: CallApiParameters<\n\t\t\tInferSchemaResult<TSchema[\"data\"], TData>,\n\t\t\tInferSchemaResult<TSchema[\"errorData\"], TErrorData>,\n\t\t\tTResultMode,\n\t\t\tTThrowOnError,\n\t\t\tTResponseType,\n\t\t\tTBaseSchema,\n\t\t\tTSchema,\n\t\t\tTBaseSchemaConfig,\n\t\t\tTSchemaConfig,\n\t\t\tTInitURL,\n\t\t\tTCurrentRouteKey,\n\t\t\tTBasePluginArray,\n\t\t\tTPluginArray\n\t\t>\n\t): CallApiResult<\n\t\tInferSchemaResult<TSchema[\"data\"], TData>,\n\t\tInferSchemaResult<TSchema[\"errorData\"], TErrorData>,\n\t\tTResultMode,\n\t\tTThrowOnError,\n\t\tTResponseType\n\t> => {\n\t\tconst [initURLOrURLObject, initConfig = {}] = parameters;\n\n\t\tconst [fetchOptions, extraOptions] = splitConfig(initConfig);\n\n\t\tconst resolvedBaseConfig = isFunction(initBaseConfig)\n\t\t\t? initBaseConfig({\n\t\t\t\t\tinitURL: initURLOrURLObject.toString(),\n\t\t\t\t\toptions: extraOptions,\n\t\t\t\t\trequest: fetchOptions,\n\t\t\t\t})\n\t\t\t: initBaseConfig;\n\n\t\tconst [baseFetchOptions, baseExtraOptions] = splitBaseConfig(resolvedBaseConfig);\n\n\t\t// == Merged Extra Options\n\t\tconst mergedExtraOptions = {\n\t\t\t...baseExtraOptions,\n\t\t\t...(baseExtraOptions.skipAutoMergeFor !== \"all\"\n\t\t\t\t&& baseExtraOptions.skipAutoMergeFor !== \"options\"\n\t\t\t\t&& extraOptions),\n\t\t};\n\n\t\t// == Merged Request Options\n\t\tconst mergedRequestOptions = {\n\t\t\t...baseFetchOptions,\n\t\t\t...(baseExtraOptions.skipAutoMergeFor !== \"all\"\n\t\t\t\t&& baseExtraOptions.skipAutoMergeFor !== \"request\"\n\t\t\t\t&& fetchOptions),\n\t\t} satisfies CallApiRequestOptions;\n\n\t\tconst baseConfig = resolvedBaseConfig as BaseCallApiExtraOptions & CallApiRequestOptions;\n\t\tconst config = initConfig as CallApiExtraOptions & CallApiRequestOptions;\n\n\t\tconst { resolvedHooks, resolvedInitURL, resolvedOptions, resolvedRequestOptions } =\n\t\t\tawait initializePlugins({\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\tinitURL: initURLOrURLObject.toString(),\n\t\t\t\toptions: mergedExtraOptions as CombinedCallApiExtraOptions,\n\t\t\t\trequest: mergedRequestOptions as CallApiRequestOptionsForHooks,\n\t\t\t});\n\n\t\tconst fullURL = getFullURL({\n\t\t\tbaseURL: resolvedOptions.baseURL,\n\t\t\tinitURL: resolvedInitURL,\n\t\t\tparams: resolvedOptions.params,\n\t\t\tquery: resolvedOptions.query,\n\t\t});\n\n\t\tconst resolvedSchemaConfig = isFunction(extraOptions.schemaConfig)\n\t\t\t? extraOptions.schemaConfig({ baseSchemaConfig: baseExtraOptions.schemaConfig ?? {} })\n\t\t\t: (extraOptions.schemaConfig ?? baseExtraOptions.schemaConfig);\n\n\t\tconst currentRouteKey = getCurrentRouteKey(resolvedInitURL, resolvedSchemaConfig);\n\n\t\tconst routeSchema = baseExtraOptions.schema?.[currentRouteKey];\n\n\t\tconst resolvedSchema = isFunction(extraOptions.schema)\n\t\t\t? extraOptions.schema({\n\t\t\t\t\tbaseSchema: baseExtraOptions.schema ?? {},\n\t\t\t\t\tcurrentRouteSchema: routeSchema ?? {},\n\t\t\t\t})\n\t\t\t: (extraOptions.schema ?? routeSchema);\n\n\t\tlet options = {\n\t\t\t...resolvedOptions,\n\t\t\t...resolvedHooks,\n\n\t\t\tfullURL,\n\t\t\tinitURL: resolvedInitURL,\n\t\t\tinitURLNormalized: normalizeURL(resolvedInitURL),\n\t\t} satisfies CombinedCallApiExtraOptions;\n\n\t\tconst newFetchController = new AbortController();\n\n\t\tconst timeoutSignal = options.timeout != null ? createTimeoutSignal(options.timeout) : null;\n\n\t\tconst combinedSignal = createCombinedSignal(\n\t\t\tresolvedRequestOptions.signal,\n\t\t\ttimeoutSignal,\n\t\t\tnewFetchController.signal\n\t\t);\n\n\t\tlet request = {\n\t\t\t...resolvedRequestOptions,\n\t\t\t// == Making sure headers is always an object\n\t\t\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- False positive\n\t\t\theaders: resolvedRequestOptions.headers ?? {},\n\n\t\t\tsignal: combinedSignal,\n\t\t} satisfies CallApiRequestOptionsForHooks;\n\n\t\tconst {\n\t\t\tdedupeStrategy,\n\t\t\thandleRequestCancelStrategy,\n\t\t\thandleRequestDeferStrategy,\n\t\t\tremoveDedupeKeyFromCache,\n\t\t} = await createDedupeStrategy({\n\t\t\t$GlobalRequestInfoCache,\n\t\t\t$LocalRequestInfoCache,\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\tnewFetchController,\n\t\t\toptions,\n\t\t\trequest,\n\t\t});\n\n\t\ttry {\n\t\t\tawait handleRequestCancelStrategy();\n\n\t\t\tawait executeHooksInTryBlock(options.onRequest?.({ baseConfig, config, options, request }));\n\n\t\t\tconst { extraOptionsValidationResult, requestOptionsValidationResult } =\n\t\t\t\tawait handleOptionsValidation({\n\t\t\t\t\textraOptions: options,\n\t\t\t\t\trequestOptions: request,\n\t\t\t\t\tschema: resolvedSchema,\n\t\t\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t\t\t});\n\n\t\t\tconst shouldApplySchemaOutput =\n\t\t\t\tBoolean(extraOptionsValidationResult)\n\t\t\t\t|| Boolean(requestOptionsValidationResult)\n\t\t\t\t|| !resolvedSchemaConfig?.disableValidationOutputApplication;\n\n\t\t\tif (shouldApplySchemaOutput) {\n\t\t\t\toptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\t...extraOptionsValidationResult,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst rawBody = shouldApplySchemaOutput ? requestOptionsValidationResult?.body : request.body;\n\n\t\t\tconst validBody = getBody({\n\t\t\t\tbody: rawBody,\n\t\t\t\tbodySerializer: options.bodySerializer,\n\t\t\t});\n\n\t\t\ttype HeaderFn = Extract<InferHeadersOption<CallApiSchema>[\"headers\"], AnyFunction>;\n\n\t\t\tconst resolvedHeaders = isFunction<HeaderFn>(fetchOptions.headers)\n\t\t\t\t? fetchOptions.headers({ baseHeaders: baseFetchOptions.headers ?? {} })\n\t\t\t\t: (fetchOptions.headers ?? baseFetchOptions.headers);\n\n\t\t\tconst validHeaders = await getHeaders({\n\t\t\t\tauth: options.auth,\n\t\t\t\tbody: rawBody,\n\t\t\t\theaders: shouldApplySchemaOutput ? requestOptionsValidationResult?.headers : resolvedHeaders,\n\t\t\t});\n\n\t\t\tconst validMethod = getMethod({\n\t\t\t\tinitURL: resolvedInitURL,\n\t\t\t\tmethod: shouldApplySchemaOutput ? requestOptionsValidationResult?.method : request.method,\n\t\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t\t});\n\n\t\t\trequest = {\n\t\t\t\t...request,\n\t\t\t\t...(Boolean(validBody) && { body: validBody }),\n\t\t\t\t...(Boolean(validHeaders) && { headers: validHeaders }),\n\t\t\t\t...(Boolean(validMethod) && { method: validMethod }),\n\t\t\t};\n\n\t\t\tconst response = await handleRequestDeferStrategy({ options, request });\n\n\t\t\t// == Also clone response when dedupeStrategy is set to \"defer\" or when onRequestStream is set, to avoid error thrown from reading response.(whatever) more than once\n\t\t\tconst shouldCloneResponse = dedupeStrategy === \"defer\" || options.cloneResponse;\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorData = await resolveResponseData<TErrorData>(\n\t\t\t\t\tshouldCloneResponse ? response.clone() : response,\n\t\t\t\t\toptions.responseType,\n\t\t\t\t\toptions.responseParser\n\t\t\t\t);\n\n\t\t\t\tconst validErrorData = await handleValidation(resolvedSchema?.errorData, {\n\t\t\t\t\tinputValue: errorData,\n\t\t\t\t\tresponse,\n\t\t\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t\t\t});\n\n\t\t\t\t// == Push all error handling responsibilities to the catch block if not retrying\n\t\t\t\tthrow new HTTPError(\n\t\t\t\t\t{\n\t\t\t\t\t\tdefaultErrorMessage: options.defaultErrorMessage,\n\t\t\t\t\t\terrorData: validErrorData,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t},\n\t\t\t\t\t{ cause: validErrorData }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst successData = await resolveResponseData<TData>(\n\t\t\t\tshouldCloneResponse ? response.clone() : response,\n\t\t\t\toptions.responseType,\n\t\t\t\toptions.responseParser\n\t\t\t);\n\n\t\t\tconst validSuccessData = await handleValidation(resolvedSchema?.data, {\n\t\t\t\tinputValue: successData,\n\t\t\t\tresponse,\n\t\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t\t});\n\n\t\t\tconst successContext = {\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\tdata: validSuccessData,\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t\tresponse,\n\t\t\t} satisfies RequestContext & SuccessContext<unknown>;\n\n\t\t\tawait executeHooksInTryBlock(\n\t\t\t\toptions.onSuccess?.(successContext),\n\n\t\t\t\toptions.onResponse?.({ ...successContext, error: null })\n\t\t\t);\n\n\t\t\tconst successResult = resolveSuccessResult(successContext.data, {\n\t\t\t\tresponse: successContext.response,\n\t\t\t\tresultMode: options.resultMode,\n\t\t\t});\n\n\t\t\treturn successResult as never;\n\n\t\t\t// == Exhaustive Error handling\n\t\t} catch (error) {\n\t\t\tconst errorInfo = {\n\t\t\t\tcloneResponse: options.cloneResponse,\n\t\t\t\tdefaultErrorMessage: options.defaultErrorMessage,\n\t\t\t\tresultMode: options.resultMode,\n\t\t\t} satisfies ErrorInfo;\n\n\t\t\tconst generalErrorResult = resolveErrorResult(error, errorInfo);\n\n\t\t\tconst errorContext = {\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\terror: generalErrorResult?.error as never,\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t\tresponse: generalErrorResult?.response as never,\n\t\t\t} satisfies ErrorContext<unknown> & RequestContext;\n\n\t\t\tconst shouldThrowOnError = isFunction(options.throwOnError)\n\t\t\t\t? options.throwOnError(errorContext)\n\t\t\t\t: options.throwOnError;\n\n\t\t\tconst hookInfo = {\n\t\t\t\terrorInfo,\n\t\t\t\tshouldThrowOnError,\n\t\t\t} satisfies ExecuteHookInfo;\n\n\t\t\tconst handleRetryOrGetErrorResult = async () => {\n\t\t\t\tconst { currentAttemptCount, getDelay, shouldAttemptRetry } =\n\t\t\t\t\tcreateRetryStrategy(errorContext);\n\n\t\t\t\tconst shouldRetry = !combinedSignal.aborted && (await shouldAttemptRetry());\n\n\t\t\t\tif (shouldRetry) {\n\t\t\t\t\tconst retryContext = {\n\t\t\t\t\t\t...errorContext,\n\t\t\t\t\t\tretryAttemptCount: currentAttemptCount,\n\t\t\t\t\t} satisfies RetryContext<unknown>;\n\n\t\t\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t\t\t[options.onRetry?.(retryContext)],\n\t\t\t\t\t\thookInfo\n\t\t\t\t\t);\n\n\t\t\t\t\tif (hookError) {\n\t\t\t\t\t\treturn hookError;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst delay = getDelay();\n\n\t\t\t\t\tawait waitFor(delay);\n\n\t\t\t\t\tconst updatedOptions = {\n\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\"~retryAttemptCount\": currentAttemptCount + 1,\n\t\t\t\t\t} satisfies typeof config;\n\n\t\t\t\t\treturn callApi(initURLOrURLObject as never, updatedOptions as never) as never;\n\t\t\t\t}\n\n\t\t\t\tif (shouldThrowOnError) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\n\t\t\t\treturn generalErrorResult;\n\t\t\t};\n\n\t\t\tif (isHTTPErrorInstance<TErrorData>(error)) {\n\t\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t\t[\n\t\t\t\t\t\toptions.onResponseError?.(errorContext),\n\t\t\t\t\t\toptions.onError?.(errorContext),\n\t\t\t\t\t\toptions.onResponse?.({ ...errorContext, data: null }),\n\t\t\t\t\t],\n\t\t\t\t\thookInfo\n\t\t\t\t);\n\n\t\t\t\treturn (hookError ?? (await handleRetryOrGetErrorResult())) as never;\n\t\t\t}\n\n\t\t\tif (isValidationErrorInstance(error)) {\n\t\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t\t[\n\t\t\t\t\t\toptions.onValidationError?.(errorContext),\n\t\t\t\t\t\toptions.onRequestError?.(errorContext),\n\t\t\t\t\t\toptions.onError?.(errorContext),\n\t\t\t\t\t],\n\t\t\t\t\thookInfo\n\t\t\t\t);\n\n\t\t\t\treturn (hookError ?? (await handleRetryOrGetErrorResult())) as never;\n\t\t\t}\n\n\t\t\tlet message: string | undefined = (error as Error | undefined)?.message;\n\n\t\t\tif (error instanceof DOMException && error.name === \"AbortError\") {\n\t\t\t\tmessage = getAbortErrorMessage(options.dedupeKey, options.fullURL);\n\n\t\t\t\t!shouldThrowOnError && console.error(`${error.name}:`, message);\n\t\t\t}\n\n\t\t\tif (error instanceof DOMException && error.name === \"TimeoutError\") {\n\t\t\t\tmessage = `Request timed out after ${options.timeout}ms`;\n\n\t\t\t\t!shouldThrowOnError && console.error(`${error.name}:`, message);\n\t\t\t}\n\n\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t[options.onRequestError?.(errorContext), options.onError?.(errorContext)],\n\t\t\t\thookInfo\n\t\t\t);\n\n\t\t\treturn (hookError\n\t\t\t\t?? getCustomizedErrorResult(await handleRetryOrGetErrorResult(), { message })) as never;\n\n\t\t\t// == Removing the now unneeded AbortController from store\n\t\t} finally {\n\t\t\tremoveDedupeKeyFromCache();\n\t\t}\n\t};\n\n\treturn callApi;\n};\n\nexport const callApi = createFetchClient();\n","import type { CallApiPlugin } from \"./plugins\";\nimport type { ResponseTypeUnion, ResultModeUnion } from \"./result\";\nimport type { CallApiParameters, InferInitURL } from \"./types\";\nimport type { DefaultDataType, DefaultPluginArray, DefaultThrowOnError } from \"./types/default-types\";\nimport type { BaseCallApiSchema, CallApiSchema, CallApiSchemaConfig } from \"./validation\";\n\nconst defineParameters = <\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResultMode extends ResultModeUnion = ResultModeUnion,\n\tTThrowOnError extends boolean = DefaultThrowOnError,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tTBaseSchema extends BaseCallApiSchema = BaseCallApiSchema,\n\tTSchema extends CallApiSchema = CallApiSchema,\n\tTBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig,\n\tTSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig,\n\tTInitURL extends InferInitURL<BaseCallApiSchema, TSchemaConfig> = InferInitURL<\n\t\tBaseCallApiSchema,\n\t\tTSchemaConfig\n\t>,\n\tTCurrentRouteKey extends string = string,\n\tTBasePluginArray extends CallApiPlugin[] = DefaultPluginArray,\n\tTPluginArray extends CallApiPlugin[] = DefaultPluginArray,\n>(\n\t...parameters: CallApiParameters<\n\t\tTData,\n\t\tTErrorData,\n\t\tTResultMode,\n\t\tTThrowOnError,\n\t\tTResponseType,\n\t\tTBaseSchema,\n\t\tTSchema,\n\t\tTBaseSchemaConfig,\n\t\tTSchemaConfig,\n\t\tTInitURL,\n\t\tTCurrentRouteKey,\n\t\tTBasePluginArray,\n\t\tTPluginArray\n\t>\n) => {\n\treturn parameters;\n};\n\nexport { defineParameters };\n"],"mappings":";;;AASA,MAAa,kBAAkB,CAAYA,UAAoBC,YAAoB;CAClF,aAAa,MAAM,SAAS,aAAa;CACzC,MAAM,MAAM,SAAS,MAAM;CAC3B,UAAU,MAAM,SAAS,UAAU;CACnC,MAAM,YAAY;EACjB,MAAM,OAAO,MAAM,SAAS,MAAM;AAClC,SAAO,OAAO,KAAK;CACnB;CACD,QAAQ,MAAM,SAAS;CACvB,MAAM,MAAM,SAAS,MAAM;AAC3B;AAoBD,MAAa,sBAAsB,CAClCD,UACAE,cACAC,WACI;CACJ,MAAM,iBAAiB,UAAU,iBAAiB;CAClD,MAAM,uBAAuB,gBAAgB,iBAAiB;CAE9D,MAAM,uBAAuB,gBAA2B,UAAU,eAAe;AAEjF,MAAK,OAAO,OAAO,sBAAsB,qBAAqB,CAC7D,OAAM,IAAI,OAAO,yBAAyB,aAAa;AAGxD,QAAO,qBAAqB,uBAAuB;AACnD;AAoGD,MAAM,mBAAmB,CACxBC,YACI;CACJ,MAAM,gBAAgB;EACrB,KAAK,MAAM;EACX,kBAAkB,MAAM,cAAc,KAAK;EAC3C,aAAa,MAAM,QAAQ;EAC3B,0BAA0B,MAAM,cAAc,aAAa;CAC3D;AAED,QAAO;AACP;AAMD,MAAa,uBAAuB,CAACC,MAAeC,SAAqC;CACxF,MAAM,EAAE,UAAU,YAAY,GAAG;CAEjC,MAAM,UAAU;EACf;EACA,OAAO;EACP;CACA;CAED,MAAM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AAgB,MAAM,SAAS,gBAAgB;AACnE,eAAW,0BAA0B,QAAQ,QAAQ;AAErD,KAAC,sBAAsB,QAAQ,OAAO,EAAE,MAAM,KAAK,IAAI,QAAQ;GAC/D;GAED,MAAM,YAAY,MAAM,yBACvB,CAAC,QAAQ,iBAAiB,aAAa,EAAE,QAAQ,UAAU,aAAa,AAAC,GACzE,SACA;AAED,UAAQ,aACJ,yBAAyB,MAAM,6BAA6B,EAAE,EAAE,QAAS,EAAC;EAG9E,UAAS;AACT,6BAA0B;EAC1B;CACD;AAED,QAAOF;AACP;AAED,MAAa,UAAU,mBAAmB;;;;AC/c1C,MAAM,mBAAmB,CAkBxB,GAAG,eAeC;AACJ,QAAO;AACP"}
|
1
|
+
{"version":3,"file":"index.js","names":["response: Response","parser: Parser","responseType?: ResponseTypeUnion","parser?: Parser","details: CallApiResultErrorVariant<unknown> | CallApiResultSuccessVariant<unknown>","data: unknown","info: SuccessInfo","error: unknown","info: ErrorInfo","errorResult: ErrorResult","customErrorInfo: { message: string | undefined }","hooks: Array<AnyFunction | undefined>","mergedHooksExecutionMode: CallApiExtraOptionsForHooks[\"mergedHooksExecutionMode\"]","ctx: unknown","hookResultsOrPromise: Array<Awaitable<unknown>>","hookInfo: ExecuteHookInfo","options: {\n\tchunk: Uint8Array;\n\ttotalBytes: number;\n\ttransferredBytes: number;\n}","requestBody: Request[\"body\"] | null","existingTotalBytes: number","context: ToStreamableRequestContext","context: StreamableResponseContext","dedupeKey: DedupeOptions[\"dedupeKey\"]","fullURL: DedupeContext[\"options\"][\"fullURL\"]","context: DedupeContext","$GlobalRequestInfoCache","deferContext: {\n\t\toptions: DedupeContext[\"options\"];\n\t\trequest: DedupeContext[\"request\"];\n\t}","plugin: TPlugin","plugins: CallApiExtraOptions[\"plugins\"] | undefined","basePlugins: BaseCallApiExtraOptions[\"plugins\"] | undefined","context: PluginInitContext","pluginHooks: Required<CallApiPlugin>[\"hooks\"]","pluginInit: CallApiPlugin[\"init\"]","resolvedHooks: Hooks","currentAttemptCount: number","options: RetryOptions<unknown>","ctx: ErrorContext<unknown> & RequestContext","validator: Extract<CallApiSchema[keyof CallApiSchema], AnyFunction>","inputData: TInput","schema: TSchema","inputData: InferSchemaInput<TSchema>","response?: Response | null","baseSchema: TBaseSchema","schema: TSchema | undefined","validationOptions: ValidationOptions<TSchema>","validationOptions: ExtraOptionsValidationOptions","validatedResultObject: Prettify<\n\t\tPick<CallApiExtraOptions, (typeof extraOptionsToBeValidated)[number]>\n\t>","validationOptions: RequestOptionsValidationOptions","validatedResultObject: Prettify<\n\t\tPick<CallApiRequestOptions, (typeof requestOptionsToBeValidated)[number]>\n\t>","validationOptions: ExtraOptionsValidationOptions & RequestOptionsValidationOptions","url: string","params: CallApiExtraOptions[\"params\"]","query: CallApiExtraOptions[\"query\"]","schemaConfig: CallApiSchemaConfig | undefined","initURL: string | undefined","options: GetMethodOptions","initURL: string","options: GetFullURLOptions","$GlobalRequestInfoCache: RequestInfoCache","initBaseConfig: BaseCallApiConfig<\n\t\tTBaseData,\n\t\tTBaseErrorData,\n\t\tTBaseResultMode,\n\t\tTBaseThrowOnError,\n\t\tTBaseResponseType,\n\t\tTBaseSchema,\n\t\tTBaseSchemaConfig,\n\t\tTBasePluginArray\n\t>","$LocalRequestInfoCache: RequestInfoCache","callApi","hookError","message: string | undefined"],"sources":["../../src/result.ts","../../src/hooks.ts","../../src/stream.ts","../../src/dedupe.ts","../../src/plugins.ts","../../src/retry.ts","../../src/validation.ts","../../src/url.ts","../../src/createFetchClient.ts","../../src/defineParameters.ts"],"sourcesContent":["import { commonDefaults, responseDefaults } from \"./constants/default-options\";\nimport type { HTTPError, ValidationError } from \"./error\";\nimport type { CallApiExtraOptions } from \"./types\";\nimport type { DefaultDataType } from \"./types/default-types\";\nimport type { Awaitable, Prettify, UnmaskType } from \"./types/type-helpers\";\nimport { isHTTPErrorInstance, isValidationErrorInstance } from \"./utils/guards\";\n\ntype Parser = (responseString: string) => Awaitable<Record<string, unknown>>;\n\nexport const getResponseType = <TResponse>(response: Response, parser: Parser) => ({\n\tarrayBuffer: () => response.arrayBuffer(),\n\tblob: () => response.blob(),\n\tformData: () => response.formData(),\n\tjson: async () => {\n\t\tconst text = await response.text();\n\t\treturn parser(text) as TResponse;\n\t},\n\tstream: () => response.body,\n\ttext: () => response.text(),\n});\n\ntype InitResponseTypeMap<TResponse = unknown> = ReturnType<typeof getResponseType<TResponse>>;\n\nexport type ResponseTypeUnion = keyof InitResponseTypeMap | null;\n\nexport type ResponseTypeMap<TResponse> = {\n\t[Key in keyof InitResponseTypeMap<TResponse>]: Awaited<ReturnType<InitResponseTypeMap<TResponse>[Key]>>;\n};\n\nexport type GetResponseType<\n\tTResponse,\n\tTResponseType extends ResponseTypeUnion,\n\tTComputedResponseTypeMap extends ResponseTypeMap<TResponse> = ResponseTypeMap<TResponse>,\n> = null extends TResponseType\n\t? TComputedResponseTypeMap[\"json\"]\n\t: TResponseType extends NonNullable<ResponseTypeUnion>\n\t\t? TComputedResponseTypeMap[TResponseType]\n\t\t: never;\n\nexport const resolveResponseData = <TResponse>(\n\tresponse: Response,\n\tresponseType?: ResponseTypeUnion,\n\tparser?: Parser\n) => {\n\tconst selectedParser = parser ?? responseDefaults.responseParser;\n\tconst selectedResponseType = responseType ?? responseDefaults.responseType;\n\n\tconst RESPONSE_TYPE_LOOKUP = getResponseType<TResponse>(response, selectedParser);\n\n\tif (!Object.hasOwn(RESPONSE_TYPE_LOOKUP, selectedResponseType)) {\n\t\tthrow new Error(`Invalid response type: ${responseType}`);\n\t}\n\n\treturn RESPONSE_TYPE_LOOKUP[selectedResponseType]();\n};\n\nexport type CallApiResultSuccessVariant<TData> = {\n\tdata: TData;\n\terror: null;\n\tresponse: Response;\n};\n\nexport type PossibleJavaScriptError = UnmaskType<{\n\terrorData: PossibleJavaScriptError[\"originalError\"];\n\tmessage: string;\n\tname: \"AbortError\" | \"Error\" | \"SyntaxError\" | \"TimeoutError\" | \"TypeError\" | (`${string}Error` & {});\n\toriginalError: DOMException | Error | SyntaxError | TypeError;\n}>;\n\nexport type PossibleHTTPError<TErrorData> = Prettify<\n\tUnmaskType<{\n\t\terrorData: TErrorData;\n\t\tmessage: string;\n\t\tname: \"HTTPError\";\n\t\toriginalError: HTTPError;\n\t}>\n>;\n\nexport type PossibleValidationError = Prettify<\n\tUnmaskType<{\n\t\terrorData: ValidationError[\"errorData\"];\n\t\tmessage: string;\n\t\tname: \"ValidationError\";\n\t\toriginalError: ValidationError;\n\t}>\n>;\n\nexport type PossibleJavaScriptOrValidationError = UnmaskType<\n\tPossibleJavaScriptError | PossibleValidationError\n>;\n\nexport type CallApiResultErrorVariant<TErrorData> =\n\t| {\n\t\t\tdata: null;\n\t\t\terror: PossibleHTTPError<TErrorData>;\n\t\t\tresponse: Response;\n\t }\n\t| {\n\t\t\tdata: null;\n\t\t\terror: PossibleJavaScriptOrValidationError;\n\t\t\tresponse: Response | null;\n\t };\n\nexport type ResultModeMap<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tTComputedData = GetResponseType<TData, TResponseType>,\n\tTComputedErrorData = GetResponseType<TErrorData, TResponseType>,\n> = UnmaskType<{\n\t/* eslint-disable perfectionist/sort-union-types -- I need the first one to be first */\n\tall: CallApiResultSuccessVariant<TComputedData> | CallApiResultErrorVariant<TComputedErrorData>;\n\n\tallWithException: CallApiResultSuccessVariant<TComputedData>;\n\n\tonlySuccess:\n\t\t| CallApiResultErrorVariant<TComputedErrorData>[\"data\"]\n\t\t| CallApiResultSuccessVariant<TComputedData>[\"data\"];\n\n\tonlySuccessWithException: CallApiResultSuccessVariant<TComputedData>[\"data\"];\n\t/* eslint-enable perfectionist/sort-union-types -- I need the first one to be first */\n}>;\n\nexport type ResultModeUnion = keyof ResultModeMap | null;\n\nexport type GetCallApiResult<\n\tTData,\n\tTErrorData,\n\tTResultMode extends ResultModeUnion,\n\tTThrowOnError extends boolean,\n\tTResponseType extends ResponseTypeUnion,\n> = TErrorData extends false\n\t? ResultModeMap<TData, TErrorData, TResponseType>[\"onlySuccessWithException\"]\n\t: TErrorData extends false | undefined\n\t\t? ResultModeMap<TData, TErrorData, TResponseType>[\"onlySuccessWithException\"]\n\t\t: TErrorData extends false | null\n\t\t\t? ResultModeMap<TData, TErrorData, TResponseType>[\"onlySuccess\"]\n\t\t\t: null extends TResultMode\n\t\t\t\t? TThrowOnError extends true\n\t\t\t\t\t? ResultModeMap<TData, TErrorData, TResponseType>[\"allWithException\"]\n\t\t\t\t\t: ResultModeMap<TData, TErrorData, TResponseType>[\"all\"]\n\t\t\t\t: TResultMode extends NonNullable<ResultModeUnion>\n\t\t\t\t\t? ResultModeMap<TData, TErrorData, TResponseType>[TResultMode]\n\t\t\t\t\t: never;\n\ntype SuccessInfo = {\n\tresponse: Response;\n\tresultMode: CallApiExtraOptions[\"resultMode\"];\n};\n\ntype LazyResultModeMap = {\n\t[key in keyof ResultModeMap]: () => ResultModeMap[key];\n};\n\nconst getResultModeMap = (\n\tdetails: CallApiResultErrorVariant<unknown> | CallApiResultSuccessVariant<unknown>\n) => {\n\tconst resultModeMap = {\n\t\tall: () => details,\n\t\tallWithException: () => resultModeMap.all() as never,\n\t\tonlySuccess: () => details.data,\n\t\tonlySuccessWithException: () => resultModeMap.onlySuccess(),\n\t} satisfies LazyResultModeMap as LazyResultModeMap;\n\n\treturn resultModeMap;\n};\n\ntype SuccessResult = CallApiResultSuccessVariant<unknown> | null;\n\n// == The CallApiResult type is used to cast all return statements due to a design limitation in ts.\n// LINK - See https://www.zhenghao.io/posts/type-functions for more info\nexport const resolveSuccessResult = (data: unknown, info: SuccessInfo): SuccessResult => {\n\tconst { response, resultMode } = info;\n\n\tconst details = {\n\t\tdata,\n\t\terror: null,\n\t\tresponse,\n\t} satisfies CallApiResultSuccessVariant<unknown>;\n\n\tconst resultModeMap = getResultModeMap(details);\n\n\tconst successResult = resultModeMap[resultMode ?? \"all\"]();\n\n\treturn successResult as SuccessResult;\n};\n\nexport type ErrorInfo = {\n\tcloneResponse: CallApiExtraOptions[\"cloneResponse\"];\n\tdefaultErrorMessage: CallApiExtraOptions[\"defaultErrorMessage\"];\n\tmessage?: string;\n\tresultMode: CallApiExtraOptions[\"resultMode\"];\n};\n\ntype ErrorResult = CallApiResultErrorVariant<unknown> | null;\n\nexport const resolveErrorResult = (error: unknown, info: ErrorInfo): ErrorResult => {\n\tconst { cloneResponse, defaultErrorMessage, message: customErrorMessage, resultMode } = info;\n\n\tlet details = {\n\t\tdata: null,\n\t\terror: {\n\t\t\terrorData: error as Error,\n\t\t\tmessage: customErrorMessage ?? (error as Error).message,\n\t\t\tname: (error as Error).name as PossibleJavaScriptError[\"name\"],\n\t\t\toriginalError: error as Error,\n\t\t},\n\t\tresponse: null,\n\t} satisfies CallApiResultErrorVariant<unknown> as CallApiResultErrorVariant<unknown>;\n\n\tif (isValidationErrorInstance(error)) {\n\t\tconst { errorData, message, response } = error;\n\n\t\tdetails = {\n\t\t\tdata: null,\n\t\t\terror: {\n\t\t\t\terrorData,\n\t\t\t\tmessage,\n\t\t\t\tname: \"ValidationError\",\n\t\t\t\toriginalError: error,\n\t\t\t},\n\t\t\tresponse,\n\t\t};\n\t}\n\n\tif (isHTTPErrorInstance<never>(error)) {\n\t\tconst selectedDefaultErrorMessage = defaultErrorMessage ?? commonDefaults.defaultErrorMessage;\n\n\t\tconst { errorData, message = selectedDefaultErrorMessage, name, response } = error;\n\n\t\tdetails = {\n\t\t\tdata: null,\n\t\t\terror: {\n\t\t\t\terrorData,\n\t\t\t\tmessage,\n\t\t\t\tname,\n\t\t\t\toriginalError: error,\n\t\t\t},\n\t\t\tresponse: cloneResponse ? response.clone() : response,\n\t\t};\n\t}\n\n\tconst resultModeMap = getResultModeMap(details);\n\n\tconst errorResult = resultModeMap[resultMode ?? \"all\"]();\n\n\treturn errorResult as ErrorResult;\n};\n\nexport const getCustomizedErrorResult = (\n\terrorResult: ErrorResult,\n\tcustomErrorInfo: { message: string | undefined }\n): ErrorResult => {\n\tif (!errorResult) {\n\t\treturn null;\n\t}\n\n\tconst { message = errorResult.error.message } = customErrorInfo;\n\n\treturn {\n\t\t...errorResult,\n\t\terror: {\n\t\t\t...errorResult.error,\n\t\t\tmessage,\n\t\t} satisfies NonNullable<ErrorResult>[\"error\"] as never,\n\t};\n};\n","import type { ValidationError } from \"./error\";\nimport {\n\ttype ErrorInfo,\n\ttype PossibleHTTPError,\n\ttype PossibleJavaScriptOrValidationError,\n\tresolveErrorResult,\n} from \"./result\";\nimport type { StreamProgressEvent } from \"./stream\";\nimport type {\n\tBaseCallApiExtraOptions,\n\tCallApiExtraOptions,\n\tCallApiExtraOptionsForHooks,\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n} from \"./types/common\";\nimport type { DefaultDataType } from \"./types/default-types\";\nimport type { AnyFunction, Awaitable, UnmaskType } from \"./types/type-helpers\";\n\nexport type PluginExtraOptions<TPluginOptions = unknown> = {\n\toptions: Partial<TPluginOptions>;\n};\n\n/* eslint-disable perfectionist/sort-intersection-types -- Plugin options should come last */\nexport interface Hooks<TData = DefaultDataType, TErrorData = DefaultDataType, TPluginOptions = unknown> {\n\t/**\n\t * Hook that will be called when any error occurs within the request/response lifecycle, regardless of whether the error is from the api or not.\n\t * It is basically a combination of `onRequestError` and `onResponseError` hooks\n\t */\n\tonError?: (\n\t\tcontext: ErrorContext<TErrorData> & PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called just before the request is being made.\n\t */\n\tonRequest?: (context: RequestContext & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when an error occurs during the fetch request.\n\t */\n\tonRequestError?: (\n\t\tcontext: RequestErrorContext & PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when upload stream progress is tracked\n\t */\n\tonRequestStream?: (\n\t\tcontext: RequestStreamContext & PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when any response is received from the api, whether successful or not\n\t */\n\tonResponse?: (\n\t\tcontext: ResponseContext<TData, TErrorData> & PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when an error response is received from the api.\n\t */\n\tonResponseError?: (\n\t\tcontext: ResponseErrorContext<TErrorData> & PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when download stream progress is tracked\n\t */\n\tonResponseStream?: (\n\t\tcontext: ResponseStreamContext & PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when a request is retried.\n\t */\n\tonRetry?: (\n\t\tresponse: RetryContext<TErrorData> & PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when a successful response is received from the api.\n\t */\n\tonSuccess?: (context: SuccessContext<TData> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook that will be called when a validation error occurs.\n\t */\n\tonValidationError?: (\n\t\tcontext: ValidationErrorContext & PluginExtraOptions<TPluginOptions>\n\t) => Awaitable<unknown>;\n}\n/* eslint-enable perfectionist/sort-intersection-types -- Plugin options should come last */\n\nexport type HooksOrHooksArray<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTMoreOptions = unknown,\n> = {\n\t[Key in keyof Hooks<TData, TErrorData, TMoreOptions>]:\n\t\t| Hooks<TData, TErrorData, TMoreOptions>[Key]\n\t\t// eslint-disable-next-line perfectionist/sort-union-types -- I need arrays to be last\n\t\t| Array<Hooks<TData, TErrorData, TMoreOptions>[Key]>;\n};\n\nexport type RequestContext = {\n\t/**\n\t * Config object passed to createFetchClient\n\t */\n\tbaseConfig: BaseCallApiExtraOptions & CallApiRequestOptions;\n\t/**\n\t * Config object passed to the callApi instance\n\t */\n\tconfig: CallApiExtraOptions & CallApiRequestOptions;\n\t/**\n\t * Merged options consisting of extra options from createFetchClient, the callApi instance and default options.\n\t *\n\t */\n\toptions: CallApiExtraOptionsForHooks;\n\t/**\n\t * Merged request consisting of request options from createFetchClient, the callApi instance and default request options.\n\t */\n\trequest: CallApiRequestOptionsForHooks;\n};\n\nexport type ResponseContext<TData, TErrorData> = RequestContext\n\t& (\n\t\t| {\n\t\t\t\tdata: null;\n\t\t\t\terror: PossibleHTTPError<TErrorData>;\n\t\t\t\tresponse: Response;\n\t\t }\n\t\t| {\n\t\t\t\tdata: null;\n\t\t\t\terror: PossibleJavaScriptOrValidationError;\n\t\t\t\tresponse: Response | null;\n\t\t }\n\t\t| {\n\t\t\t\tdata: TData;\n\t\t\t\terror: null;\n\t\t\t\tresponse: Response;\n\t\t }\n\t);\n\nexport type ValidationErrorContext = RequestContext & {\n\terror: ValidationError;\n\tresponse: Response | null;\n};\n\nexport type SuccessContext<TData> = RequestContext & {\n\tdata: TData;\n\tresponse: Response;\n};\n\nexport type RequestErrorContext = UnmaskType<\n\tRequestContext & {\n\t\terror: PossibleJavaScriptOrValidationError;\n\t\tresponse: null;\n\t}\n>;\n\nexport type ResponseErrorContext<TErrorData> = UnmaskType<\n\tExtract<ErrorContext<TErrorData>, { error: PossibleHTTPError<TErrorData> }> & RequestContext\n>;\n\nexport type RetryContext<TErrorData> = UnmaskType<\n\tErrorContext<TErrorData> & { retryAttemptCount: number }\n>;\n\nexport type ErrorContext<TErrorData> = UnmaskType<\n\tRequestContext\n\t\t& (\n\t\t\t| {\n\t\t\t\t\terror: PossibleHTTPError<TErrorData>;\n\t\t\t\t\tresponse: Response;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\terror: PossibleJavaScriptOrValidationError;\n\t\t\t\t\tresponse: Response | null;\n\t\t\t }\n\t\t)\n>;\n\nexport type RequestStreamContext = UnmaskType<\n\tRequestContext & {\n\t\tevent: StreamProgressEvent;\n\t\trequestInstance: Request;\n\t}\n>;\n\nexport type ResponseStreamContext = UnmaskType<\n\tRequestContext & {\n\t\tevent: StreamProgressEvent;\n\t\tresponse: Response;\n\t}\n>;\n\ntype HookRegistries = Required<{\n\t[Key in keyof Hooks]: Set<Hooks[Key]>;\n}>;\n\nexport const hookRegistries = {\n\tonError: new Set(),\n\tonRequest: new Set(),\n\tonRequestError: new Set(),\n\tonRequestStream: new Set(),\n\tonResponse: new Set(),\n\tonResponseError: new Set(),\n\tonResponseStream: new Set(),\n\tonRetry: new Set(),\n\tonSuccess: new Set(),\n\tonValidationError: new Set(),\n} satisfies HookRegistries;\n\nexport const composeTwoHooks = (\n\thooks: Array<AnyFunction | undefined>,\n\tmergedHooksExecutionMode: CallApiExtraOptionsForHooks[\"mergedHooksExecutionMode\"]\n) => {\n\tif (hooks.length === 0) return;\n\n\tconst mergedHook = async (ctx: unknown) => {\n\t\tif (mergedHooksExecutionMode === \"sequential\") {\n\t\t\tfor (const hook of hooks) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop -- This is necessary in this case\n\t\t\t\tawait hook?.(ctx);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (mergedHooksExecutionMode === \"parallel\") {\n\t\t\tconst hookArray = [...hooks];\n\n\t\t\tawait Promise.all(hookArray.map((uniqueHook) => uniqueHook?.(ctx)));\n\t\t}\n\t};\n\n\treturn mergedHook;\n};\n\nexport const executeHooksInTryBlock = async (...hookResultsOrPromise: Array<Awaitable<unknown>>) => {\n\tawait Promise.all(hookResultsOrPromise);\n};\n\nexport type ExecuteHookInfo = {\n\terrorInfo: ErrorInfo;\n\tshouldThrowOnError: boolean | undefined;\n};\n\nexport const executeHooksInCatchBlock = async (\n\thookResultsOrPromise: Array<Awaitable<unknown>>,\n\thookInfo: ExecuteHookInfo\n) => {\n\tconst { errorInfo, shouldThrowOnError } = hookInfo;\n\n\ttry {\n\t\tawait Promise.all(hookResultsOrPromise);\n\n\t\treturn null;\n\t} catch (hookError) {\n\t\tconst hookErrorResult = resolveErrorResult(hookError, errorInfo);\n\n\t\tif (shouldThrowOnError) {\n\t\t\tthrow hookError;\n\t\t}\n\n\t\treturn hookErrorResult;\n\t}\n};\n","import { type RequestContext, executeHooksInTryBlock } from \"./hooks\";\nimport { isObject } from \"./utils/guards\";\n\nexport type StreamProgressEvent = {\n\t/**\n\t * Current chunk of data being streamed\n\t */\n\tchunk: Uint8Array;\n\t/**\n\t * Progress in percentage\n\t */\n\tprogress: number;\n\t/**\n\t * Total size of data in bytes\n\t */\n\ttotalBytes: number;\n\t/**\n\t * Amount of data transferred so far\n\t */\n\ttransferredBytes: number;\n};\n\ndeclare global {\n\tinterface ReadableStream<R> {\n\t\t[Symbol.asyncIterator]: () => AsyncIterableIterator<R>;\n\t}\n}\n\nconst createProgressEvent = (options: {\n\tchunk: Uint8Array;\n\ttotalBytes: number;\n\ttransferredBytes: number;\n}): StreamProgressEvent => {\n\tconst { chunk, totalBytes, transferredBytes } = options;\n\n\treturn {\n\t\tchunk,\n\t\tprogress: Math.round((transferredBytes / totalBytes) * 100) || 0,\n\t\ttotalBytes,\n\t\ttransferredBytes,\n\t};\n};\n\nconst calculateTotalBytesFromBody = async (\n\trequestBody: Request[\"body\"] | null,\n\texistingTotalBytes: number\n) => {\n\tlet totalBytes = existingTotalBytes;\n\n\tif (!requestBody) {\n\t\treturn totalBytes;\n\t}\n\n\tfor await (const chunk of requestBody) {\n\t\ttotalBytes += chunk.byteLength;\n\t}\n\n\treturn totalBytes;\n};\n\ntype ToStreamableRequestContext = RequestContext & { requestInstance: Request };\n\nexport const toStreamableRequest = async (context: ToStreamableRequestContext) => {\n\tconst { baseConfig, config, options, request, requestInstance } = context;\n\n\tif (!options.onRequestStream || !requestInstance.body) return;\n\n\tconst contentLength =\n\t\trequestInstance.headers.get(\"content-length\")\n\t\t?? new Headers(request.headers as HeadersInit).get(\"content-length\")\n\t\t?? (request.body as Blob | null)?.size;\n\n\tlet totalBytes = Number(contentLength ?? 0);\n\n\tconst shouldForceContentLengthCalc = isObject(options.forceCalculateStreamSize)\n\t\t? options.forceCalculateStreamSize.request\n\t\t: options.forceCalculateStreamSize;\n\n\t// If no content length is present, we read the total bytes from the body\n\tif (!contentLength && shouldForceContentLengthCalc) {\n\t\ttotalBytes = await calculateTotalBytesFromBody(requestInstance.clone().body, totalBytes);\n\t}\n\n\tlet transferredBytes = 0;\n\n\tawait executeHooksInTryBlock(\n\t\toptions.onRequestStream({\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\tevent: createProgressEvent({ chunk: new Uint8Array(), totalBytes, transferredBytes }),\n\t\t\toptions,\n\t\t\trequest,\n\t\t\trequestInstance,\n\t\t})\n\t);\n\n\tconst body = requestInstance.body as ReadableStream<Uint8Array> | null;\n\n\tvoid new ReadableStream({\n\t\tstart: async (controller) => {\n\t\t\tif (!body) return;\n\n\t\t\tfor await (const chunk of body) {\n\t\t\t\ttransferredBytes += chunk.byteLength;\n\n\t\t\t\ttotalBytes = Math.max(totalBytes, transferredBytes);\n\n\t\t\t\tawait executeHooksInTryBlock(\n\t\t\t\t\toptions.onRequestStream?.({\n\t\t\t\t\t\tbaseConfig,\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tevent: createProgressEvent({ chunk, totalBytes, transferredBytes }),\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\trequest,\n\t\t\t\t\t\trequestInstance,\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t}\n\t\t\tcontroller.close();\n\t\t},\n\t});\n};\n\ntype StreamableResponseContext = RequestContext & { response: Response };\nexport const toStreamableResponse = async (context: StreamableResponseContext): Promise<Response> => {\n\tconst { baseConfig, config, options, request, response } = context;\n\n\tif (!options.onResponseStream || !response.body) {\n\t\treturn response;\n\t}\n\n\tconst contentLength = response.headers.get(\"content-length\");\n\n\tlet totalBytes = Number(contentLength ?? 0);\n\n\tconst shouldForceContentLengthCalc = isObject(options.forceCalculateStreamSize)\n\t\t? options.forceCalculateStreamSize.response\n\t\t: options.forceCalculateStreamSize;\n\n\t// If no content length is present and `forceContentLengthCalculation` is enabled, we read the total bytes from the body\n\tif (!contentLength && shouldForceContentLengthCalc) {\n\t\ttotalBytes = await calculateTotalBytesFromBody(response.clone().body, totalBytes);\n\t}\n\n\tlet transferredBytes = 0;\n\n\tawait executeHooksInTryBlock(\n\t\toptions.onResponseStream({\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\tevent: createProgressEvent({ chunk: new Uint8Array(), totalBytes, transferredBytes }),\n\t\t\toptions,\n\t\t\trequest,\n\t\t\tresponse,\n\t\t})\n\t);\n\n\tconst body = response.body as ReadableStream<Uint8Array> | null;\n\n\tconst stream = new ReadableStream({\n\t\tstart: async (controller) => {\n\t\t\tif (!body) return;\n\n\t\t\tfor await (const chunk of body) {\n\t\t\t\ttransferredBytes += chunk.byteLength;\n\n\t\t\t\ttotalBytes = Math.max(totalBytes, transferredBytes);\n\n\t\t\t\tawait executeHooksInTryBlock(\n\t\t\t\t\toptions.onResponseStream?.({\n\t\t\t\t\t\tbaseConfig,\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tevent: createProgressEvent({ chunk, totalBytes, transferredBytes }),\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\trequest,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t}\n\n\t\t\tcontroller.close();\n\t\t},\n\t});\n\n\treturn new Response(stream, response);\n};\n","import { dedupeDefaults } from \"./constants/default-options\";\nimport type { RequestContext } from \"./hooks\";\nimport { toStreamableRequest, toStreamableResponse } from \"./stream\";\nimport { getFetchImpl, waitFor } from \"./utils/common\";\nimport { isReadableStream } from \"./utils/guards\";\n\ntype RequestInfo = {\n\tcontroller: AbortController;\n\tresponsePromise: Promise<Response>;\n};\n\nexport type RequestInfoCache = Map<string | null, RequestInfo>;\n\ntype DedupeContext = RequestContext & {\n\t$GlobalRequestInfoCache: RequestInfoCache;\n\t$LocalRequestInfoCache: RequestInfoCache;\n\tnewFetchController: AbortController;\n};\n\nexport const getAbortErrorMessage = (\n\tdedupeKey: DedupeOptions[\"dedupeKey\"],\n\tfullURL: DedupeContext[\"options\"][\"fullURL\"]\n) => {\n\treturn dedupeKey\n\t\t? `Duplicate request detected - Aborting previous request with key '${dedupeKey}' as a new request was initiated`\n\t\t: `Duplicate request detected - Aborting previous request to '${fullURL}' as a new request with identical options was initiated`;\n};\n\nexport const createDedupeStrategy = async (context: DedupeContext) => {\n\tconst {\n\t\t$GlobalRequestInfoCache,\n\t\t$LocalRequestInfoCache,\n\t\tbaseConfig,\n\t\tconfig,\n\t\tnewFetchController,\n\t\toptions: globalOptions,\n\t\trequest: globalRequest,\n\t} = context;\n\n\tconst dedupeStrategy = globalOptions.dedupeStrategy ?? dedupeDefaults.dedupeStrategy;\n\n\tconst generateDedupeKey = () => {\n\t\tconst shouldHaveDedupeKey = dedupeStrategy === \"cancel\" || dedupeStrategy === \"defer\";\n\n\t\tif (!shouldHaveDedupeKey) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn `${globalOptions.fullURL}-${JSON.stringify({ options: globalOptions, request: globalRequest })}`;\n\t};\n\n\tconst dedupeKey = globalOptions.dedupeKey ?? generateDedupeKey();\n\n\tconst dedupeCacheScope = globalOptions.dedupeCacheScope ?? dedupeDefaults.dedupeCacheScope;\n\n\tconst $RequestInfoCache = (\n\t\t{\n\t\t\tglobal: $GlobalRequestInfoCache,\n\t\t\tlocal: $LocalRequestInfoCache,\n\t\t} satisfies Record<NonNullable<DedupeOptions[\"dedupeCacheScope\"]>, RequestInfoCache>\n\t)[dedupeCacheScope];\n\n\t// == This is to ensure cache operations only occur when key is available\n\tconst $RequestInfoCacheOrNull = dedupeKey !== null ? $RequestInfoCache : null;\n\n\t/******\n\t * == Add a small delay to the execution to ensure proper request deduplication when multiple requests with the same key start simultaneously.\n\t * == This gives time for the cache to be updated with the previous request info before the next request checks it.\n\t ******/\n\tif (dedupeKey !== null) {\n\t\tawait waitFor(0.1);\n\t}\n\n\tconst prevRequestInfo = $RequestInfoCacheOrNull?.get(dedupeKey);\n\n\tconst handleRequestCancelStrategy = () => {\n\t\tconst shouldCancelRequest = prevRequestInfo && dedupeStrategy === \"cancel\";\n\n\t\tif (!shouldCancelRequest) return;\n\n\t\tconst message = getAbortErrorMessage(globalOptions.dedupeKey, globalOptions.fullURL);\n\n\t\tconst reason = new DOMException(message, \"AbortError\");\n\n\t\tprevRequestInfo.controller.abort(reason);\n\n\t\t// == Adding this just so that eslint forces me put await when calling the function (it looks better that way tbh)\n\t\treturn Promise.resolve();\n\t};\n\n\tconst handleRequestDeferStrategy = async (deferContext: {\n\t\toptions: DedupeContext[\"options\"];\n\t\trequest: DedupeContext[\"request\"];\n\t}) => {\n\t\t// == Local options and request are needed so that transformations are applied can be applied to both from call site\n\t\tconst { options: localOptions, request: localRequest } = deferContext;\n\n\t\tconst fetchApi = getFetchImpl(localOptions.customFetchImpl);\n\n\t\tconst shouldUsePromiseFromCache = prevRequestInfo && dedupeStrategy === \"defer\";\n\n\t\tconst requestObjectForStream = isReadableStream(localRequest.body)\n\t\t\t? { ...localRequest, duplex: localRequest.duplex ?? \"half\" }\n\t\t\t: localRequest;\n\n\t\tconst requestInstance = new Request(\n\t\t\tlocalOptions.fullURL as NonNullable<typeof localOptions.fullURL>,\n\t\t\trequestObjectForStream as RequestInit\n\t\t);\n\n\t\tawait toStreamableRequest({\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\toptions: localOptions,\n\t\t\trequest: localRequest,\n\t\t\trequestInstance: requestInstance.clone(),\n\t\t});\n\n\t\tconst getFetchApiPromise = () => {\n\t\t\tif (isReadableStream(localRequest.body)) {\n\t\t\t\treturn fetchApi(requestInstance.clone());\n\t\t\t}\n\n\t\t\treturn fetchApi(\n\t\t\t\tlocalOptions.fullURL as NonNullable<typeof localOptions.fullURL>,\n\t\t\t\tlocalRequest as RequestInit\n\t\t\t);\n\t\t};\n\n\t\tconst responsePromise = shouldUsePromiseFromCache\n\t\t\t? prevRequestInfo.responsePromise\n\t\t\t: getFetchApiPromise();\n\n\t\t$RequestInfoCacheOrNull?.set(dedupeKey, { controller: newFetchController, responsePromise });\n\n\t\tconst streamableResponse = toStreamableResponse({\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\toptions: localOptions,\n\t\t\trequest: localRequest,\n\t\t\tresponse: await responsePromise,\n\t\t});\n\n\t\treturn streamableResponse;\n\t};\n\n\tconst removeDedupeKeyFromCache = () => {\n\t\t$RequestInfoCacheOrNull?.delete(dedupeKey);\n\t};\n\n\treturn {\n\t\tdedupeStrategy,\n\t\thandleRequestCancelStrategy,\n\t\thandleRequestDeferStrategy,\n\t\tremoveDedupeKeyFromCache,\n\t};\n};\n\nexport type DedupeOptions = {\n\t/**\n\t * Defines the scope of the deduplication cache, can be set to \"global\" | \"local\".\n\t * - If set to \"global\", the deduplication cache will be shared across all requests, regardless of whether they shared the same `createFetchClient` or not.\n\t * - If set to \"local\", the deduplication cache will be scoped to the current request.\n\t * @default \"local\"\n\t */\n\tdedupeCacheScope?: \"global\" | \"local\";\n\n\t/**\n\t * Custom request key to be used to identify a request in the fetch deduplication strategy.\n\t * @default the full request url + string formed from the request options\n\t */\n\tdedupeKey?: string;\n\n\t/**\n\t * Defines the deduplication strategy for the request, can be set to \"none\" | \"defer\" | \"cancel\".\n\t * - If set to \"cancel\", the previous pending request with the same request key will be cancelled and lets the new request through.\n\t * - If set to \"defer\", all new request with the same request key will be share the same response, until the previous one is completed.\n\t * - If set to \"none\", deduplication is disabled.\n\t * @default \"cancel\"\n\t */\n\tdedupeStrategy?: \"cancel\" | \"defer\" | \"none\";\n};\n","import { hookDefaults } from \"./constants/default-options\";\nimport {\n\ttype Hooks,\n\ttype HooksOrHooksArray,\n\ttype PluginExtraOptions,\n\ttype RequestContext,\n\tcomposeTwoHooks,\n\thookRegistries,\n} from \"./hooks\";\nimport type {\n\tBaseCallApiExtraOptions,\n\tCallApiExtraOptions,\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n} from \"./types/common\";\nimport type { AnyFunction, Awaitable } from \"./types/type-helpers\";\nimport type { InitURLOrURLObject } from \"./url\";\nimport { isArray, isFunction, isPlainObject, isString } from \"./utils/guards\";\n\nexport type PluginInitContext<TPluginExtraOptions = unknown> = RequestContext // eslint-disable-next-line perfectionist/sort-intersection-types -- Allow\n\t& PluginExtraOptions<TPluginExtraOptions> & { initURL: string };\n\nexport type PluginInitResult = Partial<\n\tOmit<PluginInitContext, \"initURL\" | \"request\"> & {\n\t\tinitURL: InitURLOrURLObject;\n\t\trequest: CallApiRequestOptions;\n\t}\n>;\n\nexport type PluginHooksWithMoreOptions<TMoreOptions = unknown> = HooksOrHooksArray<\n\tnever,\n\tnever,\n\tTMoreOptions\n>;\n\nexport type PluginHooks<TData = never, TErrorData = never, TMoreOptions = unknown> = HooksOrHooksArray<\n\tTData,\n\tTErrorData,\n\tTMoreOptions\n>;\n\nexport interface CallApiPlugin {\n\t/**\n\t * Defines additional options that can be passed to callApi\n\t */\n\tdefineExtraOptions?: (...params: never[]) => unknown;\n\n\t/**\n\t * A description for the plugin\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Hooks / Interceptors for the plugin\n\t */\n\thooks?: PluginHooks;\n\n\t/**\n\t * A unique id for the plugin\n\t */\n\tid: string;\n\n\t/**\n\t * A function that will be called when the plugin is initialized. This will be called before the any of the other internal functions.\n\t */\n\tinit?: (context: PluginInitContext) => Awaitable<PluginInitResult> | Awaitable<void>;\n\n\t/**\n\t * A name for the plugin\n\t */\n\tname: string;\n\n\t/**\n\t * A version for the plugin\n\t */\n\tversion?: string;\n}\n\nexport const definePlugin = <\n\t// eslint-disable-next-line perfectionist/sort-union-types -- Let the first one be first\n\tTPlugin extends CallApiPlugin | AnyFunction<CallApiPlugin>,\n>(\n\tplugin: TPlugin\n) => {\n\treturn plugin;\n};\n\nconst resolvePluginArray = (\n\tplugins: CallApiExtraOptions[\"plugins\"] | undefined,\n\tbasePlugins: BaseCallApiExtraOptions[\"plugins\"] | undefined\n) => {\n\tif (!plugins) {\n\t\treturn [];\n\t}\n\n\tif (isFunction(plugins)) {\n\t\treturn plugins({ basePlugins: basePlugins ?? [] });\n\t}\n\n\treturn plugins;\n};\n\nexport const initializePlugins = async (context: PluginInitContext) => {\n\tconst { baseConfig, config, initURL, options, request } = context;\n\n\tconst clonedHookRegistries = structuredClone(hookRegistries);\n\n\tconst addMainHooks = () => {\n\t\tfor (const key of Object.keys(clonedHookRegistries) as Array<keyof Hooks>) {\n\t\t\tconst baseHook = baseConfig;\n\t\t\tconst instanceHook = config[key];\n\n\t\t\tconst overriddenHook = options[key] as HooksOrHooksArray[typeof key];\n\n\t\t\t// If the base hook is an array and instance hook is defined, we need to compose it with the overridden hook\n\t\t\tconst mainHook =\n\t\t\t\tisArray(baseHook) && Boolean(instanceHook) ? [baseHook, instanceHook].flat() : overriddenHook;\n\n\t\t\tif (!mainHook) continue;\n\n\t\t\tclonedHookRegistries[key].add(mainHook as never);\n\t\t}\n\t};\n\n\tconst addPluginHooks = (pluginHooks: Required<CallApiPlugin>[\"hooks\"]) => {\n\t\tfor (const key of Object.keys(clonedHookRegistries) as Array<keyof Hooks>) {\n\t\t\tconst pluginHook = pluginHooks[key];\n\n\t\t\tif (!pluginHook) continue;\n\n\t\t\tclonedHookRegistries[key].add(pluginHook as never);\n\t\t}\n\t};\n\n\tconst mergedHooksExecutionOrder =\n\t\toptions.mergedHooksExecutionOrder ?? hookDefaults.mergedHooksExecutionOrder;\n\n\tif (mergedHooksExecutionOrder === \"mainHooksBeforePlugins\") {\n\t\taddMainHooks();\n\t}\n\n\tconst resolvedPlugins = resolvePluginArray(options.plugins, baseConfig.plugins);\n\n\tlet resolvedInitURL = initURL;\n\tlet resolvedOptions = options;\n\tlet resolvedRequestOptions = request;\n\n\tconst executePluginInit = async (pluginInit: CallApiPlugin[\"init\"]) => {\n\t\tif (!pluginInit) return;\n\n\t\tconst initResult = await pluginInit({\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\tinitURL,\n\t\t\toptions,\n\t\t\trequest,\n\t\t});\n\n\t\tif (!isPlainObject(initResult)) return;\n\n\t\tconst urlString = initResult.initURL?.toString();\n\n\t\tif (isString(urlString)) {\n\t\t\tresolvedInitURL = urlString;\n\t\t}\n\n\t\tif (isPlainObject(initResult.request)) {\n\t\t\tresolvedRequestOptions = initResult.request as CallApiRequestOptionsForHooks;\n\t\t}\n\n\t\tif (isPlainObject(initResult.options)) {\n\t\t\tresolvedOptions = initResult.options;\n\t\t}\n\t};\n\n\tfor (const plugin of resolvedPlugins) {\n\t\t// eslint-disable-next-line no-await-in-loop -- Await is necessary in this case.\n\t\tawait executePluginInit(plugin.init);\n\n\t\tif (!plugin.hooks) continue;\n\n\t\taddPluginHooks(plugin.hooks);\n\t}\n\n\tif (mergedHooksExecutionOrder === \"mainHooksAfterPlugins\") {\n\t\taddMainHooks();\n\t}\n\n\tconst resolvedHooks: Hooks = {};\n\n\tfor (const [key, hookRegistry] of Object.entries(clonedHookRegistries)) {\n\t\tconst flattenedHookArray = [...hookRegistry].flat();\n\n\t\tconst mergedHooksExecutionMode =\n\t\t\toptions.mergedHooksExecutionMode ?? hookDefaults.mergedHooksExecutionMode;\n\n\t\tconst composedHook = composeTwoHooks(flattenedHookArray, mergedHooksExecutionMode);\n\n\t\tcomposedHook && (resolvedHooks[key as keyof Hooks] = composedHook);\n\t}\n\n\treturn {\n\t\tresolvedHooks,\n\t\tresolvedInitURL: resolvedInitURL.toString(),\n\t\tresolvedOptions,\n\t\tresolvedRequestOptions,\n\t};\n};\n","import { requestOptionDefaults, retryDefaults } from \"./constants/default-options\";\nimport type { ErrorContext, RequestContext } from \"./hooks\";\nimport type { MethodUnion } from \"./types\";\nimport type { Awaitable } from \"./types/type-helpers\";\nimport { isFunction, isHTTPError } from \"./utils/guards\";\n\ntype RetryCondition<TErrorData> = (context: ErrorContext<TErrorData>) => Awaitable<boolean>;\n\ntype InnerRetryKeys<TErrorData> = Exclude<keyof RetryOptions<TErrorData>, \"~retryAttemptCount\" | \"retry\">;\n\ntype InnerRetryOptions<TErrorData> = {\n\t[Key in InnerRetryKeys<TErrorData> as Key extends `retry${infer TRest}`\n\t\t? Uncapitalize<TRest> extends \"attempts\"\n\t\t\t? never\n\t\t\t: Uncapitalize<TRest>\n\t\t: Key]?: RetryOptions<TErrorData>[Key];\n} & {\n\tattempts: NonNullable<RetryOptions<TErrorData>[\"retryAttempts\"]>;\n};\n\nexport interface RetryOptions<TErrorData> {\n\t/**\n\t * Keeps track of the number of times the request has already been retried\n\t *\n\t * @deprecated **NOTE**: This property is used internally to track retries. Please abstain from modifying it.\n\t */\n\treadonly [\"~retryAttemptCount\"]?: number;\n\n\t/**\n\t * All retry options in a single object instead of separate properties\n\t */\n\tretry?: InnerRetryOptions<TErrorData>;\n\n\t/**\n\t * Number of allowed retry attempts on HTTP errors\n\t * @default 0\n\t */\n\tretryAttempts?: number;\n\n\t/**\n\t * Callback whose return value determines if a request should be retried or not\n\t */\n\tretryCondition?: RetryCondition<TErrorData>;\n\n\t/**\n\t * Delay between retries in milliseconds\n\t * @default 1000\n\t */\n\tretryDelay?: number | ((currentAttemptCount: number) => number);\n\n\t/**\n\t * Maximum delay in milliseconds. Only applies to exponential strategy\n\t * @default 10000\n\t */\n\tretryMaxDelay?: number;\n\n\t/**\n\t * HTTP methods that are allowed to retry\n\t * @default [\"GET\", \"POST\"]\n\t */\n\tretryMethods?: MethodUnion[];\n\n\t/**\n\t * HTTP status codes that trigger a retry\n\t */\n\tretryStatusCodes?: number[];\n\n\t/**\n\t * Strategy to use when retrying\n\t * @default \"linear\"\n\t */\n\tretryStrategy?: \"exponential\" | \"linear\";\n}\n\nconst getLinearDelay = (currentAttemptCount: number, options: RetryOptions<unknown>) => {\n\tconst retryDelay = options.retryDelay ?? options.retry?.delay;\n\n\tconst resolveRetryDelay =\n\t\t(isFunction(retryDelay) ? retryDelay(currentAttemptCount) : retryDelay) ?? retryDefaults.delay;\n\n\treturn resolveRetryDelay;\n};\n\nconst getExponentialDelay = (currentAttemptCount: number, options: RetryOptions<unknown>) => {\n\tconst retryDelay = options.retryDelay ?? options.retry?.delay ?? retryDefaults.delay;\n\n\tconst resolvedRetryDelay = Number(\n\t\tisFunction(retryDelay) ? retryDelay(currentAttemptCount) : retryDelay\n\t);\n\n\tconst maxDelay = Number(options.retryMaxDelay ?? options.retry?.maxDelay ?? retryDefaults.maxDelay);\n\n\tconst exponentialDelay = resolvedRetryDelay * 2 ** currentAttemptCount;\n\n\treturn Math.min(exponentialDelay, maxDelay);\n};\n\nexport const createRetryStrategy = (ctx: ErrorContext<unknown> & RequestContext) => {\n\tconst { options } = ctx;\n\n\t// eslint-disable-next-line ts-eslint/no-deprecated -- Allowed for internal use\n\tconst currentAttemptCount = options[\"~retryAttemptCount\"] ?? 1;\n\n\tconst retryStrategy = options.retryStrategy ?? options.retry?.strategy ?? retryDefaults.strategy;\n\n\tconst getDelay = () => {\n\t\tswitch (retryStrategy) {\n\t\t\tcase \"exponential\": {\n\t\t\t\treturn getExponentialDelay(currentAttemptCount, options);\n\t\t\t}\n\t\t\tcase \"linear\": {\n\t\t\t\treturn getLinearDelay(currentAttemptCount, options);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Invalid retry strategy: ${String(retryStrategy)}`);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst shouldAttemptRetry = async () => {\n\t\tconst retryCondition = options.retryCondition ?? options.retry?.condition ?? retryDefaults.condition;\n\n\t\tconst maximumRetryAttempts =\n\t\t\toptions.retryAttempts ?? options.retry?.attempts ?? retryDefaults.attempts;\n\n\t\tconst customRetryCondition = await retryCondition(ctx);\n\n\t\tconst baseShouldRetry = maximumRetryAttempts >= currentAttemptCount && customRetryCondition;\n\n\t\tif (!baseShouldRetry) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// == If error is not an HTTP error, just return true since at this point we know it's a retryable error\n\t\tif (!isHTTPError(ctx.error)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst selectedMethodArray = options.retryMethods ?? options.retry?.methods ?? retryDefaults.methods;\n\n\t\tconst retryMethods = new Set(selectedMethodArray);\n\n\t\tconst method = ctx.request.method ?? requestOptionDefaults.method;\n\n\t\tconst includesMethod = Boolean(method) && retryMethods.has(method);\n\n\t\tconst selectedStatusCodeArray = options.retryStatusCodes ?? options.retry?.statusCodes;\n\n\t\tconst retryStatusCodes = selectedStatusCodeArray ? new Set(selectedStatusCodeArray) : null;\n\n\t\tconst includesStatusCodes =\n\t\t\tBoolean(ctx.response?.status) && (retryStatusCodes?.has(ctx.response.status) ?? true);\n\n\t\tconst shouldRetry = includesMethod && includesStatusCodes;\n\n\t\treturn shouldRetry;\n\t};\n\n\treturn {\n\t\tcurrentAttemptCount,\n\t\tgetDelay,\n\t\tshouldAttemptRetry,\n\t};\n};\n","import { ValidationError } from \"./error\";\nimport type {\n\tBody,\n\tCallApiExtraOptions,\n\tCallApiRequestOptions,\n\tGlobalMeta,\n\tHeadersOption,\n\tMethodUnion,\n} from \"./types\";\nimport type { StandardSchemaV1 } from \"./types/standard-schema\";\nimport {\n\ttype AnyFunction,\n\ttype AnyString,\n\ttype Awaitable,\n\ttype Prettify,\n\ttype UnionToIntersection,\n\ttype Writeable,\n\tdefineEnum,\n} from \"./types/type-helpers\";\nimport type { Params, Query } from \"./url\";\nimport { isFunction } from \"./utils/guards\";\n\ntype InferSchemaInput<TSchema extends CallApiSchema[keyof CallApiSchema]> =\n\tTSchema extends StandardSchemaV1\n\t\t? StandardSchemaV1.InferInput<TSchema>\n\t\t: TSchema extends (value: infer TInput) => unknown\n\t\t\t? TInput\n\t\t\t: never;\n\nexport type InferSchemaResult<TSchema, TFallbackResult = NonNullable<unknown>> = undefined extends TSchema\n\t? TFallbackResult\n\t: TSchema extends StandardSchemaV1\n\t\t? StandardSchemaV1.InferOutput<TSchema>\n\t\t: TSchema extends AnyFunction<infer TResult>\n\t\t\t? Awaited<TResult>\n\t\t\t: TFallbackResult;\n\nconst handleValidatorFunction = async <TInput>(\n\tvalidator: Extract<CallApiSchema[keyof CallApiSchema], AnyFunction>,\n\tinputData: TInput\n): Promise<StandardSchemaV1.Result<TInput>> => {\n\ttry {\n\t\tconst result = await validator(inputData as never);\n\n\t\treturn { issues: undefined, value: result as never };\n\t} catch (error) {\n\t\treturn { issues: error as never, value: undefined };\n\t}\n};\n\nexport const standardSchemaParser = async <\n\tTSchema extends NonNullable<CallApiSchema[keyof CallApiSchema]>,\n>(\n\tschema: TSchema,\n\tinputData: InferSchemaInput<TSchema>,\n\tresponse?: Response | null\n): Promise<InferSchemaResult<TSchema>> => {\n\tconst result = isFunction(schema)\n\t\t? await handleValidatorFunction(schema, inputData)\n\t\t: await schema[\"~standard\"].validate(inputData);\n\n\t// == If the `issues` field exists, it means the validation failed\n\tif (result.issues) {\n\t\tthrow new ValidationError(\n\t\t\t{ issues: result.issues, response: response ?? null },\n\t\t\t{ cause: result.issues }\n\t\t);\n\t}\n\n\treturn result.value as never;\n};\n\nexport interface CallApiSchemaConfig {\n\t/**\n\t * The base url of the schema. By default it's the baseURL of the fetch instance.\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Disables runtime validation for the schema.\n\t */\n\tdisableRuntimeValidation?: boolean;\n\n\t/**\n\t * If `true`, the original input value will be used instead of the transformed/validated output.\n\t *\n\t * This is useful when you want to validate the input but don't want any transformations\n\t * applied by the validation schema (e.g., type coercion, default values, etc).\n\t */\n\tdisableValidationOutputApplication?: boolean;\n\n\t/**\n\t * Controls the inference of the method option based on the route modifiers (`@get/`, `@post/`, `@put/`, `@patch/`, `@delete/`).\n\t *\n\t * - When `true`, the method option is made required on the type level and is not automatically added to the request options.\n\t * - When `false` or `undefined` (default), the method option is not required on the type level, and is automatically added to the request options.\n\t *\n\t */\n\trequireHttpMethodProvision?: boolean;\n\n\t/**\n\t * Controls the strictness of API route validation.\n\t *\n\t * When true:\n\t * - Only routes explicitly defined in the schema will be considered valid to typescript\n\t * - Attempting to call undefined routes will result in type errors\n\t * - Useful for ensuring API calls conform exactly to your schema definition\n\t *\n\t * When false or undefined (default):\n\t * - All routes will be allowed, whether they are defined in the schema or not\n\t * - Provides more flexibility but less type safety\n\t *\n\t * @default false\n\t */\n\tstrict?: boolean;\n}\n\nexport interface CallApiSchema {\n\t/**\n\t * The schema to use for validating the request body.\n\t */\n\tbody?: StandardSchemaV1<Body> | ((body: Body) => Awaitable<Body>);\n\n\t/**\n\t * The schema to use for validating the response data.\n\t */\n\tdata?: StandardSchemaV1 | ((data: unknown) => unknown);\n\n\t/**\n\t * The schema to use for validating the response error data.\n\t */\n\terrorData?: StandardSchemaV1 | ((errorData: unknown) => unknown);\n\n\t/**\n\t * The schema to use for validating the request headers.\n\t */\n\theaders?:\n\t\t| StandardSchemaV1<HeadersOption | undefined>\n\t\t| ((headers: HeadersOption) => Awaitable<HeadersOption>);\n\n\t/**\n\t * The schema to use for validating the meta option.\n\t */\n\tmeta?: StandardSchemaV1<GlobalMeta | undefined> | ((meta: GlobalMeta) => Awaitable<GlobalMeta>);\n\n\t/**\n\t * The schema to use for validating the request method.\n\t */\n\tmethod?: StandardSchemaV1<MethodUnion | undefined> | ((method: MethodUnion) => Awaitable<MethodUnion>);\n\n\t/**\n\t * The schema to use for validating the request url parameters.\n\t */\n\tparams?: StandardSchemaV1<Params | undefined> | ((params: Params) => Awaitable<Params>);\n\n\t/**\n\t * The schema to use for validating the request url queries.\n\t */\n\tquery?: StandardSchemaV1<Query | undefined> | ((query: Query) => Awaitable<Query>);\n}\n\nexport const routeKeyMethods = defineEnum([\"delete\", \"get\", \"patch\", \"post\", \"put\"]);\n\nexport type RouteKeyMethods = (typeof routeKeyMethods)[number];\n\ntype PossibleRouteKey = `@${RouteKeyMethods}/` | AnyString;\n\nexport type BaseCallApiSchema = {\n\t[Key in PossibleRouteKey]?: CallApiSchema;\n};\n\nexport const defineSchema = <const TBaseSchema extends BaseCallApiSchema>(baseSchema: TBaseSchema) => {\n\treturn baseSchema as Writeable<typeof baseSchema, \"deep\">;\n};\n\ntype ValidationOptions<\n\tTSchema extends CallApiSchema[keyof CallApiSchema] = CallApiSchema[keyof CallApiSchema],\n> = {\n\tinputValue: InferSchemaInput<TSchema>;\n\tresponse?: Response | null;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nexport const handleValidation = async <TSchema extends CallApiSchema[keyof CallApiSchema]>(\n\tschema: TSchema | undefined,\n\tvalidationOptions: ValidationOptions<TSchema>\n): Promise<InferSchemaResult<TSchema>> => {\n\tconst { inputValue, response, schemaConfig } = validationOptions;\n\n\tif (!schema || schemaConfig?.disableRuntimeValidation) {\n\t\treturn inputValue as never;\n\t}\n\n\tconst validResult = await standardSchemaParser(schema, inputValue, response);\n\n\treturn validResult as never;\n};\n\ntype LastOf<TValue> =\n\tUnionToIntersection<TValue extends unknown ? () => TValue : never> extends () => infer R ? R : never;\n\ntype Push<TArray extends unknown[], TArrayItem> = [...TArray, TArrayItem];\n\ntype UnionToTuple<\n\tTUnion,\n\tTComputedLastUnion = LastOf<TUnion>,\n\tTComputedIsUnionEqualToNever = [TUnion] extends [never] ? true : false,\n> = true extends TComputedIsUnionEqualToNever\n\t? []\n\t: Push<UnionToTuple<Exclude<TUnion, TComputedLastUnion>>, TComputedLastUnion>;\n\nexport type Tuple<\n\tTTuple,\n\tTArray extends TTuple[] = [],\n> = UnionToTuple<TTuple>[\"length\"] extends TArray[\"length\"]\n\t? [...TArray]\n\t: Tuple<TTuple, [TTuple, ...TArray]>;\n\nconst extraOptionsToBeValidated = [\"meta\", \"params\", \"query\"] satisfies Tuple<\n\tExtract<keyof CallApiSchema, keyof CallApiExtraOptions>\n>;\n\ntype ExtraOptionsValidationOptions = {\n\textraOptions: CallApiExtraOptions;\n\tschema: CallApiSchema | undefined;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nconst handleExtraOptionsValidation = async (validationOptions: ExtraOptionsValidationOptions) => {\n\tconst { extraOptions, schema, schemaConfig } = validationOptions;\n\n\tconst validationResultArray = await Promise.all(\n\t\textraOptionsToBeValidated.map((propertyKey) =>\n\t\t\thandleValidation(schema?.[propertyKey], {\n\t\t\t\tinputValue: extraOptions[propertyKey],\n\t\t\t\tschemaConfig,\n\t\t\t})\n\t\t)\n\t);\n\n\tconst validatedResultObject: Prettify<\n\t\tPick<CallApiExtraOptions, (typeof extraOptionsToBeValidated)[number]>\n\t> = {};\n\n\tfor (const [index, propertyKey] of extraOptionsToBeValidated.entries()) {\n\t\tconst validationResult = validationResultArray[index];\n\n\t\tif (validationResult === undefined) continue;\n\n\t\tvalidatedResultObject[propertyKey] = validationResult as never;\n\t}\n\n\treturn validatedResultObject;\n};\n\nconst requestOptionsToBeValidated = [\"body\", \"headers\", \"method\"] satisfies Tuple<\n\tExtract<keyof CallApiSchema, keyof CallApiRequestOptions>\n>;\n\ntype RequestOptionsValidationOptions = {\n\trequestOptions: CallApiRequestOptions;\n\tschema: CallApiSchema | undefined;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nconst handleRequestOptionsValidation = async (validationOptions: RequestOptionsValidationOptions) => {\n\tconst { requestOptions, schema, schemaConfig } = validationOptions;\n\n\tconst validationResultArray = await Promise.all(\n\t\trequestOptionsToBeValidated.map((propertyKey) =>\n\t\t\thandleValidation(schema?.[propertyKey], {\n\t\t\t\tinputValue: requestOptions[propertyKey],\n\t\t\t\tschemaConfig,\n\t\t\t})\n\t\t)\n\t);\n\n\tconst validatedResultObject: Prettify<\n\t\tPick<CallApiRequestOptions, (typeof requestOptionsToBeValidated)[number]>\n\t> = {};\n\n\tfor (const [index, propertyKey] of requestOptionsToBeValidated.entries()) {\n\t\tconst validationResult = validationResultArray[index];\n\n\t\tif (validationResult === undefined) continue;\n\n\t\tvalidatedResultObject[propertyKey] = validationResult as never;\n\t}\n\n\treturn validatedResultObject;\n};\n\nexport const handleOptionsValidation = async (\n\tvalidationOptions: ExtraOptionsValidationOptions & RequestOptionsValidationOptions\n) => {\n\tconst { extraOptions, requestOptions, schema, schemaConfig } = validationOptions;\n\n\tif (schemaConfig?.disableRuntimeValidation) {\n\t\treturn {\n\t\t\textraOptionsValidationResult: null,\n\t\t\trequestOptionsValidationResult: null,\n\t\t};\n\t}\n\n\tconst [extraOptionsValidationResult, requestOptionsValidationResult] = await Promise.all([\n\t\thandleExtraOptionsValidation({ extraOptions, schema, schemaConfig }),\n\t\thandleRequestOptionsValidation({ requestOptions, schema, schemaConfig }),\n\t]);\n\n\treturn { extraOptionsValidationResult, requestOptionsValidationResult };\n};\n","import { requestOptionDefaults } from \"./constants/default-options\";\nimport type { CallApiExtraOptions, CallApiRequestOptions } from \"./types/common\";\nimport type { UnmaskType } from \"./types/type-helpers\";\nimport { toQueryString } from \"./utils\";\nimport { isArray } from \"./utils/guards\";\nimport { type CallApiSchemaConfig, routeKeyMethods } from \"./validation\";\n\nconst slash = \"/\";\nconst column = \":\";\nconst mergeUrlWithParams = (url: string, params: CallApiExtraOptions[\"params\"]) => {\n\tif (!params) {\n\t\treturn url;\n\t}\n\n\tlet newUrl = url;\n\n\tif (isArray(params)) {\n\t\tconst matchedParamArray = newUrl.split(slash).filter((param) => param.startsWith(column));\n\n\t\tfor (const [index, matchedParam] of matchedParamArray.entries()) {\n\t\t\tconst realParam = params[index] as string;\n\t\t\tnewUrl = newUrl.replace(matchedParam, realParam);\n\t\t}\n\n\t\treturn newUrl;\n\t}\n\n\tfor (const [key, value] of Object.entries(params)) {\n\t\tnewUrl = newUrl.replace(`${column}${key}`, String(value));\n\t}\n\n\treturn newUrl;\n};\n\nconst questionMark = \"?\";\nconst ampersand = \"&\";\nconst mergeUrlWithQuery = (url: string, query: CallApiExtraOptions[\"query\"]): string => {\n\tif (!query) {\n\t\treturn url;\n\t}\n\n\tconst queryString = toQueryString(query);\n\n\tif (queryString?.length === 0) {\n\t\treturn url;\n\t}\n\n\tif (url.endsWith(questionMark)) {\n\t\treturn `${url}${queryString}`;\n\t}\n\n\tif (url.includes(questionMark)) {\n\t\treturn `${url}${ampersand}${queryString}`;\n\t}\n\n\treturn `${url}${questionMark}${queryString}`;\n};\n\nexport const getCurrentRouteKey = (url: string, schemaConfig: CallApiSchemaConfig | undefined) => {\n\tlet currentRouteKey = url;\n\n\tif (schemaConfig?.baseURL && currentRouteKey.startsWith(schemaConfig.baseURL)) {\n\t\tcurrentRouteKey = currentRouteKey.replace(schemaConfig.baseURL, \"\");\n\t}\n\n\treturn currentRouteKey;\n};\n\n/**\n * @description\n * Extracts the method from the URL if it is a schema modifier.\n *\n * @param initURL - The URL to extract the method from.\n * @returns The method if it is a schema modifier, otherwise undefined.\n */\nexport const extractMethodFromURL = (initURL: string | undefined) => {\n\tif (!initURL?.startsWith(\"@\")) return;\n\n\tconst method = initURL.split(\"@\")[1]?.split(\"/\")[0];\n\n\tif (!method || !routeKeyMethods.includes(method)) return;\n\n\treturn method;\n};\n\nexport type GetMethodOptions = {\n\tinitURL: string | undefined;\n\tmethod: CallApiRequestOptions[\"method\"];\n\tschemaConfig?: CallApiSchemaConfig;\n};\n\nexport const getMethod = (options: GetMethodOptions) => {\n\tconst { initURL, method, schemaConfig } = options;\n\n\tif (schemaConfig?.requireHttpMethodProvision === true) {\n\t\treturn method?.toUpperCase() ?? requestOptionDefaults.method;\n\t}\n\n\treturn (\n\t\tmethod?.toUpperCase() ?? extractMethodFromURL(initURL)?.toUpperCase() ?? requestOptionDefaults.method\n\t);\n};\n\nexport const normalizeURL = (initURL: string) => {\n\tconst methodFromURL = extractMethodFromURL(initURL);\n\n\tif (!methodFromURL) {\n\t\treturn initURL;\n\t}\n\n\tconst normalizedURL = initURL.replace(`@${methodFromURL}/`, \"/\");\n\n\treturn normalizedURL;\n};\n\ntype GetFullURLOptions = {\n\tbaseURL: string | undefined;\n\tinitURL: string;\n\tparams: CallApiExtraOptions[\"params\"];\n\tquery: CallApiExtraOptions[\"query\"];\n};\n\nexport const getFullURL = (options: GetFullURLOptions) => {\n\tconst { baseURL, initURL, params, query } = options;\n\n\tconst normalizedURL = normalizeURL(initURL);\n\n\tconst urlWithMergedParams = mergeUrlWithParams(normalizedURL, params);\n\n\tconst urlWithMergedQueryAndParams = mergeUrlWithQuery(urlWithMergedParams, query);\n\n\tif (urlWithMergedQueryAndParams.startsWith(\"http\") || !baseURL) {\n\t\treturn urlWithMergedQueryAndParams;\n\t}\n\n\treturn `${baseURL}${urlWithMergedQueryAndParams}`;\n};\n\nexport type AllowedQueryParamValues = UnmaskType<boolean | number | string>;\n\nexport type Params = UnmaskType<\n\t// eslint-disable-next-line perfectionist/sort-union-types -- I need the Record to be first\n\tRecord<string, AllowedQueryParamValues> | AllowedQueryParamValues[]\n>;\n\nexport type Query = UnmaskType<Record<string, AllowedQueryParamValues>>;\n\nexport type InitURLOrURLObject = string | URL;\n\nexport interface URLOptions {\n\t/**\n\t * Base URL to be prepended to all request URLs\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Resolved request URL\n\t */\n\treadonly fullURL?: string;\n\n\t/**\n\t * The url string passed to the callApi instance\n\t */\n\treadonly initURL?: string;\n\n\t/**\n\t * The URL string passed to the callApi instance, but normalized (removed any method modifiers etc)\n\t */\n\treadonly initURLNormalized?: string;\n\n\t/**\n\t * Parameters to be appended to the URL (i.e: /:id)\n\t */\n\tparams?: Params;\n\n\t/**\n\t * Query parameters to append to the URL.\n\t */\n\tquery?: Query;\n}\n","import { type RequestInfoCache, createDedupeStrategy, getAbortErrorMessage } from \"./dedupe\";\nimport { HTTPError } from \"./error\";\nimport {\n\ttype ErrorContext,\n\ttype ExecuteHookInfo,\n\ttype RetryContext,\n\ttype SuccessContext,\n\texecuteHooksInCatchBlock,\n\texecuteHooksInTryBlock,\n} from \"./hooks\";\nimport { type CallApiPlugin, initializePlugins } from \"./plugins\";\nimport {\n\ttype ErrorInfo,\n\ttype ResponseTypeUnion,\n\ttype ResultModeUnion,\n\tgetCustomizedErrorResult,\n\tresolveErrorResult,\n\tresolveResponseData,\n\tresolveSuccessResult,\n} from \"./result\";\nimport { createRetryStrategy } from \"./retry\";\nimport type { GetCurrentRouteKey, InferHeadersOption, InferInitURL } from \"./types\";\nimport type {\n\tBaseCallApiConfig,\n\tBaseCallApiExtraOptions,\n\tCallApiExtraOptions,\n\tCallApiExtraOptionsForHooks,\n\tCallApiParameters,\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n\tCallApiResult,\n} from \"./types/common\";\nimport type { DefaultDataType, DefaultPluginArray, DefaultThrowOnError } from \"./types/default-types\";\nimport type { AnyFunction } from \"./types/type-helpers\";\nimport { getCurrentRouteKey, getFullURL, getMethod, normalizeURL } from \"./url\";\nimport {\n\tcreateCombinedSignal,\n\tcreateTimeoutSignal,\n\tgetBody,\n\tgetHeaders,\n\tsplitBaseConfig,\n\tsplitConfig,\n\twaitFor,\n} from \"./utils/common\";\nimport { isFunction, isHTTPErrorInstance, isValidationErrorInstance } from \"./utils/guards\";\nimport {\n\ttype BaseCallApiSchema,\n\ttype CallApiSchema,\n\ttype CallApiSchemaConfig,\n\ttype InferSchemaResult,\n\thandleOptionsValidation,\n\thandleValidation,\n} from \"./validation\";\n\nconst $GlobalRequestInfoCache: RequestInfoCache = new Map();\n\nexport const createFetchClient = <\n\tTBaseData = DefaultDataType,\n\tTBaseErrorData = DefaultDataType,\n\tTBaseResultMode extends ResultModeUnion = ResultModeUnion,\n\tTBaseThrowOnError extends boolean = DefaultThrowOnError,\n\tTBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tconst TBaseSchema extends BaseCallApiSchema = BaseCallApiSchema,\n\tconst TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig,\n\tTBasePluginArray extends CallApiPlugin[] = DefaultPluginArray,\n>(\n\tinitBaseConfig: BaseCallApiConfig<\n\t\tTBaseData,\n\t\tTBaseErrorData,\n\t\tTBaseResultMode,\n\t\tTBaseThrowOnError,\n\t\tTBaseResponseType,\n\t\tTBaseSchema,\n\t\tTBaseSchemaConfig,\n\t\tTBasePluginArray\n\t> = {} as never\n) => {\n\tconst $LocalRequestInfoCache: RequestInfoCache = new Map();\n\n\tconst callApi = async <\n\t\tTData = TBaseData,\n\t\tTErrorData = TBaseErrorData,\n\t\tTResultMode extends ResultModeUnion = TBaseResultMode,\n\t\tTThrowOnError extends boolean = TBaseThrowOnError,\n\t\tTResponseType extends ResponseTypeUnion = TBaseResponseType,\n\t\tTSchemaConfig extends CallApiSchemaConfig = TBaseSchemaConfig,\n\t\tTInitURL extends InferInitURL<TBaseSchema, TSchemaConfig> = InferInitURL<TBaseSchema, TSchemaConfig>,\n\t\tTCurrentRouteKey extends GetCurrentRouteKey<TSchemaConfig, TInitURL> = GetCurrentRouteKey<\n\t\t\tTSchemaConfig,\n\t\t\tTInitURL\n\t\t>,\n\t\tTSchema extends CallApiSchema = NonNullable<TBaseSchema[TCurrentRouteKey]>,\n\t\tTPluginArray extends CallApiPlugin[] = TBasePluginArray,\n\t>(\n\t\t...parameters: CallApiParameters<\n\t\t\tInferSchemaResult<TSchema[\"data\"], TData>,\n\t\t\tInferSchemaResult<TSchema[\"errorData\"], TErrorData>,\n\t\t\tTResultMode,\n\t\t\tTThrowOnError,\n\t\t\tTResponseType,\n\t\t\tTBaseSchema,\n\t\t\tTSchema,\n\t\t\tTBaseSchemaConfig,\n\t\t\tTSchemaConfig,\n\t\t\tTInitURL,\n\t\t\tTCurrentRouteKey,\n\t\t\tTBasePluginArray,\n\t\t\tTPluginArray\n\t\t>\n\t): CallApiResult<\n\t\tInferSchemaResult<TSchema[\"data\"], TData>,\n\t\tInferSchemaResult<TSchema[\"errorData\"], TErrorData>,\n\t\tTResultMode,\n\t\tTThrowOnError,\n\t\tTResponseType\n\t> => {\n\t\tconst [initURLOrURLObject, initConfig = {}] = parameters;\n\n\t\tconst [fetchOptions, extraOptions] = splitConfig(initConfig);\n\n\t\tconst resolvedBaseConfig = isFunction(initBaseConfig)\n\t\t\t? initBaseConfig({\n\t\t\t\t\tinitURL: initURLOrURLObject.toString(),\n\t\t\t\t\toptions: extraOptions,\n\t\t\t\t\trequest: fetchOptions,\n\t\t\t\t})\n\t\t\t: initBaseConfig;\n\n\t\tconst [baseFetchOptions, baseExtraOptions] = splitBaseConfig(resolvedBaseConfig);\n\n\t\t// == Merged Extra Options\n\t\tconst mergedExtraOptions = {\n\t\t\t...baseExtraOptions,\n\t\t\t...(baseExtraOptions.skipAutoMergeFor !== \"all\"\n\t\t\t\t&& baseExtraOptions.skipAutoMergeFor !== \"options\"\n\t\t\t\t&& extraOptions),\n\t\t};\n\n\t\t// == Merged Request Options\n\t\tconst mergedRequestOptions = {\n\t\t\t...baseFetchOptions,\n\t\t\t...(baseExtraOptions.skipAutoMergeFor !== \"all\"\n\t\t\t\t&& baseExtraOptions.skipAutoMergeFor !== \"request\"\n\t\t\t\t&& fetchOptions),\n\t\t} satisfies CallApiRequestOptions;\n\n\t\tconst baseConfig = resolvedBaseConfig as BaseCallApiExtraOptions & CallApiRequestOptions;\n\t\tconst config = initConfig as CallApiExtraOptions & CallApiRequestOptions;\n\n\t\tconst { resolvedHooks, resolvedInitURL, resolvedOptions, resolvedRequestOptions } =\n\t\t\tawait initializePlugins({\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\tinitURL: initURLOrURLObject.toString(),\n\t\t\t\toptions: mergedExtraOptions as CallApiExtraOptionsForHooks,\n\t\t\t\trequest: mergedRequestOptions as CallApiRequestOptionsForHooks,\n\t\t\t});\n\n\t\tconst fullURL = getFullURL({\n\t\t\tbaseURL: resolvedOptions.baseURL,\n\t\t\tinitURL: resolvedInitURL,\n\t\t\tparams: resolvedOptions.params,\n\t\t\tquery: resolvedOptions.query,\n\t\t});\n\n\t\tconst resolvedSchemaConfig = isFunction(extraOptions.schemaConfig)\n\t\t\t? extraOptions.schemaConfig({ baseSchemaConfig: baseExtraOptions.schemaConfig ?? {} })\n\t\t\t: (extraOptions.schemaConfig ?? baseExtraOptions.schemaConfig);\n\n\t\tconst currentRouteKey = getCurrentRouteKey(resolvedInitURL, resolvedSchemaConfig);\n\n\t\tconst routeSchema = baseExtraOptions.schema?.[currentRouteKey];\n\n\t\tconst resolvedSchema = isFunction(extraOptions.schema)\n\t\t\t? extraOptions.schema({\n\t\t\t\t\tbaseSchema: baseExtraOptions.schema ?? {},\n\t\t\t\t\tcurrentRouteSchema: routeSchema ?? {},\n\t\t\t\t})\n\t\t\t: (extraOptions.schema ?? routeSchema);\n\n\t\tlet options = {\n\t\t\t...resolvedOptions,\n\t\t\t...resolvedHooks,\n\n\t\t\tfullURL,\n\t\t\tinitURL: resolvedInitURL,\n\t\t\tinitURLNormalized: normalizeURL(resolvedInitURL),\n\t\t} satisfies CallApiExtraOptionsForHooks;\n\n\t\tconst newFetchController = new AbortController();\n\n\t\tconst timeoutSignal = options.timeout != null ? createTimeoutSignal(options.timeout) : null;\n\n\t\tconst combinedSignal = createCombinedSignal(\n\t\t\tresolvedRequestOptions.signal,\n\t\t\ttimeoutSignal,\n\t\t\tnewFetchController.signal\n\t\t);\n\n\t\tlet request = {\n\t\t\t...resolvedRequestOptions,\n\t\t\t// == Making sure headers is always an object\n\t\t\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- False positive\n\t\t\theaders: resolvedRequestOptions.headers ?? {},\n\n\t\t\tsignal: combinedSignal,\n\t\t} satisfies CallApiRequestOptionsForHooks;\n\n\t\tconst {\n\t\t\tdedupeStrategy,\n\t\t\thandleRequestCancelStrategy,\n\t\t\thandleRequestDeferStrategy,\n\t\t\tremoveDedupeKeyFromCache,\n\t\t} = await createDedupeStrategy({\n\t\t\t$GlobalRequestInfoCache,\n\t\t\t$LocalRequestInfoCache,\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\tnewFetchController,\n\t\t\toptions,\n\t\t\trequest,\n\t\t});\n\n\t\ttry {\n\t\t\tawait handleRequestCancelStrategy();\n\n\t\t\tawait executeHooksInTryBlock(options.onRequest?.({ baseConfig, config, options, request }));\n\n\t\t\tconst { extraOptionsValidationResult, requestOptionsValidationResult } =\n\t\t\t\tawait handleOptionsValidation({\n\t\t\t\t\textraOptions: options,\n\t\t\t\t\trequestOptions: request,\n\t\t\t\t\tschema: resolvedSchema,\n\t\t\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t\t\t});\n\n\t\t\tconst shouldApplySchemaOutput =\n\t\t\t\tBoolean(extraOptionsValidationResult)\n\t\t\t\t|| Boolean(requestOptionsValidationResult)\n\t\t\t\t|| !resolvedSchemaConfig?.disableValidationOutputApplication;\n\n\t\t\tif (shouldApplySchemaOutput) {\n\t\t\t\toptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\t...extraOptionsValidationResult,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst rawBody = shouldApplySchemaOutput ? requestOptionsValidationResult?.body : request.body;\n\n\t\t\tconst validBody = getBody({\n\t\t\t\tbody: rawBody,\n\t\t\t\tbodySerializer: options.bodySerializer,\n\t\t\t});\n\n\t\t\ttype HeaderFn = Extract<InferHeadersOption<CallApiSchema>[\"headers\"], AnyFunction>;\n\n\t\t\tconst resolvedHeaders = isFunction<HeaderFn>(fetchOptions.headers)\n\t\t\t\t? fetchOptions.headers({ baseHeaders: baseFetchOptions.headers ?? {} })\n\t\t\t\t: (fetchOptions.headers ?? baseFetchOptions.headers);\n\n\t\t\tconst validHeaders = await getHeaders({\n\t\t\t\tauth: options.auth,\n\t\t\t\tbody: rawBody,\n\t\t\t\theaders: shouldApplySchemaOutput ? requestOptionsValidationResult?.headers : resolvedHeaders,\n\t\t\t});\n\n\t\t\tconst validMethod = getMethod({\n\t\t\t\tinitURL: resolvedInitURL,\n\t\t\t\tmethod: shouldApplySchemaOutput ? requestOptionsValidationResult?.method : request.method,\n\t\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t\t});\n\n\t\t\trequest = {\n\t\t\t\t...request,\n\t\t\t\t...(Boolean(validBody) && { body: validBody }),\n\t\t\t\t...(Boolean(validHeaders) && { headers: validHeaders }),\n\t\t\t\t...(Boolean(validMethod) && { method: validMethod }),\n\t\t\t};\n\n\t\t\tconst response = await handleRequestDeferStrategy({ options, request });\n\n\t\t\t// == Also clone response when dedupeStrategy is set to \"defer\" or when onRequestStream is set, to avoid error thrown from reading response.(whatever) more than once\n\t\t\tconst shouldCloneResponse = dedupeStrategy === \"defer\" || options.cloneResponse;\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorData = await resolveResponseData<TErrorData>(\n\t\t\t\t\tshouldCloneResponse ? response.clone() : response,\n\t\t\t\t\toptions.responseType,\n\t\t\t\t\toptions.responseParser\n\t\t\t\t);\n\n\t\t\t\tconst validErrorData = await handleValidation(resolvedSchema?.errorData, {\n\t\t\t\t\tinputValue: errorData,\n\t\t\t\t\tresponse,\n\t\t\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t\t\t});\n\n\t\t\t\t// == Push all error handling responsibilities to the catch block if not retrying\n\t\t\t\tthrow new HTTPError(\n\t\t\t\t\t{\n\t\t\t\t\t\tdefaultErrorMessage: options.defaultErrorMessage,\n\t\t\t\t\t\terrorData: validErrorData,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t},\n\t\t\t\t\t{ cause: validErrorData }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst successData = await resolveResponseData<TData>(\n\t\t\t\tshouldCloneResponse ? response.clone() : response,\n\t\t\t\toptions.responseType,\n\t\t\t\toptions.responseParser\n\t\t\t);\n\n\t\t\tconst validSuccessData = await handleValidation(resolvedSchema?.data, {\n\t\t\t\tinputValue: successData,\n\t\t\t\tresponse,\n\t\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t\t});\n\n\t\t\tconst successContext = {\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\tdata: validSuccessData,\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t\tresponse,\n\t\t\t} satisfies SuccessContext<unknown>;\n\n\t\t\tawait executeHooksInTryBlock(\n\t\t\t\toptions.onSuccess?.(successContext),\n\n\t\t\t\toptions.onResponse?.({ ...successContext, error: null })\n\t\t\t);\n\n\t\t\tconst successResult = resolveSuccessResult(successContext.data, {\n\t\t\t\tresponse: successContext.response,\n\t\t\t\tresultMode: options.resultMode,\n\t\t\t});\n\n\t\t\treturn successResult as never;\n\n\t\t\t// == Exhaustive Error handling\n\t\t} catch (error) {\n\t\t\tconst errorInfo = {\n\t\t\t\tcloneResponse: options.cloneResponse,\n\t\t\t\tdefaultErrorMessage: options.defaultErrorMessage,\n\t\t\t\tresultMode: options.resultMode,\n\t\t\t} satisfies ErrorInfo;\n\n\t\t\tconst generalErrorResult = resolveErrorResult(error, errorInfo);\n\n\t\t\tconst errorContext = {\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\terror: generalErrorResult?.error as never,\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t\tresponse: generalErrorResult?.response as never,\n\t\t\t} satisfies ErrorContext<unknown>;\n\n\t\t\tconst shouldThrowOnError = isFunction(options.throwOnError)\n\t\t\t\t? options.throwOnError(errorContext)\n\t\t\t\t: options.throwOnError;\n\n\t\t\tconst hookInfo = {\n\t\t\t\terrorInfo,\n\t\t\t\tshouldThrowOnError,\n\t\t\t} satisfies ExecuteHookInfo;\n\n\t\t\tconst handleRetryOrGetErrorResult = async () => {\n\t\t\t\tconst { currentAttemptCount, getDelay, shouldAttemptRetry } =\n\t\t\t\t\tcreateRetryStrategy(errorContext);\n\n\t\t\t\tconst shouldRetry = !combinedSignal.aborted && (await shouldAttemptRetry());\n\n\t\t\t\tif (shouldRetry) {\n\t\t\t\t\tconst retryContext = {\n\t\t\t\t\t\t...errorContext,\n\t\t\t\t\t\tretryAttemptCount: currentAttemptCount,\n\t\t\t\t\t} satisfies RetryContext<unknown>;\n\n\t\t\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t\t\t[options.onRetry?.(retryContext)],\n\t\t\t\t\t\thookInfo\n\t\t\t\t\t);\n\n\t\t\t\t\tif (hookError) {\n\t\t\t\t\t\treturn hookError;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst delay = getDelay();\n\n\t\t\t\t\tawait waitFor(delay);\n\n\t\t\t\t\tconst updatedOptions = {\n\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\"~retryAttemptCount\": currentAttemptCount + 1,\n\t\t\t\t\t} satisfies typeof config;\n\n\t\t\t\t\treturn callApi(initURLOrURLObject as never, updatedOptions as never) as never;\n\t\t\t\t}\n\n\t\t\t\tif (shouldThrowOnError) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\n\t\t\t\treturn generalErrorResult;\n\t\t\t};\n\n\t\t\tif (isHTTPErrorInstance<TErrorData>(error)) {\n\t\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t\t[\n\t\t\t\t\t\toptions.onResponseError?.(errorContext),\n\t\t\t\t\t\toptions.onError?.(errorContext),\n\t\t\t\t\t\toptions.onResponse?.({ ...errorContext, data: null }),\n\t\t\t\t\t],\n\t\t\t\t\thookInfo\n\t\t\t\t);\n\n\t\t\t\treturn (hookError ?? (await handleRetryOrGetErrorResult())) as never;\n\t\t\t}\n\n\t\t\tif (isValidationErrorInstance(error)) {\n\t\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t\t[\n\t\t\t\t\t\toptions.onValidationError?.(errorContext),\n\t\t\t\t\t\toptions.onRequestError?.(errorContext),\n\t\t\t\t\t\toptions.onError?.(errorContext),\n\t\t\t\t\t],\n\t\t\t\t\thookInfo\n\t\t\t\t);\n\n\t\t\t\treturn (hookError ?? (await handleRetryOrGetErrorResult())) as never;\n\t\t\t}\n\n\t\t\tlet message: string | undefined = (error as Error | undefined)?.message;\n\n\t\t\tif (error instanceof DOMException && error.name === \"AbortError\") {\n\t\t\t\tmessage = getAbortErrorMessage(options.dedupeKey, options.fullURL);\n\n\t\t\t\t!shouldThrowOnError && console.error(`${error.name}:`, message);\n\t\t\t}\n\n\t\t\tif (error instanceof DOMException && error.name === \"TimeoutError\") {\n\t\t\t\tmessage = `Request timed out after ${options.timeout}ms`;\n\n\t\t\t\t!shouldThrowOnError && console.error(`${error.name}:`, message);\n\t\t\t}\n\n\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t[options.onRequestError?.(errorContext), options.onError?.(errorContext)],\n\t\t\t\thookInfo\n\t\t\t);\n\n\t\t\treturn (hookError\n\t\t\t\t?? getCustomizedErrorResult(await handleRetryOrGetErrorResult(), { message })) as never;\n\n\t\t\t// == Removing the now unneeded AbortController from store\n\t\t} finally {\n\t\t\tremoveDedupeKeyFromCache();\n\t\t}\n\t};\n\n\treturn callApi;\n};\n\nexport const callApi = createFetchClient();\n","import type { CallApiPlugin } from \"./plugins\";\nimport type { ResponseTypeUnion, ResultModeUnion } from \"./result\";\nimport type { CallApiParameters, InferInitURL } from \"./types\";\nimport type { DefaultDataType, DefaultPluginArray, DefaultThrowOnError } from \"./types/default-types\";\nimport type { BaseCallApiSchema, CallApiSchema, CallApiSchemaConfig } from \"./validation\";\n\nconst defineParameters = <\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResultMode extends ResultModeUnion = ResultModeUnion,\n\tTThrowOnError extends boolean = DefaultThrowOnError,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tTBaseSchema extends BaseCallApiSchema = BaseCallApiSchema,\n\tTSchema extends CallApiSchema = CallApiSchema,\n\tTBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig,\n\tTSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig,\n\tTInitURL extends InferInitURL<BaseCallApiSchema, TSchemaConfig> = InferInitURL<\n\t\tBaseCallApiSchema,\n\t\tTSchemaConfig\n\t>,\n\tTCurrentRouteKey extends string = string,\n\tTBasePluginArray extends CallApiPlugin[] = DefaultPluginArray,\n\tTPluginArray extends CallApiPlugin[] = DefaultPluginArray,\n>(\n\t...parameters: CallApiParameters<\n\t\tTData,\n\t\tTErrorData,\n\t\tTResultMode,\n\t\tTThrowOnError,\n\t\tTResponseType,\n\t\tTBaseSchema,\n\t\tTSchema,\n\t\tTBaseSchemaConfig,\n\t\tTSchemaConfig,\n\t\tTInitURL,\n\t\tTCurrentRouteKey,\n\t\tTBasePluginArray,\n\t\tTPluginArray\n\t>\n) => {\n\treturn parameters;\n};\n\nexport { defineParameters };\n"],"mappings":";;;AASA,MAAa,kBAAkB,CAAYA,UAAoBC,YAAoB;CAClF,aAAa,MAAM,SAAS,aAAa;CACzC,MAAM,MAAM,SAAS,MAAM;CAC3B,UAAU,MAAM,SAAS,UAAU;CACnC,MAAM,YAAY;EACjB,MAAM,OAAO,MAAM,SAAS,MAAM;AAClC,SAAO,OAAO,KAAK;CACnB;CACD,QAAQ,MAAM,SAAS;CACvB,MAAM,MAAM,SAAS,MAAM;AAC3B;AAoBD,MAAa,sBAAsB,CAClCD,UACAE,cACAC,WACI;CACJ,MAAM,iBAAiB,UAAU,iBAAiB;CAClD,MAAM,uBAAuB,gBAAgB,iBAAiB;CAE9D,MAAM,uBAAuB,gBAA2B,UAAU,eAAe;AAEjF,MAAK,OAAO,OAAO,sBAAsB,qBAAqB,CAC7D,OAAM,IAAI,OAAO,yBAAyB,aAAa;AAGxD,QAAO,qBAAqB,uBAAuB;AACnD;AAoGD,MAAM,mBAAmB,CACxBC,YACI;CACJ,MAAM,gBAAgB;EACrB,KAAK,MAAM;EACX,kBAAkB,MAAM,cAAc,KAAK;EAC3C,aAAa,MAAM,QAAQ;EAC3B,0BAA0B,MAAM,cAAc,aAAa;CAC3D;AAED,QAAO;AACP;AAMD,MAAa,uBAAuB,CAACC,MAAeC,SAAqC;CACxF,MAAM,EAAE,UAAU,YAAY,GAAG;CAEjC,MAAM,UAAU;EACf;EACA,OAAO;EACP;CACA;CAED,MAAM,gBAAgB,iBAAiB,QAAQ;CAE/C,MAAM,gBAAgB,cAAc,cAAc,QAAQ;AAE1D,QAAO;AACP;AAWD,MAAa,qBAAqB,CAACC,OAAgBC,SAAiC;CACnF,MAAM,EAAE,eAAe,qBAA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B,CAAC,QAAQ,iBAAiB,aAAa,EAAE,QAAQ,UAAU,aAAa,AAAC,GACzE,SACA;AAED,UAAQ,aACJ,yBAAyB,MAAM,6BAA6B,EAAE,EAAE,QAAS,EAAC;EAG9E,UAAS;AACT,6BAA0B;EAC1B;CACD;AAED,QAAOF;AACP;AAED,MAAa,UAAU,mBAAmB;;;;AC9c1C,MAAM,mBAAmB,CAkBxB,GAAG,eAeC;AACJ,QAAO;AACP"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CallApiExtraOptions, CallApiResultErrorVariant, HTTPError, PossibleHTTPError, PossibleJavaScriptError, PossibleValidationError, ValidationError } from "../common-
|
1
|
+
import { CallApiExtraOptions, CallApiResultErrorVariant, HTTPError, PossibleHTTPError, PossibleJavaScriptError, PossibleValidationError, ValidationError } from "../common-Ib2vb30V.js";
|
2
2
|
|
3
3
|
//#region src/utils/common.d.ts
|
4
4
|
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zayne-labs/callapi",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.8.
|
4
|
+
"version": "1.8.5",
|
5
5
|
"description": "A lightweight wrapper over fetch with quality of life improvements like built-in request cancellation, retries, interceptors and more",
|
6
6
|
"author": "Ryan Zayne",
|
7
7
|
"license": "MIT",
|