@nestia/core 14.0.1 → 14.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/lib/adaptors/McpAdaptor.d.ts +24 -3
  2. package/lib/adaptors/McpAdaptor.js +72 -34
  3. package/lib/adaptors/McpAdaptor.js.map +1 -1
  4. package/lib/adaptors/WebSocketAdaptor.d.ts +37 -0
  5. package/lib/adaptors/WebSocketAdaptor.js +60 -16
  6. package/lib/adaptors/WebSocketAdaptor.js.map +1 -1
  7. package/lib/adaptors/internal/external_context.js +18 -5
  8. package/lib/adaptors/internal/external_context.js.map +1 -1
  9. package/lib/decorators/DynamicModule.d.ts +12 -0
  10. package/lib/decorators/DynamicModule.js +12 -0
  11. package/lib/decorators/DynamicModule.js.map +1 -1
  12. package/lib/decorators/EncryptedBody.d.ts +14 -6
  13. package/lib/decorators/EncryptedBody.js +37 -14
  14. package/lib/decorators/EncryptedBody.js.map +1 -1
  15. package/lib/decorators/EncryptedController.d.ts +6 -1
  16. package/lib/decorators/EncryptedController.js +6 -1
  17. package/lib/decorators/EncryptedController.js.map +1 -1
  18. package/lib/decorators/EncryptedModule.d.ts +18 -3
  19. package/lib/decorators/EncryptedModule.js +18 -3
  20. package/lib/decorators/EncryptedModule.js.map +1 -1
  21. package/lib/decorators/EncryptedRoute.d.ts +20 -11
  22. package/lib/decorators/EncryptedRoute.js +20 -11
  23. package/lib/decorators/EncryptedRoute.js.map +1 -1
  24. package/lib/decorators/HumanRoute.d.ts +5 -0
  25. package/lib/decorators/HumanRoute.js +5 -0
  26. package/lib/decorators/HumanRoute.js.map +1 -1
  27. package/lib/decorators/McpRoute.d.ts +31 -19
  28. package/lib/decorators/McpRoute.js +12 -1
  29. package/lib/decorators/McpRoute.js.map +1 -1
  30. package/lib/decorators/PlainBody.d.ts +7 -1
  31. package/lib/decorators/PlainBody.js +16 -8
  32. package/lib/decorators/PlainBody.js.map +1 -1
  33. package/lib/decorators/SwaggerCustomizer.d.ts +15 -0
  34. package/lib/decorators/SwaggerCustomizer.js +5 -0
  35. package/lib/decorators/SwaggerCustomizer.js.map +1 -1
  36. package/lib/decorators/SwaggerExample.d.ts +51 -22
  37. package/lib/decorators/SwaggerExample.js +35 -22
  38. package/lib/decorators/SwaggerExample.js.map +1 -1
  39. package/lib/decorators/TypedBody.d.ts +9 -2
  40. package/lib/decorators/TypedBody.js +19 -9
  41. package/lib/decorators/TypedBody.js.map +1 -1
  42. package/lib/decorators/TypedException.d.ts +10 -0
  43. package/lib/decorators/TypedFormData.d.ts +59 -1
  44. package/lib/decorators/TypedFormData.js +5 -0
  45. package/lib/decorators/TypedFormData.js.map +1 -1
  46. package/lib/decorators/TypedHeaders.d.ts +5 -0
  47. package/lib/decorators/TypedHeaders.js +5 -0
  48. package/lib/decorators/TypedHeaders.js.map +1 -1
  49. package/lib/decorators/TypedParam.d.ts +9 -0
  50. package/lib/decorators/TypedParam.js +9 -0
  51. package/lib/decorators/TypedParam.js.map +1 -1
  52. package/lib/decorators/TypedQuery.d.ts +16 -0
  53. package/lib/decorators/TypedQuery.js +16 -0
  54. package/lib/decorators/TypedQuery.js.map +1 -1
  55. package/lib/decorators/TypedRoute.d.ts +25 -10
  56. package/lib/decorators/TypedRoute.js +19 -10
  57. package/lib/decorators/TypedRoute.js.map +1 -1
  58. package/lib/decorators/WebSocketRoute.d.ts +18 -1
  59. package/lib/decorators/WebSocketRoute.js +18 -1
  60. package/lib/decorators/WebSocketRoute.js.map +1 -1
  61. package/lib/decorators/doNotThrowTransformError.d.ts +14 -0
  62. package/lib/decorators/doNotThrowTransformError.js +14 -0
  63. package/lib/decorators/doNotThrowTransformError.js.map +1 -1
  64. package/lib/decorators/internal/IRequestBodyValidation.d.ts +66 -0
  65. package/lib/decorators/internal/IRequestBodyValidation.js +3 -0
  66. package/lib/decorators/internal/IRequestBodyValidation.js.map +1 -0
  67. package/lib/decorators/internal/IWebSocketRouteReflect.d.ts +93 -1
  68. package/lib/decorators/internal/get_path_and_querify.js +3 -7
  69. package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
  70. package/lib/decorators/internal/get_path_and_stringify.js +3 -7
  71. package/lib/decorators/internal/get_path_and_stringify.js.map +1 -1
  72. package/lib/decorators/internal/load_controller.d.ts +14 -0
  73. package/lib/decorators/internal/load_controller.js +14 -0
  74. package/lib/decorators/internal/load_controller.js.map +1 -1
  75. package/lib/decorators/internal/split_route_arguments.d.ts +1 -0
  76. package/lib/decorators/internal/split_route_arguments.js +22 -0
  77. package/lib/decorators/internal/split_route_arguments.js.map +1 -0
  78. package/lib/decorators/internal/validate_request_body.js +68 -25
  79. package/lib/decorators/internal/validate_request_body.js.map +1 -1
  80. package/lib/options/IRequestBodyValidator.d.ts +71 -0
  81. package/lib/options/IRequestFormDataProps.d.ts +80 -0
  82. package/lib/options/IRequestHeadersValidator.d.ts +67 -0
  83. package/lib/options/IRequestQueryValidator.d.ts +68 -0
  84. package/lib/options/IResponseBodyQuerifier.d.ts +120 -0
  85. package/lib/options/IResponseBodyStringifier.d.ts +107 -0
  86. package/lib/typings/Creator.d.ts +10 -0
  87. package/lib/utils/ArrayUtil.d.ts +21 -0
  88. package/lib/utils/ArrayUtil.js +22 -1
  89. package/lib/utils/ArrayUtil.js.map +1 -1
  90. package/lib/utils/ExceptionManager.d.ts +40 -0
  91. package/lib/utils/ExceptionManager.js +34 -0
  92. package/lib/utils/ExceptionManager.js.map +1 -1
  93. package/lib/utils/SourceFinder.d.ts +22 -0
  94. package/lib/utils/SourceFinder.js +34 -7
  95. package/lib/utils/SourceFinder.js.map +1 -1
  96. package/lib/utils/VersioningStrategy.d.ts +36 -1
  97. package/lib/utils/VersioningStrategy.js +30 -9
  98. package/lib/utils/VersioningStrategy.js.map +1 -1
  99. package/native/go.mod +1 -1
  100. package/native/go.sum +2 -2
  101. package/native/plugin/plan.go +68 -2
  102. package/native/transform/ast.go +19 -1
  103. package/native/transform/build.go +51 -57
  104. package/native/transform/buildoutput/output.go +147 -0
  105. package/native/transform/contributor.go +9 -0
  106. package/native/transform/core_querify.go +37 -3
  107. package/native/transform/core_transform.go +105 -98
  108. package/native/transform/core_websocket.go +21 -5
  109. package/native/transform/node_transform.go +11 -8
  110. package/native/transform/package.go +55 -0
  111. package/native/transform/printer.go +1 -3
  112. package/native/transform/run.go +18 -0
  113. package/native/transform/schemaprojection/project.go +213 -0
  114. package/native/transform/transform.go +21 -0
  115. package/package.json +5 -4
  116. package/src/adaptors/McpAdaptor.ts +86 -26
  117. package/src/adaptors/WebSocketAdaptor.ts +66 -14
  118. package/src/adaptors/internal/external_context.ts +37 -6
  119. package/src/decorators/DynamicModule.ts +12 -0
  120. package/src/decorators/EncryptedBody.ts +37 -13
  121. package/src/decorators/EncryptedController.ts +6 -1
  122. package/src/decorators/EncryptedModule.ts +18 -3
  123. package/src/decorators/EncryptedRoute.ts +20 -11
  124. package/src/decorators/HumanRoute.ts +5 -0
  125. package/src/decorators/McpRoute.ts +31 -19
  126. package/src/decorators/PlainBody.ts +20 -10
  127. package/src/decorators/SwaggerCustomizer.ts +15 -0
  128. package/src/decorators/SwaggerExample.ts +51 -22
  129. package/src/decorators/TypedBody.ts +17 -8
  130. package/src/decorators/TypedException.ts +10 -0
  131. package/src/decorators/TypedFormData.ts +59 -1
  132. package/src/decorators/TypedHeaders.ts +5 -0
  133. package/src/decorators/TypedParam.ts +9 -0
  134. package/src/decorators/TypedQuery.ts +16 -0
  135. package/src/decorators/TypedRoute.ts +25 -10
  136. package/src/decorators/WebSocketRoute.ts +18 -1
  137. package/src/decorators/doNotThrowTransformError.ts +14 -0
  138. package/src/decorators/internal/IMcpRouteReflect.ts +7 -1
  139. package/src/decorators/internal/IRequestBodyValidation.ts +65 -0
  140. package/src/decorators/internal/IWebSocketRouteReflect.ts +95 -1
  141. package/src/decorators/internal/get_path_and_querify.ts +3 -9
  142. package/src/decorators/internal/get_path_and_stringify.ts +3 -9
  143. package/src/decorators/internal/load_controller.ts +14 -0
  144. package/src/decorators/internal/split_route_arguments.ts +20 -0
  145. package/src/decorators/internal/validate_request_body.ts +87 -34
  146. package/src/options/IRequestBodyValidator.ts +71 -0
  147. package/src/options/IRequestFormDataProps.ts +80 -0
  148. package/src/options/IRequestHeadersValidator.ts +67 -0
  149. package/src/options/IRequestQueryValidator.ts +68 -0
  150. package/src/options/IResponseBodyQuerifier.ts +120 -0
  151. package/src/options/IResponseBodyStringifier.ts +107 -0
  152. package/src/typings/Creator.ts +10 -0
  153. package/src/utils/ArrayUtil.ts +22 -3
  154. package/src/utils/ExceptionManager.ts +40 -0
  155. package/src/utils/SourceFinder.ts +38 -7
  156. package/src/utils/VersioningStrategy.ts +43 -13
