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