typia 7.0.0-dev.20240923 → 7.0.0-dev.20240928

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 (57) hide show
  1. package/lib/index.mjs +1 -0
  2. package/lib/index.mjs.map +1 -1
  3. package/lib/programmers/AssertProgrammer.d.ts +1 -1
  4. package/lib/programmers/AssertProgrammer.js +169 -127
  5. package/lib/programmers/AssertProgrammer.js.map +1 -1
  6. package/lib/programmers/CheckerProgrammer.d.ts +70 -15
  7. package/lib/programmers/CheckerProgrammer.js +998 -638
  8. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  9. package/lib/programmers/FeatureProgrammer.d.ts +7 -3
  10. package/lib/programmers/FeatureProgrammer.js +17 -17
  11. package/lib/programmers/FeatureProgrammer.js.map +1 -1
  12. package/lib/programmers/IsProgrammer.d.ts +25 -4
  13. package/lib/programmers/IsProgrammer.js +54 -39
  14. package/lib/programmers/IsProgrammer.js.map +1 -1
  15. package/lib/programmers/ValidateProgrammer.js +110 -97
  16. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  17. package/lib/programmers/helpers/UnionExplorer.d.ts +1 -1
  18. package/lib/programmers/json/JsonStringifyProgrammer.js +71 -38
  19. package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
  20. package/lib/programmers/llm/LlmApplicationProgrammer.js +16 -2
  21. package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
  22. package/lib/programmers/misc/MiscCloneProgrammer.js +504 -406
  23. package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
  24. package/lib/programmers/misc/MiscLiteralsProgrammer.js +3 -3
  25. package/lib/programmers/misc/MiscLiteralsProgrammer.js.map +1 -1
  26. package/lib/programmers/misc/MiscPruneProgrammer.js +365 -301
  27. package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
  28. package/lib/programmers/notations/NotationGeneralProgrammer.js +62 -15
  29. package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
  30. package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +17 -3
  31. package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
  32. package/lib/tags/Example.d.ts +14 -0
  33. package/lib/tags/Example.js +3 -0
  34. package/lib/tags/Example.js.map +1 -0
  35. package/lib/tags/Examples.d.ts +10 -0
  36. package/lib/tags/Examples.js +3 -0
  37. package/lib/tags/Examples.js.map +1 -0
  38. package/lib/tags/index.d.ts +2 -0
  39. package/lib/tags/index.js +2 -0
  40. package/lib/tags/index.js.map +1 -1
  41. package/package.json +2 -2
  42. package/src/programmers/AssertProgrammer.ts +185 -143
  43. package/src/programmers/CheckerProgrammer.ts +1380 -998
  44. package/src/programmers/FeatureProgrammer.ts +40 -34
  45. package/src/programmers/IsProgrammer.ts +94 -66
  46. package/src/programmers/ValidateProgrammer.ts +149 -137
  47. package/src/programmers/helpers/UnionExplorer.ts +1 -1
  48. package/src/programmers/json/JsonStringifyProgrammer.ts +60 -38
  49. package/src/programmers/llm/LlmApplicationProgrammer.ts +51 -32
  50. package/src/programmers/misc/MiscCloneProgrammer.ts +775 -600
  51. package/src/programmers/misc/MiscLiteralsProgrammer.ts +4 -4
  52. package/src/programmers/misc/MiscPruneProgrammer.ts +532 -415
  53. package/src/programmers/notations/NotationGeneralProgrammer.ts +64 -26
  54. package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +16 -9
  55. package/src/tags/Example.ts +17 -0
  56. package/src/tags/Examples.ts +16 -0
  57. package/src/tags/index.ts +20 -18
@@ -82,685 +82,1045 @@ var CheckerProgrammer;
82
82
  WRITERS
83
83
  ----------------------------------------------------------- */
84
84
  CheckerProgrammer.compose = function (props) {
85
- return FeatureProgrammer_1.FeatureProgrammer.compose(__assign(__assign({}, props), { config: configure(props.context)(props.config)(props.importer) }));
85
+ return FeatureProgrammer_1.FeatureProgrammer.compose(__assign(__assign({}, props), { config: configure(props) }));
86
86
  };
