@zayne-labs/callapi 1.6.1 → 1.6.12

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.
@@ -300,8 +300,10 @@ type MetaOption<TSchemas extends CallApiSchemas> = {
300
300
  };
301
301
  type ResultModeOption<TErrorData, TResultMode extends ResultModeUnion> = TErrorData extends false ? {
302
302
  resultMode: "onlySuccessWithException";
303
- } : {
303
+ } : undefined extends TResultMode ? {
304
304
  resultMode?: TResultMode;
305
+ } : {
306
+ resultMode: TResultMode;
305
307
  };
306
308
 
307
309
  type FetchSpecificKeysUnion = Exclude<(typeof fetchSpecificKeys)[number], "body" | "headers" | "method">;
@@ -349,7 +351,7 @@ type InterceptorsOrInterceptorArray<TData = DefaultDataType, TErrorData = Defaul
349
351
  [Key in keyof Interceptors<TData, TErrorData, TMoreOptions>]: Interceptors<TData, TErrorData, TMoreOptions>[Key] | Array<Interceptors<TData, TErrorData, TMoreOptions>[Key]>;
350
352
  };
351
353
  type FetchImpl = UnmaskType<(input: string | Request | URL, init?: RequestInit) => Promise<Response>>;
352
- type ExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TSchemas extends CallApiSchemas = DefaultMoreOptions, TPluginArray extends CallApiPlugin[] = DefaultPlugins, TResponseType extends ResponseTypeUnion = ResponseTypeUnion> = {
354
+ type ExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TSchemas extends CallApiSchemas = DefaultMoreOptions, TPluginArray extends CallApiPlugin[] = DefaultPlugins> = {
353
355
  /**
354
356
  * Authorization header value.
355
357
  */
@@ -445,18 +447,18 @@ type ExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResult
445
447
  validators?: CallApiValidators<TData, TErrorData>;
446
448
  } & InterceptorsOrInterceptorArray<TData, TErrorData> & Partial<InferPluginOptions<TPluginArray>> & MetaOption<TSchemas> & RetryOptions<TErrorData> & ResultModeOption<TErrorData, TResultMode> & UrlOptions<TSchemas>;
447
449
  declare const optionsEnumToExtendFromBase: ("plugins" | "schemas" | "validators")[];
448
- type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TSchemas extends CallApiSchemas = DefaultMoreOptions, TPluginArray extends CallApiPlugin[] = DefaultPlugins, TResponseType extends ResponseTypeUnion = ResponseTypeUnion> = CallApiRequestOptions<TSchemas> & ExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType> & {
450
+ type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TSchemas extends CallApiSchemas = DefaultMoreOptions, TPluginArray extends CallApiPlugin[] = DefaultPlugins> = CallApiRequestOptions<TSchemas> & ExtraOptions<TData, TErrorData, TResultMode, TResponseType, TSchemas, TPluginArray> & {
449
451
  /**
450
452
  * Options that should extend the base options.
451
453
  */
452
- extend?: Pick<ExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType>, (typeof optionsEnumToExtendFromBase)[number]>;
454
+ extend?: Pick<ExtraOptions<TData, TErrorData, TResultMode, TResponseType, TSchemas, TPluginArray>, (typeof optionsEnumToExtendFromBase)[number]>;
453
455
  };
454
456
  declare const optionsEnumToOmitFromBase: ("dedupeKey" | "extend")[];
455
- type BaseCallApiExtraOptions<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseSchemas extends CallApiSchemas = DefaultMoreOptions, TBasePluginArray extends CallApiPlugin[] = DefaultPlugins, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion> = Omit<Partial<CallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseSchemas, TBasePluginArray, TBaseResponseType>>, (typeof optionsEnumToOmitFromBase)[number]>;
456
- type CombinedCallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TSchemas extends CallApiSchemas = DefaultMoreOptions, TPluginArray extends CallApiPlugin[] = DefaultPlugins, TResponseType extends ResponseTypeUnion = ResponseTypeUnion> = BaseCallApiExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType> & CallApiExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType>;
457
- type CallApiParameters<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TSchemas extends CallApiSchemas = DefaultMoreOptions, TPluginArray extends CallApiPlugin[] = DefaultPlugins, TResponseType extends ResponseTypeUnion = ResponseTypeUnion> = [
457
+ type BaseCallApiExtraOptions<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchemas extends CallApiSchemas = DefaultMoreOptions, TBasePluginArray extends CallApiPlugin[] = DefaultPlugins> = Omit<Partial<CallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseResponseType, TBaseSchemas, TBasePluginArray>>, (typeof optionsEnumToOmitFromBase)[number]>;
458
+ type CombinedCallApiExtraOptions = BaseCallApiExtraOptions & CallApiExtraOptions;
459
+ type CallApiParameters<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TSchemas extends CallApiSchemas = DefaultMoreOptions, TPluginArray extends CallApiPlugin[] = DefaultPlugins> = [
458
460
  initURL: UrlOptions<TSchemas>["initURL"],
459
- config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType>
461
+ config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TResponseType, TSchemas, TPluginArray>
460
462
  ];
461
463
  type RequestContext = UnmaskType<{
462
464
  options: CombinedCallApiExtraOptions;
@@ -536,6 +538,7 @@ type ResultModeMap<TData = DefaultDataType, TErrorData = DefaultDataType, TRespo
536
538
  onlySuccessWithException: CallApiResultSuccessVariant<TComputedData>["data"];
537
539
  }>;
538
540
  type ResultModeUnion = keyof ResultModeMap | undefined;
539
- type GetCallApiResult<TData, TErrorData, TResultMode extends ResultModeUnion, TResponseType extends ResponseTypeUnion, TComputedMap extends ResultModeMap<TData, TErrorData, TResponseType> = ResultModeMap<TData, TErrorData, TResponseType>> = TErrorData extends false ? TComputedMap["onlySuccessWithException"] : undefined extends TResultMode ? TComputedMap["all"] : TResultMode extends NonNullable<ResultModeUnion> ? TComputedMap[TResultMode] : never;
541
+ type GetCallApiResult<TData, TErrorData, TResultMode extends ResultModeUnion, TResponseType extends ResponseTypeUnion, TComputedMap extends ResultModeMap<TData, TErrorData, TResponseType> = ResultModeMap<TData, TErrorData, TResponseType>> = TErrorData extends false ? TComputedMap["onlySuccessWithException"] : // If TResultMode is the entire ResultModeMap with undefined, we return the "all" variant
542
+ ResultModeUnion | undefined extends TResultMode ? TComputedMap["all"] : TResultMode extends NonNullable<ResultModeUnion> ? TComputedMap[TResultMode] : never;
540
543
 
541
544
  export { type BaseCallApiExtraOptions as B, type CallApiSchemas as C, type DefaultPlugins as D, type ErrorContext as E, type GetCallApiResult as G, type InferSchemaResult as I, type PossibleJavascriptErrorNames as P, type ResultModeUnion as R, type SuccessContext as S, type UrlOptions as U, type ResponseTypeUnion as a, type CallApiPlugin as b, type CallApiExtraOptions as c, type CallApiResultSuccessVariant as d, type CallApiResultErrorVariant as e, definePlugin as f, type PluginInitContext as g, type PossibleJavaScriptError as h, type PossibleHTTPError as i, type CallApiParameters as j, type CallApiRequestOptions as k, type CallApiRequestOptionsForHooks as l, type CombinedCallApiExtraOptions as m, type Interceptors as n, type InterceptorsOrInterceptorArray as o, type Register as p, type RequestContext as q, type RequestErrorContext as r, type ResponseContext as s, type ResponseErrorContext as t, type DefaultDataType as u, defaultRetryMethods as v, defaultRetryStatusCodes as w };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/error.ts","../../src/utils/type-guards.ts","../../src/auth.ts","../../src/utils/type-helpers.ts","../../src/types/common.ts","../../src/utils/constants.ts","../../src/utils/common.ts","../../src/dedupe.ts","../../src/plugins.ts","../../src/validation.ts","../../src/response.ts","../../src/retry.ts","../../src/url.ts","../../src/utils/polyfills.ts","../../src/createFetchClient.ts"],"sourcesContent":["export { callApi, createFetchClient } from \"./createFetchClient\";\n\nexport { definePlugin, type CallApiPlugin, type PluginInitContext } from \"./plugins\";\n\nexport type { InferSchemaResult, CallApiSchemas } from \"./validation\";\n\nexport { HTTPError } from \"./error\";\n\nexport type {\n\tBaseCallApiExtraOptions,\n\tCallApiExtraOptions,\n\tPossibleJavaScriptError,\n\tPossibleHTTPError,\n\tCallApiParameters,\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n\tCallApiResultErrorVariant,\n\tResultModeUnion,\n\tCallApiResultSuccessVariant,\n\tCombinedCallApiExtraOptions,\n\tErrorContext,\n\tInterceptors,\n\tInterceptorsOrInterceptorArray,\n\tPossibleJavascriptErrorNames,\n\tRegister,\n\tRequestContext,\n\tRequestErrorContext,\n\tResponseContext,\n\tResponseErrorContext,\n\tSuccessContext,\n} from \"./types\";\n","import type {\n\tCallApiExtraOptions,\n\tCallApiResultErrorVariant,\n\tPossibleJavascriptErrorNames,\n\tResultModeMap,\n} from \"./types/common\";\nimport { isHTTPErrorInstance, isObject } from \"./utils/type-guards\";\n\ntype ErrorInfo = {\n\tcloneResponse: CallApiExtraOptions[\"cloneResponse\"];\n\tdefaultErrorMessage: Required<CallApiExtraOptions>[\"defaultErrorMessage\"];\n\terror?: unknown;\n\tmessage?: string;\n\tresultMode: CallApiExtraOptions[\"resultMode\"];\n};\n\nexport const resolveErrorResult = <TCallApiResult = never>(info: ErrorInfo) => {\n\tconst { cloneResponse, defaultErrorMessage, error, message: customErrorMessage, resultMode } = info;\n\n\tlet errorVariantDetails: CallApiResultErrorVariant<unknown> = {\n\t\tdata: null,\n\t\terror: {\n\t\t\terrorData: error as Error,\n\t\t\tmessage: customErrorMessage ?? (error as Error).message,\n\t\t\tname: (error as Error).name as PossibleJavascriptErrorNames,\n\t\t},\n\t\tresponse: null,\n\t};\n\n\tif (isHTTPErrorInstance(error)) {\n\t\tconst { errorData, message = defaultErrorMessage, name, response } = error;\n\n\t\terrorVariantDetails = {\n\t\t\tdata: null,\n\t\t\terror: {\n\t\t\t\terrorData,\n\t\t\t\tmessage,\n\t\t\t\tname,\n\t\t\t},\n\t\t\tresponse: cloneResponse ? response.clone() : response,\n\t\t};\n\t}\n\n\tconst resultModeMap: ResultModeMap = {\n\t\tall: errorVariantDetails,\n\t\tonlyError: errorVariantDetails.error,\n\t\tonlyResponse: errorVariantDetails.response,\n\t\tonlySuccess: errorVariantDetails.data,\n\t\tonlySuccessWithException: errorVariantDetails.data,\n\t};\n\n\tconst getErrorResult = (customInfo?: Pick<ErrorInfo, \"message\">) => {\n\t\tconst errorResult = resultModeMap[resultMode ?? \"all\"] as TCallApiResult;\n\n\t\treturn isObject(customInfo) ? { ...errorResult, ...customInfo } : errorResult;\n\t};\n\n\treturn { errorVariantDetails, getErrorResult };\n};\n\ntype ErrorDetails<TErrorResponse> = {\n\tdefaultErrorMessage: string;\n\terrorData: TErrorResponse;\n\tresponse: Response;\n};\n\ntype ErrorOptions = {\n\tcause?: unknown;\n};\n\nexport class HTTPError<TErrorResponse = Record<string, unknown>> extends Error {\n\terrorData: ErrorDetails<TErrorResponse>[\"errorData\"];\n\tisHTTPError = true;\n\n\toverride name = \"HTTPError\" as const;\n\n\tresponse: ErrorDetails<TErrorResponse>[\"response\"];\n\n\tconstructor(errorDetails: ErrorDetails<TErrorResponse>, errorOptions?: ErrorOptions) {\n\t\tconst { defaultErrorMessage, errorData, response } = errorDetails;\n\n\t\tsuper((errorData as { message?: string } | undefined)?.message ?? defaultErrorMessage, errorOptions);\n\n\t\tthis.errorData = errorData;\n\t\tthis.response = response;\n\n\t\tError.captureStackTrace(this, this.constructor);\n\t}\n}\n","import { HTTPError } from \"@/error\";\nimport type { PossibleHTTPError, PossibleJavaScriptError } from \"@/types/common\";\nimport type { AnyFunction } from \"./type-helpers\";\n\ntype ErrorObjectUnion<TErrorData = unknown> = PossibleHTTPError<TErrorData> | PossibleJavaScriptError;\n\nexport const isHTTPError = <TErrorData>(\n\terror: ErrorObjectUnion<TErrorData> | null\n): error is PossibleHTTPError<TErrorData> => {\n\treturn isPlainObject(error) && error.name === \"HTTPError\";\n};\n\nexport const isHTTPErrorInstance = <TErrorResponse>(\n\terror: unknown\n): error is HTTPError<TErrorResponse> => {\n\treturn (\n\t\t// prettier-ignore\n\t\terror instanceof HTTPError|| (isPlainObject(error) && error.name === \"HTTPError\" && error.isHTTPError === true)\n\t);\n};\n\nexport const isArray = <TArrayItem>(value: unknown): value is TArrayItem[] => Array.isArray(value);\n\nexport const isObject = (value: unknown) => typeof value === \"object\" && value !== null;\n\nexport const isPlainObject = <TPlainObject extends Record<string, unknown>>(\n\tvalue: unknown\n): value is TPlainObject => {\n\tif (!isObject(value)) {\n\t\treturn false;\n\t}\n\n\tconst prototype = Object.getPrototypeOf(value) as unknown;\n\n\t// Check if it's a plain object\n\treturn (\n\t\t// prettier-ignore\n\t\t(prototype == null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value)\n\t);\n};\n\nexport const isFunction = <TFunction extends AnyFunction>(value: unknown): value is TFunction =>\n\ttypeof value === \"function\";\n\nexport const isQueryString = (value: unknown): value is string => isString(value) && value.includes(\"=\");\n\nexport const isString = (value: unknown) => typeof value === \"string\";\n\n// https://github.com/unjs/ofetch/blob/main/src/utils.ts\n// TODO Find a way to incorporate this function in checking when to apply the bodySerializer on the body and also whether to add the content type application/json\nexport const isJSONSerializable = (value: unknown) => {\n\tif (value === undefined) {\n\t\treturn false;\n\t}\n\tconst t = typeof value;\n\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- No time to make this more type-safe\n\tif (t === \"string\" || t === \"number\" || t === \"boolean\" || t === null) {\n\t\treturn true;\n\t}\n\tif (t !== \"object\") {\n\t\treturn false;\n\t}\n\tif (isArray(value)) {\n\t\treturn true;\n\t}\n\tif ((value as Buffer | null)?.buffer) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- Nullish coalescing makes no sense in this boolean context\n\t\t(value?.constructor && value.constructor.name === \"Object\") ||\n\t\ttypeof (value as { toJSON: () => unknown } | null)?.toJSON === \"function\"\n\t);\n};\n","/* eslint-disable perfectionist/sort-object-types -- Avoid Sorting for now */\n\nimport type { ExtraOptions } from \"./types/common\";\nimport { isFunction, isString } from \"./utils/type-guards\";\n\ntype ValueOrFunctionResult<TValue> = TValue | (() => TValue);\n\n/**\n * Bearer Or Token authentication\n *\n * The value of `bearer` will be added to a header as\n * `auth: Bearer some-auth-token`,\n *\n * The value of `token` will be added to a header as\n * `auth: Token some-auth-token`,\n */\nexport type BearerOrTokenAuth =\n\t| {\n\t\t\ttype?: \"Bearer\";\n\t\t\tbearer?: ValueOrFunctionResult<string | null>;\n\t\t\ttoken?: never;\n\t }\n\t| {\n\t\t\ttype?: \"Token\";\n\t\t\tbearer?: never;\n\t\t\ttoken?: ValueOrFunctionResult<string | null>;\n\t };\n\n/**\n * Basic auth\n */\nexport type BasicAuth = {\n\ttype: \"Basic\";\n\tusername: ValueOrFunctionResult<string | null | undefined>;\n\tpassword: ValueOrFunctionResult<string | null | undefined>;\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: ValueOrFunctionResult<string | null | undefined>;\n\tvalue: ValueOrFunctionResult<string | null | undefined>;\n};\n\n// eslint-disable-next-line perfectionist/sort-union-types -- Let the first one be first\nexport type Auth = BearerOrTokenAuth | BasicAuth | CustomAuth;\n\nconst getValue = (value: ValueOrFunctionResult<string | null | undefined>) => {\n\treturn isFunction(value) ? value() : value;\n};\n\ntype AuthorizationHeader = {\n\tAuthorization: string;\n};\n\nexport const getAuthHeader = (auth: ExtraOptions[\"auth\"]): false | AuthorizationHeader | undefined => {\n\tif (auth === undefined) return;\n\n\tif (isString(auth) || auth === null) {\n\t\treturn { Authorization: `Bearer ${auth}` };\n\t}\n\n\tswitch (auth.type) {\n\t\tcase \"Basic\": {\n\t\t\tconst username = getValue(auth.username);\n\t\t\tconst password = getValue(auth.password);\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\n\t\tcase \"Custom\": {\n\t\t\tconst value = getValue(auth.value);\n\n\t\t\tif (value === undefined) return;\n\n\t\t\tconst prefix = getValue(auth.prefix);\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `${prefix} ${value}`,\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\tconst bearer = getValue(auth.bearer);\n\t\t\tconst token = getValue(auth.token);\n\n\t\t\tif (\"token\" in auth && token !== undefined) {\n\t\t\t\treturn { Authorization: `Token ${token}` };\n\t\t\t}\n\n\t\t\treturn bearer !== undefined && { Authorization: `Bearer ${bearer}` };\n\t\t}\n\t}\n};\n","// == These two types allows for adding arbitrary literal types, while still provided autocomplete for defaults.\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 & { z_placeholder?: never };\nexport type AnyNumber = number & { z_placeholder?: never };\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is fine here\nexport type AnyObject = Record<string, 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 CallbackFn<in TParams, out TResult = void> = (...params: TParams[]) => TResult;\n\nexport type Prettify<TObject> = NonNullable<unknown> & { [Key in keyof TObject]: TObject[Key] };\n\nexport type Writeable<TObject, TType extends \"deep\" | \"shallow\" = \"shallow\"> = {\n\t-readonly [key in keyof TObject]: TType extends \"shallow\"\n\t\t? TObject[key]\n\t\t: TType extends \"deep\"\n\t\t\t? TObject[key] extends object\n\t\t\t\t? Writeable<TObject[key], TType>\n\t\t\t\t: TObject[key]\n\t\t\t: never;\n};\n\nexport const defineEnum = <const TValue>(value: TValue) => value as Prettify<Writeable<TValue, \"deep\">>;\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> = { _: TValue }[\"_\"];\n\nexport type Awaitable<TValue> = Promise<TValue> | TValue;\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","/* eslint-disable ts-eslint/consistent-type-definitions -- I need to use interfaces for the sake of user overrides */\nimport type { Auth } from \"../auth\";\nimport type { CallApiPlugin, DefaultPlugins, InferPluginOptions, Plugins } from \"../plugins\";\nimport type { GetResponseType, ResponseTypeUnion } from \"../response\";\nimport type { RetryOptions } from \"../retry\";\nimport type { UrlOptions } from \"../url\";\nimport type { fetchSpecificKeys } from \"../utils/constants\";\nimport { type Awaitable, type UnmaskType, defineEnum } from \"../utils/type-helpers\";\nimport type { CallApiSchemas, CallApiValidators } from \"../validation\";\nimport type {\n\tBodyOption,\n\tHeadersOption,\n\tMetaOption,\n\tMethodOption,\n\tResultModeOption,\n} from \"./conditional-types\";\n\ntype FetchSpecificKeysUnion = Exclude<(typeof fetchSpecificKeys)[number], \"body\" | \"headers\" | \"method\">;\n\nexport type CallApiRequestOptions<TSchemas extends CallApiSchemas = DefaultMoreOptions> =\n\tBodyOption<TSchemas> &\n\t\tHeadersOption<TSchemas> &\n\t\tMethodOption<TSchemas> &\n\t\tPick<RequestInit, FetchSpecificKeysUnion>;\n\nexport type CallApiRequestOptionsForHooks<TSchemas extends CallApiSchemas = DefaultMoreOptions> = Omit<\n\tCallApiRequestOptions<TSchemas>,\n\t\"headers\"\n> & {\n\theaders?: Record<string, string | undefined>;\n};\n\nexport type DefaultDataType = unknown;\n\nexport type DefaultMoreOptions = NonNullable<unknown>;\n\nexport type WithMoreOptions<TMoreOptions = DefaultMoreOptions> = {\n\toptions: CombinedCallApiExtraOptions & Partial<TMoreOptions>;\n};\n\nexport interface Interceptors<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTMoreOptions = DefaultMoreOptions,\n> {\n\t/**\n\t * Interceptor that will be called when any error occurs within the request/response lifecycle, regardless of whether the error is from the api or not.\n\t * It is basically a combination of `onRequestError` and `onResponseError` interceptors\n\t */\n\tonError?: (context: ErrorContext<TErrorData> & WithMoreOptions<TMoreOptions>) => Awaitable<unknown>;\n\n\t/**\n\t * Interceptor that will be called just before the request is made, allowing for modifications or additional operations.\n\t */\n\tonRequest?: (context: RequestContext & WithMoreOptions<TMoreOptions>) => Awaitable<unknown>;\n\n\t/**\n\t * Interceptor that will be called when an error occurs during the fetch request.\n\t */\n\tonRequestError?: (context: RequestErrorContext & WithMoreOptions<TMoreOptions>) => Awaitable<unknown>;\n\n\t/**\n\t * Interceptor that will be called when any response is received from the api, whether successful or not\n\t */\n\tonResponse?: (\n\t\tcontext: ResponseContext<TData, TErrorData> & WithMoreOptions<TMoreOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Interceptor that will be called when an error response is received from the api.\n\t */\n\tonResponseError?: (\n\t\tcontext: ResponseErrorContext<TErrorData> & WithMoreOptions<TMoreOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Interceptor that will be called when a request is retried.\n\t */\n\tonRetry?: (response: ErrorContext<TErrorData> & WithMoreOptions<TMoreOptions>) => Awaitable<unknown>;\n\t/**\n\t * Interceptor that will be called when a successful response is received from the api.\n\t */\n\tonSuccess?: (context: SuccessContext<TData> & WithMoreOptions<TMoreOptions>) => Awaitable<unknown>;\n}\n\n/* eslint-disable perfectionist/sort-union-types -- I need arrays to be last */\nexport type InterceptorsOrInterceptorArray<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTMoreOptions = DefaultMoreOptions,\n> = {\n\t[Key in keyof Interceptors<TData, TErrorData, TMoreOptions>]:\n\t\t| Interceptors<TData, TErrorData, TMoreOptions>[Key]\n\t\t| Array<Interceptors<TData, TErrorData, TMoreOptions>[Key]>;\n};\n/* eslint-enable perfectionist/sort-union-types -- I need arrays to be last */\n\ntype FetchImpl = UnmaskType<(input: string | Request | URL, init?: RequestInit) => Promise<Response>>;\n\nexport type ExtraOptions<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResultMode extends ResultModeUnion = ResultModeUnion,\n\tTSchemas extends CallApiSchemas = DefaultMoreOptions,\n\tTPluginArray extends CallApiPlugin[] = DefaultPlugins,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n> = {\n\t/**\n\t * Authorization header value.\n\t */\n\tauth?: string | Auth | null;\n\t/**\n\t * Base URL to be prepended to all request URLs\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Custom function to serialize the body object into a string.\n\t */\n\tbodySerializer?: (bodyData: Record<string, unknown>) => string;\n\n\t/**\n\t * Whether or not to clone the response, so response.json() and the like, can be read again else where.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Response/clone\n\t * @default false\n\t */\n\tcloneResponse?: boolean;\n\n\t/**\n\t * Custom fetch implementation\n\t */\n\tcustomFetchImpl?: FetchImpl;\n\n\t/**\n\t * Custom request key to be used to identify a request in the fetch deduplication strategy.\n\t * @default the full request url + string formed from the request options\n\t */\n\tdedupeKey?: string;\n\n\t/**\n\t * Defines the deduplication strategy for the request, can be set to \"none\" | \"defer\" | \"cancel\".\n\t * - If set to \"cancel\", the previous pending request with the same request key will be cancelled and lets the new request through.\n\t * - If set to \"defer\", all new request with the same request key will be share the same response, until the previous one is completed.\n\t * - If set to \"none\", deduplication is disabled.\n\t * @default \"cancel\"\n\t */\n\tdedupeStrategy?: \"cancel\" | \"defer\" | \"none\";\n\n\t/**\n\t * Default error message to use if none is provided from a response.\n\t * @default \"Failed to fetch data from server!\"\n\t */\n\tdefaultErrorMessage?: string;\n\n\t/**\n\t * Resolved request URL\n\t */\n\treadonly fullURL?: string;\n\n\t/**\n\t * Defines the mode in which the merged hooks are executed, can be set to \"parallel\" | \"sequential\".\n\t * - If set to \"parallel\", main and plugin hooks will be executed in parallel.\n\t * - If set to \"sequential\", the plugin hooks will be executed first, followed by the main hook.\n\t * @default \"parallel\"\n\t */\n\tmergedHooksExecutionMode?: \"parallel\" | \"sequential\";\n\n\t/**\n\t * - Controls what order in which the merged hooks execute\n\t * @default \"mainHooksLast\"\n\t */\n\tmergedHooksExecutionOrder?: \"mainHooksAfterPlugins\" | \"mainHooksBeforePlugins\";\n\n\t/**\n\t * An array of CallApi plugins. It allows you to extend the behavior of the library.\n\t */\n\tplugins?: Plugins<TPluginArray>;\n\n\t/**\n\t * Custom function to parse the response string into a object.\n\t */\n\tresponseParser?: (responseString: string) => Awaitable<Record<string, unknown>>;\n\n\t/**\n\t * Expected response type, affects how response is parsed\n\t * @default \"json\"\n\t */\n\tresponseType?: TResponseType;\n\n\t/**\n\t * Mode of the result, can influence how results are handled or returned.\n\t * Can be set to \"all\" | \"onlySuccess\" | \"onlyError\" | \"onlyResponse\".\n\t * @default \"all\"\n\t */\n\tresultMode?: TResultMode;\n\n\t/**\n\t * Type-safe schemas for the response validation.\n\t */\n\tschemas?: TSchemas;\n\n\t/**\n\t * If true or the function returns true, throws errors instead of returning them\n\t * The function is passed the error object and can be used to conditionally throw the error\n\t * @default false\n\t */\n\tthrowOnError?: boolean | ((context: ErrorContext<TErrorData>) => boolean);\n\n\t/**\n\t * Request timeout in milliseconds\n\t */\n\ttimeout?: number;\n\n\t/**\n\t * Custom validation functions for response validation\n\t */\n\tvalidators?: CallApiValidators<TData, TErrorData>;\n\t/* eslint-disable perfectionist/sort-intersection-types -- Allow these to be last for the sake of docs */\n} & InterceptorsOrInterceptorArray<TData, TErrorData> &\n\tPartial<InferPluginOptions<TPluginArray>> &\n\tMetaOption<TSchemas> &\n\tRetryOptions<TErrorData> &\n\tResultModeOption<TErrorData, TResultMode> &\n\tUrlOptions<TSchemas>;\n/* eslint-enable perfectionist/sort-intersection-types -- Allow these to be last for the sake of docs */\n\nexport const optionsEnumToExtendFromBase = defineEnum([\"plugins\", \"validators\", \"schemas\"] satisfies Array<\n\tkeyof ExtraOptions\n>);\n\nexport type CallApiExtraOptions<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResultMode extends ResultModeUnion = ResultModeUnion,\n\tTSchemas extends CallApiSchemas = DefaultMoreOptions,\n\tTPluginArray extends CallApiPlugin[] = DefaultPlugins,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n> = CallApiRequestOptions<TSchemas> &\n\tExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType> & {\n\t\t/**\n\t\t * Options that should extend the base options.\n\t\t */\n\t\textend?: Pick<\n\t\t\tExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType>,\n\t\t\t(typeof optionsEnumToExtendFromBase)[number]\n\t\t>;\n\t};\n\nexport const optionsEnumToOmitFromBase = defineEnum([\"extend\", \"dedupeKey\"] satisfies Array<\n\tkeyof CallApiExtraOptions\n>);\n\nexport type BaseCallApiExtraOptions<\n\tTBaseData = DefaultDataType,\n\tTBaseErrorData = DefaultDataType,\n\tTBaseResultMode extends ResultModeUnion = ResultModeUnion,\n\tTBaseSchemas extends CallApiSchemas = DefaultMoreOptions,\n\tTBasePluginArray extends CallApiPlugin[] = DefaultPlugins,\n\tTBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n> = Omit<\n\tPartial<\n\t\tCallApiExtraOptions<\n\t\t\tTBaseData,\n\t\t\tTBaseErrorData,\n\t\t\tTBaseResultMode,\n\t\t\tTBaseSchemas,\n\t\t\tTBasePluginArray,\n\t\t\tTBaseResponseType\n\t\t>\n\t>,\n\t(typeof optionsEnumToOmitFromBase)[number]\n>;\n\nexport type CombinedCallApiExtraOptions<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResultMode extends ResultModeUnion = ResultModeUnion,\n\tTSchemas extends CallApiSchemas = DefaultMoreOptions,\n\tTPluginArray extends CallApiPlugin[] = DefaultPlugins,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n> = BaseCallApiExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType> &\n\tCallApiExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType>;\n\nexport type CallApiParameters<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResultMode extends ResultModeUnion = ResultModeUnion,\n\tTSchemas extends CallApiSchemas = DefaultMoreOptions,\n\tTPluginArray extends CallApiPlugin[] = DefaultPlugins,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n> = [\n\tinitURL: UrlOptions<TSchemas>[\"initURL\"],\n\tconfig?: CallApiExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType>,\n];\n\nexport type RequestContext = UnmaskType<{\n\toptions: CombinedCallApiExtraOptions;\n\trequest: CallApiRequestOptionsForHooks;\n}>;\n\nexport type ResponseContext<TData, TErrorData> = UnmaskType<\n\t| {\n\t\t\tdata: TData;\n\t\t\terror: null;\n\t\t\toptions: CombinedCallApiExtraOptions;\n\t\t\trequest: CallApiRequestOptionsForHooks;\n\t\t\tresponse: Response;\n\t }\n\t// eslint-disable-next-line perfectionist/sort-union-types -- I need the first one to be first\n\t| {\n\t\t\tdata: null;\n\t\t\terror: PossibleHTTPError<TErrorData>;\n\t\t\toptions: CombinedCallApiExtraOptions;\n\t\t\trequest: CallApiRequestOptionsForHooks;\n\t\t\tresponse: Response;\n\t }\n>;\n\nexport type SuccessContext<TData> = UnmaskType<{\n\tdata: TData;\n\toptions: CombinedCallApiExtraOptions;\n\trequest: CallApiRequestOptionsForHooks;\n\tresponse: Response;\n}>;\n\nexport type PossibleJavascriptErrorNames =\n\t| \"AbortError\"\n\t| \"Error\"\n\t| \"SyntaxError\"\n\t| \"TimeoutError\"\n\t| \"TypeError\"\n\t| (`${string}Error` & DefaultMoreOptions);\n\nexport type PossibleJavaScriptError = UnmaskType<{\n\terrorData: DOMException | Error | SyntaxError | TypeError;\n\tmessage: string;\n\tname: PossibleJavascriptErrorNames;\n}>;\n\nexport type PossibleHTTPError<TErrorData> = UnmaskType<{\n\terrorData: TErrorData;\n\tmessage: string;\n\tname: \"HTTPError\";\n}>;\n\nexport type RequestErrorContext = UnmaskType<{\n\terror: PossibleJavaScriptError;\n\toptions: CombinedCallApiExtraOptions;\n\trequest: CallApiRequestOptionsForHooks;\n}>;\n\nexport type ResponseErrorContext<TErrorData> = UnmaskType<{\n\terror: PossibleHTTPError<TErrorData>;\n\toptions: CombinedCallApiExtraOptions;\n\trequest: CallApiRequestOptionsForHooks;\n\tresponse: Response;\n}>;\n\nexport type ErrorContext<TErrorData> = UnmaskType<\n\t| {\n\t\t\terror: PossibleHTTPError<TErrorData>;\n\t\t\toptions: CombinedCallApiExtraOptions;\n\t\t\trequest: CallApiRequestOptionsForHooks;\n\t\t\tresponse: Response;\n\t }\n\t| {\n\t\t\terror: PossibleJavaScriptError;\n\t\t\toptions: CombinedCallApiExtraOptions;\n\t\t\trequest: CallApiRequestOptionsForHooks;\n\t\t\tresponse: null;\n\t }\n>;\n\nexport type CallApiResultSuccessVariant<TData> = {\n\tdata: TData;\n\terror: null;\n\tresponse: Response;\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: PossibleJavaScriptError;\n\t\t\tresponse: null;\n\t };\n\nexport type ResultModeMap<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tTComputedData = GetResponseType<TData, TResponseType>,\n\tTComputedErrorData = GetResponseType<TErrorData, TResponseType>,\n> = UnmaskType<{\n\t/* eslint-disable perfectionist/sort-union-types -- I need the first one to be first */\n\tall: CallApiResultSuccessVariant<TComputedData> | CallApiResultErrorVariant<TComputedErrorData>;\n\n\tonlyError:\n\t\t| CallApiResultSuccessVariant<TComputedData>[\"error\"]\n\t\t| CallApiResultErrorVariant<TComputedErrorData>[\"error\"];\n\n\tonlyResponse:\n\t\t| CallApiResultErrorVariant<TComputedErrorData>[\"response\"]\n\t\t| CallApiResultSuccessVariant<TComputedData>[\"response\"];\n\n\tonlySuccess:\n\t\t| CallApiResultErrorVariant<TComputedErrorData>[\"data\"]\n\t\t| CallApiResultSuccessVariant<TComputedData>[\"data\"];\n\n\tonlySuccessWithException: CallApiResultSuccessVariant<TComputedData>[\"data\"];\n\t/* eslint-enable perfectionist/sort-union-types -- I need the first one to be first */\n}>;\n\nexport type ResultModeUnion = keyof ResultModeMap | undefined;\n\nexport type GetCallApiResult<\n\tTData,\n\tTErrorData,\n\tTResultMode extends ResultModeUnion,\n\tTResponseType extends ResponseTypeUnion,\n\tTComputedMap extends ResultModeMap<TData, TErrorData, TResponseType> = ResultModeMap<\n\t\tTData,\n\t\tTErrorData,\n\t\tTResponseType\n\t>,\n> = TErrorData extends false\n\t? TComputedMap[\"onlySuccessWithException\"]\n\t: undefined extends TResultMode\n\t\t? TComputedMap[\"all\"]\n\t\t: TResultMode extends NonNullable<ResultModeUnion>\n\t\t\t? TComputedMap[TResultMode]\n\t\t\t: never;\n","import type { BaseCallApiExtraOptions } from \"../types/common\";\nimport { defineEnum } from \"./type-helpers\";\n\nexport const fetchSpecificKeys = defineEnum([\n\t\"body\",\n\t\"integrity\",\n\t\"method\",\n\t\"headers\",\n\t\"signal\",\n\t\"cache\",\n\t\"redirect\",\n\t\"window\",\n\t\"credentials\",\n\t\"keepalive\",\n\t\"referrer\",\n\t\"priority\",\n\t\"mode\",\n\t\"referrerPolicy\",\n] satisfies Array<keyof RequestInit>);\n\nconst retryStatusCodesLookup = defineEnum({\n\t408: \"Request Timeout\",\n\t409: \"Conflict\",\n\t425: \"Too Early\",\n\t429: \"Too Many Requests\",\n\t500: \"Internal Server Error\",\n\t502: \"Bad Gateway\",\n\t503: \"Service Unavailable\",\n\t504: \"Gateway Timeout\",\n});\n\nexport const defaultRetryMethods = [\"GET\", \"POST\"] satisfies BaseCallApiExtraOptions[\"retryMethods\"];\n\n// prettier-ignore\nexport const defaultRetryStatusCodes = Object.keys(retryStatusCodesLookup).map(Number) as Required<BaseCallApiExtraOptions>[\"retryStatusCodes\"];\n","import { getAuthHeader } from \"@/auth\";\nimport {\n\ttype BaseCallApiExtraOptions,\n\ttype CallApiExtraOptions,\n\ttype CallApiRequestOptions,\n\toptionsEnumToOmitFromBase,\n} from \"../types/common\";\nimport { fetchSpecificKeys } from \"./constants\";\nimport { isArray, isFunction, isPlainObject, isQueryString, isString } from \"./type-guards\";\nimport type { AnyFunction, Awaitable } from \"./type-helpers\";\n\nconst omitKeys = <TObject extends Record<string, unknown>, const TOmitArray extends Array<keyof TObject>>(\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 Omit<TObject, TOmitArray[number]>;\n};\n\nconst pickKeys = <TObject extends Record<string, unknown>, const TPickArray extends Array<keyof TObject>>(\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, [\n\t\t\t...fetchSpecificKeys,\n\t\t\t...optionsEnumToOmitFromBase,\n\t\t]) 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 || isPlainObject(headers)) {\n\t\treturn headers;\n\t}\n\n\treturn Object.fromEntries(headers);\n};\n\ntype ToQueryStringFn = {\n\t(params: CallApiExtraOptions[\"query\"]): string | null;\n\t(params: Required<CallApiExtraOptions>[\"query\"]): string;\n};\n\nexport const toQueryString: ToQueryStringFn = (params) => {\n\tif (!params) {\n\t\tconsole.error(\"toQueryString:\", \"No query params provided!\");\n\n\t\treturn null as never;\n\t}\n\n\treturn new URLSearchParams(params as Record<string, string>).toString();\n};\n\n// export mergeAndResolve\n\nexport const mergeAndResolveHeaders = (options: {\n\tauth: CallApiExtraOptions[\"auth\"];\n\tbaseHeaders: CallApiExtraOptions[\"headers\"];\n\tbody: CallApiExtraOptions[\"body\"];\n\theaders: CallApiExtraOptions[\"headers\"];\n}) => {\n\tconst { auth, baseHeaders, body, headers } = options;\n\n\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- Nullish coalescing makes no sense in this boolean context\n\tconst shouldResolveHeaders = Boolean(baseHeaders || headers || body || auth);\n\n\t// == Return early if any of the following conditions are not met (so that native fetch would auto set the correct headers):\n\t// == - headers are provided\n\t// == - The body is an object\n\t// == - The auth option is provided\n\tif (!shouldResolveHeaders) return;\n\n\tconst headersObject: Record<string, string | undefined> = {\n\t\t...getAuthHeader(auth),\n\t\t...objectifyHeaders(baseHeaders),\n\t\t...objectifyHeaders(headers),\n\t};\n\n\tif (isQueryString(body)) {\n\t\theadersObject[\"Content-Type\"] = \"application/x-www-form-urlencoded\";\n\n\t\treturn headersObject;\n\t}\n\n\tif (isPlainObject(body) || (isString(body) && body.startsWith(\"{\"))) {\n\t\theadersObject[\"Content-Type\"] = \"application/json\";\n\t\theadersObject.Accept = \"application/json\";\n\t}\n\n\treturn headersObject;\n};\n\nexport const combineHooks = <TInterceptor extends AnyFunction | Array<AnyFunction | undefined>>(\n\tbaseInterceptor: TInterceptor | undefined,\n\tinterceptor: TInterceptor | undefined\n) => {\n\tif (isArray(baseInterceptor)) {\n\t\treturn [baseInterceptor, interceptor].flat() as TInterceptor;\n\t}\n\n\treturn interceptor ?? baseInterceptor;\n};\n\nexport const getFetchImpl = (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 executeHooks = <TInterceptor extends Awaitable<unknown>>(...interceptors: TInterceptor[]) =>\n\tPromise.all(interceptors);\n\nconst PromiseWithResolvers = () => {\n\tlet reject!: (reason?: unknown) => void;\n\tlet resolve!: (value: unknown) => void;\n\n\tconst promise = new Promise((res, rej) => {\n\t\tresolve = res;\n\t\treject = rej;\n\t});\n\n\treturn { promise, reject, resolve };\n};\n\nexport const waitUntil = (delay: number) => {\n\tif (delay === 0) return;\n\n\tconst { promise, resolve } = PromiseWithResolvers();\n\n\tsetTimeout(resolve, delay);\n\n\treturn promise;\n};\n","import type { CallApiExtraOptions, CallApiRequestOptions } from \"./types/common\";\nimport { getFetchImpl, waitUntil } from \"./utils/common\";\n\ntype RequestInfo = {\n\tcontroller: AbortController;\n\tresponsePromise: Promise<Response>;\n};\n\nexport type RequestInfoCache = Map<string | null, RequestInfo>;\n\ntype DedupeContext = {\n\t$RequestInfoCache: RequestInfoCache;\n\tnewFetchController: AbortController;\n\toptions: CallApiExtraOptions;\n\trequest: CallApiRequestOptions;\n};\n\nexport const createDedupeStrategy = async (context: DedupeContext) => {\n\tconst { $RequestInfoCache, newFetchController, options, request } = context;\n\n\tconst generateDedupeKey = () => {\n\t\tconst shouldHaveDedupeKey =\n\t\t\toptions.dedupeStrategy === \"cancel\" || options.dedupeStrategy === \"defer\";\n\n\t\tif (!shouldHaveDedupeKey) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn `${options.fullURL}-${JSON.stringify({ options, request })}`;\n\t};\n\n\tconst dedupeKey = options.dedupeKey ?? generateDedupeKey();\n\n\t// == This is to ensure cache operations only occur when key is available\n\tconst $RequestInfoCacheOrNull = dedupeKey !== null ? $RequestInfoCache : null;\n\n\t/******\n\t * == Add a small delay to the execution to ensure proper request deduplication when multiple requests with the same key start simultaneously.\n\t * == This gives time for the cache to be updated with the previous request info before the next request checks it.\n\t ******/\n\tif (dedupeKey !== null) {\n\t\tawait waitUntil(0.1);\n\t}\n\n\tconst prevRequestInfo = $RequestInfoCacheOrNull?.get(dedupeKey);\n\n\tconst handleRequestCancelDedupeStrategy = () => {\n\t\tconst shouldCancelRequest = prevRequestInfo && options.dedupeStrategy === \"cancel\";\n\n\t\tif (shouldCancelRequest) {\n\t\t\tconst message = options.dedupeKey\n\t\t\t\t? `Duplicate request detected - Aborting previous request with key '${options.dedupeKey}' as a new request was initiated`\n\t\t\t\t: `Duplicate request detected - Aborting previous request to '${options.fullURL}' as a new request with identical options was initiated`;\n\n\t\t\tconst reason = new DOMException(message, \"AbortError\");\n\n\t\t\tprevRequestInfo.controller.abort(reason);\n\t\t}\n\t};\n\n\tconst handleRequestDeferDedupeStrategy = () => {\n\t\tconst fetchApi = getFetchImpl(options.customFetchImpl);\n\n\t\tconst shouldUsePromiseFromCache = prevRequestInfo && options.dedupeStrategy === \"defer\";\n\n\t\tconst responsePromise = shouldUsePromiseFromCache\n\t\t\t? prevRequestInfo.responsePromise\n\t\t\t: fetchApi(options.fullURL as NonNullable<typeof options.fullURL>, request as RequestInit);\n\n\t\t$RequestInfoCacheOrNull?.set(dedupeKey, { controller: newFetchController, responsePromise });\n\n\t\treturn responsePromise;\n\t};\n\n\tconst removeDedupeKeyFromCache = () => $RequestInfoCacheOrNull?.delete(dedupeKey);\n\n\treturn {\n\t\thandleRequestCancelDedupeStrategy,\n\t\thandleRequestDeferDedupeStrategy,\n\t\tremoveDedupeKeyFromCache,\n\t};\n};\n","/* eslint-disable ts-eslint/consistent-type-definitions -- I need to use interfaces for the sake of user overrides */\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type {\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n\tCombinedCallApiExtraOptions,\n\tDefaultMoreOptions,\n\tInterceptors,\n\tInterceptorsOrInterceptorArray,\n\tWithMoreOptions,\n} from \"./types/common\";\nimport { isFunction, isPlainObject, isString } from \"./utils/type-guards\";\nimport type { AnyFunction, Awaitable } from \"./utils/type-helpers\";\nimport type { InferSchemaResult } from \"./validation\";\n\ntype UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : never) extends (\n\tparam: infer TParam\n) => void\n\t? TParam\n\t: never;\n\nexport type DefaultPlugins = CallApiPlugin[];\n\ntype InferSchema<TResult> = TResult extends StandardSchemaV1\n\t? InferSchemaResult<TResult, NonNullable<unknown>>\n\t: TResult;\n\nexport type InferPluginOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<\n\tInferSchema<ReturnType<NonNullable<TPluginArray[number][\"createExtraOptions\"]>>>\n>;\n\nexport type PluginInitContext<TMoreOptions = DefaultMoreOptions> = WithMoreOptions<TMoreOptions> & {\n\tinitURL: string;\n\toptions: CombinedCallApiExtraOptions;\n\trequest: CallApiRequestOptionsForHooks;\n};\n\nexport type PluginInitResult = Partial<\n\tOmit<PluginInitContext, \"request\"> & { request: CallApiRequestOptions }\n>;\n\nexport interface CallApiPlugin<TData = never, TErrorData = never> {\n\t/**\n\t * Defines additional options that can be passed to callApi\n\t */\n\tcreateExtraOptions?: (...params: never[]) => unknown;\n\n\t/**\n\t * A description for the plugin\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Hooks / Interceptors for the plugin\n\t */\n\thooks?: InterceptorsOrInterceptorArray<TData, TErrorData>;\n\n\t/**\n\t * A unique id for the plugin\n\t */\n\tid: string;\n\n\t/**\n\t * A function that will be called when the plugin is initialized. This will be called before the any of the other internal functions.\n\t */\n\tinit?: (context: PluginInitContext) => Awaitable<PluginInitResult> | Awaitable<void>;\n\n\t/**\n\t * A name for the plugin\n\t */\n\tname: string;\n\n\t/**\n\t * A version for the plugin\n\t */\n\tversion?: string;\n}\n\nexport const definePlugin = <\n\t// eslint-disable-next-line perfectionist/sort-union-types -- Let the first one be first\n\tTPlugin extends CallApiPlugin | AnyFunction<CallApiPlugin>,\n>(\n\tplugin: TPlugin\n) => {\n\treturn plugin;\n};\n\nconst createMergedHook = (\n\thooks: Array<AnyFunction | undefined>,\n\tmergedHooksExecutionMode: CombinedCallApiExtraOptions[\"mergedHooksExecutionMode\"]\n) => {\n\treturn async (ctx: Record<string, unknown>) => {\n\t\tif (mergedHooksExecutionMode === \"sequential\") {\n\t\t\tfor (const hook of hooks) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop -- This is necessary in this case\n\t\t\t\tawait hook?.(ctx);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (mergedHooksExecutionMode === \"parallel\") {\n\t\t\tconst hookArray = [...hooks];\n\n\t\t\tawait Promise.all(hookArray.map((uniqueHook) => uniqueHook?.(ctx)));\n\t\t}\n\t};\n};\n\n// prettier-ignore\ntype HookRegistries = {\n\t[Key in keyof Interceptors]: Set<Interceptors[Key]>;\n};\n\nexport const hooksEnum = {\n\tonError: new Set(),\n\tonRequest: new Set(),\n\tonRequestError: new Set(),\n\tonResponse: new Set(),\n\tonResponseError: new Set(),\n\tonRetry: new Set(),\n\tonSuccess: new Set(),\n} satisfies HookRegistries;\n\nexport type Plugins<TPluginArray extends CallApiPlugin[]> =\n\t| TPluginArray\n\t| ((context: PluginInitContext) => TPluginArray);\n\nconst getPluginArray = (plugins: Plugins<CallApiPlugin[]> | undefined, context: PluginInitContext) => {\n\tif (!plugins) {\n\t\treturn [];\n\t}\n\n\treturn isFunction(plugins) ? plugins(context) : plugins;\n};\n\nexport const initializePlugins = async (context: PluginInitContext) => {\n\tconst { initURL, options, request } = context;\n\n\tconst hookRegistries = structuredClone(hooksEnum);\n\n\tconst addMainHooks = () => {\n\t\tfor (const key of Object.keys(hooksEnum)) {\n\t\t\tconst mainHook = options[key as keyof Interceptors] as never;\n\n\t\t\thookRegistries[key as keyof Interceptors].add(mainHook);\n\t\t}\n\t};\n\n\tconst addPluginHooks = (pluginHooks: Required<CallApiPlugin>[\"hooks\"]) => {\n\t\tfor (const key of Object.keys(hooksEnum)) {\n\t\t\tconst pluginHook = pluginHooks[key as keyof Interceptors] as never;\n\n\t\t\thookRegistries[key as keyof Interceptors].add(pluginHook);\n\t\t}\n\t};\n\n\tif (options.mergedHooksExecutionOrder === \"mainHooksBeforePlugins\") {\n\t\taddMainHooks();\n\t}\n\n\tconst resolvedPlugins = [\n\t\t...getPluginArray(options.plugins, context),\n\t\t...getPluginArray(options.extend?.plugins, context),\n\t];\n\n\tlet resolvedUrl = initURL;\n\tlet resolvedOptions = options;\n\tlet resolvedRequestOptions = request;\n\n\tconst executePluginInit = async (pluginInit: CallApiPlugin[\"init\"]) => {\n\t\tif (!pluginInit) return;\n\n\t\tconst initResult = await pluginInit({ initURL, options, request });\n\n\t\tif (!isPlainObject(initResult)) return;\n\n\t\tif (isString(initResult.initURL)) {\n\t\t\tresolvedUrl = initResult.initURL;\n\t\t}\n\n\t\tif (isPlainObject(initResult.request)) {\n\t\t\tresolvedRequestOptions = initResult.request as CallApiRequestOptionsForHooks;\n\t\t}\n\n\t\tif (isPlainObject(initResult.options)) {\n\t\t\tresolvedOptions = initResult.options;\n\t\t}\n\t};\n\n\tfor (const plugin of resolvedPlugins) {\n\t\t// eslint-disable-next-line no-await-in-loop -- Await is necessary in this case.\n\t\tawait executePluginInit(plugin.init);\n\n\t\tif (!plugin.hooks) continue;\n\n\t\taddPluginHooks(plugin.hooks);\n\t}\n\n\tif (\n\t\t!options.mergedHooksExecutionOrder ||\n\t\toptions.mergedHooksExecutionOrder === \"mainHooksAfterPlugins\"\n\t) {\n\t\taddMainHooks();\n\t}\n\n\tconst resolvedHooks = {} as Required<Interceptors>;\n\n\tfor (const [key, hookRegistry] of Object.entries(hookRegistries)) {\n\t\tconst flattenedHookArray = [...hookRegistry].flat();\n\n\t\tconst mergedHook = createMergedHook(flattenedHookArray, options.mergedHooksExecutionMode);\n\n\t\tresolvedHooks[key as keyof Interceptors] = mergedHook;\n\t}\n\n\treturn {\n\t\tresolvedHooks,\n\t\tresolvedOptions,\n\t\tresolvedRequestOptions,\n\t\turl: resolvedUrl,\n\t};\n};\n","/* eslint-disable ts-eslint/consistent-type-definitions -- I need to use interfaces for the sake of user overrides */\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { Body, GlobalMeta, Headers, Method } from \"./types\";\nimport type { CombinedCallApiExtraOptions } from \"./types/common\";\nimport type { InitURL, Params, Query } from \"./url\";\n\nexport const standardSchemaParser = async <TSchema extends StandardSchemaV1>(\n\tschema: TSchema,\n\tinputData: StandardSchemaV1.InferInput<TSchema>\n): Promise<StandardSchemaV1.InferOutput<TSchema>> => {\n\tconst result = await schema[\"~standard\"].validate(inputData);\n\n\t// == If the `issues` field exists, it means the validation failed\n\tif (result.issues) {\n\t\tthrow new Error(JSON.stringify(result.issues, null, 2), { cause: result.issues });\n\t}\n\n\treturn result.value;\n};\n\nexport interface CallApiSchemas {\n\t/**\n\t * The schema to use for validating the request body.\n\t */\n\tbody?: StandardSchemaV1<Body>;\n\n\t/**\n\t * The schema to use for validating the response data.\n\t */\n\tdata?: StandardSchemaV1;\n\n\t/**\n\t * The schema to use for validating the response error data.\n\t */\n\terrorData?: StandardSchemaV1;\n\n\t/**\n\t * The schema to use for validating the request headers.\n\t */\n\theaders?: StandardSchemaV1<Headers>;\n\n\t/**\n\t * The schema to use for validating the request url.\n\t */\n\tinitURL?: StandardSchemaV1<InitURL>;\n\n\t/**\n\t * The schema to use for validating the meta option.\n\t */\n\tmeta?: StandardSchemaV1<GlobalMeta>;\n\n\t/**\n\t * The schema to use for validating the request method.\n\t */\n\tmethod?: StandardSchemaV1<Method>;\n\n\t/**\n\t * The schema to use for validating the request url parameter.\n\t */\n\tparams?: StandardSchemaV1<Params>;\n\n\t/**\n\t * The schema to use for validating the request url querys.\n\t */\n\tquery?: StandardSchemaV1<Query>;\n}\n\nexport interface CallApiValidators<TData = unknown, TErrorData = unknown> {\n\t/**\n\t * Custom function to validate the response data.\n\t */\n\tdata?: (value: unknown) => TData;\n\n\t/**\n\t * Custom function to validate the response error data, stemming from the api.\n\t * This only runs if the api actually sends back error status codes, else it will be ignored, in which case you should only use the `responseValidator` option.\n\t */\n\terrorData?: (value: unknown) => TErrorData;\n}\n\nexport type InferSchemaResult<TSchema, TData> = TSchema extends StandardSchemaV1\n\t? StandardSchemaV1.InferOutput<TSchema>\n\t: TData;\n\nexport const createExtensibleSchemasAndValidators = (options: CombinedCallApiExtraOptions) => {\n\tconst schemas =\n\t\toptions.schemas && ({ ...options.schemas, ...options.extend?.schemas } as CallApiSchemas);\n\n\tconst validators = options.validators && { ...options.validators, ...options.extend?.validators };\n\n\treturn { schemas, validators };\n};\n","import type { CallApiExtraOptions, ResultModeMap } from \"./types\";\nimport type { Awaitable } from \"./utils/type-helpers\";\nimport { type CallApiSchemas, type CallApiValidators, standardSchemaParser } from \"./validation\";\n\ntype Parser = (responseString: string) => Awaitable<Record<string, unknown>>;\n\nexport const getResponseType = <TResponse>(response: Response, parser?: Parser) => ({\n\tarrayBuffer: () => response.arrayBuffer(),\n\tblob: () => response.blob(),\n\tformData: () => response.formData(),\n\tjson: async () => {\n\t\tif (parser) {\n\t\t\tconst text = await response.text();\n\t\t\treturn parser(text) as TResponse;\n\t\t}\n\n\t\treturn response.json() as Promise<TResponse>;\n\t},\n\tstream: () => response.body,\n\ttext: () => response.text(),\n});\n\ntype InitResponseTypeMap<TResponse = unknown> = ReturnType<typeof getResponseType<TResponse>>;\n\nexport type ResponseTypeUnion = keyof InitResponseTypeMap | undefined;\n\nexport type ResponseTypeMap<TResponse> = {\n\t[Key in keyof InitResponseTypeMap<TResponse>]: Awaited<ReturnType<InitResponseTypeMap<TResponse>[Key]>>;\n};\n\nexport type GetResponseType<\n\tTResponse,\n\tTResponseType extends ResponseTypeUnion,\n\tTComputedMap extends ResponseTypeMap<TResponse> = ResponseTypeMap<TResponse>,\n> = undefined extends TResponseType\n\t? TComputedMap[\"json\"]\n\t: TResponseType extends NonNullable<ResponseTypeUnion>\n\t\t? TComputedMap[TResponseType]\n\t\t: never;\n\nexport const resolveResponseData = async <TResponse>(\n\tresponse: Response,\n\tresponseType: keyof ResponseTypeMap<TResponse>,\n\tparser: Parser | undefined,\n\tschema?: NonNullable<CallApiSchemas>[keyof NonNullable<CallApiSchemas>],\n\tvalidator?: NonNullable<CallApiValidators>[keyof NonNullable<CallApiValidators>]\n) => {\n\tconst RESPONSE_TYPE_LOOKUP = getResponseType<TResponse>(response, parser);\n\n\tif (!Object.hasOwn(RESPONSE_TYPE_LOOKUP, responseType)) {\n\t\tthrow new Error(`Invalid response type: ${responseType}`);\n\t}\n\n\tconst responseData = await RESPONSE_TYPE_LOOKUP[responseType]();\n\n\tconst validResponseData = validator ? validator(responseData) : responseData;\n\n\tconst schemaValidResponseData = schema\n\t\t? await standardSchemaParser(schema, validResponseData)\n\t\t: validResponseData;\n\n\treturn schemaValidResponseData;\n};\n\ntype SuccessInfo = {\n\tdata: unknown;\n\tresponse: Response;\n\tresultMode: CallApiExtraOptions[\"resultMode\"];\n};\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 = <TCallApiResult>(info: SuccessInfo): TCallApiResult => {\n\tconst { data, response, resultMode } = info;\n\n\tconst apiDetails = { data, error: null, response };\n\n\tif (!resultMode) {\n\t\treturn apiDetails as TCallApiResult;\n\t}\n\n\tconst resultModeMap: ResultModeMap = {\n\t\tall: apiDetails,\n\t\tonlyError: apiDetails.error,\n\t\tonlyResponse: apiDetails.response,\n\t\tonlySuccess: apiDetails.data,\n\t\tonlySuccessWithException: apiDetails.data,\n\t};\n\n\treturn resultModeMap[resultMode] as TCallApiResult;\n};\n","/* eslint-disable ts-eslint/consistent-type-definitions -- I need to use interfaces for the sake of user overrides */\n\nimport type { Method } from \"./types\";\nimport type { ErrorContext } from \"./types/common\";\nimport type { AnyNumber } from \"./utils/type-helpers\";\n\ntype RetryCondition<TErrorData> = (context: ErrorContext<TErrorData>) => boolean | Promise<boolean>;\n\nexport interface RetryOptions<TErrorData> {\n\t/**\n\t * Keeps track of the number of times the request has already been retried\n\t * @deprecated This property is used internally to track retries. Please abstain from modifying it.\n\t */\n\treadonly \"~retryCount\"?: number;\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;\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?: Method[];\n\n\t/**\n\t * HTTP status codes that trigger a retry\n\t * @default [409, 425, 429, 500, 502, 503, 504]\n\t */\n\tretryStatusCodes?: Array<409 | 425 | 429 | 500 | 502 | 503 | 504 | AnyNumber>;\n\n\t/**\n\t * Strategy to use when retrying\n\t * @default \"linear\"\n\t */\n\tretryStrategy?: \"exponential\" | \"linear\";\n}\n\nconst getLinearDelay = <TErrorData>(options: RetryOptions<TErrorData>) => options.retryDelay ?? 1000;\n\nconst getExponentialDelay = <TErrorData>(\n\tcurrentAttemptCount: number,\n\toptions: RetryOptions<TErrorData>\n) => {\n\tconst maxDelay = options.retryMaxDelay ?? 10000;\n\n\tconst exponentialDelay = (options.retryDelay ?? 1000) * 2 ** currentAttemptCount;\n\n\treturn Math.min(exponentialDelay, maxDelay);\n};\n\nexport const createRetryStrategy = <TErrorData>(\n\toptions: RetryOptions<TErrorData>,\n\tctx: ErrorContext<TErrorData>\n) => {\n\tconst currentRetryCount = options[\"~retryCount\"] ?? 0;\n\n\tconst getDelay = () => {\n\t\tif (options.retryStrategy === \"exponential\") {\n\t\t\treturn getExponentialDelay(currentRetryCount, options);\n\t\t}\n\n\t\treturn getLinearDelay(options);\n\t};\n\n\tconst shouldAttemptRetry = async () => {\n\t\tconst customRetryCondition = (await options.retryCondition?.(ctx)) ?? true;\n\n\t\tconst maxRetryAttempts = options.retryAttempts ?? 0;\n\n\t\tconst baseRetryCondition = maxRetryAttempts > currentRetryCount && customRetryCondition;\n\n\t\tif (ctx.error.name !== \"HTTPError\") {\n\t\t\treturn baseRetryCondition;\n\t\t}\n\n\t\tconst includesMethod =\n\t\t\t// eslint-disable-next-line no-implicit-coercion -- Boolean doesn't narrow\n\t\t\t!!ctx.request.method && options.retryMethods?.includes(ctx.request.method);\n\n\t\tconst includesCodes =\n\t\t\t// eslint-disable-next-line no-implicit-coercion -- Boolean doesn't narrow\n\t\t\t!!ctx.response?.status && options.retryStatusCodes?.includes(ctx.response.status);\n\n\t\treturn includesCodes && includesMethod && baseRetryCondition;\n\t};\n\n\treturn {\n\t\tgetDelay,\n\t\tshouldAttemptRetry,\n\t};\n};\n","/* eslint-disable ts-eslint/consistent-type-definitions -- I need to use interfaces for the sake of user overrides */\n\nimport type { CallApiExtraOptions } from \"./types/common\";\nimport { toQueryString } from \"./utils\";\nimport { isArray } from \"./utils/type-guards\";\nimport type { UnmaskType } from \"./utils/type-helpers\";\nimport type { CallApiSchemas, InferSchemaResult } from \"./validation\";\n\nconst slash = \"/\";\nconst column = \":\";\nconst mergeUrlWithParams = (url: string, params: CallApiExtraOptions[\"params\"]) => {\n\tif (!params) {\n\t\treturn url;\n\t}\n\n\tlet newUrl = url;\n\n\tif (isArray(params)) {\n\t\tconst matchedParamArray = newUrl.split(slash).filter((param) => param.startsWith(column));\n\n\t\tfor (const [index, matchedParam] of matchedParamArray.entries()) {\n\t\t\tconst realParam = params[index] as string;\n\t\t\tnewUrl = newUrl.replace(matchedParam, realParam);\n\t\t}\n\n\t\treturn newUrl;\n\t}\n\n\tfor (const [key, value] of Object.entries(params)) {\n\t\tnewUrl = newUrl.replace(`${column}${key}`, String(value));\n\t}\n\n\treturn newUrl;\n};\n\nconst questionMark = \"?\";\nconst ampersand = \"&\";\nconst mergeUrlWithQuery = (url: string, query: CallApiExtraOptions[\"query\"]): string => {\n\tif (!query) {\n\t\treturn url;\n\t}\n\n\tconst queryString = toQueryString(query);\n\n\tif (queryString?.length === 0) {\n\t\treturn url;\n\t}\n\n\tif (url.endsWith(questionMark)) {\n\t\treturn `${url}${queryString}`;\n\t}\n\n\tif (url.includes(questionMark)) {\n\t\treturn `${url}${ampersand}${queryString}`;\n\t}\n\n\treturn `${url}${questionMark}${queryString}`;\n};\n\nexport const mergeUrlWithParamsAndQuery = (\n\turl: string,\n\tparams: CallApiExtraOptions[\"params\"],\n\tquery: CallApiExtraOptions[\"query\"]\n) => {\n\tconst urlWithMergedParams = mergeUrlWithParams(url, params);\n\n\treturn mergeUrlWithQuery(urlWithMergedParams, query);\n};\n\nexport type Params = UnmaskType<\n\t// eslint-disable-next-line perfectionist/sort-union-types -- I need the Record to be first\n\tRecord<string, boolean | number | string> | Array<boolean | number | string>\n>;\n\nexport type Query = UnmaskType<Record<string, boolean | number | string>>;\n\nexport type InitURL = UnmaskType<string>;\n\nexport interface UrlOptions<TSchemas extends CallApiSchemas> {\n\t/**\n\t * URL to be used in the request.\n\t */\n\treadonly initURL?: InferSchemaResult<TSchemas[\"initURL\"], InitURL>;\n\n\t/**\n\t * Parameters to be appended to the URL (i.e: /:id)\n\t */\n\tparams?: InferSchemaResult<TSchemas[\"params\"], Params>;\n\n\t/**\n\t * Query parameters to append to the URL.\n\t */\n\tquery?: InferSchemaResult<TSchemas[\"query\"], Query>;\n}\n","// prettier-ignore\nexport const createCombinedSignal = (...signals: Array<AbortSignal | null | undefined>) => AbortSignal.any(signals.filter(Boolean));\n\nexport const createTimeoutSignal = (milliseconds: number) => AbortSignal.timeout(milliseconds);\n","import { type RequestInfoCache, createDedupeStrategy } from \"./dedupe\";\nimport { HTTPError, resolveErrorResult } from \"./error\";\nimport { type CallApiPlugin, type DefaultPlugins, hooksEnum, initializePlugins } from \"./plugins\";\nimport { type ResponseTypeUnion, resolveResponseData, resolveSuccessResult } from \"./response\";\nimport { createRetryStrategy } from \"./retry\";\nimport type {\n\tBaseCallApiExtraOptions,\n\tCallApiParameters,\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n\tCombinedCallApiExtraOptions,\n\tDefaultDataType,\n\tDefaultMoreOptions,\n\tGetCallApiResult,\n\tInterceptors,\n\tResultModeUnion,\n} from \"./types/common\";\nimport { mergeUrlWithParamsAndQuery } from \"./url\";\nimport {\n\tcombineHooks,\n\texecuteHooks,\n\tmergeAndResolveHeaders,\n\tsplitBaseConfig,\n\tsplitConfig,\n\twaitUntil,\n} from \"./utils/common\";\nimport { defaultRetryMethods, defaultRetryStatusCodes } from \"./utils/constants\";\nimport { createCombinedSignal, createTimeoutSignal } from \"./utils/polyfills\";\nimport { isFunction, isHTTPErrorInstance, isPlainObject } from \"./utils/type-guards\";\nimport {\n\ttype CallApiSchemas,\n\ttype InferSchemaResult,\n\tcreateExtensibleSchemasAndValidators,\n} from \"./validation\";\n\nexport const createFetchClient = <\n\tTBaseData = DefaultDataType,\n\tTBaseErrorData = DefaultDataType,\n\tTBaseResultMode extends ResultModeUnion = ResultModeUnion,\n\tTBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tTBaseSchemas extends CallApiSchemas = DefaultMoreOptions,\n\tTBasePluginArray extends CallApiPlugin[] = DefaultPlugins,\n\tTBaseComputedData = InferSchemaResult<TBaseSchemas[\"data\"], TBaseData>,\n\tTBaseComputedErrorData = InferSchemaResult<TBaseSchemas[\"errorData\"], TBaseErrorData>,\n>(\n\tbaseConfig?: BaseCallApiExtraOptions<\n\t\tTBaseData,\n\t\tTBaseErrorData,\n\t\tTBaseResultMode,\n\t\tTBaseSchemas,\n\t\tTBasePluginArray,\n\t\tTBaseResponseType\n\t>\n) => {\n\tconst [baseFetchOptions, baseExtraOptions] = splitBaseConfig(baseConfig ?? {});\n\n\tconst $RequestInfoCache: RequestInfoCache = new Map();\n\n\tconst callApi = async <\n\t\tTData = TBaseComputedData,\n\t\tTErrorData = TBaseComputedErrorData,\n\t\tTResultMode extends ResultModeUnion = TBaseResultMode,\n\t\tTResponseType extends ResponseTypeUnion = TBaseResponseType,\n\t\tTSchemas extends CallApiSchemas = TBaseSchemas,\n\t\tTPluginArray extends CallApiPlugin[] = TBasePluginArray,\n\t\tTComputedData = InferSchemaResult<TSchemas[\"data\"], TData>,\n\t\tTComputedErrorData = InferSchemaResult<TSchemas[\"errorData\"], TErrorData>,\n\t>(\n\t\t...parameters: CallApiParameters<\n\t\t\tTData,\n\t\t\tTErrorData,\n\t\t\tTResultMode,\n\t\t\tTSchemas,\n\t\t\tTPluginArray,\n\t\t\tTResponseType\n\t\t>\n\t): Promise<GetCallApiResult<TComputedData, TComputedErrorData, TResultMode, TBaseResponseType>> => {\n\t\tconst [initURL, config = {} as never] = parameters;\n\n\t\tconst [fetchOptions, extraOptions] = splitConfig(config);\n\n\t\tconst initCombinedHooks = {} as Required<Interceptors>;\n\n\t\tfor (const key of Object.keys(hooksEnum)) {\n\t\t\tconst combinedHook = combineHooks(\n\t\t\t\tbaseExtraOptions[key as keyof Interceptors],\n\t\t\t\textraOptions[key as keyof Interceptors]\n\t\t\t);\n\n\t\t\tinitCombinedHooks[key as keyof Interceptors] = combinedHook as never;\n\t\t}\n\n\t\t// == Default Extra Options\n\t\tconst defaultExtraOptions = {\n\t\t\tbaseURL: \"\",\n\t\t\tbodySerializer: JSON.stringify,\n\t\t\tdedupeStrategy: \"cancel\",\n\t\t\tdefaultErrorMessage: \"Failed to fetch data from server!\",\n\t\t\tmergedHooksExecutionMode: \"parallel\",\n\t\t\tmergedHooksExecutionOrder: \"mainHooksAfterPlugins\",\n\t\t\tresponseType: \"json\",\n\t\t\tresultMode: \"all\",\n\t\t\tretryAttempts: 0,\n\t\t\tretryDelay: 1000,\n\t\t\tretryMaxDelay: 10000,\n\t\t\tretryMethods: defaultRetryMethods,\n\t\t\tretryStatusCodes: defaultRetryStatusCodes,\n\t\t\tretryStrategy: \"linear\",\n\n\t\t\t...baseExtraOptions,\n\t\t\t...extraOptions,\n\n\t\t\t...initCombinedHooks,\n\t\t} satisfies CombinedCallApiExtraOptions;\n\n\t\tconst body = fetchOptions.body ?? baseFetchOptions.body;\n\n\t\t// == Default Request Options\n\t\tconst defaultRequestOptions = {\n\t\t\tbody: isPlainObject(body) ? defaultExtraOptions.bodySerializer(body) : body,\n\n\t\t\t...baseFetchOptions,\n\t\t\t...fetchOptions,\n\n\t\t\theaders: mergeAndResolveHeaders({\n\t\t\t\tauth: defaultExtraOptions.auth,\n\t\t\t\tbaseHeaders: baseFetchOptions.headers,\n\t\t\t\tbody,\n\t\t\t\theaders: fetchOptions.headers,\n\t\t\t}),\n\n\t\t\tsignal: fetchOptions.signal ?? baseFetchOptions.signal,\n\t\t} satisfies CallApiRequestOptions;\n\n\t\tconst { resolvedHooks, resolvedOptions, resolvedRequestOptions, url } = await initializePlugins({\n\t\t\tinitURL: initURL as string,\n\t\t\toptions: defaultExtraOptions,\n\t\t\trequest: defaultRequestOptions,\n\t\t});\n\n\t\tconst fullURL = `${resolvedOptions.baseURL}${mergeUrlWithParamsAndQuery(url, resolvedOptions.params, resolvedOptions.query)}`;\n\n\t\tconst options = {\n\t\t\t...resolvedOptions,\n\t\t\t...resolvedHooks,\n\t\t\tfullURL,\n\t\t\tinitURL: initURL as string,\n\t\t} satisfies CombinedCallApiExtraOptions as typeof defaultExtraOptions & typeof resolvedHooks;\n\n\t\tconst newFetchController = new AbortController();\n\n\t\tconst timeoutSignal = options.timeout != null ? createTimeoutSignal(options.timeout) : null;\n\n\t\tconst combinedSignal = createCombinedSignal(\n\t\t\tresolvedRequestOptions.signal,\n\t\t\ttimeoutSignal,\n\t\t\tnewFetchController.signal\n\t\t);\n\n\t\tconst request = {\n\t\t\t...resolvedRequestOptions,\n\t\t\tsignal: combinedSignal,\n\t\t} satisfies CallApiRequestOptionsForHooks;\n\n\t\tconst {\n\t\t\thandleRequestCancelDedupeStrategy,\n\t\t\thandleRequestDeferDedupeStrategy,\n\t\t\tremoveDedupeKeyFromCache,\n\t\t} = await createDedupeStrategy({ $RequestInfoCache, newFetchController, options, request });\n\n\t\thandleRequestCancelDedupeStrategy();\n\n\t\ttry {\n\t\t\tawait executeHooks(options.onRequest({ options, request }));\n\n\t\t\t// == Apply determined headers again after onRequest incase they were modified\n\t\t\trequest.headers = mergeAndResolveHeaders({\n\t\t\t\tauth: options.auth,\n\t\t\t\tbaseHeaders: baseFetchOptions.headers,\n\t\t\t\tbody,\n\t\t\t\theaders: request.headers,\n\t\t\t});\n\n\t\t\tconst response = await handleRequestDeferDedupeStrategy();\n\n\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\tconst shouldCloneResponse = options.dedupeStrategy === \"defer\" || options.cloneResponse;\n\n\t\t\tconst { schemas, validators } = createExtensibleSchemasAndValidators(options);\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorData = await resolveResponseData<TErrorData>(\n\t\t\t\t\tshouldCloneResponse ? response.clone() : response,\n\t\t\t\t\toptions.responseType,\n\t\t\t\t\toptions.responseParser,\n\t\t\t\t\tschemas?.errorData,\n\t\t\t\t\tvalidators?.errorData\n\t\t\t\t);\n\n\t\t\t\t// == Push all error handling responsibilities to the catch block if not retrying\n\t\t\t\tthrow new HTTPError({\n\t\t\t\t\tdefaultErrorMessage: options.defaultErrorMessage,\n\t\t\t\t\terrorData,\n\t\t\t\t\tresponse,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst successData = await resolveResponseData<TData>(\n\t\t\t\tshouldCloneResponse ? response.clone() : response,\n\t\t\t\toptions.responseType,\n\t\t\t\toptions.responseParser,\n\t\t\t\tschemas?.data,\n\t\t\t\tvalidators?.data\n\t\t\t);\n\n\t\t\tconst successContext = {\n\t\t\t\tdata: successData as never,\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t\tresponse: options.cloneResponse ? response.clone() : response,\n\t\t\t};\n\n\t\t\tawait executeHooks(\n\t\t\t\toptions.onSuccess(successContext),\n\n\t\t\t\toptions.onResponse({ ...successContext, error: null })\n\t\t\t);\n\n\t\t\treturn await resolveSuccessResult({\n\t\t\t\tdata: successContext.data,\n\t\t\t\tresponse: successContext.response,\n\t\t\t\tresultMode: options.resultMode,\n\t\t\t});\n\n\t\t\t// == Exhaustive Error handling\n\t\t} catch (error) {\n\t\t\tconst { errorVariantDetails, getErrorResult } = resolveErrorResult({\n\t\t\t\tcloneResponse: options.cloneResponse,\n\t\t\t\tdefaultErrorMessage: options.defaultErrorMessage,\n\t\t\t\terror,\n\t\t\t\tresultMode: options.resultMode,\n\t\t\t});\n\n\t\t\tconst errorContext = {\n\t\t\t\terror: errorVariantDetails.error as never,\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t};\n\n\t\t\tconst errorContextWithResponse = {\n\t\t\t\t...errorContext,\n\t\t\t\tresponse: errorVariantDetails.response as NonNullable<typeof errorVariantDetails.response>,\n\t\t\t};\n\n\t\t\tconst { getDelay, shouldAttemptRetry } = createRetryStrategy(options, errorContextWithResponse);\n\n\t\t\tconst shouldRetry = !combinedSignal.aborted && (await shouldAttemptRetry());\n\n\t\t\tif (shouldRetry) {\n\t\t\t\tawait executeHooks(options.onRetry(errorContextWithResponse));\n\n\t\t\t\tconst delay = getDelay();\n\n\t\t\t\tawait waitUntil(delay);\n\n\t\t\t\tconst updatedOptions = {\n\t\t\t\t\t...config,\n\t\t\t\t\t\"~retryCount\": (options[\"~retryCount\"] ?? 0) + 1,\n\t\t\t\t} satisfies typeof config as typeof config;\n\n\t\t\t\treturn await callApi(initURL, updatedOptions);\n\t\t\t}\n\n\t\t\tconst shouldThrowOnError = isFunction(options.throwOnError)\n\t\t\t\t? options.throwOnError(errorContextWithResponse)\n\t\t\t\t: options.throwOnError;\n\n\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping -- False alarm: this function is depends on this scope\n\t\t\tconst handleThrowOnError = () => {\n\t\t\t\tif (!shouldThrowOnError) return;\n\n\t\t\t\t// eslint-disable-next-line ts-eslint/only-throw-error -- It's fine to throw this\n\t\t\t\tthrow errorVariantDetails.error;\n\t\t\t};\n\n\t\t\tif (isHTTPErrorInstance<TErrorData>(error)) {\n\t\t\t\tawait executeHooks(\n\t\t\t\t\toptions.onResponseError(errorContextWithResponse),\n\n\t\t\t\t\toptions.onError(errorContextWithResponse),\n\n\t\t\t\t\toptions.onResponse({ ...errorContextWithResponse, data: null })\n\t\t\t\t);\n\n\t\t\t\thandleThrowOnError();\n\n\t\t\t\treturn getErrorResult();\n\t\t\t}\n\n\t\t\tif (error instanceof DOMException && error.name === \"AbortError\") {\n\t\t\t\tconst { message, name } = error;\n\n\t\t\t\tconsole.error(`${name}:`, message);\n\n\t\t\t\thandleThrowOnError();\n\n\t\t\t\treturn getErrorResult();\n\t\t\t}\n\n\t\t\tif (error instanceof DOMException && error.name === \"TimeoutError\") {\n\t\t\t\tconst message = `Request timed out after ${options.timeout}ms`;\n\n\t\t\t\tconsole.error(`${error.name}:`, message);\n\n\t\t\t\thandleThrowOnError();\n\n\t\t\t\treturn getErrorResult({ message });\n\t\t\t}\n\n\t\t\tawait executeHooks(\n\t\t\t\t// == At this point only the request errors exist, so the request error interceptor is called\n\t\t\t\toptions.onRequestError(errorContext),\n\n\t\t\t\t// == Also call the onError interceptor\n\t\t\t\toptions.onError(errorContextWithResponse)\n\t\t\t);\n\n\t\t\thandleThrowOnError();\n\n\t\t\treturn getErrorResult();\n\n\t\t\t// == Removing the now unneeded AbortController from store\n\t\t} finally {\n\t\t\tremoveDedupeKeyFromCache();\n\t\t}\n\t};\n\n\tcallApi.create = createFetchClient;\n\n\treturn callApi;\n};\n\nexport const callApi = createFetchClient();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBO,IAAM,qBAAqB,CAAyB,SAAoB;AAC9E,QAAM,EAAE,eAAe,qBAAqB,OAAO,SAAS,oBAAoB,WAAW,IAAI;AAE/F,MAAI,sBAA0D;AAAA,IAC7D,MAAM;AAAA,IACN,OAAO;AAAA,MACN,WAAW;AAAA,MACX,SAAS,sBAAuB,MAAgB;AAAA,MAChD,MAAO,MAAgB;AAAA,IACxB;AAAA,IACA,UAAU;AAAA,EACX;AAEA,MAAI,oBAAoB,KAAK,GAAG;AAC/B,UAAM,EAAE,WAAW,UAAU,qBAAqB,MAAM,SAAS,IAAI;AAErE,0BAAsB;AAAA,MACrB,MAAM;AAAA,MACN,OAAO;AAAA,QACN;AAAA,QACA;A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AAAA;AAAA,QAGnC,QAAQ,QAAQ,wBAAwB;AAAA,MACzC;AAEA,yBAAmB;AAEnB,aAAO,eAAe;AAAA,IAGvB,UAAE;AACD,+BAAyB;AAAA,IAC1B;AAAA,EACD;AAEA,EAAAA,SAAQ,SAAS;AAEjB,SAAOA;AACR;AAEO,IAAM,UAAU,kBAAkB;","names":["callApi"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/error.ts","../../src/utils/type-guards.ts","../../src/auth.ts","../../src/utils/type-helpers.ts","../../src/types/common.ts","../../src/utils/constants.ts","../../src/utils/common.ts","../../src/dedupe.ts","../../src/plugins.ts","../../src/validation.ts","../../src/response.ts","../../src/retry.ts","../../src/url.ts","../../src/utils/polyfills.ts","../../src/createFetchClient.ts"],"sourcesContent":["export { callApi, createFetchClient } from \"./createFetchClient\";\n\nexport { definePlugin, type CallApiPlugin, type PluginInitContext } from \"./plugins\";\n\nexport type { InferSchemaResult, CallApiSchemas } from \"./validation\";\n\nexport { HTTPError } from \"./error\";\n\nexport type {\n\tBaseCallApiExtraOptions,\n\tCallApiExtraOptions,\n\tPossibleJavaScriptError,\n\tPossibleHTTPError,\n\tCallApiParameters,\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n\tCallApiResultErrorVariant,\n\tResultModeUnion,\n\tCallApiResultSuccessVariant,\n\tCombinedCallApiExtraOptions,\n\tErrorContext,\n\tInterceptors,\n\tInterceptorsOrInterceptorArray,\n\tPossibleJavascriptErrorNames,\n\tRegister,\n\tRequestContext,\n\tRequestErrorContext,\n\tResponseContext,\n\tResponseErrorContext,\n\tSuccessContext,\n} from \"./types\";\n","import type {\n\tCallApiExtraOptions,\n\tCallApiResultErrorVariant,\n\tPossibleJavascriptErrorNames,\n\tResultModeMap,\n} from \"./types/common\";\nimport { isHTTPErrorInstance, isObject } from \"./utils/type-guards\";\n\ntype ErrorInfo = {\n\tcloneResponse: CallApiExtraOptions[\"cloneResponse\"];\n\tdefaultErrorMessage: Required<CallApiExtraOptions>[\"defaultErrorMessage\"];\n\terror?: unknown;\n\tmessage?: string;\n\tresultMode: CallApiExtraOptions[\"resultMode\"];\n};\n\nexport const resolveErrorResult = <TCallApiResult = never>(info: ErrorInfo) => {\n\tconst { cloneResponse, defaultErrorMessage, error, message: customErrorMessage, resultMode } = info;\n\n\tlet errorVariantDetails: CallApiResultErrorVariant<unknown> = {\n\t\tdata: null,\n\t\terror: {\n\t\t\terrorData: error as Error,\n\t\t\tmessage: customErrorMessage ?? (error as Error).message,\n\t\t\tname: (error as Error).name as PossibleJavascriptErrorNames,\n\t\t},\n\t\tresponse: null,\n\t};\n\n\tif (isHTTPErrorInstance(error)) {\n\t\tconst { errorData, message = defaultErrorMessage, name, response } = error;\n\n\t\terrorVariantDetails = {\n\t\t\tdata: null,\n\t\t\terror: {\n\t\t\t\terrorData,\n\t\t\t\tmessage,\n\t\t\t\tname,\n\t\t\t},\n\t\t\tresponse: cloneResponse ? response.clone() : response,\n\t\t};\n\t}\n\n\tconst resultModeMap: ResultModeMap = {\n\t\tall: errorVariantDetails,\n\t\tonlyError: errorVariantDetails.error,\n\t\tonlyResponse: errorVariantDetails.response,\n\t\tonlySuccess: errorVariantDetails.data,\n\t\tonlySuccessWithException: errorVariantDetails.data,\n\t};\n\n\tconst getErrorResult = (customInfo?: Pick<ErrorInfo, \"message\">) => {\n\t\tconst errorResult = resultModeMap[resultMode ?? \"all\"] as TCallApiResult;\n\n\t\treturn isObject(customInfo) ? { ...errorResult, ...customInfo } : errorResult;\n\t};\n\n\treturn { errorVariantDetails, getErrorResult };\n};\n\ntype ErrorDetails<TErrorResponse> = {\n\tdefaultErrorMessage: string;\n\terrorData: TErrorResponse;\n\tresponse: Response;\n};\n\ntype ErrorOptions = {\n\tcause?: unknown;\n};\n\nexport class HTTPError<TErrorResponse = Record<string, unknown>> extends Error {\n\terrorData: ErrorDetails<TErrorResponse>[\"errorData\"];\n\tisHTTPError = true;\n\n\toverride name = \"HTTPError\" as const;\n\n\tresponse: ErrorDetails<TErrorResponse>[\"response\"];\n\n\tconstructor(errorDetails: ErrorDetails<TErrorResponse>, errorOptions?: ErrorOptions) {\n\t\tconst { defaultErrorMessage, errorData, response } = errorDetails;\n\n\t\tsuper((errorData as { message?: string } | undefined)?.message ?? defaultErrorMessage, errorOptions);\n\n\t\tthis.errorData = errorData;\n\t\tthis.response = response;\n\n\t\tError.captureStackTrace(this, this.constructor);\n\t}\n}\n","import { HTTPError } from \"@/error\";\nimport type { PossibleHTTPError, PossibleJavaScriptError } from \"@/types/common\";\nimport type { AnyFunction } from \"./type-helpers\";\n\ntype ErrorObjectUnion<TErrorData = unknown> = PossibleHTTPError<TErrorData> | PossibleJavaScriptError;\n\nexport const isHTTPError = <TErrorData>(\n\terror: ErrorObjectUnion<TErrorData> | null\n): error is PossibleHTTPError<TErrorData> => {\n\treturn isPlainObject(error) && error.name === \"HTTPError\";\n};\n\nexport const isHTTPErrorInstance = <TErrorResponse>(\n\terror: unknown\n): error is HTTPError<TErrorResponse> => {\n\treturn (\n\t\t// prettier-ignore\n\t\terror instanceof HTTPError|| (isPlainObject(error) && error.name === \"HTTPError\" && error.isHTTPError === true)\n\t);\n};\n\nexport const isArray = <TArrayItem>(value: unknown): value is TArrayItem[] => Array.isArray(value);\n\nexport const isObject = (value: unknown) => typeof value === \"object\" && value !== null;\n\nexport const isPlainObject = <TPlainObject extends Record<string, unknown>>(\n\tvalue: unknown\n): value is TPlainObject => {\n\tif (!isObject(value)) {\n\t\treturn false;\n\t}\n\n\tconst prototype = Object.getPrototypeOf(value) as unknown;\n\n\t// Check if it's a plain object\n\treturn (\n\t\t// prettier-ignore\n\t\t(prototype == null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value)\n\t);\n};\n\nexport const isFunction = <TFunction extends AnyFunction>(value: unknown): value is TFunction =>\n\ttypeof value === \"function\";\n\nexport const isQueryString = (value: unknown): value is string => isString(value) && value.includes(\"=\");\n\nexport const isString = (value: unknown) => typeof value === \"string\";\n\n// https://github.com/unjs/ofetch/blob/main/src/utils.ts\n// TODO Find a way to incorporate this function in checking when to apply the bodySerializer on the body and also whether to add the content type application/json\nexport const isJSONSerializable = (value: unknown) => {\n\tif (value === undefined) {\n\t\treturn false;\n\t}\n\tconst t = typeof value;\n\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- No time to make this more type-safe\n\tif (t === \"string\" || t === \"number\" || t === \"boolean\" || t === null) {\n\t\treturn true;\n\t}\n\tif (t !== \"object\") {\n\t\treturn false;\n\t}\n\tif (isArray(value)) {\n\t\treturn true;\n\t}\n\tif ((value as Buffer | null)?.buffer) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- Nullish coalescing makes no sense in this boolean context\n\t\t(value?.constructor && value.constructor.name === \"Object\") ||\n\t\ttypeof (value as { toJSON: () => unknown } | null)?.toJSON === \"function\"\n\t);\n};\n","/* eslint-disable perfectionist/sort-object-types -- Avoid Sorting for now */\n\nimport type { ExtraOptions } from \"./types/common\";\nimport { isFunction, isString } from \"./utils/type-guards\";\n\ntype ValueOrFunctionResult<TValue> = TValue | (() => TValue);\n\n/**\n * Bearer Or Token authentication\n *\n * The value of `bearer` will be added to a header as\n * `auth: Bearer some-auth-token`,\n *\n * The value of `token` will be added to a header as\n * `auth: Token some-auth-token`,\n */\nexport type BearerOrTokenAuth =\n\t| {\n\t\t\ttype?: \"Bearer\";\n\t\t\tbearer?: ValueOrFunctionResult<string | null>;\n\t\t\ttoken?: never;\n\t }\n\t| {\n\t\t\ttype?: \"Token\";\n\t\t\tbearer?: never;\n\t\t\ttoken?: ValueOrFunctionResult<string | null>;\n\t };\n\n/**\n * Basic auth\n */\nexport type BasicAuth = {\n\ttype: \"Basic\";\n\tusername: ValueOrFunctionResult<string | null | undefined>;\n\tpassword: ValueOrFunctionResult<string | null | undefined>;\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: ValueOrFunctionResult<string | null | undefined>;\n\tvalue: ValueOrFunctionResult<string | null | undefined>;\n};\n\n// eslint-disable-next-line perfectionist/sort-union-types -- Let the first one be first\nexport type Auth = BearerOrTokenAuth | BasicAuth | CustomAuth;\n\nconst getValue = (value: ValueOrFunctionResult<string | null | undefined>) => {\n\treturn isFunction(value) ? value() : value;\n};\n\ntype AuthorizationHeader = {\n\tAuthorization: string;\n};\n\nexport const getAuthHeader = (auth: ExtraOptions[\"auth\"]): false | AuthorizationHeader | undefined => {\n\tif (auth === undefined) return;\n\n\tif (isString(auth) || auth === null) {\n\t\treturn { Authorization: `Bearer ${auth}` };\n\t}\n\n\tswitch (auth.type) {\n\t\tcase \"Basic\": {\n\t\t\tconst username = getValue(auth.username);\n\t\t\tconst password = getValue(auth.password);\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\n\t\tcase \"Custom\": {\n\t\t\tconst value = getValue(auth.value);\n\n\t\t\tif (value === undefined) return;\n\n\t\t\tconst prefix = getValue(auth.prefix);\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `${prefix} ${value}`,\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\tconst bearer = getValue(auth.bearer);\n\t\t\tconst token = getValue(auth.token);\n\n\t\t\tif (\"token\" in auth && token !== undefined) {\n\t\t\t\treturn { Authorization: `Token ${token}` };\n\t\t\t}\n\n\t\t\treturn bearer !== undefined && { Authorization: `Bearer ${bearer}` };\n\t\t}\n\t}\n};\n","// == These two types allows for adding arbitrary literal types, while still provided autocomplete for defaults.\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 & { z_placeholder?: never };\nexport type AnyNumber = number & { z_placeholder?: never };\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is fine here\nexport type AnyObject = Record<string, 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 CallbackFn<in TParams, out TResult = void> = (...params: TParams[]) => TResult;\n\nexport type Prettify<TObject> = NonNullable<unknown> & { [Key in keyof TObject]: TObject[Key] };\n\nexport type Writeable<TObject, TType extends \"deep\" | \"shallow\" = \"shallow\"> = {\n\t-readonly [key in keyof TObject]: TType extends \"shallow\"\n\t\t? TObject[key]\n\t\t: TType extends \"deep\"\n\t\t\t? TObject[key] extends object\n\t\t\t\t? Writeable<TObject[key], TType>\n\t\t\t\t: TObject[key]\n\t\t\t: never;\n};\n\nexport const defineEnum = <const TValue>(value: TValue) => value as Prettify<Writeable<TValue, \"deep\">>;\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> = { _: TValue }[\"_\"];\n\nexport type Awaitable<TValue> = Promise<TValue> | TValue;\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","/* eslint-disable ts-eslint/consistent-type-definitions -- I need to use interfaces for the sake of user overrides */\nimport type { Auth } from \"../auth\";\nimport type { CallApiPlugin, DefaultPlugins, InferPluginOptions, Plugins } from \"../plugins\";\nimport type { GetResponseType, ResponseTypeUnion } from \"../response\";\nimport type { RetryOptions } from \"../retry\";\nimport type { UrlOptions } from \"../url\";\nimport type { fetchSpecificKeys } from \"../utils/constants\";\nimport { type Awaitable, type UnmaskType, defineEnum } from \"../utils/type-helpers\";\nimport type { CallApiSchemas, CallApiValidators } from \"../validation\";\nimport type {\n\tBodyOption,\n\tHeadersOption,\n\tMetaOption,\n\tMethodOption,\n\tResultModeOption,\n} from \"./conditional-types\";\n\ntype FetchSpecificKeysUnion = Exclude<(typeof fetchSpecificKeys)[number], \"body\" | \"headers\" | \"method\">;\n\nexport type CallApiRequestOptions<TSchemas extends CallApiSchemas = DefaultMoreOptions> =\n\tBodyOption<TSchemas> &\n\t\tHeadersOption<TSchemas> &\n\t\tMethodOption<TSchemas> &\n\t\tPick<RequestInit, FetchSpecificKeysUnion>;\n\nexport type CallApiRequestOptionsForHooks<TSchemas extends CallApiSchemas = DefaultMoreOptions> = Omit<\n\tCallApiRequestOptions<TSchemas>,\n\t\"headers\"\n> & {\n\theaders?: Record<string, string | undefined>;\n};\n\nexport type DefaultDataType = unknown;\n\nexport type DefaultMoreOptions = NonNullable<unknown>;\n\nexport type WithMoreOptions<TMoreOptions = DefaultMoreOptions> = {\n\toptions: CombinedCallApiExtraOptions & Partial<TMoreOptions>;\n};\n\nexport interface Interceptors<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTMoreOptions = DefaultMoreOptions,\n> {\n\t/**\n\t * Interceptor that will be called when any error occurs within the request/response lifecycle, regardless of whether the error is from the api or not.\n\t * It is basically a combination of `onRequestError` and `onResponseError` interceptors\n\t */\n\tonError?: (context: ErrorContext<TErrorData> & WithMoreOptions<TMoreOptions>) => Awaitable<unknown>;\n\n\t/**\n\t * Interceptor that will be called just before the request is made, allowing for modifications or additional operations.\n\t */\n\tonRequest?: (context: RequestContext & WithMoreOptions<TMoreOptions>) => Awaitable<unknown>;\n\n\t/**\n\t * Interceptor that will be called when an error occurs during the fetch request.\n\t */\n\tonRequestError?: (context: RequestErrorContext & WithMoreOptions<TMoreOptions>) => Awaitable<unknown>;\n\n\t/**\n\t * Interceptor that will be called when any response is received from the api, whether successful or not\n\t */\n\tonResponse?: (\n\t\tcontext: ResponseContext<TData, TErrorData> & WithMoreOptions<TMoreOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Interceptor that will be called when an error response is received from the api.\n\t */\n\tonResponseError?: (\n\t\tcontext: ResponseErrorContext<TErrorData> & WithMoreOptions<TMoreOptions>\n\t) => Awaitable<unknown>;\n\n\t/**\n\t * Interceptor that will be called when a request is retried.\n\t */\n\tonRetry?: (response: ErrorContext<TErrorData> & WithMoreOptions<TMoreOptions>) => Awaitable<unknown>;\n\t/**\n\t * Interceptor that will be called when a successful response is received from the api.\n\t */\n\tonSuccess?: (context: SuccessContext<TData> & WithMoreOptions<TMoreOptions>) => Awaitable<unknown>;\n}\n\n/* eslint-disable perfectionist/sort-union-types -- I need arrays to be last */\nexport type InterceptorsOrInterceptorArray<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTMoreOptions = DefaultMoreOptions,\n> = {\n\t[Key in keyof Interceptors<TData, TErrorData, TMoreOptions>]:\n\t\t| Interceptors<TData, TErrorData, TMoreOptions>[Key]\n\t\t| Array<Interceptors<TData, TErrorData, TMoreOptions>[Key]>;\n};\n/* eslint-enable perfectionist/sort-union-types -- I need arrays to be last */\n\ntype FetchImpl = UnmaskType<(input: string | Request | URL, init?: RequestInit) => Promise<Response>>;\n\nexport type ExtraOptions<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResultMode extends ResultModeUnion = ResultModeUnion,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tTSchemas extends CallApiSchemas = DefaultMoreOptions,\n\tTPluginArray extends CallApiPlugin[] = DefaultPlugins,\n> = {\n\t/**\n\t * Authorization header value.\n\t */\n\tauth?: string | Auth | null;\n\t/**\n\t * Base URL to be prepended to all request URLs\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Custom function to serialize the body object into a string.\n\t */\n\tbodySerializer?: (bodyData: Record<string, unknown>) => string;\n\n\t/**\n\t * Whether or not to clone the response, so response.json() and the like, can be read again else where.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Response/clone\n\t * @default false\n\t */\n\tcloneResponse?: boolean;\n\n\t/**\n\t * Custom fetch implementation\n\t */\n\tcustomFetchImpl?: FetchImpl;\n\n\t/**\n\t * Custom request key to be used to identify a request in the fetch deduplication strategy.\n\t * @default the full request url + string formed from the request options\n\t */\n\tdedupeKey?: string;\n\n\t/**\n\t * Defines the deduplication strategy for the request, can be set to \"none\" | \"defer\" | \"cancel\".\n\t * - If set to \"cancel\", the previous pending request with the same request key will be cancelled and lets the new request through.\n\t * - If set to \"defer\", all new request with the same request key will be share the same response, until the previous one is completed.\n\t * - If set to \"none\", deduplication is disabled.\n\t * @default \"cancel\"\n\t */\n\tdedupeStrategy?: \"cancel\" | \"defer\" | \"none\";\n\n\t/**\n\t * Default error message to use if none is provided from a response.\n\t * @default \"Failed to fetch data from server!\"\n\t */\n\tdefaultErrorMessage?: string;\n\n\t/**\n\t * Resolved request URL\n\t */\n\treadonly fullURL?: string;\n\n\t/**\n\t * Defines the mode in which the merged hooks are executed, can be set to \"parallel\" | \"sequential\".\n\t * - If set to \"parallel\", main and plugin hooks will be executed in parallel.\n\t * - If set to \"sequential\", the plugin hooks will be executed first, followed by the main hook.\n\t * @default \"parallel\"\n\t */\n\tmergedHooksExecutionMode?: \"parallel\" | \"sequential\";\n\n\t/**\n\t * - Controls what order in which the merged hooks execute\n\t * @default \"mainHooksLast\"\n\t */\n\tmergedHooksExecutionOrder?: \"mainHooksAfterPlugins\" | \"mainHooksBeforePlugins\";\n\n\t/**\n\t * An array of CallApi plugins. It allows you to extend the behavior of the library.\n\t */\n\tplugins?: Plugins<TPluginArray>;\n\n\t/**\n\t * Custom function to parse the response string into a object.\n\t */\n\tresponseParser?: (responseString: string) => Awaitable<Record<string, unknown>>;\n\n\t/**\n\t * Expected response type, affects how response is parsed\n\t * @default \"json\"\n\t */\n\tresponseType?: TResponseType;\n\n\t/**\n\t * Mode of the result, can influence how results are handled or returned.\n\t * Can be set to \"all\" | \"onlySuccess\" | \"onlyError\" | \"onlyResponse\".\n\t * @default \"all\"\n\t */\n\tresultMode?: TResultMode;\n\n\t/**\n\t * Type-safe schemas for the response validation.\n\t */\n\tschemas?: TSchemas;\n\n\t/**\n\t * If true or the function returns true, throws errors instead of returning them\n\t * The function is passed the error object and can be used to conditionally throw the error\n\t * @default false\n\t */\n\tthrowOnError?: boolean | ((context: ErrorContext<TErrorData>) => boolean);\n\n\t/**\n\t * Request timeout in milliseconds\n\t */\n\ttimeout?: number;\n\n\t/**\n\t * Custom validation functions for response validation\n\t */\n\tvalidators?: CallApiValidators<TData, TErrorData>;\n\t/* eslint-disable perfectionist/sort-intersection-types -- Allow these to be last for the sake of docs */\n} & InterceptorsOrInterceptorArray<TData, TErrorData> &\n\tPartial<InferPluginOptions<TPluginArray>> &\n\tMetaOption<TSchemas> &\n\tRetryOptions<TErrorData> &\n\tResultModeOption<TErrorData, TResultMode> &\n\tUrlOptions<TSchemas>;\n/* eslint-enable perfectionist/sort-intersection-types -- Allow these to be last for the sake of docs */\n\nexport const optionsEnumToExtendFromBase = defineEnum([\"plugins\", \"validators\", \"schemas\"] satisfies Array<\n\tkeyof ExtraOptions\n>);\n\nexport type CallApiExtraOptions<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResultMode extends ResultModeUnion = ResultModeUnion,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tTSchemas extends CallApiSchemas = DefaultMoreOptions,\n\tTPluginArray extends CallApiPlugin[] = DefaultPlugins,\n> = CallApiRequestOptions<TSchemas> &\n\tExtraOptions<TData, TErrorData, TResultMode, TResponseType, TSchemas, TPluginArray> & {\n\t\t/**\n\t\t * Options that should extend the base options.\n\t\t */\n\t\textend?: Pick<\n\t\t\tExtraOptions<TData, TErrorData, TResultMode, TResponseType, TSchemas, TPluginArray>,\n\t\t\t(typeof optionsEnumToExtendFromBase)[number]\n\t\t>;\n\t};\n\nexport const optionsEnumToOmitFromBase = defineEnum([\"extend\", \"dedupeKey\"] satisfies Array<\n\tkeyof CallApiExtraOptions\n>);\n\nexport type BaseCallApiExtraOptions<\n\tTBaseData = DefaultDataType,\n\tTBaseErrorData = DefaultDataType,\n\tTBaseResultMode extends ResultModeUnion = ResultModeUnion,\n\tTBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tTBaseSchemas extends CallApiSchemas = DefaultMoreOptions,\n\tTBasePluginArray extends CallApiPlugin[] = DefaultPlugins,\n> = Omit<\n\tPartial<\n\t\tCallApiExtraOptions<\n\t\t\tTBaseData,\n\t\t\tTBaseErrorData,\n\t\t\tTBaseResultMode,\n\t\t\tTBaseResponseType,\n\t\t\tTBaseSchemas,\n\t\t\tTBasePluginArray\n\t\t>\n\t>,\n\t(typeof optionsEnumToOmitFromBase)[number]\n>;\n\nexport type CombinedCallApiExtraOptions = BaseCallApiExtraOptions & CallApiExtraOptions;\n\nexport type CallApiParameters<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResultMode extends ResultModeUnion = ResultModeUnion,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tTSchemas extends CallApiSchemas = DefaultMoreOptions,\n\tTPluginArray extends CallApiPlugin[] = DefaultPlugins,\n> = [\n\tinitURL: UrlOptions<TSchemas>[\"initURL\"],\n\tconfig?: CallApiExtraOptions<TData, TErrorData, TResultMode, TResponseType, TSchemas, TPluginArray>,\n];\n\nexport type RequestContext = UnmaskType<{\n\toptions: CombinedCallApiExtraOptions;\n\trequest: CallApiRequestOptionsForHooks;\n}>;\n\nexport type ResponseContext<TData, TErrorData> = UnmaskType<\n\t| {\n\t\t\tdata: TData;\n\t\t\terror: null;\n\t\t\toptions: CombinedCallApiExtraOptions;\n\t\t\trequest: CallApiRequestOptionsForHooks;\n\t\t\tresponse: Response;\n\t }\n\t// eslint-disable-next-line perfectionist/sort-union-types -- I need the first one to be first\n\t| {\n\t\t\tdata: null;\n\t\t\terror: PossibleHTTPError<TErrorData>;\n\t\t\toptions: CombinedCallApiExtraOptions;\n\t\t\trequest: CallApiRequestOptionsForHooks;\n\t\t\tresponse: Response;\n\t }\n>;\n\nexport type SuccessContext<TData> = UnmaskType<{\n\tdata: TData;\n\toptions: CombinedCallApiExtraOptions;\n\trequest: CallApiRequestOptionsForHooks;\n\tresponse: Response;\n}>;\n\nexport type PossibleJavascriptErrorNames =\n\t| \"AbortError\"\n\t| \"Error\"\n\t| \"SyntaxError\"\n\t| \"TimeoutError\"\n\t| \"TypeError\"\n\t| (`${string}Error` & DefaultMoreOptions);\n\nexport type PossibleJavaScriptError = UnmaskType<{\n\terrorData: DOMException | Error | SyntaxError | TypeError;\n\tmessage: string;\n\tname: PossibleJavascriptErrorNames;\n}>;\n\nexport type PossibleHTTPError<TErrorData> = UnmaskType<{\n\terrorData: TErrorData;\n\tmessage: string;\n\tname: \"HTTPError\";\n}>;\n\nexport type RequestErrorContext = UnmaskType<{\n\terror: PossibleJavaScriptError;\n\toptions: CombinedCallApiExtraOptions;\n\trequest: CallApiRequestOptionsForHooks;\n}>;\n\nexport type ResponseErrorContext<TErrorData> = UnmaskType<{\n\terror: PossibleHTTPError<TErrorData>;\n\toptions: CombinedCallApiExtraOptions;\n\trequest: CallApiRequestOptionsForHooks;\n\tresponse: Response;\n}>;\n\nexport type ErrorContext<TErrorData> = UnmaskType<\n\t| {\n\t\t\terror: PossibleHTTPError<TErrorData>;\n\t\t\toptions: CombinedCallApiExtraOptions;\n\t\t\trequest: CallApiRequestOptionsForHooks;\n\t\t\tresponse: Response;\n\t }\n\t| {\n\t\t\terror: PossibleJavaScriptError;\n\t\t\toptions: CombinedCallApiExtraOptions;\n\t\t\trequest: CallApiRequestOptionsForHooks;\n\t\t\tresponse: null;\n\t }\n>;\n\nexport type CallApiResultSuccessVariant<TData> = {\n\tdata: TData;\n\terror: null;\n\tresponse: Response;\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: PossibleJavaScriptError;\n\t\t\tresponse: null;\n\t };\n\nexport type ResultModeMap<\n\tTData = DefaultDataType,\n\tTErrorData = DefaultDataType,\n\tTResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tTComputedData = GetResponseType<TData, TResponseType>,\n\tTComputedErrorData = GetResponseType<TErrorData, TResponseType>,\n> = UnmaskType<{\n\t/* eslint-disable perfectionist/sort-union-types -- I need the first one to be first */\n\tall: CallApiResultSuccessVariant<TComputedData> | CallApiResultErrorVariant<TComputedErrorData>;\n\n\tonlyError:\n\t\t| CallApiResultSuccessVariant<TComputedData>[\"error\"]\n\t\t| CallApiResultErrorVariant<TComputedErrorData>[\"error\"];\n\n\tonlyResponse:\n\t\t| CallApiResultErrorVariant<TComputedErrorData>[\"response\"]\n\t\t| CallApiResultSuccessVariant<TComputedData>[\"response\"];\n\n\tonlySuccess:\n\t\t| CallApiResultErrorVariant<TComputedErrorData>[\"data\"]\n\t\t| CallApiResultSuccessVariant<TComputedData>[\"data\"];\n\n\tonlySuccessWithException: CallApiResultSuccessVariant<TComputedData>[\"data\"];\n\t/* eslint-enable perfectionist/sort-union-types -- I need the first one to be first */\n}>;\n\nexport type ResultModeUnion = keyof ResultModeMap | undefined;\n\nexport type GetCallApiResult<\n\tTData,\n\tTErrorData,\n\tTResultMode extends ResultModeUnion,\n\tTResponseType extends ResponseTypeUnion,\n\tTComputedMap extends ResultModeMap<TData, TErrorData, TResponseType> = ResultModeMap<\n\t\tTData,\n\t\tTErrorData,\n\t\tTResponseType\n\t>,\n> = TErrorData extends false\n\t? TComputedMap[\"onlySuccessWithException\"]\n\t: // If TResultMode is the entire ResultModeMap with undefined, we return the \"all\" variant\n\t\tResultModeUnion | undefined extends TResultMode\n\t\t? TComputedMap[\"all\"]\n\t\t: TResultMode extends NonNullable<ResultModeUnion>\n\t\t\t? TComputedMap[TResultMode]\n\t\t\t: never;\n","import type { BaseCallApiExtraOptions } from \"../types/common\";\nimport { defineEnum } from \"./type-helpers\";\n\nexport const fetchSpecificKeys = defineEnum([\n\t\"body\",\n\t\"integrity\",\n\t\"method\",\n\t\"headers\",\n\t\"signal\",\n\t\"cache\",\n\t\"redirect\",\n\t\"window\",\n\t\"credentials\",\n\t\"keepalive\",\n\t\"referrer\",\n\t\"priority\",\n\t\"mode\",\n\t\"referrerPolicy\",\n] satisfies Array<keyof RequestInit>);\n\nconst retryStatusCodesLookup = defineEnum({\n\t408: \"Request Timeout\",\n\t409: \"Conflict\",\n\t425: \"Too Early\",\n\t429: \"Too Many Requests\",\n\t500: \"Internal Server Error\",\n\t502: \"Bad Gateway\",\n\t503: \"Service Unavailable\",\n\t504: \"Gateway Timeout\",\n});\n\nexport const defaultRetryMethods = [\"GET\", \"POST\"] satisfies BaseCallApiExtraOptions[\"retryMethods\"];\n\n// prettier-ignore\nexport const defaultRetryStatusCodes = Object.keys(retryStatusCodesLookup).map(Number) as Required<BaseCallApiExtraOptions>[\"retryStatusCodes\"];\n","import { getAuthHeader } from \"@/auth\";\nimport {\n\ttype BaseCallApiExtraOptions,\n\ttype CallApiExtraOptions,\n\ttype CallApiRequestOptions,\n\toptionsEnumToOmitFromBase,\n} from \"../types/common\";\nimport { fetchSpecificKeys } from \"./constants\";\nimport { isArray, isFunction, isPlainObject, isQueryString, isString } from \"./type-guards\";\nimport type { AnyFunction, Awaitable } from \"./type-helpers\";\n\nconst omitKeys = <TObject extends Record<string, unknown>, const TOmitArray extends Array<keyof TObject>>(\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 Omit<TObject, TOmitArray[number]>;\n};\n\nconst pickKeys = <TObject extends Record<string, unknown>, const TPickArray extends Array<keyof TObject>>(\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, [\n\t\t\t...fetchSpecificKeys,\n\t\t\t...optionsEnumToOmitFromBase,\n\t\t]) 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 || isPlainObject(headers)) {\n\t\treturn headers;\n\t}\n\n\treturn Object.fromEntries(headers);\n};\n\ntype ToQueryStringFn = {\n\t(params: CallApiExtraOptions[\"query\"]): string | null;\n\t(params: Required<CallApiExtraOptions>[\"query\"]): string;\n};\n\nexport const toQueryString: ToQueryStringFn = (params) => {\n\tif (!params) {\n\t\tconsole.error(\"toQueryString:\", \"No query params provided!\");\n\n\t\treturn null as never;\n\t}\n\n\treturn new URLSearchParams(params as Record<string, string>).toString();\n};\n\n// export mergeAndResolve\n\nexport const mergeAndResolveHeaders = (options: {\n\tauth: CallApiExtraOptions[\"auth\"];\n\tbaseHeaders: CallApiExtraOptions[\"headers\"];\n\tbody: CallApiExtraOptions[\"body\"];\n\theaders: CallApiExtraOptions[\"headers\"];\n}) => {\n\tconst { auth, baseHeaders, body, headers } = options;\n\n\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- Nullish coalescing makes no sense in this boolean context\n\tconst shouldResolveHeaders = Boolean(baseHeaders || headers || body || auth);\n\n\t// == Return early if any of the following conditions are not met (so that native fetch would auto set the correct headers):\n\t// == - headers are provided\n\t// == - The body is an object\n\t// == - The auth option is provided\n\tif (!shouldResolveHeaders) return;\n\n\tconst headersObject: Record<string, string | undefined> = {\n\t\t...getAuthHeader(auth),\n\t\t...objectifyHeaders(baseHeaders),\n\t\t...objectifyHeaders(headers),\n\t};\n\n\tif (isQueryString(body)) {\n\t\theadersObject[\"Content-Type\"] = \"application/x-www-form-urlencoded\";\n\n\t\treturn headersObject;\n\t}\n\n\tif (isPlainObject(body) || (isString(body) && body.startsWith(\"{\"))) {\n\t\theadersObject[\"Content-Type\"] = \"application/json\";\n\t\theadersObject.Accept = \"application/json\";\n\t}\n\n\treturn headersObject;\n};\n\nexport const combineHooks = <TInterceptor extends AnyFunction | Array<AnyFunction | undefined>>(\n\tbaseInterceptor: TInterceptor | undefined,\n\tinterceptor: TInterceptor | undefined\n) => {\n\tif (isArray(baseInterceptor)) {\n\t\treturn [baseInterceptor, interceptor].flat() as TInterceptor;\n\t}\n\n\treturn interceptor ?? baseInterceptor;\n};\n\nexport const getFetchImpl = (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 executeHooks = <TInterceptor extends Awaitable<unknown>>(...interceptors: TInterceptor[]) =>\n\tPromise.all(interceptors);\n\nconst PromiseWithResolvers = () => {\n\tlet reject!: (reason?: unknown) => void;\n\tlet resolve!: (value: unknown) => void;\n\n\tconst promise = new Promise((res, rej) => {\n\t\tresolve = res;\n\t\treject = rej;\n\t});\n\n\treturn { promise, reject, resolve };\n};\n\nexport const waitUntil = (delay: number) => {\n\tif (delay === 0) return;\n\n\tconst { promise, resolve } = PromiseWithResolvers();\n\n\tsetTimeout(resolve, delay);\n\n\treturn promise;\n};\n","import type { CallApiExtraOptions, CallApiRequestOptions } from \"./types/common\";\nimport { getFetchImpl, waitUntil } from \"./utils/common\";\n\ntype RequestInfo = {\n\tcontroller: AbortController;\n\tresponsePromise: Promise<Response>;\n};\n\nexport type RequestInfoCache = Map<string | null, RequestInfo>;\n\ntype DedupeContext = {\n\t$RequestInfoCache: RequestInfoCache;\n\tnewFetchController: AbortController;\n\toptions: CallApiExtraOptions;\n\trequest: CallApiRequestOptions;\n};\n\nexport const createDedupeStrategy = async (context: DedupeContext) => {\n\tconst { $RequestInfoCache, newFetchController, options, request } = context;\n\n\tconst generateDedupeKey = () => {\n\t\tconst shouldHaveDedupeKey =\n\t\t\toptions.dedupeStrategy === \"cancel\" || options.dedupeStrategy === \"defer\";\n\n\t\tif (!shouldHaveDedupeKey) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn `${options.fullURL}-${JSON.stringify({ options, request })}`;\n\t};\n\n\tconst dedupeKey = options.dedupeKey ?? generateDedupeKey();\n\n\t// == This is to ensure cache operations only occur when key is available\n\tconst $RequestInfoCacheOrNull = dedupeKey !== null ? $RequestInfoCache : null;\n\n\t/******\n\t * == Add a small delay to the execution to ensure proper request deduplication when multiple requests with the same key start simultaneously.\n\t * == This gives time for the cache to be updated with the previous request info before the next request checks it.\n\t ******/\n\tif (dedupeKey !== null) {\n\t\tawait waitUntil(0.1);\n\t}\n\n\tconst prevRequestInfo = $RequestInfoCacheOrNull?.get(dedupeKey);\n\n\tconst handleRequestCancelDedupeStrategy = () => {\n\t\tconst shouldCancelRequest = prevRequestInfo && options.dedupeStrategy === \"cancel\";\n\n\t\tif (shouldCancelRequest) {\n\t\t\tconst message = options.dedupeKey\n\t\t\t\t? `Duplicate request detected - Aborting previous request with key '${options.dedupeKey}' as a new request was initiated`\n\t\t\t\t: `Duplicate request detected - Aborting previous request to '${options.fullURL}' as a new request with identical options was initiated`;\n\n\t\t\tconst reason = new DOMException(message, \"AbortError\");\n\n\t\t\tprevRequestInfo.controller.abort(reason);\n\t\t}\n\t};\n\n\tconst handleRequestDeferDedupeStrategy = () => {\n\t\tconst fetchApi = getFetchImpl(options.customFetchImpl);\n\n\t\tconst shouldUsePromiseFromCache = prevRequestInfo && options.dedupeStrategy === \"defer\";\n\n\t\tconst responsePromise = shouldUsePromiseFromCache\n\t\t\t? prevRequestInfo.responsePromise\n\t\t\t: fetchApi(options.fullURL as NonNullable<typeof options.fullURL>, request as RequestInit);\n\n\t\t$RequestInfoCacheOrNull?.set(dedupeKey, { controller: newFetchController, responsePromise });\n\n\t\treturn responsePromise;\n\t};\n\n\tconst removeDedupeKeyFromCache = () => $RequestInfoCacheOrNull?.delete(dedupeKey);\n\n\treturn {\n\t\thandleRequestCancelDedupeStrategy,\n\t\thandleRequestDeferDedupeStrategy,\n\t\tremoveDedupeKeyFromCache,\n\t};\n};\n","/* eslint-disable ts-eslint/consistent-type-definitions -- I need to use interfaces for the sake of user overrides */\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type {\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n\tCombinedCallApiExtraOptions,\n\tDefaultMoreOptions,\n\tInterceptors,\n\tInterceptorsOrInterceptorArray,\n\tWithMoreOptions,\n} from \"./types/common\";\nimport { isFunction, isPlainObject, isString } from \"./utils/type-guards\";\nimport type { AnyFunction, Awaitable } from \"./utils/type-helpers\";\nimport type { InferSchemaResult } from \"./validation\";\n\ntype UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : never) extends (\n\tparam: infer TParam\n) => void\n\t? TParam\n\t: never;\n\nexport type DefaultPlugins = CallApiPlugin[];\n\ntype InferSchema<TResult> = TResult extends StandardSchemaV1\n\t? InferSchemaResult<TResult, NonNullable<unknown>>\n\t: TResult;\n\nexport type InferPluginOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<\n\tInferSchema<ReturnType<NonNullable<TPluginArray[number][\"createExtraOptions\"]>>>\n>;\n\nexport type PluginInitContext<TMoreOptions = DefaultMoreOptions> = WithMoreOptions<TMoreOptions> & {\n\tinitURL: string;\n\toptions: CombinedCallApiExtraOptions;\n\trequest: CallApiRequestOptionsForHooks;\n};\n\nexport type PluginInitResult = Partial<\n\tOmit<PluginInitContext, \"request\"> & { request: CallApiRequestOptions }\n>;\n\nexport interface CallApiPlugin<TData = never, TErrorData = never> {\n\t/**\n\t * Defines additional options that can be passed to callApi\n\t */\n\tcreateExtraOptions?: (...params: never[]) => unknown;\n\n\t/**\n\t * A description for the plugin\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Hooks / Interceptors for the plugin\n\t */\n\thooks?: InterceptorsOrInterceptorArray<TData, TErrorData>;\n\n\t/**\n\t * A unique id for the plugin\n\t */\n\tid: string;\n\n\t/**\n\t * A function that will be called when the plugin is initialized. This will be called before the any of the other internal functions.\n\t */\n\tinit?: (context: PluginInitContext) => Awaitable<PluginInitResult> | Awaitable<void>;\n\n\t/**\n\t * A name for the plugin\n\t */\n\tname: string;\n\n\t/**\n\t * A version for the plugin\n\t */\n\tversion?: string;\n}\n\nexport const definePlugin = <\n\t// eslint-disable-next-line perfectionist/sort-union-types -- Let the first one be first\n\tTPlugin extends CallApiPlugin | AnyFunction<CallApiPlugin>,\n>(\n\tplugin: TPlugin\n) => {\n\treturn plugin;\n};\n\nconst createMergedHook = (\n\thooks: Array<AnyFunction | undefined>,\n\tmergedHooksExecutionMode: CombinedCallApiExtraOptions[\"mergedHooksExecutionMode\"]\n) => {\n\treturn async (ctx: Record<string, unknown>) => {\n\t\tif (mergedHooksExecutionMode === \"sequential\") {\n\t\t\tfor (const hook of hooks) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop -- This is necessary in this case\n\t\t\t\tawait hook?.(ctx);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (mergedHooksExecutionMode === \"parallel\") {\n\t\t\tconst hookArray = [...hooks];\n\n\t\t\tawait Promise.all(hookArray.map((uniqueHook) => uniqueHook?.(ctx)));\n\t\t}\n\t};\n};\n\n// prettier-ignore\ntype HookRegistries = {\n\t[Key in keyof Interceptors]: Set<Interceptors[Key]>;\n};\n\nexport const hooksEnum = {\n\tonError: new Set(),\n\tonRequest: new Set(),\n\tonRequestError: new Set(),\n\tonResponse: new Set(),\n\tonResponseError: new Set(),\n\tonRetry: new Set(),\n\tonSuccess: new Set(),\n} satisfies HookRegistries;\n\nexport type Plugins<TPluginArray extends CallApiPlugin[]> =\n\t| TPluginArray\n\t| ((context: PluginInitContext) => TPluginArray);\n\nconst getPluginArray = (plugins: Plugins<CallApiPlugin[]> | undefined, context: PluginInitContext) => {\n\tif (!plugins) {\n\t\treturn [];\n\t}\n\n\treturn isFunction(plugins) ? plugins(context) : plugins;\n};\n\nexport const initializePlugins = async (context: PluginInitContext) => {\n\tconst { initURL, options, request } = context;\n\n\tconst hookRegistries = structuredClone(hooksEnum);\n\n\tconst addMainHooks = () => {\n\t\tfor (const key of Object.keys(hooksEnum)) {\n\t\t\tconst mainHook = options[key as keyof Interceptors] as never;\n\n\t\t\thookRegistries[key as keyof Interceptors].add(mainHook);\n\t\t}\n\t};\n\n\tconst addPluginHooks = (pluginHooks: Required<CallApiPlugin>[\"hooks\"]) => {\n\t\tfor (const key of Object.keys(hooksEnum)) {\n\t\t\tconst pluginHook = pluginHooks[key as keyof Interceptors] as never;\n\n\t\t\thookRegistries[key as keyof Interceptors].add(pluginHook);\n\t\t}\n\t};\n\n\tif (options.mergedHooksExecutionOrder === \"mainHooksBeforePlugins\") {\n\t\taddMainHooks();\n\t}\n\n\tconst resolvedPlugins = [\n\t\t...getPluginArray(options.plugins, context),\n\t\t...getPluginArray(options.extend?.plugins, context),\n\t];\n\n\tlet resolvedUrl = initURL;\n\tlet resolvedOptions = options;\n\tlet resolvedRequestOptions = request;\n\n\tconst executePluginInit = async (pluginInit: CallApiPlugin[\"init\"]) => {\n\t\tif (!pluginInit) return;\n\n\t\tconst initResult = await pluginInit({ initURL, options, request });\n\n\t\tif (!isPlainObject(initResult)) return;\n\n\t\tif (isString(initResult.initURL)) {\n\t\t\tresolvedUrl = initResult.initURL;\n\t\t}\n\n\t\tif (isPlainObject(initResult.request)) {\n\t\t\tresolvedRequestOptions = initResult.request as CallApiRequestOptionsForHooks;\n\t\t}\n\n\t\tif (isPlainObject(initResult.options)) {\n\t\t\tresolvedOptions = initResult.options;\n\t\t}\n\t};\n\n\tfor (const plugin of resolvedPlugins) {\n\t\t// eslint-disable-next-line no-await-in-loop -- Await is necessary in this case.\n\t\tawait executePluginInit(plugin.init);\n\n\t\tif (!plugin.hooks) continue;\n\n\t\taddPluginHooks(plugin.hooks);\n\t}\n\n\tif (\n\t\t!options.mergedHooksExecutionOrder ||\n\t\toptions.mergedHooksExecutionOrder === \"mainHooksAfterPlugins\"\n\t) {\n\t\taddMainHooks();\n\t}\n\n\tconst resolvedHooks = {} as Required<Interceptors>;\n\n\tfor (const [key, hookRegistry] of Object.entries(hookRegistries)) {\n\t\tconst flattenedHookArray = [...hookRegistry].flat();\n\n\t\tconst mergedHook = createMergedHook(flattenedHookArray, options.mergedHooksExecutionMode);\n\n\t\tresolvedHooks[key as keyof Interceptors] = mergedHook;\n\t}\n\n\treturn {\n\t\tresolvedHooks,\n\t\tresolvedOptions,\n\t\tresolvedRequestOptions,\n\t\turl: resolvedUrl,\n\t};\n};\n","/* eslint-disable ts-eslint/consistent-type-definitions -- I need to use interfaces for the sake of user overrides */\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { Body, GlobalMeta, Headers, Method } from \"./types\";\nimport type { CombinedCallApiExtraOptions } from \"./types/common\";\nimport type { InitURL, Params, Query } from \"./url\";\n\nexport const standardSchemaParser = async <TSchema extends StandardSchemaV1>(\n\tschema: TSchema,\n\tinputData: StandardSchemaV1.InferInput<TSchema>\n): Promise<StandardSchemaV1.InferOutput<TSchema>> => {\n\tconst result = await schema[\"~standard\"].validate(inputData);\n\n\t// == If the `issues` field exists, it means the validation failed\n\tif (result.issues) {\n\t\tthrow new Error(JSON.stringify(result.issues, null, 2), { cause: result.issues });\n\t}\n\n\treturn result.value;\n};\n\nexport interface CallApiSchemas {\n\t/**\n\t * The schema to use for validating the request body.\n\t */\n\tbody?: StandardSchemaV1<Body>;\n\n\t/**\n\t * The schema to use for validating the response data.\n\t */\n\tdata?: StandardSchemaV1;\n\n\t/**\n\t * The schema to use for validating the response error data.\n\t */\n\terrorData?: StandardSchemaV1;\n\n\t/**\n\t * The schema to use for validating the request headers.\n\t */\n\theaders?: StandardSchemaV1<Headers>;\n\n\t/**\n\t * The schema to use for validating the request url.\n\t */\n\tinitURL?: StandardSchemaV1<InitURL>;\n\n\t/**\n\t * The schema to use for validating the meta option.\n\t */\n\tmeta?: StandardSchemaV1<GlobalMeta>;\n\n\t/**\n\t * The schema to use for validating the request method.\n\t */\n\tmethod?: StandardSchemaV1<Method>;\n\n\t/**\n\t * The schema to use for validating the request url parameter.\n\t */\n\tparams?: StandardSchemaV1<Params>;\n\n\t/**\n\t * The schema to use for validating the request url querys.\n\t */\n\tquery?: StandardSchemaV1<Query>;\n}\n\nexport interface CallApiValidators<TData = unknown, TErrorData = unknown> {\n\t/**\n\t * Custom function to validate the response data.\n\t */\n\tdata?: (value: unknown) => TData;\n\n\t/**\n\t * Custom function to validate the response error data, stemming from the api.\n\t * This only runs if the api actually sends back error status codes, else it will be ignored, in which case you should only use the `responseValidator` option.\n\t */\n\terrorData?: (value: unknown) => TErrorData;\n}\n\nexport type InferSchemaResult<TSchema, TData> = TSchema extends StandardSchemaV1\n\t? StandardSchemaV1.InferOutput<TSchema>\n\t: TData;\n\nexport const createExtensibleSchemasAndValidators = (options: CombinedCallApiExtraOptions) => {\n\tconst schemas =\n\t\toptions.schemas && ({ ...options.schemas, ...options.extend?.schemas } as CallApiSchemas);\n\n\tconst validators = options.validators && { ...options.validators, ...options.extend?.validators };\n\n\treturn { schemas, validators };\n};\n","import type { CallApiExtraOptions, ResultModeMap } from \"./types\";\nimport type { Awaitable } from \"./utils/type-helpers\";\nimport { type CallApiSchemas, type CallApiValidators, standardSchemaParser } from \"./validation\";\n\ntype Parser = (responseString: string) => Awaitable<Record<string, unknown>>;\n\nexport const getResponseType = <TResponse>(response: Response, parser?: Parser) => ({\n\tarrayBuffer: () => response.arrayBuffer(),\n\tblob: () => response.blob(),\n\tformData: () => response.formData(),\n\tjson: async () => {\n\t\tif (parser) {\n\t\t\tconst text = await response.text();\n\t\t\treturn parser(text) as TResponse;\n\t\t}\n\n\t\treturn response.json() as Promise<TResponse>;\n\t},\n\tstream: () => response.body,\n\ttext: () => response.text(),\n});\n\ntype InitResponseTypeMap<TResponse = unknown> = ReturnType<typeof getResponseType<TResponse>>;\n\nexport type ResponseTypeUnion = keyof InitResponseTypeMap | undefined;\n\nexport type ResponseTypeMap<TResponse> = {\n\t[Key in keyof InitResponseTypeMap<TResponse>]: Awaited<ReturnType<InitResponseTypeMap<TResponse>[Key]>>;\n};\n\nexport type GetResponseType<\n\tTResponse,\n\tTResponseType extends ResponseTypeUnion,\n\tTComputedMap extends ResponseTypeMap<TResponse> = ResponseTypeMap<TResponse>,\n> = undefined extends TResponseType\n\t? TComputedMap[\"json\"]\n\t: TResponseType extends NonNullable<ResponseTypeUnion>\n\t\t? TComputedMap[TResponseType]\n\t\t: never;\n\nexport const resolveResponseData = async <TResponse>(\n\tresponse: Response,\n\tresponseType: keyof ResponseTypeMap<TResponse>,\n\tparser: Parser | undefined,\n\tschema?: NonNullable<CallApiSchemas>[keyof NonNullable<CallApiSchemas>],\n\tvalidator?: NonNullable<CallApiValidators>[keyof NonNullable<CallApiValidators>]\n) => {\n\tconst RESPONSE_TYPE_LOOKUP = getResponseType<TResponse>(response, parser);\n\n\tif (!Object.hasOwn(RESPONSE_TYPE_LOOKUP, responseType)) {\n\t\tthrow new Error(`Invalid response type: ${responseType}`);\n\t}\n\n\tconst responseData = await RESPONSE_TYPE_LOOKUP[responseType]();\n\n\tconst validResponseData = validator ? validator(responseData) : responseData;\n\n\tconst schemaValidResponseData = schema\n\t\t? await standardSchemaParser(schema, validResponseData)\n\t\t: validResponseData;\n\n\treturn schemaValidResponseData;\n};\n\ntype SuccessInfo = {\n\tdata: unknown;\n\tresponse: Response;\n\tresultMode: CallApiExtraOptions[\"resultMode\"];\n};\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 = <TCallApiResult>(info: SuccessInfo): TCallApiResult => {\n\tconst { data, response, resultMode } = info;\n\n\tconst apiDetails = { data, error: null, response };\n\n\tif (!resultMode) {\n\t\treturn apiDetails as TCallApiResult;\n\t}\n\n\tconst resultModeMap: ResultModeMap = {\n\t\tall: apiDetails,\n\t\tonlyError: apiDetails.error,\n\t\tonlyResponse: apiDetails.response,\n\t\tonlySuccess: apiDetails.data,\n\t\tonlySuccessWithException: apiDetails.data,\n\t};\n\n\treturn resultModeMap[resultMode] as TCallApiResult;\n};\n","/* eslint-disable ts-eslint/consistent-type-definitions -- I need to use interfaces for the sake of user overrides */\n\nimport type { Method } from \"./types\";\nimport type { ErrorContext } from \"./types/common\";\nimport type { AnyNumber } from \"./utils/type-helpers\";\n\ntype RetryCondition<TErrorData> = (context: ErrorContext<TErrorData>) => boolean | Promise<boolean>;\n\nexport interface RetryOptions<TErrorData> {\n\t/**\n\t * Keeps track of the number of times the request has already been retried\n\t * @deprecated This property is used internally to track retries. Please abstain from modifying it.\n\t */\n\treadonly \"~retryCount\"?: number;\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;\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?: Method[];\n\n\t/**\n\t * HTTP status codes that trigger a retry\n\t * @default [409, 425, 429, 500, 502, 503, 504]\n\t */\n\tretryStatusCodes?: Array<409 | 425 | 429 | 500 | 502 | 503 | 504 | AnyNumber>;\n\n\t/**\n\t * Strategy to use when retrying\n\t * @default \"linear\"\n\t */\n\tretryStrategy?: \"exponential\" | \"linear\";\n}\n\nconst getLinearDelay = <TErrorData>(options: RetryOptions<TErrorData>) => options.retryDelay ?? 1000;\n\nconst getExponentialDelay = <TErrorData>(\n\tcurrentAttemptCount: number,\n\toptions: RetryOptions<TErrorData>\n) => {\n\tconst maxDelay = options.retryMaxDelay ?? 10000;\n\n\tconst exponentialDelay = (options.retryDelay ?? 1000) * 2 ** currentAttemptCount;\n\n\treturn Math.min(exponentialDelay, maxDelay);\n};\n\nexport const createRetryStrategy = <TErrorData>(\n\toptions: RetryOptions<TErrorData>,\n\tctx: ErrorContext<TErrorData>\n) => {\n\tconst currentRetryCount = options[\"~retryCount\"] ?? 0;\n\n\tconst getDelay = () => {\n\t\tif (options.retryStrategy === \"exponential\") {\n\t\t\treturn getExponentialDelay(currentRetryCount, options);\n\t\t}\n\n\t\treturn getLinearDelay(options);\n\t};\n\n\tconst shouldAttemptRetry = async () => {\n\t\tconst customRetryCondition = (await options.retryCondition?.(ctx)) ?? true;\n\n\t\tconst maxRetryAttempts = options.retryAttempts ?? 0;\n\n\t\tconst baseRetryCondition = maxRetryAttempts > currentRetryCount && customRetryCondition;\n\n\t\tif (ctx.error.name !== \"HTTPError\") {\n\t\t\treturn baseRetryCondition;\n\t\t}\n\n\t\tconst includesMethod =\n\t\t\t// eslint-disable-next-line no-implicit-coercion -- Boolean doesn't narrow\n\t\t\t!!ctx.request.method && options.retryMethods?.includes(ctx.request.method);\n\n\t\tconst includesCodes =\n\t\t\t// eslint-disable-next-line no-implicit-coercion -- Boolean doesn't narrow\n\t\t\t!!ctx.response?.status && options.retryStatusCodes?.includes(ctx.response.status);\n\n\t\treturn includesCodes && includesMethod && baseRetryCondition;\n\t};\n\n\treturn {\n\t\tgetDelay,\n\t\tshouldAttemptRetry,\n\t};\n};\n","/* eslint-disable ts-eslint/consistent-type-definitions -- I need to use interfaces for the sake of user overrides */\n\nimport type { CallApiExtraOptions } from \"./types/common\";\nimport { toQueryString } from \"./utils\";\nimport { isArray } from \"./utils/type-guards\";\nimport type { UnmaskType } from \"./utils/type-helpers\";\nimport type { CallApiSchemas, InferSchemaResult } from \"./validation\";\n\nconst slash = \"/\";\nconst column = \":\";\nconst mergeUrlWithParams = (url: string, params: CallApiExtraOptions[\"params\"]) => {\n\tif (!params) {\n\t\treturn url;\n\t}\n\n\tlet newUrl = url;\n\n\tif (isArray(params)) {\n\t\tconst matchedParamArray = newUrl.split(slash).filter((param) => param.startsWith(column));\n\n\t\tfor (const [index, matchedParam] of matchedParamArray.entries()) {\n\t\t\tconst realParam = params[index] as string;\n\t\t\tnewUrl = newUrl.replace(matchedParam, realParam);\n\t\t}\n\n\t\treturn newUrl;\n\t}\n\n\tfor (const [key, value] of Object.entries(params)) {\n\t\tnewUrl = newUrl.replace(`${column}${key}`, String(value));\n\t}\n\n\treturn newUrl;\n};\n\nconst questionMark = \"?\";\nconst ampersand = \"&\";\nconst mergeUrlWithQuery = (url: string, query: CallApiExtraOptions[\"query\"]): string => {\n\tif (!query) {\n\t\treturn url;\n\t}\n\n\tconst queryString = toQueryString(query);\n\n\tif (queryString?.length === 0) {\n\t\treturn url;\n\t}\n\n\tif (url.endsWith(questionMark)) {\n\t\treturn `${url}${queryString}`;\n\t}\n\n\tif (url.includes(questionMark)) {\n\t\treturn `${url}${ampersand}${queryString}`;\n\t}\n\n\treturn `${url}${questionMark}${queryString}`;\n};\n\nexport const mergeUrlWithParamsAndQuery = (\n\turl: string,\n\tparams: CallApiExtraOptions[\"params\"],\n\tquery: CallApiExtraOptions[\"query\"]\n) => {\n\tconst urlWithMergedParams = mergeUrlWithParams(url, params);\n\n\treturn mergeUrlWithQuery(urlWithMergedParams, query);\n};\n\nexport type Params = UnmaskType<\n\t// eslint-disable-next-line perfectionist/sort-union-types -- I need the Record to be first\n\tRecord<string, boolean | number | string> | Array<boolean | number | string>\n>;\n\nexport type Query = UnmaskType<Record<string, boolean | number | string>>;\n\nexport type InitURL = UnmaskType<string>;\n\nexport interface UrlOptions<TSchemas extends CallApiSchemas> {\n\t/**\n\t * URL to be used in the request.\n\t */\n\treadonly initURL?: InferSchemaResult<TSchemas[\"initURL\"], InitURL>;\n\n\t/**\n\t * Parameters to be appended to the URL (i.e: /:id)\n\t */\n\tparams?: InferSchemaResult<TSchemas[\"params\"], Params>;\n\n\t/**\n\t * Query parameters to append to the URL.\n\t */\n\tquery?: InferSchemaResult<TSchemas[\"query\"], Query>;\n}\n","// prettier-ignore\nexport const createCombinedSignal = (...signals: Array<AbortSignal | null | undefined>) => AbortSignal.any(signals.filter(Boolean));\n\nexport const createTimeoutSignal = (milliseconds: number) => AbortSignal.timeout(milliseconds);\n","import { type RequestInfoCache, createDedupeStrategy } from \"./dedupe\";\nimport { HTTPError, resolveErrorResult } from \"./error\";\nimport { type CallApiPlugin, type DefaultPlugins, hooksEnum, initializePlugins } from \"./plugins\";\nimport { type ResponseTypeUnion, resolveResponseData, resolveSuccessResult } from \"./response\";\nimport { createRetryStrategy } from \"./retry\";\nimport type {\n\tBaseCallApiExtraOptions,\n\tCallApiParameters,\n\tCallApiRequestOptions,\n\tCallApiRequestOptionsForHooks,\n\tCombinedCallApiExtraOptions,\n\tDefaultDataType,\n\tDefaultMoreOptions,\n\tGetCallApiResult,\n\tInterceptors,\n\tResultModeUnion,\n} from \"./types/common\";\nimport { mergeUrlWithParamsAndQuery } from \"./url\";\nimport {\n\tcombineHooks,\n\texecuteHooks,\n\tmergeAndResolveHeaders,\n\tsplitBaseConfig,\n\tsplitConfig,\n\twaitUntil,\n} from \"./utils/common\";\nimport { defaultRetryMethods, defaultRetryStatusCodes } from \"./utils/constants\";\nimport { createCombinedSignal, createTimeoutSignal } from \"./utils/polyfills\";\nimport { isFunction, isHTTPErrorInstance, isPlainObject } from \"./utils/type-guards\";\nimport {\n\ttype CallApiSchemas,\n\ttype InferSchemaResult,\n\tcreateExtensibleSchemasAndValidators,\n} from \"./validation\";\n\nexport const createFetchClient = <\n\tTBaseData = DefaultDataType,\n\tTBaseErrorData = DefaultDataType,\n\tTBaseResultMode extends ResultModeUnion = ResultModeUnion,\n\tTBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion,\n\tTBaseSchemas extends CallApiSchemas = DefaultMoreOptions,\n\tTBasePluginArray extends CallApiPlugin[] = DefaultPlugins,\n\tTBaseComputedData = InferSchemaResult<TBaseSchemas[\"data\"], TBaseData>,\n\tTBaseComputedErrorData = InferSchemaResult<TBaseSchemas[\"errorData\"], TBaseErrorData>,\n>(\n\tbaseConfig?: BaseCallApiExtraOptions<\n\t\tTBaseData,\n\t\tTBaseErrorData,\n\t\tTBaseResultMode,\n\t\tTBaseResponseType,\n\t\tTBaseSchemas,\n\t\tTBasePluginArray\n\t>\n) => {\n\tconst [baseFetchOptions, baseExtraOptions] = splitBaseConfig(baseConfig ?? {});\n\n\tconst $RequestInfoCache: RequestInfoCache = new Map();\n\n\tconst callApi = async <\n\t\tTData = TBaseComputedData,\n\t\tTErrorData = TBaseComputedErrorData,\n\t\tTResultMode extends ResultModeUnion = TBaseResultMode,\n\t\tTResponseType extends ResponseTypeUnion = TBaseResponseType,\n\t\tTSchemas extends CallApiSchemas = TBaseSchemas,\n\t\tTPluginArray extends CallApiPlugin[] = TBasePluginArray,\n\t\tTComputedData = InferSchemaResult<TSchemas[\"data\"], TData>,\n\t\tTComputedErrorData = InferSchemaResult<TSchemas[\"errorData\"], TErrorData>,\n\t>(\n\t\t...parameters: CallApiParameters<\n\t\t\tTData,\n\t\t\tTErrorData,\n\t\t\tTResultMode,\n\t\t\tTResponseType,\n\t\t\tTSchemas,\n\t\t\tTPluginArray\n\t\t>\n\t): Promise<GetCallApiResult<TComputedData, TComputedErrorData, TResultMode, TBaseResponseType>> => {\n\t\tconst [initURL, config = {} as never] = parameters;\n\n\t\tconst [fetchOptions, extraOptions] = splitConfig(config);\n\n\t\tconst initCombinedHooks = {} as Required<Interceptors>;\n\n\t\tfor (const key of Object.keys(hooksEnum)) {\n\t\t\tconst combinedHook = combineHooks(\n\t\t\t\tbaseExtraOptions[key as keyof Interceptors],\n\t\t\t\textraOptions[key as keyof Interceptors]\n\t\t\t);\n\n\t\t\tinitCombinedHooks[key as keyof Interceptors] = combinedHook as never;\n\t\t}\n\n\t\t// == Default Extra Options\n\t\tconst defaultExtraOptions = {\n\t\t\tbaseURL: \"\",\n\t\t\tbodySerializer: JSON.stringify,\n\t\t\tdedupeStrategy: \"cancel\",\n\t\t\tdefaultErrorMessage: \"Failed to fetch data from server!\",\n\t\t\tmergedHooksExecutionMode: \"parallel\",\n\t\t\tmergedHooksExecutionOrder: \"mainHooksAfterPlugins\",\n\t\t\tresponseType: \"json\",\n\t\t\tresultMode: \"all\",\n\t\t\tretryAttempts: 0,\n\t\t\tretryDelay: 1000,\n\t\t\tretryMaxDelay: 10000,\n\t\t\tretryMethods: defaultRetryMethods,\n\t\t\tretryStatusCodes: defaultRetryStatusCodes,\n\t\t\tretryStrategy: \"linear\",\n\n\t\t\t...baseExtraOptions,\n\t\t\t...extraOptions,\n\n\t\t\t...initCombinedHooks,\n\t\t} satisfies CombinedCallApiExtraOptions;\n\n\t\tconst body = fetchOptions.body ?? baseFetchOptions.body;\n\n\t\t// == Default Request Options\n\t\tconst defaultRequestOptions = {\n\t\t\tbody: isPlainObject(body) ? defaultExtraOptions.bodySerializer(body) : body,\n\n\t\t\t...baseFetchOptions,\n\t\t\t...fetchOptions,\n\n\t\t\theaders: mergeAndResolveHeaders({\n\t\t\t\tauth: defaultExtraOptions.auth,\n\t\t\t\tbaseHeaders: baseFetchOptions.headers,\n\t\t\t\tbody,\n\t\t\t\theaders: fetchOptions.headers,\n\t\t\t}),\n\n\t\t\tsignal: fetchOptions.signal ?? baseFetchOptions.signal,\n\t\t} satisfies CallApiRequestOptions;\n\n\t\tconst { resolvedHooks, resolvedOptions, resolvedRequestOptions, url } = await initializePlugins({\n\t\t\tinitURL: initURL as string,\n\t\t\toptions: defaultExtraOptions,\n\t\t\trequest: defaultRequestOptions,\n\t\t});\n\n\t\tconst fullURL = `${resolvedOptions.baseURL}${mergeUrlWithParamsAndQuery(url, resolvedOptions.params, resolvedOptions.query)}`;\n\n\t\tconst options = {\n\t\t\t...resolvedOptions,\n\t\t\t...resolvedHooks,\n\t\t\tfullURL,\n\t\t\tinitURL: initURL as string,\n\t\t} satisfies CombinedCallApiExtraOptions as typeof defaultExtraOptions & typeof resolvedHooks;\n\n\t\tconst newFetchController = new AbortController();\n\n\t\tconst timeoutSignal = options.timeout != null ? createTimeoutSignal(options.timeout) : null;\n\n\t\tconst combinedSignal = createCombinedSignal(\n\t\t\tresolvedRequestOptions.signal,\n\t\t\ttimeoutSignal,\n\t\t\tnewFetchController.signal\n\t\t);\n\n\t\tconst request = {\n\t\t\t...resolvedRequestOptions,\n\t\t\tsignal: combinedSignal,\n\t\t} satisfies CallApiRequestOptionsForHooks;\n\n\t\tconst {\n\t\t\thandleRequestCancelDedupeStrategy,\n\t\t\thandleRequestDeferDedupeStrategy,\n\t\t\tremoveDedupeKeyFromCache,\n\t\t} = await createDedupeStrategy({ $RequestInfoCache, newFetchController, options, request });\n\n\t\thandleRequestCancelDedupeStrategy();\n\n\t\ttry {\n\t\t\tawait executeHooks(options.onRequest({ options, request }));\n\n\t\t\t// == Apply determined headers again after onRequest incase they were modified\n\t\t\trequest.headers = mergeAndResolveHeaders({\n\t\t\t\tauth: options.auth,\n\t\t\t\tbaseHeaders: baseFetchOptions.headers,\n\t\t\t\tbody,\n\t\t\t\theaders: request.headers,\n\t\t\t});\n\n\t\t\tconst response = await handleRequestDeferDedupeStrategy();\n\n\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\tconst shouldCloneResponse = options.dedupeStrategy === \"defer\" || options.cloneResponse;\n\n\t\t\tconst { schemas, validators } = createExtensibleSchemasAndValidators(options);\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorData = await resolveResponseData<TErrorData>(\n\t\t\t\t\tshouldCloneResponse ? response.clone() : response,\n\t\t\t\t\toptions.responseType,\n\t\t\t\t\toptions.responseParser,\n\t\t\t\t\tschemas?.errorData,\n\t\t\t\t\tvalidators?.errorData\n\t\t\t\t);\n\n\t\t\t\t// == Push all error handling responsibilities to the catch block if not retrying\n\t\t\t\tthrow new HTTPError({\n\t\t\t\t\tdefaultErrorMessage: options.defaultErrorMessage,\n\t\t\t\t\terrorData,\n\t\t\t\t\tresponse,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst successData = await resolveResponseData<TData>(\n\t\t\t\tshouldCloneResponse ? response.clone() : response,\n\t\t\t\toptions.responseType,\n\t\t\t\toptions.responseParser,\n\t\t\t\tschemas?.data,\n\t\t\t\tvalidators?.data\n\t\t\t);\n\n\t\t\tconst successContext = {\n\t\t\t\tdata: successData as never,\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t\tresponse: options.cloneResponse ? response.clone() : response,\n\t\t\t};\n\n\t\t\tawait executeHooks(\n\t\t\t\toptions.onSuccess(successContext),\n\n\t\t\t\toptions.onResponse({ ...successContext, error: null })\n\t\t\t);\n\n\t\t\treturn await resolveSuccessResult({\n\t\t\t\tdata: successContext.data,\n\t\t\t\tresponse: successContext.response,\n\t\t\t\tresultMode: options.resultMode,\n\t\t\t});\n\n\t\t\t// == Exhaustive Error handling\n\t\t} catch (error) {\n\t\t\tconst { errorVariantDetails, getErrorResult } = resolveErrorResult({\n\t\t\t\tcloneResponse: options.cloneResponse,\n\t\t\t\tdefaultErrorMessage: options.defaultErrorMessage,\n\t\t\t\terror,\n\t\t\t\tresultMode: options.resultMode,\n\t\t\t});\n\n\t\t\tconst errorContext = {\n\t\t\t\terror: errorVariantDetails.error as never,\n\t\t\t\toptions,\n\t\t\t\trequest,\n\t\t\t};\n\n\t\t\tconst errorContextWithResponse = {\n\t\t\t\t...errorContext,\n\t\t\t\tresponse: errorVariantDetails.response as NonNullable<typeof errorVariantDetails.response>,\n\t\t\t};\n\n\t\t\tconst { getDelay, shouldAttemptRetry } = createRetryStrategy(options, errorContextWithResponse);\n\n\t\t\tconst shouldRetry = !combinedSignal.aborted && (await shouldAttemptRetry());\n\n\t\t\tif (shouldRetry) {\n\t\t\t\tawait executeHooks(options.onRetry(errorContextWithResponse));\n\n\t\t\t\tconst delay = getDelay();\n\n\t\t\t\tawait waitUntil(delay);\n\n\t\t\t\tconst updatedOptions = {\n\t\t\t\t\t...config,\n\t\t\t\t\t\"~retryCount\": (options[\"~retryCount\"] ?? 0) + 1,\n\t\t\t\t} satisfies typeof config as typeof config;\n\n\t\t\t\treturn await callApi(initURL, updatedOptions);\n\t\t\t}\n\n\t\t\tconst shouldThrowOnError = isFunction(options.throwOnError)\n\t\t\t\t? options.throwOnError(errorContextWithResponse)\n\t\t\t\t: options.throwOnError;\n\n\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping -- False alarm: this function is depends on this scope\n\t\t\tconst handleThrowOnError = () => {\n\t\t\t\tif (!shouldThrowOnError) return;\n\n\t\t\t\t// eslint-disable-next-line ts-eslint/only-throw-error -- It's fine to throw this\n\t\t\t\tthrow errorVariantDetails.error;\n\t\t\t};\n\n\t\t\tif (isHTTPErrorInstance<TErrorData>(error)) {\n\t\t\t\tawait executeHooks(\n\t\t\t\t\toptions.onResponseError(errorContextWithResponse),\n\n\t\t\t\t\toptions.onError(errorContextWithResponse),\n\n\t\t\t\t\toptions.onResponse({ ...errorContextWithResponse, data: null })\n\t\t\t\t);\n\n\t\t\t\thandleThrowOnError();\n\n\t\t\t\treturn getErrorResult();\n\t\t\t}\n\n\t\t\tif (error instanceof DOMException && error.name === \"AbortError\") {\n\t\t\t\tconst { message, name } = error;\n\n\t\t\t\tconsole.error(`${name}:`, message);\n\n\t\t\t\thandleThrowOnError();\n\n\t\t\t\treturn getErrorResult();\n\t\t\t}\n\n\t\t\tif (error instanceof DOMException && error.name === \"TimeoutError\") {\n\t\t\t\tconst message = `Request timed out after ${options.timeout}ms`;\n\n\t\t\t\tconsole.error(`${error.name}:`, message);\n\n\t\t\t\thandleThrowOnError();\n\n\t\t\t\treturn getErrorResult({ message });\n\t\t\t}\n\n\t\t\tawait executeHooks(\n\t\t\t\t// == At this point only the request errors exist, so the request error interceptor is called\n\t\t\t\toptions.onRequestError(errorContext),\n\n\t\t\t\t// == Also call the onError interceptor\n\t\t\t\toptions.onError(errorContextWithResponse)\n\t\t\t);\n\n\t\t\thandleThrowOnError();\n\n\t\t\treturn getErrorResult();\n\n\t\t\t// == Removing the now unneeded AbortController from store\n\t\t} finally {\n\t\t\tremoveDedupeKeyFromCache();\n\t\t}\n\t};\n\n\tcallApi.create = createFetchClient;\n\n\treturn callApi;\n};\n\nexport const callApi = createFetchClient();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBO,IAAM,qBAAqB,CAAyB,SAAoB;AAC9E,QAAM,EAAE,eAAe,qBAAqB,OAAO,SAAS,oBAAoB,WAAW,IAAI;AAE/F,MAAI,sBAA0D;AAAA,IAC7D,MAAM;AAAA,IACN,OAAO;AAAA,MACN,WAAW;AAAA,MACX,SAAS,sBAAuB,MAAgB;AAAA,MAChD,MAAO,MAAgB;AAAA,IACxB;AAAA,IACA,UAAU;AAAA,EACX;AAEA,MAAI,oBAAoB,KAAK,GAAG;AAC/B,UAAM,EAAE,WAAW,UAAU,qBAAqB,MAAM,SAAS,IAAI;AAErE,0BAAsB;AAAA,MACrB,MAAM;AAAA,MACN,OAAO;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,MACA,UAAU,gBAAgB,SAAS,MAAM,IAAI;AAAA,IA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nB,aAAO,eAAe;AAAA,IAGvB,UAAE;AACD,+BAAyB;AAAA,IAC1B;AAAA,EACD;AAEA,EAAAA,SAAQ,SAAS;AAEjB,SAAOA;AACR;AAEO,IAAM,UAAU,kBAAkB;","names":["callApi"]}
@@ -1,14 +1,14 @@
1
- import { R as ResultModeUnion, a as ResponseTypeUnion, C as CallApiSchemas, b as CallApiPlugin, D as DefaultPlugins, I as InferSchemaResult, c as CallApiExtraOptions, G as GetCallApiResult, d as CallApiResultSuccessVariant, e as CallApiResultErrorVariant, P as PossibleJavascriptErrorNames, B as BaseCallApiExtraOptions } from './common-Bo0qdTwp.cjs';
2
- export { j as CallApiParameters, k as CallApiRequestOptions, l as CallApiRequestOptionsForHooks, m as CombinedCallApiExtraOptions, E as ErrorContext, n as Interceptors, o as InterceptorsOrInterceptorArray, g as PluginInitContext, i as PossibleHTTPError, h as PossibleJavaScriptError, p as Register, q as RequestContext, r as RequestErrorContext, s as ResponseContext, t as ResponseErrorContext, S as SuccessContext, f as definePlugin } from './common-Bo0qdTwp.cjs';
1
+ import { R as ResultModeUnion, a as ResponseTypeUnion, C as CallApiSchemas, b as CallApiPlugin, D as DefaultPlugins, I as InferSchemaResult, c as CallApiExtraOptions, G as GetCallApiResult, d as CallApiResultSuccessVariant, e as CallApiResultErrorVariant, P as PossibleJavascriptErrorNames, B as BaseCallApiExtraOptions } from './common-BriivbRX.cjs';
2
+ export { j as CallApiParameters, k as CallApiRequestOptions, l as CallApiRequestOptionsForHooks, m as CombinedCallApiExtraOptions, E as ErrorContext, n as Interceptors, o as InterceptorsOrInterceptorArray, g as PluginInitContext, i as PossibleHTTPError, h as PossibleJavaScriptError, p as Register, q as RequestContext, r as RequestErrorContext, s as ResponseContext, t as ResponseErrorContext, S as SuccessContext, f as definePlugin } from './common-BriivbRX.cjs';
3
3
  export { H as HTTPError } from './error-lBRMiMeF.cjs';
4
4
  import '@standard-schema/spec';
5
5
 
6
- declare const createFetchClient: <TBaseData = unknown, TBaseErrorData = unknown, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchemas extends CallApiSchemas = {}, TBasePluginArray extends CallApiPlugin[] = DefaultPlugins, TBaseComputedData = InferSchemaResult<TBaseSchemas["data"], TBaseData>, TBaseComputedErrorData = InferSchemaResult<TBaseSchemas["errorData"], TBaseErrorData>>(baseConfig?: BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseSchemas, TBasePluginArray, TBaseResponseType>) => {
7
- <TData = TBaseComputedData, TErrorData = TBaseComputedErrorData, TResultMode extends ResultModeUnion = TBaseResultMode, TResponseType extends ResponseTypeUnion = TBaseResponseType, TSchemas extends CallApiSchemas = TBaseSchemas, TPluginArray extends CallApiPlugin[] = TBasePluginArray, TComputedData = InferSchemaResult<TSchemas["data"], TData>, TComputedErrorData = InferSchemaResult<TSchemas["errorData"], TErrorData>>(initURL: InferSchemaResult<TSchemas["initURL"], string> | undefined, config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType> | undefined): Promise<GetCallApiResult<TComputedData, TComputedErrorData, TResultMode, TBaseResponseType>>;
6
+ declare const createFetchClient: <TBaseData = unknown, TBaseErrorData = unknown, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchemas extends CallApiSchemas = {}, TBasePluginArray extends CallApiPlugin[] = DefaultPlugins, TBaseComputedData = InferSchemaResult<TBaseSchemas["data"], TBaseData>, TBaseComputedErrorData = InferSchemaResult<TBaseSchemas["errorData"], TBaseErrorData>>(baseConfig?: BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseResponseType, TBaseSchemas, TBasePluginArray>) => {
7
+ <TData = TBaseComputedData, TErrorData = TBaseComputedErrorData, TResultMode extends ResultModeUnion = TBaseResultMode, TResponseType extends ResponseTypeUnion = TBaseResponseType, TSchemas extends CallApiSchemas = TBaseSchemas, TPluginArray extends CallApiPlugin[] = TBasePluginArray, TComputedData = InferSchemaResult<TSchemas["data"], TData>, TComputedErrorData = InferSchemaResult<TSchemas["errorData"], TErrorData>>(initURL: InferSchemaResult<TSchemas["initURL"], string> | undefined, config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TResponseType, TSchemas, TPluginArray> | undefined): Promise<GetCallApiResult<TComputedData, TComputedErrorData, TResultMode, TBaseResponseType>>;
8
8
  create: /*elided*/ any;
9
9
  };
10
10
  declare const callApi: {
11
- <TData = unknown, TErrorData = unknown, TResultMode extends ResultModeUnion = ResultModeUnion, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TSchemas extends CallApiSchemas = {}, TPluginArray extends CallApiPlugin[] = DefaultPlugins, TComputedData = InferSchemaResult<TSchemas["data"], TData>, TComputedErrorData = InferSchemaResult<TSchemas["errorData"], TErrorData>>(initURL: InferSchemaResult<TSchemas["initURL"], string> | undefined, config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType> | undefined): Promise<GetCallApiResult<TComputedData, TComputedErrorData, TResultMode, ResponseTypeUnion, {
11
+ <TData = unknown, TErrorData = unknown, TResultMode extends ResultModeUnion = ResultModeUnion, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TSchemas extends CallApiSchemas = {}, TPluginArray extends CallApiPlugin[] = DefaultPlugins, TComputedData = InferSchemaResult<TSchemas["data"], TData>, TComputedErrorData = InferSchemaResult<TSchemas["errorData"], TErrorData>>(initURL: InferSchemaResult<TSchemas["initURL"], string> | undefined, config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TResponseType, TSchemas, TPluginArray> | undefined): Promise<GetCallApiResult<TComputedData, TComputedErrorData, TResultMode, ResponseTypeUnion, {
12
12
  all: CallApiResultSuccessVariant<Awaited<TComputedData>> | CallApiResultErrorVariant<Awaited<TComputedErrorData>>;
13
13
  onlyError: {
14
14
  errorData: DOMException | Error | SyntaxError | TypeError;
@@ -23,8 +23,8 @@ declare const callApi: {
23
23
  onlySuccess: Awaited<TComputedData> | null;
24
24
  onlySuccessWithException: Awaited<TComputedData>;
25
25
  }>>;
26
- create: <TBaseData = unknown, TBaseErrorData = unknown, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchemas extends CallApiSchemas = {}, TBasePluginArray extends CallApiPlugin[] = DefaultPlugins, TBaseComputedData = InferSchemaResult<TBaseSchemas["data"], TBaseData>, TBaseComputedErrorData = InferSchemaResult<TBaseSchemas["errorData"], TBaseErrorData>>(baseConfig?: BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseSchemas, TBasePluginArray, TBaseResponseType>) => {
27
- <TData = TBaseComputedData, TErrorData = TBaseComputedErrorData, TResultMode extends ResultModeUnion = TBaseResultMode, TResponseType extends ResponseTypeUnion = TBaseResponseType, TSchemas extends CallApiSchemas = TBaseSchemas, TPluginArray extends CallApiPlugin[] = TBasePluginArray, TComputedData = InferSchemaResult<TSchemas["data"], TData>, TComputedErrorData = InferSchemaResult<TSchemas["errorData"], TErrorData>>(initURL: InferSchemaResult<TSchemas["initURL"], string> | undefined, config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TSchemas, TPluginArray, TResponseType> | undefined): Promise<GetCallApiResult<TComputedData, TComputedErrorData, TResultMode, TBaseResponseType>>;
26
+ create: <TBaseData = unknown, TBaseErrorData = unknown, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchemas extends CallApiSchemas = {}, TBasePluginArray extends CallApiPlugin[] = DefaultPlugins, TBaseComputedData = InferSchemaResult<TBaseSchemas["data"], TBaseData>, TBaseComputedErrorData = InferSchemaResult<TBaseSchemas["errorData"], TBaseErrorData>>(baseConfig?: BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseResponseType, TBaseSchemas, TBasePluginArray>) => {
27
+ <TData = TBaseComputedData, TErrorData = TBaseComputedErrorData, TResultMode extends ResultModeUnion = TBaseResultMode, TResponseType extends ResponseTypeUnion = TBaseResponseType, TSchemas extends CallApiSchemas = TBaseSchemas, TPluginArray extends CallApiPlugin[] = TBasePluginArray, TComputedData = InferSchemaResult<TSchemas["data"], TData>, TComputedErrorData = InferSchemaResult<TSchemas["errorData"], TErrorData>>(initURL: InferSchemaResult<TSchemas["initURL"], string> | undefined, config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TResponseType, TSchemas, TPluginArray> | undefined): Promise<GetCallApiResult<TComputedData, TComputedErrorData, TResultMode, TBaseResponseType>>;
28
28
  create: /*elided*/ any;
29
29
  };
30
30
  };