@zayne-labs/callapi-plugins 4.0.11 → 4.0.12
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 +29 -24
- package/package.json +3 -3
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
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/
|
|
4
|
+
//#region ../callapi/dist/esm/validation-uPnlxhfx.d.ts
|
|
5
|
+
//#region src/constants/common.d.ts
|
|
6
|
+
declare const fetchSpecificKeys: readonly (keyof RequestInit | "duplex")[];
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/constants/validation.d.ts
|
|
9
|
+
declare const fallBackRouteSchemaKey = ".";
|
|
10
|
+
//#endregion
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region ../callapi/dist/esm/common-Clx7i8bR.d.ts
|
|
5
13
|
//#region src/types/type-helpers.d.ts
|
|
6
14
|
type AnyString = string & NonNullable<unknown>;
|
|
7
15
|
type AnyNumber = number & NonNullable<unknown>;
|
|
@@ -65,8 +73,13 @@ type CustomAuth = {
|
|
|
65
73
|
};
|
|
66
74
|
type Auth = PossibleAuthValueOrGetter | BearerOrTokenAuth | BasicAuth | CustomAuth;
|
|
67
75
|
//#endregion
|
|
68
|
-
//#region src/
|
|
69
|
-
|
|
76
|
+
//#region src/utils/external/body.d.ts
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/types/default-types.d.ts
|
|
80
|
+
type DefaultDataType = unknown;
|
|
81
|
+
type DefaultPluginArray = CallApiPlugin[];
|
|
82
|
+
type DefaultThrowOnError = boolean;
|
|
70
83
|
//#endregion
|
|
71
84
|
//#region src/types/standard-schema.d.ts
|
|
72
85
|
/**
|
|
@@ -289,8 +302,9 @@ interface URLOptions {
|
|
|
289
302
|
}
|
|
290
303
|
//#endregion
|
|
291
304
|
//#region src/validation.d.ts
|
|
292
|
-
type
|
|
293
|
-
type
|
|
305
|
+
type ResultVariant = "infer-input" | "infer-output";
|
|
306
|
+
type InferSchemaResult<TSchema$1, TFallbackResult, TResultVariant extends ResultVariant> = undefined extends TSchema$1 ? TFallbackResult : TSchema$1 extends StandardSchemaV1 ? TResultVariant extends "infer-input" ? StandardSchemaV1.InferInput<TSchema$1> : StandardSchemaV1.InferOutput<TSchema$1> : TSchema$1 extends AnyFunction$1<infer TResult> ? Awaited<TResult> : TFallbackResult;
|
|
307
|
+
type InferSchemaInput<TSchema$1, TFallbackResult = unknown> = InferSchemaResult<TSchema$1, TFallbackResult, "infer-input">;
|
|
294
308
|
interface CallApiSchemaConfig {
|
|
295
309
|
/**
|
|
296
310
|
* The base url of the schema. By default it's the baseURL of the callApi instance.
|
|
@@ -369,17 +383,8 @@ type BaseCallApiSchemaAndConfig = {
|
|
|
369
383
|
config?: CallApiSchemaConfig;
|
|
370
384
|
routes: BaseCallApiSchemaRoutes;
|
|
371
385
|
};
|
|
372
|
-
declare const fallBackRouteSchemaKey = ".";
|
|
373
386
|
type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
|
|
374
387
|
//#endregion
|
|
375
|
-
//#region src/utils/external/body.d.ts
|
|
376
|
-
|
|
377
|
-
//#endregion
|
|
378
|
-
//#region src/types/default-types.d.ts
|
|
379
|
-
type DefaultDataType = unknown;
|
|
380
|
-
type DefaultPluginArray = CallApiPlugin[];
|
|
381
|
-
type DefaultThrowOnError = boolean;
|
|
382
|
-
//#endregion
|
|
383
388
|
//#region src/utils/external/error.d.ts
|
|
384
389
|
type HTTPErrorDetails<TErrorData$1> = Pick<CallApiExtraOptions, "defaultHTTPErrorMessage"> & {
|
|
385
390
|
errorData: TErrorData$1;
|
|
@@ -1155,7 +1160,7 @@ interface RetryOptions<TErrorData$1> {
|
|
|
1155
1160
|
/**
|
|
1156
1161
|
* @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
|
|
1157
1162
|
*/
|
|
1158
|
-
type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends
|
|
1163
|
+
type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaInput<TSchemaOption, undefined> ? TObject : Required<TObject>;
|
|
1159
1164
|
type ApplyURLBasedConfig<TSchemaConfig$1 extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig$1["prefix"] extends string ? `${TSchemaConfig$1["prefix"]}${TSchemaRouteKeys}` : TSchemaConfig$1["baseURL"] extends string ? `${TSchemaConfig$1["baseURL"]}${TSchemaRouteKeys}` : TSchemaRouteKeys;
|
|
1160
1165
|
type ApplyStrictConfig<TSchemaConfig$1 extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig$1["strict"] extends true ? TSchemaRouteKeys :
|
|
1161
1166
|
// eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
|
|
@@ -1172,7 +1177,7 @@ type InferBodyOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequired
|
|
|
1172
1177
|
/**
|
|
1173
1178
|
* Body of the request, can be a object or any other supported body type.
|
|
1174
1179
|
*/
|
|
1175
|
-
body?:
|
|
1180
|
+
body?: InferSchemaInput<TSchema$1["body"], Body>;
|
|
1176
1181
|
}>;
|
|
1177
1182
|
type MethodUnion = UnmaskType<"CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" | AnyString>;
|
|
1178
1183
|
type InferMethodFromURL<TInitURL> = string extends TInitURL ? MethodUnion : TInitURL extends `@${infer TMethod extends RouteKeyMethods}/${string}` ? Uppercase<TMethod> : MethodUnion;
|
|
@@ -1181,16 +1186,16 @@ type InferMethodOption<TSchema$1 extends CallApiSchema, TInitURL> = MakeSchemaOp
|
|
|
1181
1186
|
* HTTP method for the request.
|
|
1182
1187
|
* @default "GET"
|
|
1183
1188
|
*/
|
|
1184
|
-
method?:
|
|
1189
|
+
method?: InferSchemaInput<TSchema$1["method"], InferMethodFromURL<TInitURL>>;
|
|
1185
1190
|
}>;
|
|
1186
1191
|
type HeadersOption = UnmaskType<Record<"Authorization", CommonAuthorizationHeaders | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | Array<[string, string]>>;
|
|
1187
1192
|
type InferHeadersOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["headers"], {
|
|
1188
1193
|
/**
|
|
1189
1194
|
* Headers to be used in the request.
|
|
1190
1195
|
*/
|
|
1191
|
-
headers?:
|
|
1196
|
+
headers?: InferSchemaInput<TSchema$1["headers"], HeadersOption> | ((context: {
|
|
1192
1197
|
baseHeaders: NonNullable<HeadersOption>;
|
|
1193
|
-
}) =>
|
|
1198
|
+
}) => InferSchemaInput<TSchema$1["headers"], HeadersOption>);
|
|
1194
1199
|
}>;
|
|
1195
1200
|
type InferRequestOptions<TSchema$1 extends CallApiSchema, TInitURL extends InferInitURL<BaseCallApiSchemaRoutes, CallApiSchemaConfig>> = InferBodyOption<TSchema$1> & InferHeadersOption<TSchema$1> & InferMethodOption<TSchema$1, TInitURL>;
|
|
1196
1201
|
interface Register {}
|
|
@@ -1221,13 +1226,13 @@ type InferMetaOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequired
|
|
|
1221
1226
|
* });
|
|
1222
1227
|
* ```
|
|
1223
1228
|
*/
|
|
1224
|
-
meta?:
|
|
1229
|
+
meta?: InferSchemaInput<TSchema$1["meta"], GlobalMeta>;
|
|
1225
1230
|
}>;
|
|
1226
1231
|
type InferQueryOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["query"], {
|
|
1227
1232
|
/**
|
|
1228
1233
|
* Parameters to be appended to the URL (i.e: /:id)
|
|
1229
1234
|
*/
|
|
1230
|
-
query?:
|
|
1235
|
+
query?: InferSchemaInput<TSchema$1["query"], Query>;
|
|
1231
1236
|
}>;
|
|
1232
1237
|
type EmptyString = "";
|
|
1233
1238
|
type EmptyTuple = readonly [];
|
|
@@ -1237,15 +1242,15 @@ type ExtractRouteParamNames<TCurrentRoute$1, TParamNamesAccumulator extends Stri
|
|
|
1237
1242
|
type ConvertParamNamesToRecord<TParamNames extends StringTuple> = Prettify<TParamNames extends (readonly [infer TFirstParamName extends string, ...infer TRemainingParamNames extends StringTuple]) ? Record<TFirstParamName, AllowedQueryParamValues> & ConvertParamNamesToRecord<TRemainingParamNames> : NonNullable<unknown>>;
|
|
1238
1243
|
type ConvertParamNamesToTuple<TParamNames extends StringTuple> = TParamNames extends readonly [string, ...infer TRemainingParamNames extends StringTuple] ? [AllowedQueryParamValues, ...ConvertParamNamesToTuple<TRemainingParamNames>] : [];
|
|
1239
1244
|
type InferParamsFromRoute<TCurrentRoute$1> = ExtractRouteParamNames<TCurrentRoute$1> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute$1> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute$1>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute$1>> : Params;
|
|
1240
|
-
type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> ? undefined extends
|
|
1245
|
+
type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> ? undefined extends InferSchemaInput<TParamsSchemaOption, null> ? TObject : Required<TObject> : TObject>;
|
|
1241
1246
|
type InferParamsOption<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema$1["params"], TBaseSchemaRoutes$1, TCurrentRouteSchemaKey, {
|
|
1242
1247
|
/**
|
|
1243
1248
|
* Parameters to be appended to the URL (i.e: /:id)
|
|
1244
1249
|
*/
|
|
1245
|
-
params?:
|
|
1250
|
+
params?: InferSchemaInput<TSchema$1["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
|
|
1246
1251
|
}>;
|
|
1247
1252
|
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>;
|
|
1248
|
-
type InferPluginOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction$1<infer TReturnedSchema> ?
|
|
1253
|
+
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>;
|
|
1249
1254
|
type ResultModeOption<TErrorData$1, TResultMode extends ResultModeUnion> = TErrorData$1 extends false ? {
|
|
1250
1255
|
resultMode: "onlyData";
|
|
1251
1256
|
} : TErrorData$1 extends false | undefined ? {
|
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.12",
|
|
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.12"
|
|
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.12"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public",
|