express-zod-api 25.2.0-beta.2 → 25.3.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.ts CHANGED
@@ -1,23 +1,25 @@
1
- import '@express-zod-api/zod-plugin';
2
- import compression from 'compression';
3
- import * as express from 'express';
4
- import express__default, { Request, Response, NextFunction, RequestHandler, IRouter } from 'express';
5
- import * as express_fileupload from 'express-fileupload';
6
- import express_fileupload__default from 'express-fileupload';
7
- import https, { ServerOptions } from 'node:https';
8
- import * as zod from 'zod';
9
- import { z } from 'zod';
10
- import { HttpError } from 'http-errors';
11
- import { ListenOptions } from 'node:net';
12
- import * as qs from 'qs';
13
- import * as express_serve_static_core from 'express-serve-static-core';
14
- import http from 'node:http';
15
- import { SchemaObject, ReferenceObject, TagObject, OpenApiBuilder } from 'openapi3-ts/oas31';
16
- import * as node_mocks_http from 'node-mocks-http';
17
- import { RequestOptions, ResponseOptions } from 'node-mocks-http';
18
- import ts from 'typescript';
19
- import * as zod_v4_core from 'zod/v4/core';
1
+ import "@express-zod-api/zod-plugin";
2
+ import * as zod0 from "zod";
3
+ import { z } from "zod";
4
+ import { HttpError } from "http-errors";
5
+ import "ansis";
6
+ import * as express0 from "express";
7
+ import express, { IRouter, NextFunction, Request, RequestHandler, Response } from "express";
8
+ import http from "node:http";
9
+ import https, { ServerOptions } from "node:https";
10
+ import { OpenApiBuilder, ReferenceObject, SchemaObject, TagObject } from "openapi3-ts/oas31";
11
+ import * as node_mocks_http0 from "node-mocks-http";
12
+ import { RequestOptions, ResponseOptions } from "node-mocks-http";
13
+ import ts from "typescript";
14
+ import compression from "compression";
15
+ import * as express_fileupload0 from "express-fileupload";
16
+ import fileUpload from "express-fileupload";
17
+ import { ListenOptions } from "node:net";
18
+ import * as express_serve_static_core0 from "express-serve-static-core";
19
+ import * as qs0 from "qs";
20
+ import * as zod_v4_core0 from "zod/v4/core";
20
21
 
22
+ //#region src/method.d.ts
21
23
  declare const methods: ("get" | "post" | "put" | "delete" | "patch")[];
22
24
  declare const clientMethods: ("get" | "post" | "put" | "delete" | "patch" | "head")[];
23
25
  /**
@@ -32,19 +34,31 @@ type Method = (typeof methods)[number];
32
34
  * @example Method | "head"
33
35
  * */
34
36
  type ClientMethod = (typeof clientMethods)[number];
35
-
37
+ /**
38
+ * @desc Methods supported in CORS headers
39
+ * @see makeCorsHeaders
40
+ * @see createWrongMethodHandler
41
+ * @example ClientMethod | "options"
42
+ * */
43
+ //#endregion
44
+ //#region src/api-response.d.ts
36
45
  /** @public this is the user facing configuration */
37
46
  interface ApiResponse<S extends z.ZodType> {
38
- schema: S;
39
- /** @default 200 for a positive and 400 for a negative response */
40
- statusCode?: number | [number, ...number[]];
41
- /**
42
- * @example null is for no content, such as 204 and 302
43
- * @default "application/json"
44
- * */
45
- mimeType?: string | [string, ...string[]] | null;
47
+ schema: S;
48
+ /** @default 200 for a positive and 400 for a negative response */
49
+ statusCode?: number | [number, ...number[]];
50
+ /**
51
+ * @example null is for no content, such as 204 and 302
52
+ * @default "application/json"
53
+ * */
54
+ mimeType?: string | [string, ...string[]] | null;
46
55
  }
47
-
56
+ /**
57
+ * @private This is what the framework entities operate
58
+ * @see normalize
59
+ * */
60
+ //#endregion
61
+ //#region src/common-helpers.d.ts
48
62
  /** @since zod 3.25.61 output type fixed */
49
63
  declare const emptySchema: z.ZodObject<{}, z.core.$strip>;
50
64
  type EmptySchema = typeof emptySchema;
@@ -58,16 +72,19 @@ type NoNever<T, F> = [T] extends [never] ? F : T;
58
72
  * @example declare module "express-zod-api" { interface TagOverrides { users: unknown } }
59
73
  * @link https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
60
74
  * */
61
- interface TagOverrides {
62
- }
75
+ interface TagOverrides {}
63
76
  type Tag = NoNever<keyof TagOverrides, string>;
64
- declare const getMessageFromError: (error: Error) => string;
77
+ /** @see https://expressjs.com/en/guide/routing.html */
65
78
 
79
+ declare const getMessageFromError: (error: Error) => string;
80
+ /** Faster replacement to instanceof for code operating core types (traversing schemas) */
81
+ //#endregion
82
+ //#region src/logger-helpers.d.ts
66
83
  declare const severity: {
67
- debug: number;
68
- info: number;
69
- warn: number;
70
- error: number;
84
+ debug: number;
85
+ info: number;
86
+ warn: number;
87
+ error: number;
71
88
  };
72
89
  type Severity = keyof typeof severity;
73
90
  /** @desc You can use any logger compatible with this type. */
@@ -77,125 +94,136 @@ type AbstractLogger = Record<Severity, (message: string, meta?: any) => any>;
77
94
  * @example declare module "express-zod-api" { interface LoggerOverrides extends winston.Logger {} }
78
95
  * @link https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
79
96
  * */
80
- interface LoggerOverrides {
81
- }
97
+ interface LoggerOverrides {}
82
98
  type ActualLogger = AbstractLogger & LoggerOverrides;
