typia 3.7.0-dev.20230310 → 3.7.0-dev.20230401
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 +16 -45
- package/lib/IRandomGenerator.d.ts +2 -1
- package/lib/executable/TypiaSetupWizard.js +12 -2
- package/lib/executable/TypiaSetupWizard.js.map +1 -1
- package/lib/factories/MetadataCollection.d.ts +9 -1
- package/lib/factories/MetadataCollection.js +75 -2
- package/lib/factories/MetadataCollection.js.map +1 -1
- package/lib/factories/MetadataTagFactory.js +151 -132
- package/lib/factories/MetadataTagFactory.js.map +1 -1
- package/lib/factories/TypeFactory.js +1 -1
- package/lib/factories/TypeFactory.js.map +1 -1
- package/lib/factories/TypiaFileFactory.js +61 -54
- package/lib/factories/TypiaFileFactory.js.map +1 -1
- package/lib/functional/$dictionary.d.ts +1 -0
- package/lib/functional/$dictionary.js +14 -0
- package/lib/functional/$dictionary.js.map +1 -0
- package/lib/functional/$is_custom.d.ts +2 -0
- package/lib/functional/$is_custom.js +12 -0
- package/lib/functional/$is_custom.js.map +1 -0
- package/lib/functional/$is_date.d.ts +1 -0
- package/lib/functional/$is_date.js +9 -0
- package/lib/functional/$is_date.js.map +1 -0
- package/lib/functional/$is_datetime.d.ts +1 -0
- package/lib/functional/$is_datetime.js +8 -0
- package/lib/functional/$is_datetime.js.map +1 -0
- package/lib/functional/Namespace.js +6 -0
- package/lib/functional/Namespace.js.map +1 -1
- package/lib/metadata/IMetadataTag.d.ts +30 -38
- package/lib/metadata/Metadata.js +2 -2
- package/lib/metadata/Metadata.js.map +1 -1
- package/lib/module.d.ts +25 -2
- package/lib/module.js +12 -5
- package/lib/module.js.map +1 -1
- package/lib/programmers/AssertProgrammer.js +11 -0
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +4 -2
- package/lib/programmers/CheckerProgrammer.js +26 -27
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/CloneProgrammer.js +2 -2
- package/lib/programmers/CloneProgrammer.js.map +1 -1
- package/lib/programmers/FeatureProgrammer.d.ts +3 -2
- package/lib/programmers/FeatureProgrammer.js +5 -5
- package/lib/programmers/FeatureProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.d.ts +1 -1
- package/lib/programmers/IsProgrammer.js +32 -2
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/PruneProgrammer.js +2 -2
- package/lib/programmers/PruneProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.js +1 -2
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/StringifyProgrammer.js +6 -6
- package/lib/programmers/StringifyProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +11 -0
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/ICheckEntry.d.ts +11 -0
- package/lib/{messages/IProtocolMap.js → programmers/helpers/ICheckEntry.js} +1 -1
- package/lib/programmers/helpers/ICheckEntry.js.map +1 -0
- package/lib/programmers/helpers/UnionExplorer.d.ts +7 -7
- package/lib/programmers/helpers/UnionExplorer.js +6 -6
- package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
- package/lib/programmers/internal/application_object.js +11 -11
- package/lib/programmers/internal/application_object.js.map +1 -1
- package/lib/programmers/internal/application_schema.js +3 -5
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/internal/application_string.js +8 -5
- package/lib/programmers/internal/application_string.js.map +1 -1
- package/lib/programmers/internal/check_array.js +35 -10
- package/lib/programmers/internal/check_array.js.map +1 -1
- package/lib/programmers/internal/check_array_length.js +23 -36
- package/lib/programmers/internal/check_array_length.js.map +1 -1
- package/lib/programmers/internal/check_bigint.d.ts +1 -3
- package/lib/programmers/internal/check_bigint.js +92 -57
- package/lib/programmers/internal/check_bigint.js.map +1 -1
- package/lib/programmers/internal/check_custom.d.ts +5 -0
- package/lib/programmers/internal/check_custom.js +40 -0
- package/lib/programmers/internal/check_custom.js.map +1 -0
- package/lib/programmers/internal/check_number.js +126 -73
- package/lib/programmers/internal/check_number.js.map +1 -1
- package/lib/programmers/internal/check_string.js +10 -9
- package/lib/programmers/internal/check_string.js.map +1 -1
- package/lib/programmers/internal/check_string_tags.js +63 -24
- package/lib/programmers/internal/check_string_tags.js.map +1 -1
- package/lib/programmers/internal/check_template.js +23 -11
- package/lib/programmers/internal/check_template.js.map +1 -1
- package/lib/programmers/internal/check_union_array_like.d.ts +2 -2
- package/lib/programmers/internal/check_union_array_like.js +4 -4
- package/lib/programmers/internal/check_union_array_like.js.map +1 -1
- package/lib/programmers/internal/check_union_tuple.js +2 -2
- package/lib/programmers/internal/check_union_tuple.js.map +1 -1
- package/lib/programmers/internal/feature_object_entries.js +1 -1
- package/lib/programmers/internal/feature_object_entries.js.map +1 -1
- package/lib/transformers/CallExpressionTransformer.js +1 -3
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js +3 -1
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js +1 -1
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js.map +1 -1
- package/lib/transformers/features/miscellaneous/RandomTransformer.js +1 -1
- package/lib/transformers/features/miscellaneous/RandomTransformer.js.map +1 -1
- package/lib/transformers/internal/GenericTransformer.js +2 -2
- package/lib/transformers/internal/GenericTransformer.js.map +1 -1
- package/lib/typings/Customizable.d.ts +6 -0
- package/lib/{messages/IProtocolMessage.js → typings/Customizable.js} +1 -1
- package/lib/typings/Customizable.js.map +1 -0
- package/lib/utils/RandomGenerator.js +8 -2
- package/lib/utils/RandomGenerator.js.map +1 -1
- package/package.json +10 -9
- package/src/IRandomGenerator.ts +2 -1
- package/src/executable/TypiaSetupWizard.ts +16 -6
- package/src/factories/MetadataCollection.ts +41 -2
- package/src/factories/MetadataTagFactory.ts +186 -149
- package/src/factories/TypeFactory.ts +1 -1
- package/src/factories/TypiaFileFactory.ts +10 -7
- package/src/functional/$dictionary.ts +17 -0
- package/src/functional/$is_custom.ts +14 -0
- package/src/functional/$is_date.ts +4 -0
- package/src/functional/$is_datetime.ts +3 -0
- package/src/functional/Namespace.ts +6 -0
- package/src/metadata/IMetadataTag.ts +46 -70
- package/src/metadata/Metadata.ts +3 -6
- package/src/module.ts +39 -10
- package/src/programmers/AssertProgrammer.ts +24 -0
- package/src/programmers/CheckerProgrammer.ts +66 -37
- package/src/programmers/CloneProgrammer.ts +2 -0
- package/src/programmers/FeatureProgrammer.ts +12 -5
- package/src/programmers/IsProgrammer.ts +7 -1
- package/src/programmers/PruneProgrammer.ts +2 -0
- package/src/programmers/RandomProgrammer.ts +1 -4
- package/src/programmers/StringifyProgrammer.ts +6 -0
- package/src/programmers/ValidateProgrammer.ts +24 -0
- package/src/programmers/helpers/ICheckEntry.ts +12 -0
- package/src/programmers/helpers/UnionExplorer.ts +7 -0
- package/src/programmers/internal/application_object.ts +5 -5
- package/src/programmers/internal/application_schema.ts +3 -7
- package/src/programmers/internal/application_string.ts +6 -2
- package/src/programmers/internal/check_array.ts +15 -11
- package/src/programmers/internal/check_array_length.ts +31 -35
- package/src/programmers/internal/check_bigint.ts +76 -58
- package/src/programmers/internal/check_custom.ts +41 -0
- package/src/programmers/internal/check_number.ts +106 -77
- package/src/programmers/internal/check_string.ts +15 -14
- package/src/programmers/internal/check_string_tags.ts +23 -13
- package/src/programmers/internal/check_template.ts +16 -7
- package/src/programmers/internal/check_union_array_like.ts +5 -0
- package/src/programmers/internal/check_union_tuple.ts +2 -0
- package/src/programmers/internal/feature_object_entries.ts +1 -0
- package/src/transformers/CallExpressionTransformer.ts +9 -16
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +3 -1
- package/src/transformers/features/miscellaneous/CreateRandomGenerator.ts +1 -1
- package/src/transformers/features/miscellaneous/RandomTransformer.ts +1 -1
- package/src/transformers/internal/GenericTransformer.ts +2 -2
- package/src/typings/Customizable.ts +6 -0
- package/src/utils/RandomGenerator.ts +8 -2
- package/lib/factories/ProtocolFactory.d.ts +0 -8
- package/lib/factories/ProtocolFactory.js +0 -112
- package/lib/factories/ProtocolFactory.js.map +0 -1
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.d.ts +0 -16
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js +0 -156
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js.map +0 -1
- package/lib/factories/internal/protocols/emplace_protocol_object.d.ts +0 -3
- package/lib/factories/internal/protocols/emplace_protocol_object.js +0 -47
- package/lib/factories/internal/protocols/emplace_protocol_object.js.map +0 -1
- package/lib/factories/internal/protocols/emplace_protocol_property.d.ts +0 -4
- package/lib/factories/internal/protocols/emplace_protocol_property.js +0 -20
- package/lib/factories/internal/protocols/emplace_protocol_property.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_atomic.d.ts +0 -3
- package/lib/factories/internal/protocols/iterate_protocol_atomic.js +0 -69
- package/lib/factories/internal/protocols/iterate_protocol_atomic.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_constant.d.ts +0 -2
- package/lib/factories/internal/protocols/iterate_protocol_constant.js +0 -30
- package/lib/factories/internal/protocols/iterate_protocol_constant.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_main.d.ts +0 -3
- package/lib/factories/internal/protocols/iterate_protocol_main.js +0 -17
- package/lib/factories/internal/protocols/iterate_protocol_main.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_map.d.ts +0 -4
- package/lib/factories/internal/protocols/iterate_protocol_map.js +0 -75
- package/lib/factories/internal/protocols/iterate_protocol_map.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_metadata.d.ts +0 -5
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js +0 -190
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_native.d.ts +0 -2
- package/lib/factories/internal/protocols/iterate_protocol_native.js +0 -33
- package/lib/factories/internal/protocols/iterate_protocol_native.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_never.d.ts +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_never.js +0 -6
- package/lib/factories/internal/protocols/iterate_protocol_never.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_object.d.ts +0 -4
- package/lib/factories/internal/protocols/iterate_protocol_object.js +0 -157
- package/lib/factories/internal/protocols/iterate_protocol_object.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_repeated.d.ts +0 -5
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js +0 -25
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_tuple.d.ts +0 -3
- package/lib/factories/internal/protocols/iterate_protocol_tuple.js +0 -46
- package/lib/factories/internal/protocols/iterate_protocol_tuple.js.map +0 -1
- package/lib/functional/$proto_bytes.d.ts +0 -2
- package/lib/functional/$proto_bytes.js +0 -37
- package/lib/functional/$proto_bytes.js.map +0 -1
- package/lib/functional/$proto_field.d.ts +0 -10
- package/lib/functional/$proto_field.js +0 -42
- package/lib/functional/$proto_field.js.map +0 -1
- package/lib/functional/$proto_float.d.ts +0 -4
- package/lib/functional/$proto_float.js +0 -28
- package/lib/functional/$proto_float.js.map +0 -1
- package/lib/functional/$proto_i32.d.ts +0 -2
- package/lib/functional/$proto_i32.js +0 -23
- package/lib/functional/$proto_i32.js.map +0 -1
- package/lib/functional/$proto_i64.d.ts +0 -2
- package/lib/functional/$proto_i64.js +0 -31
- package/lib/functional/$proto_i64.js.map +0 -1
- package/lib/functional/$proto_size.d.ts +0 -6
- package/lib/functional/$proto_size.js +0 -76
- package/lib/functional/$proto_size.js.map +0 -1
- package/lib/functional/$proto_string.d.ts +0 -2
- package/lib/functional/$proto_string.js +0 -34
- package/lib/functional/$proto_string.js.map +0 -1
- package/lib/functional/$varint.d.ts +0 -6
- package/lib/functional/$varint.js +0 -99
- package/lib/functional/$varint.js.map +0 -1
- package/lib/functional/$zigzag.d.ts +0 -4
- package/lib/functional/$zigzag.js +0 -34
- package/lib/functional/$zigzag.js.map +0 -1
- package/lib/messages/IProtocolMap.d.ts +0 -5
- package/lib/messages/IProtocolMap.js.map +0 -1
- package/lib/messages/IProtocolMessage.d.ts +0 -5
- package/lib/messages/IProtocolMessage.js.map +0 -1
- package/lib/messages/IProtocolProperty.d.ts +0 -12
- package/lib/messages/IProtocolProperty.js +0 -3
- package/lib/messages/IProtocolProperty.js.map +0 -1
- package/lib/programmers/MessageProgrammer.d.ts +0 -5
- package/lib/programmers/MessageProgrammer.js +0 -141
- package/lib/programmers/MessageProgrammer.js.map +0 -1
- package/lib/transformers/features/protocols/MessageTransformer.d.ts +0 -5
- package/lib/transformers/features/protocols/MessageTransformer.js +0 -17
- package/lib/transformers/features/protocols/MessageTransformer.js.map +0 -1
- package/lib/utils/NameEncoder.d.ts +0 -4
- package/lib/utils/NameEncoder.js +0 -89
- package/lib/utils/NameEncoder.js.map +0 -1
- package/src/factories/ProtocolFactory.ts +0 -79
- package/src/factories/internal/protocols/ProtocolMetadataUtil.ts +0 -163
- package/src/factories/internal/protocols/emplace_protocol_object.ts +0 -25
- package/src/factories/internal/protocols/emplace_protocol_property.ts +0 -12
- package/src/factories/internal/protocols/iterate_protocol_atomic.ts +0 -34
- package/src/factories/internal/protocols/iterate_protocol_constant.ts +0 -27
- package/src/factories/internal/protocols/iterate_protocol_main.ts +0 -19
- package/src/factories/internal/protocols/iterate_protocol_map.ts +0 -58
- package/src/factories/internal/protocols/iterate_protocol_metadata.ts +0 -96
- package/src/factories/internal/protocols/iterate_protocol_native.ts +0 -34
- package/src/factories/internal/protocols/iterate_protocol_never.ts +0 -1
- package/src/factories/internal/protocols/iterate_protocol_object.ts +0 -110
- package/src/factories/internal/protocols/iterate_protocol_repeated.ts +0 -34
- package/src/factories/internal/protocols/iterate_protocol_tuple.ts +0 -29
- package/src/functional/$proto_bytes.ts +0 -25
- package/src/functional/$proto_field.ts +0 -30
- package/src/functional/$proto_float.ts +0 -37
- package/src/functional/$proto_i32.ts +0 -29
- package/src/functional/$proto_i64.ts +0 -37
- package/src/functional/$proto_size.ts +0 -82
- package/src/functional/$proto_string.ts +0 -24
- package/src/functional/$varint.ts +0 -130
- package/src/functional/$zigzag.ts +0 -39
- package/src/messages/IProtocolMap.ts +0 -5
- package/src/messages/IProtocolMessage.ts +0 -6
- package/src/messages/IProtocolProperty.ts +0 -13
- package/src/programmers/MessageProgrammer.ts +0 -126
- package/src/transformers/features/protocols/MessageTransformer.ts +0 -32
- package/src/utils/NameEncoder.ts +0 -32
package/src/metadata/Metadata.ts
CHANGED
|
@@ -205,7 +205,6 @@ export class Metadata {
|
|
|
205
205
|
public empty(): boolean {
|
|
206
206
|
return this.bucket() === 0 || this.size() === 0;
|
|
207
207
|
}
|
|
208
|
-
|
|
209
208
|
public size(): number {
|
|
210
209
|
return (
|
|
211
210
|
(this.resolved ? 1 : 0) +
|
|
@@ -224,7 +223,6 @@ export class Metadata {
|
|
|
224
223
|
this.maps.length
|
|
225
224
|
);
|
|
226
225
|
}
|
|
227
|
-
|
|
228
226
|
public bucket(): number {
|
|
229
227
|
return (
|
|
230
228
|
(this.resolved ? 1 : 0) +
|
|
@@ -241,7 +239,6 @@ export class Metadata {
|
|
|
241
239
|
(this.maps.length ? 1 : 0)
|
|
242
240
|
);
|
|
243
241
|
}
|
|
244
|
-
|
|
245
242
|
public isConstant(): boolean {
|
|
246
243
|
return this.bucket() === (this.constants.length ? 1 : 0);
|
|
247
244
|
}
|
|
@@ -511,15 +508,15 @@ function getName(metadata: Metadata): string {
|
|
|
511
508
|
elements.push(`Map<${map.key.getName()}, ${map.value.getName()}>`);
|
|
512
509
|
|
|
513
510
|
// ARRAY
|
|
514
|
-
if (metadata.rest !== null)
|
|
515
|
-
elements.push(`Rest<${metadata.rest.getName()}>`);
|
|
511
|
+
if (metadata.rest !== null) elements.push(`...${metadata.rest.getName()}`);
|
|
516
512
|
for (const tuple of metadata.tuples)
|
|
517
513
|
elements.push(`[${tuple.map((elem) => elem.getName()).join(", ")}]`);
|
|
518
514
|
for (const array of metadata.arrays)
|
|
519
515
|
elements.push(`Array<${array.getName()}>`);
|
|
520
516
|
|
|
521
517
|
// OBJECT
|
|
522
|
-
for (const object of metadata.objects)
|
|
518
|
+
for (const object of metadata.objects)
|
|
519
|
+
elements.push(`Resolve<${object.name}>`);
|
|
523
520
|
if (metadata.resolved !== null) elements.push(metadata.resolved.getName());
|
|
524
521
|
|
|
525
522
|
// RETURNS
|
package/src/module.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { $dictionary } from "./functional/$dictionary";
|
|
1
2
|
import { Namespace } from "./functional/Namespace";
|
|
2
3
|
|
|
3
4
|
import { IMetadataApplication } from "./metadata/IMetadataApplication";
|
|
4
5
|
import { IJsonApplication } from "./schemas/IJsonApplication";
|
|
5
6
|
|
|
7
|
+
import { Customizable } from "./typings/Customizable";
|
|
8
|
+
|
|
6
9
|
import { IRandomGenerator } from "./IRandomGenerator";
|
|
7
10
|
import { IValidation } from "./IValidation";
|
|
8
11
|
import { Primitive } from "./Primitive";
|
|
@@ -20,7 +23,6 @@ export * from "./TypeGuardError";
|
|
|
20
23
|
SINGLE FUNCTIONS
|
|
21
24
|
- BASIC VALIDATORS
|
|
22
25
|
- STRICT VALIDATORS
|
|
23
|
-
- PROTOCOL BUFFER FUNCTIONS
|
|
24
26
|
- JSON FUNCTIONS
|
|
25
27
|
- MISCELLANEOUS
|
|
26
28
|
==============================================================
|
|
@@ -411,15 +413,42 @@ export function validateEquals(): never {
|
|
|
411
413
|
}
|
|
412
414
|
Object.assign(validateEquals, Namespace.validate());
|
|
413
415
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
416
|
+
/**
|
|
417
|
+
* Add validation tag.
|
|
418
|
+
*
|
|
419
|
+
* If you want to add a custom validation logic, you can use this function.
|
|
420
|
+
*
|
|
421
|
+
* ```ts
|
|
422
|
+
* typia.addValidationTag("powerOf")("number")(
|
|
423
|
+
* (text: string) => {
|
|
424
|
+
* const denominator: number = Math.log(Number(text));
|
|
425
|
+
* return (value: number) => {
|
|
426
|
+
* value = Math.log(value) / denominator;
|
|
427
|
+
* return value === Math.floor(value);
|
|
428
|
+
* };
|
|
429
|
+
* }
|
|
430
|
+
* );
|
|
431
|
+
* typia.addValidationTag("dollar")("string")(
|
|
432
|
+
* () => (value: string) => value.startsWith("$"),
|
|
433
|
+
* );
|
|
434
|
+
* ```
|
|
435
|
+
*
|
|
436
|
+
* @param name Name of tag (`@name`)
|
|
437
|
+
* @returns Currying function
|
|
438
|
+
*/
|
|
439
|
+
export const addValidationTag =
|
|
440
|
+
(name: string) =>
|
|
441
|
+
/**
|
|
442
|
+
* @param type Type of target value
|
|
443
|
+
*/
|
|
444
|
+
<Type extends keyof Customizable>(type: Type) =>
|
|
445
|
+
/**
|
|
446
|
+
* @param closure Closure function for custom validation
|
|
447
|
+
*/
|
|
448
|
+
(closure: (text: string) => (value: Customizable[Type]) => boolean) => {
|
|
449
|
+
const key = `${name}:${type}` as const;
|
|
450
|
+
if (!$dictionary.has(key)) $dictionary.set(key, closure);
|
|
451
|
+
};
|
|
423
452
|
|
|
424
453
|
/* -----------------------------------------------------------
|
|
425
454
|
JSON FUNCTIONS
|
|
@@ -30,6 +30,30 @@ export namespace AssertProgrammer {
|
|
|
30
30
|
trace: true,
|
|
31
31
|
numeric: OptionPredicator.numeric(project.options),
|
|
32
32
|
equals,
|
|
33
|
+
atomist: (explore) => (tuple) => (input) =>
|
|
34
|
+
[
|
|
35
|
+
tuple.expression,
|
|
36
|
+
...tuple.tags.map((tag) =>
|
|
37
|
+
ts.factory.createLogicalOr(
|
|
38
|
+
tag.expression,
|
|
39
|
+
create_guard_call(importer)(
|
|
40
|
+
explore.from === "top"
|
|
41
|
+
? ts.factory.createTrue()
|
|
42
|
+
: ts.factory.createIdentifier(
|
|
43
|
+
"_exceptionable",
|
|
44
|
+
),
|
|
45
|
+
)(
|
|
46
|
+
ts.factory.createIdentifier(
|
|
47
|
+
explore.postfix
|
|
48
|
+
? `_path + ${explore.postfix}`
|
|
49
|
+
: "_path",
|
|
50
|
+
),
|
|
51
|
+
tag.expected,
|
|
52
|
+
input,
|
|
53
|
+
),
|
|
54
|
+
),
|
|
55
|
+
),
|
|
56
|
+
].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
|
|
33
57
|
combiner: combiner(equals)(importer),
|
|
34
58
|
joiner: joiner(equals)(importer),
|
|
35
59
|
success: ts.factory.createTrue(),
|
|
@@ -16,6 +16,7 @@ import { IProject } from "../transformers/IProject";
|
|
|
16
16
|
import { FeatureProgrammer } from "./FeatureProgrammer";
|
|
17
17
|
import { AtomicPredicator } from "./helpers/AtomicPredicator";
|
|
18
18
|
import { FunctionImporter } from "./helpers/FunctionImporeter";
|
|
19
|
+
import { ICheckEntry } from "./helpers/ICheckEntry";
|
|
19
20
|
import { IExpressionEntry } from "./helpers/IExpressionEntry";
|
|
20
21
|
import { OptionPredicator } from "./helpers/OptionPredicator";
|
|
21
22
|
import { UnionExplorer } from "./helpers/UnionExplorer";
|
|
@@ -39,6 +40,9 @@ export namespace CheckerProgrammer {
|
|
|
39
40
|
numeric: boolean;
|
|
40
41
|
combiner: IConfig.Combiner;
|
|
41
42
|
decoder?: FeatureProgrammer.Decoder<Metadata, ts.Expression>;
|
|
43
|
+
atomist: (
|
|
44
|
+
explore: IExplore,
|
|
45
|
+
) => (check: ICheckEntry) => (input: ts.Expression) => ts.Expression;
|
|
42
46
|
joiner: IConfig.IJoiner;
|
|
43
47
|
success: ts.Expression;
|
|
44
48
|
}
|
|
@@ -217,6 +221,7 @@ export namespace CheckerProgrammer {
|
|
|
217
221
|
meta: Metadata,
|
|
218
222
|
explore: IExplore,
|
|
219
223
|
tags: IMetadataTag[],
|
|
224
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
220
225
|
) => ts.Expression;
|
|
221
226
|
|
|
222
227
|
/**
|
|
@@ -232,6 +237,7 @@ export namespace CheckerProgrammer {
|
|
|
232
237
|
meta: Metadata,
|
|
233
238
|
explore: IExplore,
|
|
234
239
|
tags: IMetadataTag[],
|
|
240
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
235
241
|
) => ts.Expression;
|
|
236
242
|
|
|
237
243
|
/**
|
|
@@ -246,7 +252,8 @@ export namespace CheckerProgrammer {
|
|
|
246
252
|
input: ts.Expression,
|
|
247
253
|
meta: Metadata,
|
|
248
254
|
explore: IExplore,
|
|
249
|
-
|
|
255
|
+
metaTags: IMetadataTag[],
|
|
256
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
250
257
|
): ts.Expression {
|
|
251
258
|
if (meta.any) return config.success;
|
|
252
259
|
|
|
@@ -315,20 +322,25 @@ export namespace CheckerProgrammer {
|
|
|
315
322
|
if (AtomicPredicator.atomic(meta)(type) === false) continue;
|
|
316
323
|
else if (type === "number")
|
|
317
324
|
binaries.push({
|
|
318
|
-
expression:
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
325
|
+
expression: config.atomist(explore)(
|
|
326
|
+
check_number(project, config.numeric)(importer)(
|
|
327
|
+
metaTags,
|
|
328
|
+
)(jsDocTags)(input),
|
|
329
|
+
)(input),
|
|
322
330
|
combined: false,
|
|
323
331
|
});
|
|
324
332
|
else if (type === "bigint")
|
|
325
333
|
binaries.push({
|
|
326
|
-
expression:
|
|
334
|
+
expression: config.atomist(explore)(
|
|
335
|
+
check_bigint(importer)(metaTags)(jsDocTags)(input),
|
|
336
|
+
)(input),
|
|
327
337
|
combined: false,
|
|
328
338
|
});
|
|
329
339
|
else if (type === "string")
|
|
330
340
|
binaries.push({
|
|
331
|
-
expression:
|
|
341
|
+
expression: config.atomist(explore)(
|
|
342
|
+
check_string(importer)(metaTags)(jsDocTags)(input),
|
|
343
|
+
)(input),
|
|
332
344
|
combined: false,
|
|
333
345
|
});
|
|
334
346
|
else
|
|
@@ -342,11 +354,11 @@ export namespace CheckerProgrammer {
|
|
|
342
354
|
if (meta.templates.length)
|
|
343
355
|
if (AtomicPredicator.template(meta))
|
|
344
356
|
binaries.push({
|
|
345
|
-
expression:
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
),
|
|
357
|
+
expression: config.atomist(explore)(
|
|
358
|
+
check_template(importer)(metaTags)(jsDocTags)(
|
|
359
|
+
meta.templates,
|
|
360
|
+
)(input),
|
|
361
|
+
)(input),
|
|
350
362
|
combined: false,
|
|
351
363
|
});
|
|
352
364
|
|
|
@@ -394,6 +406,7 @@ export namespace CheckerProgrammer {
|
|
|
394
406
|
from: "array",
|
|
395
407
|
},
|
|
396
408
|
[],
|
|
409
|
+
[],
|
|
397
410
|
),
|
|
398
411
|
);
|
|
399
412
|
}
|
|
@@ -418,6 +431,7 @@ export namespace CheckerProgrammer {
|
|
|
418
431
|
from: "array",
|
|
419
432
|
},
|
|
420
433
|
[],
|
|
434
|
+
[],
|
|
421
435
|
),
|
|
422
436
|
);
|
|
423
437
|
}
|
|
@@ -425,7 +439,11 @@ export namespace CheckerProgrammer {
|
|
|
425
439
|
// ARRAYS AND TUPLES
|
|
426
440
|
if (meta.tuples.length + meta.arrays.length > 0) {
|
|
427
441
|
const install = prepare(
|
|
428
|
-
|
|
442
|
+
config.atomist(explore)(
|
|
443
|
+
check_array(importer)(
|
|
444
|
+
meta.tuples.length === 0 ? metaTags : [],
|
|
445
|
+
)(jsDocTags)(input),
|
|
446
|
+
)(input),
|
|
429
447
|
[...meta.tuples, ...meta.arrays]
|
|
430
448
|
.map((elem) =>
|
|
431
449
|
Array.isArray(elem)
|
|
@@ -445,7 +463,8 @@ export namespace CheckerProgrammer {
|
|
|
445
463
|
...explore,
|
|
446
464
|
from: "array",
|
|
447
465
|
},
|
|
448
|
-
|
|
466
|
+
metaTags,
|
|
467
|
+
jsDocTags,
|
|
449
468
|
),
|
|
450
469
|
);
|
|
451
470
|
else if (meta.arrays.some((elem) => elem.any)) install(null);
|
|
@@ -459,7 +478,8 @@ export namespace CheckerProgrammer {
|
|
|
459
478
|
...explore,
|
|
460
479
|
from: "array",
|
|
461
480
|
},
|
|
462
|
-
|
|
481
|
+
metaTags,
|
|
482
|
+
jsDocTags,
|
|
463
483
|
),
|
|
464
484
|
);
|
|
465
485
|
else
|
|
@@ -468,7 +488,8 @@ export namespace CheckerProgrammer {
|
|
|
468
488
|
input,
|
|
469
489
|
[...meta.tuples, ...meta.arrays],
|
|
470
490
|
explore,
|
|
471
|
-
|
|
491
|
+
metaTags,
|
|
492
|
+
jsDocTags,
|
|
472
493
|
),
|
|
473
494
|
);
|
|
474
495
|
}
|
|
@@ -580,6 +601,7 @@ export namespace CheckerProgrammer {
|
|
|
580
601
|
tuple: Array<Metadata>,
|
|
581
602
|
explore: IExplore,
|
|
582
603
|
tagList: IMetadataTag[],
|
|
604
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
583
605
|
): ts.Expression {
|
|
584
606
|
const binaries: ts.Expression[] = tuple
|
|
585
607
|
.filter((meta) => meta.rest === null)
|
|
@@ -595,6 +617,7 @@ export namespace CheckerProgrammer {
|
|
|
595
617
|
: `[${index}]`,
|
|
596
618
|
},
|
|
597
619
|
tagList,
|
|
620
|
+
jsDocTags,
|
|
598
621
|
),
|
|
599
622
|
);
|
|
600
623
|
const rest: ts.Expression | null =
|
|
@@ -621,6 +644,7 @@ export namespace CheckerProgrammer {
|
|
|
621
644
|
start: tuple.length - 1,
|
|
622
645
|
},
|
|
623
646
|
tagList,
|
|
647
|
+
jsDocTags,
|
|
624
648
|
)
|
|
625
649
|
: null;
|
|
626
650
|
|
|
@@ -728,12 +752,14 @@ export namespace CheckerProgrammer {
|
|
|
728
752
|
entry[0],
|
|
729
753
|
{ ...explore, postfix: `${explore.postfix}[0]` },
|
|
730
754
|
[],
|
|
755
|
+
[],
|
|
731
756
|
),
|
|
732
757
|
func(
|
|
733
758
|
ts.factory.createElementAccessExpression(input, 1),
|
|
734
759
|
entry[1],
|
|
735
760
|
{ ...explore, postfix: `${explore.postfix}[1]` },
|
|
736
761
|
[],
|
|
762
|
+
[],
|
|
737
763
|
),
|
|
738
764
|
);
|
|
739
765
|
},
|
|
@@ -759,6 +785,7 @@ export namespace CheckerProgrammer {
|
|
|
759
785
|
}),
|
|
760
786
|
explore,
|
|
761
787
|
[],
|
|
788
|
+
[],
|
|
762
789
|
),
|
|
763
790
|
empty: config.success,
|
|
764
791
|
success: config.success,
|
|
@@ -806,39 +833,41 @@ export namespace CheckerProgrammer {
|
|
|
806
833
|
importer: FunctionImporter,
|
|
807
834
|
) =>
|
|
808
835
|
UnionExplorer.array_or_tuple({
|
|
809
|
-
checker: (front, target, explore, tags, array) =>
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
decoder: (input, target, explore, tags) =>
|
|
836
|
+
checker: (front, target, explore, tags, jsDocTags, array) =>
|
|
837
|
+
Array.isArray(target)
|
|
838
|
+
? check_union_tuple(project, config, importer)(
|
|
839
|
+
front,
|
|
840
|
+
target,
|
|
841
|
+
explore,
|
|
842
|
+
tags,
|
|
843
|
+
jsDocTags,
|
|
844
|
+
array,
|
|
845
|
+
)
|
|
846
|
+
: config.atomist(explore)({
|
|
847
|
+
expression: decode(project, config, importer)(
|
|
848
|
+
front,
|
|
849
|
+
target,
|
|
850
|
+
explore,
|
|
851
|
+
tags,
|
|
852
|
+
jsDocTags,
|
|
853
|
+
),
|
|
854
|
+
tags: check_array_length(tags)(array),
|
|
855
|
+
})(array),
|
|
856
|
+
decoder: (input, target, explore, tags, jsDocTags) =>
|
|
830
857
|
Array.isArray(target)
|
|
831
858
|
? decode_tuple(project, config, importer, true)(
|
|
832
859
|
input,
|
|
833
860
|
target,
|
|
834
861
|
explore,
|
|
835
862
|
tags,
|
|
863
|
+
jsDocTags,
|
|
836
864
|
)
|
|
837
865
|
: decode_array(project, config, importer, true)(
|
|
838
866
|
input,
|
|
839
867
|
target,
|
|
840
868
|
explore,
|
|
841
869
|
tags,
|
|
870
|
+
jsDocTags,
|
|
842
871
|
),
|
|
843
872
|
empty: config.success,
|
|
844
873
|
success: config.success,
|
|
@@ -109,6 +109,7 @@ export namespace CloneProgrammer {
|
|
|
109
109
|
})(),
|
|
110
110
|
explore,
|
|
111
111
|
[],
|
|
112
|
+
[],
|
|
112
113
|
),
|
|
113
114
|
value: () =>
|
|
114
115
|
decode_tuple(project, importer)(input, tuple, explore),
|
|
@@ -128,6 +129,7 @@ export namespace CloneProgrammer {
|
|
|
128
129
|
from: "array",
|
|
129
130
|
},
|
|
130
131
|
[],
|
|
132
|
+
[],
|
|
131
133
|
),
|
|
132
134
|
});
|
|
133
135
|
|
|
@@ -6,6 +6,7 @@ import { StatementFactory } from "../factories/StatementFactory";
|
|
|
6
6
|
import { TypeFactory } from "../factories/TypeFactory";
|
|
7
7
|
import { ValueFactory } from "../factories/ValueFactory";
|
|
8
8
|
|
|
9
|
+
import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
|
|
9
10
|
import { IMetadataTag } from "../metadata/IMetadataTag";
|
|
10
11
|
import { Metadata } from "../metadata/Metadata";
|
|
11
12
|
import { MetadataObject } from "../metadata/MetadataObject";
|
|
@@ -202,7 +203,8 @@ export namespace FeatureProgrammer {
|
|
|
202
203
|
input: ts.Expression,
|
|
203
204
|
target: T,
|
|
204
205
|
explore: IExplore,
|
|
205
|
-
|
|
206
|
+
metaTags: IMetadataTag[],
|
|
207
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
206
208
|
): Output;
|
|
207
209
|
}
|
|
208
210
|
|
|
@@ -241,6 +243,7 @@ export namespace FeatureProgrammer {
|
|
|
241
243
|
postfix: '""',
|
|
242
244
|
},
|
|
243
245
|
[],
|
|
246
|
+
[],
|
|
244
247
|
);
|
|
245
248
|
|
|
246
249
|
// RETURNS THE OPTIMAL ARROW FUNCTION
|
|
@@ -350,6 +353,7 @@ export namespace FeatureProgrammer {
|
|
|
350
353
|
postfix: "",
|
|
351
354
|
},
|
|
352
355
|
[],
|
|
356
|
+
[],
|
|
353
357
|
),
|
|
354
358
|
);
|
|
355
359
|
}
|
|
@@ -363,7 +367,8 @@ export namespace FeatureProgrammer {
|
|
|
363
367
|
combiner: (
|
|
364
368
|
input: ts.Expression,
|
|
365
369
|
arrow: ts.ArrowFunction,
|
|
366
|
-
|
|
370
|
+
metaTags: IMetadataTag[],
|
|
371
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
367
372
|
) => ts.Expression,
|
|
368
373
|
) {
|
|
369
374
|
const rand: string = importer.increment().toString();
|
|
@@ -381,7 +386,8 @@ export namespace FeatureProgrammer {
|
|
|
381
386
|
input: ts.Expression,
|
|
382
387
|
meta: Metadata,
|
|
383
388
|
explore: IExplore,
|
|
384
|
-
|
|
389
|
+
metaTags: IMetadataTag[],
|
|
390
|
+
jsDocTags: IJsDocTagInfo[],
|
|
385
391
|
) => {
|
|
386
392
|
const arrow: ts.ArrowFunction = ts.factory.createArrowFunction(
|
|
387
393
|
undefined,
|
|
@@ -406,10 +412,11 @@ export namespace FeatureProgrammer {
|
|
|
406
412
|
explore.postfix,
|
|
407
413
|
)(rand),
|
|
408
414
|
},
|
|
409
|
-
|
|
415
|
+
metaTags,
|
|
416
|
+
jsDocTags,
|
|
410
417
|
),
|
|
411
418
|
);
|
|
412
|
-
return combiner(input, arrow,
|
|
419
|
+
return combiner(input, arrow, metaTags, jsDocTags);
|
|
413
420
|
};
|
|
414
421
|
}
|
|
415
422
|
|
|
@@ -27,6 +27,11 @@ export namespace IsProgrammer {
|
|
|
27
27
|
numeric: OptionPredicator.numeric({
|
|
28
28
|
numeric: options?.numeric,
|
|
29
29
|
}),
|
|
30
|
+
atomist: () => (entry) => () =>
|
|
31
|
+
[
|
|
32
|
+
entry.expression,
|
|
33
|
+
...entry.tags.map((tag) => tag.expression),
|
|
34
|
+
].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
|
|
30
35
|
combiner: () => (type: "and" | "or") => {
|
|
31
36
|
const initial: ts.TrueLiteral | ts.FalseLiteral =
|
|
32
37
|
type === "and"
|
|
@@ -105,7 +110,7 @@ export namespace IsProgrammer {
|
|
|
105
110
|
})(importer);
|
|
106
111
|
config.trace = equals;
|
|
107
112
|
|
|
108
|
-
config.decoder = (input, target, explore, tags) => {
|
|
113
|
+
config.decoder = (input, target, explore, tags, jsDocTags) => {
|
|
109
114
|
if (
|
|
110
115
|
target.size() === 1 &&
|
|
111
116
|
target.objects.length === 1 &&
|
|
@@ -137,6 +142,7 @@ export namespace IsProgrammer {
|
|
|
137
142
|
target,
|
|
138
143
|
explore,
|
|
139
144
|
tags,
|
|
145
|
+
jsDocTags,
|
|
140
146
|
);
|
|
141
147
|
};
|
|
142
148
|
|
|
@@ -88,6 +88,7 @@ export namespace PruneProgrammer {
|
|
|
88
88
|
})(),
|
|
89
89
|
explore,
|
|
90
90
|
[],
|
|
91
|
+
[],
|
|
91
92
|
),
|
|
92
93
|
value: () =>
|
|
93
94
|
decode_tuple(project, importer)(input, tuple, explore),
|
|
@@ -107,6 +108,7 @@ export namespace PruneProgrammer {
|
|
|
107
108
|
from: "array",
|
|
108
109
|
},
|
|
109
110
|
[],
|
|
111
|
+
[],
|
|
110
112
|
),
|
|
111
113
|
});
|
|
112
114
|
|
|
@@ -344,10 +344,7 @@ export namespace RandomProgrammer {
|
|
|
344
344
|
(importer: FunctionImporter) =>
|
|
345
345
|
(tags: IMetadataTag[]): ts.Expression => {
|
|
346
346
|
for (const t of tags)
|
|
347
|
-
if (
|
|
348
|
-
t.kind === "format" &&
|
|
349
|
-
["uuid", "email", "url", "ipv4", "ipv6"].includes(t.value)
|
|
350
|
-
)
|
|
347
|
+
if (t.kind === "format")
|
|
351
348
|
return ts.factory.createCallExpression(
|
|
352
349
|
COALESCE(importer)(t.value),
|
|
353
350
|
undefined,
|
|
@@ -172,6 +172,7 @@ export namespace StringifyProgrammer {
|
|
|
172
172
|
partial,
|
|
173
173
|
explore,
|
|
174
174
|
[],
|
|
175
|
+
[],
|
|
175
176
|
),
|
|
176
177
|
value: () =>
|
|
177
178
|
decode_atomic(project, importer)(
|
|
@@ -200,6 +201,7 @@ export namespace StringifyProgrammer {
|
|
|
200
201
|
})(),
|
|
201
202
|
explore,
|
|
202
203
|
[],
|
|
204
|
+
[],
|
|
203
205
|
),
|
|
204
206
|
value: () =>
|
|
205
207
|
decode_atomic(project, importer)(
|
|
@@ -222,6 +224,7 @@ export namespace StringifyProgrammer {
|
|
|
222
224
|
})(),
|
|
223
225
|
explore,
|
|
224
226
|
[],
|
|
227
|
+
[],
|
|
225
228
|
),
|
|
226
229
|
value: () =>
|
|
227
230
|
decode_constant_string(project, importer)(
|
|
@@ -246,6 +249,7 @@ export namespace StringifyProgrammer {
|
|
|
246
249
|
})(),
|
|
247
250
|
explore,
|
|
248
251
|
[],
|
|
252
|
+
[],
|
|
249
253
|
),
|
|
250
254
|
value: () =>
|
|
251
255
|
decode_atomic(project, importer)(
|
|
@@ -275,6 +279,7 @@ export namespace StringifyProgrammer {
|
|
|
275
279
|
})(),
|
|
276
280
|
explore,
|
|
277
281
|
[],
|
|
282
|
+
[],
|
|
278
283
|
),
|
|
279
284
|
value: () =>
|
|
280
285
|
decode_tuple(project, importer)(
|
|
@@ -311,6 +316,7 @@ export namespace StringifyProgrammer {
|
|
|
311
316
|
from: "array",
|
|
312
317
|
},
|
|
313
318
|
[],
|
|
319
|
+
[],
|
|
314
320
|
);
|
|
315
321
|
|
|
316
322
|
unions.push({
|
|
@@ -31,6 +31,30 @@ export namespace ValidateProgrammer {
|
|
|
31
31
|
trace: true,
|
|
32
32
|
numeric: OptionPredicator.numeric(project.options),
|
|
33
33
|
equals,
|
|
34
|
+
atomist: (explore) => (tuple) => (input) =>
|
|
35
|
+
[
|
|
36
|
+
tuple.expression,
|
|
37
|
+
...tuple.tags.map((tag) =>
|
|
38
|
+
ts.factory.createLogicalOr(
|
|
39
|
+
tag.expression,
|
|
40
|
+
create_report_call(
|
|
41
|
+
explore.from === "top"
|
|
42
|
+
? ts.factory.createTrue()
|
|
43
|
+
: ts.factory.createIdentifier(
|
|
44
|
+
"_exceptionable",
|
|
45
|
+
),
|
|
46
|
+
)(
|
|
47
|
+
ts.factory.createIdentifier(
|
|
48
|
+
explore.postfix
|
|
49
|
+
? `_path + ${explore.postfix}`
|
|
50
|
+
: "_path",
|
|
51
|
+
),
|
|
52
|
+
tag.expected,
|
|
53
|
+
input,
|
|
54
|
+
),
|
|
55
|
+
),
|
|
56
|
+
),
|
|
57
|
+
].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
|
|
34
58
|
combiner: combine(equals)(importer),
|
|
35
59
|
joiner: joiner(equals)(importer),
|
|
36
60
|
success: ts.factory.createTrue(),
|