@zayne-labs/callapi 1.6.15 → 1.6.16

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.
@@ -115,23 +115,75 @@ interface CallApiValidators<TData = unknown, TErrorData = unknown> {
115
115
  }
116
116
  type InferSchemaResult<TSchema, TData> = TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TData;
117
117
 
118
- type Params = UnmaskType<Record<string, boolean | number | string> | Array<boolean | number | string>>;
119
- type Query = UnmaskType<Record<string, boolean | number | string>>;
120
- type InitURL = UnmaskType<string | URL>;
121
- interface UrlOptions<TSchemas extends CallApiSchemas> {
118
+ /**
119
+ * @description Makes a type required if TSchema type is undefined or if the output type of TSchema contains undefined, otherwise keeps it as is
120
+ */
121
+ type MakeSchemaOptionRequired<TSchema extends StandardSchemaV1 | undefined, TObject> = undefined extends TSchema ? TObject : undefined extends InferSchemaResult<TSchema, NonNullable<unknown>> ? TObject : Required<TObject>;
122
+ type JsonPrimitive = boolean | number | string | null | undefined;
123
+ type SerializableObject = Record<keyof object, unknown>;
124
+ type SerializableArray = Array<JsonPrimitive | SerializableArray | SerializableObject> | ReadonlyArray<JsonPrimitive | SerializableArray | SerializableObject>;
125
+ type Body = UnmaskType<RequestInit["body"] | SerializableArray | SerializableObject>;
126
+ type BodyOption<TSchemas extends CallApiSchemas> = MakeSchemaOptionRequired<TSchemas["body"], {
122
127
  /**
123
- * URL to be used in the request.
128
+ * Body of the request, can be a object or any other supported body type.
124
129
  */
125
- readonly initURL?: string;
130
+ body?: InferSchemaResult<TSchemas["body"], Body>;
131
+ }>;
132
+ type Method = UnmaskType<"CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" | AnyString>;
133
+ type MethodOption<TSchemas extends CallApiSchemas> = MakeSchemaOptionRequired<TSchemas["method"], {
126
134
  /**
127
- * Parameters to be appended to the URL (i.e: /:id)
135
+ * HTTP method for the request.
136
+ * @default "GET"
128
137
  */
129
- params?: InferSchemaResult<TSchemas["params"], Params>;
138
+ method?: InferSchemaResult<TSchemas["method"], Method>;
139
+ }>;
140
+ type Headers = UnmaskType<Record<"Authorization", CommonAuthorizationHeaders> | Record<"Content-Type", CommonContentTypes> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | RequestInit["headers"]>;
141
+ type HeadersOption<TSchemas extends CallApiSchemas> = MakeSchemaOptionRequired<TSchemas["headers"], {
130
142
  /**
131
- * Query parameters to append to the URL.
143
+ * Headers to be used in the request.
132
144
  */
133
- query?: InferSchemaResult<TSchemas["query"], Query>;
145
+ headers?: InferSchemaResult<TSchemas["headers"], Headers>;
146
+ }>;
147
+ interface Register {
134
148
  }
149
+ type GlobalMeta = Register extends {
150
+ meta?: infer TMeta extends Record<string, unknown>;
151
+ } ? TMeta : never;
152
+ type MetaOption<TSchemas extends CallApiSchemas> = {
153
+ /**
154
+ * - An optional field you can fill with additional information,
155
+ * to associate with the request, typically used for logging or tracing.
156
+ *
157
+ * - A good use case for this, would be to use the info to handle specific cases in any of the shared interceptors.
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * const callMainApi = callApi.create({
162
+ * baseURL: "https://main-api.com",
163
+ * onResponseError: ({ response, options }) => {
164
+ * if (options.meta?.userId) {
165
+ * console.error(`User ${options.meta.userId} made an error`);
166
+ * }
167
+ * },
168
+ * });
169
+ *
170
+ * const response = await callMainApi({
171
+ * url: "https://example.com/api/data",
172
+ * meta: { userId: "123" },
173
+ * });
174
+ * ```
175
+ */
176
+ meta?: InferSchemaResult<TSchemas["meta"], GlobalMeta>;
177
+ };
178
+ type ResultModeOption<TErrorData, TResultMode extends ResultModeUnion> = TErrorData extends false ? {
179
+ resultMode: "onlySuccessWithException";
180
+ } : TErrorData extends false | undefined ? {
181
+ resultMode?: "onlySuccessWithException";
182
+ } : undefined extends TResultMode ? {
183
+ resultMode?: TResultMode;
184
+ } : {
185
+ resultMode: TResultMode;
186
+ };
135
187
 
136
188
  type RetryCondition<TErrorData> = (context: ErrorContext<TErrorData>) => boolean | Promise<boolean>;
137
189
  interface RetryOptions<TErrorData> {
@@ -201,6 +253,8 @@ type UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) =>
201
253
  type InferSchema<TResult> = TResult extends StandardSchemaV1 ? InferSchemaResult<TResult, NonNullable<unknown>> : TResult;
202
254
  type InferPluginOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<InferSchema<ReturnType<NonNullable<TPluginArray[number]["createExtraOptions"]>>>>;
203
255
  type PluginInitContext<TMoreOptions = DefaultMoreOptions> = WithMoreOptions<TMoreOptions> & {
256
+ baseConfig: BaseCallApiExtraOptions & CallApiRequestOptions;
257
+ config: CallApiExtraOptions & CallApiRequestOptions;
204
258
  initURL: InitURL | undefined;
205
259
  options: CombinedCallApiExtraOptions;
206
260
  request: CallApiRequestOptionsForHooks;
@@ -239,79 +293,12 @@ interface CallApiPlugin<TData = never, TErrorData = never> {
239
293
  version?: string;
240
294
  }
241
295
  declare const definePlugin: <TPlugin extends CallApiPlugin | AnyFunction<CallApiPlugin>>(plugin: TPlugin) => TPlugin;
242
- type Plugins<TPluginArray extends CallApiPlugin[]> = TPluginArray | ((context: PluginInitContext) => TPluginArray);
296
+ type Plugins<TPluginArray extends CallApiPlugin[]> = TPluginArray;
243
297
 
244
298
  declare const fetchSpecificKeys: ("body" | "cache" | "credentials" | "headers" | "integrity" | "keepalive" | "method" | "mode" | "priority" | "redirect" | "referrer" | "referrerPolicy" | "signal" | "window")[];
245
299
  declare const defaultRetryMethods: ("GET" | "POST")[];
246
300
  declare const defaultRetryStatusCodes: Required<BaseCallApiExtraOptions>["retryStatusCodes"];
247
301
 
248
- /**
249
- * @description Makes a type required if TSchema type is undefined or if the output type of TSchema contains undefined, otherwise keeps it as is
250
- */
251
- type MakeSchemaOptionRequired<TSchema extends StandardSchemaV1 | undefined, TObject> = undefined extends TSchema ? TObject : undefined extends InferSchemaResult<TSchema, NonNullable<unknown>> ? TObject : Required<TObject>;
252
- type Body = UnmaskType<Record<string, unknown> | RequestInit["body"]>;
253
- type BodyOption<TSchemas extends CallApiSchemas> = MakeSchemaOptionRequired<TSchemas["body"], {
254
- /**
255
- * Body of the request, can be a object or any other supported body type.
256
- */
257
- body?: InferSchemaResult<TSchemas["body"], Body>;
258
- }>;
259
- type Method = UnmaskType<"CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" | AnyString>;
260
- type MethodOption<TSchemas extends CallApiSchemas> = MakeSchemaOptionRequired<TSchemas["method"], {
261
- /**
262
- * HTTP method for the request.
263
- * @default "GET"
264
- */
265
- method?: InferSchemaResult<TSchemas["method"], Method>;
266
- }>;
267
- type Headers = UnmaskType<Record<"Authorization", CommonAuthorizationHeaders> | Record<"Content-Type", CommonContentTypes> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | RequestInit["headers"]>;
268
- type HeadersOption<TSchemas extends CallApiSchemas> = MakeSchemaOptionRequired<TSchemas["headers"], {
269
- /**
270
- * Headers to be used in the request.
271
- */
272
- headers?: InferSchemaResult<TSchemas["headers"], Headers>;
273
- }>;
274
- interface Register {
275
- }
276
- type GlobalMeta = Register extends {
277
- meta?: infer TMeta extends Record<string, unknown>;
278
- } ? TMeta : never;
279
- type MetaOption<TSchemas extends CallApiSchemas> = {
280
- /**
281
- * - An optional field you can fill with additional information,
282
- * to associate with the request, typically used for logging or tracing.
283
- *
284
- * - A good use case for this, would be to use the info to handle specific cases in any of the shared interceptors.
285
- *
286
- * @example
287
- * ```ts
288
- * const callMainApi = callApi.create({
289
- * baseURL: "https://main-api.com",
290
- * onResponseError: ({ response, options }) => {
291
- * if (options.meta?.userId) {
292
- * console.error(`User ${options.meta.userId} made an error`);
293
- * }
294
- * },
295
- * });
296
- *
297
- * const response = await callMainApi({
298
- * url: "https://example.com/api/data",
299
- * meta: { userId: "123" },
300
- * });
301
- * ```
302
- */
303
- meta?: InferSchemaResult<TSchemas["meta"], GlobalMeta>;
304
- };
305
- type ResultModeOption<TErrorData, TResultMode extends ResultModeUnion> = TErrorData extends false ? {
306
- resultMode: "onlySuccessWithException";
307
- } : TErrorData extends false | undefined ? {
308
- resultMode?: "onlySuccessWithException";
309
- } : undefined extends TResultMode ? {
310
- resultMode?: TResultMode;
311
- } : {
312
- resultMode: TResultMode;
313
- };
314
-
315
302
  type FetchSpecificKeysUnion = Exclude<(typeof fetchSpecificKeys)[number], "body" | "headers" | "method">;
316
303
  type CallApiRequestOptions<TSchemas extends CallApiSchemas = DefaultMoreOptions> = BodyOption<TSchemas> & HeadersOption<TSchemas> & MethodOption<TSchemas> & Pick<RequestInit, FetchSpecificKeysUnion>;
317
304
  type CallApiRequestOptionsForHooks<TSchemas extends CallApiSchemas = DefaultMoreOptions> = Omit<CallApiRequestOptions<TSchemas>, "headers"> & {
@@ -451,7 +438,7 @@ type ExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResult
451
438
  validators?: CallApiValidators<TData, TErrorData>;
452
439
  } & InterceptorsOrInterceptorArray<TData, TErrorData> & Partial<InferPluginOptions<TPluginArray>> & MetaOption<TSchemas> & RetryOptions<TErrorData> & ResultModeOption<TErrorData, TResultMode> & UrlOptions<TSchemas>;
453
440
  declare const optionsEnumToExtendFromBase: ("plugins" | "schemas" | "validators")[];
454
- type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TSchemas extends CallApiSchemas = DefaultMoreOptions> = CallApiRequestOptions<TSchemas> & ExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas> & {
441
+ type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TSchemas extends CallApiSchemas = DefaultMoreOptions> = ExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas> & {
455
442
  /**
456
443
  * Options that should extend the base options.
457
444
  */
@@ -460,9 +447,14 @@ type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType,
460
447
  declare const optionsEnumToOmitFromBase: ("dedupeKey" | "extend")[];
461
448
  type BaseCallApiExtraOptions<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemas extends CallApiSchemas = DefaultMoreOptions> = Omit<Partial<CallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemas>>, (typeof optionsEnumToOmitFromBase)[number]>;
462
449
  type CombinedCallApiExtraOptions = BaseCallApiExtraOptions & CallApiExtraOptions;
450
+ type BaseCallApiConfig<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemas extends CallApiSchemas = DefaultMoreOptions> = (CallApiRequestOptions<TBaseSchemas> & BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemas>) | ((context: {
451
+ initURL: string;
452
+ options: CallApiExtraOptions;
453
+ request: CallApiRequestOptions;
454
+ }) => CallApiRequestOptions<TBaseSchemas> & BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemas>);
463
455
  type CallApiParameters<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TSchemas extends CallApiSchemas = DefaultMoreOptions> = [
464
456
  initURL: InferSchemaResult<TSchemas["initURL"], InitURL>,
465
- config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas>
457
+ config?: CallApiRequestOptions<TSchemas> & CallApiExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas>
466
458
  ];
467
459
  type RequestContext = UnmaskType<{
468
460
  options: CombinedCallApiExtraOptions;
@@ -548,6 +540,24 @@ type ResultModeMap<TData = DefaultDataType, TErrorData = DefaultDataType, TRespo
548
540
  type ResultModeUnion = keyof ResultModeMap | undefined;
549
541
  type GetCallApiResult<TData, TErrorData, TResultMode extends ResultModeUnion, TThrowOnError extends boolean, TResponseType extends ResponseTypeUnion> = TErrorData extends false | undefined ? ResultModeMap<TData, TErrorData, TResponseType>["onlySuccessWithException"] : ResultModeUnion | undefined extends TResultMode ? TThrowOnError extends true ? ResultModeMap<TData, TErrorData, TResponseType>["allWithException"] : ResultModeMap<TData, TErrorData, TResponseType>["all"] : TResultMode extends NonNullable<ResultModeUnion> ? TResultMode extends "onlySuccess" ? ResultModeMap<TData, TErrorData, TResponseType>["onlySuccessWithException"] : TResultMode extends "onlyResponse" ? ResultModeMap<TData, TErrorData, TResponseType>["onlyResponseWithException"] : ResultModeMap<TData, TErrorData, TResponseType>[TResultMode] : never;
550
542
 
543
+ type Params = UnmaskType<Record<string, boolean | number | string> | Array<boolean | number | string>>;
544
+ type Query = UnmaskType<Record<string, boolean | number | string>>;
545
+ type InitURL = UnmaskType<string | URL>;
546
+ interface UrlOptions<TSchemas extends CallApiSchemas> {
547
+ /**
548
+ * URL to be used in the request.
549
+ */
550
+ readonly initURL?: string;
551
+ /**
552
+ * Parameters to be appended to the URL (i.e: /:id)
553
+ */
554
+ params?: InferSchemaResult<TSchemas["params"], Params>;
555
+ /**
556
+ * Query parameters to append to the URL.
557
+ */
558
+ query?: InferSchemaResult<TSchemas["query"], Query>;
559
+ }
560
+
551
561
  type ErrorDetails<TErrorResponse> = {
552
562
  defaultErrorMessage: string;
553
563
  errorData: TErrorResponse;
@@ -564,4 +574,4 @@ declare class HTTPError<TErrorResponse = Record<string, unknown>> extends Error
564
574
  constructor(errorDetails: ErrorDetails<TErrorResponse>, errorOptions?: ErrorOptions);
565
575
  }
566
576
 
567
- export { type BaseCallApiExtraOptions as B, type CallApiPlugin as C, type DefaultPluginArray as D, type ErrorContext as E, type GetCallApiResult as G, HTTPError as H, type InferSchemaResult as I, type PluginInitContext as P, type ResultModeUnion as R, type SuccessContext as S, type ResponseTypeUnion as a, type CallApiSchemas as b, type CallApiExtraOptions as c, type DefaultDataType as d, type DefaultThrowOnError as e, type DefaultMoreOptions as f, type CallApiParameters as g, definePlugin as h, type PossibleJavaScriptError as i, type PossibleHTTPError as j, type CallApiRequestOptions as k, type CallApiRequestOptionsForHooks as l, type CallApiResultErrorVariant as m, type CallApiResultSuccessVariant as n, type CombinedCallApiExtraOptions as o, type Interceptors as p, type InterceptorsOrInterceptorArray as q, type PossibleJavascriptErrorNames as r, type Register as s, type RequestContext as t, type RequestErrorContext as u, type ResponseContext as v, type ResponseErrorContext as w, defaultRetryMethods as x, defaultRetryStatusCodes as y };
577
+ export { type AnyString as A, type BaseCallApiConfig as B, type CallApiPlugin as C, type DefaultPluginArray as D, type ExtraOptions as E, type Interceptors as F, type GetCallApiResult as G, HTTPError as H, type InferSchemaResult as I, type PossibleJavascriptErrorNames as J, type Register as K, type RequestContext as L, type MetaOption as M, type RequestErrorContext as N, type ResponseContext as O, type PossibleJavaScriptError as P, type ResponseErrorContext as Q, type ResultModeUnion as R, type SerializableArray as S, type SuccessContext as T, type UrlOptions as U, defaultRetryMethods as V, defaultRetryStatusCodes as W, type ResponseTypeUnion as a, type CallApiSchemas as b, type SerializableObject as c, type CommonContentTypes as d, type CommonRequestHeaders as e, type Auth as f, type Awaitable as g, type CombinedCallApiExtraOptions as h, type CallApiRequestOptionsForHooks as i, type CallApiValidators as j, type InterceptorsOrInterceptorArray as k, type RetryOptions as l, type ResultModeOption as m, type DefaultDataType as n, type DefaultThrowOnError as o, type DefaultMoreOptions as p, type CallApiParameters as q, definePlugin as r, type PluginInitContext as s, type BaseCallApiExtraOptions as t, type CallApiExtraOptions as u, type PossibleHTTPError as v, type CallApiRequestOptions as w, type CallApiResultErrorVariant as x, type CallApiResultSuccessVariant as y, type ErrorContext as z };
@@ -1,19 +1,118 @@
1
- import { R as ResultModeUnion, a as ResponseTypeUnion, C as CallApiPlugin, D as DefaultPluginArray, b as CallApiSchemas, I as InferSchemaResult, c as CallApiExtraOptions, G as GetCallApiResult, B as BaseCallApiExtraOptions, d as DefaultDataType, e as DefaultThrowOnError, f as DefaultMoreOptions, g as CallApiParameters } from './error-MH9dJCiM.js';
2
- export { k as CallApiRequestOptions, l as CallApiRequestOptionsForHooks, m as CallApiResultErrorVariant, n as CallApiResultSuccessVariant, o as CombinedCallApiExtraOptions, E as ErrorContext, H as HTTPError, p as Interceptors, q as InterceptorsOrInterceptorArray, P as PluginInitContext, j as PossibleHTTPError, i as PossibleJavaScriptError, r as PossibleJavascriptErrorNames, s as Register, t as RequestContext, u as RequestErrorContext, v as ResponseContext, w as ResponseErrorContext, S as SuccessContext, h as definePlugin } from './error-MH9dJCiM.js';
3
- import '@standard-schema/spec';
1
+ import { R as ResultModeUnion, a as ResponseTypeUnion, C as CallApiPlugin, D as DefaultPluginArray, b as CallApiSchemas, I as InferSchemaResult, S as SerializableArray, c as SerializableObject, d as CommonContentTypes, e as CommonRequestHeaders, A as AnyString, f as Auth, g as Awaitable, P as PossibleJavaScriptError, h as CombinedCallApiExtraOptions, i as CallApiRequestOptionsForHooks, j as CallApiValidators, k as InterceptorsOrInterceptorArray, M as MetaOption, l as RetryOptions, m as ResultModeOption, U as UrlOptions, E as ExtraOptions, G as GetCallApiResult, n as DefaultDataType, o as DefaultThrowOnError, p as DefaultMoreOptions, B as BaseCallApiConfig, q as CallApiParameters } from './error-BokQ-iQX.js';
2
+ export { t as BaseCallApiExtraOptions, u as CallApiExtraOptions, w as CallApiRequestOptions, x as CallApiResultErrorVariant, y as CallApiResultSuccessVariant, z as ErrorContext, H as HTTPError, F as Interceptors, s as PluginInitContext, v as PossibleHTTPError, J as PossibleJavascriptErrorNames, K as Register, L as RequestContext, N as RequestErrorContext, O as ResponseContext, Q as ResponseErrorContext, T as SuccessContext, r as definePlugin } from './error-BokQ-iQX.js';
3
+ import * as _standard_schema_spec from '@standard-schema/spec';
4
4
 
5
- declare const createFetchClient: <TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemas extends CallApiSchemas = DefaultMoreOptions>(baseConfig?: BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemas>) => {
6
- <TData = InferSchemaResult<TBaseSchemas["data"], TBaseData>, TErrorData = InferSchemaResult<TBaseSchemas["errorData"], TBaseErrorData>, TResultMode extends ResultModeUnion = TBaseResultMode, TThrowOnError extends boolean = TBaseThrowOnError, TResponseType extends ResponseTypeUnion = TBaseResponseType, TPluginArray extends CallApiPlugin[] = TBasePluginArray, TSchemas extends CallApiSchemas = TBaseSchemas>(initURL: InferSchemaResult<TSchemas["initURL"], string | URL>, config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas> | undefined): Promise<GetCallApiResult<InferSchemaResult<TSchemas["data"], TData>, InferSchemaResult<TSchemas["errorData"], TErrorData>, TResultMode, TThrowOnError, TResponseType>>;
7
- create: <TBaseData = unknown, TBaseErrorData = unknown, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = boolean, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemas extends CallApiSchemas = {}>(baseConfig?: BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemas>) => /*elided*/ any;
8
- };
9
- declare const callApi: {
10
- <TData = unknown, TErrorData = unknown, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = boolean, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TSchemas extends CallApiSchemas = {}>(initURL: InferSchemaResult<TSchemas["initURL"], string | URL>, config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas> | undefined): Promise<GetCallApiResult<InferSchemaResult<TSchemas["data"], TData>, InferSchemaResult<TSchemas["errorData"], TErrorData>, TResultMode, TThrowOnError, TResponseType>>;
11
- create: <TBaseData = unknown, TBaseErrorData = unknown, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = boolean, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemas extends CallApiSchemas = {}>(baseConfig?: BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemas>) => {
12
- <TData = InferSchemaResult<TBaseSchemas["data"], TBaseData>, TErrorData = InferSchemaResult<TBaseSchemas["errorData"], TBaseErrorData>, TResultMode extends ResultModeUnion = TBaseResultMode, TThrowOnError extends boolean = TBaseThrowOnError, TResponseType extends ResponseTypeUnion = TBaseResponseType, TPluginArray extends CallApiPlugin[] = TBasePluginArray, TSchemas extends CallApiSchemas = TBaseSchemas>(initURL: InferSchemaResult<TSchemas["initURL"], string | URL>, config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas> | undefined): Promise<GetCallApiResult<InferSchemaResult<TSchemas["data"], TData>, InferSchemaResult<TSchemas["errorData"], TErrorData>, TResultMode, TThrowOnError, TResponseType>>;
13
- create: /*elided*/ any;
14
- };
15
- };
5
+ declare const createFetchClient: <TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemas extends CallApiSchemas = DefaultMoreOptions>(baseConfig?: BaseCallApiConfig<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemas>) => <TData = InferSchemaResult<TBaseSchemas["data"], TBaseData>, TErrorData = InferSchemaResult<TBaseSchemas["errorData"], TBaseErrorData>, TResultMode extends ResultModeUnion = TBaseResultMode, TThrowOnError extends boolean = TBaseThrowOnError, TResponseType extends ResponseTypeUnion = TBaseResponseType, TPluginArray extends CallApiPlugin[] = TBasePluginArray, TSchemas extends CallApiSchemas = TBaseSchemas>(initURL: InferSchemaResult<TSchemas["initURL"], string | URL>, config?: ((undefined extends TSchemas["body"] ? {
6
+ body?: InferSchemaResult<TSchemas["body"], BodyInit | SerializableArray | SerializableObject | null | undefined> | undefined;
7
+ } : undefined extends InferSchemaResult<TSchemas["body"], {}> ? {
8
+ body?: InferSchemaResult<TSchemas["body"], BodyInit | SerializableArray | SerializableObject | null | undefined> | undefined;
9
+ } : Required<{
10
+ body?: InferSchemaResult<TSchemas["body"], BodyInit | SerializableArray | SerializableObject | null | undefined> | undefined;
11
+ }>) & (undefined extends TSchemas["headers"] ? {
12
+ headers?: InferSchemaResult<TSchemas["headers"], Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}`> | Record<"Content-Type", CommonContentTypes> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | HeadersInit | undefined> | undefined;
13
+ } : undefined extends InferSchemaResult<TSchemas["headers"], {}> ? {
14
+ headers?: InferSchemaResult<TSchemas["headers"], Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}`> | Record<"Content-Type", CommonContentTypes> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | HeadersInit | undefined> | undefined;
15
+ } : Required<{
16
+ headers?: InferSchemaResult<TSchemas["headers"], Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}`> | Record<"Content-Type", CommonContentTypes> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | HeadersInit | undefined> | undefined;
17
+ }>) & (undefined extends TSchemas["method"] ? {
18
+ method?: InferSchemaResult<TSchemas["method"], AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE"> | undefined;
19
+ } : undefined extends InferSchemaResult<TSchemas["method"], {}> ? {
20
+ method?: InferSchemaResult<TSchemas["method"], AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE"> | undefined;
21
+ } : Required<{
22
+ method?: InferSchemaResult<TSchemas["method"], AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE"> | undefined;
23
+ }>) & Pick<RequestInit, "cache" | "credentials" | "integrity" | "keepalive" | "mode" | "priority" | "redirect" | "referrer" | "referrerPolicy" | "signal" | "window"> & {
24
+ auth?: string | Auth | null;
25
+ baseURL?: string;
26
+ bodySerializer?: (bodyData: Record<string, unknown>) => string;
27
+ cloneResponse?: boolean;
28
+ customFetchImpl?: (input: string | Request | URL, init?: RequestInit) => Promise<Response>;
29
+ dedupeKey?: string;
30
+ dedupeStrategy?: "cancel" | "defer" | "none";
31
+ defaultErrorMessage?: string;
32
+ readonly fullURL?: string;
33
+ mergedHooksExecutionMode?: "parallel" | "sequential";
34
+ mergedHooksExecutionOrder?: "mainHooksAfterPlugins" | "mainHooksBeforePlugins";
35
+ plugins?: TPluginArray | undefined;
36
+ responseParser?: (responseString: string) => Awaitable<Record<string, unknown>>;
37
+ responseType?: TResponseType | undefined;
38
+ resultMode?: TResultMode | undefined;
39
+ schemas?: TSchemas | undefined;
40
+ throwOnError?: TThrowOnError | ((context: {
41
+ error: PossibleJavaScriptError;
42
+ options: CombinedCallApiExtraOptions;
43
+ request: CallApiRequestOptionsForHooks;
44
+ response: null;
45
+ } | {
46
+ error: {
47
+ errorData: TErrorData;
48
+ message: string;
49
+ name: "HTTPError";
50
+ };
51
+ options: CombinedCallApiExtraOptions;
52
+ request: CallApiRequestOptionsForHooks;
53
+ response: Response;
54
+ }) => TThrowOnError) | undefined;
55
+ timeout?: number;
56
+ validators?: CallApiValidators<TData, TErrorData> | undefined;
57
+ } & InterceptorsOrInterceptorArray<TData, TErrorData, {}> & Partial<((ReturnType<NonNullable<TPluginArray[number]["createExtraOptions"]>> extends infer T ? T extends ReturnType<NonNullable<TPluginArray[number]["createExtraOptions"]>> ? T extends _standard_schema_spec.StandardSchemaV1<unknown, unknown> ? InferSchemaResult<T, {}> : T : never : never) extends infer T_1 ? T_1 extends (ReturnType<NonNullable<TPluginArray[number]["createExtraOptions"]>> extends infer T_2 ? T_2 extends ReturnType<NonNullable<TPluginArray[number]["createExtraOptions"]>> ? T_2 extends _standard_schema_spec.StandardSchemaV1<unknown, unknown> ? InferSchemaResult<T_2, {}> : T_2 : never : never) ? T_1 extends unknown ? (param: T_1) => void : never : never : never) extends (param: infer TParam) => void ? TParam : never> & MetaOption<TSchemas> & RetryOptions<TErrorData> & ResultModeOption<TErrorData, TResultMode> & UrlOptions<TSchemas> & {
58
+ extend?: Pick<ExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas>, "plugins" | "schemas" | "validators"> | undefined;
59
+ }) | undefined) => Promise<GetCallApiResult<InferSchemaResult<TSchemas["data"], TData>, InferSchemaResult<TSchemas["errorData"], TErrorData>, TResultMode, TThrowOnError, TResponseType>>;
60
+ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = boolean, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TSchemas extends CallApiSchemas = {}>(initURL: InferSchemaResult<TSchemas["initURL"], string | URL>, config?: ((undefined extends TSchemas["body"] ? {
61
+ body?: InferSchemaResult<TSchemas["body"], BodyInit | SerializableArray | SerializableObject | null | undefined> | undefined;
62
+ } : undefined extends InferSchemaResult<TSchemas["body"], {}> ? {
63
+ body?: InferSchemaResult<TSchemas["body"], BodyInit | SerializableArray | SerializableObject | null | undefined> | undefined;
64
+ } : Required<{
65
+ body?: InferSchemaResult<TSchemas["body"], BodyInit | SerializableArray | SerializableObject | null | undefined> | undefined;
66
+ }>) & (undefined extends TSchemas["headers"] ? {
67
+ headers?: InferSchemaResult<TSchemas["headers"], Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}`> | Record<"Content-Type", CommonContentTypes> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | HeadersInit | undefined> | undefined;
68
+ } : undefined extends InferSchemaResult<TSchemas["headers"], {}> ? {
69
+ headers?: InferSchemaResult<TSchemas["headers"], Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}`> | Record<"Content-Type", CommonContentTypes> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | HeadersInit | undefined> | undefined;
70
+ } : Required<{
71
+ headers?: InferSchemaResult<TSchemas["headers"], Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}`> | Record<"Content-Type", CommonContentTypes> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | HeadersInit | undefined> | undefined;
72
+ }>) & (undefined extends TSchemas["method"] ? {
73
+ method?: InferSchemaResult<TSchemas["method"], AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE"> | undefined;
74
+ } : undefined extends InferSchemaResult<TSchemas["method"], {}> ? {
75
+ method?: InferSchemaResult<TSchemas["method"], AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE"> | undefined;
76
+ } : Required<{
77
+ method?: InferSchemaResult<TSchemas["method"], AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE"> | undefined;
78
+ }>) & Pick<RequestInit, "cache" | "credentials" | "integrity" | "keepalive" | "mode" | "priority" | "redirect" | "referrer" | "referrerPolicy" | "signal" | "window"> & {
79
+ auth?: string | Auth | null;
80
+ baseURL?: string;
81
+ bodySerializer?: (bodyData: Record<string, unknown>) => string;
82
+ cloneResponse?: boolean;
83
+ customFetchImpl?: (input: string | Request | URL, init?: RequestInit) => Promise<Response>;
84
+ dedupeKey?: string;
85
+ dedupeStrategy?: "cancel" | "defer" | "none";
86
+ defaultErrorMessage?: string;
87
+ readonly fullURL?: string;
88
+ mergedHooksExecutionMode?: "parallel" | "sequential";
89
+ mergedHooksExecutionOrder?: "mainHooksAfterPlugins" | "mainHooksBeforePlugins";
90
+ plugins?: TPluginArray | undefined;
91
+ responseParser?: (responseString: string) => Awaitable<Record<string, unknown>>;
92
+ responseType?: TResponseType | undefined;
93
+ resultMode?: TResultMode | undefined;
94
+ schemas?: TSchemas | undefined;
95
+ throwOnError?: TThrowOnError | ((context: {
96
+ error: PossibleJavaScriptError;
97
+ options: CombinedCallApiExtraOptions;
98
+ request: CallApiRequestOptionsForHooks;
99
+ response: null;
100
+ } | {
101
+ error: {
102
+ errorData: TErrorData;
103
+ message: string;
104
+ name: "HTTPError";
105
+ };
106
+ options: CombinedCallApiExtraOptions;
107
+ request: CallApiRequestOptionsForHooks;
108
+ response: Response;
109
+ }) => TThrowOnError) | undefined;
110
+ timeout?: number;
111
+ validators?: CallApiValidators<TData, TErrorData> | undefined;
112
+ } & InterceptorsOrInterceptorArray<TData, TErrorData, {}> & Partial<((ReturnType<NonNullable<TPluginArray[number]["createExtraOptions"]>> extends infer T ? T extends ReturnType<NonNullable<TPluginArray[number]["createExtraOptions"]>> ? T extends _standard_schema_spec.StandardSchemaV1<unknown, unknown> ? InferSchemaResult<T, {}> : T : never : never) extends infer T_1 ? T_1 extends (ReturnType<NonNullable<TPluginArray[number]["createExtraOptions"]>> extends infer T_2 ? T_2 extends ReturnType<NonNullable<TPluginArray[number]["createExtraOptions"]>> ? T_2 extends _standard_schema_spec.StandardSchemaV1<unknown, unknown> ? InferSchemaResult<T_2, {}> : T_2 : never : never) ? T_1 extends unknown ? (param: T_1) => void : never : never : never) extends (param: infer TParam) => void ? TParam : never> & MetaOption<TSchemas> & RetryOptions<TErrorData> & ResultModeOption<TErrorData, TResultMode> & UrlOptions<TSchemas> & {
113
+ extend?: Pick<ExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas>, "plugins" | "schemas" | "validators"> | undefined;
114
+ }) | undefined) => Promise<GetCallApiResult<InferSchemaResult<TSchemas["data"], TData>, InferSchemaResult<TSchemas["errorData"], TErrorData>, TResultMode, TThrowOnError, TResponseType>>;
16
115
 
17
116
  declare const defineParameters: <TData = unknown, TErrorData = unknown, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TSchemas extends CallApiSchemas = DefaultMoreOptions>(...parameters: CallApiParameters<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas>) => CallApiParameters<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas>;
18
117
 
19
- export { BaseCallApiExtraOptions, CallApiExtraOptions, CallApiParameters, CallApiPlugin, CallApiSchemas, InferSchemaResult, ResultModeUnion, callApi, createFetchClient, defineParameters };
118
+ export { CallApiParameters, CallApiPlugin, CallApiRequestOptionsForHooks, CallApiSchemas, CombinedCallApiExtraOptions, InferSchemaResult, InterceptorsOrInterceptorArray, PossibleJavaScriptError, ResultModeUnion, callApi, createFetchClient, defineParameters };
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { splitBaseConfig, splitConfig, combineHooks, mergeAndResolveHeaders, isPlainObject, defaultRetryStatusCodes, defaultRetryMethods, executeHooks, HTTPError, resolveErrorResult, waitUntil, isFunction, isHTTPErrorInstance, omitKeys, isString, isArray, toQueryString, getFetchImpl } from './chunk-JP7YMR7V.js';
2
- export { HTTPError } from './chunk-JP7YMR7V.js';
1
+ import { splitConfig, isFunction, splitBaseConfig, combineHooks, mergeAndResolveHeaders, isPlainObject, executeHooks, HTTPError, resolveErrorResult, waitUntil, isHTTPErrorInstance, defaultRetryStatusCodes, defaultRetryMethods, omitKeys, isString, isArray, toQueryString, getFetchImpl } from './chunk-JG2BPHMX.js';
2
+ export { HTTPError } from './chunk-JG2BPHMX.js';
3
3
 
4
4
  // src/dedupe.ts
5
5
  var createDedupeStrategy = async (context) => {
@@ -67,14 +67,14 @@ var hooksEnum = {
67
67
  onRetry: /* @__PURE__ */ new Set(),
68
68
  onSuccess: /* @__PURE__ */ new Set()
69
69
  };
70
- var getPluginArray = (plugins, context) => {
70
+ var getPluginArray = (plugins) => {
71
71
  if (!plugins) {
72
72
  return [];
73
73
  }
74
- return isFunction(plugins) ? plugins(context) : plugins;
74
+ return plugins;
75
75
  };
76
76
  var initializePlugins = async (context) => {
77
- const { initURL, options, request } = context;
77
+ const { baseConfig, config, initURL, options, request } = context;
78
78
  const hookRegistries = structuredClone(hooksEnum);
79
79
  const addMainHooks = () => {
80
80
  for (const key of Object.keys(hooksEnum)) {
@@ -92,15 +92,21 @@ var initializePlugins = async (context) => {
92
92
  addMainHooks();
93
93
  }
94
94
  const resolvedPlugins = [
95
- ...getPluginArray(options.plugins, context),
96
- ...getPluginArray(options.extend?.plugins, context)
95
+ ...getPluginArray(options.plugins),
96
+ ...getPluginArray(options.extend?.plugins)
97
97
  ];
98
98
  let resolvedUrl = initURL;
99
99
  let resolvedOptions = options;
100
100
  let resolvedRequestOptions = request;
101
101
  const executePluginInit = async (pluginInit) => {
102
102
  if (!pluginInit) return;
103
- const initResult = await pluginInit({ initURL, options, request });
103
+ const initResult = await pluginInit({
104
+ baseConfig,
105
+ config,
106
+ initURL,
107
+ options,
108
+ request
109
+ });
104
110
  if (!isPlainObject(initResult)) return;
105
111
  if (isString(initResult.initURL)) {
106
112
  resolvedUrl = initResult.initURL;
@@ -283,12 +289,13 @@ var handleValidation = async (responseData, schema, validator) => {
283
289
  };
284
290
 
285
291
  // src/createFetchClient.ts
286
- var createFetchClient = (baseConfig) => {
287
- const [baseFetchOptions, baseExtraOptions] = splitBaseConfig(baseConfig ?? {});
292
+ var createFetchClient = (baseConfig = {}) => {
288
293
  const $RequestInfoCache = /* @__PURE__ */ new Map();
289
294
  const callApi2 = async (...parameters) => {
290
295
  const [initURL, config = {}] = parameters;
291
296
  const [fetchOptions, extraOptions] = splitConfig(config);
297
+ const resolvedBaseConfig = isFunction(baseConfig) ? baseConfig({ initURL: initURL.toString(), options: extraOptions, request: fetchOptions }) : baseConfig;
298
+ const [baseFetchOptions, baseExtraOptions] = splitBaseConfig(resolvedBaseConfig);
292
299
  const initCombinedHooks = {};
293
300
  for (const key of Object.keys(hooksEnum)) {
294
301
  const combinedHook = combineHooks(
@@ -316,20 +323,13 @@ var createFetchClient = (baseConfig) => {
316
323
  ...extraOptions,
317
324
  ...initCombinedHooks
318
325
  };
319
- const body = fetchOptions.body ?? baseFetchOptions.body;
320
326
  const defaultRequestOptions = {
321
327
  ...baseFetchOptions,
322
- ...fetchOptions,
323
- body: isPlainObject(body) ? defaultExtraOptions.bodySerializer(body) : body,
324
- headers: mergeAndResolveHeaders({
325
- auth: defaultExtraOptions.auth,
326
- baseHeaders: baseFetchOptions.headers,
327
- body,
328
- headers: fetchOptions.headers
329
- }),
330
- signal: fetchOptions.signal ?? baseFetchOptions.signal
328
+ ...fetchOptions
331
329
  };
332
330
  const { resolvedHooks, resolvedOptions, resolvedRequestOptions, url } = await initializePlugins({
331
+ baseConfig: resolvedBaseConfig,
332
+ config,
333
333
  initURL,
334
334
  options: defaultExtraOptions,
335
335
  request: defaultRequestOptions
@@ -350,6 +350,13 @@ var createFetchClient = (baseConfig) => {
350
350
  );
351
351
  const request = {
352
352
  ...resolvedRequestOptions,
353
+ body: isPlainObject(resolvedRequestOptions.body) ? options.bodySerializer(resolvedRequestOptions.body) : resolvedRequestOptions.body,
354
+ headers: mergeAndResolveHeaders({
355
+ auth: options.auth,
356
+ baseHeaders: baseFetchOptions.headers,
357
+ body: resolvedRequestOptions.body,
358
+ headers: fetchOptions.headers
359
+ }),
353
360
  signal: combinedSignal
354
361
  };
355
362
  const { handleRequestCancelStrategy, handleRequestDeferStrategy, removeDedupeKeyFromCache } = await createDedupeStrategy({ $RequestInfoCache, newFetchController, options, request });
@@ -359,12 +366,12 @@ var createFetchClient = (baseConfig) => {
359
366
  request.headers = mergeAndResolveHeaders({
360
367
  auth: options.auth,
361
368
  baseHeaders: baseFetchOptions.headers,
362
- body,
369
+ body: request.body,
363
370
  headers: request.headers
364
371
  });
365
372
  const response = await handleRequestDeferStrategy();
366
- const shouldCloneResponse = options.dedupeStrategy === "defer" || options.cloneResponse;
367
373
  const { schemas, validators } = createExtensibleSchemasAndValidators(options);
374
+ const shouldCloneResponse = options.dedupeStrategy === "defer" || options.cloneResponse;
368
375
  if (!response.ok) {
369
376
  const errorData = await resolveResponseData(
370
377
  shouldCloneResponse ? response.clone() : response,
@@ -466,7 +473,6 @@ var createFetchClient = (baseConfig) => {
466
473
  removeDedupeKeyFromCache();
467
474
  }
468
475
  };
469
- callApi2.create = createFetchClient;
470
476
  return callApi2;
471
477
  };
472
478
  var callApi = createFetchClient();