typia 5.2.6 → 5.2.7-dev.20231109

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 (125) hide show
  1. package/lib/factories/ExpressionFactory.js +14 -16
  2. package/lib/factories/ExpressionFactory.js.map +1 -1
  3. package/lib/factories/JsonMetadataFactory.d.ts +1 -1
  4. package/lib/factories/JsonMetadataFactory.js +2 -2
  5. package/lib/factories/JsonMetadataFactory.js.map +1 -1
  6. package/lib/factories/LiteralFactory.js +2 -0
  7. package/lib/factories/LiteralFactory.js.map +1 -1
  8. package/lib/factories/MetadataFactory.d.ts +1 -1
  9. package/lib/factories/MetadataFactory.js +233 -168
  10. package/lib/factories/MetadataFactory.js.map +1 -1
  11. package/lib/factories/NumericRangeFactory.d.ts +2 -2
  12. package/lib/factories/NumericRangeFactory.js +41 -21
  13. package/lib/factories/NumericRangeFactory.js.map +1 -1
  14. package/lib/factories/ProtobufFactory.d.ts +1 -1
  15. package/lib/factories/ProtobufFactory.js +2 -2
  16. package/lib/factories/ProtobufFactory.js.map +1 -1
  17. package/lib/programmers/CheckerProgrammer.js +11 -16
  18. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  19. package/lib/programmers/RandomProgrammer.js +1 -1
  20. package/lib/programmers/RandomProgrammer.js.map +1 -1
  21. package/lib/programmers/http/HttpHeadersProgrammer.js +1 -1
  22. package/lib/programmers/http/HttpHeadersProgrammer.js.map +1 -1
  23. package/lib/programmers/http/HttpParameterProgrammer.js +1 -1
  24. package/lib/programmers/http/HttpParameterProgrammer.js.map +1 -1
  25. package/lib/programmers/http/HttpQueryProgrammer.js +1 -1
  26. package/lib/programmers/http/HttpQueryProgrammer.js.map +1 -1
  27. package/lib/programmers/internal/application_array.js +8 -0
  28. package/lib/programmers/internal/application_array.js.map +1 -1
  29. package/lib/programmers/internal/application_number.js +8 -1
  30. package/lib/programmers/internal/application_number.js.map +1 -1
  31. package/lib/programmers/internal/application_string.js +8 -1
  32. package/lib/programmers/internal/application_string.js.map +1 -1
  33. package/lib/programmers/internal/check_array_length.js +7 -4
  34. package/lib/programmers/internal/check_array_length.js.map +1 -1
  35. package/lib/programmers/internal/check_bigint.js +7 -4
  36. package/lib/programmers/internal/check_bigint.js.map +1 -1
  37. package/lib/programmers/internal/check_number.js +7 -4
  38. package/lib/programmers/internal/check_number.js.map +1 -1
  39. package/lib/programmers/internal/check_string.js.map +1 -1
  40. package/lib/programmers/json/JsonAssertParseProgrammer.js +1 -1
  41. package/lib/programmers/json/JsonAssertParseProgrammer.js.map +1 -1
  42. package/lib/programmers/json/JsonIsParseProgrammer.js +1 -1
  43. package/lib/programmers/json/JsonIsParseProgrammer.js.map +1 -1
  44. package/lib/programmers/json/JsonStringifyProgrammer.js +3 -8
  45. package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
  46. package/lib/programmers/json/JsonValidateParseProgrammer.js +1 -1
  47. package/lib/programmers/json/JsonValidateParseProgrammer.js.map +1 -1
  48. package/lib/programmers/misc/MiscCloneProgrammer.js +19 -24
  49. package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
  50. package/lib/programmers/misc/MiscLiteralsProgrammer.js +1 -1
  51. package/lib/programmers/misc/MiscLiteralsProgrammer.js.map +1 -1
  52. package/lib/programmers/misc/MiscPruneProgrammer.js +11 -16
  53. package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
  54. package/lib/programmers/notations/NotationGeneralProgrammer.js +11 -16
  55. package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
  56. package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +1 -1
  57. package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
  58. package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +38 -42
  59. package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
  60. package/lib/programmers/protobuf/ProtobufMessageProgrammer.d.ts +1 -1
  61. package/lib/programmers/protobuf/ProtobufMessageProgrammer.js +22 -25
  62. package/lib/programmers/protobuf/ProtobufMessageProgrammer.js.map +1 -1
  63. package/lib/schemas/json/IJsonSchema.d.ts +1 -0
  64. package/lib/schemas/metadata/Metadata.js +1 -6
  65. package/lib/schemas/metadata/Metadata.js.map +1 -1
  66. package/lib/schemas/metadata/MetadataAtomic.d.ts +2 -0
  67. package/lib/schemas/metadata/MetadataAtomic.js +15 -0
  68. package/lib/schemas/metadata/MetadataAtomic.js.map +1 -1
  69. package/lib/transformers/features/json/JsonApplicationTransformer.d.ts +1 -1
  70. package/lib/transformers/features/json/JsonApplicationTransformer.js +4 -5
  71. package/lib/transformers/features/json/JsonApplicationTransformer.js.map +1 -1
  72. package/lib/transformers/features/misc/MetadataTransformer.d.ts +1 -1
  73. package/lib/transformers/features/misc/MetadataTransformer.js +3 -4
  74. package/lib/transformers/features/misc/MetadataTransformer.js.map +1 -1
  75. package/package.json +2 -2
  76. package/src/Primitive.ts +135 -135
  77. package/src/executable/TypiaSetupWizard.ts +142 -142
  78. package/src/executable/setup/CommandExecutor.ts +8 -8
  79. package/src/factories/ExpressionFactory.ts +12 -13
  80. package/src/factories/JsonMetadataFactory.ts +53 -50
  81. package/src/factories/LiteralFactory.ts +2 -0
  82. package/src/factories/MetadataCollection.ts +282 -282
  83. package/src/factories/MetadataFactory.ts +48 -18
  84. package/src/factories/NumericRangeFactory.ts +56 -17
  85. package/src/factories/ProtobufFactory.ts +5 -2
  86. package/src/factories/internal/metadata/emplace_metadata_object.ts +178 -178
  87. package/src/functional/$stoll.ts +8 -8
  88. package/src/functional/Namespace.ts +168 -168
  89. package/src/programmers/AssertProgrammer.ts +322 -322
  90. package/src/programmers/CheckerProgrammer.ts +16 -17
  91. package/src/programmers/IsProgrammer.ts +258 -258
  92. package/src/programmers/RandomProgrammer.ts +4 -1
  93. package/src/programmers/ValidateProgrammer.ts +350 -350
  94. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  95. package/src/programmers/http/HttpHeadersProgrammer.ts +4 -1
  96. package/src/programmers/http/HttpParameterProgrammer.ts +4 -1
  97. package/src/programmers/http/HttpQueryProgrammer.ts +4 -1
  98. package/src/programmers/internal/application_array.ts +8 -0
  99. package/src/programmers/internal/application_number.ts +8 -1
  100. package/src/programmers/internal/application_string.ts +8 -1
  101. package/src/programmers/internal/check_array_length.ts +5 -2
  102. package/src/programmers/internal/check_bigint.ts +5 -2
  103. package/src/programmers/internal/check_dynamic_key.ts +178 -178
  104. package/src/programmers/internal/check_dynamic_properties.ts +202 -202
  105. package/src/programmers/internal/check_number.ts +5 -2
  106. package/src/programmers/internal/check_object.ts +62 -62
  107. package/src/programmers/internal/check_string.ts +0 -1
  108. package/src/programmers/json/JsonAssertParseProgrammer.ts +1 -0
  109. package/src/programmers/json/JsonIsParseProgrammer.ts +1 -0
  110. package/src/programmers/json/JsonStringifyProgrammer.ts +959 -960
  111. package/src/programmers/json/JsonValidateParseProgrammer.ts +1 -0
  112. package/src/programmers/misc/MiscCloneProgrammer.ts +787 -786
  113. package/src/programmers/misc/MiscLiteralsProgrammer.ts +4 -1
  114. package/src/programmers/misc/MiscPruneProgrammer.ts +549 -548
  115. package/src/programmers/notations/NotationGeneralProgrammer.ts +717 -716
  116. package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +1 -0
  117. package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +872 -882
  118. package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +21 -21
  119. package/src/schemas/json/IJsonSchema.ts +1 -0
  120. package/src/schemas/metadata/IMetadataTypeTag.ts +7 -0
  121. package/src/schemas/metadata/Metadata.ts +1 -6
  122. package/src/schemas/metadata/MetadataAtomic.ts +17 -0
  123. package/src/transform.ts +35 -35
  124. package/src/transformers/features/json/JsonApplicationTransformer.ts +7 -4
  125. package/src/transformers/features/misc/MetadataTransformer.ts +6 -3
