@zayne-labs/callapi 1.12.0 → 1.12.2
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 +1 -1
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +2 -3
- package/dist/{default-types-BUYTny8V.d.ts → default-types-CLNJkstU.d.ts} +21 -10
- package/dist/{defaults-gB08KAp_.js → defaults-DsWxUrb7.js} +150 -30
- package/dist/defaults-DsWxUrb7.js.map +1 -0
- package/dist/{index-D67wXPS1.d.ts → index-D8lqvO-d.d.ts} +6 -6
- package/dist/index.d.ts +3 -3
- package/dist/index.js +40 -44
- package/dist/index.js.map +1 -1
- package/dist/utils/external/index.d.ts +5 -2
- package/dist/utils/external/index.js +2 -119
- package/package.json +15 -15
- package/dist/defaults-gB08KAp_.js.map +0 -1
- package/dist/guards-D7k3EcVD.js +0 -22
- package/dist/guards-D7k3EcVD.js.map +0 -1
- package/dist/utils/external/index.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ct as DistributiveOmit, E as CallApiResult, Et as Writeable, M as GlobalMeta, O as GetBaseSchemaConfig, S as CallApiContext, St as AnyString, _ as ResponseTypeType, _t as InferSchemaOutput, ct as ThrowOnErrorBoolean, d as GetResponseType, dt as BaseCallApiSchemaRoutes, et as ApplyStrictConfig, f as InferCallApiResult, g as ResponseTypeMap, i as CallApiPlugin, k as GetBaseSchemaRoutes, l as CallApiResultSuccessOrErrorVariant, mt as CallApiSchemaConfig, n as DefaultDataType, nt as GetCurrentRouteSchema, ot as InferInitURL, pt as CallApiSchema, r as DefaultPluginArray, rt as GetCurrentRouteSchemaKey, t as DefaultCallApiContext, tt as ApplyURLBasedConfig, u as CallApiResultSuccessVariant, ut as BaseCallApiSchemaAndConfig, v as ResultModeType, vt as InferSchemaResult, wt as NoInferUnMasked, x as CallApiConfig, y as BaseCallApiConfig } from "./default-types-CLNJkstU.js";
|
|
2
2
|
|
|
3
3
|
//#region src/createFetchClient.d.ts
|
|
4
4
|
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>;
|
|
5
5
|
declare const createFetchClient: <TBaseCallApiContext extends CallApiContext = {
|
|
6
|
+
InferredExtraOptions: unknown;
|
|
6
7
|
Data: DefaultDataType;
|
|
7
8
|
ErrorData: DefaultDataType;
|
|
8
|
-
InferredExtraOptions: unknown;
|
|
9
9
|
ResultMode: ResultModeType;
|
|
10
10
|
Meta: GlobalMeta;
|
|
11
11
|
}, 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, {
|
|
@@ -14,8 +14,8 @@ declare const createFetchClient: <TBaseCallApiContext extends CallApiContext = {
|
|
|
14
14
|
onlyData: NoInferUnMasked<TComputedData>;
|
|
15
15
|
onlyResponse: Response;
|
|
16
16
|
withoutResponse: {
|
|
17
|
-
error: null;
|
|
18
17
|
data: NoInferUnMasked<TComputedData>;
|
|
18
|
+
error: null;
|
|
19
19
|
};
|
|
20
20
|
}, {
|
|
21
21
|
all: TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>;
|
|
@@ -25,9 +25,9 @@ declare const createFetchClient: <TBaseCallApiContext extends CallApiContext = {
|
|
|
25
25
|
withoutResponse: DistributiveOmit<TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>, "response"> extends infer T ? { [Key in keyof T]: T[Key] } : never;
|
|
26
26
|
}>>(initURL: TInitURL, initConfig?: CallApiConfig<TCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBasePluginArray, TPluginArray>) => Promise<TComputedResult>;
|
|
27
27
|
declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode extends ResultModeType = ResultModeType, TCallApiContext extends CallApiContext = {
|
|
28
|
+
InferredExtraOptions: unknown;
|
|
28
29
|
Data: DefaultDataType;
|
|
29
30
|
ErrorData: DefaultDataType;
|
|
30
|
-
InferredExtraOptions: unknown;
|
|
31
31
|
ResultMode: ResultModeType;
|
|
32
32
|
Meta: GlobalMeta;
|
|
33
33
|
}, 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<{
|
|
@@ -68,8 +68,8 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
|
|
|
68
68
|
onlyData: NoInferUnMasked<TComputedData>;
|
|
69
69
|
onlyResponse: Response;
|
|
70
70
|
withoutResponse: {
|
|
71
|
-
error: null;
|
|
72
71
|
data: NoInferUnMasked<TComputedData>;
|
|
72
|
+
error: null;
|
|
73
73
|
};
|
|
74
74
|
}, {
|
|
75
75
|
all: TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>;
|
|
@@ -88,4 +88,4 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
|
|
|
88
88
|
}, TSchema, CallApiSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, DefaultPluginArray, TPluginArray>) => Promise<TComputedResult>;
|
|
89
89
|
//#endregion
|
|
90
90
|
export { createFetchClient as n, createFetchClientWithContext as r, callApi as t };
|
|
91
|
-
//# sourceMappingURL=index-
|
|
91
|
+
//# sourceMappingURL=index-D8lqvO-d.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as GetCallApiContext, B as DedupeOptions, C as CallApiExtraOptions, D as CallApiResultLoose, G as HooksOrHooksArray, H as CallApiRequestOptionsForHooks, J as ResponseContext, K as RequestContext, L as FetchImpl, N as InstanceContext, P as Register, Q as
|
|
2
|
-
import { n as createFetchClient, r as createFetchClientWithContext, t as callApi } from "./index-
|
|
3
|
-
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, InferAllMainRoutes, 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 };
|
|
1
|
+
import { $ as RetryOptions, A as GetCallApiContext, B as DedupeOptions, C as CallApiExtraOptions, D as CallApiResultLoose, G as HooksOrHooksArray, H as CallApiRequestOptionsForHooks, J as ResponseContext, K as RequestContext, L as FetchImpl, N as InstanceContext, P as Register, Q as RefetchOptions, R as FetchMiddlewareContext, T as CallApiRequestOptions, U as ErrorContext, V as CallApiExtraOptionsForHooks, W as Hooks, X as ResponseStreamContext, Y as ResponseErrorContext, Z as SuccessContext, _ as ResponseTypeType, _t as InferSchemaOutput, a as PluginHooks, at as InferAllMainRoutes, b as BaseCallApiExtraOptions, c as CallApiResultErrorVariant, dt as BaseCallApiSchemaRoutes, ft as BaseSchemaRouteKeyPrefixes, gt as InferSchemaInput, h as PossibleValidationError, i as CallApiPlugin, it as InferAllMainRouteKeys, j as GetCallApiContextRequired, l as CallApiResultSuccessOrErrorVariant, lt as URLOptions, m as PossibleJavaScriptError, mt as CallApiSchemaConfig, o as PluginMiddlewares, ot as InferInitURL, p as PossibleHTTPError, pt as CallApiSchema, q as RequestStreamContext, rt as GetCurrentRouteSchemaKey, s as PluginSetupContext, st as InferParamsFromRoute, t as DefaultCallApiContext, u as CallApiResultSuccessVariant, v as ResultModeType, w as CallApiParameters, x as CallApiConfig, y as BaseCallApiConfig, z as Middlewares } from "./default-types-CLNJkstU.js";
|
|
2
|
+
import { n as createFetchClient, r as createFetchClientWithContext, t as callApi } from "./index-D8lqvO-d.js";
|
|
3
|
+
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, InferAllMainRoutes, InferInitURL, InferParamsFromRoute, InferSchemaInput, InferSchemaOutput, InstanceContext, Middlewares, PluginHooks, PluginMiddlewares, PluginSetupContext, PossibleHTTPError, PossibleJavaScriptError, PossibleValidationError, RefetchOptions, Register, RequestContext, RequestStreamContext, ResponseContext, ResponseErrorContext, ResponseStreamContext, ResponseTypeType, ResultModeType, RetryOptions, SuccessContext, URLOptions, callApi, createFetchClient, createFetchClientWithContext };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as isValidationErrorInstance, n as isHTTPErrorInstance } from "./guards-D7k3EcVD.js";
|
|
3
|
-
|
|
1
|
+
import { A as getFullAndNormalizedURL, B as isFunction, H as isString, M as handleConfigValidation, N as handleSchemaValidation, P as HTTPError, R as isArray, V as isReadableStream, a as getBody, c as getMethod, d as splitBaseConfig, f as splitConfig, g as isHTTPErrorInstance, i as createTimeoutSignal, j as getCurrentRouteSchemaKeyAndMainInitURL, l as getResolvedHeaders, o as getFetchImpl, p as waitFor, r as createCombinedSignal, s as getHeaders, t as extraOptionDefaults, u as omitKeys, y as isValidationErrorInstance, z as isBoolean } from "./defaults-DsWxUrb7.js";
|
|
4
2
|
//#region src/result.ts
|
|
5
3
|
const getResponseType = (response, responseParser) => ({
|
|
6
4
|
arrayBuffer: () => response.arrayBuffer(),
|
|
@@ -109,7 +107,6 @@ const getCustomizedErrorResult = (errorResult, customErrorInfo) => {
|
|
|
109
107
|
}
|
|
110
108
|
};
|
|
111
109
|
};
|
|
112
|
-
|
|
113
110
|
//#endregion
|
|
114
111
|
//#region src/hooks.ts
|
|
115
112
|
const getHookRegistriesAndKeys = () => {
|
|
@@ -159,7 +156,6 @@ const executeHooksInCatchBlock = async (hookResultsOrPromise, hookInfo) => {
|
|
|
159
156
|
return errorResult;
|
|
160
157
|
}
|
|
161
158
|
};
|
|
162
|
-
|
|
163
159
|
//#endregion
|
|
164
160
|
//#region src/stream.ts
|
|
165
161
|
const createProgressEvent = (options) => {
|
|
@@ -263,7 +259,6 @@ const toStreamableResponse = (context) => {
|
|
|
263
259
|
} });
|
|
264
260
|
return new Response(stream, response);
|
|
265
261
|
};
|
|
266
|
-
|
|
267
262
|
//#endregion
|
|
268
263
|
//#region src/dedupe.ts
|
|
269
264
|
const createDedupeStrategy = async (context) => {
|
|
@@ -284,8 +279,7 @@ const createDedupeStrategy = async (context) => {
|
|
|
284
279
|
if (!dedupeKey) return;
|
|
285
280
|
const dedupeCacheScope = globalOptions.dedupeCacheScope ?? extraOptionDefaults.dedupeCacheScope;
|
|
286
281
|
const dedupeCacheScopeKey = getDedupeCacheScopeKey();
|
|
287
|
-
|
|
288
|
-
const $RequestInfoCache = dedupeCacheScope === "global" ? $GlobalRequestInfoCache.get(dedupeCacheScopeKey) : $LocalRequestInfoCache;
|
|
282
|
+
const $RequestInfoCache = dedupeCacheScope === "global" ? $GlobalRequestInfoCache.get(dedupeCacheScopeKey) ?? $GlobalRequestInfoCache.set(dedupeCacheScopeKey, /* @__PURE__ */ new Map()).get(dedupeCacheScopeKey) : $LocalRequestInfoCache;
|
|
289
283
|
return {
|
|
290
284
|
delete: () => $RequestInfoCache?.delete(dedupeKey),
|
|
291
285
|
get: () => $RequestInfoCache?.get(dedupeKey),
|
|
@@ -317,7 +311,7 @@ const createDedupeStrategy = async (context) => {
|
|
|
317
311
|
* simultaneously (same problem as microtasks). Any non-zero value (even 0.0000000001) forces
|
|
318
312
|
* proper sequential task queue scheduling, ensuring each request gets its own task slot.
|
|
319
313
|
*/
|
|
320
|
-
if (dedupeKey !== null) await waitFor(.
|
|
314
|
+
if (dedupeKey !== null) await waitFor(.01);
|
|
321
315
|
const prevRequestInfo = $RequestInfoCache?.get();
|
|
322
316
|
const getAbortErrorMessage = () => {
|
|
323
317
|
if (globalOptions.dedupeKey) return `Duplicate request detected - Aborted previous request with key '${dedupeKey}'`;
|
|
@@ -360,7 +354,6 @@ const createDedupeStrategy = async (context) => {
|
|
|
360
354
|
resolvedDedupeStrategy
|
|
361
355
|
};
|
|
362
356
|
};
|
|
363
|
-
|
|
364
357
|
//#endregion
|
|
365
358
|
//#region src/middlewares.ts
|
|
366
359
|
const getMiddlewareRegistriesAndKeys = () => {
|
|
@@ -389,7 +382,6 @@ const composeMiddlewaresFromArray = (middlewareArray) => {
|
|
|
389
382
|
}
|
|
390
383
|
return composedMiddleware;
|
|
391
384
|
};
|
|
392
|
-
|
|
393
385
|
//#endregion
|
|
394
386
|
//#region src/plugins.ts
|
|
395
387
|
const getResolvedPlugins = (context) => {
|
|
@@ -397,30 +389,16 @@ const getResolvedPlugins = (context) => {
|
|
|
397
389
|
return isFunction(options.plugins) ? options.plugins({ basePlugins: baseConfig.plugins ?? [] }) : options.plugins ?? [];
|
|
398
390
|
};
|
|
399
391
|
const initializePlugins = async (setupContext) => {
|
|
400
|
-
const { baseConfig, config,
|
|
392
|
+
const { baseConfig, config, currentRouteSchemaKey, mainInitURL, options, request } = setupContext;
|
|
401
393
|
const { addMainHooks, addMainMiddlewares, addPluginHooks, addPluginMiddlewares, getResolvedHooks, getResolvedMiddlewares } = setupHooksAndMiddlewares({
|
|
402
394
|
baseConfig,
|
|
403
395
|
config,
|
|
404
396
|
options
|
|
405
397
|
});
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
extraOptions: config,
|
|
409
|
-
initURL
|
|
410
|
-
});
|
|
411
|
-
let resolvedCurrentRouteSchemaKey = initURLResult.currentRouteSchemaKey;
|
|
412
|
-
let resolvedInitURL = initURLResult.mainInitURL;
|
|
398
|
+
let resolvedCurrentRouteSchemaKey = currentRouteSchemaKey;
|
|
399
|
+
let resolvedInitURL = mainInitURL;
|
|
413
400
|
const resolvedOptions = options;
|
|
414
|
-
const resolvedRequest =
|
|
415
|
-
headers: getResolvedHeaders({
|
|
416
|
-
baseHeaders: baseConfig.headers,
|
|
417
|
-
headers: config.headers
|
|
418
|
-
}),
|
|
419
|
-
method: getMethod({
|
|
420
|
-
initURL: resolvedInitURL,
|
|
421
|
-
method: request.method
|
|
422
|
-
})
|
|
423
|
-
});
|
|
401
|
+
const resolvedRequest = request;
|
|
424
402
|
const executePluginSetupFn = async (pluginSetup) => {
|
|
425
403
|
if (!pluginSetup) return;
|
|
426
404
|
const initResult = await pluginSetup(setupContext);
|
|
@@ -435,7 +413,7 @@ const initializePlugins = async (setupContext) => {
|
|
|
435
413
|
resolvedCurrentRouteSchemaKey = newURLResult.currentRouteSchemaKey;
|
|
436
414
|
resolvedInitURL = newURLResult.mainInitURL;
|
|
437
415
|
}
|
|
438
|
-
if (initResult.request) Object.assign(resolvedRequest, initResult.request);
|
|
416
|
+
if (initResult.request) Object.assign(resolvedRequest, initResult.request, initResult.request.extraFetchOptions);
|
|
439
417
|
if (initResult.options) Object.assign(resolvedOptions, initResult.options);
|
|
440
418
|
};
|
|
441
419
|
const resolvedPlugins = getResolvedPlugins({
|
|
@@ -527,18 +505,17 @@ const setupHooksAndMiddlewares = (context) => {
|
|
|
527
505
|
getResolvedMiddlewares
|
|
528
506
|
};
|
|
529
507
|
};
|
|
530
|
-
|
|
531
508
|
//#endregion
|
|
532
509
|
//#region src/refetch.ts
|
|
533
510
|
const createRefetchManager = (ctx) => {
|
|
534
511
|
const { callApi, callApiArgs, options } = ctx;
|
|
535
512
|
const currentRefetchCount = options["~refetchCount"] ?? 1;
|
|
536
|
-
const refetch = (refetchOptionOverrides) => {
|
|
513
|
+
const refetch = async (refetchOptionOverrides) => {
|
|
537
514
|
const maxRefetchAttempts = refetchOptionOverrides?.refetchAttempts ?? options.refetchAttempts ?? extraOptionDefaults.refetchAttempts;
|
|
538
515
|
if (!(currentRefetchCount <= maxRefetchAttempts)) {
|
|
539
516
|
const message = `Maximum refetch attempts (${maxRefetchAttempts}) exceeded. This prevents infinite loops. Increase 'maxRefetchAttempts' if needed.`;
|
|
540
517
|
console.error(message);
|
|
541
|
-
return
|
|
518
|
+
return null;
|
|
542
519
|
}
|
|
543
520
|
const updatedConfig = {
|
|
544
521
|
...callApiArgs.config,
|
|
@@ -549,7 +526,6 @@ const createRefetchManager = (ctx) => {
|
|
|
549
526
|
};
|
|
550
527
|
return { refetch };
|
|
551
528
|
};
|
|
552
|
-
|
|
553
529
|
//#endregion
|
|
554
530
|
//#region src/retry.ts
|
|
555
531
|
const getLinearDelay = (currentAttemptCount, options) => {
|
|
@@ -608,7 +584,6 @@ const createRetryManager = (ctx) => {
|
|
|
608
584
|
};
|
|
609
585
|
return { handleRetryOrGetErrorResult };
|
|
610
586
|
};
|
|
611
|
-
|
|
612
587
|
//#endregion
|
|
613
588
|
//#region src/createFetchClient.ts
|
|
614
589
|
const $GlobalRequestInfoCache = /* @__PURE__ */ new Map();
|
|
@@ -632,14 +607,31 @@ const createFetchClientWithContext = () => {
|
|
|
632
607
|
};
|
|
633
608
|
const mergedRequestOptions = {
|
|
634
609
|
...baseFetchOptions,
|
|
635
|
-
|
|
610
|
+
...baseFetchOptions.extraFetchOptions,
|
|
611
|
+
...!shouldSkipAutoMergeForRequest && fetchOptions,
|
|
612
|
+
...!shouldSkipAutoMergeForRequest && fetchOptions.extraFetchOptions
|
|
636
613
|
};
|
|
614
|
+
const initURLResult = getCurrentRouteSchemaKeyAndMainInitURL({
|
|
615
|
+
baseExtraOptions: baseConfig,
|
|
616
|
+
extraOptions: config,
|
|
617
|
+
initURL: initURL.toString()
|
|
618
|
+
});
|
|
637
619
|
const { resolvedCurrentRouteSchemaKey, resolvedHooks, resolvedInitURL, resolvedMiddlewares, resolvedOptions, resolvedRequest } = await initializePlugins({
|
|
638
620
|
baseConfig,
|
|
639
621
|
config,
|
|
640
|
-
|
|
622
|
+
...initURLResult,
|
|
641
623
|
options: mergedExtraOptions,
|
|
642
|
-
request:
|
|
624
|
+
request: {
|
|
625
|
+
...mergedRequestOptions,
|
|
626
|
+
headers: getResolvedHeaders({
|
|
627
|
+
baseHeaders: baseConfig.headers,
|
|
628
|
+
headers: config.headers
|
|
629
|
+
}),
|
|
630
|
+
method: getMethod({
|
|
631
|
+
initURL: initURLResult.initURL,
|
|
632
|
+
method: mergedRequestOptions.method
|
|
633
|
+
})
|
|
634
|
+
}
|
|
643
635
|
});
|
|
644
636
|
const { fullURL, normalizedInitURL } = getFullAndNormalizedURL({
|
|
645
637
|
baseURL: resolvedOptions.baseURL,
|
|
@@ -647,7 +639,7 @@ const createFetchClientWithContext = () => {
|
|
|
647
639
|
params: resolvedOptions.params,
|
|
648
640
|
query: resolvedOptions.query
|
|
649
641
|
});
|
|
650
|
-
const
|
|
642
|
+
const initOptions = {
|
|
651
643
|
...resolvedOptions,
|
|
652
644
|
...resolvedHooks,
|
|
653
645
|
...resolvedMiddlewares,
|
|
@@ -661,9 +653,12 @@ const createFetchClientWithContext = () => {
|
|
|
661
653
|
config,
|
|
662
654
|
initURL
|
|
663
655
|
},
|
|
664
|
-
options
|
|
656
|
+
options: initOptions
|
|
665
657
|
});
|
|
666
|
-
options
|
|
658
|
+
const options = {
|
|
659
|
+
...initOptions,
|
|
660
|
+
refetch
|
|
661
|
+
};
|
|
667
662
|
const newFetchController = new AbortController();
|
|
668
663
|
const combinedSignal = createCombinedSignal(createTimeoutSignal(options.timeout), resolvedRequest.signal, newFetchController.signal);
|
|
669
664
|
const request = {
|
|
@@ -695,7 +690,7 @@ const createFetchClientWithContext = () => {
|
|
|
695
690
|
request
|
|
696
691
|
});
|
|
697
692
|
Object.assign(options, extraOptionsValidationResult);
|
|
698
|
-
|
|
693
|
+
const modifiedRequestOptionsValidationResult = {
|
|
699
694
|
body: getBody({
|
|
700
695
|
body: requestOptionsValidationResult.body,
|
|
701
696
|
bodySerializer: options.bodySerializer,
|
|
@@ -710,7 +705,8 @@ const createFetchClientWithContext = () => {
|
|
|
710
705
|
initURL: resolvedInitURL,
|
|
711
706
|
method: requestOptionsValidationResult.method
|
|
712
707
|
})
|
|
713
|
-
}
|
|
708
|
+
};
|
|
709
|
+
Object.assign(request, modifiedRequestOptionsValidationResult);
|
|
714
710
|
const readyRequestContext = {
|
|
715
711
|
baseConfig,
|
|
716
712
|
config,
|
|
@@ -835,7 +831,7 @@ const createFetchClientWithContext = () => {
|
|
|
835
831
|
};
|
|
836
832
|
const createFetchClient = createFetchClientWithContext();
|
|
837
833
|
const callApi = createFetchClient();
|
|
838
|
-
|
|
839
834
|
//#endregion
|
|
840
835
|
export { callApi, createFetchClient, createFetchClientWithContext };
|
|
836
|
+
|
|
841
837
|
//# sourceMappingURL=index.js.map
|