@zayne-labs/callapi 1.11.0 → 1.11.1
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/README.md +165 -95
- package/dist/esm/{common-CEcqiR7c.js → common-B2rPuIEQ.js} +28 -29
- package/dist/esm/common-B2rPuIEQ.js.map +1 -0
- package/dist/esm/{common-CPTdKchS.d.ts → common-BMWVqV15.d.ts} +14 -9
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +27 -30
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/index.d.ts +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/package.json +1 -1
- package/dist/esm/common-CEcqiR7c.js.map +0 -1
@@ -16,6 +16,7 @@ type UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) =>
|
|
16
16
|
type UnmaskType<TValue> = {
|
17
17
|
_: TValue;
|
18
18
|
}["_"];
|
19
|
+
type RemovePrefix<TPrefix extends "dedupe" | "retry", TKey extends string> = TKey extends `${TPrefix}${infer TRest}` ? Uncapitalize<TRest> : TKey;
|
19
20
|
type Awaitable<TValue> = Promise<TValue> | TValue;
|
20
21
|
type CommonRequestHeaders = "Access-Control-Allow-Credentials" | "Access-Control-Allow-Headers" | "Access-Control-Allow-Methods" | "Access-Control-Allow-Origin" | "Access-Control-Expose-Headers" | "Access-Control-Max-Age" | "Age" | "Allow" | "Cache-Control" | "Clear-Site-Data" | "Content-Disposition" | "Content-Encoding" | "Content-Language" | "Content-Length" | "Content-Location" | "Content-Range" | "Content-Security-Policy-Report-Only" | "Content-Security-Policy" | "Cookie" | "Cross-Origin-Embedder-Policy" | "Cross-Origin-Opener-Policy" | "Cross-Origin-Resource-Policy" | "Date" | "ETag" | "Expires" | "Last-Modified" | "Location" | "Permissions-Policy" | "Pragma" | "Retry-After" | "Save-Data" | "Sec-CH-Prefers-Color-Scheme" | "Sec-CH-Prefers-Reduced-Motion" | "Sec-CH-UA-Arch" | "Sec-CH-UA-Bitness" | "Sec-CH-UA-Form-Factor" | "Sec-CH-UA-Full-Version-List" | "Sec-CH-UA-Full-Version" | "Sec-CH-UA-Mobile" | "Sec-CH-UA-Model" | "Sec-CH-UA-Platform-Version" | "Sec-CH-UA-Platform" | "Sec-CH-UA-WoW64" | "Sec-CH-UA" | "Sec-Fetch-Dest" | "Sec-Fetch-Mode" | "Sec-Fetch-Site" | "Sec-Fetch-User" | "Sec-GPC" | "Server-Timing" | "Server" | "Service-Worker-Navigation-Preload" | "Set-Cookie" | "Strict-Transport-Security" | "Timing-Allow-Origin" | "Trailer" | "Transfer-Encoding" | "Upgrade" | "Vary" | "Warning" | "WWW-Authenticate" | "X-Content-Type-Options" | "X-DNS-Prefetch-Control" | "X-Frame-Options" | "X-Permitted-Cross-Domain-Policies" | "X-Powered-By" | "X-Robots-Tag" | "X-XSS-Protection" | AnyString;
|
21
22
|
type CommonAuthorizationHeaders = `${"Basic" | "Bearer" | "Token"} ${string}`;
|
@@ -61,7 +62,7 @@ type CustomAuth = {
|
|
61
62
|
type Auth = PossibleAuthValueOrGetter | BearerOrTokenAuth | BasicAuth | CustomAuth;
|
62
63
|
//#endregion
|
63
64
|
//#region src/constants/common.d.ts
|
64
|
-
declare const fetchSpecificKeys: (keyof RequestInit | "duplex")[];
|
65
|
+
declare const fetchSpecificKeys: readonly (keyof RequestInit | "duplex")[];
|
65
66
|
//#endregion
|
66
67
|
//#region src/types/standard-schema.d.ts
|
67
68
|
/**
|
@@ -356,7 +357,7 @@ interface CallApiSchema {
|
|
356
357
|
*/
|
357
358
|
query?: StandardSchemaV1<Query | undefined> | ((query: Query) => Awaitable<Query | undefined>);
|
358
359
|
}
|
359
|
-
declare const routeKeyMethods: ["delete", "get", "patch", "post", "put"];
|
360
|
+
declare const routeKeyMethods: readonly ["delete", "get", "patch", "post", "put"];
|
360
361
|
type RouteKeyMethods = (typeof routeKeyMethods)[number];
|
361
362
|
type RouteKeyMethodsURLUnion = `@${RouteKeyMethods}/`;
|
362
363
|
type BaseCallApiSchemaRoutes = Partial<Record<AnyString | RouteKeyMethodsURLUnion, CallApiSchema>>;
|
@@ -862,7 +863,13 @@ type ResponseStreamContext = UnmaskType<RequestContext & {
|
|
862
863
|
//#endregion
|
863
864
|
//#region src/dedupe.d.ts
|
864
865
|
type DedupeStrategyUnion = UnmaskType<"cancel" | "defer" | "none">;
|
866
|
+
type DedupeOptionKeys = Exclude<keyof DedupeOptions, "dedupe">;
|
867
|
+
type InnerDedupeOptions = { [Key in DedupeOptionKeys as RemovePrefix<"dedupe", Key>]?: DedupeOptions[Key] };
|
865
868
|
type DedupeOptions = {
|
869
|
+
/**
|
870
|
+
* All dedupe options in a single object instead of separate properties
|
871
|
+
*/
|
872
|
+
dedupe?: InnerDedupeOptions;
|
866
873
|
/**
|
867
874
|
* Controls the scope of request deduplication caching.
|
868
875
|
*
|
@@ -1071,7 +1078,7 @@ type DedupeOptions = {
|
|
1071
1078
|
};
|
1072
1079
|
//#endregion
|
1073
1080
|
//#region src/retry.d.ts
|
1074
|
-
declare const defaultRetryStatusCodesLookup: () => {
|
1081
|
+
declare const defaultRetryStatusCodesLookup: () => Readonly<{
|
1075
1082
|
408: "Request Timeout";
|
1076
1083
|
409: "Conflict";
|
1077
1084
|
425: "Too Early";
|
@@ -1080,13 +1087,11 @@ declare const defaultRetryStatusCodesLookup: () => {
|
|
1080
1087
|
502: "Bad Gateway";
|
1081
1088
|
503: "Service Unavailable";
|
1082
1089
|
504: "Gateway Timeout";
|
1083
|
-
}
|
1090
|
+
}>;
|
1084
1091
|
type RetryStatusCodes = UnmaskType<AnyNumber | keyof ReturnType<typeof defaultRetryStatusCodesLookup>>;
|
1085
1092
|
type RetryCondition<TErrorData> = (context: ErrorContext<TErrorData>) => Awaitable<boolean>;
|
1086
|
-
type
|
1087
|
-
type InnerRetryOptions<TErrorData> = { [Key in
|
1088
|
-
attempts: NonNullable<RetryOptions<TErrorData>["retryAttempts"]>;
|
1089
|
-
};
|
1093
|
+
type RetryOptionKeys<TErrorData> = Exclude<keyof RetryOptions<TErrorData>, "~retryAttemptCount" | "retry">;
|
1094
|
+
type InnerRetryOptions<TErrorData> = { [Key in RetryOptionKeys<TErrorData> as RemovePrefix<"retry", Key>]?: RetryOptions<TErrorData>[Key] };
|
1090
1095
|
interface RetryOptions<TErrorData> {
|
1091
1096
|
/**
|
1092
1097
|
* Keeps track of the number of times the request has already been retried
|
@@ -1789,4 +1794,4 @@ type CallApiParameters<TData = DefaultDataType, TErrorData = DefaultDataType, TR
|
|
1789
1794
|
type CallApiResult<TData, TErrorData, TResultMode extends ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion, TResponseType extends ResponseTypeUnion> = Promise<GetCallApiResult<TData, TErrorData, TResultMode, TThrowOnError, TResponseType>>;
|
1790
1795
|
//#endregion
|
1791
1796
|
export { AnyFunction, AnyString, ApplyStrictConfig, ApplyURLBasedConfig, BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchemaAndConfig, BaseCallApiSchemaRoutes, CallApiConfig, CallApiExtraOptions, CallApiExtraOptionsForHooks, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig, DedupeOptions, DefaultDataType, DefaultPluginArray, DefaultThrowOnError, ErrorContext, GetCurrentRouteSchema, GetCurrentRouteSchemaKey, GetResponseType, HTTPError, Hooks, HooksOrHooksArray, InferInitURL, InferParamsFromRoute, InferSchemaOutputResult, PluginExtraOptions, PluginHooks, PluginHooksWithMoreOptions, PluginSetupContext, PossibleHTTPError, PossibleJavaScriptError, PossibleJavaScriptOrValidationError, PossibleValidationError, Register, RequestContext, RequestStreamContext, ResponseContext, ResponseErrorContext, ResponseStreamContext, ResponseTypeMap, ResponseTypeUnion, ResultModeUnion, RetryOptions, SuccessContext, ThrowOnErrorUnion, URLOptions, ValidationError, Writeable, fallBackRouteSchemaKey };
|
1792
|
-
//# sourceMappingURL=common-
|
1797
|
+
//# sourceMappingURL=common-BMWVqV15.d.ts.map
|
package/dist/esm/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { AnyFunction, AnyString, ApplyStrictConfig, ApplyURLBasedConfig, BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchemaAndConfig, BaseCallApiSchemaRoutes, CallApiConfig, CallApiExtraOptions, CallApiExtraOptionsForHooks, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig, DedupeOptions, DefaultDataType, DefaultPluginArray, DefaultThrowOnError, ErrorContext, GetCurrentRouteSchema, GetCurrentRouteSchemaKey, GetResponseType, HTTPError, Hooks, HooksOrHooksArray, InferInitURL, InferParamsFromRoute, InferSchemaOutputResult, PluginExtraOptions, PluginHooks, PluginHooksWithMoreOptions, PluginSetupContext, PossibleHTTPError, PossibleJavaScriptError, PossibleJavaScriptOrValidationError, PossibleValidationError, Register, RequestContext, RequestStreamContext, ResponseContext, ResponseErrorContext, ResponseStreamContext, ResponseTypeMap, ResponseTypeUnion, ResultModeUnion, RetryOptions, SuccessContext, ThrowOnErrorUnion, URLOptions, ValidationError, Writeable, fallBackRouteSchemaKey } from "./common-
|
1
|
+
import { AnyFunction, AnyString, ApplyStrictConfig, ApplyURLBasedConfig, BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchemaAndConfig, BaseCallApiSchemaRoutes, CallApiConfig, CallApiExtraOptions, CallApiExtraOptionsForHooks, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig, DedupeOptions, DefaultDataType, DefaultPluginArray, DefaultThrowOnError, ErrorContext, GetCurrentRouteSchema, GetCurrentRouteSchemaKey, GetResponseType, HTTPError, Hooks, HooksOrHooksArray, InferInitURL, InferParamsFromRoute, InferSchemaOutputResult, PluginExtraOptions, PluginHooks, PluginHooksWithMoreOptions, PluginSetupContext, PossibleHTTPError, PossibleJavaScriptError, PossibleJavaScriptOrValidationError, PossibleValidationError, Register, RequestContext, RequestStreamContext, ResponseContext, ResponseErrorContext, ResponseStreamContext, ResponseTypeMap, ResponseTypeUnion, ResultModeUnion, RetryOptions, SuccessContext, ThrowOnErrorUnion, URLOptions, ValidationError, Writeable, fallBackRouteSchemaKey } from "./common-BMWVqV15.js";
|
2
2
|
|
3
3
|
//#region src/createFetchClient.d.ts
|
4
4
|
|
package/dist/esm/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { HTTPError, ValidationError, createCombinedSignal, createTimeoutSignal, deterministicHashFn, extraOptionDefaults, fallBackRouteSchemaKey, getBody, getCurrentRouteSchemaKeyAndMainInitURL, getFetchImpl, getFullAndNormalizedURL, getHeaders, getMethod, handleConfigValidation, handleSchemaValidation, isArray, isBoolean, isFunction, isHTTPErrorInstance, isObject, isPlainObject, isReadableStream, isString, isValidationErrorInstance, splitBaseConfig, splitConfig, waitFor } from "./common-
|
1
|
+
import { HTTPError, ValidationError, createCombinedSignal, createTimeoutSignal, deterministicHashFn, extraOptionDefaults, fallBackRouteSchemaKey, getBody, getCurrentRouteSchemaKeyAndMainInitURL, getFetchImpl, getFullAndNormalizedURL, getHeaders, getMethod, handleConfigValidation, handleSchemaValidation, isArray, isBoolean, isFunction, isHTTPErrorInstance, isObject, isPlainObject, isReadableStream, isString, isValidationErrorInstance, splitBaseConfig, splitConfig, waitFor } from "./common-B2rPuIEQ.js";
|
2
2
|
|
3
3
|
//#region src/result.ts
|
4
4
|
const getResponseType = (response, parser) => ({
|
@@ -20,14 +20,14 @@ const textTypes = new Set([
|
|
20
20
|
const JSON_REGEX = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
|
21
21
|
const detectResponseType = (response) => {
|
22
22
|
const initContentType = response.headers.get("content-type");
|
23
|
-
if (!initContentType) return extraOptionDefaults
|
23
|
+
if (!initContentType) return extraOptionDefaults.responseType;
|
24
24
|
const contentType = initContentType.split(";")[0] ?? "";
|
25
25
|
if (JSON_REGEX.test(contentType)) return "json";
|
26
26
|
if (textTypes.has(contentType) || contentType.startsWith("text/")) return "text";
|
27
27
|
return "blob";
|
28
28
|
};
|
29
29
|
const resolveResponseData = (response, responseType, parser) => {
|
30
|
-
const selectedParser = parser ?? extraOptionDefaults
|
30
|
+
const selectedParser = parser ?? extraOptionDefaults.responseParser;
|
31
31
|
const selectedResponseType = responseType ?? detectResponseType(response);
|
32
32
|
const RESPONSE_TYPE_LOOKUP = getResponseType(response, selectedParser);
|
33
33
|
if (!Object.hasOwn(RESPONSE_TYPE_LOOKUP, selectedResponseType)) throw new Error(`Invalid response type: ${responseType}`);
|
@@ -265,19 +265,20 @@ const toStreamableResponse = async (context) => {
|
|
265
265
|
//#region src/dedupe.ts
|
266
266
|
const createDedupeStrategy = async (context) => {
|
267
267
|
const { $GlobalRequestInfoCache: $GlobalRequestInfoCache$1, $LocalRequestInfoCache, baseConfig, config, newFetchController, options: globalOptions, request: globalRequest } = context;
|
268
|
-
const dedupeStrategy = globalOptions.dedupeStrategy ?? extraOptionDefaults
|
268
|
+
const dedupeStrategy = globalOptions.dedupeStrategy ?? globalOptions.dedupe?.strategy ?? extraOptionDefaults.dedupeStrategy;
|
269
269
|
const resolvedDedupeStrategy = isFunction(dedupeStrategy) ? dedupeStrategy(context) : dedupeStrategy;
|
270
270
|
const getDedupeKey = () => {
|
271
271
|
if (!(resolvedDedupeStrategy === "cancel" || resolvedDedupeStrategy === "defer")) return null;
|
272
|
-
|
272
|
+
const dedupeKey$1 = globalOptions.dedupeKey ?? globalOptions.dedupe?.key;
|
273
|
+
if (dedupeKey$1) return isFunction(dedupeKey$1) ? dedupeKey$1(context) : dedupeKey$1;
|
273
274
|
return `${globalOptions.fullURL}-${deterministicHashFn({
|
274
275
|
options: globalOptions,
|
275
276
|
request: globalRequest
|
276
277
|
})}`;
|
277
278
|
};
|
278
279
|
const dedupeKey = getDedupeKey();
|
279
|
-
const dedupeCacheScope = globalOptions.dedupeCacheScope ?? extraOptionDefaults
|
280
|
-
const dedupeCacheScopeKey = globalOptions.dedupeCacheScopeKey ?? extraOptionDefaults
|
280
|
+
const dedupeCacheScope = globalOptions.dedupeCacheScope ?? globalOptions.dedupe?.cacheScope ?? extraOptionDefaults.dedupeCacheScope;
|
281
|
+
const dedupeCacheScopeKey = globalOptions.dedupeCacheScopeKey ?? globalOptions.dedupe?.cacheScopeKey ?? extraOptionDefaults.dedupeCacheScopeKey;
|
281
282
|
if (dedupeCacheScope === "global" && !$GlobalRequestInfoCache$1.has(dedupeCacheScopeKey)) $GlobalRequestInfoCache$1.set(dedupeCacheScopeKey, /* @__PURE__ */ new Map());
|
282
283
|
const $RequestInfoCache = dedupeCacheScope === "global" ? $GlobalRequestInfoCache$1.get(dedupeCacheScopeKey) : $LocalRequestInfoCache;
|
283
284
|
const $RequestInfoCacheOrNull = dedupeKey !== null ? $RequestInfoCache : null;
|
@@ -288,8 +289,8 @@ const createDedupeStrategy = async (context) => {
|
|
288
289
|
if (dedupeKey !== null) await waitFor(.1);
|
289
290
|
const prevRequestInfo = $RequestInfoCacheOrNull?.get(dedupeKey);
|
290
291
|
const getAbortErrorMessage = () => {
|
291
|
-
if (globalOptions.dedupeKey) return `Duplicate request detected - Aborted previous request with key '${dedupeKey}'
|
292
|
-
return `Duplicate request
|
292
|
+
if (globalOptions.dedupeKey) return `Duplicate request detected - Aborted previous request with key '${dedupeKey}'`;
|
293
|
+
return `Duplicate request aborted - Aborted previous request to '${globalOptions.fullURL}'`;
|
293
294
|
};
|
294
295
|
const handleRequestCancelStrategy = () => {
|
295
296
|
if (!(prevRequestInfo && resolvedDedupeStrategy === "cancel")) return;
|
@@ -460,7 +461,7 @@ const setupHooksAndMiddlewares = (context) => {
|
|
460
461
|
if (hookRegistry.size === 0) continue;
|
461
462
|
const flattenedHookArray = [...hookRegistry].flat();
|
462
463
|
if (flattenedHookArray.length === 0) continue;
|
463
|
-
resolvedHooks[hookName] = composeAllHooks(flattenedHookArray, options.hooksExecutionMode ?? extraOptionDefaults
|
464
|
+
resolvedHooks[hookName] = composeAllHooks(flattenedHookArray, options.hooksExecutionMode ?? extraOptionDefaults.hooksExecutionMode);
|
464
465
|
}
|
465
466
|
return resolvedHooks;
|
466
467
|
};
|
@@ -488,19 +489,19 @@ const setupHooksAndMiddlewares = (context) => {
|
|
488
489
|
//#region src/retry.ts
|
489
490
|
const getLinearDelay = (currentAttemptCount, options) => {
|
490
491
|
const retryDelay = options.retryDelay ?? options.retry?.delay;
|
491
|
-
return (isFunction(retryDelay) ? retryDelay(currentAttemptCount) : retryDelay) ?? extraOptionDefaults
|
492
|
+
return (isFunction(retryDelay) ? retryDelay(currentAttemptCount) : retryDelay) ?? extraOptionDefaults.retryDelay;
|
492
493
|
};
|
493
494
|
const getExponentialDelay = (currentAttemptCount, options) => {
|
494
|
-
const retryDelay = options.retryDelay ?? options.retry?.delay ?? extraOptionDefaults
|
495
|
+
const retryDelay = options.retryDelay ?? options.retry?.delay ?? extraOptionDefaults.retryDelay;
|
495
496
|
const resolvedRetryDelay = isFunction(retryDelay) ? retryDelay(currentAttemptCount) : retryDelay;
|
496
|
-
const maxDelay = options.retryMaxDelay ?? options.retry?.maxDelay ?? extraOptionDefaults
|
497
|
+
const maxDelay = options.retryMaxDelay ?? options.retry?.maxDelay ?? extraOptionDefaults.retryMaxDelay;
|
497
498
|
const exponentialDelay = resolvedRetryDelay * 2 ** currentAttemptCount;
|
498
499
|
return Math.min(exponentialDelay, maxDelay);
|
499
500
|
};
|
500
501
|
const createRetryStrategy = (ctx) => {
|
501
502
|
const { options, request } = ctx;
|
502
503
|
const currentAttemptCount = options["~retryAttemptCount"] ?? 1;
|
503
|
-
const retryStrategy = options.retryStrategy ?? options.retry?.strategy ?? extraOptionDefaults
|
504
|
+
const retryStrategy = options.retryStrategy ?? options.retry?.strategy ?? extraOptionDefaults.retryStrategy;
|
504
505
|
const getDelay = () => {
|
505
506
|
switch (retryStrategy) {
|
506
507
|
case "exponential": return getExponentialDelay(currentAttemptCount, options);
|
@@ -510,13 +511,13 @@ const createRetryStrategy = (ctx) => {
|
|
510
511
|
};
|
511
512
|
const shouldAttemptRetry = async () => {
|
512
513
|
if (isBoolean(request.signal) && request.signal.aborted) return false;
|
513
|
-
const retryCondition = options.retryCondition ?? options.retry?.condition ?? extraOptionDefaults
|
514
|
-
const maximumRetryAttempts = options.retryAttempts ?? options.retry?.attempts ?? extraOptionDefaults
|
514
|
+
const retryCondition = options.retryCondition ?? options.retry?.condition ?? extraOptionDefaults.retryCondition;
|
515
|
+
const maximumRetryAttempts = options.retryAttempts ?? options.retry?.attempts ?? extraOptionDefaults.retryAttempts;
|
515
516
|
const customRetryCondition = await retryCondition(ctx);
|
516
517
|
if (!(currentAttemptCount <= maximumRetryAttempts && customRetryCondition)) return false;
|
517
|
-
const retryMethods = new Set(options.retryMethods ?? options.retry?.methods ?? extraOptionDefaults
|
518
|
+
const retryMethods = new Set(options.retryMethods ?? options.retry?.methods ?? extraOptionDefaults.retryMethods);
|
518
519
|
const includesMethod = isString(ctx.request.method) && retryMethods.size > 0 ? retryMethods.has(ctx.request.method) : true;
|
519
|
-
const retryStatusCodes = new Set(options.retryStatusCodes ?? options.retry?.statusCodes ?? extraOptionDefaults
|
520
|
+
const retryStatusCodes = new Set(options.retryStatusCodes ?? options.retry?.statusCodes ?? extraOptionDefaults.retryStatusCodes);
|
520
521
|
const includesStatusCodes = ctx.response != null && retryStatusCodes.size > 0 ? retryStatusCodes.has(ctx.response.status) : true;
|
521
522
|
return includesMethod && includesStatusCodes;
|
522
523
|
};
|
@@ -566,7 +567,7 @@ const createFetchClient = (initBaseConfig = {}) => {
|
|
566
567
|
params: resolvedOptions.params,
|
567
568
|
query: resolvedOptions.query
|
568
569
|
});
|
569
|
-
|
570
|
+
const options = {
|
570
571
|
...resolvedOptions,
|
571
572
|
...resolvedHooks,
|
572
573
|
...resolvedMiddlewares,
|
@@ -581,7 +582,7 @@ const createFetchClient = (initBaseConfig = {}) => {
|
|
581
582
|
initURL: resolvedInitURL,
|
582
583
|
method: resolvedRequestOptions.method
|
583
584
|
});
|
584
|
-
|
585
|
+
const request = {
|
585
586
|
...resolvedRequestOptions,
|
586
587
|
method: initMethod,
|
587
588
|
signal: combinedSignal
|
@@ -610,10 +611,7 @@ const createFetchClient = (initBaseConfig = {}) => {
|
|
610
611
|
options,
|
611
612
|
requestOptions: request
|
612
613
|
});
|
613
|
-
if (shouldApplySchemaOutput) options
|
614
|
-
...options,
|
615
|
-
...extraOptionsValidationResult
|
616
|
-
};
|
614
|
+
if (shouldApplySchemaOutput) Object.assign(options, extraOptionsValidationResult);
|
617
615
|
const validMethod = getMethod({
|
618
616
|
initURL: resolvedInitURL,
|
619
617
|
method: shouldApplySchemaOutput ? requestOptionsValidationResult?.method : request.method
|
@@ -628,12 +626,11 @@ const createFetchClient = (initBaseConfig = {}) => {
|
|
628
626
|
body: validBody,
|
629
627
|
headers: shouldApplySchemaOutput ? requestOptionsValidationResult?.headers : resolvedHeaders
|
630
628
|
});
|
631
|
-
request
|
632
|
-
...
|
633
|
-
...
|
634
|
-
...
|
635
|
-
|
636
|
-
};
|
629
|
+
Object.assign(request, {
|
630
|
+
...validBody && { body: validBody },
|
631
|
+
...validHeaders && { headers: validHeaders },
|
632
|
+
...validMethod && { method: validMethod }
|
633
|
+
});
|
637
634
|
await executeHooks(options.onRequestReady?.({
|
638
635
|
baseConfig,
|
639
636
|
config,
|