typia 13.1.19 → 13.2.0
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/lib/executable/FileSystemIdentity.d.ts +23 -0
- package/lib/executable/FileSystemIdentity.js +30 -0
- package/lib/executable/FileSystemIdentity.js.map +1 -1
- package/lib/executable/FileSystemIdentity.mjs +4 -0
- package/lib/executable/FileSystemIdentity.mjs.map +1 -1
- package/lib/executable/TypiaGenerateWizard.js +15 -9
- package/lib/executable/TypiaGenerateWizard.js.map +1 -1
- package/lib/executable/TypiaGenerateWizard.mjs +11 -7
- package/lib/executable/TypiaGenerateWizard.mjs.map +1 -1
- package/lib/internal/_ProtobufReader.d.ts +18 -3
- package/lib/internal/_ProtobufReader.js +39 -11
- package/lib/internal/_ProtobufReader.js.map +1 -1
- package/lib/internal/_ProtobufReader.mjs +37 -10
- package/lib/internal/_ProtobufReader.mjs.map +1 -1
- package/lib/internal/_jsonStringifyArray.d.ts +1 -0
- package/lib/internal/_jsonStringifyArray.js +48 -0
- package/lib/internal/_jsonStringifyArray.js.map +1 -0
- package/lib/internal/_jsonStringifyArray.mjs +40 -0
- package/lib/internal/_jsonStringifyArray.mjs.map +1 -0
- package/lib/internal/_jsonStringifyElement.d.ts +1 -0
- package/lib/internal/_jsonStringifyElement.js +23 -0
- package/lib/internal/_jsonStringifyElement.js.map +1 -0
- package/lib/internal/_jsonStringifyElement.mjs +23 -0
- package/lib/internal/_jsonStringifyElement.mjs.map +1 -0
- package/lib/internal/_jsonStringifyProperty.d.ts +1 -0
- package/lib/internal/_jsonStringifyProperty.js +31 -0
- package/lib/internal/_jsonStringifyProperty.js.map +1 -0
- package/lib/internal/_jsonStringifyProperty.mjs +31 -0
- package/lib/internal/_jsonStringifyProperty.mjs.map +1 -0
- package/lib/internal/_llmApplicationFinalize.js +1 -1
- package/lib/internal/_llmApplicationFinalize.js.map +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
- package/lib/internal/_randomFormatByte.js +24 -1
- package/lib/internal/_randomFormatByte.js.map +1 -1
- package/lib/internal/_randomFormatByte.mjs +20 -2
- package/lib/internal/_randomFormatByte.mjs.map +1 -1
- package/lib/internal/_randomFormatDate.d.ts +3 -6
- package/lib/internal/_randomFormatDate.js +2 -10
- package/lib/internal/_randomFormatDate.js.map +1 -1
- package/lib/internal/_randomFormatDate.mjs +2 -6
- package/lib/internal/_randomFormatDate.mjs.map +1 -1
- package/lib/internal/_randomFormatDatetime.d.ts +3 -6
- package/lib/internal/_randomFormatDatetime.js +25 -8
- package/lib/internal/_randomFormatDatetime.js.map +1 -1
- package/lib/internal/_randomFormatDatetime.mjs +17 -7
- package/lib/internal/_randomFormatDatetime.mjs.map +1 -1
- package/lib/internal/_randomFormatDuration.js +23 -15
- package/lib/internal/_randomFormatDuration.js.map +1 -1
- package/lib/internal/_randomFormatDuration.mjs +23 -15
- package/lib/internal/_randomFormatDuration.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv4.js +31 -1
- package/lib/internal/_randomFormatIpv4.js.map +1 -1
- package/lib/internal/_randomFormatIpv4.mjs +23 -2
- package/lib/internal/_randomFormatIpv4.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv6.js +57 -1
- package/lib/internal/_randomFormatIpv6.js.map +1 -1
- package/lib/internal/_randomFormatIpv6.mjs +45 -2
- package/lib/internal/_randomFormatIpv6.mjs.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.js +14 -2
- package/lib/internal/_randomFormatJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.mjs +13 -3
- package/lib/internal/_randomFormatJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatRegex.js +14 -1
- package/lib/internal/_randomFormatRegex.js.map +1 -1
- package/lib/internal/_randomFormatRegex.mjs +14 -2
- package/lib/internal/_randomFormatRegex.mjs.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.js +19 -5
- package/lib/internal/_randomFormatRelativeJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs +21 -6
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatTime.js +33 -7
- package/lib/internal/_randomFormatTime.js.map +1 -1
- package/lib/internal/_randomFormatTime.mjs +37 -5
- package/lib/internal/_randomFormatTime.mjs.map +1 -1
- package/lib/internal/_randomPattern.js.map +1 -1
- package/lib/internal/_randomPattern.mjs.map +1 -1
- package/lib/internal/_randomStringLength.d.ts +41 -10
- package/lib/internal/_randomStringLength.js +49 -13
- package/lib/internal/_randomStringLength.js.map +1 -1
- package/lib/internal/_randomStringLength.mjs +48 -13
- package/lib/internal/_randomStringLength.mjs.map +1 -1
- package/lib/internal/private/__notationRename.js.map +1 -1
- package/lib/internal/private/__notationRename.mjs.map +1 -1
- package/lib/internal/private/__randomComposition.d.ts +23 -0
- package/lib/internal/private/__randomComposition.js +48 -0
- package/lib/internal/private/__randomComposition.js.map +1 -0
- package/lib/internal/private/__randomComposition.mjs +54 -0
- package/lib/internal/private/__randomComposition.mjs.map +1 -0
- package/lib/internal/private/__randomEpoch.d.ts +19 -0
- package/lib/internal/private/__randomEpoch.js +31 -0
- package/lib/internal/private/__randomEpoch.js.map +1 -0
- package/lib/internal/private/__randomEpoch.mjs +28 -0
- package/lib/internal/private/__randomEpoch.mjs.map +1 -0
- package/native/cmd/ttsc-typia/build.go +3 -0
- package/native/cmd/ttsc-typia/callable_interface_function_semantics_transform_test.go +331 -0
- package/native/cmd/ttsc-typia/callable_type_literal_boundaries_transform_test.go +1184 -0
- package/native/cmd/ttsc-typia/compare_functional_union_membership_transform_test.go +434 -0
- package/native/cmd/ttsc-typia/compare_template_literal_union_transform_test.go +241 -0
- package/native/cmd/ttsc-typia/default_library_spoof_native_identity_transform_test.go +216 -0
- package/native/cmd/ttsc-typia/json_schema_dynamic_key_determinism_transform_test.go +246 -0
- package/native/cmd/ttsc-typia/json_stringify_contextual_undefined_transform_test.go +556 -0
- package/native/cmd/ttsc-typia/lib_replacement_native_identity_transform_test.go +277 -0
- package/native/cmd/ttsc-typia/native_named_intersection_union_transform_test.go +390 -0
- package/native/cmd/ttsc-typia/node_buffer_native_exports_is_transform_test.go +526 -0
- package/native/cmd/ttsc-typia/package_declaration_native_identity_is_transform_test.go +293 -0
- package/native/cmd/ttsc-typia/protobuf_diagnostic_code_transform_test.go +167 -0
- package/native/cmd/ttsc-typia/symbol_index_domain_transform_test.go +316 -0
- package/native/cmd/ttsc-typia/transform.go +23 -0
- package/native/cmd/ttsc-typia/transform_helpers_test.go +77 -2
- package/native/cmd/ttsc-typia/user_global_native_identity_transform_test.go +484 -0
- package/native/core/factories/ProtobufFactory.go +6 -1
- package/native/core/factories/internal/metadata/MetadataHelper.go +185 -30
- package/native/core/factories/internal/metadata/emplace_metadata_object.go +25 -0
- package/native/core/factories/internal/metadata/iterate_metadata_function.go +1 -1
- package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +103 -23
- package/native/core/factories/internal/metadata/iterate_metadata_map.go +3 -7
- package/native/core/factories/internal/metadata/iterate_metadata_native.go +32 -14
- package/native/core/factories/internal/metadata/iterate_metadata_set.go +3 -7
- package/native/core/programmers/compare/CompareEqualProgrammer.go +27 -13
- package/native/core/programmers/helpers/FunctionProgrammer.go +6 -13
- package/native/core/programmers/helpers/StringifyJoinder.go +129 -50
- package/native/core/programmers/helpers/joiner_branch_coverage_test.go +116 -120
- package/native/core/programmers/iterate/iterate_check_coverage_test.go +76 -158
- package/native/core/programmers/iterate/iterate_utility_coverage_test.go +231 -270
- package/native/core/programmers/iterate/json_schema_object.go +49 -7
- package/native/core/programmers/iterate/json_schema_pattern_property_order_test.go +44 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader.go +34 -1
- package/native/core/programmers/iterate/template_runtime_pattern.go +11 -0
- package/native/core/programmers/json/JsonStringifyProgrammer.go +47 -6
- package/native/core/programmers/llm/LlmApplicationProgrammer.go +9 -1
- package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +1 -1
- package/native/core/schemas/metadata/MetadataCollection.go +0 -9
- package/native/core/schemas/metadata/MetadataDefaultLibrary.go +81 -0
- package/native/core/schemas/metadata/MetadataObjectType.go +7 -18
- package/native/go.mod +4 -4
- package/native/transform/features/protobuf/ProtobufMessageTransformer.go +1 -1
- package/package.json +3 -7
- package/src/executable/FileSystemIdentity.ts +33 -0
- package/src/executable/TypiaGenerateWizard.ts +18 -12
- package/src/internal/_ProtobufReader.ts +40 -11
- package/src/internal/_jsonStringifyArray.ts +50 -0
- package/src/internal/_jsonStringifyElement.ts +19 -0
- package/src/internal/_jsonStringifyProperty.ts +30 -0
- package/src/internal/_llmApplicationFinalize.ts +6 -1
- package/src/internal/_randomFormatByte.ts +30 -3
- package/src/internal/_randomFormatDate.ts +4 -20
- package/src/internal/_randomFormatDatetime.ts +34 -20
- package/src/internal/_randomFormatDuration.ts +19 -4
- package/src/internal/_randomFormatIpv4.ts +43 -3
- package/src/internal/_randomFormatIpv6.ts +67 -3
- package/src/internal/_randomFormatJsonPointer.ts +23 -3
- package/src/internal/_randomFormatRegex.ts +21 -3
- package/src/internal/_randomFormatRelativeJsonPointer.ts +23 -10
- package/src/internal/_randomFormatTime.ts +45 -12
- package/src/internal/_randomPattern.ts +4 -1
- package/src/internal/_randomStringLength.ts +61 -17
- package/src/internal/private/__notationRename.ts +1 -4
- package/src/internal/private/__randomComposition.ts +50 -0
- package/src/internal/private/__randomEpoch.ts +34 -0
- package/native/adapter/visit.go +0 -173
- package/native/adapter/visit_property_chain_edges_test.go +0 -129
- package/native/core/programmers/helpers/disable_function_programmer_declare.go +0 -10
- package/native/core/programmers/iterate/check_union_array_like.go +0 -422
- package/native/core/programmers/iterate/prune_object_properties.go +0 -105
- package/native/core/programmers/iterate/stringify_dynamic_properties.go +0 -219
- package/native/core/programmers/iterate/stringify_native.go +0 -14
- package/native/core/programmers/iterate/stringify_regular_properties.go +0 -112
- package/native/core/schemas/metadata/MetadataApplication.go +0 -41
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
package iterate
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
5
|
-
shimprinter "github.com/microsoft/typescript-go/shim/printer"
|
|
6
|
-
nativecontext "github.com/samchon/typia/packages/typia/native/core/context"
|
|
7
|
-
nativefactories "github.com/samchon/typia/packages/typia/native/core/factories"
|
|
8
|
-
nativehelpers "github.com/samchon/typia/packages/typia/native/core/programmers/helpers"
|
|
9
|
-
nativemetadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
func Stringify_dynamic_properties(dynamic []nativehelpers.IExpressionEntry, regular []string, emit ...*shimprinter.EmitContext) *shimast.Node {
|
|
13
|
-
f := nativecontext.EmitFactoryOf(stringify_dynamic_properties_factory, emit...)
|
|
14
|
-
statements := []*shimast.Node{
|
|
15
|
-
f.NewIfStatement(
|
|
16
|
-
f.NewBinaryExpression(
|
|
17
|
-
nil,
|
|
18
|
-
f.NewIdentifier("undefined"),
|
|
19
|
-
nil,
|
|
20
|
-
f.NewToken(shimast.KindEqualsEqualsEqualsToken),
|
|
21
|
-
f.NewIdentifier("value"),
|
|
22
|
-
),
|
|
23
|
-
f.NewReturnStatement(
|
|
24
|
-
f.NewStringLiteral("", shimast.TokenFlagsNone),
|
|
25
|
-
),
|
|
26
|
-
nil,
|
|
27
|
-
),
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
output := func() *shimast.Node {
|
|
31
|
-
mapped := f.NewCallExpression(
|
|
32
|
-
nativefactories.IdentifierFactory.Access(
|
|
33
|
-
nil,
|
|
34
|
-
f.NewCallExpression(
|
|
35
|
-
f.NewIdentifier("Object.entries"),
|
|
36
|
-
nil,
|
|
37
|
-
nil,
|
|
38
|
-
f.NewNodeList([]*shimast.Node{
|
|
39
|
-
f.NewIdentifier("input"),
|
|
40
|
-
}),
|
|
41
|
-
shimast.NodeFlagsNone,
|
|
42
|
-
),
|
|
43
|
-
"map",
|
|
44
|
-
),
|
|
45
|
-
nil,
|
|
46
|
-
nil,
|
|
47
|
-
f.NewNodeList([]*shimast.Node{
|
|
48
|
-
f.NewArrowFunction(
|
|
49
|
-
nil,
|
|
50
|
-
nil,
|
|
51
|
-
f.NewNodeList([]*shimast.Node{
|
|
52
|
-
nativefactories.IdentifierFactory.Parameter(
|
|
53
|
-
stringify_dynamic_properties_binding_pattern(emit...),
|
|
54
|
-
f.NewTypeReferenceNode(
|
|
55
|
-
f.NewIdentifier("[string, any]"),
|
|
56
|
-
nil,
|
|
57
|
-
),
|
|
58
|
-
nil,
|
|
59
|
-
),
|
|
60
|
-
}),
|
|
61
|
-
nil,
|
|
62
|
-
nil,
|
|
63
|
-
f.NewToken(shimast.KindEqualsGreaterThanToken),
|
|
64
|
-
f.NewBlock(
|
|
65
|
-
f.NewNodeList(statements),
|
|
66
|
-
false,
|
|
67
|
-
),
|
|
68
|
-
),
|
|
69
|
-
}),
|
|
70
|
-
shimast.NodeFlagsNone,
|
|
71
|
-
)
|
|
72
|
-
filtered := f.NewCallExpression(
|
|
73
|
-
nativefactories.IdentifierFactory.Access(nil, mapped, "filter"),
|
|
74
|
-
nil,
|
|
75
|
-
nil,
|
|
76
|
-
f.NewNodeList([]*shimast.Node{
|
|
77
|
-
f.NewArrowFunction(
|
|
78
|
-
nil,
|
|
79
|
-
nil,
|
|
80
|
-
f.NewNodeList([]*shimast.Node{
|
|
81
|
-
nativefactories.IdentifierFactory.Parameter("str", nil, nil),
|
|
82
|
-
}),
|
|
83
|
-
nil,
|
|
84
|
-
nil,
|
|
85
|
-
f.NewToken(shimast.KindEqualsGreaterThanToken),
|
|
86
|
-
f.NewBinaryExpression(
|
|
87
|
-
nil,
|
|
88
|
-
f.NewStringLiteral("", shimast.TokenFlagsNone),
|
|
89
|
-
nil,
|
|
90
|
-
f.NewToken(shimast.KindExclamationEqualsEqualsToken),
|
|
91
|
-
f.NewIdentifier("str"),
|
|
92
|
-
),
|
|
93
|
-
),
|
|
94
|
-
}),
|
|
95
|
-
shimast.NodeFlagsNone,
|
|
96
|
-
)
|
|
97
|
-
return f.NewCallExpression(
|
|
98
|
-
nativefactories.IdentifierFactory.Access(nil, filtered, "join"),
|
|
99
|
-
nil,
|
|
100
|
-
nil,
|
|
101
|
-
f.NewNodeList([]*shimast.Node{
|
|
102
|
-
f.NewStringLiteral(",", shimast.TokenFlagsNone),
|
|
103
|
-
}),
|
|
104
|
-
shimast.NodeFlagsNone,
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if len(regular) != 0 {
|
|
109
|
-
elements := make([]*shimast.Node, 0, len(regular))
|
|
110
|
-
for _, key := range regular {
|
|
111
|
-
elements = append(elements, f.NewStringLiteral(key, shimast.TokenFlagsNone))
|
|
112
|
-
}
|
|
113
|
-
statements = append(statements, f.NewIfStatement(
|
|
114
|
-
f.NewCallExpression(
|
|
115
|
-
nativefactories.IdentifierFactory.Access(
|
|
116
|
-
nil,
|
|
117
|
-
f.NewArrayLiteralExpression(
|
|
118
|
-
f.NewNodeList(elements),
|
|
119
|
-
false,
|
|
120
|
-
),
|
|
121
|
-
"some",
|
|
122
|
-
),
|
|
123
|
-
nil,
|
|
124
|
-
nil,
|
|
125
|
-
f.NewNodeList([]*shimast.Node{
|
|
126
|
-
f.NewArrowFunction(
|
|
127
|
-
nil,
|
|
128
|
-
nil,
|
|
129
|
-
f.NewNodeList([]*shimast.Node{
|
|
130
|
-
nativefactories.IdentifierFactory.Parameter("regular", nil, nil),
|
|
131
|
-
}),
|
|
132
|
-
nil,
|
|
133
|
-
nil,
|
|
134
|
-
f.NewToken(shimast.KindEqualsGreaterThanToken),
|
|
135
|
-
f.NewBinaryExpression(
|
|
136
|
-
nil,
|
|
137
|
-
f.NewIdentifier("regular"),
|
|
138
|
-
nil,
|
|
139
|
-
f.NewToken(shimast.KindEqualsEqualsEqualsToken),
|
|
140
|
-
f.NewIdentifier("key"),
|
|
141
|
-
),
|
|
142
|
-
),
|
|
143
|
-
}),
|
|
144
|
-
shimast.NodeFlagsNone,
|
|
145
|
-
),
|
|
146
|
-
f.NewReturnStatement(
|
|
147
|
-
f.NewStringLiteral("", shimast.TokenFlagsNone),
|
|
148
|
-
),
|
|
149
|
-
nil,
|
|
150
|
-
))
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
simple := len(dynamic) == 1 &&
|
|
154
|
-
dynamic[0].Key.Size() == 1 &&
|
|
155
|
-
len(dynamic[0].Key.Atomics) != 0 &&
|
|
156
|
-
dynamic[0].Key.Atomics[0].Type == "string"
|
|
157
|
-
if simple {
|
|
158
|
-
statements = append(statements, stringify_dynamic_properties_stringify(dynamic[0], emit...))
|
|
159
|
-
return output()
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
for _, entry := range dynamic {
|
|
163
|
-
statements = append(statements, f.NewIfStatement(
|
|
164
|
-
f.NewCallExpression(
|
|
165
|
-
f.NewIdentifier("RegExp(/"+metadata_to_pattern(struct {
|
|
166
|
-
top bool
|
|
167
|
-
metadata *nativemetadata.MetadataSchema
|
|
168
|
-
}{
|
|
169
|
-
top: true,
|
|
170
|
-
metadata: entry.Key,
|
|
171
|
-
})+"/).test"),
|
|
172
|
-
nil,
|
|
173
|
-
nil,
|
|
174
|
-
f.NewNodeList([]*shimast.Node{
|
|
175
|
-
f.NewIdentifier("key"),
|
|
176
|
-
}),
|
|
177
|
-
shimast.NodeFlagsNone,
|
|
178
|
-
),
|
|
179
|
-
stringify_dynamic_properties_stringify(entry, emit...),
|
|
180
|
-
nil,
|
|
181
|
-
))
|
|
182
|
-
}
|
|
183
|
-
statements = append(statements, f.NewReturnStatement(
|
|
184
|
-
f.NewStringLiteral("", shimast.TokenFlagsNone),
|
|
185
|
-
))
|
|
186
|
-
return output()
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
func stringify_dynamic_properties_stringify(entry nativehelpers.IExpressionEntry, emit ...*shimprinter.EmitContext) *shimast.Node {
|
|
190
|
-
f := nativecontext.EmitFactoryOf(stringify_dynamic_properties_factory, emit...)
|
|
191
|
-
return f.NewReturnStatement(
|
|
192
|
-
nativefactories.TemplateFactory.Generate([]*shimast.Node{
|
|
193
|
-
f.NewCallExpression(
|
|
194
|
-
f.NewIdentifier("JSON.stringify"),
|
|
195
|
-
nil,
|
|
196
|
-
f.NewNodeList(nil),
|
|
197
|
-
f.NewNodeList([]*shimast.Node{
|
|
198
|
-
f.NewIdentifier("key"),
|
|
199
|
-
}),
|
|
200
|
-
shimast.NodeFlagsNone,
|
|
201
|
-
),
|
|
202
|
-
f.NewStringLiteral(":", shimast.TokenFlagsNone),
|
|
203
|
-
entry.Expression,
|
|
204
|
-
}),
|
|
205
|
-
)
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
func stringify_dynamic_properties_binding_pattern(emit ...*shimprinter.EmitContext) *shimast.Node {
|
|
209
|
-
f := nativecontext.EmitFactoryOf(stringify_dynamic_properties_factory, emit...)
|
|
210
|
-
return f.NewBindingPattern(
|
|
211
|
-
shimast.KindArrayBindingPattern,
|
|
212
|
-
f.NewNodeList([]*shimast.Node{
|
|
213
|
-
f.NewBindingElement(nil, nil, f.NewIdentifier("key"), nil),
|
|
214
|
-
f.NewBindingElement(nil, nil, f.NewIdentifier("value"), nil),
|
|
215
|
-
}),
|
|
216
|
-
)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
var stringify_dynamic_properties_factory = shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
package iterate
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
5
|
-
shimprinter "github.com/microsoft/typescript-go/shim/printer"
|
|
6
|
-
nativecontext "github.com/samchon/typia/packages/typia/native/core/context"
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
var stringify_native_factory = shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
|
|
10
|
-
|
|
11
|
-
func Stringify_native(emit ...*shimprinter.EmitContext) *shimast.Node {
|
|
12
|
-
f := nativecontext.EmitFactoryOf(stringify_native_factory, emit...)
|
|
13
|
-
return f.NewStringLiteral("{}", shimast.TokenFlagsNone)
|
|
14
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
package iterate
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"encoding/json"
|
|
5
|
-
"sort"
|
|
6
|
-
|
|
7
|
-
shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
8
|
-
shimprinter "github.com/microsoft/typescript-go/shim/printer"
|
|
9
|
-
nativecontext "github.com/samchon/typia/packages/typia/native/core/context"
|
|
10
|
-
nativefactories "github.com/samchon/typia/packages/typia/native/core/factories"
|
|
11
|
-
nativehelpers "github.com/samchon/typia/packages/typia/native/core/programmers/helpers"
|
|
12
|
-
nativemetadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
type Stringify_regular_propertiesProps struct {
|
|
16
|
-
Regular []nativehelpers.IExpressionEntry
|
|
17
|
-
Dynamic []nativehelpers.IExpressionEntry
|
|
18
|
-
Emit *shimprinter.EmitContext
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
func Stringify_regular_properties(props Stringify_regular_propertiesProps) []*shimast.Node {
|
|
22
|
-
f := nativecontext.EmitFactoryOf(stringify_regular_properties_factory, props.Emit)
|
|
23
|
-
output := []*shimast.Node{}
|
|
24
|
-
|
|
25
|
-
sort.Slice(props.Regular, func(i int, j int) bool {
|
|
26
|
-
return stringify_regular_properties_sequence(props.Regular[i].Meta) < stringify_regular_properties_sequence(props.Regular[j].Meta)
|
|
27
|
-
})
|
|
28
|
-
for index, entry := range props.Regular {
|
|
29
|
-
key := entry.Key.GetSoleLiteral()
|
|
30
|
-
if key == nil {
|
|
31
|
-
continue
|
|
32
|
-
}
|
|
33
|
-
encoded, err := json.Marshal(*key)
|
|
34
|
-
if err != nil {
|
|
35
|
-
encoded = []byte("\"" + *key + "\"")
|
|
36
|
-
}
|
|
37
|
-
base := []*shimast.Node{
|
|
38
|
-
f.NewStringLiteral(string(encoded)+":", shimast.TokenFlagsNone),
|
|
39
|
-
entry.Expression,
|
|
40
|
-
}
|
|
41
|
-
if index != len(props.Regular)-1 || len(props.Dynamic) != 0 {
|
|
42
|
-
base = append(base, f.NewStringLiteral(",", shimast.TokenFlagsNone))
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
empty := (!entry.Meta.IsRequired() && !entry.Meta.Nullable && entry.Meta.Size() == 0) ||
|
|
46
|
-
(len(entry.Meta.Functions) != 0 && !entry.Meta.Nullable && entry.Meta.Size() == 1)
|
|
47
|
-
if empty {
|
|
48
|
-
continue
|
|
49
|
-
}
|
|
50
|
-
if !entry.Meta.IsRequired() || len(entry.Meta.Functions) != 0 || entry.Meta.Any {
|
|
51
|
-
output = append(output, nativefactories.ExpressionFactory.Conditional(
|
|
52
|
-
stringify_regular_properties_condition(entry, props.Emit),
|
|
53
|
-
f.NewStringLiteral("", shimast.TokenFlagsNone),
|
|
54
|
-
nativefactories.TemplateFactory.Generate(base),
|
|
55
|
-
))
|
|
56
|
-
} else {
|
|
57
|
-
output = append(output, base...)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return output
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
func stringify_regular_properties_condition(entry nativehelpers.IExpressionEntry, emit ...*shimprinter.EmitContext) *shimast.Node {
|
|
64
|
-
f := nativecontext.EmitFactoryOf(stringify_regular_properties_factory, emit...)
|
|
65
|
-
conditions := []*shimast.Node{}
|
|
66
|
-
if !entry.Meta.IsRequired() || entry.Meta.Any {
|
|
67
|
-
conditions = append(conditions, f.NewBinaryExpression(
|
|
68
|
-
nil,
|
|
69
|
-
f.NewIdentifier("undefined"),
|
|
70
|
-
nil,
|
|
71
|
-
f.NewToken(shimast.KindEqualsEqualsEqualsToken),
|
|
72
|
-
entry.Input,
|
|
73
|
-
))
|
|
74
|
-
}
|
|
75
|
-
if len(entry.Meta.Functions) != 0 || entry.Meta.Any {
|
|
76
|
-
conditions = append(conditions, f.NewBinaryExpression(
|
|
77
|
-
nil,
|
|
78
|
-
f.NewStringLiteral("function", shimast.TokenFlagsNone),
|
|
79
|
-
nil,
|
|
80
|
-
f.NewToken(shimast.KindEqualsEqualsEqualsToken),
|
|
81
|
-
nativefactories.ValueFactory.TYPEOF(entry.Input),
|
|
82
|
-
))
|
|
83
|
-
}
|
|
84
|
-
return stringify_regular_properties_reduce(conditions, shimast.KindBarBarToken, emit...)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
func stringify_regular_properties_reduce(expressions []*shimast.Node, operator shimast.Kind, emit ...*shimprinter.EmitContext) *shimast.Node {
|
|
88
|
-
f := nativecontext.EmitFactoryOf(stringify_regular_properties_factory, emit...)
|
|
89
|
-
if len(expressions) == 0 {
|
|
90
|
-
return f.NewKeywordExpression(shimast.KindFalseKeyword)
|
|
91
|
-
}
|
|
92
|
-
output := expressions[0]
|
|
93
|
-
for _, next := range expressions[1:] {
|
|
94
|
-
output = f.NewBinaryExpression(
|
|
95
|
-
nil,
|
|
96
|
-
output,
|
|
97
|
-
nil,
|
|
98
|
-
f.NewToken(operator),
|
|
99
|
-
next,
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
return output
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
func stringify_regular_properties_sequence(meta *nativemetadata.MetadataSchema) int {
|
|
106
|
-
if meta.Any || !meta.IsRequired() || len(meta.Functions) != 0 {
|
|
107
|
-
return 0
|
|
108
|
-
}
|
|
109
|
-
return 1
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
var stringify_regular_properties_factory = shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
package metadata
|
|
2
|
-
|
|
3
|
-
type IMetadataSchemaCollection struct {
|
|
4
|
-
Schemas []*IMetadataSchema
|
|
5
|
-
Components IMetadataComponents
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
type MetadataApplication struct {
|
|
9
|
-
Schemas []*MetadataSchema
|
|
10
|
-
Components *MetadataComponents
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
func MetadataApplication_create(props MetadataApplication) *MetadataApplication {
|
|
14
|
-
return &MetadataApplication{
|
|
15
|
-
Schemas: props.Schemas,
|
|
16
|
-
Components: props.Components,
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
func MetadataApplication_from(app IMetadataSchemaCollection) *MetadataApplication {
|
|
21
|
-
components := MetadataComponents_from(app.Components)
|
|
22
|
-
metadatas := make([]*MetadataSchema, 0, len(app.Schemas))
|
|
23
|
-
for _, metadata := range app.Schemas {
|
|
24
|
-
metadatas = append(metadatas, MetadataSchema_from(metadata, components.Dictionary))
|
|
25
|
-
}
|
|
26
|
-
return MetadataApplication_create(MetadataApplication{
|
|
27
|
-
Schemas: metadatas,
|
|
28
|
-
Components: components,
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
func (app *MetadataApplication) ToJSON() IMetadataSchemaCollection {
|
|
33
|
-
schemas := make([]*IMetadataSchema, 0, len(app.Schemas))
|
|
34
|
-
for _, schema := range app.Schemas {
|
|
35
|
-
schemas = append(schemas, schema.ToJSON())
|
|
36
|
-
}
|
|
37
|
-
return IMetadataSchemaCollection{
|
|
38
|
-
Schemas: schemas,
|
|
39
|
-
Components: app.Components.ToJSON(),
|
|
40
|
-
}
|
|
41
|
-
}
|