express-zod-api 21.9.0 → 22.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
@@ -12,7 +12,7 @@ import { ListenOptions } from 'node:net';
12
12
  import * as qs from 'qs';
13
13
  import * as express_serve_static_core from 'express-serve-static-core';
14
14
  import http from 'node:http';
15
- import { SchemaObject, ReferenceObject, OpenApiBuilder, SecuritySchemeType, SecuritySchemeObject } from 'openapi3-ts/oas31';
15
+ import { SchemaObject, ReferenceObject, TagObject, OpenApiBuilder, SecuritySchemeType, SecuritySchemeObject } from 'openapi3-ts/oas31';
16
16
  import * as node_mocks_http from 'node-mocks-http';
17
17
  import { RequestOptions, ResponseOptions } from 'node-mocks-http';
18
18
  import ts from 'typescript';
@@ -442,15 +442,11 @@ type HeadersProvider = (params: {
442
442
  endpoint: AbstractEndpoint;
443
443
  logger: ActualLogger;
444
444
  }) => Headers | Promise<Headers>;
445
- type TagsConfig<TAG extends string> = Record<TAG, string | {
446
- description: string;
447
- url?: string;
448
- }>;
449
445
  type ChildLoggerProvider = (params: {
450
446
  request: Request;
451
447
  parent: ActualLogger;
452
448
  }) => ActualLogger | Promise<ActualLogger>;
