typia 4.0.0 → 4.0.1-dev.20230604

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 (87) hide show
  1. package/lib/programmers/ApplicationProgrammer.js +1 -1
  2. package/lib/programmers/internal/application_array.js +19 -41
  3. package/lib/programmers/internal/application_array.js.map +1 -1
  4. package/lib/programmers/internal/application_definition.d.ts +1 -1
  5. package/lib/programmers/internal/application_definition.js +8 -8
  6. package/lib/programmers/internal/application_definition.js.map +1 -1
  7. package/lib/programmers/internal/application_native.js +3 -3
  8. package/lib/programmers/internal/application_object.js +4 -4
  9. package/lib/programmers/internal/application_schema.js +3 -3
  10. package/lib/programmers/internal/application_schema.js.map +1 -1
  11. package/lib/programmers/internal/application_tuple.js +8 -30
  12. package/lib/programmers/internal/application_tuple.js.map +1 -1
  13. package/lib/schemas/IJsonComponents.d.ts +1 -12
  14. package/lib/schemas/IJsonSchema.d.ts +1 -1
  15. package/package.json +1 -1
  16. package/src/IRandomGenerator.ts +34 -34
  17. package/src/factories/IdentifierFactory.ts +65 -65
  18. package/src/factories/MetadataCollection.ts +254 -254
  19. package/src/factories/MetadataFactory.ts +40 -40
  20. package/src/factories/MetadataTagFactory.ts +300 -300
  21. package/src/factories/internal/metadata/emplace_metadata_array.ts +34 -34
  22. package/src/factories/internal/metadata/emplace_metadata_definition.ts +35 -35
  23. package/src/factories/internal/metadata/emplace_metadata_object.ts +142 -142
  24. package/src/factories/internal/metadata/emplace_metadata_tuple.ts +50 -50
  25. package/src/factories/internal/metadata/explore_metadata.ts +66 -66
  26. package/src/factories/internal/metadata/iterate_metadata.ts +77 -77
  27. package/src/factories/internal/metadata/iterate_metadata_array.ts +25 -25
  28. package/src/factories/internal/metadata/iterate_metadata_collection.ts +130 -130
  29. package/src/factories/internal/metadata/iterate_metadata_definition.ts +30 -30
  30. package/src/factories/internal/metadata/iterate_metadata_object.ts +49 -49
  31. package/src/factories/internal/metadata/iterate_metadata_sort.ts +68 -68
  32. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +24 -24
  33. package/src/factories/internal/metadata/iterate_metadata_union.ts +68 -68
  34. package/src/metadata/IMetadata.ts +27 -27
  35. package/src/metadata/IMetadataAlias.ts +12 -12
  36. package/src/metadata/IMetadataApplication.ts +7 -7
  37. package/src/metadata/IMetadataArray.ts +10 -10
  38. package/src/metadata/IMetadataCollection.ts +11 -11
  39. package/src/metadata/IMetadataDictionary.ts +14 -14
  40. package/src/metadata/IMetadataObject.ts +18 -18
  41. package/src/metadata/IMetadataProperty.ts +11 -11
  42. package/src/metadata/IMetadataTuple.ts +10 -10
  43. package/src/metadata/Metadata.ts +585 -585
  44. package/src/metadata/MetadataAlias.ts +61 -61
  45. package/src/metadata/MetadataArray.ts +52 -52
  46. package/src/metadata/MetadataObject.ts +114 -114
  47. package/src/metadata/MetadataProperty.ts +64 -64
  48. package/src/metadata/MetadataTuple.ts +53 -53
  49. package/src/programmers/ApplicationProgrammer.ts +55 -55
  50. package/src/programmers/AssertProgrammer.ts +291 -291
  51. package/src/programmers/CheckerProgrammer.ts +1182 -1182
  52. package/src/programmers/CloneProgrammer.ts +595 -595
  53. package/src/programmers/FeatureProgrammer.ts +495 -495
  54. package/src/programmers/IsProgrammer.ts +250 -250
  55. package/src/programmers/LiteralsProgrammer.ts +66 -66
  56. package/src/programmers/PruneProgrammer.ts +550 -550
  57. package/src/programmers/RandomProgrammer.ts +589 -589
  58. package/src/programmers/StringifyProgrammer.ts +990 -990
  59. package/src/programmers/ValidateProgrammer.ts +313 -313
  60. package/src/programmers/helpers/FunctionImporeter.ts +78 -78
  61. package/src/programmers/helpers/RandomJoiner.ts +173 -173
  62. package/src/programmers/helpers/UnionExplorer.ts +301 -301
  63. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  64. package/src/programmers/helpers/disable_function_importer_declare.ts +26 -26
  65. package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
  66. package/src/programmers/internal/application_array.ts +30 -64
  67. package/src/programmers/internal/application_boolean.ts +15 -15
  68. package/src/programmers/internal/application_constant.ts +26 -26
  69. package/src/programmers/internal/application_default.ts +17 -17
  70. package/src/programmers/internal/application_definition.ts +45 -45
  71. package/src/programmers/internal/application_native.ts +39 -39
  72. package/src/programmers/internal/application_number.ts +74 -74
  73. package/src/programmers/internal/application_object.ts +167 -167
  74. package/src/programmers/internal/application_schema.ts +156 -164
  75. package/src/programmers/internal/application_tuple.ts +47 -77
  76. package/src/programmers/internal/check_union_array_like.ts +329 -329
  77. package/src/programmers/internal/feature_object_entries.ts +63 -63
  78. package/src/programmers/internal/wrap_metadata_rest_tuple.ts +16 -16
  79. package/src/schemas/IJsonApplication.ts +8 -8
  80. package/src/schemas/IJsonComponents.ts +34 -45
  81. package/src/schemas/IJsonSchema.ts +134 -134
  82. package/src/transformers/CallExpressionTransformer.ts +179 -179
  83. package/src/transformers/FileTransformer.ts +47 -47
  84. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +104 -104
  85. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +53 -53
  86. package/src/utils/ArrayUtil.ts +45 -45
  87. package/src/utils/RandomGenerator.ts +81 -81
