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.
- package/lib/index.mjs +1 -0
- package/lib/index.mjs.map +1 -1
- package/lib/programmers/AssertProgrammer.d.ts +1 -1
- package/lib/programmers/AssertProgrammer.js +169 -127
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +70 -15
- package/lib/programmers/CheckerProgrammer.js +998 -638
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/FeatureProgrammer.d.ts +7 -3
- package/lib/programmers/FeatureProgrammer.js +17 -17
- package/lib/programmers/FeatureProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.d.ts +25 -4
- package/lib/programmers/IsProgrammer.js +54 -39
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +110 -97
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/UnionExplorer.d.ts +1 -1
- package/lib/programmers/json/JsonStringifyProgrammer.js +71 -38
- package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js +16 -2
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js +504 -406
- package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscLiteralsProgrammer.js +3 -3
- package/lib/programmers/misc/MiscLiteralsProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscPruneProgrammer.js +365 -301
- package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
- package/lib/programmers/notations/NotationGeneralProgrammer.js +62 -15
- package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +17 -3
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
- package/lib/tags/Example.d.ts +14 -0
- package/lib/tags/Example.js +3 -0
- package/lib/tags/Example.js.map +1 -0
- package/lib/tags/Examples.d.ts +10 -0
- package/lib/tags/Examples.js +3 -0
- package/lib/tags/Examples.js.map +1 -0
- package/lib/tags/index.d.ts +2 -0
- package/lib/tags/index.js +2 -0
- package/lib/tags/index.js.map +1 -1
- package/package.json +2 -2
- package/src/programmers/AssertProgrammer.ts +185 -143
- package/src/programmers/CheckerProgrammer.ts +1380 -998
- package/src/programmers/FeatureProgrammer.ts +40 -34
- package/src/programmers/IsProgrammer.ts +94 -66
- package/src/programmers/ValidateProgrammer.ts +149 -137
- package/src/programmers/helpers/UnionExplorer.ts +1 -1
- package/src/programmers/json/JsonStringifyProgrammer.ts +60 -38
- package/src/programmers/llm/LlmApplicationProgrammer.ts +51 -32
- package/src/programmers/misc/MiscCloneProgrammer.ts +775 -600
- package/src/programmers/misc/MiscLiteralsProgrammer.ts +4 -4
- package/src/programmers/misc/MiscPruneProgrammer.ts +532 -415
- package/src/programmers/notations/NotationGeneralProgrammer.ts +64 -26
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +16 -9
- package/src/tags/Example.ts +17 -0
- package/src/tags/Examples.ts +16 -0
- 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
|
|
85
|
+
return FeatureProgrammer_1.FeatureProgrammer.compose(__assign(__assign({}, props), { config: configure(props) }));
|
|
86
86
|
};
|
|
87
|
-
CheckerProgrammer.write = function (
|
|
88
|
-
return
|
|
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 (
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
|
|
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 (
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
|
|
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 (
|
|
109
|
-
return
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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 (
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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 (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
|
297
|
-
var
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
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 (
|
|
408
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
318
409
|
finally {
|
|
319
410
|
try {
|
|
320
|
-
if (
|
|
411
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
321
412
|
}
|
|
322
|
-
finally { if (
|
|
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
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
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
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
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
|
-
|
|
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 (
|
|
501
|
-
var
|
|
502
|
-
|
|
503
|
-
|
|
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
|
|
520
|
-
|
|
521
|
-
return
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
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
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
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
|
|
550
|
-
|
|
551
|
-
return
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
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
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
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 (
|
|
616
|
-
return
|
|
617
|
-
|
|
618
|
-
return
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
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 (
|
|
633
|
-
return
|
|
634
|
-
|
|
635
|
-
return
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
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 (
|
|
653
|
-
return
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
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 (
|
|
670
|
-
return
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
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 (
|
|
687
|
-
return
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
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 (
|
|
722
|
-
|
|
723
|
-
return
|
|
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 (
|
|
743
|
-
return
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
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 (
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
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
|