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.
Files changed (169) hide show
  1. package/lib/executable/FileSystemIdentity.d.ts +23 -0
  2. package/lib/executable/FileSystemIdentity.js +30 -0
  3. package/lib/executable/FileSystemIdentity.js.map +1 -1
  4. package/lib/executable/FileSystemIdentity.mjs +4 -0
  5. package/lib/executable/FileSystemIdentity.mjs.map +1 -1
  6. package/lib/executable/TypiaGenerateWizard.js +15 -9
  7. package/lib/executable/TypiaGenerateWizard.js.map +1 -1
  8. package/lib/executable/TypiaGenerateWizard.mjs +11 -7
  9. package/lib/executable/TypiaGenerateWizard.mjs.map +1 -1
  10. package/lib/internal/_ProtobufReader.d.ts +18 -3
  11. package/lib/internal/_ProtobufReader.js +39 -11
  12. package/lib/internal/_ProtobufReader.js.map +1 -1
  13. package/lib/internal/_ProtobufReader.mjs +37 -10
  14. package/lib/internal/_ProtobufReader.mjs.map +1 -1
  15. package/lib/internal/_jsonStringifyArray.d.ts +1 -0
  16. package/lib/internal/_jsonStringifyArray.js +48 -0
  17. package/lib/internal/_jsonStringifyArray.js.map +1 -0
  18. package/lib/internal/_jsonStringifyArray.mjs +40 -0
  19. package/lib/internal/_jsonStringifyArray.mjs.map +1 -0
  20. package/lib/internal/_jsonStringifyElement.d.ts +1 -0
  21. package/lib/internal/_jsonStringifyElement.js +23 -0
  22. package/lib/internal/_jsonStringifyElement.js.map +1 -0
  23. package/lib/internal/_jsonStringifyElement.mjs +23 -0
  24. package/lib/internal/_jsonStringifyElement.mjs.map +1 -0
  25. package/lib/internal/_jsonStringifyProperty.d.ts +1 -0
  26. package/lib/internal/_jsonStringifyProperty.js +31 -0
  27. package/lib/internal/_jsonStringifyProperty.js.map +1 -0
  28. package/lib/internal/_jsonStringifyProperty.mjs +31 -0
  29. package/lib/internal/_jsonStringifyProperty.mjs.map +1 -0
  30. package/lib/internal/_llmApplicationFinalize.js +1 -1
  31. package/lib/internal/_llmApplicationFinalize.js.map +1 -1
  32. package/lib/internal/_llmApplicationFinalize.mjs +1 -1
  33. package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
  34. package/lib/internal/_randomFormatByte.js +24 -1
  35. package/lib/internal/_randomFormatByte.js.map +1 -1
  36. package/lib/internal/_randomFormatByte.mjs +20 -2
  37. package/lib/internal/_randomFormatByte.mjs.map +1 -1
  38. package/lib/internal/_randomFormatDate.d.ts +3 -6
  39. package/lib/internal/_randomFormatDate.js +2 -10
  40. package/lib/internal/_randomFormatDate.js.map +1 -1
  41. package/lib/internal/_randomFormatDate.mjs +2 -6
  42. package/lib/internal/_randomFormatDate.mjs.map +1 -1
  43. package/lib/internal/_randomFormatDatetime.d.ts +3 -6
  44. package/lib/internal/_randomFormatDatetime.js +25 -8
  45. package/lib/internal/_randomFormatDatetime.js.map +1 -1
  46. package/lib/internal/_randomFormatDatetime.mjs +17 -7
  47. package/lib/internal/_randomFormatDatetime.mjs.map +1 -1
  48. package/lib/internal/_randomFormatDuration.js +23 -15
  49. package/lib/internal/_randomFormatDuration.js.map +1 -1
  50. package/lib/internal/_randomFormatDuration.mjs +23 -15
  51. package/lib/internal/_randomFormatDuration.mjs.map +1 -1
  52. package/lib/internal/_randomFormatIpv4.js +31 -1
  53. package/lib/internal/_randomFormatIpv4.js.map +1 -1
  54. package/lib/internal/_randomFormatIpv4.mjs +23 -2
  55. package/lib/internal/_randomFormatIpv4.mjs.map +1 -1
  56. package/lib/internal/_randomFormatIpv6.js +57 -1
  57. package/lib/internal/_randomFormatIpv6.js.map +1 -1
  58. package/lib/internal/_randomFormatIpv6.mjs +45 -2
  59. package/lib/internal/_randomFormatIpv6.mjs.map +1 -1
  60. package/lib/internal/_randomFormatJsonPointer.js +14 -2
  61. package/lib/internal/_randomFormatJsonPointer.js.map +1 -1
  62. package/lib/internal/_randomFormatJsonPointer.mjs +13 -3
  63. package/lib/internal/_randomFormatJsonPointer.mjs.map +1 -1
  64. package/lib/internal/_randomFormatRegex.js +14 -1
  65. package/lib/internal/_randomFormatRegex.js.map +1 -1
  66. package/lib/internal/_randomFormatRegex.mjs +14 -2
  67. package/lib/internal/_randomFormatRegex.mjs.map +1 -1
  68. package/lib/internal/_randomFormatRelativeJsonPointer.js +19 -5
  69. package/lib/internal/_randomFormatRelativeJsonPointer.js.map +1 -1
  70. package/lib/internal/_randomFormatRelativeJsonPointer.mjs +21 -6
  71. package/lib/internal/_randomFormatRelativeJsonPointer.mjs.map +1 -1
  72. package/lib/internal/_randomFormatTime.js +33 -7
  73. package/lib/internal/_randomFormatTime.js.map +1 -1
  74. package/lib/internal/_randomFormatTime.mjs +37 -5
  75. package/lib/internal/_randomFormatTime.mjs.map +1 -1
  76. package/lib/internal/_randomPattern.js.map +1 -1
  77. package/lib/internal/_randomPattern.mjs.map +1 -1
  78. package/lib/internal/_randomStringLength.d.ts +41 -10
  79. package/lib/internal/_randomStringLength.js +49 -13
  80. package/lib/internal/_randomStringLength.js.map +1 -1
  81. package/lib/internal/_randomStringLength.mjs +48 -13
  82. package/lib/internal/_randomStringLength.mjs.map +1 -1
  83. package/lib/internal/private/__notationRename.js.map +1 -1
  84. package/lib/internal/private/__notationRename.mjs.map +1 -1
  85. package/lib/internal/private/__randomComposition.d.ts +23 -0
  86. package/lib/internal/private/__randomComposition.js +48 -0
  87. package/lib/internal/private/__randomComposition.js.map +1 -0
  88. package/lib/internal/private/__randomComposition.mjs +54 -0
  89. package/lib/internal/private/__randomComposition.mjs.map +1 -0
  90. package/lib/internal/private/__randomEpoch.d.ts +19 -0
  91. package/lib/internal/private/__randomEpoch.js +31 -0
  92. package/lib/internal/private/__randomEpoch.js.map +1 -0
  93. package/lib/internal/private/__randomEpoch.mjs +28 -0
  94. package/lib/internal/private/__randomEpoch.mjs.map +1 -0
  95. package/native/cmd/ttsc-typia/build.go +3 -0
  96. package/native/cmd/ttsc-typia/callable_interface_function_semantics_transform_test.go +331 -0
  97. package/native/cmd/ttsc-typia/callable_type_literal_boundaries_transform_test.go +1184 -0
  98. package/native/cmd/ttsc-typia/compare_functional_union_membership_transform_test.go +434 -0
  99. package/native/cmd/ttsc-typia/compare_template_literal_union_transform_test.go +241 -0
  100. package/native/cmd/ttsc-typia/default_library_spoof_native_identity_transform_test.go +216 -0
  101. package/native/cmd/ttsc-typia/json_schema_dynamic_key_determinism_transform_test.go +246 -0
  102. package/native/cmd/ttsc-typia/json_stringify_contextual_undefined_transform_test.go +556 -0
  103. package/native/cmd/ttsc-typia/lib_replacement_native_identity_transform_test.go +277 -0
  104. package/native/cmd/ttsc-typia/native_named_intersection_union_transform_test.go +390 -0
  105. package/native/cmd/ttsc-typia/node_buffer_native_exports_is_transform_test.go +526 -0
  106. package/native/cmd/ttsc-typia/package_declaration_native_identity_is_transform_test.go +293 -0
  107. package/native/cmd/ttsc-typia/protobuf_diagnostic_code_transform_test.go +167 -0
  108. package/native/cmd/ttsc-typia/symbol_index_domain_transform_test.go +316 -0
  109. package/native/cmd/ttsc-typia/transform.go +23 -0
  110. package/native/cmd/ttsc-typia/transform_helpers_test.go +77 -2
  111. package/native/cmd/ttsc-typia/user_global_native_identity_transform_test.go +484 -0
  112. package/native/core/factories/ProtobufFactory.go +6 -1
  113. package/native/core/factories/internal/metadata/MetadataHelper.go +185 -30
  114. package/native/core/factories/internal/metadata/emplace_metadata_object.go +25 -0
  115. package/native/core/factories/internal/metadata/iterate_metadata_function.go +1 -1
  116. package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +103 -23
  117. package/native/core/factories/internal/metadata/iterate_metadata_map.go +3 -7
  118. package/native/core/factories/internal/metadata/iterate_metadata_native.go +32 -14
  119. package/native/core/factories/internal/metadata/iterate_metadata_set.go +3 -7
  120. package/native/core/programmers/compare/CompareEqualProgrammer.go +27 -13
  121. package/native/core/programmers/helpers/FunctionProgrammer.go +6 -13
  122. package/native/core/programmers/helpers/StringifyJoinder.go +129 -50
  123. package/native/core/programmers/helpers/joiner_branch_coverage_test.go +116 -120
  124. package/native/core/programmers/iterate/iterate_check_coverage_test.go +76 -158
  125. package/native/core/programmers/iterate/iterate_utility_coverage_test.go +231 -270
  126. package/native/core/programmers/iterate/json_schema_object.go +49 -7
  127. package/native/core/programmers/iterate/json_schema_pattern_property_order_test.go +44 -0
  128. package/native/core/programmers/iterate/openapi_v3_downgrader.go +34 -1
  129. package/native/core/programmers/iterate/template_runtime_pattern.go +11 -0
  130. package/native/core/programmers/json/JsonStringifyProgrammer.go +47 -6
  131. package/native/core/programmers/llm/LlmApplicationProgrammer.go +9 -1
  132. package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +1 -1
  133. package/native/core/schemas/metadata/MetadataCollection.go +0 -9
  134. package/native/core/schemas/metadata/MetadataDefaultLibrary.go +81 -0
  135. package/native/core/schemas/metadata/MetadataObjectType.go +7 -18
  136. package/native/go.mod +4 -4
  137. package/native/transform/features/protobuf/ProtobufMessageTransformer.go +1 -1
  138. package/package.json +3 -7
  139. package/src/executable/FileSystemIdentity.ts +33 -0
  140. package/src/executable/TypiaGenerateWizard.ts +18 -12
  141. package/src/internal/_ProtobufReader.ts +40 -11
  142. package/src/internal/_jsonStringifyArray.ts +50 -0
  143. package/src/internal/_jsonStringifyElement.ts +19 -0
  144. package/src/internal/_jsonStringifyProperty.ts +30 -0
  145. package/src/internal/_llmApplicationFinalize.ts +6 -1
  146. package/src/internal/_randomFormatByte.ts +30 -3
  147. package/src/internal/_randomFormatDate.ts +4 -20
  148. package/src/internal/_randomFormatDatetime.ts +34 -20
  149. package/src/internal/_randomFormatDuration.ts +19 -4
  150. package/src/internal/_randomFormatIpv4.ts +43 -3
  151. package/src/internal/_randomFormatIpv6.ts +67 -3
  152. package/src/internal/_randomFormatJsonPointer.ts +23 -3
  153. package/src/internal/_randomFormatRegex.ts +21 -3
  154. package/src/internal/_randomFormatRelativeJsonPointer.ts +23 -10
  155. package/src/internal/_randomFormatTime.ts +45 -12
  156. package/src/internal/_randomPattern.ts +4 -1
  157. package/src/internal/_randomStringLength.ts +61 -17
  158. package/src/internal/private/__notationRename.ts +1 -4
  159. package/src/internal/private/__randomComposition.ts +50 -0
  160. package/src/internal/private/__randomEpoch.ts +34 -0
  161. package/native/adapter/visit.go +0 -173
  162. package/native/adapter/visit_property_chain_edges_test.go +0 -129
  163. package/native/core/programmers/helpers/disable_function_programmer_declare.go +0 -10
  164. package/native/core/programmers/iterate/check_union_array_like.go +0 -422
  165. package/native/core/programmers/iterate/prune_object_properties.go +0 -105
  166. package/native/core/programmers/iterate/stringify_dynamic_properties.go +0 -219
  167. package/native/core/programmers/iterate/stringify_native.go +0 -14
  168. package/native/core/programmers/iterate/stringify_regular_properties.go +0 -112
  169. package/native/core/schemas/metadata/MetadataApplication.go +0 -41
