@zayne-labs/callapi-plugins 4.0.24 → 4.0.26

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/index.d.ts +228 -234
  2. package/package.json +4 -4
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ declare const fallBackRouteSchemaKey = "@default";
10
10
  type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
11
11
  //#endregion
12
12
  //#endregion
13
- //#region ../callapi/dist/common-Bkz3oogl.d.ts
13
+ //#region ../callapi/dist/validation-BeCBQ6_6.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>;
@@ -31,6 +31,7 @@ type UnmaskType<TValue$1> = {
31
31
  }["_"];
32
32
  type RemovePrefix<TPrefix extends "dedupe" | "retry", TKey extends string> = TKey extends `${TPrefix}${infer TRest}` ? Uncapitalize<TRest> : TKey;
33
33
  type Awaitable<TValue$1> = Promise<TValue$1> | TValue$1;
34
+ type DistributiveOmit<TObject, TKeysToOmit extends keyof TObject> = TObject extends unknown ? Omit<TObject, TKeysToOmit> : never;
34
35
  type CommonRequestHeaders = "Access-Control-Allow-Credentials" | "Access-Control-Allow-Headers" | "Access-Control-Allow-Methods" | "Access-Control-Allow-Origin" | "Access-Control-Expose-Headers" | "Access-Control-Max-Age" | "Age" | "Allow" | "Cache-Control" | "Clear-Site-Data" | "Content-Disposition" | "Content-Encoding" | "Content-Language" | "Content-Length" | "Content-Location" | "Content-Range" | "Content-Security-Policy-Report-Only" | "Content-Security-Policy" | "Cookie" | "Cross-Origin-Embedder-Policy" | "Cross-Origin-Opener-Policy" | "Cross-Origin-Resource-Policy" | "Date" | "ETag" | "Expires" | "Last-Modified" | "Location" | "Permissions-Policy" | "Pragma" | "Retry-After" | "Save-Data" | "Sec-CH-Prefers-Color-Scheme" | "Sec-CH-Prefers-Reduced-Motion" | "Sec-CH-UA-Arch" | "Sec-CH-UA-Bitness" | "Sec-CH-UA-Form-Factor" | "Sec-CH-UA-Full-Version-List" | "Sec-CH-UA-Full-Version" | "Sec-CH-UA-Mobile" | "Sec-CH-UA-Model" | "Sec-CH-UA-Platform-Version" | "Sec-CH-UA-Platform" | "Sec-CH-UA-WoW64" | "Sec-CH-UA" | "Sec-Fetch-Dest" | "Sec-Fetch-Mode" | "Sec-Fetch-Site" | "Sec-Fetch-User" | "Sec-GPC" | "Server-Timing" | "Server" | "Service-Worker-Navigation-Preload" | "Set-Cookie" | "Strict-Transport-Security" | "Timing-Allow-Origin" | "Trailer" | "Transfer-Encoding" | "Upgrade" | "Vary" | "Warning" | "WWW-Authenticate" | "X-Content-Type-Options" | "X-DNS-Prefetch-Control" | "X-Frame-Options" | "X-Permitted-Cross-Domain-Policies" | "X-Powered-By" | "X-Robots-Tag" | "X-XSS-Protection" | AnyString;
35
36
  type CommonAuthorizationHeaders = `${"Basic" | "Bearer" | "Token"} ${string}`;
36
37
  type CommonContentTypes = "application/epub+zip" | "application/gzip" | "application/json" | "application/ld+json" | "application/octet-stream" | "application/ogg" | "application/pdf" | "application/rtf" | "application/vnd.ms-fontobject" | "application/wasm" | "application/xhtml+xml" | "application/xml" | "application/zip" | "audio/aac" | "audio/mpeg" | "audio/ogg" | "audio/opus" | "audio/webm" | "audio/x-midi" | "font/otf" | "font/ttf" | "font/woff" | "font/woff2" | "image/avif" | "image/bmp" | "image/gif" | "image/jpeg" | "image/png" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/x-icon" | "model/gltf-binary" | "model/gltf+json" | "text/calendar" | "text/css" | "text/csv" | "text/html" | "text/javascript" | "text/plain" | "video/3gpp" | "video/3gpp2" | "video/av1" | "video/mp2t" | "video/mp4" | "video/mpeg" | "video/ogg" | "video/webm" | "video/x-msvideo" | AnyString;
