@zayne-labs/callapi 1.14.2 → 1.16.0

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.
@@ -1,13 +1,31 @@
1
- import { At as BaseCallApiSchemaAndConfig, Dt as ResultModeType, Et as ResponseTypeType, Gt as NoInferUnMasked, Ht as CommonContentTypes, It as InferSchemaOutput, Kt as Writeable, Lt as InferSchemaResult, Nt as CallApiSchema, O as GlobalMeta, Pt as CallApiSchemaConfig, S as CallApiResult, T as GetBaseSchemaRoutes, Tt as ResponseTypeMap, Ut as CommonRequestHeaders, Vt as AnyString, Wt as DistributiveOmit, _ as CallApiConfig, a as GetCurrentRouteSchemaKey, b as CallApiParameters, bt as GetResponseType, ct as DefaultDataType, d as SerializableArray, f as SerializableObject, h as BaseCallApiConfig, i as GetCurrentRouteSchema, jt as BaseCallApiSchemaRoutes, l as InferInitURL, lt as DefaultPluginArray, m as AuthOption, n as ApplyURLBasedConfig, o as HeadersOption, p as ThrowOnErrorBoolean, r as Body, st as DefaultCallApiContext, t as ApplyStrictConfig, u as InferParamsFromRoute, ut as CallApiPlugin, v as CallApiContext, vt as CallApiResultSuccessOrErrorVariant, w as GetBaseSchemaConfig, xt as InferCallApiResult, yt as CallApiResultSuccessVariant } from "./conditional-types-C9cMfJMZ.js";
1
+ import { $t as DefaultCallApiContext, Ct as CallApiResult, Et as GetBaseSchemaRoutes, Ft as CallApiSchema, It as CallApiSchemaConfig, J as CallApiResultSuccessVariant, Jt as CommonRequestHeaders, Kt as AnyString, Mt as BaseCallApiSchemaAndConfig, Nt as BaseCallApiSchemaRoutes, Qt as Writeable, Rt as InferSchemaOutput, Tt as GetBaseSchemaConfig, X as InferCallApiResult, Xt as NoInferUnMasked, Y as GetResponseType, Yt as DistributiveOmit, Zt as UnionToIntersection, _t as BaseCallApiConfig, at as Body, c as MetaWithContextTag, ct as HeadersOption, dt as InferInitURL, en as DefaultMetaObject, et as ResponseTypeMap, ft as InferParamsFromRoute, gt as AuthOption, ht as ThrowOnErrorBoolean, it as ApplyURLBasedConfig, l as CallApiPlugin, mt as SerializableObject, nt as ResultModeType, o as InferExtraOptionsFromTag, ot as GetCurrentRouteSchema, pt as SerializableArray, q as CallApiResultSuccessOrErrorVariant, qt as CommonContentTypes, r as ExtraOptionsWithContextTag, rt as ApplyStrictConfig, s as InferMetaFromTag, st as GetCurrentRouteSchemaKey, t as CallApiContext, tn as DefaultPluginArray, tt as ResponseTypeType, xt as CallApiParameters, yt as CallApiConfig, zt as InferSchemaResult } from "./callapi-context-NF0HXJwF.js";
2
2
  //#region src/createFetchClient.d.ts
