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