@zayne-labs/callapi-plugins 4.0.19 → 4.0.21

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.
Files changed (2) hide show
  1. package/dist/esm/index.d.ts +26 -14
  2. package/package.json +3 -3
@@ -10,7 +10,7 @@ declare const fallBackRouteSchemaKey = "@default";
10
10
  type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
11
11
  //#endregion
12
12
  //#endregion
13
- //#region ../callapi/dist/esm/common-BH5urZ-n.d.ts
13
+ //#region ../callapi/dist/esm/common-C7HSoU-H.d.ts
14
14
  //#region src/types/type-helpers.d.ts
15
15
  type AnyString = string & NonNullable<unknown>;
16
16
  type AnyNumber = number & NonNullable<unknown>;
@@ -305,7 +305,7 @@ interface URLOptions {
305
305
  //#region src/validation.d.ts
306
306
  type ResultVariant = "infer-input" | "infer-output";
307
307
  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;
308
- type InferSchemaInput<TSchema$1, TFallbackResult = unknown> = InferSchemaResult<TSchema$1, TFallbackResult, "infer-input">;
308
+ type InferSchemaOutput<TSchema$1, TFallbackResult = unknown> = InferSchemaResult<TSchema$1, TFallbackResult, "infer-output">;
309
309
  interface CallApiSchemaConfig {
310
310
  /**
311
311
  * The base url of the schema. By default it's the baseURL of the callApi instance.
@@ -456,6 +456,10 @@ type CallApiResultSuccessVariant<TData$1> = {
456
456
  error: null;
457
457
  response: Response;
458
458
  };
459
+ type CallApiResultSuccessVariantWithoutResponse<TData$1> = {
460
+ data: NoInfer<TData$1>;
461
+ error: null;
462
+ };
459
463
  type PossibleJavaScriptError = UnmaskType<{
460
464
  errorData: false;
461
465
  message: string;
@@ -485,18 +489,26 @@ type CallApiResultErrorVariant<TErrorData$1> = {
485
489
  error: PossibleJavaScriptOrValidationError;
486
490
  response: Response | null;
487
491
  };
492
+ type CallApiResultErrorVariantWithoutResponse<TErrorData$1> = {
493
+ data: null;
494
+ error: PossibleHTTPError<TErrorData$1>;
495
+ } | {
496
+ data: null;
497
+ error: PossibleJavaScriptOrValidationError;
498
+ };
488
499
  type CallApiSuccessOrErrorVariant<TData$1, TError> = CallApiResultErrorVariant<TError> | CallApiResultSuccessVariant<TData$1>;
500
+ type CallApiSuccessOrErrorVariantWithoutResponse<TData$1, TErrorData$1> = CallApiResultErrorVariantWithoutResponse<TErrorData$1> | CallApiResultSuccessVariantWithoutResponse<TData$1>;
489
501
  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<{
490
502
  all: TComputedResult;
491
503
  onlyData: TComputedResult["data"];
492
504
  onlyResponse: TComputedResult["response"];
493
- withoutResponse: Omit<TComputedResult, "response">;
505
+ withoutResponse: CallApiSuccessOrErrorVariantWithoutResponse<TComputedData, TComputedErrorData>;
494
506
  }>;
495
507
  type ResultModeMapWithException<TData$1, TResponseType extends ResponseTypeType, TComputedData = GetResponseType<TData$1, TResponseType>, TComputedResult extends CallApiResultSuccessVariant<TComputedData> = CallApiResultSuccessVariant<TComputedData>> = {
496
508
  all: TComputedResult;
497
509
  onlyData: TComputedResult["data"];
498
510
  onlyResponse: TComputedResult["response"];
499
- withoutResponse: Omit<TComputedResult, "response">;
511
+ withoutResponse: CallApiResultSuccessVariantWithoutResponse<TComputedData>;
500
512
  };
501
513
  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>;
502
514
  type ResultModePlaceholder = null;
@@ -1165,7 +1177,7 @@ interface RetryOptions<TErrorData$1> {
1165
1177
  /**
1166
1178
  * @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
1167
1179
  */
1168
- type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaInput<TSchemaOption, undefined> ? TObject : Required<TObject>;
1180
+ type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaOutput<TSchemaOption, undefined> ? TObject : Required<TObject>;
1169
1181
  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;
1170
1182
  type ApplyStrictConfig<TSchemaConfig$1 extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig$1["strict"] extends true ? TSchemaRouteKeys :
1171
1183
  // eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
@@ -1182,7 +1194,7 @@ type InferBodyOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequired
1182
1194
  /**
1183
1195
  * Body of the request, can be a object or any other supported body type.
1184
1196
  */
1185
- body?: InferSchemaInput<TSchema$1["body"], Body>;
1197
+ body?: InferSchemaOutput<TSchema$1["body"], Body>;
1186
1198
  }>;
1187
1199
  type MethodUnion = UnmaskType<"CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" | AnyString>;
1188
1200
  type InferMethodFromURL<TInitURL> = string extends TInitURL ? MethodUnion : TInitURL extends `@${infer TMethod extends RouteKeyMethods}/${string}` ? Uppercase<TMethod> : MethodUnion;
@@ -1191,16 +1203,16 @@ type InferMethodOption<TSchema$1 extends CallApiSchema, TInitURL> = MakeSchemaOp
1191
1203
  * HTTP method for the request.
1192
1204
  * @default "GET"
1193
1205
  */
1194
- method?: InferSchemaInput<TSchema$1["method"], InferMethodFromURL<TInitURL>>;
1206
+ method?: InferSchemaOutput<TSchema$1["method"], InferMethodFromURL<TInitURL>>;
1195
1207
  }>;