@@ -182,210 +183,6 @@ declare namespace StandardSchemaV1 {
182
183
  type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
183
184
  }
184
185
  //#endregion
185
- //#region src/url.d.ts
186
- type AllowedQueryParamValues = UnmaskType<boolean | number | string>;
187
- type RecordStyleParams = UnmaskType<Record<string, AllowedQueryParamValues>>;
188
- type TupleStyleParams = UnmaskType<AllowedQueryParamValues[]>;
189
- type Params = UnmaskType<RecordStyleParams | TupleStyleParams>;
190
- type Query = UnmaskType<Record<string, AllowedQueryParamValues>>;
191
- type InitURLOrURLObject = AnyString | RouteKeyMethodsURLUnion | URL;
192
- interface URLOptions {
193
- /**
194
- * Base URL for all API requests. Will only be prepended to relative URLs.
195
- *
196
- * Absolute URLs (starting with http/https) will not be prepended by the baseURL.
197
- *
198
- * @example
199
- * ```ts
200
- * // Set base URL for all requests
201
- * baseURL: "https://api.example.com/v1"
202
- *
203
- * // Then use relative URLs in requests
204
- * callApi("/users") // → https://api.example.com/v1/users
205
- * callApi("/posts/123") // → https://api.example.com/v1/posts/123
206
- *
207
- * // Environment-specific base URLs
208
- * baseURL: process.env.NODE_ENV === "production"
209
- * ? "https://api.example.com"
210
- * : "http://localhost:3000/api"
211
- * ```
212
- */
213
- baseURL?: string;
214
- /**
215
- * Resolved request URL after processing baseURL, parameters, and query strings (readonly)
216
- *
217
- * This is the final URL that will be used for the HTTP request, computed from
218
- * baseURL, initURL, params, and query parameters.
219
- *
220
- */
221
- readonly fullURL?: string;
222
- /**
223
- * The original URL string passed to the callApi instance (readonly)
224
- *
225
- * This preserves the original URL as provided, including any method modifiers like "@get/" or "@post/".
226
- *
227
- */
228
- readonly initURL?: string;
229
- /**
230
- * The URL string after normalization, with method modifiers removed(readonly)
231
- *
232
- * Method modifiers like "@get/", "@post/" are stripped to create a clean URL
233
- * for parameter substitution and final URL construction.
234
- *
235
- */
236
- readonly initURLNormalized?: string;
237
- /**
238
- * Parameters to be substituted into URL path segments.
239
- *
240
- * Supports both object-style (named parameters) and array-style (positional parameters)
241
- * for flexible URL parameter substitution.
242
- *
243
- * @example
244
- * ```typescript
245
- * // Object-style parameters (recommended)
246
- * const namedParams: URLOptions = {
247
- * initURL: "/users/:userId/posts/:postId",
248
- * params: { userId: "123", postId: "456" }
249
- * };
250
- * // Results in: /users/123/posts/456
251
- *
252
- * // Array-style parameters (positional)
253
- * const positionalParams: URLOptions = {
254
- * initURL: "/users/:userId/posts/:postId",
255
- * params: ["123", "456"] // Maps in order: userId=123, postId=456
256
- * };
257
- * // Results in: /users/123/posts/456
258
- *
259
- * // Single parameter
260
- * const singleParam: URLOptions = {
261
- * initURL: "/users/:id",
262
- * params: { id: "user-123" }
263
- * };
264
- * // Results in: /users/user-123
265
- * ```
266
- */
267
- params?: Params;
268
- /**
269
- * Query parameters to append to the URL as search parameters.
270
- *
271
- * These will be serialized into the URL query string using standard
272
- * URL encoding practices.
273
- *
274
- * @example
275
- * ```typescript
276
- * // Basic query parameters
277
- * const queryOptions: URLOptions = {
278
- * initURL: "/users",
279
- * query: {
280
- * page: 1,
281
- * limit: 10,
282
- * search: "john doe",
283
- * active: true
284
- * }
285
- * };
286
- * // Results in: /users?page=1&limit=10&search=john%20doe&active=true
287
- *
288
- * // Filtering and sorting
289
- * const filterOptions: URLOptions = {
290
- * initURL: "/products",
291
- * query: {
292
- * category: "electronics",
293
- * minPrice: 100,
294
- * maxPrice: 500,
295
- * sortBy: "price",
296
- * order: "asc"
297
- * }
298
- * };
299
- * // Results in: /products?category=electronics&minPrice=100&maxPrice=500&sortBy=price&order=asc
300
- * ```
301
- */
302
- query?: Query;
303
- }
304
- //#endregion
305
- //#region src/validation.d.ts
306
- type ResultVariant = "infer-input" | "infer-output";
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 InferSchemaOutput<TSchema$1, TFallbackResult = unknown> = InferSchemaResult<TSchema$1, TFallbackResult, "infer-output">;
309
- interface CallApiSchemaConfig {
310
- /**
311
- * The base url of the schema. By default it's the baseURL of the callApi instance.
312
- */
313
- baseURL?: string;
314
- /**
315
- * Disables runtime validation for the schema.
316
- */
317
- disableRuntimeValidation?: boolean;
318
- /**
319
- * If `true`, the original input value will be used instead of the transformed/validated output.
320
- *
321
- * This is useful when you want to validate the input but don't want any transformations
322
- * applied by the validation schema (e.g., type coercion, default values, etc).
323
- */
324
- disableValidationOutputApplication?: boolean;
325
- /**
326
- * Optional url prefix that will be substituted for the `baseURL` of the schemaConfig at runtime.
327
- *
328
- * This allows you to reuse the same schema against different base URLs (for example,
329
- * swapping between `/api/v1` and `/api/v2`) without redefining the entire schema.
330
- */
331
- prefix?: string;
332
- /**
333
- * Controls the strictness of API route validation.
334
- *
335
- * When true:
336
- * - Only routes explicitly defined in the schema will be considered valid to typescript and the runtime.
337
- * - Attempting to call routes not defined in the schema will result in both type errors and runtime validation errors.
338
- * - Useful for ensuring API calls conform exactly to your schema definition
339
- *
340
- * When false or undefined (default):
341
- * - All routes will be allowed, whether they are defined in the schema or not
342
- */
343
- strict?: boolean;
344
- }
345
- interface CallApiSchema {
346
- /**
347
- * The schema to use for validating the request body.
348
- */
349
- body?: StandardSchemaV1<Body | undefined> | ((body: Body) => Awaitable<Body | undefined>);
350
- /**
351
- * The schema to use for validating the response data.
352
- */
353
- data?: StandardSchemaV1 | ((data: unknown) => unknown);
354
- /**
355
- * The schema to use for validating the response error data.
356
- */
357
- errorData?: StandardSchemaV1 | ((errorData: unknown) => unknown);
358
- /**
359
- * The schema to use for validating the request headers.
360
- */
361
- headers?: StandardSchemaV1<HeadersOption | undefined> | ((headers: HeadersOption) => Awaitable<HeadersOption | undefined>);
362
- /**
363
- * The schema to use for validating the meta option.
364
- */
365
- meta?: StandardSchemaV1<GlobalMeta | undefined> | ((meta: GlobalMeta) => Awaitable<GlobalMeta | undefined>);
366
- /**
367
- * The schema to use for validating the request method.
368
- */
369
- method?: StandardSchemaV1<MethodUnion | undefined> | ((method: MethodUnion) => Awaitable<MethodUnion | undefined>);
370
- /**
371
- * The schema to use for validating the request url parameters.
372
- */
373
- params?: StandardSchemaV1<Params | undefined> | ((params: Params) => Awaitable<Params | undefined>);
374
- /**
375
- * The schema to use for validating the request url queries.
376
- */
377
- query?: StandardSchemaV1<Query | undefined> | ((query: Query) => Awaitable<Query | undefined>);
378
- }
379
- declare const routeKeyMethods: readonly ["delete", "get", "patch", "post", "put"];
380
- type RouteKeyMethods = (typeof routeKeyMethods)[number];
381
- type RouteKeyMethodsURLUnion = `@${RouteKeyMethods}/`;
382
- type BaseSchemaRouteKeyPrefixes = FallBackRouteSchemaKey | RouteKeyMethodsURLUnion;
383
- type BaseCallApiSchemaRoutes = Partial<Record<AnyString | BaseSchemaRouteKeyPrefixes, CallApiSchema>>;
384
- type BaseCallApiSchemaAndConfig = {
385
- config?: CallApiSchemaConfig;
386
- routes: BaseCallApiSchemaRoutes;
387
- };
388
- //#endregion
389
186
  //#region src/utils/external/error.d.ts
