typia 13.0.0-dev.20260510 → 13.0.0-dev.20260514

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.
@@ -1,56 +1,63 @@
1
1
  package metadata
2
2
 
3
3
  import (
4
- nativechecker "github.com/microsoft/typescript-go/shim/checker"
5
- schemametadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
4
+ nativechecker "github.com/microsoft/typescript-go/shim/checker"
5
+ schemametadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
6
6
  )
7
7
 
8
8
  type MetadataFactory_IOptions struct {
9
- Escape bool
10
- Absorb bool
11
- Constant bool
12
- Functional bool
13
- Validate func(props struct {
14
- Metadata *schemametadata.MetadataSchema
15
- Explore MetadataFactory_IExplore
16
- Top *schemametadata.MetadataSchema
17
- }) []string
18
- OnError func(node any, message string)
9
+ Escape bool
10
+ Absorb bool
11
+ Constant bool
12
+ Functional bool
13
+ Validate func(props struct {
14
+ Metadata *schemametadata.MetadataSchema
15
+ Explore MetadataFactory_IExplore
16
+ Top *schemametadata.MetadataSchema
17
+ }) []string
18
+ OnError func(node any, message string)
19
19
  }
20
20
 
21
21
  type MetadataFactory_IError struct {
22
- Name string
23
- Explore MetadataFactory_IExplore
24
- Messages []string
22
+ Name string
23
+ Explore MetadataFactory_IExplore
24
+ Messages []string
25
25
  }
26
26
 
27
27
  type MetadataFactory_IExplore struct {
28
- Top bool
29
- Object *schemametadata.MetadataObjectType
30
- Property any
31
- Parameter any
32
- Nested any
33
- Aliased bool
34
- Escaped bool
35
- Output bool
28
+ Top bool
29
+ Object *schemametadata.MetadataObjectType
30
+ Property any
31
+ Parameter any
32
+ Nested any
33
+ Aliased bool
34
+ Escaped bool
35
+ Output bool
36
36
  }
37
37
 
38
38
  type MetadataFactory_IExplore_Function func(MetadataFactory_IExplore) MetadataFactory_IExplore
39
39
 
40
40
  type IMetadataIteratorProps struct {
41
- Options MetadataFactory_IOptions
42
- Checker *nativechecker.Checker
43
- Components *schemametadata.MetadataCollection
44
- Errors *[]MetadataFactory_IError
45
- Metadata *schemametadata.MetadataSchema
46
- Type *nativechecker.Type
47
- Explore MetadataFactory_IExplore
48
- Intersected bool
41
+ Options MetadataFactory_IOptions
42
+ Checker *nativechecker.Checker
43
+ Components *schemametadata.MetadataCollection
44
+ Errors *[]MetadataFactory_IError
45
+ Metadata *schemametadata.MetadataSchema
46
+ Type *nativechecker.Type
47
+ Explore MetadataFactory_IExplore
48
+ Intersected bool
49
49
  }
50
50
 
51
51
  var MetadataTypeTagAnalyzer func(props struct {
52
- Errors *[]MetadataFactory_IError
53
- Type string
54
- Objects []*schemametadata.MetadataObjectType
55
- Explore MetadataFactory_IExplore
52
+ Errors *[]MetadataFactory_IError
53
+ Type string
54
+ Objects []*schemametadata.MetadataObjectType
55
+ Explore MetadataFactory_IExplore
56
56
  }) []schemametadata.IMetadataTypeTag
57
+
58
+ var MetadataCommentTagAnalyzer func(props struct {
59
+ Errors *[]MetadataFactory_IError
60
+ Metadata *schemametadata.MetadataSchema
61
+ Tags []schemametadata.IJsDocTagInfo
62
+ Explore MetadataFactory_IExplore
63
+ })
@@ -1,11 +1,12 @@
1
1
  package metadata
2
2
 