83
-
84
- interface Context extends FlatObject {
85
- requestId?: string;
99
+ //#endregion
100
+ //#region src/builtin-logger.d.ts
101
+ interface Context$1 extends FlatObject {
102
+ requestId?: string;
86
103
  }
87
104
  interface BuiltinLoggerConfig {
88
- /**
89
- * @desc The minimal severity to log or "silent" to disable logging
90
- * @example "debug" also enables pretty output for inspected entities
91
- * */
92
- level: "silent" | "warn" | "info" | "debug";
93
- /** @desc Enables colors on printed severity and inspected entities */
94
- color: boolean;
95
- /**
96
- * @desc Control how deeply entities should be inspected
97
- * @example null
98
- * @example Infinity
99
- * */
100
- depth: number | null;
101
- /**
102
- * @desc Context: the metadata applicable for each logged entry, used by .child() method
103
- * @see childLoggerProvider
104
- * */
105
- ctx: Context;
105
+ /**
106
+ * @desc The minimal severity to log or "silent" to disable logging
107
+ * @example "debug" also enables pretty output for inspected entities
108
+ * */
109
+ level: "silent" | "warn" | "info" | "debug";
110
+ /** @desc Enables colors on printed severity and inspected entities */
111
+ color: boolean;
112
+ /**
113
+ * @desc Control how deeply entities should be inspected
114
+ * @example null
115
+ * @example Infinity
116
+ * */
117
+ depth: number | null;
118
+ /**
119
+ * @desc Context: the metadata applicable for each logged entry, used by .child() method
120
+ * @see childLoggerProvider
121
+ * */
122
+ ctx: Context$1;
106
123
  }
107
124
  interface ProfilerOptions {
108
- message: string;
109
- /** @default "debug" */
110
- severity?: Severity | ((ms: number) => Severity);
111
- /** @default formatDuration - adaptive units and limited fraction */
112
- formatter?: (ms: number) => string | number;
125
+ message: string;
126
+ /** @default "debug" */
127
+ severity?: Severity | ((ms: number) => Severity);
128
+ /** @default formatDuration - adaptive units and limited fraction */
129
+ formatter?: (ms: number) => string | number;
113
130
  }
114
131
  /** @desc Built-in console logger with optional colorful inspections */
115
132
  declare class BuiltinLogger implements AbstractLogger {
116
- protected readonly config: BuiltinLoggerConfig;
117
- /** @example new BuiltinLogger({ level: "debug", color: true, depth: 4 }) */
118
- constructor({ color, level, depth, ctx, }?: Partial<BuiltinLoggerConfig>);
119
- protected format(subject: unknown): string;
120
- protected print(method: Severity, message: string, meta?: unknown): void;
121
- debug(message: string, meta?: unknown): void;
122
- info(message: string, meta?: unknown): void;
123
- warn(message: string, meta?: unknown): void;
124
- error(message: string, meta?: unknown): void;
125
- child(ctx: Context): BuiltinLogger;
126
- /**
127
- * @desc The argument used for instance created by .child() method
128
- * @see ChildLoggerProvider
129
- * */
130
- get ctx(): Context;
131
- /** @desc Measures the duration until you invoke the returned callback */
132
- profile(message: string): () => void;
133
- profile(options: ProfilerOptions): () => void;
133
+ protected readonly config: BuiltinLoggerConfig;
134
+ /** @example new BuiltinLogger({ level: "debug", color: true, depth: 4 }) */
135
+ constructor({
136
+ color,
137
+ level,
138
+ depth,
139
+ ctx
140
+ }?: Partial<BuiltinLoggerConfig>);
141
+ protected format(subject: unknown): string;
142
+ protected print(method: Severity, message: string, meta?: unknown): void;
143
+ debug(message: string, meta?: unknown): void;
144
+ info(message: string, meta?: unknown): void;
145
+ warn(message: string, meta?: unknown): void;
146
+ error(message: string, meta?: unknown): void;
147
+ child(ctx: Context$1): BuiltinLogger;
148
+ /**
149
+ * @desc The argument used for instance created by .child() method
150
+ * @see ChildLoggerProvider
151
+ * */
152
+ get ctx(): Context$1;
153
+ /** @desc Measures the duration until you invoke the returned callback */
154
+ profile(message: string): () => void;
155
+ profile(options: ProfilerOptions): () => void;
134
156
  }
135
-
157
+ //#endregion
158
+ //#region src/io-schema.d.ts
136
159
  type Base$1 = object & {
137
- [Symbol.iterator]?: never;
160
+ [Symbol.iterator]?: never;
138
161
  };
139
162
  /** @desc The type allowed on the top level of Middlewares and Endpoints */
140
163
  type IOSchema = z.ZodType<Base$1>;
141
164
  /** EndpointsFactory schema extended type when adding a Middleware */
142
165
  type Extension<Current extends IOSchema | undefined, Inc extends IOSchema | undefined> = Current extends IOSchema ? Inc extends IOSchema ? z.ZodIntersection<Current, Inc> : Current : Inc;
166
+ /** Makes a schema for EndpointsFactory extended with a Middleware */
167
+
143
168
  /** The Endpoint input schema type, condition wrapped into schema to make it z.output-compatible */
144
169
  type FinalInputSchema<FIN extends IOSchema | undefined, BIN extends IOSchema> = z.ZodIntersection<FIN extends IOSchema ? FIN : BIN, BIN>;
145
-
170
+ /** Makes the Endpoint input schema */
171
+ //#endregion
172
+ //#region src/logical-container.d.ts
146
173
  type LogicalOr<T> = {
147
- or: T[];
174
+ or: T[];
148
175
  };
149
176
  type LogicalAnd<T> = {
150
- and: T[];
177
+ and: T[];
151
178
  };
152
179
  type LogicalContainer<T> = LogicalOr<T | LogicalAnd<T>> | LogicalAnd<T | LogicalOr<T>> | T;
153
-
180
+ //#endregion
181
+ //#region src/security.d.ts
154
182
  interface BasicSecurity {
155
- type: "basic";
183
+ type: "basic";
156
184
  }
157
185
  interface BearerSecurity {
158
- type: "bearer";
159
- format?: "JWT" | string;
186
+ type: "bearer";
187
+ format?: "JWT" | string;
160
188
  }
161
189
  interface InputSecurity<K extends string> {
162
- type: "input";
163
- name: K;
190
+ type: "input";
191
+ name: K;
164
192
  }
165
193
  interface HeaderSecurity {
166
- type: "header";
167
- name: string;
194
+ type: "header";
195
+ name: string;
168
196
  }
169
197
  interface CookieSecurity {
170
- type: "cookie";
171
- name: string;
198
+ type: "cookie";
199
+ name: string;
172
200
  }
173
201
  /**
174
202
  * @see https://swagger.io/docs/specification/authentication/openid-connect-discovery/
175
203
  * @desc available scopes has to be provided via the specified URL
176
204
  */
177
205
  interface OpenIdSecurity {
178
- type: "openid";
179
- url: string;
206
+ type: "openid";
207
+ url: string;
180
208
  }
181
209
  interface AuthUrl {
182
- /**
183
- * @desc The authorization URL to use for this flow. Can be relative to the API server URL.
184
- * @see https://swagger.io/docs/specification/api-host-and-base-path/
185
- */
186
- authorizationUrl: string;
210
+ /**
211
+ * @desc The authorization URL to use for this flow. Can be relative to the API server URL.
212
+ * @see https://swagger.io/docs/specification/api-host-and-base-path/
213
+ */
214
+ authorizationUrl: string;
187
215
  }
188
216
  interface TokenUrl {
189
- /** @desc The token URL to use for this flow. Can be relative to the API server URL. */
190
- tokenUrl: string;
217
+ /** @desc The token URL to use for this flow. Can be relative to the API server URL. */
218
+ tokenUrl: string;
191
219
  }
192
220
  interface RefreshUrl {
193
- /** @desc The URL to be used for obtaining refresh tokens. Can be relative to the API server URL. */
194
- refreshUrl?: string;
221
+ /** @desc The URL to be used for obtaining refresh tokens. Can be relative to the API server URL. */
222
+ refreshUrl?: string;
195
223
  }
196
224
  interface Scopes<K extends string> {
197
- /** @desc The available scopes for the OAuth2 security and their short descriptions. Optional. */
198
- scopes?: Record<K, string>;
225
+ /** @desc The available scopes for the OAuth2 security and their short descriptions. Optional. */
226
+ scopes?: Record<K, string>;
199
227
  }
200
228
  type AuthCodeFlow<S extends string> = AuthUrl & TokenUrl & RefreshUrl & Scopes<S>;
201
229
  type ImplicitFlow<S extends string> = AuthUrl & RefreshUrl & Scopes<S>;
@@ -205,17 +233,17 @@ type ClientCredFlow<S extends string> = TokenUrl & RefreshUrl & Scopes<S>;
205
233
  * @see https://swagger.io/docs/specification/authentication/oauth2/
206
234
  */
207
235
  interface OAuth2Security<S extends string> {
208
- type: "oauth2";
209
- flows?: {
210
- /** @desc Authorization Code flow (previously called accessCode in OpenAPI 2.0) */
211
- authorizationCode?: AuthCodeFlow<S>;
212
- /** @desc Implicit flow */
213
- implicit?: ImplicitFlow<S>;
214
- /** @desc Resource Owner Password flow */
215
- password?: PasswordFlow<S>;
216
- /** @desc Client Credentials flow (previously called application in OpenAPI 2.0) */
217
- clientCredentials?: ClientCredFlow<S>;
218
- };
236
+ type: "oauth2";
237
+ flows?: {
238
+ /** @desc Authorization Code flow (previously called accessCode in OpenAPI 2.0) */
239
+ authorizationCode?: AuthCodeFlow<S>;
240
+ /** @desc Implicit flow */
241
+ implicit?: ImplicitFlow<S>;
242
+ /** @desc Resource Owner Password flow */
243
+ password?: PasswordFlow<S>;
244
+ /** @desc Client Credentials flow (previously called application in OpenAPI 2.0) */
245
+ clientCredentials?: ClientCredFlow<S>;
246
+ };
219
247
  }
220
248
  /**
221
249
  * @desc Middleware security schema descriptor
@@ -223,122 +251,139 @@ interface OAuth2Security<S extends string> {
223
251
  * @param S is an optional union of scopes used by OAuth2Security
224
252
  * */
225
253
  type Security<K extends string = string, S extends string = string> = BasicSecurity | BearerSecurity | InputSecurity<K> | HeaderSecurity | CookieSecurity | OpenIdSecurity | OAuth2Security<S>;
226
-
254
+ //#endregion
255
+ //#region src/middleware.d.ts
227
256
  type Handler$2<IN, OPT, OUT> = (params: {
228
- /** @desc The inputs from the enabled input sources validated against the input schema of the Middleware */
229
- input: IN;
257
+ /** @desc The inputs from the enabled input sources validated against the input schema of the Middleware */
258
+ input: IN;
259
+ /**
260
+ * @desc The returns of the previously executed Middlewares (typed when chaining Middlewares)
261
+ * @link https://github.com/RobinTail/express-zod-api/discussions/1250
262
+ * */
263
+ options: OPT;
264
+ /** @link https://expressjs.com/en/5x/api.html#req */
265
+ request: Request;
266
+ /** @link https://expressjs.com/en/5x/api.html#res */
267
+ response: Response;
268
+ /** @desc The instance of the configured logger */
269
+ logger: ActualLogger;
270
+ }) => Promise<OUT>;
271
+ declare abstract class AbstractMiddleware {
272
+ abstract execute(params: {
273
+ input: unknown;
274
+ options: FlatObject;
275
+ request: Request;
276
+ response: Response;
277
+ logger: ActualLogger;
278
+ }): Promise<FlatObject>;
279
+ }
280
+ declare class Middleware<OPT extends FlatObject, OUT extends FlatObject, SCO extends string, IN extends IOSchema | undefined = undefined> extends AbstractMiddleware {
281
+ #private;
282
+ constructor({
283
+ input,
284
+ security,
285
+ handler
286
+ }: {
230
287
  /**
231
- * @desc The returns of the previously executed Middlewares (typed when chaining Middlewares)
232
- * @link https://github.com/RobinTail/express-zod-api/discussions/1250
288
+ * @desc Input schema of the Middleware, combining properties from all the enabled input sources
289
+ * @default undefined
290
+ * @see defaultInputSources
233
291
  * */
292
+ input?: IN;
293
+ /** @desc Declaration of the security schemas implemented within the handler */
294
+ security?: LogicalContainer<Security<Extract<keyof z.input<IN>, string>, SCO>>;
295
+ /** @desc The handler returning options available to Endpoints */
296
+ handler: Handler$2<z.output<IN>, OPT, OUT>;
297
+ });
298
+ /** @throws InputValidationError */
299
+ execute({
300
+ input,
301
+ ...rest
302
+ }: {
303
+ input: unknown;
234
304
  options: OPT;
235
- /** @link https://expressjs.com/en/5x/api.html#req */
236
305
  request: Request;
237
- /** @link https://expressjs.com/en/5x/api.html#res */
238
306
  response: Response;
239
- /** @desc The instance of the configured logger */
240
307
  logger: ActualLogger;
241
- }) => Promise<OUT>;
242
- declare abstract class AbstractMiddleware {
243
- abstract execute(params: {
244
- input: unknown;
245
- options: FlatObject;
246
- request: Request;
247
- response: Response;
248
- logger: ActualLogger;
249
- }): Promise<FlatObject>;
250
- }
251
- declare class Middleware<OPT extends FlatObject, OUT extends FlatObject, SCO extends string, IN extends IOSchema | undefined = undefined> extends AbstractMiddleware {
252
- #private;
253
- constructor({ input, security, handler, }: {
254
- /**
255
- * @desc Input schema of the Middleware, combining properties from all the enabled input sources
256
- * @default undefined
257
- * @see defaultInputSources
258
- * */
259
- input?: IN;
260
- /** @desc Declaration of the security schemas implemented within the handler */
261
- security?: LogicalContainer<Security<Extract<keyof z.input<IN>, string>, SCO>>;
262
- /** @desc The handler returning options available to Endpoints */
263
- handler: Handler$2<z.output<IN>, OPT, OUT>;
264
- });
265
- /** @throws InputValidationError */
266
- execute({ input, ...rest }: {
267
- input: unknown;
268
- options: OPT;
269
- request: Request;
270
- response: Response;
271
- logger: ActualLogger;
272
- }): Promise<OUT>;
308
+ }): Promise<OUT>;
273
309
  }