390
187
  type HTTPErrorDetails<TErrorData$1> = Pick<CallApiExtraOptions, "defaultHTTPErrorMessage"> & {
391
188
  errorData: TErrorData$1;
@@ -457,10 +254,6 @@ type CallApiResultSuccessVariant<TData$1> = {
457
254
  error: null;
458
255
  response: Response;
459
256
  };
460
- type CallApiResultSuccessVariantWithoutResponse<TData$1> = {
461
- data: NoInfer<TData$1>;
462
- error: null;
463
- };
464
257
  type PossibleJavaScriptError = UnmaskType<{
465
258
  errorData: false;
466
259
  message: string;
@@ -490,26 +283,18 @@ type CallApiResultErrorVariant<TErrorData$1> = {
490
283
  error: PossibleJavaScriptOrValidationError;
491
284
  response: Response | null;
492
285
  };
493
- type CallApiResultErrorVariantWithoutResponse<TErrorData$1> = {
494
- data: null;
495
- error: PossibleHTTPError<TErrorData$1>;
496
- } | {
497
- data: null;
498
- error: PossibleJavaScriptOrValidationError;
499
- };
500
286
  type CallApiSuccessOrErrorVariant<TData$1, TError> = CallApiResultErrorVariant<TError> | CallApiResultSuccessVariant<TData$1>;
501
- type CallApiSuccessOrErrorVariantWithoutResponse<TData$1, TErrorData$1> = CallApiResultErrorVariantWithoutResponse<TErrorData$1> | CallApiResultSuccessVariantWithoutResponse<TData$1>;
502
287
  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<{
503
288
  all: TComputedResult;
504
289
  onlyData: TComputedResult["data"];
505
290
  onlyResponse: TComputedResult["response"];
506
- withoutResponse: CallApiSuccessOrErrorVariantWithoutResponse<TComputedData, TComputedErrorData>;
291
+ withoutResponse: DistributiveOmit<TComputedResult, "response">;
507
292
  }>;
508
293
  type ResultModeMapWithException<TData$1, TResponseType extends ResponseTypeType, TComputedData = GetResponseType<TData$1, TResponseType>, TComputedResult extends CallApiResultSuccessVariant<TComputedData> = CallApiResultSuccessVariant<TComputedData>> = {
509
294
  all: TComputedResult;
510
295
  onlyData: TComputedResult["data"];
511
296
  onlyResponse: TComputedResult["response"];
512
- withoutResponse: CallApiResultSuccessVariantWithoutResponse<TComputedData>;
297
+ withoutResponse: DistributiveOmit<TComputedResult, "response">;
513
298
  };
514
299
  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>;
515
300
  type ResultModePlaceholder = null;
@@ -555,8 +340,128 @@ interface Middlewares {
555
340
  }) => FetchImpl;
556
341
  }
