@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.
- package/LICENSE +21 -21
- package/MIGRATION.md +169 -169
- package/README.md +93 -93
- package/lib/adaptors/McpAdaptor.d.ts +75 -0
- package/lib/adaptors/McpAdaptor.js +257 -0
- package/lib/adaptors/McpAdaptor.js.map +1 -0
- package/lib/adaptors/WebSocketAdaptor.js +4 -4
- package/lib/adaptors/WebSocketAdaptor.js.map +1 -1
- package/lib/decorators/McpRoute.d.ts +69 -0
- package/lib/decorators/McpRoute.js +58 -0
- package/lib/decorators/McpRoute.js.map +1 -0
- package/lib/decorators/TypedParam.js +4 -4
- package/lib/decorators/TypedParam.js.map +1 -1
- package/lib/decorators/TypedRoute.js +1 -1
- package/lib/decorators/TypedRoute.js.map +1 -1
- package/lib/decorators/internal/IMcpRouteReflect.d.ts +2 -0
- package/lib/decorators/internal/IMcpRouteReflect.js +3 -0
- package/lib/decorators/internal/IMcpRouteReflect.js.map +1 -0
- package/lib/decorators/internal/get_path_and_querify.js +4 -4
- package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
- package/lib/decorators/internal/get_path_and_stringify.js +4 -4
- package/lib/decorators/internal/get_path_and_stringify.js.map +1 -1
- package/lib/decorators/internal/load_controller.js +34 -65
- package/lib/decorators/internal/load_controller.js.map +1 -1
- package/lib/decorators/internal/validate_request_body.js +4 -4
- package/lib/decorators/internal/validate_request_body.js.map +1 -1
- package/lib/decorators/internal/validate_request_form_data.js +4 -4
- package/lib/decorators/internal/validate_request_form_data.js.map +1 -1
- package/lib/decorators/internal/validate_request_headers.js +4 -4
- package/lib/decorators/internal/validate_request_headers.js.map +1 -1
- package/lib/decorators/internal/validate_request_query.js +4 -4
- package/lib/decorators/internal/validate_request_query.js.map +1 -1
- package/lib/module.d.ts +2 -0
- package/lib/module.js +2 -0
- package/lib/module.js.map +1 -1
- package/native/cmd/ttsc-nestia/main.go +11 -11
- package/native/go.mod +32 -32
- package/native/go.sum +54 -54
- package/native/plugin/plan.go +102 -102
- package/native/transform/ast.go +32 -32
- package/native/transform/build.go +380 -444
- package/native/transform/cleanup.go +408 -408
- package/native/transform/contributor.go +97 -68
- package/native/transform/core_querify.go +231 -227
- package/native/transform/core_transform.go +1996 -1713
- package/native/transform/core_websocket.go +115 -115
- package/native/transform/exports.go +13 -13
- package/native/transform/mcp_transform.go +414 -0
- package/native/transform/node_transform.go +357 -0
- package/native/transform/path_rewrite.go +285 -285
- package/native/transform/printer.go +244 -244
- package/native/transform/rewrite.go +668 -662
- package/native/transform/run.go +73 -73
- package/native/transform/transform.go +336 -403
- package/native/transform/typia_fast.go +352 -326
- package/native/transform/typia_replacement.go +24 -24
- package/native/transform.cjs +43 -43
- package/package.json +15 -8
- package/src/adaptors/McpAdaptor.ts +276 -0
- package/src/adaptors/WebSocketAdaptor.ts +429 -429
- package/src/decorators/DynamicModule.ts +44 -44
- package/src/decorators/EncryptedBody.ts +97 -97
- package/src/decorators/EncryptedController.ts +40 -40
- package/src/decorators/EncryptedModule.ts +98 -98
- package/src/decorators/EncryptedRoute.ts +213 -213
- package/src/decorators/HumanRoute.ts +21 -21
- package/src/decorators/McpRoute.ts +154 -0
- package/src/decorators/NoTransformConfigurationError.ts +40 -40
- package/src/decorators/PlainBody.ts +76 -76
- package/src/decorators/SwaggerCustomizer.ts +97 -97
- package/src/decorators/SwaggerExample.ts +180 -180
- package/src/decorators/TypedBody.ts +57 -57
- package/src/decorators/TypedException.ts +147 -147
- package/src/decorators/TypedFormData.ts +187 -187
- package/src/decorators/TypedHeaders.ts +66 -66
- package/src/decorators/TypedParam.ts +77 -77
- package/src/decorators/TypedQuery.ts +234 -234
- package/src/decorators/TypedRoute.ts +198 -196
- package/src/decorators/WebSocketRoute.ts +242 -242
- package/src/decorators/doNotThrowTransformError.ts +5 -5
- package/src/decorators/internal/EncryptedConstant.ts +2 -2
- package/src/decorators/internal/IMcpRouteReflect.ts +40 -0
- package/src/decorators/internal/IWebSocketRouteReflect.ts +23 -23
- package/src/decorators/internal/get_path_and_querify.ts +94 -94
- package/src/decorators/internal/get_path_and_stringify.ts +110 -110
- package/src/decorators/internal/get_text_body.ts +16 -16
- package/src/decorators/internal/headers_to_object.ts +11 -11
- package/src/decorators/internal/is_request_body_undefined.ts +12 -12
- package/src/decorators/internal/load_controller.ts +91 -76
- package/src/decorators/internal/route_error.ts +43 -43
- package/src/decorators/internal/validate_request_body.ts +64 -64
- package/src/decorators/internal/validate_request_form_data.ts +67 -67
- package/src/decorators/internal/validate_request_headers.ts +76 -76
- package/src/decorators/internal/validate_request_query.ts +83 -83
- package/src/index.ts +5 -5
- package/src/module.ts +25 -23
- package/src/options/IRequestBodyValidator.ts +20 -20
- package/src/options/IRequestFormDataProps.ts +27 -27
- package/src/options/IRequestHeadersValidator.ts +22 -22
- package/src/options/IRequestQueryValidator.ts +20 -20
- package/src/options/IResponseBodyQuerifier.ts +25 -25
- package/src/options/IResponseBodyStringifier.ts +30 -30
- package/src/transform.ts +101 -101
- package/src/typings/Creator.ts +3 -3
- package/src/typings/get-function-location.d.ts +7 -7
- package/src/utils/ArrayUtil.ts +7 -7
- package/src/utils/ExceptionManager.ts +115 -115
- package/src/utils/Singleton.ts +16 -16
- package/src/utils/SourceFinder.ts +54 -54
- package/src/utils/VersioningStrategy.ts +27 -27
- package/native/transform/cleanup_test.go +0 -76
- package/native/transform/commonjs_import_alias_test.go +0 -49
- package/native/transform/core_dispatch_test.go +0 -127
- package/native/transform/path_rewrite_test.go +0 -243
- package/native/transform/rewrite_test.go +0 -118
- package/native/transform/rewrite_unique_base_test.go +0 -48
package/native/plugin/plan.go
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
package plugin
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"encoding/json"
|
|
5
|
-
"fmt"
|
|
6
|
-
"strings"
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
const (
|
|
10
|
-
CoreNativeTransform = "@nestia/core/native/transform.cjs"
|
|
11
|
-
CoreTransform = "@nestia/core/lib/transform"
|
|
12
|
-
SDKNativeTransform = "@nestia/sdk/native/transform.cjs"
|
|
13
|
-
SDKTransform = "@nestia/sdk/lib/transform"
|
|
14
|
-
TypiaTransform = "typia/lib/transform"
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
type Entry struct {
|
|
18
|
-
Name string
|
|
19
|
-
Stage string
|
|
20
|
-
Transform string
|
|
21
|
-
Config map[string]any
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type Plan struct {
|
|
25
|
-
Core bool
|
|
26
|
-
SDK bool
|
|
27
|
-
Typia bool
|
|
28
|
-
Entries []Entry
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
func (p Plan) UsesNestia() bool {
|
|
32
|
-
return p.Core || p.SDK
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
func ParsePlan(payload string) (Plan, error) {
|
|
36
|
-
payload = strings.TrimSpace(payload)
|
|
37
|
-
if payload == "" {
|
|
38
|
-
return Plan{}, nil
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var raws []struct {
|
|
42
|
-
Name string `json:"name"`
|
|
43
|
-
Stage string `json:"stage"`
|
|
44
|
-
Config map[string]any `json:"config"`
|
|
45
|
-
}
|
|
46
|
-
if err := json.Unmarshal([]byte(payload), &raws); err != nil {
|
|
47
|
-
return Plan{}, fmt.Errorf("parse plugins-json: %w", err)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
plan := Plan{
|
|
51
|
-
Entries: make([]Entry, 0, len(raws)),
|
|
52
|
-
}
|
|
53
|
-
for _, raw := range raws {
|
|
54
|
-
stage := raw.Stage
|
|
55
|
-
if stage == "" {
|
|
56
|
-
stage = "transform"
|
|
57
|
-
}
|
|
58
|
-
transform := stringConfig(raw.Config, "transform")
|
|
59
|
-
entry := Entry{
|
|
60
|
-
Name: raw.Name,
|
|
61
|
-
Stage: stage,
|
|
62
|
-
Transform: transform,
|
|
63
|
-
Config: raw.Config,
|
|
64
|
-
}
|
|
65
|
-
plan.Entries = append(plan.Entries, entry)
|
|
66
|
-
kind := classify(entry)
|
|
67
|
-
plan.Core = plan.Core || kind == "core"
|
|
68
|
-
plan.SDK = plan.SDK || kind == "sdk"
|
|
69
|
-
plan.Typia = plan.Typia || kind == "typia"
|
|
70
|
-
}
|
|
71
|
-
return plan, nil
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
func classify(entry Entry) string {
|
|
75
|
-
name := strings.TrimSpace(entry.Name)
|
|
76
|
-
transform := strings.TrimSpace(entry.Transform)
|
|
77
|
-
switch {
|
|
78
|
-
case name == "@nestia/core" || transform == CoreTransform || transform == CoreNativeTransform:
|
|
79
|
-
return "core"
|
|
80
|
-
case name == "@nestia/sdk" || transform == SDKTransform || transform == SDKNativeTransform:
|
|
81
|
-
return "sdk"
|
|
82
|
-
case name == "typia" || transform == TypiaTransform:
|
|
83
|
-
return "typia"
|
|
84
|
-
default:
|
|
85
|
-
return ""
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
func stringConfig(config map[string]any, key string) string {
|
|
90
|
-
if config == nil {
|
|
91
|
-
return ""
|
|
92
|
-
}
|
|
93
|
-
value, ok := config[key]
|
|
94
|
-
if !ok {
|
|
95
|
-
return ""
|
|
96
|
-
}
|
|
97
|
-
text, ok := value.(string)
|
|
98
|
-
if !ok {
|
|
99
|
-
return ""
|
|
100
|
-
}
|
|
101
|
-
return text
|
|
102
|
-
}
|
|
1
|
+
package plugin
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"fmt"
|
|
6
|
+
"strings"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
const (
|
|
10
|
+
CoreNativeTransform = "@nestia/core/native/transform.cjs"
|
|
11
|
+
CoreTransform = "@nestia/core/lib/transform"
|
|
12
|
+
SDKNativeTransform = "@nestia/sdk/native/transform.cjs"
|
|
13
|
+
SDKTransform = "@nestia/sdk/lib/transform"
|
|
14
|
+
TypiaTransform = "typia/lib/transform"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
type Entry struct {
|
|
18
|
+
Name string
|
|
19
|
+
Stage string
|
|
20
|
+
Transform string
|
|
21
|
+
Config map[string]any
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type Plan struct {
|
|
25
|
+
Core bool
|
|
26
|
+
SDK bool
|
|
27
|
+
Typia bool
|
|
28
|
+
Entries []Entry
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
func (p Plan) UsesNestia() bool {
|
|
32
|
+
return p.Core || p.SDK
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
func ParsePlan(payload string) (Plan, error) {
|
|
36
|
+
payload = strings.TrimSpace(payload)
|
|
37
|
+
if payload == "" {
|
|
38
|
+
return Plan{}, nil
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var raws []struct {
|
|
42
|
+
Name string `json:"name"`
|
|
43
|
+
Stage string `json:"stage"`
|
|
44
|
+
Config map[string]any `json:"config"`
|
|
45
|
+
}
|
|
46
|
+
if err := json.Unmarshal([]byte(payload), &raws); err != nil {
|
|
47
|
+
return Plan{}, fmt.Errorf("parse plugins-json: %w", err)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
plan := Plan{
|
|
51
|
+
Entries: make([]Entry, 0, len(raws)),
|
|
52
|
+
}
|
|
53
|
+
for _, raw := range raws {
|
|
54
|
+
stage := raw.Stage
|
|
55
|
+
if stage == "" {
|
|
56
|
+
stage = "transform"
|
|
57
|
+
}
|
|
58
|
+
transform := stringConfig(raw.Config, "transform")
|
|
59
|
+
entry := Entry{
|
|
60
|
+
Name: raw.Name,
|
|
61
|
+
Stage: stage,
|
|
62
|
+
Transform: transform,
|
|
63
|
+
Config: raw.Config,
|
|
64
|
+
}
|
|
65
|
+
plan.Entries = append(plan.Entries, entry)
|
|
66
|
+
kind := classify(entry)
|
|
67
|
+
plan.Core = plan.Core || kind == "core"
|
|
68
|
+
plan.SDK = plan.SDK || kind == "sdk"
|
|
69
|
+
plan.Typia = plan.Typia || kind == "typia"
|
|
70
|
+
}
|
|
71
|
+
return plan, nil
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
func classify(entry Entry) string {
|
|
75
|
+
name := strings.TrimSpace(entry.Name)
|
|
76
|
+
transform := strings.TrimSpace(entry.Transform)
|
|
77
|
+
switch {
|
|
78
|
+
case name == "@nestia/core" || transform == CoreTransform || transform == CoreNativeTransform:
|
|
79
|
+
return "core"
|
|
80
|
+
case name == "@nestia/sdk" || transform == SDKTransform || transform == SDKNativeTransform:
|
|
81
|
+
return "sdk"
|
|
82
|
+
case name == "typia" || transform == TypiaTransform:
|
|
83
|
+
return "typia"
|
|
84
|
+
default:
|
|
85
|
+
return ""
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
func stringConfig(config map[string]any, key string) string {
|
|
90
|
+
if config == nil {
|
|
91
|
+
return ""
|
|
92
|
+
}
|
|
93
|
+
value, ok := config[key]
|
|
94
|
+
if !ok {
|
|
95
|
+
return ""
|
|
96
|
+
}
|
|
97
|
+
text, ok := value.(string)
|
|
98
|
+
if !ok {
|
|
99
|
+
return ""
|
|
100
|
+
}
|
|
101
|
+
return text
|
|
102
|
+
}
|
package/native/transform/ast.go
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
package transform
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"strings"
|
|
5
|
-
|
|
6
|
-
shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
// NodeName returns the trimmed identifier text of a named AST node
|
|
10
|
-
// (method, parameter, ...). Empty when the node has no name.
|
|
11
|
-
func NodeName(node *shimast.Node) string {
|
|
12
|
-
if node == nil || node.Name() == nil {
|
|
13
|
-
return ""
|
|
14
|
-
}
|
|
15
|
-
return strings.Trim(node.Name().Text(), "\"'")
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// NodeText returns the verbatim source slice spanned by a node.
|
|
19
|
-
func NodeText(node *shimast.Node) string {
|
|
20
|
-
if node == nil {
|
|
21
|
-
return ""
|
|
22
|
-
}
|
|
23
|
-
source, ok := SourceFileText(shimast.GetSourceFileOfNode(node))
|
|
24
|
-
if ok == false {
|
|
25
|
-
return ""
|
|
26
|
-
}
|
|
27
|
-
start, end := node.Pos(), node.End()
|
|
28
|
-
if start < 0 || end > len(source) || start >= end {
|
|
29
|
-
return ""
|
|
30
|
-
}
|
|
31
|
-
return strings.TrimSpace(source[start:end])
|
|
32
|
-
}
|
|
1
|
+
package transform
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"strings"
|
|
5
|
+
|
|
6
|
+
shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
// NodeName returns the trimmed identifier text of a named AST node
|
|
10
|
+
// (method, parameter, ...). Empty when the node has no name.
|
|
11
|
+
func NodeName(node *shimast.Node) string {
|
|
12
|
+
if node == nil || node.Name() == nil {
|
|
13
|
+
return ""
|
|
14
|
+
}
|
|
15
|
+
return strings.Trim(node.Name().Text(), "\"'")
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// NodeText returns the verbatim source slice spanned by a node.
|
|
19
|
+
func NodeText(node *shimast.Node) string {
|
|
20
|
+
if node == nil {
|
|
21
|
+
return ""
|
|
22
|
+
}
|
|
23
|
+
source, ok := SourceFileText(shimast.GetSourceFileOfNode(node))
|
|
24
|
+
if ok == false {
|
|
25
|
+
return ""
|
|
26
|
+
}
|
|
27
|
+
start, end := node.Pos(), node.End()
|
|
28
|
+
if start < 0 || end > len(source) || start >= end {
|
|
29
|
+
return ""
|
|
30
|
+
}
|
|
31
|
+
return strings.TrimSpace(source[start:end])
|
|
32
|
+
}
|