@nestia/core 12.0.0-dev.20260601.1 → 12.0.0-dev.20260612.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.
Files changed (116) hide show
  1. package/LICENSE +21 -21
  2. package/MIGRATION.md +169 -169
  3. package/README.md +93 -93
  4. package/lib/adaptors/McpAdaptor.d.ts +75 -0
  5. package/lib/adaptors/McpAdaptor.js +257 -0
  6. package/lib/adaptors/McpAdaptor.js.map +1 -0
  7. package/lib/adaptors/WebSocketAdaptor.js +4 -4
  8. package/lib/adaptors/WebSocketAdaptor.js.map +1 -1
  9. package/lib/decorators/McpRoute.d.ts +69 -0
  10. package/lib/decorators/McpRoute.js +58 -0
  11. package/lib/decorators/McpRoute.js.map +1 -0
  12. package/lib/decorators/TypedParam.js +4 -4
  13. package/lib/decorators/TypedParam.js.map +1 -1
  14. package/lib/decorators/TypedRoute.js +1 -1
  15. package/lib/decorators/TypedRoute.js.map +1 -1
  16. package/lib/decorators/internal/IMcpRouteReflect.d.ts +2 -0
  17. package/lib/decorators/internal/IMcpRouteReflect.js +3 -0
  18. package/lib/decorators/internal/IMcpRouteReflect.js.map +1 -0
  19. package/lib/decorators/internal/get_path_and_querify.js +4 -4
  20. package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
  21. package/lib/decorators/internal/get_path_and_stringify.js +4 -4
  22. package/lib/decorators/internal/get_path_and_stringify.js.map +1 -1
  23. package/lib/decorators/internal/load_controller.js +34 -65
  24. package/lib/decorators/internal/load_controller.js.map +1 -1
  25. package/lib/decorators/internal/validate_request_body.js +4 -4
  26. package/lib/decorators/internal/validate_request_body.js.map +1 -1
  27. package/lib/decorators/internal/validate_request_form_data.js +4 -4
  28. package/lib/decorators/internal/validate_request_form_data.js.map +1 -1
  29. package/lib/decorators/internal/validate_request_headers.js +4 -4
  30. package/lib/decorators/internal/validate_request_headers.js.map +1 -1
  31. package/lib/decorators/internal/validate_request_query.js +4 -4
  32. package/lib/decorators/internal/validate_request_query.js.map +1 -1
  33. package/lib/module.d.ts +2 -0
  34. package/lib/module.js +2 -0
  35. package/lib/module.js.map +1 -1
  36. package/native/cmd/ttsc-nestia/main.go +11 -11
  37. package/native/go.mod +32 -32
  38. package/native/go.sum +54 -54
  39. package/native/plugin/plan.go +102 -102
  40. package/native/transform/ast.go +32 -32
  41. package/native/transform/build.go +380 -444
  42. package/native/transform/cleanup.go +408 -408
  43. package/native/transform/contributor.go +97 -68
  44. package/native/transform/core_querify.go +231 -227
  45. package/native/transform/core_transform.go +1996 -1713
  46. package/native/transform/core_websocket.go +115 -115
  47. package/native/transform/exports.go +13 -13
  48. package/native/transform/mcp_transform.go +414 -0
  49. package/native/transform/node_transform.go +357 -0
  50. package/native/transform/path_rewrite.go +285 -285
  51. package/native/transform/printer.go +244 -244
  52. package/native/transform/rewrite.go +668 -662
  53. package/native/transform/run.go +73 -73
  54. package/native/transform/transform.go +336 -403
  55. package/native/transform/typia_fast.go +352 -326
  56. package/native/transform/typia_replacement.go +24 -24
  57. package/native/transform.cjs +43 -43
  58. package/package.json +15 -8
  59. package/src/adaptors/McpAdaptor.ts +276 -0
  60. package/src/adaptors/WebSocketAdaptor.ts +429 -429
  61. package/src/decorators/DynamicModule.ts +44 -44
  62. package/src/decorators/EncryptedBody.ts +97 -97
  63. package/src/decorators/EncryptedController.ts +40 -40
  64. package/src/decorators/EncryptedModule.ts +98 -98
  65. package/src/decorators/EncryptedRoute.ts +213 -213
  66. package/src/decorators/HumanRoute.ts +21 -21
  67. package/src/decorators/McpRoute.ts +154 -0
  68. package/src/decorators/NoTransformConfigurationError.ts +40 -40
  69. package/src/decorators/PlainBody.ts +76 -76
  70. package/src/decorators/SwaggerCustomizer.ts +97 -97
  71. package/src/decorators/SwaggerExample.ts +180 -180
  72. package/src/decorators/TypedBody.ts +57 -57
  73. package/src/decorators/TypedException.ts +147 -147
  74. package/src/decorators/TypedFormData.ts +187 -187
  75. package/src/decorators/TypedHeaders.ts +66 -66
  76. package/src/decorators/TypedParam.ts +77 -77
  77. package/src/decorators/TypedQuery.ts +234 -234
  78. package/src/decorators/TypedRoute.ts +198 -196
  79. package/src/decorators/WebSocketRoute.ts +242 -242
  80. package/src/decorators/doNotThrowTransformError.ts +5 -5
  81. package/src/decorators/internal/EncryptedConstant.ts +2 -2
  82. package/src/decorators/internal/IMcpRouteReflect.ts +40 -0
  83. package/src/decorators/internal/IWebSocketRouteReflect.ts +23 -23
  84. package/src/decorators/internal/get_path_and_querify.ts +94 -94
  85. package/src/decorators/internal/get_path_and_stringify.ts +110 -110
  86. package/src/decorators/internal/get_text_body.ts +16 -16
  87. package/src/decorators/internal/headers_to_object.ts +11 -11
  88. package/src/decorators/internal/is_request_body_undefined.ts +12 -12
  89. package/src/decorators/internal/load_controller.ts +91 -76
  90. package/src/decorators/internal/route_error.ts +43 -43
  91. package/src/decorators/internal/validate_request_body.ts +64 -64
  92. package/src/decorators/internal/validate_request_form_data.ts +67 -67
  93. package/src/decorators/internal/validate_request_headers.ts +76 -76
  94. package/src/decorators/internal/validate_request_query.ts +83 -83
  95. package/src/index.ts +5 -5
  96. package/src/module.ts +25 -23
  97. package/src/options/IRequestBodyValidator.ts +20 -20
  98. package/src/options/IRequestFormDataProps.ts +27 -27
  99. package/src/options/IRequestHeadersValidator.ts +22 -22
  100. package/src/options/IRequestQueryValidator.ts +20 -20
  101. package/src/options/IResponseBodyQuerifier.ts +25 -25
  102. package/src/options/IResponseBodyStringifier.ts +30 -30
  103. package/src/transform.ts +101 -101
  104. package/src/typings/Creator.ts +3 -3
  105. package/src/typings/get-function-location.d.ts +7 -7
  106. package/src/utils/ArrayUtil.ts +7 -7
  107. package/src/utils/ExceptionManager.ts +115 -115
  108. package/src/utils/Singleton.ts +16 -16
  109. package/src/utils/SourceFinder.ts +54 -54
  110. package/src/utils/VersioningStrategy.ts +27 -27
  111. package/native/transform/cleanup_test.go +0 -76
  112. package/native/transform/commonjs_import_alias_test.go +0 -49
  113. package/native/transform/core_dispatch_test.go +0 -127
  114. package/native/transform/path_rewrite_test.go +0 -243
  115. package/native/transform/rewrite_test.go +0 -118
  116. package/native/transform/rewrite_unique_base_test.go +0 -48
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Jeongho Nam
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Jeongho Nam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/MIGRATION.md CHANGED
@@ -1,169 +1,169 @@
1
- # Migration: Go-backed transform
2
-
3
- > [!NOTE]
4
- > This guide covers the **`@next`** line of Nestia, which runs on
5
- > TypeScript-Go (`@typescript/native-preview`) hosted by `ttsc`. For the
6
- > stable, stock-TypeScript v6 transform path, follow
7
- > [setup](https://nestia.io/docs/setup) instead.
8
-
9
- Nestia replaces the TypeScript-side transformer pipeline with a Go-backed binary (`ttsc-nestia`) hosted by `ttsc`. Public decorator APIs are unchanged; only your build configuration and tool chain change.
10
-
11
- ## What stayed the same
12
-
13
- - All `@TypedBody`, `@TypedRoute`, `@TypedQuery`, `@TypedHeaders`, `@TypedParam`, `@TypedException`, `@TypedFormData`, `@PlainBody`, `@HumanRoute`, `@EncryptedBody`, `@EncryptedRoute`, `@EncryptedController`, `@EncryptedModule`, `@SwaggerCustomizer`, `@SwaggerExample`, `@WebSocketRoute`, `WebSocketAdaptor`, `DynamicModule`, `ExceptionManager`, `doNotThrowTransformError` — identical signatures.
14
- - All `IRequest*Validator` / `IResponse*Querifier` / `IResponse*Stringifier` runtime option interfaces — identical shapes.
15
- - `INestiaConfig` shape, `nestia.config.ts` lookup, and the CLI subcommands (`start`, `template`, `setup`, `dependencies`, `init`, `sdk`, `swagger`, `e2e`, `all`).
16
-
17
- ## What changed
18
-
19
- ### 1. `tsconfig.json` plugin entry
20
-
21
- ```diff
22
- {
23
- "compilerOptions": {
24
- "plugins": [
25
- - { "transform": "@nestia/core/lib/transform" },
26
- + { "transform": "@nestia/core/native/transform.cjs" }
27
- ]
28
- }
29
- }
30
- ```
31
-
32
- ### 2. Build command — `ttsc`, not `tsc`
33
-
34
- The Go binary is hosted by [`ttsc`](https://www.npmjs.com/package/ttsc), a TypeScript-Go compiler driver. Stock `tsc` cannot host Go plugins.
35
-
36
- ```diff
37
- {
38
- "scripts": {
39
- - "build": "tsc"
40
- + "build": "ttsc"
41
- }
42
- }
43
- ```
44
-
45
- ### 3. Dependencies
46
-
47
- Keep `@nestia/core`, `@nestia/fetcher`, and `typia` as runtime dependencies.
48
- **`@nestia/sdk` is now a runtime dependency too** — the Go binary needs to
49
- resolve it to attach SDK / Swagger / e2e metadata, and projects that serve
50
- runtime Swagger via `NestiaSwaggerComposer` already needed it at runtime.
51
- Install `ttsc` and `@typescript/native-preview` as devDependencies, and remove
52
- `ts-patch` and `typia patch` postinstalls — they are no longer used.
53
-
54
- ```diff
55
- {
56
- "dependencies": {
57
- + "@nestia/sdk": "^11.2.0"
58
- },
59
- "devDependencies": {
60
- - "ts-patch": "...",
61
- - "@nestia/sdk": "...",
62
- + "ttsc": "^0.10.2",
63
- + "@typescript/native-preview": "..."
64
- },
65
- "scripts": {
66
- - "prepare": "ts-patch install && typia patch",
67
- "build": "ttsc"
68
- }
69
- }
70
- ```
71
-
72
- ### 4. TypeScript-Go preview pin
73
-
74
- The Go binary hash-locks to a specific TypeScript-Go upstream commit, surfaced through `@typescript/native-preview`. Loose ranges may drift the AST contract.
75
-
76
- ```diff
77
- - "typescript": "^5.6.0"
78
- + "@typescript/native-preview": "7.0.0-dev.20260505.1"
79
- ```
80
-
81
- The legacy `typescript` package is no longer required at runtime; keep it only if your editor language service needs it.
82
-
83
- ### 5. `npx nestia setup` no longer writes `tsconfig.json` plugins
84
-
85
- The wizard still exists — `npx nestia setup` installs the new dep / devDep
86
- split (`ttsc` + `@typescript/native-preview` as devDependencies; `typia`,
87
- `@nestia/core`, `@nestia/sdk`, `@nestia/fetcher` as dependencies; `nestia` as
88
- devDependency). It no longer touches `tsconfig.json` or runs `ts-patch`,
89
- because `ttsc` auto-discovers the Nestia transform from each package's
90
- `package.json#ttsc.plugin` block.
91
-
92
- You only need `compilerOptions.plugins` if you want to override transform
93
- options (`stringify`, `llm`, etc.) — see §6.
94
-
95
- ### 6. Optional plugin composition order
96
-
97
- If you do choose to register plugins manually (for example, to pass
98
- `stringify` or `llm` options), the recommended shape is: typia (host
99
- tombstone) → `@nestia/sdk/lib/transform` → `@nestia/core/native/transform.cjs`.
100
- The `typia` entry stays with `enabled: false` — typia runs inside the Go
101
- binary, but tooling may still inspect the entry.
102
-
103
- ```jsonc
104
- "plugins": [
105
- { "transform": "typia/lib/transform", "enabled": false },
106
- { "transform": "@nestia/sdk/lib/transform" },
107
- { "transform": "@nestia/core/native/transform.cjs" }
108
- ]
109
- ```
110
-
111
- `@nestia/sdk` ships its plugin as `lib/transform` (a thin descriptor) while `@nestia/core` ships `native/transform.cjs` (the Go binary host). The asymmetry is intentional: the Go binary inside `transform.cjs` recognizes an SDK descriptor by name and runs both transforms in one compiler pass via `composes`, so plugin order in the array does not matter.
112
-
113
- ### 7. Internal symbols removed
114
-
115
- The `INestiaTransformOptions`, `INestiaTransformProject`, `PlainBodyProgrammer`, `TypedBodyProgrammer`, and the `programmers/` / `transformers/` directories were deleted. None were exported from `module.ts`; if your code imported them via deep paths it must be rewritten against the new pipeline or migrated to `@nestia/factory`.
116
-
117
- ### 8. `@nestia/factory` is a new published package
118
-
119
- `@nestia/factory` provides a printer-compatible TypeScript AST factory used by `@nestia/sdk` and `@nestia/migrate`. Third-party code generators that previously reached into `@nestia/core`'s internal `factories/` can depend on `@nestia/factory` directly. The surface tracks internal needs but is publicly consumable.
120
-
121
- ### 9. Runtime requirement: Go 1.26+ on PATH
122
-
123
- Until prebuilt binaries are distributed via optional npm dependencies, the local toolchain must have Go 1.26+ available. CI runners typically have Go preinstalled on Ubuntu images; for deterministic builds, add `actions/setup-go@v5` with `go-version-file: packages/core/native/go.mod` to your workflows.
124
-
125
- ### 10. Diagnostic format
126
-
127
- Compilation failures now surface through `ttsc-nestia: ...` stderr. The `NoTransformConfigurationError` thrown at runtime points back to this document and to https://nestia.io/docs/setup.
128
-
129
- ### 11. Optional cache profiling: `TTSC_NESTIA_PROFILE`
130
-
131
- Set `TTSC_NESTIA_PROFILE=1` before running `ttsc` to print per-pass cache hit / miss counters to stderr:
132
-
133
- ```bash
134
- TTSC_NESTIA_PROFILE=1 ttsc
135
- ```
136
-
137
- ```
138
- ttsc-nestia profile: core-cache hits=1024 misses=234
139
- ttsc-nestia profile: sdk-cache hits=567 misses=89
140
- ```
141
-
142
- Informational only — the counters do not affect compilation output or exit code. Useful when investigating large-codebase build times.
143
-
144
- ### 12. Panic stack opt-in: `NESTIA_NATIVE_DEBUG_STACK`
145
-
146
- If the Go binary aborts with `nestia.internal.panic`, set `NESTIA_NATIVE_DEBUG_STACK=1` to also print the full Go stack alongside the diagnostic. Off by default to keep build output clean; turn it on only when reproducing a panic for triage.
147
-
148
- ## Quickest upgrade recipe
149
-
150
- ```bash
151
- # 1. Drop the old patch chain
152
- npm uninstall ts-patch
153
-
154
- # 2. Reinstall dependencies in the new order. The runtime set matches what
155
- # `npx nestia setup` installs, plus `@nestia/e2e` for projects that emit
156
- # the generated e2e bundle (`npx nestia dependencies` adds it separately).
157
- npm i -D ttsc @typescript/native-preview
158
- npm i typia
159
- npm i @nestia/core @nestia/sdk @nestia/e2e @nestia/fetcher
160
- npm i -D nestia
161
-
162
- # 3. Update the build script (see §2)
163
- # Optional: if you registered plugins manually, update the entries (§6)
164
-
165
- # 4. Build
166
- npm run build
167
- ```
168
-
169
- If `ttsc` exits with `failed to compile`, run `npx ttsc -p tsconfig.json` directly to see the underlying `ttsc-nestia: ...` stderr diagnostic (this is the same output the SDK and CLI consume).
1
+ # Migration: Go-backed transform
2
+
3
+ > [!NOTE]
4
+ > This guide covers the **`@next`** line of Nestia, which runs on
5
+ > TypeScript-Go (`@typescript/native-preview`) hosted by `ttsc`. For the
6
+ > stable, stock-TypeScript v6 transform path, follow
7
+ > [setup](https://nestia.io/docs/setup) instead.
8
+
9
+ Nestia replaces the TypeScript-side transformer pipeline with a Go-backed binary (`ttsc-nestia`) hosted by `ttsc`. Public decorator APIs are unchanged; only your build configuration and tool chain change.
10
+
11
+ ## What stayed the same
12
+
13
+ - All `@TypedBody`, `@TypedRoute`, `@TypedQuery`, `@TypedHeaders`, `@TypedParam`, `@TypedException`, `@TypedFormData`, `@PlainBody`, `@HumanRoute`, `@EncryptedBody`, `@EncryptedRoute`, `@EncryptedController`, `@EncryptedModule`, `@SwaggerCustomizer`, `@SwaggerExample`, `@WebSocketRoute`, `WebSocketAdaptor`, `DynamicModule`, `ExceptionManager`, `doNotThrowTransformError` — identical signatures.
14
+ - All `IRequest*Validator` / `IResponse*Querifier` / `IResponse*Stringifier` runtime option interfaces — identical shapes.
15
+ - `INestiaConfig` shape, `nestia.config.ts` lookup, and the CLI subcommands (`start`, `template`, `setup`, `dependencies`, `init`, `sdk`, `swagger`, `e2e`, `all`).
16
+
17
+ ## What changed
18
+
19
+ ### 1. `tsconfig.json` plugin entry
20
+
21
+ ```diff
22
+ {
23
+ "compilerOptions": {
24
+ "plugins": [
25
+ - { "transform": "@nestia/core/lib/transform" },
26
+ + { "transform": "@nestia/core/native/transform.cjs" }
27
+ ]
28
+ }
29
+ }
30
+ ```
31
+
32
+ ### 2. Build command — `ttsc`, not `tsc`
33
+
34
+ The Go binary is hosted by [`ttsc`](https://www.npmjs.com/package/ttsc), a TypeScript-Go compiler driver. Stock `tsc` cannot host Go plugins.
35
+
36
+ ```diff
37
+ {
38
+ "scripts": {
39
+ - "build": "tsc"
40
+ + "build": "ttsc"
41
+ }
42
+ }
43
+ ```
44
+
45
+ ### 3. Dependencies
46
+
47
+ Keep `@nestia/core`, `@nestia/fetcher`, and `typia` as runtime dependencies.
48
+ **`@nestia/sdk` is now a runtime dependency too** — the Go binary needs to
49
+ resolve it to attach SDK / Swagger / e2e metadata, and projects that serve
50
+ runtime Swagger via `NestiaSwaggerComposer` already needed it at runtime.
51
+ Install `ttsc` and `@typescript/native-preview` as devDependencies, and remove
52
+ `ts-patch` and `typia patch` postinstalls — they are no longer used.
53
+
54
+ ```diff
55
+ {
56
+ "dependencies": {
57
+ + "@nestia/sdk": "^11.2.0"
58
+ },
59
+ "devDependencies": {
60
+ - "ts-patch": "...",
61
+ - "@nestia/sdk": "...",
62
+ + "ttsc": "^0.10.2",
63
+ + "@typescript/native-preview": "..."
64
+ },
65
+ "scripts": {
66
+ - "prepare": "ts-patch install && typia patch",
67
+ "build": "ttsc"
68
+ }
69
+ }
70
+ ```
71
+
72
+ ### 4. TypeScript-Go preview pin
73
+
74
+ The Go binary hash-locks to a specific TypeScript-Go upstream commit, surfaced through `@typescript/native-preview`. Loose ranges may drift the AST contract.
75
+
76
+ ```diff
77
+ - "typescript": "^5.6.0"
78
+ + "@typescript/native-preview": "7.0.0-dev.20260505.1"
79
+ ```
80
+
81
+ The legacy `typescript` package is no longer required at runtime; keep it only if your editor language service needs it.
82
+
83
+ ### 5. `npx nestia setup` no longer writes `tsconfig.json` plugins
84
+
85
+ The wizard still exists — `npx nestia setup` installs the new dep / devDep
86
+ split (`ttsc` + `@typescript/native-preview` as devDependencies; `typia`,
87
+ `@nestia/core`, `@nestia/sdk`, `@nestia/fetcher` as dependencies; `nestia` as
88
+ devDependency). It no longer touches `tsconfig.json` or runs `ts-patch`,
89
+ because `ttsc` auto-discovers the Nestia transform from each package's
90
+ `package.json#ttsc.plugin` block.
91
+
92
+ You only need `compilerOptions.plugins` if you want to override transform
93
+ options (`stringify`, `llm`, etc.) — see §6.
94
+
95
+ ### 6. Optional plugin composition order
96
+
97
+ If you do choose to register plugins manually (for example, to pass
98
+ `stringify` or `llm` options), the recommended shape is: typia (host
99
+ tombstone) → `@nestia/sdk/lib/transform` → `@nestia/core/native/transform.cjs`.
100
+ The `typia` entry stays with `enabled: false` — typia runs inside the Go
101
+ binary, but tooling may still inspect the entry.
102
+
103
+ ```jsonc
104
+ "plugins": [
105
+ { "transform": "typia/lib/transform", "enabled": false },
106
+ { "transform": "@nestia/sdk/lib/transform" },
107
+ { "transform": "@nestia/core/native/transform.cjs" }
108
+ ]
109
+ ```
110
+
111
+ `@nestia/sdk` ships its plugin as `lib/transform` (a thin descriptor) while `@nestia/core` ships `native/transform.cjs` (the Go binary host). The asymmetry is intentional: the Go binary inside `transform.cjs` recognizes an SDK descriptor by name and runs both transforms in one compiler pass via `composes`, so plugin order in the array does not matter.
112
+
113
+ ### 7. Internal symbols removed
114
+
115
+ The `INestiaTransformOptions`, `INestiaTransformProject`, `PlainBodyProgrammer`, `TypedBodyProgrammer`, and the `programmers/` / `transformers/` directories were deleted. None were exported from `module.ts`; if your code imported them via deep paths it must be rewritten against the new pipeline or migrated to `@nestia/factory`.
116
+
117
+ ### 8. `@nestia/factory` is a new published package
118
+
119
+ `@nestia/factory` provides a printer-compatible TypeScript AST factory used by `@nestia/sdk` and `@nestia/migrate`. Third-party code generators that previously reached into `@nestia/core`'s internal `factories/` can depend on `@nestia/factory` directly. The surface tracks internal needs but is publicly consumable.
120
+
121
+ ### 9. Runtime requirement: Go 1.26+ on PATH
122
+
123
+ Until prebuilt binaries are distributed via optional npm dependencies, the local toolchain must have Go 1.26+ available. CI runners typically have Go preinstalled on Ubuntu images; for deterministic builds, add `actions/setup-go@v5` with `go-version-file: packages/core/native/go.mod` to your workflows.
124
+
125
+ ### 10. Diagnostic format
126
+
127
+ Compilation failures now surface through `ttsc-nestia: ...` stderr. The `NoTransformConfigurationError` thrown at runtime points back to this document and to https://nestia.io/docs/setup.
128
+
129
+ ### 11. Optional cache profiling: `TTSC_NESTIA_PROFILE`
130
+
131
+ Set `TTSC_NESTIA_PROFILE=1` before running `ttsc` to print per-pass cache hit / miss counters to stderr:
132
+
133
+ ```bash
134
+ TTSC_NESTIA_PROFILE=1 ttsc
135
+ ```
136
+
137
+ ```
138
+ ttsc-nestia profile: core-cache hits=1024 misses=234
139
+ ttsc-nestia profile: sdk-cache hits=567 misses=89
140
+ ```
141
+
142
+ Informational only — the counters do not affect compilation output or exit code. Useful when investigating large-codebase build times.
143
+
144
+ ### 12. Panic stack opt-in: `NESTIA_NATIVE_DEBUG_STACK`
145
+
146
+ If the Go binary aborts with `nestia.internal.panic`, set `NESTIA_NATIVE_DEBUG_STACK=1` to also print the full Go stack alongside the diagnostic. Off by default to keep build output clean; turn it on only when reproducing a panic for triage.
147
+
148
+ ## Quickest upgrade recipe
149
+
150
+ ```bash
151
+ # 1. Drop the old patch chain
152
+ npm uninstall ts-patch
153
+
154
+ # 2. Reinstall dependencies in the new order. The runtime set matches what
155
+ # `npx nestia setup` installs, plus `@nestia/e2e` for projects that emit
156
+ # the generated e2e bundle (`npx nestia dependencies` adds it separately).
157
+ npm i -D ttsc @typescript/native-preview
158
+ npm i typia
159
+ npm i @nestia/core @nestia/sdk @nestia/e2e @nestia/fetcher
160
+ npm i -D nestia
161
+
162
+ # 3. Update the build script (see §2)
163
+ # Optional: if you registered plugins manually, update the entries (§6)
164
+
165
+ # 4. Build
166
+ npm run build
167
+ ```
168
+
169
+ If `ttsc` exits with `failed to compile`, run `npx ttsc -p tsconfig.json` directly to see the underlying `ttsc-nestia: ...` stderr diagnostic (this is the same output the SDK and CLI consume).
package/README.md CHANGED
@@ -1,93 +1,93 @@
1
- # Nestia
2
- ![Nestia Logo](https://nestia.io/logo.png)
3
-
4
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/nestia/blob/master/LICENSE)
5
- [![npm version](https://img.shields.io/npm/v/@nestia/fetcher.svg)](https://www.npmjs.com/package/@nestia/fetcher)
6
- [![Downloads](https://img.shields.io/npm/dm/@nestia/fetcher.svg)](https://www.npmjs.com/package/@nestia/fetcher)
7
- [![Build Status](https://github.com/samchon/nestia/workflows/test/badge.svg)](https://github.com/samchon/nestia/actions?query=workflow%3Atest)
8
- [![Guide Documents](https://img.shields.io/badge/Guide-Documents-forestgreen)](https://nestia.io/docs/)
9
- [![Gurubase](https://img.shields.io/badge/Gurubase-Document%20Chatbot-006BFF)](https://gurubase.io/g/nestia)
10
- [![Discord Badge](https://img.shields.io/badge/discord-samchon-d91965?style=flat&labelColor=5866f2&logo=discord&logoColor=white&link=https://discord.gg/E94XhzrUCZ)](https://discord.gg/E94XhzrUCZ)
11
-
12
- Nestia is a set of helper libraries for NestJS, supporting below features:
13
-
14
- - `@nestia/core`:
15
- - Super-fast/easy decorators
16
- - Advanced WebSocket routes
17
- - `@nestia/sdk`:
18
- - Swagger generator, more evolved than ever
19
- - SDK library generator for clients
20
- - Mockup Simulator for client applications
21
- - Automatic E2E test functions generator
22
- - `@nestia/e2e`: Test program utilizing e2e test functions
23
- - `@nestia/benchmark`: Benchmark program using e2e test functions
24
- - `@nestia/editor`: Swagger-UI with Online TypeScript Editor
25
- - [`@agentica`](https://github.com/wrtnlabs/agentica): Agentic AI library specialized in LLM function calling
26
- - [`@autobe`](https://github.com/wrtnlabs/autobe): Vibe coding agent generating NestJS application
27
- - `nestia`: Just CLI (command line interface) tool
28
-
29
- > [!NOTE]
30
- >
31
- > - **Only one line** required, with pure TypeScript type
32
- > - Enhance performance **30x** up
33
- > - Runtime validator is **20,000x faster** than `class-validator`
34
- > - JSON serialization is **200x faster** than `class-transformer`
35
- > - Software Development Kit
36
- > - Collection of typed `fetch` functions with DTO structures like [tRPC](https://trpc.io/)
37
- > - Mockup simulator means embedded backend simulator in the SDK
38
- > - similar with [msw](https://mswjs.io/), but fully automated
39
-
40
- ![nestia-sdk-demo](https://user-images.githubusercontent.com/13158709/215004990-368c589d-7101-404e-b81b-fbc936382f05.gif)
41
-
42
- > Left is NestJS server code, and right is client (frontend) code utilizing SDK
43
-
44
-
45
-
46
-
47
- ## Sponsors and Backers
48
- Thanks for your support.
49
-
50
- Your donation would encourage `nestia` development.
51
-
52
- [![Backers](https://opencollective.com/nestia/backers.svg?avatarHeight=75&width=600)](https://opencollective.com/nestia)
53
-
54
-
55
-
56
-
57
- ## Guide Documents
58
- Check out the document in the [website](https://nestia.io/docs/):
59
-
60
- ### 🏠 Home
61
- - [Introduction](https://nestia.io/docs/)
62
- - [Setup](https://nestia.io/docs/setup/)
63
- - [Pure TypeScript](https://nestia.io/docs/pure)
64
-
65
- ### 📖 Features
66
- - Core Library
67
- - [`@WebSocketRoute`](https://nestia.io/docs/core/WebSocketRoute)
68
- - [`@TypedRoute`](https://nestia.io/docs/core/TypedRoute/)
69
- - [**`@TypedBody`**](https://nestia.io/docs/core/TypedBody/)
70
- - [`@TypedParam`](https://nestia.io/docs/core/TypedParam/)
71
- - [`@TypedQuery`](https://nestia.io/docs/core/TypedQuery/)
72
- - [`@TypedFormData`](https://nestia.io/docs/core/TypedFormData/)
73
- - [`@TypedHeaders`](https://nestia.io/docs/core/TypedHeaders/)
74
- - [`@TypedException`](https://nestia.io/docs/core/TypedException/)
75
- - Software Development Kit
76
- - [SDK Builder](https://nestia.io/docs/sdk/)
77
- - [Mockup Simulator](https://nestia.io/docs/sdk/simulate/)
78
- - [E2E Test Functions](https://nestia.io/docs/sdk/e2e/)
79
- - [Distribution](https://nestia.io/docs/sdk/distribute/)
80
- - Swagger Document
81
- - [Swagger Builder](https://nestia.io/docs/swagger/)
82
- - [**AI Chatbot Development**](https://nestia.io/docs/swagger/chat/)
83
- - [Cloud Swagger Editor](https://nestia.io/docs/swagger/editor/)
84
- - [Documentation Strategy](https://nestia.io/docs/swagger/strategy/)
85
- - E2E Testing
86
- - [Why E2E Test?](https://nestia.io/docs/e2e/why/)
87
- - [Test Program Development](https://nestia.io/docs/e2e/development/)
88
- - [Performance Benchmark](https://nestia.io/docs/e2e/benchmark/)
89
-
90
- ### 🔗 Appendix
91
- - [API Documents](https://nestia.io/api)
92
- - [⇲ Benchmark Result](https://github.com/samchon/nestia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz)
93
- - [⇲ `dev.to` Articles](https://dev.to/samchon/series/22751)
1
+ # Nestia
2
+ ![Nestia Logo](https://nestia.io/logo.png)
3
+
4
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/nestia/blob/master/LICENSE)
5
+ [![npm version](https://img.shields.io/npm/v/@nestia/fetcher.svg)](https://www.npmjs.com/package/@nestia/fetcher)
6
+ [![Downloads](https://img.shields.io/npm/dm/@nestia/fetcher.svg)](https://www.npmjs.com/package/@nestia/fetcher)
7
+ [![Build Status](https://github.com/samchon/nestia/workflows/test/badge.svg)](https://github.com/samchon/nestia/actions?query=workflow%3Atest)
8
+ [![Guide Documents](https://img.shields.io/badge/Guide-Documents-forestgreen)](https://nestia.io/docs/)
9
+ [![Gurubase](https://img.shields.io/badge/Gurubase-Document%20Chatbot-006BFF)](https://gurubase.io/g/nestia)
10
+ [![Discord Badge](https://img.shields.io/badge/discord-samchon-d91965?style=flat&labelColor=5866f2&logo=discord&logoColor=white&link=https://discord.gg/E94XhzrUCZ)](https://discord.gg/E94XhzrUCZ)
11
+
12
+ Nestia is a set of helper libraries for NestJS, supporting below features:
13
+
14
+ - `@nestia/core`:
15
+ - Super-fast/easy decorators
16
+ - Advanced WebSocket routes
17
+ - `@nestia/sdk`:
18
+ - Swagger generator, more evolved than ever
19
+ - SDK library generator for clients
20
+ - Mockup Simulator for client applications
21
+ - Automatic E2E test functions generator
22
+ - `@nestia/e2e`: Test program utilizing e2e test functions
23
+ - `@nestia/benchmark`: Benchmark program using e2e test functions
24
+ - `@nestia/editor`: Swagger-UI with Online TypeScript Editor
25
+ - [`@agentica`](https://github.com/wrtnlabs/agentica): Agentic AI library specialized in LLM function calling
26
+ - [`@autobe`](https://github.com/wrtnlabs/autobe): Vibe coding agent generating NestJS application
27
+ - `nestia`: Just CLI (command line interface) tool
28
+
29
+ > [!NOTE]
30
+ >
31
+ > - **Only one line** required, with pure TypeScript type
32
+ > - Enhance performance **30x** up
33
+ > - Runtime validator is **20,000x faster** than `class-validator`
34
+ > - JSON serialization is **200x faster** than `class-transformer`
35
+ > - Software Development Kit
36
+ > - Collection of typed `fetch` functions with DTO structures like [tRPC](https://trpc.io/)
37
+ > - Mockup simulator means embedded backend simulator in the SDK
38
+ > - similar with [msw](https://mswjs.io/), but fully automated
39
+
40
+ ![nestia-sdk-demo](https://user-images.githubusercontent.com/13158709/215004990-368c589d-7101-404e-b81b-fbc936382f05.gif)
41
+
42
+ > Left is NestJS server code, and right is client (frontend) code utilizing SDK
43
+
44
+
45
+
46
+
47
+ ## Sponsors and Backers
48
+ Thanks for your support.
49
+
50
+ Your donation would encourage `nestia` development.
51
+
52
+ [![Backers](https://opencollective.com/nestia/backers.svg?avatarHeight=75&width=600)](https://opencollective.com/nestia)
53
+
54
+
55
+
56
+
57
+ ## Guide Documents
58
+ Check out the document in the [website](https://nestia.io/docs/):
59
+
60
+ ### 🏠 Home
61
+ - [Introduction](https://nestia.io/docs/)
62
+ - [Setup](https://nestia.io/docs/setup/)
63
+ - [Pure TypeScript](https://nestia.io/docs/pure)
64
+
65
+ ### 📖 Features
66
+ - Core Library
67
+ - [`@WebSocketRoute`](https://nestia.io/docs/core/WebSocketRoute)
68
+ - [`@TypedRoute`](https://nestia.io/docs/core/TypedRoute/)
69
+ - [**`@TypedBody`**](https://nestia.io/docs/core/TypedBody/)
70
+ - [`@TypedParam`](https://nestia.io/docs/core/TypedParam/)
71
+ - [`@TypedQuery`](https://nestia.io/docs/core/TypedQuery/)
72
+ - [`@TypedFormData`](https://nestia.io/docs/core/TypedFormData/)
73
+ - [`@TypedHeaders`](https://nestia.io/docs/core/TypedHeaders/)
74
+ - [`@TypedException`](https://nestia.io/docs/core/TypedException/)
75
+ - Software Development Kit
76
+ - [SDK Builder](https://nestia.io/docs/sdk/)
77
+ - [Mockup Simulator](https://nestia.io/docs/sdk/simulate/)
78
+ - [E2E Test Functions](https://nestia.io/docs/sdk/e2e/)
79
+ - [Distribution](https://nestia.io/docs/sdk/distribute/)
80
+ - Swagger Document
81
+ - [Swagger Builder](https://nestia.io/docs/swagger/)
82
+ - [**AI Chatbot Development**](https://nestia.io/docs/swagger/chat/)
83
+ - [Cloud Swagger Editor](https://nestia.io/docs/swagger/editor/)
84
+ - [Documentation Strategy](https://nestia.io/docs/swagger/strategy/)
85
+ - E2E Testing
86
+ - [Why E2E Test?](https://nestia.io/docs/e2e/why/)
87
+ - [Test Program Development](https://nestia.io/docs/e2e/development/)
88
+ - [Performance Benchmark](https://nestia.io/docs/e2e/benchmark/)
89
+
90
+ ### 🔗 Appendix
91
+ - [API Documents](https://nestia.io/api)
92
+ - [⇲ Benchmark Result](https://github.com/samchon/nestia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz)
93
+ - [⇲ `dev.to` Articles](https://dev.to/samchon/series/22751)
@@ -0,0 +1,75 @@
1
+ import { INestApplication } from "@nestjs/common";
2
+ /**
3
+ * MCP (Model Context Protocol) adaptor.
4
+ *
5
+ * `McpAdaptor` exposes every method decorated with {@link McpRoute} as an MCP
6
+ * tool, reachable by LLM clients through a stateless Streamable HTTP endpoint.
7
+ *
8
+ * At bootstrap the adaptor walks the {@link NestContainer}, collects every
9
+ * controller method carrying `"nestia/McpRoute"` metadata, and caches a tool
10
+ * registry. A fresh MCP server and transport pair is spun up per incoming HTTP
11
+ * request, following MCP stateless Streamable HTTP mode. This adaptor
12
+ * intentionally does not manage `Mcp-Session-Id` state.
13
+ *
14
+ * Typia-generated JSON Schemas flow through unchanged; the Zod-based high-level
15
+ * registration API of `McpServer` is bypassed by accessing the low-level
16
+ * `.server` handler.
17
+ *
18
+ * Error mapping follows the MCP specification:
19
+ *
20
+ * - Unknown tool name: JSON-RPC `-32601`.
21
+ * - Typia validation failure: JSON-RPC `-32602` with structured diagnostics.
22
+ * - Handler throws {@link HttpException}: success response with `isError: true`,
23
+ * so the LLM can read the message and recover.
24
+ * - Any other throw: JSON-RPC `-32603`.
25
+ *
26
+ * @author wildduck - https://github.com/wildduck2
27
+ * @example
28
+ * ```typescript
29
+ * import core from "@nestia/core";
30
+ * import { NestFactory } from "@nestjs/core";
31
+ *
32
+ * const app = await NestFactory.create(AppModule);
33
+ * await core.McpAdaptor.upgrade(app, { path: "/mcp" });
34
+ * await app.listen(3000);
35
+ * ```;
36
+ */
37
+ export declare class McpAdaptor {
38
+ /**
39
+ * Upgrade a running Nest application with a stateless MCP endpoint.
40
+ *
41
+ * Scans the application container for methods decorated with {@link McpRoute},
42
+ * then registers a catch-all HTTP route at the configured path. Each incoming
43
+ * request builds a fresh MCP server + transport on demand, wires the
44
+ * registered tools into it, and delegates handling.
45
+ *
46
+ * Must be called after `NestFactory.create(...)` but before `app.listen(...)`
47
+ * if you want the MCP endpoint to be reachable alongside your regular HTTP
48
+ * routes.
49
+ *
50
+ * @param app Running Nest application instance.
51
+ * @param options Transport and identity overrides.
52
+ */
53
+ static upgrade(app: INestApplication, options?: McpAdaptor.IOptions): Promise<void>;
54
+ }
55
+ export declare namespace McpAdaptor {
56
+ /** Configuration options for {@link McpAdaptor.upgrade}. */
57
+ interface IOptions {
58
+ /**
59
+ * HTTP path where the MCP endpoint will be mounted.
60
+ *
61
+ * @default "/mcp"
62
+ */
63
+ path?: string;
64
+ /**
65
+ * Identity advertised to MCP clients during the initialize handshake. Shows
66
+ * up in Claude Desktop / Cursor's MCP panel.
67
+ *
68
+ * @default { name: "nestia-mcp", version: "1.0.0" }
69
+ */
70
+ serverInfo?: {
71
+ name: string;
72
+ version: string;
73
+ };
74
+ }
75
+ }