@zayne-labs/callapi-plugins 4.0.14 → 4.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.d.ts +23 -18
- package/package.json +3 -3
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as _zayne_labs_callapi_utils0 from "@zayne-labs/callapi/utils";
|
|
2
2
|
import { AnyFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
3
3
|
|
|
4
|
-
//#region ../callapi/dist/esm/validation-
|
|
4
|
+
//#region ../callapi/dist/esm/validation-Dq--Q5zC.d.ts
|
|
5
5
|
//#region src/constants/common.d.ts
|
|
6
6
|
declare const fetchSpecificKeys: readonly (keyof RequestInit | "duplex")[];
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/constants/validation.d.ts
|
|
9
|
-
declare const fallBackRouteSchemaKey = "
|
|
9
|
+
declare const fallBackRouteSchemaKey = "@default";
|
|
10
|
+
type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
|
|
10
11
|
//#endregion
|
|
11
12
|
//#endregion
|
|
12
|
-
//#region ../callapi/dist/esm/common-
|
|
13
|
+
//#region ../callapi/dist/esm/common-CYwKssG-.d.ts
|
|
13
14
|
//#region src/types/type-helpers.d.ts
|
|
14
15
|
type AnyString = string & NonNullable<unknown>;
|
|
15
16
|
type AnyNumber = number & NonNullable<unknown>;
|
|
@@ -378,12 +379,11 @@ interface CallApiSchema {
|
|
|
378
379
|
declare const routeKeyMethods: readonly ["delete", "get", "patch", "post", "put"];
|
|
379
380
|
type RouteKeyMethods = (typeof routeKeyMethods)[number];
|
|
380
381
|
type RouteKeyMethodsURLUnion = `@${RouteKeyMethods}/`;
|
|
381
|
-
type BaseCallApiSchemaRoutes = Partial<Record<AnyString | RouteKeyMethodsURLUnion, CallApiSchema>>;
|
|
382
|
+
type BaseCallApiSchemaRoutes = Partial<Record<AnyString | FallBackRouteSchemaKey | RouteKeyMethodsURLUnion, CallApiSchema>>;
|
|
382
383
|
type BaseCallApiSchemaAndConfig = {
|
|
383
384
|
config?: CallApiSchemaConfig;
|
|
384
385
|
routes: BaseCallApiSchemaRoutes;
|
|
385
386
|
};
|
|
386
|
-
type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
|
|
387
387
|
//#endregion
|
|
388
388
|
//#region src/utils/external/error.d.ts
|
|
389
389
|
type HTTPErrorDetails<TErrorData$1> = Pick<CallApiExtraOptions, "defaultHTTPErrorMessage"> & {
|
|
@@ -446,9 +446,11 @@ declare const getResponseType: <TResponse>(response: Response, parser: Parser<TR
|
|
|
446
446
|
text: () => Promise<string>;
|
|
447
447
|
};
|
|
448
448
|
type InitResponseTypeMap<TResponse$1 = unknown> = ReturnType<typeof getResponseType<TResponse$1>>;
|
|
449
|
-
type ResponseTypeUnion = keyof InitResponseTypeMap
|
|
449
|
+
type ResponseTypeUnion = keyof InitResponseTypeMap;
|
|
450
|
+
type ResponseTypePlaceholder = null;
|
|
451
|
+
type ResponseTypeType = ResponseTypePlaceholder | ResponseTypeUnion;
|
|
450
452
|
type ResponseTypeMap<TResponse$1> = { [Key in keyof InitResponseTypeMap<TResponse$1>]: Awaited<ReturnType<InitResponseTypeMap<TResponse$1>[Key]>> };
|
|
451
|
-
type GetResponseType<TResponse$1, TResponseType extends
|
|
453
|
+
type GetResponseType<TResponse$1, TResponseType extends ResponseTypeType, TComputedResponseTypeMap extends ResponseTypeMap<TResponse$1> = ResponseTypeMap<TResponse$1>> = null extends TResponseType ? TComputedResponseTypeMap["json"] : TResponseType extends NonNullable<ResponseTypeType> ? TComputedResponseTypeMap[TResponseType] : never;
|
|
452
454
|
type CallApiResultSuccessVariant<TData$1> = {
|
|
453
455
|
data: NoInfer<TData$1>;
|
|
454
456
|
error: null;
|
|
@@ -484,19 +486,22 @@ type CallApiResultErrorVariant<TErrorData$1> = {
|
|
|
484
486
|
response: Response | null;
|
|
485
487
|
};
|
|
486
488
|
type CallApiSuccessOrErrorVariant<TData$1, TError> = CallApiResultErrorVariant<TError> | CallApiResultSuccessVariant<TData$1>;
|
|
487
|
-
type ResultModeMapWithoutException<TData$1, TErrorData$1, TResponseType extends
|
|
489
|
+
type ResultModeMapWithoutException<TData$1, TErrorData$1, TResponseType extends ResponseTypeType, TComputedData = GetResponseType<TData$1, TResponseType>, TComputedErrorData = GetResponseType<TErrorData$1, TResponseType>, TComputedResult extends CallApiSuccessOrErrorVariant<TComputedData, TComputedErrorData> = CallApiSuccessOrErrorVariant<TComputedData, TComputedErrorData>> = UnmaskType<{
|
|
488
490
|
all: TComputedResult;
|
|
489
491
|
onlyData: TComputedResult["data"];
|
|
490
492
|
onlyResponse: TComputedResult["response"];
|
|
493
|
+
withoutResponse: TComputedResult["data"] | TComputedResult["error"];
|
|
491
494
|
}>;
|
|
492
|
-
type ResultModeMapWithException<TData$1, TResponseType extends
|
|
495
|
+
type ResultModeMapWithException<TData$1, TResponseType extends ResponseTypeType, TComputedData = GetResponseType<TData$1, TResponseType>, TComputedResult extends CallApiResultSuccessVariant<TComputedData> = CallApiResultSuccessVariant<TComputedData>> = {
|
|
493
496
|
all: TComputedResult;
|
|
494
497
|
onlyData: TComputedResult["data"];
|
|
495
498
|
onlyResponse: TComputedResult["response"];
|
|
499
|
+
withoutResponse: TComputedResult["data"] | TComputedResult["error"];
|
|
496
500
|
};
|
|
497
|
-
type ResultModeMap<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResponseType extends
|
|
501
|
+
type ResultModeMap<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResponseType extends ResponseTypeType = ResponseTypeType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError> = TThrowOnError extends true ? ResultModeMapWithException<TData$1, TResponseType> : ResultModeMapWithoutException<TData$1, TErrorData$1, TResponseType>;
|
|
498
502
|
type ResultModePlaceholder = null;
|
|
499
|
-
type ResultModeUnion = keyof ResultModeMap
|
|
503
|
+
type ResultModeUnion = keyof ResultModeMap;
|
|
504
|
+
type ResultModeType = ResultModePlaceholder | ResultModeUnion;
|
|
500
505
|
//#endregion
|
|
501
506
|
//#region src/middlewares.d.ts
|
|
502
507
|
type FetchImpl = UnmaskType<(input: string | Request | URL, init?: RequestInit) => Promise<Response>>;
|
|
@@ -1170,7 +1175,7 @@ type InferAllRouteKeys<TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TSch
|
|
|
1170
1175
|
type InferInitURL<TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TSchemaConfig$1 extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes$1 extends never ? InitURLOrURLObject : InferAllRouteKeys<TBaseSchemaRoutes$1, TSchemaConfig$1>;
|
|
1171
1176
|
type GetCurrentRouteSchema<TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TComputedFallBackRouteSchema = TBaseSchemaRoutes$1[FallBackRouteSchemaKey], TComputedCurrentRouteSchema = TBaseSchemaRoutes$1[TCurrentRouteSchemaKey], TComputedRouteSchema extends CallApiSchema = NonNullable<Omit<TComputedFallBackRouteSchema, keyof TComputedCurrentRouteSchema> & TComputedCurrentRouteSchema>> = TComputedRouteSchema extends CallApiSchema ? Writeable<TComputedRouteSchema, "deep"> : CallApiSchema;
|
|
1172
1177
|
type JsonPrimitive = boolean | number | string | null | undefined;
|
|
1173
|
-
type SerializableObject = Record<
|
|
1178
|
+
type SerializableObject = Record<PropertyKey, unknown>;
|
|
1174
1179
|
type SerializableArray = Array<JsonPrimitive | SerializableObject> | ReadonlyArray<JsonPrimitive | SerializableObject>;
|
|
1175
1180
|
type Body = UnmaskType<RequestInit["body"] | SerializableArray | SerializableObject>;
|
|
1176
1181
|
type InferBodyOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["body"], {
|
|
@@ -1251,7 +1256,7 @@ type InferParamsOption<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes$1 exte
|
|
|
1251
1256
|
}>;
|
|
1252
1257
|
type InferExtraOptions<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = InferMetaOption<TSchema$1> & InferParamsOption<TSchema$1, TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> & InferQueryOption<TSchema$1>;
|
|
1253
1258
|
type InferPluginOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction$1<infer TReturnedSchema> ? InferSchemaInput<TReturnedSchema> : never : never : never>;
|
|
1254
|
-
type ResultModeOption<TErrorData$1, TResultMode extends
|
|
1259
|
+
type ResultModeOption<TErrorData$1, TResultMode extends ResultModeType> = TErrorData$1 extends false ? {
|
|
1255
1260
|
resultMode: "onlyData";
|
|
1256
1261
|
} : TErrorData$1 extends false | undefined ? {
|
|
1257
1262
|
resultMode?: "onlyData";
|
|
@@ -1291,7 +1296,7 @@ type CallApiRequestOptions = Prettify<{
|
|
|
1291
1296
|
type CallApiRequestOptionsForHooks = Omit<CallApiRequestOptions, "headers"> & {
|
|
1292
1297
|
headers: Record<string, string | undefined>;
|
|
1293
1298
|
};
|
|
1294
|
-
type SharedExtraOptions<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResultMode extends
|
|
1299
|
+
type SharedExtraOptions<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = DedupeOptions & HookConfigOptions & HooksOrHooksArray<TData$1, TErrorData$1, Partial<InferPluginOptions<TPluginArray>>> & Middlewares & Partial<InferPluginOptions<TPluginArray>> & ResultModeOption<TErrorData$1, TResultMode> & RetryOptions<TErrorData$1> & ThrowOnErrorOption<TErrorData$1, TThrowOnError> & URLOptions & {
|
|
1295
1300
|
/**
|
|
1296
1301
|
* Automatically add an Authorization header value.
|
|
1297
1302
|
*
|
|
@@ -1665,7 +1670,7 @@ type SharedExtraOptions<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataTyp
|
|
|
1665
1670
|
*/
|
|
1666
1671
|
timeout?: number;
|
|
1667
1672
|
};
|
|
1668
|
-
type BaseCallApiExtraOptions<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends
|
|
1673
|
+
type BaseCallApiExtraOptions<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeType = ResultModeType, TBaseThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TBaseResponseType extends ResponseTypeType = ResponseTypeType, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig> = SharedExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray> & {
|
|
1669
1674
|
/**
|
|
1670
1675
|
* Array of base CallApi plugins to extend library functionality.
|
|
1671
1676
|
*
|
|
@@ -1775,7 +1780,7 @@ type InferExtendSchemaConfigContext<TBaseSchemaConfig extends CallApiSchemaConfi
|
|
|
1775
1780
|
type InferExtendPluginContext<TBasePluginArray extends CallApiPlugin[]> = {
|
|
1776
1781
|
basePlugins: TBasePluginArray;
|
|
1777
1782
|
};
|
|
1778
|
-
type CallApiExtraOptions<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResultMode extends
|
|
1783
|
+
type CallApiExtraOptions<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema$1 extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig$1 extends CallApiSchemaConfig = CallApiSchemaConfig, TCurrentRouteSchemaKey extends string = string, TComputedPluginContext = InferExtendPluginContext<TBasePluginArray>, TComputedSchemaContext = InferExtendSchemaContext<TBaseSchemaRoutes$1, TCurrentRouteSchemaKey>, TComputedSchemaConfigContext = InferExtendSchemaConfigContext<TBaseSchemaConfig>> = SharedExtraOptions<TData$1, TErrorData$1, TResultMode, TThrowOnError, TResponseType, TPluginArray> & {
|
|
1779
1784
|
/**
|
|
1780
1785
|
* Array of instance-specific CallApi plugins or a function to configure plugins.
|
|
1781
1786
|
*
|
|
@@ -1809,8 +1814,8 @@ type BaseInstanceContext = {
|
|
|
1809
1814
|
options: CallApiExtraOptions;
|
|
1810
1815
|
request: CallApiRequestOptions;
|
|
1811
1816
|
};
|
|
1812
|
-
type BaseCallApiConfig<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends
|
|
1813
|
-
type CallApiConfig<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResultMode extends
|
|
1817
|
+
type BaseCallApiConfig<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeType = ResultModeType, TBaseThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TBaseResponseType extends ResponseTypeType = ResponseTypeType, TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedBaseConfig = BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemaAndConfig>> = (CallApiRequestOptions & TComputedBaseConfig) | ((context: BaseInstanceContext) => CallApiRequestOptions & TComputedBaseConfig);
|
|
1818
|
+
type CallApiConfig<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema$1 extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig$1 extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InitURLOrURLObject = InitURLOrURLObject, TCurrentRouteSchemaKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = InferExtraOptions<TSchema$1, TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> & InferRequestOptions<TSchema$1, TInitURL> & Omit<CallApiExtraOptions<TData$1, TErrorData$1, TResultMode, TThrowOnError, TResponseType, TBasePluginArray, TPluginArray, TBaseSchemaRoutes$1, TSchema$1, TBaseSchemaConfig, TSchemaConfig$1, TCurrentRouteSchemaKey>, keyof InferExtraOptions<CallApiSchema, BaseCallApiSchemaRoutes, string>> & Omit<CallApiRequestOptions, keyof InferRequestOptions<CallApiSchema, string>>;
|
|
1814
1819
|
//#endregion
|
|
1815
1820
|
//#region src/logger/logger.d.ts
|
|
1816
1821
|
type ConsoleLikeObject = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zayne-labs/callapi-plugins",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.16",
|
|
5
5
|
"description": "A collection of plugins for callapi",
|
|
6
6
|
"author": "Ryan Zayne",
|
|
7
7
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@zayne-labs/toolkit-type-helpers": ">=0.11.17",
|
|
23
23
|
"consola": "3.x.x",
|
|
24
|
-
"@zayne-labs/callapi": "1.11.
|
|
24
|
+
"@zayne-labs/callapi": "1.11.16"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@arethetypeswrong/cli": "0.18.2",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"tsdown": "^0.15.9",
|
|
39
39
|
"typescript": "5.9.3",
|
|
40
40
|
"vitest": "^4.0.1",
|
|
41
|
-
"@zayne-labs/callapi": "1.11.
|
|
41
|
+
"@zayne-labs/callapi": "1.11.16"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public",
|