@@ -1,422 +0,0 @@
1
- package iterate
2
-
3
- import (
4
- "strings"
5
-
6
- shimast "github.com/microsoft/typescript-go/shim/ast"
7
- shimprinter "github.com/microsoft/typescript-go/shim/printer"
8
- nativecontext "github.com/samchon/typia/packages/typia/native/core/context"
9
- nativefactories "github.com/samchon/typia/packages/typia/native/core/factories"
10
- nativemetadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
11
- )
12
-
13
- type Check_union_array_likeProps struct {
14
- Config Check_union_array_like_IConfig
15
- Accessor Check_union_array_like_IAccessor
16
- Parameters []*shimast.Node
17
- Input *shimast.Expression
18
- Definitions []any
19
- Explore any
20
- Emit *shimprinter.EmitContext
21
- }
22
-
23
- type Check_union_array_like_IConfig struct {
24
- Checker func(props Check_union_array_like_CheckerProps) *shimast.Node
25
- Decoder func(props Check_union_array_like_DecoderProps) *shimast.Node
26
- Empty *shimast.Node
27
- Success *shimast.Expression
28
- Failure func(props Check_union_array_like_FailureProps) *shimast.Node
29
- }
30
-
31
- type Check_union_array_like_CheckerProps struct {
32
- Input *shimast.Expression
33
- Definition any
34
- Explore any
35
- Container *shimast.Expression
36
- }
37
-
38
- type Check_union_array_like_DecoderProps struct {
39
- Input *shimast.Expression
40
- Definition any
41
- Explore any
42
- }
43
-
44
- type Check_union_array_like_FailureProps struct {
45
- Input *shimast.Expression
46
- Expected string
47
- Explore any
48
- }
49
-
50
- type Check_union_array_like_IAccessor struct {
51
- Transform func(origin any) any
52
- Element func(meta any) any
53
- Name func(meta any, elem any) string
54
- Front func(input *shimast.Expression) *shimast.Node
55
- Array func(input *shimast.Expression) *shimast.Node
56
- Size func(input *shimast.Expression) *shimast.Node
57
- }
58
-
59
- func Check_union_array_like(props Check_union_array_likeProps) *shimast.Node {
60
- f := nativecontext.EmitFactoryOf(check_union_array_like_factory, props.Emit)
61
- targets := make([]any, 0, len(props.Definitions))
62
- for _, definition := range props.Definitions {
63
- targets = append(targets, props.Accessor.Transform(definition))
64
- }
65
- if len(targets) == 1 {
66
- return f.NewArrowFunction(
67
- nil,
68
- nil,
69
- f.NewNodeList(props.Parameters),
70
- nil,
71
- nil,
72
- f.NewToken(shimast.KindEqualsGreaterThanToken),
73
- props.Config.Decoder(Check_union_array_like_DecoderProps{
74
- Input: props.Accessor.Array(props.Input),
75
- Definition: targets[0],
76
- Explore: props.Explore,
77
- }),
78
- )
79
- }
80
-
81
- array := f.NewIdentifier("array")
82
- top := f.NewIdentifier("top")
83
- statements := []*shimast.Node{}
84
- tupleList := []*nativemetadata.MetadataTuple{}
85
- arrayList := []*nativemetadata.MetadataArray{}
86
- for _, target := range targets {
87
- switch v := target.(type) {
88
- case *nativemetadata.MetadataTuple:
89
- tupleList = append(tupleList, v)
90
- case *nativemetadata.MetadataArray:
91
- arrayList = append(arrayList, v)
92
- }
93
- }
94
-
95
- predicate := func(meta any) *shimast.Node {
96
- inputType := f.NewTypeReferenceNode(f.NewIdentifier("any[]"), nil)
97
- postfix := ""
98
- if _, ok := meta.(*nativemetadata.MetadataArrayType); ok {
99
- inputType = nativefactories.TypeFactory.Keyword("any")
100
- postfix = "\"[0]\""
101
- }
102
- return f.NewAsExpression(
103
- f.NewArrayLiteralExpression(
104
- f.NewNodeList([]*shimast.Node{
105
- f.NewArrowFunction(
106
- nil,
107
- nil,
108
- f.NewNodeList([]*shimast.Node{
109
- nativefactories.IdentifierFactory.Parameter("top", inputType, nil),
110
- }),
111
- nativefactories.TypeFactory.Keyword("any"),
112
- nil,
113
- f.NewToken(shimast.KindEqualsGreaterThanToken),
114
- props.Config.Checker(Check_union_array_like_CheckerProps{
115
- Input: f.NewIdentifier("top"),
116
- Definition: props.Accessor.Element(meta),
117
- Explore: check_union_array_like_explore(props.Explore, false, postfix),
118
- Container: array,
119
- }),
120
- ),
121
- f.NewArrowFunction(
122
- nil,
123
- nil,
124
- f.NewNodeList([]*shimast.Node{
125
- nativefactories.IdentifierFactory.Parameter(
126
- "entire",
127
- f.NewTypeReferenceNode(f.NewIdentifier("any[]"), nil),
128
- nil,
129
- ),
130
- }),
131
- nativefactories.TypeFactory.Keyword("any"),
132
- nil,
133
- f.NewToken(shimast.KindEqualsGreaterThanToken),
134
- props.Config.Decoder(Check_union_array_like_DecoderProps{
135
- Input: f.NewIdentifier("entire"),
136
- Definition: meta,
137
- Explore: check_union_array_like_explore_trace(props.Explore, true),
138
- }),
139
- ),
140
- }),
141
- true,
142
- ),
143
- f.NewTypeReferenceNode(f.NewIdentifier("const"), nil),
144
- )
145
- }
146
-
147
- iterate := func(init string, from *shimast.Expression, ifStatement *shimast.Node) *shimast.Node {
148
- return f.NewForInOrOfStatement(
149
- shimast.KindForOfStatement,
150
- nil,
151
- f.NewVariableDeclarationList(
152
- f.NewNodeList([]*shimast.Node{
153
- f.NewVariableDeclaration(
154
- f.NewIdentifier(init),
155
- nil,
156
- nil,
157
- nil,
158
- ),
159
- }),
160
- shimast.NodeFlagsConst,
161
- ),
162
- from,
163
- ifStatement,
164
- )
165
- }
166
-
167
- if len(tupleList) != 0 {
168
- tuplePredicates := make([]*shimast.Node, 0, len(tupleList))
169
- for _, x := range tupleList {
170
- tuplePredicates = append(tuplePredicates, predicate(x))
171
- }
172
- statements = append(statements,
173
- nativefactories.StatementFactory.Constant(nativefactories.StatementFactory_ConstantProps{
174
- Name: "array",
175
- Value: props.Accessor.Array(props.Input),
176
- }),
177
- nativefactories.StatementFactory.Constant(nativefactories.StatementFactory_ConstantProps{
178
- Name: "tuplePredicators",
179
- Value: f.NewArrayLiteralExpression(
180
- f.NewNodeList(tuplePredicates),
181
- true,
182
- ),
183
- }),
184
- iterate(
185
- "pred",
186
- f.NewIdentifier("tuplePredicators"),
187
- f.NewIfStatement(
188
- f.NewCallExpression(
189
- f.NewIdentifier("pred[0]"),
190
- nil,
191
- nil,
192
- f.NewNodeList([]*shimast.Node{array}),
193
- shimast.NodeFlagsNone,
194
- ),
195
- f.NewReturnStatement(
196
- f.NewCallExpression(
197
- f.NewIdentifier("pred[1]"),
198
- nil,
199
- nil,
200
- f.NewNodeList([]*shimast.Node{array}),
201
- shimast.NodeFlagsNone,
202
- ),
203
- ),
204
- nil,
205
- ),
206
- ),
207
- )
208
- }
209
- if len(arrayList) != 0 {
210
- if len(tupleList) == 0 {
211
- statements = append(statements, nativefactories.StatementFactory.Constant(nativefactories.StatementFactory_ConstantProps{
212
- Name: "array",
213
- Value: props.Accessor.Array(props.Input),
214
- }))
215
- }
216
- arrayPredicates := make([]*shimast.Node, 0, len(arrayList))
217
- for _, x := range arrayList {
218
- arrayPredicates = append(arrayPredicates, predicate(x))
219
- }
220
- statements = append(statements,
221
- nativefactories.StatementFactory.Constant(nativefactories.StatementFactory_ConstantProps{
222
- Name: "top",
223
- Value: props.Accessor.Front(props.Input),
224
- }),
225
- f.NewIfStatement(
226
- f.NewBinaryExpression(
227
- nil,
228
- nativefactories.ExpressionFactory.Number(0),
229
- nil,
230
- f.NewToken(shimast.KindEqualsEqualsEqualsToken),
231
- props.Accessor.Size(props.Input),
232
- ),
233
- check_union_array_like_return_or_statement(props.Config.Empty, props.Emit),
234
- nil,
235
- ),
236
- nativefactories.StatementFactory.Constant(nativefactories.StatementFactory_ConstantProps{
237
- Name: "arrayPredicators",
238
- Value: f.NewArrayLiteralExpression(
239
- f.NewNodeList(arrayPredicates),
240
- true,
241
- ),
242
- }),
243
- nativefactories.StatementFactory.Constant(nativefactories.StatementFactory_ConstantProps{
244
- Name: "passed",
245
- Value: f.NewCallExpression(
246
- nativefactories.IdentifierFactory.Access(nil, f.NewIdentifier("arrayPredicators"), "filter"),
247
- nil,
248
- nil,
249
- f.NewNodeList([]*shimast.Node{
250
- f.NewArrowFunction(
251
- nil,
252
- nil,
253
- f.NewNodeList([]*shimast.Node{
254
- nativefactories.IdentifierFactory.Parameter("pred", nil, nil),
255
- }),
256
- nil,
257
- nil,
258
- f.NewToken(shimast.KindEqualsGreaterThanToken),
259
- f.NewCallExpression(
260
- f.NewIdentifier("pred[0]"),
261
- nil,
262
- nil,
263
- f.NewNodeList([]*shimast.Node{top}),
264
- shimast.NodeFlagsNone,
265
- ),
266
- ),
267
- }),
268
- shimast.NodeFlagsNone,
269
- ),
270
- }),
271
- check_union_array_like_array_if(iterate, array, top, props.Config.Success, props.Emit),
272
- )
273
- }
274
- names := make([]string, 0, len(targets))
275
- for _, target := range targets {
276
- elem := props.Accessor.Element(target)
277
- names = append(names, props.Accessor.Name(target, elem))
278
- }
279
- statements = append(statements, props.Config.Failure(Check_union_array_like_FailureProps{
280
- Input: props.Input,
281
- Expected: "(" + strings.Join(names, " | ") + ")",
282
- Explore: props.Explore,
283
- }))
284
- return f.NewArrowFunction(
285
- nil,
286
- nil,
287
- f.NewNodeList(props.Parameters),
288
- nil,
289
- nil,
290
- f.NewToken(shimast.KindEqualsGreaterThanToken),
291
- f.NewBlock(
292
- f.NewNodeList(statements),
293
- true,
294
- ),
295
- )
296
- }
297
-
298
- func check_union_array_like_array_if(iterate func(init string, from *shimast.Expression, ifStatement *shimast.Node) *shimast.Node, array *shimast.Node, top *shimast.Node, success *shimast.Expression, emit ...*shimprinter.EmitContext) *shimast.Node {
299
- f := nativecontext.EmitFactoryOf(check_union_array_like_factory, emit...)
300
- return f.NewIfStatement(
301
- f.NewBinaryExpression(
302
- nil,
303
- nativefactories.ExpressionFactory.Number(1),
304
- nil,
305
- f.NewToken(shimast.KindEqualsEqualsEqualsToken),
306
- f.NewIdentifier("passed.length"),
307
- ),
308
- f.NewReturnStatement(
309
- f.NewCallExpression(
310
- f.NewElementAccessExpression(
311
- f.NewNonNullExpression(
312
- f.NewIdentifier("passed[0]"),
313
- shimast.NodeFlagsNone,
314
- ),
315
- nil,
316
- nativefactories.ExpressionFactory.Number(1),
317
- shimast.NodeFlagsNone,
318
- ),
319
- nil,
320
- nil,
321
- f.NewNodeList([]*shimast.Node{array}),
322
- shimast.NodeFlagsNone,
323
- ),
324
- ),
325
- f.NewIfStatement(
326
- f.NewBinaryExpression(
327
- nil,
328
- nativefactories.ExpressionFactory.Number(1),
329
- nil,
330
- f.NewToken(shimast.KindLessThanToken),
331
- f.NewIdentifier("passed.length"),
332
- ),
333
- iterate(
334
- "pred",
335
- f.NewIdentifier("passed"),
336
- f.NewIfStatement(
337
- f.NewCallExpression(
338
- nativefactories.IdentifierFactory.Access(nil, array, "every"),
339
- nil,
340
- nil,
341
- f.NewNodeList([]*shimast.Node{
342
- f.NewArrowFunction(
343
- nil,
344
- nil,
345
- f.NewNodeList([]*shimast.Node{
346
- nativefactories.IdentifierFactory.Parameter("value", nativefactories.TypeFactory.Keyword("any"), nil),
347
- }),
348
- nil,
349
- nil,
350
- f.NewToken(shimast.KindEqualsGreaterThanToken),
351
- f.NewBinaryExpression(
352
- nil,
353
- success,
354
- nil,
355
- f.NewToken(shimast.KindEqualsEqualsEqualsToken),
356
- f.NewCallExpression(
357
- f.NewIdentifier("pred[0]"),
358
- nil,
359
- nil,
360
- f.NewNodeList([]*shimast.Node{
361
- f.NewIdentifier("value"),
362
- }),
363
- shimast.NodeFlagsNone,
364
- ),
365
- ),
366
- ),
367
- }),
368
- shimast.NodeFlagsNone,
369
- ),
370
- f.NewReturnStatement(
371
- f.NewCallExpression(
372
- f.NewIdentifier("pred[1]"),
373
- nil,
374
- nil,
375
- f.NewNodeList([]*shimast.Node{
376
- f.NewIdentifier("array"),
377
- }),
378
- shimast.NodeFlagsNone,
379
- ),
380
- ),
381
- nil,
382
- ),
383
- ),
384
- nil,
385
- ),
386
- )
387
- }
388
-
389
- func check_union_array_like_return_or_statement(node *shimast.Node, emit ...*shimprinter.EmitContext) *shimast.Node {
390
- f := nativecontext.EmitFactoryOf(check_union_array_like_factory, emit...)
391
- if node == nil || node.Kind == shimast.KindReturnStatement {
392
- return node
393
- }
394
- return f.NewReturnStatement(node)
395
- }
396
-
397
- func check_union_array_like_explore(base any, tracable bool, postfix string) any {
398
- if value, ok := base.(map[string]any); ok {
399
- next := map[string]any{}
400
- for k, v := range value {
401
- next[k] = v
402
- }
403
- next["tracable"] = tracable
404
- next["postfix"] = postfix
405
- return next
406
- }
407
- return base
408
- }
409
-
410
- func check_union_array_like_explore_trace(base any, tracable bool) any {
411
- if value, ok := base.(map[string]any); ok {
412
- next := map[string]any{}
413
- for k, v := range value {
414
- next[k] = v
415
- }
416
- next["tracable"] = tracable
417
- return next
418
- }
419
- return base
420
- }
421
-
422
- var check_union_array_like_factory = shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
@@ -1,105 +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
- nativemetadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
8
- )
9
-
10
- func Prune_object_properties(object *nativemetadata.MetadataObjectType, emit ...*shimprinter.EmitContext) *shimast.Node {
11
- f := nativecontext.EmitFactoryOf(prune_object_properties_factory, emit...)
12
- input := f.NewIdentifier("input")
13
- key := f.NewIdentifier("key")
14
-
15
- conditions := []*shimast.Node{}
16
- for _, prop := range object.Properties {
17
- name := prop.Key.GetSoleLiteral()
18
- if name != nil {
19
- conditions = append(conditions, f.NewBinaryExpression(
20
- nil,
21
- f.NewStringLiteral(*name, shimast.TokenFlagsNone),
22
- nil,
23
- f.NewToken(shimast.KindEqualsEqualsEqualsToken),
24
- f.NewIdentifier("key"),
25
- ))
26
- continue
27
- }
28
- conditions = append(conditions, f.NewCallExpression(
29
- f.NewIdentifier("RegExp(/"+metadata_to_pattern(struct {
30
- top bool
31
- metadata *nativemetadata.MetadataSchema
32
- }{
33
- top: true,
34
- metadata: prop.Key,
35
- })+"/).test"),
36
- nil,
37
- nil,
38
- f.NewNodeList([]*shimast.Node{key}),
39
- shimast.NodeFlagsNone,
40
- ))
41
- }
42
-
43
- statements := []*shimast.Node{}
44
- if len(conditions) != 0 {
45
- statements = append(statements, f.NewIfStatement(
46
- prune_object_properties_reduce(conditions, shimast.KindBarBarToken, emit...),
47
- f.NewContinueStatement(nil),
48
- nil,
49
- ))
50
- }
51
- statements = append(statements, f.NewExpressionStatement(
52
- f.NewDeleteExpression(
53
- f.NewElementAccessExpression(input, nil, key, shimast.NodeFlagsNone),
54
- ),
55
- ))
56
-
57
- statement := statements[0]
58
- if len(statements) != 1 {
59
- statement = f.NewBlock(
60
- f.NewNodeList(statements),
61
- true,
62
- )
63
- }
64
-
65
- return f.NewForInOrOfStatement(
66
- shimast.KindForOfStatement,
67
- nil,
68
- f.NewVariableDeclarationList(
69
- f.NewNodeList([]*shimast.Node{
70
- f.NewVariableDeclaration(
71
- f.NewIdentifier("key"),
72
- nil,
73
- nil,
74
- nil,
75
- ),
76
- }),
77
- shimast.NodeFlagsConst,
78
- ),
79
- f.NewCallExpression(
80
- f.NewIdentifier("Object.keys"),
81
- nil,
82
- nil,
83
- f.NewNodeList([]*shimast.Node{input}),
84
- shimast.NodeFlagsNone,
85
- ),
86
- statement,
87
- )
88
- }
89
-
90
- func prune_object_properties_reduce(expressions []*shimast.Node, operator shimast.Kind, emit ...*shimprinter.EmitContext) *shimast.Node {
91
- f := nativecontext.EmitFactoryOf(prune_object_properties_factory, emit...)
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
- var prune_object_properties_factory = shimast.NewNodeFactory(shimast.NodeFactoryHooks{})