express-zod-api 22.13.1 → 23.0.0-beta.1

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
@@ -11,7 +11,7 @@ import { ListenOptions } from 'node:net';
11
11
  import * as qs from 'qs';
12
12
  import * as express_serve_static_core from 'express-serve-static-core';
13
13
  import http from 'node:http';
14
- import { SchemaObject, ReferenceObject, TagObject, OpenApiBuilder, SecuritySchemeType, SecuritySchemeObject } from 'openapi3-ts/oas31';
14
+ import { SchemaObject, ReferenceObject, TagObject, OpenApiBuilder } from 'openapi3-ts/oas31';
15
15
  import * as node_mocks_http from 'node-mocks-http';
16
16
  import { RequestOptions, ResponseOptions } from 'node-mocks-http';
17
17
  import ts from 'typescript';
@@ -86,36 +86,6 @@ declare class BuiltinLogger implements AbstractLogger {
86
86
  profile(options: ProfilerOptions): () => void;
87
87
  }
88
88
 
89
- declare const defaultStatusCodes: {
90
- positive: number;
91
- negative: number;
92
- };
93
- type ResponseVariant = keyof typeof defaultStatusCodes;
94
- /** @public this is the user facing configuration */
95
- interface ApiResponse<S extends z.ZodTypeAny> {
96
- schema: S;
97
- /** @default 200 for a positive and 400 for a negative response */
98
- statusCode?: number | [number, ...number[]];
99
- /**
100
- * @example null is for no content, such as 204 and 302
101
- * @default "application/json"
102
- * */
103
- mimeType?: string | [string, ...string[]] | null;
104
- /** @deprecated use statusCode */
105
- statusCodes?: never;
106
- /** @deprecated use mimeType */
107
- mimeTypes?: never;
108
- }
109
- /**
110
- * @private This is what the framework entities operate
111
- * @see normalize
112
- * */
113
- interface NormalizedResponse {
114
- schema: z.ZodTypeAny;
115
- statusCodes: [number, ...number[]];
116
- mimeTypes: [string, ...string[]] | null;
117
- }
118
-
119
89
  /** @desc Accepts an object shape or a custom object schema */
120
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>;
121
91
  type FormSchema = ReturnType<typeof form>;
@@ -139,8 +109,7 @@ interface InputSecurity<K extends string> {
139
109
  type: "input";
140
110
  name: K;
141
111
  }