3
- 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>, TBody extends InferSchemaOutput<TSchema["body"], Body> = InferSchemaOutput<TSchema["body"], SerializableObject | BodyInit | SerializableArray | null>, 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, initConfig]: CallApiParameters<TComputedData, TComputedErrorData, TResultMode, TCallApiContext, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBody, TBasePluginArray, TPluginArray>) => Promise<TComputedResult>;
4
- declare const createFetchClient: <TBaseCallApiContext extends CallApiContext = {
5
- InferredExtraOptions: unknown;
6
- Data: DefaultDataType;
7
- ErrorData: DefaultDataType;
8
- ResultMode: ResultModeType;
9
- Meta: GlobalMeta;
10
- }, 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]>>, TBody extends InferSchemaResult<TSchema["body"], SerializableObject | BodyInit | SerializableArray | null, "infer-output"> = InferSchemaResult<TSchema["body"], SerializableObject | BodyInit | SerializableArray | null, "infer-output">, 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, {
3
+ 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, TBaseMeta extends DefaultMetaObject = DefaultMetaObject, TComputedBaseSchemaConfig extends CallApiSchemaConfig = GetBaseSchemaConfig<TBaseSchemaAndConfig>, TComputedBaseSchemaRoutes extends BaseCallApiSchemaRoutes = GetBaseSchemaRoutes<TBaseSchemaAndConfig>, TComputedBaseCallApiContext extends DefaultCallApiContext = Omit<TBaseCallApiContext, "InferredExtraOptions" | "Meta" | "Data" | "ErrorData" | "ResultMode"> & {
4
+ Data: TBaseData;
5
+ ErrorData: TBaseErrorData;
6
+ InferredExtraOptions: UnionToIntersection<TBasePluginArray[number] extends (infer T_1) ? T_1 extends TBasePluginArray[number] ? T_1 extends CallApiPlugin<DefaultCallApiContext> ? (T_1["extraOptionsDef"] extends ExtraOptionsWithContextTag<infer TExtraOptions extends unknown> ? TExtraOptions : never) | InferExtraOptionsFromTag<T_1> : never : never : never> & TBaseCallApiContext["InferredExtraOptions"];
7
+ Meta: InferMetaFromTag<TBaseMeta, unknown> & UnionToIntersection<TBasePluginArray[number] extends (infer T_2) ? T_2 extends TBasePluginArray[number] ? T_2 extends CallApiPlugin<DefaultCallApiContext> ? (T_2["metaDef"] extends MetaWithContextTag<infer TMeta extends DefaultMetaObject | undefined> ? TMeta : never) | InferMetaFromTag<T_2, never> : never : never : never> & TBaseCallApiContext["Meta"];
8
+ ResultMode: TBaseResultMode;
9
+ } extends (infer T) ? { [Key in keyof T]: T[Key]; } : never>(initBaseConfig?: BaseCallApiConfig<TComputedBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBaseMeta, TBaseSchemaAndConfig, TBasePluginArray>) => <TData = TBaseData, TErrorData = TBaseErrorData, TResultMode extends ResultModeType = TBaseResultMode, TCallApiContext extends CallApiContext = TComputedBaseCallApiContext, 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>, TBody extends InferSchemaOutput<TSchema["body"], Body> = InferSchemaOutput<TSchema["body"], SerializableObject | BodyInit | SerializableArray | null>, const TPluginArray extends CallApiPlugin[] = TBasePluginArray, TComputedData = InferSchemaOutput<TSchema["data"], GetResponseType<TData, TResponseType>>, TComputedErrorData = InferSchemaOutput<TSchema["errorData"], GetResponseType<TErrorData, TResponseType>>, TComputedCallApiContext extends DefaultCallApiContext = Omit<TCallApiContext, "InferredExtraOptions" | "Meta" | "Data" | "ErrorData" | "ResultMode"> & {
10
+ Data: TComputedData;
11
+ ErrorData: TComputedErrorData;
12
+ InferredExtraOptions: UnionToIntersection<TPluginArray[number] extends (infer T_4) ? T_4 extends TPluginArray[number] ? T_4 extends CallApiPlugin<DefaultCallApiContext> ? (T_4["extraOptionsDef"] extends ExtraOptionsWithContextTag<infer TExtraOptions extends unknown> ? TExtraOptions : never) | InferExtraOptionsFromTag<T_4> : never : never : never> & TCallApiContext["InferredExtraOptions"];
13
+ Meta: InferSchemaResult<TSchema["meta"], UnionToIntersection<TPluginArray[number] extends (infer T_5) ? T_5 extends TPluginArray[number] ? T_5 extends CallApiPlugin<DefaultCallApiContext> ? (T_5["metaDef"] extends MetaWithContextTag<infer TMeta extends DefaultMetaObject | undefined> ? TMeta : never) | InferMetaFromTag<T_5, never> : never : never : never> & TCallApiContext["Meta"], "infer-output">;
14
+ ResultMode: TResultMode;
15
+ } extends (infer T_3) ? { [Key_1 in keyof T_3]: T_3[Key_1]; } : never, TComputedResult = CallApiResult<TComputedData, TComputedErrorData, TResultMode, TThrowOnError>>(...[initURL, initConfig]: CallApiParameters<TComputedData, TComputedErrorData, TResultMode, TComputedCallApiContext, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBody, TBasePluginArray, TPluginArray>) => Promise<TComputedResult>;
16
+ declare const createFetchClient: <TBaseCallApiContext extends CallApiContext = DefaultCallApiContext, 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, TBaseMeta extends DefaultMetaObject = DefaultMetaObject, TComputedBaseSchemaConfig extends CallApiSchemaConfig = Writeable<NonNullable<TBaseSchemaAndConfig["config"]>, "deep">, TComputedBaseSchemaRoutes extends BaseCallApiSchemaRoutes = Writeable<TBaseSchemaAndConfig["routes"], "deep">, TComputedBaseCallApiContext extends DefaultCallApiContext = Omit<TBaseCallApiContext, "InferredExtraOptions" | "Meta" | "Data" | "ErrorData" | "ResultMode"> & {
17
+ Data: TBaseData;
18
+ ErrorData: TBaseErrorData;
19
+ InferredExtraOptions: UnionToIntersection<TBasePluginArray[number] extends (infer T_1) ? T_1 extends TBasePluginArray[number] ? T_1 extends CallApiPlugin<DefaultCallApiContext> ? (T_1["extraOptionsDef"] extends ExtraOptionsWithContextTag<infer TExtraOptions extends unknown> ? TExtraOptions : never) | InferExtraOptionsFromTag<T_1> : never : never : never> & TBaseCallApiContext["InferredExtraOptions"];
20
+ Meta: InferMetaFromTag<TBaseMeta, unknown> & UnionToIntersection<TBasePluginArray[number] extends (infer T_2) ? T_2 extends TBasePluginArray[number] ? T_2 extends CallApiPlugin<DefaultCallApiContext> ? (T_2["metaDef"] extends MetaWithContextTag<infer TMeta extends DefaultMetaObject | undefined> ? TMeta : never) | InferMetaFromTag<T_2, never> : never : never : never> & TBaseCallApiContext["Meta"];
21
+ ResultMode: TBaseResultMode;
22
+ } extends (infer T) ? { [Key in keyof T]: T[Key]; } : never>(initBaseConfig?: BaseCallApiConfig<TComputedBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBaseMeta, TBaseSchemaAndConfig, TBasePluginArray>) => <TData = TBaseData, TErrorData = TBaseErrorData, TResultMode extends ResultModeType = TBaseResultMode, TCallApiContext extends CallApiContext = TComputedBaseCallApiContext, 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]>>, TBody extends InferSchemaResult<TSchema["body"], SerializableObject | BodyInit | SerializableArray | null, "infer-output"> = InferSchemaResult<TSchema["body"], SerializableObject | BodyInit | SerializableArray | null, "infer-output">, 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">, TComputedCallApiContext extends DefaultCallApiContext = Omit<TCallApiContext, "InferredExtraOptions" | "Meta" | "Data" | "ErrorData" | "ResultMode"> & {
23
+ Data: TComputedData;
24
+ ErrorData: TComputedErrorData;
25
+ InferredExtraOptions: UnionToIntersection<TPluginArray[number] extends (infer T_4) ? T_4 extends TPluginArray[number] ? T_4 extends CallApiPlugin<DefaultCallApiContext> ? (T_4["extraOptionsDef"] extends ExtraOptionsWithContextTag<infer TExtraOptions extends unknown> ? TExtraOptions : never) | InferExtraOptionsFromTag<T_4> : never : never : never> & TCallApiContext["InferredExtraOptions"];
26
+ Meta: InferSchemaResult<TSchema["meta"], UnionToIntersection<TPluginArray[number] extends (infer T_5) ? T_5 extends TPluginArray[number] ? T_5 extends CallApiPlugin<DefaultCallApiContext> ? (T_5["metaDef"] extends MetaWithContextTag<infer TMeta extends DefaultMetaObject | undefined> ? TMeta : never) | InferMetaFromTag<T_5, never> : never : never : never> & TCallApiContext["Meta"], "infer-output">;
27
+ ResultMode: TResultMode;
28
+ } extends (infer T_3) ? { [Key_1 in keyof T_3]: T_3[Key_1]; } : never, TComputedResult = InferCallApiResult<TComputedData, TComputedErrorData, TResultMode, TThrowOnError, {
11
29
  all: CallApiResultSuccessVariant<TComputedData>;
12
30
  fetchApi: Response;
13
31
  onlyData: NoInferUnMasked<TComputedData>;
@@ -21,15 +39,31 @@ declare const createFetchClient: <TBaseCallApiContext extends CallApiContext = {
21
39
  fetchApi: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["response"];
22
40
  onlyData: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["data"];
23
41
  onlyResponse: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["response"];
24
- withoutResponse: DistributiveOmit<TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>, "response"> extends (infer T) ? { [Key in keyof T]: T[Key]; } : never;
25
- }>>(...[initURL, initConfig]: CallApiParameters<TComputedData, TComputedErrorData, TResultMode, TCallApiContext, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBody, TBasePluginArray, TPluginArray, CallApiConfig<TCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBody, TBasePluginArray, TPluginArray>, (undefined extends InferSchemaResult<TSchema["auth"], undefined, "infer-output"> ? {
42
+ withoutResponse: DistributiveOmit<TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>, "response"> extends (infer T_6) ? { [Key_2 in keyof T_6]: T_6[Key_2]; } : never;
43
+ }>>(...[initURL, initConfig]: CallApiParameters<TComputedData, TComputedErrorData, TResultMode, TComputedCallApiContext, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBody, TBasePluginArray, TPluginArray, (undefined extends InferSchemaResult<TSchema["body"], undefined, "infer-output"> ? {
44
+ body?: TBody | undefined;
45
+ } : Required<{
46
+ body?: TBody | undefined;
47
+ }>) & (undefined extends InferSchemaResult<TSchema["headers"], undefined, "infer-output"> ? {
48
+ headers?: InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output"> | ((context: {
49
+ baseHeaders: Extract<HeadersOption, Record<string, unknown>>;
50
+ }) => InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output">) | undefined;
51
+ } : Required<{
52
+ headers?: InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output"> | ((context: {
53
+ baseHeaders: Extract<HeadersOption, Record<string, unknown>>;
54
+ }) => InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output">) | undefined;
55
+ }>) & (undefined extends InferSchemaResult<TSchema["method"], undefined, "infer-output"> ? {
56
+ method?: InferSchemaResult<TSchema["method"], string extends TInitURL ? AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" : TInitURL extends `@${infer TMethod extends "delete" | "get" | "patch" | "post" | "put"}/${string}` ? Uppercase<TMethod> : AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE", "infer-output"> | undefined;
57
+ } : Required<{
58
+ method?: InferSchemaResult<TSchema["method"], string extends TInitURL ? AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" : TInitURL extends `@${infer TMethod extends "delete" | "get" | "patch" | "post" | "put"}/${string}` ? Uppercase<TMethod> : AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE", "infer-output"> | undefined;
59
+ }>) & (undefined extends InferSchemaResult<TSchema["auth"], undefined, "infer-output"> ? {
26
60
  auth?: InferSchemaResult<TSchema["auth"], AuthOption, "infer-output"> | undefined;
27
61
  } : Required<{
28
62
  auth?: InferSchemaResult<TSchema["auth"], AuthOption, "infer-output"> | undefined;
29
63
  }>) & (undefined extends InferSchemaResult<TSchema["meta"], undefined, "infer-output"> ? {
30
- meta?: InferSchemaResult<TSchema["meta"], TCallApiContext["Meta"], "infer-output"> | undefined;
64
+ meta?: InferSchemaResult<TSchema["meta"], TComputedCallApiContext["Meta"] extends DefaultMetaObject ? TComputedCallApiContext["Meta"] : DefaultMetaObject, "infer-output"> | undefined;
31
65
  } : Required<{
32
- meta?: InferSchemaResult<TSchema["meta"], TCallApiContext["Meta"], "infer-output"> | undefined;
66
+ meta?: InferSchemaResult<TSchema["meta"], TComputedCallApiContext["Meta"] extends DefaultMetaObject ? TComputedCallApiContext["Meta"] : DefaultMetaObject, "infer-output"> | undefined;
33
67
  }>) & (undefined extends InferSchemaResult<TSchema["params"], undefined, "infer-output"> ? Record<string, string | number | boolean> | (string | number | boolean)[] extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? {
34
68
  params?: InferSchemaResult<TSchema["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>, "infer-output"> | undefined;
35
69
  } : TCurrentRouteSchemaKey extends Extract<keyof TComputedBaseSchemaRoutes, TCurrentRouteSchemaKey> ? undefined extends InferSchemaResult<TSchema["params"], null, "infer-output"> ? {
@@ -50,29 +84,13 @@ declare const createFetchClient: <TBaseCallApiContext extends CallApiContext = {
50
84
  query?: InferSchemaResult<TSchema["query"], URLSearchParams | Record<string, string | number | boolean | (unknown[] | Record<string, unknown> | null | undefined)>, "infer-output"> | undefined;
51
85
  } : Required<{
52
86
  query?: InferSchemaResult<TSchema["query"], URLSearchParams | Record<string, string | number | boolean | (unknown[] | Record<string, unknown> | null | undefined)>, "infer-output"> | undefined;
53
- }>) & (undefined extends InferSchemaResult<TSchema["body"], undefined, "infer-output"> ? {
54
- body?: TBody | undefined;
55
- } : Required<{
56
- body?: TBody | undefined;
57
- }>) & (undefined extends InferSchemaResult<TSchema["headers"], undefined, "infer-output"> ? {
58
- headers?: InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output"> | ((context: {
59
- baseHeaders: Extract<HeadersOption, Record<string, unknown>>;
60
- }) => InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output">) | undefined;
61
- } : Required<{
62
- headers?: InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output"> | ((context: {
63
- baseHeaders: Extract<HeadersOption, Record<string, unknown>>;
64
- }) => InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output">) | undefined;
65
- }>) & (undefined extends InferSchemaResult<TSchema["method"], undefined, "infer-output"> ? {
66
- method?: InferSchemaResult<TSchema["method"], string extends TInitURL ? AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" : TInitURL extends `@${infer TMethod extends "delete" | "get" | "patch" | "post" | "put"}/${string}` ? Uppercase<TMethod> : AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE", "infer-output"> | undefined;
67
- } : Required<{
68
- method?: InferSchemaResult<TSchema["method"], string extends TInitURL ? AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" : TInitURL extends `@${infer TMethod extends "delete" | "get" | "patch" | "post" | "put"}/${string}` ? Uppercase<TMethod> : AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE", "infer-output"> | undefined;
69
- }>)>) => Promise<TComputedResult>;
87
+ }>), CallApiConfig<TComputedCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBody, TBasePluginArray, TPluginArray>>) => Promise<TComputedResult>;
70
88
  declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode extends ResultModeType = ResultModeType, TCallApiContext extends CallApiContext = {
89
+ Data: unknown;
90
+ ErrorData: unknown;
71
91
  InferredExtraOptions: unknown;
72
- Data: DefaultDataType;
73
- ErrorData: DefaultDataType;
92
+ Meta: unknown;
74
93
  ResultMode: ResultModeType;
75
- Meta: GlobalMeta;
76
94
  }, 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<{
77
95
  [x: AnyString]: CallApiSchema | undefined;
78
96
  "@default"?: CallApiSchema | undefined;
@@ -105,7 +123,13 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
105
123
  "@patch/"?: CallApiSchema | undefined;
106
124
  "@post/"?: CallApiSchema | undefined;
107
125
  "@put/"?: CallApiSchema | undefined;
108
- }[TCurrentRouteSchemaKey]>>, TBody extends InferSchemaResult<TSchema["body"], SerializableObject | BodyInit | SerializableArray | null, "infer-output"> = InferSchemaResult<TSchema["body"], SerializableObject | BodyInit | SerializableArray | null, "infer-output">, const TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedData = InferSchemaResult<TSchema["data"], GetResponseType<TData, TResponseType, ResponseTypeMap<TData>>, "infer-output">, TComputedErrorData = InferSchemaResult<TSchema["errorData"], GetResponseType<TErrorData, TResponseType, ResponseTypeMap<TErrorData>>, "infer-output">, TComputedResult = InferCallApiResult<TComputedData, TComputedErrorData, TResultMode, TThrowOnError, {
126
+ }[TCurrentRouteSchemaKey]>>, TBody extends InferSchemaResult<TSchema["body"], SerializableObject | BodyInit | SerializableArray | null, "infer-output"> = InferSchemaResult<TSchema["body"], SerializableObject | BodyInit | SerializableArray | null, "infer-output">, const TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedData = InferSchemaResult<TSchema["data"], GetResponseType<TData, TResponseType, ResponseTypeMap<TData>>, "infer-output">, TComputedErrorData = InferSchemaResult<TSchema["errorData"], GetResponseType<TErrorData, TResponseType, ResponseTypeMap<TErrorData>>, "infer-output">, TComputedCallApiContext extends DefaultCallApiContext = Omit<TCallApiContext, "InferredExtraOptions" | "Meta" | "Data" | "ErrorData" | "ResultMode"> & {
127
+ Data: TComputedData;
128
+ ErrorData: TComputedErrorData;
129
+ InferredExtraOptions: UnionToIntersection<TPluginArray[number] extends (infer T_1) ? T_1 extends TPluginArray[number] ? T_1 extends CallApiPlugin<DefaultCallApiContext> ? (T_1["extraOptionsDef"] extends ExtraOptionsWithContextTag<infer TExtraOptions extends unknown> ? TExtraOptions : never) | InferExtraOptionsFromTag<T_1> : never : never : never> & TCallApiContext["InferredExtraOptions"];
130
+ Meta: InferSchemaResult<TSchema["meta"], UnionToIntersection<TPluginArray[number] extends (infer T_2) ? T_2 extends TPluginArray[number] ? T_2 extends CallApiPlugin<DefaultCallApiContext> ? (T_2["metaDef"] extends MetaWithContextTag<infer TMeta extends DefaultMetaObject | undefined> ? TMeta : never) | InferMetaFromTag<T_2, never> : never : never : never> & TCallApiContext["Meta"], "infer-output">;
131
+ ResultMode: TResultMode;
132
+ } extends (infer T) ? { [Key in keyof T]: T[Key]; } : never, TComputedResult = InferCallApiResult<TComputedData, TComputedErrorData, TResultMode, TThrowOnError, {
109
133
  all: CallApiResultSuccessVariant<TComputedData>;
110
134
  fetchApi: Response;
111
135
  onlyData: NoInferUnMasked<TComputedData>;
@@ -119,16 +143,8 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
119
143
  fetchApi: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["response"];
120
144
  onlyData: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["data"];
121
145
  onlyResponse: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["response"];
122
- withoutResponse: DistributiveOmit<TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>, "response"> extends (infer T) ? { [Key in keyof T]: T[Key]; } : never;
123
- }>>(...[initURL, initConfig]: CallApiParameters<TComputedData, TComputedErrorData, TResultMode, TCallApiContext, TThrowOnError, TResponseType, {
124
- [x: AnyString]: CallApiSchema | undefined;
125
- "@default"?: CallApiSchema | undefined;
126
- "@delete/"?: CallApiSchema | undefined;
127
- "@get/"?: CallApiSchema | undefined;
128
- "@patch/"?: CallApiSchema | undefined;
129
- "@post/"?: CallApiSchema | undefined;
130
- "@put/"?: CallApiSchema | undefined;
131
- }, TSchema, CallApiSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBody, DefaultPluginArray, TPluginArray, CallApiConfig<TCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, {
146
+ withoutResponse: DistributiveOmit<TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>, "response"> extends (infer T_3) ? { [Key_1 in keyof T_3]: T_3[Key_1]; } : never;
147
+ }>>(...[initURL, initConfig]: CallApiParameters<TComputedData, TComputedErrorData, TResultMode, TComputedCallApiContext, TThrowOnError, TResponseType, {
132
148
  [x: AnyString]: CallApiSchema | undefined;
133
149
  "@default"?: CallApiSchema | undefined;
134
150
  "@delete/"?: CallApiSchema | undefined;
@@ -136,14 +152,30 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
136
152
  "@patch/"?: CallApiSchema | undefined;
137
153
  "@post/"?: CallApiSchema | undefined;
138
154
  "@put/"?: CallApiSchema | undefined;
139
- }, TSchema, CallApiSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBody, DefaultPluginArray, TPluginArray>, (undefined extends InferSchemaResult<TSchema["auth"], undefined, "infer-output"> ? {
155
+ }, TSchema, CallApiSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBody, DefaultPluginArray, TPluginArray, (undefined extends InferSchemaResult<TSchema["body"], undefined, "infer-output"> ? {
156
+ body?: TBody | undefined;
157
+ } : Required<{
158
+ body?: TBody | undefined;
159
+ }>) & (undefined extends InferSchemaResult<TSchema["headers"], undefined, "infer-output"> ? {
160
+ headers?: InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output"> | ((context: {
161
+ baseHeaders: Extract<HeadersOption, Record<string, unknown>>;
162
+ }) => InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output">) | undefined;
163
+ } : Required<{
164
+ headers?: InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output"> | ((context: {
165
+ baseHeaders: Extract<HeadersOption, Record<string, unknown>>;
166
+ }) => InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output">) | undefined;
167
+ }>) & (undefined extends InferSchemaResult<TSchema["method"], undefined, "infer-output"> ? {
168
+ method?: InferSchemaResult<TSchema["method"], string extends TInitURL ? AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" : TInitURL extends `@${infer TMethod extends "delete" | "get" | "patch" | "post" | "put"}/${string}` ? Uppercase<TMethod> : AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE", "infer-output"> | undefined;
169
+ } : Required<{
170
+ method?: InferSchemaResult<TSchema["method"], string extends TInitURL ? AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" : TInitURL extends `@${infer TMethod extends "delete" | "get" | "patch" | "post" | "put"}/${string}` ? Uppercase<TMethod> : AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE", "infer-output"> | undefined;
171
+ }>) & (undefined extends InferSchemaResult<TSchema["auth"], undefined, "infer-output"> ? {
140
172
  auth?: InferSchemaResult<TSchema["auth"], AuthOption, "infer-output"> | undefined;
141
173
  } : Required<{
142
174
  auth?: InferSchemaResult<TSchema["auth"], AuthOption, "infer-output"> | undefined;
143
175
  }>) & (undefined extends InferSchemaResult<TSchema["meta"], undefined, "infer-output"> ? {
144
- meta?: InferSchemaResult<TSchema["meta"], TCallApiContext["Meta"], "infer-output"> | undefined;
176
+ meta?: InferSchemaResult<TSchema["meta"], TComputedCallApiContext["Meta"] extends DefaultMetaObject ? TComputedCallApiContext["Meta"] : DefaultMetaObject, "infer-output"> | undefined;
145
177
  } : Required<{
146
- meta?: InferSchemaResult<TSchema["meta"], TCallApiContext["Meta"], "infer-output"> | undefined;
178
+ meta?: InferSchemaResult<TSchema["meta"], TComputedCallApiContext["Meta"] extends DefaultMetaObject ? TComputedCallApiContext["Meta"] : DefaultMetaObject, "infer-output"> | undefined;
147
179
  }>) & (undefined extends InferSchemaResult<TSchema["params"], undefined, "infer-output"> ? Record<string, string | number | boolean> | (string | number | boolean)[] extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? {
148
180
  params?: InferSchemaResult<TSchema["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>, "infer-output"> | undefined;
149
181
  } : TCurrentRouteSchemaKey extends Extract<AnyString, TCurrentRouteSchemaKey> | Extract<"@default", TCurrentRouteSchemaKey> | Extract<"@delete/", TCurrentRouteSchemaKey> | Extract<"@get/", TCurrentRouteSchemaKey> | Extract<"@patch/", TCurrentRouteSchemaKey> | Extract<"@post/", TCurrentRouteSchemaKey> | Extract<"@put/", TCurrentRouteSchemaKey> ? undefined extends InferSchemaResult<TSchema["params"], null, "infer-output"> ? {
@@ -164,23 +196,15 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
164
196
  query?: InferSchemaResult<TSchema["query"], URLSearchParams | Record<string, string | number | boolean | (unknown[] | Record<string, unknown> | null | undefined)>, "infer-output"> | undefined;
165
197
  } : Required<{
166
198
  query?: InferSchemaResult<TSchema["query"], URLSearchParams | Record<string, string | number | boolean | (unknown[] | Record<string, unknown> | null | undefined)>, "infer-output"> | undefined;
167
- }>) & (undefined extends InferSchemaResult<TSchema["body"], undefined, "infer-output"> ? {
168
- body?: TBody | undefined;
169
- } : Required<{
170
- body?: TBody | undefined;
171
- }>) & (undefined extends InferSchemaResult<TSchema["headers"], undefined, "infer-output"> ? {
172
- headers?: InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output"> | ((context: {
173
- baseHeaders: Extract<HeadersOption, Record<string, unknown>>;
174
- }) => InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output">) | undefined;
175
- } : Required<{
176
- headers?: InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output"> | ((context: {
177
- baseHeaders: Extract<HeadersOption, Record<string, unknown>>;
178
- }) => InferSchemaResult<TSchema["headers"], Headers | Record<"Authorization", `Basic ${string}` | `Bearer ${string}` | `Token ${string}` | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | [string, string][], "infer-output">) | undefined;
179
- }>) & (undefined extends InferSchemaResult<TSchema["method"], undefined, "infer-output"> ? {
180
- method?: InferSchemaResult<TSchema["method"], string extends TInitURL ? AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" : TInitURL extends `@${infer TMethod extends "delete" | "get" | "patch" | "post" | "put"}/${string}` ? Uppercase<TMethod> : AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE", "infer-output"> | undefined;
181
- } : Required<{
182
- method?: InferSchemaResult<TSchema["method"], string extends TInitURL ? AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" : TInitURL extends `@${infer TMethod extends "delete" | "get" | "patch" | "post" | "put"}/${string}` ? Uppercase<TMethod> : AnyString | "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE", "infer-output"> | undefined;
183
- }>)>) => Promise<TComputedResult>;
199
+ }>), CallApiConfig<TComputedCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, {
200
+ [x: AnyString]: CallApiSchema | undefined;
201
+ "@default"?: CallApiSchema | undefined;
202
+ "@delete/"?: CallApiSchema | undefined;
203
+ "@get/"?: CallApiSchema | undefined;
204
+ "@patch/"?: CallApiSchema | undefined;
205
+ "@post/"?: CallApiSchema | undefined;
206
+ "@put/"?: CallApiSchema | undefined;
207
+ }, TSchema, CallApiSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBody, DefaultPluginArray, TPluginArray>>) => Promise<TComputedResult>;
184
208
  //#endregion