87
- CheckerProgrammer.write = function (project) {
88
- return function (config) {
89
- return function (importer) {
90
- return FeatureProgrammer_1.FeatureProgrammer.write(project)(configure(project)(config)(importer))(importer);
91
- };
92
- };
87
+ CheckerProgrammer.write = function (props) {
88
+ return FeatureProgrammer_1.FeatureProgrammer.write(props.context)(configure(props))(props.importer)(props.type, props.name);
93
89
  };
94
- CheckerProgrammer.write_object_functions = function (project) {
95
- return function (config) {
96
- return function (importer) {
97
- return FeatureProgrammer_1.FeatureProgrammer.write_object_functions(configure(project)(config)(importer))(importer);
98
- };
99
- };
90
+ CheckerProgrammer.write_object_functions = function (props) {
91
+ return FeatureProgrammer_1.FeatureProgrammer.write_object_functions({
92
+ config: configure(props),
93
+ importer: props.importer,
94
+ collection: props.collection,
95
+ });
100
96
  };
101
- CheckerProgrammer.write_union_functions = function (project) {
102
- return function (config) {
103
- return function (importer) {
104
- return FeatureProgrammer_1.FeatureProgrammer.write_union_functions(configure(project)(__assign(__assign({}, config), { numeric: false }))(importer));
105
- };
106
- };
97
+ CheckerProgrammer.write_union_functions = function (props) {
98
+ return FeatureProgrammer_1.FeatureProgrammer.write_union_functions(configure({
99
+ context: props.context,
100
+ config: __assign(__assign({}, props.config), { numeric: false }),
101
+ importer: props.importer,
102
+ }))(props.collection);
107
103
  };
108
- CheckerProgrammer.write_array_functions = function (project) {
109
- return function (config) {
110
- return function (importer) {
111
- return function (collection) {
112
- return collection
113
- .arrays()
114
- .filter(function (a) { return a.recursive; })
115
- .map(function (type, i) {
116
- return StatementFactory_1.StatementFactory.constant("".concat(config.prefix, "a").concat(i), typescript_1.default.factory.createArrowFunction(undefined, undefined, FeatureProgrammer_1.FeatureProgrammer.parameterDeclarations(config)(TypeFactory_1.TypeFactory.keyword("any"))(typescript_1.default.factory.createIdentifier("input")), TypeFactory_1.TypeFactory.keyword("any"), undefined, decode_array_inline(project)(config)(importer)(typescript_1.default.factory.createIdentifier("input"), MetadataArray_1.MetadataArray.create({
117
- type: type,
118
- tags: [],
119
- }), {
120
- tracable: config.trace,
121
- source: "function",
122
- from: "array",
123
- postfix: "",
124
- })));
125
- });
126
- };
127
- };
128
- };
104
+ CheckerProgrammer.write_array_functions = function (props) {
105
+ return props.collection
106
+ .arrays()
107
+ .filter(function (a) { return a.recursive; })
108
+ .map(function (type, i) {
109
+ return StatementFactory_1.StatementFactory.constant("".concat(props.config.prefix, "a").concat(i), typescript_1.default.factory.createArrowFunction(undefined, undefined, FeatureProgrammer_1.FeatureProgrammer.parameterDeclarations(props.config)(TypeFactory_1.TypeFactory.keyword("any"))(typescript_1.default.factory.createIdentifier("input")), TypeFactory_1.TypeFactory.keyword("any"), undefined, decode_array_inline(__assign(__assign({}, props), { input: typescript_1.default.factory.createIdentifier("input"), array: MetadataArray_1.MetadataArray.create({
110
+ type: type,
111
+ tags: [],
112
+ }), explore: {
113
+ tracable: props.config.trace,
114
+ source: "function",
115
+ from: "array",
116
+ postfix: "",
117
+ } }))));
118
+ });
129
119
  };
130
- CheckerProgrammer.write_tuple_functions = function (project) {
131
- return function (config) {
132
- return function (importer) {
133
- return function (collection) {
134
- return collection
135
- .tuples()
136
- .filter(function (t) { return t.recursive; })
137
- .map(function (tuple, i) {
138
- return StatementFactory_1.StatementFactory.constant("".concat(config.prefix, "t").concat(i), typescript_1.default.factory.createArrowFunction(undefined, undefined, FeatureProgrammer_1.FeatureProgrammer.parameterDeclarations(config)(TypeFactory_1.TypeFactory.keyword("any"))(typescript_1.default.factory.createIdentifier("input")), TypeFactory_1.TypeFactory.keyword("any"), undefined, decode_tuple_inline(project)(config)(importer)(typescript_1.default.factory.createIdentifier("input"), tuple, {
139
- tracable: config.trace,
140
- source: "function",
141
- from: "array",
142
- postfix: "",
143
- })));
144
- });
145
- };
146
- };
147
- };
120
+ CheckerProgrammer.write_tuple_functions = function (props) {
121
+ return props.collection
122
+ .tuples()
123
+ .filter(function (t) { return t.recursive; })
124
+ .map(function (tuple, i) {
125
+ return StatementFactory_1.StatementFactory.constant("".concat(props.config.prefix, "t").concat(i), typescript_1.default.factory.createArrowFunction(undefined, undefined, FeatureProgrammer_1.FeatureProgrammer.parameterDeclarations(props.config)(TypeFactory_1.TypeFactory.keyword("any"))(typescript_1.default.factory.createIdentifier("input")), TypeFactory_1.TypeFactory.keyword("any"), undefined, decode_tuple_inline({
126
+ config: props.config,
127
+ context: props.context,
128
+ importer: props.importer,
129
+ input: typescript_1.default.factory.createIdentifier("input"),
130
+ tuple: tuple,
131
+ explore: {
132
+ tracable: props.config.trace,
133
+ source: "function",
134
+ from: "array",
135
+ postfix: "",
136
+ },
137
+ })));
138
+ });
148
139
  };
149
- var configure = function (project) {
150
- return function (config) {
151
- return function (importer) {
152
- var _a;
153
- return ({
154
- types: {
155
- input: function () { return TypeFactory_1.TypeFactory.keyword("any"); },
156
- output: function (type, name) {
157
- return typescript_1.default.factory.createTypePredicateNode(undefined, "input", typescript_1.default.factory.createTypeReferenceNode(name !== null && name !== void 0 ? name : TypeFactory_1.TypeFactory.getFullName(project.checker)(type)));
158
- },
140
+ var configure = function (props) {
141
+ var _a;
142
+ return ({
143
+ types: {
144
+ input: function () { return TypeFactory_1.TypeFactory.keyword("any"); },
145
+ output: function (type, name) {
146
+ return typescript_1.default.factory.createTypePredicateNode(undefined, "input", typescript_1.default.factory.createTypeReferenceNode(name !== null && name !== void 0 ? name : TypeFactory_1.TypeFactory.getFullName(props.context.checker)(type)));
147
+ },
148
+ },
149
+ trace: props.config.trace,
150
+ path: props.config.path,
151
+ prefix: props.config.prefix,
152
+ initializer: function (context) { return function (importer) { return function (type) {
153
+ var collection = new MetadataCollection_1.MetadataCollection();
154
+ var result = MetadataFactory_1.MetadataFactory.analyze({
155
+ checker: context.checker,
156
+ transformer: context.transformer,
157
+ options: {
158
+ escape: false,
159
+ constant: true,
160
+ absorb: true,
159
161
  },
160
- trace: config.trace,
161
- path: config.path,
162
- prefix: config.prefix,
163
- initializer: function (project) { return function (importer) { return function (type) {
164
- var collection = new MetadataCollection_1.MetadataCollection();
165
- var result = MetadataFactory_1.MetadataFactory.analyze({
166
- checker: project.checker,
167
- transformer: project.transformer,
168
- options: {
169
- escape: false,
170
- constant: true,
171
- absorb: true,
172
- },
173
- collection: collection,
174
- type: type,
162
+ collection: collection,
163
+ type: type,
164
+ });
165
+ if (result.success === false)
166
+ throw TransformerError_1.TransformerError.from("typia.".concat(importer.method))(result.errors);
167
+ return [collection, result.data];
168
+ }; }; },
169
+ addition: props.config.addition,
170
+ decoder: function () {
171
+ return props.config.decoder
172
+ ? function (input, metadata, explore) {
173
+ return props.config.decoder()(input, metadata, explore);
174
+ }
175
+ : function (input, metadata, explore) {
176
+ return CheckerProgrammer.decode({
177
+ context: props.context,
178
+ config: props.config,
179
+ importer: props.importer,
180
+ input: input,
181
+ metadata: metadata,
182
+ explore: explore,
183
+ });
184
+ };
185
+ },
186
+ objector: {
187
+ checker: function () { return function (input, metadata, explore) {
188
+ var _a, _b, _c;
189
+ return (_c = (_b = (_a = props.config).decoder) === null || _b === void 0 ? void 0 : _b.call(_a)(input, metadata, explore)) !== null && _c !== void 0 ? _c : CheckerProgrammer.decode({
190
+ context: props.context,
191
+ config: props.config,
192
+ importer: props.importer,
193
+ input: input,
194
+ metadata: metadata,
195
+ explore: explore,
196
+ });
197
+ }; },
198
+ decoder: function () { return function (input, object, explore) {
199
+ return CheckerProgrammer.decode_object({
200
+ config: props.config,
201
+ importer: props.importer,
202
+ input: input,
203
+ object: object,
204
+ explore: explore,
205
+ });
206
+ }; },
207
+ joiner: props.config.joiner.object,
208
+ unionizer: props.config.equals
209
+ ? (0, decode_union_object_1.decode_union_object)(function (input, object, explore) {
210
+ return CheckerProgrammer.decode_object({
211
+ config: props.config,
212
+ importer: props.importer,
213
+ object: object,
214
+ input: input,
215
+ explore: explore,
216
+ });
217
+ })(function (input, object, explore) {
218
+ return CheckerProgrammer.decode_object({
219
+ config: props.config,
220
+ importer: props.importer,
221
+ input: input,
222
+ object: object,
223
+ explore: __assign(__assign({}, explore), { tracable: true }),
224
+ });
225
+ })((_a = props.config.joiner.is) !== null && _a !== void 0 ? _a : (function (expr) { return expr; }))(function (input, expected) {
226
+ return typescript_1.default.factory.createReturnStatement(props.config.joiner.failure({
227
+ input: input,
228
+ expected: expected,
229
+ }));
230
+ })
231
+ : function (input, targets, explore) {
232
+ return props.config.combiner({
233
+ explore: explore,
234
+ logic: "or",
235
+ input: input,
236
+ binaries: targets.map(function (object) { return ({
237
+ expression: CheckerProgrammer.decode_object({
238
+ config: props.config,
239
+ importer: props.importer,
240
+ input: input,
241
+ object: object,
242
+ explore: explore,
243
+ }),
244
+ combined: true,
245
+ }); }),
246
+ expected: "(".concat(targets.map(function (t) { return t.name; }).join(" | "), ")"),
175
247
  });
176
- if (result.success === false)
177
- throw TransformerError_1.TransformerError.from("typia.".concat(importer.method))(result.errors);
178
- return [collection, result.data];
179
- }; }; },
180
- addition: config.addition,
181
- decoder: function () { var _a, _b; return (_b = (_a = config.decoder) === null || _a === void 0 ? void 0 : _a.call(config)) !== null && _b !== void 0 ? _b : CheckerProgrammer.decode(project)(config)(importer); },
182
- objector: {
183
- checker: function () { var _a, _b; return (_b = (_a = config.decoder) === null || _a === void 0 ? void 0 : _a.call(config)) !== null && _b !== void 0 ? _b : CheckerProgrammer.decode(project)(config)(importer); },
184
- decoder: function () { return CheckerProgrammer.decode_object(config)(importer); },
185
- joiner: config.joiner.object,
186
- unionizer: config.equals
187
- ? (0, decode_union_object_1.decode_union_object)(CheckerProgrammer.decode_object(config)(importer))(function (input, obj, explore) {
188
- return CheckerProgrammer.decode_object(config)(importer)(input, obj, __assign(__assign({}, explore), { tracable: true }));
189
- })((_a = config.joiner.is) !== null && _a !== void 0 ? _a : (function (expr) { return expr; }))(function (value, expected) {
190
- return typescript_1.default.factory.createReturnStatement(config.joiner.failure(value, expected));
191
- })
192
- : function (input, targets, explore) {
193
- return config.combiner(explore)("or")(input, targets.map(function (obj) { return ({
194
- expression: CheckerProgrammer.decode_object(config)(importer)(input, obj, explore),
195
- combined: true,
196
- }); }), "(".concat(targets.map(function (t) { return t.name; }).join(" | "), ")"));
197
- },
198
- failure: function (value, expected) {
199
- return typescript_1.default.factory.createReturnStatement(config.joiner.failure(value, expected));
200
- },
201
- is: config.joiner.is,
202
- required: config.joiner.required,
203
- full: config.joiner.full,
204
- type: TypeFactory_1.TypeFactory.keyword("boolean"),
205
- },
206
- generator: {
207
- unions: config.numeric
208
- ? function () {
209
- return FeatureProgrammer_1.FeatureProgrammer.write_union_functions(configure(project)(__assign(__assign({}, config), { numeric: false }))(importer));
210
- }
211
- : undefined,
212
- arrays: function () { return CheckerProgrammer.write_array_functions(project)(config)(importer); },
213
- tuples: function () { return CheckerProgrammer.write_tuple_functions(project)(config)(importer); },
214
248
  },
215
- });
216
- };
217
- };
249
+ failure: function (input, expected) {
250
+ return typescript_1.default.factory.createReturnStatement(props.config.joiner.failure({
251
+ input: input,
252
+ expected: expected,
253
+ }));
254
+ },
255
+ is: props.config.joiner.is,
256
+ required: props.config.joiner.required,
257
+ full: props.config.joiner.full
258
+ ? function (condition) { return function (input, expected, explore) {
259
+ return props.config.joiner.full({
260
+ condition: condition,
261
+ input: input,
262
+ expected: expected,
263
+ explore: explore,
264
+ });
265
+ }; }
266
+ : undefined,
267
+ type: TypeFactory_1.TypeFactory.keyword("boolean"),
268
+ },
269
+ generator: {
270
+ unions: props.config.numeric
271
+ ? function () {
272
+ return FeatureProgrammer_1.FeatureProgrammer.write_union_functions(configure(__assign(__assign({}, props), { config: __assign(__assign({}, props.config), { numeric: false }) })));
273
+ }
274
+ : undefined,
275
+ arrays: function () { return function (collection) {
276
+ return CheckerProgrammer.write_array_functions(__assign(__assign({}, props), { collection: collection }));
277
+ }; },
278
+ tuples: function () { return function (collection) {
279
+ return CheckerProgrammer.write_tuple_functions(__assign(__assign({}, props), { collection: collection }));
280
+ }; },
281
+ },
282
+ });
218
283
  };
219
284
  /* -----------------------------------------------------------
220
285
  DECODERS
221
286
  ----------------------------------------------------------- */
222
- /**
223
- * @internal
224
- */
225
- CheckerProgrammer.decode = function (project) {
226
- return function (config) {
227
- return function (importer) {
228
- return function (input, metadata, explore) {
229
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
230
- if (metadata.any)
231
- return config.success;
232
- var top = [];
233
- var binaries = [];
234
- var add = create_add(binaries)(input);
235
- var getConstantValue = function (value) {
236
- if (typeof value === "string")
237
- return typescript_1.default.factory.createStringLiteral(value);
238
- else if (typeof value === "bigint")
239
- return ExpressionFactory_1.ExpressionFactory.bigint(value);
240
- return typescript_1.default.factory.createIdentifier(value.toString());
241
- };
242
- //----
243
- // CHECK OPTIONAL
244
- //----
245
- // @todo -> should be elaborated
246
- var checkOptional = metadata.empty() || metadata.isUnionBucket();
247
- // NULLABLE
248
- if (checkOptional || metadata.nullable)
249
- (metadata.nullable ? add : create_add(top)(input))(metadata.nullable, ValueFactory_1.ValueFactory.NULL());
250
- // UNDEFINDABLE
251
- if (checkOptional || !metadata.isRequired())
252
- (metadata.isRequired() ? create_add(top)(input) : add)(!metadata.isRequired(), ValueFactory_1.ValueFactory.UNDEFINED());
253
- // FUNCTIONAL
254
- if (metadata.functions.length)
255
- if (OptionPredicator_1.OptionPredicator.functional(project.options) ||
256
- metadata.size() !== 1)
257
- add(true, typescript_1.default.factory.createStringLiteral("function"), ValueFactory_1.ValueFactory.TYPEOF(input));
258
- else
259
- binaries.push({
260
- combined: false,
261
- expression: config.success,
262
- });
263
- //----
264
- // VALUES
265
- //----
266
- // CONSTANT VALUES
267
- var constants = metadata.constants.filter(function (c) {
268
- return AtomicPredicator_1.AtomicPredicator.constant({
269
- metadata: metadata,
270
- name: c.type,
271
- });
272
- });
273
- var constantLength = constants
274
- .map(function (c) { return c.values.length; })
275
- .reduce(function (a, b) { return a + b; }, 0);
276
- if (constantLength >= 10) {
277
- var values = constants
278
- .map(function (c) { return c.values.map(function (v) { return v.value; }); })
279
- .flat();
280
- add(true, typescript_1.default.factory.createTrue(), typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(importer.emplaceVariable("".concat(config.prefix, "v").concat(importer.increment()), typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier("Set"), undefined, [
281
- typescript_1.default.factory.createArrayLiteralExpression(values.map(function (v) {
282
- return typeof v === "boolean"
283
- ? v === true
284
- ? typescript_1.default.factory.createTrue()
285
- : typescript_1.default.factory.createFalse()
286
- : typeof v === "bigint"
287
- ? ExpressionFactory_1.ExpressionFactory.bigint(v)
288
- : typeof v === "number"
289
- ? ExpressionFactory_1.ExpressionFactory.number(v)
290
- : typescript_1.default.factory.createStringLiteral(v.toString());
291
- })),
292
- ])))("has"), undefined, [input]));
293
- }
294
- else
287
+ CheckerProgrammer.decode = function (props) {
288
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
289
+ if (props.metadata.any)
290
+ return props.config.success;
291
+ var top = [];
292
+ var binaries = [];
293
+ var add = function (next) {
294
+ return create_add({
295
+ binaries: binaries,
296
+ left: next.left,
297
+ right: next.right,
298
+ exact: next.exact,
299
+ default: props.input,
300
+ });
301
+ };
302
+ var getConstantValue = function (value) {
303
+ if (typeof value === "string")
304
+ return typescript_1.default.factory.createStringLiteral(value);
305
+ else if (typeof value === "bigint")
306
+ return ExpressionFactory_1.ExpressionFactory.bigint(value);
307
+ return typescript_1.default.factory.createIdentifier(value.toString());
308
+ };
309
+ //----
310
+ // CHECK OPTIONAL
311
+ //----
312
+ // @todo -> should be elaborated
313
+ var checkOptional = props.metadata.empty() || props.metadata.isUnionBucket();
314
+ // NULLABLE
315
+ if (checkOptional || props.metadata.nullable)
316
+ if (props.metadata.nullable)
317
+ add({
318
+ exact: props.metadata.nullable,
319
+ left: ValueFactory_1.ValueFactory.NULL(),
320
+ });
321
+ else
322
+ create_add({
323
+ binaries: top,
324
+ default: props.input,
325
+ exact: props.metadata.nullable,
326
+ left: ValueFactory_1.ValueFactory.NULL(),
327
+ });
328
+ // UNDEFINDABLE
329
+ if (checkOptional || !props.metadata.isRequired())
330
+ if (props.metadata.isRequired())
331
+ create_add({
332
+ binaries: top,
333
+ default: props.input,
334
+ exact: false,
335
+ left: ValueFactory_1.ValueFactory.UNDEFINED(),
336
+ });
337
+ else
338
+ add({
339
+ exact: true,
340
+ left: ValueFactory_1.ValueFactory.UNDEFINED(),
341
+ });
342
+ // FUNCTIONAL
343
+ if (props.metadata.functions.length)
344
+ if (OptionPredicator_1.OptionPredicator.functional(props.context.options) ||
345
+ props.metadata.size() !== 1)
346
+ add({
347
+ exact: true,
348
+ left: typescript_1.default.factory.createStringLiteral("function"),
349
+ right: ValueFactory_1.ValueFactory.TYPEOF(props.input),
350
+ });
351
+ else
352
+ binaries.push({
353
+ combined: false,
354
+ expression: props.config.success,
355
+ });
356
+ //----
357
+ // VALUES
358
+ //----
359
+ // CONSTANT VALUES
360
+ var constants = props.metadata.constants.filter(function (c) {
361
+ return AtomicPredicator_1.AtomicPredicator.constant({
362
+ metadata: props.metadata,
363
+ name: c.type,
364
+ });
365
+ });
366
+ var constantLength = constants
367
+ .map(function (c) { return c.values.length; })
368
+ .reduce(function (a, b) { return a + b; }, 0);
369
+ if (constantLength >= 10) {
370
+ var values = constants
371
+ .map(function (c) { return c.values.map(function (v) { return v.value; }); })
372
+ .flat();
373
+ add({
374
+ exact: true,
375
+ left: typescript_1.default.factory.createTrue(),
376
+ right: typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(props.importer.emplaceVariable("".concat(props.config.prefix, "v").concat(props.importer.increment()), typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier("Set"), undefined, [
377
+ typescript_1.default.factory.createArrayLiteralExpression(values.map(function (v) {
378
+ return typeof v === "boolean"
379
+ ? v === true
380
+ ? typescript_1.default.factory.createTrue()
381
+ : typescript_1.default.factory.createFalse()
382
+ : typeof v === "bigint"
383
+ ? ExpressionFactory_1.ExpressionFactory.bigint(v)
384
+ : typeof v === "number"
385
+ ? ExpressionFactory_1.ExpressionFactory.number(v)
386
+ : typescript_1.default.factory.createStringLiteral(v.toString());
387
+ })),
388
+ ])))("has"), undefined, [props.input]),
389
+ });
390
+ }
391
+ else
392
+ try {
393
+ for (var constants_1 = __values(constants), constants_1_1 = constants_1.next(); !constants_1_1.done; constants_1_1 = constants_1.next()) {
394
+ var c = constants_1_1.value;
395
+ if (AtomicPredicator_1.AtomicPredicator.constant({
396
+ metadata: props.metadata,
397
+ name: c.type,
398
+ }))
295
399
  try {
296
- for (var constants_1 = __values(constants), constants_1_1 = constants_1.next(); !constants_1_1.done; constants_1_1 = constants_1.next()) {
297
- var c = constants_1_1.value;
298
- if (AtomicPredicator_1.AtomicPredicator.constant({
299
- metadata: metadata,
300
- name: c.type,
301
- }))
302
- try {
303
- for (var _e = (e_2 = void 0, __values(c.values)), _f = _e.next(); !_f.done; _f = _e.next()) {
304
- var v = _f.value;
305
- add(true, getConstantValue(v.value));
306
- }
307
- }
308
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
309
- finally {
310
- try {
311
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
312
- }
313
- finally { if (e_2) throw e_2.error; }
314
- }
400
+ for (var _e = (e_2 = void 0, __values(c.values)), _f = _e.next(); !_f.done; _f = _e.next()) {
401
+ var v = _f.value;
402
+ add({
403
+ exact: true,
404
+ left: getConstantValue(v.value),
405
+ });
315
406
  }
316
407
  }
317
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
408
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
318
409
  finally {
319
410
  try {
320
- if (constants_1_1 && !constants_1_1.done && (_a = constants_1.return)) _a.call(constants_1);
411
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
321
412
  }
322
- finally { if (e_1) throw e_1.error; }
323
- }
324
- try {
325
- // ATOMIC VALUES
326
- for (var _g = __values(metadata.atomics), _h = _g.next(); !_h.done; _h = _g.next()) {
327
- var atom = _h.value;
328
- if (AtomicPredicator_1.AtomicPredicator.atomic({
329
- metadata: metadata,
330
- name: atom.type,
331
- }) === false)
332
- continue;
333
- else if (atom.type === "number")
334
- binaries.push({
335
- expression: config.atomist(explore)((0, check_number_1.check_number)(project, config.numeric)(atom)(input))(input),
336
- combined: false,
337
- });
338
- else if (atom.type === "bigint")
339
- binaries.push({
340
- expression: config.atomist(explore)((0, check_bigint_1.check_bigint)(project)(atom)(input))(input),
341
- combined: false,
342
- });
343
- else if (atom.type === "string")
344
- binaries.push({
345
- expression: config.atomist(explore)((0, check_string_1.check_string)(project)(atom)(input))(input),
346
- combined: false,
347
- });
348
- else
349
- add(true, typescript_1.default.factory.createStringLiteral(atom.type), ValueFactory_1.ValueFactory.TYPEOF(input));
350
- }
351
- }
352
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
353
- finally {
354
- try {
355
- if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
413
+ finally { if (e_2) throw e_2.error; }
356
414
  }
357
- finally { if (e_3) throw e_3.error; }
358
- }
359
- // TEMPLATE LITERAL VALUES
360
- if (metadata.templates.length)
361
- if (AtomicPredicator_1.AtomicPredicator.template(metadata))
362
- binaries.push({
363
- expression: config.atomist(explore)((0, check_template_1.check_template)(metadata.templates)(input))(input),
364
- combined: false,
365
- });
366
- try {
367
- // NATIVE CLASSES
368
- for (var _j = __values(metadata.natives), _k = _j.next(); !_k.done; _k = _j.next()) {
369
- var native = _k.value;
370
- binaries.push({
371
- expression: (0, check_native_1.check_native)(native)(input),
372
- combined: false,
373
- });
374
- }
375
- }
376
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
377
- finally {
378
- try {
379
- if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
380
- }
381
- finally { if (e_4) throw e_4.error; }
382
- }
383
- var instances = [];
384
- var prepare = function (pre, expected) {
385
- return function (body) {
386
- return instances.push({
387
- pre: pre,
388
- expected: expected,
389
- body: body,
390
- });
391
- };
392
- };
393
- // SETS
394
- if (metadata.sets.length) {
395
- var install = prepare((0, check_native_1.check_native)("Set")(input), metadata.sets.map(function (elem) { return "Set<".concat(elem.getName(), ">"); }).join(" | "));
396
- if (metadata.sets.some(function (elem) { return elem.any; }))
397
- install(null);
398
- else
399
- install(explore_sets(project)(config)(importer)(input, metadata.sets, __assign(__assign({}, explore), { from: "array" })));
400
- }
401
- // MAPS
402
- if (metadata.maps.length) {
403
- var install = prepare((0, check_native_1.check_native)("Map")(input), metadata.maps
404
- .map(function (_a) {
405
- var key = _a.key, value = _a.value;
406
- return "Map<".concat(key, ", ").concat(value, ">");
407
- })
408
- .join(" | "));
409
- if (metadata.maps.some(function (elem) { return elem.key.any && elem.value.any; }))
410
- install(null);
411
- else
412
- install(explore_maps(project)(config)(importer)(input, metadata.maps, __assign(__assign({}, explore), { from: "array" })));
413
- }
414
- // ARRAYS AND TUPLES
415
- if (metadata.tuples.length + metadata.arrays.length > 0) {
416
- var install = prepare(config.atomist(explore)({
417
- expected: __spreadArray(__spreadArray([], __read(metadata.tuples.map(function (t) { return t.type.name; })), false), __read(metadata.arrays.map(function (a) { return a.getName(); })), false).join(" | "),
418
- expression: ExpressionFactory_1.ExpressionFactory.isArray(input),
415
+ }
416
+ }
417
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
418
+ finally {
419
+ try {
420
+ if (constants_1_1 && !constants_1_1.done && (_a = constants_1.return)) _a.call(constants_1);
421
+ }
422
+ finally { if (e_1) throw e_1.error; }
423
+ }
424
+ try {
425
+ // ATOMIC VALUES
426
+ for (var _g = __values(props.metadata.atomics), _h = _g.next(); !_h.done; _h = _g.next()) {
427
+ var atom = _h.value;
428
+ if (AtomicPredicator_1.AtomicPredicator.atomic({
429
+ metadata: props.metadata,
430
+ name: atom.type,
431
+ }) === false)
432
+ continue;
433
+ else if (atom.type === "number")
434
+ binaries.push({
435
+ expression: props.config.atomist({
436
+ explore: props.explore,
437
+ entry: (0, check_number_1.check_number)(props.context, props.config.numeric)(atom)(props.input),
438
+ input: props.input,
439
+ }),
440
+ combined: false,
441
+ });
442
+ else if (atom.type === "bigint")
443
+ binaries.push({
444
+ expression: props.config.atomist({
445
+ explore: props.explore,
446
+ entry: (0, check_bigint_1.check_bigint)(props.context)(atom)(props.input),
447
+ input: props.input,
448
+ }),
449
+ combined: false,
450
+ });
451
+ else if (atom.type === "string")
452
+ binaries.push({
453
+ expression: props.config.atomist({
454
+ explore: props.explore,
455
+ entry: (0, check_string_1.check_string)(props.context)(atom)(props.input),
456
+ input: props.input,
457
+ }),
458
+ combined: false,
459
+ });
460
+ else
461
+ add({
462
+ exact: true,
463
+ left: typescript_1.default.factory.createStringLiteral(atom.type),
464
+ right: ValueFactory_1.ValueFactory.TYPEOF(props.input),
465
+ });
466
+ }
467
+ }
468
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
469
+ finally {
470
+ try {
471
+ if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
472
+ }
473
+ finally { if (e_3) throw e_3.error; }
474
+ }
475
+ // TEMPLATE LITERAL VALUES
476
+ if (props.metadata.templates.length)
477
+ if (AtomicPredicator_1.AtomicPredicator.template(props.metadata))
478
+ binaries.push({
479
+ expression: props.config.atomist({
480
+ explore: props.explore,
481
+ entry: (0, check_template_1.check_template)(props.metadata.templates)(props.input),
482
+ input: props.input,
483
+ }),
484
+ combined: false,
485
+ });
486
+ try {
487
+ // NATIVE CLASSES
488
+ for (var _j = __values(props.metadata.natives), _k = _j.next(); !_k.done; _k = _j.next()) {
489
+ var native = _k.value;
490
+ binaries.push({
491
+ expression: (0, check_native_1.check_native)(native)(props.input),
492
+ combined: false,
493
+ });
494
+ }
495
+ }
496
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
497
+ finally {
498
+ try {
499
+ if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
500
+ }
501
+ finally { if (e_4) throw e_4.error; }
502
+ }
503
+ var instances = [];
504
+ var prepare = function (next) { return instances.push(next); };
505
+ // SETS
506
+ if (props.metadata.sets.length) {
507
+ var install = function (body) {
508
+ return prepare({
509
+ knock: (0, check_native_1.check_native)("Set")(props.input),
510
+ expected: props.metadata.sets
511
+ .map(function (elem) { return "Set<".concat(elem.getName(), ">"); })
512
+ .join(" | "),
513
+ body: body,
514
+ });
515
+ };
516
+ if (props.metadata.sets.some(function (elem) { return elem.any; }))
517
+ install(null);
518
+ else
519
+ install(explore_sets({
520
+ config: props.config,
521
+ context: props.context,
522
+ importer: props.importer,
523
+ sets: props.metadata.sets,
524
+ input: props.input,
525
+ explore: __assign(__assign({}, props.explore), { from: "array" }),
526
+ }));
527
+ }
528
+ // MAPS
529
+ if (props.metadata.maps.length) {
530
+ var install = function (body) {
531
+ return prepare({
532
+ knock: (0, check_native_1.check_native)("Map")(props.input),
533
+ expected: props.metadata.maps
534
+ .map(function (_a) {
535
+ var key = _a.key, value = _a.value;
536
+ return "Map<".concat(key, ", ").concat(value, ">");
537
+ })
538
+ .join(" | "),
539
+ body: body,
540
+ });
541
+ };
542
+ if (props.metadata.maps.some(function (elem) { return elem.key.any && elem.value.any; }))
543
+ install(null);
544
+ else
545
+ install(explore_maps({
546
+ config: props.config,
547
+ context: props.context,
548
+ importer: props.importer,
549
+ maps: props.metadata.maps,
550
+ input: props.input,
551
+ explore: __assign(__assign({}, props.explore), { from: "array" }),
552
+ }));
553
+ }
554
+ // ARRAYS AND TUPLES
555
+ if (props.metadata.tuples.length + props.metadata.arrays.length > 0) {
556
+ var install = function (body) {
557
+ return prepare({
558
+ knock: props.config.atomist({
559
+ explore: props.explore,
560
+ entry: {
561
+ expected: __spreadArray(__spreadArray([], __read(props.metadata.tuples.map(function (t) { return t.type.name; })), false), __read(props.metadata.arrays.map(function (a) { return a.getName(); })), false).join(" | "),
562
+ expression: ExpressionFactory_1.ExpressionFactory.isArray(props.input),
419
563
  conditions: [],
420
- })(input), __spreadArray(__spreadArray([], __read(metadata.tuples), false), __read(metadata.arrays), false).map(function (elem) { return elem.type.name; })
421
- .join(" | "));
422
- if (metadata.arrays.length === 0)
423
- if (metadata.tuples.length === 1)
424
- install(decode_tuple(project)(config)(importer)(input, metadata.tuples[0], __assign(__assign({}, explore), { from: "array" })));
425
- // TUPLE ONLY
426
- else
427
- install(explore_tuples(project)(config)(importer)(input, metadata.tuples, __assign(__assign({}, explore), { from: "array" })));
428
- else if (metadata.arrays.some(function (elem) { return elem.type.value.any; }))
429
- install(null);
430
- else if (metadata.tuples.length === 0)
431
- if (metadata.arrays.length === 1)
432
- // ARRAY ONLY
433
- install(decode_array(project)(config)(importer)(input, metadata.arrays[0], __assign(__assign({}, explore), { from: "array" })));
434
- else
435
- install(explore_arrays(project)(config)(importer)(input, metadata.arrays, __assign(__assign({}, explore), { from: "array" })));
436
- else
437
- install(explore_arrays_and_tuples(project)(config)(importer)(input, __spreadArray(__spreadArray([], __read(metadata.tuples), false), __read(metadata.arrays), false), explore));
438
- }
439
- // OBJECT
440
- if (metadata.objects.length > 0)
441
- prepare(ExpressionFactory_1.ExpressionFactory.isObject({
442
- checkNull: true,
443
- checkArray: metadata.objects.some(function (obj) {
444
- return obj.properties.every(function (prop) { return !prop.key.isSoleLiteral() || !prop.value.isRequired(); });
445
- }),
446
- })(input), metadata.objects.map(function (obj) { return obj.name; }).join(" | "))(explore_objects(config)(importer)(input, metadata, __assign(__assign({}, explore), { from: "object" })));
447
- if (instances.length) {
448
- var transformer = function (merger) {
449
- return function (ins) {
450
- return ins.body
451
- ? {
452
- expression: merger(ins.pre, ins.body),
453
- combined: true,
454
- }
455
- : {
456
- expression: ins.pre,
457
- combined: false,
458
- };
459
- };
460
- };
461
- if (instances.length === 1)
462
- binaries.push(transformer(function (pre, body) {
463
- return config.combiner(explore)("and")(input, [pre, body].map(function (expression) { return ({
464
- expression: expression,
465
- combined: expression !== pre,
466
- }); }), metadata.getName());
467
- })(instances[0]));
468
- else
469
- binaries.push({
470
- expression: config.combiner(explore)("or")(input, instances.map(transformer(typescript_1.default.factory.createLogicalAnd)), metadata.getName()),
471
- combined: true,
472
- });
473
- }
474
- // ESCAPED CASE
475
- if (metadata.escaped !== null)
476
- binaries.push({
564
+ },
565
+ input: props.input,
566
+ }),
567
+ expected: __spreadArray(__spreadArray([], __read(props.metadata.tuples), false), __read(props.metadata.arrays), false).map(function (elem) { return elem.type.name; })
568
+ .join(" | "),
569
+ body: body,
570
+ });
571
+ };
572
+ if (props.metadata.arrays.length === 0)
573
+ if (props.metadata.tuples.length === 1)
574
+ install(decode_tuple({
575
+ config: props.config,
576
+ context: props.context,
577
+ importer: props.importer,
578
+ tuple: props.metadata.tuples[0],
579
+ input: props.input,
580
+ explore: __assign(__assign({}, props.explore), { from: "array" }),
581
+ }));
582
+ // TUPLE ONLY
583
+ else
584
+ install(explore_tuples({
585
+ config: props.config,
586
+ context: props.context,
587
+ importer: props.importer,
588
+ tuples: props.metadata.tuples,
589
+ input: props.input,
590
+ explore: __assign(__assign({}, props.explore), { from: "array" }),
591
+ }));
592
+ else if (props.metadata.arrays.some(function (elem) { return elem.type.value.any; }))
593
+ install(null);
594
+ else if (props.metadata.tuples.length === 0)
595
+ if (props.metadata.arrays.length === 1)
596
+ // ARRAY ONLY
597
+ install(decode_array({
598
+ config: props.config,
599
+ context: props.context,
600
+ importer: props.importer,
601
+ array: props.metadata.arrays[0],
602
+ input: props.input,
603
+ explore: __assign(__assign({}, props.explore), { from: "array" }),
604
+ }));
605
+ else
606
+ install(explore_arrays({
607
+ config: props.config,
608
+ context: props.context,
609
+ importer: props.importer,
610
+ arrays: props.metadata.arrays,
611
+ input: props.input,
612
+ explore: __assign(__assign({}, props.explore), { from: "array" }),
613
+ }));
614
+ else
615
+ install(explore_arrays_and_tuples({
616
+ config: props.config,
617
+ context: props.context,
618
+ importer: props.importer,
619
+ definitions: __spreadArray(__spreadArray([], __read(props.metadata.tuples), false), __read(props.metadata.arrays), false),
620
+ input: props.input,
621
+ explore: props.explore,
622
+ }));
623
+ }
624
+ // OBJECT
625
+ if (props.metadata.objects.length > 0)
626
+ prepare({
627
+ knock: ExpressionFactory_1.ExpressionFactory.isObject({
628
+ checkNull: true,
629
+ checkArray: props.metadata.objects.some(function (obj) {
630
+ return obj.properties.every(function (prop) { return !prop.key.isSoleLiteral() || !prop.value.isRequired(); });
631
+ }),
632
+ })(props.input),
633
+ expected: props.metadata.objects.map(function (obj) { return obj.name; }).join(" | "),
634
+ body: explore_objects({
635
+ config: props.config,
636
+ importer: props.importer,
637
+ metadata: props.metadata,
638
+ input: props.input,
639
+ explore: __assign(__assign({}, props.explore), { from: "object" }),
640
+ }),
641
+ });
642
+ if (instances.length) {
643
+ var transformer = function (merger) {
644
+ return function (ins) {
645
+ return ins.body
646
+ ? {
647
+ expression: merger(ins.knock, ins.body),
648
+ combined: true,
649
+ }
650
+ : {
651
+ expression: ins.knock,
477
652
  combined: false,
478
- expression: metadata.escaped.original.size() === 1 &&
479
- metadata.escaped.original.natives.length === 1
480
- ? (0, check_native_1.check_native)(metadata.escaped.original.natives[0])(input)
481
- : typescript_1.default.factory.createLogicalAnd(CheckerProgrammer.decode(project)(config)(importer)(input, metadata.escaped.original, explore), typescript_1.default.factory.createLogicalAnd(IsProgrammer_1.IsProgrammer.decode_to_json(false)(input), decode_escaped(project)(config)(importer)(input, metadata.escaped.returns, explore))),
482
- });
483
- //----
484
- // COMBINE CONDITIONS
485
- //----
486
- return top.length && binaries.length
487
- ? config.combiner(explore)("and")(input, __spreadArray(__spreadArray([], __read(top), false), [
488
- {
489
- expression: config.combiner(explore)("or")(input, binaries, metadata.getName()),
490
- combined: true,
491
- },
492
- ], false), metadata.getName())
493
- : binaries.length
494
- ? config.combiner(explore)("or")(input, binaries, metadata.getName())
495
- : config.success;
653
+ };
496
654
  };
497
655
  };
498
- };
656
+ if (instances.length === 1)
657
+ binaries.push(transformer(function (pre, body) {
658
+ return props.config.combiner({
659
+ explore: props.explore,
660
+ logic: "and",
661
+ input: props.input,
662
+ binaries: [pre, body].map(function (expression) { return ({
663
+ expression: expression,
664
+ combined: expression !== pre,
665
+ }); }),
666
+ expected: props.metadata.getName(),
667
+ });
668
+ })(instances[0]));
669
+ else
670
+ binaries.push({
671
+ expression: props.config.combiner({
672
+ explore: props.explore,
673
+ logic: "or",
674
+ input: props.input,
675
+ binaries: instances.map(transformer(typescript_1.default.factory.createLogicalAnd)),
676
+ expected: props.metadata.getName(),
677
+ }),
678
+ combined: true,
679
+ });
680
+ }
681
+ // ESCAPED CASE
682
+ if (props.metadata.escaped !== null)
683
+ binaries.push({
684
+ combined: false,
685
+ expression: props.metadata.escaped.original.size() === 1 &&
686
+ props.metadata.escaped.original.natives.length === 1
687
+ ? (0, check_native_1.check_native)(props.metadata.escaped.original.natives[0])(props.input)
688
+ : typescript_1.default.factory.createLogicalAnd(CheckerProgrammer.decode({
689
+ context: props.context,
690
+ config: props.config,
691
+ importer: props.importer,
692
+ metadata: props.metadata.escaped.original,
693
+ input: props.input,
694
+ explore: props.explore,
695
+ }), typescript_1.default.factory.createLogicalAnd(IsProgrammer_1.IsProgrammer.decode_to_json({
696
+ checkNull: false,
697
+ input: props.input,
698
+ }), decode_escaped({
699
+ config: props.config,
700
+ context: props.context,
701
+ importer: props.importer,
702
+ metadata: props.metadata.escaped.returns,
703
+ input: props.input,
704
+ explore: props.explore,
705
+ }))),
706
+ });
707
+ //----
708
+ // COMBINE CONDITIONS
709
+ //----
710
+ return top.length && binaries.length
711
+ ? props.config.combiner({
712
+ explore: props.explore,
713
+ logic: "and",
714
+ input: props.input,
715
+ binaries: __spreadArray(__spreadArray([], __read(top), false), [
716
+ {
717
+ expression: props.config.combiner({
718
+ explore: props.explore,
719
+ logic: "or",
720
+ input: props.input,
721
+ binaries: binaries,
722
+ expected: props.metadata.getName(),
723
+ }),
724
+ combined: true,
725
+ },
726
+ ], false),
727
+ expected: props.metadata.getName(),
728
+ })
729
+ : binaries.length
730
+ ? props.config.combiner({
731
+ explore: props.explore,
732
+ logic: "or",
733
+ input: props.input,
734
+ binaries: binaries,
735
+ expected: props.metadata.getName(),
736
+ })
737
+ : props.config.success;
499
738
  };
500
- CheckerProgrammer.decode_object = function (config) { return function (importer) {
501
- var func = FeatureProgrammer_1.FeatureProgrammer.decode_object(config)(importer);
502
- return function (input, obj, explore) {
503
- obj.validated = true;
504
- return func(input, obj, explore);
505
- };
506
- }; };
507
- var decode_array = function (project) {
508
- return function (config) {
509
- return function (importer) {
510
- return function (input, array, explore) {
511
- if (array.type.recursive === false)
512
- return decode_array_inline(project)(config)(importer)(input, array, explore);
513
- explore = __assign(__assign({}, explore), { source: "function", from: "array" });
514
- return typescript_1.default.factory.createLogicalOr(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(importer.useLocal("".concat(config.prefix, "a").concat(array.type.index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(config)(__assign(__assign({}, explore), { source: "function", from: "array" }))(input)), config.joiner.failure(input, array.type.name, explore));
515
- };
516
- };
517
- };
739
+ CheckerProgrammer.decode_object = function (props) {
740
+ var _a;
741
+ (_a = props.object).validated || (_a.validated = true);
742
+ return FeatureProgrammer_1.FeatureProgrammer.decode_object(props.config)(props.importer)(props.input, props.object, props.explore);
518
743
  };
519
- var decode_array_inline = function (project) {
520
- return function (config) {
521
- return function (importer) {
522
- return function (input, array, explore) {
523
- var length = (0, check_array_length_1.check_array_length)(project)(array)(input);
524
- var main = FeatureProgrammer_1.FeatureProgrammer.decode_array({
525
- prefix: config.prefix,
526
- trace: config.trace,
527
- path: config.path,
528
- decoder: function () { return CheckerProgrammer.decode(project)(config)(importer); },
529
- })(importer)(config.joiner.array)(input, array, explore);
530
- return length.expression === null && length.conditions.length === 0
531
- ? main
532
- : typescript_1.default.factory.createLogicalAnd(config.atomist(explore)(length)(input), main);
533
- };
534
- };
535
- };
744
+ var decode_array = function (props) {
745
+ if (props.array.type.recursive === false)
746
+ return decode_array_inline(props);
747
+ var arrayExplore = __assign(__assign({}, props.explore), { source: "function", from: "array" });
748
+ return typescript_1.default.factory.createLogicalOr(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(props.importer.useLocal("".concat(props.config.prefix, "a").concat(props.array.type.index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(props.config)(__assign(__assign({}, arrayExplore), { source: "function", from: "array" }))(props.input)), props.config.joiner.failure({
749
+ input: props.input,
750
+ expected: props.array.type.name,
751
+ explore: arrayExplore,
752
+ }));
536
753
  };
537
- var decode_tuple = function (project) {
538
- return function (config) {
539
- return function (importer) {
540
- return function (input, tuple, explore) {
541
- if (tuple.type.recursive === false)
542
- return decode_tuple_inline(project)(config)(importer)(input, tuple.type, explore);
543
- explore = __assign(__assign({}, explore), { source: "function", from: "array" });
544
- return typescript_1.default.factory.createLogicalOr(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(importer.useLocal("".concat(config.prefix, "t").concat(tuple.type.index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(config)(__assign(__assign({}, explore), { source: "function" }))(input)), config.joiner.failure(input, tuple.type.name, explore));
545
- };
546
- };
547
- };
754
+ var decode_array_inline = function (props) {
755
+ var length = (0, check_array_length_1.check_array_length)(props.context)(props.array)(props.input);
756
+ var main = FeatureProgrammer_1.FeatureProgrammer.decode_array({
757
+ prefix: props.config.prefix,
758
+ trace: props.config.trace,
759
+ path: props.config.path,
760
+ decoder: function () { return function (input, metadata, explore) {
761
+ return CheckerProgrammer.decode(__assign(__assign({}, props), { input: input, metadata: metadata, explore: explore }));
762
+ }; },
763
+ })(props.importer)(props.config.joiner.array)(props.input, props.array, props.explore);
764
+ return length.expression === null && length.conditions.length === 0
765
+ ? main
766
+ : typescript_1.default.factory.createLogicalAnd(props.config.atomist({
767
+ explore: props.explore,
768
+ input: props.input,
769
+ entry: length,
770
+ }), main);
548
771
  };
549
- var decode_tuple_inline = function (project) {
550
- return function (config) {
551
- return function (importer) {
552
- return function (input, tuple, explore) {
553
- var binaries = tuple.elements
554
- .filter(function (meta) { return meta.rest === null; })
555
- .map(function (meta, index) {
556
- return CheckerProgrammer.decode(project)(config)(importer)(typescript_1.default.factory.createElementAccessExpression(input, index), meta, __assign(__assign({}, explore), { from: "array", postfix: explore.postfix.length
557
- ? "".concat((0, postfix_of_tuple_1.postfix_of_tuple)(explore.postfix), "[").concat(index, "]\"")
558
- : "\"[".concat(index, "]\"") }));
559
- });
560
- var rest = tuple.elements.length && tuple.elements.at(-1).rest !== null
561
- ? CheckerProgrammer.decode(project)(config)(importer)(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(input)("slice"), undefined, [ExpressionFactory_1.ExpressionFactory.number(tuple.elements.length - 1)]), (0, wrap_metadata_rest_tuple_1.wrap_metadata_rest_tuple)(tuple.elements.at(-1).rest), __assign(__assign({}, explore), { start: tuple.elements.length - 1 }))
562
- : null;
563
- var arrayLength = typescript_1.default.factory.createPropertyAccessExpression(input, "length");
564
- return config.combiner(explore)("and")(input, __spreadArray(__spreadArray(__spreadArray([], __read((rest === null
565
- ? tuple.elements.every(function (t) { return t.optional === false; })
566
- ? [
567
- {
568
- combined: false,
569
- expression: typescript_1.default.factory.createStrictEquality(arrayLength, ExpressionFactory_1.ExpressionFactory.number(tuple.elements.length)),
570
- },
571
- ]
572
- : [
573
- {
574
- combined: false,
575
- expression: typescript_1.default.factory.createLogicalAnd(typescript_1.default.factory.createLessThanEquals(ExpressionFactory_1.ExpressionFactory.number(tuple.elements.filter(function (t) { return t.optional === false; })
576
- .length), arrayLength), typescript_1.default.factory.createGreaterThanEquals(ExpressionFactory_1.ExpressionFactory.number(tuple.elements.length), arrayLength)),
577
- },
578
- ]
579
- : [])), false), __read((config.joiner.tuple
580
- ? [
581
- {
582
- expression: config.joiner.tuple(binaries),
583
- combined: true,
584
- },
585
- ]
586
- : binaries.map(function (expression) { return ({
587
- expression: expression,
588
- combined: true,
589
- }); }))), false), __read((rest !== null
590
- ? [
591
- {
592
- expression: rest,
593
- combined: true,
594
- },
595
- ]
596
- : [])), false), "[".concat(tuple.elements.map(function (t) { return t.getName(); }).join(", "), "]"));
597
- };
598
- };
599
- };
772
+ var decode_tuple = function (props) {
773
+ if (props.tuple.type.recursive === false)
774
+ return decode_tuple_inline(__assign(__assign({}, props), { tuple: props.tuple.type }));
775
+ var arrayExplore = __assign(__assign({}, props.explore), { source: "function", from: "array" });
776
+ return typescript_1.default.factory.createLogicalOr(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(props.importer.useLocal("".concat(props.config.prefix, "t").concat(props.tuple.type.index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(props.config)(__assign(__assign({}, arrayExplore), { source: "function" }))(props.input)), props.config.joiner.failure({
777
+ input: props.input,
778
+ expected: props.tuple.type.name,
779
+ explore: arrayExplore,
780
+ }));
600
781
  };
601
- var decode_escaped = function (project) {
602
- return function (config) {
603
- return function (importer) {
604
- return function (input, meta, explore) {
605
- return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createParenthesizedExpression(typescript_1.default.factory.createArrowFunction(undefined, undefined, [IdentifierFactory_1.IdentifierFactory.parameter("input", TypeFactory_1.TypeFactory.keyword("any"))], undefined, undefined, CheckerProgrammer.decode(project)(config)(importer)(typescript_1.default.factory.createIdentifier("input"), meta, explore))), undefined, [
606
- typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(input)("toJSON"), undefined, []),
607
- ]);
608
- };
609
- };
610
- };
782
+ var decode_tuple_inline = function (props) {
783
+ var binaries = props.tuple.elements
784
+ .filter(function (metadata) { return metadata.rest === null; })
785
+ .map(function (metadata, index) {
786
+ return CheckerProgrammer.decode({
787
+ context: props.context,
788
+ config: props.config,
789
+ importer: props.importer,
790
+ input: typescript_1.default.factory.createElementAccessExpression(props.input, index),
791
+ metadata: metadata,
792
+ explore: __assign(__assign({}, props.explore), { from: "array", postfix: props.explore.postfix.length
793
+ ? "".concat((0, postfix_of_tuple_1.postfix_of_tuple)(props.explore.postfix), "[").concat(index, "]\"")
794
+ : "\"[".concat(index, "]\"") }),
795
+ });
796
+ });
797
+ var rest = props.tuple.elements.length && props.tuple.elements.at(-1).rest !== null
798
+ ? CheckerProgrammer.decode({
799
+ config: props.config,
800
+ context: props.context,
801
+ importer: props.importer,
802
+ input: typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(props.input)("slice"), undefined, [ExpressionFactory_1.ExpressionFactory.number(props.tuple.elements.length - 1)]),
803
+ metadata: (0, wrap_metadata_rest_tuple_1.wrap_metadata_rest_tuple)(props.tuple.elements.at(-1).rest),
804
+ explore: __assign(__assign({}, props.explore), { start: props.tuple.elements.length - 1 }),
805
+ })
806
+ : null;
807
+ var arrayLength = typescript_1.default.factory.createPropertyAccessExpression(props.input, "length");
808
+ return props.config.combiner({
809
+ explore: props.explore,
810
+ logic: "and",
811
+ input: props.input,
812
+ binaries: __spreadArray(__spreadArray(__spreadArray([], __read((rest === null
813
+ ? props.tuple.elements.every(function (t) { return t.optional === false; })
814
+ ? [
815
+ {
816
+ combined: false,
817
+ expression: typescript_1.default.factory.createStrictEquality(arrayLength, ExpressionFactory_1.ExpressionFactory.number(props.tuple.elements.length)),
818
+ },
819
+ ]
820
+ : [
821
+ {
822
+ combined: false,
823
+ expression: typescript_1.default.factory.createLogicalAnd(typescript_1.default.factory.createLessThanEquals(ExpressionFactory_1.ExpressionFactory.number(props.tuple.elements.filter(function (t) { return t.optional === false; })
824
+ .length), arrayLength), typescript_1.default.factory.createGreaterThanEquals(ExpressionFactory_1.ExpressionFactory.number(props.tuple.elements.length), arrayLength)),
825
+ },
826
+ ]
827
+ : [])), false), __read((props.config.joiner.tuple
828
+ ? [
829
+ {
830
+ expression: props.config.joiner.tuple(binaries),
831
+ combined: true,
832
+ },
833
+ ]
834
+ : binaries.map(function (expression) { return ({
835
+ expression: expression,
836
+ combined: true,
837
+ }); }))), false), __read((rest !== null
838
+ ? [
839
+ {
840
+ expression: rest,
841
+ combined: true,
842
+ },
843
+ ]
844
+ : [])), false),
845
+ expected: "[".concat(props.tuple.elements.map(function (t) { return t.getName(); }).join(", "), "]"),
846
+ });
847
+ };
848
+ var decode_escaped = function (props) {
849
+ return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createParenthesizedExpression(typescript_1.default.factory.createArrowFunction(undefined, undefined, [IdentifierFactory_1.IdentifierFactory.parameter("input", TypeFactory_1.TypeFactory.keyword("any"))], undefined, undefined, CheckerProgrammer.decode(__assign(__assign({}, props), { input: typescript_1.default.factory.createIdentifier("input") })))), undefined, [
850
+ typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(props.input)("toJSON"), undefined, []),
851
+ ]);
611
852
  };
612
853
  /* -----------------------------------------------------------
613
854
  UNION TYPE EXPLORERS
614
855
  ----------------------------------------------------------- */
615
- var explore_sets = function (project) {
616
- return function (config) {
617
- return function (importer) {
618
- return function (input, sets, explore) {
619
- return typescript_1.default.factory.createCallExpression(UnionExplorer_1.UnionExplorer.set({
620
- checker: CheckerProgrammer.decode(project)(config)(importer),
621
- decoder: decode_array(project)(config)(importer),
622
- empty: config.success,
623
- success: config.success,
624
- failure: function (input, expected, explore) {
625
- return typescript_1.default.factory.createReturnStatement(config.joiner.failure(input, expected, explore));
626
- },
627
- })([])(input, sets, explore), undefined, undefined);
628
- };
629
- };
630
- };
856
+ var explore_sets = function (props) {
857
+ return typescript_1.default.factory.createCallExpression(UnionExplorer_1.UnionExplorer.set({
858
+ checker: function (input, metadata, explore, _container) {
859
+ return CheckerProgrammer.decode({
860
+ context: props.context,
861
+ config: props.config,
862
+ importer: props.importer,
863
+ input: input,
864
+ metadata: metadata,
865
+ explore: explore,
866
+ });
867
+ },
868
+ decoder: function (input, array, explore) {
869
+ return decode_array({
870
+ config: props.config,
871
+ context: props.context,
872
+ importer: props.importer,
873
+ array: array,
874
+ input: input,
875
+ explore: explore,
876
+ });
877
+ },
878
+ empty: props.config.success,
879
+ success: props.config.success,
880
+ failure: function (input, expected, explore) {
881
+ return typescript_1.default.factory.createReturnStatement(props.config.joiner.failure({
882
+ input: input,
883
+ expected: expected,
884
+ explore: explore,
885
+ }));
886
+ },
887
+ })([])(props.input, props.sets, props.explore), undefined, undefined);
631
888
  };
632
- var explore_maps = function (project) {
633
- return function (config) {
634
- return function (importer) {
635
- return function (input, maps, explore) {
636
- return typescript_1.default.factory.createCallExpression(UnionExplorer_1.UnionExplorer.map({
637
- checker: function (input, entry, explore) {
638
- var func = CheckerProgrammer.decode(project)(config)(importer);
639
- return typescript_1.default.factory.createLogicalAnd(func(typescript_1.default.factory.createElementAccessExpression(input, 0), entry[0], __assign(__assign({}, explore), { postfix: "".concat(explore.postfix, "[0]") })), func(typescript_1.default.factory.createElementAccessExpression(input, 1), entry[1], __assign(__assign({}, explore), { postfix: "".concat(explore.postfix, "[1]") })));
640
- },
641
- decoder: decode_array(project)(config)(importer),
642
- empty: config.success,
643
- success: config.success,
644
- failure: function (input, expected, explore) {
645
- return typescript_1.default.factory.createReturnStatement(config.joiner.failure(input, expected, explore));
646
- },
647
- })([])(input, maps, explore), undefined, undefined);
648
- };
649
- };
650
- };
889
+ var explore_maps = function (props) {
890
+ return typescript_1.default.factory.createCallExpression(UnionExplorer_1.UnionExplorer.map({
891
+ checker: function (input, entry, explore) {
892
+ return typescript_1.default.factory.createLogicalAnd(CheckerProgrammer.decode({
893
+ config: props.config,
894
+ context: props.context,
895
+ importer: props.importer,
896
+ input: typescript_1.default.factory.createElementAccessExpression(input, 0),
897
+ metadata: entry[0],
898
+ explore: __assign(__assign({}, explore), { postfix: "".concat(explore.postfix, "[0]") }),
899
+ }), CheckerProgrammer.decode({
900
+ config: props.config,
901
+ context: props.context,
902
+ importer: props.importer,
903
+ input: typescript_1.default.factory.createElementAccessExpression(input, 1),
904
+ metadata: entry[1],
905
+ explore: __assign(__assign({}, explore), { postfix: "".concat(explore.postfix, "[1]") }),
906
+ }));
907
+ },
908
+ decoder: function (input, array, explore) {
909
+ return decode_array({
910
+ context: props.context,
911
+ config: props.config,
912
+ importer: props.importer,
913
+ array: array,
914
+ input: input,
915
+ explore: explore,
916
+ });
917
+ },
918
+ empty: props.config.success,
919
+ success: props.config.success,
920
+ failure: function (input, expected, explore) {
921
+ return typescript_1.default.factory.createReturnStatement(props.config.joiner.failure({
922
+ input: input,
923
+ expected: expected,
924
+ explore: explore,
925
+ }));
926
+ },
927
+ })([])(props.input, props.maps, props.explore), undefined, undefined);
651
928
  };
652
- var explore_tuples = function (project) {
653
- return function (config) {
654
- return function (importer) {
655
- return function (input, tuples, explore) {
656
- return explore_array_like_union_types(config)(importer)(UnionExplorer_1.UnionExplorer.tuple({
657
- checker: decode_tuple(project)(config)(importer),
658
- decoder: decode_tuple(project)(config)(importer),
659
- empty: config.success,
660
- success: config.success,
661
- failure: function (input, expected, explore) {
662
- return typescript_1.default.factory.createReturnStatement(config.joiner.failure(input, expected, explore));
663
- },
664
- }))(input, tuples, explore);
665
- };
666
- };
667
- };
929
+ var explore_tuples = function (props) {
930
+ return explore_array_like_union_types({
931
+ config: props.config,
932
+ importer: props.importer,
933
+ factory: UnionExplorer_1.UnionExplorer.tuple({
934
+ checker: function (input, tuple, explore) {
935
+ return decode_tuple({
936
+ context: props.context,
937
+ config: props.config,
938
+ importer: props.importer,
939
+ input: input,
940
+ tuple: tuple,
941
+ explore: explore,
942
+ });
943
+ },
944
+ decoder: function (input, tuple, explore) {
945
+ return decode_tuple({
946
+ context: props.context,
947
+ config: props.config,
948
+ importer: props.importer,
949
+ tuple: tuple,
950
+ input: input,
951
+ explore: explore,
952
+ });
953
+ },
954
+ empty: props.config.success,
955
+ success: props.config.success,
956
+ failure: function (input, expected, explore) {
957
+ return typescript_1.default.factory.createReturnStatement(props.config.joiner.failure({
958
+ input: input,
959
+ expected: expected,
960
+ explore: explore,
961
+ }));
962
+ },
963
+ }),
964
+ definitions: props.tuples,
965
+ input: props.input,
966
+ explore: props.explore,
967
+ });
668
968
  };
669
- var explore_arrays = function (project) {
670
- return function (config) {
671
- return function (importer) {
672
- return function (input, arrays, explore) {
673
- return explore_array_like_union_types(config)(importer)(UnionExplorer_1.UnionExplorer.array({
674
- checker: CheckerProgrammer.decode(project)(config)(importer),
675
- decoder: decode_array(project)(config)(importer),
676
- empty: config.success,
677
- success: config.success,
678
- failure: function (input, expected, explore) {
679
- return typescript_1.default.factory.createReturnStatement(config.joiner.failure(input, expected, explore));
680
- },
681
- }))(input, arrays, explore);
682
- };
683
- };
684
- };
969
+ var explore_arrays = function (props) {
970
+ return explore_array_like_union_types({
971
+ config: props.config,
972
+ importer: props.importer,
973
+ factory: UnionExplorer_1.UnionExplorer.array({
974
+ checker: function (input, metadata, explore) {
975
+ return CheckerProgrammer.decode({
976
+ context: props.context,
977
+ config: props.config,
978
+ importer: props.importer,
979
+ metadata: metadata,
980
+ input: input,
981
+ explore: explore,
982
+ });
983
+ },
984
+ decoder: function (input, array, explore) {
985
+ return decode_array({
986
+ context: props.context,
987
+ config: props.config,
988
+ importer: props.importer,
989
+ array: array,
990
+ input: input,
991
+ explore: explore,
992
+ });
993
+ },
994
+ empty: props.config.success,
995
+ success: props.config.success,
996
+ failure: function (input, expected, explore) {
997
+ return typescript_1.default.factory.createReturnStatement(props.config.joiner.failure({
998
+ input: input,
999
+ expected: expected,
1000
+ explore: explore,
1001
+ }));
1002
+ },
1003
+ }),
1004
+ definitions: props.arrays,
1005
+ input: props.input,
1006
+ explore: props.explore,
1007
+ });
685
1008
  };
686
- var explore_arrays_and_tuples = function (project) {
687
- return function (config) {
688
- return function (importer) {
689
- return function (input, elements, explore) {
690
- return explore_array_like_union_types(config)(importer)(UnionExplorer_1.UnionExplorer.array_or_tuple({
691
- checker: function (front, target, explore, array) {
692
- return target instanceof MetadataTuple_1.MetadataTuple
693
- ? decode_tuple(project)(config)(importer)(front, target, explore)
694
- : config.atomist(explore)({
695
- expected: elements
696
- .map(function (elem) {
697
- return elem instanceof MetadataArray_1.MetadataArray
698
- ? elem.getName()
699
- : elem.type.name;
700
- })
701
- .join(" | "),
702
- expression: CheckerProgrammer.decode(project)(config)(importer)(front, target, explore),
703
- conditions: [],
704
- })(array);
705
- },
706
- decoder: function (input, target, explore) {
707
- return target instanceof MetadataTuple_1.MetadataTuple
708
- ? decode_tuple(project)(config)(importer)(input, target, explore)
709
- : decode_array(project)(config)(importer)(input, target, explore);
710
- },
711
- empty: config.success,
712
- success: config.success,
713
- failure: function (input, expected, explore) {
714
- return typescript_1.default.factory.createReturnStatement(config.joiner.failure(input, expected, explore));
715
- },
716
- }))(input, elements, explore);
717
- };
718
- };
719
- };
1009
+ var explore_arrays_and_tuples = function (props) {
1010
+ return explore_array_like_union_types({
1011
+ config: props.config,
1012
+ importer: props.importer,
1013
+ factory: UnionExplorer_1.UnionExplorer.array_or_tuple({
1014
+ checker: function (input, definition, explore, array) {
1015
+ return definition instanceof MetadataTuple_1.MetadataTuple
1016
+ ? decode_tuple({
1017
+ config: props.config,
1018
+ context: props.context,
1019
+ importer: props.importer,
1020
+ input: input,
1021
+ tuple: definition,
1022
+ explore: explore,
1023
+ })
1024
+ : props.config.atomist({
1025
+ explore: explore,
1026
+ entry: {
1027
+ expected: props.definitions
1028
+ .map(function (elem) {
1029
+ return elem instanceof MetadataArray_1.MetadataArray
1030
+ ? elem.getName()
1031
+ : elem.type.name;
1032
+ })
1033
+ .join(" | "),
1034
+ expression: CheckerProgrammer.decode({
1035
+ importer: props.importer,
1036
+ context: props.context,
1037
+ config: props.config,
1038
+ input: input,
1039
+ metadata: definition,
1040
+ explore: explore,
1041
+ }),
1042
+ conditions: [],
1043
+ },
1044
+ input: array,
1045
+ });
1046
+ },
1047
+ decoder: function (input, definition, explore) {
1048
+ return definition instanceof MetadataTuple_1.MetadataTuple
1049
+ ? decode_tuple({
1050
+ context: props.context,
1051
+ config: props.config,
1052
+ importer: props.importer,
1053
+ input: input,
1054
+ tuple: definition,
1055
+ explore: explore,
1056
+ })
1057
+ : decode_array({
1058
+ context: props.context,
1059
+ config: props.config,
1060
+ importer: props.importer,
1061
+ input: input,
1062
+ array: definition,
1063
+ explore: explore,
1064
+ });
1065
+ },
1066
+ empty: props.config.success,
1067
+ success: props.config.success,
1068
+ failure: function (input, expected, explore) {
1069
+ return typescript_1.default.factory.createReturnStatement(props.config.joiner.failure({
1070
+ input: input,
1071
+ expected: expected,
1072
+ explore: explore,
1073
+ }));
1074
+ },
1075
+ }),
1076
+ input: props.input,
1077
+ definitions: props.definitions,
1078
+ explore: props.explore,
1079
+ });
720
1080
  };
721
- var explore_array_like_union_types = function (config) {
722
- return function (importer) {
723
- return function (factory) {
724
- return function (input, elements, explore) {
725
- var arrow = function (parameters) {
726
- return function (explore) {
727
- return function (input) {
728
- return factory(parameters)(input, elements, explore);
729
- };
730
- };
731
- };
732
- if (elements.every(function (e) { return e.type.recursive === false; }))
733
- typescript_1.default.factory.createCallExpression(arrow([])(explore)(input), undefined, []);
734
- explore = __assign(__assign({}, explore), { source: "function", from: "array" });
735
- return typescript_1.default.factory.createLogicalOr(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(importer.emplaceUnion(config.prefix, elements.map(function (e) { return e.type.name; }).join(" | "), function () {
736
- return arrow(FeatureProgrammer_1.FeatureProgrammer.parameterDeclarations(config)(TypeFactory_1.TypeFactory.keyword("any"))(typescript_1.default.factory.createIdentifier("input")))(__assign(__assign({}, explore), { postfix: "" }))(typescript_1.default.factory.createIdentifier("input"));
737
- })), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(config)(explore)(input)), config.joiner.failure(input, elements.map(function (e) { return e.type.name; }).join(" | "), explore));
738
- };
739
- };
1081
+ var explore_array_like_union_types = function (props) {
1082
+ var arrow = function (next) {
1083
+ return props.factory(next.parameters)(next.input, props.definitions, next.explore);
740
1084
  };
1085
+ if (props.definitions.every(function (e) { return e.type.recursive === false; }))
1086
+ typescript_1.default.factory.createCallExpression(arrow({
1087
+ explore: props.explore,
1088
+ input: props.input,
1089
+ parameters: [],
1090
+ }), undefined, []);
1091
+ var arrayExplore = __assign(__assign({}, props.explore), { source: "function", from: "array" });
1092
+ return typescript_1.default.factory.createLogicalOr(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(props.importer.emplaceUnion(props.config.prefix, props.definitions.map(function (e) { return e.type.name; }).join(" | "), function () {
1093
+ return arrow({
1094
+ parameters: FeatureProgrammer_1.FeatureProgrammer.parameterDeclarations(props.config)(TypeFactory_1.TypeFactory.keyword("any"))(typescript_1.default.factory.createIdentifier("input")),
1095
+ explore: __assign(__assign({}, arrayExplore), { postfix: "" }),
1096
+ input: typescript_1.default.factory.createIdentifier("input"),
1097
+ });
1098
+ })), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(props.config)(arrayExplore)(props.input)), props.config.joiner.failure({
1099
+ input: props.input,
1100
+ expected: props.definitions.map(function (e) { return e.type.name; }).join(" | "),
1101
+ explore: arrayExplore,
1102
+ }));
741
1103
  };
742
- var explore_objects = function (config) {
743
- return function (importer) {
744
- return function (input, meta, explore) {
745
- return meta.objects.length === 1
746
- ? CheckerProgrammer.decode_object(config)(importer)(input, meta.objects[0], explore)
747
- : typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(importer.useLocal("".concat(config.prefix, "u").concat(meta.union_index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(config)(explore)(input));
748
- };
749
- };
1104
+ var explore_objects = function (props) {
1105
+ return props.metadata.objects.length === 1
1106
+ ? CheckerProgrammer.decode_object({
1107
+ config: props.config,
1108
+ importer: props.importer,
1109
+ object: props.metadata.objects[0],
1110
+ input: props.input,
1111
+ explore: props.explore,
1112
+ })
1113
+ : typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(props.importer.useLocal("".concat(props.config.prefix, "u").concat(props.metadata.union_index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(props.config)(props.explore)(props.input));
750
1114
  };
751
1115
  })(CheckerProgrammer || (exports.CheckerProgrammer = CheckerProgrammer = {}));
752
- var create_add = function (binaries) {
753
- return function (defaultInput) {
754
- return function (exact, left, right) {
755
- if (right === void 0) { right = defaultInput; }
756
- var factory = exact
757
- ? typescript_1.default.factory.createStrictEquality
758
- : typescript_1.default.factory.createStrictInequality;
759
- binaries.push({
760
- expression: factory(left, right),
761
- combined: false,
762
- });
763
- };
764
- };
1116
+ var create_add = function (props) {
1117
+ var _a;
1118
+ var factory = props.exact
1119
+ ? typescript_1.default.factory.createStrictEquality
1120
+ : typescript_1.default.factory.createStrictInequality;
1121
+ props.binaries.push({
1122
+ expression: factory(props.left, (_a = props.right) !== null && _a !== void 0 ? _a : props.default),
1123
+ combined: false,
1124
+ });
765
1125
  };
766
1126
  //# sourceMappingURL=CheckerProgrammer.js.map