typia 7.0.0-dev.20240923 → 7.0.0-dev.20240924
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/programmers/FeatureProgrammer.d.ts +2 -2
- package/lib/programmers/FeatureProgrammer.js +2 -2
- package/lib/programmers/json/JsonStringifyProgrammer.js +3 -3
- package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js +456 -405
- 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 +336 -300
- package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
- package/package.json +1 -1
- package/src/programmers/FeatureProgrammer.ts +3 -3
- package/src/programmers/json/JsonStringifyProgrammer.ts +4 -3
- package/src/programmers/misc/MiscCloneProgrammer.ts +737 -600
- package/src/programmers/misc/MiscLiteralsProgrammer.ts +4 -4
- package/src/programmers/misc/MiscPruneProgrammer.ts +508 -412
|
@@ -63,7 +63,7 @@ var wrap_metadata_rest_tuple_1 = require("../internal/wrap_metadata_rest_tuple")
|
|
|
63
63
|
var MiscPruneProgrammer;
|
|
64
64
|
(function (MiscPruneProgrammer) {
|
|
65
65
|
MiscPruneProgrammer.decompose = function (props) {
|
|
66
|
-
var config = configure(props
|
|
66
|
+
var config = configure(props);
|
|
67
67
|
if (props.validated === false)
|
|
68
68
|
config.addition = function (collection) {
|
|
69
69
|
return IsProgrammer_1.IsProgrammer.write_function_statements(props.context)(props.importer)(collection);
|
|
@@ -84,333 +84,373 @@ var MiscPruneProgrammer;
|
|
|
84
84
|
result: result,
|
|
85
85
|
});
|
|
86
86
|
};
|
|
87
|
-
var write_array_functions = function (
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
87
|
+
var write_array_functions = function (props) {
|
|
88
|
+
return props.collection
|
|
89
|
+
.arrays()
|
|
90
|
+
.filter(function (a) { return a.recursive; })
|
|
91
|
+
.map(function (type, i) {
|
|
92
|
+
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({
|
|
93
|
+
config: props.config,
|
|
94
|
+
importer: props.importer,
|
|
95
|
+
input: typescript_1.default.factory.createIdentifier("input"),
|
|
96
|
+
array: MetadataArray_1.MetadataArray.create({
|
|
97
|
+
type: type,
|
|
98
|
+
tags: [],
|
|
99
|
+
}),
|
|
100
|
+
explore: {
|
|
101
|
+
tracable: props.config.trace,
|
|
102
|
+
source: "function",
|
|
103
|
+
from: "array",
|
|
104
|
+
postfix: "",
|
|
105
|
+
},
|
|
106
|
+
})));
|
|
107
|
+
});
|
|
106
108
|
};
|
|
107
|
-
var write_tuple_functions = function (
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
109
|
+
var write_tuple_functions = function (props) {
|
|
110
|
+
return props.collection
|
|
111
|
+
.tuples()
|
|
112
|
+
.filter(function (t) { return t.recursive; })
|
|
113
|
+
.map(function (tuple, i) {
|
|
114
|
+
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({
|
|
115
|
+
context: props.context,
|
|
116
|
+
config: props.config,
|
|
117
|
+
importer: props.importer,
|
|
118
|
+
input: typescript_1.default.factory.createIdentifier("input"),
|
|
119
|
+
tuple: tuple,
|
|
120
|
+
explore: {
|
|
121
|
+
tracable: props.config.trace,
|
|
122
|
+
source: "function",
|
|
123
|
+
from: "array",
|
|
124
|
+
postfix: "",
|
|
125
|
+
},
|
|
126
|
+
})));
|
|
127
|
+
});
|
|
125
128
|
};
|
|
126
129
|
/* -----------------------------------------------------------
|
|
127
130
|
DECODERS
|
|
128
131
|
----------------------------------------------------------- */
|
|
129
|
-
var decode = function (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf(native)(input); },
|
|
186
|
-
value: function () { return typescript_1.default.factory.createReturnStatement(); },
|
|
187
|
-
});
|
|
188
|
-
};
|
|
189
|
-
try {
|
|
190
|
-
for (var _e = __values(meta.natives), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
191
|
-
var native = _f.value;
|
|
192
|
-
_loop_2(native);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
196
|
-
finally {
|
|
197
|
-
try {
|
|
198
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
199
|
-
}
|
|
200
|
-
finally { if (e_2) throw e_2.error; }
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (meta.sets.length)
|
|
204
|
-
unions.push({
|
|
205
|
-
type: "set",
|
|
206
|
-
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf("Set")(input); },
|
|
207
|
-
value: function () { return typescript_1.default.factory.createReturnStatement(); },
|
|
208
|
-
});
|
|
209
|
-
if (meta.maps.length)
|
|
210
|
-
unions.push({
|
|
211
|
-
type: "map",
|
|
212
|
-
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf("Map")(input); },
|
|
213
|
-
value: function () { return typescript_1.default.factory.createReturnStatement(); },
|
|
214
|
-
});
|
|
215
|
-
// OBJECTS
|
|
216
|
-
if (meta.objects.length)
|
|
217
|
-
unions.push({
|
|
218
|
-
type: "object",
|
|
219
|
-
is: function () {
|
|
220
|
-
return ExpressionFactory_1.ExpressionFactory.isObject({
|
|
221
|
-
checkNull: true,
|
|
222
|
-
checkArray: false,
|
|
223
|
-
})(input);
|
|
224
|
-
},
|
|
225
|
-
value: function () {
|
|
226
|
-
return explore_objects(config)(importer)(input, meta, __assign(__assign({}, explore), { from: "object" }));
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
//----
|
|
230
|
-
// STATEMENTS
|
|
231
|
-
//----
|
|
232
|
-
var converter = function (v) {
|
|
233
|
-
return typescript_1.default.isReturnStatement(v) || typescript_1.default.isBlock(v)
|
|
234
|
-
? v
|
|
235
|
-
: typescript_1.default.factory.createExpressionStatement(v);
|
|
236
|
-
};
|
|
237
|
-
var statements = unions.map(function (u) {
|
|
238
|
-
return typescript_1.default.factory.createIfStatement(u.is(), converter(u.value()));
|
|
239
|
-
});
|
|
240
|
-
return typescript_1.default.factory.createBlock(statements, true);
|
|
241
|
-
};
|
|
132
|
+
var decode = function (props) {
|
|
133
|
+
var e_1, _a, e_2, _b;
|
|
134
|
+
if (filter(props.metadata) === false)
|
|
135
|
+
return typescript_1.default.factory.createBlock([]);
|
|
136
|
+
var unions = [];
|
|
137
|
+
var _loop_1 = function (tuple) {
|
|
138
|
+
unions.push({
|
|
139
|
+
type: "tuple",
|
|
140
|
+
is: function () {
|
|
141
|
+
return IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer)(props.input, (function () {
|
|
142
|
+
var partial = Metadata_1.Metadata.initialize();
|
|
143
|
+
partial.tuples.push(tuple);
|
|
144
|
+
return partial;
|
|
145
|
+
})(), props.explore);
|
|
146
|
+
},
|
|
147
|
+
value: function () {
|
|
148
|
+
return decode_tuple(__assign(__assign({}, props), { tuple: tuple }));
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
try {
|
|
153
|
+
//----
|
|
154
|
+
// LIST UP UNION TYPES
|
|
155
|
+
//----
|
|
156
|
+
// TUPLES
|
|
157
|
+
for (var _c = __values(props.metadata.tuples.filter(function (tuple) {
|
|
158
|
+
return tuple.type.elements.some(function (e) { var _a; return filter((_a = e.rest) !== null && _a !== void 0 ? _a : e); });
|
|
159
|
+
})), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
160
|
+
var tuple = _d.value;
|
|
161
|
+
_loop_1(tuple);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
165
|
+
finally {
|
|
166
|
+
try {
|
|
167
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
168
|
+
}
|
|
169
|
+
finally { if (e_1) throw e_1.error; }
|
|
170
|
+
}
|
|
171
|
+
// ARRAYS
|
|
172
|
+
if (props.metadata.arrays.filter(function (a) { return filter(a.type.value); }).length)
|
|
173
|
+
unions.push({
|
|
174
|
+
type: "array",
|
|
175
|
+
is: function () { return ExpressionFactory_1.ExpressionFactory.isArray(props.input); },
|
|
176
|
+
value: function () {
|
|
177
|
+
return explore_arrays(__assign(__assign({}, props), { arrays: props.metadata.arrays, explore: __assign(__assign({}, props.explore), { from: "array" }) }));
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
// BUILT-IN CLASSES
|
|
181
|
+
if (props.metadata.natives.length) {
|
|
182
|
+
var _loop_2 = function (native) {
|
|
183
|
+
unions.push({
|
|
184
|
+
type: "native",
|
|
185
|
+
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf(native)(props.input); },
|
|
186
|
+
value: function () { return typescript_1.default.factory.createReturnStatement(); },
|
|
187
|
+
});
|
|
242
188
|
};
|
|
189
|
+
try {
|
|
190
|
+
for (var _e = __values(props.metadata.natives), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
191
|
+
var native = _f.value;
|
|
192
|
+
_loop_2(native);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
196
|
+
finally {
|
|
197
|
+
try {
|
|
198
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
199
|
+
}
|
|
200
|
+
finally { if (e_2) throw e_2.error; }
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (props.metadata.sets.length)
|
|
204
|
+
unions.push({
|
|
205
|
+
type: "set",
|
|
206
|
+
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf("Set")(props.input); },
|
|
207
|
+
value: function () { return typescript_1.default.factory.createReturnStatement(); },
|
|
208
|
+
});
|
|
209
|
+
if (props.metadata.maps.length)
|
|
210
|
+
unions.push({
|
|
211
|
+
type: "map",
|
|
212
|
+
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf("Map")(props.input); },
|
|
213
|
+
value: function () { return typescript_1.default.factory.createReturnStatement(); },
|
|
214
|
+
});
|
|
215
|
+
// OBJECTS
|
|
216
|
+
if (props.metadata.objects.length)
|
|
217
|
+
unions.push({
|
|
218
|
+
type: "object",
|
|
219
|
+
is: function () {
|
|
220
|
+
return ExpressionFactory_1.ExpressionFactory.isObject({
|
|
221
|
+
checkNull: true,
|
|
222
|
+
checkArray: false,
|
|
223
|
+
})(props.input);
|
|
224
|
+
},
|
|
225
|
+
value: function () {
|
|
226
|
+
return explore_objects(__assign(__assign({}, props), { explore: __assign(__assign({}, props.explore), { from: "object" }) }));
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
//----
|
|
230
|
+
// STATEMENTS
|
|
231
|
+
//----
|
|
232
|
+
var converter = function (v) {
|
|
233
|
+
return typescript_1.default.isReturnStatement(v) || typescript_1.default.isBlock(v)
|
|
234
|
+
? v
|
|
235
|
+
: typescript_1.default.factory.createExpressionStatement(v);
|
|
243
236
|
};
|
|
237
|
+
var statements = unions.map(function (u) {
|
|
238
|
+
return typescript_1.default.factory.createIfStatement(u.is(), converter(u.value()));
|
|
239
|
+
});
|
|
240
|
+
return typescript_1.default.factory.createBlock(statements, true);
|
|
244
241
|
};
|
|
245
|
-
var decode_object = function (
|
|
242
|
+
var decode_object = function (props) {
|
|
246
243
|
return FeatureProgrammer_1.FeatureProgrammer.decode_object({
|
|
247
244
|
trace: false,
|
|
248
245
|
path: false,
|
|
249
246
|
prefix: PREFIX,
|
|
250
|
-
})(importer);
|
|
247
|
+
})(props.importer)(props.input, props.object, props.explore);
|
|
251
248
|
};
|
|
252
|
-
var decode_array = function (
|
|
253
|
-
return
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
? 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))
|
|
257
|
-
: decode_array_inline(config)(importer)(input, array, explore);
|
|
258
|
-
};
|
|
259
|
-
};
|
|
249
|
+
var decode_array = function (props) {
|
|
250
|
+
return props.array.type.recursive
|
|
251
|
+
? 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({}, props.explore), { source: "function", from: "array" }))(props.input))
|
|
252
|
+
: decode_array_inline(props);
|
|
260
253
|
};
|
|
261
|
-
var decode_array_inline = function (
|
|
262
|
-
return
|
|
263
|
-
return function (input, array, explore) {
|
|
264
|
-
return FeatureProgrammer_1.FeatureProgrammer.decode_array(config)(importer)(PruneJoiner_1.PruneJoiner.array)(input, array, explore);
|
|
265
|
-
};
|
|
266
|
-
};
|
|
254
|
+
var decode_array_inline = function (props) {
|
|
255
|
+
return FeatureProgrammer_1.FeatureProgrammer.decode_array(props.config)(props.importer)(PruneJoiner_1.PruneJoiner.array)(props.input, props.array, props.explore);
|
|
267
256
|
};
|
|
268
|
-
var decode_tuple = function (
|
|
269
|
-
return
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return tuple.type.recursive
|
|
273
|
-
? 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))
|
|
274
|
-
: decode_tuple_inline(project)(config)(importer)(input, tuple.type, explore);
|
|
275
|
-
};
|
|
276
|
-
};
|
|
277
|
-
};
|
|
257
|
+
var decode_tuple = function (props) {
|
|
258
|
+
return props.tuple.type.recursive
|
|
259
|
+
? 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({}, props.explore), { source: "function" }))(props.input))
|
|
260
|
+
: decode_tuple_inline(__assign(__assign({}, props), { tuple: props.tuple.type }));
|
|
278
261
|
};
|
|
279
|
-
var decode_tuple_inline = function (
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
262
|
+
var decode_tuple_inline = function (props) {
|
|
263
|
+
var elements = props.tuple.elements
|
|
264
|
+
.map(function (elem, index) { return [elem, index]; })
|
|
265
|
+
.filter(function (_a) {
|
|
266
|
+
var _b = __read(_a, 1), elem = _b[0];
|
|
267
|
+
return filter(elem) && elem.rest === null;
|
|
268
|
+
})
|
|
269
|
+
.map(function (_a) {
|
|
270
|
+
var _b = __read(_a, 2), elem = _b[0], index = _b[1];
|
|
271
|
+
return decode({
|
|
272
|
+
context: props.context,
|
|
273
|
+
config: props.config,
|
|
274
|
+
importer: props.importer,
|
|
275
|
+
input: typescript_1.default.factory.createElementAccessExpression(props.input, index),
|
|
276
|
+
metadata: elem,
|
|
277
|
+
explore: __assign(__assign({}, props.explore), { from: "array", postfix: props.explore.postfix.length
|
|
278
|
+
? "".concat((0, postfix_of_tuple_1.postfix_of_tuple)(props.explore.postfix), "[").concat(index, "]\"")
|
|
279
|
+
: "\"[".concat(index, "]\"") }),
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
var rest = (function () {
|
|
283
|
+
if (props.tuple.elements.length === 0)
|
|
284
|
+
return null;
|
|
285
|
+
var last = props.tuple.elements.at(-1);
|
|
286
|
+
var rest = last.rest;
|
|
287
|
+
if (rest === null || filter(rest) === false)
|
|
288
|
+
return null;
|
|
289
|
+
return decode({
|
|
290
|
+
context: props.context,
|
|
291
|
+
config: props.config,
|
|
292
|
+
importer: props.importer,
|
|
293
|
+
input: typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(props.input)("slice"), undefined, [ExpressionFactory_1.ExpressionFactory.number(props.tuple.elements.length - 1)]),
|
|
294
|
+
metadata: (0, wrap_metadata_rest_tuple_1.wrap_metadata_rest_tuple)(props.tuple.elements.at(-1).rest),
|
|
295
|
+
explore: __assign(__assign({}, props.explore), { start: props.tuple.elements.length - 1 }),
|
|
296
|
+
});
|
|
297
|
+
})();
|
|
298
|
+
return PruneJoiner_1.PruneJoiner.tuple({
|
|
299
|
+
elements: elements,
|
|
300
|
+
rest: rest,
|
|
301
|
+
});
|
|
311
302
|
};
|
|
312
303
|
/* -----------------------------------------------------------
|
|
313
304
|
UNION TYPE EXPLORERS
|
|
314
305
|
----------------------------------------------------------- */
|
|
315
|
-
var explore_objects = function (
|
|
316
|
-
|
|
317
|
-
return
|
|
318
|
-
|
|
319
|
-
return decode_object(importer)(input, meta.objects[0], explore);
|
|
320
|
-
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(importer.useLocal("".concat(PREFIX, "u").concat(meta.union_index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(config)(explore)(input));
|
|
321
|
-
};
|
|
322
|
-
};
|
|
306
|
+
var explore_objects = function (props) {
|
|
307
|
+
if (props.metadata.objects.length === 1)
|
|
308
|
+
return decode_object(__assign(__assign({}, props), { object: props.metadata.objects[0] }));
|
|
309
|
+
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(props.importer.useLocal("".concat(PREFIX, "u").concat(props.metadata.union_index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(props.config)(props.explore)(props.input));
|
|
323
310
|
};
|
|
324
|
-
var explore_arrays = function (
|
|
325
|
-
return function (
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
311
|
+
var explore_arrays = function (props) {
|
|
312
|
+
return explore_array_like_union_types(__assign(__assign({}, props), { elements: props.arrays, factory: function (next) {
|
|
313
|
+
return UnionExplorer_1.UnionExplorer.array({
|
|
314
|
+
checker: IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer),
|
|
315
|
+
decoder: function (input, array, explore) {
|
|
316
|
+
return decode_array({
|
|
317
|
+
config: props.config,
|
|
318
|
+
importer: props.importer,
|
|
319
|
+
input: input,
|
|
320
|
+
array: array,
|
|
321
|
+
explore: explore,
|
|
322
|
+
});
|
|
323
|
+
},
|
|
324
|
+
empty: typescript_1.default.factory.createStringLiteral("[]"),
|
|
325
|
+
success: typescript_1.default.factory.createTrue(),
|
|
326
|
+
failure: function (input, expected) {
|
|
327
|
+
return create_throw_error({
|
|
328
|
+
importer: props.importer,
|
|
329
|
+
expected: expected,
|
|
330
|
+
input: input,
|
|
331
|
+
});
|
|
332
|
+
},
|
|
333
|
+
})(next.parameters)(next.input, next.elements, next.explore);
|
|
334
|
+
} }));
|
|
340
335
|
};
|
|
341
|
-
var explore_array_like_union_types = function (
|
|
342
|
-
|
|
343
|
-
return
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
};
|
|
350
|
-
};
|
|
351
|
-
};
|
|
352
|
-
if (elements.every(function (e) { return e.type.recursive === false; }))
|
|
353
|
-
typescript_1.default.factory.createCallExpression(arrow([])(explore)(input), undefined, []);
|
|
354
|
-
explore = __assign(__assign({}, explore), { source: "function", from: "array" });
|
|
355
|
-
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(importer.emplaceUnion(config.prefix, elements.map(function (e) { return e.type.name; }).join(" | "), function () {
|
|
356
|
-
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"));
|
|
357
|
-
})), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(config)(explore)(input));
|
|
358
|
-
};
|
|
359
|
-
};
|
|
336
|
+
var explore_array_like_union_types = function (props) {
|
|
337
|
+
var arrow = function (next) {
|
|
338
|
+
return props.factory({
|
|
339
|
+
elements: props.elements,
|
|
340
|
+
parameters: next.parameters,
|
|
341
|
+
input: next.input,
|
|
342
|
+
explore: next.explore,
|
|
343
|
+
});
|
|
360
344
|
};
|
|
345
|
+
if (props.elements.every(function (e) { return e.type.recursive === false; }))
|
|
346
|
+
typescript_1.default.factory.createCallExpression(arrow({
|
|
347
|
+
parameters: [],
|
|
348
|
+
explore: props.explore,
|
|
349
|
+
input: props.input,
|
|
350
|
+
}), undefined, []);
|
|
351
|
+
var explore = __assign(__assign({}, props.explore), { source: "function", from: "array" });
|
|
352
|
+
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(props.importer.emplaceUnion(props.config.prefix, props.elements.map(function (e) { return e.type.name; }).join(" | "), function () {
|
|
353
|
+
return arrow({
|
|
354
|
+
parameters: FeatureProgrammer_1.FeatureProgrammer.parameterDeclarations(props.config)(TypeFactory_1.TypeFactory.keyword("any"))(typescript_1.default.factory.createIdentifier("input")),
|
|
355
|
+
explore: __assign(__assign({}, explore), { postfix: "" }),
|
|
356
|
+
input: typescript_1.default.factory.createIdentifier("input"),
|
|
357
|
+
});
|
|
358
|
+
})), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(props.config)(props.explore)(props.input));
|
|
361
359
|
};
|
|
362
360
|
// @todo -> must filter out recursive visit
|
|
363
|
-
var filter = function (
|
|
364
|
-
return
|
|
365
|
-
(
|
|
366
|
-
|
|
361
|
+
var filter = function (metadata) {
|
|
362
|
+
return metadata.any === false &&
|
|
363
|
+
(metadata.objects.length !== 0 ||
|
|
364
|
+
metadata.tuples.some(function (t) {
|
|
367
365
|
return !!t.type.elements.length &&
|
|
368
366
|
t.type.elements.some(function (e) { var _a; return filter((_a = e.rest) !== null && _a !== void 0 ? _a : e); });
|
|
369
367
|
}) ||
|
|
370
|
-
|
|
368
|
+
metadata.arrays.some(function (e) { return filter(e.type.value); }));
|
|
371
369
|
};
|
|
372
370
|
/* -----------------------------------------------------------
|
|
373
371
|
CONFIGURATIONS
|
|
374
372
|
----------------------------------------------------------- */
|
|
375
373
|
var PREFIX = "$p";
|
|
376
|
-
var configure = function (
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
return typescript_1.default.factory.createTypeReferenceNode(name !== null && name !== void 0 ? name : TypeFactory_1.TypeFactory.getFullName(project.checker)(type));
|
|
382
|
-
},
|
|
383
|
-
output: function () { return TypeFactory_1.TypeFactory.keyword("void"); },
|
|
374
|
+
var configure = function (props) {
|
|
375
|
+
var config = {
|
|
376
|
+
types: {
|
|
377
|
+
input: function (type, name) {
|
|
378
|
+
return typescript_1.default.factory.createTypeReferenceNode(name !== null && name !== void 0 ? name : TypeFactory_1.TypeFactory.getFullName(props.context.checker)(type));
|
|
384
379
|
},
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
380
|
+
output: function () { return TypeFactory_1.TypeFactory.keyword("void"); },
|
|
381
|
+
},
|
|
382
|
+
prefix: PREFIX,
|
|
383
|
+
trace: false,
|
|
384
|
+
path: false,
|
|
385
|
+
initializer: initializer,
|
|
386
|
+
decoder: function () { return function (input, metadata, explore) {
|
|
387
|
+
return decode({
|
|
388
|
+
context: props.context,
|
|
389
|
+
importer: props.importer,
|
|
390
|
+
config: config,
|
|
391
|
+
input: input,
|
|
392
|
+
metadata: metadata,
|
|
393
|
+
explore: explore,
|
|
394
|
+
});
|
|
395
|
+
}; },
|
|
396
|
+
objector: {
|
|
397
|
+
checker: function () { return IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer); },
|
|
398
|
+
decoder: function () { return function (input, object, explore) {
|
|
399
|
+
return decode_object({
|
|
400
|
+
importer: props.importer,
|
|
401
|
+
input: input,
|
|
402
|
+
object: object,
|
|
403
|
+
explore: explore,
|
|
404
|
+
});
|
|
405
|
+
}; },
|
|
406
|
+
joiner: PruneJoiner_1.PruneJoiner.object,
|
|
407
|
+
unionizer: (0, decode_union_object_1.decode_union_object)(IsProgrammer_1.IsProgrammer.decode_object(props.context)(props.importer))(function (input, object, explore) {
|
|
408
|
+
return decode_object({
|
|
409
|
+
importer: props.importer,
|
|
410
|
+
input: input,
|
|
411
|
+
object: object,
|
|
412
|
+
explore: explore,
|
|
413
|
+
});
|
|
414
|
+
})(function (exp) { return exp; })(function (input, expected) {
|
|
415
|
+
return create_throw_error({
|
|
416
|
+
importer: props.importer,
|
|
417
|
+
expected: expected,
|
|
418
|
+
input: input,
|
|
419
|
+
});
|
|
420
|
+
}),
|
|
421
|
+
failure: function (input, expected) {
|
|
422
|
+
return create_throw_error({
|
|
423
|
+
importer: props.importer,
|
|
424
|
+
expected: expected,
|
|
425
|
+
input: input,
|
|
426
|
+
});
|
|
404
427
|
},
|
|
405
|
-
}
|
|
406
|
-
|
|
428
|
+
},
|
|
429
|
+
generator: {
|
|
430
|
+
arrays: function () { return function (collection) {
|
|
431
|
+
return write_array_functions({
|
|
432
|
+
config: config,
|
|
433
|
+
importer: props.importer,
|
|
434
|
+
collection: collection,
|
|
435
|
+
});
|
|
436
|
+
}; },
|
|
437
|
+
tuples: function () { return function (collection) {
|
|
438
|
+
return write_tuple_functions({
|
|
439
|
+
config: config,
|
|
440
|
+
context: props.context,
|
|
441
|
+
importer: props.importer,
|
|
442
|
+
collection: collection,
|
|
443
|
+
});
|
|
444
|
+
}; },
|
|
445
|
+
},
|
|
407
446
|
};
|
|
447
|
+
return config;
|
|
408
448
|
};
|
|
409
|
-
var initializer = function (
|
|
449
|
+
var initializer = function (context) { return function (importer) { return function (type) {
|
|
410
450
|
var collection = new MetadataCollection_1.MetadataCollection();
|
|
411
451
|
var result = MetadataFactory_1.MetadataFactory.analyze({
|
|
412
|
-
checker:
|
|
413
|
-
transformer:
|
|
452
|
+
checker: context.checker,
|
|
453
|
+
transformer: context.transformer,
|
|
414
454
|
options: {
|
|
415
455
|
escape: false,
|
|
416
456
|
constant: true,
|
|
@@ -423,17 +463,13 @@ var MiscPruneProgrammer;
|
|
|
423
463
|
throw TransformerError_1.TransformerError.from("typia.misc.".concat(importer.method))(result.errors);
|
|
424
464
|
return [collection, result.data];
|
|
425
465
|
}; }; };
|
|
426
|
-
var create_throw_error = function (
|
|
427
|
-
return
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
], true),
|
|
434
|
-
]));
|
|
435
|
-
};
|
|
436
|
-
};
|
|
466
|
+
var create_throw_error = function (props) {
|
|
467
|
+
return typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(props.importer.use("throws"), [], [
|
|
468
|
+
typescript_1.default.factory.createObjectLiteralExpression([
|
|
469
|
+
typescript_1.default.factory.createPropertyAssignment("expected", typescript_1.default.factory.createStringLiteral(props.expected)),
|
|
470
|
+
typescript_1.default.factory.createPropertyAssignment("value", props.input),
|
|
471
|
+
], true),
|
|
472
|
+
]));
|
|
437
473
|
};
|
|
438
474
|
})(MiscPruneProgrammer || (exports.MiscPruneProgrammer = MiscPruneProgrammer = {}));
|
|
439
475
|
//# sourceMappingURL=MiscPruneProgrammer.js.map
|