3
3
  import (
4
- "strings"
4
+ "strings"
5
5
 
6
- nativeast "github.com/microsoft/typescript-go/shim/ast"
7
- nativechecker "github.com/microsoft/typescript-go/shim/checker"
8
- schemametadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
6
+ nativeast "github.com/microsoft/typescript-go/shim/ast"
7
+ nativechecker "github.com/microsoft/typescript-go/shim/checker"
8
+ nativescanner "github.com/microsoft/typescript-go/shim/scanner"
9
+ schemametadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
9
10
  )
10
11
 
11
12
  type metadataHelperNamespace struct{}
@@ -13,213 +14,245 @@ type metadataHelperNamespace struct{}
13
14
  var MetadataHelper = metadataHelperNamespace{}
14
15
 
15
16
  func (metadataHelperNamespace) Literal_to_metadata(key string) *schemametadata.MetadataSchema {
16
- metadata := schemametadata.MetadataSchema_initialize()
17
- metadata.Constants = append(metadata.Constants, schemametadata.MetadataConstant_create(schemametadata.MetadataConstant{
18
- Type: "string",
19
- Values: []*schemametadata.MetadataConstantValue{
20
- schemametadata.MetadataConstantValue_create(schemametadata.MetadataConstantValue{
21
- Value: key,
22
- Tags: [][]schemametadata.IMetadataTypeTag{},
23
- }),
24
- },
25
- }))
26
- return metadata
17
+ metadata := schemametadata.MetadataSchema_initialize()
18
+ metadata.Constants = append(metadata.Constants, schemametadata.MetadataConstant_create(schemametadata.MetadataConstant{
19
+ Type: "string",
20
+ Values: []*schemametadata.MetadataConstantValue{
21
+ schemametadata.MetadataConstantValue_create(schemametadata.MetadataConstantValue{
22
+ Value: key,
23
+ Tags: [][]schemametadata.IMetadataTypeTag{},
24
+ }),
25
+ },
26
+ }))
27
+ return metadata
27
28
  }
28
29
 
29
30
  func metadata_array_util_add_bool(array *[]bool, value bool) {
30
- for _, elem := range *array {
31
- if elem == value {
32
- return
33
- }
34
- }
35
- *array = append(*array, value)
31
+ for _, elem := range *array {
32
+ if elem == value {
33
+ return
34
+ }
35
+ }
36
+ *array = append(*array, value)
36
37
  }
37
38
 
38
39
  func metadata_type_full_name(checker *nativechecker.Checker, typ *nativechecker.Type) string {
39
- if checker == nil || typ == nil {
40
- return ""
41
- }
42
- if typ.IsUnion() || typ.IsIntersection() {
43
- joiner := " | "
44
- if typ.IsIntersection() {
45
- joiner = " & "
46
- }
47
- children := typ.Types()
48
- names := make([]string, 0, len(children))
49
- for _, child := range children {
50
- names = append(names, metadata_type_full_name(checker, child))
51
- }
52
- return strings.Join(names, joiner)
53
- }
54
- return checker.TypeToString(typ)
40
+ if checker == nil || typ == nil {
41
+ return ""
42
+ }
43
+ if typ.IsUnion() || typ.IsIntersection() {
44
+ joiner := " | "
45
+ if typ.IsIntersection() {
46
+ joiner = " & "
47
+ }
48
+ children := typ.Types()
49
+ names := make([]string, 0, len(children))
50
+ for _, child := range children {
51
+ names = append(names, metadata_type_full_name(checker, child))
52
+ }
53
+ return strings.Join(names, joiner)
54
+ }
55
+ return checker.TypeToString(typ)
55
56
  }
56
57
 
57
58
  func metadata_get_type_arguments(checker *nativechecker.Checker, typ *nativechecker.Type) (output []*nativechecker.Type) {
58
- if checker == nil || typ == nil {
59
- return nil
60
- }
61
- defer func() {
62
- if recover() != nil {
63
- output = nil
64
- }
65
- }()
66
- return checker.GetTypeArguments(typ)
59
+ if checker == nil || typ == nil {
60
+ return nil
61
+ }
62
+ defer func() {
63
+ if recover() != nil {
64
+ output = nil
65
+ }
66
+ }()
67
+ return checker.GetTypeArguments(typ)
67
68
  }