274
310
  declare class ExpressMiddleware<R extends Request, S extends Response, OUT extends FlatObject> extends Middleware<FlatObject, OUT, string> {
275
- constructor(nativeMw: (request: R, response: S, next: NextFunction) => any, { provider, transformer, }?: {
276
- provider?: (request: R, response: S) => OUT | Promise<OUT>;
277
- transformer?: (err: Error) => Error;
278
- });
311
+ constructor(nativeMw: (request: R, response: S, next: NextFunction) => any, {
312
+ provider,
313
+ transformer
314
+ }?: {
315
+ provider?: (request: R, response: S) => OUT | Promise<OUT>;
316
+ transformer?: (err: Error) => Error;
317
+ });
279
318
  }
280
-
319
+ //#endregion
320
+ //#region src/depends-on-method.d.ts
281
321
  declare class DependsOnMethod extends Routable {
282
- #private;
283
- constructor(endpoints: Partial<Record<Method, AbstractEndpoint>>);
284
- deprecated(): this;
322
+ #private;
323
+ constructor(endpoints: Partial<Record<Method, AbstractEndpoint>>);
324
+ deprecated(): this;
285
325
  }
286
-
287
- type OriginalStatic = typeof express__default.static;
326
+ //#endregion
327
+ //#region src/serve-static.d.ts
328
+ type OriginalStatic = typeof express.static;
288
329
  declare class ServeStatic {
289
- #private;
290
- constructor(...params: Parameters<OriginalStatic>);
330
+ #private;
331
+ constructor(...params: Parameters<OriginalStatic>);
291
332
  }
292
-
333
+ //#endregion
334
+ //#region src/result-helpers.d.ts
293
335
  type ResultSchema<R extends Result> = R extends Result<infer S> ? S : never;
294
336
  type DiscriminatedResult = {
295
- output: FlatObject;
296
- error: null;
337
+ output: FlatObject;
338
+ error: null;
297
339
  } | {
298
- output: null;
299
- error: Error;
340
+ output: null;
341
+ error: Error;
300
342
  };
343
+ /** @throws ResultHandlerError when Result is an empty array */
344
+
301
345
  /**
302
346
  * @example InputValidationError —> BadRequest(400)
303
347
  * @example Error —> InternalServerError(500)
304
348
  * */
305
349
  declare const ensureHttpError: (error: Error) => HttpError;
306
-
350
+ //#endregion
351
+ //#region src/result-handler.d.ts
307
352
  type Handler$1<RES = unknown> = (params: DiscriminatedResult & {
308
- /** null in case of failure to parse or to find the matching endpoint (error: not found) */
309
- input: FlatObject | null;
310
- /** can be empty: check presence of the required property using "in" operator */
311
- options: FlatObject;
312
- request: Request;
313
- response: Response<RES>;
314
- logger: ActualLogger;
353
+ /** null in case of failure to parse or to find the matching endpoint (error: not found) */
354
+ input: FlatObject | null;
355
+ /** can be empty: check presence of the required property using "in" operator */
356
+ options: FlatObject;
357
+ request: Request;
358
+ response: Response<RES>;
359
+ logger: ActualLogger;
315
360
  }) => void | Promise<void>;
316
361
  type Result<S extends z.ZodType = z.ZodType> = S | ApiResponse<S> | ApiResponse<S>[];
317
362
  type LazyResult<R extends Result, A extends unknown[] = []> = (...args: A) => R;
318
363
  declare abstract class AbstractResultHandler {
319
- #private;
320
- protected constructor(handler: Handler$1);
321
- execute(...params: Parameters<Handler$1>): void | Promise<void>;
364
+ #private;
365
+ protected constructor(handler: Handler$1);
366
+ execute(...params: Parameters<Handler$1>): void | Promise<void>;
322
367
  }
323
368
  declare class ResultHandler<POS extends Result, NEG extends Result> extends AbstractResultHandler {
324
- #private;
325
- constructor(params: {
326
- /** @desc A description of the API response in case of success (schema, status code, MIME type) */
327
- positive: POS | LazyResult<POS, [IOSchema]>;
328
- /** @desc A description of the API response in case of error (schema, status code, MIME type) */
329
- negative: NEG | LazyResult<NEG>;
330
- /** @desc The actual implementation to transmit the response in any case */
331
- handler: Handler$1<z.output<ResultSchema<POS> | ResultSchema<NEG>>>;
332
- });
369
+ #private;
370
+ constructor(params: {
371
+ /** @desc A description of the API response in case of success (schema, status code, MIME type) */
372
+ positive: POS | LazyResult<POS, [IOSchema]>;
373
+ /** @desc A description of the API response in case of error (schema, status code, MIME type) */
374
+ negative: NEG | LazyResult<NEG>;
375
+ /** @desc The actual implementation to transmit the response in any case */
376
+ handler: Handler$1<z.output<ResultSchema<POS> | ResultSchema<NEG>>>;
377
+ });
333
378
  }
334
379
  declare const defaultResultHandler: ResultHandler<z.ZodObject<{
335
- status: z.ZodLiteral<"success">;
336
- data: IOSchema;
380
+ status: z.ZodLiteral<"success">;
381
+ data: IOSchema;
337
382
  }, z.core.$strip>, z.ZodObject<{
338
- status: z.ZodLiteral<"error">;
339
- error: z.ZodObject<{
340
- message: z.ZodString;
341
- }, z.core.$strip>;
383
+ status: z.ZodLiteral<"error">;
384
+ error: z.ZodObject<{
385
+ message: z.ZodString;
386
+ }, z.core.$strip>;
342
387
  }, z.core.$strip>>;
343
388
  /**
344
389
  * @deprecated Resist the urge of using it: this handler is designed only to simplify the migration of legacy APIs.
@@ -346,13 +391,15 @@ declare const defaultResultHandler: ResultHandler<z.ZodObject<{
346
391
  * @desc This handler expects your endpoint to have the property 'items' in the output object schema
347
392
  * */
348
393
  declare const arrayResultHandler: ResultHandler<z.ZodArray<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>> | z.ZodArray<z.ZodAny>, {
349
- schema: z.ZodString;
350
- mimeType: string;
394
+ schema: z.ZodString;
395
+ mimeType: string;
351
396
  }>;
352
-
397
+ //#endregion
398
+ //#region src/server-helpers.d.ts
353
399
  /** @desc Returns child logger for the given request (if configured) or the configured logger otherwise */
354
400
  type GetLogger = (request?: Request) => ActualLogger;
355
-
401
+ //#endregion
402
+ //#region src/routing.d.ts
356
403
  /**
357
404
  * @example { v1: { books: { ":bookId": getBookEndpoint } } }
358
405
  * @example { "v1/books/:bookId": getBookEndpoint }
@@ -360,273 +407,293 @@ type GetLogger = (request?: Request) => ActualLogger;
360
407
  * @example { v1: { "patch /books/:bookId": changeBookEndpoint } }
361
408
  * */
362
409
  interface Routing {
363
- [K: string]: Routing | DependsOnMethod | AbstractEndpoint | ServeStatic;
410
+ [K: string]: Routing | DependsOnMethod | AbstractEndpoint | ServeStatic;
364
411
  }
365
-
412
+ //#endregion
413
+ //#region src/routable.d.ts
366
414
  declare abstract class Routable {
367
- /** @desc Marks the route as deprecated (makes a copy of the endpoint) */
368
- abstract deprecated(): this;
369
- /** @desc Enables nested routes within the path assigned to the subject */
370
- nest(routing: Routing): Routing;
415
+ /** @desc Marks the route as deprecated (makes a copy of the endpoint) */
416
+ abstract deprecated(): this;
417
+ /** @desc Enables nested routes within the path assigned to the subject */
418
+ nest(routing: Routing): Routing;
371
419
  }
372
-
420
+ //#endregion
421
+ //#region src/endpoint.d.ts
373
422
  type Handler<IN, OUT, OPT> = (params: {
374
- /** @desc The inputs from the enabled input sources validated against the final input schema (incl. Middlewares) */
375
- input: IN;
376
- /** @desc The returns of the assigned Middlewares */
377
- options: OPT;
378
- /** @desc The instance of the configured logger */
379
- logger: ActualLogger;
423
+ /** @desc The inputs from the enabled input sources validated against the final input schema (incl. Middlewares) */
424
+ input: IN;
425
+ /** @desc The returns of the assigned Middlewares */
426
+ options: OPT;
427
+ /** @desc The instance of the configured logger */
428
+ logger: ActualLogger;
380
429
  }) => Promise<OUT>;
381
430
  declare abstract class AbstractEndpoint extends Routable {
382
- abstract execute(params: {
383
- request: Request;
384
- response: Response;
385
- logger: ActualLogger;
386
- config: CommonConfig;
387
- }): Promise<void>;
431
+ abstract execute(params: {
432
+ request: Request;
433
+ response: Response;
434
+ logger: ActualLogger;
435
+ config: CommonConfig;
436
+ }): Promise<void>;
388
437
  }
