@nestia/core 14.0.0 → 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 (192) hide show
  1. package/MIGRATION.md +20 -0
  2. package/README.md +1 -1
  3. package/lib/adaptors/McpAdaptor.d.ts +29 -3
  4. package/lib/adaptors/McpAdaptor.js +150 -24
  5. package/lib/adaptors/McpAdaptor.js.map +1 -1
  6. package/lib/adaptors/WebSocketAdaptor.d.ts +37 -0
  7. package/lib/adaptors/WebSocketAdaptor.js +184 -48
  8. package/lib/adaptors/WebSocketAdaptor.js.map +1 -1
  9. package/lib/adaptors/internal/RoutePathMatcher.d.ts +1 -0
  10. package/lib/adaptors/internal/RoutePathMatcher.js +88 -0
  11. package/lib/adaptors/internal/RoutePathMatcher.js.map +1 -0
  12. package/lib/adaptors/internal/external_context.d.ts +1 -0
  13. package/lib/adaptors/internal/external_context.js +56 -0
  14. package/lib/adaptors/internal/external_context.js.map +1 -0
  15. package/lib/decorators/DynamicModule.d.ts +12 -0
  16. package/lib/decorators/DynamicModule.js +12 -0
  17. package/lib/decorators/DynamicModule.js.map +1 -1
  18. package/lib/decorators/EncryptedBody.d.ts +14 -6
  19. package/lib/decorators/EncryptedBody.js +39 -16
  20. package/lib/decorators/EncryptedBody.js.map +1 -1
  21. package/lib/decorators/EncryptedController.d.ts +6 -1
  22. package/lib/decorators/EncryptedController.js +7 -2
  23. package/lib/decorators/EncryptedController.js.map +1 -1
  24. package/lib/decorators/EncryptedModule.d.ts +25 -6
  25. package/lib/decorators/EncryptedModule.js +87 -18
  26. package/lib/decorators/EncryptedModule.js.map +1 -1
  27. package/lib/decorators/EncryptedRoute.d.ts +20 -11
  28. package/lib/decorators/EncryptedRoute.js +27 -13
  29. package/lib/decorators/EncryptedRoute.js.map +1 -1
  30. package/lib/decorators/HumanRoute.d.ts +5 -0
  31. package/lib/decorators/HumanRoute.js +5 -0
  32. package/lib/decorators/HumanRoute.js.map +1 -1
  33. package/lib/decorators/McpRoute.d.ts +31 -19
  34. package/lib/decorators/McpRoute.js +12 -1
  35. package/lib/decorators/McpRoute.js.map +1 -1
  36. package/lib/decorators/PlainBody.d.ts +7 -1
  37. package/lib/decorators/PlainBody.js +16 -8
  38. package/lib/decorators/PlainBody.js.map +1 -1
  39. package/lib/decorators/SwaggerCustomizer.d.ts +15 -0
  40. package/lib/decorators/SwaggerCustomizer.js +5 -0
  41. package/lib/decorators/SwaggerCustomizer.js.map +1 -1
  42. package/lib/decorators/SwaggerExample.d.ts +51 -22
  43. package/lib/decorators/SwaggerExample.js +35 -22
  44. package/lib/decorators/SwaggerExample.js.map +1 -1
  45. package/lib/decorators/TypedBody.d.ts +10 -3
  46. package/lib/decorators/TypedBody.js +20 -10
  47. package/lib/decorators/TypedBody.js.map +1 -1
  48. package/lib/decorators/TypedException.d.ts +10 -0
  49. package/lib/decorators/TypedFormData.d.ts +81 -9
  50. package/lib/decorators/TypedFormData.js +121 -31
  51. package/lib/decorators/TypedFormData.js.map +1 -1
  52. package/lib/decorators/TypedHeaders.d.ts +5 -0
  53. package/lib/decorators/TypedHeaders.js +5 -0
  54. package/lib/decorators/TypedHeaders.js.map +1 -1
  55. package/lib/decorators/TypedParam.d.ts +12 -3
  56. package/lib/decorators/TypedParam.js +12 -3
  57. package/lib/decorators/TypedParam.js.map +1 -1
  58. package/lib/decorators/TypedQuery.d.ts +17 -1
  59. package/lib/decorators/TypedQuery.js +25 -4
  60. package/lib/decorators/TypedQuery.js.map +1 -1
  61. package/lib/decorators/TypedRoute.d.ts +25 -10
  62. package/lib/decorators/TypedRoute.js +19 -10
  63. package/lib/decorators/TypedRoute.js.map +1 -1
  64. package/lib/decorators/WebSocketRoute.d.ts +18 -1
  65. package/lib/decorators/WebSocketRoute.js +18 -1
  66. package/lib/decorators/WebSocketRoute.js.map +1 -1
  67. package/lib/decorators/doNotThrowTransformError.d.ts +14 -0
  68. package/lib/decorators/doNotThrowTransformError.js +14 -0
  69. package/lib/decorators/doNotThrowTransformError.js.map +1 -1
  70. package/lib/decorators/internal/EncryptedConstant.js +13 -2
  71. package/lib/decorators/internal/EncryptedConstant.js.map +1 -1
  72. package/lib/decorators/internal/IRequestBodyValidation.d.ts +66 -0
  73. package/lib/decorators/internal/IRequestBodyValidation.js +3 -0
  74. package/lib/decorators/internal/IRequestBodyValidation.js.map +1 -0
  75. package/lib/decorators/internal/IWebSocketRouteReflect.d.ts +93 -1
  76. package/lib/decorators/internal/get_encryption_password.d.ts +1 -0
  77. package/lib/decorators/internal/get_encryption_password.js +14 -0
  78. package/lib/decorators/internal/get_encryption_password.js.map +1 -0
  79. package/lib/decorators/internal/get_path_and_querify.js +23 -9
  80. package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
  81. package/lib/decorators/internal/get_path_and_stringify.js +3 -7
  82. package/lib/decorators/internal/get_path_and_stringify.js.map +1 -1
  83. package/lib/decorators/internal/get_text_body.js +9 -3
  84. package/lib/decorators/internal/get_text_body.js.map +1 -1
  85. package/lib/decorators/internal/group_entries.d.ts +1 -0
  86. package/lib/decorators/internal/group_entries.js +19 -0
  87. package/lib/decorators/internal/group_entries.js.map +1 -0
  88. package/lib/decorators/internal/load_controller.d.ts +14 -0
  89. package/lib/decorators/internal/load_controller.js +14 -0
  90. package/lib/decorators/internal/load_controller.js.map +1 -1
  91. package/lib/decorators/internal/split_route_arguments.d.ts +1 -0
  92. package/lib/decorators/internal/split_route_arguments.js +22 -0
  93. package/lib/decorators/internal/split_route_arguments.js.map +1 -0
  94. package/lib/decorators/internal/validate_request_body.js +68 -25
  95. package/lib/decorators/internal/validate_request_body.js.map +1 -1
  96. package/lib/decorators/internal/validate_request_form_data.js +3 -1
  97. package/lib/decorators/internal/validate_request_form_data.js.map +1 -1
  98. package/lib/decorators/internal/validate_request_headers.js +2 -1
  99. package/lib/decorators/internal/validate_request_headers.js.map +1 -1
  100. package/lib/decorators/internal/validate_request_query.js +3 -1
  101. package/lib/decorators/internal/validate_request_query.js.map +1 -1
  102. package/lib/options/IRequestBodyValidator.d.ts +71 -0
  103. package/lib/options/IRequestFormDataProps.d.ts +80 -0
  104. package/lib/options/IRequestHeadersValidator.d.ts +67 -0
  105. package/lib/options/IRequestQueryValidator.d.ts +68 -0
  106. package/lib/options/IResponseBodyQuerifier.d.ts +125 -1
  107. package/lib/options/IResponseBodyStringifier.d.ts +107 -0
  108. package/lib/typings/Creator.d.ts +10 -0
  109. package/lib/utils/ArrayUtil.d.ts +21 -0
  110. package/lib/utils/ArrayUtil.js +22 -1
  111. package/lib/utils/ArrayUtil.js.map +1 -1
  112. package/lib/utils/ExceptionManager.d.ts +43 -4
  113. package/lib/utils/ExceptionManager.js +44 -6
  114. package/lib/utils/ExceptionManager.js.map +1 -1
  115. package/lib/utils/SourceFinder.d.ts +22 -0
  116. package/lib/utils/SourceFinder.js +60 -10
  117. package/lib/utils/SourceFinder.js.map +1 -1
  118. package/lib/utils/VersioningStrategy.d.ts +45 -2
  119. package/lib/utils/VersioningStrategy.js +40 -7
  120. package/lib/utils/VersioningStrategy.js.map +1 -1
  121. package/native/go.mod +1 -1
  122. package/native/go.sum +2 -2
  123. package/native/plugin/plan.go +68 -2
  124. package/native/transform/ast.go +23 -3
  125. package/native/transform/build.go +51 -57
  126. package/native/transform/buildoutput/output.go +147 -0
  127. package/native/transform/contributor.go +9 -0
  128. package/native/transform/core_querify.go +63 -9
  129. package/native/transform/core_transform.go +180 -98
  130. package/native/transform/core_websocket.go +111 -14
  131. package/native/transform/node_transform.go +17 -8
  132. package/native/transform/package.go +55 -0
  133. package/native/transform/printer.go +1 -3
  134. package/native/transform/run.go +18 -0
  135. package/native/transform/schemaprojection/project.go +213 -0
  136. package/native/transform/transform.go +29 -18
  137. package/native/transform/typia_fast.go +6 -0
  138. package/native/transform.cjs +49 -0
  139. package/package.json +13 -15
  140. package/src/adaptors/McpAdaptor.ts +215 -33
  141. package/src/adaptors/WebSocketAdaptor.ts +202 -52
  142. package/src/adaptors/internal/RoutePathMatcher.ts +91 -0
  143. package/src/adaptors/internal/external_context.ts +81 -0
  144. package/src/decorators/DynamicModule.ts +12 -0
  145. package/src/decorators/EncryptedBody.ts +39 -15
  146. package/src/decorators/EncryptedController.ts +12 -3
  147. package/src/decorators/EncryptedModule.ts +89 -18
  148. package/src/decorators/EncryptedRoute.ts +27 -16
  149. package/src/decorators/HumanRoute.ts +5 -0
  150. package/src/decorators/McpRoute.ts +31 -19
  151. package/src/decorators/PlainBody.ts +20 -10
  152. package/src/decorators/SwaggerCustomizer.ts +15 -0
  153. package/src/decorators/SwaggerExample.ts +51 -22
  154. package/src/decorators/TypedBody.ts +18 -9
  155. package/src/decorators/TypedException.ts +10 -0
  156. package/src/decorators/TypedFormData.ts +207 -45
  157. package/src/decorators/TypedHeaders.ts +5 -0
  158. package/src/decorators/TypedParam.ts +12 -3
  159. package/src/decorators/TypedQuery.ts +35 -7
  160. package/src/decorators/TypedRoute.ts +25 -10
  161. package/src/decorators/WebSocketRoute.ts +18 -1
  162. package/src/decorators/doNotThrowTransformError.ts +14 -0
  163. package/src/decorators/internal/EncryptedConstant.ts +14 -1
  164. package/src/decorators/internal/IMcpRouteReflect.ts +7 -1
  165. package/src/decorators/internal/IRequestBodyValidation.ts +65 -0
  166. package/src/decorators/internal/IWebSocketRouteReflect.ts +95 -1
  167. package/src/decorators/internal/get_encryption_password.ts +19 -0
  168. package/src/decorators/internal/get_path_and_querify.ts +31 -10
  169. package/src/decorators/internal/get_path_and_stringify.ts +3 -9
  170. package/src/decorators/internal/get_text_body.ts +8 -4
  171. package/src/decorators/internal/group_entries.ts +17 -0
  172. package/src/decorators/internal/load_controller.ts +14 -0
  173. package/src/decorators/internal/split_route_arguments.ts +20 -0
  174. package/src/decorators/internal/validate_request_body.ts +87 -34
  175. package/src/decorators/internal/validate_request_form_data.ts +3 -1
  176. package/src/decorators/internal/validate_request_headers.ts +2 -2
  177. package/src/decorators/internal/validate_request_query.ts +3 -2
  178. package/src/options/IRequestBodyValidator.ts +71 -0
  179. package/src/options/IRequestFormDataProps.ts +80 -0
  180. package/src/options/IRequestHeadersValidator.ts +67 -0
  181. package/src/options/IRequestQueryValidator.ts +68 -0
  182. package/src/options/IResponseBodyQuerifier.ts +126 -1
  183. package/src/options/IResponseBodyStringifier.ts +107 -0
  184. package/src/typings/Creator.ts +10 -0
  185. package/src/utils/ArrayUtil.ts +22 -3
  186. package/src/utils/ExceptionManager.ts +50 -6
  187. package/src/utils/SourceFinder.ts +62 -10
  188. package/src/utils/VersioningStrategy.ts +55 -11
  189. package/lib/transform.d.ts +0 -10
  190. package/lib/transform.js +0 -25
  191. package/lib/transform.js.map +0 -1
  192. package/src/transform.ts +0 -26
