@zayne-labs/callapi 1.11.36 → 1.11.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults-B-dOt2Dd.js","names":[],"sources":["../src/types/type-helpers.ts","../src/constants/defaults.ts"],"sourcesContent":["// == These two types allows for adding arbitrary literal types, while still provided autocomplete for defaults.\n\n// == Usually intersection with \"{}\" or \"NonNullable<unknown>\" would make it work fine, but the placeholder with never type is added to make the AnyWhatever type appear last in a given union.\nexport type AnyString = string & NonNullable<unknown>;\nexport type AnyNumber = number & NonNullable<unknown>;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is fine here\nexport type AnyObject = Record<keyof any, any>;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport type AnyFunction<TResult = unknown> = (...args: any[]) => TResult;\n\nexport type Prettify<TObject> = NonNullable<unknown> & { [Key in keyof TObject]: TObject[Key] };\n\ntype WriteableLevel = \"deep\" | \"shallow\";\n\n/**\n * Makes all properties in an object type writeable (removes readonly modifiers).\n * Supports both shallow and deep modes, and handles special cases like arrays, tuples, and unions.\n * @template TObject - The object type to make writeable\n * @template TVariant - The level of writeable transformation (\"shallow\" | \"deep\")\n */\n\ntype ArrayOrObject = Record<number | string | symbol, unknown> | unknown[] | readonly unknown[];\n\nexport type Writeable<TObject, TLevel extends WriteableLevel = \"shallow\"> =\n\tTObject extends ArrayOrObject ?\n\t\t{\n\t\t\t-readonly [Key in keyof TObject]: TLevel extends \"deep\" ?\n\t\t\t\tNonNullable<TObject[Key]> extends ArrayOrObject ?\n\t\t\t\t\tWriteable<TObject[Key], \"deep\">\n\t\t\t\t:\tTObject[Key]\n\t\t\t:\tTObject[Key];\n\t\t}\n\t:\tTObject;\n\nexport const defineEnum = <const TValue extends object>(value: TValue) =>\n\tObject.freeze(value) as Readonly<Writeable<TValue>>;\n\nexport type UnionToIntersection<TUnion> =\n\t(TUnion extends unknown ? (param: TUnion) => void : never) extends (param: infer TParam) => void ?\n\t\tTParam\n\t:\tnever;\n\n// == Using this Immediately Indexed Mapped type helper to help show computed type of anything passed to it instead of just the type name\nexport type UnmaskType<TValue> = { value: TValue }[\"value\"];\n\n/**\n * @description Userland implementation of NoInfer intrinsic type, but this one doesn't show up on hover like the intrinsic one\n *\n * Prevents TypeScript from inferring `TGeneric` at this position by creating a circular dependency.\n * The tuple index `[TGeneric extends unknown ? 0 : never]` depends on `TGeneric`, forcing TS to\n * skip this site for inference and use other arguments or defaults instead.\n */\nexport type NoInferUnMasked<TGeneric> = [TGeneric][TGeneric extends unknown ? 0 : never];\n\nexport type
|
|
1
|
+
{"version":3,"file":"defaults-B-dOt2Dd.js","names":[],"sources":["../src/types/type-helpers.ts","../src/constants/defaults.ts"],"sourcesContent":["// == These two types allows for adding arbitrary literal types, while still provided autocomplete for defaults.\n\n// == Usually intersection with \"{}\" or \"NonNullable<unknown>\" would make it work fine, but the placeholder with never type is added to make the AnyWhatever type appear last in a given union.\nexport type AnyString = string & NonNullable<unknown>;\nexport type AnyNumber = number & NonNullable<unknown>;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is fine here\nexport type AnyObject = Record<keyof any, any>;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport type AnyFunction<TResult = unknown> = (...args: any[]) => TResult;\n\nexport type Prettify<TObject> = NonNullable<unknown> & { [Key in keyof TObject]: TObject[Key] };\n\ntype WriteableLevel = \"deep\" | \"shallow\";\n\n/**\n * Makes all properties in an object type writeable (removes readonly modifiers).\n * Supports both shallow and deep modes, and handles special cases like arrays, tuples, and unions.\n * @template TObject - The object type to make writeable\n * @template TVariant - The level of writeable transformation (\"shallow\" | \"deep\")\n */\n\ntype ArrayOrObject = Record<number | string | symbol, unknown> | unknown[] | readonly unknown[];\n\nexport type Writeable<TObject, TLevel extends WriteableLevel = \"shallow\"> =\n\tTObject extends ArrayOrObject ?\n\t\t{\n\t\t\t-readonly [Key in keyof TObject]: TLevel extends \"deep\" ?\n\t\t\t\tNonNullable<TObject[Key]> extends ArrayOrObject ?\n\t\t\t\t\tWriteable<TObject[Key], \"deep\">\n\t\t\t\t:\tTObject[Key]\n\t\t\t:\tTObject[Key];\n\t\t}\n\t:\tTObject;\n\nexport const defineEnum = <const TValue extends object>(value: TValue) =>\n\tObject.freeze(value) as Readonly<Writeable<TValue>>;\n\nexport type UnionToIntersection<TUnion> =\n\t(TUnion extends unknown ? (param: TUnion) => void : never) extends (param: infer TParam) => void ?\n\t\tTParam\n\t:\tnever;\n\n// == Using this Immediately Indexed Mapped type helper to help show computed type of anything passed to it instead of just the type name\nexport type UnmaskType<TValue> = { value: TValue }[\"value\"];\n\n/**\n * @description Userland implementation of NoInfer intrinsic type, but this one doesn't show up on hover like the intrinsic one\n *\n * Prevents TypeScript from inferring `TGeneric` at this position by creating a circular dependency.\n * The tuple index `[TGeneric extends unknown ? 0 : never]` depends on `TGeneric`, forcing TS to\n * skip this site for inference and use other arguments or defaults instead.\n */\nexport type NoInferUnMasked<TGeneric> = [TGeneric][TGeneric extends unknown ? 0 : never];\n\nexport type RemoveDedupeOrRetryPrefix<TPrefixToRemove extends \"dedupe\" | \"retry\", TKey extends string> =\n\tTKey extends `${TPrefixToRemove}${infer TRest}` ? Uncapitalize<TRest> : TKey;\n\ntype RemoveSlashImpl<TUrl extends string, TDirection extends \"leading\" | \"trailing\"> =\n\tTDirection extends \"leading\" ?\n\t\tTUrl extends `/${infer TWithoutLeadingSlash}` ?\n\t\t\tTWithoutLeadingSlash\n\t\t:\tTUrl\n\t: TDirection extends \"trailing\" ?\n\t\tTUrl extends `${infer TWithoutTailingSlash}/` ?\n\t\t\tTWithoutTailingSlash\n\t\t:\tTUrl\n\t:\tnever;\n\nexport type RemoveTrailingSlash<TUrl extends string> = RemoveSlashImpl<TUrl, \"trailing\">;\nexport type RemoveLeadingSlash<TUrl extends string> = RemoveSlashImpl<TUrl, \"leading\">;\n\nexport type Awaitable<TValue> = Promise<TValue> | TValue;\n\n// export type MatchExactObjectType<TActualObject extends TExpectedObject, TExpectedObject> = {\n// \t[Key in keyof TActualObject]: Key extends keyof TExpectedObject ? TActualObject[Key] : never;\n// };\n\nexport type Satisfies<TActualObject extends TExpectedObject, TExpectedObject> = {\n\t[Key in keyof TActualObject]: Key extends keyof TExpectedObject ? TActualObject[Key] : never;\n};\n// export type Satisfies<TActualObject extends TExpectedObject, TExpectedObject> = {\n// \t[Key in keyof TActualObject & keyof TExpectedObject]: TActualObject[Key];\n// };\n\nexport type DistributiveOmit<TObject, TKeysToOmit extends keyof TObject> =\n\tTObject extends unknown ? Omit<TObject, TKeysToOmit> : never;\n\nexport type CommonRequestHeaders =\n\t| \"Access-Control-Allow-Credentials\"\n\t| \"Access-Control-Allow-Headers\"\n\t| \"Access-Control-Allow-Methods\"\n\t| \"Access-Control-Allow-Origin\"\n\t| \"Access-Control-Expose-Headers\"\n\t| \"Access-Control-Max-Age\"\n\t| \"Age\"\n\t| \"Allow\"\n\t| \"Cache-Control\"\n\t| \"Clear-Site-Data\"\n\t| \"Content-Disposition\"\n\t| \"Content-Encoding\"\n\t| \"Content-Language\"\n\t| \"Content-Length\"\n\t| \"Content-Location\"\n\t| \"Content-Range\"\n\t| \"Content-Security-Policy-Report-Only\"\n\t| \"Content-Security-Policy\"\n\t| \"Cookie\"\n\t| \"Cross-Origin-Embedder-Policy\"\n\t| \"Cross-Origin-Opener-Policy\"\n\t| \"Cross-Origin-Resource-Policy\"\n\t| \"Date\"\n\t| \"ETag\"\n\t| \"Expires\"\n\t| \"Last-Modified\"\n\t| \"Location\"\n\t| \"Permissions-Policy\"\n\t| \"Pragma\"\n\t| \"Retry-After\"\n\t| \"Save-Data\"\n\t| \"Sec-CH-Prefers-Color-Scheme\"\n\t| \"Sec-CH-Prefers-Reduced-Motion\"\n\t| \"Sec-CH-UA-Arch\"\n\t| \"Sec-CH-UA-Bitness\"\n\t| \"Sec-CH-UA-Form-Factor\"\n\t| \"Sec-CH-UA-Full-Version-List\"\n\t| \"Sec-CH-UA-Full-Version\"\n\t| \"Sec-CH-UA-Mobile\"\n\t| \"Sec-CH-UA-Model\"\n\t| \"Sec-CH-UA-Platform-Version\"\n\t| \"Sec-CH-UA-Platform\"\n\t| \"Sec-CH-UA-WoW64\"\n\t| \"Sec-CH-UA\"\n\t| \"Sec-Fetch-Dest\"\n\t| \"Sec-Fetch-Mode\"\n\t| \"Sec-Fetch-Site\"\n\t| \"Sec-Fetch-User\"\n\t| \"Sec-GPC\"\n\t| \"Server-Timing\"\n\t| \"Server\"\n\t| \"Service-Worker-Navigation-Preload\"\n\t| \"Set-Cookie\"\n\t| \"Strict-Transport-Security\"\n\t| \"Timing-Allow-Origin\"\n\t| \"Trailer\"\n\t| \"Transfer-Encoding\"\n\t| \"Upgrade\"\n\t| \"Vary\"\n\t| \"Warning\"\n\t| \"WWW-Authenticate\"\n\t| \"X-Content-Type-Options\"\n\t| \"X-DNS-Prefetch-Control\"\n\t| \"X-Frame-Options\"\n\t| \"X-Permitted-Cross-Domain-Policies\"\n\t| \"X-Powered-By\"\n\t| \"X-Robots-Tag\"\n\t| \"X-XSS-Protection\"\n\t| AnyString;\n\nexport type CommonAuthorizationHeaders = `${\"Basic\" | \"Bearer\" | \"Token\"} ${string}`;\n\nexport type CommonContentTypes =\n\t| \"application/epub+zip\"\n\t| \"application/gzip\"\n\t| \"application/json\"\n\t| \"application/ld+json\"\n\t| \"application/octet-stream\"\n\t| \"application/ogg\"\n\t| \"application/pdf\"\n\t| \"application/rtf\"\n\t| \"application/vnd.ms-fontobject\"\n\t| \"application/wasm\"\n\t| \"application/xhtml+xml\"\n\t| \"application/xml\"\n\t| \"application/zip\"\n\t| \"audio/aac\"\n\t| \"audio/mpeg\"\n\t| \"audio/ogg\"\n\t| \"audio/opus\"\n\t| \"audio/webm\"\n\t| \"audio/x-midi\"\n\t| \"font/otf\"\n\t| \"font/ttf\"\n\t| \"font/woff\"\n\t| \"font/woff2\"\n\t| \"image/avif\"\n\t| \"image/bmp\"\n\t| \"image/gif\"\n\t| \"image/jpeg\"\n\t| \"image/png\"\n\t| \"image/svg+xml\"\n\t| \"image/tiff\"\n\t| \"image/webp\"\n\t| \"image/x-icon\"\n\t| \"model/gltf-binary\"\n\t| \"model/gltf+json\"\n\t| \"text/calendar\"\n\t| \"text/css\"\n\t| \"text/csv\"\n\t| \"text/html\"\n\t| \"text/javascript\"\n\t| \"text/plain\"\n\t| \"video/3gpp\"\n\t| \"video/3gpp2\"\n\t| \"video/av1\"\n\t| \"video/mp2t\"\n\t| \"video/mp4\"\n\t| \"video/mpeg\"\n\t| \"video/ogg\"\n\t| \"video/webm\"\n\t| \"video/x-msvideo\"\n\t| AnyString;\n","import type { CallApiConfig, CallApiExtraOptions } from \"../types/common\";\nimport { defineEnum } from \"../types/type-helpers\";\n\nexport const extraOptionDefaults = Object.freeze(\n\tdefineEnum({\n\t\t// Common defaults\n\t\tbodySerializer: JSON.stringify,\n\t\tdefaultHTTPErrorMessage: \"Request failed unexpectedly\",\n\n\t\t// Dedupe defaults\n\t\t/* eslint-disable perfectionist/sort-objects -- Allow */\n\t\tdedupeCacheScope: \"local\",\n\t\tdedupeCacheScopeKey: \"default\",\n\t\tdedupeStrategy: \"cancel\",\n\t\t/* eslint-enable perfectionist/sort-objects -- Allow */\n\n\t\t// Hook defaults\n\t\thooksExecutionMode: \"parallel\",\n\n\t\t// Response defaults\n\t\tresponseParser: JSON.parse,\n\t\tresponseType: \"json\",\n\t\tresultMode: \"all\",\n\n\t\t// Retry Defaults\n\t\tretryAttempts: 0,\n\t\tretryCondition: () => true,\n\t\tretryDelay: 1000,\n\t\tretryMaxDelay: 10000,\n\t\tretryMethods: [\"GET\", \"POST\"],\n\t\tretryStatusCodes: [],\n\t\tretryStrategy: \"linear\",\n\t} satisfies CallApiExtraOptions)\n);\n\nexport const requestOptionDefaults = defineEnum({\n\tmethod: \"GET\",\n} satisfies CallApiConfig);\n"],"mappings":";AAoCA,MAAa,cAA2C,UACvD,OAAO,OAAO,MAAM;;;;AClCrB,MAAa,sBAAsB,OAAO,OACzC,WAAW;CAEV,gBAAgB,KAAK;CACrB,yBAAyB;CAIzB,kBAAkB;CAClB,qBAAqB;CACrB,gBAAgB;CAIhB,oBAAoB;CAGpB,gBAAgB,KAAK;CACrB,cAAc;CACd,YAAY;CAGZ,eAAe;CACf,sBAAsB;CACtB,YAAY;CACZ,eAAe;CACf,cAAc,CAAC,OAAO,OAAO;CAC7B,kBAAkB,EAAE;CACpB,eAAe;CACf,CAA+B,CAChC;AAED,MAAa,wBAAwB,WAAW,EAC/C,QAAQ,OACR,CAAyB"}
|
|
@@ -26,7 +26,10 @@ type UnmaskType<TValue> = {
|
|
|
26
26
|
* skip this site for inference and use other arguments or defaults instead.
|
|
27
27
|
*/
|
|
28
28
|
type NoInferUnMasked<TGeneric> = [TGeneric][TGeneric extends unknown ? 0 : never];
|
|
29
|
-
type
|
|
29
|
+
type RemoveDedupeOrRetryPrefix<TPrefixToRemove extends "dedupe" | "retry", TKey extends string> = TKey extends `${TPrefixToRemove}${infer TRest}` ? Uncapitalize<TRest> : TKey;
|
|
30
|
+
type RemoveSlashImpl<TUrl extends string, TDirection extends "leading" | "trailing"> = TDirection extends "leading" ? TUrl extends `/${infer TWithoutLeadingSlash}` ? TWithoutLeadingSlash : TUrl : TDirection extends "trailing" ? TUrl extends `${infer TWithoutTailingSlash}/` ? TWithoutTailingSlash : TUrl : never;
|
|
31
|
+
type RemoveTrailingSlash<TUrl extends string> = RemoveSlashImpl<TUrl, "trailing">;
|
|
32
|
+
type RemoveLeadingSlash<TUrl extends string> = RemoveSlashImpl<TUrl, "leading">;
|
|
30
33
|
type Awaitable<TValue> = Promise<TValue> | TValue;
|
|
31
34
|
type Satisfies<TActualObject extends TExpectedObject, TExpectedObject> = { [Key in keyof TActualObject]: Key extends keyof TExpectedObject ? TActualObject[Key] : never };
|
|
32
35
|
type DistributiveOmit<TObject, TKeysToOmit extends keyof TObject> = TObject extends unknown ? Omit<TObject, TKeysToOmit> : never;
|
|
@@ -303,7 +306,7 @@ type ResponseStreamContext<TCallApiContext extends Pick<CallApiContext, "Inferre
|
|
|
303
306
|
//#region src/dedupe.d.ts
|
|
304
307
|
type DedupeStrategyUnion = UnmaskType<"cancel" | "defer" | "none">;
|
|
305
308
|
type DedupeOptionKeys = Exclude<keyof DedupeOptions, "dedupe">;
|
|
306
|
-
type InnerDedupeOptions = { [Key in DedupeOptionKeys as
|
|
309
|
+
type InnerDedupeOptions = { [Key in DedupeOptionKeys as RemoveDedupeOrRetryPrefix<"dedupe", Key>]?: DedupeOptions[Key] };
|
|
307
310
|
type DedupeOptions = {
|
|
308
311
|
/**
|
|
309
312
|
* All dedupe options in a single object instead of separate properties
|
|
@@ -725,7 +728,7 @@ interface CallApiSchema {
|
|
|
725
728
|
}
|
|
726
729
|
declare const routeKeyMethods: readonly ["delete", "get", "patch", "post", "put"];
|
|
727
730
|
type RouteKeyMethods = (typeof routeKeyMethods)[number];
|
|
728
|
-
type RouteKeyMethodsURLUnion =
|
|
731
|
+
type RouteKeyMethodsURLUnion = `${AtSymbol}${RouteKeyMethods}/`;
|
|
729
732
|
type BaseSchemaRouteKeyPrefixes = FallBackRouteSchemaKey | RouteKeyMethodsURLUnion;
|
|
730
733
|
type BaseCallApiSchemaRoutes = Partial<Record<AnyString | BaseSchemaRouteKeyPrefixes, CallApiSchema>>;
|
|
731
734
|
type BaseCallApiSchemaAndConfig = {
|
|
@@ -734,6 +737,8 @@ type BaseCallApiSchemaAndConfig = {
|
|
|
734
737
|
};
|
|
735
738
|
//#endregion
|
|
736
739
|
//#region src/url.d.ts
|
|
740
|
+
declare const atSymbol = "@";
|
|
741
|
+
type AtSymbol = typeof atSymbol;
|
|
737
742
|
type AllowedQueryParamValues = UnmaskType<boolean | number | string>;
|
|
738
743
|
type RecordStyleParams = UnmaskType<Record<string, AllowedQueryParamValues>>;
|
|
739
744
|
type TupleStyleParams = UnmaskType<AllowedQueryParamValues[]>;
|
|
@@ -858,15 +863,15 @@ interface URLOptions {
|
|
|
858
863
|
* @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
|
|
859
864
|
*/
|
|
860
865
|
type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaOutput<TSchemaOption, undefined> ? TObject : Required<TObject>;
|
|
861
|
-
type
|
|
862
|
-
type ApplyURLBasedConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["prefix"] extends string ?
|
|
866
|
+
type MergeBaseWithRouteKey<TBaseURLOrPrefix extends string | undefined, TRouteKey extends string> = TBaseURLOrPrefix extends string ? TRouteKey extends `${AtSymbol}${infer TMethod extends RouteKeyMethods}/${infer TRestOfRoutKey}` ? `${AtSymbol}${TMethod}/${RemoveLeadingSlash<RemoveTrailingSlash<TBaseURLOrPrefix>>}/${RemoveLeadingSlash<TRestOfRoutKey>}` : `${TBaseURLOrPrefix}${TRouteKey}` : TRouteKey;
|
|
867
|
+
type ApplyURLBasedConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["prefix"] extends string ? MergeBaseWithRouteKey<TSchemaConfig["prefix"], TSchemaRouteKeys> : TSchemaConfig["baseURL"] extends string ? MergeBaseWithRouteKey<TSchemaConfig["baseURL"], TSchemaRouteKeys> : TSchemaRouteKeys;
|
|
863
868
|
type ApplyStrictConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["strict"] extends true ? TSchemaRouteKeys :
|
|
864
869
|
// eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
|
|
865
870
|
TSchemaRouteKeys | Exclude<InitURLOrURLObject, RouteKeyMethodsURLUnion>;
|
|
866
871
|
type ApplySchemaConfiguration<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, TSchemaRouteKeys>>;
|
|
867
872
|
type InferAllRouteKeys<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = ApplySchemaConfiguration<TSchemaConfig, Exclude<Extract<keyof TBaseSchemaRoutes, string>, FallBackRouteSchemaKey>>;
|
|
868
873
|
type InferInitURL<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes extends never ? InitURLOrURLObject : InferAllRouteKeys<TBaseSchemaRoutes, TSchemaConfig>;
|
|
869
|
-
type GetCurrentRouteSchemaKey<TSchemaConfig extends CallApiSchemaConfig, TPath> = TPath extends URL ? string : TSchemaConfig["
|
|
874
|
+
type GetCurrentRouteSchemaKey<TSchemaConfig extends CallApiSchemaConfig, TPath> = TPath extends URL ? string : TSchemaConfig["prefix"] extends string ? TPath extends (`${AtSymbol}${infer TMethod extends RouteKeyMethods}/${RemoveLeadingSlash<TSchemaConfig["prefix"]>}${infer TCurrentRoute}`) ? `${AtSymbol}${TMethod}/${RemoveLeadingSlash<TCurrentRoute>}` : TPath extends `${TSchemaConfig["prefix"]}${infer TCurrentRoute}` ? TCurrentRoute : string : TSchemaConfig["baseURL"] extends string ? TPath extends (`${AtSymbol}${infer TMethod extends RouteKeyMethods}/${TSchemaConfig["baseURL"]}${infer TCurrentRoute}`) ? `${AtSymbol}${TMethod}/${RemoveLeadingSlash<TCurrentRoute>}` : TPath extends `${TSchemaConfig["baseURL"]}${infer TCurrentRoute}` ? TCurrentRoute : string : TPath;
|
|
870
875
|
type GetCurrentRouteSchema<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TComputedFallBackRouteSchema = TBaseSchemaRoutes[FallBackRouteSchemaKey], TComputedCurrentRouteSchema = TBaseSchemaRoutes[TCurrentRouteSchemaKey], TComputedRouteSchema extends CallApiSchema = NonNullable<Omit<TComputedFallBackRouteSchema, keyof TComputedCurrentRouteSchema> & TComputedCurrentRouteSchema>> = TComputedRouteSchema extends CallApiSchema ? Writeable<TComputedRouteSchema, "deep"> : CallApiSchema;
|
|
871
876
|
type JsonPrimitive = boolean | number | string | null | undefined;
|
|
872
877
|
type SerializableObject = Record<PropertyKey, unknown>;
|
|
@@ -879,7 +884,7 @@ type InferBodyOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIf
|
|
|
879
884
|
body?: InferSchemaOutput<TSchema["body"], Body>;
|
|
880
885
|
}>;
|
|
881
886
|
type MethodUnion = UnmaskType<"CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" | AnyString>;
|
|
882
|
-
type InferMethodFromURL<TInitURL> = string extends TInitURL ? MethodUnion : TInitURL extends
|
|
887
|
+
type InferMethodFromURL<TInitURL> = string extends TInitURL ? MethodUnion : TInitURL extends `${AtSymbol}${infer TMethod extends RouteKeyMethods}/${string}` ? Uppercase<TMethod> : MethodUnion;
|
|
883
888
|
type InferMethodOption<TSchema extends CallApiSchema, TInitURL> = MakeSchemaOptionRequiredIfDefined<TSchema["method"], {
|
|
884
889
|
/**
|
|
885
890
|
* HTTP method for the request.
|
|
@@ -981,10 +986,10 @@ type EmptyString = "";
|
|
|
981
986
|
type EmptyTuple = readonly [];
|
|
982
987
|
type StringTuple = readonly string[];
|
|
983
988
|
type PossibleParamNamePatterns = `${string}:${string}` | `${string}{${string}}${"" | AnyString}`;
|
|
984
|
-
type ExtractRouteParamNames<TCurrentRoute, TParamNamesAccumulator extends StringTuple = EmptyTuple> = TCurrentRoute extends PossibleParamNamePatterns ? TCurrentRoute extends `${infer TRoutePrefix}:${infer TParamAndRemainingRoute}` ? TParamAndRemainingRoute extends `${infer TCurrentParam}/${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}/${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}/${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamAndRemainingRoute extends `${infer TCurrentParam}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<TRoutePrefix, TParamNamesAccumulator> : ExtractRouteParamNames<TRoutePrefix, [...TParamNamesAccumulator, TCurrentParam]> : ExtractRouteParamNames<TRoutePrefix, TParamNamesAccumulator> : TCurrentRoute extends `${infer TRoutePrefix}{${infer TCurrentParam}}${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamNamesAccumulator : TParamNamesAccumulator;
|
|
989
|
+
type ExtractRouteParamNames<TCurrentRoute$1, TParamNamesAccumulator extends StringTuple = EmptyTuple> = TCurrentRoute$1 extends PossibleParamNamePatterns ? TCurrentRoute$1 extends `${infer TRoutePrefix}:${infer TParamAndRemainingRoute}` ? TParamAndRemainingRoute extends `${infer TCurrentParam}/${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}/${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}/${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamAndRemainingRoute extends `${infer TCurrentParam}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<TRoutePrefix, TParamNamesAccumulator> : ExtractRouteParamNames<TRoutePrefix, [...TParamNamesAccumulator, TCurrentParam]> : ExtractRouteParamNames<TRoutePrefix, TParamNamesAccumulator> : TCurrentRoute$1 extends `${infer TRoutePrefix}{${infer TCurrentParam}}${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamNamesAccumulator : TParamNamesAccumulator;
|
|
985
990
|
type ConvertParamNamesToRecord<TParamNames extends StringTuple> = Prettify<TParamNames extends (readonly [infer TFirstParamName extends string, ...infer TRemainingParamNames extends StringTuple]) ? Record<TFirstParamName, AllowedQueryParamValues> & ConvertParamNamesToRecord<TRemainingParamNames> : NonNullable<unknown>>;
|
|
986
991
|
type ConvertParamNamesToTuple<TParamNames extends StringTuple> = TParamNames extends readonly [string, ...infer TRemainingParamNames extends StringTuple] ? [AllowedQueryParamValues, ...ConvertParamNamesToTuple<TRemainingParamNames>] : [];
|
|
987
|
-
type InferParamsFromRoute<TCurrentRoute> = ExtractRouteParamNames<TCurrentRoute> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute>> : Params;
|
|
992
|
+
type InferParamsFromRoute<TCurrentRoute$1> = ExtractRouteParamNames<TCurrentRoute$1> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute$1> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute$1>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute$1>> : Params;
|
|
988
993
|
type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes, TCurrentRouteSchemaKey> ? undefined extends InferSchemaOutput<TParamsSchemaOption, null> ? TObject : Required<TObject> : TObject>;
|
|
989
994
|
type InferParamsOption<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema["params"], TBaseSchemaRoutes, TCurrentRouteSchemaKey, {
|
|
990
995
|
/**
|
|
@@ -1028,7 +1033,7 @@ type RetryCondition<TErrorData> = (context: ErrorContext<{
|
|
|
1028
1033
|
ErrorData: TErrorData;
|
|
1029
1034
|
}>) => Awaitable<boolean>;
|
|
1030
1035
|
type RetryOptionKeys<TErrorData> = Exclude<keyof RetryOptions<TErrorData>, "~retryAttemptCount" | "retry">;
|
|
1031
|
-
type InnerRetryOptions<TErrorData> = { [Key in RetryOptionKeys<TErrorData> as
|
|
1036
|
+
type InnerRetryOptions<TErrorData> = { [Key in RetryOptionKeys<TErrorData> as RemoveDedupeOrRetryPrefix<"retry", Key>]?: RetryOptions<TErrorData>[Key] };
|
|
1032
1037
|
interface RetryOptions<TErrorData> {
|
|
1033
1038
|
/**
|
|
1034
1039
|
* Keeps track of the number of times the request has already been retried
|
|
@@ -1644,6 +1649,7 @@ type GetBaseSchemaConfig<TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig
|
|
|
1644
1649
|
type InferExtendSchemaContext<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = {
|
|
1645
1650
|
baseSchemaRoutes: TBaseSchemaRoutes;
|
|
1646
1651
|
currentRouteSchema: GetCurrentRouteSchema<TBaseSchemaRoutes, TCurrentRouteSchemaKey>;
|
|
1652
|
+
currentRouteSchemaKey: TCurrentRouteSchemaKey;
|
|
1647
1653
|
};
|
|
1648
1654
|
type GetExtendSchemaConfigContext<TBaseSchemaConfig extends CallApiSchemaConfig> = {
|
|
1649
1655
|
baseSchemaConfig: TBaseSchemaConfig;
|
|
@@ -1651,7 +1657,7 @@ type GetExtendSchemaConfigContext<TBaseSchemaConfig extends CallApiSchemaConfig>
|
|
|
1651
1657
|
type InferExtendPluginContext<TBasePluginArray extends CallApiPlugin[]> = {
|
|
1652
1658
|
basePlugins: TBasePluginArray;
|
|
1653
1659
|
};
|
|
1654
|
-
type CallApiExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TCurrentRouteSchemaKey extends string = string
|
|
1660
|
+
type CallApiExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TCurrentRouteSchemaKey extends string = string> = SharedExtraOptions<TCallApiContext, TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray> & {
|
|
1655
1661
|
/**
|
|
1656
1662
|
* Array of instance-specific CallApi plugins or a function to configure plugins.
|
|
1657
1663
|
*
|
|
@@ -1660,7 +1666,7 @@ type CallApiExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApi
|
|
|
1660
1666
|
* that receives base plugins and returns the instance plugins.
|
|
1661
1667
|
*
|
|
1662
1668
|
*/
|
|
1663
|
-
plugins?: TPluginArray | ((context:
|
|
1669
|
+
plugins?: TPluginArray | ((context: InferExtendPluginContext<TBasePluginArray>) => TPluginArray);
|
|
1664
1670
|
/**
|
|
1665
1671
|
* For instance-specific validation schemas
|
|
1666
1672
|
*
|
|
@@ -1669,7 +1675,7 @@ type CallApiExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApi
|
|
|
1669
1675
|
* Can be a static schema object or a function that receives base schema context and returns instance schemas.
|
|
1670
1676
|
*
|
|
1671
1677
|
*/
|
|
1672
|
-
schema?: TSchema | ((context:
|
|
1678
|
+
schema?: TSchema | ((context: InferExtendSchemaContext<TBaseSchemaRoutes, TCurrentRouteSchemaKey>) => TSchema);
|
|
1673
1679
|
/**
|
|
1674
1680
|
* Instance-specific schema configuration or a function to configure schema behavior.
|
|
1675
1681
|
*
|
|
@@ -1677,7 +1683,7 @@ type CallApiExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApi
|
|
|
1677
1683
|
* Can override base schema configuration or extend it with instance-specific validation rules.
|
|
1678
1684
|
*
|
|
1679
1685
|
*/
|
|
1680
|
-
schemaConfig?: TSchemaConfig | ((context:
|
|
1686
|
+
schemaConfig?: TSchemaConfig | ((context: GetExtendSchemaConfigContext<TBaseSchemaConfig>) => TSchemaConfig);
|
|
1681
1687
|
};
|
|
1682
1688
|
type CallApiExtraOptionsForHooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> = Hooks & Omit<CallApiExtraOptions<TCallApiContext>, keyof Hooks>;
|
|
1683
1689
|
type InstanceContext = {
|
|
@@ -1822,9 +1828,9 @@ type DefaultCallApiContext = Prettify<Required<Omit<CallApiContext, "Meta">> & {
|
|
|
1822
1828
|
//#region src/createFetchClient.d.ts
|
|
1823
1829
|
declare const createFetchClientWithContext: <TOuterCallApiContext extends CallApiContext = DefaultCallApiContext>() => <TBaseCallApiContext extends CallApiContext = TOuterCallApiContext, TBaseData = TBaseCallApiContext["Data"], TBaseErrorData = TBaseCallApiContext["ErrorData"], TBaseResultMode extends ResultModeType = (TBaseCallApiContext["ResultMode"] extends ResultModeType ? TBaseCallApiContext["ResultMode"] : ResultModeType), TBaseThrowOnError extends ThrowOnErrorUnion = boolean, TBaseResponseType extends ResponseTypeType = ResponseTypeType, const TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig, const TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedBaseSchemaConfig extends CallApiSchemaConfig = GetBaseSchemaConfig<TBaseSchemaAndConfig>, TComputedBaseSchemaRoutes extends BaseCallApiSchemaRoutes = GetBaseSchemaRoutes<TBaseSchemaAndConfig>>(initBaseConfig?: BaseCallApiConfig<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBaseSchemaAndConfig, TBasePluginArray>) => <TData = TBaseData, TErrorData = TBaseErrorData, TResultMode extends ResultModeType = TBaseResultMode, TCallApiContext extends CallApiContext = TBaseCallApiContext, TThrowOnError extends ThrowOnErrorUnion = TBaseThrowOnError, TResponseType extends ResponseTypeType = TBaseResponseType, const TSchemaConfig extends CallApiSchemaConfig = TComputedBaseSchemaConfig, TInitURL extends InferInitURL<TComputedBaseSchemaRoutes, TSchemaConfig> = InferInitURL<TComputedBaseSchemaRoutes, TSchemaConfig>, TCurrentRouteSchemaKey extends GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL> = GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL>, const TSchema extends CallApiSchema = GetCurrentRouteSchema<TComputedBaseSchemaRoutes, TCurrentRouteSchemaKey>, const TPluginArray extends CallApiPlugin[] = TBasePluginArray, TComputedData = InferSchemaOutput<TSchema["data"], GetResponseType<TData, TResponseType>>, TComputedErrorData = InferSchemaOutput<TSchema["errorData"], GetResponseType<TErrorData, TResponseType>>, TComputedResult = CallApiResult<TComputedData, TComputedErrorData, TResultMode, TThrowOnError>>(initURL: TInitURL, initConfig?: CallApiConfig<TCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBasePluginArray, TPluginArray>) => Promise<TComputedResult>;
|
|
1824
1830
|
declare const createFetchClient: <TBaseCallApiContext extends CallApiContext = {
|
|
1831
|
+
InferredExtraOptions: unknown;
|
|
1825
1832
|
Data: DefaultDataType;
|
|
1826
1833
|
ErrorData: DefaultDataType;
|
|
1827
|
-
InferredExtraOptions: unknown;
|
|
1828
1834
|
ResultMode: ResultModeType;
|
|
1829
1835
|
Meta: GlobalMeta;
|
|
1830
1836
|
}, TBaseData = TBaseCallApiContext["Data"], TBaseErrorData = TBaseCallApiContext["ErrorData"], TBaseResultMode extends ResultModeType = (TBaseCallApiContext["ResultMode"] extends ResultModeType ? TBaseCallApiContext["ResultMode"] : ResultModeType), TBaseThrowOnError extends ThrowOnErrorUnion = boolean, TBaseResponseType extends ResponseTypeType = ResponseTypeType, const TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig, const TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedBaseSchemaConfig extends CallApiSchemaConfig = Writeable<NonNullable<TBaseSchemaAndConfig["config"]>, "deep">, TComputedBaseSchemaRoutes extends BaseCallApiSchemaRoutes = Writeable<TBaseSchemaAndConfig["routes"], "deep">>(initBaseConfig?: BaseCallApiConfig<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBaseSchemaAndConfig, TBasePluginArray>) => <TData = TBaseData, TErrorData = TBaseErrorData, TResultMode extends ResultModeType = TBaseResultMode, TCallApiContext extends CallApiContext = TBaseCallApiContext, TThrowOnError extends ThrowOnErrorUnion = TBaseThrowOnError, TResponseType extends ResponseTypeType = TBaseResponseType, const TSchemaConfig extends CallApiSchemaConfig = TComputedBaseSchemaConfig, TInitURL extends InferInitURL<TComputedBaseSchemaRoutes, TSchemaConfig> = InferInitURL<TComputedBaseSchemaRoutes, TSchemaConfig>, TCurrentRouteSchemaKey extends GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL> = GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL>, const TSchema extends CallApiSchema = GetCurrentRouteSchema<TComputedBaseSchemaRoutes, TCurrentRouteSchemaKey, TComputedBaseSchemaRoutes["@default"], TComputedBaseSchemaRoutes[TCurrentRouteSchemaKey], NonNullable<Omit<TComputedBaseSchemaRoutes["@default"], keyof TComputedBaseSchemaRoutes[TCurrentRouteSchemaKey]> & TComputedBaseSchemaRoutes[TCurrentRouteSchemaKey]>>, const TPluginArray extends CallApiPlugin[] = TBasePluginArray, TComputedData = InferSchemaResult<TSchema["data"], GetResponseType<TData, TResponseType, ResponseTypeMap<TData>>, "infer-output">, TComputedErrorData = InferSchemaResult<TSchema["errorData"], GetResponseType<TErrorData, TResponseType, ResponseTypeMap<TErrorData>>, "infer-output">, TComputedResult = InferCallApiResult<TComputedData, TComputedErrorData, TResultMode, TThrowOnError, {
|
|
@@ -1842,9 +1848,9 @@ declare const createFetchClient: <TBaseCallApiContext extends CallApiContext = {
|
|
|
1842
1848
|
withoutResponse: DistributiveOmit<TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>, "response"> extends infer T ? { [Key in keyof T]: T[Key] } : never;
|
|
1843
1849
|
}>>(initURL: TInitURL, initConfig?: CallApiConfig<TCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBasePluginArray, TPluginArray>) => Promise<TComputedResult>;
|
|
1844
1850
|
declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode extends ResultModeType = ResultModeType, TCallApiContext extends CallApiContext = {
|
|
1851
|
+
InferredExtraOptions: unknown;
|
|
1845
1852
|
Data: DefaultDataType;
|
|
1846
1853
|
ErrorData: DefaultDataType;
|
|
1847
|
-
InferredExtraOptions: unknown;
|
|
1848
1854
|
ResultMode: ResultModeType;
|
|
1849
1855
|
Meta: GlobalMeta;
|
|
1850
1856
|
}, TThrowOnError extends ThrowOnErrorUnion = boolean, TResponseType extends ResponseTypeType = ResponseTypeType, const TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, AnyString | "@delete/" | "@get/" | "@patch/" | "@post/" | "@put/">> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, AnyString | "@delete/" | "@get/" | "@patch/" | "@post/" | "@put/">>, TCurrentRouteSchemaKey extends GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL> = GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL>, const TSchema extends CallApiSchema = GetCurrentRouteSchema<{
|
|
@@ -1903,4 +1909,4 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
|
|
|
1903
1909
|
}, TSchema, CallApiSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, DefaultPluginArray, TPluginArray>) => Promise<TComputedResult>;
|
|
1904
1910
|
//#endregion
|
|
1905
1911
|
export { ResponseStreamContext as $, Register as A, InferSchemaInput as B, CallApiParameters as C, GetExtendSchemaConfigContext as D, CallApiResultLoose as E, URLOptions as F, DedupeOptions as G, FetchImpl as H, BaseCallApiSchemaRoutes as I, HooksOrHooksArray as J, ErrorContext as K, BaseSchemaRouteKeyPrefixes as L, ValidationError as M, RetryOptions as N, InferExtendSchemaContext as O, InferParamsFromRoute as P, ResponseErrorContext as Q, CallApiSchema as R, CallApiExtraOptionsForHooks as S, CallApiRequestOptionsForHooks as T, FetchMiddlewareContext as U, InferSchemaOutput as V, Middlewares as W, RequestStreamContext as X, RequestContext as Y, ResponseContext as Z, ResultModeType as _, CallApiPlugin as a, CallApiConfig as b, PluginSetupContext as c, CallApiResultSuccessVariant as d, SuccessContext as et, PossibleHTTPError as f, ResponseTypeType as g, PossibleValidationError as h, DefaultCallApiContext as i, HTTPError as j, InstanceContext as k, CallApiResultErrorVariant as l, PossibleJavaScriptOrValidationError as m, createFetchClient as n, Satisfies as nt, PluginHooks as o, PossibleJavaScriptError as p, Hooks as q, createFetchClientWithContext as r, Writeable as rt, PluginMiddlewares as s, callApi as t, AnyFunction as tt, CallApiResultSuccessOrErrorVariant as u, BaseCallApiConfig as v, CallApiRequestOptions as w, CallApiExtraOptions as x, BaseCallApiExtraOptions as y, CallApiSchemaConfig as z };
|
|
1906
|
-
//# sourceMappingURL=index-
|
|
1912
|
+
//# sourceMappingURL=index-DGGInQcS.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as ResponseStreamContext, A as Register, B as InferSchemaInput, C as CallApiParameters, D as GetExtendSchemaConfigContext, E as CallApiResultLoose, F as URLOptions, G as DedupeOptions, H as FetchImpl, I as BaseCallApiSchemaRoutes, J as HooksOrHooksArray, K as ErrorContext, L as BaseSchemaRouteKeyPrefixes, N as RetryOptions, O as InferExtendSchemaContext, P as InferParamsFromRoute, Q as ResponseErrorContext, R as CallApiSchema, S as CallApiExtraOptionsForHooks, T as CallApiRequestOptionsForHooks, U as FetchMiddlewareContext, V as InferSchemaOutput, W as Middlewares, X as RequestStreamContext, Y as RequestContext, Z as ResponseContext, _ as ResultModeType, a as CallApiPlugin, b as CallApiConfig, c as PluginSetupContext, d as CallApiResultSuccessVariant, et as SuccessContext, f as PossibleHTTPError, g as ResponseTypeType, h as PossibleValidationError, i as DefaultCallApiContext, k as InstanceContext, l as CallApiResultErrorVariant, m as PossibleJavaScriptOrValidationError, n as createFetchClient, o as PluginHooks, p as PossibleJavaScriptError, q as Hooks, r as createFetchClientWithContext, s as PluginMiddlewares, t as callApi, u as CallApiResultSuccessOrErrorVariant, v as BaseCallApiConfig, w as CallApiRequestOptions, x as CallApiExtraOptions, y as BaseCallApiExtraOptions, z as CallApiSchemaConfig } from "./index-
|
|
1
|
+
import { $ as ResponseStreamContext, A as Register, B as InferSchemaInput, C as CallApiParameters, D as GetExtendSchemaConfigContext, E as CallApiResultLoose, F as URLOptions, G as DedupeOptions, H as FetchImpl, I as BaseCallApiSchemaRoutes, J as HooksOrHooksArray, K as ErrorContext, L as BaseSchemaRouteKeyPrefixes, N as RetryOptions, O as InferExtendSchemaContext, P as InferParamsFromRoute, Q as ResponseErrorContext, R as CallApiSchema, S as CallApiExtraOptionsForHooks, T as CallApiRequestOptionsForHooks, U as FetchMiddlewareContext, V as InferSchemaOutput, W as Middlewares, X as RequestStreamContext, Y as RequestContext, Z as ResponseContext, _ as ResultModeType, a as CallApiPlugin, b as CallApiConfig, c as PluginSetupContext, d as CallApiResultSuccessVariant, et as SuccessContext, f as PossibleHTTPError, g as ResponseTypeType, h as PossibleValidationError, i as DefaultCallApiContext, k as InstanceContext, l as CallApiResultErrorVariant, m as PossibleJavaScriptOrValidationError, n as createFetchClient, o as PluginHooks, p as PossibleJavaScriptError, q as Hooks, r as createFetchClientWithContext, s as PluginMiddlewares, t as callApi, u as CallApiResultSuccessOrErrorVariant, v as BaseCallApiConfig, w as CallApiRequestOptions, x as CallApiExtraOptions, y as BaseCallApiExtraOptions, z as CallApiSchemaConfig } from "./index-DGGInQcS.js";
|
|
2
2
|
export { BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchemaRoutes, BaseSchemaRouteKeyPrefixes, CallApiConfig, CallApiExtraOptions, CallApiExtraOptionsForHooks, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResultLoose as CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessOrErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig, DedupeOptions, DefaultCallApiContext, ErrorContext, FetchImpl, FetchMiddlewareContext, GetExtendSchemaConfigContext, Hooks, HooksOrHooksArray, InferExtendSchemaContext, InferParamsFromRoute, InferSchemaInput, InferSchemaOutput, InstanceContext, Middlewares, PluginHooks, PluginMiddlewares, PluginSetupContext, PossibleHTTPError, PossibleJavaScriptError, PossibleJavaScriptOrValidationError, PossibleValidationError, Register, RequestContext, RequestStreamContext, ResponseContext, ResponseErrorContext, ResponseStreamContext, ResponseTypeType, ResultModeType, RetryOptions, SuccessContext, URLOptions, callApi, createFetchClient, createFetchClientWithContext };
|
package/dist/index.js
CHANGED
|
@@ -167,7 +167,8 @@ const getResolvedSchema = (context) => {
|
|
|
167
167
|
currentRouteSchema,
|
|
168
168
|
resolvedSchema: isFunction(extraOptions.schema) ? extraOptions.schema({
|
|
169
169
|
baseSchemaRoutes: baseExtraOptions.schema?.routes ?? {},
|
|
170
|
-
currentRouteSchema: resolvedRouteSchema ?? {}
|
|
170
|
+
currentRouteSchema: resolvedRouteSchema ?? {},
|
|
171
|
+
currentRouteSchemaKey
|
|
171
172
|
}) : extraOptions.schema ?? resolvedRouteSchema
|
|
172
173
|
};
|
|
173
174
|
};
|
|
@@ -175,6 +176,7 @@ const getResolvedSchemaConfig = (context) => {
|
|
|
175
176
|
const { baseExtraOptions, extraOptions } = context;
|
|
176
177
|
return isFunction(extraOptions.schemaConfig) ? extraOptions.schemaConfig({ baseSchemaConfig: baseExtraOptions.schema?.config ?? {} }) : extraOptions.schemaConfig ?? baseExtraOptions.schema?.config;
|
|
177
178
|
};
|
|
179
|
+
const removeLeadingSlash = (value) => value.startsWith("/") ? value.slice(1) : value;
|
|
178
180
|
const getCurrentRouteSchemaKeyAndMainInitURL = (context) => {
|
|
179
181
|
const { baseExtraOptions, extraOptions, initURL } = context;
|
|
180
182
|
const schemaConfig = getResolvedSchemaConfig({
|
|
@@ -183,11 +185,19 @@ const getCurrentRouteSchemaKeyAndMainInitURL = (context) => {
|
|
|
183
185
|
});
|
|
184
186
|
let currentRouteSchemaKey = initURL;
|
|
185
187
|
let mainInitURL = initURL;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
188
|
+
const methodFromURL = extractMethodFromURL(initURL);
|
|
189
|
+
const pathWithoutMethod = normalizeURL(initURL, { retainLeadingSlashForRelativeURLs: false });
|
|
190
|
+
const prefixWithoutLeadingSlash = schemaConfig?.prefix && removeLeadingSlash(schemaConfig.prefix);
|
|
191
|
+
if (schemaConfig?.prefix && prefixWithoutLeadingSlash && pathWithoutMethod.startsWith(prefixWithoutLeadingSlash)) {
|
|
192
|
+
const restOfPathWithoutPrefix = pathWithoutMethod.slice(prefixWithoutLeadingSlash.length);
|
|
193
|
+
currentRouteSchemaKey = methodFromURL ? `${atSymbol}${methodFromURL}/${removeLeadingSlash(restOfPathWithoutPrefix)}` : restOfPathWithoutPrefix;
|
|
194
|
+
const pathWithReplacedPrefix = pathWithoutMethod.replace(prefixWithoutLeadingSlash, schemaConfig.baseURL ?? "");
|
|
195
|
+
mainInitURL = methodFromURL ? `${atSymbol}${methodFromURL}/${removeLeadingSlash(pathWithReplacedPrefix)}` : pathWithReplacedPrefix;
|
|
196
|
+
}
|
|
197
|
+
if (schemaConfig?.baseURL && pathWithoutMethod.startsWith(schemaConfig.baseURL)) {
|
|
198
|
+
const restOfPathWithoutBaseURL = pathWithoutMethod.slice(schemaConfig.baseURL.length);
|
|
199
|
+
currentRouteSchemaKey = methodFromURL ? `${atSymbol}${methodFromURL}/${removeLeadingSlash(restOfPathWithoutBaseURL)}` : restOfPathWithoutBaseURL;
|
|
189
200
|
}
|
|
190
|
-
if (schemaConfig?.baseURL && currentRouteSchemaKey.startsWith(schemaConfig.baseURL)) currentRouteSchemaKey = currentRouteSchemaKey.replace(schemaConfig.baseURL, "");
|
|
191
201
|
return {
|
|
192
202
|
currentRouteSchemaKey,
|
|
193
203
|
mainInitURL
|
|
@@ -248,14 +258,16 @@ const mergeUrlWithQuery = (url, query) => {
|
|
|
248
258
|
*/
|
|
249
259
|
const extractMethodFromURL = (initURL) => {
|
|
250
260
|
if (!initURL?.startsWith("@")) return;
|
|
251
|
-
const
|
|
252
|
-
if (!
|
|
253
|
-
return
|
|
261
|
+
const methodFromURL = routeKeyMethods.find((method) => initURL.startsWith(`${atSymbol}${method}${slash}`));
|
|
262
|
+
if (!methodFromURL) return;
|
|
263
|
+
return methodFromURL;
|
|
254
264
|
};
|
|
255
|
-
const
|
|
265
|
+
const atSymbol = "@";
|
|
266
|
+
const normalizeURL = (initURL, options = {}) => {
|
|
267
|
+
const { retainLeadingSlashForRelativeURLs = true } = options;
|
|
256
268
|
const methodFromURL = extractMethodFromURL(initURL);
|
|
257
269
|
if (!methodFromURL) return initURL;
|
|
258
|
-
return initURL.includes("http") ? initURL.replace(
|
|
270
|
+
return retainLeadingSlashForRelativeURLs && !initURL.includes("http") ? initURL.replace(`${atSymbol}${methodFromURL}`, "") : initURL.replace(`${atSymbol}${methodFromURL}${slash}`, "");
|
|
259
271
|
};
|
|
260
272
|
const getFullURL = (initURL, baseURL) => {
|
|
261
273
|
if (!baseURL || initURL.startsWith("http")) return initURL;
|
|
@@ -266,7 +278,7 @@ const getFullAndNormalizedURL = (options) => {
|
|
|
266
278
|
const normalizedInitURL = normalizeURL(initURL);
|
|
267
279
|
const fullURL = getFullURL(mergeUrlWithQuery(mergeUrlWithParams(normalizedInitURL, params), query), baseURL);
|
|
268
280
|
if (!URL.canParse(fullURL)) {
|
|
269
|
-
const errorMessage = !baseURL ? `Invalid URL '${
|
|
281
|
+
const errorMessage = !baseURL ? `Invalid URL '${initURL}'. Are you passing a relative url to CallApi without setting the 'baseURL' option?` : `Invalid URL '${fullURL}'. Please validate that you are passing the correct url.`;
|
|
270
282
|
console.error(errorMessage);
|
|
271
283
|
}
|
|
272
284
|
return {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["validatedResultObject: Prettify<\n\t\tPick<CallApiExtraOptions, (typeof extraOptionsToBeValidated)[number]>\n\t>","validatedResultObject: Prettify<\n\t\tPick<CallApiRequestOptions, (typeof requestOptionsToBeValidated)[number]>\n\t>","result: Record<string, unknown>","hookRegistries: HookRegistries","dedupeKey","dedupeCacheScopeKey","$GlobalRequestInfoCache","middlewareRegistries: MiddlewareRegistries","composedMiddleware: Middlewares[keyof Middlewares]","resolvedHooks: Hooks","resolvedMiddlewares: Middlewares","callApi","$GlobalRequestInfoCache: GlobalRequestInfoCache","createFetchClient","$LocalRequestInfoCache: RequestInfoCache","callApi"],"sources":["../src/auth.ts","../src/validation.ts","../src/url.ts","../src/utils/polyfills/combinedSignal.ts","../src/utils/polyfills/timeoutSignal.ts","../src/utils/common.ts","../src/result.ts","../src/hooks.ts","../src/stream.ts","../src/dedupe.ts","../src/middlewares.ts","../src/plugins.ts","../src/retry.ts","../src/createFetchClient.ts"],"sourcesContent":["/* eslint-disable perfectionist/sort-object-types -- Avoid Sorting for now */\n\nimport type { CallApiExtraOptions } from \"./types/common\";\nimport type { Awaitable } from \"./types/type-helpers\";\nimport { isFunction, isObject, isPromise } from \"./utils/guards\";\n\ntype PossibleAuthValue = Awaitable<string | null | undefined>;\n\ntype PossibleAuthValueOrGetter = PossibleAuthValue | (() => PossibleAuthValue);\n\n// export type BearerOrTokenAuth =\n// \t| {\n// \t\t\ttype?: \"Bearer\" | undefined;\n// \t\t\tbearer?: PossibleAuthValueOrGetter;\n// \t\t\ttoken?: never;\n// \t }\n// \t| {\n// \t\t\ttype?: \"Token\";\n// \t\t\tbearer?: never;\n// \t\t\ttoken?: PossibleAuthValueOrGetter;\n// \t };\n\nexport type BearerAuth = {\n\ttype: \"Bearer\";\n\tvalue: PossibleAuthValueOrGetter;\n};\n\nexport type TokenAuth = {\n\ttype: \"Token\";\n\tvalue: PossibleAuthValueOrGetter;\n};\n\nexport type BasicAuth = {\n\ttype: \"Basic\";\n\tusername: PossibleAuthValueOrGetter;\n\tpassword: PossibleAuthValueOrGetter;\n};\n\n/**\n * Custom auth\n *\n * @param prefix - prefix of the header\n * @param authValue - value of the header\n *\n * @example\n * ```ts\n * {\n * type: \"Custom\",\n * prefix: \"Token\",\n * authValue: \"token\"\n * }\n * ```\n */\nexport type CustomAuth = {\n\ttype: \"Custom\";\n\tprefix: PossibleAuthValueOrGetter;\n\tvalue: PossibleAuthValueOrGetter;\n};\n\n// eslint-disable-next-line perfectionist/sort-union-types -- Let the first one be first\nexport type AuthOption = PossibleAuthValueOrGetter | BearerAuth | TokenAuth | BasicAuth | CustomAuth;\n\nconst resolveAuthValue = (value: PossibleAuthValueOrGetter) => (isFunction(value) ? value() : value);\n\ntype AuthHeaderObject = { Authorization: string };\n\nexport const getAuthHeader = async (\n\tauth: CallApiExtraOptions[\"auth\"]\n): Promise<AuthHeaderObject | undefined> => {\n\tif (auth === undefined) return;\n\n\tif (isPromise(auth) || isFunction(auth) || !isObject(auth)) {\n\t\tconst authValue = await resolveAuthValue(auth);\n\n\t\tif (authValue === undefined) return;\n\n\t\treturn {\n\t\t\tAuthorization: `Bearer ${authValue}`,\n\t\t};\n\t}\n\n\tswitch (auth.type) {\n\t\tcase \"Basic\": {\n\t\t\tconst [username, password] = await Promise.all([\n\t\t\t\tresolveAuthValue(auth.username),\n\t\t\t\tresolveAuthValue(auth.password),\n\t\t\t]);\n\n\t\t\tif (username === undefined || password === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `Basic ${globalThis.btoa(`${username}:${password}`)}`,\n\t\t\t};\n\t\t}\n\t\tcase \"Bearer\": {\n\t\t\tconst value = await resolveAuthValue(auth.value);\n\n\t\t\tif (value === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `Bearer ${value}`,\n\t\t\t};\n\t\t}\n\t\tcase \"Custom\": {\n\t\t\tconst [prefix, value] = await Promise.all([\n\t\t\t\tresolveAuthValue(auth.prefix),\n\t\t\t\tresolveAuthValue(auth.value),\n\t\t\t]);\n\n\t\t\tif (value === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `${prefix} ${value}`,\n\t\t\t};\n\t\t}\n\n\t\tcase \"Token\": {\n\t\t\tconst value = await resolveAuthValue(auth.value);\n\n\t\t\tif (value === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `Token ${value}`,\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\tauth satisfies never;\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// default: {\n\t\t// \tconst [bearer, token] = await Promise.all([\n\t\t// \t\tresolveAuthValue(auth.bearer),\n\t\t// \t\tresolveAuthValue(auth.token),\n\t\t// \t]);\n\n\t\t// \tif (bearer !== undefined) {\n\t\t// \t\treturn { Authorization: `Bearer ${bearer}` };\n\t\t// \t}\n\n\t\t// \tif (token === undefined) return;\n\n\t\t// \treturn { Authorization: `Token ${token}` };\n\t\t// }\n\t}\n};\n","import type { AuthOption } from \"./auth\";\nimport { fallBackRouteSchemaKey, type FallBackRouteSchemaKey } from \"./constants/validation\";\nimport type {\n\tBaseCallApiExtraOptions,\n\tCallApiExtraOptions,\n\tCallApiRequestOptions,\n\tGlobalMeta,\n} from \"./types/common\";\nimport type { Body, HeadersOption, MethodUnion } from \"./types/conditional-types\";\nimport type { StandardSchemaV1 } from \"./types/standard-schema\";\nimport {\n\ttype AnyFunction,\n\ttype AnyString,\n\ttype Awaitable,\n\tdefineEnum,\n\ttype Prettify,\n\ttype UnionToIntersection,\n} from \"./types/type-helpers\";\nimport type { Params, Query } from \"./url\";\nimport { toArray } from \"./utils/common\";\nimport { ValidationError } from \"./utils/external/error\";\nimport { isFunction, isObject } from \"./utils/guards\";\n\ntype ResultVariant = \"infer-input\" | \"infer-output\";\n\nexport type InferSchemaResult<TSchema, TFallbackResult, TResultVariant extends ResultVariant> =\n\t// == Checking for undefined first and returning fallback to avoid type errors when passing the config around (weird tbh)\n\tundefined extends TSchema ? TFallbackResult\n\t: TSchema extends StandardSchemaV1 ?\n\t\tTResultVariant extends \"infer-input\" ?\n\t\t\tStandardSchemaV1.InferInput<TSchema>\n\t\t:\tStandardSchemaV1.InferOutput<TSchema>\n\t: TSchema extends AnyFunction<infer TResult> ? Awaited<TResult>\n\t: TFallbackResult;\n\nexport type InferSchemaOutput<TSchema, TFallbackResult = unknown> = InferSchemaResult<\n\tTSchema,\n\tTFallbackResult,\n\t\"infer-output\"\n>;\n\nexport type InferSchemaInput<TSchema, TFallbackResult = unknown> = InferSchemaResult<\n\tTSchema,\n\tTFallbackResult,\n\t\"infer-input\"\n>;\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: toArray(error) as never, value: undefined };\n\t}\n};\n\nexport const standardSchemaParser = async <\n\tTFullSchema extends CallApiSchema,\n\tTSchemaName extends keyof CallApiSchema,\n\tTSchema extends NonNullable<TFullSchema[TSchemaName]>,\n>(\n\tfullSchema: TFullSchema | undefined,\n\tschemaName: TSchemaName,\n\toptions: { inputValue: InferSchemaInput<TSchema>; response?: Response | null }\n): Promise<InferSchemaOutput<TSchema>> => {\n\tconst { inputValue, response } = options;\n\n\tconst schema = fullSchema?.[schemaName];\n\n\tif (!schema) {\n\t\treturn inputValue as never;\n\t}\n\n\tconst result =\n\t\tisFunction(schema) ?\n\t\t\tawait handleValidatorFunction(schema, inputValue)\n\t\t:\tawait schema[\"~standard\"].validate(inputValue);\n\n\t// == If the `issues` field exists, it means the validation failed\n\n\tif (result.issues) {\n\t\tthrow new ValidationError({\n\t\t\tissueCause: schemaName,\n\t\t\tissues: result.issues,\n\t\t\tresponse: response ?? null,\n\t\t});\n\t}\n\n\treturn result.value as never;\n};\n\ntype BooleanObject = {\n\t[Key in keyof CallApiSchema]: boolean;\n};\n\nexport interface CallApiSchemaConfig {\n\t/**\n\t * The base url of the schema. By default it's the baseURL of the callApi instance.\n\t */\n\tbaseURL?: \"\" | AnyString;\n\n\t/**\n\t * Disables runtime validation for the schema.\n\t */\n\tdisableRuntimeValidation?: boolean | BooleanObject;\n\n\t/**\n\t * If `true`, the original input value will be used instead of the transformed/validated output.\n\t *\n\t * When true, the original input is returned unchanged after validation, ignoring any schema-level\n\t * transformations such as type coercion, default values, or field mapping. Only the validation\n\t * step is executed; the resulting value is discarded in favor of the raw input.\n\t */\n\tdisableRuntimeValidationTransform?: boolean | BooleanObject;\n\n\t/**\n\t * Optional url prefix that will be substituted for the `baseURL` of the schemaConfig at runtime.\n\t *\n\t * Enables a short, stable prefix for routes while keeping the full `baseURL` centralized in config.\n\t * Keeps route definitions concise and shields them from changes to the underlying base URL.\n\t */\n\tprefix?: \"\" | AnyString;\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 and the runtime.\n\t * - Attempting to call routes not defined in the schema will result in both type errors and runtime validation 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 */\n\tstrict?: boolean;\n}\n\nexport interface CallApiSchema {\n\tauth?:\n\t\t| StandardSchemaV1<AuthOption | undefined>\n\t\t| ((auth: AuthOption) => Awaitable<AuthOption | undefined>);\n\n\t/**\n\t * The schema to use for validating the request body.\n\t */\n\tbody?: StandardSchemaV1<Body | undefined> | ((body: Body) => Awaitable<Body | undefined>);\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 | undefined>);\n\n\t/**\n\t * The schema to use for validating the meta option.\n\t */\n\tmeta?:\n\t\t| StandardSchemaV1<GlobalMeta | undefined>\n\t\t| ((meta: GlobalMeta) => Awaitable<GlobalMeta | undefined>);\n\n\t/**\n\t * The schema to use for validating the request method.\n\t */\n\tmethod?:\n\t\t| StandardSchemaV1<MethodUnion | undefined>\n\t\t| ((method: MethodUnion) => Awaitable<MethodUnion | undefined>);\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 | undefined>);\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 | undefined>);\n}\n\nexport const routeKeyMethods = defineEnum([\"delete\", \"get\", \"patch\", \"post\", \"put\"]);\n\nexport type RouteKeyMethods = (typeof routeKeyMethods)[number];\n\nexport type RouteKeyMethodsURLUnion = `@${RouteKeyMethods}/`;\n\nexport type BaseSchemaRouteKeyPrefixes = FallBackRouteSchemaKey | RouteKeyMethodsURLUnion;\n\nexport type BaseCallApiSchemaRoutes = Partial<\n\tRecord<AnyString | BaseSchemaRouteKeyPrefixes, CallApiSchema>\n>;\n\nexport type BaseCallApiSchemaAndConfig = {\n\tconfig?: CallApiSchemaConfig;\n\troutes: BaseCallApiSchemaRoutes;\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 handleSchemaValidation = async <\n\tTFullSchema extends CallApiSchema,\n\tTSchemaName extends keyof CallApiSchema,\n\tTSchema extends NonNullable<TFullSchema[TSchemaName]>,\n>(\n\tfullSchema: TFullSchema | undefined,\n\tschemaName: TSchemaName,\n\tvalidationOptions: ValidationOptions<TSchema>\n): Promise<InferSchemaOutput<TSchema>> => {\n\tconst { inputValue, response, schemaConfig } = validationOptions;\n\n\tconst disableRuntimeValidationBooleanObject =\n\t\tisObject(schemaConfig?.disableRuntimeValidation) ? schemaConfig.disableRuntimeValidation : {};\n\n\tconst shouldDisableRuntimeValidation =\n\t\tschemaConfig?.disableRuntimeValidation === true\n\t\t|| disableRuntimeValidationBooleanObject[schemaName] === true;\n\n\tif (shouldDisableRuntimeValidation) {\n\t\treturn inputValue as never;\n\t}\n\n\tconst validResult = await standardSchemaParser(fullSchema, schemaName, { inputValue, response });\n\n\tconst disableResultApplicationBooleanObject =\n\t\tisObject(schemaConfig?.disableRuntimeValidationTransform) ?\n\t\t\tschemaConfig.disableRuntimeValidationTransform\n\t\t:\t{};\n\n\tconst shouldDisableResultApplication =\n\t\tschemaConfig?.disableRuntimeValidationTransform === true\n\t\t|| disableResultApplicationBooleanObject[schemaName] === true;\n\n\tif (shouldDisableResultApplication) {\n\t\treturn inputValue as never;\n\t}\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> =\n\ttrue extends TComputedIsUnionEqualToNever ? []\n\t:\tPush<UnionToTuple<Exclude<TUnion, TComputedLastUnion>>, TComputedLastUnion>;\n\nexport type Tuple<TTuple, TArray extends TTuple[] = []> =\n\tUnionToTuple<TTuple>[\"length\"] extends TArray[\"length\"] ? [...TArray]\n\t:\tTuple<TTuple, [TTuple, ...TArray]>;\n\nconst extraOptionsToBeValidated = [\"meta\", \"params\", \"query\", \"auth\"] satisfies Tuple<\n\tExtract<keyof CallApiSchema, keyof CallApiExtraOptions>\n>;\n\ntype ExtraOptionsValidationOptions = {\n\toptions: CallApiExtraOptions;\n\tschema: CallApiSchema | undefined;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nconst handleExtraOptionsValidation = async (validationOptions: ExtraOptionsValidationOptions) => {\n\tconst { options, schema, schemaConfig } = validationOptions;\n\n\tconst validationResultArray = await Promise.all(\n\t\textraOptionsToBeValidated.map((schemaName) =>\n\t\t\thandleSchemaValidation(schema, schemaName, {\n\t\t\t\tinputValue: options[schemaName],\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, schemaName] of extraOptionsToBeValidated.entries()) {\n\t\tconst validationResult = validationResultArray[index];\n\n\t\tif (validationResult === undefined) continue;\n\n\t\tvalidatedResultObject[schemaName] = 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\trequest: CallApiRequestOptions;\n\tschema: CallApiSchema | undefined;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nconst handleRequestOptionsValidation = async (validationOptions: RequestOptionsValidationOptions) => {\n\tconst { request, schema, schemaConfig } = validationOptions;\n\n\tconst validationResultArray = await Promise.all(\n\t\trequestOptionsToBeValidated.map((schemaName) => {\n\t\t\treturn handleSchemaValidation(schema, schemaName, {\n\t\t\t\tinputValue: request[schemaName],\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 handleConfigValidation = async (\n\tvalidationOptions: GetResolvedSchemaContext\n\t\t& Omit<ExtraOptionsValidationOptions & RequestOptionsValidationOptions, \"schema\" | \"schemaConfig\">\n) => {\n\tconst { baseExtraOptions, currentRouteSchemaKey, extraOptions, options, request } = validationOptions;\n\n\tconst { currentRouteSchema, resolvedSchema } = getResolvedSchema({\n\t\tbaseExtraOptions,\n\t\tcurrentRouteSchemaKey,\n\t\textraOptions,\n\t});\n\n\tconst resolvedSchemaConfig = getResolvedSchemaConfig({ baseExtraOptions, extraOptions });\n\n\tif (resolvedSchemaConfig?.strict === true && !currentRouteSchema) {\n\t\tthrow new ValidationError({\n\t\t\tissueCause: \"schemaConfig-(strict)\",\n\t\t\tissues: [{ message: `Strict Mode - No schema found for route '${currentRouteSchemaKey}' ` }],\n\t\t\tresponse: null,\n\t\t});\n\t}\n\n\tconst [extraOptionsValidationResult, requestOptionsValidationResult] = await Promise.all([\n\t\thandleExtraOptionsValidation({\n\t\t\toptions,\n\t\t\tschema: resolvedSchema,\n\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t}),\n\t\thandleRequestOptionsValidation({\n\t\t\trequest,\n\t\t\tschema: resolvedSchema,\n\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t}),\n\t]);\n\n\treturn {\n\t\textraOptionsValidationResult,\n\t\trequestOptionsValidationResult,\n\t\tresolvedSchema,\n\t\tresolvedSchemaConfig,\n\t};\n};\n\ntype GetResolvedSchemaContext = {\n\tbaseExtraOptions: BaseCallApiExtraOptions;\n\tcurrentRouteSchemaKey: string;\n\textraOptions: CallApiExtraOptions;\n};\n\nexport const getResolvedSchema = (context: GetResolvedSchemaContext) => {\n\tconst { baseExtraOptions, currentRouteSchemaKey, extraOptions } = context;\n\n\tconst fallbackRouteSchema = baseExtraOptions.schema?.routes[fallBackRouteSchemaKey];\n\tconst currentRouteSchema = baseExtraOptions.schema?.routes[currentRouteSchemaKey];\n\n\tconst resolvedRouteSchema = {\n\t\t...fallbackRouteSchema,\n\t\t// == Current route schema takes precedence over fallback route schema\n\t\t...currentRouteSchema,\n\t} satisfies CallApiSchema as CallApiSchema | undefined;\n\n\tconst resolvedSchema =\n\t\tisFunction(extraOptions.schema) ?\n\t\t\textraOptions.schema({\n\t\t\t\tbaseSchemaRoutes: baseExtraOptions.schema?.routes ?? {},\n\t\t\t\tcurrentRouteSchema: resolvedRouteSchema ?? {},\n\t\t\t})\n\t\t:\t(extraOptions.schema ?? resolvedRouteSchema);\n\n\treturn { currentRouteSchema, resolvedSchema };\n};\n\nexport const getResolvedSchemaConfig = (\n\tcontext: Omit<GetResolvedSchemaContext, \"currentRouteSchemaKey\">\n) => {\n\tconst { baseExtraOptions, extraOptions } = context;\n\n\tconst resolvedSchemaConfig =\n\t\tisFunction(extraOptions.schemaConfig) ?\n\t\t\textraOptions.schemaConfig({ baseSchemaConfig: baseExtraOptions.schema?.config ?? {} })\n\t\t:\t(extraOptions.schemaConfig ?? baseExtraOptions.schema?.config);\n\n\treturn resolvedSchemaConfig;\n};\n\nexport const getCurrentRouteSchemaKeyAndMainInitURL = (\n\tcontext: Pick<GetResolvedSchemaContext, \"baseExtraOptions\" | \"extraOptions\"> & { initURL: string }\n) => {\n\tconst { baseExtraOptions, extraOptions, initURL } = context;\n\n\tconst schemaConfig = getResolvedSchemaConfig({ baseExtraOptions, extraOptions });\n\n\tlet currentRouteSchemaKey = initURL;\n\tlet mainInitURL = initURL;\n\n\tif (schemaConfig?.prefix && currentRouteSchemaKey.startsWith(schemaConfig.prefix)) {\n\t\tcurrentRouteSchemaKey = currentRouteSchemaKey.replace(schemaConfig.prefix, \"\");\n\n\t\tmainInitURL = mainInitURL.replace(schemaConfig.prefix, schemaConfig.baseURL ?? \"\");\n\t}\n\n\tif (schemaConfig?.baseURL && currentRouteSchemaKey.startsWith(schemaConfig.baseURL)) {\n\t\tcurrentRouteSchemaKey = currentRouteSchemaKey.replace(schemaConfig.baseURL, \"\");\n\t}\n\n\treturn { currentRouteSchemaKey, mainInitURL };\n};\n","import type { CallApiExtraOptions } from \"./types/common\";\nimport type { AnyString, UnmaskType } from \"./types/type-helpers\";\nimport { toQueryString } from \"./utils/external/body\";\nimport { isArray } from \"./utils/guards\";\nimport { type RouteKeyMethodsURLUnion, routeKeyMethods } from \"./validation\";\n\nconst slash = \"/\";\nconst colon = \":\";\nconst openBrace = \"{\";\nconst closeBrace = \"}\";\n\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 urlParts = newUrl.split(slash);\n\n\t\t// == Find all parameters in order (both :param and {param} patterns)\n\t\tconst matchedParamsArray = urlParts.filter(\n\t\t\t(part) => part.startsWith(colon) || (part.startsWith(openBrace) && part.endsWith(closeBrace))\n\t\t);\n\n\t\tfor (const [paramIndex, matchedParam] of matchedParamsArray.entries()) {\n\t\t\tconst stringParamValue = String(params[paramIndex]);\n\t\t\tnewUrl = newUrl.replace(matchedParam, stringParamValue);\n\t\t}\n\n\t\treturn newUrl;\n\t}\n\n\t// == Handle object params - replace both :param and {param} patterns\n\tfor (const [paramKey, paramValue] of Object.entries(params)) {\n\t\tconst colonPattern = `${colon}${paramKey}` as const;\n\t\tconst bracePattern = `${openBrace}${paramKey}${closeBrace}` as const;\n\t\tconst stringValue = String(paramValue);\n\n\t\tnewUrl = newUrl.replace(colonPattern, stringValue);\n\t\tnewUrl = newUrl.replace(bracePattern, stringValue);\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\n/**\n * @description Extracts the HTTP method from method-prefixed route patterns.\n *\n * Analyzes URLs that start with method modifiers (e.g., \"@get/\", \"@post/\") and extracts\n * the HTTP method for use in API requests. This enables method specification directly\n * in route definitions.\n *\n * @param initURL - The URL string to analyze for method modifiers\n * @returns The extracted HTTP method (lowercase) if found, otherwise undefined\n *\n * @example\n * ```typescript\n * extractMethodFromURL(\"@get/users\"); // Returns: \"get\"\n * extractMethodFromURL(\"@post/users\"); // Returns: \"post\"\n * ```\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 as (typeof routeKeyMethods)[number])) return;\n\n\treturn method;\n};\n\nconst normalizeURL = (initURL: string) => {\n\tconst methodFromURL = extractMethodFromURL(initURL);\n\n\tif (!methodFromURL) {\n\t\treturn initURL;\n\t}\n\n\tconst normalizedURL =\n\t\tinitURL.includes(\"http\") ?\n\t\t\tinitURL.replace(`@${methodFromURL}/`, \"\")\n\t\t:\tinitURL.replace(`@${methodFromURL}/`, \"/\");\n\n\treturn normalizedURL;\n};\n\ntype GetFullURLOptions = {\n\t/** Base URL to prepend to relative URLs */\n\tbaseURL: string | undefined;\n\t/** Initial URL pattern that may contain parameters and method modifiers */\n\tinitURL: string;\n\t/** Parameters to substitute into the URL path */\n\tparams: CallApiExtraOptions[\"params\"];\n\t/** Query parameters to append to the URL */\n\tquery: CallApiExtraOptions[\"query\"];\n};\n\nconst getFullURL = (initURL: string, baseURL: string | undefined) => {\n\tif (!baseURL || initURL.startsWith(\"http\")) {\n\t\treturn initURL;\n\t}\n\n\tconst shouldAddSlash = initURL.length > 0 && !initURL.startsWith(slash) && !baseURL.endsWith(slash);\n\n\treturn shouldAddSlash ? `${baseURL}${slash}${initURL}` : `${baseURL}${initURL}`;\n};\n\nexport const getFullAndNormalizedURL = (options: GetFullURLOptions) => {\n\tconst { baseURL, initURL, params, query } = options;\n\n\tconst normalizedInitURL = normalizeURL(initURL);\n\n\tconst initURLWithParams = mergeUrlWithParams(normalizedInitURL, params);\n\n\tconst initURLWithParamsAndQuery = mergeUrlWithQuery(initURLWithParams, query);\n\n\tconst fullURL = getFullURL(initURLWithParamsAndQuery, baseURL);\n\n\tif (!URL.canParse(fullURL)) {\n\t\tconst errorMessage =\n\t\t\t!baseURL ?\n\t\t\t\t`Invalid URL '${fullURL}'. Are you passing a relative url to CallApi but not setting the 'baseURL' option?`\n\t\t\t:\t`Invalid URL '${fullURL}'. Please validate that you are passing the correct url.`;\n\n\t\tconsole.error(errorMessage);\n\t}\n\n\treturn {\n\t\tfullURL,\n\t\tnormalizedInitURL,\n\t};\n};\n\nexport type AllowedQueryParamValues = UnmaskType<boolean | number | string>;\n\nexport type RecordStyleParams = UnmaskType<Record<string, AllowedQueryParamValues>>;\n\nexport type TupleStyleParams = UnmaskType<AllowedQueryParamValues[]>;\n\nexport type Params = UnmaskType<RecordStyleParams | TupleStyleParams>;\n\nexport type Query = UnmaskType<Record<string, AllowedQueryParamValues>>;\n\nexport type InitURLOrURLObject = AnyString | RouteKeyMethodsURLUnion | URL;\n\nexport interface URLOptions {\n\t/**\n\t * Base URL for all API requests. Will only be prepended to relative URLs.\n\t *\n\t * Absolute URLs (starting with http/https) will not be prepended by the baseURL.\n\t *\n\t * @example\n\t * ```ts\n\t * // Set base URL for all requests\n\t * baseURL: \"https://api.example.com/v1\"\n\t *\n\t * // Then use relative URLs in requests\n\t * callApi(\"/users\") // → https://api.example.com/v1/users\n\t * callApi(\"/posts/123\") // → https://api.example.com/v1/posts/123\n\t *\n\t * // Environment-specific base URLs\n\t * baseURL: process.env.NODE_ENV === \"production\"\n\t * ? \"https://api.example.com\"\n\t * : \"http://localhost:3000/api\"\n\t * ```\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Resolved request URL after processing baseURL, parameters, and query strings (readonly)\n\t *\n\t * This is the final URL that will be used for the HTTP request, computed from\n\t * baseURL, initURL, params, and query parameters.\n\t *\n\t */\n\treadonly fullURL?: string;\n\n\t/**\n\t * The original URL string passed to the callApi instance (readonly)\n\t *\n\t * This preserves the original URL as provided, including any method modifiers like \"@get/\" or \"@post/\".\n\t *\n\t */\n\treadonly initURL?: string;\n\n\t/**\n\t * The URL string after normalization, with method modifiers removed(readonly)\n\t *\n\t * Method modifiers like \"@get/\", \"@post/\" are stripped to create a clean URL\n\t * for parameter substitution and final URL construction.\n\t *\n\t */\n\treadonly initURLNormalized?: string;\n\n\t/**\n\t * Parameters to be substituted into URL path segments.\n\t *\n\t * Supports both object-style (named parameters) and array-style (positional parameters)\n\t * for flexible URL parameter substitution.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Object-style parameters (recommended)\n\t * const namedParams: URLOptions = {\n\t * initURL: \"/users/:userId/posts/:postId\",\n\t * params: { userId: \"123\", postId: \"456\" }\n\t * };\n\t * // Results in: /users/123/posts/456\n\t *\n\t * // Array-style parameters (positional)\n\t * const positionalParams: URLOptions = {\n\t * initURL: \"/users/:userId/posts/:postId\",\n\t * params: [\"123\", \"456\"] // Maps in order: userId=123, postId=456\n\t * };\n\t * // Results in: /users/123/posts/456\n\t *\n\t * // Single parameter\n\t * const singleParam: URLOptions = {\n\t * initURL: \"/users/:id\",\n\t * params: { id: \"user-123\" }\n\t * };\n\t * // Results in: /users/user-123\n\t * ```\n\t */\n\tparams?: Params;\n\n\t/**\n\t * Query parameters to append to the URL as search parameters.\n\t *\n\t * These will be serialized into the URL query string using standard\n\t * URL encoding practices.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Basic query parameters\n\t * const queryOptions: URLOptions = {\n\t * initURL: \"/users\",\n\t * query: {\n\t * page: 1,\n\t * limit: 10,\n\t * search: \"john doe\",\n\t * active: true\n\t * }\n\t * };\n\t * // Results in: /users?page=1&limit=10&search=john%20doe&active=true\n\t *\n\t * // Filtering and sorting\n\t * const filterOptions: URLOptions = {\n\t * initURL: \"/products\",\n\t * query: {\n\t * category: \"electronics\",\n\t * minPrice: 100,\n\t * maxPrice: 500,\n\t * sortBy: \"price\",\n\t * order: \"asc\"\n\t * }\n\t * };\n\t * // Results in: /products?category=electronics&minPrice=100&maxPrice=500&sortBy=price&order=asc\n\t * ```\n\t */\n\tquery?: Query;\n}\n","export const createCombinedSignalPolyfill = (signals: AbortSignal[]) => {\n\tconst controller = new AbortController();\n\n\tconst handleAbort = (actualSignal: AbortSignal) => {\n\t\tif (controller.signal.aborted) return;\n\n\t\tcontroller.abort(actualSignal.reason);\n\t};\n\n\tfor (const actualSignal of signals) {\n\t\tif (actualSignal.aborted) {\n\t\t\thandleAbort(actualSignal);\n\t\t\tbreak;\n\t\t}\n\n\t\tactualSignal.addEventListener(\"abort\", () => handleAbort(actualSignal), {\n\t\t\tsignal: controller.signal,\n\t\t});\n\t}\n\n\treturn controller.signal;\n};\n","export const createTimeoutSignalPolyfill = (milliseconds: number) => {\n\tconst controller = new AbortController();\n\n\tconst reason = new DOMException(\"Request timed out\", \"TimeoutError\");\n\n\tconst timeout = setTimeout(() => controller.abort(reason), milliseconds);\n\n\tcontroller.signal.addEventListener(\"abort\", () => clearTimeout(timeout));\n\n\treturn controller.signal;\n};\n","import { getAuthHeader } from \"../auth\";\nimport { fetchSpecificKeys } from \"../constants/common\";\nimport { extraOptionDefaults, requestOptionDefaults } from \"../constants/defaults\";\nimport type { RequestContext } from \"../hooks\";\nimport type { Middlewares } from \"../middlewares\";\nimport type { BaseCallApiExtraOptions, CallApiExtraOptions, CallApiRequestOptions } from \"../types/common\";\nimport type { InferHeadersOption } from \"../types/conditional-types\";\nimport type { DistributiveOmit } from \"../types/type-helpers\";\nimport { extractMethodFromURL } from \"../url\";\nimport type { CallApiSchema } from \"../validation\";\nimport { toQueryString } from \"./external\";\nimport {\n\tisArray,\n\tisFunction,\n\tisPlainObject,\n\tisQueryString,\n\tisSerializableObject,\n\tisValidJsonString,\n} from \"./guards\";\nimport { createCombinedSignalPolyfill, createTimeoutSignalPolyfill } from \"./polyfills\";\n\nexport const omitKeys = <\n\tTObject extends Record<string, unknown>,\n\tconst TOmitArray extends Array<keyof TObject> | ReadonlyArray<keyof TObject>,\n>(\n\tinitialObject: TObject,\n\tkeysToOmit: TOmitArray\n) => {\n\tconst updatedObject = {} as Record<string, unknown>;\n\n\tconst keysToOmitSet = new Set(keysToOmit);\n\n\tfor (const [key, value] of Object.entries(initialObject)) {\n\t\tif (!keysToOmitSet.has(key)) {\n\t\t\tupdatedObject[key] = value;\n\t\t}\n\t}\n\n\treturn updatedObject as DistributiveOmit<TObject, TOmitArray[number]>;\n};\n\nexport const pickKeys = <\n\tTObject extends Record<string, unknown>,\n\tconst TPickArray extends Array<keyof TObject> | ReadonlyArray<keyof TObject>,\n>(\n\tinitialObject: TObject,\n\tkeysToPick: TPickArray\n) => {\n\tconst updatedObject = {} as Record<string, unknown>;\n\n\tconst keysToPickSet = new Set(keysToPick);\n\n\tfor (const [key, value] of Object.entries(initialObject)) {\n\t\tif (keysToPickSet.has(key)) {\n\t\t\tupdatedObject[key] = value;\n\t\t}\n\t}\n\n\treturn updatedObject as Pick<TObject, TPickArray[number]>;\n};\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport const splitBaseConfig = (baseConfig: Record<string, any>) =>\n\t[\n\t\tpickKeys(baseConfig, fetchSpecificKeys) as CallApiRequestOptions,\n\t\tomitKeys(baseConfig, fetchSpecificKeys) as BaseCallApiExtraOptions,\n\t] as const;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport const splitConfig = (config: Record<string, any>) =>\n\t[\n\t\tpickKeys(config, fetchSpecificKeys) as CallApiRequestOptions,\n\t\tomitKeys(config, fetchSpecificKeys) as CallApiExtraOptions,\n\t] as const;\n\nexport const objectifyHeaders = (headers: CallApiRequestOptions[\"headers\"]) => {\n\tif (!headers) {\n\t\treturn {};\n\t}\n\n\tif (isPlainObject(headers)) {\n\t\treturn headers as Record<string, string>;\n\t}\n\n\treturn Object.fromEntries(headers);\n};\n\nexport type GetResolvedHeadersOptions = {\n\tbaseHeaders: CallApiRequestOptions[\"headers\"];\n\theaders: InferHeadersOption<CallApiSchema>[\"headers\"];\n};\n\nexport const getResolvedHeaders = (options: GetResolvedHeadersOptions) => {\n\tconst { baseHeaders, headers } = options;\n\n\tconst resolvedHeaders =\n\t\tisFunction(headers) ?\n\t\t\theaders({ baseHeaders: objectifyHeaders(baseHeaders) })\n\t\t:\t(headers ?? baseHeaders);\n\n\treturn objectifyHeaders(resolvedHeaders);\n};\n\nconst detectContentTypeHeader = (body: CallApiRequestOptions[\"body\"]) => {\n\tif (isQueryString(body)) {\n\t\treturn { \"Content-Type\": \"application/x-www-form-urlencoded\" };\n\t}\n\n\tif (isSerializableObject(body) || isValidJsonString(body)) {\n\t\treturn { Accept: \"application/json\", \"Content-Type\": \"application/json\" };\n\t}\n\n\treturn null;\n};\n\nexport type GetHeadersOptions = {\n\tauth: CallApiExtraOptions[\"auth\"];\n\tbody: CallApiRequestOptions[\"body\"];\n\tresolvedHeaders: CallApiRequestOptions[\"headers\"];\n};\n\nexport const getHeaders = async (options: GetHeadersOptions) => {\n\tconst { auth, body, resolvedHeaders } = options;\n\n\tconst authHeaderObject = await getAuthHeader(auth);\n\n\tconst resolvedHeadersObject = objectifyHeaders(resolvedHeaders);\n\n\tconst hasExistingContentType =\n\t\tObject.hasOwn(resolvedHeadersObject, \"Content-Type\")\n\t\t|| Object.hasOwn(resolvedHeadersObject, \"content-type\");\n\n\tif (!hasExistingContentType) {\n\t\tconst contentTypeHeader = detectContentTypeHeader(body);\n\t\tcontentTypeHeader && Object.assign(resolvedHeadersObject, contentTypeHeader);\n\t}\n\n\tconst headersObject: Record<string, string> = {\n\t\t...authHeaderObject,\n\t\t...resolvedHeadersObject,\n\t};\n\n\treturn headersObject;\n};\n\nexport type GetMethodContext = {\n\t/** The URL string that may contain method modifiers like \"@get/\" or \"@post/\" */\n\tinitURL: string | undefined;\n\t/** Explicitly specified HTTP method */\n\tmethod: CallApiRequestOptions[\"method\"];\n};\n\nexport const getMethod = (ctx: GetMethodContext) => {\n\tconst { initURL, method } = ctx;\n\n\treturn (\n\t\tmethod?.toUpperCase() ?? extractMethodFromURL(initURL)?.toUpperCase() ?? requestOptionDefaults.method\n\t);\n};\n\nexport type GetBodyOptions = Pick<GetHeadersOptions, \"body\" | \"resolvedHeaders\"> & {\n\tbodySerializer: CallApiExtraOptions[\"bodySerializer\"];\n};\n\nexport const getBody = (options: GetBodyOptions) => {\n\tconst { body, bodySerializer, resolvedHeaders } = options;\n\n\tconst headers = new Headers(resolvedHeaders as Record<string, string>);\n\n\tconst existingContentType = headers.get(\"content-type\");\n\n\tif (!existingContentType && isSerializableObject(body)) {\n\t\tconst selectedBodySerializer = bodySerializer ?? extraOptionDefaults.bodySerializer;\n\n\t\treturn selectedBodySerializer(body);\n\t}\n\n\tif (existingContentType === \"application/x-www-form-urlencoded\" && isSerializableObject(body)) {\n\t\treturn toQueryString(body as Record<string, string>);\n\t}\n\n\treturn body;\n};\n\nexport const getInitFetchImpl = (customFetchImpl: CallApiExtraOptions[\"customFetchImpl\"]) => {\n\tif (customFetchImpl) {\n\t\treturn customFetchImpl;\n\t}\n\n\tif (typeof globalThis !== \"undefined\" && isFunction(globalThis.fetch)) {\n\t\treturn globalThis.fetch;\n\t}\n\n\tthrow new Error(\"No fetch implementation found\");\n};\n\nexport const getFetchImpl = (context: {\n\tcustomFetchImpl: CallApiExtraOptions[\"customFetchImpl\"];\n\tfetchMiddleware: Middlewares[\"fetchMiddleware\"];\n\trequestContext: RequestContext;\n}) => {\n\tconst { customFetchImpl, fetchMiddleware, requestContext } = context;\n\n\tconst initFetchImpl = getInitFetchImpl(customFetchImpl);\n\n\tconst resolvedFetchImpl =\n\t\tfetchMiddleware ? fetchMiddleware({ ...requestContext, fetchImpl: initFetchImpl }) : initFetchImpl;\n\n\treturn resolvedFetchImpl;\n};\n\nexport const waitFor = (delay: number) => {\n\tif (delay === 0) return;\n\n\tconst promise = new Promise((resolve) => setTimeout(resolve, delay));\n\n\treturn promise;\n};\n\nexport const createCombinedSignal = (...signals: Array<AbortSignal | null | undefined>) => {\n\tconst cleanedSignals = signals.filter((signal) => signal != null);\n\n\tif (!(\"any\" in AbortSignal)) {\n\t\treturn createCombinedSignalPolyfill(cleanedSignals);\n\t}\n\n\tconst combinedSignal = AbortSignal.any(cleanedSignals);\n\n\treturn combinedSignal;\n};\n\nexport const createTimeoutSignal = (milliseconds: number | null | undefined) => {\n\tif (milliseconds == null) {\n\t\treturn null;\n\t}\n\n\tif (!(\"timeout\" in AbortSignal)) {\n\t\treturn createTimeoutSignalPolyfill(milliseconds);\n\t}\n\n\treturn AbortSignal.timeout(milliseconds);\n};\n\nexport const deterministicHashFn = (value: unknown): string => {\n\treturn JSON.stringify(value, (_, val: unknown) => {\n\t\tif (!isPlainObject(val)) {\n\t\t\treturn val;\n\t\t}\n\n\t\tconst sortedKeys = Object.keys(val).toSorted();\n\n\t\tconst result: Record<string, unknown> = {};\n\n\t\tfor (const key of sortedKeys) {\n\t\t\tresult[key] = val[key];\n\t\t}\n\n\t\treturn result;\n\t});\n};\n\nexport const toArray = (value: unknown) => (isArray(value) ? value : [value]);\n","import { extraOptionDefaults } from \"./constants/defaults\";\nimport type { CallApiExtraOptions } from \"./types/common\";\nimport type { ThrowOnErrorUnion } from \"./types/conditional-types\";\nimport type { DefaultDataType, DefaultThrowOnError } from \"./types/default-types\";\nimport type {\n\tAnyString,\n\tAwaitable,\n\tDistributiveOmit,\n\tNoInferUnMasked,\n\tPrettify,\n\tUnmaskType,\n} from \"./types/type-helpers\";\nimport { omitKeys } from \"./utils/common\";\nimport type { HTTPError, ValidationError } from \"./utils/external/error\";\nimport { isHTTPErrorInstance, isValidationErrorInstance } from \"./utils/external/guards\";\n\nexport type ResponseType = \"blob\" | \"json\" | \"text\";\n\ntype Parser<TData> = (responseString: string) => Awaitable<TData>;\n\nexport const getResponseType = <TResponse>(response: Response, parser: Parser<TResponse>) => ({\n\tarrayBuffer: () => response.arrayBuffer(),\n\tblob: () => response.blob(),\n\tformData: () => response.formData(),\n\tjson: async (): Promise<TResponse> => {\n\t\tconst text = await response.text();\n\t\treturn parser(text);\n\t},\n\tstream: () => response.body,\n\ttext: () => response.text(),\n});\n\ntype InitResponseTypeMap<TResponse = unknown> = ReturnType<typeof getResponseType<TResponse>>;\n\ntype ResponseTypeUnion = keyof InitResponseTypeMap;\n\ntype ResponseTypePlaceholder = null;\n\nexport type ResponseTypeType = ResponseTypePlaceholder | ResponseTypeUnion;\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 ResponseTypeType,\n\tTComputedResponseTypeMap extends ResponseTypeMap<TResponse> = ResponseTypeMap<TResponse>,\n> =\n\tnull extends TResponseType ? TComputedResponseTypeMap[\"json\"]\n\t: TResponseType extends NonNullable<ResponseTypeType> ? TComputedResponseTypeMap[TResponseType]\n\t: never;\n\nconst textTypes = new Set([\"image/svg\", \"application/xml\", \"application/xhtml\", \"application/html\"]);\nconst JSON_REGEX = /^application\\/(?:[\\w!#$%&*.^`~-]*\\+)?json(;.+)?$/i;\n\nconst detectResponseType = (response: Response): Extract<ResponseTypeType, \"blob\" | \"json\" | \"text\"> => {\n\tconst initContentType = response.headers.get(\"content-type\");\n\n\tif (!initContentType) {\n\t\treturn extraOptionDefaults.responseType;\n\t}\n\n\tconst contentType = initContentType.split(\";\")[0] ?? \"\";\n\n\tif (JSON_REGEX.test(contentType)) {\n\t\treturn \"json\";\n\t}\n\n\tif (textTypes.has(contentType) || contentType.startsWith(\"text/\")) {\n\t\treturn \"text\";\n\t}\n\n\treturn \"blob\";\n};\n\nexport const resolveResponseData = <TResponse>(\n\tresponse: Response,\n\tresponseType: ResponseTypeType | undefined,\n\tparser: Parser<TResponse> | undefined\n) => {\n\tconst selectedParser = parser ?? extraOptionDefaults.responseParser;\n\tconst selectedResponseType = responseType ?? detectResponseType(response);\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: NoInferUnMasked<TData>;\n\terror: null;\n\tresponse: Response;\n};\nexport type PossibleJavaScriptError = UnmaskType<{\n\terrorData: false;\n\tmessage: string;\n\tname: \"AbortError\" | \"Error\" | \"SyntaxError\" | \"TimeoutError\" | \"TypeError\" | AnyString;\n\toriginalError: DOMException | Error | SyntaxError | TypeError;\n}>;\n\nexport type PossibleHTTPError<TErrorData> = UnmaskType<{\n\terrorData: NoInferUnMasked<TErrorData>;\n\tmessage: string;\n\tname: \"HTTPError\";\n\toriginalError: HTTPError;\n}>;\n\nexport type PossibleValidationError = UnmaskType<{\n\terrorData: ValidationError[\"errorData\"];\n\tissueCause: ValidationError[\"issueCause\"];\n\tmessage: string;\n\tname: \"ValidationError\";\n\toriginalError: ValidationError;\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 CallApiResultSuccessOrErrorVariant<TData, TError> =\n\t| CallApiResultErrorVariant<TError>\n\t| CallApiResultSuccessVariant<TData>;\n\nexport type ResultModeMap<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError,\n\tTComputedResultWithoutException extends CallApiResultSuccessOrErrorVariant<TData, TErrorData> =\n\t\tCallApiResultSuccessOrErrorVariant<TData, TErrorData>,\n\tTComputedResultWithException extends CallApiResultSuccessVariant<TData> =\n\t\tCallApiResultSuccessVariant<TData>,\n\tTComputedResult extends TThrowOnError extends true ? TComputedResultWithException\n\t:\tTComputedResultWithoutException = TThrowOnError extends true ? TComputedResultWithException\n\t:\tTComputedResultWithoutException,\n> = UnmaskType<{\n\tall: TComputedResult;\n\tonlyData: TComputedResult[\"data\"];\n\tonlyResponse: TComputedResult[\"response\"];\n\twithoutResponse: Prettify<DistributiveOmit<TComputedResult, \"response\">>;\n}>;\n\ntype ResultModePlaceholder = null;\n\ntype ResultModeUnion = keyof ResultModeMap;\n\n// FIXME - Revisit this idea later. Take inspirations from how zod does it with pick({}) and omit({d})\n// type ResultModeObject = { data?: boolean; error?: boolean; response?: boolean };\n\nexport type ResultModeType = ResultModePlaceholder | ResultModeUnion;\n\nexport type InferCallApiResult<\n\tTData,\n\tTErrorData,\n\tTResultMode extends ResultModeType,\n\tTThrowOnError extends ThrowOnErrorUnion,\n\tTComputedResultModeMapWithException extends ResultModeMap<TData, TErrorData, true> = ResultModeMap<\n\t\tTData,\n\t\tTErrorData,\n\t\ttrue\n\t>,\n\tTComputedResultModeMapWithoutException extends ResultModeMap<TData, TErrorData, TThrowOnError> =\n\t\tResultModeMap<TData, TErrorData, TThrowOnError>,\n> =\n\tTErrorData extends false ? TComputedResultModeMapWithException[\"onlyData\"]\n\t: TErrorData extends false | undefined ? TComputedResultModeMapWithException[\"onlyData\"]\n\t: ResultModePlaceholder extends TResultMode ? TComputedResultModeMapWithoutException[\"all\"]\n\t: TResultMode extends ResultModeUnion ? TComputedResultModeMapWithoutException[TResultMode]\n\t: never;\n\ntype SuccessInfo = Pick<CallApiExtraOptions, \"resultMode\"> & {\n\tresponse: Response;\n};\n\ntype LazyResultModeMap = {\n\t[key in keyof ResultModeMap]: () => ResultModeMap[key];\n};\n\nconst getResultModeMap = (details: ResultModeMap[\"all\"]): LazyResultModeMap => {\n\treturn {\n\t\tall: () => details,\n\t\tonlyData: () => details.data,\n\t\tonlyResponse: () => details.response,\n\t\twithoutResponse: () => omitKeys(details, [\"response\"]),\n\t};\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 = Omit<SuccessInfo, \"response\">\n\t& Pick<CallApiExtraOptions, \"cloneResponse\"> & {\n\t\tmessage?: string;\n\t};\n\ntype ErrorResult = {\n\terrorDetails: CallApiResultErrorVariant<unknown>;\n\terrorResult: CallApiResultErrorVariant<unknown> | null;\n};\n\nexport const resolveErrorResult = (error: unknown, info: ErrorInfo): ErrorResult => {\n\tconst { cloneResponse, message: customErrorMessage, resultMode } = info;\n\n\tlet errorDetails = {\n\t\tdata: null,\n\t\terror: {\n\t\t\terrorData: false,\n\t\t\tmessage: customErrorMessage ?? (error as Error).message,\n\t\t\tname: (error as Error).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\terrorDetails = {\n\t\t\tdata: null,\n\t\t\terror: {\n\t\t\t\terrorData,\n\t\t\t\tissueCause: error.issueCause,\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 { errorData, message, name, response } = error;\n\n\t\terrorDetails = {\n\t\t\tdata: null,\n\t\t\terror: { errorData, message, name, originalError: error },\n\t\t\tresponse: cloneResponse ? response.clone() : response,\n\t\t};\n\t}\n\n\tconst resultModeMap = getResultModeMap(errorDetails);\n\n\tconst errorResult = resultModeMap[resultMode ?? \"all\"]() as never;\n\n\treturn { errorDetails, errorResult };\n};\n\nexport const getCustomizedErrorResult = (\n\terrorResult: ErrorResult[\"errorResult\"],\n\tcustomErrorInfo: { message: string | undefined }\n): ErrorResult[\"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[\"errorResult\"]>[\"error\"] as never,\n\t};\n};\n","import {\n\ttype CallApiResultErrorVariant,\n\ttype CallApiResultSuccessVariant,\n\ttype ErrorInfo,\n\ttype PossibleHTTPError,\n\ttype PossibleJavaScriptError,\n\ttype PossibleJavaScriptOrValidationError,\n\ttype PossibleValidationError,\n\tresolveErrorResult,\n} from \"./result\";\nimport type { StreamProgressEvent } from \"./stream\";\nimport type {\n\tBaseCallApiConfig,\n\tCallApiConfig,\n\tCallApiContext,\n\tCallApiExtraOptionsForHooks,\n\tCallApiRequestOptionsForHooks,\n} from \"./types/common\";\nimport type { DefaultCallApiContext } from \"./types/default-types\";\nimport type { AnyFunction, Awaitable, Prettify } from \"./types/type-helpers\";\n\nexport interface Hooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> {\n\t/**\n\t * Hook called when any error occurs within the request/response lifecycle.\n\t *\n\t * This is a unified error handler that catches both request errors (network failures,\n\t * timeouts, etc.) and response errors (HTTP error status codes). It's essentially\n\t * a combination of `onRequestError` and `onResponseError` hooks.\n\t *\n\t * @param context - Error context containing error details, request info, and response (if available)\n\t * @returns Promise or void - Hook can be async or sync\n\t */\n\tonError?: (context: ErrorContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called before the HTTP request is sent and before any internal processing of the request object begins.\n\t *\n\t * This is the ideal place to modify request headers, add authentication,\n\t * implement request logging, or perform any setup before the network call.\n\t *\n\t * @param context - Request context with mutable request object and configuration\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonRequest?: (context: RequestContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called when an error occurs during the fetch request itself.\n\t *\n\t * This handles network-level errors like connection failures, timeouts,\n\t * DNS resolution errors, or other issues that prevent getting an HTTP response.\n\t * Note that HTTP error status codes (4xx, 5xx) are handled by `onResponseError`.\n\t *\n\t * @param context - Request error context with error details and null response\n\t * @returns Promise or void - Hook can be async or sync\n\t */\n\tonRequestError?: (context: RequestErrorContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called just before the HTTP request is sent and after the request has been processed.\n\t *\n\t * @param context - Request context with mutable request object and configuration\n\t */\n\tonRequestReady?: (context: RequestContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called during upload stream progress tracking.\n\t *\n\t * This hook is triggered when uploading data (like file uploads) and provides\n\t * progress information about the upload. Useful for implementing progress bars\n\t * or upload status indicators.\n\t *\n\t * @param context - Request stream context with progress event and request instance\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonRequestStream?: (context: RequestStreamContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called when any HTTP response is received from the API.\n\t *\n\t * This hook is triggered for both successful (2xx) and error (4xx, 5xx) responses.\n\t * It's useful for response logging, metrics collection, or any processing that\n\t * should happen regardless of response status.\n\t *\n\t * @param context - Response context with either success data or error information\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonResponse?: (context: ResponseContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called when an HTTP error response (4xx, 5xx) is received from the API.\n\t *\n\t * This handles server-side errors where an HTTP response was successfully received\n\t * but indicates an error condition. Different from `onRequestError` which handles\n\t * network-level failures.\n\t *\n\t * @param context - Response error context with HTTP error details and response\n\t * @returns Promise or void - Hook can be async or sync\n\t */\n\tonResponseError?: (context: ResponseErrorContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called during download stream progress tracking.\n\t *\n\t * This hook is triggered when downloading data (like file downloads) and provides\n\t * progress information about the download. Useful for implementing progress bars\n\t * or download status indicators.\n\t *\n\t * @param context - Response stream context with progress event and response\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonResponseStream?: (context: ResponseStreamContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called when a request is being retried.\n\t *\n\t * This hook is triggered before each retry attempt, providing information about\n\t * the previous failure and the current retry attempt number. Useful for implementing\n\t * custom retry logic, exponential backoff, or retry logging.\n\t *\n\t * @param context - Retry context with error details and retry attempt count\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonRetry?: (response: RetryContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called when a successful response (2xx status) is received from the API.\n\t *\n\t * This hook is triggered only for successful responses and provides access to\n\t * the parsed response data. Ideal for success logging, caching, or post-processing\n\t * of successful API responses.\n\t *\n\t * @param context - Success context with parsed response data and response object\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonSuccess?: (context: SuccessContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called when a validation error occurs.\n\t *\n\t * This hook is triggered when request or response data fails validation against\n\t * a defined schema. It provides access to the validation error details and can\n\t * be used for custom error handling, logging, or fallback behavior.\n\t *\n\t * @param context - Validation error context with error details and response (if available)\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonValidationError?: (context: ValidationErrorContext<TCallApiContext>) => Awaitable<unknown>;\n}\n\nexport type HooksOrHooksArray<TCallApiContext extends NoInfer<CallApiContext> = DefaultCallApiContext> = {\n\t[Key in keyof Hooks<TCallApiContext>]:\n\t\t| Hooks<TCallApiContext>[Key]\n\t\t// eslint-disable-next-line perfectionist/sort-union-types -- I need arrays to be last\n\t\t| Array<Hooks<TCallApiContext>[Key]>;\n};\n\nexport interface HookConfigOptions {\n\t/**\n\t * Controls the execution mode of all composed hooks (main + plugin hooks).\n\t *\n\t * - **\"parallel\"**: All hooks execute simultaneously via Promise.all() for better performance\n\t * - **\"sequential\"**: All hooks execute one by one in registration order via await in a loop\n\t *\n\t * This affects how ALL hooks execute together, regardless of their source (main or plugin).\n\t *\n\t * @default \"parallel\"\n\t */\n\thooksExecutionMode?: \"parallel\" | \"sequential\";\n}\n\nexport type RequestContext<\n\tTCallApiContext extends Pick<CallApiContext, \"InferredExtraOptions\" | \"Meta\"> = DefaultCallApiContext,\n> = {\n\t/**\n\t * Base configuration object passed to createFetchClient.\n\t *\n\t * Contains the foundational configuration that applies to all requests\n\t * made by this client instance, such as baseURL, default headers, and\n\t * global options.\n\t */\n\tbaseConfig: Exclude<BaseCallApiConfig, AnyFunction>;\n\n\t/**\n\t * Instance-specific configuration object passed to the callApi instance.\n\t *\n\t * Contains configuration specific to this particular API call, which\n\t * can override or extend the base configuration.\n\t */\n\tconfig: CallApiConfig;\n\n\t/**\n\t * Merged options combining base config, instance config, and default options.\n\t *\n\t * This is the final resolved configuration that will be used for the request,\n\t * with proper precedence applied (instance > base > defaults).\n\t */\n\toptions: CallApiExtraOptionsForHooks<TCallApiContext>;\n\n\t/**\n\t * Merged request object ready to be sent.\n\t *\n\t * Contains the final request configuration including URL, method, headers,\n\t * body, and other fetch options. This object can be modified in onRequest\n\t * hooks to customize the outgoing request.\n\t */\n\trequest: CallApiRequestOptionsForHooks;\n};\n\nexport type ValidationErrorContext<\n\tTCallApiContext extends Pick<CallApiContext, \"InferredExtraOptions\" | \"Meta\"> = DefaultCallApiContext,\n> = RequestContext<TCallApiContext> & {\n\terror: PossibleValidationError;\n\tresponse: Response | null;\n};\n\nexport type SuccessContext<\n\tTCallApiContext extends Pick<CallApiContext, \"Data\" | \"InferredExtraOptions\" | \"Meta\"> =\n\t\tDefaultCallApiContext,\n> = RequestContext<TCallApiContext> & {\n\tdata: TCallApiContext[\"Data\"];\n\tresponse: Response;\n};\n\nexport type ResponseContext<\n\tTCallApiContext extends Pick<CallApiContext, \"Data\" | \"ErrorData\" | \"InferredExtraOptions\" | \"Meta\"> =\n\t\tDefaultCallApiContext,\n> = RequestContext<TCallApiContext>\n\t& (\n\t\t| Prettify<CallApiResultSuccessVariant<TCallApiContext[\"Data\"]>>\n\t\t| Prettify<\n\t\t\t\tExtract<\n\t\t\t\t\tCallApiResultErrorVariant<TCallApiContext[\"ErrorData\"]>,\n\t\t\t\t\t{ error: PossibleHTTPError<TCallApiContext[\"ErrorData\"]> }\n\t\t\t\t>\n\t\t >\n\t);\n\nexport type RequestErrorContext<\n\tTCallApiContext extends Pick<CallApiContext, \"InferredExtraOptions\" | \"Meta\"> = DefaultCallApiContext,\n> = RequestContext<TCallApiContext> & {\n\terror: PossibleJavaScriptError;\n\tresponse: null;\n};\n\nexport type ErrorContext<\n\tTCallApiContext extends Pick<CallApiContext, \"ErrorData\" | \"InferredExtraOptions\" | \"Meta\"> =\n\t\tDefaultCallApiContext,\n> = RequestContext<TCallApiContext>\n\t& (\n\t\t| {\n\t\t\t\terror: PossibleHTTPError<TCallApiContext[\"ErrorData\"]>;\n\t\t\t\tresponse: Response;\n\t\t }\n\t\t| {\n\t\t\t\terror: PossibleJavaScriptOrValidationError;\n\t\t\t\tresponse: Response | null;\n\t\t }\n\t);\n\nexport type ResponseErrorContext<\n\tTCallApiContext extends Pick<CallApiContext, \"ErrorData\" | \"InferredExtraOptions\" | \"Meta\"> =\n\t\tDefaultCallApiContext,\n> = Extract<ErrorContext<TCallApiContext>, { error: PossibleHTTPError<TCallApiContext[\"ErrorData\"]> }>\n\t& RequestContext<TCallApiContext>;\n\nexport type RetryContext<\n\tTCallApiContext extends Pick<CallApiContext, \"ErrorData\" | \"InferredExtraOptions\" | \"Meta\"> =\n\t\tDefaultCallApiContext,\n> = ErrorContext<TCallApiContext> & {\n\tretryAttemptCount: number;\n};\n\nexport type RequestStreamContext<\n\tTCallApiContext extends Pick<CallApiContext, \"InferredExtraOptions\" | \"Meta\"> = DefaultCallApiContext,\n> = RequestContext<TCallApiContext> & {\n\tevent: StreamProgressEvent;\n\trequestInstance: Request;\n};\n\nexport type ResponseStreamContext<\n\tTCallApiContext extends Pick<CallApiContext, \"InferredExtraOptions\" | \"Meta\"> = DefaultCallApiContext,\n> = RequestContext<TCallApiContext> & {\n\tevent: StreamProgressEvent;\n\tresponse: Response;\n};\n\ntype HookRegistries = Required<{\n\t[Key in keyof Hooks]: Set<Hooks[Key]>;\n}>;\n\nexport const getHookRegistriesAndKeys = () => {\n\tconst hookRegistries: HookRegistries = {\n\t\tonError: new Set(),\n\t\tonRequest: new Set(),\n\t\tonRequestError: new Set(),\n\t\tonRequestReady: new Set(),\n\t\tonRequestStream: new Set(),\n\t\tonResponse: new Set(),\n\t\tonResponseError: new Set(),\n\t\tonResponseStream: new Set(),\n\t\tonRetry: new Set(),\n\t\tonSuccess: new Set(),\n\t\tonValidationError: new Set(),\n\t};\n\n\tconst hookRegistryKeys = Object.keys(hookRegistries) as Array<keyof Hooks>;\n\n\treturn { hookRegistries, hookRegistryKeys };\n};\n\nexport const composeHooksFromArray = (\n\thooksArray: Array<Hooks[keyof Hooks] | undefined>,\n\thooksExecutionMode: CallApiExtraOptionsForHooks[\"hooksExecutionMode\"]\n) => {\n\tconst composedHook = async (ctx: unknown) => {\n\t\tswitch (hooksExecutionMode) {\n\t\t\tcase \"parallel\": {\n\t\t\t\tawait Promise.all(hooksArray.map((uniqueHook) => uniqueHook?.(ctx as never)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"sequential\": {\n\t\t\t\tfor (const hook of hooksArray) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop -- This is necessary in this case\n\t\t\t\t\tawait hook?.(ctx as never);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\thooksExecutionMode satisfies undefined;\n\t\t\t}\n\t\t}\n\t};\n\n\treturn composedHook;\n};\n\nexport const executeHooks = 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\tif (shouldThrowOnError) {\n\t\t\tthrow hookError;\n\t\t}\n\n\t\tconst { errorResult } = resolveErrorResult(hookError, errorInfo);\n\n\t\treturn errorResult;\n\t}\n};\n","import {\n\texecuteHooks,\n\ttype RequestContext,\n\ttype RequestStreamContext,\n\ttype ResponseStreamContext,\n} from \"./hooks\";\nimport { isObject, isReadableStream } 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\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;\n\nexport const toStreamableRequest = async (\n\tcontext: ToStreamableRequestContext\n): Promise<Request | RequestInit> => {\n\tconst { baseConfig, config, options, request } = context;\n\n\tif (!options.onRequestStream || !isReadableStream(request.body)) {\n\t\treturn request as RequestInit;\n\t}\n\n\tconst requestInstance = new Request(\n\t\toptions.fullURL as NonNullable<typeof options.fullURL>,\n\t\t{ ...request, duplex: \"half\" } as RequestInit\n\t);\n\n\tconst contentLength = requestInstance.headers.get(\"content-length\");\n\n\tlet totalBytes = Number(contentLength ?? 0);\n\n\tconst shouldForcefullyCalcStreamSize =\n\t\tisObject(options.forcefullyCalculateStreamSize) ?\n\t\t\toptions.forcefullyCalculateStreamSize.request\n\t\t:\toptions.forcefullyCalculateStreamSize;\n\n\t// == If no content length is present, we read the total bytes from the body\n\tif (!contentLength && shouldForcefullyCalcStreamSize) {\n\t\ttotalBytes = await calculateTotalBytesFromBody(requestInstance.clone().body, totalBytes);\n\t}\n\n\tlet transferredBytes = 0;\n\n\tconst stream = new ReadableStream({\n\t\tstart: async (controller) => {\n\t\t\tconst body = requestInstance.body;\n\n\t\t\tif (!body) return;\n\n\t\t\tconst requestStreamContext = {\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\tevent: createProgressEvent({ chunk: new Uint8Array(), totalBytes, transferredBytes }),\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t\trequestInstance,\n\t\t\t} satisfies RequestStreamContext;\n\n\t\t\tawait executeHooks(options.onRequestStream?.(requestStreamContext));\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 executeHooks(\n\t\t\t\t\toptions.onRequestStream?.({\n\t\t\t\t\t\t...requestStreamContext,\n\t\t\t\t\t\tevent: createProgressEvent({ chunk, totalBytes, transferredBytes }),\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 Request(requestInstance, { body: stream, duplex: \"half\" } as RequestInit);\n};\n\ntype StreamableResponseContext = RequestContext & { response: Response };\n\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 =\n\t\tisObject(options.forcefullyCalculateStreamSize) ?\n\t\t\toptions.forcefullyCalculateStreamSize.response\n\t\t:\toptions.forcefullyCalculateStreamSize;\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\tconst stream = new ReadableStream({\n\t\tstart: async (controller) => {\n\t\t\tconst body = response.body;\n\n\t\t\tif (!body) return;\n\n\t\t\tconst responseStreamContext = {\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\tevent: createProgressEvent({ chunk: new Uint8Array(), totalBytes, transferredBytes }),\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t\tresponse,\n\t\t\t} satisfies ResponseStreamContext;\n\n\t\t\tawait executeHooks(options.onResponseStream?.(responseStreamContext));\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 executeHooks(\n\t\t\t\t\toptions.onResponseStream?.({\n\t\t\t\t\t\t...responseStreamContext,\n\t\t\t\t\t\tevent: createProgressEvent({ chunk, totalBytes, transferredBytes }),\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 { extraOptionDefaults } from \"./constants/defaults\";\nimport type { RequestContext } from \"./hooks\";\nimport { toStreamableRequest, toStreamableResponse } from \"./stream\";\nimport type { AnyString, RemovePrefix, UnmaskType } from \"./types/type-helpers\";\nimport { deterministicHashFn, waitFor } from \"./utils/common\";\nimport { isFunction } from \"./utils/guards\";\n\ntype RequestInfo = {\n\tcontroller: AbortController;\n\tresponsePromise: Promise<Response>;\n};\n\n/**\n * Cache that stores active request information for deduplication within a specific scope.\n *\n * Maps deduplication keys to their corresponding request information, including the abort controller\n * and response promise. A `null` key represents requests that don't participate in deduplication.\n *\n * **Internal Usage:**\n * This type is primarily used internally by the deduplication system. You typically won't need to\n * interact with it directly unless you're building custom deduplication logic or debugging.\n *\n * @example\n * ```ts\n * // This is handled internally, but conceptually:\n * const cache: RequestInfoCache = new Map([\n * [\"user-123\", { controller: abortController, responsePromise: fetchPromise }],\n * [\"config\", { controller: abortController2, responsePromise: fetchPromise2 }],\n * ]);\n * ```\n */\nexport type RequestInfoCache = Map<string | null, RequestInfo>;\n\n/**\n * Global cache that manages multiple request info caches, organized by scope keys.\n *\n * This enables the global deduplication feature by maintaining separate cache namespaces\n * for different scope keys. Each scope key gets its own `RequestInfoCache` instance.\n *\n * **Cache Lifecycle:**\n * - Caches are created on-demand when first accessed\n * - Automatic cleanup occurs when no references remain\n * - Each scope key maintains independent deduplication state\n *\n * **Memory Considerations:**\n * - Each scope key creates a separate cache instance\n * - Consider the number of different scope keys in your application\n * - Caches are cleaned up automatically when clients are garbage collected\n *\n * @example\n * ```ts\n * // This is managed internally, but conceptually:\n * const globalCache: GlobalRequestInfoCache = new Map([\n * [\"user-service\", new Map([...])], // Cache for user service requests\n * [\"analytics\", new Map([...])], // Cache for analytics requests\n * [\"default\", new Map([...])] // Default cache scope\n * ]);\n * ```\n */\nexport type GlobalRequestInfoCache = Map<DedupeOptions[\"dedupeCacheScopeKey\"], RequestInfoCache>;\n\ntype DedupeContext = RequestContext & {\n\t$GlobalRequestInfoCache: GlobalRequestInfoCache;\n\t$LocalRequestInfoCache: RequestInfoCache;\n\tnewFetchController: AbortController;\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 =\n\t\tglobalOptions.dedupeStrategy ?? globalOptions.dedupe?.strategy ?? extraOptionDefaults.dedupeStrategy;\n\n\tconst resolvedDedupeStrategy = isFunction(dedupeStrategy) ? dedupeStrategy(context) : dedupeStrategy;\n\n\tconst getDedupeKey = () => {\n\t\tconst shouldHaveDedupeKey =\n\t\t\tresolvedDedupeStrategy === \"cancel\" || resolvedDedupeStrategy === \"defer\";\n\n\t\tif (!shouldHaveDedupeKey) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst dedupeKey = globalOptions.dedupeKey ?? globalOptions.dedupe?.key;\n\n\t\tconst resolvedDedupeKey = isFunction(dedupeKey) ? dedupeKey(context) : dedupeKey;\n\n\t\tif (resolvedDedupeKey === undefined) {\n\t\t\tconst defaultDedupeKey = `${globalOptions.fullURL}-${deterministicHashFn({ options: globalOptions, request: globalRequest })}`;\n\n\t\t\treturn defaultDedupeKey;\n\t\t}\n\n\t\treturn resolvedDedupeKey;\n\t};\n\n\tconst getDedupeCacheScopeKey = () => {\n\t\tconst dedupeCacheScopeKey = globalOptions.dedupeCacheScopeKey ?? globalOptions.dedupe?.cacheScopeKey;\n\n\t\tconst resolvedDedupeCacheScopeKey =\n\t\t\tisFunction(dedupeCacheScopeKey) ? dedupeCacheScopeKey(context) : dedupeCacheScopeKey;\n\n\t\tif (resolvedDedupeCacheScopeKey === undefined) {\n\t\t\treturn extraOptionDefaults.dedupeCacheScopeKey;\n\t\t}\n\n\t\treturn resolvedDedupeCacheScopeKey;\n\t};\n\n\tconst dedupeKey = getDedupeKey();\n\n\tconst dedupeCacheScope =\n\t\tglobalOptions.dedupeCacheScope\n\t\t?? globalOptions.dedupe?.cacheScope\n\t\t?? extraOptionDefaults.dedupeCacheScope;\n\n\tconst dedupeCacheScopeKey = getDedupeCacheScopeKey();\n\n\tif (dedupeCacheScope === \"global\" && !$GlobalRequestInfoCache.has(dedupeCacheScopeKey)) {\n\t\t$GlobalRequestInfoCache.set(dedupeCacheScopeKey, new Map());\n\t}\n\n\tconst $RequestInfoCache =\n\t\tdedupeCacheScope === \"global\" ?\n\t\t\t$GlobalRequestInfoCache.get(dedupeCacheScopeKey)\n\t\t:\t$LocalRequestInfoCache;\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 * Force sequential execution of parallel requests to enable proper cache-based deduplication.\n\t *\n\t * Problem: When Promise.all([callApi(url), callApi(url)]) executes, both requests\n\t * start synchronously and reach this point before either can populate the cache.\n\t *\n\t * Why `await Promise.resolve()` fails:\n\t * - All microtasks in a batch resolve together at the next microtask checkpoint\n\t * - Both requests resume execution simultaneously after the await\n\t * - Both check `prevRequestInfo` at the same time → both see empty cache\n\t * - Both proceed to populate cache → deduplication fails\n\t *\n\t * Why `wait new Promise(()=> setTimeout(resolve, number))` works:\n\t * - Each setTimeout creates a separate task in the task queue\n\t * - Tasks execute sequentially, not simultaneously\n\t * - Request 1's task runs first: checks cache (empty) → continues → populates cache\n\t * - Request 2's task runs after: checks cache (populated) → uses cached promise\n\t * - Deduplication succeeds\n\t *\n\t * IMPORTANT: The delay must be non-zero. setTimeout(fn, 0) fails because JavaScript engines\n\t * may optimize zero-delay timers by batching them together, causing all requests to resume\n\t * simultaneously (same problem as microtasks). Any non-zero value (even 0.0000000001) forces\n\t * proper sequential task queue scheduling, ensuring each request gets its own task slot.\n\t */\n\tif (dedupeKey !== null) {\n\t\tawait waitFor(0.001);\n\t}\n\n\tconst prevRequestInfo = $RequestInfoCacheOrNull?.get(dedupeKey);\n\n\tconst getAbortErrorMessage = () => {\n\t\tif (globalOptions.dedupeKey) {\n\t\t\treturn `Duplicate request detected - Aborted previous request with key '${dedupeKey}'`;\n\t\t}\n\n\t\treturn `Duplicate request aborted - Aborted previous request to '${globalOptions.fullURL}'`;\n\t};\n\n\tconst handleRequestCancelStrategy = () => {\n\t\tconst shouldCancelRequest = prevRequestInfo && resolvedDedupeStrategy === \"cancel\";\n\n\t\tif (!shouldCancelRequest) return;\n\n\t\tconst message = getAbortErrorMessage();\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\tfetchApi: NonNullable<DedupeContext[\"options\"][\"customFetchImpl\"]>;\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 { fetchApi, options: localOptions, request: localRequest } = deferContext;\n\n\t\tconst shouldUsePromiseFromCache = prevRequestInfo && resolvedDedupeStrategy === \"defer\";\n\n\t\tconst streamableContext = {\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\toptions: localOptions,\n\t\t\trequest: localRequest,\n\t\t} satisfies RequestContext;\n\n\t\tconst streamableRequest = await toStreamableRequest(streamableContext);\n\n\t\tconst responsePromise =\n\t\t\tshouldUsePromiseFromCache ?\n\t\t\t\tprevRequestInfo.responsePromise\n\t\t\t:\tfetchApi(localOptions.fullURL as NonNullable<typeof localOptions.fullURL>, streamableRequest);\n\n\t\t$RequestInfoCacheOrNull?.set(dedupeKey, { controller: newFetchController, responsePromise });\n\n\t\tconst response = await responsePromise;\n\n\t\treturn toStreamableResponse({ ...streamableContext, response });\n\t};\n\n\tconst removeDedupeKeyFromCache = () => {\n\t\t$RequestInfoCacheOrNull?.delete(dedupeKey);\n\t};\n\n\treturn {\n\t\tgetAbortErrorMessage,\n\t\thandleRequestCancelStrategy,\n\t\thandleRequestDeferStrategy,\n\t\tremoveDedupeKeyFromCache,\n\t\tresolvedDedupeStrategy,\n\t};\n};\n\ntype DedupeStrategyUnion = UnmaskType<\"cancel\" | \"defer\" | \"none\">;\n\ntype DedupeOptionKeys = Exclude<keyof DedupeOptions, \"dedupe\">;\n\ntype InnerDedupeOptions = {\n\t[Key in DedupeOptionKeys as RemovePrefix<\"dedupe\", Key>]?: DedupeOptions[Key];\n};\n\nexport type DedupeOptions = {\n\t/**\n\t * All dedupe options in a single object instead of separate properties\n\t */\n\tdedupe?: InnerDedupeOptions;\n\n\t/**\n\t * Controls the scope of request deduplication caching.\n\t *\n\t * - `\"global\"`: Shares deduplication cache across all `createFetchClient` instances with the same `dedupeCacheScopeKey`.\n\t * Useful for applications with multiple API clients that should share deduplication state.\n\t * - `\"local\"`: Limits deduplication to requests within the same `createFetchClient` instance.\n\t * Provides better isolation and is recommended for most use cases.\n\t *\n\t *\n\t * **Real-world Scenarios:**\n\t * - Use `\"global\"` when you have multiple API clients (user service, auth service, etc.) that might make overlapping requests\n\t * - Use `\"local\"` (default) for single-purpose clients or when you want strict isolation between different parts of your app\n\t *\n\t * @example\n\t * ```ts\n\t * // Local scope - each client has its own deduplication cache\n\t * const userClient = createFetchClient({ baseURL: \"/api/users\" });\n\t * const postClient = createFetchClient({ baseURL: \"/api/posts\" });\n\t * // These clients won't share deduplication state\n\t *\n\t * // Global scope - share cache across related clients\n\t * const userClient = createFetchClient({\n\t * baseURL: \"/api/users\",\n\t * dedupeCacheScope: \"global\",\n\t * });\n\t * const postClient = createFetchClient({\n\t * baseURL: \"/api/posts\",\n\t * dedupeCacheScope: \"global\",\n\t * });\n\t * // These clients will share deduplication state\n\t * ```\n\t *\n\t * @default \"local\"\n\t */\n\tdedupeCacheScope?: \"global\" | \"local\";\n\n\t/**\n\t * Unique namespace for the global deduplication cache when using `dedupeCacheScope: \"global\"`.\n\t *\n\t * This creates logical groupings of deduplication caches. All instances with the same key\n\t * will share the same cache namespace, allowing fine-grained control over which clients\n\t * share deduplication state.\n\t *\n\t * **Best Practices:**\n\t * - Use descriptive names that reflect the logical grouping (e.g., \"user-service\", \"analytics-api\")\n\t * - Keep scope keys consistent across related API clients\n\t * - Consider using different scope keys for different environments (dev, staging, prod)\n\t * - Avoid overly broad scope keys that might cause unintended cache sharing\n\t *\n\t * **Cache Management:**\n\t * - Each scope key maintains its own independent cache\n\t * - Caches are automatically cleaned up when no references remain\n\t * - Consider the memory implications of multiple global scopes\n\t *\n\t * @example\n\t * ```ts\n\t * // Group related API clients together\n\t * const userClient = createFetchClient({\n\t * baseURL: \"/api/users\",\n\t * dedupeCacheScope: \"global\",\n\t * dedupeCacheScopeKey: \"user-service\"\n\t * });\n\t * const profileClient = createFetchClient({\n\t * baseURL: \"/api/profiles\",\n\t * dedupeCacheScope: \"global\",\n\t * dedupeCacheScopeKey: \"user-service\" // Same scope - will share cache\n\t * });\n\t *\n\t * // Separate analytics client with its own cache\n\t * const analyticsClient = createFetchClient({\n\t * baseURL: \"/api/analytics\",\n\t * dedupeCacheScope: \"global\",\n\t * dedupeCacheScopeKey: \"analytics-service\" // Different scope\n\t * });\n\t *\n\t * // Environment-specific scoping\n\t * const apiClient = createFetchClient({\n\t * dedupeCacheScope: \"global\",\n\t * dedupeCacheScopeKey: `api-${process.env.NODE_ENV}` // \"api-development\", \"api-production\", etc.\n\t * });\n\t * ```\n\t *\n\t * @default \"default\"\n\t */\n\tdedupeCacheScopeKey?: \"default\" | AnyString | ((context: RequestContext) => string | undefined);\n\n\t/**\n\t * Custom key generator for request deduplication.\n\t *\n\t * Override the default key generation strategy to control exactly which requests\n\t * are considered duplicates. The default key combines URL, method, body, and\n\t * relevant headers (excluding volatile ones like 'Date', 'Authorization', etc.).\n\t *\n\t * **Default Key Generation:**\n\t * The auto-generated key includes:\n\t * - Full request URL (including query parameters)\n\t * - HTTP method (GET, POST, etc.)\n\t * - Request body (for POST/PUT/PATCH requests)\n\t * - Stable headers (excludes Date, Authorization, User-Agent, etc.)\n\t *\n\t * **Custom Key Best Practices:**\n\t * - Include only the parts of the request that should affect deduplication\n\t * - Avoid including volatile data (timestamps, random IDs, etc.)\n\t * - Consider performance - simpler keys are faster to compute and compare\n\t * - Ensure keys are deterministic for the same logical request\n\t * - Use consistent key formats across your application\n\t *\n\t * **Performance Considerations:**\n\t * - Function-based keys are computed on every request - keep them lightweight\n\t * - String keys are fastest but least flexible\n\t * - Consider caching expensive key computations if needed\n\t *\n\t * @example\n\t * ```ts\n\t * import { callApi } from \"@zayne-labs/callapi\";\n\t *\n\t * // Simple static key - useful for singleton requests\n\t * const config = callApi(\"/api/config\", {\n\t * dedupeKey: \"app-config\",\n\t * dedupeStrategy: \"defer\" // Share the same config across all requests\n\t * });\n\t *\n\t * // URL and method only - ignore headers and body\n\t * const userData = callApi(\"/api/user/123\", {\n\t * dedupeKey: (context) => `${context.options.method}:${context.options.fullURL}`\n\t * });\n\t *\n\t * // Include specific headers in deduplication\n\t * const apiCall = callApi(\"/api/data\", {\n\t * dedupeKey: (context) => {\n\t * const authHeader = context.request.headers.get(\"Authorization\");\n\t * return `${context.options.fullURL}-${authHeader}`;\n\t * }\n\t * });\n\t *\n\t * // User-specific deduplication\n\t * const userSpecificCall = callApi(\"/api/dashboard\", {\n\t * dedupeKey: (context) => {\n\t * const userId = context.options.fullURL.match(/user\\/(\\d+)/)?.[1];\n\t * return `dashboard-${userId}`;\n\t * }\n\t * });\n\t *\n\t * // Ignore certain query parameters\n\t * const searchCall = callApi(\"/api/search?q=test×tamp=123456\", {\n\t * dedupeKey: (context) => {\n\t * const url = new URL(context.options.fullURL);\n\t * url.searchParams.delete(\"timestamp\"); // Remove volatile param\n\t * return `search:${url.toString()}`;\n\t * }\n\t * });\n\t * ```\n\t *\n\t * @default Auto-generated from request details\n\t */\n\tdedupeKey?: string | ((context: RequestContext) => string | undefined);\n\n\t/**\n\t * Strategy for handling duplicate requests. Can be a static string or callback function.\n\t *\n\t * **Available Strategies:**\n\t * - `\"cancel\"`: Cancel previous request when new one starts (good for search)\n\t * - `\"defer\"`: Share response between duplicate requests (good for config loading)\n\t * - `\"none\"`: No deduplication, all requests execute independently\n\t *\n\t * @example\n\t * ```ts\n\t * // Static strategies\n\t * const searchClient = createFetchClient({\n\t * dedupeStrategy: \"cancel\" // Cancel previous searches\n\t * });\n\t *\n\t * const configClient = createFetchClient({\n\t * dedupeStrategy: \"defer\" // Share config across components\n\t * });\n\t *\n\t * // Dynamic strategy based on request\n\t * const smartClient = createFetchClient({\n\t * dedupeStrategy: (context) => {\n\t * return context.options.method === \"GET\" ? \"defer\" : \"cancel\";\n\t * }\n\t * });\n\t *\n\t * // Search-as-you-type with cancel strategy\n\t * const handleSearch = async (query: string) => {\n\t * try {\n\t * const { data } = await callApi(\"/api/search\", {\n\t * method: \"POST\",\n\t * body: { query },\n\t * dedupeStrategy: \"cancel\",\n\t * dedupeKey: \"search\" // Cancel previous searches, only latest one goes through\n\t * });\n\t *\n\t * updateSearchResults(data);\n\t * } catch (error) {\n\t * if (error.name === \"AbortError\") {\n\t * // Previous search cancelled - (expected behavior)\n\t * return;\n\t * }\n\t * console.error(\"Search failed:\", error);\n\t * }\n\t * };\n\t *\n\t * ```\n\t *\n\t * @default \"cancel\"\n\t */\n\tdedupeStrategy?: DedupeStrategyUnion | ((context: RequestContext) => DedupeStrategyUnion);\n};\n","import type { RequestContext } from \"./hooks\";\nimport type { CallApiContext } from \"./types/common\";\nimport type { DefaultCallApiContext } from \"./types/default-types\";\nimport type { UnmaskType } from \"./types/type-helpers\";\n\nexport type FetchImpl = UnmaskType<\n\t(input: string | Request | URL, init?: RequestInit) => Promise<Response>\n>;\n\nexport type FetchMiddlewareContext<TCallApiContext extends CallApiContext> =\n\tRequestContext<TCallApiContext> & {\n\t\tfetchImpl: FetchImpl;\n\t};\n\nexport interface Middlewares<TCallApiContext extends NoInfer<CallApiContext> = DefaultCallApiContext> {\n\t/**\n\t * Wraps the fetch implementation to intercept requests at the network layer.\n\t *\n\t * Takes a context object containing the current fetch function and returns a new fetch function.\n\t * Use it to cache responses, add logging, handle offline mode, or short-circuit requests etc.\n\t * Multiple middleware compose in order: plugins → base config → per-request.\n\t *\n\t * Unlike `customFetchImpl`, middleware can call through to the original fetch.\n\t *\n\t * @example\n\t * ```ts\n\t * // Cache responses\n\t * const cache = new Map();\n\t *\n\t * fetchMiddleware: (ctx) => async (input, init) => {\n\t * const key = input.toString();\n\t *\n\t * const cachedResponse = cache.get(key);\n\t *\n\t * if (cachedResponse) {\n\t *\t return cachedResponse.clone();\n\t * }\n\t *\n\t * const response = await ctx.fetchImpl(input, init);\n\t * cache.set(key, response.clone());\n\t *\n\t * return response;\n\t * }\n\t *\n\t * // Handle offline\n\t * fetchMiddleware: (ctx) => async (...parameters) => {\n\t * if (!navigator.onLine) {\n\t * return new Response('{\"error\": \"offline\"}', { status: 503 });\n\t * }\n\t *\n\t * return ctx.fetchImpl(...parameters);\n\t * }\n\t * ```\n\t */\n\tfetchMiddleware?: (context: FetchMiddlewareContext<TCallApiContext>) => FetchImpl;\n}\n\ntype MiddlewareRegistries = Required<{\n\t[Key in keyof Middlewares]: Set<Middlewares[Key]>;\n}>;\n\nexport const getMiddlewareRegistriesAndKeys = () => {\n\tconst middlewareRegistries: MiddlewareRegistries = {\n\t\tfetchMiddleware: new Set(),\n\t};\n\n\tconst middlewareRegistryKeys = Object.keys(middlewareRegistries) as Array<keyof Middlewares>;\n\n\treturn { middlewareRegistries, middlewareRegistryKeys };\n};\n\nexport const composeMiddlewaresFromArray = (\n\tmiddlewareArray: Array<Middlewares[keyof Middlewares] | undefined>\n) => {\n\tlet composedMiddleware: Middlewares[keyof Middlewares];\n\n\tfor (const currentMiddleware of middlewareArray) {\n\t\tif (!currentMiddleware) continue;\n\n\t\tconst previousMiddleware = composedMiddleware;\n\n\t\tif (!previousMiddleware) {\n\t\t\tcomposedMiddleware = currentMiddleware;\n\t\t\tcontinue;\n\t\t}\n\n\t\tcomposedMiddleware = (context) => {\n\t\t\tconst prevFetchImpl = previousMiddleware(context);\n\t\t\tconst fetchImpl = currentMiddleware({ ...context, fetchImpl: prevFetchImpl });\n\n\t\t\treturn fetchImpl;\n\t\t};\n\t}\n\n\treturn composedMiddleware;\n};\n","import { extraOptionDefaults } from \"./constants/defaults\";\nimport {\n\tcomposeHooksFromArray,\n\tgetHookRegistriesAndKeys,\n\ttype Hooks,\n\ttype HooksOrHooksArray,\n\ttype RequestContext,\n} from \"./hooks\";\nimport {\n\tcomposeMiddlewaresFromArray,\n\tgetMiddlewareRegistriesAndKeys,\n\ttype Middlewares,\n} from \"./middlewares\";\nimport type { CallApiContext, CallApiRequestOptions, OverrideCallApiContext } from \"./types/common\";\nimport type { DefaultCallApiContext, DefaultDataType } from \"./types/default-types\";\nimport type { AnyFunction, Awaitable, UnionToIntersection } from \"./types/type-helpers\";\nimport type { InitURLOrURLObject } from \"./url\";\nimport { getMethod, getResolvedHeaders } from \"./utils/common\";\nimport { isArray, isFunction, isString } from \"./utils/guards\";\nimport {\n\ttype BaseCallApiSchemaAndConfig,\n\tgetCurrentRouteSchemaKeyAndMainInitURL,\n\ttype InferSchemaOutput,\n} from \"./validation\";\n\nexport type PluginSetupContext<TCallApiContext extends CallApiContext = DefaultCallApiContext> =\n\tRequestContext<TCallApiContext> & { initURL: string };\n\nexport type PluginInitResult<TCallApiContext extends CallApiContext = DefaultCallApiContext> = Partial<\n\tOmit<PluginSetupContext<TCallApiContext>, \"initURL\" | \"request\"> & {\n\t\tinitURL: InitURLOrURLObject;\n\t\trequest: CallApiRequestOptions;\n\t}\n>;\n\ntype GetDefaultDataTypeForPlugins<TData> = DefaultDataType extends TData ? never : TData;\n\nexport type PluginHooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> =\n\tHooksOrHooksArray<\n\t\tOverrideCallApiContext<\n\t\t\tTCallApiContext,\n\t\t\t{\n\t\t\t\tData: GetDefaultDataTypeForPlugins<TCallApiContext[\"Data\"]>;\n\t\t\t\tErrorData: GetDefaultDataTypeForPlugins<TCallApiContext[\"ErrorData\"]>;\n\t\t\t}\n\t\t>\n\t>;\n\nexport type PluginMiddlewares<TCallApiContext extends CallApiContext = DefaultCallApiContext> =\n\tMiddlewares<\n\t\tOverrideCallApiContext<\n\t\t\tTCallApiContext,\n\t\t\t{\n\t\t\t\tData: GetDefaultDataTypeForPlugins<TCallApiContext[\"Data\"]>;\n\t\t\t\tErrorData: GetDefaultDataTypeForPlugins<TCallApiContext[\"ErrorData\"]>;\n\t\t\t}\n\t\t>\n\t>;\n\nexport interface CallApiPlugin<TCallApiContext extends CallApiContext = DefaultCallApiContext> {\n\t/**\n\t * Defines additional options that can be passed to callApi\n\t */\n\tdefineExtraOptions?: () => TCallApiContext[\"InferredExtraOptions\"];\n\n\t/**\n\t * A description for the plugin\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Hooks for the plugin\n\t */\n\thooks?:\n\t\t| PluginHooks<TCallApiContext>\n\t\t| ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginHooks<TCallApiContext>>);\n\n\t/**\n\t * A unique id for the plugin\n\t */\n\tid: string;\n\n\t/**\n\t * Middlewares that for the plugin\n\t */\n\tmiddlewares?:\n\t\t| PluginMiddlewares<TCallApiContext>\n\t\t| ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginMiddlewares<TCallApiContext>>);\n\n\t/**\n\t * A name for the plugin\n\t */\n\tname: string;\n\n\t/**\n\t * Base schema for the client.\n\t */\n\tschema?: BaseCallApiSchemaAndConfig;\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\tsetup?: (\n\t\tcontext: PluginSetupContext<TCallApiContext>\n\t) => Awaitable<PluginInitResult<TCallApiContext>> | Awaitable<void>;\n\n\t/**\n\t * A version for the plugin\n\t */\n\tversion?: string;\n}\n\nexport type InferPluginExtraOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<\n\tTPluginArray extends Array<infer TPlugin> ?\n\t\tTPlugin extends CallApiPlugin ?\n\t\t\tTPlugin[\"defineExtraOptions\"] extends AnyFunction<infer TResult> ?\n\t\t\t\tInferSchemaOutput<TResult, TResult>\n\t\t\t:\tnever\n\t\t:\tnever\n\t:\tnever\n>;\n\nexport const getResolvedPlugins = (context: Pick<RequestContext, \"baseConfig\" | \"options\">) => {\n\tconst { baseConfig, options } = context;\n\n\tconst resolvedPlugins =\n\t\tisFunction(options.plugins) ?\n\t\t\toptions.plugins({ basePlugins: baseConfig.plugins ?? [] })\n\t\t:\t(options.plugins ?? []);\n\n\treturn resolvedPlugins;\n};\n\nexport const initializePlugins = async (setupContext: PluginSetupContext) => {\n\tconst { baseConfig, config, initURL, options, request } = setupContext;\n\n\tconst {\n\t\taddMainHooks,\n\t\taddMainMiddlewares,\n\t\taddPluginHooks,\n\t\taddPluginMiddlewares,\n\t\tgetResolvedHooks,\n\t\tgetResolvedMiddlewares,\n\t} = setupHooksAndMiddlewares({ baseConfig, config, options });\n\n\tconst initURLResult = getCurrentRouteSchemaKeyAndMainInitURL({\n\t\tbaseExtraOptions: baseConfig,\n\t\textraOptions: config,\n\t\tinitURL,\n\t});\n\n\tlet resolvedCurrentRouteSchemaKey = initURLResult.currentRouteSchemaKey;\n\tlet resolvedInitURL = initURLResult.mainInitURL;\n\tconst resolvedOptions = options;\n\tconst resolvedRequest = Object.assign(request, {\n\t\theaders: getResolvedHeaders({ baseHeaders: baseConfig.headers, headers: config.headers }),\n\t\tmethod: getMethod({ initURL: resolvedInitURL, method: request.method }),\n\t});\n\n\tconst executePluginSetupFn = async (pluginSetup: CallApiPlugin[\"setup\"]) => {\n\t\tif (!pluginSetup) return;\n\n\t\tconst initResult = await pluginSetup(setupContext);\n\n\t\tif (!initResult) return;\n\n\t\tconst urlString = initResult.initURL?.toString();\n\n\t\tif (isString(urlString)) {\n\t\t\tconst newURLResult = getCurrentRouteSchemaKeyAndMainInitURL({\n\t\t\t\tbaseExtraOptions: baseConfig,\n\t\t\t\textraOptions: config,\n\t\t\t\tinitURL: urlString,\n\t\t\t});\n\n\t\t\tresolvedCurrentRouteSchemaKey = newURLResult.currentRouteSchemaKey;\n\t\t\tresolvedInitURL = newURLResult.mainInitURL;\n\t\t}\n\n\t\tif (initResult.request) {\n\t\t\tObject.assign(resolvedRequest, initResult.request);\n\t\t}\n\n\t\tif (initResult.options) {\n\t\t\tObject.assign(resolvedOptions, initResult.options);\n\t\t}\n\t};\n\n\tconst resolvedPlugins = getResolvedPlugins({ baseConfig, options });\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\tconst [, pluginHooks, pluginMiddlewares] = await Promise.all([\n\t\t\texecutePluginSetupFn(plugin.setup),\n\t\t\tisFunction(plugin.hooks) ? plugin.hooks(setupContext) : plugin.hooks,\n\t\t\tisFunction(plugin.middlewares) ? plugin.middlewares(setupContext) : plugin.middlewares,\n\t\t]);\n\n\t\tpluginHooks && addPluginHooks(pluginHooks);\n\t\tpluginMiddlewares && addPluginMiddlewares(pluginMiddlewares);\n\t}\n\n\taddMainHooks();\n\n\taddMainMiddlewares();\n\n\tconst resolvedHooks = getResolvedHooks();\n\n\tconst resolvedMiddlewares = getResolvedMiddlewares();\n\n\treturn {\n\t\tresolvedCurrentRouteSchemaKey,\n\t\tresolvedHooks,\n\t\tresolvedInitURL,\n\t\tresolvedMiddlewares,\n\t\tresolvedOptions,\n\t\tresolvedRequest,\n\t};\n};\n\nconst setupHooksAndMiddlewares = (\n\tcontext: Pick<PluginSetupContext, \"baseConfig\" | \"config\" | \"options\">\n) => {\n\tconst { baseConfig, config, options } = context;\n\n\tconst { hookRegistries, hookRegistryKeys } = getHookRegistriesAndKeys();\n\n\tconst { middlewareRegistries, middlewareRegistryKeys } = getMiddlewareRegistriesAndKeys();\n\n\tconst addMainHooks = () => {\n\t\tfor (const hookName of hookRegistryKeys) {\n\t\t\tconst overriddenHook = options[hookName];\n\t\t\tconst baseHook = baseConfig[hookName];\n\t\t\tconst instanceHook = config[hookName];\n\n\t\t\tconst shouldMergeBaseAndInstanceHooks = isArray(baseHook) && instanceHook;\n\n\t\t\tconst mainHook =\n\t\t\t\tshouldMergeBaseAndInstanceHooks ? [baseHook, instanceHook].flat() : overriddenHook;\n\n\t\t\tmainHook && hookRegistries[hookName].add(mainHook as never);\n\t\t}\n\t};\n\n\tconst addPluginHooks = (pluginHooks: PluginHooks) => {\n\t\tfor (const hookName of hookRegistryKeys) {\n\t\t\tconst pluginHook = pluginHooks[hookName];\n\n\t\t\tpluginHook && hookRegistries[hookName].add(pluginHook as never);\n\t\t}\n\t};\n\n\tconst addMainMiddlewares = () => {\n\t\tfor (const middlewareName of middlewareRegistryKeys) {\n\t\t\tconst baseMiddleware = baseConfig[middlewareName];\n\t\t\tconst instanceMiddleware = config[middlewareName];\n\n\t\t\tbaseMiddleware && middlewareRegistries[middlewareName].add(baseMiddleware);\n\n\t\t\tinstanceMiddleware && middlewareRegistries[middlewareName].add(instanceMiddleware);\n\t\t}\n\t};\n\n\tconst addPluginMiddlewares = (pluginMiddlewares: PluginMiddlewares) => {\n\t\tfor (const middlewareName of middlewareRegistryKeys) {\n\t\t\tconst pluginMiddleware = pluginMiddlewares[middlewareName];\n\n\t\t\tif (!pluginMiddleware) continue;\n\n\t\t\tmiddlewareRegistries[middlewareName].add(pluginMiddleware);\n\t\t}\n\t};\n\n\tconst getResolvedHooks = () => {\n\t\tconst resolvedHooks: Hooks = {};\n\n\t\tfor (const [hookName, hookRegistry] of Object.entries(hookRegistries)) {\n\t\t\tif (hookRegistry.size === 0) continue;\n\n\t\t\t// == Flatten the hook registry to remove any nested arrays, incase an array of hooks is passed to any of the hooks\n\t\t\tconst flattenedHookArray = [...hookRegistry].flat();\n\n\t\t\tif (flattenedHookArray.length === 0) continue;\n\n\t\t\tconst hooksExecutionMode = options.hooksExecutionMode ?? extraOptionDefaults.hooksExecutionMode;\n\n\t\t\tconst composedHook = composeHooksFromArray(flattenedHookArray, hooksExecutionMode);\n\n\t\t\tresolvedHooks[hookName as keyof Hooks] = composedHook;\n\t\t}\n\n\t\treturn resolvedHooks;\n\t};\n\n\tconst getResolvedMiddlewares = () => {\n\t\tconst resolvedMiddlewares: Middlewares = {};\n\n\t\tfor (const [middlewareName, middlewareRegistry] of Object.entries(middlewareRegistries)) {\n\t\t\tif (middlewareRegistry.size === 0) continue;\n\n\t\t\tconst middlewareArray = [...middlewareRegistry];\n\n\t\t\tif (middlewareArray.length === 0) continue;\n\n\t\t\tconst composedMiddleware = composeMiddlewaresFromArray(middlewareArray);\n\n\t\t\tresolvedMiddlewares[middlewareName as keyof Middlewares] = composedMiddleware;\n\t\t}\n\n\t\treturn resolvedMiddlewares;\n\t};\n\n\treturn {\n\t\taddMainHooks,\n\t\taddMainMiddlewares,\n\t\taddPluginHooks,\n\t\taddPluginMiddlewares,\n\t\tgetResolvedHooks,\n\t\tgetResolvedMiddlewares,\n\t};\n};\n","import { extraOptionDefaults } from \"./constants/defaults\";\nimport {\n\texecuteHooksInCatchBlock,\n\ttype ErrorContext,\n\ttype ExecuteHookInfo,\n\ttype RequestContext,\n\ttype RetryContext,\n} from \"./hooks\";\nimport type { CallApiResultErrorVariant } from \"./result\";\nimport type { CallApiConfig } from \"./types/common\";\nimport type { MethodUnion } from \"./types/conditional-types\";\nimport {\n\tdefineEnum,\n\ttype AnyNumber,\n\ttype Awaitable,\n\ttype RemovePrefix,\n\ttype UnmaskType,\n} from \"./types/type-helpers\";\nimport type { InitURLOrURLObject } from \"./url\";\nimport { waitFor } from \"./utils/common\";\nimport { isBoolean, isFunction, isString } from \"./utils/guards\";\n\n// eslint-disable-next-line ts-eslint/no-unused-vars -- Ignore\nconst defaultRetryStatusCodesLookup = () =>\n\tdefineEnum({\n\t\t408: \"Request Timeout\",\n\t\t409: \"Conflict\",\n\t\t425: \"Too Early\",\n\t\t429: \"Too Many Requests\",\n\t\t500: \"Internal Server Error\",\n\t\t502: \"Bad Gateway\",\n\t\t503: \"Service Unavailable\",\n\t\t504: \"Gateway Timeout\",\n\t});\n\ntype RetryStatusCodes = UnmaskType<AnyNumber | keyof ReturnType<typeof defaultRetryStatusCodesLookup>>;\n\ntype RetryCondition<TErrorData> = (context: ErrorContext<{ ErrorData: TErrorData }>) => Awaitable<boolean>;\n\ntype RetryOptionKeys<TErrorData> = Exclude<keyof RetryOptions<TErrorData>, \"~retryAttemptCount\" | \"retry\">;\n\ntype InnerRetryOptions<TErrorData> = {\n\t[Key in RetryOptionKeys<TErrorData> as RemovePrefix<\"retry\", Key>]?: RetryOptions<TErrorData>[Key];\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 * @internal\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?: RetryStatusCodes[];\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)\n\t\t?? extraOptionDefaults.retryDelay;\n\n\treturn resolveRetryDelay;\n};\n\nconst getExponentialDelay = (currentAttemptCount: number, options: RetryOptions<unknown>) => {\n\tconst retryDelay = options.retryDelay ?? options.retry?.delay ?? extraOptionDefaults.retryDelay;\n\n\tconst resolvedRetryDelay = isFunction(retryDelay) ? retryDelay(currentAttemptCount) : retryDelay;\n\n\tconst maxDelay = options.retryMaxDelay ?? options.retry?.maxDelay ?? extraOptionDefaults.retryMaxDelay;\n\n\tconst exponentialDelay = resolvedRetryDelay * 2 ** currentAttemptCount;\n\n\treturn Math.min(exponentialDelay, maxDelay);\n};\n\nexport const createRetryManager = (ctx: ErrorContext<{ ErrorData: unknown }> & RequestContext) => {\n\tconst { options, request } = 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 =\n\t\toptions.retryStrategy ?? options.retry?.strategy ?? extraOptionDefaults.retryStrategy;\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\tif (isBoolean(request.signal) && request.signal.aborted) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst retryCondition =\n\t\t\toptions.retryCondition ?? options.retry?.condition ?? extraOptionDefaults.retryCondition;\n\n\t\tconst maximumRetryAttempts =\n\t\t\toptions.retryAttempts ?? options.retry?.attempts ?? extraOptionDefaults.retryAttempts;\n\n\t\tconst customRetryCondition = await retryCondition(ctx);\n\n\t\tconst baseShouldRetry = currentAttemptCount <= maximumRetryAttempts && customRetryCondition;\n\n\t\tif (!baseShouldRetry) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst retryMethods = new Set(\n\t\t\toptions.retryMethods ?? options.retry?.methods ?? extraOptionDefaults.retryMethods\n\t\t);\n\n\t\tconst includesMethod =\n\t\t\tisString(ctx.request.method) && retryMethods.size > 0 ?\n\t\t\t\tretryMethods.has(ctx.request.method)\n\t\t\t:\ttrue;\n\n\t\tconst retryStatusCodes = new Set(\n\t\t\toptions.retryStatusCodes ?? options.retry?.statusCodes ?? extraOptionDefaults.retryStatusCodes\n\t\t);\n\n\t\tconst includesStatusCodes =\n\t\t\tctx.response != null && retryStatusCodes.size > 0 ?\n\t\t\t\tretryStatusCodes.has(ctx.response.status)\n\t\t\t:\ttrue;\n\n\t\tconst shouldRetry = includesMethod && includesStatusCodes;\n\n\t\treturn shouldRetry;\n\t};\n\n\ttype CallApiImpl = (\n\t\tinitURL: never,\n\t\tinit?: CallApiConfig\n\t) => Promise<CallApiResultErrorVariant<unknown>>;\n\n\tconst handleRetry = async <TCallapi extends CallApiImpl>(context: {\n\t\tcallApi: TCallapi;\n\t\tcallApiArgs: { config: CallApiConfig; initURL: InitURLOrURLObject };\n\t\terrorContext: ErrorContext<{ ErrorData: unknown }>;\n\t\thookInfo: ExecuteHookInfo;\n\t}) => {\n\t\tconst { callApi, callApiArgs, errorContext, hookInfo } = context;\n\n\t\tconst retryContext = {\n\t\t\t...errorContext,\n\t\t\tretryAttemptCount: currentAttemptCount,\n\t\t} satisfies RetryContext<{ ErrorData: unknown }>;\n\n\t\tconst hookError = await executeHooksInCatchBlock([options.onRetry?.(retryContext)], hookInfo);\n\n\t\tif (hookError) {\n\t\t\treturn hookError;\n\t\t}\n\n\t\tawait waitFor(getDelay());\n\n\t\tconst updatedOptions = {\n\t\t\t...callApiArgs.config,\n\t\t\t\"~retryAttemptCount\": currentAttemptCount + 1,\n\t\t} satisfies CallApiConfig;\n\n\t\treturn callApi(callApiArgs.initURL as never, updatedOptions);\n\t};\n\n\treturn {\n\t\thandleRetry,\n\t\tshouldAttemptRetry,\n\t};\n};\n","import { createDedupeStrategy, type GlobalRequestInfoCache, type RequestInfoCache } from \"./dedupe\";\nimport {\n\ttype ErrorContext,\n\ttype ExecuteHookInfo,\n\texecuteHooks,\n\texecuteHooksInCatchBlock,\n\ttype RequestContext,\n\ttype SuccessContext,\n} from \"./hooks\";\nimport { type CallApiPlugin, initializePlugins } from \"./plugins\";\nimport {\n\ttype ErrorInfo,\n\tgetCustomizedErrorResult,\n\ttype GetResponseType,\n\tresolveErrorResult,\n\tresolveResponseData,\n\tresolveSuccessResult,\n\ttype ResponseTypeType,\n\ttype ResultModeType,\n} from \"./result\";\nimport { createRetryManager } from \"./retry\";\nimport type {\n\tBaseCallApiConfig,\n\tCallApiConfig,\n\tCallApiContext,\n\tCallApiExtraOptionsForHooks,\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n\tCallApiResult,\n\tGetBaseSchemaConfig,\n\tGetBaseSchemaRoutes,\n} from \"./types/common\";\nimport type {\n\tGetCurrentRouteSchema,\n\tGetCurrentRouteSchemaKey,\n\tInferInitURL,\n\tThrowOnErrorUnion,\n} from \"./types/conditional-types\";\nimport type {\n\tDefaultCallApiContext,\n\tDefaultPluginArray,\n\tDefaultThrowOnError,\n} from \"./types/default-types\";\nimport type { AnyFunction } from \"./types/type-helpers\";\nimport { getFullAndNormalizedURL } from \"./url\";\nimport {\n\tcreateCombinedSignal,\n\tcreateTimeoutSignal,\n\tgetBody,\n\tgetFetchImpl,\n\tgetHeaders,\n\tgetMethod,\n\tsplitBaseConfig,\n\tsplitConfig,\n} from \"./utils/common\";\nimport { HTTPError } from \"./utils/external/error\";\nimport { isHTTPErrorInstance, isValidationErrorInstance } from \"./utils/external/guards\";\nimport { isFunction } from \"./utils/guards\";\nimport {\n\ttype BaseCallApiSchemaAndConfig,\n\ttype BaseCallApiSchemaRoutes,\n\ttype CallApiSchema,\n\ttype CallApiSchemaConfig,\n\thandleConfigValidation,\n\thandleSchemaValidation,\n\ttype InferSchemaOutput,\n} from \"./validation\";\n\nconst $GlobalRequestInfoCache: GlobalRequestInfoCache = new Map();\n\nexport const createFetchClientWithContext = <\n\tTOuterCallApiContext extends CallApiContext = DefaultCallApiContext,\n>() => {\n\tconst createFetchClient = <\n\t\tTBaseCallApiContext extends CallApiContext = TOuterCallApiContext,\n\t\tTBaseData = TBaseCallApiContext[\"Data\"],\n\t\tTBaseErrorData = TBaseCallApiContext[\"ErrorData\"],\n\t\tTBaseResultMode extends ResultModeType = TBaseCallApiContext[\"ResultMode\"] extends ResultModeType ?\n\t\t\tTBaseCallApiContext[\"ResultMode\"]\n\t\t:\tDefaultCallApiContext[\"ResultMode\"],\n\t\tTBaseThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError,\n\t\tTBaseResponseType extends ResponseTypeType = ResponseTypeType,\n\t\tconst TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig,\n\t\tconst TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray,\n\t\tTComputedBaseSchemaConfig extends CallApiSchemaConfig = GetBaseSchemaConfig<TBaseSchemaAndConfig>,\n\t\tTComputedBaseSchemaRoutes extends BaseCallApiSchemaRoutes =\n\t\t\tGetBaseSchemaRoutes<TBaseSchemaAndConfig>,\n\t\t// TComputedBaseData = GetResponseType<TBaseData, TBaseResponseType>,\n\t\t// TComputedBaseErrorData = GetResponseType<TBaseErrorData, TBaseResponseType>,\n\t>(\n\t\tinitBaseConfig: BaseCallApiConfig<\n\t\t\tTBaseCallApiContext,\n\t\t\tTBaseData,\n\t\t\tTBaseErrorData,\n\t\t\tTBaseResultMode,\n\t\t\tTBaseThrowOnError,\n\t\t\tTBaseResponseType,\n\t\t\tTBaseSchemaAndConfig,\n\t\t\tTBasePluginArray\n\t\t> = {} as never\n\t) => {\n\t\tconst $LocalRequestInfoCache: RequestInfoCache = new Map();\n\n\t\tconst callApi = async <\n\t\t\tTData = TBaseData,\n\t\t\tTErrorData = TBaseErrorData,\n\t\t\tTResultMode extends ResultModeType = TBaseResultMode,\n\t\t\tTCallApiContext extends CallApiContext = TBaseCallApiContext,\n\t\t\tTThrowOnError extends ThrowOnErrorUnion = TBaseThrowOnError,\n\t\t\tTResponseType extends ResponseTypeType = TBaseResponseType,\n\t\t\tconst TSchemaConfig extends CallApiSchemaConfig = TComputedBaseSchemaConfig,\n\t\t\tTInitURL extends InferInitURL<TComputedBaseSchemaRoutes, TSchemaConfig> = InferInitURL<\n\t\t\t\tTComputedBaseSchemaRoutes,\n\t\t\t\tTSchemaConfig\n\t\t\t>,\n\t\t\tTCurrentRouteSchemaKey extends GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL> =\n\t\t\t\tGetCurrentRouteSchemaKey<TSchemaConfig, TInitURL>,\n\t\t\tconst TSchema extends CallApiSchema = GetCurrentRouteSchema<\n\t\t\t\tTComputedBaseSchemaRoutes,\n\t\t\t\tTCurrentRouteSchemaKey\n\t\t\t>,\n\t\t\tconst TPluginArray extends CallApiPlugin[] = TBasePluginArray,\n\t\t\tTComputedData = InferSchemaOutput<TSchema[\"data\"], GetResponseType<TData, TResponseType>>,\n\t\t\tTComputedErrorData = InferSchemaOutput<\n\t\t\t\tTSchema[\"errorData\"],\n\t\t\t\tGetResponseType<TErrorData, TResponseType>\n\t\t\t>,\n\t\t\tTComputedResult = CallApiResult<TComputedData, TComputedErrorData, TResultMode, TThrowOnError>,\n\t\t>(\n\t\t\tinitURL: TInitURL,\n\t\t\tinitConfig: CallApiConfig<\n\t\t\t\tTCallApiContext,\n\t\t\t\tTComputedData,\n\t\t\t\tTComputedErrorData,\n\t\t\t\tTResultMode,\n\t\t\t\tTThrowOnError,\n\t\t\t\tTResponseType,\n\t\t\t\tTComputedBaseSchemaRoutes,\n\t\t\t\tTSchema,\n\t\t\t\tTComputedBaseSchemaConfig,\n\t\t\t\tTSchemaConfig,\n\t\t\t\tTInitURL,\n\t\t\t\tTCurrentRouteSchemaKey,\n\t\t\t\tTBasePluginArray,\n\t\t\t\tTPluginArray\n\t\t\t> = {} as never\n\t\t): Promise<TComputedResult> => {\n\t\t\tconst [fetchOptions, extraOptions] = splitConfig(initConfig);\n\n\t\t\tconst resolvedBaseConfig =\n\t\t\t\tisFunction(initBaseConfig) ?\n\t\t\t\t\tinitBaseConfig({\n\t\t\t\t\t\tinitURL: initURL.toString(),\n\t\t\t\t\t\toptions: extraOptions,\n\t\t\t\t\t\trequest: fetchOptions,\n\t\t\t\t\t})\n\t\t\t\t:\tinitBaseConfig;\n\n\t\t\tconst baseConfig = resolvedBaseConfig as Exclude<BaseCallApiConfig, AnyFunction>;\n\t\t\tconst config = initConfig as CallApiConfig;\n\n\t\t\tconst [baseFetchOptions, baseExtraOptions] = splitBaseConfig(baseConfig);\n\n\t\t\tconst shouldSkipAutoMergeForOptions =\n\t\t\t\tbaseExtraOptions.skipAutoMergeFor === \"all\" || baseExtraOptions.skipAutoMergeFor === \"options\";\n\n\t\t\tconst shouldSkipAutoMergeForRequest =\n\t\t\t\tbaseExtraOptions.skipAutoMergeFor === \"all\" || baseExtraOptions.skipAutoMergeFor === \"request\";\n\n\t\t\t// == Merged Extra Options\n\t\t\tconst mergedExtraOptions = {\n\t\t\t\t...baseExtraOptions,\n\t\t\t\t...(!shouldSkipAutoMergeForOptions && extraOptions),\n\t\t\t};\n\n\t\t\t// == Merged Request Options\n\t\t\tconst mergedRequestOptions = {\n\t\t\t\t...baseFetchOptions,\n\t\t\t\t...(!shouldSkipAutoMergeForRequest && fetchOptions),\n\t\t\t} satisfies CallApiRequestOptions;\n\n\t\t\tconst {\n\t\t\t\tresolvedCurrentRouteSchemaKey,\n\t\t\t\tresolvedHooks,\n\t\t\t\tresolvedInitURL,\n\t\t\t\tresolvedMiddlewares,\n\t\t\t\tresolvedOptions,\n\t\t\t\tresolvedRequest,\n\t\t\t} = await initializePlugins({\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\tinitURL: initURL.toString(),\n\t\t\t\toptions: mergedExtraOptions as CallApiExtraOptionsForHooks,\n\t\t\t\trequest: mergedRequestOptions as CallApiRequestOptionsForHooks,\n\t\t\t});\n\n\t\t\tconst { fullURL, normalizedInitURL } = getFullAndNormalizedURL({\n\t\t\t\tbaseURL: resolvedOptions.baseURL,\n\t\t\t\tinitURL: resolvedInitURL,\n\t\t\t\tparams: resolvedOptions.params,\n\t\t\t\tquery: resolvedOptions.query,\n\t\t\t});\n\n\t\t\tconst options = {\n\t\t\t\t...resolvedOptions,\n\t\t\t\t...resolvedHooks,\n\t\t\t\t...resolvedMiddlewares,\n\n\t\t\t\tfullURL,\n\t\t\t\tinitURL: resolvedInitURL,\n\t\t\t\tinitURLNormalized: normalizedInitURL,\n\t\t\t} satisfies CallApiExtraOptionsForHooks;\n\n\t\t\tconst newFetchController = new AbortController();\n\n\t\t\tconst timeoutSignal = createTimeoutSignal(options.timeout);\n\n\t\t\tconst combinedSignal = createCombinedSignal(\n\t\t\t\ttimeoutSignal,\n\t\t\t\tresolvedRequest.signal,\n\t\t\t\tnewFetchController.signal\n\t\t\t);\n\n\t\t\tconst request = {\n\t\t\t\t...resolvedRequest,\n\n\t\t\t\tsignal: combinedSignal,\n\t\t\t} satisfies CallApiRequestOptionsForHooks;\n\n\t\t\tconst {\n\t\t\t\tgetAbortErrorMessage,\n\t\t\t\thandleRequestCancelStrategy,\n\t\t\t\thandleRequestDeferStrategy,\n\t\t\t\tremoveDedupeKeyFromCache,\n\t\t\t\tresolvedDedupeStrategy,\n\t\t\t} = await createDedupeStrategy({\n\t\t\t\t$GlobalRequestInfoCache,\n\t\t\t\t$LocalRequestInfoCache,\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\tnewFetchController,\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\tawait handleRequestCancelStrategy();\n\n\t\t\t\tawait executeHooks(options.onRequest?.({ baseConfig, config, options, request }));\n\n\t\t\t\tconst {\n\t\t\t\t\textraOptionsValidationResult,\n\t\t\t\t\trequestOptionsValidationResult,\n\t\t\t\t\tresolvedSchema,\n\t\t\t\t\tresolvedSchemaConfig,\n\t\t\t\t} = await handleConfigValidation({\n\t\t\t\t\tbaseExtraOptions,\n\t\t\t\t\tcurrentRouteSchemaKey: resolvedCurrentRouteSchemaKey,\n\t\t\t\t\textraOptions,\n\t\t\t\t\toptions,\n\t\t\t\t\trequest,\n\t\t\t\t});\n\n\t\t\t\t// == Apply Schema Output for Extra Options\n\t\t\t\tObject.assign(options, extraOptionsValidationResult);\n\n\t\t\t\t// == Apply Schema Output for Request Options\n\t\t\t\tObject.assign(request, {\n\t\t\t\t\tbody: getBody({\n\t\t\t\t\t\tbody: requestOptionsValidationResult.body,\n\t\t\t\t\t\tbodySerializer: options.bodySerializer,\n\t\t\t\t\t\tresolvedHeaders: requestOptionsValidationResult.headers,\n\t\t\t\t\t}),\n\t\t\t\t\theaders: await getHeaders({\n\t\t\t\t\t\tauth: options.auth,\n\t\t\t\t\t\tbody: requestOptionsValidationResult.body,\n\t\t\t\t\t\tresolvedHeaders: requestOptionsValidationResult.headers,\n\t\t\t\t\t}),\n\t\t\t\t\tmethod: getMethod({\n\t\t\t\t\t\tinitURL: resolvedInitURL,\n\t\t\t\t\t\tmethod: requestOptionsValidationResult.method,\n\t\t\t\t\t}),\n\t\t\t\t});\n\n\t\t\t\tconst readyRequestContext = { baseConfig, config, options, request } satisfies RequestContext;\n\n\t\t\t\tawait executeHooks(options.onRequestReady?.(readyRequestContext));\n\n\t\t\t\tconst fetchApi = getFetchImpl({\n\t\t\t\t\tcustomFetchImpl: options.customFetchImpl,\n\t\t\t\t\tfetchMiddleware: options.fetchMiddleware,\n\t\t\t\t\trequestContext: readyRequestContext,\n\t\t\t\t});\n\n\t\t\t\tconst response = await handleRequestDeferStrategy({ fetchApi, options, request });\n\n\t\t\t\t// == Also clone response when dedupeStrategy is set to \"defer\" to avoid error thrown from reading response.(whatever) more than once\n\t\t\t\tconst shouldCloneResponse = resolvedDedupeStrategy === \"defer\" || options.cloneResponse;\n\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tconst errorData = await resolveResponseData(\n\t\t\t\t\t\tshouldCloneResponse ? response.clone() : response,\n\t\t\t\t\t\toptions.responseType,\n\t\t\t\t\t\toptions.responseParser\n\t\t\t\t\t);\n\n\t\t\t\t\tconst validErrorData = await handleSchemaValidation(resolvedSchema, \"errorData\", {\n\t\t\t\t\t\tinputValue: errorData,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t\t\t\t});\n\n\t\t\t\t\t// == Push all error handling responsibilities to the catch block if not retrying\n\t\t\t\t\tthrow new HTTPError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdefaultHTTPErrorMessage: options.defaultHTTPErrorMessage,\n\t\t\t\t\t\t\terrorData: validErrorData,\n\t\t\t\t\t\t\tresponse,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ cause: validErrorData }\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst successData = await resolveResponseData(\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 validSuccessData = await handleSchemaValidation(resolvedSchema, \"data\", {\n\t\t\t\t\tinputValue: successData,\n\t\t\t\t\tresponse,\n\t\t\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t\t\t});\n\n\t\t\t\tconst successContext = {\n\t\t\t\t\tbaseConfig,\n\t\t\t\t\tconfig,\n\t\t\t\t\tdata: validSuccessData,\n\t\t\t\t\toptions,\n\t\t\t\t\trequest,\n\t\t\t\t\tresponse,\n\t\t\t\t} satisfies SuccessContext;\n\n\t\t\t\tawait executeHooks(\n\t\t\t\t\toptions.onSuccess?.(successContext),\n\n\t\t\t\t\toptions.onResponse?.({ ...successContext, error: null })\n\t\t\t\t);\n\n\t\t\t\tconst successResult = resolveSuccessResult(successContext.data, {\n\t\t\t\t\tresponse: successContext.response,\n\t\t\t\t\tresultMode: options.resultMode,\n\t\t\t\t});\n\n\t\t\t\treturn successResult as never;\n\n\t\t\t\t// == Exhaustive Error handling\n\t\t\t} catch (error) {\n\t\t\t\tconst errorInfo = {\n\t\t\t\t\tcloneResponse: options.cloneResponse,\n\t\t\t\t\tresultMode: options.resultMode,\n\t\t\t\t} satisfies ErrorInfo;\n\n\t\t\t\tconst { errorDetails, errorResult } = resolveErrorResult(error, errorInfo);\n\n\t\t\t\tconst errorContext = {\n\t\t\t\t\tbaseConfig,\n\t\t\t\t\tconfig,\n\t\t\t\t\terror: errorDetails.error as never,\n\t\t\t\t\toptions,\n\t\t\t\t\trequest,\n\t\t\t\t\tresponse: errorDetails.response as never,\n\t\t\t\t} satisfies ErrorContext<{ ErrorData: unknown }>;\n\n\t\t\t\tconst shouldThrowOnError = Boolean(\n\t\t\t\t\tisFunction(options.throwOnError) ? options.throwOnError(errorContext) : options.throwOnError\n\t\t\t\t);\n\n\t\t\t\tconst hookInfo = {\n\t\t\t\t\terrorInfo,\n\t\t\t\t\tshouldThrowOnError,\n\t\t\t\t} satisfies ExecuteHookInfo;\n\n\t\t\t\tconst { handleRetry, shouldAttemptRetry } = createRetryManager(errorContext);\n\n\t\t\t\tconst handleRetryOrGetErrorResult = async () => {\n\t\t\t\t\tconst shouldRetry = await shouldAttemptRetry();\n\n\t\t\t\t\tif (shouldRetry) {\n\t\t\t\t\t\treturn handleRetry({\n\t\t\t\t\t\t\tcallApi,\n\t\t\t\t\t\t\tcallApiArgs: { config, initURL },\n\t\t\t\t\t\t\terrorContext,\n\t\t\t\t\t\t\thookInfo,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tif (shouldThrowOnError) {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn errorResult;\n\t\t\t\t};\n\n\t\t\t\tif (isValidationErrorInstance(error)) {\n\t\t\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t\t\t[options.onValidationError?.(errorContext), options.onError?.(errorContext)],\n\t\t\t\t\t\thookInfo\n\t\t\t\t\t);\n\n\t\t\t\t\treturn (hookError ?? (await handleRetryOrGetErrorResult())) as never;\n\t\t\t\t}\n\n\t\t\t\tif (isHTTPErrorInstance<TErrorData>(error)) {\n\t\t\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\toptions.onResponseError?.(errorContext),\n\t\t\t\t\t\t\toptions.onError?.(errorContext),\n\t\t\t\t\t\t\toptions.onResponse?.({ ...errorContext, data: null }),\n\t\t\t\t\t\t],\n\t\t\t\t\t\thookInfo\n\t\t\t\t\t);\n\n\t\t\t\t\treturn (hookError ?? (await handleRetryOrGetErrorResult())) as never;\n\t\t\t\t}\n\n\t\t\t\tlet message = (error as Error | undefined)?.message;\n\n\t\t\t\tif (error instanceof DOMException && error.name === \"AbortError\") {\n\t\t\t\t\tmessage = getAbortErrorMessage();\n\n\t\t\t\t\t!shouldThrowOnError && console.error(`${error.name}:`, message);\n\t\t\t\t}\n\n\t\t\t\tif (error instanceof DOMException && error.name === \"TimeoutError\") {\n\t\t\t\t\tmessage = `Request timed out after ${options.timeout}ms`;\n\n\t\t\t\t\t!shouldThrowOnError && console.error(`${error.name}:`, message);\n\t\t\t\t}\n\n\t\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t\t[options.onRequestError?.(errorContext), options.onError?.(errorContext)],\n\t\t\t\t\thookInfo\n\t\t\t\t);\n\n\t\t\t\treturn (hookError\n\t\t\t\t\t?? getCustomizedErrorResult(await handleRetryOrGetErrorResult(), { message })) as never;\n\n\t\t\t\t// == Removing the now unneeded AbortController from store\n\t\t\t} finally {\n\t\t\t\tremoveDedupeKeyFromCache();\n\t\t\t}\n\t\t};\n\n\t\treturn callApi;\n\t};\n\n\treturn createFetchClient;\n};\n\nexport const createFetchClient = createFetchClientWithContext();\n\nexport const callApi = createFetchClient();\n"],"mappings":";;;;;AA8DA,MAAM,oBAAoB,UAAsC,WAAW,MAAM,GAAG,OAAO,GAAG;AAI9F,MAAa,gBAAgB,OAC5B,SAC2C;AAC3C,KAAI,SAAS,OAAW;AAExB,KAAI,UAAU,KAAK,IAAI,WAAW,KAAK,IAAI,CAAC,SAAS,KAAK,EAAE;EAC3D,MAAM,YAAY,MAAM,iBAAiB,KAAK;AAE9C,MAAI,cAAc,OAAW;AAE7B,SAAO,EACN,eAAe,UAAU,aACzB;;AAGF,SAAQ,KAAK,MAAb;EACC,KAAK,SAAS;GACb,MAAM,CAAC,UAAU,YAAY,MAAM,QAAQ,IAAI,CAC9C,iBAAiB,KAAK,SAAS,EAC/B,iBAAiB,KAAK,SAAS,CAC/B,CAAC;AAEF,OAAI,aAAa,UAAa,aAAa,OAAW;AAEtD,UAAO,EACN,eAAe,SAAS,WAAW,KAAK,GAAG,SAAS,GAAG,WAAW,IAClE;;EAEF,KAAK,UAAU;GACd,MAAM,QAAQ,MAAM,iBAAiB,KAAK,MAAM;AAEhD,OAAI,UAAU,OAAW;AAEzB,UAAO,EACN,eAAe,UAAU,SACzB;;EAEF,KAAK,UAAU;GACd,MAAM,CAAC,QAAQ,SAAS,MAAM,QAAQ,IAAI,CACzC,iBAAiB,KAAK,O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AU,aAAa;KAC/B,QAAQ,aAAa;MAAE,GAAG;MAAc,MAAM;MAAM,CAAC;KACrD,EACD,SACA,IAEqB,MAAM,6BAA6B;IAG1D,IAAI,UAAW,OAA6B;AAE5C,QAAI,iBAAiB,gBAAgB,MAAM,SAAS,cAAc;AACjE,eAAU,sBAAsB;AAEhC,MAAC,sBAAsB,QAAQ,MAAM,GAAG,MAAM,KAAK,IAAI,QAAQ;;AAGhE,QAAI,iBAAiB,gBAAgB,MAAM,SAAS,gBAAgB;AACnE,eAAU,2BAA2B,QAAQ,QAAQ;AAErD,MAAC,sBAAsB,QAAQ,MAAM,GAAG,MAAM,KAAK,IAAI,QAAQ;;AAQhE,WALkB,MAAM,yBACvB,CAAC,QAAQ,iBAAiB,aAAa,EAAE,QAAQ,UAAU,aAAa,CAAC,EACzE,SACA,IAGG,yBAAyB,MAAM,6BAA6B,EAAE,EAAE,SAAS,CAAC;aAGrE;AACT,8BAA0B;;;AAI5B,SAAOA;;AAGR,QAAOF;;AAGR,MAAa,oBAAoB,8BAA8B;AAE/D,MAAa,UAAU,mBAAmB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["validatedResultObject: Prettify<\n\t\tPick<CallApiExtraOptions, (typeof extraOptionsToBeValidated)[number]>\n\t>","validatedResultObject: Prettify<\n\t\tPick<CallApiRequestOptions, (typeof requestOptionsToBeValidated)[number]>\n\t>","result: Record<string, unknown>","hookRegistries: HookRegistries","dedupeKey","dedupeCacheScopeKey","$GlobalRequestInfoCache","middlewareRegistries: MiddlewareRegistries","composedMiddleware: Middlewares[keyof Middlewares]","resolvedHooks: Hooks","resolvedMiddlewares: Middlewares","callApi","$GlobalRequestInfoCache: GlobalRequestInfoCache","createFetchClient","$LocalRequestInfoCache: RequestInfoCache","callApi"],"sources":["../src/auth.ts","../src/validation.ts","../src/url.ts","../src/utils/polyfills/combinedSignal.ts","../src/utils/polyfills/timeoutSignal.ts","../src/utils/common.ts","../src/result.ts","../src/hooks.ts","../src/stream.ts","../src/dedupe.ts","../src/middlewares.ts","../src/plugins.ts","../src/retry.ts","../src/createFetchClient.ts"],"sourcesContent":["/* eslint-disable perfectionist/sort-object-types -- Avoid Sorting for now */\n\nimport type { CallApiExtraOptions } from \"./types/common\";\nimport type { Awaitable } from \"./types/type-helpers\";\nimport { isFunction, isObject, isPromise } from \"./utils/guards\";\n\ntype PossibleAuthValue = Awaitable<string | null | undefined>;\n\ntype PossibleAuthValueOrGetter = PossibleAuthValue | (() => PossibleAuthValue);\n\n// export type BearerOrTokenAuth =\n// \t| {\n// \t\t\ttype?: \"Bearer\" | undefined;\n// \t\t\tbearer?: PossibleAuthValueOrGetter;\n// \t\t\ttoken?: never;\n// \t }\n// \t| {\n// \t\t\ttype?: \"Token\";\n// \t\t\tbearer?: never;\n// \t\t\ttoken?: PossibleAuthValueOrGetter;\n// \t };\n\nexport type BearerAuth = {\n\ttype: \"Bearer\";\n\tvalue: PossibleAuthValueOrGetter;\n};\n\nexport type TokenAuth = {\n\ttype: \"Token\";\n\tvalue: PossibleAuthValueOrGetter;\n};\n\nexport type BasicAuth = {\n\ttype: \"Basic\";\n\tusername: PossibleAuthValueOrGetter;\n\tpassword: PossibleAuthValueOrGetter;\n};\n\n/**\n * Custom auth\n *\n * @param prefix - prefix of the header\n * @param authValue - value of the header\n *\n * @example\n * ```ts\n * {\n * type: \"Custom\",\n * prefix: \"Token\",\n * authValue: \"token\"\n * }\n * ```\n */\nexport type CustomAuth = {\n\ttype: \"Custom\";\n\tprefix: PossibleAuthValueOrGetter;\n\tvalue: PossibleAuthValueOrGetter;\n};\n\n// eslint-disable-next-line perfectionist/sort-union-types -- Let the first one be first\nexport type AuthOption = PossibleAuthValueOrGetter | BearerAuth | TokenAuth | BasicAuth | CustomAuth;\n\nconst resolveAuthValue = (value: PossibleAuthValueOrGetter) => (isFunction(value) ? value() : value);\n\ntype AuthHeaderObject = { Authorization: string };\n\nexport const getAuthHeader = async (\n\tauth: CallApiExtraOptions[\"auth\"]\n): Promise<AuthHeaderObject | undefined> => {\n\tif (auth === undefined) return;\n\n\tif (isPromise(auth) || isFunction(auth) || !isObject(auth)) {\n\t\tconst authValue = await resolveAuthValue(auth);\n\n\t\tif (authValue === undefined) return;\n\n\t\treturn {\n\t\t\tAuthorization: `Bearer ${authValue}`,\n\t\t};\n\t}\n\n\tswitch (auth.type) {\n\t\tcase \"Basic\": {\n\t\t\tconst [username, password] = await Promise.all([\n\t\t\t\tresolveAuthValue(auth.username),\n\t\t\t\tresolveAuthValue(auth.password),\n\t\t\t]);\n\n\t\t\tif (username === undefined || password === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `Basic ${globalThis.btoa(`${username}:${password}`)}`,\n\t\t\t};\n\t\t}\n\t\tcase \"Bearer\": {\n\t\t\tconst value = await resolveAuthValue(auth.value);\n\n\t\t\tif (value === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `Bearer ${value}`,\n\t\t\t};\n\t\t}\n\t\tcase \"Custom\": {\n\t\t\tconst [prefix, value] = await Promise.all([\n\t\t\t\tresolveAuthValue(auth.prefix),\n\t\t\t\tresolveAuthValue(auth.value),\n\t\t\t]);\n\n\t\t\tif (value === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `${prefix} ${value}`,\n\t\t\t};\n\t\t}\n\n\t\tcase \"Token\": {\n\t\t\tconst value = await resolveAuthValue(auth.value);\n\n\t\t\tif (value === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `Token ${value}`,\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\tauth satisfies never;\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// default: {\n\t\t// \tconst [bearer, token] = await Promise.all([\n\t\t// \t\tresolveAuthValue(auth.bearer),\n\t\t// \t\tresolveAuthValue(auth.token),\n\t\t// \t]);\n\n\t\t// \tif (bearer !== undefined) {\n\t\t// \t\treturn { Authorization: `Bearer ${bearer}` };\n\t\t// \t}\n\n\t\t// \tif (token === undefined) return;\n\n\t\t// \treturn { Authorization: `Token ${token}` };\n\t\t// }\n\t}\n};\n","import type { AuthOption } from \"./auth\";\nimport { fallBackRouteSchemaKey, type FallBackRouteSchemaKey } from \"./constants/validation\";\nimport type {\n\tBaseCallApiExtraOptions,\n\tCallApiExtraOptions,\n\tCallApiRequestOptions,\n\tGlobalMeta,\n} from \"./types/common\";\nimport type { Body, HeadersOption, MethodUnion } from \"./types/conditional-types\";\nimport type { StandardSchemaV1 } from \"./types/standard-schema\";\nimport {\n\tdefineEnum,\n\ttype AnyFunction,\n\ttype AnyString,\n\ttype Awaitable,\n\ttype Prettify,\n\ttype UnionToIntersection,\n} from \"./types/type-helpers\";\nimport {\n\tatSymbol,\n\textractMethodFromURL,\n\tnormalizeURL,\n\ttype AtSymbol,\n\ttype Params,\n\ttype Query,\n} from \"./url\";\nimport { toArray } from \"./utils/common\";\nimport { ValidationError } from \"./utils/external/error\";\nimport { isFunction, isObject } from \"./utils/guards\";\n\ntype ResultVariant = \"infer-input\" | \"infer-output\";\n\nexport type InferSchemaResult<TSchema, TFallbackResult, TResultVariant extends ResultVariant> =\n\t// == Checking for undefined first and returning fallback to avoid type errors when passing the config around (weird tbh)\n\tundefined extends TSchema ? TFallbackResult\n\t: TSchema extends StandardSchemaV1 ?\n\t\tTResultVariant extends \"infer-input\" ?\n\t\t\tStandardSchemaV1.InferInput<TSchema>\n\t\t:\tStandardSchemaV1.InferOutput<TSchema>\n\t: TSchema extends AnyFunction<infer TResult> ? Awaited<TResult>\n\t: TFallbackResult;\n\nexport type InferSchemaOutput<TSchema, TFallbackResult = unknown> = InferSchemaResult<\n\tTSchema,\n\tTFallbackResult,\n\t\"infer-output\"\n>;\n\nexport type InferSchemaInput<TSchema, TFallbackResult = unknown> = InferSchemaResult<\n\tTSchema,\n\tTFallbackResult,\n\t\"infer-input\"\n>;\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: toArray(error) as never, value: undefined };\n\t}\n};\n\nexport const standardSchemaParser = async <\n\tTFullSchema extends CallApiSchema,\n\tTSchemaName extends keyof CallApiSchema,\n\tTSchema extends NonNullable<TFullSchema[TSchemaName]>,\n>(\n\tfullSchema: TFullSchema | undefined,\n\tschemaName: TSchemaName,\n\toptions: { inputValue: InferSchemaInput<TSchema>; response?: Response | null }\n): Promise<InferSchemaOutput<TSchema>> => {\n\tconst { inputValue, response } = options;\n\n\tconst schema = fullSchema?.[schemaName];\n\n\tif (!schema) {\n\t\treturn inputValue as never;\n\t}\n\n\tconst result =\n\t\tisFunction(schema) ?\n\t\t\tawait handleValidatorFunction(schema, inputValue)\n\t\t:\tawait schema[\"~standard\"].validate(inputValue);\n\n\t// == If the `issues` field exists, it means the validation failed\n\n\tif (result.issues) {\n\t\tthrow new ValidationError({\n\t\t\tissueCause: schemaName,\n\t\t\tissues: result.issues,\n\t\t\tresponse: response ?? null,\n\t\t});\n\t}\n\n\treturn result.value as never;\n};\n\ntype BooleanObject = {\n\t[Key in keyof CallApiSchema]: boolean;\n};\n\nexport interface CallApiSchemaConfig {\n\t/**\n\t * The base url of the schema. By default it's the baseURL of the callApi instance.\n\t */\n\tbaseURL?: \"\" | AnyString;\n\n\t/**\n\t * Disables runtime validation for the schema.\n\t */\n\tdisableRuntimeValidation?: boolean | BooleanObject;\n\n\t/**\n\t * If `true`, the original input value will be used instead of the transformed/validated output.\n\t *\n\t * When true, the original input is returned unchanged after validation, ignoring any schema-level\n\t * transformations such as type coercion, default values, or field mapping. Only the validation\n\t * step is executed; the resulting value is discarded in favor of the raw input.\n\t */\n\tdisableRuntimeValidationTransform?: boolean | BooleanObject;\n\n\t/**\n\t * Optional url prefix that will be substituted for the `baseURL` of the schemaConfig at runtime.\n\t *\n\t * Enables a short, stable prefix for routes while keeping the full `baseURL` centralized in config.\n\t * Keeps route definitions concise and shields them from changes to the underlying base URL.\n\t */\n\tprefix?: \"\" | AnyString;\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 and the runtime.\n\t * - Attempting to call routes not defined in the schema will result in both type errors and runtime validation 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 */\n\tstrict?: boolean;\n}\n\nexport interface CallApiSchema {\n\tauth?:\n\t\t| StandardSchemaV1<AuthOption | undefined>\n\t\t| ((auth: AuthOption) => Awaitable<AuthOption | undefined>);\n\n\t/**\n\t * The schema to use for validating the request body.\n\t */\n\tbody?: StandardSchemaV1<Body | undefined> | ((body: Body) => Awaitable<Body | undefined>);\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 | undefined>);\n\n\t/**\n\t * The schema to use for validating the meta option.\n\t */\n\tmeta?:\n\t\t| StandardSchemaV1<GlobalMeta | undefined>\n\t\t| ((meta: GlobalMeta) => Awaitable<GlobalMeta | undefined>);\n\n\t/**\n\t * The schema to use for validating the request method.\n\t */\n\tmethod?:\n\t\t| StandardSchemaV1<MethodUnion | undefined>\n\t\t| ((method: MethodUnion) => Awaitable<MethodUnion | undefined>);\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 | undefined>);\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 | undefined>);\n}\n\nexport const routeKeyMethods = defineEnum([\"delete\", \"get\", \"patch\", \"post\", \"put\"]);\n\nexport type RouteKeyMethods = (typeof routeKeyMethods)[number];\n\nexport type RouteKeyMethodsURLUnion = `${AtSymbol}${RouteKeyMethods}/`;\n\nexport type BaseSchemaRouteKeyPrefixes = FallBackRouteSchemaKey | RouteKeyMethodsURLUnion;\n\nexport type BaseCallApiSchemaRoutes = Partial<\n\tRecord<AnyString | BaseSchemaRouteKeyPrefixes, CallApiSchema>\n>;\n\nexport type BaseCallApiSchemaAndConfig = {\n\tconfig?: CallApiSchemaConfig;\n\troutes: BaseCallApiSchemaRoutes;\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 handleSchemaValidation = async <\n\tTFullSchema extends CallApiSchema,\n\tTSchemaName extends keyof CallApiSchema,\n\tTSchema extends NonNullable<TFullSchema[TSchemaName]>,\n>(\n\tfullSchema: TFullSchema | undefined,\n\tschemaName: TSchemaName,\n\tvalidationOptions: ValidationOptions<TSchema>\n): Promise<InferSchemaOutput<TSchema>> => {\n\tconst { inputValue, response, schemaConfig } = validationOptions;\n\n\tconst disableRuntimeValidationBooleanObject =\n\t\tisObject(schemaConfig?.disableRuntimeValidation) ? schemaConfig.disableRuntimeValidation : {};\n\n\tconst shouldDisableRuntimeValidation =\n\t\tschemaConfig?.disableRuntimeValidation === true\n\t\t|| disableRuntimeValidationBooleanObject[schemaName] === true;\n\n\tif (shouldDisableRuntimeValidation) {\n\t\treturn inputValue as never;\n\t}\n\n\tconst validResult = await standardSchemaParser(fullSchema, schemaName, { inputValue, response });\n\n\tconst disableResultApplicationBooleanObject =\n\t\tisObject(schemaConfig?.disableRuntimeValidationTransform) ?\n\t\t\tschemaConfig.disableRuntimeValidationTransform\n\t\t:\t{};\n\n\tconst shouldDisableResultApplication =\n\t\tschemaConfig?.disableRuntimeValidationTransform === true\n\t\t|| disableResultApplicationBooleanObject[schemaName] === true;\n\n\tif (shouldDisableResultApplication) {\n\t\treturn inputValue as never;\n\t}\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> =\n\ttrue extends TComputedIsUnionEqualToNever ? []\n\t:\tPush<UnionToTuple<Exclude<TUnion, TComputedLastUnion>>, TComputedLastUnion>;\n\nexport type Tuple<TTuple, TArray extends TTuple[] = []> =\n\tUnionToTuple<TTuple>[\"length\"] extends TArray[\"length\"] ? [...TArray]\n\t:\tTuple<TTuple, [TTuple, ...TArray]>;\n\nconst extraOptionsToBeValidated = [\"meta\", \"params\", \"query\", \"auth\"] satisfies Tuple<\n\tExtract<keyof CallApiSchema, keyof CallApiExtraOptions>\n>;\n\ntype ExtraOptionsValidationOptions = {\n\toptions: CallApiExtraOptions;\n\tschema: CallApiSchema | undefined;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nconst handleExtraOptionsValidation = async (validationOptions: ExtraOptionsValidationOptions) => {\n\tconst { options, schema, schemaConfig } = validationOptions;\n\n\tconst validationResultArray = await Promise.all(\n\t\textraOptionsToBeValidated.map((schemaName) =>\n\t\t\thandleSchemaValidation(schema, schemaName, {\n\t\t\t\tinputValue: options[schemaName],\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, schemaName] of extraOptionsToBeValidated.entries()) {\n\t\tconst validationResult = validationResultArray[index];\n\n\t\tif (validationResult === undefined) continue;\n\n\t\tvalidatedResultObject[schemaName] = 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\trequest: CallApiRequestOptions;\n\tschema: CallApiSchema | undefined;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nconst handleRequestOptionsValidation = async (validationOptions: RequestOptionsValidationOptions) => {\n\tconst { request, schema, schemaConfig } = validationOptions;\n\n\tconst validationResultArray = await Promise.all(\n\t\trequestOptionsToBeValidated.map((schemaName) => {\n\t\t\treturn handleSchemaValidation(schema, schemaName, {\n\t\t\t\tinputValue: request[schemaName],\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 handleConfigValidation = async (\n\tvalidationOptions: GetResolvedSchemaContext\n\t\t& Omit<ExtraOptionsValidationOptions & RequestOptionsValidationOptions, \"schema\" | \"schemaConfig\">\n) => {\n\tconst { baseExtraOptions, currentRouteSchemaKey, extraOptions, options, request } = validationOptions;\n\n\tconst { currentRouteSchema, resolvedSchema } = getResolvedSchema({\n\t\tbaseExtraOptions,\n\t\tcurrentRouteSchemaKey,\n\t\textraOptions,\n\t});\n\n\tconst resolvedSchemaConfig = getResolvedSchemaConfig({ baseExtraOptions, extraOptions });\n\n\tif (resolvedSchemaConfig?.strict === true && !currentRouteSchema) {\n\t\tthrow new ValidationError({\n\t\t\tissueCause: \"schemaConfig-(strict)\",\n\t\t\tissues: [{ message: `Strict Mode - No schema found for route '${currentRouteSchemaKey}' ` }],\n\t\t\tresponse: null,\n\t\t});\n\t}\n\n\tconst [extraOptionsValidationResult, requestOptionsValidationResult] = await Promise.all([\n\t\thandleExtraOptionsValidation({\n\t\t\toptions,\n\t\t\tschema: resolvedSchema,\n\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t}),\n\t\thandleRequestOptionsValidation({\n\t\t\trequest,\n\t\t\tschema: resolvedSchema,\n\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t}),\n\t]);\n\n\treturn {\n\t\textraOptionsValidationResult,\n\t\trequestOptionsValidationResult,\n\t\tresolvedSchema,\n\t\tresolvedSchemaConfig,\n\t};\n};\n\ntype GetResolvedSchemaContext = {\n\tbaseExtraOptions: BaseCallApiExtraOptions;\n\tcurrentRouteSchemaKey: string;\n\textraOptions: CallApiExtraOptions;\n};\n\nexport const getResolvedSchema = (context: GetResolvedSchemaContext) => {\n\tconst { baseExtraOptions, currentRouteSchemaKey, extraOptions } = context;\n\n\tconst fallbackRouteSchema = baseExtraOptions.schema?.routes[fallBackRouteSchemaKey];\n\tconst currentRouteSchema = baseExtraOptions.schema?.routes[currentRouteSchemaKey];\n\n\tconst resolvedRouteSchema = {\n\t\t...fallbackRouteSchema,\n\t\t// == Current route schema takes precedence over fallback route schema\n\t\t...currentRouteSchema,\n\t} satisfies CallApiSchema as CallApiSchema | undefined;\n\n\tconst resolvedSchema =\n\t\tisFunction(extraOptions.schema) ?\n\t\t\textraOptions.schema({\n\t\t\t\tbaseSchemaRoutes: baseExtraOptions.schema?.routes ?? {},\n\t\t\t\tcurrentRouteSchema: resolvedRouteSchema ?? {},\n\t\t\t\tcurrentRouteSchemaKey,\n\t\t\t})\n\t\t:\t(extraOptions.schema ?? resolvedRouteSchema);\n\n\treturn { currentRouteSchema, resolvedSchema };\n};\n\nexport const getResolvedSchemaConfig = (\n\tcontext: Omit<GetResolvedSchemaContext, \"currentRouteSchemaKey\">\n) => {\n\tconst { baseExtraOptions, extraOptions } = context;\n\n\tconst resolvedSchemaConfig =\n\t\tisFunction(extraOptions.schemaConfig) ?\n\t\t\textraOptions.schemaConfig({ baseSchemaConfig: baseExtraOptions.schema?.config ?? {} })\n\t\t:\t(extraOptions.schemaConfig ?? baseExtraOptions.schema?.config);\n\n\treturn resolvedSchemaConfig;\n};\n\nconst removeLeadingSlash = (value: string) => (value.startsWith(\"/\") ? value.slice(1) : value);\n\nexport const getCurrentRouteSchemaKeyAndMainInitURL = (\n\tcontext: Pick<GetResolvedSchemaContext, \"baseExtraOptions\" | \"extraOptions\"> & { initURL: string }\n) => {\n\tconst { baseExtraOptions, extraOptions, initURL } = context;\n\n\tconst schemaConfig = getResolvedSchemaConfig({ baseExtraOptions, extraOptions });\n\n\tlet currentRouteSchemaKey = initURL;\n\tlet mainInitURL = initURL;\n\n\tconst methodFromURL = extractMethodFromURL(initURL);\n\n\tconst pathWithoutMethod = normalizeURL(initURL, { retainLeadingSlashForRelativeURLs: false });\n\n\tconst prefixWithoutLeadingSlash = schemaConfig?.prefix && removeLeadingSlash(schemaConfig.prefix);\n\n\tif (\n\t\tschemaConfig?.prefix\n\t\t&& prefixWithoutLeadingSlash\n\t\t&& pathWithoutMethod.startsWith(prefixWithoutLeadingSlash)\n\t) {\n\t\tconst restOfPathWithoutPrefix = pathWithoutMethod.slice(prefixWithoutLeadingSlash.length);\n\n\t\tcurrentRouteSchemaKey =\n\t\t\tmethodFromURL ?\n\t\t\t\t`${atSymbol}${methodFromURL}/${removeLeadingSlash(restOfPathWithoutPrefix)}`\n\t\t\t:\trestOfPathWithoutPrefix;\n\n\t\tconst pathWithReplacedPrefix = pathWithoutMethod.replace(\n\t\t\tprefixWithoutLeadingSlash,\n\t\t\tschemaConfig.baseURL ?? \"\"\n\t\t);\n\n\t\tmainInitURL =\n\t\t\tmethodFromURL ?\n\t\t\t\t`${atSymbol}${methodFromURL}/${removeLeadingSlash(pathWithReplacedPrefix)}`\n\t\t\t:\tpathWithReplacedPrefix;\n\t}\n\n\tif (schemaConfig?.baseURL && pathWithoutMethod.startsWith(schemaConfig.baseURL)) {\n\t\tconst restOfPathWithoutBaseURL = pathWithoutMethod.slice(schemaConfig.baseURL.length);\n\n\t\tcurrentRouteSchemaKey =\n\t\t\tmethodFromURL ?\n\t\t\t\t`${atSymbol}${methodFromURL}/${removeLeadingSlash(restOfPathWithoutBaseURL)}`\n\t\t\t:\trestOfPathWithoutBaseURL;\n\t}\n\n\treturn { currentRouteSchemaKey, mainInitURL };\n};\n","import type { CallApiExtraOptions } from \"./types/common\";\nimport type { AnyString, UnmaskType } from \"./types/type-helpers\";\nimport { toQueryString } from \"./utils/external/body\";\nimport { isArray } from \"./utils/guards\";\nimport { type RouteKeyMethodsURLUnion, routeKeyMethods } from \"./validation\";\n\nexport const slash = \"/\";\nconst colon = \":\";\nconst openBrace = \"{\";\nconst closeBrace = \"}\";\n\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 urlParts = newUrl.split(slash);\n\n\t\t// == Find all parameters in order (both :param and {param} patterns)\n\t\tconst matchedParamsArray = urlParts.filter(\n\t\t\t(part) => part.startsWith(colon) || (part.startsWith(openBrace) && part.endsWith(closeBrace))\n\t\t);\n\n\t\tfor (const [paramIndex, matchedParam] of matchedParamsArray.entries()) {\n\t\t\tconst stringParamValue = String(params[paramIndex]);\n\t\t\tnewUrl = newUrl.replace(matchedParam, stringParamValue);\n\t\t}\n\n\t\treturn newUrl;\n\t}\n\n\t// == Handle object params - replace both :param and {param} patterns\n\tfor (const [paramKey, paramValue] of Object.entries(params)) {\n\t\tconst colonPattern = `${colon}${paramKey}` as const;\n\t\tconst bracePattern = `${openBrace}${paramKey}${closeBrace}` as const;\n\t\tconst stringValue = String(paramValue);\n\n\t\tnewUrl = newUrl.replace(colonPattern, stringValue);\n\t\tnewUrl = newUrl.replace(bracePattern, stringValue);\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\n/**\n * @description Extracts the HTTP method from method-prefixed route patterns.\n *\n * Analyzes URLs that start with method modifiers (e.g., \"@get/\", \"@post/\") and extracts\n * the HTTP method for use in API requests. This enables method specification directly\n * in route definitions.\n *\n * @param initURL - The URL string to analyze for method modifiers\n * @returns The extracted HTTP method (lowercase) if found, otherwise undefined\n *\n * @example\n * ```typescript\n * extractMethodFromURL(\"@get/users\"); // Returns: \"get\"\n * extractMethodFromURL(\"@post/users\"); // Returns: \"post\"\n * ```\n */\nexport const extractMethodFromURL = (initURL: string | undefined) => {\n\tif (!initURL?.startsWith(\"@\")) return;\n\n\tconst methodFromURL = routeKeyMethods.find((method) =>\n\t\tinitURL.startsWith(`${atSymbol}${method}${slash}`)\n\t);\n\n\tif (!methodFromURL) return;\n\n\treturn methodFromURL;\n};\n\ntype NormalizeURLOptions = {\n\tretainLeadingSlashForRelativeURLs?: boolean;\n};\n\nexport const atSymbol = \"@\";\nexport type AtSymbol = typeof atSymbol;\n\nexport const normalizeURL = (initURL: string, options: NormalizeURLOptions = {}) => {\n\tconst { retainLeadingSlashForRelativeURLs = true } = options;\n\n\tconst methodFromURL = extractMethodFromURL(initURL);\n\n\tif (!methodFromURL) {\n\t\treturn initURL;\n\t}\n\n\tconst normalizedURL =\n\t\tretainLeadingSlashForRelativeURLs && !initURL.includes(\"http\") ?\n\t\t\tinitURL.replace(`${atSymbol}${methodFromURL}`, \"\")\n\t\t:\tinitURL.replace(`${atSymbol}${methodFromURL}${slash}`, \"\");\n\n\treturn normalizedURL;\n};\n\ntype GetFullURLOptions = {\n\t/** Base URL to prepend to relative URLs */\n\tbaseURL: string | undefined;\n\t/** Initial URL pattern that may contain parameters and method modifiers */\n\tinitURL: string;\n\t/** Parameters to substitute into the URL path */\n\tparams: CallApiExtraOptions[\"params\"];\n\t/** Query parameters to append to the URL */\n\tquery: CallApiExtraOptions[\"query\"];\n};\n\nconst getFullURL = (initURL: string, baseURL: string | undefined) => {\n\tif (!baseURL || initURL.startsWith(\"http\")) {\n\t\treturn initURL;\n\t}\n\n\tconst shouldAddSlash = initURL.length > 0 && !initURL.startsWith(slash) && !baseURL.endsWith(slash);\n\n\treturn shouldAddSlash ? `${baseURL}${slash}${initURL}` : `${baseURL}${initURL}`;\n};\n\nexport const getFullAndNormalizedURL = (options: GetFullURLOptions) => {\n\tconst { baseURL, initURL, params, query } = options;\n\n\tconst normalizedInitURL = normalizeURL(initURL);\n\n\tconst initURLWithParams = mergeUrlWithParams(normalizedInitURL, params);\n\n\tconst initURLWithParamsAndQuery = mergeUrlWithQuery(initURLWithParams, query);\n\n\tconst fullURL = getFullURL(initURLWithParamsAndQuery, baseURL);\n\n\tif (!URL.canParse(fullURL)) {\n\t\tconst errorMessage =\n\t\t\t!baseURL ?\n\t\t\t\t`Invalid URL '${initURL}'. Are you passing a relative url to CallApi without setting the 'baseURL' option?`\n\t\t\t:\t`Invalid URL '${fullURL}'. Please validate that you are passing the correct url.`;\n\n\t\tconsole.error(errorMessage);\n\t}\n\n\treturn {\n\t\tfullURL,\n\t\tnormalizedInitURL,\n\t};\n};\n\nexport type AllowedQueryParamValues = UnmaskType<boolean | number | string>;\n\nexport type RecordStyleParams = UnmaskType<Record<string, AllowedQueryParamValues>>;\n\nexport type TupleStyleParams = UnmaskType<AllowedQueryParamValues[]>;\n\nexport type Params = UnmaskType<RecordStyleParams | TupleStyleParams>;\n\nexport type Query = UnmaskType<Record<string, AllowedQueryParamValues>>;\n\nexport type InitURLOrURLObject = AnyString | RouteKeyMethodsURLUnion | URL;\n\nexport interface URLOptions {\n\t/**\n\t * Base URL for all API requests. Will only be prepended to relative URLs.\n\t *\n\t * Absolute URLs (starting with http/https) will not be prepended by the baseURL.\n\t *\n\t * @example\n\t * ```ts\n\t * // Set base URL for all requests\n\t * baseURL: \"https://api.example.com/v1\"\n\t *\n\t * // Then use relative URLs in requests\n\t * callApi(\"/users\") // → https://api.example.com/v1/users\n\t * callApi(\"/posts/123\") // → https://api.example.com/v1/posts/123\n\t *\n\t * // Environment-specific base URLs\n\t * baseURL: process.env.NODE_ENV === \"production\"\n\t * ? \"https://api.example.com\"\n\t * : \"http://localhost:3000/api\"\n\t * ```\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Resolved request URL after processing baseURL, parameters, and query strings (readonly)\n\t *\n\t * This is the final URL that will be used for the HTTP request, computed from\n\t * baseURL, initURL, params, and query parameters.\n\t *\n\t */\n\treadonly fullURL?: string;\n\n\t/**\n\t * The original URL string passed to the callApi instance (readonly)\n\t *\n\t * This preserves the original URL as provided, including any method modifiers like \"@get/\" or \"@post/\".\n\t *\n\t */\n\treadonly initURL?: string;\n\n\t/**\n\t * The URL string after normalization, with method modifiers removed(readonly)\n\t *\n\t * Method modifiers like \"@get/\", \"@post/\" are stripped to create a clean URL\n\t * for parameter substitution and final URL construction.\n\t *\n\t */\n\treadonly initURLNormalized?: string;\n\n\t/**\n\t * Parameters to be substituted into URL path segments.\n\t *\n\t * Supports both object-style (named parameters) and array-style (positional parameters)\n\t * for flexible URL parameter substitution.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Object-style parameters (recommended)\n\t * const namedParams: URLOptions = {\n\t * initURL: \"/users/:userId/posts/:postId\",\n\t * params: { userId: \"123\", postId: \"456\" }\n\t * };\n\t * // Results in: /users/123/posts/456\n\t *\n\t * // Array-style parameters (positional)\n\t * const positionalParams: URLOptions = {\n\t * initURL: \"/users/:userId/posts/:postId\",\n\t * params: [\"123\", \"456\"] // Maps in order: userId=123, postId=456\n\t * };\n\t * // Results in: /users/123/posts/456\n\t *\n\t * // Single parameter\n\t * const singleParam: URLOptions = {\n\t * initURL: \"/users/:id\",\n\t * params: { id: \"user-123\" }\n\t * };\n\t * // Results in: /users/user-123\n\t * ```\n\t */\n\tparams?: Params;\n\n\t/**\n\t * Query parameters to append to the URL as search parameters.\n\t *\n\t * These will be serialized into the URL query string using standard\n\t * URL encoding practices.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Basic query parameters\n\t * const queryOptions: URLOptions = {\n\t * initURL: \"/users\",\n\t * query: {\n\t * page: 1,\n\t * limit: 10,\n\t * search: \"john doe\",\n\t * active: true\n\t * }\n\t * };\n\t * // Results in: /users?page=1&limit=10&search=john%20doe&active=true\n\t *\n\t * // Filtering and sorting\n\t * const filterOptions: URLOptions = {\n\t * initURL: \"/products\",\n\t * query: {\n\t * category: \"electronics\",\n\t * minPrice: 100,\n\t * maxPrice: 500,\n\t * sortBy: \"price\",\n\t * order: \"asc\"\n\t * }\n\t * };\n\t * // Results in: /products?category=electronics&minPrice=100&maxPrice=500&sortBy=price&order=asc\n\t * ```\n\t */\n\tquery?: Query;\n}\n","export const createCombinedSignalPolyfill = (signals: AbortSignal[]) => {\n\tconst controller = new AbortController();\n\n\tconst handleAbort = (actualSignal: AbortSignal) => {\n\t\tif (controller.signal.aborted) return;\n\n\t\tcontroller.abort(actualSignal.reason);\n\t};\n\n\tfor (const actualSignal of signals) {\n\t\tif (actualSignal.aborted) {\n\t\t\thandleAbort(actualSignal);\n\t\t\tbreak;\n\t\t}\n\n\t\tactualSignal.addEventListener(\"abort\", () => handleAbort(actualSignal), {\n\t\t\tsignal: controller.signal,\n\t\t});\n\t}\n\n\treturn controller.signal;\n};\n","export const createTimeoutSignalPolyfill = (milliseconds: number) => {\n\tconst controller = new AbortController();\n\n\tconst reason = new DOMException(\"Request timed out\", \"TimeoutError\");\n\n\tconst timeout = setTimeout(() => controller.abort(reason), milliseconds);\n\n\tcontroller.signal.addEventListener(\"abort\", () => clearTimeout(timeout));\n\n\treturn controller.signal;\n};\n","import { getAuthHeader } from \"../auth\";\nimport { fetchSpecificKeys } from \"../constants/common\";\nimport { extraOptionDefaults, requestOptionDefaults } from \"../constants/defaults\";\nimport type { RequestContext } from \"../hooks\";\nimport type { Middlewares } from \"../middlewares\";\nimport type { BaseCallApiExtraOptions, CallApiExtraOptions, CallApiRequestOptions } from \"../types/common\";\nimport type { InferHeadersOption } from \"../types/conditional-types\";\nimport type { DistributiveOmit } from \"../types/type-helpers\";\nimport { extractMethodFromURL } from \"../url\";\nimport type { CallApiSchema } from \"../validation\";\nimport { toQueryString } from \"./external\";\nimport {\n\tisArray,\n\tisFunction,\n\tisPlainObject,\n\tisQueryString,\n\tisSerializableObject,\n\tisValidJsonString,\n} from \"./guards\";\nimport { createCombinedSignalPolyfill, createTimeoutSignalPolyfill } from \"./polyfills\";\n\nexport const omitKeys = <\n\tTObject extends Record<string, unknown>,\n\tconst TOmitArray extends Array<keyof TObject> | ReadonlyArray<keyof TObject>,\n>(\n\tinitialObject: TObject,\n\tkeysToOmit: TOmitArray\n) => {\n\tconst updatedObject = {} as Record<string, unknown>;\n\n\tconst keysToOmitSet = new Set(keysToOmit);\n\n\tfor (const [key, value] of Object.entries(initialObject)) {\n\t\tif (!keysToOmitSet.has(key)) {\n\t\t\tupdatedObject[key] = value;\n\t\t}\n\t}\n\n\treturn updatedObject as DistributiveOmit<TObject, TOmitArray[number]>;\n};\n\nexport const pickKeys = <\n\tTObject extends Record<string, unknown>,\n\tconst TPickArray extends Array<keyof TObject> | ReadonlyArray<keyof TObject>,\n>(\n\tinitialObject: TObject,\n\tkeysToPick: TPickArray\n) => {\n\tconst updatedObject = {} as Record<string, unknown>;\n\n\tconst keysToPickSet = new Set(keysToPick);\n\n\tfor (const [key, value] of Object.entries(initialObject)) {\n\t\tif (keysToPickSet.has(key)) {\n\t\t\tupdatedObject[key] = value;\n\t\t}\n\t}\n\n\treturn updatedObject as Pick<TObject, TPickArray[number]>;\n};\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport const splitBaseConfig = (baseConfig: Record<string, any>) =>\n\t[\n\t\tpickKeys(baseConfig, fetchSpecificKeys) as CallApiRequestOptions,\n\t\tomitKeys(baseConfig, fetchSpecificKeys) as BaseCallApiExtraOptions,\n\t] as const;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport const splitConfig = (config: Record<string, any>) =>\n\t[\n\t\tpickKeys(config, fetchSpecificKeys) as CallApiRequestOptions,\n\t\tomitKeys(config, fetchSpecificKeys) as CallApiExtraOptions,\n\t] as const;\n\nexport const objectifyHeaders = (headers: CallApiRequestOptions[\"headers\"]) => {\n\tif (!headers) {\n\t\treturn {};\n\t}\n\n\tif (isPlainObject(headers)) {\n\t\treturn headers as Record<string, string>;\n\t}\n\n\treturn Object.fromEntries(headers);\n};\n\nexport type GetResolvedHeadersOptions = {\n\tbaseHeaders: CallApiRequestOptions[\"headers\"];\n\theaders: InferHeadersOption<CallApiSchema>[\"headers\"];\n};\n\nexport const getResolvedHeaders = (options: GetResolvedHeadersOptions) => {\n\tconst { baseHeaders, headers } = options;\n\n\tconst resolvedHeaders =\n\t\tisFunction(headers) ?\n\t\t\theaders({ baseHeaders: objectifyHeaders(baseHeaders) })\n\t\t:\t(headers ?? baseHeaders);\n\n\treturn objectifyHeaders(resolvedHeaders);\n};\n\nconst detectContentTypeHeader = (body: CallApiRequestOptions[\"body\"]) => {\n\tif (isQueryString(body)) {\n\t\treturn { \"Content-Type\": \"application/x-www-form-urlencoded\" };\n\t}\n\n\tif (isSerializableObject(body) || isValidJsonString(body)) {\n\t\treturn { Accept: \"application/json\", \"Content-Type\": \"application/json\" };\n\t}\n\n\treturn null;\n};\n\nexport type GetHeadersOptions = {\n\tauth: CallApiExtraOptions[\"auth\"];\n\tbody: CallApiRequestOptions[\"body\"];\n\tresolvedHeaders: CallApiRequestOptions[\"headers\"];\n};\n\nexport const getHeaders = async (options: GetHeadersOptions) => {\n\tconst { auth, body, resolvedHeaders } = options;\n\n\tconst authHeaderObject = await getAuthHeader(auth);\n\n\tconst resolvedHeadersObject = objectifyHeaders(resolvedHeaders);\n\n\tconst hasExistingContentType =\n\t\tObject.hasOwn(resolvedHeadersObject, \"Content-Type\")\n\t\t|| Object.hasOwn(resolvedHeadersObject, \"content-type\");\n\n\tif (!hasExistingContentType) {\n\t\tconst contentTypeHeader = detectContentTypeHeader(body);\n\t\tcontentTypeHeader && Object.assign(resolvedHeadersObject, contentTypeHeader);\n\t}\n\n\tconst headersObject: Record<string, string> = {\n\t\t...authHeaderObject,\n\t\t...resolvedHeadersObject,\n\t};\n\n\treturn headersObject;\n};\n\nexport type GetMethodContext = {\n\t/** The URL string that may contain method modifiers like \"@get/\" or \"@post/\" */\n\tinitURL: string | undefined;\n\t/** Explicitly specified HTTP method */\n\tmethod: CallApiRequestOptions[\"method\"];\n};\n\nexport const getMethod = (ctx: GetMethodContext) => {\n\tconst { initURL, method } = ctx;\n\n\treturn (\n\t\tmethod?.toUpperCase() ?? extractMethodFromURL(initURL)?.toUpperCase() ?? requestOptionDefaults.method\n\t);\n};\n\nexport type GetBodyOptions = Pick<GetHeadersOptions, \"body\" | \"resolvedHeaders\"> & {\n\tbodySerializer: CallApiExtraOptions[\"bodySerializer\"];\n};\n\nexport const getBody = (options: GetBodyOptions) => {\n\tconst { body, bodySerializer, resolvedHeaders } = options;\n\n\tconst headers = new Headers(resolvedHeaders as Record<string, string>);\n\n\tconst existingContentType = headers.get(\"content-type\");\n\n\tif (!existingContentType && isSerializableObject(body)) {\n\t\tconst selectedBodySerializer = bodySerializer ?? extraOptionDefaults.bodySerializer;\n\n\t\treturn selectedBodySerializer(body);\n\t}\n\n\tif (existingContentType === \"application/x-www-form-urlencoded\" && isSerializableObject(body)) {\n\t\treturn toQueryString(body as Record<string, string>);\n\t}\n\n\treturn body;\n};\n\nexport const getInitFetchImpl = (customFetchImpl: CallApiExtraOptions[\"customFetchImpl\"]) => {\n\tif (customFetchImpl) {\n\t\treturn customFetchImpl;\n\t}\n\n\tif (typeof globalThis !== \"undefined\" && isFunction(globalThis.fetch)) {\n\t\treturn globalThis.fetch;\n\t}\n\n\tthrow new Error(\"No fetch implementation found\");\n};\n\nexport const getFetchImpl = (context: {\n\tcustomFetchImpl: CallApiExtraOptions[\"customFetchImpl\"];\n\tfetchMiddleware: Middlewares[\"fetchMiddleware\"];\n\trequestContext: RequestContext;\n}) => {\n\tconst { customFetchImpl, fetchMiddleware, requestContext } = context;\n\n\tconst initFetchImpl = getInitFetchImpl(customFetchImpl);\n\n\tconst resolvedFetchImpl =\n\t\tfetchMiddleware ? fetchMiddleware({ ...requestContext, fetchImpl: initFetchImpl }) : initFetchImpl;\n\n\treturn resolvedFetchImpl;\n};\n\nexport const waitFor = (delay: number) => {\n\tif (delay === 0) return;\n\n\tconst promise = new Promise((resolve) => setTimeout(resolve, delay));\n\n\treturn promise;\n};\n\nexport const createCombinedSignal = (...signals: Array<AbortSignal | null | undefined>) => {\n\tconst cleanedSignals = signals.filter((signal) => signal != null);\n\n\tif (!(\"any\" in AbortSignal)) {\n\t\treturn createCombinedSignalPolyfill(cleanedSignals);\n\t}\n\n\tconst combinedSignal = AbortSignal.any(cleanedSignals);\n\n\treturn combinedSignal;\n};\n\nexport const createTimeoutSignal = (milliseconds: number | null | undefined) => {\n\tif (milliseconds == null) {\n\t\treturn null;\n\t}\n\n\tif (!(\"timeout\" in AbortSignal)) {\n\t\treturn createTimeoutSignalPolyfill(milliseconds);\n\t}\n\n\treturn AbortSignal.timeout(milliseconds);\n};\n\nexport const deterministicHashFn = (value: unknown): string => {\n\treturn JSON.stringify(value, (_, val: unknown) => {\n\t\tif (!isPlainObject(val)) {\n\t\t\treturn val;\n\t\t}\n\n\t\tconst sortedKeys = Object.keys(val).toSorted();\n\n\t\tconst result: Record<string, unknown> = {};\n\n\t\tfor (const key of sortedKeys) {\n\t\t\tresult[key] = val[key];\n\t\t}\n\n\t\treturn result;\n\t});\n};\n\nexport const toArray = (value: unknown) => (isArray(value) ? value : [value]);\n","import { extraOptionDefaults } from \"./constants/defaults\";\nimport type { CallApiExtraOptions } from \"./types/common\";\nimport type { ThrowOnErrorUnion } from \"./types/conditional-types\";\nimport type { DefaultDataType, DefaultThrowOnError } from \"./types/default-types\";\nimport type {\n\tAnyString,\n\tAwaitable,\n\tDistributiveOmit,\n\tNoInferUnMasked,\n\tPrettify,\n\tUnmaskType,\n} from \"./types/type-helpers\";\nimport { omitKeys } from \"./utils/common\";\nimport type { HTTPError, ValidationError } from \"./utils/external/error\";\nimport { isHTTPErrorInstance, isValidationErrorInstance } from \"./utils/external/guards\";\n\nexport type ResponseType = \"blob\" | \"json\" | \"text\";\n\ntype Parser<TData> = (responseString: string) => Awaitable<TData>;\n\nexport const getResponseType = <TResponse>(response: Response, parser: Parser<TResponse>) => ({\n\tarrayBuffer: () => response.arrayBuffer(),\n\tblob: () => response.blob(),\n\tformData: () => response.formData(),\n\tjson: async (): Promise<TResponse> => {\n\t\tconst text = await response.text();\n\t\treturn parser(text);\n\t},\n\tstream: () => response.body,\n\ttext: () => response.text(),\n});\n\ntype InitResponseTypeMap<TResponse = unknown> = ReturnType<typeof getResponseType<TResponse>>;\n\ntype ResponseTypeUnion = keyof InitResponseTypeMap;\n\ntype ResponseTypePlaceholder = null;\n\nexport type ResponseTypeType = ResponseTypePlaceholder | ResponseTypeUnion;\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 ResponseTypeType,\n\tTComputedResponseTypeMap extends ResponseTypeMap<TResponse> = ResponseTypeMap<TResponse>,\n> =\n\tnull extends TResponseType ? TComputedResponseTypeMap[\"json\"]\n\t: TResponseType extends NonNullable<ResponseTypeType> ? TComputedResponseTypeMap[TResponseType]\n\t: never;\n\nconst textTypes = new Set([\"image/svg\", \"application/xml\", \"application/xhtml\", \"application/html\"]);\nconst JSON_REGEX = /^application\\/(?:[\\w!#$%&*.^`~-]*\\+)?json(;.+)?$/i;\n\nconst detectResponseType = (response: Response): Extract<ResponseTypeType, \"blob\" | \"json\" | \"text\"> => {\n\tconst initContentType = response.headers.get(\"content-type\");\n\n\tif (!initContentType) {\n\t\treturn extraOptionDefaults.responseType;\n\t}\n\n\tconst contentType = initContentType.split(\";\")[0] ?? \"\";\n\n\tif (JSON_REGEX.test(contentType)) {\n\t\treturn \"json\";\n\t}\n\n\tif (textTypes.has(contentType) || contentType.startsWith(\"text/\")) {\n\t\treturn \"text\";\n\t}\n\n\treturn \"blob\";\n};\n\nexport const resolveResponseData = <TResponse>(\n\tresponse: Response,\n\tresponseType: ResponseTypeType | undefined,\n\tparser: Parser<TResponse> | undefined\n) => {\n\tconst selectedParser = parser ?? extraOptionDefaults.responseParser;\n\tconst selectedResponseType = responseType ?? detectResponseType(response);\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: NoInferUnMasked<TData>;\n\terror: null;\n\tresponse: Response;\n};\nexport type PossibleJavaScriptError = UnmaskType<{\n\terrorData: false;\n\tmessage: string;\n\tname: \"AbortError\" | \"Error\" | \"SyntaxError\" | \"TimeoutError\" | \"TypeError\" | AnyString;\n\toriginalError: DOMException | Error | SyntaxError | TypeError;\n}>;\n\nexport type PossibleHTTPError<TErrorData> = UnmaskType<{\n\terrorData: NoInferUnMasked<TErrorData>;\n\tmessage: string;\n\tname: \"HTTPError\";\n\toriginalError: HTTPError;\n}>;\n\nexport type PossibleValidationError = UnmaskType<{\n\terrorData: ValidationError[\"errorData\"];\n\tissueCause: ValidationError[\"issueCause\"];\n\tmessage: string;\n\tname: \"ValidationError\";\n\toriginalError: ValidationError;\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 CallApiResultSuccessOrErrorVariant<TData, TError> =\n\t| CallApiResultErrorVariant<TError>\n\t| CallApiResultSuccessVariant<TData>;\n\nexport type ResultModeMap<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError,\n\tTComputedResultWithoutException extends CallApiResultSuccessOrErrorVariant<TData, TErrorData> =\n\t\tCallApiResultSuccessOrErrorVariant<TData, TErrorData>,\n\tTComputedResultWithException extends CallApiResultSuccessVariant<TData> =\n\t\tCallApiResultSuccessVariant<TData>,\n\tTComputedResult extends TThrowOnError extends true ? TComputedResultWithException\n\t:\tTComputedResultWithoutException = TThrowOnError extends true ? TComputedResultWithException\n\t:\tTComputedResultWithoutException,\n> = UnmaskType<{\n\tall: TComputedResult;\n\tonlyData: TComputedResult[\"data\"];\n\tonlyResponse: TComputedResult[\"response\"];\n\twithoutResponse: Prettify<DistributiveOmit<TComputedResult, \"response\">>;\n}>;\n\ntype ResultModePlaceholder = null;\n\ntype ResultModeUnion = keyof ResultModeMap;\n\n// FIXME - Revisit this idea later. Take inspirations from how zod does it with pick({}) and omit({d})\n// type ResultModeObject = { data?: boolean; error?: boolean; response?: boolean };\n\nexport type ResultModeType = ResultModePlaceholder | ResultModeUnion;\n\nexport type InferCallApiResult<\n\tTData,\n\tTErrorData,\n\tTResultMode extends ResultModeType,\n\tTThrowOnError extends ThrowOnErrorUnion,\n\tTComputedResultModeMapWithException extends ResultModeMap<TData, TErrorData, true> = ResultModeMap<\n\t\tTData,\n\t\tTErrorData,\n\t\ttrue\n\t>,\n\tTComputedResultModeMapWithoutException extends ResultModeMap<TData, TErrorData, TThrowOnError> =\n\t\tResultModeMap<TData, TErrorData, TThrowOnError>,\n> =\n\tTErrorData extends false ? TComputedResultModeMapWithException[\"onlyData\"]\n\t: TErrorData extends false | undefined ? TComputedResultModeMapWithException[\"onlyData\"]\n\t: ResultModePlaceholder extends TResultMode ? TComputedResultModeMapWithoutException[\"all\"]\n\t: TResultMode extends ResultModeUnion ? TComputedResultModeMapWithoutException[TResultMode]\n\t: never;\n\ntype SuccessInfo = Pick<CallApiExtraOptions, \"resultMode\"> & {\n\tresponse: Response;\n};\n\ntype LazyResultModeMap = {\n\t[key in keyof ResultModeMap]: () => ResultModeMap[key];\n};\n\nconst getResultModeMap = (details: ResultModeMap[\"all\"]): LazyResultModeMap => {\n\treturn {\n\t\tall: () => details,\n\t\tonlyData: () => details.data,\n\t\tonlyResponse: () => details.response,\n\t\twithoutResponse: () => omitKeys(details, [\"response\"]),\n\t};\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 = Omit<SuccessInfo, \"response\">\n\t& Pick<CallApiExtraOptions, \"cloneResponse\"> & {\n\t\tmessage?: string;\n\t};\n\ntype ErrorResult = {\n\terrorDetails: CallApiResultErrorVariant<unknown>;\n\terrorResult: CallApiResultErrorVariant<unknown> | null;\n};\n\nexport const resolveErrorResult = (error: unknown, info: ErrorInfo): ErrorResult => {\n\tconst { cloneResponse, message: customErrorMessage, resultMode } = info;\n\n\tlet errorDetails = {\n\t\tdata: null,\n\t\terror: {\n\t\t\terrorData: false,\n\t\t\tmessage: customErrorMessage ?? (error as Error).message,\n\t\t\tname: (error as Error).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\terrorDetails = {\n\t\t\tdata: null,\n\t\t\terror: {\n\t\t\t\terrorData,\n\t\t\t\tissueCause: error.issueCause,\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 { errorData, message, name, response } = error;\n\n\t\terrorDetails = {\n\t\t\tdata: null,\n\t\t\terror: { errorData, message, name, originalError: error },\n\t\t\tresponse: cloneResponse ? response.clone() : response,\n\t\t};\n\t}\n\n\tconst resultModeMap = getResultModeMap(errorDetails);\n\n\tconst errorResult = resultModeMap[resultMode ?? \"all\"]() as never;\n\n\treturn { errorDetails, errorResult };\n};\n\nexport const getCustomizedErrorResult = (\n\terrorResult: ErrorResult[\"errorResult\"],\n\tcustomErrorInfo: { message: string | undefined }\n): ErrorResult[\"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[\"errorResult\"]>[\"error\"] as never,\n\t};\n};\n","import {\n\ttype CallApiResultErrorVariant,\n\ttype CallApiResultSuccessVariant,\n\ttype ErrorInfo,\n\ttype PossibleHTTPError,\n\ttype PossibleJavaScriptError,\n\ttype PossibleJavaScriptOrValidationError,\n\ttype PossibleValidationError,\n\tresolveErrorResult,\n} from \"./result\";\nimport type { StreamProgressEvent } from \"./stream\";\nimport type {\n\tBaseCallApiConfig,\n\tCallApiConfig,\n\tCallApiContext,\n\tCallApiExtraOptionsForHooks,\n\tCallApiRequestOptionsForHooks,\n} from \"./types/common\";\nimport type { DefaultCallApiContext } from \"./types/default-types\";\nimport type { AnyFunction, Awaitable, Prettify } from \"./types/type-helpers\";\n\nexport interface Hooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> {\n\t/**\n\t * Hook called when any error occurs within the request/response lifecycle.\n\t *\n\t * This is a unified error handler that catches both request errors (network failures,\n\t * timeouts, etc.) and response errors (HTTP error status codes). It's essentially\n\t * a combination of `onRequestError` and `onResponseError` hooks.\n\t *\n\t * @param context - Error context containing error details, request info, and response (if available)\n\t * @returns Promise or void - Hook can be async or sync\n\t */\n\tonError?: (context: ErrorContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called before the HTTP request is sent and before any internal processing of the request object begins.\n\t *\n\t * This is the ideal place to modify request headers, add authentication,\n\t * implement request logging, or perform any setup before the network call.\n\t *\n\t * @param context - Request context with mutable request object and configuration\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonRequest?: (context: RequestContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called when an error occurs during the fetch request itself.\n\t *\n\t * This handles network-level errors like connection failures, timeouts,\n\t * DNS resolution errors, or other issues that prevent getting an HTTP response.\n\t * Note that HTTP error status codes (4xx, 5xx) are handled by `onResponseError`.\n\t *\n\t * @param context - Request error context with error details and null response\n\t * @returns Promise or void - Hook can be async or sync\n\t */\n\tonRequestError?: (context: RequestErrorContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called just before the HTTP request is sent and after the request has been processed.\n\t *\n\t * @param context - Request context with mutable request object and configuration\n\t */\n\tonRequestReady?: (context: RequestContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called during upload stream progress tracking.\n\t *\n\t * This hook is triggered when uploading data (like file uploads) and provides\n\t * progress information about the upload. Useful for implementing progress bars\n\t * or upload status indicators.\n\t *\n\t * @param context - Request stream context with progress event and request instance\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonRequestStream?: (context: RequestStreamContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called when any HTTP response is received from the API.\n\t *\n\t * This hook is triggered for both successful (2xx) and error (4xx, 5xx) responses.\n\t * It's useful for response logging, metrics collection, or any processing that\n\t * should happen regardless of response status.\n\t *\n\t * @param context - Response context with either success data or error information\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonResponse?: (context: ResponseContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called when an HTTP error response (4xx, 5xx) is received from the API.\n\t *\n\t * This handles server-side errors where an HTTP response was successfully received\n\t * but indicates an error condition. Different from `onRequestError` which handles\n\t * network-level failures.\n\t *\n\t * @param context - Response error context with HTTP error details and response\n\t * @returns Promise or void - Hook can be async or sync\n\t */\n\tonResponseError?: (context: ResponseErrorContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called during download stream progress tracking.\n\t *\n\t * This hook is triggered when downloading data (like file downloads) and provides\n\t * progress information about the download. Useful for implementing progress bars\n\t * or download status indicators.\n\t *\n\t * @param context - Response stream context with progress event and response\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonResponseStream?: (context: ResponseStreamContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called when a request is being retried.\n\t *\n\t * This hook is triggered before each retry attempt, providing information about\n\t * the previous failure and the current retry attempt number. Useful for implementing\n\t * custom retry logic, exponential backoff, or retry logging.\n\t *\n\t * @param context - Retry context with error details and retry attempt count\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonRetry?: (response: RetryContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called when a successful response (2xx status) is received from the API.\n\t *\n\t * This hook is triggered only for successful responses and provides access to\n\t * the parsed response data. Ideal for success logging, caching, or post-processing\n\t * of successful API responses.\n\t *\n\t * @param context - Success context with parsed response data and response object\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonSuccess?: (context: SuccessContext<TCallApiContext>) => Awaitable<unknown>;\n\n\t/**\n\t * Hook called when a validation error occurs.\n\t *\n\t * This hook is triggered when request or response data fails validation against\n\t * a defined schema. It provides access to the validation error details and can\n\t * be used for custom error handling, logging, or fallback behavior.\n\t *\n\t * @param context - Validation error context with error details and response (if available)\n\t * @returns Promise or void - Hook can be async or sync\n\t *\n\t */\n\tonValidationError?: (context: ValidationErrorContext<TCallApiContext>) => Awaitable<unknown>;\n}\n\nexport type HooksOrHooksArray<TCallApiContext extends NoInfer<CallApiContext> = DefaultCallApiContext> = {\n\t[Key in keyof Hooks<TCallApiContext>]:\n\t\t| Hooks<TCallApiContext>[Key]\n\t\t// eslint-disable-next-line perfectionist/sort-union-types -- I need arrays to be last\n\t\t| Array<Hooks<TCallApiContext>[Key]>;\n};\n\nexport interface HookConfigOptions {\n\t/**\n\t * Controls the execution mode of all composed hooks (main + plugin hooks).\n\t *\n\t * - **\"parallel\"**: All hooks execute simultaneously via Promise.all() for better performance\n\t * - **\"sequential\"**: All hooks execute one by one in registration order via await in a loop\n\t *\n\t * This affects how ALL hooks execute together, regardless of their source (main or plugin).\n\t *\n\t * @default \"parallel\"\n\t */\n\thooksExecutionMode?: \"parallel\" | \"sequential\";\n}\n\nexport type RequestContext<\n\tTCallApiContext extends Pick<CallApiContext, \"InferredExtraOptions\" | \"Meta\"> = DefaultCallApiContext,\n> = {\n\t/**\n\t * Base configuration object passed to createFetchClient.\n\t *\n\t * Contains the foundational configuration that applies to all requests\n\t * made by this client instance, such as baseURL, default headers, and\n\t * global options.\n\t */\n\tbaseConfig: Exclude<BaseCallApiConfig, AnyFunction>;\n\n\t/**\n\t * Instance-specific configuration object passed to the callApi instance.\n\t *\n\t * Contains configuration specific to this particular API call, which\n\t * can override or extend the base configuration.\n\t */\n\tconfig: CallApiConfig;\n\n\t/**\n\t * Merged options combining base config, instance config, and default options.\n\t *\n\t * This is the final resolved configuration that will be used for the request,\n\t * with proper precedence applied (instance > base > defaults).\n\t */\n\toptions: CallApiExtraOptionsForHooks<TCallApiContext>;\n\n\t/**\n\t * Merged request object ready to be sent.\n\t *\n\t * Contains the final request configuration including URL, method, headers,\n\t * body, and other fetch options. This object can be modified in onRequest\n\t * hooks to customize the outgoing request.\n\t */\n\trequest: CallApiRequestOptionsForHooks;\n};\n\nexport type ValidationErrorContext<\n\tTCallApiContext extends Pick<CallApiContext, \"InferredExtraOptions\" | \"Meta\"> = DefaultCallApiContext,\n> = RequestContext<TCallApiContext> & {\n\terror: PossibleValidationError;\n\tresponse: Response | null;\n};\n\nexport type SuccessContext<\n\tTCallApiContext extends Pick<CallApiContext, \"Data\" | \"InferredExtraOptions\" | \"Meta\"> =\n\t\tDefaultCallApiContext,\n> = RequestContext<TCallApiContext> & {\n\tdata: TCallApiContext[\"Data\"];\n\tresponse: Response;\n};\n\nexport type ResponseContext<\n\tTCallApiContext extends Pick<CallApiContext, \"Data\" | \"ErrorData\" | \"InferredExtraOptions\" | \"Meta\"> =\n\t\tDefaultCallApiContext,\n> = RequestContext<TCallApiContext>\n\t& (\n\t\t| Prettify<CallApiResultSuccessVariant<TCallApiContext[\"Data\"]>>\n\t\t| Prettify<\n\t\t\t\tExtract<\n\t\t\t\t\tCallApiResultErrorVariant<TCallApiContext[\"ErrorData\"]>,\n\t\t\t\t\t{ error: PossibleHTTPError<TCallApiContext[\"ErrorData\"]> }\n\t\t\t\t>\n\t\t >\n\t);\n\nexport type RequestErrorContext<\n\tTCallApiContext extends Pick<CallApiContext, \"InferredExtraOptions\" | \"Meta\"> = DefaultCallApiContext,\n> = RequestContext<TCallApiContext> & {\n\terror: PossibleJavaScriptError;\n\tresponse: null;\n};\n\nexport type ErrorContext<\n\tTCallApiContext extends Pick<CallApiContext, \"ErrorData\" | \"InferredExtraOptions\" | \"Meta\"> =\n\t\tDefaultCallApiContext,\n> = RequestContext<TCallApiContext>\n\t& (\n\t\t| {\n\t\t\t\terror: PossibleHTTPError<TCallApiContext[\"ErrorData\"]>;\n\t\t\t\tresponse: Response;\n\t\t }\n\t\t| {\n\t\t\t\terror: PossibleJavaScriptOrValidationError;\n\t\t\t\tresponse: Response | null;\n\t\t }\n\t);\n\nexport type ResponseErrorContext<\n\tTCallApiContext extends Pick<CallApiContext, \"ErrorData\" | \"InferredExtraOptions\" | \"Meta\"> =\n\t\tDefaultCallApiContext,\n> = Extract<ErrorContext<TCallApiContext>, { error: PossibleHTTPError<TCallApiContext[\"ErrorData\"]> }>\n\t& RequestContext<TCallApiContext>;\n\nexport type RetryContext<\n\tTCallApiContext extends Pick<CallApiContext, \"ErrorData\" | \"InferredExtraOptions\" | \"Meta\"> =\n\t\tDefaultCallApiContext,\n> = ErrorContext<TCallApiContext> & {\n\tretryAttemptCount: number;\n};\n\nexport type RequestStreamContext<\n\tTCallApiContext extends Pick<CallApiContext, \"InferredExtraOptions\" | \"Meta\"> = DefaultCallApiContext,\n> = RequestContext<TCallApiContext> & {\n\tevent: StreamProgressEvent;\n\trequestInstance: Request;\n};\n\nexport type ResponseStreamContext<\n\tTCallApiContext extends Pick<CallApiContext, \"InferredExtraOptions\" | \"Meta\"> = DefaultCallApiContext,\n> = RequestContext<TCallApiContext> & {\n\tevent: StreamProgressEvent;\n\tresponse: Response;\n};\n\ntype HookRegistries = Required<{\n\t[Key in keyof Hooks]: Set<Hooks[Key]>;\n}>;\n\nexport const getHookRegistriesAndKeys = () => {\n\tconst hookRegistries: HookRegistries = {\n\t\tonError: new Set(),\n\t\tonRequest: new Set(),\n\t\tonRequestError: new Set(),\n\t\tonRequestReady: new Set(),\n\t\tonRequestStream: new Set(),\n\t\tonResponse: new Set(),\n\t\tonResponseError: new Set(),\n\t\tonResponseStream: new Set(),\n\t\tonRetry: new Set(),\n\t\tonSuccess: new Set(),\n\t\tonValidationError: new Set(),\n\t};\n\n\tconst hookRegistryKeys = Object.keys(hookRegistries) as Array<keyof Hooks>;\n\n\treturn { hookRegistries, hookRegistryKeys };\n};\n\nexport const composeHooksFromArray = (\n\thooksArray: Array<Hooks[keyof Hooks] | undefined>,\n\thooksExecutionMode: CallApiExtraOptionsForHooks[\"hooksExecutionMode\"]\n) => {\n\tconst composedHook = async (ctx: unknown) => {\n\t\tswitch (hooksExecutionMode) {\n\t\t\tcase \"parallel\": {\n\t\t\t\tawait Promise.all(hooksArray.map((uniqueHook) => uniqueHook?.(ctx as never)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"sequential\": {\n\t\t\t\tfor (const hook of hooksArray) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop -- This is necessary in this case\n\t\t\t\t\tawait hook?.(ctx as never);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\thooksExecutionMode satisfies undefined;\n\t\t\t}\n\t\t}\n\t};\n\n\treturn composedHook;\n};\n\nexport const executeHooks = 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\tif (shouldThrowOnError) {\n\t\t\tthrow hookError;\n\t\t}\n\n\t\tconst { errorResult } = resolveErrorResult(hookError, errorInfo);\n\n\t\treturn errorResult;\n\t}\n};\n","import {\n\texecuteHooks,\n\ttype RequestContext,\n\ttype RequestStreamContext,\n\ttype ResponseStreamContext,\n} from \"./hooks\";\nimport { isObject, isReadableStream } 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\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;\n\nexport const toStreamableRequest = async (\n\tcontext: ToStreamableRequestContext\n): Promise<Request | RequestInit> => {\n\tconst { baseConfig, config, options, request } = context;\n\n\tif (!options.onRequestStream || !isReadableStream(request.body)) {\n\t\treturn request as RequestInit;\n\t}\n\n\tconst requestInstance = new Request(\n\t\toptions.fullURL as NonNullable<typeof options.fullURL>,\n\t\t{ ...request, duplex: \"half\" } as RequestInit\n\t);\n\n\tconst contentLength = requestInstance.headers.get(\"content-length\");\n\n\tlet totalBytes = Number(contentLength ?? 0);\n\n\tconst shouldForcefullyCalcStreamSize =\n\t\tisObject(options.forcefullyCalculateStreamSize) ?\n\t\t\toptions.forcefullyCalculateStreamSize.request\n\t\t:\toptions.forcefullyCalculateStreamSize;\n\n\t// == If no content length is present, we read the total bytes from the body\n\tif (!contentLength && shouldForcefullyCalcStreamSize) {\n\t\ttotalBytes = await calculateTotalBytesFromBody(requestInstance.clone().body, totalBytes);\n\t}\n\n\tlet transferredBytes = 0;\n\n\tconst stream = new ReadableStream({\n\t\tstart: async (controller) => {\n\t\t\tconst body = requestInstance.body;\n\n\t\t\tif (!body) return;\n\n\t\t\tconst requestStreamContext = {\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\tevent: createProgressEvent({ chunk: new Uint8Array(), totalBytes, transferredBytes }),\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t\trequestInstance,\n\t\t\t} satisfies RequestStreamContext;\n\n\t\t\tawait executeHooks(options.onRequestStream?.(requestStreamContext));\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 executeHooks(\n\t\t\t\t\toptions.onRequestStream?.({\n\t\t\t\t\t\t...requestStreamContext,\n\t\t\t\t\t\tevent: createProgressEvent({ chunk, totalBytes, transferredBytes }),\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 Request(requestInstance, { body: stream, duplex: \"half\" } as RequestInit);\n};\n\ntype StreamableResponseContext = RequestContext & { response: Response };\n\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 =\n\t\tisObject(options.forcefullyCalculateStreamSize) ?\n\t\t\toptions.forcefullyCalculateStreamSize.response\n\t\t:\toptions.forcefullyCalculateStreamSize;\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\tconst stream = new ReadableStream({\n\t\tstart: async (controller) => {\n\t\t\tconst body = response.body;\n\n\t\t\tif (!body) return;\n\n\t\t\tconst responseStreamContext = {\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\tevent: createProgressEvent({ chunk: new Uint8Array(), totalBytes, transferredBytes }),\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t\tresponse,\n\t\t\t} satisfies ResponseStreamContext;\n\n\t\t\tawait executeHooks(options.onResponseStream?.(responseStreamContext));\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 executeHooks(\n\t\t\t\t\toptions.onResponseStream?.({\n\t\t\t\t\t\t...responseStreamContext,\n\t\t\t\t\t\tevent: createProgressEvent({ chunk, totalBytes, transferredBytes }),\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 { extraOptionDefaults } from \"./constants/defaults\";\nimport type { RequestContext } from \"./hooks\";\nimport { toStreamableRequest, toStreamableResponse } from \"./stream\";\nimport type { AnyString, RemoveDedupeOrRetryPrefix, UnmaskType } from \"./types/type-helpers\";\nimport { deterministicHashFn, waitFor } from \"./utils/common\";\nimport { isFunction } from \"./utils/guards\";\n\ntype RequestInfo = {\n\tcontroller: AbortController;\n\tresponsePromise: Promise<Response>;\n};\n\n/**\n * Cache that stores active request information for deduplication within a specific scope.\n *\n * Maps deduplication keys to their corresponding request information, including the abort controller\n * and response promise. A `null` key represents requests that don't participate in deduplication.\n *\n * **Internal Usage:**\n * This type is primarily used internally by the deduplication system. You typically won't need to\n * interact with it directly unless you're building custom deduplication logic or debugging.\n *\n * @example\n * ```ts\n * // This is handled internally, but conceptually:\n * const cache: RequestInfoCache = new Map([\n * [\"user-123\", { controller: abortController, responsePromise: fetchPromise }],\n * [\"config\", { controller: abortController2, responsePromise: fetchPromise2 }],\n * ]);\n * ```\n */\nexport type RequestInfoCache = Map<string | null, RequestInfo>;\n\n/**\n * Global cache that manages multiple request info caches, organized by scope keys.\n *\n * This enables the global deduplication feature by maintaining separate cache namespaces\n * for different scope keys. Each scope key gets its own `RequestInfoCache` instance.\n *\n * **Cache Lifecycle:**\n * - Caches are created on-demand when first accessed\n * - Automatic cleanup occurs when no references remain\n * - Each scope key maintains independent deduplication state\n *\n * **Memory Considerations:**\n * - Each scope key creates a separate cache instance\n * - Consider the number of different scope keys in your application\n * - Caches are cleaned up automatically when clients are garbage collected\n *\n * @example\n * ```ts\n * // This is managed internally, but conceptually:\n * const globalCache: GlobalRequestInfoCache = new Map([\n * [\"user-service\", new Map([...])], // Cache for user service requests\n * [\"analytics\", new Map([...])], // Cache for analytics requests\n * [\"default\", new Map([...])] // Default cache scope\n * ]);\n * ```\n */\nexport type GlobalRequestInfoCache = Map<DedupeOptions[\"dedupeCacheScopeKey\"], RequestInfoCache>;\n\ntype DedupeContext = RequestContext & {\n\t$GlobalRequestInfoCache: GlobalRequestInfoCache;\n\t$LocalRequestInfoCache: RequestInfoCache;\n\tnewFetchController: AbortController;\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 =\n\t\tglobalOptions.dedupeStrategy ?? globalOptions.dedupe?.strategy ?? extraOptionDefaults.dedupeStrategy;\n\n\tconst resolvedDedupeStrategy = isFunction(dedupeStrategy) ? dedupeStrategy(context) : dedupeStrategy;\n\n\tconst getDedupeKey = () => {\n\t\tconst shouldHaveDedupeKey =\n\t\t\tresolvedDedupeStrategy === \"cancel\" || resolvedDedupeStrategy === \"defer\";\n\n\t\tif (!shouldHaveDedupeKey) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst dedupeKey = globalOptions.dedupeKey ?? globalOptions.dedupe?.key;\n\n\t\tconst resolvedDedupeKey = isFunction(dedupeKey) ? dedupeKey(context) : dedupeKey;\n\n\t\tif (resolvedDedupeKey === undefined) {\n\t\t\tconst defaultDedupeKey = `${globalOptions.fullURL}-${deterministicHashFn({ options: globalOptions, request: globalRequest })}`;\n\n\t\t\treturn defaultDedupeKey;\n\t\t}\n\n\t\treturn resolvedDedupeKey;\n\t};\n\n\tconst getDedupeCacheScopeKey = () => {\n\t\tconst dedupeCacheScopeKey = globalOptions.dedupeCacheScopeKey ?? globalOptions.dedupe?.cacheScopeKey;\n\n\t\tconst resolvedDedupeCacheScopeKey =\n\t\t\tisFunction(dedupeCacheScopeKey) ? dedupeCacheScopeKey(context) : dedupeCacheScopeKey;\n\n\t\tif (resolvedDedupeCacheScopeKey === undefined) {\n\t\t\treturn extraOptionDefaults.dedupeCacheScopeKey;\n\t\t}\n\n\t\treturn resolvedDedupeCacheScopeKey;\n\t};\n\n\tconst dedupeKey = getDedupeKey();\n\n\tconst dedupeCacheScope =\n\t\tglobalOptions.dedupeCacheScope\n\t\t?? globalOptions.dedupe?.cacheScope\n\t\t?? extraOptionDefaults.dedupeCacheScope;\n\n\tconst dedupeCacheScopeKey = getDedupeCacheScopeKey();\n\n\tif (dedupeCacheScope === \"global\" && !$GlobalRequestInfoCache.has(dedupeCacheScopeKey)) {\n\t\t$GlobalRequestInfoCache.set(dedupeCacheScopeKey, new Map());\n\t}\n\n\tconst $RequestInfoCache =\n\t\tdedupeCacheScope === \"global\" ?\n\t\t\t$GlobalRequestInfoCache.get(dedupeCacheScopeKey)\n\t\t:\t$LocalRequestInfoCache;\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 * Force sequential execution of parallel requests to enable proper cache-based deduplication.\n\t *\n\t * Problem: When Promise.all([callApi(url), callApi(url)]) executes, both requests\n\t * start synchronously and reach this point before either can populate the cache.\n\t *\n\t * Why `await Promise.resolve()` fails:\n\t * - All microtasks in a batch resolve together at the next microtask checkpoint\n\t * - Both requests resume execution simultaneously after the await\n\t * - Both check `prevRequestInfo` at the same time → both see empty cache\n\t * - Both proceed to populate cache → deduplication fails\n\t *\n\t * Why `wait new Promise(()=> setTimeout(resolve, number))` works:\n\t * - Each setTimeout creates a separate task in the task queue\n\t * - Tasks execute sequentially, not simultaneously\n\t * - Request 1's task runs first: checks cache (empty) → continues → populates cache\n\t * - Request 2's task runs after: checks cache (populated) → uses cached promise\n\t * - Deduplication succeeds\n\t *\n\t * IMPORTANT: The delay must be non-zero. setTimeout(fn, 0) fails because JavaScript engines\n\t * may optimize zero-delay timers by batching them together, causing all requests to resume\n\t * simultaneously (same problem as microtasks). Any non-zero value (even 0.0000000001) forces\n\t * proper sequential task queue scheduling, ensuring each request gets its own task slot.\n\t */\n\tif (dedupeKey !== null) {\n\t\tawait waitFor(0.001);\n\t}\n\n\tconst prevRequestInfo = $RequestInfoCacheOrNull?.get(dedupeKey);\n\n\tconst getAbortErrorMessage = () => {\n\t\tif (globalOptions.dedupeKey) {\n\t\t\treturn `Duplicate request detected - Aborted previous request with key '${dedupeKey}'`;\n\t\t}\n\n\t\treturn `Duplicate request aborted - Aborted previous request to '${globalOptions.fullURL}'`;\n\t};\n\n\tconst handleRequestCancelStrategy = () => {\n\t\tconst shouldCancelRequest = prevRequestInfo && resolvedDedupeStrategy === \"cancel\";\n\n\t\tif (!shouldCancelRequest) return;\n\n\t\tconst message = getAbortErrorMessage();\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\tfetchApi: NonNullable<DedupeContext[\"options\"][\"customFetchImpl\"]>;\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 { fetchApi, options: localOptions, request: localRequest } = deferContext;\n\n\t\tconst shouldUsePromiseFromCache = prevRequestInfo && resolvedDedupeStrategy === \"defer\";\n\n\t\tconst streamableContext = {\n\t\t\tbaseConfig,\n\t\t\tconfig,\n\t\t\toptions: localOptions,\n\t\t\trequest: localRequest,\n\t\t} satisfies RequestContext;\n\n\t\tconst streamableRequest = await toStreamableRequest(streamableContext);\n\n\t\tconst responsePromise =\n\t\t\tshouldUsePromiseFromCache ?\n\t\t\t\tprevRequestInfo.responsePromise\n\t\t\t:\tfetchApi(localOptions.fullURL as NonNullable<typeof localOptions.fullURL>, streamableRequest);\n\n\t\t$RequestInfoCacheOrNull?.set(dedupeKey, { controller: newFetchController, responsePromise });\n\n\t\tconst response = await responsePromise;\n\n\t\treturn toStreamableResponse({ ...streamableContext, response });\n\t};\n\n\tconst removeDedupeKeyFromCache = () => {\n\t\t$RequestInfoCacheOrNull?.delete(dedupeKey);\n\t};\n\n\treturn {\n\t\tgetAbortErrorMessage,\n\t\thandleRequestCancelStrategy,\n\t\thandleRequestDeferStrategy,\n\t\tremoveDedupeKeyFromCache,\n\t\tresolvedDedupeStrategy,\n\t};\n};\n\ntype DedupeStrategyUnion = UnmaskType<\"cancel\" | \"defer\" | \"none\">;\n\ntype DedupeOptionKeys = Exclude<keyof DedupeOptions, \"dedupe\">;\n\ntype InnerDedupeOptions = {\n\t[Key in DedupeOptionKeys as RemoveDedupeOrRetryPrefix<\"dedupe\", Key>]?: DedupeOptions[Key];\n};\n\nexport type DedupeOptions = {\n\t/**\n\t * All dedupe options in a single object instead of separate properties\n\t */\n\tdedupe?: InnerDedupeOptions;\n\n\t/**\n\t * Controls the scope of request deduplication caching.\n\t *\n\t * - `\"global\"`: Shares deduplication cache across all `createFetchClient` instances with the same `dedupeCacheScopeKey`.\n\t * Useful for applications with multiple API clients that should share deduplication state.\n\t * - `\"local\"`: Limits deduplication to requests within the same `createFetchClient` instance.\n\t * Provides better isolation and is recommended for most use cases.\n\t *\n\t *\n\t * **Real-world Scenarios:**\n\t * - Use `\"global\"` when you have multiple API clients (user service, auth service, etc.) that might make overlapping requests\n\t * - Use `\"local\"` (default) for single-purpose clients or when you want strict isolation between different parts of your app\n\t *\n\t * @example\n\t * ```ts\n\t * // Local scope - each client has its own deduplication cache\n\t * const userClient = createFetchClient({ baseURL: \"/api/users\" });\n\t * const postClient = createFetchClient({ baseURL: \"/api/posts\" });\n\t * // These clients won't share deduplication state\n\t *\n\t * // Global scope - share cache across related clients\n\t * const userClient = createFetchClient({\n\t * baseURL: \"/api/users\",\n\t * dedupeCacheScope: \"global\",\n\t * });\n\t * const postClient = createFetchClient({\n\t * baseURL: \"/api/posts\",\n\t * dedupeCacheScope: \"global\",\n\t * });\n\t * // These clients will share deduplication state\n\t * ```\n\t *\n\t * @default \"local\"\n\t */\n\tdedupeCacheScope?: \"global\" | \"local\";\n\n\t/**\n\t * Unique namespace for the global deduplication cache when using `dedupeCacheScope: \"global\"`.\n\t *\n\t * This creates logical groupings of deduplication caches. All instances with the same key\n\t * will share the same cache namespace, allowing fine-grained control over which clients\n\t * share deduplication state.\n\t *\n\t * **Best Practices:**\n\t * - Use descriptive names that reflect the logical grouping (e.g., \"user-service\", \"analytics-api\")\n\t * - Keep scope keys consistent across related API clients\n\t * - Consider using different scope keys for different environments (dev, staging, prod)\n\t * - Avoid overly broad scope keys that might cause unintended cache sharing\n\t *\n\t * **Cache Management:**\n\t * - Each scope key maintains its own independent cache\n\t * - Caches are automatically cleaned up when no references remain\n\t * - Consider the memory implications of multiple global scopes\n\t *\n\t * @example\n\t * ```ts\n\t * // Group related API clients together\n\t * const userClient = createFetchClient({\n\t * baseURL: \"/api/users\",\n\t * dedupeCacheScope: \"global\",\n\t * dedupeCacheScopeKey: \"user-service\"\n\t * });\n\t * const profileClient = createFetchClient({\n\t * baseURL: \"/api/profiles\",\n\t * dedupeCacheScope: \"global\",\n\t * dedupeCacheScopeKey: \"user-service\" // Same scope - will share cache\n\t * });\n\t *\n\t * // Separate analytics client with its own cache\n\t * const analyticsClient = createFetchClient({\n\t * baseURL: \"/api/analytics\",\n\t * dedupeCacheScope: \"global\",\n\t * dedupeCacheScopeKey: \"analytics-service\" // Different scope\n\t * });\n\t *\n\t * // Environment-specific scoping\n\t * const apiClient = createFetchClient({\n\t * dedupeCacheScope: \"global\",\n\t * dedupeCacheScopeKey: `api-${process.env.NODE_ENV}` // \"api-development\", \"api-production\", etc.\n\t * });\n\t * ```\n\t *\n\t * @default \"default\"\n\t */\n\tdedupeCacheScopeKey?: \"default\" | AnyString | ((context: RequestContext) => string | undefined);\n\n\t/**\n\t * Custom key generator for request deduplication.\n\t *\n\t * Override the default key generation strategy to control exactly which requests\n\t * are considered duplicates. The default key combines URL, method, body, and\n\t * relevant headers (excluding volatile ones like 'Date', 'Authorization', etc.).\n\t *\n\t * **Default Key Generation:**\n\t * The auto-generated key includes:\n\t * - Full request URL (including query parameters)\n\t * - HTTP method (GET, POST, etc.)\n\t * - Request body (for POST/PUT/PATCH requests)\n\t * - Stable headers (excludes Date, Authorization, User-Agent, etc.)\n\t *\n\t * **Custom Key Best Practices:**\n\t * - Include only the parts of the request that should affect deduplication\n\t * - Avoid including volatile data (timestamps, random IDs, etc.)\n\t * - Consider performance - simpler keys are faster to compute and compare\n\t * - Ensure keys are deterministic for the same logical request\n\t * - Use consistent key formats across your application\n\t *\n\t * **Performance Considerations:**\n\t * - Function-based keys are computed on every request - keep them lightweight\n\t * - String keys are fastest but least flexible\n\t * - Consider caching expensive key computations if needed\n\t *\n\t * @example\n\t * ```ts\n\t * import { callApi } from \"@zayne-labs/callapi\";\n\t *\n\t * // Simple static key - useful for singleton requests\n\t * const config = callApi(\"/api/config\", {\n\t * dedupeKey: \"app-config\",\n\t * dedupeStrategy: \"defer\" // Share the same config across all requests\n\t * });\n\t *\n\t * // URL and method only - ignore headers and body\n\t * const userData = callApi(\"/api/user/123\", {\n\t * dedupeKey: (context) => `${context.options.method}:${context.options.fullURL}`\n\t * });\n\t *\n\t * // Include specific headers in deduplication\n\t * const apiCall = callApi(\"/api/data\", {\n\t * dedupeKey: (context) => {\n\t * const authHeader = context.request.headers.get(\"Authorization\");\n\t * return `${context.options.fullURL}-${authHeader}`;\n\t * }\n\t * });\n\t *\n\t * // User-specific deduplication\n\t * const userSpecificCall = callApi(\"/api/dashboard\", {\n\t * dedupeKey: (context) => {\n\t * const userId = context.options.fullURL.match(/user\\/(\\d+)/)?.[1];\n\t * return `dashboard-${userId}`;\n\t * }\n\t * });\n\t *\n\t * // Ignore certain query parameters\n\t * const searchCall = callApi(\"/api/search?q=test×tamp=123456\", {\n\t * dedupeKey: (context) => {\n\t * const url = new URL(context.options.fullURL);\n\t * url.searchParams.delete(\"timestamp\"); // Remove volatile param\n\t * return `search:${url.toString()}`;\n\t * }\n\t * });\n\t * ```\n\t *\n\t * @default Auto-generated from request details\n\t */\n\tdedupeKey?: string | ((context: RequestContext) => string | undefined);\n\n\t/**\n\t * Strategy for handling duplicate requests. Can be a static string or callback function.\n\t *\n\t * **Available Strategies:**\n\t * - `\"cancel\"`: Cancel previous request when new one starts (good for search)\n\t * - `\"defer\"`: Share response between duplicate requests (good for config loading)\n\t * - `\"none\"`: No deduplication, all requests execute independently\n\t *\n\t * @example\n\t * ```ts\n\t * // Static strategies\n\t * const searchClient = createFetchClient({\n\t * dedupeStrategy: \"cancel\" // Cancel previous searches\n\t * });\n\t *\n\t * const configClient = createFetchClient({\n\t * dedupeStrategy: \"defer\" // Share config across components\n\t * });\n\t *\n\t * // Dynamic strategy based on request\n\t * const smartClient = createFetchClient({\n\t * dedupeStrategy: (context) => {\n\t * return context.options.method === \"GET\" ? \"defer\" : \"cancel\";\n\t * }\n\t * });\n\t *\n\t * // Search-as-you-type with cancel strategy\n\t * const handleSearch = async (query: string) => {\n\t * try {\n\t * const { data } = await callApi(\"/api/search\", {\n\t * method: \"POST\",\n\t * body: { query },\n\t * dedupeStrategy: \"cancel\",\n\t * dedupeKey: \"search\" // Cancel previous searches, only latest one goes through\n\t * });\n\t *\n\t * updateSearchResults(data);\n\t * } catch (error) {\n\t * if (error.name === \"AbortError\") {\n\t * // Previous search cancelled - (expected behavior)\n\t * return;\n\t * }\n\t * console.error(\"Search failed:\", error);\n\t * }\n\t * };\n\t *\n\t * ```\n\t *\n\t * @default \"cancel\"\n\t */\n\tdedupeStrategy?: DedupeStrategyUnion | ((context: RequestContext) => DedupeStrategyUnion);\n};\n","import type { RequestContext } from \"./hooks\";\nimport type { CallApiContext } from \"./types/common\";\nimport type { DefaultCallApiContext } from \"./types/default-types\";\nimport type { UnmaskType } from \"./types/type-helpers\";\n\nexport type FetchImpl = UnmaskType<\n\t(input: string | Request | URL, init?: RequestInit) => Promise<Response>\n>;\n\nexport type FetchMiddlewareContext<TCallApiContext extends CallApiContext> =\n\tRequestContext<TCallApiContext> & {\n\t\tfetchImpl: FetchImpl;\n\t};\n\nexport interface Middlewares<TCallApiContext extends NoInfer<CallApiContext> = DefaultCallApiContext> {\n\t/**\n\t * Wraps the fetch implementation to intercept requests at the network layer.\n\t *\n\t * Takes a context object containing the current fetch function and returns a new fetch function.\n\t * Use it to cache responses, add logging, handle offline mode, or short-circuit requests etc.\n\t * Multiple middleware compose in order: plugins → base config → per-request.\n\t *\n\t * Unlike `customFetchImpl`, middleware can call through to the original fetch.\n\t *\n\t * @example\n\t * ```ts\n\t * // Cache responses\n\t * const cache = new Map();\n\t *\n\t * fetchMiddleware: (ctx) => async (input, init) => {\n\t * const key = input.toString();\n\t *\n\t * const cachedResponse = cache.get(key);\n\t *\n\t * if (cachedResponse) {\n\t *\t return cachedResponse.clone();\n\t * }\n\t *\n\t * const response = await ctx.fetchImpl(input, init);\n\t * cache.set(key, response.clone());\n\t *\n\t * return response;\n\t * }\n\t *\n\t * // Handle offline\n\t * fetchMiddleware: (ctx) => async (...parameters) => {\n\t * if (!navigator.onLine) {\n\t * return new Response('{\"error\": \"offline\"}', { status: 503 });\n\t * }\n\t *\n\t * return ctx.fetchImpl(...parameters);\n\t * }\n\t * ```\n\t */\n\tfetchMiddleware?: (context: FetchMiddlewareContext<TCallApiContext>) => FetchImpl;\n}\n\ntype MiddlewareRegistries = Required<{\n\t[Key in keyof Middlewares]: Set<Middlewares[Key]>;\n}>;\n\nexport const getMiddlewareRegistriesAndKeys = () => {\n\tconst middlewareRegistries: MiddlewareRegistries = {\n\t\tfetchMiddleware: new Set(),\n\t};\n\n\tconst middlewareRegistryKeys = Object.keys(middlewareRegistries) as Array<keyof Middlewares>;\n\n\treturn { middlewareRegistries, middlewareRegistryKeys };\n};\n\nexport const composeMiddlewaresFromArray = (\n\tmiddlewareArray: Array<Middlewares[keyof Middlewares] | undefined>\n) => {\n\tlet composedMiddleware: Middlewares[keyof Middlewares];\n\n\tfor (const currentMiddleware of middlewareArray) {\n\t\tif (!currentMiddleware) continue;\n\n\t\tconst previousMiddleware = composedMiddleware;\n\n\t\tif (!previousMiddleware) {\n\t\t\tcomposedMiddleware = currentMiddleware;\n\t\t\tcontinue;\n\t\t}\n\n\t\tcomposedMiddleware = (context) => {\n\t\t\tconst prevFetchImpl = previousMiddleware(context);\n\t\t\tconst fetchImpl = currentMiddleware({ ...context, fetchImpl: prevFetchImpl });\n\n\t\t\treturn fetchImpl;\n\t\t};\n\t}\n\n\treturn composedMiddleware;\n};\n","import { extraOptionDefaults } from \"./constants/defaults\";\nimport {\n\tcomposeHooksFromArray,\n\tgetHookRegistriesAndKeys,\n\ttype Hooks,\n\ttype HooksOrHooksArray,\n\ttype RequestContext,\n} from \"./hooks\";\nimport {\n\tcomposeMiddlewaresFromArray,\n\tgetMiddlewareRegistriesAndKeys,\n\ttype Middlewares,\n} from \"./middlewares\";\nimport type { CallApiContext, CallApiRequestOptions, OverrideCallApiContext } from \"./types/common\";\nimport type { DefaultCallApiContext, DefaultDataType } from \"./types/default-types\";\nimport type { AnyFunction, Awaitable, UnionToIntersection } from \"./types/type-helpers\";\nimport type { InitURLOrURLObject } from \"./url\";\nimport { getMethod, getResolvedHeaders } from \"./utils/common\";\nimport { isArray, isFunction, isString } from \"./utils/guards\";\nimport {\n\ttype BaseCallApiSchemaAndConfig,\n\tgetCurrentRouteSchemaKeyAndMainInitURL,\n\ttype InferSchemaOutput,\n} from \"./validation\";\n\nexport type PluginSetupContext<TCallApiContext extends CallApiContext = DefaultCallApiContext> =\n\tRequestContext<TCallApiContext> & { initURL: string };\n\nexport type PluginInitResult<TCallApiContext extends CallApiContext = DefaultCallApiContext> = Partial<\n\tOmit<PluginSetupContext<TCallApiContext>, \"initURL\" | \"request\"> & {\n\t\tinitURL: InitURLOrURLObject;\n\t\trequest: CallApiRequestOptions;\n\t}\n>;\n\ntype GetDefaultDataTypeForPlugins<TData> = DefaultDataType extends TData ? never : TData;\n\nexport type PluginHooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> =\n\tHooksOrHooksArray<\n\t\tOverrideCallApiContext<\n\t\t\tTCallApiContext,\n\t\t\t{\n\t\t\t\tData: GetDefaultDataTypeForPlugins<TCallApiContext[\"Data\"]>;\n\t\t\t\tErrorData: GetDefaultDataTypeForPlugins<TCallApiContext[\"ErrorData\"]>;\n\t\t\t}\n\t\t>\n\t>;\n\nexport type PluginMiddlewares<TCallApiContext extends CallApiContext = DefaultCallApiContext> =\n\tMiddlewares<\n\t\tOverrideCallApiContext<\n\t\t\tTCallApiContext,\n\t\t\t{\n\t\t\t\tData: GetDefaultDataTypeForPlugins<TCallApiContext[\"Data\"]>;\n\t\t\t\tErrorData: GetDefaultDataTypeForPlugins<TCallApiContext[\"ErrorData\"]>;\n\t\t\t}\n\t\t>\n\t>;\n\nexport interface CallApiPlugin<TCallApiContext extends CallApiContext = DefaultCallApiContext> {\n\t/**\n\t * Defines additional options that can be passed to callApi\n\t */\n\tdefineExtraOptions?: () => TCallApiContext[\"InferredExtraOptions\"];\n\n\t/**\n\t * A description for the plugin\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Hooks for the plugin\n\t */\n\thooks?:\n\t\t| PluginHooks<TCallApiContext>\n\t\t| ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginHooks<TCallApiContext>>);\n\n\t/**\n\t * A unique id for the plugin\n\t */\n\tid: string;\n\n\t/**\n\t * Middlewares that for the plugin\n\t */\n\tmiddlewares?:\n\t\t| PluginMiddlewares<TCallApiContext>\n\t\t| ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginMiddlewares<TCallApiContext>>);\n\n\t/**\n\t * A name for the plugin\n\t */\n\tname: string;\n\n\t/**\n\t * Base schema for the client.\n\t */\n\tschema?: BaseCallApiSchemaAndConfig;\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\tsetup?: (\n\t\tcontext: PluginSetupContext<TCallApiContext>\n\t) => Awaitable<PluginInitResult<TCallApiContext>> | Awaitable<void>;\n\n\t/**\n\t * A version for the plugin\n\t */\n\tversion?: string;\n}\n\nexport type InferPluginExtraOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<\n\tTPluginArray extends Array<infer TPlugin> ?\n\t\tTPlugin extends CallApiPlugin ?\n\t\t\tTPlugin[\"defineExtraOptions\"] extends AnyFunction<infer TResult> ?\n\t\t\t\tInferSchemaOutput<TResult, TResult>\n\t\t\t:\tnever\n\t\t:\tnever\n\t:\tnever\n>;\n\nexport const getResolvedPlugins = (context: Pick<RequestContext, \"baseConfig\" | \"options\">) => {\n\tconst { baseConfig, options } = context;\n\n\tconst resolvedPlugins =\n\t\tisFunction(options.plugins) ?\n\t\t\toptions.plugins({ basePlugins: baseConfig.plugins ?? [] })\n\t\t:\t(options.plugins ?? []);\n\n\treturn resolvedPlugins;\n};\n\nexport const initializePlugins = async (setupContext: PluginSetupContext) => {\n\tconst { baseConfig, config, initURL, options, request } = setupContext;\n\n\tconst {\n\t\taddMainHooks,\n\t\taddMainMiddlewares,\n\t\taddPluginHooks,\n\t\taddPluginMiddlewares,\n\t\tgetResolvedHooks,\n\t\tgetResolvedMiddlewares,\n\t} = setupHooksAndMiddlewares({ baseConfig, config, options });\n\n\tconst initURLResult = getCurrentRouteSchemaKeyAndMainInitURL({\n\t\tbaseExtraOptions: baseConfig,\n\t\textraOptions: config,\n\t\tinitURL,\n\t});\n\n\tlet resolvedCurrentRouteSchemaKey = initURLResult.currentRouteSchemaKey;\n\tlet resolvedInitURL = initURLResult.mainInitURL;\n\tconst resolvedOptions = options;\n\tconst resolvedRequest = Object.assign(request, {\n\t\theaders: getResolvedHeaders({ baseHeaders: baseConfig.headers, headers: config.headers }),\n\t\tmethod: getMethod({ initURL: resolvedInitURL, method: request.method }),\n\t});\n\n\tconst executePluginSetupFn = async (pluginSetup: CallApiPlugin[\"setup\"]) => {\n\t\tif (!pluginSetup) return;\n\n\t\tconst initResult = await pluginSetup(setupContext);\n\n\t\tif (!initResult) return;\n\n\t\tconst urlString = initResult.initURL?.toString();\n\n\t\tif (isString(urlString)) {\n\t\t\tconst newURLResult = getCurrentRouteSchemaKeyAndMainInitURL({\n\t\t\t\tbaseExtraOptions: baseConfig,\n\t\t\t\textraOptions: config,\n\t\t\t\tinitURL: urlString,\n\t\t\t});\n\n\t\t\tresolvedCurrentRouteSchemaKey = newURLResult.currentRouteSchemaKey;\n\t\t\tresolvedInitURL = newURLResult.mainInitURL;\n\t\t}\n\n\t\tif (initResult.request) {\n\t\t\tObject.assign(resolvedRequest, initResult.request);\n\t\t}\n\n\t\tif (initResult.options) {\n\t\t\tObject.assign(resolvedOptions, initResult.options);\n\t\t}\n\t};\n\n\tconst resolvedPlugins = getResolvedPlugins({ baseConfig, options });\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\tconst [, pluginHooks, pluginMiddlewares] = await Promise.all([\n\t\t\texecutePluginSetupFn(plugin.setup),\n\t\t\tisFunction(plugin.hooks) ? plugin.hooks(setupContext) : plugin.hooks,\n\t\t\tisFunction(plugin.middlewares) ? plugin.middlewares(setupContext) : plugin.middlewares,\n\t\t]);\n\n\t\tpluginHooks && addPluginHooks(pluginHooks);\n\t\tpluginMiddlewares && addPluginMiddlewares(pluginMiddlewares);\n\t}\n\n\taddMainHooks();\n\n\taddMainMiddlewares();\n\n\tconst resolvedHooks = getResolvedHooks();\n\n\tconst resolvedMiddlewares = getResolvedMiddlewares();\n\n\treturn {\n\t\tresolvedCurrentRouteSchemaKey,\n\t\tresolvedHooks,\n\t\tresolvedInitURL,\n\t\tresolvedMiddlewares,\n\t\tresolvedOptions,\n\t\tresolvedRequest,\n\t};\n};\n\nconst setupHooksAndMiddlewares = (\n\tcontext: Pick<PluginSetupContext, \"baseConfig\" | \"config\" | \"options\">\n) => {\n\tconst { baseConfig, config, options } = context;\n\n\tconst { hookRegistries, hookRegistryKeys } = getHookRegistriesAndKeys();\n\n\tconst { middlewareRegistries, middlewareRegistryKeys } = getMiddlewareRegistriesAndKeys();\n\n\tconst addMainHooks = () => {\n\t\tfor (const hookName of hookRegistryKeys) {\n\t\t\tconst overriddenHook = options[hookName];\n\t\t\tconst baseHook = baseConfig[hookName];\n\t\t\tconst instanceHook = config[hookName];\n\n\t\t\tconst shouldMergeBaseAndInstanceHooks = isArray(baseHook) && instanceHook;\n\n\t\t\tconst mainHook =\n\t\t\t\tshouldMergeBaseAndInstanceHooks ? [baseHook, instanceHook].flat() : overriddenHook;\n\n\t\t\tmainHook && hookRegistries[hookName].add(mainHook as never);\n\t\t}\n\t};\n\n\tconst addPluginHooks = (pluginHooks: PluginHooks) => {\n\t\tfor (const hookName of hookRegistryKeys) {\n\t\t\tconst pluginHook = pluginHooks[hookName];\n\n\t\t\tpluginHook && hookRegistries[hookName].add(pluginHook as never);\n\t\t}\n\t};\n\n\tconst addMainMiddlewares = () => {\n\t\tfor (const middlewareName of middlewareRegistryKeys) {\n\t\t\tconst baseMiddleware = baseConfig[middlewareName];\n\t\t\tconst instanceMiddleware = config[middlewareName];\n\n\t\t\tbaseMiddleware && middlewareRegistries[middlewareName].add(baseMiddleware);\n\n\t\t\tinstanceMiddleware && middlewareRegistries[middlewareName].add(instanceMiddleware);\n\t\t}\n\t};\n\n\tconst addPluginMiddlewares = (pluginMiddlewares: PluginMiddlewares) => {\n\t\tfor (const middlewareName of middlewareRegistryKeys) {\n\t\t\tconst pluginMiddleware = pluginMiddlewares[middlewareName];\n\n\t\t\tif (!pluginMiddleware) continue;\n\n\t\t\tmiddlewareRegistries[middlewareName].add(pluginMiddleware);\n\t\t}\n\t};\n\n\tconst getResolvedHooks = () => {\n\t\tconst resolvedHooks: Hooks = {};\n\n\t\tfor (const [hookName, hookRegistry] of Object.entries(hookRegistries)) {\n\t\t\tif (hookRegistry.size === 0) continue;\n\n\t\t\t// == Flatten the hook registry to remove any nested arrays, incase an array of hooks is passed to any of the hooks\n\t\t\tconst flattenedHookArray = [...hookRegistry].flat();\n\n\t\t\tif (flattenedHookArray.length === 0) continue;\n\n\t\t\tconst hooksExecutionMode = options.hooksExecutionMode ?? extraOptionDefaults.hooksExecutionMode;\n\n\t\t\tconst composedHook = composeHooksFromArray(flattenedHookArray, hooksExecutionMode);\n\n\t\t\tresolvedHooks[hookName as keyof Hooks] = composedHook;\n\t\t}\n\n\t\treturn resolvedHooks;\n\t};\n\n\tconst getResolvedMiddlewares = () => {\n\t\tconst resolvedMiddlewares: Middlewares = {};\n\n\t\tfor (const [middlewareName, middlewareRegistry] of Object.entries(middlewareRegistries)) {\n\t\t\tif (middlewareRegistry.size === 0) continue;\n\n\t\t\tconst middlewareArray = [...middlewareRegistry];\n\n\t\t\tif (middlewareArray.length === 0) continue;\n\n\t\t\tconst composedMiddleware = composeMiddlewaresFromArray(middlewareArray);\n\n\t\t\tresolvedMiddlewares[middlewareName as keyof Middlewares] = composedMiddleware;\n\t\t}\n\n\t\treturn resolvedMiddlewares;\n\t};\n\n\treturn {\n\t\taddMainHooks,\n\t\taddMainMiddlewares,\n\t\taddPluginHooks,\n\t\taddPluginMiddlewares,\n\t\tgetResolvedHooks,\n\t\tgetResolvedMiddlewares,\n\t};\n};\n","import { extraOptionDefaults } from \"./constants/defaults\";\nimport {\n\texecuteHooksInCatchBlock,\n\ttype ErrorContext,\n\ttype ExecuteHookInfo,\n\ttype RequestContext,\n\ttype RetryContext,\n} from \"./hooks\";\nimport type { CallApiResultErrorVariant } from \"./result\";\nimport type { CallApiConfig } from \"./types/common\";\nimport type { MethodUnion } from \"./types/conditional-types\";\nimport {\n\tdefineEnum,\n\ttype AnyNumber,\n\ttype Awaitable,\n\ttype RemoveDedupeOrRetryPrefix,\n\ttype UnmaskType,\n} from \"./types/type-helpers\";\nimport type { InitURLOrURLObject } from \"./url\";\nimport { waitFor } from \"./utils/common\";\nimport { isBoolean, isFunction, isString } from \"./utils/guards\";\n\n// eslint-disable-next-line ts-eslint/no-unused-vars -- Ignore\nconst defaultRetryStatusCodesLookup = () =>\n\tdefineEnum({\n\t\t408: \"Request Timeout\",\n\t\t409: \"Conflict\",\n\t\t425: \"Too Early\",\n\t\t429: \"Too Many Requests\",\n\t\t500: \"Internal Server Error\",\n\t\t502: \"Bad Gateway\",\n\t\t503: \"Service Unavailable\",\n\t\t504: \"Gateway Timeout\",\n\t});\n\ntype RetryStatusCodes = UnmaskType<AnyNumber | keyof ReturnType<typeof defaultRetryStatusCodesLookup>>;\n\ntype RetryCondition<TErrorData> = (context: ErrorContext<{ ErrorData: TErrorData }>) => Awaitable<boolean>;\n\ntype RetryOptionKeys<TErrorData> = Exclude<keyof RetryOptions<TErrorData>, \"~retryAttemptCount\" | \"retry\">;\n\ntype InnerRetryOptions<TErrorData> = {\n\t[Key in RetryOptionKeys<TErrorData> as RemoveDedupeOrRetryPrefix<\n\t\t\"retry\",\n\t\tKey\n\t>]?: RetryOptions<TErrorData>[Key];\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 * @internal\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?: RetryStatusCodes[];\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)\n\t\t?? extraOptionDefaults.retryDelay;\n\n\treturn resolveRetryDelay;\n};\n\nconst getExponentialDelay = (currentAttemptCount: number, options: RetryOptions<unknown>) => {\n\tconst retryDelay = options.retryDelay ?? options.retry?.delay ?? extraOptionDefaults.retryDelay;\n\n\tconst resolvedRetryDelay = isFunction(retryDelay) ? retryDelay(currentAttemptCount) : retryDelay;\n\n\tconst maxDelay = options.retryMaxDelay ?? options.retry?.maxDelay ?? extraOptionDefaults.retryMaxDelay;\n\n\tconst exponentialDelay = resolvedRetryDelay * 2 ** currentAttemptCount;\n\n\treturn Math.min(exponentialDelay, maxDelay);\n};\n\nexport const createRetryManager = (ctx: ErrorContext<{ ErrorData: unknown }> & RequestContext) => {\n\tconst { options, request } = 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 =\n\t\toptions.retryStrategy ?? options.retry?.strategy ?? extraOptionDefaults.retryStrategy;\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\tif (isBoolean(request.signal) && request.signal.aborted) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst retryCondition =\n\t\t\toptions.retryCondition ?? options.retry?.condition ?? extraOptionDefaults.retryCondition;\n\n\t\tconst maximumRetryAttempts =\n\t\t\toptions.retryAttempts ?? options.retry?.attempts ?? extraOptionDefaults.retryAttempts;\n\n\t\tconst customRetryCondition = await retryCondition(ctx);\n\n\t\tconst baseShouldRetry = currentAttemptCount <= maximumRetryAttempts && customRetryCondition;\n\n\t\tif (!baseShouldRetry) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst retryMethods = new Set(\n\t\t\toptions.retryMethods ?? options.retry?.methods ?? extraOptionDefaults.retryMethods\n\t\t);\n\n\t\tconst includesMethod =\n\t\t\tisString(ctx.request.method) && retryMethods.size > 0 ?\n\t\t\t\tretryMethods.has(ctx.request.method)\n\t\t\t:\ttrue;\n\n\t\tconst retryStatusCodes = new Set(\n\t\t\toptions.retryStatusCodes ?? options.retry?.statusCodes ?? extraOptionDefaults.retryStatusCodes\n\t\t);\n\n\t\tconst includesStatusCodes =\n\t\t\tctx.response != null && retryStatusCodes.size > 0 ?\n\t\t\t\tretryStatusCodes.has(ctx.response.status)\n\t\t\t:\ttrue;\n\n\t\tconst shouldRetry = includesMethod && includesStatusCodes;\n\n\t\treturn shouldRetry;\n\t};\n\n\ttype CallApiImpl = (\n\t\tinitURL: never,\n\t\tinit?: CallApiConfig\n\t) => Promise<CallApiResultErrorVariant<unknown>>;\n\n\tconst handleRetry = async <TCallapi extends CallApiImpl>(context: {\n\t\tcallApi: TCallapi;\n\t\tcallApiArgs: { config: CallApiConfig; initURL: InitURLOrURLObject };\n\t\terrorContext: ErrorContext<{ ErrorData: unknown }>;\n\t\thookInfo: ExecuteHookInfo;\n\t}) => {\n\t\tconst { callApi, callApiArgs, errorContext, hookInfo } = context;\n\n\t\tconst retryContext = {\n\t\t\t...errorContext,\n\t\t\tretryAttemptCount: currentAttemptCount,\n\t\t} satisfies RetryContext<{ ErrorData: unknown }>;\n\n\t\tconst hookError = await executeHooksInCatchBlock([options.onRetry?.(retryContext)], hookInfo);\n\n\t\tif (hookError) {\n\t\t\treturn hookError;\n\t\t}\n\n\t\tawait waitFor(getDelay());\n\n\t\tconst updatedOptions = {\n\t\t\t...callApiArgs.config,\n\t\t\t\"~retryAttemptCount\": currentAttemptCount + 1,\n\t\t} satisfies CallApiConfig;\n\n\t\treturn callApi(callApiArgs.initURL as never, updatedOptions);\n\t};\n\n\treturn {\n\t\thandleRetry,\n\t\tshouldAttemptRetry,\n\t};\n};\n","import { createDedupeStrategy, type GlobalRequestInfoCache, type RequestInfoCache } from \"./dedupe\";\nimport {\n\ttype ErrorContext,\n\ttype ExecuteHookInfo,\n\texecuteHooks,\n\texecuteHooksInCatchBlock,\n\ttype RequestContext,\n\ttype SuccessContext,\n} from \"./hooks\";\nimport { type CallApiPlugin, initializePlugins } from \"./plugins\";\nimport {\n\ttype ErrorInfo,\n\tgetCustomizedErrorResult,\n\ttype GetResponseType,\n\tresolveErrorResult,\n\tresolveResponseData,\n\tresolveSuccessResult,\n\ttype ResponseTypeType,\n\ttype ResultModeType,\n} from \"./result\";\nimport { createRetryManager } from \"./retry\";\nimport type {\n\tBaseCallApiConfig,\n\tCallApiConfig,\n\tCallApiContext,\n\tCallApiExtraOptionsForHooks,\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n\tCallApiResult,\n\tGetBaseSchemaConfig,\n\tGetBaseSchemaRoutes,\n} from \"./types/common\";\nimport type {\n\tGetCurrentRouteSchema,\n\tGetCurrentRouteSchemaKey,\n\tInferInitURL,\n\tThrowOnErrorUnion,\n} from \"./types/conditional-types\";\nimport type {\n\tDefaultCallApiContext,\n\tDefaultPluginArray,\n\tDefaultThrowOnError,\n} from \"./types/default-types\";\nimport type { AnyFunction } from \"./types/type-helpers\";\nimport { getFullAndNormalizedURL } from \"./url\";\nimport {\n\tcreateCombinedSignal,\n\tcreateTimeoutSignal,\n\tgetBody,\n\tgetFetchImpl,\n\tgetHeaders,\n\tgetMethod,\n\tsplitBaseConfig,\n\tsplitConfig,\n} from \"./utils/common\";\nimport { HTTPError } from \"./utils/external/error\";\nimport { isHTTPErrorInstance, isValidationErrorInstance } from \"./utils/external/guards\";\nimport { isFunction } from \"./utils/guards\";\nimport {\n\ttype BaseCallApiSchemaAndConfig,\n\ttype BaseCallApiSchemaRoutes,\n\ttype CallApiSchema,\n\ttype CallApiSchemaConfig,\n\thandleConfigValidation,\n\thandleSchemaValidation,\n\ttype InferSchemaOutput,\n} from \"./validation\";\n\nconst $GlobalRequestInfoCache: GlobalRequestInfoCache = new Map();\n\nexport const createFetchClientWithContext = <\n\tTOuterCallApiContext extends CallApiContext = DefaultCallApiContext,\n>() => {\n\tconst createFetchClient = <\n\t\tTBaseCallApiContext extends CallApiContext = TOuterCallApiContext,\n\t\tTBaseData = TBaseCallApiContext[\"Data\"],\n\t\tTBaseErrorData = TBaseCallApiContext[\"ErrorData\"],\n\t\tTBaseResultMode extends ResultModeType = TBaseCallApiContext[\"ResultMode\"] extends ResultModeType ?\n\t\t\tTBaseCallApiContext[\"ResultMode\"]\n\t\t:\tDefaultCallApiContext[\"ResultMode\"],\n\t\tTBaseThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError,\n\t\tTBaseResponseType extends ResponseTypeType = ResponseTypeType,\n\t\tconst TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig,\n\t\tconst TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray,\n\t\tTComputedBaseSchemaConfig extends CallApiSchemaConfig = GetBaseSchemaConfig<TBaseSchemaAndConfig>,\n\t\tTComputedBaseSchemaRoutes extends BaseCallApiSchemaRoutes =\n\t\t\tGetBaseSchemaRoutes<TBaseSchemaAndConfig>,\n\t\t// TComputedBaseData = GetResponseType<TBaseData, TBaseResponseType>,\n\t\t// TComputedBaseErrorData = GetResponseType<TBaseErrorData, TBaseResponseType>,\n\t>(\n\t\tinitBaseConfig: BaseCallApiConfig<\n\t\t\tTBaseCallApiContext,\n\t\t\tTBaseData,\n\t\t\tTBaseErrorData,\n\t\t\tTBaseResultMode,\n\t\t\tTBaseThrowOnError,\n\t\t\tTBaseResponseType,\n\t\t\tTBaseSchemaAndConfig,\n\t\t\tTBasePluginArray\n\t\t> = {} as never\n\t) => {\n\t\tconst $LocalRequestInfoCache: RequestInfoCache = new Map();\n\n\t\tconst callApi = async <\n\t\t\tTData = TBaseData,\n\t\t\tTErrorData = TBaseErrorData,\n\t\t\tTResultMode extends ResultModeType = TBaseResultMode,\n\t\t\tTCallApiContext extends CallApiContext = TBaseCallApiContext,\n\t\t\tTThrowOnError extends ThrowOnErrorUnion = TBaseThrowOnError,\n\t\t\tTResponseType extends ResponseTypeType = TBaseResponseType,\n\t\t\tconst TSchemaConfig extends CallApiSchemaConfig = TComputedBaseSchemaConfig,\n\t\t\tTInitURL extends InferInitURL<TComputedBaseSchemaRoutes, TSchemaConfig> = InferInitURL<\n\t\t\t\tTComputedBaseSchemaRoutes,\n\t\t\t\tTSchemaConfig\n\t\t\t>,\n\t\t\tTCurrentRouteSchemaKey extends GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL> =\n\t\t\t\tGetCurrentRouteSchemaKey<TSchemaConfig, TInitURL>,\n\t\t\tconst TSchema extends CallApiSchema = GetCurrentRouteSchema<\n\t\t\t\tTComputedBaseSchemaRoutes,\n\t\t\t\tTCurrentRouteSchemaKey\n\t\t\t>,\n\t\t\tconst TPluginArray extends CallApiPlugin[] = TBasePluginArray,\n\t\t\tTComputedData = InferSchemaOutput<TSchema[\"data\"], GetResponseType<TData, TResponseType>>,\n\t\t\tTComputedErrorData = InferSchemaOutput<\n\t\t\t\tTSchema[\"errorData\"],\n\t\t\t\tGetResponseType<TErrorData, TResponseType>\n\t\t\t>,\n\t\t\tTComputedResult = CallApiResult<TComputedData, TComputedErrorData, TResultMode, TThrowOnError>,\n\t\t>(\n\t\t\tinitURL: TInitURL,\n\t\t\tinitConfig: CallApiConfig<\n\t\t\t\tTCallApiContext,\n\t\t\t\tTComputedData,\n\t\t\t\tTComputedErrorData,\n\t\t\t\tTResultMode,\n\t\t\t\tTThrowOnError,\n\t\t\t\tTResponseType,\n\t\t\t\tTComputedBaseSchemaRoutes,\n\t\t\t\tTSchema,\n\t\t\t\tTComputedBaseSchemaConfig,\n\t\t\t\tTSchemaConfig,\n\t\t\t\tTInitURL,\n\t\t\t\tTCurrentRouteSchemaKey,\n\t\t\t\tTBasePluginArray,\n\t\t\t\tTPluginArray\n\t\t\t> = {} as never\n\t\t): Promise<TComputedResult> => {\n\t\t\tconst [fetchOptions, extraOptions] = splitConfig(initConfig);\n\n\t\t\tconst resolvedBaseConfig =\n\t\t\t\tisFunction(initBaseConfig) ?\n\t\t\t\t\tinitBaseConfig({\n\t\t\t\t\t\tinitURL: initURL.toString(),\n\t\t\t\t\t\toptions: extraOptions,\n\t\t\t\t\t\trequest: fetchOptions,\n\t\t\t\t\t})\n\t\t\t\t:\tinitBaseConfig;\n\n\t\t\tconst baseConfig = resolvedBaseConfig as Exclude<BaseCallApiConfig, AnyFunction>;\n\t\t\tconst config = initConfig as CallApiConfig;\n\n\t\t\tconst [baseFetchOptions, baseExtraOptions] = splitBaseConfig(baseConfig);\n\n\t\t\tconst shouldSkipAutoMergeForOptions =\n\t\t\t\tbaseExtraOptions.skipAutoMergeFor === \"all\" || baseExtraOptions.skipAutoMergeFor === \"options\";\n\n\t\t\tconst shouldSkipAutoMergeForRequest =\n\t\t\t\tbaseExtraOptions.skipAutoMergeFor === \"all\" || baseExtraOptions.skipAutoMergeFor === \"request\";\n\n\t\t\t// == Merged Extra Options\n\t\t\tconst mergedExtraOptions = {\n\t\t\t\t...baseExtraOptions,\n\t\t\t\t...(!shouldSkipAutoMergeForOptions && extraOptions),\n\t\t\t};\n\n\t\t\t// == Merged Request Options\n\t\t\tconst mergedRequestOptions = {\n\t\t\t\t...baseFetchOptions,\n\t\t\t\t...(!shouldSkipAutoMergeForRequest && fetchOptions),\n\t\t\t} satisfies CallApiRequestOptions;\n\n\t\t\tconst {\n\t\t\t\tresolvedCurrentRouteSchemaKey,\n\t\t\t\tresolvedHooks,\n\t\t\t\tresolvedInitURL,\n\t\t\t\tresolvedMiddlewares,\n\t\t\t\tresolvedOptions,\n\t\t\t\tresolvedRequest,\n\t\t\t} = await initializePlugins({\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\tinitURL: initURL.toString(),\n\t\t\t\toptions: mergedExtraOptions as CallApiExtraOptionsForHooks,\n\t\t\t\trequest: mergedRequestOptions as CallApiRequestOptionsForHooks,\n\t\t\t});\n\n\t\t\tconst { fullURL, normalizedInitURL } = getFullAndNormalizedURL({\n\t\t\t\tbaseURL: resolvedOptions.baseURL,\n\t\t\t\tinitURL: resolvedInitURL,\n\t\t\t\tparams: resolvedOptions.params,\n\t\t\t\tquery: resolvedOptions.query,\n\t\t\t});\n\n\t\t\tconst options = {\n\t\t\t\t...resolvedOptions,\n\t\t\t\t...resolvedHooks,\n\t\t\t\t...resolvedMiddlewares,\n\n\t\t\t\tfullURL,\n\t\t\t\tinitURL: resolvedInitURL,\n\t\t\t\tinitURLNormalized: normalizedInitURL,\n\t\t\t} satisfies CallApiExtraOptionsForHooks;\n\n\t\t\tconst newFetchController = new AbortController();\n\n\t\t\tconst timeoutSignal = createTimeoutSignal(options.timeout);\n\n\t\t\tconst combinedSignal = createCombinedSignal(\n\t\t\t\ttimeoutSignal,\n\t\t\t\tresolvedRequest.signal,\n\t\t\t\tnewFetchController.signal\n\t\t\t);\n\n\t\t\tconst request = {\n\t\t\t\t...resolvedRequest,\n\n\t\t\t\tsignal: combinedSignal,\n\t\t\t} satisfies CallApiRequestOptionsForHooks;\n\n\t\t\tconst {\n\t\t\t\tgetAbortErrorMessage,\n\t\t\t\thandleRequestCancelStrategy,\n\t\t\t\thandleRequestDeferStrategy,\n\t\t\t\tremoveDedupeKeyFromCache,\n\t\t\t\tresolvedDedupeStrategy,\n\t\t\t} = await createDedupeStrategy({\n\t\t\t\t$GlobalRequestInfoCache,\n\t\t\t\t$LocalRequestInfoCache,\n\t\t\t\tbaseConfig,\n\t\t\t\tconfig,\n\t\t\t\tnewFetchController,\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\tawait handleRequestCancelStrategy();\n\n\t\t\t\tawait executeHooks(options.onRequest?.({ baseConfig, config, options, request }));\n\n\t\t\t\tconst {\n\t\t\t\t\textraOptionsValidationResult,\n\t\t\t\t\trequestOptionsValidationResult,\n\t\t\t\t\tresolvedSchema,\n\t\t\t\t\tresolvedSchemaConfig,\n\t\t\t\t} = await handleConfigValidation({\n\t\t\t\t\tbaseExtraOptions,\n\t\t\t\t\tcurrentRouteSchemaKey: resolvedCurrentRouteSchemaKey,\n\t\t\t\t\textraOptions,\n\t\t\t\t\toptions,\n\t\t\t\t\trequest,\n\t\t\t\t});\n\n\t\t\t\t// == Apply Schema Output for Extra Options\n\t\t\t\tObject.assign(options, extraOptionsValidationResult);\n\n\t\t\t\t// == Apply Schema Output for Request Options\n\t\t\t\tObject.assign(request, {\n\t\t\t\t\tbody: getBody({\n\t\t\t\t\t\tbody: requestOptionsValidationResult.body,\n\t\t\t\t\t\tbodySerializer: options.bodySerializer,\n\t\t\t\t\t\tresolvedHeaders: requestOptionsValidationResult.headers,\n\t\t\t\t\t}),\n\t\t\t\t\theaders: await getHeaders({\n\t\t\t\t\t\tauth: options.auth,\n\t\t\t\t\t\tbody: requestOptionsValidationResult.body,\n\t\t\t\t\t\tresolvedHeaders: requestOptionsValidationResult.headers,\n\t\t\t\t\t}),\n\t\t\t\t\tmethod: getMethod({\n\t\t\t\t\t\tinitURL: resolvedInitURL,\n\t\t\t\t\t\tmethod: requestOptionsValidationResult.method,\n\t\t\t\t\t}),\n\t\t\t\t});\n\n\t\t\t\tconst readyRequestContext = { baseConfig, config, options, request } satisfies RequestContext;\n\n\t\t\t\tawait executeHooks(options.onRequestReady?.(readyRequestContext));\n\n\t\t\t\tconst fetchApi = getFetchImpl({\n\t\t\t\t\tcustomFetchImpl: options.customFetchImpl,\n\t\t\t\t\tfetchMiddleware: options.fetchMiddleware,\n\t\t\t\t\trequestContext: readyRequestContext,\n\t\t\t\t});\n\n\t\t\t\tconst response = await handleRequestDeferStrategy({ fetchApi, options, request });\n\n\t\t\t\t// == Also clone response when dedupeStrategy is set to \"defer\" to avoid error thrown from reading response.(whatever) more than once\n\t\t\t\tconst shouldCloneResponse = resolvedDedupeStrategy === \"defer\" || options.cloneResponse;\n\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tconst errorData = await resolveResponseData(\n\t\t\t\t\t\tshouldCloneResponse ? response.clone() : response,\n\t\t\t\t\t\toptions.responseType,\n\t\t\t\t\t\toptions.responseParser\n\t\t\t\t\t);\n\n\t\t\t\t\tconst validErrorData = await handleSchemaValidation(resolvedSchema, \"errorData\", {\n\t\t\t\t\t\tinputValue: errorData,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t\t\t\t});\n\n\t\t\t\t\t// == Push all error handling responsibilities to the catch block if not retrying\n\t\t\t\t\tthrow new HTTPError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdefaultHTTPErrorMessage: options.defaultHTTPErrorMessage,\n\t\t\t\t\t\t\terrorData: validErrorData,\n\t\t\t\t\t\t\tresponse,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ cause: validErrorData }\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst successData = await resolveResponseData(\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 validSuccessData = await handleSchemaValidation(resolvedSchema, \"data\", {\n\t\t\t\t\tinputValue: successData,\n\t\t\t\t\tresponse,\n\t\t\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t\t\t});\n\n\t\t\t\tconst successContext = {\n\t\t\t\t\tbaseConfig,\n\t\t\t\t\tconfig,\n\t\t\t\t\tdata: validSuccessData,\n\t\t\t\t\toptions,\n\t\t\t\t\trequest,\n\t\t\t\t\tresponse,\n\t\t\t\t} satisfies SuccessContext;\n\n\t\t\t\tawait executeHooks(\n\t\t\t\t\toptions.onSuccess?.(successContext),\n\n\t\t\t\t\toptions.onResponse?.({ ...successContext, error: null })\n\t\t\t\t);\n\n\t\t\t\tconst successResult = resolveSuccessResult(successContext.data, {\n\t\t\t\t\tresponse: successContext.response,\n\t\t\t\t\tresultMode: options.resultMode,\n\t\t\t\t});\n\n\t\t\t\treturn successResult as never;\n\n\t\t\t\t// == Exhaustive Error handling\n\t\t\t} catch (error) {\n\t\t\t\tconst errorInfo = {\n\t\t\t\t\tcloneResponse: options.cloneResponse,\n\t\t\t\t\tresultMode: options.resultMode,\n\t\t\t\t} satisfies ErrorInfo;\n\n\t\t\t\tconst { errorDetails, errorResult } = resolveErrorResult(error, errorInfo);\n\n\t\t\t\tconst errorContext = {\n\t\t\t\t\tbaseConfig,\n\t\t\t\t\tconfig,\n\t\t\t\t\terror: errorDetails.error as never,\n\t\t\t\t\toptions,\n\t\t\t\t\trequest,\n\t\t\t\t\tresponse: errorDetails.response as never,\n\t\t\t\t} satisfies ErrorContext<{ ErrorData: unknown }>;\n\n\t\t\t\tconst shouldThrowOnError = Boolean(\n\t\t\t\t\tisFunction(options.throwOnError) ? options.throwOnError(errorContext) : options.throwOnError\n\t\t\t\t);\n\n\t\t\t\tconst hookInfo = {\n\t\t\t\t\terrorInfo,\n\t\t\t\t\tshouldThrowOnError,\n\t\t\t\t} satisfies ExecuteHookInfo;\n\n\t\t\t\tconst { handleRetry, shouldAttemptRetry } = createRetryManager(errorContext);\n\n\t\t\t\tconst handleRetryOrGetErrorResult = async () => {\n\t\t\t\t\tconst shouldRetry = await shouldAttemptRetry();\n\n\t\t\t\t\tif (shouldRetry) {\n\t\t\t\t\t\treturn handleRetry({\n\t\t\t\t\t\t\tcallApi,\n\t\t\t\t\t\t\tcallApiArgs: { config, initURL },\n\t\t\t\t\t\t\terrorContext,\n\t\t\t\t\t\t\thookInfo,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tif (shouldThrowOnError) {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn errorResult;\n\t\t\t\t};\n\n\t\t\t\tif (isValidationErrorInstance(error)) {\n\t\t\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t\t\t[options.onValidationError?.(errorContext), options.onError?.(errorContext)],\n\t\t\t\t\t\thookInfo\n\t\t\t\t\t);\n\n\t\t\t\t\treturn (hookError ?? (await handleRetryOrGetErrorResult())) as never;\n\t\t\t\t}\n\n\t\t\t\tif (isHTTPErrorInstance<TErrorData>(error)) {\n\t\t\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\toptions.onResponseError?.(errorContext),\n\t\t\t\t\t\t\toptions.onError?.(errorContext),\n\t\t\t\t\t\t\toptions.onResponse?.({ ...errorContext, data: null }),\n\t\t\t\t\t\t],\n\t\t\t\t\t\thookInfo\n\t\t\t\t\t);\n\n\t\t\t\t\treturn (hookError ?? (await handleRetryOrGetErrorResult())) as never;\n\t\t\t\t}\n\n\t\t\t\tlet message = (error as Error | undefined)?.message;\n\n\t\t\t\tif (error instanceof DOMException && error.name === \"AbortError\") {\n\t\t\t\t\tmessage = getAbortErrorMessage();\n\n\t\t\t\t\t!shouldThrowOnError && console.error(`${error.name}:`, message);\n\t\t\t\t}\n\n\t\t\t\tif (error instanceof DOMException && error.name === \"TimeoutError\") {\n\t\t\t\t\tmessage = `Request timed out after ${options.timeout}ms`;\n\n\t\t\t\t\t!shouldThrowOnError && console.error(`${error.name}:`, message);\n\t\t\t\t}\n\n\t\t\t\tconst hookError = await executeHooksInCatchBlock(\n\t\t\t\t\t[options.onRequestError?.(errorContext), options.onError?.(errorContext)],\n\t\t\t\t\thookInfo\n\t\t\t\t);\n\n\t\t\t\treturn (hookError\n\t\t\t\t\t?? getCustomizedErrorResult(await handleRetryOrGetErrorResult(), { message })) as never;\n\n\t\t\t\t// == Removing the now unneeded AbortController from store\n\t\t\t} finally {\n\t\t\t\tremoveDedupeKeyFromCache();\n\t\t\t}\n\t\t};\n\n\t\treturn callApi;\n\t};\n\n\treturn createFetchClient;\n};\n\nexport const createFetchClient = createFetchClientWithContext();\n\nexport const callApi = createFetchClient();\n"],"mappings":";;;;;AA8DA,MAAM,oBAA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yBACvB;KACC,QAAQ,kBAAkB,aAAa;KACvC,QAAQ,UAAU,aAAa;KAC/B,QAAQ,aAAa;MAAE,GAAG;MAAc,MAAM;MAAM,CAAC;KACrD,EACD,SACA,IAEqB,MAAM,6BAA6B;IAG1D,IAAI,UAAW,OAA6B;AAE5C,QAAI,iBAAiB,gBAAgB,MAAM,SAAS,cAAc;AACjE,eAAU,sBAAsB;AAEhC,MAAC,sBAAsB,QAAQ,MAAM,GAAG,MAAM,KAAK,IAAI,QAAQ;;AAGhE,QAAI,iBAAiB,gBAAgB,MAAM,SAAS,gBAAgB;AACnE,eAAU,2BAA2B,QAAQ,QAAQ;AAErD,MAAC,sBAAsB,QAAQ,MAAM,GAAG,MAAM,KAAK,IAAI,QAAQ;;AAQhE,WALkB,MAAM,yBACvB,CAAC,QAAQ,iBAAiB,aAAa,EAAE,QAAQ,UAAU,aAAa,CAAC,EACzE,SACA,IAGG,yBAAyB,MAAM,6BAA6B,EAAE,EAAE,SAAS,CAAC;aAGrE;AACT,8BAA0B;;;AAI5B,SAAOA;;AAGR,QAAOF;;AAGR,MAAa,oBAAoB,8BAA8B;AAE/D,MAAa,UAAU,mBAAmB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as BaseCallApiSchemaRoutes, M as ValidationError, R as CallApiSchema, a as CallApiPlugin, f as PossibleHTTPError, h as PossibleValidationError, j as HTTPError, l as CallApiResultErrorVariant, nt as Satisfies, p as PossibleJavaScriptError, rt as Writeable, tt as AnyFunction, v as BaseCallApiConfig, w as CallApiRequestOptions, z as CallApiSchemaConfig } from "../../index-
|
|
1
|
+
import { I as BaseCallApiSchemaRoutes, M as ValidationError, R as CallApiSchema, a as CallApiPlugin, f as PossibleHTTPError, h as PossibleValidationError, j as HTTPError, l as CallApiResultErrorVariant, nt as Satisfies, p as PossibleJavaScriptError, rt as Writeable, tt as AnyFunction, v as BaseCallApiConfig, w as CallApiRequestOptions, z as CallApiSchemaConfig } from "../../index-DGGInQcS.js";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/external/body.d.ts
|
|
4
4
|
declare const toQueryString: (data: NonNullable<CallApiRequestOptions["body"]>) => string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zayne-labs/callapi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.11.
|
|
4
|
+
"version": "1.11.37",
|
|
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",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"playwright": "^1.57.0",
|
|
50
50
|
"publint": "^0.3.16",
|
|
51
51
|
"size-limit": "12.0.0",
|
|
52
|
-
"tsdown": "0.18.
|
|
52
|
+
"tsdown": "0.18.1",
|
|
53
53
|
"typescript": "5.9.3",
|
|
54
54
|
"vitest": "^4.0.16",
|
|
55
55
|
"zod": "^4.2.1"
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"size-limit": [
|
|
63
63
|
{
|
|
64
64
|
"path": "./src/index.ts",
|
|
65
|
-
"limit": "6.
|
|
65
|
+
"limit": "6.8 kb"
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
"path": "./src/utils/external/index.ts",
|