68
69
 
69
70
  func metadata_get_function_node(typ *nativechecker.Type) *nativeast.Node {
70
- if typ == nil {
71
- return nil
72
- }
73
- symbol := typ.Symbol()
74
- if symbol == nil || len(symbol.Declarations) == 0 {
75
- return nil
76
- }
77
- node := symbol.Declarations[0]
78
- if nativeast.IsFunctionLike(node) {
79
- return node
80
- }
81
- if nativeast.IsPropertyAssignment(node) {
82
- initializer := node.AsPropertyAssignment().Initializer
83
- if nativeast.IsFunctionLike(initializer) {
84
- return initializer
85
- }
86
- return nil
87
- }
88
- if nativeast.IsPropertyDeclaration(node) {
89
- initializer := node.AsPropertyDeclaration().Initializer
90
- if nativeast.IsFunctionLike(initializer) {
91
- return initializer
92
- }
93
- }
94
- return nil
71
+ if typ == nil {
72
+ return nil
73
+ }
74
+ symbol := typ.Symbol()
75
+ if symbol == nil || len(symbol.Declarations) == 0 {
76
+ return nil
77
+ }
78
+ node := symbol.Declarations[0]
79
+ if nativeast.IsFunctionLike(node) {
80
+ return node
81
+ }
82
+ if nativeast.IsPropertyAssignment(node) {
83
+ initializer := node.AsPropertyAssignment().Initializer
84
+ if nativeast.IsFunctionLike(initializer) {
85
+ return initializer
86
+ }
87
+ return nil
88
+ }
89
+ if nativeast.IsPropertyDeclaration(node) {
90
+ initializer := node.AsPropertyDeclaration().Initializer
91
+ if nativeast.IsFunctionLike(initializer) {
92
+ return initializer
93
+ }
94
+ }
95
+ return nil
95
96
  }
96
97
 
97
98
  func metadata_get_return_type_of_class_method(props struct {
98
- Checker *nativechecker.Checker
99
- Class *nativechecker.Type
100
- Function string
99
+ Checker *nativechecker.Checker
100
+ Class *nativechecker.Type
101
+ Function string
101
102
  }) *nativechecker.Type {
102
- if props.Checker == nil || props.Class == nil {
103
- return nil
104
- }
105
- symbol := props.Checker.GetPropertyOfType(props.Class, props.Function)
106
- if symbol == nil || symbol.ValueDeclaration == nil {
107
- return nil
108
- }
109
- functor := props.Checker.GetTypeOfSymbolAtLocation(symbol, symbol.ValueDeclaration)
110
- signatures := props.Checker.GetSignaturesOfType(functor, nativechecker.SignatureKindCall)
111
- if len(signatures) == 0 {
112
- return nil
113
- }
114
- return props.Checker.GetReturnTypeOfSignature(signatures[0])
103
+ if props.Checker == nil || props.Class == nil {
104
+ return nil
105
+ }
106
+ symbol := props.Checker.GetPropertyOfType(props.Class, props.Function)
107
+ if symbol == nil || symbol.ValueDeclaration == nil {
108
+ return nil
109
+ }
110
+ functor := props.Checker.GetTypeOfSymbolAtLocation(symbol, symbol.ValueDeclaration)
111
+ signatures := props.Checker.GetSignaturesOfType(functor, nativechecker.SignatureKindCall)
112
+ if len(signatures) == 0 {
113
+ return nil
114
+ }
115
+ return props.Checker.GetReturnTypeOfSignature(signatures[0])
115
116
  }
116
117
 
