@zayne-labs/callapi 1.11.41 → 1.11.43
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.
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +1 -1
- package/dist/{defaults-DG6hZq9w.js → defaults-D5uiLm4M.js} +4 -2
- package/dist/defaults-D5uiLm4M.js.map +1 -0
- package/dist/{guards-CQCcnQjX.js → guards-BW5MdHRz.js} +2 -2
- package/dist/{guards-CQCcnQjX.js.map → guards-BW5MdHRz.js.map} +1 -1
- package/dist/{index-CCyp1Rmr.d.ts → index-UfuQFNcf.d.ts} +35 -64
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/utils/external/index.d.ts +3 -2
- package/dist/utils/external/index.js +6 -3
- package/dist/utils/external/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/defaults-DG6hZq9w.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as FallBackRouteSchemaKey, K as fallBackRouteSchemaKey, et as RequestContext, lt as fetchSpecificKeys } from "../index-
|
|
1
|
+
import { G as FallBackRouteSchemaKey, K as fallBackRouteSchemaKey, et as RequestContext, lt as fetchSpecificKeys } from "../index-UfuQFNcf.js";
|
|
2
2
|
|
|
3
3
|
//#region src/constants/defaults.d.ts
|
|
4
4
|
declare const extraOptionDefaults: Readonly<Readonly<{
|
package/dist/constants/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { S as fetchSpecificKeys, n as requestOptionDefaults, t as extraOptionDefaults, x as fallBackRouteSchemaKey } from "../defaults-
|
|
1
|
+
import { S as fetchSpecificKeys, n as requestOptionDefaults, t as extraOptionDefaults, x as fallBackRouteSchemaKey } from "../defaults-D5uiLm4M.js";
|
|
2
2
|
|
|
3
3
|
export { extraOptionDefaults, fallBackRouteSchemaKey, fetchSpecificKeys, requestOptionDefaults };
|
|
@@ -209,7 +209,8 @@ const routeKeyMethods = defineEnum([
|
|
|
209
209
|
"put"
|
|
210
210
|
]);
|
|
211
211
|
const handleSchemaValidation = async (fullSchema, schemaName, validationOptions) => {
|
|
212
|
-
const { inputValue, response, schemaConfig } = validationOptions;
|
|
212
|
+
const { inputValue, response, resultMode, schemaConfig } = validationOptions;
|
|
213
|
+
if (resultMode === "fetchApi" && (schemaName === "data" || schemaName === "errorData")) return inputValue;
|
|
213
214
|
const disableRuntimeValidationBooleanObject = isObject(schemaConfig?.disableRuntimeValidation) ? schemaConfig.disableRuntimeValidation : {};
|
|
214
215
|
if (schemaConfig?.disableRuntimeValidation === true || disableRuntimeValidationBooleanObject[schemaName] === true) return inputValue;
|
|
215
216
|
const validResult = await callApiSchemaParser(fullSchema, schemaName, {
|
|
@@ -237,6 +238,7 @@ const handleOptionsValidation = async (validationOptions) => {
|
|
|
237
238
|
const resolvedOptions = options ?? request;
|
|
238
239
|
const validationResultArray = await Promise.all(resolvedOptionsToBeValidated.map((schemaName) => handleSchemaValidation(schema, schemaName, {
|
|
239
240
|
inputValue: resolvedOptions[schemaName],
|
|
241
|
+
resultMode: options?.resultMode,
|
|
240
242
|
schemaConfig
|
|
241
243
|
})));
|
|
242
244
|
const validatedResultObject = {};
|
|
@@ -553,4 +555,4 @@ const requestOptionDefaults = Object.freeze(defineEnum({ method: "GET" }));
|
|
|
553
555
|
|
|
554
556
|
//#endregion
|
|
555
557
|
export { isArray as C, isObject as D, isFunction as E, isReadableStream as O, fetchSpecificKeys as S, isBoolean as T, handleConfigValidation as _, getBody as a, ValidationError as b, getMethod as c, splitBaseConfig as d, splitConfig as f, getValidatedValue as g, getCurrentRouteSchemaKeyAndMainInitURL as h, createTimeoutSignal as i, isString as k, getResolvedHeaders as l, getFullAndNormalizedURL as m, requestOptionDefaults as n, getFetchImpl as o, waitFor as p, createCombinedSignal as r, getHeaders as s, extraOptionDefaults as t, omitKeys as u, handleSchemaValidation as v, isBlob as w, fallBackRouteSchemaKey as x, HTTPError as y };
|
|
556
|
-
//# sourceMappingURL=defaults-
|
|
558
|
+
//# sourceMappingURL=defaults-D5uiLm4M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults-D5uiLm4M.js","names":[],"sources":["../src/types/type-helpers.ts","../src/utils/guards.ts","../src/auth.ts","../src/constants/common.ts","../src/constants/validation.ts","../src/utils/external/error.ts","../src/validation.ts","../src/url.ts","../src/utils/common.ts","../src/constants/defaults.ts"],"sourcesContent":["// == These two types allows for adding arbitrary literal types, while still provided autocomplete for defaults.\n\n// == Usually intersection with \"{}\" or \"NonNullable<unknown>\" would make it work fine, but the placeholder with never type is added to make the AnyWhatever type appear last in a given union.\nexport type AnyString = string & NonNullable<unknown>;\nexport type AnyNumber = number & NonNullable<unknown>;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is fine here\nexport type AnyObject = Record<keyof any, any>;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport type AnyFunction<TResult = unknown> = (...args: any[]) => TResult;\n\nexport type Prettify<TObject> = NonNullable<unknown> & { [Key in keyof TObject]: TObject[Key] };\n\ntype WriteableLevel = \"deep\" | \"shallow\";\n\n/**\n * Makes all properties in an object type writeable (removes readonly modifiers).\n * Supports both shallow and deep modes, and handles special cases like arrays, tuples, and unions.\n * @template TObject - The object type to make writeable\n * @template TVariant - The level of writeable transformation (\"shallow\" | \"deep\")\n */\n\ntype ArrayOrObject = Record<number | string | symbol, unknown> | unknown[] | readonly unknown[];\n\nexport type Writeable<TObject, TLevel extends WriteableLevel = \"shallow\"> =\n\tTObject extends ArrayOrObject ?\n\t\t{\n\t\t\t-readonly [Key in keyof TObject]: TLevel extends \"deep\" ?\n\t\t\t\tNonNullable<TObject[Key]> extends ArrayOrObject ?\n\t\t\t\t\tWriteable<TObject[Key], \"deep\">\n\t\t\t\t:\tTObject[Key]\n\t\t\t:\tTObject[Key];\n\t\t}\n\t:\tTObject;\n\nexport const defineEnum = <const TValue extends object>(value: TValue) =>\n\tObject.freeze(value) as Readonly<Writeable<TValue>>;\n\nexport type UnionToIntersection<TUnion> =\n\t(TUnion extends unknown ? (param: TUnion) => void : never) extends (param: infer TParam) => void ?\n\t\tTParam\n\t:\tnever;\n\n// == Using this Immediately Indexed Mapped type helper to help show computed type of anything passed to it instead of just the type name\nexport type UnmaskType<TValue> = { value: TValue }[\"value\"];\n\n/**\n * @description Userland implementation of NoInfer intrinsic type, but this one doesn't show up on hover like the intrinsic one\n *\n * Prevents TypeScript from inferring `TGeneric` at this position by creating a circular dependency.\n * The tuple index `[TGeneric extends unknown ? 0 : never]` depends on `TGeneric`, forcing TS to\n * skip this site for inference and use other arguments or defaults instead.\n */\nexport type NoInferUnMasked<TGeneric> = [TGeneric][TGeneric extends unknown ? 0 : never];\n\ntype RemoveSlashImpl<TUrl extends string, TDirection extends \"leading\" | \"trailing\"> =\n\tTDirection extends \"leading\" ?\n\t\tTUrl extends `/${infer TWithoutLeadingSlash}` ?\n\t\t\tTWithoutLeadingSlash\n\t\t:\tTUrl\n\t: TDirection extends \"trailing\" ?\n\t\tTUrl extends `${infer TWithoutTailingSlash}/` ?\n\t\t\tTWithoutTailingSlash\n\t\t:\tTUrl\n\t:\tnever;\n\nexport type RemoveTrailingSlash<TUrl extends string> = RemoveSlashImpl<TUrl, \"trailing\">;\nexport type RemoveLeadingSlash<TUrl extends string> = RemoveSlashImpl<TUrl, \"leading\">;\n\nexport type Awaitable<TValue> = Promise<TValue> | TValue;\n\n// export type MatchExactObjectType<TActualObject extends TExpectedObject, TExpectedObject> = {\n// \t[Key in keyof TActualObject]: Key extends keyof TExpectedObject ? TActualObject[Key] : never;\n// };\n\nexport type Satisfies<TActualObject extends TExpectedObject, TExpectedObject> = {\n\t[Key in keyof TActualObject]: Key extends keyof TExpectedObject ? TActualObject[Key] : never;\n};\n// export type Satisfies<TActualObject extends TExpectedObject, TExpectedObject> = {\n// \t[Key in keyof TActualObject & keyof TExpectedObject]: TActualObject[Key];\n// };\n\nexport type DistributiveOmit<TObject, TKeysToOmit extends keyof TObject> =\n\tTObject extends unknown ? Omit<TObject, TKeysToOmit> : never;\n\ntype ErrorMessages<TType extends number | string | symbol = never> = Partial<\n\tRecord<\"$all\" | number | symbol | (AnyString | TType), unknown>\n> | null;\n\n/**\n * Type utility that takes two types and allows only the properties of the first type. The properties of the second will be disallowed (typed as `never` by default or a custom message).\n *\n * @template TFirstType The first type. Properties of this type will be required.\n * @template TSecondType The second type. Properties of this type will be disallowed.\n * @template TErrorMessages An object of custom messages to display on the properties of the second type that are disallowed.\n */\ntype AllowOnlyFirst<TFirstType, TSecondType, TErrorMessages extends ErrorMessages = never> = Prettify<\n\tTFirstType & {\n\t\t[Key in keyof Omit<TSecondType, keyof TFirstType>]?: Key extends keyof TErrorMessages ?\n\t\t\tTErrorMessages[Key]\n\t\t: \"$all\" extends keyof TErrorMessages ? TErrorMessages[\"$all\"]\n\t\t: TErrorMessages extends null ? TErrorMessages\n\t\t: never;\n\t}\n>;\n\n/**\n * Merges all types in an array of types into one type.\n *\n * @template TArrayOfTypes Array of types to merge\n * @template TAccumulator Accumulator for the resulting merged type\n */\ntype MergeTypes<TArrayOfTypes extends unknown[], TAccumulator = NonNullable<unknown>> =\n\tTArrayOfTypes extends [infer TFirstType, ...infer TRestOfTypes] ?\n\t\tMergeTypes<\n\t\t\tTRestOfTypes,\n\t\t\t{ [Key in keyof TAccumulator | keyof TFirstType]: (TAccumulator & TFirstType)[Key] }\n\t\t>\n\t:\tTAccumulator;\n\n/**\n * Type utility that extracts discriminated properties from a union of types.\n * Takes an array of types and returns a union of types where each type has unique properties.\n *\n * @template TArrayOfTypes Array of types to process\n * @template TErrorMessages An object of custom messages to display on the properties that are disallowed.\n * @template TAccumulator Accumulator for the resulting union\n * @template TMergedProperties Merged properties from all types\n */\n\nexport type UnionDiscriminator<\n\tTArrayOfTypes extends unknown[],\n\tTErrorMessages extends ErrorMessages<keyof MergeTypes<TArrayOfTypes>> = never,\n\tTAccumulator = never,\n\tTMergedProperties = MergeTypes<TArrayOfTypes>,\n> =\n\tTArrayOfTypes extends [infer TFirstType, ...infer TRestOfTypes] ?\n\t\tUnionDiscriminator<\n\t\t\tTRestOfTypes,\n\t\t\tTErrorMessages,\n\t\t\t// eslint-disable-next-line perfectionist/sort-union-types -- Let TAccumulator be first\n\t\t\tTAccumulator | AllowOnlyFirst<TFirstType, TMergedProperties, TErrorMessages>,\n\t\t\tTMergedProperties\n\t\t>\n\t:\tTAccumulator;\n\nexport type CommonRequestHeaders =\n\t| \"Access-Control-Allow-Credentials\"\n\t| \"Access-Control-Allow-Headers\"\n\t| \"Access-Control-Allow-Methods\"\n\t| \"Access-Control-Allow-Origin\"\n\t| \"Access-Control-Expose-Headers\"\n\t| \"Access-Control-Max-Age\"\n\t| \"Age\"\n\t| \"Allow\"\n\t| \"Cache-Control\"\n\t| \"Clear-Site-Data\"\n\t| \"Content-Disposition\"\n\t| \"Content-Encoding\"\n\t| \"Content-Language\"\n\t| \"Content-Length\"\n\t| \"Content-Location\"\n\t| \"Content-Range\"\n\t| \"Content-Security-Policy-Report-Only\"\n\t| \"Content-Security-Policy\"\n\t| \"Cookie\"\n\t| \"Cross-Origin-Embedder-Policy\"\n\t| \"Cross-Origin-Opener-Policy\"\n\t| \"Cross-Origin-Resource-Policy\"\n\t| \"Date\"\n\t| \"ETag\"\n\t| \"Expires\"\n\t| \"Last-Modified\"\n\t| \"Location\"\n\t| \"Permissions-Policy\"\n\t| \"Pragma\"\n\t| \"Retry-After\"\n\t| \"Save-Data\"\n\t| \"Sec-CH-Prefers-Color-Scheme\"\n\t| \"Sec-CH-Prefers-Reduced-Motion\"\n\t| \"Sec-CH-UA-Arch\"\n\t| \"Sec-CH-UA-Bitness\"\n\t| \"Sec-CH-UA-Form-Factor\"\n\t| \"Sec-CH-UA-Full-Version-List\"\n\t| \"Sec-CH-UA-Full-Version\"\n\t| \"Sec-CH-UA-Mobile\"\n\t| \"Sec-CH-UA-Model\"\n\t| \"Sec-CH-UA-Platform-Version\"\n\t| \"Sec-CH-UA-Platform\"\n\t| \"Sec-CH-UA-WoW64\"\n\t| \"Sec-CH-UA\"\n\t| \"Sec-Fetch-Dest\"\n\t| \"Sec-Fetch-Mode\"\n\t| \"Sec-Fetch-Site\"\n\t| \"Sec-Fetch-User\"\n\t| \"Sec-GPC\"\n\t| \"Server-Timing\"\n\t| \"Server\"\n\t| \"Service-Worker-Navigation-Preload\"\n\t| \"Set-Cookie\"\n\t| \"Strict-Transport-Security\"\n\t| \"Timing-Allow-Origin\"\n\t| \"Trailer\"\n\t| \"Transfer-Encoding\"\n\t| \"Upgrade\"\n\t| \"Vary\"\n\t| \"Warning\"\n\t| \"WWW-Authenticate\"\n\t| \"X-Content-Type-Options\"\n\t| \"X-DNS-Prefetch-Control\"\n\t| \"X-Frame-Options\"\n\t| \"X-Permitted-Cross-Domain-Policies\"\n\t| \"X-Powered-By\"\n\t| \"X-Robots-Tag\"\n\t| \"X-XSS-Protection\"\n\t| AnyString;\n\nexport type CommonAuthorizationHeaders = `${\"Basic\" | \"Bearer\" | \"Token\"} ${string}`;\n\nexport type CommonContentTypes =\n\t| \"application/epub+zip\"\n\t| \"application/gzip\"\n\t| \"application/json\"\n\t| \"application/ld+json\"\n\t| \"application/octet-stream\"\n\t| \"application/ogg\"\n\t| \"application/pdf\"\n\t| \"application/rtf\"\n\t| \"application/vnd.ms-fontobject\"\n\t| \"application/wasm\"\n\t| \"application/xhtml+xml\"\n\t| \"application/xml\"\n\t| \"application/zip\"\n\t| \"audio/aac\"\n\t| \"audio/mpeg\"\n\t| \"audio/ogg\"\n\t| \"audio/opus\"\n\t| \"audio/webm\"\n\t| \"audio/x-midi\"\n\t| \"font/otf\"\n\t| \"font/ttf\"\n\t| \"font/woff\"\n\t| \"font/woff2\"\n\t| \"image/avif\"\n\t| \"image/bmp\"\n\t| \"image/gif\"\n\t| \"image/jpeg\"\n\t| \"image/png\"\n\t| \"image/svg+xml\"\n\t| \"image/tiff\"\n\t| \"image/webp\"\n\t| \"image/x-icon\"\n\t| \"model/gltf-binary\"\n\t| \"model/gltf+json\"\n\t| \"text/calendar\"\n\t| \"text/css\"\n\t| \"text/csv\"\n\t| \"text/html\"\n\t| \"text/javascript\"\n\t| \"text/plain\"\n\t| \"video/3gpp\"\n\t| \"video/3gpp2\"\n\t| \"video/av1\"\n\t| \"video/mp2t\"\n\t| \"video/mp4\"\n\t| \"video/mpeg\"\n\t| \"video/ogg\"\n\t| \"video/webm\"\n\t| \"video/x-msvideo\"\n\t| AnyString;\n","import type { AnyFunction } from \"../types/type-helpers\";\n\nexport const isArray = <TArrayItem>(value: unknown): value is TArrayItem[] => Array.isArray(value);\n\nexport const isBoolean = (value: unknown): value is boolean => typeof value === \"boolean\";\n\nexport const isBlob = (value: unknown): value is Blob => value instanceof Blob;\n\nexport const isObject = <TObject extends object>(value: unknown): value is TObject => {\n\treturn typeof value === \"object\" && value !== null;\n};\n\nconst hasObjectPrototype = (value: unknown) => {\n\treturn Object.prototype.toString.call(value) === \"[object Object]\";\n};\n\n/**\n * @description Copied from TanStack Query's isPlainObject\n * @see https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L321\n */\nexport const isPlainObject = <TPlainObject extends Record<string, unknown>>(\n\tvalue: unknown\n): value is TPlainObject => {\n\tif (!hasObjectPrototype(value)) {\n\t\treturn false;\n\t}\n\n\t// If has no constructor\n\tconst constructor = (value as object | undefined)?.constructor;\n\tif (constructor === undefined) {\n\t\treturn true;\n\t}\n\n\t// If has modified prototype\n\tconst prototype = constructor.prototype as object;\n\tif (!hasObjectPrototype(prototype)) {\n\t\treturn false;\n\t}\n\n\t// If constructor does not have an Object-specific method\n\tif (!Object.hasOwn(prototype, \"isPrototypeOf\")) {\n\t\treturn false;\n\t}\n\n\t// Handles Objects created by Object.create(<arbitrary prototype>)\n\tif (Object.getPrototypeOf(value) !== Object.prototype) {\n\t\treturn false;\n\t}\n\n\t// It's probably a plain object at this point\n\treturn true;\n};\n\nexport const isValidJsonString = (value: unknown): value is string => {\n\tif (!isString(value)) {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tJSON.parse(value);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nexport const isSerializableObject = (value: unknown) => {\n\treturn (\n\t\tisPlainObject(value)\n\t\t|| isArray(value)\n\t\t|| typeof (value as { toJSON: unknown } | undefined)?.toJSON === \"function\"\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\nexport const isPromise = (value: unknown) => value instanceof Promise;\n\nexport const isReadableStream = (value: unknown): value is ReadableStream<unknown> => {\n\treturn value instanceof ReadableStream;\n};\n\n// https://github.com/unjs/ofetch/blob/main/src/utils.ts\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\tvalue?.constructor.name === \"Object\"\n\t\t|| typeof (value as { toJSON: () => unknown } | null)?.toJSON === \"function\"\n\t);\n};\n","/* eslint-disable perfectionist/sort-object-types -- Avoid Sorting for now */\n\nimport type { CallApiExtraOptions } from \"./types/common\";\nimport type { Awaitable } from \"./types/type-helpers\";\nimport { isFunction, isObject, isPromise } from \"./utils/guards\";\n\ntype PossibleAuthValue = Awaitable<string | null | undefined>;\n\ntype PossibleAuthValueOrGetter = PossibleAuthValue | (() => PossibleAuthValue);\n\n// export type BearerOrTokenAuth =\n// \t| {\n// \t\t\ttype?: \"Bearer\" | undefined;\n// \t\t\tbearer?: PossibleAuthValueOrGetter;\n// \t\t\ttoken?: never;\n// \t }\n// \t| {\n// \t\t\ttype?: \"Token\";\n// \t\t\tbearer?: never;\n// \t\t\ttoken?: PossibleAuthValueOrGetter;\n// \t };\n\nexport type BearerAuth = {\n\ttype: \"Bearer\";\n\tvalue: PossibleAuthValueOrGetter;\n};\n\nexport type TokenAuth = {\n\ttype: \"Token\";\n\tvalue: PossibleAuthValueOrGetter;\n};\n\nexport type BasicAuth = {\n\ttype: \"Basic\";\n\tusername: PossibleAuthValueOrGetter;\n\tpassword: PossibleAuthValueOrGetter;\n};\n\n/**\n * Custom auth\n *\n * @param prefix - prefix of the header\n * @param authValue - value of the header\n *\n * @example\n * ```ts\n * {\n * type: \"Custom\",\n * prefix: \"Token\",\n * authValue: \"token\"\n * }\n * ```\n */\nexport type CustomAuth = {\n\ttype: \"Custom\";\n\tprefix: PossibleAuthValueOrGetter;\n\tvalue: PossibleAuthValueOrGetter;\n};\n\n// eslint-disable-next-line perfectionist/sort-union-types -- Let the first one be first\nexport type AuthOption = PossibleAuthValueOrGetter | BearerAuth | TokenAuth | BasicAuth | CustomAuth;\n\nconst resolveAuthValue = (value: PossibleAuthValueOrGetter) => (isFunction(value) ? value() : value);\n\ntype AuthHeaderObject = { Authorization: string };\n\nexport const getAuthHeader = async (\n\tauth: CallApiExtraOptions[\"auth\"]\n): Promise<AuthHeaderObject | undefined> => {\n\tif (auth === undefined) return;\n\n\tif (isPromise(auth) || isFunction(auth) || !isObject(auth)) {\n\t\tconst authValue = await resolveAuthValue(auth);\n\n\t\tif (authValue === undefined) return;\n\n\t\treturn {\n\t\t\tAuthorization: `Bearer ${authValue}`,\n\t\t};\n\t}\n\n\tswitch (auth.type) {\n\t\tcase \"Basic\": {\n\t\t\tconst [username, password] = await Promise.all([\n\t\t\t\tresolveAuthValue(auth.username),\n\t\t\t\tresolveAuthValue(auth.password),\n\t\t\t]);\n\n\t\t\tif (username === undefined || password === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `Basic ${globalThis.btoa(`${username}:${password}`)}`,\n\t\t\t};\n\t\t}\n\t\tcase \"Bearer\": {\n\t\t\tconst value = await resolveAuthValue(auth.value);\n\n\t\t\tif (value === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `Bearer ${value}`,\n\t\t\t};\n\t\t}\n\t\tcase \"Custom\": {\n\t\t\tconst [prefix, value] = await Promise.all([\n\t\t\t\tresolveAuthValue(auth.prefix),\n\t\t\t\tresolveAuthValue(auth.value),\n\t\t\t]);\n\n\t\t\tif (value === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `${prefix} ${value}`,\n\t\t\t};\n\t\t}\n\n\t\tcase \"Token\": {\n\t\t\tconst value = await resolveAuthValue(auth.value);\n\n\t\t\tif (value === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `Token ${value}`,\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\tauth satisfies never;\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// default: {\n\t\t// \tconst [bearer, token] = await Promise.all([\n\t\t// \t\tresolveAuthValue(auth.bearer),\n\t\t// \t\tresolveAuthValue(auth.token),\n\t\t// \t]);\n\n\t\t// \tif (bearer !== undefined) {\n\t\t// \t\treturn { Authorization: `Bearer ${bearer}` };\n\t\t// \t}\n\n\t\t// \tif (token === undefined) return;\n\n\t\t// \treturn { Authorization: `Token ${token}` };\n\t\t// }\n\t}\n};\n","import type { ModifiedRequestInit } from \"../types/common\";\nimport { defineEnum } from \"../types/type-helpers\";\n\nexport const fetchSpecificKeys = defineEnum([\n\t\"body\",\n\t\"integrity\",\n\t\"duplex\",\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 ModifiedRequestInit> as Array<keyof ModifiedRequestInit>);\n","export const fallBackRouteSchemaKey = \"@default\";\n\nexport type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;\n","import { extraOptionDefaults } from \"../../constants/defaults\";\nimport type { CallApiExtraOptions } from \"../../types/common\";\nimport type { StandardSchemaV1 } from \"../../types/standard-schema\";\nimport type { CallApiSchema, CallApiSchemaConfig } from \"../../validation\";\nimport { isObject, isString } from \"../guards\";\n\ntype HTTPErrorDetails<TErrorData> = Pick<CallApiExtraOptions, \"defaultHTTPErrorMessage\"> & {\n\terrorData: TErrorData;\n\tresponse: Response;\n};\n\nconst httpErrorSymbol = Symbol(\"HTTPError\");\n\nexport class HTTPError<TErrorData = Record<string, unknown>> extends Error {\n\terrorData: HTTPErrorDetails<TErrorData>[\"errorData\"];\n\n\treadonly httpErrorSymbol = httpErrorSymbol;\n\n\toverride name = \"HTTPError\" as const;\n\n\tresponse: HTTPErrorDetails<TErrorData>[\"response\"];\n\n\tconstructor(errorDetails: HTTPErrorDetails<TErrorData>, errorOptions?: ErrorOptions) {\n\t\tconst { defaultHTTPErrorMessage, errorData, response } = errorDetails;\n\n\t\tconst resolvedDefaultHTTPErrorMessage =\n\t\t\tisString(defaultHTTPErrorMessage) ? defaultHTTPErrorMessage : (\n\t\t\t\tdefaultHTTPErrorMessage?.({ errorData, response })\n\t\t\t);\n\n\t\tconst selectedDefaultErrorMessage =\n\t\t\tresolvedDefaultHTTPErrorMessage\n\t\t\t?? (response.statusText || extraOptionDefaults.defaultHTTPErrorMessage);\n\n\t\tconst message =\n\t\t\t(errorData as { message?: string } | undefined)?.message ?? selectedDefaultErrorMessage;\n\n\t\tsuper(message, errorOptions);\n\n\t\tthis.errorData = errorData;\n\t\tthis.response = response;\n\t}\n\n\t/**\n\t * @description Checks if the given error is an instance of HTTPError\n\t * @param error - The error to check\n\t * @returns true if the error is an instance of HTTPError, false otherwise\n\t */\n\tstatic override isError<TErrorData>(error: unknown): error is HTTPError<TErrorData> {\n\t\tif (!isObject<HTTPError>(error)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (error instanceof HTTPError) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst actualError = error as HTTPError;\n\n\t\treturn (\n\t\t\tactualError.httpErrorSymbol === httpErrorSymbol\n\t\t\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- Allow\n\t\t\t&& actualError.name === \"HTTPError\"\n\t\t);\n\t}\n}\n\nconst prettifyPath = (path: ValidationError[\"errorData\"][number][\"path\"]) => {\n\tif (!path || path.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst pathString = path.map((segment) => (isObject(segment) ? segment.key : segment)).join(\".\");\n\n\treturn ` → at ${pathString}`;\n};\n\nconst prettifyValidationIssues = (issues: ValidationError[\"errorData\"]) => {\n\tconst issuesString = issues.map((issue) => `✖ ${issue.message}${prettifyPath(issue.path)}`).join(\" | \");\n\n\treturn issuesString;\n};\n\ntype SafeExtract<TUnion, TKey extends TUnion> = Extract<TUnion, TKey>;\n\ntype ValidationErrorDetails = {\n\t/**\n\t * The cause of the validation error.\n\t *\n\t * It's either the name the schema for which validation failed, or the name of the schema config option that led to the validation error.\n\t */\n\tissueCause:\n\t\t| \"toFormData\"\n\t\t| \"toQueryString\"\n\t\t| \"unknown\"\n\t\t| `schemaConfig-(${SafeExtract<keyof CallApiSchemaConfig, \"strict\">})`\n\t\t| keyof CallApiSchema;\n\n\t/**\n\t * The issues that caused the validation error.\n\t */\n\tissues: readonly StandardSchemaV1.Issue[];\n\n\t/**\n\t * The response from server, if any.\n\t */\n\tresponse: Response | null;\n};\n\nconst validationErrorSymbol = Symbol(\"ValidationErrorSymbol\");\n\nexport class ValidationError extends Error {\n\terrorData: ValidationErrorDetails[\"issues\"];\n\n\tissueCause: ValidationErrorDetails[\"issueCause\"];\n\n\toverride name = \"ValidationError\" as const;\n\n\tresponse: ValidationErrorDetails[\"response\"];\n\n\treadonly validationErrorSymbol = validationErrorSymbol;\n\n\tconstructor(details: ValidationErrorDetails, errorOptions?: ErrorOptions) {\n\t\tconst { issueCause, issues, response } = details;\n\n\t\tconst prettyMessage = prettifyValidationIssues(issues);\n\n\t\tconst message = `(${issueCause.toUpperCase()}) - ${prettyMessage}`;\n\n\t\tsuper(message, errorOptions);\n\n\t\tthis.errorData = issues;\n\t\tthis.response = response;\n\t\tthis.issueCause = issueCause;\n\t}\n\n\t/**\n\t * @description Checks if the given error is an instance of ValidationError\n\t * @param error - The error to check\n\t * @returns true if the error is an instance of ValidationError, false otherwise\n\t */\n\tstatic override isError(error: unknown): error is ValidationError {\n\t\tif (!isObject<ValidationError>(error)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (error instanceof ValidationError) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst actualError = error as ValidationError;\n\n\t\treturn (\n\t\t\tactualError.validationErrorSymbol === validationErrorSymbol\n\t\t\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- Allow\n\t\t\t&& actualError.name === \"ValidationError\"\n\t\t);\n\t}\n}\n","import type { AuthOption } from \"./auth\";\nimport { fallBackRouteSchemaKey, type FallBackRouteSchemaKey } from \"./constants/validation\";\nimport type {\n\tBaseCallApiExtraOptions,\n\tCallApiExtraOptions,\n\tCallApiRequestOptions,\n\tGlobalMeta,\n} from \"./types/common\";\nimport type { Body, HeadersOption, MethodUnion } from \"./types/conditional-types\";\nimport type { StandardSchemaV1 } from \"./types/standard-schema\";\nimport {\n\tdefineEnum,\n\ttype AnyFunction,\n\ttype AnyString,\n\ttype Awaitable,\n\ttype UnionDiscriminator,\n\ttype UnionToIntersection,\n} from \"./types/type-helpers\";\nimport {\n\tatSymbol,\n\textractMethodFromURL,\n\tnormalizeURL,\n\ttype AtSymbol,\n\ttype Params,\n\ttype Query,\n} from \"./url\";\nimport { toArray } from \"./utils/common\";\nimport { ValidationError } from \"./utils/external/error\";\nimport { isFunction, isObject } from \"./utils/guards\";\n\ntype ResultVariant = \"infer-input\" | \"infer-output\";\n\nexport type InferSchemaResult<TSchema, TFallbackResult, TResultVariant extends ResultVariant> =\n\t// == Checking for undefined first and returning fallback to avoid type errors when passing the config around (weird tbh)\n\tundefined extends TSchema ? TFallbackResult\n\t: TSchema extends StandardSchemaV1 ?\n\t\tTResultVariant extends \"infer-input\" ?\n\t\t\tStandardSchemaV1.InferInput<TSchema>\n\t\t:\tStandardSchemaV1.InferOutput<TSchema>\n\t: TSchema extends AnyFunction<infer TResult> ? Awaited<TResult>\n\t: TFallbackResult;\n\nexport type InferSchemaOutput<TSchema, TFallbackResult = unknown> = InferSchemaResult<\n\tTSchema,\n\tTFallbackResult,\n\t\"infer-output\"\n>;\n\nexport type InferSchemaInput<TSchema, TFallbackResult = unknown> = InferSchemaResult<\n\tTSchema,\n\tTFallbackResult,\n\t\"infer-input\"\n>;\n\nconst handleValidatorFunction = <TInput>(\n\tvalidator: AnyFunction,\n\tinputData: TInput\n): Promise<StandardSchemaV1.Result<TInput>> => {\n\tconst result = new Promise((resolve) => resolve(validator(inputData as never)))\n\t\t.then((value) => ({ issues: undefined, value: value as never }))\n\t\t.catch((error) => ({ issues: toArray(error) as never, value: undefined }));\n\n\treturn result;\n};\n\nexport const getValidatedValue = <\n\tTSchema extends AnyFunction | StandardSchemaV1,\n\tTVariant extends \"async\" | \"sync\",\n>(\n\tinputValue: InferSchemaOutput<TSchema>,\n\tschema?: TSchema,\n\t_ignoredOptions?: { variant: TVariant }\n): TVariant extends \"async\" ? Promise<StandardSchemaV1.Result<typeof inputValue>>\n:\tStandardSchemaV1.Result<typeof inputValue> => {\n\tif (!schema) {\n\t\treturn { issues: undefined, value: inputValue } as never;\n\t}\n\n\tconst result =\n\t\tisFunction(schema) ?\n\t\t\thandleValidatorFunction(schema, inputValue)\n\t\t:\tschema[\"~standard\"].validate(inputValue);\n\n\treturn result as never;\n};\n\nconst callApiSchemaParser = async <\n\tTFullSchema extends CallApiSchema,\n\tTSchemaName extends keyof CallApiSchema,\n\tTSchema extends NonNullable<TFullSchema[TSchemaName]>,\n>(\n\tfullSchema: TFullSchema | undefined,\n\tschemaName: TSchemaName,\n\toptions: { inputValue: InferSchemaInput<TSchema>; response?: Response | null }\n): Promise<InferSchemaOutput<TSchema>> => {\n\tconst { inputValue, response } = options;\n\n\tconst schema = fullSchema?.[schemaName];\n\n\tconst result = await getValidatedValue(inputValue, schema);\n\n\tif (result.issues) {\n\t\tthrow new ValidationError({\n\t\t\tissueCause: schemaName,\n\t\t\tissues: result.issues,\n\t\t\tresponse: response ?? null,\n\t\t});\n\t}\n\n\treturn result.value as never;\n};\n\ntype BooleanObject = {\n\t[Key in keyof CallApiSchema]: boolean;\n};\n\nexport interface CallApiSchemaConfig {\n\t/**\n\t * The base url of the schema. By default it's the baseURL of the callApi instance.\n\t */\n\tbaseURL?: \"\" | AnyString;\n\n\t/**\n\t * Disables runtime validation for the schema.\n\t */\n\tdisableRuntimeValidation?: boolean | BooleanObject;\n\n\t/**\n\t * If `true`, the original input value will be used instead of the transformed/validated output.\n\t *\n\t * When true, the original input is returned unchanged after validation, ignoring any schema-level\n\t * transformations such as type coercion, default values, or field mapping. Only the validation\n\t * step is executed; the resulting value is discarded in favor of the raw input.\n\t */\n\tdisableRuntimeValidationTransform?: boolean | BooleanObject;\n\n\t/**\n\t * Optional url prefix that will be substituted for the `baseURL` of the schemaConfig at runtime.\n\t *\n\t * Enables a short, stable prefix for routes while keeping the full `baseURL` centralized in config.\n\t * Keeps route definitions concise and shields them from changes to the underlying base URL.\n\t */\n\tprefix?: \"\" | AnyString;\n\n\t/**\n\t * Controls the strictness of API route validation.\n\t *\n\t * When true:\n\t * - Only routes explicitly defined in the schema will be considered valid to typescript and the runtime.\n\t * - Attempting to call routes not defined in the schema will result in both type errors and runtime validation errors.\n\t * - Useful for ensuring API calls conform exactly to your schema definition\n\t *\n\t * When false or undefined (default):\n\t * - All routes will be allowed, whether they are defined in the schema or not\n\t */\n\tstrict?: boolean;\n}\n\nexport type CallApiSchemaType<TInput> =\n\t| StandardSchemaV1<TInput | undefined>\n\t| ((value: TInput) => Awaitable<TInput | undefined>);\n\nexport interface CallApiSchema {\n\tauth?: CallApiSchemaType<AuthOption>;\n\n\t/**\n\t * The schema to use for validating the request body.\n\t */\n\tbody?: CallApiSchemaType<Body>;\n\n\t/**\n\t * The schema to use for validating the response data.\n\t */\n\tdata?: CallApiSchemaType<unknown>;\n\n\t/**\n\t * The schema to use for validating the response error data.\n\t */\n\terrorData?: CallApiSchemaType<unknown>;\n\n\t/**\n\t * The schema to use for validating the request headers.\n\t */\n\theaders?: CallApiSchemaType<HeadersOption>;\n\n\t/**\n\t * The schema to use for validating the meta option.\n\t */\n\tmeta?: CallApiSchemaType<GlobalMeta>;\n\n\t/**\n\t * The schema to use for validating the request method.\n\t */\n\tmethod?: CallApiSchemaType<MethodUnion>;\n\n\t/**\n\t * The schema to use for validating the request url parameters.\n\t */\n\tparams?: CallApiSchemaType<Params>;\n\n\t/**\n\t * The schema to use for validating the request url queries.\n\t */\n\tquery?: CallApiSchemaType<Query>;\n}\n\nexport const routeKeyMethods = defineEnum([\"delete\", \"get\", \"patch\", \"post\", \"put\"]);\n\nexport type RouteKeyMethods = (typeof routeKeyMethods)[number];\n\nexport type RouteKeyMethodsURLUnion = `${AtSymbol}${RouteKeyMethods}/`;\n\nexport type BaseSchemaRouteKeyPrefixes = FallBackRouteSchemaKey | RouteKeyMethodsURLUnion;\n\nexport type BaseCallApiSchemaRoutes = Partial<\n\tRecord<AnyString | BaseSchemaRouteKeyPrefixes, CallApiSchema>\n>;\n\nexport type BaseCallApiSchemaAndConfig = {\n\tconfig?: CallApiSchemaConfig;\n\troutes: BaseCallApiSchemaRoutes;\n};\n\ntype ValidationOptions<\n\tTSchema extends CallApiSchema[keyof CallApiSchema] = CallApiSchema[keyof CallApiSchema],\n> = {\n\tinputValue: InferSchemaInput<TSchema>;\n\tresponse?: Response | null;\n\tresultMode: CallApiExtraOptions[\"resultMode\"];\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nexport const handleSchemaValidation = async <\n\tTFullSchema extends CallApiSchema,\n\tTSchemaName extends keyof CallApiSchema,\n\tTSchema extends NonNullable<TFullSchema[TSchemaName]>,\n>(\n\tfullSchema: TFullSchema | undefined,\n\tschemaName: TSchemaName,\n\tvalidationOptions: ValidationOptions<TSchema>\n): Promise<InferSchemaOutput<TSchema>> => {\n\tconst { inputValue, response, resultMode, schemaConfig } = validationOptions;\n\n\t// == If resultMode is set to `fetchApi`, return the input value as is (which is going to be `null` in this)\n\tif (resultMode === \"fetchApi\" && (schemaName === \"data\" || schemaName === \"errorData\")) {\n\t\treturn inputValue as never;\n\t}\n\n\tconst disableRuntimeValidationBooleanObject =\n\t\tisObject(schemaConfig?.disableRuntimeValidation) ? schemaConfig.disableRuntimeValidation : {};\n\n\tconst shouldDisableRuntimeValidation =\n\t\tschemaConfig?.disableRuntimeValidation === true\n\t\t|| disableRuntimeValidationBooleanObject[schemaName] === true;\n\n\tif (shouldDisableRuntimeValidation) {\n\t\treturn inputValue as never;\n\t}\n\n\tconst validResult = await callApiSchemaParser(fullSchema, schemaName, { inputValue, response });\n\n\tconst disableResultApplicationBooleanObject =\n\t\tisObject(schemaConfig?.disableRuntimeValidationTransform) ?\n\t\t\tschemaConfig.disableRuntimeValidationTransform\n\t\t:\t{};\n\n\tconst shouldDisableResultApplication =\n\t\tschemaConfig?.disableRuntimeValidationTransform === true\n\t\t|| disableResultApplicationBooleanObject[schemaName] === true;\n\n\tif (shouldDisableResultApplication) {\n\t\treturn inputValue as never;\n\t}\n\n\treturn validResult as never;\n};\n\ntype LastOf<TValue> =\n\tUnionToIntersection<TValue extends unknown ? () => TValue : never> extends () => infer R ? R : never;\n\ntype Push<TArray extends unknown[], TArrayItem> = [...TArray, TArrayItem];\n\ntype UnionToTuple<\n\tTUnion,\n\tTComputedLastUnion = LastOf<TUnion>,\n\tTComputedIsUnionEqualToNever = [TUnion] extends [never] ? true : false,\n> =\n\ttrue extends TComputedIsUnionEqualToNever ? []\n\t:\tPush<UnionToTuple<Exclude<TUnion, TComputedLastUnion>>, TComputedLastUnion>;\n\nexport type Tuple<TTuple, TArray extends TTuple[] = []> =\n\tUnionToTuple<TTuple>[\"length\"] extends TArray[\"length\"] ? [...TArray]\n\t:\tTuple<TTuple, [TTuple, ...TArray]>;\n\ntype ExtraOptionsValidationOptions = {\n\toptions: CallApiExtraOptions;\n};\n\nconst extraOptionsToBeValidated = [\"meta\", \"params\", \"query\", \"auth\"] satisfies Tuple<\n\tExtract<keyof CallApiSchema, keyof CallApiExtraOptions>\n>;\n\ntype RequestOptionsValidationOptions = {\n\trequest: CallApiRequestOptions;\n};\n\nconst requestOptionsToBeValidated = [\"body\", \"headers\", \"method\"] satisfies Tuple<\n\tExtract<keyof CallApiSchema, keyof CallApiRequestOptions>\n>;\n\ntype OptionValidationOptions = UnionDiscriminator<\n\t[ExtraOptionsValidationOptions, RequestOptionsValidationOptions]\n> & {\n\tschema: CallApiSchema | undefined;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nconst handleOptionsValidation = async <TValidationOptions extends OptionValidationOptions>(\n\tvalidationOptions: TValidationOptions\n): Promise<\n\tundefined extends TValidationOptions[\"options\"] ?\n\t\tPick<CallApiRequestOptions, (typeof requestOptionsToBeValidated)[number]>\n\t:\tPick<CallApiExtraOptions, (typeof extraOptionsToBeValidated)[number]>\n> => {\n\tconst { options, request, schema, schemaConfig } = validationOptions;\n\n\tconst resolvedOptionsToBeValidated = options ? extraOptionsToBeValidated : requestOptionsToBeValidated;\n\n\tconst resolvedOptions = options ?? request;\n\n\tconst validationResultArray = await Promise.all(\n\t\tresolvedOptionsToBeValidated.map((schemaName) =>\n\t\t\thandleSchemaValidation(schema, schemaName, {\n\t\t\t\tinputValue: resolvedOptions[schemaName as keyof typeof resolvedOptions],\n\t\t\t\tresultMode: options?.resultMode,\n\t\t\t\tschemaConfig,\n\t\t\t})\n\t\t)\n\t);\n\n\tconst validatedResultObject: Record<string, unknown> = {};\n\n\tfor (const [index, schemaName] of resolvedOptionsToBeValidated.entries()) {\n\t\tconst validationResult = validationResultArray[index];\n\n\t\tif (validationResult === undefined) continue;\n\n\t\tvalidatedResultObject[schemaName] = validationResult;\n\t}\n\n\treturn validatedResultObject;\n};\n\nexport const handleConfigValidation = async (\n\tvalidationOptions: ExtraOptionsValidationOptions\n\t\t& GetResolvedSchemaContext\n\t\t& RequestOptionsValidationOptions\n) => {\n\tconst { baseExtraOptions, currentRouteSchemaKey, extraOptions, options, request } = validationOptions;\n\n\tconst { currentRouteSchema, resolvedSchema } = getResolvedSchema({\n\t\tbaseExtraOptions,\n\t\tcurrentRouteSchemaKey,\n\t\textraOptions,\n\t});\n\n\tconst resolvedSchemaConfig = getResolvedSchemaConfig({ baseExtraOptions, extraOptions });\n\n\tif (resolvedSchemaConfig?.strict === true && !currentRouteSchema) {\n\t\tthrow new ValidationError({\n\t\t\tissueCause: \"schemaConfig-(strict)\",\n\t\t\tissues: [{ message: `Strict Mode - No schema found for route '${currentRouteSchemaKey}' ` }],\n\t\t\tresponse: null,\n\t\t});\n\t}\n\n\tconst [extraOptionsValidationResult, requestOptionsValidationResult] = await Promise.all([\n\t\thandleOptionsValidation({\n\t\t\toptions,\n\t\t\tschema: resolvedSchema,\n\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t}),\n\t\thandleOptionsValidation({\n\t\t\trequest,\n\t\t\tschema: resolvedSchema,\n\t\t\tschemaConfig: resolvedSchemaConfig,\n\t\t}),\n\t]);\n\n\treturn {\n\t\textraOptionsValidationResult,\n\t\trequestOptionsValidationResult,\n\t\tresolvedSchema,\n\t\tresolvedSchemaConfig,\n\t};\n};\n\ntype GetResolvedSchemaContext = {\n\tbaseExtraOptions: BaseCallApiExtraOptions;\n\tcurrentRouteSchemaKey: string;\n\textraOptions: CallApiExtraOptions;\n};\n\nexport const getResolvedSchema = (context: GetResolvedSchemaContext) => {\n\tconst { baseExtraOptions, currentRouteSchemaKey, extraOptions } = context;\n\n\tconst fallbackRouteSchema = baseExtraOptions.schema?.routes[fallBackRouteSchemaKey];\n\tconst currentRouteSchema = baseExtraOptions.schema?.routes[currentRouteSchemaKey];\n\n\tconst resolvedRouteSchema = {\n\t\t...fallbackRouteSchema,\n\t\t// == Current route schema takes precedence over fallback route schema\n\t\t...currentRouteSchema,\n\t} satisfies CallApiSchema as CallApiSchema | undefined;\n\n\tconst resolvedSchema =\n\t\tisFunction(extraOptions.schema) ?\n\t\t\textraOptions.schema({\n\t\t\t\tbaseSchemaRoutes: baseExtraOptions.schema?.routes ?? {},\n\t\t\t\tcurrentRouteSchema: resolvedRouteSchema ?? {},\n\t\t\t\tcurrentRouteSchemaKey,\n\t\t\t})\n\t\t:\t(extraOptions.schema ?? resolvedRouteSchema);\n\n\treturn { currentRouteSchema, resolvedSchema };\n};\n\nexport const getResolvedSchemaConfig = (\n\tcontext: Omit<GetResolvedSchemaContext, \"currentRouteSchemaKey\">\n) => {\n\tconst { baseExtraOptions, extraOptions } = context;\n\n\tconst resolvedSchemaConfig =\n\t\tisFunction(extraOptions.schemaConfig) ?\n\t\t\textraOptions.schemaConfig({ baseSchemaConfig: baseExtraOptions.schema?.config ?? {} })\n\t\t:\t(extraOptions.schemaConfig ?? baseExtraOptions.schema?.config);\n\n\treturn resolvedSchemaConfig;\n};\n\nconst removeLeadingSlash = (value: string) => (value.startsWith(\"/\") ? value.slice(1) : value);\n\nconst extractURLParts = (initURL: string) => {\n\treturn {\n\t\tmethodFromURL: extractMethodFromURL(initURL),\n\t\tpathWithoutMethod: normalizeURL(initURL, { retainLeadingSlashForRelativeURLs: false }),\n\t};\n};\n\nconst mergeURLParts = (options: { method: string | undefined; path: string }): string => {\n\tconst { method, path } = options;\n\n\treturn method ? `${atSymbol}${method}/${removeLeadingSlash(path)}` : path;\n};\n\nexport const getCurrentRouteSchemaKeyAndMainInitURL = (\n\tcontext: Pick<GetResolvedSchemaContext, \"baseExtraOptions\" | \"extraOptions\"> & { initURL: string }\n) => {\n\tconst { baseExtraOptions, extraOptions, initURL } = context;\n\n\tconst schemaConfig = getResolvedSchemaConfig({ baseExtraOptions, extraOptions });\n\n\tlet currentRouteSchemaKey = initURL;\n\tlet mainInitURL = initURL;\n\n\tconst { methodFromURL, pathWithoutMethod } = extractURLParts(initURL);\n\n\tconst prefixWithoutLeadingSlash = schemaConfig?.prefix && removeLeadingSlash(schemaConfig.prefix);\n\n\tif (prefixWithoutLeadingSlash && pathWithoutMethod.startsWith(prefixWithoutLeadingSlash)) {\n\t\tconst restOfPathWithoutPrefix = pathWithoutMethod.slice(prefixWithoutLeadingSlash.length);\n\n\t\tcurrentRouteSchemaKey = mergeURLParts({ method: methodFromURL, path: restOfPathWithoutPrefix });\n\n\t\tconst pathWithReplacedPrefix = pathWithoutMethod.replace(\n\t\t\tprefixWithoutLeadingSlash,\n\t\t\tschemaConfig.baseURL ?? \"\"\n\t\t);\n\n\t\tmainInitURL = mergeURLParts({ method: methodFromURL, path: pathWithReplacedPrefix });\n\t}\n\n\tif (schemaConfig?.baseURL && pathWithoutMethod.startsWith(schemaConfig.baseURL)) {\n\t\tconst restOfPathWithoutBaseURL = pathWithoutMethod.slice(schemaConfig.baseURL.length);\n\n\t\tcurrentRouteSchemaKey = mergeURLParts({ method: methodFromURL, path: restOfPathWithoutBaseURL });\n\t}\n\n\treturn { currentRouteSchemaKey, mainInitURL };\n};\n","import type { CallApiExtraOptions } from \"./types/common\";\nimport type { AnyString, UnmaskType } from \"./types/type-helpers\";\nimport { isArray } from \"./utils/guards\";\nimport { routeKeyMethods, type RouteKeyMethodsURLUnion } from \"./validation\";\n\nexport const slash = \"/\";\nconst colon = \":\";\nconst openBrace = \"{\";\nconst closeBrace = \"}\";\n\nconst handleArrayParams = (url: string, params: Extract<CallApiExtraOptions[\"params\"], unknown[]>) => {\n\tlet newUrl = url;\n\n\tconst urlParts = newUrl.split(slash);\n\n\t// == Find all parameters in order (both :param and {param} patterns)\n\tconst matchedParamsArray: string[] = [];\n\n\tfor (const part of urlParts) {\n\t\tconst isMatch = part.startsWith(colon) || (part.startsWith(openBrace) && part.endsWith(closeBrace));\n\n\t\tif (!isMatch) continue;\n\n\t\tmatchedParamsArray.push(part);\n\t}\n\n\tfor (const [paramIndex, matchedParam] of matchedParamsArray.entries()) {\n\t\tconst stringParamValue = String(params[paramIndex]);\n\t\tnewUrl = newUrl.replace(matchedParam, stringParamValue);\n\t}\n\n\treturn newUrl;\n};\n\nconst handleObjectParams = (\n\turl: string,\n\tparams: Extract<CallApiExtraOptions[\"params\"], Record<string, unknown>>\n) => {\n\tlet newUrl = url;\n\n\tfor (const [paramKey, paramValue] of Object.entries(params)) {\n\t\t// == Replace both :param and {param} patterns\n\t\tconst colonPattern = `${colon}${paramKey}` as const;\n\t\tconst bracePattern = `${openBrace}${paramKey}${closeBrace}` as const;\n\n\t\tconst stringValue = String(paramValue);\n\n\t\tnewUrl = newUrl.replace(colonPattern, stringValue);\n\t\tnewUrl = newUrl.replace(bracePattern, stringValue);\n\t}\n\n\treturn newUrl;\n};\n\nconst mergeUrlWithParams = (url: string, params: CallApiExtraOptions[\"params\"]) => {\n\tif (!params) {\n\t\treturn url;\n\t}\n\n\tconst newUrl = isArray(params) ? handleArrayParams(url, params) : handleObjectParams(url, params);\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 = new URLSearchParams(query as Record<string, string> | URLSearchParams).toString();\n\n\tif (queryString.length === 0) {\n\t\treturn url;\n\t}\n\n\tif (url.endsWith(questionMark)) {\n\t\treturn `${url}${queryString}`;\n\t}\n\n\tif (url.includes(questionMark)) {\n\t\treturn `${url}${ampersand}${queryString}`;\n\t}\n\n\treturn `${url}${questionMark}${queryString}`;\n};\n\n/**\n * @description Extracts the HTTP method from method-prefixed route patterns.\n *\n * Analyzes URLs that start with method modifiers (e.g., \"@get/\", \"@post/\") and extracts\n * the HTTP method for use in API requests. This enables method specification directly\n * in route definitions.\n *\n * @param initURL - The URL string to analyze for method modifiers\n * @returns The extracted HTTP method (lowercase) if found, otherwise undefined\n *\n * @example\n * ```typescript\n * extractMethodFromURL(\"@get/users\"); // Returns: \"get\"\n * extractMethodFromURL(\"@post/users\"); // Returns: \"post\"\n * ```\n */\nexport const extractMethodFromURL = (initURL: string | undefined) => {\n\tif (!initURL?.startsWith(\"@\")) return;\n\n\tconst methodFromURL = routeKeyMethods.find((method) =>\n\t\tinitURL.startsWith(`${atSymbol}${method}${slash}`)\n\t);\n\n\tif (!methodFromURL) return;\n\n\treturn methodFromURL;\n};\n\ntype NormalizeURLOptions = {\n\tretainLeadingSlashForRelativeURLs?: boolean;\n};\n\nexport const atSymbol = \"@\";\nexport type AtSymbol = typeof atSymbol;\n\nexport const normalizeURL = (initURL: string, options: NormalizeURLOptions = {}) => {\n\tconst { retainLeadingSlashForRelativeURLs = true } = options;\n\n\tconst methodFromURL = extractMethodFromURL(initURL);\n\n\tif (!methodFromURL) {\n\t\treturn initURL;\n\t}\n\n\tconst normalizedURL =\n\t\tretainLeadingSlashForRelativeURLs && !initURL.includes(\"http\") ?\n\t\t\tinitURL.replace(`${atSymbol}${methodFromURL}`, \"\")\n\t\t:\tinitURL.replace(`${atSymbol}${methodFromURL}${slash}`, \"\");\n\n\treturn normalizedURL;\n};\n\ntype GetFullURLOptions = {\n\t/** Base URL to prepend to relative URLs */\n\tbaseURL: string | undefined;\n\t/** Initial URL pattern that may contain parameters and method modifiers */\n\tinitURL: string;\n\t/** Parameters to substitute into the URL path */\n\tparams: CallApiExtraOptions[\"params\"];\n\t/** Query parameters to append to the URL */\n\tquery: CallApiExtraOptions[\"query\"];\n};\n\nconst getFullURL = (initURL: string, baseURL: string | undefined) => {\n\tif (!baseURL || initURL.startsWith(\"http\")) {\n\t\treturn initURL;\n\t}\n\n\tconst shouldAddSlash = initURL.length > 0 && !initURL.startsWith(slash) && !baseURL.endsWith(slash);\n\n\treturn shouldAddSlash ? `${baseURL}${slash}${initURL}` : `${baseURL}${initURL}`;\n};\n\nexport const getFullAndNormalizedURL = (options: GetFullURLOptions) => {\n\tconst { baseURL, initURL, params, query } = options;\n\n\tconst normalizedInitURL = normalizeURL(initURL);\n\n\tconst initURLWithParams = mergeUrlWithParams(normalizedInitURL, params);\n\n\tconst initURLWithParamsAndQuery = mergeUrlWithQuery(initURLWithParams, query);\n\n\tconst fullURL = getFullURL(initURLWithParamsAndQuery, baseURL);\n\n\tif (!URL.canParse(fullURL)) {\n\t\tconst errorMessage =\n\t\t\t!baseURL ?\n\t\t\t\t`Invalid URL '${initURL}'. Are you passing a relative url to CallApi without setting the 'baseURL' option?`\n\t\t\t:\t`Invalid URL '${fullURL}'. Please validate that you are passing the correct url.`;\n\n\t\tconsole.error(errorMessage);\n\t}\n\n\treturn {\n\t\tfullURL,\n\t\tnormalizedInitURL,\n\t};\n};\n\nexport type AllowedQueryParamValues = UnmaskType<boolean | number | string>;\n\nexport type RecordStyleParams = UnmaskType<Record<string, AllowedQueryParamValues>>;\n\nexport type TupleStyleParams = UnmaskType<AllowedQueryParamValues[]>;\n\nexport type Params = UnmaskType<RecordStyleParams | TupleStyleParams>;\n\nexport type Query = UnmaskType<Record<string, AllowedQueryParamValues> | URLSearchParams>;\n\nexport type InitURLOrURLObject = AnyString | RouteKeyMethodsURLUnion | URL;\n\nexport interface URLOptions {\n\t/**\n\t * Base URL for all API requests. Will only be prepended to relative URLs.\n\t *\n\t * Absolute URLs (starting with http/https) will not be prepended by the baseURL.\n\t *\n\t * @example\n\t * ```ts\n\t * // Set base URL for all requests\n\t * baseURL: \"https://api.example.com/v1\"\n\t *\n\t * // Then use relative URLs in requests\n\t * callApi(\"/users\") // → https://api.example.com/v1/users\n\t * callApi(\"/posts/123\") // → https://api.example.com/v1/posts/123\n\t *\n\t * // Environment-specific base URLs\n\t * baseURL: process.env.NODE_ENV === \"production\"\n\t * ? \"https://api.example.com\"\n\t * : \"http://localhost:3000/api\"\n\t * ```\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Resolved request URL after processing baseURL, parameters, and query strings (readonly)\n\t *\n\t * This is the final URL that will be used for the HTTP request, computed from\n\t * baseURL, initURL, params, and query parameters.\n\t *\n\t */\n\treadonly fullURL?: string;\n\n\t/**\n\t * The original URL string passed to the callApi instance (readonly)\n\t *\n\t * This preserves the original URL as provided, including any method modifiers like \"@get/\" or \"@post/\".\n\t *\n\t */\n\treadonly initURL?: string;\n\n\t/**\n\t * The URL string after normalization, with method modifiers removed(readonly)\n\t *\n\t * Method modifiers like \"@get/\", \"@post/\" are stripped to create a clean URL\n\t * for parameter substitution and final URL construction.\n\t *\n\t */\n\treadonly initURLNormalized?: string;\n\n\t/**\n\t * Parameters to be substituted into URL path segments.\n\t *\n\t * Supports both object-style (named parameters) and array-style (positional parameters)\n\t * for flexible URL parameter substitution.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Object-style parameters (recommended)\n\t * const namedParams: URLOptions = {\n\t * initURL: \"/users/:userId/posts/:postId\",\n\t * params: { userId: \"123\", postId: \"456\" }\n\t * };\n\t * // Results in: /users/123/posts/456\n\t *\n\t * // Array-style parameters (positional)\n\t * const positionalParams: URLOptions = {\n\t * initURL: \"/users/:userId/posts/:postId\",\n\t * params: [\"123\", \"456\"] // Maps in order: userId=123, postId=456\n\t * };\n\t * // Results in: /users/123/posts/456\n\t *\n\t * // Single parameter\n\t * const singleParam: URLOptions = {\n\t * initURL: \"/users/:id\",\n\t * params: { id: \"user-123\" }\n\t * };\n\t * // Results in: /users/user-123\n\t * ```\n\t */\n\tparams?: Params;\n\n\t/**\n\t * Query parameters to append to the URL as search parameters.\n\t *\n\t * These will be serialized into the URL query string using standard\n\t * URL encoding practices.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Basic query parameters\n\t * const queryOptions: URLOptions = {\n\t * initURL: \"/users\",\n\t * query: {\n\t * page: 1,\n\t * limit: 10,\n\t * search: \"john doe\",\n\t * active: true\n\t * }\n\t * };\n\t * // Results in: /users?page=1&limit=10&search=john%20doe&active=true\n\t *\n\t * // Filtering and sorting\n\t * const filterOptions: URLOptions = {\n\t * initURL: \"/products\",\n\t * query: {\n\t * category: \"electronics\",\n\t * minPrice: 100,\n\t * maxPrice: 500,\n\t * sortBy: \"price\",\n\t * order: \"asc\"\n\t * }\n\t * };\n\t * // Results in: /products?category=electronics&minPrice=100&maxPrice=500&sortBy=price&order=asc\n\t * ```\n\t */\n\tquery?: Query;\n}\n","import { getAuthHeader } from \"../auth\";\nimport { fetchSpecificKeys } from \"../constants/common\";\nimport { extraOptionDefaults, requestOptionDefaults } from \"../constants/defaults\";\nimport type { RequestContext } from \"../hooks\";\nimport type { Middlewares } from \"../middlewares\";\nimport type { BaseCallApiExtraOptions, CallApiExtraOptions, CallApiRequestOptions } from \"../types/common\";\nimport type { InferHeadersOption } from \"../types/conditional-types\";\nimport type { DistributiveOmit } from \"../types/type-helpers\";\nimport { extractMethodFromURL } from \"../url\";\nimport type { CallApiSchema } from \"../validation\";\nimport {\n\tisArray,\n\tisFunction,\n\tisPlainObject,\n\tisQueryString,\n\tisSerializableObject,\n\tisValidJsonString,\n} from \"./guards\";\n\nexport const omitKeys = <\n\tTObject extends Record<string, unknown>,\n\tconst TOmitArray extends Array<keyof TObject> | ReadonlyArray<keyof TObject>,\n>(\n\tinitialObject: TObject,\n\tkeysToOmit: TOmitArray\n) => {\n\tconst updatedObject = {} as Record<string, unknown>;\n\n\tconst keysToOmitSet = new Set(keysToOmit);\n\n\tfor (const [key, value] of Object.entries(initialObject)) {\n\t\tif (!keysToOmitSet.has(key)) {\n\t\t\tupdatedObject[key] = value;\n\t\t}\n\t}\n\n\treturn updatedObject as DistributiveOmit<TObject, TOmitArray[number]>;\n};\n\nexport const pickKeys = <\n\tTObject extends Record<string, unknown>,\n\tconst TPickArray extends Array<keyof TObject> | ReadonlyArray<keyof TObject>,\n>(\n\tinitialObject: TObject,\n\tkeysToPick: TPickArray\n) => {\n\tconst updatedObject = {} as Record<string, unknown>;\n\n\tconst keysToPickSet = new Set(keysToPick);\n\n\tfor (const [key, value] of Object.entries(initialObject)) {\n\t\tif (keysToPickSet.has(key)) {\n\t\t\tupdatedObject[key] = value;\n\t\t}\n\t}\n\n\treturn updatedObject as Pick<TObject, TPickArray[number]>;\n};\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport const splitBaseConfig = (baseConfig: Record<string, any>) =>\n\t[\n\t\tpickKeys(baseConfig, fetchSpecificKeys) as CallApiRequestOptions,\n\t\tomitKeys(baseConfig, fetchSpecificKeys) as BaseCallApiExtraOptions,\n\t] as const;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport const splitConfig = (config: Record<string, any>) =>\n\t[\n\t\tpickKeys(config, fetchSpecificKeys) as CallApiRequestOptions,\n\t\tomitKeys(config, fetchSpecificKeys) as CallApiExtraOptions,\n\t] as const;\n\nexport const objectifyHeaders = (headers: CallApiRequestOptions[\"headers\"]) => {\n\tif (!headers) {\n\t\treturn {};\n\t}\n\n\tif (isPlainObject(headers)) {\n\t\treturn headers as Record<string, string>;\n\t}\n\n\treturn Object.fromEntries(headers);\n};\n\nexport type GetResolvedHeadersOptions = {\n\tbaseHeaders: CallApiRequestOptions[\"headers\"];\n\theaders: InferHeadersOption<CallApiSchema>[\"headers\"];\n};\n\nexport const getResolvedHeaders = (options: GetResolvedHeadersOptions) => {\n\tconst { baseHeaders, headers } = options;\n\n\tconst resolvedHeaders =\n\t\tisFunction(headers) ?\n\t\t\theaders({ baseHeaders: objectifyHeaders(baseHeaders) })\n\t\t:\t(headers ?? baseHeaders);\n\n\treturn objectifyHeaders(resolvedHeaders);\n};\n\nconst detectContentTypeHeader = (body: CallApiRequestOptions[\"body\"]) => {\n\tif (isQueryString(body)) {\n\t\treturn { \"Content-Type\": \"application/x-www-form-urlencoded\" };\n\t}\n\n\tif (isSerializableObject(body) || isValidJsonString(body)) {\n\t\treturn { Accept: \"application/json\", \"Content-Type\": \"application/json\" };\n\t}\n\n\treturn null;\n};\n\nexport type GetHeadersOptions = {\n\tauth: CallApiExtraOptions[\"auth\"];\n\tbody: CallApiRequestOptions[\"body\"];\n\tresolvedHeaders: CallApiRequestOptions[\"headers\"];\n};\n\nexport const getHeaders = async (options: GetHeadersOptions) => {\n\tconst { auth, body, resolvedHeaders } = options;\n\n\tconst authHeaderObject = await getAuthHeader(auth);\n\n\tconst resolvedHeadersObject = objectifyHeaders(resolvedHeaders);\n\n\tconst hasExistingContentType =\n\t\tObject.hasOwn(resolvedHeadersObject, \"Content-Type\")\n\t\t|| Object.hasOwn(resolvedHeadersObject, \"content-type\");\n\n\tif (!hasExistingContentType) {\n\t\tconst contentTypeHeader = detectContentTypeHeader(body);\n\t\tcontentTypeHeader && Object.assign(resolvedHeadersObject, contentTypeHeader);\n\t}\n\n\tconst headersObject: Record<string, string> = {\n\t\t...authHeaderObject,\n\t\t...resolvedHeadersObject,\n\t};\n\n\treturn headersObject;\n};\n\nexport type GetMethodContext = {\n\t/** The URL string that may contain method modifiers like \"@get/\" or \"@post/\" */\n\tinitURL: string | undefined;\n\t/** Explicitly specified HTTP method */\n\tmethod: CallApiRequestOptions[\"method\"];\n};\n\nexport const getMethod = (ctx: GetMethodContext) => {\n\tconst { initURL, method } = ctx;\n\n\treturn (\n\t\tmethod?.toUpperCase() ?? extractMethodFromURL(initURL)?.toUpperCase() ?? requestOptionDefaults.method\n\t);\n};\n\nexport type GetBodyOptions = Pick<GetHeadersOptions, \"body\" | \"resolvedHeaders\"> & {\n\tbodySerializer: CallApiExtraOptions[\"bodySerializer\"];\n};\n\nexport const getBody = (options: GetBodyOptions) => {\n\tconst { body, bodySerializer, resolvedHeaders } = options;\n\n\tconst headers = new Headers(resolvedHeaders as Record<string, string>);\n\n\tconst existingContentType = headers.get(\"content-type\");\n\n\tif (!existingContentType && isSerializableObject(body)) {\n\t\tconst selectedBodySerializer = bodySerializer ?? extraOptionDefaults.bodySerializer;\n\n\t\treturn selectedBodySerializer(body);\n\t}\n\n\tif (existingContentType === \"application/x-www-form-urlencoded\" && isSerializableObject(body)) {\n\t\treturn new URLSearchParams(body as Record<string, string>).toString();\n\t}\n\n\treturn body;\n};\n\nexport const getInitFetchImpl = (customFetchImpl: CallApiExtraOptions[\"customFetchImpl\"]) => {\n\tif (customFetchImpl) {\n\t\treturn customFetchImpl;\n\t}\n\n\tif (typeof globalThis !== \"undefined\" && isFunction(globalThis.fetch)) {\n\t\treturn globalThis.fetch;\n\t}\n\n\tthrow new Error(\"No fetch implementation found\");\n};\n\nexport const getFetchImpl = (context: {\n\tcustomFetchImpl: CallApiExtraOptions[\"customFetchImpl\"];\n\tfetchMiddleware: Middlewares[\"fetchMiddleware\"];\n\trequestContext: RequestContext;\n}) => {\n\tconst { customFetchImpl, fetchMiddleware, requestContext } = context;\n\n\tconst initFetchImpl = getInitFetchImpl(customFetchImpl);\n\n\tconst resolvedFetchImpl =\n\t\tfetchMiddleware ? fetchMiddleware({ ...requestContext, fetchImpl: initFetchImpl }) : initFetchImpl;\n\n\treturn resolvedFetchImpl;\n};\n\nexport const waitFor = (delay: number) => {\n\tif (delay === 0) return;\n\n\tconst promise = new Promise((resolve) => setTimeout(resolve, delay));\n\n\treturn promise;\n};\n\nexport const createCombinedSignal = (...signals: Array<AbortSignal | null | undefined>) => {\n\tconst combinedSignal = AbortSignal.any(signals.filter((signal) => signal != null));\n\n\treturn combinedSignal;\n};\n\nexport const createTimeoutSignal = (milliseconds: number | null | undefined) => {\n\tif (milliseconds == null) {\n\t\treturn null;\n\t}\n\n\treturn AbortSignal.timeout(milliseconds);\n};\n\nexport const deterministicHashFn = (value: unknown): string => {\n\treturn JSON.stringify(value, (_, val: unknown) => {\n\t\tif (!isPlainObject(val)) {\n\t\t\treturn val;\n\t\t}\n\n\t\t// eslint-disable-next-line unicorn/no-array-sort -- Not necessary here\n\t\tconst sortedKeys = Object.keys(val).sort();\n\n\t\tconst result: Record<string, unknown> = {};\n\n\t\tfor (const key of sortedKeys) {\n\t\t\tresult[key] = val[key];\n\t\t}\n\n\t\treturn result;\n\t});\n};\n\nexport const toArray = (value: unknown) => (isArray(value) ? value : [value]);\n","import type { CallApiConfig, CallApiExtraOptions } from \"../types/common\";\nimport { defineEnum } from \"../types/type-helpers\";\nimport { deterministicHashFn } from \"../utils/common\";\n\nexport const extraOptionDefaults = Object.freeze(\n\tdefineEnum({\n\t\t// Common defaults\n\t\tbodySerializer: JSON.stringify,\n\t\tdefaultHTTPErrorMessage: \"Request failed unexpectedly\",\n\n\t\t// Dedupe defaults\n\t\t/* eslint-disable perfectionist/sort-objects -- Allow */\n\t\tdedupeCacheScope: \"local\",\n\t\tdedupeKey: (ctx) =>\n\t\t\t`${ctx.options.fullURL}-${deterministicHashFn({ options: ctx.options, request: ctx.request })}`,\n\t\tdedupeCacheScopeKey: \"default\",\n\t\tdedupeStrategy: \"cancel\",\n\t\t/* eslint-enable perfectionist/sort-objects -- Allow */\n\n\t\t// Hook defaults\n\t\thooksExecutionMode: \"parallel\",\n\n\t\t// Response defaults\n\t\tresponseParser: JSON.parse,\n\t\tresponseType: \"json\",\n\t\tresultMode: \"all\",\n\n\t\t// Retry Defaults\n\t\tretryAttempts: 0,\n\t\tretryCondition: () => true,\n\t\tretryDelay: 1000,\n\t\tretryMaxDelay: 10000,\n\t\tretryMethods: [\"GET\", \"POST\"],\n\t\tretryStatusCodes: [],\n\t\tretryStrategy: \"linear\",\n\t} satisfies CallApiExtraOptions)\n);\n\nexport const requestOptionDefaults = Object.freeze(\n\tdefineEnum({\n\t\tmethod: \"GET\",\n\t} satisfies CallApiConfig)\n);\n"],"mappings":";AAoCA,MAAa,cAA2C,UACvD,OAAO,OAAO,MAAM;;;;ACnCrB,MAAa,WAAuB,UAA0C,MAAM,QAAQ,MAAM;AAElG,MAAa,aAAa,UAAqC,OAAO,UAAU;AAEhF,MAAa,UAAU,UAAkC,iBAAiB;AAE1E,MAAa,YAAoC,UA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QAFuB,YAAY,IAAI,QAAQ,QAAQ,WAAW,UAAU,KAAK,CAAC;;AAKnF,MAAa,uBAAuB,iBAA4C;AAC/E,KAAI,gBAAgB,KACnB,QAAO;AAGR,QAAO,YAAY,QAAQ,aAAa;;AAGzC,MAAa,uBAAuB,UAA2B;AAC9D,QAAO,KAAK,UAAU,QAAQ,GAAG,QAAiB;AACjD,MAAI,CAAC,cAAc,IAAI,CACtB,QAAO;EAIR,MAAM,aAAa,OAAO,KAAK,IAAI,CAAC,MAAM;EAE1C,MAAM,SAAkC,EAAE;AAE1C,OAAK,MAAM,OAAO,WACjB,QAAO,OAAO,IAAI;AAGnB,SAAO;GACN;;AAGH,MAAa,WAAW,UAAoB,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;;;;ACtP5E,MAAa,sBAAsB,OAAO,OACzC,WAAW;CAEV,gBAAgB,KAAK;CACrB,yBAAyB;CAIzB,kBAAkB;CAClB,YAAY,QACX,GAAG,IAAI,QAAQ,QAAQ,GAAG,oBAAoB;EAAE,SAAS,IAAI;EAAS,SAAS,IAAI;EAAS,CAAC;CAC9F,qBAAqB;CACrB,gBAAgB;CAIhB,oBAAoB;CAGpB,gBAAgB,KAAK;CACrB,cAAc;CACd,YAAY;CAGZ,eAAe;CACf,sBAAsB;CACtB,YAAY;CACZ,eAAe;CACf,cAAc,CAAC,OAAO,OAAO;CAC7B,kBAAkB,EAAE;CACpB,eAAe;CACf,CAA+B,CAChC;AAED,MAAa,wBAAwB,OAAO,OAC3C,WAAW,EACV,QAAQ,OACR,CAAyB,CAC1B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as isObject, b as ValidationError, y as HTTPError } from "./defaults-
|
|
1
|
+
import { D as isObject, b as ValidationError, y as HTTPError } from "./defaults-D5uiLm4M.js";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/external/guards.ts
|
|
4
4
|
const isHTTPError = (error) => {
|
|
@@ -19,4 +19,4 @@ const isJavascriptError = (error) => {
|
|
|
19
19
|
|
|
20
20
|
//#endregion
|
|
21
21
|
export { isValidationErrorInstance as a, isValidationError as i, isHTTPErrorInstance as n, isJavascriptError as r, isHTTPError as t };
|
|
22
|
-
//# sourceMappingURL=guards-
|
|
22
|
+
//# sourceMappingURL=guards-BW5MdHRz.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards-
|
|
1
|
+
{"version":3,"file":"guards-BW5MdHRz.js","names":[],"sources":["../src/utils/external/guards.ts"],"sourcesContent":["import type {\n\tCallApiResultErrorVariant,\n\tPossibleHTTPError,\n\tPossibleJavaScriptError,\n\tPossibleValidationError,\n} from \"../../result\";\nimport { isObject } from \"../guards\";\nimport { HTTPError, ValidationError } from \"./error\";\n\nexport const isHTTPError = <TErrorData>(\n\terror: CallApiResultErrorVariant<TErrorData>[\"error\"] | null\n): error is PossibleHTTPError<TErrorData> => {\n\treturn isObject(error) && error.name === \"HTTPError\";\n};\n\nexport const isHTTPErrorInstance = <TErrorData>(error: unknown) => {\n\treturn HTTPError.isError<TErrorData>(error);\n};\n\nexport const isValidationError = (\n\terror: CallApiResultErrorVariant<unknown>[\"error\"] | null\n): error is PossibleValidationError => {\n\treturn isObject(error) && error.name === \"ValidationError\";\n};\n\nexport const isValidationErrorInstance = (error: unknown): error is ValidationError => {\n\treturn ValidationError.isError(error);\n};\n\nexport const isJavascriptError = (\n\terror: CallApiResultErrorVariant<unknown>[\"error\"] | null\n): error is PossibleJavaScriptError => {\n\treturn isObject(error) && !isHTTPError(error) && !isValidationError(error);\n};\n"],"mappings":";;;AASA,MAAa,eACZ,UAC4C;AAC5C,QAAO,SAAS,MAAM,IAAI,MAAM,SAAS;;AAG1C,MAAa,uBAAmC,UAAmB;AAClE,QAAO,UAAU,QAAoB,MAAM;;AAG5C,MAAa,qBACZ,UACsC;AACtC,QAAO,SAAS,MAAM,IAAI,MAAM,SAAS;;AAG1C,MAAa,6BAA6B,UAA6C;AACtF,QAAO,gBAAgB,QAAQ,MAAM;;AAGtC,MAAa,qBACZ,UACsC;AACtC,QAAO,SAAS,MAAM,IAAI,CAAC,YAAY,MAAM,IAAI,CAAC,kBAAkB,MAAM"}
|
|
@@ -993,11 +993,11 @@ type ResultModeOption<TErrorData, TResultMode extends ResultModeType> = TErrorDa
|
|
|
993
993
|
} : {
|
|
994
994
|
resultMode?: TResultMode;
|
|
995
995
|
};
|
|
996
|
-
type
|
|
997
|
-
type ThrowOnErrorType<TErrorData, TThrowOnError extends
|
|
996
|
+
type ThrowOnErrorBoolean = boolean;
|
|
997
|
+
type ThrowOnErrorType<TErrorData, TThrowOnError extends ThrowOnErrorBoolean> = TThrowOnError | ((context: ErrorContext<{
|
|
998
998
|
ErrorData: TErrorData;
|
|
999
999
|
}>) => TThrowOnError);
|
|
1000
|
-
type ThrowOnErrorOption<TErrorData, TThrowOnError extends
|
|
1000
|
+
type ThrowOnErrorOption<TErrorData, TThrowOnError extends ThrowOnErrorBoolean> = TErrorData extends false ? {
|
|
1001
1001
|
throwOnError: true;
|
|
1002
1002
|
} : TErrorData extends false | undefined ? {
|
|
1003
1003
|
throwOnError?: true;
|
|
@@ -1147,9 +1147,9 @@ type CallApiRequestOptions = {
|
|
|
1147
1147
|
method?: MethodUnion;
|
|
1148
1148
|
} & Pick<ModifiedRequestInit, FetchSpecificKeysUnion>;
|
|
1149
1149
|
type CallApiRequestOptionsForHooks = Omit<CallApiRequestOptions, "headers"> & {
|
|
1150
|
-
headers: Record<
|
|
1150
|
+
headers: Record<"Authorization" | "Content-Type" | CommonRequestHeaders, string | undefined>;
|
|
1151
1151
|
};
|
|
1152
|
-
type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends
|
|
1152
|
+
type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedMergedPluginExtraOptions = Partial<InferPluginExtraOptions<TPluginArray> & InferSchemaOutput<TCallApiContext["InferredExtraOptions"], TCallApiContext["InferredExtraOptions"]>>, TComputedCallApiContext extends CallApiContext = OverrideCallApiContext<TCallApiContext, {
|
|
1153
1153
|
Data: TData;
|
|
1154
1154
|
ErrorData: TErrorData;
|
|
1155
1155
|
InferredExtraOptions: TComputedMergedPluginExtraOptions;
|
|
@@ -1401,58 +1401,23 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
|
|
|
1401
1401
|
*/
|
|
1402
1402
|
responseType?: TResponseType;
|
|
1403
1403
|
/**
|
|
1404
|
-
*
|
|
1404
|
+
* Dictates how CallApi processes and returns the final result
|
|
1405
1405
|
*
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1406
|
+
- **"all"** (default): Returns `{ data, error, response }`. Standard lifecycle.
|
|
1407
|
+
- **"onlyData"**: Returns only the data from the response.
|
|
1408
|
+
- **"onlyResponse"**: Returns only the `Response` object.
|
|
1409
|
+
- **"fetchApi"**: Also returns only the `Response` object, but also skips parsing of the response body internally and data/errorData schema validation.
|
|
1410
|
+
- **"withoutResponse"**: Returns `{ data, error }`. Standard lifecycle, but omits the `response` property.
|
|
1409
1411
|
*
|
|
1410
|
-
* When combined with throwOnError: true, null/error variants are automatically removed:
|
|
1411
|
-
* - **"all" + throwOnError: true**: Returns { data, error: null, response } (error property is null, throws instead)
|
|
1412
|
-
* - **"onlyData" + throwOnError: true**: Returns data (never null, throws on error)
|
|
1413
1412
|
*
|
|
1414
|
-
*
|
|
1413
|
+
* **Note:**
|
|
1414
|
+
* By default, simplified modes (`"onlyData"`, `"onlyResponse"`, `"fetchApi"`) do not throw errors.
|
|
1415
|
+
* Success/failure should be handled via hooks or by checking the return value (e.g., `if (data)` or `if (response?.ok)`).
|
|
1416
|
+
* To force an exception instead, set `throwOnError: true`.
|
|
1415
1417
|
*
|
|
1416
|
-
* @example
|
|
1417
|
-
* ```ts
|
|
1418
|
-
* // Complete result with all information (default)
|
|
1419
|
-
* const { data, error, response } = await callApi("/users", { resultMode: "all" });
|
|
1420
|
-
* if (error) {
|
|
1421
|
-
* console.error("Request failed:", error);
|
|
1422
|
-
* } else {
|
|
1423
|
-
* console.log("Users:", data);
|
|
1424
|
-
* }
|
|
1425
1418
|
*
|
|
1426
|
-
*
|
|
1427
|
-
* try {
|
|
1428
|
-
* const { data, response } = await callApi("/users", {
|
|
1429
|
-
* resultMode: "all",
|
|
1430
|
-
* throwOnError: true
|
|
1431
|
-
* });
|
|
1432
|
-
* console.log("Users:", data); // data is never null here
|
|
1433
|
-
* } catch (error) {
|
|
1434
|
-
* console.error("Request failed:", error);
|
|
1435
|
-
* }
|
|
1436
|
-
*
|
|
1437
|
-
* // Only data, returns null on errors
|
|
1438
|
-
* const users = await callApi("/users", { resultMode: "onlyData" });
|
|
1439
|
-
* if (users) {
|
|
1440
|
-
* console.log("Users:", users);
|
|
1441
|
-
* } else {
|
|
1442
|
-
* console.log("Request failed");
|
|
1443
|
-
* }
|
|
1419
|
+
* @default "all"
|
|
1444
1420
|
*
|
|
1445
|
-
* // Only data, throws on errors (throwOnError removes null from type)
|
|
1446
|
-
* try {
|
|
1447
|
-
* const users = await callApi("/users", {
|
|
1448
|
-
* resultMode: "onlyData",
|
|
1449
|
-
* throwOnError: true
|
|
1450
|
-
* });
|
|
1451
|
-
* console.log("Users:", users); // users is never null here
|
|
1452
|
-
* } catch (error) {
|
|
1453
|
-
* console.error("Request failed:", error);
|
|
1454
|
-
* }
|
|
1455
|
-
* ```
|
|
1456
1421
|
*/
|
|
1457
1422
|
resultMode?: TResultMode;
|
|
1458
1423
|
/**
|
|
@@ -1525,7 +1490,7 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
|
|
|
1525
1490
|
*/
|
|
1526
1491
|
timeout?: number;
|
|
1527
1492
|
};
|
|
1528
|
-
type BaseCallApiExtraOptions<TBaseCallApiContext extends CallApiContext = DefaultCallApiContext, TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeType = ResultModeType, TBaseThrowOnError extends
|
|
1493
|
+
type BaseCallApiExtraOptions<TBaseCallApiContext extends CallApiContext = DefaultCallApiContext, TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeType = ResultModeType, TBaseThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeType = ResponseTypeType, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig> = SharedExtraOptions<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray> & {
|
|
1529
1494
|
/**
|
|
1530
1495
|
* Array of base CallApi plugins to extend library functionality.
|
|
1531
1496
|
*
|
|
@@ -1638,7 +1603,7 @@ type GetExtendSchemaConfigContext<TBaseSchemaConfig extends CallApiSchemaConfig>
|
|
|
1638
1603
|
type InferExtendPluginContext<TBasePluginArray extends CallApiPlugin[]> = {
|
|
1639
1604
|
basePlugins: TBasePluginArray;
|
|
1640
1605
|
};
|
|
1641
|
-
type CallApiExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends
|
|
1606
|
+
type CallApiExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TCurrentRouteSchemaKey extends string = string> = SharedExtraOptions<TCallApiContext, TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray> & {
|
|
1642
1607
|
/**
|
|
1643
1608
|
* Array of instance-specific CallApi plugins or a function to configure plugins.
|
|
1644
1609
|
*
|
|
@@ -1672,11 +1637,11 @@ type InstanceContext = {
|
|
|
1672
1637
|
options: CallApiExtraOptions;
|
|
1673
1638
|
request: CallApiRequestOptions;
|
|
1674
1639
|
};
|
|
1675
|
-
type BaseCallApiConfig<TBaseCallApiContext extends CallApiContext = DefaultCallApiContext, TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeType = ResultModeType, TBaseThrowOnError extends
|
|
1676
|
-
type CallApiConfig<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends
|
|
1677
|
-
type CallApiParameters<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TCallApiContext extends CallApiContext = DefaultCallApiContext, TThrowOnError extends
|
|
1678
|
-
type CallApiResult<TData, TErrorData, TResultMode extends ResultModeType, TThrowOnError extends
|
|
1679
|
-
type CallApiResultLoose<TData, TErrorData, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends
|
|
1640
|
+
type BaseCallApiConfig<TBaseCallApiContext extends CallApiContext = DefaultCallApiContext, TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeType = ResultModeType, TBaseThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeType = ResponseTypeType, TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedBaseConfig = BaseCallApiExtraOptions<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemaAndConfig>> = (CallApiRequestOptions & TComputedBaseConfig) | ((context: InstanceContext) => CallApiRequestOptions & TComputedBaseConfig);
|
|
1641
|
+
type CallApiConfig<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InitURLOrURLObject = InitURLOrURLObject, TCurrentRouteSchemaKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = InferExtraOptions<TSchema, TBaseSchemaRoutes, TCurrentRouteSchemaKey, TCallApiContext> & InferRequestOptions<TSchema, TInitURL> & Omit<CallApiExtraOptions<TCallApiContext, TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TBasePluginArray, TPluginArray, TBaseSchemaRoutes, TSchema, TBaseSchemaConfig, TSchemaConfig, TCurrentRouteSchemaKey>, keyof InferExtraOptions<CallApiSchema, BaseCallApiSchemaRoutes, string, CallApiContext>> & Omit<CallApiRequestOptions, keyof InferRequestOptions<CallApiSchema, string>>;
|
|
1642
|
+
type CallApiParameters<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TCallApiContext extends CallApiContext = DefaultCallApiContext, TThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InitURLOrURLObject = InitURLOrURLObject, TCurrentRouteSchemaKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = [initURL: TInitURL, config?: CallApiConfig<TCallApiContext, TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TBaseSchemaRoutes, TSchema, TBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBasePluginArray, TPluginArray>];
|
|
1643
|
+
type CallApiResult<TData, TErrorData, TResultMode extends ResultModeType, TThrowOnError extends ThrowOnErrorBoolean> = InferCallApiResult<TData, TErrorData, TResultMode, TThrowOnError>;
|
|
1644
|
+
type CallApiResultLoose<TData, TErrorData, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorBoolean = ThrowOnErrorBoolean> = InferCallApiResult<TData, TErrorData, TResultMode, TThrowOnError>;
|
|
1680
1645
|
//#endregion
|
|
1681
1646
|
//#region src/result.d.ts
|
|
1682
1647
|
type ResponseParser<TData> = (text: string) => Awaitable<TData>;
|
|
@@ -1732,8 +1697,10 @@ type CallApiResultErrorVariant<TErrorData> = {
|
|
|
1732
1697
|
response: Response | null;
|
|
1733
1698
|
};
|
|
1734
1699
|
type CallApiResultSuccessOrErrorVariant<TData, TError> = CallApiResultErrorVariant<TError> | CallApiResultSuccessVariant<TData>;
|
|
1735
|
-
type
|
|
1700
|
+
type GetCallApiResult<TThrowOnError extends ThrowOnErrorBoolean, TResultWithException extends CallApiResultSuccessVariant<unknown>, TResultWithoutException extends CallApiResultSuccessOrErrorVariant<unknown, unknown>> = TThrowOnError extends true ? TResultWithException : TResultWithoutException;
|
|
1701
|
+
type ResultModeMap<TData = DefaultDataType, TErrorData = DefaultDataType, TThrowOnError extends ThrowOnErrorBoolean = DefaultThrowOnError, TComputedResult extends GetCallApiResult<TThrowOnError, CallApiResultSuccessVariant<TData>, CallApiResultSuccessOrErrorVariant<TData, TErrorData>> = GetCallApiResult<TThrowOnError, CallApiResultSuccessVariant<TData>, CallApiResultSuccessOrErrorVariant<TData, TErrorData>>> = UnmaskType<{
|
|
1736
1702
|
all: TComputedResult;
|
|
1703
|
+
fetchApi: TComputedResult["response"];
|
|
1737
1704
|
onlyData: TComputedResult["data"];
|
|
1738
1705
|
onlyResponse: TComputedResult["response"];
|
|
1739
1706
|
withoutResponse: Prettify<DistributiveOmit<TComputedResult, "response">>;
|
|
@@ -1741,7 +1708,7 @@ type ResultModeMap<TData = DefaultDataType, TErrorData = DefaultDataType, TThrow
|
|
|
1741
1708
|
type ResultModePlaceholder = null;
|
|
1742
1709
|
type ResultModeUnion = keyof ResultModeMap;
|
|
1743
1710
|
type ResultModeType = ResultModePlaceholder | ResultModeUnion;
|
|
1744
|
-
type InferCallApiResult<TData, TErrorData, TResultMode extends ResultModeType, TThrowOnError extends
|
|
1711
|
+
type InferCallApiResult<TData, TErrorData, TResultMode extends ResultModeType, TThrowOnError extends ThrowOnErrorBoolean, TComputedResultModeMapWithException extends ResultModeMap<TData, TErrorData, true> = ResultModeMap<TData, TErrorData, true>, TComputedResultModeMapWithoutException extends ResultModeMap<TData, TErrorData, TThrowOnError> = ResultModeMap<TData, TErrorData, TThrowOnError>> = TErrorData extends false ? TComputedResultModeMapWithException["onlyData"] : TErrorData extends false | undefined ? TComputedResultModeMapWithException["onlyData"] : ResultModePlaceholder extends TResultMode ? TComputedResultModeMapWithoutException["all"] : TResultMode extends ResultModeUnion ? TComputedResultModeMapWithoutException[TResultMode] : never;
|
|
1745
1712
|
//#endregion
|
|
1746
1713
|
//#region src/plugins.d.ts
|
|
1747
1714
|
type PluginSetupContext<TCallApiContext extends CallApiContext = DefaultCallApiContext> = RequestContext<TCallApiContext> & {
|
|
@@ -1810,15 +1777,16 @@ type DefaultCallApiContext = Prettify<OverrideCallApiContext<Required<CallApiCon
|
|
|
1810
1777
|
}>>;
|
|
1811
1778
|
//#endregion
|
|
1812
1779
|
//#region src/createFetchClient.d.ts
|
|
1813
|
-
declare const createFetchClientWithContext: <TOuterCallApiContext extends CallApiContext = DefaultCallApiContext>() => <TBaseCallApiContext extends CallApiContext = TOuterCallApiContext, TBaseData = TBaseCallApiContext["Data"], TBaseErrorData = TBaseCallApiContext["ErrorData"], TBaseResultMode extends ResultModeType = (TBaseCallApiContext["ResultMode"] extends ResultModeType ? TBaseCallApiContext["ResultMode"] : ResultModeType), TBaseThrowOnError extends
|
|
1780
|
+
declare const createFetchClientWithContext: <TOuterCallApiContext extends CallApiContext = DefaultCallApiContext>() => <TBaseCallApiContext extends CallApiContext = TOuterCallApiContext, TBaseData = TBaseCallApiContext["Data"], TBaseErrorData = TBaseCallApiContext["ErrorData"], TBaseResultMode extends ResultModeType = (TBaseCallApiContext["ResultMode"] extends ResultModeType ? TBaseCallApiContext["ResultMode"] : ResultModeType), TBaseThrowOnError extends ThrowOnErrorBoolean = boolean, TBaseResponseType extends ResponseTypeType = ResponseTypeType, const TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig, const TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedBaseSchemaConfig extends CallApiSchemaConfig = GetBaseSchemaConfig<TBaseSchemaAndConfig>, TComputedBaseSchemaRoutes extends BaseCallApiSchemaRoutes = GetBaseSchemaRoutes<TBaseSchemaAndConfig>>(initBaseConfig?: BaseCallApiConfig<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBaseSchemaAndConfig, TBasePluginArray>) => <TData = TBaseData, TErrorData = TBaseErrorData, TResultMode extends ResultModeType = TBaseResultMode, TCallApiContext extends CallApiContext = TBaseCallApiContext, TThrowOnError extends ThrowOnErrorBoolean = TBaseThrowOnError, TResponseType extends ResponseTypeType = TBaseResponseType, const TSchemaConfig extends CallApiSchemaConfig = TComputedBaseSchemaConfig, TInitURL extends InferInitURL<TComputedBaseSchemaRoutes, TSchemaConfig> = InferInitURL<TComputedBaseSchemaRoutes, TSchemaConfig>, TCurrentRouteSchemaKey extends GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL> = GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL>, const TSchema extends CallApiSchema = GetCurrentRouteSchema<TComputedBaseSchemaRoutes, TCurrentRouteSchemaKey>, const TPluginArray extends CallApiPlugin[] = TBasePluginArray, TComputedData = InferSchemaOutput<TSchema["data"], GetResponseType<TData, TResponseType>>, TComputedErrorData = InferSchemaOutput<TSchema["errorData"], GetResponseType<TErrorData, TResponseType>>, TComputedResult = CallApiResult<TComputedData, TComputedErrorData, TResultMode, TThrowOnError>>(initURL: TInitURL, initConfig?: CallApiConfig<TCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBasePluginArray, TPluginArray>) => Promise<TComputedResult>;
|
|
1814
1781
|
declare const createFetchClient: <TBaseCallApiContext extends CallApiContext = {
|
|
1815
1782
|
InferredExtraOptions: unknown;
|
|
1816
1783
|
Data: DefaultDataType;
|
|
1817
1784
|
ErrorData: DefaultDataType;
|
|
1818
1785
|
ResultMode: ResultModeType;
|
|
1819
1786
|
Meta: GlobalMeta;
|
|
1820
|
-
}, TBaseData = TBaseCallApiContext["Data"], TBaseErrorData = TBaseCallApiContext["ErrorData"], TBaseResultMode extends ResultModeType = (TBaseCallApiContext["ResultMode"] extends ResultModeType ? TBaseCallApiContext["ResultMode"] : ResultModeType), TBaseThrowOnError extends
|
|
1787
|
+
}, TBaseData = TBaseCallApiContext["Data"], TBaseErrorData = TBaseCallApiContext["ErrorData"], TBaseResultMode extends ResultModeType = (TBaseCallApiContext["ResultMode"] extends ResultModeType ? TBaseCallApiContext["ResultMode"] : ResultModeType), TBaseThrowOnError extends ThrowOnErrorBoolean = boolean, TBaseResponseType extends ResponseTypeType = ResponseTypeType, const TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig, const TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedBaseSchemaConfig extends CallApiSchemaConfig = Writeable<NonNullable<TBaseSchemaAndConfig["config"]>, "deep">, TComputedBaseSchemaRoutes extends BaseCallApiSchemaRoutes = Writeable<TBaseSchemaAndConfig["routes"], "deep">>(initBaseConfig?: BaseCallApiConfig<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBaseSchemaAndConfig, TBasePluginArray>) => <TData = TBaseData, TErrorData = TBaseErrorData, TResultMode extends ResultModeType = TBaseResultMode, TCallApiContext extends CallApiContext = TBaseCallApiContext, TThrowOnError extends ThrowOnErrorBoolean = TBaseThrowOnError, TResponseType extends ResponseTypeType = TBaseResponseType, const TSchemaConfig extends CallApiSchemaConfig = TComputedBaseSchemaConfig, TInitURL extends InferInitURL<TComputedBaseSchemaRoutes, TSchemaConfig> = InferInitURL<TComputedBaseSchemaRoutes, TSchemaConfig>, TCurrentRouteSchemaKey extends GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL> = GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL>, const TSchema extends CallApiSchema = GetCurrentRouteSchema<TComputedBaseSchemaRoutes, TCurrentRouteSchemaKey, TComputedBaseSchemaRoutes["@default"], TComputedBaseSchemaRoutes[TCurrentRouteSchemaKey], NonNullable<Omit<TComputedBaseSchemaRoutes["@default"], keyof TComputedBaseSchemaRoutes[TCurrentRouteSchemaKey]> & TComputedBaseSchemaRoutes[TCurrentRouteSchemaKey]>>, const TPluginArray extends CallApiPlugin[] = TBasePluginArray, TComputedData = InferSchemaResult<TSchema["data"], GetResponseType<TData, TResponseType, ResponseTypeMap<TData>>, "infer-output">, TComputedErrorData = InferSchemaResult<TSchema["errorData"], GetResponseType<TErrorData, TResponseType, ResponseTypeMap<TErrorData>>, "infer-output">, TComputedResult = InferCallApiResult<TComputedData, TComputedErrorData, TResultMode, TThrowOnError, {
|
|
1821
1788
|
all: CallApiResultSuccessVariant<TComputedData>;
|
|
1789
|
+
fetchApi: Response;
|
|
1822
1790
|
onlyData: NoInferUnMasked<TComputedData>;
|
|
1823
1791
|
onlyResponse: Response;
|
|
1824
1792
|
withoutResponse: {
|
|
@@ -1827,6 +1795,7 @@ declare const createFetchClient: <TBaseCallApiContext extends CallApiContext = {
|
|
|
1827
1795
|
};
|
|
1828
1796
|
}, {
|
|
1829
1797
|
all: TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>;
|
|
1798
|
+
fetchApi: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["response"];
|
|
1830
1799
|
onlyData: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["data"];
|
|
1831
1800
|
onlyResponse: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["response"];
|
|
1832
1801
|
withoutResponse: DistributiveOmit<TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>, "response"> extends infer T ? { [Key in keyof T]: T[Key] } : never;
|
|
@@ -1837,7 +1806,7 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
|
|
|
1837
1806
|
ErrorData: DefaultDataType;
|
|
1838
1807
|
ResultMode: ResultModeType;
|
|
1839
1808
|
Meta: GlobalMeta;
|
|
1840
|
-
}, TThrowOnError extends
|
|
1809
|
+
}, TThrowOnError extends ThrowOnErrorBoolean = boolean, TResponseType extends ResponseTypeType = ResponseTypeType, const TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, AnyString | "@delete/" | "@get/" | "@patch/" | "@post/" | "@put/">> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, AnyString | "@delete/" | "@get/" | "@patch/" | "@post/" | "@put/">>, TCurrentRouteSchemaKey extends GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL> = GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL>, const TSchema extends CallApiSchema = GetCurrentRouteSchema<{
|
|
1841
1810
|
[x: AnyString]: CallApiSchema | undefined;
|
|
1842
1811
|
"@default"?: CallApiSchema | undefined;
|
|
1843
1812
|
"@delete/"?: CallApiSchema | undefined;
|
|
@@ -1871,6 +1840,7 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
|
|
|
1871
1840
|
"@put/"?: CallApiSchema | undefined;
|
|
1872
1841
|
}[TCurrentRouteSchemaKey]>>, const TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedData = InferSchemaResult<TSchema["data"], GetResponseType<TData, TResponseType, ResponseTypeMap<TData>>, "infer-output">, TComputedErrorData = InferSchemaResult<TSchema["errorData"], GetResponseType<TErrorData, TResponseType, ResponseTypeMap<TErrorData>>, "infer-output">, TComputedResult = InferCallApiResult<TComputedData, TComputedErrorData, TResultMode, TThrowOnError, {
|
|
1873
1842
|
all: CallApiResultSuccessVariant<TComputedData>;
|
|
1843
|
+
fetchApi: Response;
|
|
1874
1844
|
onlyData: NoInferUnMasked<TComputedData>;
|
|
1875
1845
|
onlyResponse: Response;
|
|
1876
1846
|
withoutResponse: {
|
|
@@ -1879,6 +1849,7 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
|
|
|
1879
1849
|
};
|
|
1880
1850
|
}, {
|
|
1881
1851
|
all: TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>;
|
|
1852
|
+
fetchApi: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["response"];
|
|
1882
1853
|
onlyData: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["data"];
|
|
1883
1854
|
onlyResponse: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["response"];
|
|
1884
1855
|
withoutResponse: DistributiveOmit<TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>, "response"> extends infer T ? { [Key in keyof T]: T[Key] } : never;
|
|
@@ -1893,4 +1864,4 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
|
|
|
1893
1864
|
}, TSchema, CallApiSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, DefaultPluginArray, TPluginArray>) => Promise<TComputedResult>;
|
|
1894
1865
|
//#endregion
|
|
1895
1866
|
export { HooksOrHooksArray as $, HTTPError as A, CallApiSchema as B, CallApiRequestOptions as C, GetCallApiContextRequired as D, GetCallApiContext as E, InferInitURL as F, FallBackRouteSchemaKey as G, CallApiSchemaType as H, InferParamsFromRoute as I, FetchMiddlewareContext as J, fallBackRouteSchemaKey as K, URLOptions as L, RetryOptions as M, GetCurrentRouteSchemaKey as N, InstanceContext as O, InferAllMainRouteKeys as P, Hooks as Q, BaseCallApiSchemaRoutes as R, CallApiParameters as S, CallApiResultLoose as T, InferSchemaInput as U, CallApiSchemaConfig as V, InferSchemaOutput as W, DedupeOptions as X, Middlewares as Y, ErrorContext as Z, BaseCallApiConfig as _, CallApiPlugin as a, SuccessContext as at, CallApiExtraOptions as b, PluginSetupContext as c, Writeable as ct, CallApiResultSuccessVariant as d, RequestContext as et, PossibleHTTPError as f, ResultModeType as g, ResponseTypeType as h, DefaultCallApiContext as i, ResponseStreamContext as it, ValidationError as j, Register as k, CallApiResultErrorVariant as l, fetchSpecificKeys as lt, PossibleValidationError as m, createFetchClient as n, ResponseContext as nt, PluginHooks as o, AnyFunction as ot, PossibleJavaScriptError as p, FetchImpl as q, createFetchClientWithContext as r, ResponseErrorContext as rt, PluginMiddlewares as s, Satisfies as st, callApi as t, RequestStreamContext as tt, CallApiResultSuccessOrErrorVariant as u, BaseCallApiExtraOptions as v, CallApiRequestOptionsForHooks as w, CallApiExtraOptionsForHooks as x, CallApiConfig as y, BaseSchemaRouteKeyPrefixes as z };
|
|
1896
|
-
//# sourceMappingURL=index-
|
|
1867
|
+
//# sourceMappingURL=index-UfuQFNcf.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as HooksOrHooksArray, B as CallApiSchema, C as CallApiRequestOptions, D as GetCallApiContextRequired, E as GetCallApiContext, F as InferInitURL, I as InferParamsFromRoute, J as FetchMiddlewareContext, L as URLOptions, M as RetryOptions, N as GetCurrentRouteSchemaKey, O as InstanceContext, P as InferAllMainRouteKeys, Q as Hooks, R as BaseCallApiSchemaRoutes, S as CallApiParameters, T as CallApiResultLoose, U as InferSchemaInput, V as CallApiSchemaConfig, W as InferSchemaOutput, X as DedupeOptions, Y as Middlewares, Z as ErrorContext, _ as BaseCallApiConfig, a as CallApiPlugin, at as SuccessContext, b as CallApiExtraOptions, c as PluginSetupContext, d as CallApiResultSuccessVariant, et as RequestContext, f as PossibleHTTPError, g as ResultModeType, h as ResponseTypeType, i as DefaultCallApiContext, it as ResponseStreamContext, k as Register, l as CallApiResultErrorVariant, m as PossibleValidationError, n as createFetchClient, nt as ResponseContext, o as PluginHooks, p as PossibleJavaScriptError, q as FetchImpl, r as createFetchClientWithContext, rt as ResponseErrorContext, s as PluginMiddlewares, t as callApi, tt as RequestStreamContext, u as CallApiResultSuccessOrErrorVariant, v as BaseCallApiExtraOptions, w as CallApiRequestOptionsForHooks, x as CallApiExtraOptionsForHooks, y as CallApiConfig, z as BaseSchemaRouteKeyPrefixes } from "./index-
|
|
1
|
+
import { $ as HooksOrHooksArray, B as CallApiSchema, C as CallApiRequestOptions, D as GetCallApiContextRequired, E as GetCallApiContext, F as InferInitURL, I as InferParamsFromRoute, J as FetchMiddlewareContext, L as URLOptions, M as RetryOptions, N as GetCurrentRouteSchemaKey, O as InstanceContext, P as InferAllMainRouteKeys, Q as Hooks, R as BaseCallApiSchemaRoutes, S as CallApiParameters, T as CallApiResultLoose, U as InferSchemaInput, V as CallApiSchemaConfig, W as InferSchemaOutput, X as DedupeOptions, Y as Middlewares, Z as ErrorContext, _ as BaseCallApiConfig, a as CallApiPlugin, at as SuccessContext, b as CallApiExtraOptions, c as PluginSetupContext, d as CallApiResultSuccessVariant, et as RequestContext, f as PossibleHTTPError, g as ResultModeType, h as ResponseTypeType, i as DefaultCallApiContext, it as ResponseStreamContext, k as Register, l as CallApiResultErrorVariant, m as PossibleValidationError, n as createFetchClient, nt as ResponseContext, o as PluginHooks, p as PossibleJavaScriptError, q as FetchImpl, r as createFetchClientWithContext, rt as ResponseErrorContext, s as PluginMiddlewares, t as callApi, tt as RequestStreamContext, u as CallApiResultSuccessOrErrorVariant, v as BaseCallApiExtraOptions, w as CallApiRequestOptionsForHooks, x as CallApiExtraOptionsForHooks, y as CallApiConfig, z as BaseSchemaRouteKeyPrefixes } from "./index-UfuQFNcf.js";
|
|
2
2
|
export { BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchemaRoutes, BaseSchemaRouteKeyPrefixes, CallApiConfig, CallApiExtraOptions, CallApiExtraOptionsForHooks, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResultLoose as CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessOrErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig, DedupeOptions, DefaultCallApiContext, ErrorContext, FetchImpl, FetchMiddlewareContext, GetCallApiContext, GetCallApiContextRequired, GetCurrentRouteSchemaKey, Hooks, HooksOrHooksArray, InferAllMainRouteKeys, InferInitURL, InferParamsFromRoute, InferSchemaInput, InferSchemaOutput, InstanceContext, Middlewares, PluginHooks, PluginMiddlewares, PluginSetupContext, PossibleHTTPError, PossibleJavaScriptError, PossibleValidationError, Register, RequestContext, RequestStreamContext, ResponseContext, ResponseErrorContext, ResponseStreamContext, ResponseTypeType, ResultModeType, RetryOptions, SuccessContext, URLOptions, callApi, createFetchClient, createFetchClientWithContext };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as isArray, E as isFunction, O as isReadableStream, T as isBoolean, _ as handleConfigValidation, a as getBody, c as getMethod, d as splitBaseConfig, f as splitConfig, h as getCurrentRouteSchemaKeyAndMainInitURL, i as createTimeoutSignal, k as isString, l as getResolvedHeaders, m as getFullAndNormalizedURL, o as getFetchImpl, p as waitFor, r as createCombinedSignal, s as getHeaders, t as extraOptionDefaults, u as omitKeys, v as handleSchemaValidation, y as HTTPError } from "./defaults-
|
|
2
|
-
import { a as isValidationErrorInstance, n as isHTTPErrorInstance } from "./guards-
|
|
1
|
+
import { C as isArray, E as isFunction, O as isReadableStream, T as isBoolean, _ as handleConfigValidation, a as getBody, c as getMethod, d as splitBaseConfig, f as splitConfig, h as getCurrentRouteSchemaKeyAndMainInitURL, i as createTimeoutSignal, k as isString, l as getResolvedHeaders, m as getFullAndNormalizedURL, o as getFetchImpl, p as waitFor, r as createCombinedSignal, s as getHeaders, t as extraOptionDefaults, u as omitKeys, v as handleSchemaValidation, y as HTTPError } from "./defaults-D5uiLm4M.js";
|
|
2
|
+
import { a as isValidationErrorInstance, n as isHTTPErrorInstance } from "./guards-BW5MdHRz.js";
|
|
3
3
|
|
|
4
4
|
//#region src/result.ts
|
|
5
5
|
const getResponseType = (response, responseParser) => ({
|
|
@@ -28,7 +28,8 @@ const detectResponseType = (response) => {
|
|
|
28
28
|
return "blob";
|
|
29
29
|
};
|
|
30
30
|
const resolveResponseData = async (options) => {
|
|
31
|
-
const { response, responseParser, responseType } = options;
|
|
31
|
+
const { response, responseParser, responseType, resultMode } = options;
|
|
32
|
+
if (resultMode === "fetchApi") return null;
|
|
32
33
|
const selectedParser = responseParser ?? extraOptionDefaults.responseParser;
|
|
33
34
|
const selectedResponseType = responseType ?? detectResponseType(response);
|
|
34
35
|
const RESPONSE_TYPE_LOOKUP = getResponseType(response, selectedParser);
|
|
@@ -38,6 +39,7 @@ const resolveResponseData = async (options) => {
|
|
|
38
39
|
const getResultModeMap = (details) => {
|
|
39
40
|
return {
|
|
40
41
|
all: () => details,
|
|
42
|
+
fetchApi: () => details.response,
|
|
41
43
|
onlyData: () => details.data,
|
|
42
44
|
onlyResponse: () => details.response,
|
|
43
45
|
withoutResponse: () => omitKeys(details, ["response"])
|
|
@@ -697,12 +699,14 @@ const createFetchClientWithContext = () => {
|
|
|
697
699
|
const responseData = await resolveResponseData({
|
|
698
700
|
response: Boolean(resolvedDedupeStrategy === "defer" || options.cloneResponse) ? response.clone() : response,
|
|
699
701
|
responseParser: options.responseParser,
|
|
700
|
-
responseType: options.responseType
|
|
702
|
+
responseType: options.responseType,
|
|
703
|
+
resultMode: options.resultMode
|
|
701
704
|
});
|
|
702
705
|
if (!response.ok) {
|
|
703
706
|
const validErrorData = await handleSchemaValidation(resolvedSchema, "errorData", {
|
|
704
707
|
inputValue: responseData,
|
|
705
708
|
response,
|
|
709
|
+
resultMode: options.resultMode,
|
|
706
710
|
schemaConfig: resolvedSchemaConfig
|
|
707
711
|
});
|
|
708
712
|
throw new HTTPError({
|
|
@@ -717,6 +721,7 @@ const createFetchClientWithContext = () => {
|
|
|
717
721
|
data: await handleSchemaValidation(resolvedSchema, "data", {
|
|
718
722
|
inputValue: responseData,
|
|
719
723
|
response,
|
|
724
|
+
resultMode: options.resultMode,
|
|
720
725
|
schemaConfig: resolvedSchemaConfig
|
|
721
726
|
}),
|
|
722
727
|
options,
|