389
438
  declare class Endpoint<IN extends IOSchema, OUT extends IOSchema, OPT extends FlatObject> extends AbstractEndpoint {
390
- #private;
391
- constructor(def: {
392
- deprecated?: boolean;
393
- middlewares?: AbstractMiddleware[];
394
- inputSchema: IN;
395
- outputSchema: OUT;
396
- handler: Handler<z.output<IN>, z.input<OUT>, OPT>;
397
- resultHandler: AbstractResultHandler;
398
- description?: string;
399
- shortDescription?: string;
400
- getOperationId?: (method: ClientMethod) => string | undefined;
401
- methods?: Method[];
402
- scopes?: string[];
403
- tags?: string[];
404
- });
405
- deprecated(): this;
406
- execute({ request, response, logger, config, }: {
407
- request: Request;
408
- response: Response;
409
- logger: ActualLogger;
410
- config: CommonConfig;
411
- }): Promise<undefined>;
439
+ #private;
440
+ constructor(def: {
441
+ deprecated?: boolean;
442
+ middlewares?: AbstractMiddleware[];
443
+ inputSchema: IN;
444
+ outputSchema: OUT;
445
+ handler: Handler<z.output<IN>, z.input<OUT>, OPT>;
446
+ resultHandler: AbstractResultHandler;
447
+ description?: string;
448
+ shortDescription?: string;
449
+ getOperationId?: (method: ClientMethod) => string | undefined;
450
+ methods?: Method[];
451
+ scopes?: string[];
452
+ tags?: string[];
453
+ });
454
+ deprecated(): this;
455
+ execute({
456
+ request,
457
+ response,
458
+ logger,
459
+ config
460
+ }: {
461
+ request: Request;
462
+ response: Response;
463
+ logger: ActualLogger;
464
+ config: CommonConfig;
465
+ }): Promise<undefined>;
412
466
  }
413
-
467
+ //#endregion
468
+ //#region src/config-type.d.ts
414
469
  type InputSource = keyof Pick<Request, "query" | "body" | "files" | "params" | "headers">;
415
470
  type InputSources = Record<Method, InputSource[]>;
416
471
  type Headers = Record<string, string>;
417
472
  type HeadersProvider = (params: {
418
- /** @desc The default headers to be overridden. */
419
- defaultHeaders: Headers;
420
- request: Request;
421
- endpoint: AbstractEndpoint;
422
- logger: ActualLogger;
473
+ /** @desc The default headers to be overridden. */
474
+ defaultHeaders: Headers;
475
+ request: Request;
476
+ endpoint: AbstractEndpoint;
477
+ logger: ActualLogger;
423
478
  }) => Headers | Promise<Headers>;
424
479
  type ChildLoggerProvider = (params: {
425
- request: Request;
426
- parent: ActualLogger;
480
+ request: Request;
481
+ parent: ActualLogger;
427
482
  }) => ActualLogger | Promise<ActualLogger>;
428
483
  type LogAccess = (request: Request, logger: ActualLogger) => void;
429
484
  interface CommonConfig {
430
- /**
431
- * @desc Enables cross-origin resource sharing.
432
- * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
433
- * @desc You can override the default CORS headers by setting up a provider function here.
434
- */
435
- cors: boolean | HeadersProvider;
436
- /**
437
- * @desc How to respond to a request that uses a wrong method to an existing endpoint
438
- * @example 404 — Not found
439
- * @example 405 — Method not allowed, incl. the "Allow" header with a list of methods
440
- * @default 405
441
- * */
442
- wrongMethodBehavior?: 404 | 405;
443
- /**
444
- * @desc The ResultHandler to use for handling routing, parsing and upload errors
445
- * @default defaultResultHandler
446
- * @see defaultResultHandler
447
- */
448
- errorHandler?: AbstractResultHandler;
449
- /**
450
- * @desc Built-in logger configuration or an instance of any compatible logger.
451
- * @example { level: "debug", color: true }
452
- * @default { level: NODE_ENV === "production" ? "warn" : "debug", color: isSupported(), depth: 2 }
453
- * */
454
- logger?: Partial<BuiltinLoggerConfig> | AbstractLogger;
455
- /**
456
- * @desc A child logger returned by this function can override the logger in all handlers for each request
457
- * @example ({ parent }) => parent.child({ requestId: uuid() })
458
- * */
459
- childLoggerProvider?: ChildLoggerProvider;
460
- /**
461
- * @desc The function for producing access logs
462
- * @default ({ method, path }, logger) => logger.debug(`${method}: ${path}`)
463
- * @example null — disables the feature
464
- * */
465
- accessLogger?: null | LogAccess;
466
- /**
467
- * @desc You can disable the startup logo.
468
- * @default true
469
- */
470
- startupLogo?: boolean;
471
- /**
472
- * @desc Which properties of request are combined into the input for endpoints and middlewares.
473
- * @desc The order matters: priority from lowest to highest
474
- * @default defaultInputSources
475
- * @see defaultInputSources
476
- */
477
- inputSources?: Partial<InputSources>;
485
+ /**
486
+ * @desc Enables cross-origin resource sharing.
487
+ * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
488
+ * @desc You can override the default CORS headers by setting up a provider function here.
489
+ */
490
+ cors: boolean | HeadersProvider;
491
+ /**
492
+ * @desc How to respond to a request that uses a wrong method to an existing endpoint
493
+ * @example 404 — Not found
494
+ * @example 405 — Method not allowed, incl. the "Allow" header with a list of methods
495
+ * @default 405
496
+ * */
497
+ wrongMethodBehavior?: 404 | 405;
498
+ /**
499
+ * @desc The ResultHandler to use for handling routing, parsing and upload errors
500
+ * @default defaultResultHandler
501
+ * @see defaultResultHandler
502
+ */
503
+ errorHandler?: AbstractResultHandler;
504
+ /**
505
+ * @desc Built-in logger configuration or an instance of any compatible logger.
506
+ * @example { level: "debug", color: true }
507
+ * @default { level: NODE_ENV === "production" ? "warn" : "debug", color: isSupported(), depth: 2 }
508
+ * */
509
+ logger?: Partial<BuiltinLoggerConfig> | AbstractLogger;
510
+ /**
511
+ * @desc A child logger returned by this function can override the logger in all handlers for each request
512
+ * @example ({ parent }) => parent.child({ requestId: uuid() })
513
+ * */
514
+ childLoggerProvider?: ChildLoggerProvider;
515
+ /**
516
+ * @desc The function for producing access logs
517
+ * @default ({ method, path }, logger) => logger.debug(`${method}: ${path}`)
518
+ * @example null — disables the feature
519
+ * */
520
+ accessLogger?: null | LogAccess;
521
+ /**
522
+ * @desc You can disable the startup logo.
523
+ * @default true
524
+ */
525
+ startupLogo?: boolean;
526
+ /**
527
+ * @desc Which properties of request are combined into the input for endpoints and middlewares.
528
+ * @desc The order matters: priority from lowest to highest
529
+ * @default defaultInputSources
530
+ * @see defaultInputSources
531
+ */
532
+ inputSources?: Partial<InputSources>;
478
533
  }
479
534
  type BeforeUpload = (params: {
480
- request: Request;
481
- logger: ActualLogger;
535
+ request: Request;
536
+ logger: ActualLogger;
482
537
  }) => void | Promise<void>;