117
118
  func metadata_node_js_doc_tags(symbol *nativeast.Symbol) []schemametadata.IJsDocTagInfo {
118
- output := []schemametadata.IJsDocTagInfo{}
119
- for _, node := range metadata_node_declarations(symbol) {
120
- for _, jsdoc := range node.JSDoc(nil) {
121
- doc := jsdoc.AsJSDoc()
122
- if doc == nil || doc.Tags == nil {
123
- continue
124
- }
125
- for _, tag := range doc.Tags.Nodes {
126
- if tag == nil || tag.TagName() == nil {
127
- continue
128
- }
129
- texts := []schemametadata.IJsDocTagInfo_IText{}
130
- if name := metadata_js_doc_parameter_name(tag); name != "" {
131
- texts = append(texts, schemametadata.IJsDocTagInfo_IText{
132
- Kind: "parameterName",
133
- Text: name,
134
- })
135
- }
136
- if text := metadata_js_doc_comment_text(tag.CommentList()); text != "" {
137
- texts = append(texts, schemametadata.IJsDocTagInfo_IText{
138
- Kind: "text",
139
- Text: text,
140
- })
141
- }
142
- output = append(output, schemametadata.IJsDocTagInfo{
143
- Name: tag.TagName().Text(),
144
- Text: texts,
145
- })
146
- }
147
- }
148
- }
149
- return output
119
+ output := []schemametadata.IJsDocTagInfo{}
120
+ for _, node := range metadata_node_declarations(symbol) {
121
+ for _, jsdoc := range node.JSDoc(nil) {
122
+ doc := jsdoc.AsJSDoc()
123
+ if doc == nil || doc.Tags == nil {
124
+ continue
125
+ }
126
+ for _, tag := range doc.Tags.Nodes {
127
+ if tag == nil || tag.TagName() == nil {
128
+ continue
129
+ }
130
+ texts := []schemametadata.IJsDocTagInfo_IText{}
131
+ if name := metadata_js_doc_parameter_name(tag); name != "" {
132
+ texts = append(texts, schemametadata.IJsDocTagInfo_IText{
133
+ Kind: "parameterName",
134
+ Text: name,
135
+ })
136
+ }
137
+ if text := metadata_js_doc_type_expression_text(tag); text != "" {
138
+ texts = append(texts, schemametadata.IJsDocTagInfo_IText{
139
+ Kind: "text",
140
+ Text: text,
141
+ })
142
+ }
143
+ if text := metadata_js_doc_comment_text(tag.CommentList()); text != "" {
144
+ texts = append(texts, schemametadata.IJsDocTagInfo_IText{
145
+ Kind: "text",
146
+ Text: text,
147
+ })
148
+ }
149
+ output = append(output, schemametadata.IJsDocTagInfo{
150
+ Name: tag.TagName().Text(),
151
+ Text: texts,
152
+ })
153
+ }
154
+ }
155
+ }
156
+ return output
150
157
  }
151
158
 
152
159
  func metadata_node_description(symbol *nativeast.Symbol) *string {
153
- for _, node := range metadata_node_declarations(symbol) {
154
- for _, jsdoc := range node.JSDoc(nil) {
155
- doc := jsdoc.AsJSDoc()
156
- if doc == nil {
157
- continue
158
- }
159
- if text := metadata_js_doc_comment_text(doc.Comment); text != "" {
160
- return &text
161
- }
162
- }
163
- }
164
- return nil
160
+ for _, node := range metadata_node_declarations(symbol) {
161
+ for _, jsdoc := range node.JSDoc(nil) {
162
+ doc := jsdoc.AsJSDoc()
163
+ if doc == nil {
164
+ continue
165
+ }
166
+ if text := metadata_js_doc_comment_text(doc.Comment); text != "" {
167
+ return &text
168
+ }
169
+ }
170
+ }
171
+ return nil
165
172
  }
166
173
 
167
174
  func metadata_is_internal(symbol *nativeast.Symbol) bool {
168
- return false
175
+ return false
169
176
  }
170
177
 
