express-zod-api 23.5.0 → 24.0.0-beta.2

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/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
- import * as zod from 'zod';
2
- import { z } from 'zod';
1
+ import * as zod_v4 from 'zod/v4';
2
+ import { z } from 'zod/v4';
3
+ import * as zod_v4_core from 'zod/v4/core';
4
+ import { $ZodType, $ZodShape, $ZodLooseShape, $ZodObjectConfig, JSONSchema } from 'zod/v4/core';
3
5
  import compression from 'compression';
4
6
  import * as express from 'express';
5
7
  import express__default, { Request, Response, NextFunction, RequestHandler, IRouter } from 'express';
@@ -86,10 +88,6 @@ declare class BuiltinLogger implements AbstractLogger {
86
88
  profile(options: ProfilerOptions): () => void;
87
89
  }
88
90
 
89
- /** @desc Accepts an object shape or a custom object schema */
90
- declare const form: <S extends z.ZodRawShape>(base: S | z.ZodObject<S>) => z.ZodBranded<z.ZodObject<S, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<S>, any> extends infer T ? { [k in keyof T]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<S>, any>[k]; } : never, z.baseObjectInputType<S> extends infer T_1 ? { [k_1 in keyof T_1]: z.baseObjectInputType<S>[k_1]; } : never>, symbol>;
91
- type FormSchema = ReturnType<typeof form>;
92
-
93
91
  type LogicalOr<T> = {
94
92
  or: T[];
95
93
  };
@@ -195,9 +193,10 @@ declare abstract class AbstractMiddleware {
195
193
  logger: ActualLogger;
196
194
  }): Promise<FlatObject>;
197
195
  }