@@ -1,350 +1,350 @@
1
- import ts from "typescript";
2
-
3
- import { ExpressionFactory } from "../factories/ExpressionFactory";
4
- import { IdentifierFactory } from "../factories/IdentifierFactory";
5
- import { StatementFactory } from "../factories/StatementFactory";
6
- import { TypeFactory } from "../factories/TypeFactory";
7
-
8
- import { IProject } from "../transformers/IProject";
9
-
10
- import { CheckerProgrammer } from "./CheckerProgrammer";
11
- import { IsProgrammer } from "./IsProgrammer";
12
- import { FunctionImporter } from "./helpers/FunctionImporeter";
13
- import { OptionPredicator } from "./helpers/OptionPredicator";
14
- import { check_everything } from "./internal/check_everything";
15
- import { check_object } from "./internal/check_object";
16
-
17
- export namespace ValidateProgrammer {
18
- export const write =
19
- (project: IProject) =>
20
- (modulo: ts.LeftHandSideExpression) =>
21
- (equals: boolean) =>
22
- (type: ts.Type, name?: string) => {
23
- const importer: FunctionImporter = new FunctionImporter(
24
- modulo.getText(),
25
- );
26
-
27
- const is = IsProgrammer.write(project)(modulo, true)(equals)(
28
- type,
29
- name ?? TypeFactory.getFullName(project.checker)(type),
30
- );
31
- const validate: ts.ArrowFunction = CheckerProgrammer.write(project)(
32
- {
33
- prefix: "$v",
34
- path: true,
35
- trace: true,
36
- numeric: OptionPredicator.numeric(project.options),
37
- equals,
38
- atomist: (explore) => (entry) => (input) =>
39
- [
40
- ...(entry.expression ? [entry.expression] : []),
41
- ...(entry.conditions.length === 0
42
- ? []
43
- : entry.conditions.length === 1
44
- ? entry.conditions[0]!.map((cond) =>
45
- ts.factory.createLogicalOr(
46
- cond.expression,
47
- create_report_call(
48
- explore.from === "top"
49
- ? ts.factory.createTrue()
50
- : ts.factory.createIdentifier(
51
- "_exceptionable",
52
- ),
53
- )(
54
- ts.factory.createIdentifier(
55
- explore.postfix
56
- ? `_path + ${explore.postfix}`
57
- : "_path",
58
- ),
59
- cond.expected,
60
- input,
61
- ),
62
- ),
63
- )
64
- : [
65
- ts.factory.createLogicalOr(
66
- entry.conditions
67
- .map((set) =>
68
- set
69
- .map((s) => s.expression)
70
- .reduce((a, b) =>
71
- ts.factory.createLogicalAnd(
72
- a,
73
- b,
74
- ),
75
- ),
76
- )
77
- .reduce((a, b) =>
78
- ts.factory.createLogicalOr(
79
- a,
80
- b,
81
- ),
82
- ),
83
- create_report_call(
84
- explore.from === "top"
85
- ? ts.factory.createTrue()
86
- : ts.factory.createIdentifier(
87
- "_exceptionable",
88
- ),
89
- )(
90
- ts.factory.createIdentifier(
91
- explore.postfix
92
- ? `_path + ${explore.postfix}`
93
- : "_path",
94
- ),
95
- entry.expected,
96
- input,
97
- ),
98
- ),
99
- ]),
100
- ].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
101
- combiner: combine(equals)(project)(importer),
102
- joiner: joiner(equals)(project)(importer),
103
- success: ts.factory.createTrue(),
104
- addition: () => importer.declare(modulo),
105
- },
106
- )(importer)(type, name);
107
-
108
- return ts.factory.createArrowFunction(
109
- undefined,
110
- undefined,
111
- [
112
- IdentifierFactory.parameter(
113
- "input",
114
- TypeFactory.keyword("any"),
115
- ),
116
- ],
117
- ts.factory.createTypeReferenceNode(
118
- `typia.IValidation<${
119
- name ?? TypeFactory.getFullName(project.checker)(type)
120
- }>`,
121
- ),
122
- undefined,
123
- ts.factory.createBlock(
124
- [
125
- StatementFactory.constant(
126
- "errors",
127
- ts.factory.createAsExpression(
128
- ts.factory.createArrayLiteralExpression([]),
129
- ts.factory.createArrayTypeNode(
130
- TypeFactory.keyword("any"),
131
- ),
132
- ),
133
- ),
134
- StatementFactory.constant("__is", is),
135
- ts.factory.createIfStatement(
136
- ts.factory.createStrictEquality(
137
- ts.factory.createFalse(),
138
- ts.factory.createCallExpression(
139
- ts.factory.createIdentifier("__is"),
140
- undefined,
141
- [ts.factory.createIdentifier("input")],
142
- ),
143
- ),
144
- ts.factory.createBlock([
145
- StatementFactory.constant(
146
- "$report",
147
- ts.factory.createCallExpression(
148
- IdentifierFactory.access(
149
- ts.factory.createParenthesizedExpression(
150
- ts.factory.createAsExpression(
151
- modulo,
152
- TypeFactory.keyword("any"),
153
- ),
154
- ),
155
- )("report"),
156
- [],
157
- [ts.factory.createIdentifier("errors")],
158
- ),
159
- ),
160
- ts.factory.createExpressionStatement(
161
- ts.factory.createCallExpression(
162
- validate,
163
- undefined,
164
- [
165
- ts.factory.createIdentifier(
166
- "input",
167
- ),
168
- ts.factory.createStringLiteral(
169
- "$input",
170
- ),
171
- ts.factory.createTrue(),
172
- ],
173
- ),
174
- ),
175
- ]),
176
- ),
177
- StatementFactory.constant(
178
- "success",
179
- ts.factory.createStrictEquality(
180
- ExpressionFactory.number(0),
181
- ts.factory.createIdentifier("errors.length"),
182
- ),
183
- ),
184
- ts.factory.createReturnStatement(
185
- ts.factory.createAsExpression(
186
- create_output(),
187
- TypeFactory.keyword("any"),
188
- ),
189
- ),
190
- ],
191
- true,
192
- ),
193
- );
194
- };
195
- }
196
-
197
- const combine =
198
- (equals: boolean) =>
199
- (project: IProject) =>
200
- (importer: FunctionImporter): CheckerProgrammer.IConfig.Combiner =>
201
- (explore: CheckerProgrammer.IExplore) => {
202
- if (explore.tracable === false)
203
- return IsProgrammer.configure({
204
- object: validate_object(equals)(project)(importer),
205
- numeric: true,
206
- })(project)(importer).combiner(explore);
207
-
208
- const path: string = explore.postfix
209
- ? `_path + ${explore.postfix}`
210
- : "_path";
211
- return (logic) => (input, binaries, expected) =>
212
- logic === "and"
213
- ? binaries
214
- .map((binary) =>
215
- binary.combined
216
- ? binary.expression
217
- : ts.factory.createLogicalOr(
218
- binary.expression,
219
- create_report_call(
220
- explore.source === "top"
221
- ? ts.factory.createTrue()
222
- : ts.factory.createIdentifier(
223
- "_exceptionable",
224
- ),
225
- )(
226
- ts.factory.createIdentifier(path),
227
- expected,
228
- input,
229
- ),
230
- ),
231
- )
232
- .reduce(ts.factory.createLogicalAnd)
233
- : ts.factory.createLogicalOr(
234
- binaries
235
- .map((binary) => binary.expression)
236
- .reduce(ts.factory.createLogicalOr),
237
- create_report_call(
238
- explore.source === "top"
239
- ? ts.factory.createTrue()
240
- : ts.factory.createIdentifier("_exceptionable"),
241
- )(ts.factory.createIdentifier(path), expected, input),
242
- );
243
- };
244
-
245
- const validate_object =
246
- (equals: boolean) => (project: IProject) => (importer: FunctionImporter) =>
247
- check_object({
248
- equals,
249
- undefined: true,
250
- assert: false,
251
- reduce: ts.factory.createLogicalAnd,
252
- positive: ts.factory.createTrue(),
253
- superfluous: (value) =>
254
- create_report_call()(
255
- ts.factory.createAdd(
256
- ts.factory.createIdentifier("_path"),
257
- ts.factory.createCallExpression(
258
- importer.use("join"),
259
- undefined,
260
- [ts.factory.createIdentifier("key")],
261
- ),
262
- ),
263
- "undefined",
264
- value,
265
- ),
266
- halt: (expr) =>
267
- ts.factory.createLogicalOr(
268
- ts.factory.createStrictEquality(
269
- ts.factory.createFalse(),
270
- ts.factory.createIdentifier("_exceptionable"),
271
- ),
272
- expr,
273
- ),
274
- })(project)(importer);
275
-
276
- const joiner =
277
- (equals: boolean) =>
278
- (project: IProject) =>
279
- (importer: FunctionImporter): CheckerProgrammer.IConfig.IJoiner => ({
280
- object: validate_object(equals)(project)(importer),
281
- array: (input, arrow) =>
282
- check_everything(
283
- ts.factory.createCallExpression(
284
- IdentifierFactory.access(input)("map"),
285
- undefined,
286
- [arrow],
287
- ),
288
- ),
289
- failure: (value, expected, explore) =>
290
- create_report_call(
291
- explore?.from === "top"
292
- ? ts.factory.createTrue()
293
- : ts.factory.createIdentifier("_exceptionable"),
294
- )(
295
- ts.factory.createIdentifier(
296
- explore?.postfix ? `_path + ${explore.postfix}` : "_path",
297
- ),
298
- expected,
299
- value,
300
- ),
301
- tuple: (binaries) =>
302
- check_everything(
303
- ts.factory.createArrayLiteralExpression(binaries, true),
304
- ),
305
- });
306
-
307
- const create_output = () =>
308
- ts.factory.createObjectLiteralExpression(
309
- [
310
- ts.factory.createShorthandPropertyAssignment("success"),
311
- ts.factory.createShorthandPropertyAssignment("errors"),
312
- ts.factory.createPropertyAssignment(
313
- "data",
314
- ts.factory.createConditionalExpression(
315
- ts.factory.createIdentifier("success"),
316
- undefined,
317
- ts.factory.createIdentifier("input"),
318
- undefined,
319
- ts.factory.createIdentifier("undefined"),
320
- ),
321
- ),
322
- ],
323
- true,
324
- );
325
-
326
- const create_report_call =
327
- (exceptionable?: ts.Expression) =>
328
- (
329
- path: ts.Expression,
330
- expected: string,
331
- value: ts.Expression,
332
- ): ts.Expression =>
333
- ts.factory.createCallExpression(
334
- ts.factory.createIdentifier("$report"),
335
- undefined,
336
- [
337
- exceptionable ?? ts.factory.createIdentifier("_exceptionable"),
338
- ts.factory.createObjectLiteralExpression(
339
- [
340
- ts.factory.createPropertyAssignment("path", path),
341
- ts.factory.createPropertyAssignment(
342
- "expected",
343
- ts.factory.createStringLiteral(expected),
344
- ),
345
- ts.factory.createPropertyAssignment("value", value),
346
- ],
347
- true,
348
- ),
349
- ],
350
- );
1
+ import ts from "typescript";
2
+
3
+ import { ExpressionFactory } from "../factories/ExpressionFactory";
4
+ import { IdentifierFactory } from "../factories/IdentifierFactory";
5
+ import { StatementFactory } from "../factories/StatementFactory";
6
+ import { TypeFactory } from "../factories/TypeFactory";
7
+
8
+ import { IProject } from "../transformers/IProject";
9
+
10
+ import { CheckerProgrammer } from "./CheckerProgrammer";
11
+ import { IsProgrammer } from "./IsProgrammer";
12
+ import { FunctionImporter } from "./helpers/FunctionImporeter";
13
+ import { OptionPredicator } from "./helpers/OptionPredicator";
14
+ import { check_everything } from "./internal/check_everything";
15
+ import { check_object } from "./internal/check_object";
16
+
17
+ export namespace ValidateProgrammer {
18
+ export const write =
19
+ (project: IProject) =>
20
+ (modulo: ts.LeftHandSideExpression) =>
21
+ (equals: boolean) =>
22
+ (type: ts.Type, name?: string) => {
23
+ const importer: FunctionImporter = new FunctionImporter(
24
+ modulo.getText(),
25
+ );
26
+
27
+ const is = IsProgrammer.write(project)(modulo, true)(equals)(
28
+ type,
29
+ name ?? TypeFactory.getFullName(project.checker)(type),
30
+ );
31
+ const validate: ts.ArrowFunction = CheckerProgrammer.write(project)(
32
+ {
33
+ prefix: "$v",
34
+ path: true,
35
+ trace: true,
36
+ numeric: OptionPredicator.numeric(project.options),
37
+ equals,
38
+ atomist: (explore) => (entry) => (input) =>
39
+ [
40
+ ...(entry.expression ? [entry.expression] : []),
41
+ ...(entry.conditions.length === 0
42
+ ? []
43
+ : entry.conditions.length === 1
44
+ ? entry.conditions[0]!.map((cond) =>
45
+ ts.factory.createLogicalOr(
46
+ cond.expression,
47
+ create_report_call(
48
+ explore.from === "top"
49
+ ? ts.factory.createTrue()
50
+ : ts.factory.createIdentifier(
51
+ "_exceptionable",
52
+ ),
53
+ )(
54
+ ts.factory.createIdentifier(
55
+ explore.postfix
56
+ ? `_path + ${explore.postfix}`
57
+ : "_path",
58
+ ),
59
+ cond.expected,
60
+ input,
61
+ ),
62
+ ),
63
+ )
64
+ : [
65
+ ts.factory.createLogicalOr(
66
+ entry.conditions
67
+ .map((set) =>
68
+ set
69
+ .map((s) => s.expression)
70
+ .reduce((a, b) =>
71
+ ts.factory.createLogicalAnd(
72
+ a,
73
+ b,
74
+ ),
75
+ ),
76
+ )
77
+ .reduce((a, b) =>
78
+ ts.factory.createLogicalOr(
79
+ a,
80
+ b,
81
+ ),
82
+ ),
83
+ create_report_call(
84
+ explore.from === "top"
85
+ ? ts.factory.createTrue()
86
+ : ts.factory.createIdentifier(
87
+ "_exceptionable",
88
+ ),
89
+ )(
90
+ ts.factory.createIdentifier(
91
+ explore.postfix
92
+ ? `_path + ${explore.postfix}`
93
+ : "_path",
94
+ ),
95
+ entry.expected,
96
+ input,
97
+ ),
98
+ ),
99
+ ]),
100
+ ].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
101
+ combiner: combine(equals)(project)(importer),
102
+ joiner: joiner(equals)(project)(importer),
103
+ success: ts.factory.createTrue(),
104
+ addition: () => importer.declare(modulo),
105
+ },
106
+ )(importer)(type, name);
107
+
108
+ return ts.factory.createArrowFunction(
109
+ undefined,
110
+ undefined,
111
+ [
112
+ IdentifierFactory.parameter(
113
+ "input",
114
+ TypeFactory.keyword("any"),
115
+ ),
116
+ ],
117
+ ts.factory.createTypeReferenceNode(
118
+ `typia.IValidation<${
119
+ name ?? TypeFactory.getFullName(project.checker)(type)
120
+ }>`,
121
+ ),
122
+ undefined,
123
+ ts.factory.createBlock(
124
+ [
125
+ StatementFactory.constant(
126
+ "errors",
127
+ ts.factory.createAsExpression(
128
+ ts.factory.createArrayLiteralExpression([]),
129
+ ts.factory.createArrayTypeNode(
130
+ TypeFactory.keyword("any"),
131
+ ),
132
+ ),
133
+ ),
134
+ StatementFactory.constant("__is", is),
135
+ ts.factory.createIfStatement(
136
+ ts.factory.createStrictEquality(
137
+ ts.factory.createFalse(),
138
+ ts.factory.createCallExpression(
139
+ ts.factory.createIdentifier("__is"),
140
+ undefined,
141
+ [ts.factory.createIdentifier("input")],
142
+ ),
143
+ ),
144
+ ts.factory.createBlock([
145
+ StatementFactory.constant(
146
+ "$report",
147
+ ts.factory.createCallExpression(
148
+ IdentifierFactory.access(
149
+ ts.factory.createParenthesizedExpression(
150
+ ts.factory.createAsExpression(
151
+ modulo,
152
+ TypeFactory.keyword("any"),
153
+ ),
154
+ ),
155
+ )("report"),
156
+ [],
157
+ [ts.factory.createIdentifier("errors")],
158
+ ),
159
+ ),
160
+ ts.factory.createExpressionStatement(
161
+ ts.factory.createCallExpression(
162
+ validate,
163
+ undefined,
164
+ [
165
+ ts.factory.createIdentifier(
166
+ "input",
167
+ ),
168
+ ts.factory.createStringLiteral(
169
+ "$input",
170
+ ),
171
+ ts.factory.createTrue(),
172
+ ],
173
+ ),
174
+ ),
175
+ ]),
176
+ ),
177
+ StatementFactory.constant(
178
+ "success",
179
+ ts.factory.createStrictEquality(
180
+ ExpressionFactory.number(0),
181
+ ts.factory.createIdentifier("errors.length"),
182
+ ),
183
+ ),
184
+ ts.factory.createReturnStatement(
185
+ ts.factory.createAsExpression(
186
+ create_output(),
187
+ TypeFactory.keyword("any"),
188
+ ),
189
+ ),
190
+ ],
191
+ true,
192
+ ),
193
+ );
194
+ };
195
+ }
196
+
197
+ const combine =
198
+ (equals: boolean) =>
199
+ (project: IProject) =>
200
+ (importer: FunctionImporter): CheckerProgrammer.IConfig.Combiner =>
201
+ (explore: CheckerProgrammer.IExplore) => {
202
+ if (explore.tracable === false)
203
+ return IsProgrammer.configure({
204
+ object: validate_object(equals)(project)(importer),
205
+ numeric: true,
206
+ })(project)(importer).combiner(explore);
207
+
208
+ const path: string = explore.postfix
209
+ ? `_path + ${explore.postfix}`
210
+ : "_path";
211
+ return (logic) => (input, binaries, expected) =>
212
+ logic === "and"
213
+ ? binaries
214
+ .map((binary) =>
215
+ binary.combined
216
+ ? binary.expression
217
+ : ts.factory.createLogicalOr(
218
+ binary.expression,
219
+ create_report_call(
220
+ explore.source === "top"
221
+ ? ts.factory.createTrue()
222
+ : ts.factory.createIdentifier(
223
+ "_exceptionable",
224
+ ),
225
+ )(
226
+ ts.factory.createIdentifier(path),
227
+ expected,
228
+ input,
229
+ ),
230
+ ),
231
+ )
232
+ .reduce(ts.factory.createLogicalAnd)
233
+ : ts.factory.createLogicalOr(
234
+ binaries
235
+ .map((binary) => binary.expression)
236
+ .reduce(ts.factory.createLogicalOr),
237
+ create_report_call(
238
+ explore.source === "top"
239
+ ? ts.factory.createTrue()
240
+ : ts.factory.createIdentifier("_exceptionable"),
241
+ )(ts.factory.createIdentifier(path), expected, input),
242
+ );
243
+ };
244
+
245
+ const validate_object =
246
+ (equals: boolean) => (project: IProject) => (importer: FunctionImporter) =>
247
+ check_object({
248
+ equals,
249
+ undefined: true,
250
+ assert: false,
251
+ reduce: ts.factory.createLogicalAnd,
252
+ positive: ts.factory.createTrue(),
253
+ superfluous: (value) =>
254
+ create_report_call()(
255
+ ts.factory.createAdd(
256
+ ts.factory.createIdentifier("_path"),
257
+ ts.factory.createCallExpression(
258
+ importer.use("join"),
259
+ undefined,
260
+ [ts.factory.createIdentifier("key")],
261
+ ),
262
+ ),
263
+ "undefined",
264
+ value,
265
+ ),
266
+ halt: (expr) =>
267
+ ts.factory.createLogicalOr(
268
+ ts.factory.createStrictEquality(
269
+ ts.factory.createFalse(),
270
+ ts.factory.createIdentifier("_exceptionable"),
271
+ ),
272
+ expr,
273
+ ),
274
+ })(project)(importer);
275
+
276
+ const joiner =
277
+ (equals: boolean) =>
278
+ (project: IProject) =>
279
+ (importer: FunctionImporter): CheckerProgrammer.IConfig.IJoiner => ({
280
+ object: validate_object(equals)(project)(importer),
281
+ array: (input, arrow) =>
282
+ check_everything(
283
+ ts.factory.createCallExpression(
284
+ IdentifierFactory.access(input)("map"),
285
+ undefined,
286
+ [arrow],
287
+ ),
288
+ ),
289
+ failure: (value, expected, explore) =>
290
+ create_report_call(
291
+ explore?.from === "top"
292
+ ? ts.factory.createTrue()
293
+ : ts.factory.createIdentifier("_exceptionable"),
294
+ )(
295
+ ts.factory.createIdentifier(
296
+ explore?.postfix ? `_path + ${explore.postfix}` : "_path",
297
+ ),
298
+ expected,
299
+ value,
300
+ ),
301
+ tuple: (binaries) =>
302
+ check_everything(
303
+ ts.factory.createArrayLiteralExpression(binaries, true),
304
+ ),
305
+ });
306
+
307
+ const create_output = () =>
308
+ ts.factory.createObjectLiteralExpression(
309
+ [
310
+ ts.factory.createShorthandPropertyAssignment("success"),
311
+ ts.factory.createShorthandPropertyAssignment("errors"),
312
+ ts.factory.createPropertyAssignment(
313
+ "data",
314
+ ts.factory.createConditionalExpression(
315
+ ts.factory.createIdentifier("success"),
316
+ undefined,
317
+ ts.factory.createIdentifier("input"),
318
+ undefined,
319
+ ts.factory.createIdentifier("undefined"),
320
+ ),
321
+ ),
322
+ ],
323
+ true,
324
+ );
325
+
326
+ const create_report_call =
327
+ (exceptionable?: ts.Expression) =>
328
+ (
329
+ path: ts.Expression,
330
+ expected: string,
331
+ value: ts.Expression,
332
+ ): ts.Expression =>
333
+ ts.factory.createCallExpression(
334
+ ts.factory.createIdentifier("$report"),
335
+ undefined,
336
+ [
337
+ exceptionable ?? ts.factory.createIdentifier("_exceptionable"),
338
+ ts.factory.createObjectLiteralExpression(
339
+ [
340
+ ts.factory.createPropertyAssignment("path", path),
341
+ ts.factory.createPropertyAssignment(
342
+ "expected",
343
+ ts.factory.createStringLiteral(expected),
344
+ ),
345
+ ts.factory.createPropertyAssignment("value", value),
346
+ ],
347
+ true,
348
+ ),
349
+ ],
350
+ );