1196
1208
  type HeadersOption = UnmaskType<Record<"Authorization", CommonAuthorizationHeaders | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | Array<[string, string]>>;
1197
1209
  type InferHeadersOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["headers"], {
1198
1210
  /**
1199
1211
  * Headers to be used in the request.
1200
1212
  */
1201
- headers?: InferSchemaInput<TSchema$1["headers"], HeadersOption> | ((context: {
1213
+ headers?: InferSchemaOutput<TSchema$1["headers"], HeadersOption> | ((context: {
1202
1214
  baseHeaders: NonNullable<HeadersOption>;
1203
- }) => InferSchemaInput<TSchema$1["headers"], HeadersOption>);
1215
+ }) => InferSchemaOutput<TSchema$1["headers"], HeadersOption>);
1204
1216
  }>;
1205
1217
  type InferRequestOptions<TSchema$1 extends CallApiSchema, TInitURL extends InferInitURL<BaseCallApiSchemaRoutes, CallApiSchemaConfig>> = InferBodyOption<TSchema$1> & InferHeadersOption<TSchema$1> & InferMethodOption<TSchema$1, TInitURL>;
1206
1218
  interface Register {}
@@ -1231,13 +1243,13 @@ type InferMetaOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequired
1231
1243
  * });
1232
1244
  * ```
1233
1245
  */
1234
- meta?: InferSchemaInput<TSchema$1["meta"], GlobalMeta>;
1246
+ meta?: InferSchemaOutput<TSchema$1["meta"], GlobalMeta>;
1235
1247
  }>;
1236
1248
  type InferQueryOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["query"], {
1237
1249
  /**
1238
1250
  * Parameters to be appended to the URL (i.e: /:id)
1239
1251
  */
1240
- query?: InferSchemaInput<TSchema$1["query"], Query>;
1252
+ query?: InferSchemaOutput<TSchema$1["query"], Query>;
1241
1253
  }>;
1242
1254
  type EmptyString = "";
1243
1255
  type EmptyTuple = readonly [];
@@ -1247,15 +1259,15 @@ type ExtractRouteParamNames<TCurrentRoute$1, TParamNamesAccumulator extends Stri
1247
1259
  type ConvertParamNamesToRecord<TParamNames extends StringTuple> = Prettify<TParamNames extends (readonly [infer TFirstParamName extends string, ...infer TRemainingParamNames extends StringTuple]) ? Record<TFirstParamName, AllowedQueryParamValues> & ConvertParamNamesToRecord<TRemainingParamNames> : NonNullable<unknown>>;
1248
1260
  type ConvertParamNamesToTuple<TParamNames extends StringTuple> = TParamNames extends readonly [string, ...infer TRemainingParamNames extends StringTuple] ? [AllowedQueryParamValues, ...ConvertParamNamesToTuple<TRemainingParamNames>] : [];
1249
1261
  type InferParamsFromRoute<TCurrentRoute$1> = ExtractRouteParamNames<TCurrentRoute$1> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute$1> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute$1>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute$1>> : Params;
1250
- 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>;
1262
+ 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 InferSchemaOutput<TParamsSchemaOption, null> ? TObject : Required<TObject> : TObject>;
1251
1263
  type InferParamsOption<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema$1["params"], TBaseSchemaRoutes$1, TCurrentRouteSchemaKey, {
1252
1264
  /**
1253
1265
  * Parameters to be appended to the URL (i.e: /:id)
1254
1266
  */
1255
- params?: InferSchemaInput<TSchema$1["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
1267
+ params?: InferSchemaOutput<TSchema$1["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
1256
1268
  }>;
1257
1269
  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>;
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>;
1270
+ type InferPluginOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction$1<infer TReturnedSchema> ? InferSchemaOutput<TReturnedSchema> : never : never : never>;
1259
1271
  type ResultModeOption<TErrorData$1, TResultMode extends ResultModeType> = TErrorData$1 extends false ? {
1260
1272
  resultMode: "onlyData";
1261
1273
  } : 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.19",
4
+ "version": "4.0.21",
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.19"
24
+ "@zayne-labs/callapi": "1.11.21"
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.19"
41
+ "@zayne-labs/callapi": "1.11.21"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public",