package/MIGRATION.md CHANGED
@@ -93,6 +93,26 @@ Add `compilerOptions.plugins` only when you want to override those options:
93
93
  The `typia` entry is a host tombstone for tools that inspect plugin arrays.
94
94
  The actual typia transform is composed by the native Nestia binary.
95
95
 
96
+ ### A plugin list kept from nestia v11
97
+
98
+ A project upgraded from nestia v11 may still list the plugins that version documented:
99
+
100
+ ```jsonc
101
+ {
102
+ "compilerOptions": {
103
+ "plugins": [
104
+ { "transform": "typia/lib/transform" },
105
+ { "transform": "@nestia/core/lib/transform", "validate": "assert", "stringify": "assert" },
106
+ { "transform": "@nestia/sdk/lib/transform" }
107
+ ]
108
+ }
109
+ }
110
+ ```
111
+
112
+ It builds unchanged. `@nestia/core/lib/transform` resolves to the same descriptor as `@nestia/core/native/transform.cjs`, which composes the `typia` entry and applies the `validate` and `stringify` options. The `@nestia/sdk/lib/transform` entry attaches SDK metadata in every build, as it did in v11, so `@nestia/sdk` must stay installed at runtime. Replace the list with the override above, or remove it for the defaults.
113
+
114
+ Releases before this change gave `@nestia/core/lib/transform` a host of its own, and ttsc stopped with `multiple compiler native backends cannot share one emit pass`. On such a release, replace the list as above.
115
+
96
116
  ## CLI setup flow