185
209
  export { createFetchClient as n, createFetchClientWithContext as r, callApi as t };
186
- //# sourceMappingURL=index-Dcg43451.d.ts.map
210
+ //# sourceMappingURL=index-bRY6RbJu.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as Register, B as ResponseErrorContext, C as CallApiResultLoose, Ct as PossibleJavaScriptError, D as GetCallApiContextRequired, Dt as ResultModeType, E as GetCallApiContext, Et as ResponseTypeType, F as Hooks, Ft as InferSchemaInput, H as SuccessContext, I as HooksOrHooksArray, It as InferSchemaOutput, L as RequestContext, M as CallApiExtraOptionsForHooks, Mt as BaseSchemaRouteKeyPrefixes, N as CallApiRequestOptionsForHooks, Nt as CallApiSchema, P as ErrorContext, Pt as CallApiSchemaConfig, R as RequestStreamContext, Rt as URLOptions, St as PossibleHTTPError, U as RefetchOptions, V as ResponseStreamContext, W as RetryOptions, _ as CallApiConfig, _t as CallApiResultErrorVariant, a as GetCurrentRouteSchemaKey, b as CallApiParameters, c as InferAllMainRoutes, dt as PluginHooks, ft as PluginMiddlewares, g as BaseCallApiExtraOptions, gt as Middlewares, h as BaseCallApiConfig, ht as FetchMiddlewareContext, j as DedupeOptions, jt as BaseCallApiSchemaRoutes, k as InstanceContext, l as InferInitURL, mt as FetchImpl, pt as PluginSetupContext, s as InferAllMainRouteKeys, st as DefaultCallApiContext, u as InferParamsFromRoute, ut as CallApiPlugin, vt as CallApiResultSuccessOrErrorVariant, wt as PossibleValidationError, x as CallApiRequestOptions, y as CallApiExtraOptions, yt as CallApiResultSuccessVariant, z as ResponseContext } from "./conditional-types-C9cMfJMZ.js";
2
- import { n as createFetchClient, r as createFetchClientWithContext, t as callApi } from "./index-Dcg43451.js";
3
- export { type BaseCallApiConfig, type BaseCallApiExtraOptions, type BaseCallApiSchemaRoutes, type BaseSchemaRouteKeyPrefixes, type CallApiConfig, type CallApiExtraOptions, type CallApiExtraOptionsForHooks, type CallApiParameters, type CallApiPlugin, type CallApiRequestOptions, type CallApiRequestOptionsForHooks, type CallApiResultLoose as CallApiResult, type CallApiResultErrorVariant, type CallApiResultSuccessOrErrorVariant, type CallApiResultSuccessVariant, type CallApiSchema, type CallApiSchemaConfig, type DedupeOptions, type DefaultCallApiContext, type ErrorContext, type FetchImpl, type FetchMiddlewareContext, type GetCallApiContext, type GetCallApiContextRequired, type GetCurrentRouteSchemaKey, type Hooks, type HooksOrHooksArray, type InferAllMainRouteKeys, type InferAllMainRoutes, type InferInitURL, type InferParamsFromRoute, type InferSchemaInput, type InferSchemaOutput, type InstanceContext, type Middlewares, type PluginHooks, type PluginMiddlewares, type PluginSetupContext, type PossibleHTTPError, type PossibleJavaScriptError, type PossibleValidationError, type RefetchOptions, type Register, type RequestContext, type RequestStreamContext, type ResponseContext, type ResponseErrorContext, type ResponseStreamContext, type ResponseTypeType, type ResultModeType, type RetryOptions, type SuccessContext, type URLOptions, callApi, createFetchClient, createFetchClientWithContext };
1
+ import { $ as PossibleValidationError, $t as DefaultCallApiContext, C as SuccessContext, Dt as InstanceContext, Ft as CallApiSchema, Gt as DedupeOptions, Ht as FetchImpl, It as CallApiSchemaConfig, J as CallApiResultSuccessVariant, K as CallApiResultErrorVariant, Lt as InferSchemaInput, Nt as BaseCallApiSchemaRoutes, Ot as Register, Pt as BaseSchemaRouteKeyPrefixes, Q as PossibleJavaScriptError, Rt as InferSchemaOutput, S as ResponseStreamContext, St as CallApiRequestOptions, T as RetryOptions, Ut as FetchMiddlewareContext, Wt as Middlewares, Z as PossibleHTTPError, _ as HooksOrHooksArray, _t as BaseCallApiConfig, a as GetCallApiContextRequired, b as ResponseContext, bt as CallApiExtraOptions, c as MetaWithContextTag, d as PluginMiddlewares, dt as InferInitURL, en as DefaultMetaObject, f as PluginSetupContext, ft as InferParamsFromRoute, g as Hooks, h as ErrorContext, i as GetCallApiContext, jt as URLOptions, l as CallApiPlugin, lt as InferAllMainRouteKeys, m as CallApiRequestOptionsForHooks, n as ContextTag, nt as ResultModeType, p as CallApiExtraOptionsForHooks, q as CallApiResultSuccessOrErrorVariant, r as ExtraOptionsWithContextTag, st as GetCurrentRouteSchemaKey, tt as ResponseTypeType, u as PluginHooks, ut as InferAllMainRoutes, v as RequestContext, vt as BaseCallApiExtraOptions, w as RefetchOptions, wt as CallApiResultLoose, x as ResponseErrorContext, xt as CallApiParameters, y as RequestStreamContext, yt as CallApiConfig } from "./callapi-context-NF0HXJwF.js";
2
+ import { n as createFetchClient, r as createFetchClientWithContext, t as callApi } from "./index-bRY6RbJu.js";
3
+ export { type BaseCallApiConfig, type BaseCallApiExtraOptions, type BaseCallApiSchemaRoutes, type BaseSchemaRouteKeyPrefixes, type CallApiConfig, type CallApiExtraOptions, type CallApiExtraOptionsForHooks, type CallApiParameters, type CallApiPlugin, type CallApiRequestOptions, type CallApiRequestOptionsForHooks, type CallApiResultLoose as CallApiResult, type CallApiResultErrorVariant, type CallApiResultSuccessOrErrorVariant, type CallApiResultSuccessVariant, type CallApiSchema, type CallApiSchemaConfig, type ContextTag, type DedupeOptions, type DefaultCallApiContext, type DefaultMetaObject, type ErrorContext, type ExtraOptionsWithContextTag, type FetchImpl, type FetchMiddlewareContext, type GetCallApiContext, type GetCallApiContextRequired, type GetCurrentRouteSchemaKey, type Hooks, type HooksOrHooksArray, type InferAllMainRouteKeys, type InferAllMainRoutes, type InferInitURL, type InferParamsFromRoute, type InferSchemaInput, type InferSchemaOutput, type InstanceContext, type MetaWithContextTag, type Middlewares, type PluginHooks, type PluginMiddlewares, type PluginSetupContext, type PossibleHTTPError, type PossibleJavaScriptError, type PossibleValidationError, type RefetchOptions, type Register, type RequestContext, type RequestStreamContext, type ResponseContext, type ResponseErrorContext, type ResponseStreamContext, type ResponseTypeType, type ResultModeType, type RetryOptions, type SuccessContext, type URLOptions, callApi, createFetchClient, createFetchClientWithContext };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as getCurrentRouteSchemaKeyAndMainInitURL, I as isArray, L as isFunction, M as handleSchemaValidation, N as HTTPError, R as isString, a as getBody, c as getMethod, d as splitConfig, f as waitFor, g as isHTTPErrorInstance, i as createTimeoutSignal, j as handleConfigValidation, l as getResolvedHeaders, o as getFetchImpl, p as getFullAndNormalizedURL, r as createCombinedSignal, s as getHeaders, t as extraOptionDefaults, u as omitKeys, y as isValidationErrorInstance } from "./constants-C8dGbmdY.js";
1
+ import { B as isArray, F as handleConfigValidation, H as isString, I as handleSchemaValidation, L as HTTPError, P as getCurrentRouteSchemaKeyAndMainInitURL, V as isFunction, a as getBody, c as getMethod, d as splitConfig, f as waitFor, i as createTimeoutSignal, l as getResolvedHeaders, o as getFetchImpl, p as getFullAndNormalizedURL, r as createCombinedSignal, s as getHeaders, t as extraOptionDefaults, u as omitKeys, v as isHTTPErrorInstance, x as isValidationErrorInstance } from "./constants-KCmRZnc7.js";
2
2
  //#region src/result.ts