171
178
  func metadata_node_declarations(symbol *nativeast.Symbol) []*nativeast.Node {
172
- if symbol == nil {
173
- return nil
174
- }
175
- output := []*nativeast.Node{}
176
- visited := map[*nativeast.Node]bool{}
177
- appendNode := func(node *nativeast.Node) {
178
- if node != nil && visited[node] == false {
179
- visited[node] = true
180
- output = append(output, node)
181
- }
182
- }
183
- appendNode(symbol.ValueDeclaration)
184
- for _, node := range symbol.Declarations {
185
- appendNode(node)
186
- }
187
- return output
179
+ if symbol == nil {
180
+ return nil
181
+ }
182
+ output := []*nativeast.Node{}
183
+ visited := map[*nativeast.Node]bool{}
184
+ appendNode := func(node *nativeast.Node) {
185
+ if node != nil && visited[node] == false {
186
+ visited[node] = true
187
+ output = append(output, node)
188
+ }
189
+ }
190
+ appendNode(symbol.ValueDeclaration)
191
+ for _, node := range symbol.Declarations {
192
+ appendNode(node)
193
+ }
194
+ return output
188
195
  }
189
196
 
190
197
  func metadata_js_doc_parameter_name(tag *nativeast.Node) string {
191
- if tag == nil {
192
- return ""
193
- }
194
- if tag.Kind.String() != "KindJSDocParameterTag" && tag.Kind.String() != "KindJSDocPropertyTag" {
195
- return ""
196
- }
197
- name := tag.AsJSDocParameterOrPropertyTag().Name()
198
- if name == nil {
199
- return ""
200
- }
201
- return name.Text()
198
+ if tag == nil {
199
+ return ""
200
+ }
201
+ if tag.Kind.String() != "KindJSDocParameterTag" && tag.Kind.String() != "KindJSDocPropertyTag" {
202
+ return ""
203
+ }
204
+ name := tag.AsJSDocParameterOrPropertyTag().Name()
205
+ if name == nil {
206
+ return ""
207
+ }
208
+ return name.Text()
209
+ }
210
+
211
+ func metadata_js_doc_type_expression_text(tag *nativeast.Node) string {
212
+ if tag == nil {
213
+ return ""
214
+ }
215
+ switch tag.Kind {
216
+ case nativeast.KindJSDocTypeTag,
217
+ nativeast.KindJSDocParameterTag,
218
+ nativeast.KindJSDocPropertyTag,
219
+ nativeast.KindJSDocReturnTag,
220
+ nativeast.KindJSDocTypedefTag,
221
+ nativeast.KindJSDocSatisfiesTag,
222
+ nativeast.KindJSDocThrowsTag:
223
+ default:
224
+ return ""
225
+ }
226
+ expr := tag.TypeExpression()
227
+ if expr == nil {
228
+ return ""
229
+ }
230
+ typ := expr.Type()
231
+ if typ == nil {
232
+ return ""
233
+ }
234
+ return metadata_clean_js_doc_text(nativescanner.GetTextOfNode(typ))
202
235
  }
203
236
 
204
237
  func metadata_js_doc_comment_text(list *nativeast.NodeList) string {
205
- if list == nil {
206
- return ""
207
- }
208
- parts := []string{}
209
- for _, node := range list.Nodes {
210
- if node != nil {
211
- parts = append(parts, node.Text())
212
- }
213
- }
214
- return metadata_clean_js_doc_text(strings.Join(parts, ""))
238
+ if list == nil {
239
+ return ""
240
+ }
241
+ parts := []string{}
242
+ for _, node := range list.Nodes {
243
+ if node != nil {
244
+ parts = append(parts, node.Text())
245
+ }
246
+ }
247
+ return metadata_clean_js_doc_text(strings.Join(parts, ""))
215
248
  }
216
249
 