198
- declare class Middleware<OPT extends FlatObject, OUT extends FlatObject, SCO extends string, IN extends IOSchema<"strip"> = EmptySchema> extends AbstractMiddleware {
196
+ declare class Middleware<OPT extends FlatObject, OUT extends FlatObject, SCO extends string, IN extends IOSchema = EmptySchema> extends AbstractMiddleware {
199
197
  #private;
200
- constructor({ input, security, handler, }: {
198
+ constructor({ input, // @todo revisit
199
+ security, handler, }: {
201
200
  /**
202
201
  * @desc Input schema of the Middleware, combining properties from all the enabled input sources
203
202
  * @default z.object({})
@@ -225,27 +224,11 @@ declare class ExpressMiddleware<R extends Request, S extends Response, OUT exten
225
224
  });
226
225
  }
227
226
 
228
- declare const base: z.ZodObject<{
229
- raw: z.ZodBranded<z.ZodType<Buffer<ArrayBufferLike>, z.ZodTypeDef, Buffer<ArrayBufferLike>>, symbol>;
230
- }, "strip", z.ZodTypeAny, {
231
- raw: Buffer<ArrayBufferLike> & z.BRAND<symbol>;
232
- }, {
233
- raw: Buffer<ArrayBufferLike>;
234
- }>;
235
- /** Shorthand for z.object({ raw: ez.file("buffer") }) */
236
- declare function raw(): z.ZodBranded<typeof base, symbol>;
237
- declare function raw<S extends z.ZodRawShape>(extra: S): z.ZodBranded<ReturnType<typeof base.extend<S>>, symbol>;
238
- type RawSchema = ReturnType<typeof raw>;
239
-
240
- type BaseObject<U extends z.UnknownKeysParam> = z.ZodObject<z.ZodRawShape, U>;
241
- interface ObjectBasedEffect<T extends z.ZodTypeAny> extends z.ZodEffects<T, FlatObject> {
242
- }
243
- type EffectsChain<U extends z.UnknownKeysParam> = ObjectBasedEffect<BaseObject<U> | EffectsChain<U>>;
244
- /**
245
- * @desc The type allowed on the top level of Middlewares and Endpoints
246
- * @param U — only "strip" is allowed for Middlewares due to intersection issue (Zod) #600
247
- * */
248
- type IOSchema<U extends z.UnknownKeysParam = z.UnknownKeysParam> = BaseObject<U> | EffectsChain<U> | RawSchema | FormSchema | z.ZodUnion<[IOSchema<U>, ...IOSchema<U>[]]> | z.ZodIntersection<IOSchema<U>, IOSchema<U>> | z.ZodDiscriminatedUnion<string, BaseObject<U>[]> | z.ZodPipeline<ObjectBasedEffect<BaseObject<U>>, BaseObject<U>>;
227
+ type Base = object & {
228
+ [Symbol.iterator]?: never;
229
+ };
230
+ /** @desc The type allowed on the top level of Middlewares and Endpoints */
231
+ type IOSchema = z.ZodType<Base>;
249
232
 
250
233
  declare const methods: ("get" | "post" | "put" | "delete" | "patch")[];
251
234
  type Method = (typeof methods)[number];
@@ -263,7 +246,7 @@ declare class ServeStatic {
263
246
  }
264
247
 
265
248
  /** @public this is the user facing configuration */
266
- interface ApiResponse<S extends z.ZodTypeAny> {
249
+ interface ApiResponse<S extends z.ZodType> {
267
250
  schema: S;
268
251
  /** @default 200 for a positive and 400 for a negative response */
269
252
  statusCode?: number | [number, ...number[]];
@@ -279,25 +262,29 @@ interface ApiResponse<S extends z.ZodTypeAny> {
279
262
  }
280
263
 
281
264
  type ResultSchema<R extends Result> = R extends Result<infer S> ? S : never;
265
+ type DiscriminatedResult = {
266
+ output: FlatObject;
267
+ error: null;
268
+ } | {
269
+ output: null;
270
+ error: Error;
271
+ };
282
272
  /**
283
273
  * @example InputValidationError —> BadRequest(400)
284
274
  * @example Error —> InternalServerError(500)
285
275
  * */
286
276
  declare const ensureHttpError: (error: Error) => HttpError;
287
277
 
288
- type Handler$1<RES = unknown> = (params: {
278
+ type Handler$1<RES = unknown> = (params: DiscriminatedResult & {
289
279
  /** null in case of failure to parse or to find the matching endpoint (error: not found) */
290
280
  input: FlatObject | null;
291
- /** null in case of errors or failures */
292
- output: FlatObject | null;
293
281
  /** can be empty: check presence of the required property using "in" operator */
294
282
  options: FlatObject;
295
- error: Error | null;
296
283
  request: Request;
297
284
  response: Response<RES>;
298
285
  logger: ActualLogger;
299
286
  }) => void | Promise<void>;
300
- type Result<S extends z.ZodTypeAny = z.ZodTypeAny> = S | ApiResponse<S> | ApiResponse<S>[];
287
+ type Result<S extends z.ZodType = z.ZodType> = S | ApiResponse<S> | ApiResponse<S>[];
301
288
  type LazyResult<R extends Result, A extends unknown[] = []> = (...args: A) => R;
302
289
  declare abstract class AbstractResultHandler {
303
290
  #private;
@@ -318,38 +305,18 @@ declare class ResultHandler<POS extends Result, NEG extends Result> extends Abst
318
305
  declare const defaultResultHandler: ResultHandler<z.ZodObject<{
319
306
  status: z.ZodLiteral<"success">;
320
307
  data: IOSchema;
321
- }, "strip", z.ZodTypeAny, {
322
- status: "success";
323
- data?: unknown;
324
- }, {
325
- status: "success";
326
- data?: unknown;
327
- }>, z.ZodObject<{
308
+ }, z.core.$strip>, z.ZodObject<{
328
309
  status: z.ZodLiteral<"error">;
329
310
  error: z.ZodObject<{
330
311
  message: z.ZodString;
331
- }, "strip", z.ZodTypeAny, {
332
- message: string;
333
- }, {
334
- message: string;
335
- }>;
336
- }, "strip", z.ZodTypeAny, {
337
- error: {
338
- message: string;
339
- };
340
- status: "error";
341
- }, {
342
- error: {
343
- message: string;
344
- };
345
- status: "error";
346
- }>>;
312
+ }, z.core.$strip>;
313
+ }, z.core.$strip>>;
347
314
  /**
348
315
  * @deprecated Resist the urge of using it: this handler is designed only to simplify the migration of legacy APIs.
349
316
  * @desc Responding with array is a bad practice keeping your endpoints from evolving without breaking changes.
350
317
  * @desc This handler expects your endpoint to have the property 'items' in the output object schema
351
318
  * */
352
- declare const arrayResultHandler: ResultHandler<z.ZodArray<z.ZodTypeAny, "many">, z.ZodString>;
319
+ declare const arrayResultHandler: ResultHandler<z.ZodArray<z.core.$ZodType<unknown, unknown>> | z.ZodArray<z.ZodAny>, z.ZodString>;
353
320
 
354
321
  /** @desc Returns child logger for the given request (if configured) or the configured logger otherwise */
355
322
  type GetLogger = (request?: Request) => ActualLogger;
@@ -575,8 +542,8 @@ declare function createConfig(config: ServerConfig): ServerConfig;
575
542
  declare function createConfig(config: AppConfig): AppConfig;
576
543
 
577
544
  /** @desc this type does not allow props assignment, but it works for reading them when merged with another interface */
578
- type EmptyObject = Record<string, never>;
579
- type EmptySchema = z.ZodObject<EmptyObject, "strip">;
545
+ type EmptyObject = z.output<EmptySchema>;
546
+ type EmptySchema = z.ZodRecord<z.ZodString, z.ZodNever>;
580
547
  type FlatObject = Record<string, unknown>;
581
548
  /** @link https://stackoverflow.com/a/65492934 */
582
549
  type NoNever<T, F> = [T] extends [never] ? F : T;
@@ -589,35 +556,6 @@ interface TagOverrides {
589
556
  }
590
557
  type Tag = NoNever<keyof TagOverrides, string>;
591
558
  declare const getMessageFromError: (error: Error) => string;
592
- declare const getExamples: <T extends z.ZodType, V extends "original" | "parsed" | undefined>({ schema, variant, validate, pullProps, }: {
593
- schema: T;
594
- /**
595
- * @desc examples variant: original or parsed
596
- * @example "parsed" — for the case when possible schema transformations should be applied
597
- * @default "original"
598
- * @override validate: variant "parsed" activates validation as well
599
- * */
600
- variant?: V;
601
- /**
602
- * @desc filters out the examples that do not match the schema
603
- * @default variant === "parsed"
604
- * */
605
- validate?: boolean;
606
- /**
607
- * @desc should pull examples from properties — applicable to ZodObject only
608
- * @default false
609
- * */
610
- pullProps?: boolean;
611
- }) => ReadonlyArray<V extends "parsed" ? z.output<T> : z.input<T>>;
612
-
613
- declare const metaSymbol: unique symbol;
614
- interface Metadata {
615
- examples: unknown[];
616
- /** @override ZodDefault::_def.defaultValue() in depictDefault */
617
- defaultLabel?: string;
618
- brand?: string | number | symbol;
619
- isDeprecated?: boolean;
620
- }
621
559
 
622
560
  /**
623
561
  * @fileoverview Mapping utils for Zod Runtime Plugin (remap)
@@ -636,29 +574,32 @@ type Intact<T, U> = {
636
574
  [K in Exclude<keyof T, keyof U>]: T[K];
637
575
  };
638
576
 
639
- declare module "zod" {
640
- interface ZodTypeDef {
641
- [metaSymbol]?: Metadata;
577
+ declare module "zod/v4/core" {
578
+ interface GlobalMeta {
579
+ deprecated?: boolean;
580
+ default?: unknown;
642
581
  }
582
+ }
583
+ declare module "zod/v4" {
643
584
  interface ZodType {
644
- /** @desc Add an example value (before any transformations, can be called multiple times) */
645
- example(example: this["_input"]): this;
585
+ /** @desc Shorthand for .meta({examples}), it can be called multiple times */
586
+ example(example: z.output<this>): this;
646
587
  deprecated(): this;
647
588
  }
648
- interface ZodDefault<T extends z.ZodTypeAny> {
649
- /** @desc Change the default value in the generated Documentation to a label */
589
+ interface ZodDefault<T extends $ZodType = $ZodType> extends ZodType {
590
+ /** @desc Change the default value in the generated Documentation to a label, alias for .meta({ default }) */
650
591
  label(label: string): this;
651
592
  }
652
- interface ZodObject<T extends z.ZodRawShape, UnknownKeys extends z.UnknownKeysParam = z.UnknownKeysParam, Catchall extends z.ZodTypeAny = z.ZodTypeAny, Output = z.objectOutputType<T, Catchall, UnknownKeys>, Input = z.objectInputType<T, Catchall, UnknownKeys>> {
593
+ interface ZodObject<out Shape extends $ZodShape = $ZodLooseShape, out Config extends $ZodObjectConfig = $ZodObjectConfig> extends ZodType {
653
594
  remap<V extends string, U extends {
654
- [P in keyof T]?: V;
655
- }>(mapping: U): z.ZodPipeline<z.ZodEffects<this, FlatObject>, // internal type simplified
656
- z.ZodObject<Remap<T, U, V> & Intact<T, U>, UnknownKeys>>;
657
- remap<U extends z.ZodRawShape>(mapper: (subject: T) => U): z.ZodPipeline<z.ZodEffects<this, FlatObject>, z.ZodObject<U>>;
595
+ [P in keyof Shape]?: V;
596
+ }>(mapping: U): z.ZodPipe<z.ZodPipe<this, z.ZodTransform<FlatObject, FlatObject>>, z.ZodObject<Remap<Shape, U, V> & Intact<Shape, U>, Config>>;
597
+ remap<U extends $ZodShape>(mapper: (subject: Shape) => U): z.ZodPipe<z.ZodPipe<this, z.ZodTransform<FlatObject, FlatObject>>, // internal type simplified
598
+ z.ZodObject<U>>;
658
599
  }
659
600
  }
660
601
 
661
- interface BuildProps<IN extends IOSchema, OUT extends IOSchema | z.ZodVoid, MIN extends IOSchema<"strip">, OPT extends FlatObject, SCO extends string> {
602
+ interface BuildProps<IN extends IOSchema, OUT extends IOSchema | z.ZodVoid, MIN extends IOSchema, OPT extends FlatObject, SCO extends string> {
662
603
  /**
663
604
  * @desc Input schema of the Endpoint, combining properties from all the enabled input sources (path params, headers)
664
605
  * @default z.object({})
@@ -694,29 +635,30 @@ interface BuildProps<IN extends IOSchema, OUT extends IOSchema | z.ZodVoid, MIN
694
635
  /** @desc Marks the operation deprecated in the generated Documentation */
695
636
  deprecated?: boolean;
696
637
  }
697
- declare class EndpointsFactory<IN extends IOSchema<"strip"> = EmptySchema, OUT extends FlatObject = EmptyObject, SCO extends string = string> {
638
+ declare class EndpointsFactory<IN extends IOSchema = EmptySchema, OUT extends FlatObject = EmptyObject, SCO extends string = string> {
698
639
  #private;
699
640
  protected resultHandler: AbstractResultHandler;
700
641
  protected middlewares: AbstractMiddleware[];
701
642
  constructor(resultHandler: AbstractResultHandler);
702
- addMiddleware<AOUT extends FlatObject, ASCO extends string, AIN extends IOSchema<"strip"> = EmptySchema>(subject: Middleware<OUT, AOUT, ASCO, AIN> | ConstructorParameters<typeof Middleware<OUT, AOUT, ASCO, AIN>>[0]): EndpointsFactory<z.ZodIntersection<IN, AIN>, OUT & AOUT, SCO & ASCO>;
703
- use: <R extends Request, S extends Response, AOUT extends FlatObject = EmptyObject>(nativeMw: (request: R, response: S, next: express.NextFunction) => void | Promise<void>, params_1?: {
643
+ addMiddleware<AOUT extends FlatObject, ASCO extends string, AIN extends IOSchema = EmptySchema>(subject: Middleware<OUT, AOUT, ASCO, AIN> | ConstructorParameters<typeof Middleware<OUT, AOUT, ASCO, AIN>>[0]): EndpointsFactory<z.ZodIntersection<IN, AIN>, OUT & AOUT, SCO & ASCO>;
644
+ use: <R extends Request, S extends Response, AOUT extends FlatObject = Record<string, never>>(nativeMw: (request: R, response: S, next: express.NextFunction) => void | Promise<void>, params_1?: {
704
645
  provider?: ((request: R, response: S) => AOUT | Promise<AOUT>) | undefined;
705
646
  transformer?: (err: Error) => Error;
706
647
  } | undefined) => EndpointsFactory<IN, OUT & AOUT, SCO>;
707
648
  addExpressMiddleware<R extends Request, S extends Response, AOUT extends FlatObject = EmptyObject>(...params: ConstructorParameters<typeof ExpressMiddleware<R, S, AOUT>>): EndpointsFactory<IN, OUT & AOUT, SCO>;
708
649
  addOptions<AOUT extends FlatObject>(getOptions: () => Promise<AOUT>): EndpointsFactory<IN, OUT & AOUT, SCO>;
709
- build<BOUT extends IOSchema, BIN extends IOSchema = EmptySchema>({ input, output: outputSchema, operationId, scope, tag, method, ...rest }: BuildProps<BIN, BOUT, IN, OUT, SCO>): Endpoint<z.ZodIntersection<IN, BIN>, BOUT, OUT>;
650
+ build<BOUT extends IOSchema, BIN extends IOSchema = EmptySchema>({ input, // @todo revisit
651
+ output: outputSchema, operationId, scope, tag, method, ...rest }: BuildProps<BIN, BOUT, IN, OUT, SCO>): Endpoint<z.ZodIntersection<IN, BIN>, BOUT, OUT>;
710
652
  /** @desc shorthand for returning {} while having output schema z.object({}) */
711
- buildVoid<BIN extends IOSchema = EmptySchema>({ handler, ...rest }: Omit<BuildProps<BIN, z.ZodVoid, IN, OUT, SCO>, "output">): Endpoint<z.ZodIntersection<IN, BIN>, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, OUT>;
653
+ buildVoid<BIN extends IOSchema = EmptySchema>({ handler, ...rest }: Omit<BuildProps<BIN, z.ZodVoid, IN, OUT, SCO>, "output">): Endpoint<z.ZodIntersection<IN, BIN>, z.ZodObject<{}, z.core.$strip>, OUT>;
712
654
  }
713
- declare const defaultEndpointsFactory: EndpointsFactory<EmptySchema, EmptyObject, string>;
655
+ declare const defaultEndpointsFactory: EndpointsFactory<EmptySchema, Record<string, never>, string>;
714
656
  /**
715
657
  * @deprecated Resist the urge of using it: this factory is designed only to simplify the migration of legacy APIs.
716
658
  * @desc Responding with array is a bad practice keeping your endpoints from evolving without breaking changes.
717
659
  * @desc The result handler of this factory expects your endpoint to have the property 'items' in the output schema
718
660
  */
719
- declare const arrayEndpointsFactory: EndpointsFactory<EmptySchema, EmptyObject, string>;
661
+ declare const arrayEndpointsFactory: EndpointsFactory<EmptySchema, Record<string, never>, string>;
720
662
 
721
663
  declare const attachRouting: (config: AppConfig, routing: Routing) => {
722
664
  notFoundHandler: express__default.RequestHandler<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>;
@@ -728,47 +670,21 @@ declare const createServer: (config: ServerConfig, routing: Routing) => Promise<
728
670
  servers: (http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | https.Server<typeof http.IncomingMessage, typeof http.ServerResponse>)[];
729
671
  }>;
730
672
 
731
- declare const variants: {
732
- buffer: () => z.ZodBranded<z.ZodType<Buffer<ArrayBufferLike>, z.ZodTypeDef, Buffer<ArrayBufferLike>>, symbol>;
733
- string: () => z.ZodBranded<z.ZodString, symbol>;
734
- binary: () => z.ZodBranded<z.ZodUnion<[z.ZodType<Buffer<ArrayBufferLike>, z.ZodTypeDef, Buffer<ArrayBufferLike>>, z.ZodString]>, symbol>;
735
- base64: () => z.ZodBranded<z.ZodString, symbol>;
736
- };
737
- type Variants = typeof variants;
738
- type Variant = keyof Variants;
739
- declare function file(): ReturnType<Variants["string"]>;
740
- declare function file<K extends Variant>(variant: K): ReturnType<Variants[K]>;
741
-
742
- declare const ez: {
743
- dateIn: () => zod.ZodBranded<zod.ZodPipeline<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodString, zod.ZodString]>, Date, string>, zod.ZodEffects<zod.ZodDate, Date, Date>>, symbol>;
744
- dateOut: () => zod.ZodBranded<zod.ZodEffects<zod.ZodEffects<zod.ZodDate, Date, Date>, string, Date>, symbol>;
745
- form: <S extends zod.ZodRawShape>(base: S | zod.ZodObject<S>) => zod.ZodBranded<zod.ZodObject<S, zod.UnknownKeysParam, zod.ZodTypeAny, zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<S>, any> extends infer T ? { [k in keyof T]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<S>, any>[k]; } : never, zod.baseObjectInputType<S> extends infer T_1 ? { [k_1 in keyof T_1]: zod.baseObjectInputType<S>[k_1]; } : never>, symbol>;
746
- file: typeof file;
747
- upload: () => zod.ZodBranded<zod.ZodType<express_fileupload.UploadedFile, zod.ZodTypeDef, express_fileupload.UploadedFile>, symbol>;
748
- raw: typeof raw;
749
- };
750
-
751
- interface NextHandlerInc<U> {
752
- next: (schema: z.ZodTypeAny) => U;
753
- }
754
- interface PrevInc<U> {
755
- prev: U;
756
- }
757
- type SchemaHandler<U, Context extends FlatObject = EmptyObject, Variant extends "regular" | "each" | "last" = "regular"> = (schema: any, // eslint-disable-line @typescript-eslint/no-explicit-any -- for assignment compatibility
758
- ctx: Context & (Variant extends "regular" ? NextHandlerInc<U> : Variant extends "each" ? PrevInc<U> : Context)) => U;
759
- type HandlingRules<U, Context extends FlatObject = EmptyObject, K extends string | symbol = string | symbol> = Partial<Record<K, SchemaHandler<U, Context>>>;
760
-
761
- type NumericRange = Record<"integer" | "float", [number, number]>;
762
- interface OpenAPIContext extends FlatObject {
763
- isResponse: boolean;
764
- makeRef: (schema: z.ZodTypeAny, subject: SchemaObject | ReferenceObject | (() => SchemaObject | ReferenceObject), name?: string) => ReferenceObject;
765
- numericRange?: NumericRange | null;
673
+ interface ReqResCommons {
674
+ makeRef: (key: object, subject: SchemaObject | ReferenceObject, name?: string) => ReferenceObject;
766
675
  path: string;
767
676
  method: Method;
768
677
  }
769
- type Depicter = SchemaHandler<SchemaObject | ReferenceObject, OpenAPIContext>;
678
+ interface OpenAPIContext extends ReqResCommons {
679
+ isResponse: boolean;
680
+ }
681
+ type Depicter = (zodCtx: {
682
+ zodSchema: $ZodType;
683
+ jsonSchema: JSONSchema.BaseSchema;
684
+ }, oasCtx: OpenAPIContext) => JSONSchema.BaseSchema | SchemaObject;
770
685
  /** @desc Using defaultIsHeader when returns null or undefined */
771
686
  type IsHeader = (name: string, method: Method, path: string) => boolean | null | undefined;
687
+ type BrandHandling = Record<string | symbol, Depicter>;
772
688
  declare const depictTags: (tags: Partial<Record<Tag, string | {
773
689
  description: string;
774
690
  url?: string;
@@ -793,21 +709,15 @@ interface DocumentationParams {
793
709
  descriptions?: Partial<Record<Component, Descriptor>>;
794
710
  /** @default true */
795
711
  hasSummaryFromDescription?: boolean;
796
- /**
797
- * @desc Acceptable limits of z.number() that API can handle (default: the limits of JavaScript engine)
798
- * @default {integer:[Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER], float:[-Number.MAX_VALUE, Number.MAX_VALUE]}
799
- * @example null — to disable the feature
800
- * @see depictNumber */
801
- numericRange?: NumericRange | null;
802
712
  /** @default inline */
803
713
  composition?: "inline" | "components";
804
714
  /**
805
715
  * @desc Handling rules for your own branded schemas.
806
716
  * @desc Keys: brands (recommended to use unique symbols).
807
717
  * @desc Values: functions having schema as first argument that you should assign type to, second one is a context.
808
- * @example { MyBrand: ( schema: typeof myBrandSchema, { next } ) => ({ type: "object" })
718
+ * @example { MyBrand: ( { zodSchema, jsonSchema } ) => ({ type: "object" })
809
719
  */
810
- brandHandling?: HandlingRules<SchemaObject | ReferenceObject, OpenAPIContext>;
720
+ brandHandling?: BrandHandling;
811
721
  /**
812
722
  * @desc Ability to configure recognition of headers among other input data
813
723
  * @desc Only applicable when "headers" is present within inputSources config option
@@ -824,7 +734,7 @@ interface DocumentationParams {
824
734
  }
825
735
  declare class Documentation extends OpenApiBuilder {
826
736
  #private;
827
- constructor({ routing, config, title, version, serverUrl, descriptions, brandHandling, tags, isHeader, numericRange, hasSummaryFromDescription, composition, }: DocumentationParams);
737
+ constructor({ routing, config, title, version, serverUrl, descriptions, brandHandling, tags, isHeader, hasSummaryFromDescription, composition, }: DocumentationParams);
828
738
  }
829
739
 
830
740
  /** @desc An error related to the wrong Routing declaration */
@@ -917,13 +827,19 @@ declare abstract class IntegrationBase {
917
827
  protected constructor(serverUrl: string);
918
828
  }
919
829
 
830
+ interface NextHandlerInc<U> {
831
+ next: (schema: $ZodType) => U;
832
+ }
833
+ interface PrevInc<U> {
834
+ prev: U;
835
+ }
836
+ type SchemaHandler<U, Context extends FlatObject = EmptyObject, Variant extends "regular" | "each" | "last" = "regular"> = (schema: any, // eslint-disable-line @typescript-eslint/no-explicit-any -- for assignment compatibility
837
+ ctx: Context & (Variant extends "regular" ? NextHandlerInc<U> : Variant extends "each" ? PrevInc<U> : Context)) => U;
838
+ type HandlingRules<U, Context extends FlatObject = EmptyObject, K extends string | symbol = string | symbol> = Partial<Record<K, SchemaHandler<U, Context>>>;
839
+
920
840
  interface ZTSContext extends FlatObject {
921
841
  isResponse: boolean;
922
- makeAlias: (schema: z.ZodTypeAny, produce: () => ts.TypeNode) => ts.TypeNode;
923
- optionalPropStyle: {
924
- withQuestionMark?: boolean;
925
- withUndefined?: boolean;
926
- };
842
+ makeAlias: (key: object, produce: () => ts.TypeNode) => ts.TypeNode;
927
843
  }
928
844
  type Producer = SchemaHandler<ts.TypeNode, ZTSContext>;
929
845
 
@@ -945,27 +861,11 @@ interface IntegrationParams {
945
861
  * @default https://example.com
946
862
  * */
947
863
  serverUrl?: string;
948
- /**
949
- * @desc configures the style of object's optional properties
950
- * @default { withQuestionMark: true, withUndefined: true }
951
- */
952
- optionalPropStyle?: {
953
- /**
954
- * @desc add question mark to the optional property definition
955
- * @example { someProp?: boolean }
956
- * */
957
- withQuestionMark?: boolean;
958
- /**
959
- * @desc add undefined to the property union type
960
- * @example { someProp: boolean | undefined }
961
- */
962
- withUndefined?: boolean;
963
- };
964
864
  /**
965
865
  * @desc The schema to use for responses without body such as 204
966
866
  * @default z.undefined()
967
867
  * */
968
- noContent?: z.ZodTypeAny;
868
+ noContent?: z.ZodType;
969
869
  /**
970
870
  * @desc Handling rules for your own branded schemas.
971
871
  * @desc Keys: brands (recommended to use unique symbols).
@@ -985,12 +885,12 @@ interface FormattedPrintingOptions {
985
885
  }
986
886
  declare class Integration extends IntegrationBase {
987
887
  #private;
988
- constructor({ routing, brandHandling, variant, clientClassName, subscriptionClassName, serverUrl, optionalPropStyle, noContent, }: IntegrationParams);
888
+ constructor({ routing, brandHandling, variant, clientClassName, subscriptionClassName, serverUrl, noContent, }: IntegrationParams);
989
889
  print(printerOptions?: ts.PrinterOptions): string;
990
890
  printFormatted({ printerOptions, format: userDefined, }?: FormattedPrintingOptions): Promise<string>;
991
891
  }
992
892
 
993
- type EventsMap = Record<string, z.ZodTypeAny>;
893
+ type EventsMap = Record<string, z.ZodType>;
994
894
  interface Emitter<E extends EventsMap> extends FlatObject {
995
895
  /** @desc Returns true when the connection was closed or terminated */
996
896
  isClosed: () => boolean;
@@ -1001,4 +901,44 @@ declare class EventStreamFactory<E extends EventsMap> extends EndpointsFactory<E
1001
901
  constructor(events: E);
1002
902
  }
1003
903
 
1004
- export { type ApiResponse, type AppConfig, type BasicSecurity, type BearerSecurity, BuiltinLogger, type CommonConfig, type CookieSecurity, DependsOnMethod, type Depicter, Documentation, DocumentationError, EndpointsFactory, EventStreamFactory, type FlatObject, type HeaderSecurity, type IOSchema, type InputSecurity, InputValidationError, Integration, type LoggerOverrides, type Method, Middleware, MissingPeerError, type OAuth2Security, type OpenIdSecurity, OutputValidationError, type Producer, ResultHandler, type Routing, RoutingError, ServeStatic, type ServerConfig, type TagOverrides, arrayEndpointsFactory, arrayResultHandler, attachRouting, createConfig, createServer, defaultEndpointsFactory, defaultResultHandler, ensureHttpError, ez, getExamples, getMessageFromError, testEndpoint, testMiddleware };
904
+ declare const variants: {
905
+ buffer: () => z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
906
+ string: () => z.core.$ZodBranded<z.ZodString, symbol>;
907
+ binary: () => z.core.$ZodBranded<z.ZodUnion<[z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodString]>, symbol>;
908
+ base64: () => z.core.$ZodBranded<z.ZodBase64, symbol>;
909
+ };
910
+ type Variants = typeof variants;
911
+ type Variant = keyof Variants;
912
+ declare function file(): ReturnType<Variants["string"]>;
913
+ declare function file<K extends Variant>(variant: K): ReturnType<Variants[K]>;
914
+
915
+ declare const base: z.ZodObject<{
916
+ raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
917
+ }, z.core.$strip>;
918
+ declare const extended: <S extends $ZodShape>(extra: S) => z.core.$ZodBranded<z.ZodObject<("raw" & keyof S extends never ? {
919
+ raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
920
+ } & S : ({
921
+ raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
922
+ } extends infer T_2 extends z.core.util.SomeObject ? { [K in keyof T_2 as K extends keyof S ? never : K]: {
923
+ raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
924
+ }[K]; } : never) & { [K_1 in keyof S]: S[K_1]; }) extends infer T ? { [k in keyof T]: ("raw" & keyof S extends never ? {
925
+ raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
926
+ } & S : ({
927
+ raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
928
+ } extends infer T_1 extends z.core.util.SomeObject ? { [K in keyof T_1 as K extends keyof S ? never : K]: {
929
+ raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
930
+ }[K]; } : never) & { [K_1 in keyof S]: S[K_1]; })[k]; } : never, z.core.$strip>, symbol>;
931
+ /** Shorthand for z.object({ raw: ez.file("buffer") }) */
932
+ declare function raw(): ReturnType<typeof base.brand<symbol>>;
933
+ declare function raw<S extends $ZodShape>(extra: S): ReturnType<typeof extended<S>>;
934
+
935
+ declare const ez: {
936
+ dateIn: () => zod_v4_core.$ZodBranded<zod_v4.ZodPipe<zod_v4.ZodPipe<zod_v4.ZodUnion<[zod_v4.ZodString, zod_v4.ZodString, zod_v4.ZodString]>, zod_v4.ZodTransform<Date, string>>, zod_v4.ZodDate>, symbol>;
937
+ dateOut: () => zod_v4_core.$ZodBranded<zod_v4.ZodPipe<zod_v4.ZodDate, zod_v4.ZodTransform<string, Date>>, symbol>;
938
+ form: <S extends zod_v4_core.$ZodShape>(base: S | zod_v4.ZodObject<S>) => zod_v4_core.$ZodBranded<zod_v4.ZodObject<{ -readonly [P in keyof S]: S[P]; }, zod_v4_core.$strip>, symbol>;
939
+ file: typeof file;
940
+ upload: () => zod_v4_core.$ZodBranded<zod_v4.ZodCustom<express_fileupload.UploadedFile, express_fileupload.UploadedFile>, symbol>;
941
+ raw: typeof raw;
942
+ };
943
+
944
+ export { type ApiResponse, type AppConfig, type BasicSecurity, type BearerSecurity, BuiltinLogger, type CommonConfig, type CookieSecurity, DependsOnMethod, type Depicter, Documentation, DocumentationError, EndpointsFactory, EventStreamFactory, type FlatObject, type HeaderSecurity, type IOSchema, type InputSecurity, InputValidationError, Integration, type LoggerOverrides, type Method, Middleware, MissingPeerError, type OAuth2Security, type OpenIdSecurity, OutputValidationError, type Producer, ResultHandler, type Routing, RoutingError, ServeStatic, type ServerConfig, type TagOverrides, arrayEndpointsFactory, arrayResultHandler, attachRouting, createConfig, createServer, defaultEndpointsFactory, defaultResultHandler, ensureHttpError, ez, getMessageFromError, testEndpoint, testMiddleware };