@@ -1,313 +1,313 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../factories/IdentifierFactory";
4
- import { StatementFactory } from "../factories/StatementFactory";
5
- import { TypeFactory } from "../factories/TypeFactory";
6
-
7
- import { IProject } from "../transformers/IProject";
8
-
9
- import { CheckerProgrammer } from "./CheckerProgrammer";
10
- import { IsProgrammer } from "./IsProgrammer";
11
- import { FunctionImporter } from "./helpers/FunctionImporeter";
12
- import { OptionPredicator } from "./helpers/OptionPredicator";
13
- import { check_everything } from "./internal/check_everything";
14
- import { check_object } from "./internal/check_object";
15
-
16
- export namespace ValidateProgrammer {
17
- /**
18
- * @deprecated Use `write()` function instead
19
- */
20
- export const generate =
21
- (
22
- project: IProject,
23
- modulo: ts.LeftHandSideExpression,
24
- equals: boolean = false,
25
- ) =>
26
- (type: ts.Type, name?: string) =>
27
- write(project)(modulo)(equals)(type, name);
28
-
29
- export const write =
30
- (project: IProject) =>
31
- (modulo: ts.LeftHandSideExpression) =>
32
- (equals: boolean) =>
33
- (type: ts.Type, name?: string) => {
34
- const importer: FunctionImporter = new FunctionImporter();
35
-
36
- const is = IsProgrammer.write(project)(modulo, true)(equals)(
37
- type,
38
- name ?? TypeFactory.getFullName(project.checker)(type),
39
- );
40
- const validate: ts.ArrowFunction = CheckerProgrammer.write(project)(
41
- {
42
- prefix: "$v",
43
- path: true,
44
- trace: true,
45
- numeric: OptionPredicator.numeric(project.options),
46
- equals,
47
- atomist: (explore) => (tuple) => (input) =>
48
- [
49
- tuple.expression,
50
- ...tuple.tags.map((tag) =>
51
- ts.factory.createLogicalOr(
52
- tag.expression,
53
- create_report_call(
54
- explore.from === "top"
55
- ? ts.factory.createTrue()
56
- : ts.factory.createIdentifier(
57
- "_exceptionable",
58
- ),
59
- )(
60
- ts.factory.createIdentifier(
61
- explore.postfix
62
- ? `_path + ${explore.postfix}`
63
- : "_path",
64
- ),
65
- tag.expected,
66
- input,
67
- ),
68
- ),
69
- ),
70
- ].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
71
- combiner: combine(equals)(importer),
72
- joiner: joiner(equals)(importer),
73
- success: ts.factory.createTrue(),
74
- addition: () => importer.declare(modulo),
75
- },
76
- )(importer)(type, name);
77
-
78
- return ts.factory.createArrowFunction(
79
- undefined,
80
- undefined,
81
- [
82
- IdentifierFactory.parameter(
83
- "input",
84
- TypeFactory.keyword("any"),
85
- ),
86
- ],
87
- ts.factory.createTypeReferenceNode(
88
- `typia.IValidation<${
89
- name ?? TypeFactory.getFullName(project.checker)(type)
90
- }>`,
91
- ),
92
- undefined,
93
- ts.factory.createBlock(
94
- [
95
- StatementFactory.constant(
96
- "errors",
97
- ts.factory.createAsExpression(
98
- ts.factory.createArrayLiteralExpression([]),
99
- ts.factory.createArrayTypeNode(
100
- TypeFactory.keyword("any"),
101
- ),
102
- ),
103
- ),
104
- StatementFactory.constant(
105
- "$report",
106
- ts.factory.createCallExpression(
107
- IdentifierFactory.access(
108
- ts.factory.createParenthesizedExpression(
109
- ts.factory.createAsExpression(
110
- modulo,
111
- TypeFactory.keyword("any"),
112
- ),
113
- ),
114
- )("report"),
115
- [],
116
- [ts.factory.createIdentifier("errors")],
117
- ),
118
- ),
119
- StatementFactory.constant("__is", is),
120
- ts.factory.createIfStatement(
121
- ts.factory.createStrictEquality(
122
- ts.factory.createFalse(),
123
- ts.factory.createCallExpression(
124
- ts.factory.createIdentifier("__is"),
125
- undefined,
126
- [ts.factory.createIdentifier("input")],
127
- ),
128
- ),
129
- ts.factory.createExpressionStatement(
130
- ts.factory.createCallExpression(
131
- validate,
132
- undefined,
133
- [
134
- ts.factory.createIdentifier("input"),
135
- ts.factory.createStringLiteral(
136
- "$input",
137
- ),
138
- ts.factory.createTrue(),
139
- ],
140
- ),
141
- ),
142
- ),
143
- StatementFactory.constant(
144
- "success",
145
- ts.factory.createStrictEquality(
146
- ts.factory.createNumericLiteral(0),
147
- ts.factory.createIdentifier("errors.length"),
148
- ),
149
- ),
150
- ts.factory.createReturnStatement(
151
- ts.factory.createAsExpression(
152
- create_output(),
153
- TypeFactory.keyword("any"),
154
- ),
155
- ),
156
- ],
157
- true,
158
- ),
159
- );
160
- };
161
- }
162
-
163
- const combine =
164
- (equals: boolean) =>
165
- (importer: FunctionImporter): CheckerProgrammer.IConfig.Combiner =>
166
- (explore: CheckerProgrammer.IExplore) => {
167
- if (explore.tracable === false)
168
- return IsProgrammer.configure({
169
- object: validate_object(equals)(importer),
170
- numeric: true,
171
- })(importer).combiner(explore);
172
-
173
- const path: string = explore.postfix
174
- ? `_path + ${explore.postfix}`
175
- : "_path";
176
- return (logic) => (input, binaries, expected) =>
177
- logic === "and"
178
- ? binaries
179
- .map((binary) =>
180
- binary.combined
181
- ? binary.expression
182
- : ts.factory.createLogicalOr(
183
- binary.expression,
184
- create_report_call(
185
- explore.source === "top"
186
- ? ts.factory.createTrue()
187
- : ts.factory.createIdentifier(
188
- "_exceptionable",
189
- ),
190
- )(
191
- ts.factory.createIdentifier(path),
192
- expected,
193
- input,
194
- ),
195
- ),
196
- )
197
- .reduce(ts.factory.createLogicalAnd)
198
- : ts.factory.createLogicalOr(
199
- binaries
200
- .map((binary) => binary.expression)
201
- .reduce(ts.factory.createLogicalOr),
202
- create_report_call(
203
- explore.source === "top"
204
- ? ts.factory.createTrue()
205
- : ts.factory.createIdentifier("_exceptionable"),
206
- )(ts.factory.createIdentifier(path), expected, input),
207
- );
208
- };
209
-
210
- const validate_object = (equals: boolean) => (importer: FunctionImporter) =>
211
- check_object({
212
- equals,
213
- undefined: true,
214
- assert: false,
215
- reduce: ts.factory.createLogicalAnd,
216
- positive: ts.factory.createTrue(),
217
- superfluous: (value) =>
218
- create_report_call()(
219
- ts.factory.createAdd(
220
- ts.factory.createIdentifier("_path"),
221
- ts.factory.createCallExpression(
222
- importer.use("join"),
223
- undefined,
224
- [ts.factory.createIdentifier("key")],
225
- ),
226
- ),
227
- "undefined",
228
- value,
229
- ),
230
- halt: (expr) =>
231
- ts.factory.createLogicalOr(
232
- ts.factory.createStrictEquality(
233
- ts.factory.createFalse(),
234
- ts.factory.createIdentifier("_exceptionable"),
235
- ),
236
- expr,
237
- ),
238
- })(importer);
239
-
240
- const joiner =
241
- (equals: boolean) =>
242
- (importer: FunctionImporter): CheckerProgrammer.IConfig.IJoiner => ({
243
- object: validate_object(equals)(importer),
244
- array: (input, arrow) =>
245
- check_everything(
246
- ts.factory.createCallExpression(
247
- IdentifierFactory.access(input)("map"),
248
- undefined,
249
- [arrow],
250
- ),
251
- ),
252
- failure: (value, expected, explore) =>
253
- create_report_call(
254
- explore?.from === "top"
255
- ? ts.factory.createTrue()
256
- : ts.factory.createIdentifier("_exceptionable"),
257
- )(
258
- ts.factory.createIdentifier(
259
- explore?.postfix ? `_path + ${explore.postfix}` : "_path",
260
- ),
261
- expected,
262
- value,
263
- ),
264
- tuple: (binaries) =>
265
- check_everything(
266
- ts.factory.createArrayLiteralExpression(binaries, true),
267
- ),
268
- });
269
-
270
- const create_output = () =>
271
- ts.factory.createObjectLiteralExpression(
272
- [
273
- ts.factory.createShorthandPropertyAssignment("success"),
274
- ts.factory.createShorthandPropertyAssignment("errors"),
275
- ts.factory.createPropertyAssignment(
276
- "data",
277
- ts.factory.createConditionalExpression(
278
- ts.factory.createIdentifier("success"),
279
- undefined,
280
- ts.factory.createIdentifier("input"),
281
- undefined,
282
- ts.factory.createIdentifier("undefined"),
283
- ),
284
- ),
285
- ],
286
- true,
287
- );
288
-
289
- const create_report_call =
290
- (exceptionable?: ts.Expression) =>
291
- (
292
- path: ts.Expression,
293
- expected: string,
294
- value: ts.Expression,
295
- ): ts.Expression =>
296
- ts.factory.createCallExpression(
297
- ts.factory.createIdentifier("$report"),
298
- undefined,
299
- [
300
- exceptionable ?? ts.factory.createIdentifier("_exceptionable"),
301
- ts.factory.createObjectLiteralExpression(
302
- [
303
- ts.factory.createPropertyAssignment("path", path),
304
- ts.factory.createPropertyAssignment(
305
- "expected",
306
- ts.factory.createStringLiteral(expected),
307
- ),
308
- ts.factory.createPropertyAssignment("value", value),
309
- ],
310
- true,
311
- ),
312
- ],
313
- );
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../factories/IdentifierFactory";
4
+ import { StatementFactory } from "../factories/StatementFactory";
5
+ import { TypeFactory } from "../factories/TypeFactory";
6
+
7
+ import { IProject } from "../transformers/IProject";
8
+
9
+ import { CheckerProgrammer } from "./CheckerProgrammer";
10
+ import { IsProgrammer } from "./IsProgrammer";
11
+ import { FunctionImporter } from "./helpers/FunctionImporeter";
12
+ import { OptionPredicator } from "./helpers/OptionPredicator";
13
+ import { check_everything } from "./internal/check_everything";
14
+ import { check_object } from "./internal/check_object";
15
+
16
+ export namespace ValidateProgrammer {
17
+ /**
18
+ * @deprecated Use `write()` function instead
19
+ */
20
+ export const generate =
21
+ (
22
+ project: IProject,
23
+ modulo: ts.LeftHandSideExpression,
24
+ equals: boolean = false,
25
+ ) =>
26
+ (type: ts.Type, name?: string) =>
27
+ write(project)(modulo)(equals)(type, name);
28
+
29
+ export const write =
30
+ (project: IProject) =>
31
+ (modulo: ts.LeftHandSideExpression) =>
32
+ (equals: boolean) =>
33
+ (type: ts.Type, name?: string) => {
34
+ const importer: FunctionImporter = new FunctionImporter();
35
+
36
+ const is = IsProgrammer.write(project)(modulo, true)(equals)(
37
+ type,
38
+ name ?? TypeFactory.getFullName(project.checker)(type),
39
+ );
40
+ const validate: ts.ArrowFunction = CheckerProgrammer.write(project)(
41
+ {
42
+ prefix: "$v",
43
+ path: true,
44
+ trace: true,
45
+ numeric: OptionPredicator.numeric(project.options),
46
+ equals,
47
+ atomist: (explore) => (tuple) => (input) =>
48
+ [
49
+ tuple.expression,
50
+ ...tuple.tags.map((tag) =>
51
+ ts.factory.createLogicalOr(
52
+ tag.expression,
53
+ create_report_call(
54
+ explore.from === "top"
55
+ ? ts.factory.createTrue()
56
+ : ts.factory.createIdentifier(
57
+ "_exceptionable",
58
+ ),
59
+ )(
60
+ ts.factory.createIdentifier(
61
+ explore.postfix
62
+ ? `_path + ${explore.postfix}`
63
+ : "_path",
64
+ ),
65
+ tag.expected,
66
+ input,
67
+ ),
68
+ ),
69
+ ),
70
+ ].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
71
+ combiner: combine(equals)(importer),
72
+ joiner: joiner(equals)(importer),
73
+ success: ts.factory.createTrue(),
74
+ addition: () => importer.declare(modulo),
75
+ },
76
+ )(importer)(type, name);
77
+
78
+ return ts.factory.createArrowFunction(
79
+ undefined,
80
+ undefined,
81
+ [
82
+ IdentifierFactory.parameter(
83
+ "input",
84
+ TypeFactory.keyword("any"),
85
+ ),
86
+ ],
87
+ ts.factory.createTypeReferenceNode(
88
+ `typia.IValidation<${
89
+ name ?? TypeFactory.getFullName(project.checker)(type)
90
+ }>`,
91
+ ),
92
+ undefined,
93
+ ts.factory.createBlock(
94
+ [
95
+ StatementFactory.constant(
96
+ "errors",
97
+ ts.factory.createAsExpression(
98
+ ts.factory.createArrayLiteralExpression([]),
99
+ ts.factory.createArrayTypeNode(
100
+ TypeFactory.keyword("any"),
101
+ ),
102
+ ),
103
+ ),
104
+ StatementFactory.constant(
105
+ "$report",
106
+ ts.factory.createCallExpression(
107
+ IdentifierFactory.access(
108
+ ts.factory.createParenthesizedExpression(
109
+ ts.factory.createAsExpression(
110
+ modulo,
111
+ TypeFactory.keyword("any"),
112
+ ),
113
+ ),
114
+ )("report"),
115
+ [],
116
+ [ts.factory.createIdentifier("errors")],
117
+ ),
118
+ ),
119
+ StatementFactory.constant("__is", is),
120
+ ts.factory.createIfStatement(
121
+ ts.factory.createStrictEquality(
122
+ ts.factory.createFalse(),
123
+ ts.factory.createCallExpression(
124
+ ts.factory.createIdentifier("__is"),
125
+ undefined,
126
+ [ts.factory.createIdentifier("input")],
127
+ ),
128
+ ),
129
+ ts.factory.createExpressionStatement(
130
+ ts.factory.createCallExpression(
131
+ validate,
132
+ undefined,
133
+ [
134
+ ts.factory.createIdentifier("input"),
135
+ ts.factory.createStringLiteral(
136
+ "$input",
137
+ ),
138
+ ts.factory.createTrue(),
139
+ ],
140
+ ),
141
+ ),
142
+ ),
143
+ StatementFactory.constant(
144
+ "success",
145
+ ts.factory.createStrictEquality(
146
+ ts.factory.createNumericLiteral(0),
147
+ ts.factory.createIdentifier("errors.length"),
148
+ ),
149
+ ),
150
+ ts.factory.createReturnStatement(
151
+ ts.factory.createAsExpression(
152
+ create_output(),
153
+ TypeFactory.keyword("any"),
154
+ ),
155
+ ),
156
+ ],
157
+ true,
158
+ ),
159
+ );
160
+ };
161
+ }
162
+
163
+ const combine =
164
+ (equals: boolean) =>
165
+ (importer: FunctionImporter): CheckerProgrammer.IConfig.Combiner =>
166
+ (explore: CheckerProgrammer.IExplore) => {
167
+ if (explore.tracable === false)
168
+ return IsProgrammer.configure({
169
+ object: validate_object(equals)(importer),
170
+ numeric: true,
171
+ })(importer).combiner(explore);
172
+
173
+ const path: string = explore.postfix
174
+ ? `_path + ${explore.postfix}`
175
+ : "_path";
176
+ return (logic) => (input, binaries, expected) =>
177
+ logic === "and"
178
+ ? binaries
179
+ .map((binary) =>
180
+ binary.combined
181
+ ? binary.expression
182
+ : ts.factory.createLogicalOr(
183
+ binary.expression,
184
+ create_report_call(
185
+ explore.source === "top"
186
+ ? ts.factory.createTrue()
187
+ : ts.factory.createIdentifier(
188
+ "_exceptionable",
189
+ ),
190
+ )(
191
+ ts.factory.createIdentifier(path),
192
+ expected,
193
+ input,
194
+ ),
195
+ ),
196
+ )
197
+ .reduce(ts.factory.createLogicalAnd)
198
+ : ts.factory.createLogicalOr(
199
+ binaries
200
+ .map((binary) => binary.expression)
201
+ .reduce(ts.factory.createLogicalOr),
202
+ create_report_call(
203
+ explore.source === "top"
204
+ ? ts.factory.createTrue()
205
+ : ts.factory.createIdentifier("_exceptionable"),
206
+ )(ts.factory.createIdentifier(path), expected, input),
207
+ );
208
+ };
209
+
210
+ const validate_object = (equals: boolean) => (importer: FunctionImporter) =>
211
+ check_object({
212
+ equals,
213
+ undefined: true,
214
+ assert: false,
215
+ reduce: ts.factory.createLogicalAnd,
216
+ positive: ts.factory.createTrue(),
217
+ superfluous: (value) =>
218
+ create_report_call()(
219
+ ts.factory.createAdd(
220
+ ts.factory.createIdentifier("_path"),
221
+ ts.factory.createCallExpression(
222
+ importer.use("join"),
223
+ undefined,
224
+ [ts.factory.createIdentifier("key")],
225
+ ),
226
+ ),
227
+ "undefined",
228
+ value,
229
+ ),
230
+ halt: (expr) =>
231
+ ts.factory.createLogicalOr(
232
+ ts.factory.createStrictEquality(
233
+ ts.factory.createFalse(),
234
+ ts.factory.createIdentifier("_exceptionable"),
235
+ ),
236
+ expr,
237
+ ),
238
+ })(importer);
239
+
240
+ const joiner =
241
+ (equals: boolean) =>
242
+ (importer: FunctionImporter): CheckerProgrammer.IConfig.IJoiner => ({
243
+ object: validate_object(equals)(importer),
244
+ array: (input, arrow) =>
245
+ check_everything(
246
+ ts.factory.createCallExpression(
247
+ IdentifierFactory.access(input)("map"),
248
+ undefined,
249
+ [arrow],
250
+ ),
251
+ ),
252
+ failure: (value, expected, explore) =>
253
+ create_report_call(
254
+ explore?.from === "top"
255
+ ? ts.factory.createTrue()
256
+ : ts.factory.createIdentifier("_exceptionable"),
257
+ )(
258
+ ts.factory.createIdentifier(
259
+ explore?.postfix ? `_path + ${explore.postfix}` : "_path",
260
+ ),
261
+ expected,
262
+ value,
263
+ ),
264
+ tuple: (binaries) =>
265
+ check_everything(
266
+ ts.factory.createArrayLiteralExpression(binaries, true),
267
+ ),
268
+ });
269
+
270
+ const create_output = () =>
271
+ ts.factory.createObjectLiteralExpression(
272
+ [
273
+ ts.factory.createShorthandPropertyAssignment("success"),
274
+ ts.factory.createShorthandPropertyAssignment("errors"),
275
+ ts.factory.createPropertyAssignment(
276
+ "data",
277
+ ts.factory.createConditionalExpression(
278
+ ts.factory.createIdentifier("success"),
279
+ undefined,
280
+ ts.factory.createIdentifier("input"),
281
+ undefined,
282
+ ts.factory.createIdentifier("undefined"),
283
+ ),
284
+ ),
285
+ ],
286
+ true,
287
+ );
288
+
289
+ const create_report_call =
290
+ (exceptionable?: ts.Expression) =>
291
+ (
292
+ path: ts.Expression,
293
+ expected: string,
294
+ value: ts.Expression,
295
+ ): ts.Expression =>
296
+ ts.factory.createCallExpression(
297
+ ts.factory.createIdentifier("$report"),
298
+ undefined,
299
+ [
300
+ exceptionable ?? ts.factory.createIdentifier("_exceptionable"),
301
+ ts.factory.createObjectLiteralExpression(
302
+ [
303
+ ts.factory.createPropertyAssignment("path", path),
304
+ ts.factory.createPropertyAssignment(
305
+ "expected",
306
+ ts.factory.createStringLiteral(expected),
307
+ ),
308
+ ts.factory.createPropertyAssignment("value", value),
309
+ ],
310
+ true,
311
+ ),
312
+ ],
313
+ );