@nestia/core 12.0.0-dev.20260521.6 → 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 -437
  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 -387
  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
@@ -1,73 +1,73 @@
1
- package transform
2
-
3
- import (
4
- "fmt"
5
- "io"
6
- "os"
7
- "runtime/debug"
8
- )
9
-
10
- var (
11
- stdout io.Writer = os.Stdout
12
- stderr io.Writer = os.Stderr
13
- )
14
-
15
- // Run wraps run() in a panic recovery envelope so that any unexpected
16
- // panic surfaces as a one-line transform-diagnostic on stderr instead of
17
- // a multi-line raw Go stack trace. The diagnostic uses the same `<file> -
18
- // error TS(code): message` shape as every other nestia / typia diagnostic;
19
- // ttsc reads it via `error.stderr` (`RuntimeCompiler.compile` at
20
- // `ConfigAnalyzer.ts:170-174`) rather than its structured-diagnostic regex,
21
- // which is a pre-existing protocol shared by all `nestia.*` codes. The
22
- // full stack is preserved behind NESTIA_NATIVE_DEBUG_STACK for triage.
23
- //
24
- // This is the `@nestia/core` plugin entry point. It performs typia and core
25
- // decorator rewrites, then runs any statically linked contributor rewrite
26
- // collectors such as the SDK metadata pass when the caller explicitly enables
27
- // them.
28
- func Run(args []string) (code int) {
29
- defer func() {
30
- if exp := recover(); exp != nil {
31
- diag := Diagnostic{
32
- Code: "nestia.internal.panic",
33
- Message: fmt.Sprintf("ttsc-nestia panicked: %v", exp),
34
- }
35
- WriteTypiaTransformDiagnostics(stderr, []Diagnostic{diag}, "")
36
- if os.Getenv("NESTIA_NATIVE_DEBUG_STACK") != "" {
37
- fmt.Fprintln(stderr, string(debug.Stack()))
38
- }
39
- code = 3
40
- }
41
- }()
42
- return run(args)
43
- }
44
-
45
- func run(args []string) int {
46
- if len(args) == 0 {
47
- return runHelp(nil)
48
- }
49
- command := args[0]
50
- rest := args[1:]
51
- switch command {
52
- case "build":
53
- return runBuild(rest)
54
- case "check":
55
- return runCheck(rest)
56
- case "transform":
57
- return runTransform(rest)
58
- case "version":
59
- fmt.Fprintln(stdout, "ttsc-nestia 0.1.0")
60
- return 0
61
- case "help", "-h", "--help":
62
- return runHelp(rest)
63
- default:
64
- fmt.Fprintf(stderr, "ttsc-nestia: unknown command %q\n", command)
65
- return 2
66
- }
67
- }
68
-
69
- func runHelp(args []string) int {
70
- _ = args
71
- fmt.Fprintln(stdout, "usage: ttsc-nestia <build|check|transform|version>")
72
- return 0
73
- }
1
+ package transform
2
+
3
+ import (
4
+ "fmt"
5
+ "io"
6
+ "os"
7
+ "runtime/debug"
8
+ )
9
+
10
+ var (
11
+ stdout io.Writer = os.Stdout
12
+ stderr io.Writer = os.Stderr
13
+ )
14
+
15
+ // Run wraps run() in a panic recovery envelope so that any unexpected
16
+ // panic surfaces as a one-line transform-diagnostic on stderr instead of
17
+ // a multi-line raw Go stack trace. The diagnostic uses the same `<file> -
18
+ // error TS(code): message` shape as every other nestia / typia diagnostic;
19
+ // ttsc reads it via `error.stderr` (`RuntimeCompiler.compile` at
20
+ // `ConfigAnalyzer.ts:170-174`) rather than its structured-diagnostic regex,
21
+ // which is a pre-existing protocol shared by all `nestia.*` codes. The
22
+ // full stack is preserved behind NESTIA_NATIVE_DEBUG_STACK for triage.
23
+ //
24
+ // This is the `@nestia/core` plugin entry point. It performs typia and core
25
+ // decorator rewrites, then runs any statically linked contributor rewrite
26
+ // collectors such as the SDK metadata pass when the caller explicitly enables
27
+ // them.
28
+ func Run(args []string) (code int) {
29
+ defer func() {
30
+ if exp := recover(); exp != nil {
31
+ diag := Diagnostic{
32
+ Code: "nestia.internal.panic",
33
+ Message: fmt.Sprintf("ttsc-nestia panicked: %v", exp),
34
+ }
35
+ WriteTypiaTransformDiagnostics(stderr, []Diagnostic{diag}, "")
36
+ if os.Getenv("NESTIA_NATIVE_DEBUG_STACK") != "" {
37
+ fmt.Fprintln(stderr, string(debug.Stack()))
38
+ }
39
+ code = 3
40
+ }
41
+ }()
42
+ return run(args)
43
+ }
44
+
45
+ func run(args []string) int {
46
+ if len(args) == 0 {
47
+ return runHelp(nil)
48
+ }
49
+ command := args[0]
50
+ rest := args[1:]
51
+ switch command {
52
+ case "build":
53
+ return runBuild(rest)
54
+ case "check":
55
+ return runCheck(rest)
56
+ case "transform":
57
+ return runTransform(rest)
58
+ case "version":
59
+ fmt.Fprintln(stdout, "ttsc-nestia 0.1.0")
60
+ return 0
61
+ case "help", "-h", "--help":
62
+ return runHelp(rest)
63
+ default:
64
+ fmt.Fprintf(stderr, "ttsc-nestia: unknown command %q\n", command)
65
+ return 2
66
+ }
67
+ }
68
+
69
+ func runHelp(args []string) int {
70
+ _ = args
71
+ fmt.Fprintln(stdout, "usage: ttsc-nestia <build|check|transform|version>")
72
+ return 0
73
+ }