453
- interface CommonConfig<TAG extends string = string> {
449
+ interface CommonConfig {
454
450
  /**
455
451
  * @desc Enables cross-origin resource sharing.
456
452
  * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
@@ -486,11 +482,6 @@ interface CommonConfig<TAG extends string = string> {
486
482
  * @see defaultInputSources
487
483
  */
488
484
  inputSources?: Partial<InputSources>;
489
- /**
490
- * @desc Optional endpoints tagging configuration.
491
- * @example: { users: "Everything about the users" }
492
- */
493
- tags?: TagsConfig<TAG>;
494
485
  }
495
486
  type BeforeUpload = (params: {
496
487
  request: Request;
@@ -538,7 +529,7 @@ interface HttpsConfig extends HttpConfig {
538
529
  /** @desc At least "cert" and "key" options required. */
539
530
  options: ServerOptions;
540
531
  }
541
- interface ServerConfig<TAG extends string = string> extends CommonConfig<TAG> {
532
+ interface ServerConfig extends CommonConfig {
542
533
  /** @desc HTTP server configuration. */
543
534
  http?: HttpConfig;
544
535
  /** @desc HTTPS server configuration. */
@@ -581,17 +572,27 @@ interface ServerConfig<TAG extends string = string> extends CommonConfig<TAG> {
581
572
  * */
582
573
  gracefulShutdown?: boolean | GracefulOptions;
583
574
  }
584
- interface AppConfig<TAG extends string = string> extends CommonConfig<TAG> {
575
+ interface AppConfig extends CommonConfig {
585
576
  /** @desc Your custom express app or express router instead. */
586
577
  app: IRouter;
587
578
  }
588
- declare function createConfig<TAG extends string>(config: ServerConfig<TAG>): ServerConfig<TAG>;
589
- declare function createConfig<TAG extends string>(config: AppConfig<TAG>): AppConfig<TAG>;
579
+ declare function createConfig(config: ServerConfig): ServerConfig;
580
+ declare function createConfig(config: AppConfig): AppConfig;
590
581
 
591
582
  /** @desc this type does not allow props assignment, but it works for reading them when merged with another interface */
592
583
  type EmptyObject = Record<string, never>;
593
584
  type EmptySchema = z.ZodObject<EmptyObject, "strip">;
594
585
  type FlatObject = Record<string, unknown>;
586
+ /** @link https://stackoverflow.com/a/65492934 */
587
+ type NoNever<T, F> = [T] extends [never] ? F : T;
588
+ /**
589
+ * @desc Using module augmentation approach you can specify tags as the keys of this interface
590
+ * @example declare module "express-zod-api" { interface TagOverrides { users: unknown } }
591
+ * @link https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
592
+ * */
593
+ interface TagOverrides {
594
+ }
595
+ type Tag = NoNever<keyof TagOverrides, string>;
595
596
  declare const getMessageFromError: (error: Error) => string;
596
597
  declare const getExamples: <T extends z.ZodTypeAny, V extends "original" | "parsed" | undefined>({ schema, variant, validate, }: {
597
598
  schema: T;
@@ -655,7 +656,7 @@ declare module "zod" {
655
656
  }
656
657
  }
657
658
 
658
- interface BuildProps<IN extends IOSchema, OUT extends IOSchema | z.ZodVoid, MIN extends IOSchema<"strip">, OPT extends FlatObject, SCO extends string, TAG extends string> {
659
+ interface BuildProps<IN extends IOSchema, OUT extends IOSchema | z.ZodVoid, MIN extends IOSchema<"strip">, OPT extends FlatObject, SCO extends string> {
659
660
  input?: IN;
660
661
  output: OUT;
661
662
  handler: Handler<z.output<z.ZodIntersection<MIN, IN>>, z.input<OUT>, OPT>;
@@ -664,37 +665,31 @@ interface BuildProps<IN extends IOSchema, OUT extends IOSchema | z.ZodVoid, MIN
664
665
  operationId?: string | ((method: Method) => string);
665
666
  method?: Method | [Method, ...Method[]];
666
667
  scope?: SCO | SCO[];
667
- tag?: TAG | TAG[];
668
+ tag?: Tag | Tag[];
668
669
  }
669
- declare class EndpointsFactory<IN extends IOSchema<"strip"> = EmptySchema, OUT extends FlatObject = EmptyObject, SCO extends string = string, TAG extends string = string> {
670
+ declare class EndpointsFactory<IN extends IOSchema<"strip"> = EmptySchema, OUT extends FlatObject = EmptyObject, SCO extends string = string> {
670
671
  #private;
671
672
  protected resultHandler: AbstractResultHandler;
672
673
  protected middlewares: AbstractMiddleware[];
673
- /** @desc Consider using the "config" prop with the "tags" option to enforce constraints on tagging the endpoints */
674
674
  constructor(resultHandler: AbstractResultHandler);
675
- /** @todo consider migrating tags into augmentation approach in v22 */
676
- constructor(params: {
677
- resultHandler: AbstractResultHandler;
678
- config?: CommonConfig<TAG>;
679
- });
680
- 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, TAG>;
675
+ 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>;
681
676
  use: <R extends Request, S extends Response, AOUT extends FlatObject = EmptyObject>(nativeMw: (request: R, response: S, next: express.NextFunction) => void | Promise<void>, params_1?: {
682
677
  provider?: ((request: R, response: S) => AOUT | Promise<AOUT>) | undefined;
683
678
  transformer?: (err: Error) => Error;
684
- } | undefined) => EndpointsFactory<IN, OUT & AOUT, SCO, TAG>;
685
- addExpressMiddleware<R extends Request, S extends Response, AOUT extends FlatObject = EmptyObject>(...params: ConstructorParameters<typeof ExpressMiddleware<R, S, AOUT>>): EndpointsFactory<IN, OUT & AOUT, SCO, TAG>;
686
- addOptions<AOUT extends FlatObject>(getOptions: () => Promise<AOUT>): EndpointsFactory<IN, OUT & AOUT, SCO, TAG>;
687
- build<BOUT extends IOSchema, BIN extends IOSchema = EmptySchema>({ input, handler, output: outputSchema, description, shortDescription, operationId, scope, tag, method, }: BuildProps<BIN, BOUT, IN, OUT, SCO, TAG>): Endpoint<z.ZodIntersection<IN, BIN>, BOUT, OUT>;
679
+ } | undefined) => EndpointsFactory<IN, OUT & AOUT, SCO>;
680
+ addExpressMiddleware<R extends Request, S extends Response, AOUT extends FlatObject = EmptyObject>(...params: ConstructorParameters<typeof ExpressMiddleware<R, S, AOUT>>): EndpointsFactory<IN, OUT & AOUT, SCO>;
681
+ addOptions<AOUT extends FlatObject>(getOptions: () => Promise<AOUT>): EndpointsFactory<IN, OUT & AOUT, SCO>;
682
+ build<BOUT extends IOSchema, BIN extends IOSchema = EmptySchema>({ input, handler, output: outputSchema, description, shortDescription, operationId, scope, tag, method, }: BuildProps<BIN, BOUT, IN, OUT, SCO>): Endpoint<z.ZodIntersection<IN, BIN>, BOUT, OUT>;
688
683
  /** @desc shorthand for returning {} while having output schema z.object({}) */
689
- buildVoid<BIN extends IOSchema = EmptySchema>({ handler, ...rest }: Omit<BuildProps<BIN, z.ZodVoid, IN, OUT, SCO, TAG>, "output">): Endpoint<z.ZodIntersection<IN, BIN>, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, OUT>;
684
+ 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>;
690
685
  }
691
- declare const defaultEndpointsFactory: EndpointsFactory<EmptySchema, EmptyObject, string, string>;
686
+ declare const defaultEndpointsFactory: EndpointsFactory<EmptySchema, EmptyObject, string>;
692
687
  /**
693
688
  * @deprecated Resist the urge of using it: this factory is designed only to simplify the migration of legacy APIs.
694
689
  * @desc Responding with array is a bad practice keeping your endpoints from evolving without breaking changes.
695
690
  * @desc The result handler of this factory expects your endpoint to have the property 'items' in the output schema
696
691
  */
697
- declare const arrayEndpointsFactory: EndpointsFactory<EmptySchema, EmptyObject, string, string>;
692
+ declare const arrayEndpointsFactory: EndpointsFactory<EmptySchema, EmptyObject, string>;
698
693
 
699
694
  declare const attachRouting: (config: AppConfig, routing: Routing) => {
700
695
  notFoundHandler: express__default.RequestHandler<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>;
@@ -752,6 +747,10 @@ interface OpenAPIContext extends FlatObject {
752
747
  method: Method;
753
748
  }
754
749
  type Depicter = SchemaHandler<SchemaObject | ReferenceObject, OpenAPIContext>;
750
+ declare const depictTags: (tags: Partial<Record<Tag, string | {
751
+ description: string;
752
+ url?: string;
753
+ }>>) => TagObject[];
755
754
 
756
755
  type Component = "positiveResponse" | "negativeResponse" | "requestParameter" | "requestBody";
757
756
  /** @desc user defined function that creates a component description from its properties */
@@ -781,6 +780,12 @@ interface DocumentationParams {
781
780
  * @example { MyBrand: ( schema: typeof myBrandSchema, { next } ) => ({ type: "object" })
782
781
  */
783
782
  brandHandling?: HandlingRules<SchemaObject | ReferenceObject, OpenAPIContext>;
783
+ /**
784
+ * @desc Extended description of tags used in endpoints. For enforcing constraints:
785
+ * @see TagOverrides
786
+ * @example { users: "About users", files: { description: "About files", url: "https://example.com" } }
787
+ * */
788
+ tags?: Parameters<typeof depictTags>[0];
784
789
  }
785
790
  declare class Documentation extends OpenApiBuilder {
786
791
  protected lastSecuritySchemaIds: Map<SecuritySchemeType, number>;
@@ -789,7 +794,7 @@ declare class Documentation extends OpenApiBuilder {
789
794
  protected makeRef(schema: z.ZodTypeAny, subject: SchemaObject | ReferenceObject | (() => SchemaObject | ReferenceObject), name?: string | undefined): ReferenceObject;
790
795
  protected ensureUniqOperationId(path: string, method: Method, userDefined?: string): string;
791
796
  protected ensureUniqSecuritySchemaName(subject: SecuritySchemeObject): string;
792
- constructor({ routing, config, title, version, serverUrl, descriptions, brandHandling, hasSummaryFromDescription, composition, }: DocumentationParams);
797
+ constructor({ routing, config, title, version, serverUrl, descriptions, brandHandling, tags, hasSummaryFromDescription, composition, }: DocumentationParams);
793
798
  }
794
799
 
795
800
  /** @desc An error related to the wrong Routing declaration */
@@ -920,10 +925,10 @@ interface IntegrationParams {
920
925
  * */
921
926
  variant?: "types" | "client";
922
927
  /**
923
- * @todo remove in v22
924
- * @deprecated
928
+ * @desc The API URL to use in the generated code
929
+ * @default https://example.com
925
930
  * */
926
- splitResponse?: boolean;
931
+ serverUrl?: string;
927
932
  /**
928
933
  * @desc configures the style of object's optional properties
929
934
  * @default { withQuestionMark: true, withUndefined: true }
@@ -967,7 +972,6 @@ declare class Integration {
967
972
  protected program: ts.Node[];
968
973
  protected usage: Array<ts.Node | string>;
969
974
  protected registry: Map<string, Record<IOKind, ts.TypeNode> & {
970
- isJson: boolean;
971
975
  tags: ReadonlyArray<string>;
972
976
  }>;
973
977
  protected paths: Set<string>;
@@ -976,18 +980,12 @@ declare class Integration {
976
980
  pathType: ts.Identifier;
977
981
  methodType: ts.Identifier;
978
982
  requestType: ts.Identifier;
979
- /** @todo remove in v22 */
980
- methodPathType: ts.Identifier;
981
983
  inputInterface: ts.Identifier;
982
984
  posResponseInterface: ts.Identifier;
983
985
  negResponseInterface: ts.Identifier;
984
986
  encResponseInterface: ts.Identifier;
985
987
  responseInterface: ts.Identifier;
986
- /** @todo remove in v22 */
987
- jsonEndpointsConst: ts.Identifier;
988
988
  endpointTagsConst: ts.Identifier;
989
- /** @todo remove in v22 */
990
- providerType: ts.Identifier;
991
989
  implementationType: ts.Identifier;
992
990
  clientClass: ts.Identifier;
993
991
  keyParameter: ts.Identifier;
@@ -995,8 +993,6 @@ declare class Integration {
995
993
  paramsArgument: ts.Identifier;
996
994
  methodParameter: ts.Identifier;
997
995
  requestParameter: ts.Identifier;
998
- /** @todo use request and params in v22 */
999
- args: ts.Identifier;
1000
996
  accumulator: ts.Identifier;
1001
997
  provideMethod: ts.Identifier;
1002
998
  implementationArgument: ts.Identifier;
@@ -1019,7 +1015,7 @@ declare class Integration {
1019
1015
  protected makeAlias(schema: z.ZodTypeAny, produce: () => ts.TypeNode): ts.TypeReferenceNode;
1020
1016
  /** @example SomeOf<_>*/
1021
1017
  protected makeSomeOf: ({ name }: ts.TypeAliasDeclaration) => ts.TypeReferenceNode;
1022
- constructor({ routing, brandHandling, variant, optionalPropStyle, noContent, }: IntegrationParams);
1018
+ constructor({ routing, brandHandling, variant, serverUrl, optionalPropStyle, noContent, }: IntegrationParams);
1023
1019
  protected printUsage(printerOptions?: ts.PrinterOptions): string | undefined;
1024
1020
  print(printerOptions?: ts.PrinterOptions): string;
1025
1021
  printFormatted({ printerOptions, format: userDefined, }?: FormattedPrintingOptions): Promise<string>;
@@ -1032,12 +1028,8 @@ interface Emitter<E extends EventsMap> extends FlatObject {
1032
1028
  /** @desc Sends an event to the stream accordin to the declared schema */
1033
1029
  emit: <K extends keyof E>(event: K, data: z.input<E[K]>) => void;
1034
1030
  }
1035
- /** @desc This feature is in active development and can be changed or removed regardlress of SemVer */
1036
- declare class EventStreamFactory<E extends EventsMap, TAG extends string> extends EndpointsFactory<EmptySchema, Emitter<E>, string, TAG> {
1037
- constructor({ events, config }: {
1038
- events: E;
1039
- config?: CommonConfig<TAG>;
1040
- });
1031
+ declare class EventStreamFactory<E extends EventsMap> extends EndpointsFactory<EmptySchema, Emitter<E>> {
1032
+ constructor(events: E);
1041
1033
  }
1042
1034
 
1043
- export { type ApiResponse, type AppConfig, type BasicSecurity, type BearerSecurity, BuiltinLogger, type CommonConfig, type CookieSecurity, type CustomHeaderSecurity, DependsOnMethod, type Depicter, Documentation, DocumentationError, EndpointsFactory, EventStreamFactory, type FlatObject, type IOSchema, type InputSecurity, InputValidationError, Integration, type LoggerOverrides, type Method, Middleware, MissingPeerError, type NormalizedResponse, type OAuth2Security, type OpenIdSecurity, OutputValidationError, type Producer, ResultHandler, type Routing, RoutingError, ServeStatic, type ServerConfig, arrayEndpointsFactory, arrayResultHandler, attachRouting, createConfig, createServer, defaultEndpointsFactory, defaultResultHandler, ensureHttpError, ez, getExamples, getMessageFromError, testEndpoint, testMiddleware };
1035
+ export { type ApiResponse, type AppConfig, type BasicSecurity, type BearerSecurity, BuiltinLogger, type CommonConfig, type CookieSecurity, type CustomHeaderSecurity, DependsOnMethod, type Depicter, Documentation, DocumentationError, EndpointsFactory, EventStreamFactory, type FlatObject, type IOSchema, type InputSecurity, InputValidationError, Integration, type LoggerOverrides, type Method, Middleware, MissingPeerError, type NormalizedResponse, 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 };
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ import { ListenOptions } from 'node:net';
12
12
  import * as qs from 'qs';
13
13
  import * as express_serve_static_core from 'express-serve-static-core';
14
14
  import http from 'node:http';
15
- import { SchemaObject, ReferenceObject, OpenApiBuilder, SecuritySchemeType, SecuritySchemeObject } from 'openapi3-ts/oas31';
15
+ import { SchemaObject, ReferenceObject, TagObject, OpenApiBuilder, SecuritySchemeType, SecuritySchemeObject } from 'openapi3-ts/oas31';
16
16
  import * as node_mocks_http from 'node-mocks-http';
17
17
  import { RequestOptions, ResponseOptions } from 'node-mocks-http';
18
18
  import ts from 'typescript';
@@ -442,15 +442,11 @@ type HeadersProvider = (params: {
442
442
  endpoint: AbstractEndpoint;
443
443
  logger: ActualLogger;
444
444
  }) => Headers | Promise<Headers>;
445
- type TagsConfig<TAG extends string> = Record<TAG, string | {
446
- description: string;
447
- url?: string;
448
- }>;
449
445
  type ChildLoggerProvider = (params: {
450
446
  request: Request;
451
447
  parent: ActualLogger;
452
448
  }) => ActualLogger | Promise<ActualLogger>;
453
- interface CommonConfig<TAG extends string = string> {
449
+ interface CommonConfig {
454
450
  /**
455
451
  * @desc Enables cross-origin resource sharing.
456
452
  * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
@@ -486,11 +482,6 @@ interface CommonConfig<TAG extends string = string> {
486
482
  * @see defaultInputSources
487
483
  */
488
484
  inputSources?: Partial<InputSources>;
489
- /**
490
- * @desc Optional endpoints tagging configuration.
491
- * @example: { users: "Everything about the users" }
492
- */
493
- tags?: TagsConfig<TAG>;
494
485
  }
495
486
  type BeforeUpload = (params: {
496
487
  request: Request;
@@ -538,7 +529,7 @@ interface HttpsConfig extends HttpConfig {
538
529
  /** @desc At least "cert" and "key" options required. */
539
530
  options: ServerOptions;
540
531
  }
541
- interface ServerConfig<TAG extends string = string> extends CommonConfig<TAG> {
532
+ interface ServerConfig extends CommonConfig {
542
533
  /** @desc HTTP server configuration. */
543
534
  http?: HttpConfig;
544
535
  /** @desc HTTPS server configuration. */
@@ -581,17 +572,27 @@ interface ServerConfig<TAG extends string = string> extends CommonConfig<TAG> {
581
572
  * */
582
573
  gracefulShutdown?: boolean | GracefulOptions;
583
574
  }
584
- interface AppConfig<TAG extends string = string> extends CommonConfig<TAG> {
575
+ interface AppConfig extends CommonConfig {
585
576
  /** @desc Your custom express app or express router instead. */
586
577
  app: IRouter;
587
578
  }
588
- declare function createConfig<TAG extends string>(config: ServerConfig<TAG>): ServerConfig<TAG>;
589
- declare function createConfig<TAG extends string>(config: AppConfig<TAG>): AppConfig<TAG>;
579
+ declare function createConfig(config: ServerConfig): ServerConfig;
580
+ declare function createConfig(config: AppConfig): AppConfig;
590
581
 
591
582
  /** @desc this type does not allow props assignment, but it works for reading them when merged with another interface */
592
583
  type EmptyObject = Record<string, never>;
593
584
  type EmptySchema = z.ZodObject<EmptyObject, "strip">;
594
585
  type FlatObject = Record<string, unknown>;
586
+ /** @link https://stackoverflow.com/a/65492934 */
587
+ type NoNever<T, F> = [T] extends [never] ? F : T;
588
+ /**
589
+ * @desc Using module augmentation approach you can specify tags as the keys of this interface
590
+ * @example declare module "express-zod-api" { interface TagOverrides { users: unknown } }
591
+ * @link https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
592
+ * */
593
+ interface TagOverrides {
594
+ }
595
+ type Tag = NoNever<keyof TagOverrides, string>;
595
596
  declare const getMessageFromError: (error: Error) => string;
596
597
  declare const getExamples: <T extends z.ZodTypeAny, V extends "original" | "parsed" | undefined>({ schema, variant, validate, }: {
597
598
  schema: T;
@@ -655,7 +656,7 @@ declare module "zod" {
655
656
  }
656
657
  }
657
658
 
658
- interface BuildProps<IN extends IOSchema, OUT extends IOSchema | z.ZodVoid, MIN extends IOSchema<"strip">, OPT extends FlatObject, SCO extends string, TAG extends string> {
659
+ interface BuildProps<IN extends IOSchema, OUT extends IOSchema | z.ZodVoid, MIN extends IOSchema<"strip">, OPT extends FlatObject, SCO extends string> {
659
660
  input?: IN;
660
661
  output: OUT;
661
662
  handler: Handler<z.output<z.ZodIntersection<MIN, IN>>, z.input<OUT>, OPT>;
@@ -664,37 +665,31 @@ interface BuildProps<IN extends IOSchema, OUT extends IOSchema | z.ZodVoid, MIN
664
665
  operationId?: string | ((method: Method) => string);
665
666
  method?: Method | [Method, ...Method[]];
666
667
  scope?: SCO | SCO[];
667
- tag?: TAG | TAG[];
668
+ tag?: Tag | Tag[];
668
669
  }
669
- declare class EndpointsFactory<IN extends IOSchema<"strip"> = EmptySchema, OUT extends FlatObject = EmptyObject, SCO extends string = string, TAG extends string = string> {
670
+ declare class EndpointsFactory<IN extends IOSchema<"strip"> = EmptySchema, OUT extends FlatObject = EmptyObject, SCO extends string = string> {
670
671
  #private;
671
672
  protected resultHandler: AbstractResultHandler;
672
673
  protected middlewares: AbstractMiddleware[];
673
- /** @desc Consider using the "config" prop with the "tags" option to enforce constraints on tagging the endpoints */
674
674
  constructor(resultHandler: AbstractResultHandler);
675
- /** @todo consider migrating tags into augmentation approach in v22 */
676
- constructor(params: {
677
- resultHandler: AbstractResultHandler;
678
- config?: CommonConfig<TAG>;
679
- });
680
- 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, TAG>;
675
+ 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>;
681
676
  use: <R extends Request, S extends Response, AOUT extends FlatObject = EmptyObject>(nativeMw: (request: R, response: S, next: express.NextFunction) => void | Promise<void>, params_1?: {
682
677
  provider?: ((request: R, response: S) => AOUT | Promise<AOUT>) | undefined;
683
678
  transformer?: (err: Error) => Error;
684
- } | undefined) => EndpointsFactory<IN, OUT & AOUT, SCO, TAG>;
685
- addExpressMiddleware<R extends Request, S extends Response, AOUT extends FlatObject = EmptyObject>(...params: ConstructorParameters<typeof ExpressMiddleware<R, S, AOUT>>): EndpointsFactory<IN, OUT & AOUT, SCO, TAG>;
686
- addOptions<AOUT extends FlatObject>(getOptions: () => Promise<AOUT>): EndpointsFactory<IN, OUT & AOUT, SCO, TAG>;
687
- build<BOUT extends IOSchema, BIN extends IOSchema = EmptySchema>({ input, handler, output: outputSchema, description, shortDescription, operationId, scope, tag, method, }: BuildProps<BIN, BOUT, IN, OUT, SCO, TAG>): Endpoint<z.ZodIntersection<IN, BIN>, BOUT, OUT>;
679
+ } | undefined) => EndpointsFactory<IN, OUT & AOUT, SCO>;
680
+ addExpressMiddleware<R extends Request, S extends Response, AOUT extends FlatObject = EmptyObject>(...params: ConstructorParameters<typeof ExpressMiddleware<R, S, AOUT>>): EndpointsFactory<IN, OUT & AOUT, SCO>;
681
+ addOptions<AOUT extends FlatObject>(getOptions: () => Promise<AOUT>): EndpointsFactory<IN, OUT & AOUT, SCO>;
682
+ build<BOUT extends IOSchema, BIN extends IOSchema = EmptySchema>({ input, handler, output: outputSchema, description, shortDescription, operationId, scope, tag, method, }: BuildProps<BIN, BOUT, IN, OUT, SCO>): Endpoint<z.ZodIntersection<IN, BIN>, BOUT, OUT>;
688
683
  /** @desc shorthand for returning {} while having output schema z.object({}) */
689
- buildVoid<BIN extends IOSchema = EmptySchema>({ handler, ...rest }: Omit<BuildProps<BIN, z.ZodVoid, IN, OUT, SCO, TAG>, "output">): Endpoint<z.ZodIntersection<IN, BIN>, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, OUT>;
684
+ 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>;
690
685
  }
691
- declare const defaultEndpointsFactory: EndpointsFactory<EmptySchema, EmptyObject, string, string>;
686
+ declare const defaultEndpointsFactory: EndpointsFactory<EmptySchema, EmptyObject, string>;
692
687
  /**
693
688
  * @deprecated Resist the urge of using it: this factory is designed only to simplify the migration of legacy APIs.
694
689
  * @desc Responding with array is a bad practice keeping your endpoints from evolving without breaking changes.
695
690
  * @desc The result handler of this factory expects your endpoint to have the property 'items' in the output schema
696
691
  */
697
- declare const arrayEndpointsFactory: EndpointsFactory<EmptySchema, EmptyObject, string, string>;
692
+ declare const arrayEndpointsFactory: EndpointsFactory<EmptySchema, EmptyObject, string>;
698
693
 
699
694
  declare const attachRouting: (config: AppConfig, routing: Routing) => {
700
695
  notFoundHandler: express__default.RequestHandler<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>;
@@ -752,6 +747,10 @@ interface OpenAPIContext extends FlatObject {
752
747
  method: Method;
753
748
  }
754
749
  type Depicter = SchemaHandler<SchemaObject | ReferenceObject, OpenAPIContext>;
750
+ declare const depictTags: (tags: Partial<Record<Tag, string | {
751
+ description: string;
752
+ url?: string;
753
+ }>>) => TagObject[];
755
754
 
756
755
  type Component = "positiveResponse" | "negativeResponse" | "requestParameter" | "requestBody";
757
756
  /** @desc user defined function that creates a component description from its properties */
@@ -781,6 +780,12 @@ interface DocumentationParams {
781
780
  * @example { MyBrand: ( schema: typeof myBrandSchema, { next } ) => ({ type: "object" })
782
781
  */
783
782
  brandHandling?: HandlingRules<SchemaObject | ReferenceObject, OpenAPIContext>;
783
+ /**
784
+ * @desc Extended description of tags used in endpoints. For enforcing constraints:
785
+ * @see TagOverrides
786
+ * @example { users: "About users", files: { description: "About files", url: "https://example.com" } }
787
+ * */
788
+ tags?: Parameters<typeof depictTags>[0];
784
789
  }
785
790
  declare class Documentation extends OpenApiBuilder {
786
791
  protected lastSecuritySchemaIds: Map<SecuritySchemeType, number>;
@@ -789,7 +794,7 @@ declare class Documentation extends OpenApiBuilder {
789
794
  protected makeRef(schema: z.ZodTypeAny, subject: SchemaObject | ReferenceObject | (() => SchemaObject | ReferenceObject), name?: string | undefined): ReferenceObject;
790
795
  protected ensureUniqOperationId(path: string, method: Method, userDefined?: string): string;
791
796
  protected ensureUniqSecuritySchemaName(subject: SecuritySchemeObject): string;
792
- constructor({ routing, config, title, version, serverUrl, descriptions, brandHandling, hasSummaryFromDescription, composition, }: DocumentationParams);
797
+ constructor({ routing, config, title, version, serverUrl, descriptions, brandHandling, tags, hasSummaryFromDescription, composition, }: DocumentationParams);
793
798
  }
794
799
 
795
800
  /** @desc An error related to the wrong Routing declaration */
@@ -920,10 +925,10 @@ interface IntegrationParams {
920
925
  * */
921
926
  variant?: "types" | "client";
922
927
  /**
923
- * @todo remove in v22
924
- * @deprecated
928
+ * @desc The API URL to use in the generated code
929
+ * @default https://example.com
925
930
  * */
926
- splitResponse?: boolean;
931
+ serverUrl?: string;
927
932
  /**
928
933
  * @desc configures the style of object's optional properties
929
934
  * @default { withQuestionMark: true, withUndefined: true }
@@ -967,7 +972,6 @@ declare class Integration {
967
972
  protected program: ts.Node[];
968
973
  protected usage: Array<ts.Node | string>;
969
974
  protected registry: Map<string, Record<IOKind, ts.TypeNode> & {
970
- isJson: boolean;
971
975
  tags: ReadonlyArray<string>;
972
976
  }>;
973
977
  protected paths: Set<string>;
@@ -976,18 +980,12 @@ declare class Integration {
976
980
  pathType: ts.Identifier;
977
981
  methodType: ts.Identifier;
978
982
  requestType: ts.Identifier;
979
- /** @todo remove in v22 */
980
- methodPathType: ts.Identifier;
981
983
  inputInterface: ts.Identifier;
982
984
  posResponseInterface: ts.Identifier;
983
985
  negResponseInterface: ts.Identifier;
984
986
  encResponseInterface: ts.Identifier;
985
987
  responseInterface: ts.Identifier;
986
- /** @todo remove in v22 */
987
- jsonEndpointsConst: ts.Identifier;
988
988
  endpointTagsConst: ts.Identifier;
989
- /** @todo remove in v22 */
990
- providerType: ts.Identifier;
991
989
  implementationType: ts.Identifier;
992
990
  clientClass: ts.Identifier;
993
991
  keyParameter: ts.Identifier;
@@ -995,8 +993,6 @@ declare class Integration {
995
993
  paramsArgument: ts.Identifier;
996
994
  methodParameter: ts.Identifier;
997
995
  requestParameter: ts.Identifier;
998
- /** @todo use request and params in v22 */
999
- args: ts.Identifier;
1000
996
  accumulator: ts.Identifier;
1001
997
  provideMethod: ts.Identifier;
1002
998
  implementationArgument: ts.Identifier;
@@ -1019,7 +1015,7 @@ declare class Integration {
1019
1015
  protected makeAlias(schema: z.ZodTypeAny, produce: () => ts.TypeNode): ts.TypeReferenceNode;
1020
1016
  /** @example SomeOf<_>*/
1021
1017
  protected makeSomeOf: ({ name }: ts.TypeAliasDeclaration) => ts.TypeReferenceNode;
1022
- constructor({ routing, brandHandling, variant, optionalPropStyle, noContent, }: IntegrationParams);
1018
+ constructor({ routing, brandHandling, variant, serverUrl, optionalPropStyle, noContent, }: IntegrationParams);
1023
1019
  protected printUsage(printerOptions?: ts.PrinterOptions): string | undefined;
1024
1020
  print(printerOptions?: ts.PrinterOptions): string;
1025
1021
  printFormatted({ printerOptions, format: userDefined, }?: FormattedPrintingOptions): Promise<string>;
@@ -1032,12 +1028,8 @@ interface Emitter<E extends EventsMap> extends FlatObject {
1032
1028
  /** @desc Sends an event to the stream accordin to the declared schema */
1033
1029
  emit: <K extends keyof E>(event: K, data: z.input<E[K]>) => void;
1034
1030
  }
1035
- /** @desc This feature is in active development and can be changed or removed regardlress of SemVer */
1036
- declare class EventStreamFactory<E extends EventsMap, TAG extends string> extends EndpointsFactory<EmptySchema, Emitter<E>, string, TAG> {
1037
- constructor({ events, config }: {
1038
- events: E;
1039
- config?: CommonConfig<TAG>;
1040
- });
1031
+ declare class EventStreamFactory<E extends EventsMap> extends EndpointsFactory<EmptySchema, Emitter<E>> {
1032
+ constructor(events: E);
1041
1033
  }
1042
1034
 
1043
- export { type ApiResponse, type AppConfig, type BasicSecurity, type BearerSecurity, BuiltinLogger, type CommonConfig, type CookieSecurity, type CustomHeaderSecurity, DependsOnMethod, type Depicter, Documentation, DocumentationError, EndpointsFactory, EventStreamFactory, type FlatObject, type IOSchema, type InputSecurity, InputValidationError, Integration, type LoggerOverrides, type Method, Middleware, MissingPeerError, type NormalizedResponse, type OAuth2Security, type OpenIdSecurity, OutputValidationError, type Producer, ResultHandler, type Routing, RoutingError, ServeStatic, type ServerConfig, arrayEndpointsFactory, arrayResultHandler, attachRouting, createConfig, createServer, defaultEndpointsFactory, defaultResultHandler, ensureHttpError, ez, getExamples, getMessageFromError, testEndpoint, testMiddleware };
1035
+ export { type ApiResponse, type AppConfig, type BasicSecurity, type BearerSecurity, BuiltinLogger, type CommonConfig, type CookieSecurity, type CustomHeaderSecurity, DependsOnMethod, type Depicter, Documentation, DocumentationError, EndpointsFactory, EventStreamFactory, type FlatObject, type IOSchema, type InputSecurity, InputValidationError, Integration, type LoggerOverrides, type Method, Middleware, MissingPeerError, type NormalizedResponse, 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 };