97
117
 
98
118
  The CLI no longer provides an interactive setup command. Install packages and
package/README.md CHANGED
@@ -60,7 +60,7 @@ Check out the document in the [website](https://nestia.io/docs/):
60
60
  ### 🏠 Home
61
61
  - [Introduction](https://nestia.io/docs/)
62
62
  - [Setup](https://nestia.io/docs/setup/)
63
- - [Pure TypeScript](https://nestia.io/docs/pure)
63
+ - [Pure TypeScript](https://nestia.io/docs/core/TypedBody/)
64
64
 
65
65
  ### 📖 Features
66
66
  - Core Library
@@ -15,6 +15,11 @@ import { INestApplication } from "@nestjs/common";
15
15
  * registration API of `McpServer` is bypassed by accessing the low-level
16
16
  * `.server` handler.
17
17
  *
18
+ * A tool call passes the guards, interceptors, pipes, and exception filters
19
+ * NestJS applies to an HTTP route on the same method, with the MCP HTTP request
20
+ * as the execution context. The endpoint is mounted at `path` as given, outside
21
+ * the application's global prefix.
22
+ *
18
23
  * Error mapping follows the MCP specification:
19
24
  *
20
25
  * - Unknown tool name: JSON-RPC `-32601`.
@@ -25,14 +30,12 @@ import { INestApplication } from "@nestjs/common";
25
30
  *
26
31
  * @author wildduck - https://github.com/wildduck2
27
32
  * @example
28
- * ```typescript
29
33
  * import core from "@nestia/core";
30
34
  * import { NestFactory } from "@nestjs/core";
31
35
  *
32
36
  * const app = await NestFactory.create(AppModule);
33
37
  * await core.McpAdaptor.upgrade(app, { path: "/mcp" });
34
38
  * await app.listen(3000);
35
- * ```;
36
39
  */
37
40
  export declare class McpAdaptor {
38
41
  /**
@@ -49,11 +52,34 @@ export declare class McpAdaptor {
49
52
  *
50
53
  * @param app Running Nest application instance.
51
54
  * @param options Transport and identity overrides.
55
+ * @evidence contracts/common.md#principled-implementation Tools are collected once from the prototype chain of every controller instance by the `nestia/McpRoute` metadata, with the first definition of a property name winning and accessors skipped without execution, duplicates by tool name refused before serving, and each call runs through NestJS's `ExternalContextCreator` so guards, interceptors, pipes, and exception filters apply as for an HTTP route; every request gets a fresh MCP server and Streamable HTTP transport, which stateless mode requires, and both are closed in a `finally`.
56
+ * @evidence contracts/common.md#clear-and-simple-design One entry point does discovery and registration; the per-tool call (`createHandler`), the duplicate check, the SDK loader, and the per-request response facade are separate module-private functions.
57
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Reading the module graph goes through the internal `app.container`, because `INestApplication` exposes no public accessor for it, `create_external_context_creator` constructs an owned subclass through the Nest constructor and overrides module selection on that type, because the default looks for provider classes while controllers belong to the controller collection, and `get_request_context_id` registers the request provider on the request object as NestJS's router does for an HTTP route, and a per-request response facade forwards native state, events and method receivers without replacing raw methods. After a tool or its exception filter has sent headers, only the facade suppresses subsequent transport writes and preserves callbacks and chaining. Native transport writes do not themselves activate takeover. The remaining foreign-internal reads are the application container and Nest request context registration; the MCP SDK uses its public Node response injection boundary.
58
+ * @evidence contracts/common.md#meaningful-documentation The comment states the stateless mode, what is discovered, and that the SDK is an optional dependency; the options documentation states the path and server information.
59
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation MCP tool discovery and HTTP transport callbacks carry protocol values; optional SDK imports use Node module resolution and no native file identity or child process is defined here.
52
60
  */
53
61
  static upgrade(app: INestApplication, options?: McpAdaptor.IOptions): Promise<void>;
54
62
  }
63
+ /**
64
+ * Types of {@link McpAdaptor}: the options of `upgrade` and the record of a
65
+ * registered tool.
66
+ *
67
+ * @evidence contracts/common.md#principled-implementation The class exposes one static entry point, so the adapter has no instance state: the tool list is closed over by the registered route handler.
68
+ * @evidence contracts/common.md#clear-and-simple-design One static method and two nested types.
69
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It has no fixture or tool name, and the MCP SDK is loaded lazily so an application that never enables MCP does not need it.
70
+ * @evidence contracts/common.md#meaningful-documentation The class comment explains what an MCP route is and how to enable it.
71
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation MCP tool discovery and HTTP transport callbacks carry protocol values; optional SDK imports use Node module resolution and no native file identity or child process is defined here.
72
+ */
55
73
  export declare namespace McpAdaptor {
56
- /** Configuration options for {@link McpAdaptor.upgrade}. */
74
+ /**
75
+ * Configuration options for {@link McpAdaptor.upgrade}.
76
+ *
77
+ * @evidence contracts/common.md#principled-implementation The two options are the route path, with `/mcp` as the default, and the server information reported to clients, with a default name and version.
78
+ * @evidence contracts/common.md#clear-and-simple-design A flat record of two optional values.
79
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type; the defaults are stated in the code that reads them.
80
+ * @evidence contracts/common.md#meaningful-documentation Each option documents its meaning.
81
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation MCP tool discovery and HTTP transport callbacks carry protocol values; optional SDK imports use Node module resolution and no native file identity or child process is defined here.
82
+ */
57
83
  interface IOptions {
58
84
  /**
59
85
  * HTTP path where the MCP endpoint will be mounted.
@@ -44,6 +44,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
44
44
  Object.defineProperty(exports, "__esModule", { value: true });
45
45
  exports.McpAdaptor = void 0;
46
46
  const common_1 = require("@nestjs/common");
47
+ const route_paramtypes_enum_1 = require("@nestjs/common/enums/route-paramtypes.enum");
48
+ const injector_1 = require("@nestjs/core/injector/injector");
49
+ const validate_request_body_1 = require("../decorators/internal/validate_request_body");
50
+ const external_context_1 = require("./internal/external_context");
47
51
  /**
48
52
  * MCP (Model Context Protocol) adaptor.
49
53
  *
@@ -60,6 +64,11 @@ const common_1 = require("@nestjs/common");
60
64
  * registration API of `McpServer` is bypassed by accessing the low-level
61
65
  * `.server` handler.
62
66
  *
67
+ * A tool call passes the guards, interceptors, pipes, and exception filters
68
+ * NestJS applies to an HTTP route on the same method, with the MCP HTTP request
69
+ * as the execution context. The endpoint is mounted at `path` as given, outside
70
+ * the application's global prefix.
71
+ *
63
72
  * Error mapping follows the MCP specification:
64
73
  *
65
74
  * - Unknown tool name: JSON-RPC `-32601`.
@@ -70,14 +79,12 @@ const common_1 = require("@nestjs/common");
70
79
  *
71
80
  * @author wildduck - https://github.com/wildduck2
72
81
  * @example
73
- * ```typescript
74
82
  * import core from "@nestia/core";
75
83
  * import { NestFactory } from "@nestjs/core";
76
84
  *
77
85
  * const app = await NestFactory.create(AppModule);
78
86
  * await core.McpAdaptor.upgrade(app, { path: "/mcp" });
79
87
  * await app.listen(3000);
80
- * ```;
81
88
  */
82
89
  class McpAdaptor {
83
90
  /**
@@ -94,6 +101,11 @@ class McpAdaptor {
94
101
  *
95
102
  * @param app Running Nest application instance.
96
103
  * @param options Transport and identity overrides.
104
+ * @evidence contracts/common.md#principled-implementation Tools are collected once from the prototype chain of every controller instance by the `nestia/McpRoute` metadata, with the first definition of a property name winning and accessors skipped without execution, duplicates by tool name refused before serving, and each call runs through NestJS's `ExternalContextCreator` so guards, interceptors, pipes, and exception filters apply as for an HTTP route; every request gets a fresh MCP server and Streamable HTTP transport, which stateless mode requires, and both are closed in a `finally`.
105
+ * @evidence contracts/common.md#clear-and-simple-design One entry point does discovery and registration; the per-tool call (`createHandler`), the duplicate check, the SDK loader, and the per-request response facade are separate module-private functions.
106
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Reading the module graph goes through the internal `app.container`, because `INestApplication` exposes no public accessor for it, `create_external_context_creator` constructs an owned subclass through the Nest constructor and overrides module selection on that type, because the default looks for provider classes while controllers belong to the controller collection, and `get_request_context_id` registers the request provider on the request object as NestJS's router does for an HTTP route, and a per-request response facade forwards native state, events and method receivers without replacing raw methods. After a tool or its exception filter has sent headers, only the facade suppresses subsequent transport writes and preserves callbacks and chaining. Native transport writes do not themselves activate takeover. The remaining foreign-internal reads are the application container and Nest request context registration; the MCP SDK uses its public Node response injection boundary.
107
+ * @evidence contracts/common.md#meaningful-documentation The comment states the stateless mode, what is discovered, and that the SDK is an optional dependency; the options documentation states the path and server information.
108
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation MCP tool discovery and HTTP transport callbacks carry protocol values; optional SDK imports use Node module resolution and no native file identity or child process is defined here.
97
109
  */
98
110
  static upgrade(app_1) {
99
111
  return __awaiter(this, arguments, void 0, function* (app, options = {}) {
@@ -103,7 +115,9 @@ class McpAdaptor {
103
115
  throw new Error("McpAdaptor.upgrade() supports stateless Streamable HTTP only; sessioned mode is not implemented.");
104
116
  const tools = [];
105
117
  const container = app.container;
106
- for (const module of container.getModules().values()) {
118
+ const injector = new injector_1.Injector();
119
+ for (const [moduleKey, module] of container.getModules()) {
120
+ const creator = (0, external_context_1.create_external_context_creator)(container, moduleKey);
107
121
  for (const wrapper of module.controllers.values()) {
108
122
  const instance = wrapper.instance;
109
123
  if (!instance)
@@ -114,19 +128,26 @@ class McpAdaptor {
114
128
  if (key === "constructor" || visited.has(key))
115
129
  continue;
116
130
  visited.add(key);
117
- const method = proto[key];
131
+ // Route discovery inspects data descriptors without invoking accessors.
132
+ const method = (_a = Object.getOwnPropertyDescriptor(proto, key)) === null || _a === void 0 ? void 0 : _a.value;
118
133
  if (typeof method !== "function")
119
134
  continue;
120
135
  const meta = Reflect.getMetadata("nestia/McpRoute", method);
121
136
  if (!meta)
122
137
  continue;
123
138
  const params = (_d = Reflect.getMetadata("nestia/McpRoute/Parameters", proto, key)) !== null && _d !== void 0 ? _d : [];
124
- const paramValidator = (_a = params.find((p) => p.category === "params")) === null || _a === void 0 ? void 0 : _a.validate;
125
139
  tools.push({
126
140
  meta,
127
141
  source: `${(_f = (_e = (_b = wrapper.metatype) === null || _b === void 0 ? void 0 : _b.name) !== null && _e !== void 0 ? _e : (_c = proto.constructor) === null || _c === void 0 ? void 0 : _c.name) !== null && _f !== void 0 ? _f : "UnknownController"}.${String(key)}`,
128
- validateArgs: paramValidator,
129
- handler: (args) => __awaiter(this, void 0, void 0, function* () { return method.call(instance, args); }),
142
+ handler: createHandler({
143
+ container,
144
+ injector,
145
+ creator,
146
+ module,
147
+ wrapper,
148
+ key,
149
+ argument: params.find((p) => p.category === "params"),
150
+ }),
130
151
  });
131
152
  }
132
153
  }
@@ -148,6 +169,7 @@ class McpAdaptor {
148
169
  capabilities: { tools: {} },
149
170
  });
150
171
  const server = mcp.server;
172
+ const relay = transportResponse((_a = res.raw) !== null && _a !== void 0 ? _a : res);
151
173
  server.setRequestHandler(ListToolsRequestSchema, () => __awaiter(this, void 0, void 0, function* () {
152
174
  return ({
153
175
  tools: tools.map((t) => ({
@@ -166,23 +188,16 @@ class McpAdaptor {
166
188
  if (!tool)
167
189
  throw new McpError(ErrorCode.MethodNotFound, `Tool not found: ${reqMsg.params.name}`);
168
190
  const args = (_a = reqMsg.params.arguments) !== null && _a !== void 0 ? _a : {};
169
- if (tool.validateArgs) {
170
- const err = tool.validateArgs(args);
171
- if (err !== null) {
172
- const body = err instanceof common_1.BadRequestException
173
- ? err.getResponse()
174
- : undefined;
175
- throw new McpError(ErrorCode.InvalidParams, err.message, {
176
- errors: body === null || body === void 0 ? void 0 : body.errors,
177
- path: body === null || body === void 0 ? void 0 : body.path,
178
- expected: body === null || body === void 0 ? void 0 : body.expected,
179
- value: body === null || body === void 0 ? void 0 : body.value,
180
- reason: body === null || body === void 0 ? void 0 : body.reason,
181
- });
182
- }
183
- }
184
191
  try {
185
- const result = yield tool.handler(args);
192
+ const result = yield tool.handler({
193
+ request: req,
194
+ response: res,
195
+ args,
196
+ });
197
+ if (relay.takeOver())
198
+ return { content: [] };
199
+ if (result instanceof Error)
200
+ throw result;
186
201
  if (result === undefined)
187
202
  return { content: [] };
188
203
  return {
@@ -195,6 +210,18 @@ class McpAdaptor {
195
210
  };
196
211
  }
197
212
  catch (e) {
213
+ if (relay.takeOver())
214
+ return { content: [] };
215
+ if (INVALID_ARGUMENTS.has(e)) {
216
+ const body = e.getResponse();
217
+ throw new McpError(ErrorCode.InvalidParams, e.message, {
218
+ errors: body === null || body === void 0 ? void 0 : body.errors,
219
+ path: body === null || body === void 0 ? void 0 : body.path,
220
+ expected: body === null || body === void 0 ? void 0 : body.expected,
221
+ value: body === null || body === void 0 ? void 0 : body.value,
222
+ reason: body === null || body === void 0 ? void 0 : body.reason,
223
+ });
224
+ }
198
225
  if (e instanceof common_1.HttpException) {
199
226
  return {
200
227
  content: [{ type: "text", text: e.message }],
@@ -210,7 +237,7 @@ class McpAdaptor {
210
237
  });
211
238
  try {
212
239
  yield mcp.connect(transport);
213
- yield transport.handleRequest((_a = req.raw) !== null && _a !== void 0 ? _a : req, (_b = res.raw) !== null && _b !== void 0 ? _b : res, req.body);
240
+ yield transport.handleRequest((_b = req.raw) !== null && _b !== void 0 ? _b : req, relay.response, req.body);
214
241
  }
215
242
  finally {
216
243
  yield transport.close().catch(() => { });
@@ -221,6 +248,105 @@ class McpAdaptor {
221
248
  }
222
249
  }
223
250
  exports.McpAdaptor = McpAdaptor;
251
+ /**
252
+ * The tool's call through the enhancers NestJS applies to a route of the same
253
+ * method: guards, interceptors, pipes, and exception filters, bound to the
254
+ * method, its controller, or globally. The MCP HTTP request is the execution
255
+ * context, so a guard reading `switchToHttp().getRequest()` works unchanged.
256
+ *
257
+ * The arguments reach the method through the pipes as its body would, validated
258
+ * by typia at that stage: after the guards, as `@TypedBody()` is. An invalid
259
+ * argument is thrown as the validator's `BadRequestException`, which an
260
+ * exception filter may map; unmapped, it becomes JSON-RPC `-32602`. Successful
261
+ * resolver data becomes the argument before pipes execute. Legacy error-only
262
+ * metadata callbacks retain raw input on null success.
263
+ *
264
+ * A controller that is request-scoped, itself or through an enhancer or a
265
+ * dependency, is built per request with its enhancers, as NestJS builds it for
266
+ * an HTTP route; the static instance is only a placeholder without them.
267
+ */
268
+ const createHandler = (props) => {
269
+ var _a, _b;
270
+ var _c;
271
+ // the arguments stand at the params' position, or first when undecorated
272
+ const index = (_c = (_a = props.argument) === null || _a === void 0 ? void 0 : _a.index) !== null && _c !== void 0 ? _c : 0;
273
+ Reflect.defineMetadata(PARAMS_METADATA, { [`${route_paramtypes_enum_1.RouteParamtypes.BODY}:${index}`]: { index, data: undefined } }, props.wrapper.instance.constructor, props.key);
274
+ const validate = (_b = props.argument) === null || _b === void 0 ? void 0 : _b.validate;
275
+ const create = (instance, contextId) => props.creator.create(instance, instance[props.key], props.key, PARAMS_METADATA, {
276
+ // [request, response, next] as an HTTP route has, then the arguments
277
+ exchangeKeyForValue: (_type, _data, [, , , args]) => {
278
+ if (!validate)
279
+ return args;
280
+ const result = (0, validate_request_body_1.resolve_request_body)(validate, args);
281
+ if (result.success)
282
+ return result.data;
283
+ INVALID_ARGUMENTS.add(result.error);
284
+ throw result.error;
285
+ },
286
+ }, contextId, contextId && props.wrapper.id);
287
+ let target;
288
+ return (input) => __awaiter(void 0, void 0, void 0, function* () {
289
+ const call = (fn) => fn(input.request, input.response, undefined, input.args);
290
+ // resolved at the first call, so global enhancers init() registers count
291
+ if (props.wrapper.isDependencyTreeStatic())
292
+ return call((target !== null && target !== void 0 ? target : (target = create(props.wrapper.instance))));
293
+ const contextId = (0, external_context_1.get_request_context_id)(props.container, input.request, props.wrapper.isDependencyTreeDurable());
294
+ const instance = yield props.injector.loadPerContext(props.wrapper.instance, props.module, props.module.controllers, contextId);
295
+ return call(create(instance, contextId));
296
+ });
297
+ };
298
+ /**
299
+ * The transport's response view. Native state, events and method receivers stay
300
+ * on the real response; only this view's writes stop after a tool's exception
301
+ * filter has already answered. Normal transport writes never activate
302
+ * takeover.
303
+ */
304
+ const transportResponse = (raw) => {
305
+ let takenOver = false;
306
+ const respond = (key, args) => {
307
+ if (takenOver) {
308
+ const callback = args.find((arg) => typeof arg === "function");
309
+ if ((key === "write" || key === "end") && typeof callback === "function")
310
+ queueMicrotask(() => callback());
311
+ return key === "write"
312
+ ? true
313
+ : key === "flushHeaders"
314
+ ? undefined
315
+ : response;
316
+ }
317
+ const result = Reflect.apply(raw[key], raw, args);
318
+ return result === raw ? response : result;
319
+ };
320
+ const writes = new Map(["writeHead", "flushHeaders", "write", "end"].map((key) => [
321
+ key,
322
+ (...args) => respond(key, args),
323
+ ]));
324
+ const response = new Proxy(raw, {
325
+ get: (target, key) => {
326
+ const write = writes.get(key);
327
+ if (write !== undefined)
328
+ return write;
329
+ const value = Reflect.get(target, key, target);
330
+ if (typeof value !== "function")
331
+ return value;
332
+ return (...args) => {
333
+ const result = Reflect.apply(value, target, args);
334
+ return result === target ? response : result;
335
+ };
336
+ },
337
+ set: (target, key, value) => Reflect.set(target, key, value, target),
338
+ });
339
+ return {
340
+ response,
341
+ takeOver: () => {
342
+ takenOver || (takenOver = raw.headersSent === true);
343
+ return takenOver;
344
+ },
345
+ };
346
+ };
347
+ const PARAMS_METADATA = "nestia/McpRoute/ExternalParameters";
348
+ /** The validators' exceptions, told apart from a handler's own. */
349
+ const INVALID_ARGUMENTS = new WeakSet();
224
350
  const assertUniqueTools = (tools) => {
225
351
  var _a;
226
352
  const dict = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"McpAdaptor.js","sourceRoot":"","sources":["../../src/adaptors/McpAdaptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAIwB;AAKxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH;IACE;;;;;;;;;;;;;;OAcG;IACI,MAAM,CAAO,OAAO;6DACzB,GAAqB,EACrB,OAAO,GAAwB,EAAE;;;YAEjC,IAAI,WAAW,IAAK,OAAmC;gBACrD,MAAM,IAAI,KAAK,CACb,kGAAkG,CACnG,CAAC;YAEJ,MAAM,KAAK,GAAuB,EAAE,CAAC;YACrC,MAAM,SAAS,GAAI,GAAW,CAAC,SAA0B,CAAC;YAC1D,KAAK,MAAM,MAAM,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC;gBACrD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;oBAClD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;oBAClC,IAAI,CAAC,QAAQ;wBAAE,SAAS;oBACxB,MAAM,OAAO,GAAgB,IAAI,GAAG,EAAE,CAAC;oBACvC,KACE,IAAI,KAAK,GAAQ,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,EAChD,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS,EAC5C,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EACpC,CAAC;wBACD,K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sB,EAAE,KAAK,CAAC,sBAAsB;YACpD,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC;IACJ,CAAC;eAAO,CAAC;QACP,MAAM,IAAI,KAAK,CACb,iGAAiG,CAClG,CAAC;IACJ,CAAC;AACH,CAAC,CAAA,CAAC"}
@@ -1,6 +1,43 @@
1
1
  import { INestApplication } from "@nestjs/common";
2
+ /**
3
+ * Serves the `@WebSocketRoute()` methods of a NestJS application over
4
+ * WebSocket.
5
+ *
6
+ * Call {@link upgrade} after the application has been created. It finds the
7
+ * routes, checks them, and takes over the HTTP server's `upgrade` events. A
8
+ * handshake whose path matches no route is rejected with close code 1002.
9
+ *
10
+ * @evidence contracts/common.md#principled-implementation Routes are matched by paths built from the global prefix, the version, the module prefix, the controller path, and the method path, joined and normalized the same way for every combination; the adapter answers upgrade events itself through a `ws` server in no-server mode and removes its listeners when the HTTP server closes.
11
+ * @evidence contracts/common.md#clear-and-simple-design A class with one static factory, one `close` property, and the private handler; discovery, method checks, termination, and close reasons are module-private functions.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The global prefix, versioning options, and module graph are read from `app.config` and `app.container`, which NestJS keeps internal because `INestApplication` has no public accessor for them; this is the limitation of the adapter, not a fixture-specific branch.
13
+ * @evidence contracts/common.md#meaningful-documentation The comment states when to call it and what happens to an unmatched handshake.
14
+ * @evidence contracts/portability.md#os-neutral-implementation Diagnostic source URLs are converted by fileURLToPath before path.relative uses native paths; route matching uses HTTP path segments separately from filesystem paths. No filesystem case policy is inferred from the OS.
15
+ */
2
16
  export declare class WebSocketAdaptor {
17
+ /**
18
+ * Creates the adapter for the application: it visits every controller,
19
+ * validates the WebSocket routes, and starts listening for upgrade events.
20
+ *
21
+ * All route errors of the application are collected and thrown together, with
22
+ * the controller, method, source location, and reasons of each.
23
+ *
24
+ * @evidence contracts/common.md#principled-implementation Controller data-method descriptors are checked before any handshake is served, with child properties shadowing inherited methods and accessors never executed, and all defects are reported in one error, so a misconfigured route fails at start and not at the first client; source locations come from `get-function-location`, converted with `fileURLToPath` so a `file:` URL becomes the path on every platform.
25
+ * @evidence contracts/common.md#clear-and-simple-design One asynchronous factory that awaits the visitor and hands the operator list to the private constructor.
26
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The visitor reports through the same error path for every controller; no controller or route name is special-cased.
27
+ * @evidence contracts/common.md#meaningful-documentation The comment states the collected error report and the effect on the server.
28
+ * @evidence contracts/portability.md#os-neutral-implementation Diagnostic source URLs are converted by fileURLToPath before path.relative uses native paths; route matching uses HTTP path segments separately from filesystem paths. No filesystem case policy is inferred from the OS.
29
+ */
3
30
  static upgrade(app: INestApplication): Promise<WebSocketAdaptor>;
31
+ /**
32
+ * Stops the adapter: removes its listeners from the HTTP server and closes
33
+ * the WebSocket server.
34
+ *
35
+ * @evidence contracts/common.md#principled-implementation The listeners are removed before the `ws` server closes, so no upgrade event reaches a closing server, and the returned promise resolves when the server has closed.
36
+ * @evidence contracts/common.md#clear-and-simple-design An arrow property so the same function value can be registered and unregistered as the HTTP server's close listener.
37
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It releases exactly what the adapter registered.
38
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is released.
39
+ * @evidence contracts/portability.md#os-neutral-implementation Diagnostic source URLs are converted by fileURLToPath before path.relative uses native paths; route matching uses HTTP path segments separately from filesystem paths. No filesystem case policy is inferred from the OS.
40
+ */
4
41
  readonly close: () => Promise<void>;
5
42
  private constructor();
6
43
  private readonly handleUpgrade;