557
342
  //#endregion
343
+ //#region src/url.d.ts
344
+ type AllowedQueryParamValues = UnmaskType<boolean | number | string>;
345
+ type RecordStyleParams = UnmaskType<Record<string, AllowedQueryParamValues>>;
346
+ type TupleStyleParams = UnmaskType<AllowedQueryParamValues[]>;
347
+ type Params = UnmaskType<RecordStyleParams | TupleStyleParams>;
348
+ type Query = UnmaskType<Record<string, AllowedQueryParamValues>>;
349
+ type InitURLOrURLObject = AnyString | RouteKeyMethodsURLUnion | URL;
350
+ interface URLOptions {
351
+ /**
352
+ * Base URL for all API requests. Will only be prepended to relative URLs.
353
+ *
354
+ * Absolute URLs (starting with http/https) will not be prepended by the baseURL.
355
+ *
356
+ * @example
357
+ * ```ts
358
+ * // Set base URL for all requests
359
+ * baseURL: "https://api.example.com/v1"
360
+ *
361
+ * // Then use relative URLs in requests
362
+ * callApi("/users") // → https://api.example.com/v1/users
363
+ * callApi("/posts/123") // → https://api.example.com/v1/posts/123
364
+ *
365
+ * // Environment-specific base URLs
366
+ * baseURL: process.env.NODE_ENV === "production"
367
+ * ? "https://api.example.com"
368
+ * : "http://localhost:3000/api"
369
+ * ```
370
+ */
371
+ baseURL?: string;
372
+ /**
373
+ * Resolved request URL after processing baseURL, parameters, and query strings (readonly)
374
+ *
375
+ * This is the final URL that will be used for the HTTP request, computed from
376
+ * baseURL, initURL, params, and query parameters.
377
+ *
378
+ */
379
+ readonly fullURL?: string;
380
+ /**
381
+ * The original URL string passed to the callApi instance (readonly)
382
+ *
383
+ * This preserves the original URL as provided, including any method modifiers like "@get/" or "@post/".
384
+ *
385
+ */
386
+ readonly initURL?: string;
387
+ /**
388
+ * The URL string after normalization, with method modifiers removed(readonly)
389
+ *
390
+ * Method modifiers like "@get/", "@post/" are stripped to create a clean URL
391
+ * for parameter substitution and final URL construction.
392
+ *
393
+ */
394
+ readonly initURLNormalized?: string;
395
+ /**
396
+ * Parameters to be substituted into URL path segments.
397
+ *
398
+ * Supports both object-style (named parameters) and array-style (positional parameters)
399
+ * for flexible URL parameter substitution.
400
+ *
401
+ * @example
402
+ * ```typescript
403
+ * // Object-style parameters (recommended)
404
+ * const namedParams: URLOptions = {
405
+ * initURL: "/users/:userId/posts/:postId",
406
+ * params: { userId: "123", postId: "456" }
407
+ * };
408
+ * // Results in: /users/123/posts/456
409
+ *
410
+ * // Array-style parameters (positional)
411
+ * const positionalParams: URLOptions = {
412
+ * initURL: "/users/:userId/posts/:postId",
413
+ * params: ["123", "456"] // Maps in order: userId=123, postId=456
414
+ * };
415
+ * // Results in: /users/123/posts/456
416
+ *
417
+ * // Single parameter
418
+ * const singleParam: URLOptions = {
419
+ * initURL: "/users/:id",
420
+ * params: { id: "user-123" }
421
+ * };
422
+ * // Results in: /users/user-123
423
+ * ```
424
+ */
425
+ params?: Params;
426
+ /**
427
+ * Query parameters to append to the URL as search parameters.
428
+ *
429
+ * These will be serialized into the URL query string using standard
430
+ * URL encoding practices.
431
+ *
432
+ * @example
433
+ * ```typescript
434
+ * // Basic query parameters
435
+ * const queryOptions: URLOptions = {
436
+ * initURL: "/users",
437
+ * query: {
438
+ * page: 1,
439
+ * limit: 10,
440
+ * search: "john doe",
441
+ * active: true
442
+ * }
443
+ * };
444
+ * // Results in: /users?page=1&limit=10&search=john%20doe&active=true
445
+ *
446
+ * // Filtering and sorting
447
+ * const filterOptions: URLOptions = {
448
+ * initURL: "/products",
449
+ * query: {
450
+ * category: "electronics",
451
+ * minPrice: 100,
452
+ * maxPrice: 500,
453
+ * sortBy: "price",
454
+ * order: "asc"
455
+ * }
456
+ * };
457
+ * // Results in: /products?category=electronics&minPrice=100&maxPrice=500&sortBy=price&order=asc
458
+ * ```
459
+ */
460
+ query?: Query;
461
+ }
462
+ //#endregion
558
463
  //#region src/plugins.d.ts