217
250
  func metadata_clean_js_doc_text(text string) string {
218
- text = strings.ReplaceAll(text, "\r\n", "\n")
219
- text = strings.ReplaceAll(text, "\r", "\n")
220
- lines := strings.Split(text, "\n")
221
- for i, line := range lines {
222
- lines[i] = strings.TrimRight(line, " \t")
223
- }
224
- return strings.TrimSpace(strings.Join(lines, "\n"))
251
+ text = strings.ReplaceAll(text, "\r\n", "\n")
252
+ text = strings.ReplaceAll(text, "\r", "\n")
253
+ lines := strings.Split(text, "\n")
254
+ for i, line := range lines {
255
+ lines[i] = strings.TrimRight(line, " \t")
256
+ }
257
+ return strings.TrimSpace(strings.Join(lines, "\n"))
225
258
  }
@@ -3,18 +3,32 @@ package metadata
3
3
  import schemametadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
4
4
 
5
5
  func Iterate_metadata_comment_tags(props struct {
6
- Errors *[]MetadataFactory_IError
7
- Object *schemametadata.MetadataObjectType
6
+ Errors *[]MetadataFactory_IError
7
+ Object *schemametadata.MetadataObjectType
8
8
  }) {
9
- if props.Object == nil || props.Object.Tagged_ == true {
10
- return
11
- }
12
- props.Object.Tagged_ = true
9
+ if props.Object == nil || props.Object.Tagged_ == true || MetadataCommentTagAnalyzer == nil {
10
+ return
11
+ }
12
+ props.Object.Tagged_ = true
13
13
 
14
- for _, property := range props.Object.Properties {
15
- _ = property
16
- // JSDoc extraction through the TypeScript-Go shim is not yet complete.
17
- // The traversal point is kept in the original file location so the
18
- // MetadataCommentTagFactory port can be wired without changing callers.
19
- }
14
+ for _, property := range props.Object.Properties {
15
+ if property == nil || property.Value == nil || len(property.JsDocTags) == 0 {
16
+ continue
17
+ }
18
+ MetadataCommentTagAnalyzer(struct {
19
+ Errors *[]MetadataFactory_IError
20
+ Metadata *schemametadata.MetadataSchema
21
+ Tags []schemametadata.IJsDocTagInfo
22
+ Explore MetadataFactory_IExplore
23
+ }{
24
+ Errors: props.Errors,
25
+ Metadata: property.Value,
26
+ Tags: property.JsDocTags,
27
+ Explore: MetadataFactory_IExplore{
28
+ Top: false,
29
+ Object: props.Object,
30
+ Property: property,
31
+ },
32
+ })
33
+ }
20
34
  }
package/native/go.work ADDED
@@ -0,0 +1,22 @@
1
+ go 1.26
2
+
3
+ use (
4
+ .
5
+ ../../../../ttsc/packages/ttsc
6
+ ../../../../ttsc/packages/ttsc/shim/ast
7
+ ../../../../ttsc/packages/ttsc/shim/bundled
8
+ ../../../../ttsc/packages/ttsc/shim/checker
9
+ ../../../../ttsc/packages/ttsc/shim/compiler
10
+ ../../../../ttsc/packages/ttsc/shim/core
11
+ ../../../../ttsc/packages/ttsc/shim/diagnosticwriter
12
+ ../../../../ttsc/packages/ttsc/shim/parser
13
+ ../../../../ttsc/packages/ttsc/shim/printer
14
+ ../../../../ttsc/packages/ttsc/shim/scanner
15
+ ../../../../ttsc/packages/ttsc/shim/tsoptions
16
+ ../../../../ttsc/packages/ttsc/shim/tspath
17
+ ../../../../ttsc/packages/ttsc/shim/vfs
18
+ ../../../../ttsc/packages/ttsc/shim/vfs/cachedvfs
19
+ ../../../../ttsc/packages/ttsc/shim/vfs/osvfs
20
+ )
21
+
22
+ replace github.com/samchon/ttsc/packages/ttsc v0.0.0 => ../../../../ttsc/packages/ttsc