typia 7.0.0-dev.20240922 → 7.0.0-dev.20240923
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.
|
@@ -61,7 +61,6 @@ var ValueFactory_1 = require("../../factories/ValueFactory");
|
|
|
61
61
|
var Metadata_1 = require("../../schemas/metadata/Metadata");
|
|
62
62
|
var MetadataArray_1 = require("../../schemas/metadata/MetadataArray");
|
|
63
63
|
var MetadataAtomic_1 = require("../../schemas/metadata/MetadataAtomic");
|
|
64
|
-
var ArrayUtil_1 = require("../../utils/ArrayUtil");
|
|
65
64
|
var FeatureProgrammer_1 = require("../FeatureProgrammer");
|
|
66
65
|
var IsProgrammer_1 = require("../IsProgrammer");
|
|
67
66
|
var AtomicPredicator_1 = require("../helpers/AtomicPredicator");
|
|
@@ -80,7 +79,7 @@ var JsonStringifyProgrammer;
|
|
|
80
79
|
WRITER
|
|
81
80
|
----------------------------------------------------------- */
|
|
82
81
|
JsonStringifyProgrammer.decompose = function (props) {
|
|
83
|
-
var config = configure(props
|
|
82
|
+
var config = configure(props);
|
|
84
83
|
if (props.validated === false)
|
|
85
84
|
config.addition = function (collection) {
|
|
86
85
|
return IsProgrammer_1.IsProgrammer.write_function_statements(props.context)(props.importer)(collection);
|
|
@@ -101,429 +100,405 @@ var JsonStringifyProgrammer;
|
|
|
101
100
|
result: result,
|
|
102
101
|
});
|
|
103
102
|
};
|
|
104
|
-
var write_array_functions = function (
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
103
|
+
var write_array_functions = function (props) {
|
|
104
|
+
return props.collection
|
|
105
|
+
.arrays()
|
|
106
|
+
.filter(function (a) { return a.recursive; })
|
|
107
|
+
.map(function (type, i) {
|
|
108
|
+
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({
|
|
109
|
+
config: props.config,
|
|
110
|
+
importer: props.importer,
|
|
111
|
+
input: typescript_1.default.factory.createIdentifier("input"),
|
|
112
|
+
array: MetadataArray_1.MetadataArray.create({
|
|
113
|
+
type: type,
|
|
114
|
+
tags: [],
|
|
115
|
+
}),
|
|
116
|
+
explore: {
|
|
117
|
+
tracable: props.config.trace,
|
|
118
|
+
source: "function",
|
|
119
|
+
from: "array",
|
|
120
|
+
postfix: "",
|
|
121
|
+
},
|
|
122
|
+
})));
|
|
123
|
+
});
|
|
123
124
|
};
|
|
124
|
-
var write_tuple_functions = function (
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
125
|
+
var write_tuple_functions = function (props) {
|
|
126
|
+
return props.collection
|
|
127
|
+
.tuples()
|
|
128
|
+
.filter(function (t) { return t.recursive; })
|
|
129
|
+
.map(function (tuple, i) {
|
|
130
|
+
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({
|
|
131
|
+
context: props.context,
|
|
132
|
+
config: props.config,
|
|
133
|
+
importer: props.importer,
|
|
134
|
+
input: typescript_1.default.factory.createIdentifier("input"),
|
|
135
|
+
tuple: tuple,
|
|
136
|
+
explore: {
|
|
137
|
+
tracable: props.config.trace,
|
|
138
|
+
source: "function",
|
|
139
|
+
from: "array",
|
|
140
|
+
postfix: "",
|
|
141
|
+
},
|
|
142
|
+
})));
|
|
143
|
+
});
|
|
142
144
|
};
|
|
143
145
|
/* -----------------------------------------------------------
|
|
144
146
|
DECODERS
|
|
145
147
|
----------------------------------------------------------- */
|
|
146
|
-
var decode = function (
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
};
|
|
342
|
-
unions.push({
|
|
343
|
-
type: "array",
|
|
344
|
-
is: function () { return ExpressionFactory_1.ExpressionFactory.isArray(input); },
|
|
345
|
-
value: value,
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
// BUILT-IN CLASSES
|
|
349
|
-
if (metadata.natives.length) {
|
|
350
|
-
var _loop_4 = function (native) {
|
|
351
|
-
unions.push({
|
|
352
|
-
type: "object",
|
|
353
|
-
is: function () { return (0, check_native_1.check_native)(native)(input); },
|
|
354
|
-
value: function () {
|
|
355
|
-
return AtomicPredicator_1.AtomicPredicator.native(native)
|
|
356
|
-
? decode_atomic(project)(importer)(input, native.toLowerCase(), explore)
|
|
357
|
-
: typescript_1.default.factory.createStringLiteral("{}");
|
|
358
|
-
},
|
|
359
|
-
});
|
|
360
|
-
};
|
|
361
|
-
try {
|
|
362
|
-
for (var _l = __values(metadata.natives), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
363
|
-
var native = _m.value;
|
|
364
|
-
_loop_4(native);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
368
|
-
finally {
|
|
369
|
-
try {
|
|
370
|
-
if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
|
|
371
|
-
}
|
|
372
|
-
finally { if (e_4) throw e_4.error; }
|
|
373
|
-
}
|
|
148
|
+
var decode = function (props) {
|
|
149
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
150
|
+
// ANY TYPE
|
|
151
|
+
if (props.metadata.any === true)
|
|
152
|
+
return wrap_required({
|
|
153
|
+
input: props.input,
|
|
154
|
+
metadata: props.metadata,
|
|
155
|
+
explore: props.explore,
|
|
156
|
+
expression: wrap_functional({
|
|
157
|
+
input: props.input,
|
|
158
|
+
metadata: props.metadata,
|
|
159
|
+
explore: props.explore,
|
|
160
|
+
expression: typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("JSON.stringify"), undefined, [props.input]),
|
|
161
|
+
}),
|
|
162
|
+
});
|
|
163
|
+
// ONLY NULL OR UNDEFINED
|
|
164
|
+
var size = props.metadata.size();
|
|
165
|
+
if (size === 0 &&
|
|
166
|
+
(props.metadata.isRequired() === false ||
|
|
167
|
+
props.metadata.nullable === true)) {
|
|
168
|
+
if (props.metadata.isRequired() === false &&
|
|
169
|
+
props.metadata.nullable === true)
|
|
170
|
+
return props.explore.from === "array"
|
|
171
|
+
? typescript_1.default.factory.createStringLiteral("null")
|
|
172
|
+
: typescript_1.default.factory.createConditionalExpression(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createNull(), props.input), undefined, typescript_1.default.factory.createStringLiteral("null"), undefined, typescript_1.default.factory.createIdentifier("undefined"));
|
|
173
|
+
else if (props.metadata.isRequired() === false)
|
|
174
|
+
return props.explore.from === "array"
|
|
175
|
+
? typescript_1.default.factory.createStringLiteral("null")
|
|
176
|
+
: typescript_1.default.factory.createIdentifier("undefined");
|
|
177
|
+
else
|
|
178
|
+
return typescript_1.default.factory.createStringLiteral("null");
|
|
179
|
+
}
|
|
180
|
+
//----
|
|
181
|
+
// LIST UP UNION TYPES
|
|
182
|
+
//----
|
|
183
|
+
var unions = [];
|
|
184
|
+
// toJSON() METHOD
|
|
185
|
+
if (props.metadata.escaped !== null)
|
|
186
|
+
unions.push({
|
|
187
|
+
type: "resolved",
|
|
188
|
+
is: props.metadata.escaped.original.size() === 1 &&
|
|
189
|
+
props.metadata.escaped.original.natives[0] === "Date"
|
|
190
|
+
? function () { return (0, check_native_1.check_native)("Date")(props.input); }
|
|
191
|
+
: function () { return IsProgrammer_1.IsProgrammer.decode_to_json(false)(props.input); },
|
|
192
|
+
value: function () {
|
|
193
|
+
return decode_to_json(__assign(__assign({}, props), { metadata: props.metadata.escaped.returns }));
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
else if (props.metadata.functions.length)
|
|
197
|
+
unions.push({
|
|
198
|
+
type: "functional",
|
|
199
|
+
is: function () { return IsProgrammer_1.IsProgrammer.decode_functional(props.input); },
|
|
200
|
+
value: function () { return decode_functional(props.explore); },
|
|
201
|
+
});
|
|
202
|
+
// TEMPLATES
|
|
203
|
+
if (props.metadata.templates.length)
|
|
204
|
+
if (AtomicPredicator_1.AtomicPredicator.template(props.metadata)) {
|
|
205
|
+
var partial_1 = Metadata_1.Metadata.initialize();
|
|
206
|
+
partial_1.atomics.push(MetadataAtomic_1.MetadataAtomic.create({ type: "string", tags: [] })),
|
|
207
|
+
unions.push({
|
|
208
|
+
type: "template literal",
|
|
209
|
+
is: function () {
|
|
210
|
+
return IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer)(props.input, partial_1, props.explore);
|
|
211
|
+
},
|
|
212
|
+
value: function () {
|
|
213
|
+
return decode_atomic(__assign(__assign({}, props), { type: "string" }));
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
var _loop_1 = function (constant) {
|
|
218
|
+
if (AtomicPredicator_1.AtomicPredicator.constant({
|
|
219
|
+
metadata: props.metadata,
|
|
220
|
+
name: constant.type,
|
|
221
|
+
}) === false)
|
|
222
|
+
return "continue";
|
|
223
|
+
else if (constant.type !== "string")
|
|
224
|
+
unions.push({
|
|
225
|
+
type: "atomic",
|
|
226
|
+
is: function () {
|
|
227
|
+
return IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer)(props.input, (function () {
|
|
228
|
+
var partial = Metadata_1.Metadata.initialize();
|
|
229
|
+
partial.atomics.push(MetadataAtomic_1.MetadataAtomic.create({
|
|
230
|
+
type: constant.type,
|
|
231
|
+
tags: [],
|
|
232
|
+
}));
|
|
233
|
+
return partial;
|
|
234
|
+
})(), props.explore);
|
|
235
|
+
},
|
|
236
|
+
value: function () {
|
|
237
|
+
return decode_atomic(__assign(__assign({}, props), { type: constant.type }));
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
else if (props.metadata.templates.length === 0)
|
|
241
|
+
unions.push({
|
|
242
|
+
type: "const string",
|
|
243
|
+
is: function () {
|
|
244
|
+
return IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer)(props.input, (function () {
|
|
245
|
+
var partial = Metadata_1.Metadata.initialize();
|
|
246
|
+
partial.atomics.push(MetadataAtomic_1.MetadataAtomic.create({
|
|
247
|
+
type: "string",
|
|
248
|
+
tags: [],
|
|
249
|
+
}));
|
|
250
|
+
return partial;
|
|
251
|
+
})(), props.explore);
|
|
252
|
+
},
|
|
253
|
+
value: function () {
|
|
254
|
+
return decode_constant_string(__assign(__assign({}, props), { values: __spreadArray([], __read(constant.values.map(function (v) { return v.value; })), false) }));
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
try {
|
|
259
|
+
// CONSTANTS
|
|
260
|
+
for (var _e = __values(props.metadata.constants), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
261
|
+
var constant = _f.value;
|
|
262
|
+
_loop_1(constant);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
266
|
+
finally {
|
|
267
|
+
try {
|
|
268
|
+
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
269
|
+
}
|
|
270
|
+
finally { if (e_1) throw e_1.error; }
|
|
271
|
+
}
|
|
272
|
+
var _loop_2 = function (a) {
|
|
273
|
+
if (AtomicPredicator_1.AtomicPredicator.atomic({
|
|
274
|
+
metadata: props.metadata,
|
|
275
|
+
name: a.type,
|
|
276
|
+
}))
|
|
277
|
+
unions.push({
|
|
278
|
+
type: "atomic",
|
|
279
|
+
is: function () {
|
|
280
|
+
return IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer)(props.input, (function () {
|
|
281
|
+
var partial = Metadata_1.Metadata.initialize();
|
|
282
|
+
partial.atomics.push(a);
|
|
283
|
+
return partial;
|
|
284
|
+
})(), props.explore);
|
|
285
|
+
},
|
|
286
|
+
value: function () {
|
|
287
|
+
return decode_atomic(__assign(__assign({}, props), { type: a.type }));
|
|
288
|
+
},
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
try {
|
|
292
|
+
/// ATOMICS
|
|
293
|
+
for (var _g = __values(props.metadata.atomics), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
294
|
+
var a = _h.value;
|
|
295
|
+
_loop_2(a);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
299
|
+
finally {
|
|
300
|
+
try {
|
|
301
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
302
|
+
}
|
|
303
|
+
finally { if (e_2) throw e_2.error; }
|
|
304
|
+
}
|
|
305
|
+
var _loop_3 = function (tuple) {
|
|
306
|
+
unions.push({
|
|
307
|
+
type: "tuple",
|
|
308
|
+
is: function () {
|
|
309
|
+
return IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer)(props.input, (function () {
|
|
310
|
+
var partial = Metadata_1.Metadata.initialize();
|
|
311
|
+
partial.tuples.push(tuple);
|
|
312
|
+
return partial;
|
|
313
|
+
})(), props.explore);
|
|
314
|
+
},
|
|
315
|
+
value: function () {
|
|
316
|
+
return decode_tuple(__assign(__assign({}, props), { tuple: tuple }));
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
try {
|
|
321
|
+
// TUPLES
|
|
322
|
+
for (var _j = __values(props.metadata.tuples), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
323
|
+
var tuple = _k.value;
|
|
324
|
+
_loop_3(tuple);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
328
|
+
finally {
|
|
329
|
+
try {
|
|
330
|
+
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
|
|
331
|
+
}
|
|
332
|
+
finally { if (e_3) throw e_3.error; }
|
|
333
|
+
}
|
|
334
|
+
// ARRAYS
|
|
335
|
+
if (props.metadata.arrays.length) {
|
|
336
|
+
var value = props.metadata.arrays.length === 1
|
|
337
|
+
? function () {
|
|
338
|
+
return decode_array(__assign(__assign({}, props), { array: props.metadata.arrays[0], explore: __assign(__assign({}, props.explore), { from: "array" }) }));
|
|
339
|
+
}
|
|
340
|
+
: props.metadata.arrays.some(function (elem) { return elem.type.value.any; })
|
|
341
|
+
? function () {
|
|
342
|
+
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("JSON.stringify"), undefined, [props.input]);
|
|
374
343
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
unions.push({
|
|
378
|
-
type: "object",
|
|
379
|
-
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf("Set")(input); },
|
|
380
|
-
value: function () { return typescript_1.default.factory.createStringLiteral("{}"); },
|
|
381
|
-
});
|
|
382
|
-
// MAPS
|
|
383
|
-
if (metadata.maps.length)
|
|
384
|
-
unions.push({
|
|
385
|
-
type: "object",
|
|
386
|
-
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf("Map")(input); },
|
|
387
|
-
value: function () { return typescript_1.default.factory.createStringLiteral("{}"); },
|
|
388
|
-
});
|
|
389
|
-
// OBJECTS
|
|
390
|
-
if (metadata.objects.length)
|
|
391
|
-
unions.push({
|
|
392
|
-
type: "object",
|
|
393
|
-
is: function () {
|
|
394
|
-
return ExpressionFactory_1.ExpressionFactory.isObject({
|
|
395
|
-
checkNull: true,
|
|
396
|
-
checkArray: metadata.objects.some(function (obj) {
|
|
397
|
-
return obj.properties.every(function (prop) {
|
|
398
|
-
return !prop.key.isSoleLiteral() || !prop.value.isRequired();
|
|
399
|
-
});
|
|
400
|
-
}),
|
|
401
|
-
})(input);
|
|
402
|
-
},
|
|
403
|
-
value: function () {
|
|
404
|
-
return explore_objects(config)(importer)(input, metadata, __assign(__assign({}, explore), { from: "object" }));
|
|
405
|
-
},
|
|
406
|
-
});
|
|
407
|
-
//----
|
|
408
|
-
// RETURNS
|
|
409
|
-
//----
|
|
410
|
-
// CHECK NULL AND UNDEFINED
|
|
411
|
-
var wrapper = function (output) {
|
|
412
|
-
return wrap_required(input, metadata, explore)(wrap_nullable(input, metadata)(output));
|
|
344
|
+
: function () {
|
|
345
|
+
return explore_arrays(__assign(__assign({}, props), { elements: props.metadata.arrays, explore: __assign(__assign({}, props.explore), { from: "array" }) }));
|
|
413
346
|
};
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
347
|
+
unions.push({
|
|
348
|
+
type: "array",
|
|
349
|
+
is: function () { return ExpressionFactory_1.ExpressionFactory.isArray(props.input); },
|
|
350
|
+
value: value,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
// BUILT-IN CLASSES
|
|
354
|
+
if (props.metadata.natives.length) {
|
|
355
|
+
var _loop_4 = function (native) {
|
|
356
|
+
unions.push({
|
|
357
|
+
type: "object",
|
|
358
|
+
is: function () { return (0, check_native_1.check_native)(native)(props.input); },
|
|
359
|
+
value: function () {
|
|
360
|
+
return AtomicPredicator_1.AtomicPredicator.native(native)
|
|
361
|
+
? decode_atomic(__assign(__assign({}, props), { type: native.toLowerCase() }))
|
|
362
|
+
: typescript_1.default.factory.createStringLiteral("{}");
|
|
363
|
+
},
|
|
364
|
+
});
|
|
427
365
|
};
|
|
366
|
+
try {
|
|
367
|
+
for (var _l = __values(props.metadata.natives), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
368
|
+
var native = _m.value;
|
|
369
|
+
_loop_4(native);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
373
|
+
finally {
|
|
374
|
+
try {
|
|
375
|
+
if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
|
|
376
|
+
}
|
|
377
|
+
finally { if (e_4) throw e_4.error; }
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
// SETS
|
|
381
|
+
if (props.metadata.sets.length)
|
|
382
|
+
unions.push({
|
|
383
|
+
type: "object",
|
|
384
|
+
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf("Set")(props.input); },
|
|
385
|
+
value: function () { return typescript_1.default.factory.createStringLiteral("{}"); },
|
|
386
|
+
});
|
|
387
|
+
// MAPS
|
|
388
|
+
if (props.metadata.maps.length)
|
|
389
|
+
unions.push({
|
|
390
|
+
type: "object",
|
|
391
|
+
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf("Map")(props.input); },
|
|
392
|
+
value: function () { return typescript_1.default.factory.createStringLiteral("{}"); },
|
|
393
|
+
});
|
|
394
|
+
// OBJECTS
|
|
395
|
+
if (props.metadata.objects.length)
|
|
396
|
+
unions.push({
|
|
397
|
+
type: "object",
|
|
398
|
+
is: function () {
|
|
399
|
+
return ExpressionFactory_1.ExpressionFactory.isObject({
|
|
400
|
+
checkNull: true,
|
|
401
|
+
checkArray: props.metadata.objects.some(function (objects) {
|
|
402
|
+
return objects.properties.every(function (prop) { return !prop.key.isSoleLiteral() || !prop.value.isRequired(); });
|
|
403
|
+
}),
|
|
404
|
+
})(props.input);
|
|
405
|
+
},
|
|
406
|
+
value: function () {
|
|
407
|
+
return explore_objects(__assign(__assign({}, props), { explore: __assign(__assign({}, props.explore), { from: "object" }) }));
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
//----
|
|
411
|
+
// RETURNS
|
|
412
|
+
//----
|
|
413
|
+
// CHECK NULL AND UNDEFINED
|
|
414
|
+
var wrapper = function (output) {
|
|
415
|
+
return wrap_required({
|
|
416
|
+
input: props.input,
|
|
417
|
+
metadata: props.metadata,
|
|
418
|
+
explore: props.explore,
|
|
419
|
+
expression: wrap_nullable({
|
|
420
|
+
input: props.input,
|
|
421
|
+
metadata: props.metadata,
|
|
422
|
+
expression: output,
|
|
423
|
+
}),
|
|
424
|
+
});
|
|
428
425
|
};
|
|
426
|
+
// DIRECT RETURN
|
|
427
|
+
if (unions.length === 0)
|
|
428
|
+
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("JSON.stringify"), undefined, [props.input]);
|
|
429
|
+
else if (unions.length === 1)
|
|
430
|
+
return wrapper(unions[0].value());
|
|
431
|
+
// RETURN WITH TYPE CHECKING
|
|
432
|
+
return wrapper(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, iterate({
|
|
433
|
+
importer: props.importer,
|
|
434
|
+
input: props.input,
|
|
435
|
+
expected: props.metadata.getName(),
|
|
436
|
+
unions: unions,
|
|
437
|
+
})), undefined, undefined));
|
|
429
438
|
};
|
|
430
|
-
var decode_object = function (
|
|
439
|
+
var decode_object = function (props) {
|
|
431
440
|
return FeatureProgrammer_1.FeatureProgrammer.decode_object({
|
|
432
441
|
trace: false,
|
|
433
442
|
path: false,
|
|
434
443
|
prefix: PREFIX,
|
|
435
|
-
})(importer);
|
|
444
|
+
})(props.importer)(props.input, props.object, props.explore);
|
|
436
445
|
};
|
|
437
|
-
var decode_array = function (
|
|
438
|
-
return
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
? 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))
|
|
442
|
-
: decode_array_inline(config)(importer)(input, array, explore);
|
|
443
|
-
};
|
|
444
|
-
};
|
|
446
|
+
var decode_array = function (props) {
|
|
447
|
+
return props.array.type.recursive
|
|
448
|
+
? 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))
|
|
449
|
+
: decode_array_inline(props);
|
|
445
450
|
};
|
|
446
|
-
var decode_array_inline = function (
|
|
447
|
-
return
|
|
448
|
-
return function (input, array, explore) {
|
|
449
|
-
return FeatureProgrammer_1.FeatureProgrammer.decode_array(config)(importer)(StringifyJoinder_1.StringifyJoiner.array)(input, array, explore);
|
|
450
|
-
};
|
|
451
|
-
};
|
|
451
|
+
var decode_array_inline = function (props) {
|
|
452
|
+
return FeatureProgrammer_1.FeatureProgrammer.decode_array(props.config)(props.importer)(StringifyJoinder_1.StringifyJoiner.array)(props.input, props.array, props.explore);
|
|
452
453
|
};
|
|
453
|
-
var decode_tuple = function (
|
|
454
|
-
return
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
return tuple.type.recursive
|
|
458
|
-
? 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))
|
|
459
|
-
: decode_tuple_inline(project)(config)(importer)(input, tuple.type, explore);
|
|
460
|
-
};
|
|
461
|
-
};
|
|
462
|
-
};
|
|
454
|
+
var decode_tuple = function (props) {
|
|
455
|
+
return props.tuple.type.recursive
|
|
456
|
+
? 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))
|
|
457
|
+
: decode_tuple_inline(__assign(__assign({}, props), { tuple: props.tuple.type }));
|
|
463
458
|
};
|
|
464
|
-
var decode_tuple_inline = function (
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
.
|
|
470
|
-
.
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
elements: elements,
|
|
486
|
-
rest: rest,
|
|
487
|
-
});
|
|
488
|
-
};
|
|
489
|
-
};
|
|
490
|
-
};
|
|
459
|
+
var decode_tuple_inline = function (props) {
|
|
460
|
+
var elements = props.tuple.elements
|
|
461
|
+
.filter(function (elem) { return elem.rest === null; })
|
|
462
|
+
.map(function (elem, index) {
|
|
463
|
+
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
|
|
464
|
+
? "".concat((0, postfix_of_tuple_1.postfix_of_tuple)(props.explore.postfix), "[").concat(index, "]\"")
|
|
465
|
+
: "\"[".concat(index, "]\"") }) }));
|
|
466
|
+
});
|
|
467
|
+
var rest = (function () {
|
|
468
|
+
if (props.tuple.elements.length === 0)
|
|
469
|
+
return null;
|
|
470
|
+
var last = props.tuple.elements.at(-1);
|
|
471
|
+
if (last.rest === null)
|
|
472
|
+
return null;
|
|
473
|
+
var code = 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 }) }));
|
|
474
|
+
return typescript_1.default.factory.createCallExpression(props.importer.use("rest"), undefined, [code]);
|
|
475
|
+
})();
|
|
476
|
+
return StringifyJoinder_1.StringifyJoiner.tuple({
|
|
477
|
+
elements: elements,
|
|
478
|
+
rest: rest,
|
|
479
|
+
});
|
|
491
480
|
};
|
|
492
|
-
var decode_atomic = function (
|
|
493
|
-
|
|
494
|
-
return
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
: typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(input)("toString"), undefined, undefined);
|
|
502
|
-
};
|
|
503
|
-
};
|
|
481
|
+
var decode_atomic = function (props) {
|
|
482
|
+
if (props.type === "string")
|
|
483
|
+
return typescript_1.default.factory.createCallExpression(props.importer.use("string"), undefined, [props.input]);
|
|
484
|
+
else if (props.type === "number" &&
|
|
485
|
+
OptionPredicator_1.OptionPredicator.numeric(props.context.options))
|
|
486
|
+
props = __assign(__assign({}, props), { input: typescript_1.default.factory.createCallExpression(props.importer.use("number"), undefined, [props.input]) });
|
|
487
|
+
return props.explore.from !== "top"
|
|
488
|
+
? props.input
|
|
489
|
+
: typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(props.input)("toString"), undefined, undefined);
|
|
504
490
|
};
|
|
505
|
-
var decode_constant_string = function (
|
|
506
|
-
|
|
507
|
-
return
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
].reduce(function (x, y) { return typescript_1.default.factory.createAdd(x, y); });
|
|
514
|
-
else
|
|
515
|
-
return decode_atomic(project)(importer)(input, "string", explore);
|
|
516
|
-
};
|
|
517
|
-
};
|
|
491
|
+
var decode_constant_string = function (props) {
|
|
492
|
+
if (props.values.every(function (v) { return !StringifyPredicator_1.StringifyPredicator.require_escape(v); }))
|
|
493
|
+
return [
|
|
494
|
+
typescript_1.default.factory.createStringLiteral('"'),
|
|
495
|
+
props.input,
|
|
496
|
+
typescript_1.default.factory.createStringLiteral('"'),
|
|
497
|
+
].reduce(function (x, y) { return typescript_1.default.factory.createAdd(x, y); });
|
|
498
|
+
return decode_atomic(__assign(__assign({}, props), { type: "string" }));
|
|
518
499
|
};
|
|
519
|
-
var decode_to_json = function (
|
|
520
|
-
return
|
|
521
|
-
return function (importer) {
|
|
522
|
-
return function (input, resolved, explore) {
|
|
523
|
-
return decode(project)(config)(importer)(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(input)("toJSON"), undefined, []), resolved, explore);
|
|
524
|
-
};
|
|
525
|
-
};
|
|
526
|
-
};
|
|
500
|
+
var decode_to_json = function (props) {
|
|
501
|
+
return decode(__assign(__assign({}, props), { input: typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(props.input)("toJSON"), undefined, []) }));
|
|
527
502
|
};
|
|
528
503
|
var decode_functional = function (explore) {
|
|
529
504
|
return explore.from === "array"
|
|
@@ -533,71 +508,79 @@ var JsonStringifyProgrammer;
|
|
|
533
508
|
/* -----------------------------------------------------------
|
|
534
509
|
EXPLORERS
|
|
535
510
|
----------------------------------------------------------- */
|
|
536
|
-
var explore_objects = function (
|
|
537
|
-
return
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
511
|
+
var explore_objects = function (props) {
|
|
512
|
+
return props.metadata.objects.length === 1
|
|
513
|
+
? decode_object({
|
|
514
|
+
importer: props.importer,
|
|
515
|
+
input: props.input,
|
|
516
|
+
object: props.metadata.objects[0],
|
|
517
|
+
explore: props.explore,
|
|
518
|
+
})
|
|
519
|
+
: 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));
|
|
544
520
|
};
|
|
545
|
-
var explore_arrays = function (
|
|
546
|
-
return function (
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
521
|
+
var explore_arrays = function (props) {
|
|
522
|
+
return explore_array_like_union_types(__assign(__assign({}, props), { factory: function (next) {
|
|
523
|
+
return UnionExplorer_1.UnionExplorer.array({
|
|
524
|
+
checker: IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer),
|
|
525
|
+
decoder: function (input, array, explore) {
|
|
526
|
+
return decode_array({
|
|
527
|
+
config: props.config,
|
|
528
|
+
importer: props.importer,
|
|
529
|
+
input: input,
|
|
530
|
+
array: array,
|
|
531
|
+
explore: explore,
|
|
532
|
+
});
|
|
533
|
+
},
|
|
534
|
+
empty: typescript_1.default.factory.createStringLiteral("[]"),
|
|
535
|
+
success: typescript_1.default.factory.createTrue(),
|
|
536
|
+
failure: function (input, expected) {
|
|
537
|
+
return create_throw_error({
|
|
538
|
+
importer: props.importer,
|
|
539
|
+
expected: expected,
|
|
540
|
+
input: input,
|
|
541
|
+
});
|
|
542
|
+
},
|
|
543
|
+
})(next.parameters)(next.input, next.elements, next.explore);
|
|
544
|
+
} }));
|
|
561
545
|
};
|
|
562
|
-
var explore_array_like_union_types = function (
|
|
563
|
-
|
|
564
|
-
return
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
};
|
|
571
|
-
};
|
|
572
|
-
};
|
|
573
|
-
if (elements.every(function (e) { return e.type.recursive === false; }))
|
|
574
|
-
typescript_1.default.factory.createCallExpression(arrow([])(explore)(input), undefined, []);
|
|
575
|
-
explore = __assign(__assign({}, explore), { source: "function", from: "array" });
|
|
576
|
-
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 () {
|
|
577
|
-
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"));
|
|
578
|
-
})), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(config)(explore)(input));
|
|
579
|
-
};
|
|
580
|
-
};
|
|
546
|
+
var explore_array_like_union_types = function (props) {
|
|
547
|
+
var arrow = function (next) {
|
|
548
|
+
return props.factory({
|
|
549
|
+
elements: props.elements,
|
|
550
|
+
parameters: next.parameters,
|
|
551
|
+
input: next.input,
|
|
552
|
+
explore: next.explore,
|
|
553
|
+
});
|
|
581
554
|
};
|
|
555
|
+
if (props.elements.every(function (e) { return e.type.recursive === false; }))
|
|
556
|
+
typescript_1.default.factory.createCallExpression(arrow({
|
|
557
|
+
parameters: [],
|
|
558
|
+
explore: props.explore,
|
|
559
|
+
input: props.input,
|
|
560
|
+
}), undefined, []);
|
|
561
|
+
var explore = __assign(__assign({}, props.explore), { source: "function", from: "array" });
|
|
562
|
+
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 () {
|
|
563
|
+
return arrow({
|
|
564
|
+
parameters: FeatureProgrammer_1.FeatureProgrammer.parameterDeclarations(props.config)(TypeFactory_1.TypeFactory.keyword("any"))(typescript_1.default.factory.createIdentifier("input")),
|
|
565
|
+
explore: __assign(__assign({}, explore), { postfix: "" }),
|
|
566
|
+
input: typescript_1.default.factory.createIdentifier("input"),
|
|
567
|
+
});
|
|
568
|
+
})), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(props.config)(explore)(props.input));
|
|
582
569
|
};
|
|
583
570
|
/* -----------------------------------------------------------
|
|
584
571
|
RETURN SCRIPTS
|
|
585
572
|
----------------------------------------------------------- */
|
|
586
|
-
var wrap_required = function (
|
|
587
|
-
if (
|
|
588
|
-
return
|
|
589
|
-
return
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
: typescript_1.default.factory.createIdentifier("undefined"));
|
|
593
|
-
};
|
|
573
|
+
var wrap_required = function (props) {
|
|
574
|
+
if (props.metadata.isRequired() === true && props.metadata.any === false)
|
|
575
|
+
return props.expression;
|
|
576
|
+
return typescript_1.default.factory.createConditionalExpression(typescript_1.default.factory.createStrictInequality(typescript_1.default.factory.createIdentifier("undefined"), props.input), undefined, props.expression, undefined, props.explore.from === "array"
|
|
577
|
+
? typescript_1.default.factory.createStringLiteral("null")
|
|
578
|
+
: typescript_1.default.factory.createIdentifier("undefined"));
|
|
594
579
|
};
|
|
595
|
-
var wrap_nullable = function (
|
|
596
|
-
if (
|
|
597
|
-
return
|
|
598
|
-
return
|
|
599
|
-
return typescript_1.default.factory.createConditionalExpression(typescript_1.default.factory.createStrictInequality(typescript_1.default.factory.createNull(), input), undefined, expression, undefined, typescript_1.default.factory.createStringLiteral("null"));
|
|
600
|
-
};
|
|
580
|
+
var wrap_nullable = function (props) {
|
|
581
|
+
if (props.metadata.nullable === false)
|
|
582
|
+
return props.expression;
|
|
583
|
+
return typescript_1.default.factory.createConditionalExpression(typescript_1.default.factory.createStrictInequality(typescript_1.default.factory.createNull(), props.input), undefined, props.expression, undefined, typescript_1.default.factory.createStringLiteral("null"));
|
|
601
584
|
};
|
|
602
585
|
var wrap_functional = function (props) {
|
|
603
586
|
if (props.metadata.functions.length === 0)
|
|
@@ -615,46 +598,88 @@ var JsonStringifyProgrammer;
|
|
|
615
598
|
CONFIGURATIONS
|
|
616
599
|
----------------------------------------------------------- */
|
|
617
600
|
var PREFIX = "$s";
|
|
618
|
-
var configure = function (
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
return typescript_1.default.factory.createTypeReferenceNode(name !== null && name !== void 0 ? name : TypeFactory_1.TypeFactory.getFullName(project.checker)(type));
|
|
624
|
-
},
|
|
625
|
-
output: function () { return TypeFactory_1.TypeFactory.keyword("string"); },
|
|
601
|
+
var configure = function (props) {
|
|
602
|
+
var config = {
|
|
603
|
+
types: {
|
|
604
|
+
input: function (type, name) {
|
|
605
|
+
return typescript_1.default.factory.createTypeReferenceNode(name !== null && name !== void 0 ? name : TypeFactory_1.TypeFactory.getFullName(props.context.checker)(type));
|
|
626
606
|
},
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
607
|
+
output: function () { return TypeFactory_1.TypeFactory.keyword("string"); },
|
|
608
|
+
},
|
|
609
|
+
prefix: PREFIX,
|
|
610
|
+
trace: false,
|
|
611
|
+
path: false,
|
|
612
|
+
initializer: initializer,
|
|
613
|
+
decoder: function () { return function (input, metadata, explore) {
|
|
614
|
+
return decode({
|
|
615
|
+
config: config,
|
|
616
|
+
context: props.context,
|
|
617
|
+
importer: props.importer,
|
|
618
|
+
input: input,
|
|
619
|
+
metadata: metadata,
|
|
620
|
+
explore: explore,
|
|
621
|
+
});
|
|
622
|
+
}; },
|
|
623
|
+
objector: {
|
|
624
|
+
checker: function () { return IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer); },
|
|
625
|
+
decoder: function () { return function (input, object, explore) {
|
|
626
|
+
return decode_object({
|
|
627
|
+
importer: props.importer,
|
|
628
|
+
input: input,
|
|
629
|
+
object: object,
|
|
630
|
+
explore: explore,
|
|
631
|
+
});
|
|
632
|
+
}; },
|
|
633
|
+
joiner: function (next) {
|
|
634
|
+
return StringifyJoinder_1.StringifyJoiner.object(__assign(__assign({}, next), { importer: props.importer }));
|
|
644
635
|
},
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
636
|
+
unionizer: (0, decode_union_object_1.decode_union_object)(IsProgrammer_1.IsProgrammer.decode_object(props.context)(props.importer))(function (input, object, explore) {
|
|
637
|
+
return decode_object({
|
|
638
|
+
importer: props.importer,
|
|
639
|
+
input: input,
|
|
640
|
+
object: object,
|
|
641
|
+
explore: explore,
|
|
642
|
+
});
|
|
643
|
+
})(function (exp) { return exp; })(function (input, expected) {
|
|
644
|
+
return create_throw_error({
|
|
645
|
+
importer: props.importer,
|
|
646
|
+
expected: expected,
|
|
647
|
+
input: input,
|
|
648
|
+
});
|
|
649
|
+
}),
|
|
650
|
+
failure: function (input, expected) {
|
|
651
|
+
return create_throw_error({
|
|
652
|
+
importer: props.importer,
|
|
653
|
+
expected: expected,
|
|
654
|
+
input: input,
|
|
655
|
+
});
|
|
648
656
|
},
|
|
649
|
-
}
|
|
650
|
-
|
|
657
|
+
},
|
|
658
|
+
generator: {
|
|
659
|
+
arrays: function () { return function (collection) {
|
|
660
|
+
return write_array_functions({
|
|
661
|
+
config: config,
|
|
662
|
+
importer: props.importer,
|
|
663
|
+
collection: collection,
|
|
664
|
+
});
|
|
665
|
+
}; },
|
|
666
|
+
tuples: function () { return function (collection) {
|
|
667
|
+
return write_tuple_functions({
|
|
668
|
+
config: config,
|
|
669
|
+
context: props.context,
|
|
670
|
+
importer: props.importer,
|
|
671
|
+
collection: collection,
|
|
672
|
+
});
|
|
673
|
+
}; },
|
|
674
|
+
},
|
|
651
675
|
};
|
|
676
|
+
return config;
|
|
652
677
|
};
|
|
653
|
-
var initializer = function (
|
|
678
|
+
var initializer = function (context) { return function (importer) { return function (type) {
|
|
654
679
|
return JsonMetadataFactory_1.JsonMetadataFactory.analyze({
|
|
655
680
|
method: "typia.json.".concat(importer.method),
|
|
656
|
-
checker:
|
|
657
|
-
transformer:
|
|
681
|
+
checker: context.checker,
|
|
682
|
+
transformer: context.transformer,
|
|
658
683
|
type: type,
|
|
659
684
|
});
|
|
660
685
|
}; }; };
|