559
- type PluginSetupContext<TPluginExtraOptions = unknown> = RequestContext & PluginExtraOptions<TPluginExtraOptions> & {
464
+ type PluginSetupContext<TPluginExtraOptions = unknown> = PluginExtraOptions<TPluginExtraOptions> & RequestContext & {
560
465
  initURL: string;
561
466
  };
562
467
  type PluginInitResult = Partial<Omit<PluginSetupContext, "initURL" | "request"> & {
@@ -1216,11 +1121,7 @@ type InferHeadersOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequi
1216
1121
  }) => InferSchemaOutput<TSchema$1["headers"], HeadersOption>);
1217
1122
  }>;
1218
1123
  type InferRequestOptions<TSchema$1 extends CallApiSchema, TInitURL extends InferInitURL<BaseCallApiSchemaRoutes, CallApiSchemaConfig>> = InferBodyOption<TSchema$1> & InferHeadersOption<TSchema$1> & InferMethodOption<TSchema$1, TInitURL>;
1219
- interface Register {}
1220
- type GlobalMeta = Register extends {
1221
- meta?: infer TMeta extends Record<string, unknown>;
1222
- } ? TMeta : never;
1223
- type InferMetaOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["meta"], {
1124
+ type InferMetaOption<TSchema$1 extends CallApiSchema, TCallApiContext extends CallApiContext> = MakeSchemaOptionRequiredIfDefined<TSchema$1["meta"], {
1224
1125
  /**
1225
1126
  * - An optional field you can fill with additional information,
1226
1127
  * to associate with the request, typically used for logging or tracing.
@@ -1244,7 +1145,7 @@ type InferMetaOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequired
1244
1145
  * });
1245
1146
  * ```
1246
1147
  */
1247
- meta?: InferSchemaOutput<TSchema$1["meta"], GlobalMeta>;
1148
+ meta?: InferSchemaOutput<TSchema$1["meta"], TCallApiContext["Meta"]>;
1248
1149
  }>;
1249
1150
  type InferQueryOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["query"], {
1250
1151
  /**
@@ -1267,7 +1168,7 @@ type InferParamsOption<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes$1 exte
1267
1168
  */
1268
1169
  params?: InferSchemaOutput<TSchema$1["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
1269
1170
  }>;
1270
- 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>;
1171
+ type InferExtraOptions<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TCallApiContext extends CallApiContext> = InferMetaOption<TSchema$1, TCallApiContext> & InferParamsOption<TSchema$1, TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> & InferQueryOption<TSchema$1>;
1271
1172
  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>;
1272
1173
  type ResultModeOption<TErrorData$1, TResultMode extends ResultModeType> = TErrorData$1 extends false ? {
1273
1174
  resultMode: "onlyData";
@@ -1287,6 +1188,14 @@ type ThrowOnErrorOption<TErrorData$1, TThrowOnError extends ThrowOnErrorUnion> =
1287
1188
  };
1288
1189
  //#endregion
1289
1190
  //#region src/types/common.d.ts
1191
+ interface Register {}
1192
+ type MetaObjectType = Record<string, unknown>;
1193
+ type GlobalMeta = Register extends {
1194
+ meta?: infer TMeta extends MetaObjectType;
1195
+ } ? TMeta : never;
1196
+ type CallApiContext = {
1197
+ Meta?: MetaObjectType;
1198
+ };
1290
1199
  type FetchSpecificKeysUnion = Exclude<(typeof fetchSpecificKeys)[number], "body" | "headers" | "method">;
1291
1200
  type ModifiedRequestInit = RequestInit & {
1292
1201
  duplex?: "half";
@@ -1309,7 +1218,7 @@ type CallApiRequestOptions = Prettify<{
1309
1218
  type CallApiRequestOptionsForHooks = Omit<CallApiRequestOptions, "headers"> & {
1310
1219
  headers: Record<string, string | undefined>;
1311
1220
  };
1312
- 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 & {
1221
+ type SharedExtraOptions<TCallApiContext extends CallApiContext = CallApiContext, 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 & {
1313
1222
  /**
1314
1223
  * Automatically add an Authorization header value.
1315
1224
  *
@@ -1487,7 +1396,7 @@ type SharedExtraOptions<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataTyp
1487
1396
  * });
1488
1397
  * ```
1489
1398
  */
1490
- meta?: GlobalMeta;
1399
+ meta?: TCallApiContext["Meta"];
1491
1400
  /**
1492
1401
  * Custom function to parse response strings into actual value instead of the default response.json().
1493
1402
  *
@@ -1683,7 +1592,7 @@ type SharedExtraOptions<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataTyp
1683
1592
  */
1684
1593
  timeout?: number;
1685
1594
  };
1686
- 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> & {
1595
+ type BaseCallApiExtraOptions<TBaseCallApiContext extends CallApiContext = CallApiContext, 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<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray> & {
1687
1596
  /**
1688
1597
  * Array of base CallApi plugins to extend library functionality.
1689
1598
  *
@@ -1793,7 +1702,7 @@ type InferExtendSchemaConfigContext<TBaseSchemaConfig extends CallApiSchemaConfi
1793
1702
  type InferExtendPluginContext<TBasePluginArray extends CallApiPlugin[]> = {
1794
1703
  basePlugins: TBasePluginArray;
1795
1704
  };
1796
- 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> & {
1705
+ type CallApiExtraOptions<TCallApiContext extends CallApiContext = CallApiContext, 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<TCallApiContext, TData$1, TErrorData$1, TResultMode, TThrowOnError, TResponseType, TPluginArray> & {
1797
1706
  /**
1798
1707
  * Array of instance-specific CallApi plugins or a function to configure plugins.
1799
1708
  *
@@ -1821,14 +1730,99 @@ type CallApiExtraOptions<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataTy
1821
1730
  */
1822
1731
  schemaConfig?: TSchemaConfig$1 | ((context: TComputedSchemaConfigContext) => TSchemaConfig$1);
1823
1732
  };
1824
- type CallApiExtraOptionsForHooks = Hooks & Omit<CallApiExtraOptions, keyof Hooks>;
1733
+ type CallApiExtraOptionsForHooks<TCallApiContext extends CallApiContext = CallApiContext> = Hooks & Omit<CallApiExtraOptions<TCallApiContext>, keyof Hooks>;
1825
1734
  type InstanceContext = {
1826
1735
  initURL: string;
1827
1736
  options: CallApiExtraOptions;
1828
1737
  request: CallApiRequestOptions;
1829
1738
  };
1830
- 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: InstanceContext) => CallApiRequestOptions & TComputedBaseConfig);
1831
- 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>>;
1739
+ type BaseCallApiConfig<TBaseCallApiContext extends CallApiContext = CallApiContext, 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<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemaAndConfig>> = (CallApiRequestOptions & TComputedBaseConfig) | ((context: InstanceContext) => CallApiRequestOptions & TComputedBaseConfig);
1740
+ type CallApiConfig<TCallApiContext extends CallApiContext = CallApiContext, 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, TCallApiContext> & InferRequestOptions<TSchema$1, TInitURL> & Omit<CallApiExtraOptions<TCallApiContext, TData$1, TErrorData$1, TResultMode, TThrowOnError, TResponseType, TBasePluginArray, TPluginArray, TBaseSchemaRoutes$1, TSchema$1, TBaseSchemaConfig, TSchemaConfig$1, TCurrentRouteSchemaKey>, keyof InferExtraOptions<CallApiSchema, BaseCallApiSchemaRoutes, string, CallApiContext>> & Omit<CallApiRequestOptions, keyof InferRequestOptions<CallApiSchema, string>>;
1741
+ //#endregion
1742
+ //#region src/validation.d.ts
1743
+ type ResultVariant = "infer-input" | "infer-output";
1744
+ 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;
1745
+ type InferSchemaOutput<TSchema$1, TFallbackResult = unknown> = InferSchemaResult<TSchema$1, TFallbackResult, "infer-output">;
1746
+ interface CallApiSchemaConfig {
1747
+ /**
1748
+ * The base url of the schema. By default it's the baseURL of the callApi instance.
1749
+ */
1750
+ baseURL?: string;
1751
+ /**
1752
+ * Disables runtime validation for the schema.
1753
+ */
1754
+ disableRuntimeValidation?: boolean;
1755
+ /**
1756
+ * If `true`, the original input value will be used instead of the transformed/validated output.
1757
+ *
1758
+ * This is useful when you want to validate the input but don't want any transformations
1759
+ * applied by the validation schema (e.g., type coercion, default values, etc).
1760
+ */
1761
+ disableValidationOutputApplication?: boolean;
1762
+ /**
1763
+ * Optional url prefix that will be substituted for the `baseURL` of the schemaConfig at runtime.
1764
+ *
1765
+ * This allows you to reuse the same schema against different base URLs (for example,
1766
+ * swapping between `/api/v1` and `/api/v2`) without redefining the entire schema.
1767
+ */
1768
+ prefix?: string;
1769
+ /**
1770
+ * Controls the strictness of API route validation.
1771
+ *
1772
+ * When true:
1773
+ * - Only routes explicitly defined in the schema will be considered valid to typescript and the runtime.
1774
+ * - Attempting to call routes not defined in the schema will result in both type errors and runtime validation errors.
1775
+ * - Useful for ensuring API calls conform exactly to your schema definition
1776
+ *
1777
+ * When false or undefined (default):
1778
+ * - All routes will be allowed, whether they are defined in the schema or not
1779
+ */
1780
+ strict?: boolean;
1781
+ }
1782
+ interface CallApiSchema {
1783
+ /**
1784
+ * The schema to use for validating the request body.
1785
+ */
1786
+ body?: StandardSchemaV1<Body | undefined> | ((body: Body) => Awaitable<Body | undefined>);
1787
+ /**
1788
+ * The schema to use for validating the response data.
1789
+ */
1790
+ data?: StandardSchemaV1 | ((data: unknown) => unknown);
1791
+ /**
1792
+ * The schema to use for validating the response error data.
1793
+ */
1794
+ errorData?: StandardSchemaV1 | ((errorData: unknown) => unknown);
1795
+ /**
1796
+ * The schema to use for validating the request headers.
1797
+ */
1798
+ headers?: StandardSchemaV1<HeadersOption | undefined> | ((headers: HeadersOption) => Awaitable<HeadersOption | undefined>);
1799
+ /**
1800
+ * The schema to use for validating the meta option.
1801
+ */
1802
+ meta?: StandardSchemaV1<GlobalMeta | undefined> | ((meta: GlobalMeta) => Awaitable<GlobalMeta | undefined>);
1803
+ /**
1804
+ * The schema to use for validating the request method.
1805
+ */
1806
+ method?: StandardSchemaV1<MethodUnion | undefined> | ((method: MethodUnion) => Awaitable<MethodUnion | undefined>);
1807
+ /**
1808
+ * The schema to use for validating the request url parameters.
1809
+ */
1810
+ params?: StandardSchemaV1<Params | undefined> | ((params: Params) => Awaitable<Params | undefined>);
1811
+ /**
1812
+ * The schema to use for validating the request url queries.
1813
+ */
1814
+ query?: StandardSchemaV1<Query | undefined> | ((query: Query) => Awaitable<Query | undefined>);
1815
+ }
1816
+ declare const routeKeyMethods: readonly ["delete", "get", "patch", "post", "put"];
1817
+ type RouteKeyMethods = (typeof routeKeyMethods)[number];
1818
+ type RouteKeyMethodsURLUnion = `@${RouteKeyMethods}/`;
1819
+ type BaseSchemaRouteKeyPrefixes = FallBackRouteSchemaKey | RouteKeyMethodsURLUnion;
1820
+ type BaseCallApiSchemaRoutes = Partial<Record<AnyString | BaseSchemaRouteKeyPrefixes, CallApiSchema>>;
1821
+ type BaseCallApiSchemaAndConfig = {
1822
+ config?: CallApiSchemaConfig;
1823
+ routes: BaseCallApiSchemaRoutes;
1824
+ };
1825
+ //#endregion
1832
1826
  //#endregion
1833
1827
  //#region src/logger/logger.d.ts
1834
1828
  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.24",
4
+ "version": "4.0.26",
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"
24
+ "@zayne-labs/callapi": "1.11.26"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@arethetypeswrong/cli": "0.18.2",
@@ -37,8 +37,8 @@
37
37
  "size-limit": "11.2.0",
38
38
  "tsdown": "0.15.9",
39
39
  "typescript": "5.9.3",
40
- "vitest": "^4.0.12",
41
- "@zayne-labs/callapi": "1.11.24"
40
+ "vitest": "^4.0.14",
41
+ "@zayne-labs/callapi": "1.11.26"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public",