3
3
  const getResponseType = (response, responseParser) => ({
4
4
  arrayBuffer: () => response.arrayBuffer(),
@@ -16,11 +16,11 @@ const textTypes = /* @__PURE__ */ new Set([
16
16
  "application/xhtml",
17
17
  "application/html"
18
18
  ]);
19
- const JSON_REGEX = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
19
+ const JSON_REGEX = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(?:;.+)?$/i;
20
20
  const detectResponseType = (response) => {
21
21
  const initContentType = response.headers.get("content-type");
22
22
  if (!initContentType) return extraOptionDefaults.responseType;
23
- const contentType = initContentType.split(";")[0] ?? "";
23
+ const contentType = initContentType.split(";", 1)[0] ?? "";
24
24
  if (JSON_REGEX.test(contentType)) return "json";
25
25
  if (textTypes.has(contentType) || contentType.startsWith("text/")) return "text";
26
26
  return "blob";
@@ -123,10 +123,7 @@ const composeHooksFromArray = (hooksArray, hooksExecutionMode) => {
123
123
  case "parallel":
124
124
  await Promise.all(hooksArray.map((hook) => hook?.(ctx)));
125
125
  break;
126
- case "sequential":
127
- for (const hook of hooksArray) await hook?.(ctx);
128
- break;
129
- default:
126
+ case "sequential": for (const hook of hooksArray) await hook?.(ctx);
130
127
  }
131
128
  };
132
129
  return composedHook;
@@ -162,8 +159,7 @@ const createProgressEvent = (options) => {
162
159
  };
163
160
  const textEncoder = new TextEncoder();
164
161
  const estimateBodySize = (body) => {
165
- if (!body) return 0;
166
- if (body instanceof ReadableStream) return 0;
162
+ if (!body || body instanceof ReadableStream) return 0;
167
163
  if (body instanceof FormData) {
168
164
  let size = 0;
169
165
  for (const [key, value] of body) {
@@ -291,7 +287,10 @@ const createDedupeManager = async (context) => {
291
287
  const resolvedDedupeCacheScopeKey = isFunction(dedupeCacheScopeKey) ? dedupeCacheScopeKey(context) : dedupeCacheScopeKey;
292
288
  const $RequestInfoCache = dedupeCacheScope === "global" ? $GlobalRequestInfoCache.get(resolvedDedupeCacheScopeKey) ?? $GlobalRequestInfoCache.set(resolvedDedupeCacheScopeKey, /* @__PURE__ */ new Map()).get(resolvedDedupeCacheScopeKey) : $LocalRequestInfoCache;
293
289
  return {
294
- delete: () => $RequestInfoCache?.delete(dedupeKey),
290
+ delete: () => {
291
+ $RequestInfoCache?.delete(dedupeKey);
292
+ dedupeCacheScope === "global" && $RequestInfoCache?.size === 0 && $GlobalRequestInfoCache.delete(resolvedDedupeCacheScopeKey);
293
+ },
295
294
  get: () => $RequestInfoCache?.get(dedupeKey),
296
295
  set: (value) => $RequestInfoCache?.set(dedupeKey, value)
297
296
  };
@@ -493,7 +492,8 @@ const setupHooksAndMiddlewares = (context) => {
493
492
  resolvedHooks[hookName] = flattenedHookArray[0];
494
493
  continue;
495
494
  }
496
- resolvedHooks[hookName] = composeHooksFromArray(flattenedHookArray, options.hooksExecutionMode ?? extraOptionDefaults.hooksExecutionMode);
495
+ const hooksExecutionMode = options.hooksExecutionMode ?? extraOptionDefaults.hooksExecutionMode;
496
+ resolvedHooks[hookName] = composeHooksFromArray(flattenedHookArray, hooksExecutionMode);
497
497
  }
498
498
  return resolvedHooks;
499
499
  };
@@ -519,21 +519,21 @@ const setupHooksAndMiddlewares = (context) => {
519
519
  };
520
520
  //#endregion
521
521
  //#region src/refetch.ts
522
- const shouldAttemptRefetchSymbol = Symbol("shouldAttemptRefetch");
522
+ const refetchAttemptTrackerSymbol = Symbol("refetchAttemptTracker");
523
523
  const createRefetchManager = (ctx) => {
524
524
  const { callApi, callApiArgs, options, removeDedupeCacheEntry } = ctx;
525
525
  const shouldAttemptRefetch = () => {
526
- return options[shouldAttemptRefetchSymbol] ?? false;
526
+ return options[refetchAttemptTrackerSymbol] ?? false;
527
527
  };
528
528
  const refetch = () => {
529
- options[shouldAttemptRefetchSymbol] = true;
529
+ options[refetchAttemptTrackerSymbol] = true;
530
530
  };
531
531
  const handleRefetch = () => {
532
532
  if (shouldAttemptRefetch()) {
533
533
  removeDedupeCacheEntry();
534
534
  return callApi(callApiArgs.initURL, {
535
535
  ...callApiArgs.config,
536
- [shouldAttemptRefetchSymbol]: false
536
+ [refetchAttemptTrackerSymbol]: false
537
537
  });
538
538
  }
539
539
  return null;
@@ -545,6 +545,15 @@ const createRefetchManager = (ctx) => {
545
545
  };
546
546
  //#endregion
547
547
  //#region src/retry.ts
548
+ const getRetryAfterDelay = (retryAfter) => {
549
+ const normalizedRetryAfter = retryAfter?.trim();
550
+ if (!normalizedRetryAfter) return;
551
+ const retryAfterSeconds = Number(normalizedRetryAfter);
552
+ if (Number.isSafeInteger(retryAfterSeconds) && retryAfterSeconds >= 0) return retryAfterSeconds * 1e3;
553
+ const retryAt = Date.parse(normalizedRetryAfter);
554
+ if (Number.isNaN(retryAt)) return;
555
+ return Math.max(0, retryAt - Date.now());
556
+ };
548
557
  const createRetryManager = (ctx) => {
549
558
  const { callApi, callApiArgs, error, errorContext, hookInfo, removeDedupeCacheEntry } = ctx;
550
559
  const { options, request } = errorContext;
@@ -561,6 +570,8 @@ const createRetryManager = (ctx) => {
561
570
  return includesMethod && includesStatusCodes;
562
571
  };
563
572
  const getDelay = () => {
573
+ const retryAfterDelay = options.respectRetryAfter ?? extraOptionDefaults.respectRetryAfter ? getRetryAfterDelay(errorContext.response?.headers.get("retry-after")) : null;
574
+ if (retryAfterDelay != null) return retryAfterDelay;
564
575
  const retryStrategy = options.retryStrategy ?? extraOptionDefaults.retryStrategy;
565
576
  switch (retryStrategy) {
566
577
  case "exponential": {
@@ -574,7 +585,7 @@ const createRetryManager = (ctx) => {
574
585
  const retryDelay = options.retryDelay ?? extraOptionDefaults.retryDelay;
575
586
  return isFunction(retryDelay) ? retryDelay(currentRetryAttemptCount) : retryDelay;
576
587
  }
577
- default: throw new Error(`Invalid retry strategy: ${String(retryStrategy)}`);
588
+ default: throw new Error(`Invalid retry strategy: ${retryStrategy}`);
578
589
  }
579
590
  };
580
591
  const handleRetry = async () => {
@@ -669,7 +680,8 @@ const createFetchClientWithContext = () => {
669
680
  request: resolvedRequest
670
681
  }) : dedupeStrategy;
671
682
  const newFetchController = resolvedDedupeStrategy === "none" ? null : new AbortController();
672
- const combinedSignal = createCombinedSignal(createTimeoutSignal(options.timeout), resolvedRequest.signal, newFetchController?.signal);
683
+ const timeoutSignal = createTimeoutSignal(options.timeout);
684
+ const combinedSignal = createCombinedSignal(timeoutSignal, resolvedRequest.signal, newFetchController?.signal);
673
685
  const request = {
674
686
  ...resolvedRequest,
675
687
  signal: combinedSignal
@@ -744,8 +756,9 @@ const createFetchClientWithContext = () => {
744
756
  options,
745
757
  request
746
758
  });
759
+ const shouldCloneResponse = Boolean(resolvedDedupeStrategy === "defer" || options.cloneResponse);
747
760
  const responseData = await resolveResponseData({
748
- response: Boolean(resolvedDedupeStrategy === "defer" || options.cloneResponse) ? response.clone() : response,
761
+ response: shouldCloneResponse ? response.clone() : response,
749
762
  responseParser: options.responseParser,
750
763
  responseType: options.responseType,
751
764
  resultMode: options.resultMode