142
- /** @todo rename to just HeaderSecurity */
143
- interface CustomHeaderSecurity {
112
+ interface HeaderSecurity {
144
113
  type: "header";
145
114
  name: string;
146
115
  }
@@ -200,7 +169,7 @@ interface OAuth2Security<S extends string> {
200
169
  * @param K is an optional input field used by InputSecurity
201
170
  * @param S is an optional union of scopes used by OAuth2Security
202
171
  * */
203
- type Security<K extends string = string, S extends string = string> = BasicSecurity | BearerSecurity | InputSecurity<K> | CustomHeaderSecurity | CookieSecurity | OpenIdSecurity | OAuth2Security<S>;
172
+ type Security<K extends string = string, S extends string = string> = BasicSecurity | BearerSecurity | InputSecurity<K> | HeaderSecurity | CookieSecurity | OpenIdSecurity | OAuth2Security<S>;
204
173
 
205
174
  type Handler$2<IN, OPT, OUT> = (params: {
206
175
  /** @desc The inputs from the enabled input sources validated against final input schema of the Middleware */
@@ -218,8 +187,6 @@ type Handler$2<IN, OPT, OUT> = (params: {
218
187
  logger: ActualLogger;
219
188
  }) => Promise<OUT>;
220
189
  declare abstract class AbstractMiddleware {
221
- abstract getSecurity(): LogicalContainer<Security> | undefined;
222
- abstract getSchema(): IOSchema<"strip">;
223
190
  abstract execute(params: {
224
191
  input: unknown;
225
192
  options: FlatObject;
@@ -242,8 +209,6 @@ declare class Middleware<OPT extends FlatObject, OUT extends FlatObject, SCO ext
242
209
  /** @desc The handler returning options available to Endpoints */
243
210
  handler: Handler$2<z.output<IN>, OPT, OUT>;
244
211
  });
245
- getSecurity(): LogicalContainer<Security<Extract<keyof z.input<IN>, string>, SCO>> | undefined;
246
- getSchema(): IN;
247
212
  /** @throws InputValidationError */
248
213
  execute({ input, ...rest }: {
249
214
  input: unknown;
@@ -285,29 +250,32 @@ type IOSchema<U extends z.UnknownKeysParam = z.UnknownKeysParam> = BaseObject<U>
285
250
  declare const methods: ("get" | "post" | "put" | "delete" | "patch")[];
286
251
  type Method = (typeof methods)[number];
287
252
 
288
- declare const contentTypes: {
289
- json: string;
290
- upload: string;
291
- raw: string;
292
- sse: string;
293
- form: string;
294
- };
295
- type ContentType = keyof typeof contentTypes;
296
-
297
253
  declare class DependsOnMethod extends Routable {
298
254
  #private;
299
255
  constructor(endpoints: Partial<Record<Method, AbstractEndpoint>>);
300
- /** @desc [method, endpoint, siblingMethods] */
301
- get entries(): ReadonlyArray<[Method, AbstractEndpoint, Method[]]>;
302
256
  deprecated(): this;
303
257
  }
304
258
 
305
259
  type OriginalStatic = typeof express__default.static;
306
- type StaticHandler = ReturnType<OriginalStatic>;
307
260
  declare class ServeStatic {
308
- params: Parameters<OriginalStatic>;
261
+ #private;
309
262
  constructor(...params: Parameters<OriginalStatic>);
310
- apply(path: string, cb: (path: string, handler: StaticHandler) => void): void;
263
+ }
264
+
265
+ /** @public this is the user facing configuration */
266
+ interface ApiResponse<S extends z.ZodTypeAny> {
267
+ schema: S;
268
+ /** @default 200 for a positive and 400 for a negative response */
269
+ statusCode?: number | [number, ...number[]];
270
+ /**
271
+ * @example null is for no content, such as 204 and 302
272
+ * @default "application/json"
273
+ * */
274
+ mimeType?: string | [string, ...string[]] | null;
275
+ /** @deprecated use statusCode */
276
+ statusCodes?: never;
277
+ /** @deprecated use mimeType */
278
+ mimeTypes?: never;
311
279
  }
312
280
 
313
281
  type ResultSchema<R extends Result> = R extends Result<infer S> ? S : never;
@@ -333,8 +301,6 @@ type Result<S extends z.ZodTypeAny = z.ZodTypeAny> = S | ApiResponse<S> | ApiRes
333
301
  type LazyResult<R extends Result, A extends unknown[] = []> = (...args: A) => R;
334
302
  declare abstract class AbstractResultHandler {
335
303
  #private;
336
- abstract getPositiveResponse(output: IOSchema): NormalizedResponse[];
337
- abstract getNegativeResponse(): NormalizedResponse[];
338
304
  protected constructor(handler: Handler$1);
339
305
  execute(...params: Parameters<Handler$1>): void | Promise<void>;
340
306
  }
@@ -348,8 +314,6 @@ declare class ResultHandler<POS extends Result, NEG extends Result> extends Abst
348
314
  /** @desc The actual implementation to transmit the response in any case */
349
315
  handler: Handler$1<z.output<ResultSchema<POS> | ResultSchema<NEG>>>;
350
316
  });
351
- getPositiveResponse(output: IOSchema): NormalizedResponse[];
352
- getNegativeResponse(): NormalizedResponse[];
353
317
  }
354
318
  declare const defaultResultHandler: ResultHandler<z.ZodObject<{
355
319
  status: z.ZodLiteral<"success">;
@@ -409,8 +373,6 @@ type Handler<IN, OUT, OPT> = (params: {
409
373
  /** @desc The instance of the configured logger */
410
374
  logger: ActualLogger;
411
375
  }) => Promise<OUT>;
412
- type DescriptionVariant = "short" | "long";
413
- type IOVariant = "input" | "output";
414
376
  declare abstract class AbstractEndpoint extends Routable {
415
377
  abstract execute(params: {
416
378
  request: Request;
@@ -418,16 +380,6 @@ declare abstract class AbstractEndpoint extends Routable {
418
380
  logger: ActualLogger;
419
381
  config: CommonConfig;
420
382
  }): Promise<void>;
421
- abstract getDescription(variant: DescriptionVariant): string | undefined;
422
- abstract getMethods(): ReadonlyArray<Method> | undefined;
423
- abstract getSchema(variant: IOVariant): IOSchema;
424
- abstract getResponses(variant: ResponseVariant): ReadonlyArray<NormalizedResponse>;
425
- abstract getSecurity(): LogicalContainer<Security>[];
426
- abstract getScopes(): ReadonlyArray<string>;
427
- abstract getTags(): ReadonlyArray<string>;
428
- abstract getOperationId(method: Method): string | undefined;
429
- abstract getRequestType(): ContentType;
430
- abstract get isDeprecated(): boolean;
431
383
  }
432
384
  declare class Endpoint<IN extends IOSchema, OUT extends IOSchema, OPT extends FlatObject> extends AbstractEndpoint {
433
385
  #private;
@@ -446,17 +398,6 @@ declare class Endpoint<IN extends IOSchema, OUT extends IOSchema, OPT extends Fl
446
398
  tags?: string[];
447
399
  });
448
400
  deprecated(): this;
449
- get isDeprecated(): boolean;
450
- getDescription(variant: DescriptionVariant): string | undefined;
451
- getMethods(): Readonly<("get" | "post" | "put" | "delete" | "patch")[] | undefined>;
452
- getSchema(variant: "input"): IN;
453
- getSchema(variant: "output"): OUT;
454
- getRequestType(): "form" | "json" | "upload" | "raw";
455
- getResponses(variant: ResponseVariant): readonly NormalizedResponse[];
456
- getSecurity(): LogicalContainer<Security>[];
457
- getScopes(): readonly string[];
458
- getTags(): readonly string[];
459
- getOperationId(method: Method): string | undefined;
460
401
  execute({ request, response, logger, config, }: {
461
402
  request: Request;
462
403
  response: Response;
@@ -491,8 +432,7 @@ interface CommonConfig {
491
432
  * @desc How to respond to a request that uses a wrong method to an existing endpoint
492
433
  * @example 404 — Not found
493
434
  * @example 405 — Method not allowed, incl. the "Allow" header with a list of methods
494
- * @default 404
495
- * @todo consider changing default to 405 in v23
435
+ * @default 405
496
436
  * */
497
437
  wrongMethodBehavior?: 404 | 405;
498
438
  /**
@@ -877,12 +817,7 @@ interface DocumentationParams {
877
817
  tags?: Parameters<typeof depictTags>[0];
878
818
  }
879
819
  declare class Documentation extends OpenApiBuilder {
880
- protected lastSecuritySchemaIds: Map<SecuritySchemeType, number>;
881
- protected lastOperationIdSuffixes: Map<string, number>;
882
- protected references: Map<z.ZodTypeAny, string>;
883
- protected makeRef(schema: z.ZodTypeAny, subject: SchemaObject | ReferenceObject | (() => SchemaObject | ReferenceObject), name?: string | undefined): ReferenceObject;
884
- protected ensureUniqOperationId(path: string, method: Method, userDefined?: string): string;
885
- protected ensureUniqSecuritySchemaName(subject: SecuritySchemeObject): string;
820
+ #private;
886
821
  constructor({ routing, config, title, version, serverUrl, descriptions, brandHandling, tags, isHeader, numericRange, hasSummaryFromDescription, composition, }: DocumentationParams);
887
822
  }
888
823
 
@@ -951,16 +886,11 @@ declare const testEndpoint: <LOG extends FlatObject, REQ extends RequestOptions>
951
886
  _getLogs: () => Record<"debug" | "info" | "warn" | "error", unknown[]>;
952
887
  };
953
888
  }>;
954
- declare const testMiddleware: <LOG extends FlatObject, REQ extends RequestOptions>({ middleware, options, errorHandler, ...rest }: TestingProps<REQ, LOG> & {
889
+ declare const testMiddleware: <LOG extends FlatObject, REQ extends RequestOptions>({ middleware, options, ...rest }: TestingProps<REQ, LOG> & {
955
890
  /** @desc The middleware to test */
956
891
  middleware: AbstractMiddleware;
957
892
  /** @desc The aggregated output from previously executed middlewares */
958
893
  options?: FlatObject;
959
- /**
960
- * @desc Enables transforming possible middleware errors into response, so that test Middleware does not throw
961
- * @todo consider utilizing errorHandler from config instead in v23
962
- * */
963
- errorHandler?: (error: Error, response: Response) => void;
964
894
  }) => Promise<{
965
895
  requestMock: node_mocks_http.MockRequest<Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>> & REQ>;
966
896
  responseMock: node_mocks_http.MockResponse<Response<any, Record<string, any>>>;
@@ -970,70 +900,10 @@ declare const testMiddleware: <LOG extends FlatObject, REQ extends RequestOption
970
900
  output: FlatObject;
971
901
  }>;
972
902
 
973
- type Typeable = ts.TypeNode | ts.Identifier | string | ts.KeywordTypeSyntaxKind;
974
-
975
- type IOKind = "input" | "response" | ResponseVariant | "encoded";
976
- type Store = Record<IOKind, ts.TypeNode>;
977
903
  declare abstract class IntegrationBase {
904
+ #private;
978
905
  private readonly serverUrl;
979
- protected paths: Set<string>;
980
- protected tags: Map<string, readonly string[]>;
981
- protected registry: Map<string, {
982
- store: Store;
983
- isDeprecated: boolean;
984
- }>;
985
- protected ids: {
986
- pathType: ts.Identifier;
987
- implementationType: ts.Identifier;
988
- keyParameter: ts.Identifier;
989
- pathParameter: ts.Identifier;
990
- paramsArgument: ts.Identifier;
991
- ctxArgument: ts.Identifier;
992
- methodParameter: ts.Identifier;
993
- requestParameter: ts.Identifier;
994
- eventParameter: ts.Identifier;
995
- dataParameter: ts.Identifier;
996
- handlerParameter: ts.Identifier;
997
- msgParameter: ts.Identifier;
998
- parseRequestFn: ts.Identifier;
999
- substituteFn: ts.Identifier;
1000
- provideMethod: ts.Identifier;
1001
- onMethod: ts.Identifier;
1002
- implementationArgument: ts.Identifier;
1003
- hasBodyConst: ts.Identifier;
1004
- undefinedValue: ts.Identifier;
1005
- responseConst: ts.Identifier;
1006
- restConst: ts.Identifier;
1007
- searchParamsConst: ts.Identifier;
1008
- defaultImplementationConst: ts.Identifier;
1009
- clientConst: ts.Identifier;
1010
- contentTypeConst: ts.Identifier;
1011
- isJsonConst: ts.Identifier;
1012
- sourceProp: ts.Identifier;
1013
- };
1014
- protected interfaces: Record<IOKind, ts.Identifier>;
1015
- protected methodType: ts.TypeAliasDeclaration;
1016
- protected someOfType: ts.TypeAliasDeclaration;
1017
- protected requestType: ts.TypeAliasDeclaration;
1018
906
  protected constructor(serverUrl: string);
1019
- /** @example SomeOf<_> */
1020
- protected someOf: ({ name }: ts.TypeAliasDeclaration) => ts.TypeNode;
1021
- protected makePathType: () => ts.TypeAliasDeclaration;
1022
- protected makePublicInterfaces: () => ts.InterfaceDeclaration[];
1023
- protected makeEndpointTags: () => ts.VariableStatement;
1024
- protected makeImplementationType: () => ts.TypeAliasDeclaration;
1025
- protected makeParseRequestFn: () => ts.VariableStatement;
1026
- protected makeSubstituteFn: () => ts.VariableStatement;
1027
- private makeProvider;
1028
- protected makeClientClass: (name: string) => ts.ClassDeclaration;
1029
- protected makeSearchParams: (from: ts.Expression) => ts.TemplateExpression;
1030
- protected makeFetchURL: () => ts.NewExpression;
1031
- protected makeDefaultImplementation: () => ts.VariableStatement;
1032
- protected makeSubscriptionConstructor: () => ts.ConstructorDeclaration;
1033
- protected makeEventNarrow: (value: Typeable) => ts.TypeLiteralNode;
1034
- protected makeOnMethod: () => ts.MethodDeclaration;
1035
- protected makeSubscriptionClass: (name: string) => ts.ClassDeclaration;
1036
- protected makeUsageStatements: (clientClassName: string, subscriptionClassName: string) => ts.Node[];
1037
907
  }
1038
908
 
1039
909
  interface ZTSContext extends FlatObject {
@@ -1103,12 +973,8 @@ interface FormattedPrintingOptions {
1103
973
  format?: (program: string) => Promise<string>;
1104
974
  }
1105
975
  declare class Integration extends IntegrationBase {
1106
- protected program: ts.Node[];
1107
- protected usage: Array<ts.Node | string>;
1108
- protected aliases: Map<z.ZodTypeAny, ts.TypeAliasDeclaration>;
1109
- protected makeAlias(schema: z.ZodTypeAny, produce: () => ts.TypeNode): ts.TypeNode;
976
+ #private;
1110
977
  constructor({ routing, brandHandling, variant, clientClassName, subscriptionClassName, serverUrl, optionalPropStyle, noContent, }: IntegrationParams);
1111
- protected printUsage(printerOptions?: ts.PrinterOptions): string | undefined;
1112
978
  print(printerOptions?: ts.PrinterOptions): string;
1113
979
  printFormatted({ printerOptions, format: userDefined, }?: FormattedPrintingOptions): Promise<string>;
1114
980
  }
@@ -1124,4 +990,4 @@ declare class EventStreamFactory<E extends EventsMap> extends EndpointsFactory<E
1124
990
  constructor(events: E);
1125
991
  }
1126
992
 
1127
- 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 };
993
+ 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 };
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ import { ListenOptions } from 'node:net';
11
11
  import * as qs from 'qs';
12
12
  import * as express_serve_static_core from 'express-serve-static-core';
13
13
  import http from 'node:http';
14
- import { SchemaObject, ReferenceObject, TagObject, OpenApiBuilder, SecuritySchemeType, SecuritySchemeObject } from 'openapi3-ts/oas31';
14
+ import { SchemaObject, ReferenceObject, TagObject, OpenApiBuilder } from 'openapi3-ts/oas31';
15
15
  import * as node_mocks_http from 'node-mocks-http';
16
16
  import { RequestOptions, ResponseOptions } from 'node-mocks-http';
17
17
  import ts from 'typescript';
@@ -86,36 +86,6 @@ declare class BuiltinLogger implements AbstractLogger {
86
86
  profile(options: ProfilerOptions): () => void;
87
87
  }
88
88
 
89
- declare const defaultStatusCodes: {
90
- positive: number;
91
- negative: number;
92
- };
93
- type ResponseVariant = keyof typeof defaultStatusCodes;
94
- /** @public this is the user facing configuration */
95
- interface ApiResponse<S extends z.ZodTypeAny> {
96
- schema: S;
97
- /** @default 200 for a positive and 400 for a negative response */
98
- statusCode?: number | [number, ...number[]];
99
- /**
100
- * @example null is for no content, such as 204 and 302
101
- * @default "application/json"
102
- * */
103
- mimeType?: string | [string, ...string[]] | null;
104
- /** @deprecated use statusCode */
105
- statusCodes?: never;
106
- /** @deprecated use mimeType */
107
- mimeTypes?: never;
108
- }
109
- /**
110
- * @private This is what the framework entities operate
111
- * @see normalize
112
- * */
113
- interface NormalizedResponse {
114
- schema: z.ZodTypeAny;
115
- statusCodes: [number, ...number[]];
116
- mimeTypes: [string, ...string[]] | null;
117
- }
118
-
119
89
  /** @desc Accepts an object shape or a custom object schema */
120
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>;
121
91
  type FormSchema = ReturnType<typeof form>;
@@ -139,8 +109,7 @@ interface InputSecurity<K extends string> {
139
109
  type: "input";
140
110
  name: K;
141
111
  }
142
- /** @todo rename to just HeaderSecurity */
143
- interface CustomHeaderSecurity {
112
+ interface HeaderSecurity {
144
113
  type: "header";
145
114
  name: string;
146
115
  }
@@ -200,7 +169,7 @@ interface OAuth2Security<S extends string> {
200
169
  * @param K is an optional input field used by InputSecurity
201
170
  * @param S is an optional union of scopes used by OAuth2Security
202
171
  * */
203
- type Security<K extends string = string, S extends string = string> = BasicSecurity | BearerSecurity | InputSecurity<K> | CustomHeaderSecurity | CookieSecurity | OpenIdSecurity | OAuth2Security<S>;
172
+ type Security<K extends string = string, S extends string = string> = BasicSecurity | BearerSecurity | InputSecurity<K> | HeaderSecurity | CookieSecurity | OpenIdSecurity | OAuth2Security<S>;
204
173
 
205
174
  type Handler$2<IN, OPT, OUT> = (params: {
206
175
  /** @desc The inputs from the enabled input sources validated against final input schema of the Middleware */
@@ -218,8 +187,6 @@ type Handler$2<IN, OPT, OUT> = (params: {
218
187
  logger: ActualLogger;
219
188
  }) => Promise<OUT>;
220
189
  declare abstract class AbstractMiddleware {
221
- abstract getSecurity(): LogicalContainer<Security> | undefined;
222
- abstract getSchema(): IOSchema<"strip">;
223
190
  abstract execute(params: {
224
191
  input: unknown;
225
192
  options: FlatObject;
@@ -242,8 +209,6 @@ declare class Middleware<OPT extends FlatObject, OUT extends FlatObject, SCO ext
242
209
  /** @desc The handler returning options available to Endpoints */
243
210
  handler: Handler$2<z.output<IN>, OPT, OUT>;
244
211
  });
245
- getSecurity(): LogicalContainer<Security<Extract<keyof z.input<IN>, string>, SCO>> | undefined;
246
- getSchema(): IN;
247
212
  /** @throws InputValidationError */
248
213
  execute({ input, ...rest }: {
249
214
  input: unknown;
@@ -285,29 +250,32 @@ type IOSchema<U extends z.UnknownKeysParam = z.UnknownKeysParam> = BaseObject<U>
285
250
  declare const methods: ("get" | "post" | "put" | "delete" | "patch")[];
286
251
  type Method = (typeof methods)[number];
287
252
 
288
- declare const contentTypes: {
289
- json: string;
290
- upload: string;
291
- raw: string;
292
- sse: string;
293
- form: string;
294
- };
295
- type ContentType = keyof typeof contentTypes;
296
-
297
253
  declare class DependsOnMethod extends Routable {
298
254
  #private;
299
255
  constructor(endpoints: Partial<Record<Method, AbstractEndpoint>>);
300
- /** @desc [method, endpoint, siblingMethods] */
301
- get entries(): ReadonlyArray<[Method, AbstractEndpoint, Method[]]>;
302
256
  deprecated(): this;
303
257
  }
304
258
 
305
259
  type OriginalStatic = typeof express__default.static;
306
- type StaticHandler = ReturnType<OriginalStatic>;
307
260
  declare class ServeStatic {
308
- params: Parameters<OriginalStatic>;
261
+ #private;
309
262
  constructor(...params: Parameters<OriginalStatic>);
310
- apply(path: string, cb: (path: string, handler: StaticHandler) => void): void;
263
+ }
264
+
265
+ /** @public this is the user facing configuration */
266
+ interface ApiResponse<S extends z.ZodTypeAny> {
267
+ schema: S;
268
+ /** @default 200 for a positive and 400 for a negative response */
269
+ statusCode?: number | [number, ...number[]];
270
+ /**
271
+ * @example null is for no content, such as 204 and 302
272
+ * @default "application/json"
273
+ * */
274
+ mimeType?: string | [string, ...string[]] | null;
275
+ /** @deprecated use statusCode */
276
+ statusCodes?: never;
277
+ /** @deprecated use mimeType */
278
+ mimeTypes?: never;
311
279
  }
312
280
 
313
281
  type ResultSchema<R extends Result> = R extends Result<infer S> ? S : never;
@@ -333,8 +301,6 @@ type Result<S extends z.ZodTypeAny = z.ZodTypeAny> = S | ApiResponse<S> | ApiRes
333
301
  type LazyResult<R extends Result, A extends unknown[] = []> = (...args: A) => R;
334
302
  declare abstract class AbstractResultHandler {
335
303
  #private;
336
- abstract getPositiveResponse(output: IOSchema): NormalizedResponse[];
337
- abstract getNegativeResponse(): NormalizedResponse[];
338
304
  protected constructor(handler: Handler$1);
339
305
  execute(...params: Parameters<Handler$1>): void | Promise<void>;
340
306
  }
@@ -348,8 +314,6 @@ declare class ResultHandler<POS extends Result, NEG extends Result> extends Abst
348
314
  /** @desc The actual implementation to transmit the response in any case */
349
315
  handler: Handler$1<z.output<ResultSchema<POS> | ResultSchema<NEG>>>;
350
316
  });
351
- getPositiveResponse(output: IOSchema): NormalizedResponse[];
352
- getNegativeResponse(): NormalizedResponse[];
353
317
  }
354
318
  declare const defaultResultHandler: ResultHandler<z.ZodObject<{
355
319
  status: z.ZodLiteral<"success">;
@@ -409,8 +373,6 @@ type Handler<IN, OUT, OPT> = (params: {
409
373
  /** @desc The instance of the configured logger */
410
374
  logger: ActualLogger;
411
375
  }) => Promise<OUT>;
412
- type DescriptionVariant = "short" | "long";
413
- type IOVariant = "input" | "output";
414
376
  declare abstract class AbstractEndpoint extends Routable {
415
377
  abstract execute(params: {
416
378
  request: Request;
@@ -418,16 +380,6 @@ declare abstract class AbstractEndpoint extends Routable {
418
380
  logger: ActualLogger;
419
381
  config: CommonConfig;
420
382
  }): Promise<void>;
421
- abstract getDescription(variant: DescriptionVariant): string | undefined;
422
- abstract getMethods(): ReadonlyArray<Method> | undefined;
423
- abstract getSchema(variant: IOVariant): IOSchema;
424
- abstract getResponses(variant: ResponseVariant): ReadonlyArray<NormalizedResponse>;
425
- abstract getSecurity(): LogicalContainer<Security>[];
426
- abstract getScopes(): ReadonlyArray<string>;
427
- abstract getTags(): ReadonlyArray<string>;
428
- abstract getOperationId(method: Method): string | undefined;
429
- abstract getRequestType(): ContentType;
430
- abstract get isDeprecated(): boolean;
431
383
  }
432
384
  declare class Endpoint<IN extends IOSchema, OUT extends IOSchema, OPT extends FlatObject> extends AbstractEndpoint {
433
385
  #private;
@@ -446,17 +398,6 @@ declare class Endpoint<IN extends IOSchema, OUT extends IOSchema, OPT extends Fl
446
398
  tags?: string[];
447
399
  });
448
400
  deprecated(): this;
449
- get isDeprecated(): boolean;
450
- getDescription(variant: DescriptionVariant): string | undefined;
451
- getMethods(): Readonly<("get" | "post" | "put" | "delete" | "patch")[] | undefined>;
452
- getSchema(variant: "input"): IN;
453
- getSchema(variant: "output"): OUT;
454
- getRequestType(): "form" | "json" | "upload" | "raw";
455
- getResponses(variant: ResponseVariant): readonly NormalizedResponse[];
456
- getSecurity(): LogicalContainer<Security>[];
457
- getScopes(): readonly string[];
458
- getTags(): readonly string[];
459
- getOperationId(method: Method): string | undefined;
460
401
  execute({ request, response, logger, config, }: {
461
402
  request: Request;
462
403
  response: Response;
@@ -491,8 +432,7 @@ interface CommonConfig {
491
432
  * @desc How to respond to a request that uses a wrong method to an existing endpoint
492
433
  * @example 404 — Not found
493
434
  * @example 405 — Method not allowed, incl. the "Allow" header with a list of methods
494
- * @default 404
495
- * @todo consider changing default to 405 in v23
435
+ * @default 405
496
436
  * */
497
437
  wrongMethodBehavior?: 404 | 405;
498
438
  /**
@@ -877,12 +817,7 @@ interface DocumentationParams {
877
817
  tags?: Parameters<typeof depictTags>[0];
878
818
  }
879
819
  declare class Documentation extends OpenApiBuilder {
880
- protected lastSecuritySchemaIds: Map<SecuritySchemeType, number>;
881
- protected lastOperationIdSuffixes: Map<string, number>;
882
- protected references: Map<z.ZodTypeAny, string>;
883
- protected makeRef(schema: z.ZodTypeAny, subject: SchemaObject | ReferenceObject | (() => SchemaObject | ReferenceObject), name?: string | undefined): ReferenceObject;
884
- protected ensureUniqOperationId(path: string, method: Method, userDefined?: string): string;
885
- protected ensureUniqSecuritySchemaName(subject: SecuritySchemeObject): string;
820
+ #private;
886
821
  constructor({ routing, config, title, version, serverUrl, descriptions, brandHandling, tags, isHeader, numericRange, hasSummaryFromDescription, composition, }: DocumentationParams);
887
822
  }
888
823
 
@@ -951,16 +886,11 @@ declare const testEndpoint: <LOG extends FlatObject, REQ extends RequestOptions>
951
886
  _getLogs: () => Record<"debug" | "info" | "warn" | "error", unknown[]>;
952
887
  };
953
888
  }>;
954
- declare const testMiddleware: <LOG extends FlatObject, REQ extends RequestOptions>({ middleware, options, errorHandler, ...rest }: TestingProps<REQ, LOG> & {
889
+ declare const testMiddleware: <LOG extends FlatObject, REQ extends RequestOptions>({ middleware, options, ...rest }: TestingProps<REQ, LOG> & {
955
890
  /** @desc The middleware to test */
956
891
  middleware: AbstractMiddleware;
957
892
  /** @desc The aggregated output from previously executed middlewares */
958
893
  options?: FlatObject;
959
- /**
960
- * @desc Enables transforming possible middleware errors into response, so that test Middleware does not throw
961
- * @todo consider utilizing errorHandler from config instead in v23
962
- * */
963
- errorHandler?: (error: Error, response: Response) => void;
964
894
  }) => Promise<{
965
895
  requestMock: node_mocks_http.MockRequest<Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>> & REQ>;
966
896
  responseMock: node_mocks_http.MockResponse<Response<any, Record<string, any>>>;
@@ -970,70 +900,10 @@ declare const testMiddleware: <LOG extends FlatObject, REQ extends RequestOption
970
900
  output: FlatObject;
971
901
  }>;
972
902
 
973
- type Typeable = ts.TypeNode | ts.Identifier | string | ts.KeywordTypeSyntaxKind;
974
-
975
- type IOKind = "input" | "response" | ResponseVariant | "encoded";
976
- type Store = Record<IOKind, ts.TypeNode>;
977
903
  declare abstract class IntegrationBase {
904
+ #private;
978
905
  private readonly serverUrl;
979
- protected paths: Set<string>;
980
- protected tags: Map<string, readonly string[]>;
981
- protected registry: Map<string, {
982
- store: Store;
983
- isDeprecated: boolean;
984
- }>;
985
- protected ids: {
986
- pathType: ts.Identifier;
987
- implementationType: ts.Identifier;
988
- keyParameter: ts.Identifier;
989
- pathParameter: ts.Identifier;
990
- paramsArgument: ts.Identifier;
991
- ctxArgument: ts.Identifier;
992
- methodParameter: ts.Identifier;
993
- requestParameter: ts.Identifier;
994
- eventParameter: ts.Identifier;
995
- dataParameter: ts.Identifier;
996
- handlerParameter: ts.Identifier;
997
- msgParameter: ts.Identifier;
998
- parseRequestFn: ts.Identifier;
999
- substituteFn: ts.Identifier;
1000
- provideMethod: ts.Identifier;
1001
- onMethod: ts.Identifier;
1002
- implementationArgument: ts.Identifier;
1003
- hasBodyConst: ts.Identifier;
1004
- undefinedValue: ts.Identifier;
1005
- responseConst: ts.Identifier;
1006
- restConst: ts.Identifier;
1007
- searchParamsConst: ts.Identifier;
1008
- defaultImplementationConst: ts.Identifier;
1009
- clientConst: ts.Identifier;
1010
- contentTypeConst: ts.Identifier;
1011
- isJsonConst: ts.Identifier;
1012
- sourceProp: ts.Identifier;
1013
- };
1014
- protected interfaces: Record<IOKind, ts.Identifier>;
1015
- protected methodType: ts.TypeAliasDeclaration;
1016
- protected someOfType: ts.TypeAliasDeclaration;
1017
- protected requestType: ts.TypeAliasDeclaration;
1018
906
  protected constructor(serverUrl: string);
1019
- /** @example SomeOf<_> */
1020
- protected someOf: ({ name }: ts.TypeAliasDeclaration) => ts.TypeNode;
1021
- protected makePathType: () => ts.TypeAliasDeclaration;
1022
- protected makePublicInterfaces: () => ts.InterfaceDeclaration[];
1023
- protected makeEndpointTags: () => ts.VariableStatement;
1024
- protected makeImplementationType: () => ts.TypeAliasDeclaration;
1025
- protected makeParseRequestFn: () => ts.VariableStatement;
1026
- protected makeSubstituteFn: () => ts.VariableStatement;
1027
- private makeProvider;
1028
- protected makeClientClass: (name: string) => ts.ClassDeclaration;
1029
- protected makeSearchParams: (from: ts.Expression) => ts.TemplateExpression;
1030
- protected makeFetchURL: () => ts.NewExpression;
1031
- protected makeDefaultImplementation: () => ts.VariableStatement;
1032
- protected makeSubscriptionConstructor: () => ts.ConstructorDeclaration;
1033
- protected makeEventNarrow: (value: Typeable) => ts.TypeLiteralNode;
1034
- protected makeOnMethod: () => ts.MethodDeclaration;
1035
- protected makeSubscriptionClass: (name: string) => ts.ClassDeclaration;
1036
- protected makeUsageStatements: (clientClassName: string, subscriptionClassName: string) => ts.Node[];
1037
907
  }
1038
908
 
1039
909
  interface ZTSContext extends FlatObject {
@@ -1103,12 +973,8 @@ interface FormattedPrintingOptions {
1103
973
  format?: (program: string) => Promise<string>;
1104
974
  }
1105
975
  declare class Integration extends IntegrationBase {
1106
- protected program: ts.Node[];
1107
- protected usage: Array<ts.Node | string>;
1108
- protected aliases: Map<z.ZodTypeAny, ts.TypeAliasDeclaration>;
1109
- protected makeAlias(schema: z.ZodTypeAny, produce: () => ts.TypeNode): ts.TypeNode;
976
+ #private;
1110
977
  constructor({ routing, brandHandling, variant, clientClassName, subscriptionClassName, serverUrl, optionalPropStyle, noContent, }: IntegrationParams);
1111
- protected printUsage(printerOptions?: ts.PrinterOptions): string | undefined;
1112
978
  print(printerOptions?: ts.PrinterOptions): string;
1113
979
  printFormatted({ printerOptions, format: userDefined, }?: FormattedPrintingOptions): Promise<string>;
1114
980
  }
@@ -1124,4 +990,4 @@ declare class EventStreamFactory<E extends EventsMap> extends EndpointsFactory<E
1124
990
  constructor(events: E);
1125
991
  }
1126
992
 
1127
- 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 };
993
+ 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 };