@zayne-labs/callapi 1.11.20 → 1.11.22
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/{esm/common-B6fZ7-fM.d.ts → common-DvZQWmH6.d.ts} +14 -14
- package/dist/{esm/constants → constants}/index.js +2 -2
- package/dist/{esm/defaults-BD3B1uIH.js → defaults-C6WKIXsf.js} +2 -2
- package/dist/defaults-C6WKIXsf.js.map +1 -0
- package/dist/{esm/guards-ClpaRdJN.js → guards-5Ij_loC1.js} +4 -3
- package/dist/guards-5Ij_loC1.js.map +1 -0
- package/dist/{esm/index.d.ts → index.d.ts} +6 -6
- package/dist/{esm/index.js → index.js} +11 -7
- package/dist/index.js.map +1 -0
- package/dist/{esm/utils → utils}/external/index.d.ts +1 -1
- package/dist/{esm/utils → utils}/external/index.js +2 -2
- package/dist/utils/external/index.js.map +1 -0
- package/dist/{esm/validation-jR4wVvCQ.js → validation-8gwacxHw.js} +2 -2
- package/dist/validation-8gwacxHw.js.map +1 -0
- package/package.json +11 -11
- package/dist/esm/defaults-BD3B1uIH.js.map +0 -1
- package/dist/esm/guards-ClpaRdJN.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/utils/external/index.js.map +0 -1
- package/dist/esm/validation-jR4wVvCQ.js.map +0 -1
- /package/dist/{esm/constants → constants}/index.d.ts +0 -0
- /package/dist/{esm/validation-Dq--Q5zC.d.ts → validation-Dq--Q5zC.d.ts} +0 -0
|
@@ -393,7 +393,7 @@ interface CallApiSchema {
|
|
|
393
393
|
/**
|
|
394
394
|
* The schema to use for validating the request body.
|
|
395
395
|
*/
|
|
396
|
-
body?: StandardSchemaV1<Body> | ((body: Body) => Awaitable<Body>);
|
|
396
|
+
body?: StandardSchemaV1<Body | undefined> | ((body: Body) => Awaitable<Body | undefined>);
|
|
397
397
|
/**
|
|
398
398
|
* The schema to use for validating the response data.
|
|
399
399
|
*/
|
|
@@ -1241,7 +1241,7 @@ interface RetryOptions<TErrorData$1> {
|
|
|
1241
1241
|
/**
|
|
1242
1242
|
* @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
|
|
1243
1243
|
*/
|
|
1244
|
-
type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends
|
|
1244
|
+
type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaOutput<TSchemaOption, undefined> ? TObject : Required<TObject>;
|
|
1245
1245
|
type ApplyURLBasedConfig<TSchemaConfig$1 extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig$1["prefix"] extends string ? `${TSchemaConfig$1["prefix"]}${TSchemaRouteKeys}` : TSchemaConfig$1["baseURL"] extends string ? `${TSchemaConfig$1["baseURL"]}${TSchemaRouteKeys}` : TSchemaRouteKeys;
|
|
1246
1246
|
type ApplyStrictConfig<TSchemaConfig$1 extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig$1["strict"] extends true ? TSchemaRouteKeys :
|
|
1247
1247
|
// eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
|
|
@@ -1254,12 +1254,12 @@ type GetCurrentRouteSchema<TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes,
|
|
|
1254
1254
|
type JsonPrimitive = boolean | number | string | null | undefined;
|
|
1255
1255
|
type SerializableObject = Record<PropertyKey, unknown>;
|
|
1256
1256
|
type SerializableArray = Array<JsonPrimitive | SerializableObject> | ReadonlyArray<JsonPrimitive | SerializableObject>;
|
|
1257
|
-
type Body = UnmaskType<RequestInit["body"] | SerializableArray | SerializableObject>;
|
|
1257
|
+
type Body = UnmaskType<Exclude<RequestInit["body"], undefined> | SerializableArray | SerializableObject>;
|
|
1258
1258
|
type InferBodyOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["body"], {
|
|
1259
1259
|
/**
|
|
1260
1260
|
* Body of the request, can be a object or any other supported body type.
|
|
1261
1261
|
*/
|
|
1262
|
-
body?:
|
|
1262
|
+
body?: InferSchemaOutput<TSchema$1["body"], Body>;
|
|
1263
1263
|
}>;
|
|
1264
1264
|
type MethodUnion = UnmaskType<"CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" | AnyString>;
|
|
1265
1265
|
type InferMethodFromURL<TInitURL> = string extends TInitURL ? MethodUnion : TInitURL extends `@${infer TMethod extends RouteKeyMethods}/${string}` ? Uppercase<TMethod> : MethodUnion;
|
|
@@ -1268,16 +1268,16 @@ type InferMethodOption<TSchema$1 extends CallApiSchema, TInitURL> = MakeSchemaOp
|
|
|
1268
1268
|
* HTTP method for the request.
|
|
1269
1269
|
* @default "GET"
|
|
1270
1270
|
*/
|
|
1271
|
-
method?:
|
|
1271
|
+
method?: InferSchemaOutput<TSchema$1["method"], InferMethodFromURL<TInitURL>>;
|
|
1272
1272
|
}>;
|
|
1273
1273
|
type HeadersOption = UnmaskType<Record<"Authorization", CommonAuthorizationHeaders | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | Array<[string, string]>>;
|
|
1274
1274
|
type InferHeadersOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["headers"], {
|
|
1275
1275
|
/**
|
|
1276
1276
|
* Headers to be used in the request.
|
|
1277
1277
|
*/
|
|
1278
|
-
headers?:
|
|
1278
|
+
headers?: InferSchemaOutput<TSchema$1["headers"], HeadersOption> | ((context: {
|
|
1279
1279
|
baseHeaders: NonNullable<HeadersOption>;
|
|
1280
|
-
}) =>
|
|
1280
|
+
}) => InferSchemaOutput<TSchema$1["headers"], HeadersOption>);
|
|
1281
1281
|
}>;
|
|
1282
1282
|
type InferRequestOptions<TSchema$1 extends CallApiSchema, TInitURL extends InferInitURL<BaseCallApiSchemaRoutes, CallApiSchemaConfig>> = InferBodyOption<TSchema$1> & InferHeadersOption<TSchema$1> & InferMethodOption<TSchema$1, TInitURL>;
|
|
1283
1283
|
interface Register {}
|
|
@@ -1308,13 +1308,13 @@ type InferMetaOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequired
|
|
|
1308
1308
|
* });
|
|
1309
1309
|
* ```
|
|
1310
1310
|
*/
|
|
1311
|
-
meta?:
|
|
1311
|
+
meta?: InferSchemaOutput<TSchema$1["meta"], GlobalMeta>;
|
|
1312
1312
|
}>;
|
|
1313
1313
|
type InferQueryOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["query"], {
|
|
1314
1314
|
/**
|
|
1315
1315
|
* Parameters to be appended to the URL (i.e: /:id)
|
|
1316
1316
|
*/
|
|
1317
|
-
query?:
|
|
1317
|
+
query?: InferSchemaOutput<TSchema$1["query"], Query>;
|
|
1318
1318
|
}>;
|
|
1319
1319
|
type EmptyString = "";
|
|
1320
1320
|
type EmptyTuple = readonly [];
|
|
@@ -1324,15 +1324,15 @@ type ExtractRouteParamNames<TCurrentRoute$1, TParamNamesAccumulator extends Stri
|
|
|
1324
1324
|
type ConvertParamNamesToRecord<TParamNames extends StringTuple> = Prettify<TParamNames extends (readonly [infer TFirstParamName extends string, ...infer TRemainingParamNames extends StringTuple]) ? Record<TFirstParamName, AllowedQueryParamValues> & ConvertParamNamesToRecord<TRemainingParamNames> : NonNullable<unknown>>;
|
|
1325
1325
|
type ConvertParamNamesToTuple<TParamNames extends StringTuple> = TParamNames extends readonly [string, ...infer TRemainingParamNames extends StringTuple] ? [AllowedQueryParamValues, ...ConvertParamNamesToTuple<TRemainingParamNames>] : [];
|
|
1326
1326
|
type InferParamsFromRoute<TCurrentRoute$1> = ExtractRouteParamNames<TCurrentRoute$1> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute$1> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute$1>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute$1>> : Params;
|
|
1327
|
-
type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> ? undefined extends
|
|
1327
|
+
type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> ? undefined extends InferSchemaOutput<TParamsSchemaOption, null> ? TObject : Required<TObject> : TObject>;
|
|
1328
1328
|
type InferParamsOption<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema$1["params"], TBaseSchemaRoutes$1, TCurrentRouteSchemaKey, {
|
|
1329
1329
|
/**
|
|
1330
1330
|
* Parameters to be appended to the URL (i.e: /:id)
|
|
1331
1331
|
*/
|
|
1332
|
-
params?:
|
|
1332
|
+
params?: InferSchemaOutput<TSchema$1["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
|
|
1333
1333
|
}>;
|
|
1334
1334
|
type InferExtraOptions<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = InferMetaOption<TSchema$1> & InferParamsOption<TSchema$1, TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> & InferQueryOption<TSchema$1>;
|
|
1335
|
-
type InferPluginOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction<infer TReturnedSchema> ?
|
|
1335
|
+
type InferPluginOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction<infer TReturnedSchema> ? InferSchemaOutput<TReturnedSchema> : never : never : never>;
|
|
1336
1336
|
type ResultModeOption<TErrorData$1, TResultMode extends ResultModeType> = TErrorData$1 extends false ? {
|
|
1337
1337
|
resultMode: "onlyData";
|
|
1338
1338
|
} : TErrorData$1 extends false | undefined ? {
|
|
@@ -1899,5 +1899,5 @@ type CallApiParameters<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType
|
|
|
1899
1899
|
type CallApiResult<TData$1, TErrorData$1, TResultMode extends ResultModeType, TThrowOnError extends ThrowOnErrorUnion, TResponseType extends ResponseTypeType> = GetCallApiResult<TData$1, TErrorData$1, TResultMode, TThrowOnError, TResponseType>;
|
|
1900
1900
|
type CallApiResultLoose<TData$1, TErrorData$1, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorUnion = ThrowOnErrorUnion, TResponseType extends ResponseTypeType = ResponseTypeType> = GetCallApiResult<TData$1, TErrorData$1, TResultMode, TThrowOnError, TResponseType>;
|
|
1901
1901
|
//#endregion
|
|
1902
|
-
export { CallApiResultSuccessVariantWithoutResponse as $, RequestContext as A, isValidationErrorInstance as B, ThrowOnErrorUnion as C, DefaultThrowOnError as Ct, Hooks as D,
|
|
1903
|
-
//# sourceMappingURL=common-
|
|
1902
|
+
export { CallApiResultSuccessVariantWithoutResponse as $, RequestContext as A, isValidationErrorInstance as B, ThrowOnErrorUnion as C, DefaultThrowOnError as Ct, Hooks as D, ErrorContext as E, AnyString as Et, SuccessContext as F, defineSchemaConfig as G, defineMainSchema as H, isHTTPError as I, PluginHooks as J, defineSchemaRoutes as K, isHTTPErrorInstance as L, ResponseContext as M, ResponseErrorContext as N, HooksOrHooksArray as O, ResponseStreamContext as P, CallApiResultSuccessVariant as Q, isJavascriptError as R, Register as S, DefaultPluginArray as St, DedupeOptions as T, toQueryString as Tt, definePlugin as U, defineBaseConfig as V, defineSchema as W, PluginSetupContext as X, PluginHooksWithMoreOptions as Y, CallApiResultErrorVariant as Z, ApplyURLBasedConfig as _, InferSchemaInput as _t, CallApiExtraOptions as a, PossibleJavaScriptOrValidationError as at, InferInitURL as b, URLOptions as bt, CallApiRequestOptions as c, ResponseTypeType as ct, CallApiResultLoose as d, HTTPError as dt, CallApiSuccessOrErrorVariant as et, GetBaseSchemaConfig as f, ValidationError as ft, ApplyStrictConfig as g, CallApiSchemaConfig as gt, InferExtendSchemaContext as h, CallApiSchema as ht, CallApiConfig as i, PossibleJavaScriptError as it, RequestStreamContext as j, PluginExtraOptions as k, CallApiRequestOptionsForHooks as l, ResultModeMap as lt, InferExtendSchemaConfigContext as m, BaseCallApiSchemaRoutes as mt, BaseCallApiExtraOptions as n, GetResponseType as nt, CallApiExtraOptionsForHooks as o, PossibleValidationError as ot, GetBaseSchemaRoutes as p, BaseCallApiSchemaAndConfig as pt, CallApiPlugin as q, BaseInstanceContext as r, PossibleHTTPError as rt, CallApiParameters as s, ResponseTypeMap as st, BaseCallApiConfig as t, GetCallApiResult as tt, CallApiResult as u, ResultModeType as ut, GetCurrentRouteSchema as v, InferSchemaOutput as vt, RetryOptions as w, toFormData as wt, InferParamsFromRoute as x, DefaultDataType as xt, GetCurrentRouteSchemaKey as y, InferSchemaResult as yt, isValidationError as z };
|
|
1903
|
+
//# sourceMappingURL=common-DvZQWmH6.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as requestOptionDefaults, t as extraOptionDefaults } from "../defaults-
|
|
2
|
-
import { n as fetchSpecificKeys, t as fallBackRouteSchemaKey } from "../validation-
|
|
1
|
+
import { n as requestOptionDefaults, t as extraOptionDefaults } from "../defaults-C6WKIXsf.js";
|
|
2
|
+
import { n as fetchSpecificKeys, t as fallBackRouteSchemaKey } from "../validation-8gwacxHw.js";
|
|
3
3
|
|
|
4
4
|
export { extraOptionDefaults, fallBackRouteSchemaKey, fetchSpecificKeys, requestOptionDefaults };
|
|
@@ -5,7 +5,7 @@ const defineEnum = (value) => Object.freeze(value);
|
|
|
5
5
|
//#region src/constants/defaults.ts
|
|
6
6
|
const extraOptionDefaults = Object.freeze(defineEnum({
|
|
7
7
|
bodySerializer: JSON.stringify,
|
|
8
|
-
defaultHTTPErrorMessage: "
|
|
8
|
+
defaultHTTPErrorMessage: "Request failed unexpectedly",
|
|
9
9
|
dedupeCacheScope: "local",
|
|
10
10
|
dedupeCacheScopeKey: "default",
|
|
11
11
|
dedupeStrategy: "cancel",
|
|
@@ -25,4 +25,4 @@ const requestOptionDefaults = defineEnum({ method: "GET" });
|
|
|
25
25
|
|
|
26
26
|
//#endregion
|
|
27
27
|
export { requestOptionDefaults as n, defineEnum as r, extraOptionDefaults as t };
|
|
28
|
-
//# sourceMappingURL=defaults-
|
|
28
|
+
//# sourceMappingURL=defaults-C6WKIXsf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults-C6WKIXsf.js","names":[],"sources":["../src/types/type-helpers.ts","../src/constants/defaults.ts"],"sourcesContent":["// == These two types allows for adding arbitrary literal types, while still provided autocomplete for defaults.\n\n// == Usually intersection with \"{}\" or \"NonNullable<unknown>\" would make it work fine, but the placeholder with never type is added to make the AnyWhatever type appear last in a given union.\nexport type AnyString = string & NonNullable<unknown>;\nexport type AnyNumber = number & NonNullable<unknown>;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is fine here\nexport type AnyObject = Record<keyof any, any>;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport type AnyFunction<TResult = unknown> = (...args: any[]) => TResult;\n\nexport type Prettify<TObject> = NonNullable<unknown> & { [Key in keyof TObject]: TObject[Key] };\n\ntype WriteableLevel = \"deep\" | \"shallow\";\n\n/**\n * Makes all properties in an object type writeable (removes readonly modifiers).\n * Supports both shallow and deep modes, and handles special cases like arrays, tuples, and unions.\n * @template TObject - The object type to make writeable\n * @template TVariant - The level of writeable transformation (\"shallow\" | \"deep\")\n */\n\ntype ArrayOrObject = Record<number | string | symbol, unknown> | unknown[] | readonly unknown[];\n\nexport type Writeable<TObject, TLevel extends WriteableLevel = \"shallow\"> =\n\tTObject extends ArrayOrObject ?\n\t\t{\n\t\t\t-readonly [Key in keyof TObject]: TLevel extends \"deep\" ?\n\t\t\t\tNonNullable<TObject[Key]> extends ArrayOrObject ?\n\t\t\t\t\tWriteable<TObject[Key], \"deep\">\n\t\t\t\t:\tTObject[Key]\n\t\t\t:\tTObject[Key];\n\t\t}\n\t:\tTObject;\n\nexport const defineEnum = <const TValue extends object>(value: TValue) =>\n\tObject.freeze(value) as Readonly<Writeable<TValue>>;\n\nexport type UnionToIntersection<TUnion> =\n\t(TUnion extends unknown ? (param: TUnion) => void : never) extends (param: infer TParam) => void ?\n\t\tTParam\n\t:\tnever;\n\n// == Using this Immediately Indexed Mapped type helper to help show computed type of anything passed to it instead of just the type name\nexport type UnmaskType<TValue> = { _: TValue }[\"_\"];\n\nexport type RemovePrefix<TPrefix extends \"dedupe\" | \"retry\", TKey extends string> =\n\tTKey extends `${TPrefix}${infer TRest}` ? Uncapitalize<TRest> : TKey;\n\nexport type Awaitable<TValue> = Promise<TValue> | TValue;\n\nexport type MatchExactObjectType<TActualObject extends TExpectedObject, TExpectedObject> = {\n\t[Key in keyof TActualObject]: Key extends keyof TExpectedObject ? TActualObject[Key] : never;\n};\n\nexport type CommonRequestHeaders =\n\t| \"Access-Control-Allow-Credentials\"\n\t| \"Access-Control-Allow-Headers\"\n\t| \"Access-Control-Allow-Methods\"\n\t| \"Access-Control-Allow-Origin\"\n\t| \"Access-Control-Expose-Headers\"\n\t| \"Access-Control-Max-Age\"\n\t| \"Age\"\n\t| \"Allow\"\n\t| \"Cache-Control\"\n\t| \"Clear-Site-Data\"\n\t| \"Content-Disposition\"\n\t| \"Content-Encoding\"\n\t| \"Content-Language\"\n\t| \"Content-Length\"\n\t| \"Content-Location\"\n\t| \"Content-Range\"\n\t| \"Content-Security-Policy-Report-Only\"\n\t| \"Content-Security-Policy\"\n\t| \"Cookie\"\n\t| \"Cross-Origin-Embedder-Policy\"\n\t| \"Cross-Origin-Opener-Policy\"\n\t| \"Cross-Origin-Resource-Policy\"\n\t| \"Date\"\n\t| \"ETag\"\n\t| \"Expires\"\n\t| \"Last-Modified\"\n\t| \"Location\"\n\t| \"Permissions-Policy\"\n\t| \"Pragma\"\n\t| \"Retry-After\"\n\t| \"Save-Data\"\n\t| \"Sec-CH-Prefers-Color-Scheme\"\n\t| \"Sec-CH-Prefers-Reduced-Motion\"\n\t| \"Sec-CH-UA-Arch\"\n\t| \"Sec-CH-UA-Bitness\"\n\t| \"Sec-CH-UA-Form-Factor\"\n\t| \"Sec-CH-UA-Full-Version-List\"\n\t| \"Sec-CH-UA-Full-Version\"\n\t| \"Sec-CH-UA-Mobile\"\n\t| \"Sec-CH-UA-Model\"\n\t| \"Sec-CH-UA-Platform-Version\"\n\t| \"Sec-CH-UA-Platform\"\n\t| \"Sec-CH-UA-WoW64\"\n\t| \"Sec-CH-UA\"\n\t| \"Sec-Fetch-Dest\"\n\t| \"Sec-Fetch-Mode\"\n\t| \"Sec-Fetch-Site\"\n\t| \"Sec-Fetch-User\"\n\t| \"Sec-GPC\"\n\t| \"Server-Timing\"\n\t| \"Server\"\n\t| \"Service-Worker-Navigation-Preload\"\n\t| \"Set-Cookie\"\n\t| \"Strict-Transport-Security\"\n\t| \"Timing-Allow-Origin\"\n\t| \"Trailer\"\n\t| \"Transfer-Encoding\"\n\t| \"Upgrade\"\n\t| \"Vary\"\n\t| \"Warning\"\n\t| \"WWW-Authenticate\"\n\t| \"X-Content-Type-Options\"\n\t| \"X-DNS-Prefetch-Control\"\n\t| \"X-Frame-Options\"\n\t| \"X-Permitted-Cross-Domain-Policies\"\n\t| \"X-Powered-By\"\n\t| \"X-Robots-Tag\"\n\t| \"X-XSS-Protection\"\n\t| AnyString;\n\nexport type CommonAuthorizationHeaders = `${\"Basic\" | \"Bearer\" | \"Token\"} ${string}`;\n\nexport type CommonContentTypes =\n\t| \"application/epub+zip\"\n\t| \"application/gzip\"\n\t| \"application/json\"\n\t| \"application/ld+json\"\n\t| \"application/octet-stream\"\n\t| \"application/ogg\"\n\t| \"application/pdf\"\n\t| \"application/rtf\"\n\t| \"application/vnd.ms-fontobject\"\n\t| \"application/wasm\"\n\t| \"application/xhtml+xml\"\n\t| \"application/xml\"\n\t| \"application/zip\"\n\t| \"audio/aac\"\n\t| \"audio/mpeg\"\n\t| \"audio/ogg\"\n\t| \"audio/opus\"\n\t| \"audio/webm\"\n\t| \"audio/x-midi\"\n\t| \"font/otf\"\n\t| \"font/ttf\"\n\t| \"font/woff\"\n\t| \"font/woff2\"\n\t| \"image/avif\"\n\t| \"image/bmp\"\n\t| \"image/gif\"\n\t| \"image/jpeg\"\n\t| \"image/png\"\n\t| \"image/svg+xml\"\n\t| \"image/tiff\"\n\t| \"image/webp\"\n\t| \"image/x-icon\"\n\t| \"model/gltf-binary\"\n\t| \"model/gltf+json\"\n\t| \"text/calendar\"\n\t| \"text/css\"\n\t| \"text/csv\"\n\t| \"text/html\"\n\t| \"text/javascript\"\n\t| \"text/plain\"\n\t| \"video/3gpp\"\n\t| \"video/3gpp2\"\n\t| \"video/av1\"\n\t| \"video/mp2t\"\n\t| \"video/mp4\"\n\t| \"video/mpeg\"\n\t| \"video/ogg\"\n\t| \"video/webm\"\n\t| \"video/x-msvideo\"\n\t| AnyString;\n","import type { CallApiConfig, CallApiExtraOptions } from \"../types/common\";\nimport { defineEnum } from \"../types/type-helpers\";\n\nexport const extraOptionDefaults = Object.freeze(\n\tdefineEnum({\n\t\t// Common defaults\n\t\tbodySerializer: JSON.stringify,\n\t\tdefaultHTTPErrorMessage: \"Request failed unexpectedly\",\n\n\t\t// Dedupe defaults\n\t\t/* eslint-disable perfectionist/sort-objects -- Allow */\n\t\tdedupeCacheScope: \"local\",\n\t\tdedupeCacheScopeKey: \"default\",\n\t\tdedupeStrategy: \"cancel\",\n\t\t/* eslint-enable perfectionist/sort-objects -- Allow */\n\n\t\t// Hook defaults\n\t\thooksExecutionMode: \"parallel\",\n\n\t\t// Response defaults\n\t\tresponseParser: JSON.parse,\n\t\tresponseType: \"json\",\n\t\tresultMode: \"all\",\n\n\t\t// Retry Defaults\n\t\tretryAttempts: 0,\n\t\tretryCondition: () => true,\n\t\tretryDelay: 1000,\n\t\tretryMaxDelay: 10000,\n\t\tretryMethods: [\"GET\", \"POST\"],\n\t\tretryStatusCodes: [],\n\t\tretryStrategy: \"linear\",\n\t} satisfies CallApiExtraOptions)\n);\n\nexport const requestOptionDefaults = defineEnum({\n\tmethod: \"GET\",\n} satisfies CallApiConfig);\n"],"mappings":";AAoCA,MAAa,cAA2C,UACvD,OAAO,OAAO,MAAM;;;;AClCrB,MAAa,sBAAsB,OAAO,OACzC,WAAW;CAEV,gBAAgB,KAAK;CACrB,yBAAyB;CAIzB,kBAAkB;CAClB,qBAAqB;CACrB,gBAAgB;CAIhB,oBAAoB;CAGpB,gBAAgB,KAAK;CACrB,cAAc;CACd,YAAY;CAGZ,eAAe;CACf,sBAAsB;CACtB,YAAY;CACZ,eAAe;CACf,cAAc,CAAC,OAAO,OAAO;CAC7B,kBAAkB,EAAE;CACpB,eAAe;CACf,CAA+B,CAChC;AAED,MAAa,wBAAwB,WAAW,EAC/C,QAAQ,OACR,CAAyB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as extraOptionDefaults } from "./defaults-
|
|
1
|
+
import { t as extraOptionDefaults } from "./defaults-C6WKIXsf.js";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/guards.ts
|
|
4
4
|
const isArray = (value) => Array.isArray(value);
|
|
@@ -162,7 +162,8 @@ var ValidationError = class ValidationError extends Error {
|
|
|
162
162
|
validationErrorSymbol = validationErrorSymbol;
|
|
163
163
|
constructor(details, errorOptions) {
|
|
164
164
|
const { issueCause, issues, response } = details;
|
|
165
|
-
const
|
|
165
|
+
const prettyMessage = prettifyValidationIssues(issues);
|
|
166
|
+
const message = `(${issueCause.toUpperCase()}) - ${prettyMessage}`;
|
|
166
167
|
super(message, errorOptions);
|
|
167
168
|
this.errorData = issues;
|
|
168
169
|
this.response = response;
|
|
@@ -201,4 +202,4 @@ const isJavascriptError = (error) => {
|
|
|
201
202
|
|
|
202
203
|
//#endregion
|
|
203
204
|
export { isReadableStream as _, isValidationErrorInstance as a, isValidJsonString as b, toFormData as c, isBoolean as d, isFunction as f, isQueryString as g, isPromise as h, isValidationError as i, toQueryString as l, isPlainObject as m, isHTTPErrorInstance as n, HTTPError as o, isObject as p, isJavascriptError as r, ValidationError as s, isHTTPError as t, isArray as u, isSerializable as v, isString as y };
|
|
204
|
-
//# sourceMappingURL=guards-
|
|
205
|
+
//# sourceMappingURL=guards-5Ij_loC1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards-5Ij_loC1.js","names":["toQueryString: ToQueryStringFn","toFormData: ToFormDataFn"],"sources":["../src/utils/guards.ts","../src/utils/external/body.ts","../src/utils/external/error.ts","../src/utils/external/guards.ts"],"sourcesContent":["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 isSerializable = (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","import type { CallApiExtraOptions } from \"../../types/common\";\nimport { isArray, isBlob, isObject } from \"../guards\";\n\ntype ToQueryStringFn = {\n\t(query: CallApiExtraOptions[\"query\"]): string | null;\n\t(query: Required<CallApiExtraOptions>[\"query\"]): string;\n};\n\nexport const toQueryString: ToQueryStringFn = (query) => {\n\tif (!query) {\n\t\tconsole.error(\"toQueryString:\", \"No query params provided!\");\n\n\t\treturn null as never;\n\t}\n\n\treturn new URLSearchParams(query as Record<string, string>).toString();\n};\n\ntype AllowedPrimitives = boolean | number | string | Blob;\n\ntype AllowedValues = AllowedPrimitives | AllowedPrimitives[] | Record<string, AllowedPrimitives>;\n\nconst toBlobOrString = (value: AllowedPrimitives): string | Blob => {\n\treturn isBlob(value) ? value : String(value);\n};\n\ntype ToFormDataFn = {\n\t(data: Record<string, AllowedValues>): FormData;\n\n\t<TData extends Record<string, AllowedValues>>(data: TData, options: { returnType: \"inputType\" }): TData;\n};\n\n/**\n * @description Converts a plain object to FormData.\n *\n * Handles various data types:\n * - **Primitives** (string, number, boolean): Converted to strings\n * - **Blobs/Files**: Added directly to FormData\n * - **Arrays**: Each item is appended (allows multiple values for same key)\n * - **Objects**: JSON stringified before adding to FormData\n *\n * @example\n * ```ts\n * // Basic usage\n * const formData = toFormData({\n * name: \"John\",\n * age: 30,\n * active: true\n * });\n *\n * // With arrays\n * const formData = toFormData({\n * tags: [\"javascript\", \"typescript\"],\n * name: \"John\"\n * });\n *\n * // With files\n * const formData = toFormData({\n * avatar: fileBlob,\n * name: \"John\"\n * });\n *\n * // With nested objects (one level only)\n * const formData = toFormData({\n * user: { name: \"John\", age: 30 },\n * settings: { theme: \"dark\" }\n * });\n *\n * // Type-preserving usage with Zod\n * const schema = z.object({ name: z.string(), file: z.instanceof(Blob) });\n * const data = schema.parse({ name: \"John\", file: blob });\n * const typedFormData = toFormData(data, { returnType: \"inputType\" });\n * // Type is { name: string; file: Blob }, runtime is FormData\n * ```\n */\nexport const toFormData: ToFormDataFn = (data: Record<string, AllowedValues>) => {\n\tconst formData = new FormData();\n\n\tfor (const [key, value] of Object.entries(data)) {\n\t\tif (isArray(value)) {\n\t\t\tvalue.forEach((innerValue) => formData.append(key, toBlobOrString(innerValue)));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isObject(value) && !isBlob(value)) {\n\t\t\tformData.set(key, JSON.stringify(value));\n\t\t\tcontinue;\n\t\t}\n\n\t\tformData.set(key, toBlobOrString(value));\n\t}\n\n\treturn formData;\n};\n","import { extraOptionDefaults } from \"../../constants/defaults\";\nimport type { CallApiExtraOptions } from \"../../types\";\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\n\t\t.map((issue) => `✖ ${issue.message}${prettifyPath(issue.path)}`)\n\t\t.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| \"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 {\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":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./validation-Dq--Q5zC.js";
|
|
2
|
-
import { $ as CallApiResultSuccessVariantWithoutResponse, A as RequestContext, C as ThrowOnErrorUnion, Ct as DefaultThrowOnError, D as Hooks,
|
|
2
|
+
import { $ as CallApiResultSuccessVariantWithoutResponse, A as RequestContext, C as ThrowOnErrorUnion, Ct as DefaultThrowOnError, D as Hooks, E as ErrorContext, Et as AnyString, F as SuccessContext, J as PluginHooks, M as ResponseContext, N as ResponseErrorContext, O as HooksOrHooksArray, P as ResponseStreamContext, Q as CallApiResultSuccessVariant, S as Register, St as DefaultPluginArray, T as DedupeOptions, X as PluginSetupContext, Y as PluginHooksWithMoreOptions, Z as CallApiResultErrorVariant, _ as ApplyURLBasedConfig, _t as InferSchemaInput, a as CallApiExtraOptions, at as PossibleJavaScriptOrValidationError, b as InferInitURL, bt as URLOptions, c as CallApiRequestOptions, ct as ResponseTypeType, d as CallApiResultLoose, et as CallApiSuccessOrErrorVariant, f as GetBaseSchemaConfig, g as ApplyStrictConfig, gt as CallApiSchemaConfig, h as InferExtendSchemaContext, ht as CallApiSchema, i as CallApiConfig, it as PossibleJavaScriptError, j as RequestStreamContext, k as PluginExtraOptions, l as CallApiRequestOptionsForHooks, lt as ResultModeMap, m as InferExtendSchemaConfigContext, mt as BaseCallApiSchemaRoutes, n as BaseCallApiExtraOptions, nt as GetResponseType, o as CallApiExtraOptionsForHooks, ot as PossibleValidationError, p as GetBaseSchemaRoutes, pt as BaseCallApiSchemaAndConfig, q as CallApiPlugin, r as BaseInstanceContext, rt as PossibleHTTPError, s as CallApiParameters, st as ResponseTypeMap, t as BaseCallApiConfig, tt as GetCallApiResult, u as CallApiResult, ut as ResultModeType, v as GetCurrentRouteSchema, vt as InferSchemaOutput, w as RetryOptions, x as InferParamsFromRoute, xt as DefaultDataType, y as GetCurrentRouteSchemaKey, yt as InferSchemaResult } from "./common-DvZQWmH6.js";
|
|
3
3
|
|
|
4
4
|
//#region src/createFetchClient.d.ts
|
|
5
5
|
|
|
@@ -36,12 +36,12 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
|
|
|
36
36
|
"@patch/"?: CallApiSchema | undefined;
|
|
37
37
|
"@post/"?: CallApiSchema | undefined;
|
|
38
38
|
"@put/"?: CallApiSchema | undefined;
|
|
39
|
-
}[TCurrentRouteSchemaKey]>>, const TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedResult = GetCallApiResult<
|
|
40
|
-
all: CallApiResultSuccessVariant<GetResponseType<
|
|
41
|
-
onlyData: NoInfer<GetResponseType<
|
|
39
|
+
}[TCurrentRouteSchemaKey]>>, const TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedResult = GetCallApiResult<InferSchemaResult<TSchema["data"], TData, "infer-output">, InferSchemaResult<TSchema["errorData"], TErrorData, "infer-output">, TResultMode, TThrowOnError, TResponseType, {
|
|
40
|
+
all: CallApiResultSuccessVariant<GetResponseType<InferSchemaResult<TSchema["data"], TData, "infer-output">, TResponseType, ResponseTypeMap<InferSchemaResult<TSchema["data"], TData, "infer-output">>>>;
|
|
41
|
+
onlyData: NoInfer<GetResponseType<InferSchemaResult<TSchema["data"], TData, "infer-output">, TResponseType, ResponseTypeMap<InferSchemaResult<TSchema["data"], TData, "infer-output">>>>;
|
|
42
42
|
onlyResponse: Response;
|
|
43
|
-
withoutResponse: CallApiResultSuccessVariantWithoutResponse<GetResponseType<
|
|
44
|
-
}, ResultModeMap<
|
|
43
|
+
withoutResponse: CallApiResultSuccessVariantWithoutResponse<GetResponseType<InferSchemaResult<TSchema["data"], TData, "infer-output">, TResponseType, ResponseTypeMap<InferSchemaResult<TSchema["data"], TData, "infer-output">>>>;
|
|
44
|
+
}, ResultModeMap<InferSchemaResult<TSchema["data"], TData, "infer-output">, InferSchemaResult<TSchema["errorData"], TErrorData, "infer-output">, TResponseType, TThrowOnError>>>(initURL: TInitURL, initConfig?: CallApiConfig<InferSchemaResult<TSchema["data"], GetResponseType<TData, TResponseType, ResponseTypeMap<TData>>, "infer-output">, InferSchemaResult<TSchema["errorData"], GetResponseType<TErrorData, TResponseType, ResponseTypeMap<TErrorData>>, "infer-output">, TResultMode, TThrowOnError, TResponseType, {
|
|
45
45
|
[x: AnyString]: CallApiSchema | undefined;
|
|
46
46
|
"@default"?: CallApiSchema | undefined;
|
|
47
47
|
"@delete/"?: CallApiSchema | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as requestOptionDefaults, r as defineEnum, t as extraOptionDefaults } from "./defaults-
|
|
2
|
-
import { _ as isReadableStream, a as isValidationErrorInstance, b as isValidJsonString, d as isBoolean, f as isFunction, g as isQueryString, h as isPromise, l as toQueryString, m as isPlainObject, n as isHTTPErrorInstance, o as HTTPError, p as isObject, s as ValidationError, u as isArray, v as isSerializable, y as isString } from "./guards-
|
|
3
|
-
import { n as fetchSpecificKeys, t as fallBackRouteSchemaKey } from "./validation-
|
|
1
|
+
import { n as requestOptionDefaults, r as defineEnum, t as extraOptionDefaults } from "./defaults-C6WKIXsf.js";
|
|
2
|
+
import { _ as isReadableStream, a as isValidationErrorInstance, b as isValidJsonString, d as isBoolean, f as isFunction, g as isQueryString, h as isPromise, l as toQueryString, m as isPlainObject, n as isHTTPErrorInstance, o as HTTPError, p as isObject, s as ValidationError, u as isArray, v as isSerializable, y as isString } from "./guards-5Ij_loC1.js";
|
|
3
|
+
import { n as fetchSpecificKeys, t as fallBackRouteSchemaKey } from "./validation-8gwacxHw.js";
|
|
4
4
|
|
|
5
5
|
//#region src/auth.ts
|
|
6
6
|
const resolveAuthValue = (value) => isFunction(value) ? value() : value;
|
|
@@ -46,10 +46,11 @@ const handleValidatorFunction = async (validator, inputData) => {
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
const standardSchemaParser = async (fullSchema, schemaName,
|
|
49
|
+
const standardSchemaParser = async (fullSchema, schemaName, options) => {
|
|
50
|
+
const { inputValue, response } = options;
|
|
50
51
|
const schema = fullSchema?.[schemaName];
|
|
51
|
-
if (!schema) return
|
|
52
|
-
const result = isFunction(schema) ? await handleValidatorFunction(schema,
|
|
52
|
+
if (!schema) return inputValue;
|
|
53
|
+
const result = isFunction(schema) ? await handleValidatorFunction(schema, inputValue) : await schema["~standard"].validate(inputValue);
|
|
53
54
|
if (result.issues) throw new ValidationError({
|
|
54
55
|
issueCause: schemaName,
|
|
55
56
|
issues: result.issues,
|
|
@@ -67,7 +68,10 @@ const routeKeyMethods = defineEnum([
|
|
|
67
68
|
const handleSchemaValidation = async (fullSchema, schemaName, validationOptions) => {
|
|
68
69
|
const { inputValue, response, schemaConfig } = validationOptions;
|
|
69
70
|
if (schemaConfig?.disableRuntimeValidation) return inputValue;
|
|
70
|
-
return await standardSchemaParser(fullSchema, schemaName,
|
|
71
|
+
return await standardSchemaParser(fullSchema, schemaName, {
|
|
72
|
+
inputValue,
|
|
73
|
+
response
|
|
74
|
+
});
|
|
71
75
|
};
|
|
72
76
|
const extraOptionsToBeValidated = [
|
|
73
77
|
"meta",
|