483
- type UploadOptions = Pick<express_fileupload__default.Options, "createParentPath" | "uriDecodeFileNames" | "safeFileNames" | "preserveExtension" | "useTempFiles" | "tempFileDir" | "debug" | "uploadTimeout" | "limits"> & {
484
- /**
485
- * @desc The error to throw when the file exceeds the configured fileSize limit (handled by errorHandler).
486
- * @see limits
487
- * @override limitHandler
488
- * @example createHttpError(413, "The file is too large")
489
- * */
490
- limitError?: Error;
491
- /**
492
- * @desc A handler to execute before uploading — it can be used for restrictions by throwing an error.
493
- * @example ({ request }) => { throw createHttpError(403, "Not authorized"); }
494
- * */
495
- beforeUpload?: BeforeUpload;
538
+ type UploadOptions = Pick<fileUpload.Options, "createParentPath" | "uriDecodeFileNames" | "safeFileNames" | "preserveExtension" | "useTempFiles" | "tempFileDir" | "debug" | "uploadTimeout" | "limits"> & {
539
+ /**
540
+ * @desc The error to throw when the file exceeds the configured fileSize limit (handled by errorHandler).
541
+ * @see limits
542
+ * @override limitHandler
543
+ * @example createHttpError(413, "The file is too large")
544
+ * */
545
+ limitError?: Error;
546
+ /**
547
+ * @desc A handler to execute before uploading — it can be used for restrictions by throwing an error.
548
+ * @example ({ request }) => { throw createHttpError(403, "Not authorized"); }
549
+ * */
550
+ beforeUpload?: BeforeUpload;
496
551
  };
497
552
  type CompressionOptions = Pick<compression.CompressionOptions, "threshold" | "level" | "strategy" | "chunkSize" | "memLevel">;
498
553
  interface GracefulOptions {
499
- /**
500
- * @desc Time given to drain ongoing requests before closing the server.
501
- * @default 1000
502
- * */
503
- timeout?: number;
504
- /**
505
- * @desc Process event (Signal) that triggers the graceful shutdown.
506
- * @see Signals
507
- * @default [SIGINT, SIGTERM]
508
- * */
509
- events?: string[];
510
- /** @desc The hook to call after the server was closed, but before terminating the process. */
511
- beforeExit?: () => void | Promise<void>;
554
+ /**
555
+ * @desc Time given to drain ongoing requests before closing the server.
556
+ * @default 1000
557
+ * */
558
+ timeout?: number;
559
+ /**
560
+ * @desc Process event (Signal) that triggers the graceful shutdown.
561
+ * @see Signals
562
+ * @default [SIGINT, SIGTERM]
563
+ * */
564
+ events?: string[];
565
+ /** @desc The hook to call after the server was closed, but before terminating the process. */
566
+ beforeExit?: () => void | Promise<void>;
512
567
  }
513
568
  type BeforeRouting = (params: {
514
- app: IRouter;
515
- /** @desc Returns child logger for the given request (if configured) or the configured logger otherwise */
516
- getLogger: GetLogger;
569
+ app: IRouter;
570
+ /** @desc Returns child logger for the given request (if configured) or the configured logger otherwise */
571
+ getLogger: GetLogger;
517
572
  }) => void | Promise<void>;
518
573
  interface HttpConfig {
519
- /** @desc Port, UNIX socket or custom options. */
520
- listen: number | string | ListenOptions;
574
+ /** @desc Port, UNIX socket or custom options. */
575
+ listen: number | string | ListenOptions;
521
576
  }
522
577
  interface HttpsConfig extends HttpConfig {
523
- /** @desc At least "cert" and "key" options required. */
524
- options: ServerOptions;
578
+ /** @desc At least "cert" and "key" options required. */
579
+ options: ServerOptions;
525
580
  }
526
581
  interface ServerConfig extends CommonConfig {
527
- /** @desc HTTP server configuration. */
528
- http?: HttpConfig;
529
- /** @desc HTTPS server configuration. */
530
- https?: HttpsConfig;
531
- /**
532
- * @desc Custom JSON parser.
533
- * @default express.json()
534
- * @link https://expressjs.com/en/5x/api.html#express.json
535
- * */
536
- jsonParser?: RequestHandler;
537
- /**
538
- * @desc Enable or configure uploads handling.
539
- * @requires express-fileupload
540
- * */
541
- upload?: boolean | UploadOptions;
542
- /**
543
- * @desc Enable or configure response compression.
544
- * @requires compression
545
- */
546
- compression?: boolean | CompressionOptions;
547
- /**
548
- * @desc Custom raw parser (assigns Buffer to request body)
549
- * @default express.raw()
550
- * @link https://expressjs.com/en/5x/api.html#express.raw
551
- * */
552
- rawParser?: RequestHandler;
553
- /**
554
- * @desc Custom parser for URL Encoded requests used for submitting HTML forms
555
- * @default express.urlencoded()
556
- * @link https://expressjs.com/en/5x/api.html#express.urlencoded
557
- * */
558
- formParser?: RequestHandler;
559
- /**
560
- * @desc A code to execute before processing the Routing of your API (and before parsing).
561
- * @desc This can be a good place for express middlewares establishing their own routes.
562
- * @desc It can help to avoid making a DIY solution based on the attachRouting() approach.
563
- * @example ({ app }) => { app.use('/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); }
564
- * */
565
- beforeRouting?: BeforeRouting;
566
- /**
567
- * @desc Rejects new connections and attempts to finish ongoing ones in the specified time before exit.
568
- * */
569
- gracefulShutdown?: boolean | GracefulOptions;
582
+ /** @desc HTTP server configuration. */
583
+ http?: HttpConfig;
584
+ /** @desc HTTPS server configuration. */
585
+ https?: HttpsConfig;
586
+ /**
587
+ * @desc Custom JSON parser.
588
+ * @default express.json()
589
+ * @link https://expressjs.com/en/5x/api.html#express.json
590
+ * */
591
+ jsonParser?: RequestHandler;
592
+ /**
593
+ * @desc Enable or configure uploads handling.
594
+ * @requires express-fileupload
595
+ * */
596
+ upload?: boolean | UploadOptions;
597
+ /**
598
+ * @desc Enable or configure response compression.
599
+ * @requires compression
600
+ */
601
+ compression?: boolean | CompressionOptions;
602
+ /**
603
+ * @desc Custom raw parser (assigns Buffer to request body)
604
+ * @default express.raw()
605
+ * @link https://expressjs.com/en/5x/api.html#express.raw
606
+ * */
607
+ rawParser?: RequestHandler;
608
+ /**
609
+ * @desc Custom parser for URL Encoded requests used for submitting HTML forms
610
+ * @default express.urlencoded()
611
+ * @link https://expressjs.com/en/5x/api.html#express.urlencoded
612
+ * */
613
+ formParser?: RequestHandler;
614
+ /**
615
+ * @desc A code to execute before processing the Routing of your API (and before parsing).
616
+ * @desc This can be a good place for express middlewares establishing their own routes.
617
+ * @desc It can help to avoid making a DIY solution based on the attachRouting() approach.
618
+ * @example ({ app }) => { app.use('/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); }
619
+ * */
620
+ beforeRouting?: BeforeRouting;
621
+ /**
622
+ * @desc Rejects new connections and attempts to finish ongoing ones in the specified time before exit.
623
+ * */
624
+ gracefulShutdown?: boolean | GracefulOptions;
570
625
  }
571
626
  interface AppConfig extends CommonConfig {
572
- /** @desc Your custom express app or express router instead. */
573
- app: IRouter;
627
+ /** @desc Your custom express app or express router instead. */
628
+ app: IRouter;
574
629
  }
575
630
  declare function createConfig(config: ServerConfig): ServerConfig;
576
631
  declare function createConfig(config: AppConfig): AppConfig;
577
-
632
+ //#endregion
633
+ //#region src/endpoints-factory.d.ts
578
634
  interface BuildProps<IN extends IOSchema, OUT extends IOSchema | z.ZodVoid, MIN extends IOSchema | undefined, OPT extends FlatObject, SCO extends string> {
579
- /**
580
- * @desc Input schema of the Endpoint, combining properties from all the enabled input sources (path params, headers)
581
- * @default z.object({})
582
- * @see defaultInputSources
583
- * */
584
- input?: IN;
585
- /** @desc The schema by which the returns of the Endpoint handler is validated */
586
- output: OUT;
587
- /** @desc The Endpoint handler receiving the validated inputs, returns of added Middlewares (options) and a logger */
588
- handler: Handler<z.output<FinalInputSchema<MIN, IN>>, z.input<OUT>, OPT>;
589
- /** @desc The operation description for the generated Documentation */
590
- description?: string;
591
- /** @desc The operation summary for the generated Documentation (50 symbols max) */
592
- shortDescription?: string;
593
- /** @desc The operation ID for the generated Documentation (must be unique) */
594
- operationId?: string | ((method: ClientMethod) => string);
595
- /**
596
- * @desc HTTP method(s) this endpoint can handle
597
- * @default "get" unless the Endpoint is assigned within DependsOnMethod
598
- * @see DependsOnMethod
599
- * */
600
- method?: Method | [Method, ...Method[]];
601
- /**
602
- * @desc Scope(s) from the list of the ones defined by the added Middlewares having "oauth2" security type
603
- * @see OAuth2Security
604
- * */
605
- scope?: SCO | SCO[];
606
- /**
607
- * @desc Tag(s) for generating Documentation. For establishing constraints:
608
- * @see TagOverrides
609
- * */
610
- tag?: Tag | Tag[];
611
- /** @desc Marks the operation deprecated in the generated Documentation */
612
- deprecated?: boolean;
635
+ /**
636
+ * @desc Input schema of the Endpoint, combining properties from all the enabled input sources (path params, headers)
637
+ * @default z.object({})
638
+ * @see defaultInputSources
639
+ * */
640
+ input?: IN;
641
+ /** @desc The schema by which the returns of the Endpoint handler is validated */
642
+ output: OUT;
643
+ /** @desc The Endpoint handler receiving the validated inputs, returns of added Middlewares (options) and a logger */
644
+ handler: Handler<z.output<FinalInputSchema<MIN, IN>>, z.input<OUT>, OPT>;
645
+ /** @desc The operation description for the generated Documentation */
646
+ description?: string;
647
+ /** @desc The operation summary for the generated Documentation (50 symbols max) */
648
+ shortDescription?: string;
649
+ /** @desc The operation ID for the generated Documentation (must be unique) */
650
+ operationId?: string | ((method: ClientMethod) => string);
651
+ /**
652
+ * @desc HTTP method(s) this endpoint can handle
653
+ * @default "get" unless the Endpoint is assigned within DependsOnMethod
654
+ * @see DependsOnMethod
655
+ * */
656
+ method?: Method | [Method, ...Method[]];
657
+ /**
658
+ * @desc Scope(s) from the list of the ones defined by the added Middlewares having "oauth2" security type
659
+ * @see OAuth2Security
660
+ * */
661
+ scope?: SCO | SCO[];
662
+ /**
663
+ * @desc Tag(s) for generating Documentation. For establishing constraints:
664
+ * @see TagOverrides
665
+ * */
666
+ tag?: Tag | Tag[];
667
+ /** @desc Marks the operation deprecated in the generated Documentation */
668
+ deprecated?: boolean;
613
669
  }
614
670
  declare class EndpointsFactory<IN extends IOSchema | undefined = undefined, OUT extends FlatObject = EmptyObject, SCO extends string = string> {
615
- #private;
616
- protected resultHandler: AbstractResultHandler;
617
- protected schema: IN;
618
- protected middlewares: AbstractMiddleware[];
619
- constructor(resultHandler: AbstractResultHandler);
620
- addMiddleware<AOUT extends FlatObject, ASCO extends string, AIN extends IOSchema | undefined = undefined>(subject: Middleware<OUT, AOUT, ASCO, AIN> | ConstructorParameters<typeof Middleware<OUT, AOUT, ASCO, AIN>>[0]): EndpointsFactory<Extension<IN, AIN>, OUT & AOUT, SCO & ASCO>;
621
- use: <R extends Request, S extends Response, AOUT extends FlatObject = Record<string, never>>(nativeMw: (request: R, response: S, next: express.NextFunction) => any, params_1?: {
622
- provider?: ((request: R, response: S) => AOUT | Promise<AOUT>) | undefined;
623
- transformer?: (err: Error) => Error;
624
- } | undefined) => EndpointsFactory<Extension<IN, undefined>, OUT & AOUT, SCO>;
625
- addExpressMiddleware<R extends Request, S extends Response, AOUT extends FlatObject = EmptyObject>(...params: ConstructorParameters<typeof ExpressMiddleware<R, S, AOUT>>): EndpointsFactory<Extension<IN, undefined>, OUT & AOUT, SCO>;
626
- addOptions<AOUT extends FlatObject>(getOptions: () => Promise<AOUT>): EndpointsFactory<Extension<IN, undefined>, OUT & AOUT, SCO>;
627
- build<BOUT extends IOSchema, BIN extends IOSchema = EmptySchema>({ input, output: outputSchema, operationId, scope, tag, method, ...rest }: BuildProps<BIN, BOUT, IN, OUT, SCO>): Endpoint<FinalInputSchema<IN, BIN>, BOUT, OUT>;
628
- /** @desc shorthand for returning {} while having output schema z.object({}) */
629
- buildVoid<BIN extends IOSchema = EmptySchema>({ handler, ...rest }: Omit<BuildProps<BIN, z.ZodVoid, IN, OUT, SCO>, "output">): Endpoint<FinalInputSchema<IN, BIN>, z.ZodObject<{}, z.core.$strip>, OUT>;
671
+ #private;
672
+ protected resultHandler: AbstractResultHandler;
673
+ protected schema: IN;
674
+ protected middlewares: AbstractMiddleware[];
675
+ constructor(resultHandler: AbstractResultHandler);
676
+ addMiddleware<AOUT extends FlatObject, ASCO extends string, AIN extends IOSchema | undefined = undefined>(subject: Middleware<OUT, AOUT, ASCO, AIN> | ConstructorParameters<typeof Middleware<OUT, AOUT, ASCO, AIN>>[0]): EndpointsFactory<Extension<IN, AIN>, OUT & AOUT, SCO & ASCO>;
677
+ use: <R extends Request, S extends Response, AOUT extends FlatObject = Record<string, never>>(nativeMw: (request: R, response: S, next: express0.NextFunction) => any, params_1?: {
678
+ provider?: ((request: R, response: S) => AOUT | Promise<AOUT>) | undefined;
679
+ transformer?: (err: Error) => Error;
680
+ } | undefined) => EndpointsFactory<Extension<IN, undefined>, OUT & AOUT, SCO>;
681
+ addExpressMiddleware<R extends Request, S extends Response, AOUT extends FlatObject = EmptyObject>(...params: ConstructorParameters<typeof ExpressMiddleware<R, S, AOUT>>): EndpointsFactory<Extension<IN, undefined>, OUT & AOUT, SCO>;
682
+ addOptions<AOUT extends FlatObject>(getOptions: () => Promise<AOUT>): EndpointsFactory<Extension<IN, undefined>, OUT & AOUT, SCO>;
683
+ build<BOUT extends IOSchema, BIN extends IOSchema = EmptySchema>({
684
+ input,
685
+ output: outputSchema,
686
+ operationId,
687
+ scope,
688
+ tag,
689
+ method,
690
+ ...rest
691
+ }: BuildProps<BIN, BOUT, IN, OUT, SCO>): Endpoint<FinalInputSchema<IN, BIN>, BOUT, OUT>;
692
+ /** @desc shorthand for returning {} while having output schema z.object({}) */
693
+ buildVoid<BIN extends IOSchema = EmptySchema>({
694
+ handler,
695
+ ...rest
696
+ }: Omit<BuildProps<BIN, z.ZodVoid, IN, OUT, SCO>, "output">): Endpoint<FinalInputSchema<IN, BIN>, z.ZodObject<{}, z.core.$strip>, OUT>;
630
697
  }
631
698
  declare const defaultEndpointsFactory: EndpointsFactory<undefined, Record<string, never>, string>;
632
699
  /**
@@ -635,277 +702,332 @@ declare const defaultEndpointsFactory: EndpointsFactory<undefined, Record<string
635
702
  * @desc The result handler of this factory expects your endpoint to have the property 'items' in the output schema
636
703
  */
637
704
  declare const arrayEndpointsFactory: EndpointsFactory<undefined, Record<string, never>, string>;
638
-
705
+ //#endregion
706
+ //#region src/server.d.ts
639
707
  declare const attachRouting: (config: AppConfig, routing: Routing) => {
640
- notFoundHandler: express__default.RequestHandler<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>;
641
- logger: AbstractLogger | BuiltinLogger;
708
+ notFoundHandler: express.RequestHandler<express_serve_static_core0.ParamsDictionary, any, any, qs0.ParsedQs, Record<string, any>>;
709
+ logger: AbstractLogger | BuiltinLogger;
642
710
  };
643
711
  declare const createServer: (config: ServerConfig, routing: Routing) => Promise<{
644
- app: express_serve_static_core.Express;
645
- logger: AbstractLogger | BuiltinLogger;
646
- servers: (http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | https.Server<typeof http.IncomingMessage, typeof http.ServerResponse>)[];
712
+ app: express_serve_static_core0.Express;
713
+ logger: AbstractLogger | BuiltinLogger;
714
+ servers: (http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | https.Server<typeof http.IncomingMessage, typeof http.ServerResponse>)[];
647
715
  }>;
648
-
716
+ //#endregion
717
+ //#region src/documentation-helpers.d.ts
649
718
  interface ReqResCommons {
650
- makeRef: (key: object | string, subject: SchemaObject | ReferenceObject, name?: string) => ReferenceObject;
651
- path: string;
652
- method: ClientMethod;
719
+ makeRef: (key: object | string, subject: SchemaObject | ReferenceObject, name?: string) => ReferenceObject;
720
+ path: string;
721
+ method: ClientMethod;
653
722
  }
654
723
  interface OpenAPIContext extends ReqResCommons {
655
- isResponse: boolean;
724
+ isResponse: boolean;
656
725
  }
657
726
  type Depicter = (zodCtx: {
658
- zodSchema: z.core.$ZodType;
659
- jsonSchema: z.core.JSONSchema.BaseSchema;
727
+ zodSchema: z.core.$ZodType;
728
+ jsonSchema: z.core.JSONSchema.BaseSchema;
660
729
  }, oasCtx: OpenAPIContext) => z.core.JSONSchema.BaseSchema | SchemaObject;
661
730
  /** @desc Using defaultIsHeader when returns null or undefined */
662
731
  type IsHeader = (name: string, method: ClientMethod, path: string) => boolean | null | undefined;
663
732
  type BrandHandling = Record<string | symbol, Depicter>;
664
733
  declare const depictTags: (tags: Partial<Record<Tag, string | {
665
- description: string;
666
- url?: string;
734
+ description: string;
735
+ url?: string;
667
736
  }>>) => TagObject[];
668
-
737
+ //#endregion
738
+ //#region src/documentation.d.ts
669
739
  type Component = "positiveResponse" | "negativeResponse" | "requestParameter" | "requestBody";
670
740
  /** @desc user defined function that creates a component description from its properties */
671
741
  type Descriptor = (props: Record<"method" | "path" | "operationId", string> & {
672
- statusCode?: number;
742
+ statusCode?: number;
673
743
  }) => string;
674
744
  interface DocumentationParams {
675
- title: string;
676
- version: string;
677
- serverUrl: string | [string, ...string[]];
678
- routing: Routing;
679
- config: CommonConfig;
680
- /**
681
- * @desc Descriptions of various components based on their properties (method, path, operationId).
682
- * @desc When composition set to "components", component name is generated from this description
683
- * @default () => `${method} ${path} ${component}`
684
- * */
685
- descriptions?: Partial<Record<Component, Descriptor>>;
686
- /** @default true */
687
- hasSummaryFromDescription?: boolean;
688
- /**
689
- * @desc Depict the HEAD method for each Endpoint supporting the GET method (feature of Express)
690
- * @default true
691
- * */
692
- hasHeadMethod?: boolean;
693
- /** @default inline */
694
- composition?: "inline" | "components";
695
- /**
696
- * @desc Handling rules for your own branded schemas.
697
- * @desc Keys: brands (recommended to use unique symbols).
698
- * @desc Values: functions having Zod context as first argument, second one is the framework context.
699
- * @example { MyBrand: ( { zodSchema, jsonSchema } ) => ({ type: "object" })
700
- */
701
- brandHandling?: BrandHandling;
702
- /**
703
- * @desc Ability to configure recognition of headers among other input data
704
- * @desc Only applicable when "headers" is present within inputSources config option
705
- * @see defaultIsHeader
706
- * @link https://www.iana.org/assignments/http-fields/http-fields.xhtml
707
- * */
708
- isHeader?: IsHeader;
709
- /**
710
- * @desc Extended description of tags used in endpoints. For enforcing constraints:
711
- * @see TagOverrides
712
- * @example { users: "About users", files: { description: "About files", url: "https://example.com" } }
713
- * */
714
- tags?: Parameters<typeof depictTags>[0];
745
+ title: string;
746
+ version: string;
747
+ serverUrl: string | [string, ...string[]];
748
+ routing: Routing;
749
+ config: CommonConfig;
750
+ /**
751
+ * @desc Descriptions of various components based on their properties (method, path, operationId).
752
+ * @desc When composition set to "components", component name is generated from this description
753
+ * @default () => `${method} ${path} ${component}`
754
+ * */
755
+ descriptions?: Partial<Record<Component, Descriptor>>;
756
+ /** @default true */
757
+ hasSummaryFromDescription?: boolean;
758
+ /**
759
+ * @desc Depict the HEAD method for each Endpoint supporting the GET method (feature of Express)
760
+ * @default true
761
+ * */
762
+ hasHeadMethod?: boolean;
763
+ /** @default inline */
764
+ composition?: "inline" | "components";
765
+ /**
766
+ * @desc Handling rules for your own branded schemas.
767
+ * @desc Keys: brands (recommended to use unique symbols).
768
+ * @desc Values: functions having Zod context as first argument, second one is the framework context.
769
+ * @example { MyBrand: ( { zodSchema, jsonSchema } ) => ({ type: "object" })
770
+ */
771
+ brandHandling?: BrandHandling;
772
+ /**
773
+ * @desc Ability to configure recognition of headers among other input data
774
+ * @desc Only applicable when "headers" is present within inputSources config option
775
+ * @see defaultIsHeader
776
+ * @link https://www.iana.org/assignments/http-fields/http-fields.xhtml
777
+ * */
778
+ isHeader?: IsHeader;
779
+ /**
780
+ * @desc Extended description of tags used in endpoints. For enforcing constraints:
781
+ * @see TagOverrides
782
+ * @example { users: "About users", files: { description: "About files", url: "https://example.com" } }
783
+ * */
784
+ tags?: Parameters<typeof depictTags>[0];
715
785
  }
716
786
  declare class Documentation extends OpenApiBuilder {
717
- #private;
718
- constructor({ routing, config, title, version, serverUrl, descriptions, brandHandling, tags, isHeader, hasSummaryFromDescription, hasHeadMethod, composition, }: DocumentationParams);
787
+ #private;
788
+ constructor({
789
+ routing,
790
+ config,
791
+ title,
792
+ version,
793
+ serverUrl,
794
+ descriptions,
795
+ brandHandling,
796
+ tags,
797
+ isHeader,
798
+ hasSummaryFromDescription,
799
+ hasHeadMethod,
800
+ composition
801
+ }: DocumentationParams);
719
802
  }
720
-
803
+ //#endregion
804
+ //#region src/errors.d.ts
721
805
  /** @desc An error related to the wrong Routing declaration */
722
806
  declare class RoutingError extends Error {
723
- name: string;
724
- readonly cause: {
725
- method: Method;
726
- path: string;
727
- };
728
- constructor(message: string, method: Method, path: string);
807
+ name: string;
808
+ readonly cause: {
809
+ method: Method;
810
+ path: string;
811
+ };
812
+ constructor(message: string, method: Method, path: string);
729
813
  }
730
814
  /**
731
815
  * @desc An error related to the generating of the documentation
732
816
  * */
733
817
  declare class DocumentationError extends Error {
734
- name: string;
735
- readonly cause: string;
736
- constructor(message: string, { method, path, isResponse, }: Pick<OpenAPIContext, "path" | "method" | "isResponse">);
818
+ name: string;
819
+ readonly cause: string;
820
+ constructor(message: string, {
821
+ method,
822
+ path,
823
+ isResponse
824
+ }: Pick<OpenAPIContext, "path" | "method" | "isResponse">);
737
825
  }
738
826
  /** @desc An error related to the input and output schemas declaration */
739
827
  declare class IOSchemaError extends Error {
740
- name: string;
828
+ name: string;
741
829
  }
742
830
  /** @desc An error of validating the Endpoint handler's returns against the Endpoint output schema */
743
831
  declare class OutputValidationError extends IOSchemaError {
744
- readonly cause: z.ZodError;
745
- name: string;
746
- constructor(cause: z.ZodError);
832
+ readonly cause: z.ZodError;
833
+ name: string;
834
+ constructor(cause: z.ZodError);
747
835
  }
748
836
  /** @desc An error of validating the input sources against the Middleware or Endpoint input schema */
749
837
  declare class InputValidationError extends IOSchemaError {
750
- readonly cause: z.ZodError;
751
- name: string;
752
- constructor(cause: z.ZodError);
838
+ readonly cause: z.ZodError;
839
+ name: string;
840
+ constructor(cause: z.ZodError);
753
841
  }
842
+ /** @desc An error related to the execution or incorrect configuration of ResultHandler */
843
+
754
844
  declare class MissingPeerError extends Error {
755
- name: string;
756
- constructor(module: string);
845
+ name: string;
846
+ constructor(module: string);
757
847
  }
758
-
848
+ //#endregion
849
+ //#region src/testing.d.ts
759
850
  interface TestingProps<REQ, LOG> {
760
- /**
761
- * @desc Additional properties to set on Request mock
762
- * @default { method: "GET", headers: { "content-type": "application/json" } }
763
- * */
764
- requestProps?: REQ;
765
- /**
766
- * @link https://www.npmjs.com/package/node-mocks-http
767
- * @default { req: requestMock }
768
- * */
769
- responseOptions?: ResponseOptions;
770
- /**
771
- * @desc Additional properties to set on config mock
772
- * @default { cors: false, logger }
773
- * */
774
- configProps?: Partial<CommonConfig>;
775
- /**
776
- * @desc Additional properties to set on logger mock
777
- * @default { info, warn, error, debug }
778
- * */
779
- loggerProps?: LOG;
851
+ /**
852
+ * @desc Additional properties to set on Request mock
853
+ * @default { method: "GET", headers: { "content-type": "application/json" } }
854
+ * */
855
+ requestProps?: REQ;
856
+ /**
857
+ * @link https://www.npmjs.com/package/node-mocks-http
858
+ * @default { req: requestMock }
859
+ * */
860
+ responseOptions?: ResponseOptions;
861
+ /**
862
+ * @desc Additional properties to set on config mock
863
+ * @default { cors: false, logger }
864
+ * */
865
+ configProps?: Partial<CommonConfig>;
866
+ /**
867
+ * @desc Additional properties to set on logger mock
868
+ * @default { info, warn, error, debug }
869
+ * */
870
+ loggerProps?: LOG;
780
871
  }
781
- declare const testEndpoint: <LOG extends FlatObject, REQ extends RequestOptions>({ endpoint, ...rest }: TestingProps<REQ, LOG> & {
782
- /** @desc The endpoint to test */
783
- endpoint: AbstractEndpoint;
872
+ declare const testEndpoint: <LOG extends FlatObject, REQ extends RequestOptions>({
873
+ endpoint,
874
+ ...rest
875
+ }: TestingProps<REQ, LOG> & {
876
+ /** @desc The endpoint to test */
877
+ endpoint: AbstractEndpoint;
784
878
  }) => Promise<{
785
- requestMock: node_mocks_http.MockRequest<Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>> & REQ>;
786
- responseMock: node_mocks_http.MockResponse<Response<any, Record<string, any>>>;
787
- loggerMock: AbstractLogger & LOG & {
788
- _getLogs: () => Record<"error" | "debug" | "info" | "warn", unknown[]>;
789
- };
879
+ requestMock: node_mocks_http0.MockRequest<Request<express_serve_static_core0.ParamsDictionary, any, any, qs0.ParsedQs, Record<string, any>> & REQ>;
880
+ responseMock: node_mocks_http0.MockResponse<Response<any, Record<string, any>>>;
881
+ loggerMock: AbstractLogger & LOG & {
882
+ _getLogs: () => Record<"debug" | "info" | "warn" | "error", unknown[]>;
883
+ };
790
884
  }>;
791
- declare const testMiddleware: <LOG extends FlatObject, REQ extends RequestOptions>({ middleware, options, ...rest }: TestingProps<REQ, LOG> & {
792
- /** @desc The middleware to test */
793
- middleware: AbstractMiddleware;
794
- /** @desc The aggregated output from previously executed middlewares */
795
- options?: FlatObject;
885
+ declare const testMiddleware: <LOG extends FlatObject, REQ extends RequestOptions>({
886
+ middleware,
887
+ options,
888
+ ...rest
889
+ }: TestingProps<REQ, LOG> & {
890
+ /** @desc The middleware to test */
891
+ middleware: AbstractMiddleware;
892
+ /** @desc The aggregated output from previously executed middlewares */
893
+ options?: FlatObject;
796
894
  }) => Promise<{
797
- requestMock: node_mocks_http.MockRequest<Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>> & REQ>;
798
- responseMock: node_mocks_http.MockResponse<Response<any, Record<string, any>>>;
799
- loggerMock: AbstractLogger & LOG & {
800
- _getLogs: () => Record<"error" | "debug" | "info" | "warn", unknown[]>;
801
- };
802
- output: FlatObject;
895
+ requestMock: node_mocks_http0.MockRequest<Request<express_serve_static_core0.ParamsDictionary, any, any, qs0.ParsedQs, Record<string, any>> & REQ>;
896
+ responseMock: node_mocks_http0.MockResponse<Response<any, Record<string, any>>>;
897
+ loggerMock: AbstractLogger & LOG & {
898
+ _getLogs: () => Record<"debug" | "info" | "warn" | "error", unknown[]>;
899
+ };
900
+ output: FlatObject;
803
901
  }>;
804
-
902
+ //#endregion
903
+ //#region src/integration-base.d.ts
805
904
  declare abstract class IntegrationBase {
806
- #private;
807
- private readonly serverUrl;
808
- protected constructor(serverUrl: string);
905
+ #private;
906
+ private readonly serverUrl;
907
+ protected constructor(serverUrl: string);
809
908
  }
810
-
909
+ //#endregion
910
+ //#region src/schema-walker.d.ts
811
911
  interface NextHandlerInc<U> {
812
- next: (schema: z.core.$ZodType) => U;
912
+ next: (schema: z.core.$ZodType) => U;
813
913
  }
814
914
  interface PrevInc<U> {
815
- prev: U;
915
+ prev: U;
816
916
  }
817
- 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
917
+ type SchemaHandler<U, Context extends FlatObject = EmptyObject, Variant extends "regular" | "each" | "last" = "regular"> = (schema: any,
918
+ // eslint-disable-line @typescript-eslint/no-explicit-any -- for assignment compatibility
818
919
  ctx: Context & (Variant extends "regular" ? NextHandlerInc<U> : Variant extends "each" ? PrevInc<U> : Context)) => U;
819
920
  type HandlingRules<U, Context extends FlatObject = EmptyObject, K extends string | symbol = string | symbol> = Partial<Record<K, SchemaHandler<U, Context>>>;
820
-
921
+ /** @since 10.1.1 calling onEach _after_ handler and giving it the previously achieved result */
922
+ //#endregion
923
+ //#region src/zts-helpers.d.ts
821
924
  interface ZTSContext extends FlatObject {
822
- isResponse: boolean;
823
- makeAlias: (key: object, produce: () => ts.TypeNode) => ts.TypeNode;
925
+ isResponse: boolean;
926
+ makeAlias: (key: object, produce: () => ts.TypeNode) => ts.TypeNode;
824
927
  }
825
928
  type Producer = SchemaHandler<ts.TypeNode, ZTSContext>;
826
-
929
+ //#endregion
930
+ //#region src/integration.d.ts
827
931
  interface IntegrationParams {
828
- routing: Routing;
829
- /**
830
- * @desc What should be generated
831
- * @example "types" — types of your endpoint requests and responses (for a DIY solution)
832
- * @example "client" — an entity for performing typed requests and receiving typed responses
833
- * @default "client"
834
- * */
835
- variant?: "types" | "client";
836
- /** @default Client */
837
- clientClassName?: string;
838
- /** @default Subscription */
839
- subscriptionClassName?: string;
840
- /**
841
- * @desc The API URL to use in the generated code
842
- * @default https://example.com
843
- * */
844
- serverUrl?: string;
845
- /**
846
- * @desc The schema to use for responses without body such as 204
847
- * @default z.undefined()
848
- * */
849
- noContent?: z.ZodType;
850
- /**
851
- * @desc Depict the HEAD method for each Endpoint supporting the GET method (feature of Express)
852
- * @default true
853
- * */
854
- hasHeadMethod?: boolean;
855
- /**
856
- * @desc Handling rules for your own branded schemas.
857
- * @desc Keys: brands (recommended to use unique symbols).
858
- * @desc Values: functions having schema as first argument that you should assign type to, second one is a context.
859
- * @example { MyBrand: ( schema: typeof myBrandSchema, { next } ) => createKeywordTypeNode(SyntaxKind.AnyKeyword)
860
- */
861
- brandHandling?: HandlingRules<ts.TypeNode, ZTSContext>;
932
+ routing: Routing;
933
+ /**
934
+ * @desc What should be generated
935
+ * @example "types" — types of your endpoint requests and responses (for a DIY solution)
936
+ * @example "client" — an entity for performing typed requests and receiving typed responses
937
+ * @default "client"
938
+ * */
939
+ variant?: "types" | "client";
940
+ /** @default Client */
941
+ clientClassName?: string;
942
+ /** @default Subscription */
943
+ subscriptionClassName?: string;
944
+ /**
945
+ * @desc The API URL to use in the generated code
946
+ * @default https://example.com
947
+ * */
948
+ serverUrl?: string;
949
+ /**
950
+ * @desc The schema to use for responses without body such as 204
951
+ * @default z.undefined()
952
+ * */
953
+ noContent?: z.ZodType;
954
+ /**
955
+ * @desc Depict the HEAD method for each Endpoint supporting the GET method (feature of Express)
956
+ * @default true
957
+ * */
958
+ hasHeadMethod?: boolean;
959
+ /**
960
+ * @desc Handling rules for your own branded schemas.
961
+ * @desc Keys: brands (recommended to use unique symbols).
962
+ * @desc Values: functions having schema as first argument that you should assign type to, second one is a context.
963
+ * @example { MyBrand: ( schema: typeof myBrandSchema, { next } ) => createKeywordTypeNode(SyntaxKind.AnyKeyword)
964
+ */
965
+ brandHandling?: HandlingRules<ts.TypeNode, ZTSContext>;
862
966
  }
863
967
  interface FormattedPrintingOptions {
864
- /** @desc Typescript printer options */
865
- printerOptions?: ts.PrinterOptions;
866
- /**
867
- * @desc Typescript code formatter
868
- * @default prettier.format
869
- * */
870
- format?: (program: string) => Promise<string>;
968
+ /** @desc Typescript printer options */
969
+ printerOptions?: ts.PrinterOptions;
970
+ /**
971
+ * @desc Typescript code formatter
972
+ * @default prettier.format
973
+ * */
974
+ format?: (program: string) => Promise<string>;
871
975
  }
872
976
  declare class Integration extends IntegrationBase {
873
- #private;
874
- constructor({ routing, brandHandling, variant, clientClassName, subscriptionClassName, serverUrl, noContent, hasHeadMethod, }: IntegrationParams);
875
- print(printerOptions?: ts.PrinterOptions): string;
876
- printFormatted({ printerOptions, format: userDefined, }?: FormattedPrintingOptions): Promise<string>;
977
+ #private;
978
+ constructor({
979
+ routing,
980
+ brandHandling,
981
+ variant,
982
+ clientClassName,
983
+ subscriptionClassName,
984
+ serverUrl,
985
+ noContent,
986
+ hasHeadMethod
987
+ }: IntegrationParams);
988
+ print(printerOptions?: ts.PrinterOptions): string;
989
+ printFormatted({
990
+ printerOptions,
991
+ format: userDefined
992
+ }?: FormattedPrintingOptions): Promise<string>;
877
993
  }
878
-
994
+ //#endregion
995
+ //#region src/sse.d.ts
879
996
  type EventsMap = Record<string, z.ZodType>;
880
997
  interface Emitter<E extends EventsMap> extends FlatObject {
881
- /** @desc Returns true when the connection was closed or terminated */
882
- isClosed: () => boolean;
883
- /** @desc Sends an event to the stream according to the declared schema */
884
- emit: <K extends keyof E>(event: K, data: z.input<E[K]>) => void;
998
+ /** @desc Returns true when the connection was closed or terminated */
999
+ isClosed: () => boolean;
1000
+ /** @desc Sends an event to the stream according to the declared schema */
1001
+ emit: <K extends keyof E>(event: K, data: z.input<E[K]>) => void;
885
1002
  }
886
1003
  declare class EventStreamFactory<E extends EventsMap> extends EndpointsFactory<undefined, Emitter<E>> {
887
- constructor(events: E);
1004
+ constructor(events: E);
888
1005
  }
889
-
1006
+ //#endregion
1007
+ //#region src/raw-schema.d.ts
890
1008
  declare const base: z.ZodObject<{
891
- raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
1009
+ raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
892
1010
  }, z.core.$strip>;
893
1011
  type Base = ReturnType<typeof base.brand<symbol>>;
894
1012
  declare const extended: <S extends z.core.$ZodShape>(extra: S) => z.core.$ZodBranded<z.ZodObject<("raw" & keyof S extends never ? {
895
- raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
1013
+ raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
896
1014
  } & S : ({
897
- raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
898
- } extends infer T_1 extends z.core.util.SomeObject ? { [K in keyof T_1 as K extends keyof S ? never : K]: T_1[K]; } : never) & { [K_1 in keyof S]: S[K_1]; }) extends infer T ? { [k in keyof T]: T[k]; } : never, z.core.$strip>, symbol>;
1015
+ raw: z.core.$ZodBranded<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
1016
+ } extends infer T_1 extends z.core.util.SomeObject ? { [K in keyof T_1 as K extends keyof S ? never : K]: T_1[K] } : never) & { [K_1 in keyof S]: S[K_1] }) extends infer T ? { [k in keyof T]: T[k] } : never, z.core.$strip>, symbol>;
899
1017
  declare function raw(): Base;
900
1018
  declare function raw<S extends z.core.$ZodShape>(extra: S): ReturnType<typeof extended<S>>;
901
-
1019
+ //#endregion
1020
+ //#region src/proprietary-schemas.d.ts
902
1021
  declare const ez: {
903
- dateIn: ({ examples, ...rest }?: Parameters<zod.ZodString["meta"]>[0]) => zod_v4_core.$ZodBranded<zod.ZodPipe<zod.ZodPipe<zod.ZodUnion<readonly [zod.ZodISODate, zod.ZodISODateTime, zod.ZodISODateTime]>, zod.ZodTransform<Date, string>>, zod.ZodDate>, symbol>;
904
- dateOut: (meta?: Parameters<zod.ZodString["meta"]>[0]) => zod_v4_core.$ZodBranded<zod.ZodPipe<zod.ZodDate, zod.ZodTransform<string, Date>>, symbol>;
905
- form: <S extends zod_v4_core.$ZodShape>(base: S | zod.ZodObject<S>) => zod_v4_core.$ZodBranded<zod.ZodObject<S, zod_v4_core.$strip>, symbol>;
906
- upload: () => zod_v4_core.$ZodBranded<zod.ZodCustom<express_fileupload.UploadedFile, express_fileupload.UploadedFile>, symbol>;
907
- raw: typeof raw;
908
- buffer: () => zod_v4_core.$ZodBranded<zod.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
1022
+ dateIn: ({
1023
+ examples,
1024
+ ...rest
1025
+ }?: Parameters<zod0.ZodString["meta"]>[0]) => zod_v4_core0.$ZodBranded<zod0.ZodPipe<zod0.ZodPipe<zod0.ZodUnion<readonly [zod0.ZodISODate, zod0.ZodISODateTime, zod0.ZodISODateTime]>, zod0.ZodTransform<Date, string>>, zod0.ZodDate>, symbol>;
1026
+ dateOut: (meta?: Parameters<zod0.ZodString["meta"]>[0]) => zod_v4_core0.$ZodBranded<zod0.ZodPipe<zod0.ZodDate, zod0.ZodTransform<string, Date>>, symbol>;
1027
+ form: <S extends zod_v4_core0.$ZodShape>(base: S | zod0.ZodObject<S>) => zod_v4_core0.$ZodBranded<zod0.ZodObject<S, zod_v4_core0.$strip>, symbol>;
1028
+ upload: () => zod_v4_core0.$ZodBranded<zod0.ZodCustom<express_fileupload0.UploadedFile, express_fileupload0.UploadedFile>, symbol>;
1029
+ raw: typeof raw;
1030
+ buffer: () => zod_v4_core0.$ZodBranded<zod0.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, symbol>;
909
1031
  };
910
-
911
- 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 };
1032
+ //#endregion
1033
+ 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 };