typia 3.5.0-dev.20221219 → 3.5.0-dev.20230107
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/README.md +62 -17
- package/lib/executable/internal/TypiaSetupWizard.d.ts +6 -2
- package/lib/executable/internal/TypiaSetupWizard.js +25 -23
- package/lib/executable/internal/TypiaSetupWizard.js.map +1 -1
- package/lib/executable/typia.js +11 -10
- package/lib/executable/typia.js.map +1 -1
- package/lib/factories/MetadataCollection.d.ts +1 -9
- package/lib/factories/MetadataCollection.js +2 -77
- package/lib/factories/MetadataCollection.js.map +1 -1
- package/lib/factories/MetadataTagFactory.js +4 -1
- package/lib/factories/MetadataTagFactory.js.map +1 -1
- package/lib/factories/ProtocolFactory.d.ts +0 -1
- package/lib/factories/ProtocolFactory.js +0 -6
- package/lib/factories/ProtocolFactory.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_object.js +4 -2
- package/lib/factories/internal/metadata/iterate_metadata_object.js.map +1 -1
- package/lib/factories/internal/protocols/iterate_protocol_main.js +2 -3
- package/lib/factories/internal/protocols/iterate_protocol_main.js.map +1 -1
- package/lib/factories/internal/protocols/iterate_protocol_map.js +3 -4
- package/lib/factories/internal/protocols/iterate_protocol_map.js.map +1 -1
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js +2 -0
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js.map +1 -1
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js +3 -4
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js.map +1 -1
- package/lib/factories/internal/protocols/iterate_protocol_tuple.js +3 -4
- package/lib/factories/internal/protocols/iterate_protocol_tuple.js.map +1 -1
- package/lib/functional/$number.js +2 -9
- package/lib/functional/$number.js.map +1 -1
- package/lib/metadata/Metadata.js +32 -29
- package/lib/metadata/Metadata.js.map +1 -1
- package/lib/programmers/AssertParseProgrammer.js +12 -1
- package/lib/programmers/AssertParseProgrammer.js.map +1 -1
- package/lib/programmers/AssertProgrammer.js +3 -2
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/AssertStringifyProgrammer.js +13 -2
- package/lib/programmers/AssertStringifyProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +1 -0
- package/lib/programmers/CheckerProgrammer.js +153 -138
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/IsParseProgrammer.js +12 -1
- package/lib/programmers/IsParseProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.js +5 -2
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/IsStringifyProgrammer.js +13 -2
- package/lib/programmers/IsStringifyProgrammer.js.map +1 -1
- package/lib/programmers/MessageProgrammer.js +11 -6
- package/lib/programmers/MessageProgrammer.js.map +1 -1
- package/lib/programmers/StringifyProgrammer.js +6 -1
- package/lib/programmers/StringifyProgrammer.js.map +1 -1
- package/lib/programmers/ValidateParseProgrammer.js +12 -1
- package/lib/programmers/ValidateParseProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +3 -2
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/ValidateStringifyProgrammer.js +13 -2
- package/lib/programmers/ValidateStringifyProgrammer.js.map +1 -1
- package/lib/programmers/helpers/OptionPredicator.d.ts +2 -1
- package/lib/programmers/helpers/OptionPredicator.js +8 -6
- package/lib/programmers/helpers/OptionPredicator.js.map +1 -1
- package/lib/programmers/helpers/UnionExplorer.d.ts +23 -29
- package/lib/programmers/helpers/UnionExplorer.js +29 -41
- package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
- package/lib/programmers/internal/application_object.js +9 -9
- package/lib/programmers/internal/application_object.js.map +1 -1
- package/lib/programmers/internal/application_schema.js +14 -6
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/internal/check_array.js +4 -32
- package/lib/programmers/internal/check_array.js.map +1 -1
- package/lib/programmers/internal/check_array_length.d.ts +1 -0
- package/lib/programmers/internal/check_array_length.js +47 -0
- package/lib/programmers/internal/check_array_length.js.map +1 -0
- package/lib/programmers/internal/check_bigint.d.ts +3 -0
- package/lib/programmers/internal/check_bigint.js +97 -0
- package/lib/programmers/internal/check_bigint.js.map +1 -0
- package/lib/programmers/internal/check_number.js +21 -23
- package/lib/programmers/internal/check_number.js.map +1 -1
- package/lib/programmers/internal/check_union_array_like.d.ts +21 -0
- package/lib/programmers/internal/check_union_array_like.js +83 -0
- package/lib/programmers/internal/check_union_array_like.js.map +1 -0
- package/lib/programmers/internal/check_union_tuple.d.ts +1 -0
- package/lib/programmers/internal/check_union_tuple.js +11 -0
- package/lib/programmers/internal/check_union_tuple.js.map +1 -0
- package/lib/schemas/IJsonSchema.d.ts +3 -5
- package/lib/transformers/ITransformOptions.d.ts +43 -2
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js +5 -3
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/StringifyTransformer.js +12 -1
- package/lib/transformers/features/stringifiers/StringifyTransformer.js.map +1 -1
- package/lib/utils/NameEncoder.d.ts +4 -0
- package/lib/utils/NameEncoder.js +89 -0
- package/lib/utils/NameEncoder.js.map +1 -0
- package/package.json +6 -5
- package/src/executable/internal/TypiaSetupWizard.ts +37 -24
- package/src/executable/typia.ts +7 -5
- package/src/factories/MetadataCollection.ts +2 -43
- package/src/factories/MetadataTagFactory.ts +5 -1
- package/src/factories/ProtocolFactory.ts +0 -5
- package/src/factories/internal/metadata/iterate_metadata_object.ts +6 -3
- package/src/factories/internal/protocols/iterate_protocol_main.ts +2 -3
- package/src/factories/internal/protocols/iterate_protocol_map.ts +3 -5
- package/src/factories/internal/protocols/iterate_protocol_metadata.ts +1 -0
- package/src/factories/internal/protocols/iterate_protocol_repeated.ts +3 -6
- package/src/factories/internal/protocols/iterate_protocol_tuple.ts +3 -6
- package/src/functional/$number.ts +2 -9
- package/src/metadata/Metadata.ts +10 -7
- package/src/programmers/AssertParseProgrammer.ts +11 -1
- package/src/programmers/AssertProgrammer.ts +4 -3
- package/src/programmers/AssertStringifyProgrammer.ts +22 -2
- package/src/programmers/CheckerProgrammer.ts +258 -200
- package/src/programmers/IsParseProgrammer.ts +11 -1
- package/src/programmers/IsProgrammer.ts +5 -2
- package/src/programmers/IsStringifyProgrammer.ts +22 -2
- package/src/programmers/MessageProgrammer.ts +12 -6
- package/src/programmers/StringifyProgrammer.ts +7 -1
- package/src/programmers/ValidateParseProgrammer.ts +11 -1
- package/src/programmers/ValidateProgrammer.ts +3 -2
- package/src/programmers/ValidateStringifyProgrammer.ts +22 -2
- package/src/programmers/helpers/OptionPredicator.ts +7 -10
- package/src/programmers/helpers/UnionExplorer.ts +75 -238
- package/src/programmers/internal/application_default.ts +1 -1
- package/src/programmers/internal/application_object.ts +5 -5
- package/src/programmers/internal/application_schema.ts +20 -5
- package/src/programmers/internal/check_array.ts +3 -25
- package/src/programmers/internal/check_array_length.ts +45 -0
- package/src/programmers/internal/check_bigint.ts +85 -0
- package/src/programmers/internal/check_number.ts +45 -51
- package/src/programmers/internal/check_union_array_like.ts +242 -0
- package/src/programmers/internal/check_union_tuple.ts +33 -0
- package/src/schemas/IJsonSchema.ts +4 -6
- package/src/transformers/ITransformOptions.ts +45 -2
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +7 -3
- package/src/transformers/features/stringifiers/StringifyTransformer.ts +11 -1
- package/src/utils/NameEncoder.ts +32 -0
- package/lib/transformers/features/miscellaneous/CreateInstanceTransformer.d.ts +0 -5
- package/lib/transformers/features/miscellaneous/CreateInstanceTransformer.js +0 -29
- package/lib/transformers/features/miscellaneous/CreateInstanceTransformer.js.map +0 -1
- package/src/transformers/features/miscellaneous/CreateInstanceTransformer.ts +0 -41
|
@@ -18,10 +18,13 @@ import { IExpressionEntry } from "./helpers/IExpressionEntry";
|
|
|
18
18
|
import { OptionPredicator } from "./helpers/OptionPredicator";
|
|
19
19
|
import { UnionExplorer } from "./helpers/UnionExplorer";
|
|
20
20
|
import { check_array } from "./internal/check_array";
|
|
21
|
+
import { check_array_length } from "./internal/check_array_length";
|
|
22
|
+
import { check_bigint } from "./internal/check_bigint";
|
|
21
23
|
import { check_native } from "./internal/check_native";
|
|
22
24
|
import { check_number } from "./internal/check_number";
|
|
23
25
|
import { check_string } from "./internal/check_string";
|
|
24
26
|
import { check_template } from "./internal/check_template";
|
|
27
|
+
import { check_union_tuple } from "./internal/check_union_tuple";
|
|
25
28
|
import { decode_union_object } from "./internal/decode_union_object";
|
|
26
29
|
|
|
27
30
|
export namespace CheckerProgrammer {
|
|
@@ -221,7 +224,6 @@ export namespace CheckerProgrammer {
|
|
|
221
224
|
project: IProject,
|
|
222
225
|
config: IConfig,
|
|
223
226
|
importer: FunctionImporter,
|
|
224
|
-
checkTupleLength: boolean = true,
|
|
225
227
|
) {
|
|
226
228
|
return function (
|
|
227
229
|
input: ts.Expression,
|
|
@@ -299,6 +301,11 @@ export namespace CheckerProgrammer {
|
|
|
299
301
|
),
|
|
300
302
|
combined: false,
|
|
301
303
|
});
|
|
304
|
+
else if (type === "bigint")
|
|
305
|
+
binaries.push({
|
|
306
|
+
expression: check_bigint(input, tags),
|
|
307
|
+
combined: false,
|
|
308
|
+
});
|
|
302
309
|
else if (type === "string")
|
|
303
310
|
binaries.push({
|
|
304
311
|
expression: check_string(importer)(input, tags),
|
|
@@ -322,212 +329,199 @@ export namespace CheckerProgrammer {
|
|
|
322
329
|
combined: false,
|
|
323
330
|
});
|
|
324
331
|
|
|
332
|
+
// NATIVE CLASSES
|
|
333
|
+
for (const native of meta.natives)
|
|
334
|
+
binaries.push({
|
|
335
|
+
expression: check_native(native)(input),
|
|
336
|
+
combined: false,
|
|
337
|
+
});
|
|
338
|
+
|
|
325
339
|
//----
|
|
326
340
|
// INSTANCES
|
|
327
341
|
//----
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
342
|
+
interface IInstance {
|
|
343
|
+
pre: ts.Expression;
|
|
344
|
+
body: ts.Expression | null;
|
|
345
|
+
expected: string;
|
|
346
|
+
}
|
|
347
|
+
const instances: IInstance[] = [];
|
|
348
|
+
const prepare =
|
|
349
|
+
(pre: ts.Expression, expected: string) =>
|
|
350
|
+
(body: ts.Expression | null) =>
|
|
351
|
+
instances.push({
|
|
352
|
+
pre,
|
|
353
|
+
expected,
|
|
354
|
+
body,
|
|
355
|
+
});
|
|
340
356
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
)
|
|
362
|
-
combined: true,
|
|
363
|
-
});
|
|
357
|
+
// SETS
|
|
358
|
+
if (meta.sets.length) {
|
|
359
|
+
const install = prepare(
|
|
360
|
+
check_native("Set")(input),
|
|
361
|
+
meta.sets
|
|
362
|
+
.map((elem) => `Set<${elem.getName()}>`)
|
|
363
|
+
.join(" | "),
|
|
364
|
+
);
|
|
365
|
+
if (meta.sets.some((elem) => elem.any)) install(null);
|
|
366
|
+
else
|
|
367
|
+
install(
|
|
368
|
+
explore_sets(project, config, importer)(
|
|
369
|
+
input,
|
|
370
|
+
meta.sets,
|
|
371
|
+
{
|
|
372
|
+
...explore,
|
|
373
|
+
from: "array",
|
|
374
|
+
},
|
|
375
|
+
[],
|
|
376
|
+
),
|
|
377
|
+
);
|
|
364
378
|
}
|
|
365
379
|
|
|
366
|
-
//
|
|
367
|
-
if (meta.
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
380
|
+
// MAPS
|
|
381
|
+
if (meta.maps.length) {
|
|
382
|
+
const install = prepare(
|
|
383
|
+
check_native("Map")(input),
|
|
384
|
+
meta.maps
|
|
385
|
+
.map(({ key, value }) => `Map<${key}, ${value}>`)
|
|
386
|
+
.join(" | "),
|
|
387
|
+
);
|
|
388
|
+
if (meta.maps.some((elem) => elem.key.any && elem.value.any))
|
|
389
|
+
install(null);
|
|
373
390
|
else
|
|
374
|
-
|
|
375
|
-
|
|
391
|
+
install(
|
|
392
|
+
explore_maps(project, config, importer)(
|
|
376
393
|
input,
|
|
377
|
-
[
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
tags,
|
|
384
|
-
),
|
|
385
|
-
combined: false,
|
|
386
|
-
},
|
|
387
|
-
]
|
|
388
|
-
: []),
|
|
389
|
-
{
|
|
390
|
-
expression: explore_array(
|
|
391
|
-
project,
|
|
392
|
-
config,
|
|
393
|
-
importer,
|
|
394
|
-
)(
|
|
395
|
-
input,
|
|
396
|
-
meta.arrays,
|
|
397
|
-
{
|
|
398
|
-
...explore,
|
|
399
|
-
from: "array",
|
|
400
|
-
},
|
|
401
|
-
tags,
|
|
402
|
-
),
|
|
403
|
-
combined: true,
|
|
404
|
-
},
|
|
405
|
-
],
|
|
406
|
-
meta.getName(),
|
|
394
|
+
meta.maps.map((m) => [m.key, m.value]),
|
|
395
|
+
{
|
|
396
|
+
...explore,
|
|
397
|
+
from: "array",
|
|
398
|
+
},
|
|
399
|
+
[],
|
|
407
400
|
),
|
|
408
|
-
|
|
409
|
-
|
|
401
|
+
);
|
|
402
|
+
}
|
|
410
403
|
|
|
411
|
-
//
|
|
412
|
-
if (meta.
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
404
|
+
// ARRAYS AND TUPLES
|
|
405
|
+
if (meta.tuples.length + meta.arrays.length > 0) {
|
|
406
|
+
const install = prepare(
|
|
407
|
+
check_array(input, meta.tuples.length === 0 ? tags : []),
|
|
408
|
+
[...meta.tuples, ...meta.arrays]
|
|
409
|
+
.map((elem) =>
|
|
410
|
+
Array.isArray(elem)
|
|
411
|
+
? `[${elem
|
|
412
|
+
.map((elem) => elem.getName())
|
|
413
|
+
.join(", ")}]`
|
|
414
|
+
: `Array<${elem.getName()}>`,
|
|
415
|
+
)
|
|
416
|
+
.join(" | "),
|
|
417
|
+
);
|
|
418
|
+
if (meta.arrays.length === 0)
|
|
419
|
+
install(
|
|
420
|
+
explore_tuples(project, config, importer)(
|
|
421
|
+
input,
|
|
422
|
+
meta.tuples,
|
|
417
423
|
{
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
checkArray: meta.objects.some((obj) =>
|
|
421
|
-
obj.properties.every(
|
|
422
|
-
(prop) =>
|
|
423
|
-
!prop.key.isSoleLiteral() ||
|
|
424
|
-
!prop.value.required,
|
|
425
|
-
),
|
|
426
|
-
),
|
|
427
|
-
}),
|
|
428
|
-
combined: false,
|
|
424
|
+
...explore,
|
|
425
|
+
from: "array",
|
|
429
426
|
},
|
|
427
|
+
tags,
|
|
428
|
+
),
|
|
429
|
+
);
|
|
430
|
+
else if (meta.arrays.some((elem) => elem.any)) install(null);
|
|
431
|
+
else if (meta.tuples.length === 0)
|
|
432
|
+
// ARRAY ONLY
|
|
433
|
+
install(
|
|
434
|
+
explore_arrays(project, config, importer)(
|
|
435
|
+
input,
|
|
436
|
+
meta.arrays,
|
|
430
437
|
{
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
meta,
|
|
434
|
-
{
|
|
435
|
-
...explore,
|
|
436
|
-
from: "object",
|
|
437
|
-
},
|
|
438
|
-
),
|
|
439
|
-
combined: true,
|
|
438
|
+
...explore,
|
|
439
|
+
from: "array",
|
|
440
440
|
},
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
)
|
|
444
|
-
combined: true,
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
// NATIVE CLASSES
|
|
448
|
-
for (const native of meta.natives)
|
|
449
|
-
binaries.push({
|
|
450
|
-
expression: check_native(native)(input),
|
|
451
|
-
combined: false,
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
// SETS
|
|
455
|
-
if (meta.sets.length)
|
|
456
|
-
if (meta.sets.every((elem) => elem.any))
|
|
457
|
-
binaries.push({
|
|
458
|
-
combined: false,
|
|
459
|
-
expression: check_native("Set")(input),
|
|
460
|
-
});
|
|
441
|
+
tags,
|
|
442
|
+
),
|
|
443
|
+
);
|
|
461
444
|
else
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
expression: config.combiner(explore)("and")(
|
|
445
|
+
install(
|
|
446
|
+
explore_arrays_and_tuples(project, config, importer)(
|
|
465
447
|
input,
|
|
466
|
-
[
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
expression: check_native("Set")(input),
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
combined: true,
|
|
473
|
-
expression: explore_set(
|
|
474
|
-
project,
|
|
475
|
-
config,
|
|
476
|
-
importer,
|
|
477
|
-
)(
|
|
478
|
-
input,
|
|
479
|
-
meta.sets,
|
|
480
|
-
{
|
|
481
|
-
...explore,
|
|
482
|
-
from: "array",
|
|
483
|
-
},
|
|
484
|
-
[],
|
|
485
|
-
),
|
|
486
|
-
},
|
|
487
|
-
],
|
|
488
|
-
meta.getName(),
|
|
448
|
+
[...meta.tuples, ...meta.arrays],
|
|
449
|
+
explore,
|
|
450
|
+
tags,
|
|
489
451
|
),
|
|
490
|
-
|
|
452
|
+
);
|
|
453
|
+
}
|
|
491
454
|
|
|
492
|
-
//
|
|
493
|
-
if (meta.
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
455
|
+
// OBJECT
|
|
456
|
+
if (meta.objects.length > 0)
|
|
457
|
+
prepare(
|
|
458
|
+
ExpressionFactory.isObject(input, {
|
|
459
|
+
checkNull: true,
|
|
460
|
+
checkArray: meta.objects.some((obj) =>
|
|
461
|
+
obj.properties.every(
|
|
462
|
+
(prop) =>
|
|
463
|
+
!prop.key.isSoleLiteral() ||
|
|
464
|
+
!prop.value.required,
|
|
465
|
+
),
|
|
466
|
+
),
|
|
467
|
+
}),
|
|
468
|
+
meta.objects
|
|
469
|
+
.map((obj) => `Resolve<${obj.name}>`)
|
|
470
|
+
.join(" | "),
|
|
471
|
+
)(
|
|
472
|
+
explore_objects(config)(input, meta, {
|
|
473
|
+
...explore,
|
|
474
|
+
from: "object",
|
|
475
|
+
}),
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
if (instances.length) {
|
|
479
|
+
const transformer =
|
|
480
|
+
(
|
|
481
|
+
merger: (
|
|
482
|
+
x: ts.Expression,
|
|
483
|
+
y: ts.Expression,
|
|
484
|
+
) => ts.Expression,
|
|
485
|
+
) =>
|
|
486
|
+
(ins: IInstance) =>
|
|
487
|
+
ins.body
|
|
488
|
+
? {
|
|
489
|
+
expression: merger(ins.pre, ins.body),
|
|
490
|
+
combined: true,
|
|
491
|
+
}
|
|
492
|
+
: {
|
|
493
|
+
expression: ins.pre,
|
|
494
|
+
combined: false,
|
|
495
|
+
};
|
|
496
|
+
if (instances.length === 1)
|
|
497
|
+
binaries.push(
|
|
498
|
+
transformer((pre, body) =>
|
|
499
|
+
config.combiner(explore)("and")(
|
|
500
|
+
input,
|
|
501
|
+
[pre, body].map((expression) => ({
|
|
502
|
+
expression,
|
|
503
|
+
combined: expression !== pre,
|
|
504
|
+
})),
|
|
505
|
+
meta.getName(),
|
|
506
|
+
),
|
|
507
|
+
)(instances[0]!),
|
|
508
|
+
);
|
|
499
509
|
else
|
|
500
510
|
binaries.push({
|
|
501
|
-
|
|
502
|
-
expression: config.combiner(explore)("and")(
|
|
511
|
+
expression: config.combiner(explore)("or")(
|
|
503
512
|
input,
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
expression: check_native("Map")(input),
|
|
508
|
-
},
|
|
509
|
-
{
|
|
510
|
-
combined: true,
|
|
511
|
-
expression: explore_map(
|
|
512
|
-
project,
|
|
513
|
-
config,
|
|
514
|
-
importer,
|
|
515
|
-
)(
|
|
516
|
-
input,
|
|
517
|
-
meta.maps.map((m) => [m.key, m.value]),
|
|
518
|
-
{
|
|
519
|
-
...explore,
|
|
520
|
-
from: "array",
|
|
521
|
-
},
|
|
522
|
-
[],
|
|
523
|
-
),
|
|
524
|
-
},
|
|
525
|
-
],
|
|
513
|
+
instances.map(
|
|
514
|
+
transformer(ts.factory.createLogicalAnd),
|
|
515
|
+
),
|
|
526
516
|
meta.getName(),
|
|
527
517
|
),
|
|
518
|
+
combined: true,
|
|
528
519
|
});
|
|
520
|
+
}
|
|
529
521
|
|
|
522
|
+
//----
|
|
530
523
|
// COMBINE CONDITIONS
|
|
524
|
+
//----
|
|
531
525
|
return top.length && binaries.length
|
|
532
526
|
? config.combiner(explore)("and")(
|
|
533
527
|
input,
|
|
@@ -554,7 +548,7 @@ export namespace CheckerProgrammer {
|
|
|
554
548
|
};
|
|
555
549
|
}
|
|
556
550
|
|
|
557
|
-
function decode_tuple(
|
|
551
|
+
export function decode_tuple(
|
|
558
552
|
project: IProject,
|
|
559
553
|
config: IConfig,
|
|
560
554
|
importer: FunctionImporter,
|
|
@@ -682,23 +676,7 @@ export namespace CheckerProgrammer {
|
|
|
682
676
|
};
|
|
683
677
|
}
|
|
684
678
|
|
|
685
|
-
const
|
|
686
|
-
project: IProject,
|
|
687
|
-
config: IConfig,
|
|
688
|
-
importer: FunctionImporter,
|
|
689
|
-
) =>
|
|
690
|
-
UnionExplorer.array({
|
|
691
|
-
checker: decode(project, config, importer),
|
|
692
|
-
decoder: decode_array(project, config, importer, true),
|
|
693
|
-
empty: config.success,
|
|
694
|
-
success: config.success,
|
|
695
|
-
failure: (input, expected, explore) =>
|
|
696
|
-
ts.factory.createReturnStatement(
|
|
697
|
-
config.joiner.failure(input, expected, explore),
|
|
698
|
-
),
|
|
699
|
-
});
|
|
700
|
-
|
|
701
|
-
const explore_set = (
|
|
679
|
+
const explore_sets = (
|
|
702
680
|
project: IProject,
|
|
703
681
|
config: IConfig,
|
|
704
682
|
importer: FunctionImporter,
|
|
@@ -714,7 +692,7 @@ export namespace CheckerProgrammer {
|
|
|
714
692
|
),
|
|
715
693
|
});
|
|
716
694
|
|
|
717
|
-
const
|
|
695
|
+
const explore_maps = (
|
|
718
696
|
project: IProject,
|
|
719
697
|
config: IConfig,
|
|
720
698
|
importer: FunctionImporter,
|
|
@@ -768,6 +746,86 @@ export namespace CheckerProgrammer {
|
|
|
768
746
|
),
|
|
769
747
|
});
|
|
770
748
|
|
|
749
|
+
const explore_tuples = (
|
|
750
|
+
project: IProject,
|
|
751
|
+
config: IConfig,
|
|
752
|
+
importer: FunctionImporter,
|
|
753
|
+
) =>
|
|
754
|
+
UnionExplorer.tuple({
|
|
755
|
+
checker: check_union_tuple(project, config, importer),
|
|
756
|
+
decoder: decode_tuple(project, config, importer, true),
|
|
757
|
+
empty: config.success,
|
|
758
|
+
success: config.success,
|
|
759
|
+
failure: (input, expected, explore) =>
|
|
760
|
+
ts.factory.createReturnStatement(
|
|
761
|
+
config.joiner.failure(input, expected, explore),
|
|
762
|
+
),
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
const explore_arrays = (
|
|
766
|
+
project: IProject,
|
|
767
|
+
config: IConfig,
|
|
768
|
+
importer: FunctionImporter,
|
|
769
|
+
) =>
|
|
770
|
+
UnionExplorer.array({
|
|
771
|
+
checker: decode(project, config, importer),
|
|
772
|
+
decoder: decode_array(project, config, importer, true),
|
|
773
|
+
empty: config.success,
|
|
774
|
+
success: config.success,
|
|
775
|
+
failure: (input, expected, explore) =>
|
|
776
|
+
ts.factory.createReturnStatement(
|
|
777
|
+
config.joiner.failure(input, expected, explore),
|
|
778
|
+
),
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
const explore_arrays_and_tuples = (
|
|
782
|
+
project: IProject,
|
|
783
|
+
config: IConfig,
|
|
784
|
+
importer: FunctionImporter,
|
|
785
|
+
) =>
|
|
786
|
+
UnionExplorer.array_or_tuple({
|
|
787
|
+
checker: (front, target, explore, tags, array) => {
|
|
788
|
+
if (Array.isArray(target))
|
|
789
|
+
return check_union_tuple(project, config, importer)(
|
|
790
|
+
front,
|
|
791
|
+
target,
|
|
792
|
+
explore,
|
|
793
|
+
tags,
|
|
794
|
+
array,
|
|
795
|
+
);
|
|
796
|
+
const condition = decode(project, config, importer)(
|
|
797
|
+
front,
|
|
798
|
+
target,
|
|
799
|
+
explore,
|
|
800
|
+
tags,
|
|
801
|
+
);
|
|
802
|
+
const length = check_array_length(array, tags);
|
|
803
|
+
return length !== null
|
|
804
|
+
? ts.factory.createBitwiseAnd(condition, length)
|
|
805
|
+
: condition;
|
|
806
|
+
},
|
|
807
|
+
decoder: (input, target, explore, tags) =>
|
|
808
|
+
Array.isArray(target)
|
|
809
|
+
? decode_tuple(project, config, importer, true)(
|
|
810
|
+
input,
|
|
811
|
+
target,
|
|
812
|
+
explore,
|
|
813
|
+
tags,
|
|
814
|
+
)
|
|
815
|
+
: decode_array(project, config, importer, true)(
|
|
816
|
+
input,
|
|
817
|
+
target,
|
|
818
|
+
explore,
|
|
819
|
+
tags,
|
|
820
|
+
),
|
|
821
|
+
empty: config.success,
|
|
822
|
+
success: config.success,
|
|
823
|
+
failure: (input, expected, explore) =>
|
|
824
|
+
ts.factory.createReturnStatement(
|
|
825
|
+
config.joiner.failure(input, expected, explore),
|
|
826
|
+
),
|
|
827
|
+
});
|
|
828
|
+
|
|
771
829
|
const explore_objects = (config: IConfig) => {
|
|
772
830
|
const objector = decode_object(config);
|
|
773
831
|
|
|
@@ -20,7 +20,17 @@ export namespace IsParseProgrammer {
|
|
|
20
20
|
ts.factory.createBlock([
|
|
21
21
|
StatementFactory.constant(
|
|
22
22
|
"is",
|
|
23
|
-
IsProgrammer.generate(
|
|
23
|
+
IsProgrammer.generate(
|
|
24
|
+
{
|
|
25
|
+
...project,
|
|
26
|
+
options: {
|
|
27
|
+
...project.options,
|
|
28
|
+
functional: false,
|
|
29
|
+
numeric: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
modulo,
|
|
33
|
+
)(type),
|
|
24
34
|
),
|
|
25
35
|
ts.factory.createExpressionStatement(
|
|
26
36
|
ts.factory.createBinaryExpression(
|
|
@@ -11,6 +11,7 @@ import { IProject } from "../transformers/IProject";
|
|
|
11
11
|
import { CheckerProgrammer } from "./CheckerProgrammer";
|
|
12
12
|
import { FunctionImporter } from "./helpers/FunctionImporeter";
|
|
13
13
|
import { IExpressionEntry } from "./helpers/IExpressionEntry";
|
|
14
|
+
import { OptionPredicator } from "./helpers/OptionPredicator";
|
|
14
15
|
import { check_object } from "./internal/check_object";
|
|
15
16
|
import { feature_object_entries } from "./internal/feature_object_entries";
|
|
16
17
|
|
|
@@ -23,7 +24,9 @@ export namespace IsProgrammer {
|
|
|
23
24
|
trace: false,
|
|
24
25
|
path: false,
|
|
25
26
|
equals: !!options?.object,
|
|
26
|
-
numeric:
|
|
27
|
+
numeric: OptionPredicator.numeric({
|
|
28
|
+
numeric: options?.numeric,
|
|
29
|
+
}),
|
|
27
30
|
combiner: () => (type: "and" | "or") => {
|
|
28
31
|
const initial: ts.TrueLiteral | ts.FalseLiteral =
|
|
29
32
|
type === "and"
|
|
@@ -90,7 +93,7 @@ export namespace IsProgrammer {
|
|
|
90
93
|
positive: ts.factory.createTrue(),
|
|
91
94
|
superfluous: () => ts.factory.createFalse(),
|
|
92
95
|
}),
|
|
93
|
-
numeric:
|
|
96
|
+
numeric: OptionPredicator.numeric(project.options),
|
|
94
97
|
});
|
|
95
98
|
config.trace = equals;
|
|
96
99
|
|
|
@@ -21,11 +21,31 @@ export namespace IsStringifyProgrammer {
|
|
|
21
21
|
ts.factory.createBlock([
|
|
22
22
|
StatementFactory.constant(
|
|
23
23
|
"is",
|
|
24
|
-
IsProgrammer.generate(
|
|
24
|
+
IsProgrammer.generate(
|
|
25
|
+
{
|
|
26
|
+
...project,
|
|
27
|
+
options: {
|
|
28
|
+
...project.options,
|
|
29
|
+
functional: false,
|
|
30
|
+
numeric: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
modulo,
|
|
34
|
+
)(type),
|
|
25
35
|
),
|
|
26
36
|
StatementFactory.constant(
|
|
27
37
|
"stringify",
|
|
28
|
-
StringifyProgrammer.generate(
|
|
38
|
+
StringifyProgrammer.generate(
|
|
39
|
+
{
|
|
40
|
+
...project,
|
|
41
|
+
options: {
|
|
42
|
+
...project.options,
|
|
43
|
+
functional: false,
|
|
44
|
+
numeric: false,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
modulo,
|
|
48
|
+
)(type),
|
|
29
49
|
),
|
|
30
50
|
ts.factory.createReturnStatement(
|
|
31
51
|
ts.factory.createConditionalExpression(
|
|
@@ -7,7 +7,9 @@ import { Metadata } from "../metadata/Metadata";
|
|
|
7
7
|
|
|
8
8
|
import { IProject } from "../transformers/IProject";
|
|
9
9
|
|
|
10
|
+
import { Escaper } from "../utils/Escaper";
|
|
10
11
|
import { MapUtil } from "../utils/MapUtil";
|
|
12
|
+
import { NameEncoder } from "../utils/NameEncoder";
|
|
11
13
|
|
|
12
14
|
import { IProtocolMessage } from "../messages/IProtocolMessage";
|
|
13
15
|
|
|
@@ -16,7 +18,7 @@ export namespace MessageProgrammer {
|
|
|
16
18
|
({ checker }: IProject) =>
|
|
17
19
|
(type: ts.Type) => {
|
|
18
20
|
// PARSE TARGET TYPE
|
|
19
|
-
const collection: MetadataCollection =
|
|
21
|
+
const collection: MetadataCollection = new MetadataCollection();
|
|
20
22
|
const metadata: Metadata =
|
|
21
23
|
ProtocolFactory.metadata(checker)(collection)(type);
|
|
22
24
|
|
|
@@ -42,7 +44,7 @@ export namespace MessageProgrammer {
|
|
|
42
44
|
const { key, message, children } = hierarchy;
|
|
43
45
|
let index: number = 1;
|
|
44
46
|
|
|
45
|
-
const elements: string[] = [`message ${key} {`];
|
|
47
|
+
const elements: string[] = [`message ${NameEncoder.encode(key)} {`];
|
|
46
48
|
if (message !== null)
|
|
47
49
|
elements.push(
|
|
48
50
|
...message.properties.map((property) => {
|
|
@@ -51,9 +53,11 @@ export namespace MessageProgrammer {
|
|
|
51
53
|
TAB,
|
|
52
54
|
property.required ? "" : "optional ",
|
|
53
55
|
property.repeated ? "repeated " : "",
|
|
54
|
-
property.oneOf[0]!.type + " ",
|
|
55
|
-
property.key
|
|
56
|
-
|
|
56
|
+
NameEncoder.encode(property.oneOf[0]!.type) + " ",
|
|
57
|
+
Escaper.variable(property.key)
|
|
58
|
+
? property.key
|
|
59
|
+
: `v${index + 1}`,
|
|
60
|
+
" = ",
|
|
57
61
|
`${index++};`,
|
|
58
62
|
].join("");
|
|
59
63
|
return (
|
|
@@ -61,7 +65,9 @@ export namespace MessageProgrammer {
|
|
|
61
65
|
property.oneOf
|
|
62
66
|
.map(
|
|
63
67
|
(o, i) =>
|
|
64
|
-
`${TAB}${TAB}${
|
|
68
|
+
`${TAB}${TAB}${NameEncoder.encode(
|
|
69
|
+
o.type,
|
|
70
|
+
)} o${i} = ${index++};`,
|
|
65
71
|
)
|
|
66
72
|
.join("\n") +
|
|
67
73
|
`\n${TAB}}`
|