@@ -9,30 +9,43 @@
9
9
  * The decorators only affect Swagger document generation. They do not change
10
10
  * runtime behavior, validation, or SDK function signatures.
11
11
  *
12
- * @author Jeongho Nam - https://github.com/samchon
13
- * @example
14
- * ```typescript
15
- * import core from "@nestia/core";
16
- * import { Controller } from "@nestjs/common";
17
- * import typia from "typia";
12
+ * Example:
13
+ *
14
+ * ```typescript
15
+ * import core from "@nestia/core";
16
+ * import { Controller } from "@nestjs/common";
17
+ * import typia from "typia";
18
18
  *
19
- * @Controller("bbs/articles")
20
- * export class BbsArticlesController {
21
- * // Single response example.
22
- * @core.SwaggerExample.Response(typia.random<IBbsArticle>())
23
- * @core.TypedRoute.Post()
24
- * public async create(
25
- * // Multiple named parameter examples plus a default one.
26
- * @core.SwaggerExample.Parameter(typia.random<IBbsArticle.ICreate>())
27
- * @core.SwaggerExample.Parameter("x", typia.random<IBbsArticle.ICreate>())
28
- * @core.SwaggerExample.Parameter("y", typia.random<IBbsArticle.ICreate>())
29
- * @core.TypedBody()
30
- * input: IBbsArticle.ICreate,
31
- * ): Promise<IBbsArticle> {
32
- * // ...
33
- * }
19
+ * @Controller("bbs/articles")
20
+ * export class BbsArticlesController {
21
+ * // Single response example.
22
+ * @core.SwaggerExample.Response(typia.random<IBbsArticle>())
23
+ * @core.TypedRoute.Post()
24
+ * public async create(
25
+ * // Multiple named parameter examples plus a default one.
26
+ * @core.SwaggerExample.Parameter(typia.random<IBbsArticle.ICreate>())
27
+ * @core.SwaggerExample.Parameter(
28
+ * "x",
29
+ * typia.random<IBbsArticle.ICreate>(),
30
+ * )
31
+ * @core.SwaggerExample.Parameter(
32
+ * "y",
33
+ * typia.random<IBbsArticle.ICreate>(),
34
+ * )
35
+ * @core.TypedBody()
36
+ * input: IBbsArticle.ICreate,
37
+ * ): Promise<IBbsArticle> {
38
+ * // ...
34
39
  * }
35
- * ```;
40
+ * }
41
+ * ```
42
+ *
43
+ * @author Jeongho Nam - https://github.com/samchon
44
+ * @evidence contracts/common.md#principled-implementation Examples are stored as metadata on the method or on the parameter position; a call with one argument sets the single example, and a call with a key and a value adds a named example, so both OpenAPI forms are expressible.
45
+ * @evidence contracts/common.md#clear-and-simple-design Two decorators over three private metadata helpers that find or create the record.
46
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The examples are caller data, and nothing is generated here.
47
+ * @evidence contracts/common.md#meaningful-documentation The comment documents both decorators and the two call forms.
48
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Example metadata contains caller values and parameter indices without a native path or process boundary.
36
49
  */
37
50
  export namespace SwaggerExample {
38
51
  /**
@@ -51,6 +64,11 @@ export namespace SwaggerExample {
51
64
  * document.
52
65
  *
53
66
  * @template T Type of the example value (typically the route's response DTO).
67
+ * @evidence contracts/common.md#principled-implementation The value or the keyed value is recorded on the method's response example record, which the document generator reads.
68
+ * @evidence contracts/common.md#clear-and-simple-design One decorator with two overloads.
69
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The value is stored as given.
70
+ * @evidence contracts/common.md#meaningful-documentation The comment documents the overloads with an example.
71
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Example metadata contains caller values and parameter indices without a native path or process boundary.
54
72
  */
55
73
  export function Response<T>(value: T): MethodDecorator;
56
74
  export function Response<T>(key: string, value: T): MethodDecorator;
@@ -81,6 +99,11 @@ export namespace SwaggerExample {
81
99
  * `@TypedParam()`, `@TypedQuery()`, etc.); decorator order does not matter.
82
100
  *
83
101
  * @template T Type of the example value (typically the parameter's DTO).
102
+ * @evidence contracts/common.md#principled-implementation The value or the keyed value is recorded on the record for that parameter index, so several parameters keep separate examples.
103
+ * @evidence contracts/common.md#clear-and-simple-design One decorator with two overloads.
104
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The value is stored as given.
105
+ * @evidence contracts/common.md#meaningful-documentation The comment documents the overloads with an example.
106
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Example metadata contains caller values and parameter indices without a native path or process boundary.
84
107
  */
85
108
  export function Parameter<T>(value: T): ParameterDecorator;
86
109
  export function Parameter<T>(key: string, value: T): ParameterDecorator;
@@ -100,6 +123,12 @@ export namespace SwaggerExample {
100
123
  * Reflects the OpenAPI spec's two example fields: a single default `example`,
101
124
  * and/or a named map `examples`. `index` is used internally to associate
102
125
  * parameter examples with the right parameter position.
126
+ *
127
+ * @evidence contracts/common.md#principled-implementation The record holds the single example, the named examples, and the parameter index, which is everything the generator needs to attach examples.
128
+ * @evidence contracts/common.md#clear-and-simple-design A flat record whose members are all optional.
129
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
130
+ * @evidence contracts/common.md#meaningful-documentation The comment states the meaning of the members.
131
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Example metadata contains caller values and parameter indices without a native path or process boundary.
103
132
  */
104
133
  export interface IData<T> {
105
134
  examples?: Record<string, T>;
@@ -16,14 +16,21 @@ import { validate_request_body } from "./internal/validate_request_body";
16
16
  *
17
17
  * `TypedBody` is a decorator function getting `application/json` typed data
18
18
  * from request body. Also, it validates the request body data type through
19
- * [typia](https://github.com/samchon/typia) and the validation speed is maximum
20
- * 20,000x times faster than `class-validator`.
19
+ * [typia](https://github.com/samchon/typia) using the declared TypeScript
20
+ * type.
21
21
  *
22
22
  * For reference, when the request body data is not following the promised type
23
23
  * `T`, `BadRequestException` error (status code: 400) would be thrown.
24
+ * Successful assert and validate callbacks supply the decorated argument; clone
25
+ * validators can therefore return a copy without replacing the raw body.
24
26
  *
25
27
  * @author Jeongho Nam - https://github.com/samchon
26
28
  * @param validator Custom validator if required. Default is `typia.validate()`
29
+ * @evidence contracts/common.md#principled-implementation An absent body with no content type is accepted only when the validator accepts undefined; any other body must be application/json. The checker returns explicitly tagged successful data or the existing validation error, so cloned values reach the argument while raw request.body retains its identity and errors retain their response priority.
30
+ * @evidence contracts/common.md#clear-and-simple-design One parameter decorator composes shared media/absence checks and tagged resolution. The shared internal runner owns descriptor selection and error translation; PlainBody uses the same successful-value protocol for its optional transformed text assertion, preserving raw text when no assertion exists and preserving its absent-input/media error priority.
31
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The validator is generated from the type by the transform; without it the decorator throws the configuration error unless the guard is turned off.
32
+ * @evidence contracts/common.md#meaningful-documentation The comment documents the decorator, the media type rule, and the validation modes.
33
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Parsed HTTP bodies and validation callbacks are independent of native filesystem and process representation.
27
34
  */
28
35
  export function TypedBody<T>(
29
36
  validator?: IRequestBodyValidator<T>,
@@ -36,9 +43,11 @@ export function TypedBody<T>(
36
43
  const request: express.Request | FastifyRequest = context
37
44
  .switchToHttp()
38
45
  .getRequest();
39
- if (is_request_body_undefined(request) && checker(undefined as T) === null)
40
- return undefined;
41
- else if (
46
+ if (is_request_body_undefined(request)) {
47
+ const result = checker.resolve(undefined);
48
+ if (result.success) return result.data;
49
+ }
50
+ if (
42
51
  is_media_type(request.headers["content-type"], "application/json") ===
43
52
  false
44
53
  )
@@ -46,8 +55,8 @@ export function TypedBody<T>(
46
55
  `Request body type is not "application/json".`,
47
56
  );
48
57
 
49
- const error: Error | null = checker(request.body);
50
- if (error !== null) throw error;
51
- return request.body;
58
+ const result = checker.resolve(request.body);
59
+ if (!result.success) throw result.error;
60
+ return result.data;
52
61
  })();
53
62
  }
@@ -117,6 +117,16 @@ export function TypedException<T>(...args: any[]): MethodDecorator {
117
117
  return descriptor;
118
118
  };
119
119
  }
120
+ /**
121
+ * Types of {@link TypedException}: the response properties a declaration
122
+ * carries, and its named examples.
123
+ *
124
+ * @evidence contracts/common.md#principled-implementation The decorator records each declared status, description, and example on the method's metadata list, so the document generator can add the responses; the overloads without a type argument return `never` so a missing type argument is a compile error.
125
+ * @evidence contracts/common.md#clear-and-simple-design One decorator whose overloads split the property form and the positional form.
126
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It records declarations and never changes how the route responds.
127
+ * @evidence contracts/common.md#meaningful-documentation The comment documents the forms and that the status accepts range spellings.
128
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Response declarations contain HTTP status codes and examples, without native files or subprocesses.
129
+ */
120
130
  export namespace TypedException {
121
131
  /** Properties for the exception. */
122
132
  export interface IProps<T> {
@@ -74,6 +74,11 @@ import { validate_request_form_data } from "./internal/validate_request_form_dat
74
74
  * ```
75
75
  *
76
76
  * @author Jeongho Nam - https://github.com/samchon
77
+ * @evidence contracts/common.md#principled-implementation The body must be multipart; multer parses it through the caller's factory into a `FormData` of fields and `File` objects, uploaded temp files are read and always removed afterwards, multer limits map to 413 or 400 responses, and the assembled form is checked by the transformed validator.
78
+ * @evidence contracts/common.md#clear-and-simple-design One decorator with the multipart decoding, the error mapping, and the file conversion as separate module-private functions, and the multer instance created once by a `Singleton`.
79
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Errors are mapped by multer's documented codes and by exact busboy messages, and no file name is special-cased; a runtime without `File` is refused up front.
80
+ * @evidence contracts/common.md#meaningful-documentation The comment documents the factory, the memory and disk storage requirement, and the validation.
81
+ * @evidence contracts/portability.md#os-neutral-implementation Uploaded disk paths come from the storage engine and are consumed directly by Node fs readFile and rm; filename is File metadata rather than a reconstructed native path. Structural multer method signatures specify middleware rather than native path spelling.
77
82
  * @todo Change to ReadableStream through configuring storage engine of multer
78
83
  */
79
84
  export namespace TypedFormData {
@@ -134,12 +139,65 @@ export namespace TypedFormData {
134
139
  })();
135
140
  }
136
141
 
137
- /** Base type of the `multer` or `fastify-multer`. */
142
+ /**
143
+ * Base type of the `multer` or `fastify-multer`.
144
+ *
145
+ * @evidence contracts/common.md#principled-implementation The interface names the multer methods that identify a multer instance structurally, so an application can pass its own instance without this package depending on a multer type at runtime.
146
+ * @evidence contracts/common.md#clear-and-simple-design Five method members with no behavior.
147
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
148
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose as the structural stand-in for multer.
149
+ * @evidence contracts/portability.md#os-neutral-implementation Uploaded disk paths come from the storage engine and are consumed directly by Node fs readFile and rm; filename is File metadata rather than a reconstructed native path. Structural multer method signatures specify middleware rather than native path spelling.
150
+ */
138
151
  export interface IMulterBase {
152
+ /**
153
+ * Middleware factory for a single file field.
154
+ *
155
+ * @evidence contracts/common.md#principled-implementation The member mirrors multer's single-file middleware factory.
156
+ * @evidence contracts/common.md#clear-and-simple-design One method signature.
157
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
158
+ * @evidence contracts/common.md#meaningful-documentation The member is named after the multer method it mirrors.
159
+ * @evidence contracts/portability.md#os-neutral-implementation Uploaded disk paths come from the storage engine and are consumed directly by Node fs readFile and rm; filename is File metadata rather than a reconstructed native path. Structural multer method signatures specify middleware rather than native path spelling.
160
+ */
139
161
  single(fieldName: string): any;
162
+ /**
163
+ * Middleware factory for an array of files under one field.
164
+ *
165
+ * @evidence contracts/common.md#principled-implementation The member mirrors multer's array-of-files middleware factory.
166
+ * @evidence contracts/common.md#clear-and-simple-design One method signature.
167
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
168
+ * @evidence contracts/common.md#meaningful-documentation The member is named after the multer method it mirrors.
169
+ * @evidence contracts/portability.md#os-neutral-implementation Uploaded disk paths come from the storage engine and are consumed directly by Node fs readFile and rm; filename is File metadata rather than a reconstructed native path. Structural multer method signatures specify middleware rather than native path spelling.
170
+ */
140
171
  array(fieldName: string, maxCount?: number): any;
172
+ /**
173
+ * Middleware factory for several named file fields.
174
+ *
175
+ * @evidence contracts/common.md#principled-implementation The member mirrors multer's named-fields middleware factory, which is the one the decorator uses when the transform lists the file fields.
176
+ * @evidence contracts/common.md#clear-and-simple-design One method signature.
177
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
178
+ * @evidence contracts/common.md#meaningful-documentation The member is named after the multer method it mirrors.
179
+ * @evidence contracts/portability.md#os-neutral-implementation Uploaded disk paths come from the storage engine and are consumed directly by Node fs readFile and rm; filename is File metadata rather than a reconstructed native path. Structural multer method signatures specify middleware rather than native path spelling.
180
+ */
141
181
  fields(fields: readonly object[]): any;
182
+ /**
183
+ * Middleware factory that accepts every file field.
184
+ *
185
+ * @evidence contracts/common.md#principled-implementation The member mirrors multer's accept-any-file middleware factory, which the decorator uses when no transform names the file fields.
186
+ * @evidence contracts/common.md#clear-and-simple-design One method signature.
187
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
188
+ * @evidence contracts/common.md#meaningful-documentation The member is named after the multer method it mirrors.
189
+ * @evidence contracts/portability.md#os-neutral-implementation Uploaded disk paths come from the storage engine and are consumed directly by Node fs readFile and rm; filename is File metadata rather than a reconstructed native path. Structural multer method signatures specify middleware rather than native path spelling.
190
+ */
142
191
  any(): any;
192
+ /**
193
+ * Middleware factory that accepts text fields only.
194
+ *
195
+ * @evidence contracts/common.md#principled-implementation The member mirrors multer's text-fields-only middleware factory.
196
+ * @evidence contracts/common.md#clear-and-simple-design One method signature.
197
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
198
+ * @evidence contracts/common.md#meaningful-documentation The member is named after the multer method it mirrors.
199
+ * @evidence contracts/portability.md#os-neutral-implementation Uploaded disk paths come from the storage engine and are consumed directly by Node fs readFile and rm; filename is File metadata rather than a reconstructed native path. Structural multer method signatures specify middleware rather than native path spelling.
200
+ */
143
201
  none(): any;
144
202
  }
145
203
  }
@@ -47,6 +47,11 @@ import { validate_request_headers } from "./internal/validate_request_headers";
47
47
  *
48
48
  * @author Jeongho Nam - https://github.com/samchon
49
49
  * @returns Parameter decorator
50
+ * @evidence contracts/common.md#principled-implementation The header record of the request is decoded by the transformed function into the typed object, whose failure is thrown as the response; header names arrive lower-cased from Node, which the generated decoder expects.
51
+ * @evidence contracts/common.md#clear-and-simple-design One parameter decorator built from the shared header validator runner.
52
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The decoder is generated from the type by the transform; without it the request headers are passed through only when the configuration guard is off.
53
+ * @evidence contracts/common.md#meaningful-documentation The comment documents the decoding, the supported property types, and the validation modes.
54
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Header names and decoded values belong to the HTTP protocol and are not native filesystem identities.
50
55
  */
51
56
  export function TypedHeaders<T extends object>(
52
57
  validator?: IRequestHeadersValidator<T>,
@@ -30,7 +30,16 @@ import { NoTransformConfigurationError } from "./NoTransformConfigurationError";
30
30
  *
31
31
  * @author Jeongho Nam - https://github.com/samchon
32
32
  * @param name URL Parameter name
33
+ * @param assert Conversion and assertion supplied by the compile-time transform
34
+ * @param validate Emit an errors array on validation failure when true;
35
+ * otherwise expose the first failure as flat path, reason, expected and value
36
+ * fields.
33
37
  * @returns Parameter decorator
38
+ * @evidence contracts/common.md#principled-implementation The path parameter arrives as a string and is converted by the assertion function the transform generated for the declared type, so a value of the wrong type produces a 400 that names the parameter; the `validate` flag only changes the error body from the flat form to an `errors` array.
39
+ * @evidence contracts/common.md#clear-and-simple-design One decorator with one conversion function and one error-shaping branch.
40
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The conversion is generated from the declared type; without the transform the raw string is returned only when the configuration guard is off.
41
+ * @evidence contracts/common.md#meaningful-documentation The comment documents the supported types and the two error shapes.
42
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation The named path segment is an HTTP route parameter whose text is decoded by the generated validator; no native path is resolved.
34
43
  */
35
44
  export function TypedParam<T extends boolean | bigint | number | string | null>(
36
45
  name: string,
@@ -45,6 +45,11 @@ import { validate_request_query } from "./internal/validate_request_query";
45
45
  *
46
46
  * @author Jeongho Nam - https://github.com/samchon
47
47
  * @returns Parameter decorator
48
+ * @evidence contracts/common.md#principled-implementation The query string is read from the request URL after the first question mark, grouped by the transformed decoder into the typed object, and a failure is thrown as the 400 response; the decoder receives a `URLSearchParams`, so both Express and Fastify requests are handled by the same code.
49
+ * @evidence contracts/common.md#clear-and-simple-design One parameter decorator on top of the shared query validator runner.
50
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The decoder is generated from the type by the transform; without it the grouped raw query is returned only when the configuration guard is off.
51
+ * @evidence contracts/common.md#meaningful-documentation The comment documents the supported property types and the validation modes.
52
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Query decoding and response encoding operate on URLSearchParams and HTTP route metadata rather than native filesystem paths.
48
53
  */
49
54
  export function TypedQuery<T extends object>(
50
55
  validator?: IRequestQueryValidator<T>,
@@ -64,6 +69,17 @@ export function TypedQuery<T extends object>(
64
69
  return output;
65
70
  })();
66
71
  }
72
+ /**
73
+ * Variants of {@link TypedQuery}: `TypedQuery.Body` reads an urlencoded body,
74
+ * and `TypedQuery.Get`, `Post`, `Put`, `Patch`, and `Delete` return the value
75
+ * as an urlencoded response.
76
+ *
77
+ * @evidence contracts/common.md#principled-implementation `Body` requires the `application/x-www-form-urlencoded` media type and decodes the parsed body, and the route decorators serialize the returned value through the querifier the transform chose and set the response content type.
78
+ * @evidence contracts/common.md#clear-and-simple-design One body decorator and one generator that creates the five route decorators, with a small adapter class for parsed bodies.
79
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The route decorators copy typia's marker properties onto themselves exactly as `TypedRoute` does, which mutates only these exported functions.
80
+ * @evidence contracts/common.md#meaningful-documentation The comment documents the body decorator and the route decorators.
81
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Query decoding and response encoding operate on URLSearchParams and HTTP route metadata rather than native filesystem paths.
82
+ */
67
83
  export namespace TypedQuery {
68
84
  /**
69
85
  * Request body decorator.
@@ -23,17 +23,21 @@ import { route_error } from "./internal/route_error";
23
23
  /**
24
24
  * Type safe router decorator functions.
25
25
  *
26
- * `TypedRoute` is a module containing router decorator functions which can
27
- * boost up JSON string conversion speed about 200x times faster than
28
- * `class-transformer`. Furthermore, such JSON string conversion is even type
29
- * safe through [typia](https://github.com/samchon/typia).
26
+ * `TypedRoute` provides router decorators that serialize response values with
27
+ * [typia](https://github.com/samchon/typia) functions generated from the
28
+ * declared return type.
30
29
  *
31
- * For reference, if you try to invalid data that is not following the promised
32
- * type `T`, 500 internal server error would be thrown. Also, as `TypedRoute`
33
- * composes JSON string through `typia.assertStringify<T>()` function, it is not
34
- * possible to modify response data through interceptors.
30
+ * The default assert serializer rejects a response outside the declared type
31
+ * with a 500 error. The configured stringify mode can choose a different
32
+ * validation policy; `validate.log` logs failures and returns JSON text.
33
+ * Interceptors that run after this serializer receive the serialized string.
35
34
  *
36
35
  * @author Jeongho Nam - https://github.com/samchon
36
+ * @evidence contracts/common.md#principled-implementation Each method decorator combines Nest's router decorator, a JSON content type, and an interceptor that stringifies the returned value with the function the transform selected, so the JSON text is produced by generated code; an error thrown by the handler is routed to the registered exception converters.
37
+ * @evidence contracts/common.md#clear-and-simple-design One generator function creates the five HTTP-method decorators, and the interceptor and the router table are module-private.
38
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The loop after the namespace copies the marker properties of typia's stringify functions onto the decorators for the transform, which mutates only these exported functions; the logger is a module variable, not a patched global.
39
+ * @evidence contracts/common.md#meaningful-documentation The comment documents the decorator family, the path and stringify arguments, and the validation modes.
40
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Routing paths and serialized response values are HTTP protocol data; the interceptor and logger do not define a native file or subprocess boundary.
37
41
  */
38
42
  export namespace TypedRoute {
39
43
  /**
@@ -53,7 +57,7 @@ export namespace TypedRoute {
53
57
  export const Post = Generator("Post");
54
58
 
55
59
  /**
56
- * Router decorator function for the PATH method.
60
+ * Router decorator function for the PATCH method.
57
61
  *
58
62
  * @param path Path of the HTTP request
59
63
  * @returns Method decorator
@@ -82,7 +86,7 @@ export namespace TypedRoute {
82
86
  * If you've configured the transformation option to `validate.log` in the
83
87
  * `tsconfig.json` file, then the error log information of the response
84
88
  * validation failure would be logged through this function instead of
85
- * throwing the 400 bad request error.
89
+ * throwing the 500 internal server error.
86
90
  *
87
91
  * By the way, be careful. If you've configured the response transformation
88
92
  * option to be `validate.log`, client may get wrong response data. Therefore,
@@ -90,6 +94,11 @@ export namespace TypedRoute {
90
94
  *
91
95
  * @default console.log
92
96
  * @param func Logger function
97
+ * @evidence contracts/common.md#principled-implementation It replaces the module's logger variable, which the `validate.log` mode calls when a response fails validation, and the default is `console.log`.
98
+ * @evidence contracts/common.md#clear-and-simple-design One assignment.
99
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It changes only the logger variable.
100
+ * @evidence contracts/common.md#meaningful-documentation The comment states which mode uses the logger.
101
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Routing paths and serialized response values are HTTP protocol data; the interceptor and logger do not define a native file or subprocess boundary.
93
102
  */
94
103
  export function setValidateErrorLogger(
95
104
  func: (log: IValidateErrorLog) => void,
@@ -109,6 +118,12 @@ export namespace TypedRoute {
109
118
  * information `IValidateErrorLog` would be logged through the
110
119
  * {@link setValidateErrorLogger} function instead of throwing the 400 bad
111
120
  * request error.
121
+ *
122
+ * @evidence contracts/common.md#principled-implementation The record carries the method, the path, the validation errors, and the offending data, which is what a logger needs to report a response that failed its type.
123
+ * @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
124
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
125
+ * @evidence contracts/common.md#meaningful-documentation Each member documents its meaning.
126
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Routing paths and serialized response values are HTTP protocol data; the interceptor and logger do not define a native file or subprocess boundary.
112
127
  */
113
128
  export interface IValidateErrorLog {
114
129
  /** HTTP method of the request. */
@@ -38,6 +38,11 @@ import { validate_request_query } from "./internal/validate_request_query";
38
38
  * @author Jeongho Nam - https://github.com/samchon
39
39
  * @param path Path(s) of the WebSocket request
40
40
  * @returns Method decorator
41
+ * @evidence contracts/common.md#principled-implementation The decorator records the route paths as metadata on the method, with an empty list for no path, and the adapter reads that metadata to build the route table.
42
+ * @evidence contracts/common.md#clear-and-simple-design One decorator function that writes one metadata object.
43
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It uses the reflect metadata API and does not touch the server.
44
+ * @evidence contracts/common.md#meaningful-documentation The comment documents the path forms and the required parameters.
45
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation The route and parameter metadata describe WebSocket handshakes and HTTP URL fields; native files and processes are not represented.
41
46
  */
42
47
  export function WebSocketRoute(
43
48
  path?: undefined | string | string[],
@@ -57,6 +62,16 @@ export function WebSocketRoute(
57
62
  return descriptor;
58
63
  };
59
64
  }
65
+ /**
66
+ * Parameter decorators of {@link WebSocketRoute}: `Acceptor`, `Driver`,
67
+ * `Header`, `Param`, and `Query`.
68
+ *
69
+ * @evidence contracts/common.md#principled-implementation Each decorator appends category and position metadata. Header registration stores the shared checker whose resolver preserves successful callback data for the decorated argument without replacing the acceptor header; legacy error-only callbacks retain raw input. Param and query keep their own decoder contracts, and every rejected handshake retains its original error handling.
70
+ * @evidence contracts/common.md#clear-and-simple-design Five decorators sharing one `emplace` helper for the metadata list.
71
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The validators are generated from the types; without the transform the raw values are passed only when the configuration guard is off.
72
+ * @evidence contracts/common.md#meaningful-documentation Each decorator documents its meaning.
73
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation The route and parameter metadata describe WebSocket handshakes and HTTP URL fields; native files and processes are not represented.
74
+ */
60
75
  export namespace WebSocketRoute {
61
76
  /**
62
77
  * Acceptor parameter decorator.
@@ -127,7 +142,9 @@ export namespace WebSocketRoute {
127
142
  *
128
143
  * Also, this `@WebSocketRoute.Header()` decorator is optional, and can be
129
144
  * substituted by `@WebSocketRoute.Acceptor()` decorated parameter by
130
- * accessting to the {@link WebSocketAcceptor.header} property.
145
+ * accessing the {@link WebSocketAcceptor.header} property. Clone validators
146
+ * supply a separate decorated argument; the acceptor keeps its original
147
+ * header.
131
148
  */
132
149
  export function Header<T>(
133
150
  validator?: IRequestBodyValidator<T>,
@@ -1,5 +1,19 @@
1
1
  import { NoTransformConfigurationError } from "./NoTransformConfigurationError";
2
2
 
3
+ /**
4
+ * Chooses whether a decorator called without the compile-time transform throws.
5
+ *
6
+ * The initial configuration throws with instructions to build with `ttsc`.
7
+ * Calling this setter with `false`, including its omitted-argument default,
8
+ * silences the error. Passing `true` restores throwing for subsequent decorator
9
+ * construction. Decorators already constructed keep their selected callbacks.
10
+ *
11
+ * @evidence contracts/common.md#principled-implementation The function sets the one flag that `NoTransformConfigurationError` reads, so the choice is made once for the process.
12
+ * @evidence contracts/common.md#clear-and-simple-design One setter with a boolean parameter.
13
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It changes an exported flag of this package and nothing foreign.
14
+ * @evidence contracts/common.md#meaningful-documentation The comment states the default and the effect of the flag.
15
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation This setter changes an in-memory validation configuration flag and performs no filesystem or process operation.
16
+ */
3
17
  export const doNotThrowTransformError = (value: boolean = false) => {
4
18
  NoTransformConfigurationError.throws = value;
5
19
  };
@@ -1,3 +1,5 @@
1
+ import { IRequestBodyValidation } from "./IRequestBodyValidation";
2
+
1
3
  /**
2
4
  * Reflection metadata stored by the {@link McpRoute} decorator.
3
5
  *
@@ -29,12 +31,16 @@ export namespace IMcpRouteReflect {
29
31
  *
30
32
  * `validate` is the closure returned by `validate_request_body(...)`; it
31
33
  * returns `null` on success or an Error carrying validation details.
34
+ * Factory-owned callbacks additionally resolve successful data. The optional
35
+ * resolver preserves compatibility with existing error-only metadata
36
+ * callbacks.
32
37
  *
33
38
  * @internal
34
39
  */
35
40
  export interface IArgument {
36
41
  category: "params";
37
42
  index: number;
38
- validate: (input: any) => Error | null;
43
+ validate: ((input: any) => Error | null) &
44
+ Pick<IRequestBodyValidation<any>, "resolve">;
39
45
  }
40
46
  }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Internal request validation callable with an optional successful-value
3
+ * resolver.
4
+ *
5
+ * The callable preserves the legacy error-or-null metadata contract. Factory
6
+ * validators also expose `resolve` so consumers can retain clone results
7
+ * without treating a valid Error, null or undefined value as a failure.
8
+ *
9
+ * @evidence contracts/common.md#principled-implementation Resolver input is untrusted unknown and only successful data is T. Existing public descriptor callbacks retain their input:T signature; the private adapter casts once at that compatibility boundary and relies on the callback's validation decision, without asserting input validity beforehand. Assert returns and validation.data are retained; is and legacy null success retain accepted input. Errors preserve 400 details and non-guard throws, and explicit tags permit successful Error/null/undefined.
10
+ * @evidence contracts/common.md#clear-and-simple-design One callable interface and namespace separate compatibility from successful data. The private factory installs both operations on one newly created function; descriptor adapters own their existing error translation, and the shared resolver chooses the supported protocol without request-result caching or double validation.
11
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The private constructor composes an owned function and resolver without modifying foreign callbacks or public descriptors. Unknown descriptor tags reject; legacy error-only callbacks remain supported without an invented replacement value or data sentinel.
12
+ * @evidence contracts/common.md#meaningful-documentation This type explains optional resolution and tagged values; private factory/resolver native comments explain construction, single-call behavior and legacy fallback. The owning type reviews those internal operations rather than exposing them to obtain standalone documentation hosts.
13
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation The callable and tagged result describe validated JavaScript values, not native file identities or process handles.
14
+ */
15
+ export interface IRequestBodyValidation<T> {
16
+ (input: T): Error | null;
17
+
18
+ /**
19
+ * Resolves validation once, retaining its successful value when supported.
20
+ *
21
+ * @evidence contracts/common.md#principled-implementation The optional operation returns a discriminated result so successful Error, null or undefined data cannot be confused with validation failure; absence identifies legacy error-only callbacks.
22
+ * @evidence contracts/common.md#clear-and-simple-design One optional function supplements the existing callable without changing its failure protocol.
23
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The member records a real factory-owned capability rather than requiring it on legacy callbacks or using raw-data sentinels.
24
+ * @evidence contracts/common.md#meaningful-documentation The comment states single validation and successful-value retention; the owning interface explains compatibility.
25
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation The callable and tagged result describe validated JavaScript values, not native file identities or process handles.
26
+ */
27
+ resolve?: (input: unknown) => IRequestBodyValidation.IResult<T>;
28
+ }
29
+
30
+ export namespace IRequestBodyValidation {
31
+ /**
32
+ * Successful data or a validation error, distinguished independently of data.
33
+ *
34
+ * @evidence contracts/common.md#principled-implementation The success literal distinguishes a valid Error, null or undefined from a rejected value; failure alone carries the error consumers throw.
35
+ * @evidence contracts/common.md#clear-and-simple-design A two-variant union gives consumers one exhaustive success check.
36
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The result uses no data sentinel or consumer-specific exception.
37
+ * @evidence contracts/common.md#meaningful-documentation The description states the distinction that the union preserves.
38
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation The callable and tagged result describe validated JavaScript values, not native file identities or process handles.
39
+ */
40
+ export type IResult<T> =
41
+ | { success: true; data: T }
42
+ | { success: false; error: Error };
43
+
44
+ /**
45
+ * A factory-owned checker whose resolver is always present.
46
+ *
47
+ * @evidence contracts/common.md#principled-implementation Factory callers can resolve successful data directly because construction installs the resolver together with the legacy callable.
48
+ * @evidence contracts/common.md#clear-and-simple-design This interface strengthens only the optional member of the compatibility interface.
49
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The required member describes the actual factory result rather than asserting a resolver exists on foreign legacy callbacks.
50
+ * @evidence contracts/common.md#meaningful-documentation The comment identifies which owner guarantees resolver availability.
51
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation The callable and tagged result describe validated JavaScript values, not native file identities or process handles.
52
+ */
53
+ export interface IResolved<T> extends IRequestBodyValidation<T> {
54
+ /**
55
+ * Resolves validation and retains successful data.
56
+ *
57
+ * @evidence contracts/common.md#principled-implementation Factory construction installs this operation with its callable, making successful callback data available without running validation twice.
58
+ * @evidence contracts/common.md#clear-and-simple-design The required function strengthens only the compatibility interface's optional resolver.
59
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The mandatory resolver applies only to the owned factory result, never to an arbitrary legacy callback.
60
+ * @evidence contracts/common.md#meaningful-documentation The description identifies the operation's result and the owning interface states its construction guarantee.
61
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation The callable and tagged result describe validated JavaScript values, not native file identities or process handles.
62
+ */
63
+ resolve: (input: unknown) => IResult<T>;
64
+ }
65
+ }