@zayne-labs/callapi 1.15.0 → 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.
- package/dist/{conditional-types-DaKFU9_F.d.ts → callapi-context-NF0HXJwF.d.ts} +1528 -1532
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +1 -1
- package/dist/{constants-Cm0RTgJ0.js → constants-KCmRZnc7.js} +21 -20
- package/dist/constants-KCmRZnc7.js.map +1 -0
- package/dist/{index-CAOA5J63.d.ts → index-bRY6RbJu.d.ts} +89 -65
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -11
- package/dist/index.js.map +1 -1
- package/dist/utils/external/index.d.ts +2 -2
- package/dist/utils/external/index.js +2 -2
- package/package.json +12 -12
- package/dist/constants-Cm0RTgJ0.js.map +0 -1
|
@@ -1,13 +1,31 @@
|
|
|
1
|
-
import {
|
|
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,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ResultMode:
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
25
|
-
}>>(...[initURL, initConfig]: CallApiParameters<TComputedData, TComputedErrorData, TResultMode,
|
|
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"],
|
|
64
|
+
meta?: InferSchemaResult<TSchema["meta"], TComputedCallApiContext["Meta"] extends DefaultMetaObject ? TComputedCallApiContext["Meta"] : DefaultMetaObject, "infer-output"> | undefined;
|
|
31
65
|
} : Required<{
|
|
32
|
-
meta?: InferSchemaResult<TSchema["meta"],
|
|
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
|
-
}>)
|
|
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
|
-
|
|
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">,
|
|
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
|
|
123
|
-
}>>(...[initURL, initConfig]: CallApiParameters<TComputedData, TComputedErrorData, TResultMode,
|
|
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
|
|
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"],
|
|
176
|
+
meta?: InferSchemaResult<TSchema["meta"], TComputedCallApiContext["Meta"] extends DefaultMetaObject ? TComputedCallApiContext["Meta"] : DefaultMetaObject, "infer-output"> | undefined;
|
|
145
177
|
} : Required<{
|
|
146
|
-
meta?: InferSchemaResult<TSchema["meta"],
|
|
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
|
-
}>)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
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-
|
|
210
|
+
//# sourceMappingURL=index-bRY6RbJu.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as createFetchClient, r as createFetchClientWithContext, t as callApi } from "./index-
|
|
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 {
|
|
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(
|
|
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";
|
|
@@ -159,8 +159,7 @@ const createProgressEvent = (options) => {
|
|
|
159
159
|
};
|
|
160
160
|
const textEncoder = new TextEncoder();
|
|
161
161
|
const estimateBodySize = (body) => {
|
|
162
|
-
if (!body) return 0;
|
|
163
|
-
if (body instanceof ReadableStream) return 0;
|
|
162
|
+
if (!body || body instanceof ReadableStream) return 0;
|
|
164
163
|
if (body instanceof FormData) {
|
|
165
164
|
let size = 0;
|
|
166
165
|
for (const [key, value] of body) {
|
|
@@ -520,21 +519,21 @@ const setupHooksAndMiddlewares = (context) => {
|
|
|
520
519
|
};
|
|
521
520
|
//#endregion
|
|
522
521
|
//#region src/refetch.ts
|
|
523
|
-
const
|
|
522
|
+
const refetchAttemptTrackerSymbol = Symbol("refetchAttemptTracker");
|
|
524
523
|
const createRefetchManager = (ctx) => {
|
|
525
524
|
const { callApi, callApiArgs, options, removeDedupeCacheEntry } = ctx;
|
|
526
525
|
const shouldAttemptRefetch = () => {
|
|
527
|
-
return options[
|
|
526
|
+
return options[refetchAttemptTrackerSymbol] ?? false;
|
|
528
527
|
};
|
|
529
528
|
const refetch = () => {
|
|
530
|
-
options[
|
|
529
|
+
options[refetchAttemptTrackerSymbol] = true;
|
|
531
530
|
};
|
|
532
531
|
const handleRefetch = () => {
|
|
533
532
|
if (shouldAttemptRefetch()) {
|
|
534
533
|
removeDedupeCacheEntry();
|
|
535
534
|
return callApi(callApiArgs.initURL, {
|
|
536
535
|
...callApiArgs.config,
|
|
537
|
-
[
|
|
536
|
+
[refetchAttemptTrackerSymbol]: false
|
|
538
537
|
});
|
|
539
538
|
}
|
|
540
539
|
return null;
|
|
@@ -550,7 +549,7 @@ const getRetryAfterDelay = (retryAfter) => {
|
|
|
550
549
|
const normalizedRetryAfter = retryAfter?.trim();
|
|
551
550
|
if (!normalizedRetryAfter) return;
|
|
552
551
|
const retryAfterSeconds = Number(normalizedRetryAfter);
|
|
553
|
-
if (Number.
|
|
552
|
+
if (Number.isSafeInteger(retryAfterSeconds) && retryAfterSeconds >= 0) return retryAfterSeconds * 1e3;
|
|
554
553
|
const retryAt = Date.parse(normalizedRetryAfter);
|
|
555
554
|
if (Number.isNaN(retryAt)) return;
|
|
556
555
|
return Math.max(0, retryAt - Date.now());
|
|
@@ -586,7 +585,7 @@ const createRetryManager = (ctx) => {
|
|
|
586
585
|
const retryDelay = options.retryDelay ?? extraOptionDefaults.retryDelay;
|
|
587
586
|
return isFunction(retryDelay) ? retryDelay(currentRetryAttemptCount) : retryDelay;
|
|
588
587
|
}
|
|
589
|
-
default: throw new Error(`Invalid retry strategy: ${
|
|
588
|
+
default: throw new Error(`Invalid retry strategy: ${retryStrategy}`);
|
|
590
589
|
}
|
|
591
590
|
};
|
|
592
591
|
const handleRetry = async () => {
|