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
|
@@ -28,7 +28,7 @@ export namespace MetadataTagFactory {
|
|
|
28
28
|
tag: ts.JSDocTagInfo,
|
|
29
29
|
output: IMetadataTag[],
|
|
30
30
|
): IMetadataTag | null {
|
|
31
|
-
const closure =
|
|
31
|
+
const closure = _PARSER[tag.name];
|
|
32
32
|
if (closure === undefined) return null;
|
|
33
33
|
|
|
34
34
|
const text = (tag.text || [])[0]?.text;
|
|
@@ -37,166 +37,193 @@ export namespace MetadataTagFactory {
|
|
|
37
37
|
|
|
38
38
|
return closure(identifier, metadata, text, output);
|
|
39
39
|
}
|
|
40
|
-
}
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export const _PARSER: Record<
|
|
45
|
+
string,
|
|
46
|
+
(
|
|
47
|
+
identifier: () => string,
|
|
48
|
+
metadata: Metadata,
|
|
49
|
+
text: string,
|
|
50
|
+
output: IMetadataTag[],
|
|
51
|
+
) => IMetadataTag | null
|
|
52
|
+
> = {
|
|
53
|
+
/* -----------------------------------------------------------
|
|
52
54
|
ARRAY
|
|
53
55
|
----------------------------------------------------------- */
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
56
|
+
items: (identifier, metadata, text, output) => {
|
|
57
|
+
validate(identifier, metadata, output, "items", "array", [
|
|
58
|
+
"minItems",
|
|
59
|
+
]);
|
|
60
|
+
return {
|
|
61
|
+
kind: "items",
|
|
62
|
+
value: parse_number(identifier, text),
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
minItems: (identifier, metadata, text, output) => {
|
|
66
|
+
validate(identifier, metadata, output, "minItems", "array", [
|
|
67
|
+
"items",
|
|
68
|
+
]);
|
|
69
|
+
return {
|
|
70
|
+
kind: "minItems",
|
|
71
|
+
value: parse_number(identifier, text),
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
maxItems: (identifier, metadata, text, output) => {
|
|
75
|
+
validate(identifier, metadata, output, "maxItems", "array", [
|
|
76
|
+
"items",
|
|
77
|
+
]);
|
|
78
|
+
return {
|
|
79
|
+
kind: "maxItems",
|
|
80
|
+
value: parse_number(identifier, text),
|
|
81
|
+
};
|
|
82
|
+
},
|
|
75
83
|
|
|
76
|
-
|
|
84
|
+
/* -----------------------------------------------------------
|
|
77
85
|
NUMBER
|
|
78
86
|
----------------------------------------------------------- */
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
87
|
+
type: (identifier, metadata, text, output) => {
|
|
88
|
+
validate(identifier, metadata, output, "type", "number", []);
|
|
89
|
+
if (text !== "int" && text !== "uint")
|
|
90
|
+
throw new Error(
|
|
91
|
+
`${LABEL}: invalid type tag on "${identifier()}".`,
|
|
92
|
+
);
|
|
93
|
+
return { kind: "type", value: text };
|
|
94
|
+
},
|
|
95
|
+
minimum: (identifier, metadata, text, output) => {
|
|
96
|
+
validate(identifier, metadata, output, "minimum", "number", [
|
|
97
|
+
"exclusiveMinimum",
|
|
98
|
+
]);
|
|
99
|
+
return {
|
|
100
|
+
kind: "minimum",
|
|
101
|
+
value: parse_number(identifier, text),
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
maximum: (identifier, metadata, text, output) => {
|
|
105
|
+
validate(identifier, metadata, output, "maximum", "number", [
|
|
106
|
+
"exclusiveMaximum",
|
|
107
|
+
]);
|
|
108
|
+
return {
|
|
109
|
+
kind: "maximum",
|
|
110
|
+
value: parse_number(identifier, text),
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
exclusiveMinimum: (identifier, metadata, text, output) => {
|
|
114
|
+
validate(
|
|
115
|
+
identifier,
|
|
116
|
+
metadata,
|
|
117
|
+
output,
|
|
118
|
+
"exclusiveMinimum",
|
|
119
|
+
"number",
|
|
120
|
+
["minimum"],
|
|
121
|
+
);
|
|
122
|
+
return {
|
|
123
|
+
kind: "exclusiveMinimum",
|
|
124
|
+
value: parse_number(identifier, text),
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
exclusiveMaximum: (identifier, metadata, text, output) => {
|
|
128
|
+
validate(
|
|
129
|
+
identifier,
|
|
130
|
+
metadata,
|
|
131
|
+
output,
|
|
132
|
+
"exclusiveMaximum",
|
|
133
|
+
"number",
|
|
134
|
+
["maximum"],
|
|
135
|
+
);
|
|
136
|
+
return {
|
|
137
|
+
kind: "exclusiveMaximum",
|
|
138
|
+
value: parse_number(identifier, text),
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
multipleOf: (identifier, metadata, text, output) => {
|
|
142
|
+
validate(identifier, metadata, output, "multipleOf", "number", [
|
|
143
|
+
"step",
|
|
144
|
+
]);
|
|
145
|
+
return {
|
|
146
|
+
kind: "multipleOf",
|
|
147
|
+
value: parse_number(identifier, text),
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
step: (identifier, metadata, text, output) => {
|
|
151
|
+
validate(identifier, metadata, output, "step", "number", [
|
|
152
|
+
"multipleOf",
|
|
153
|
+
]);
|
|
134
154
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (minimum === undefined)
|
|
139
|
-
throw new Error(
|
|
140
|
-
`${LABEL}: step requires minimum or exclusiveMinimum tag on "${identifier()}".`,
|
|
155
|
+
const minimum: boolean = output.some(
|
|
156
|
+
(tag) =>
|
|
157
|
+
tag.kind === "minimum" || tag.kind === "exclusiveMinimum",
|
|
141
158
|
);
|
|
159
|
+
if (minimum === undefined)
|
|
160
|
+
throw new Error(
|
|
161
|
+
`${LABEL}: step requires minimum or exclusiveMinimum tag on "${identifier()}".`,
|
|
162
|
+
);
|
|
142
163
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
164
|
+
return {
|
|
165
|
+
kind: "step",
|
|
166
|
+
value: parse_number(identifier, text),
|
|
167
|
+
};
|
|
168
|
+
},
|
|
148
169
|
|
|
149
|
-
|
|
170
|
+
/* -----------------------------------------------------------
|
|
150
171
|
STRING
|
|
151
172
|
----------------------------------------------------------- */
|
|
152
|
-
|
|
153
|
-
|
|
173
|
+
format: (identifier, metadata, str, output) => {
|
|
174
|
+
validate(identifier, metadata, output, "format", "string", [
|
|
175
|
+
"pattern",
|
|
176
|
+
]);
|
|
154
177
|
|
|
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
|
-
|
|
178
|
+
// Ignore arbitrary @format values in the internal metadata,
|
|
179
|
+
// these are currently only supported on the typia.application() API.
|
|
180
|
+
const value: IMetadataTag.IFormat["value"] | undefined =
|
|
181
|
+
FORMATS.get(str);
|
|
182
|
+
if (value === undefined) return null;
|
|
183
|
+
return {
|
|
184
|
+
kind: "format",
|
|
185
|
+
value,
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
pattern: (identifier, metadata, value, output) => {
|
|
189
|
+
validate(identifier, metadata, output, "pattern", "string", [
|
|
190
|
+
"format",
|
|
191
|
+
]);
|
|
192
|
+
return {
|
|
193
|
+
kind: "pattern",
|
|
194
|
+
value,
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
length: (identifier, metadata, text, output) => {
|
|
198
|
+
validate(identifier, metadata, output, "length", "string", [
|
|
199
|
+
"minLength",
|
|
200
|
+
"maxLength",
|
|
201
|
+
]);
|
|
202
|
+
return {
|
|
203
|
+
kind: "length",
|
|
204
|
+
value: parse_number(identifier, text),
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
minLength: (identifier, metadata, text, output) => {
|
|
208
|
+
validate(identifier, metadata, output, "minLength", "string", [
|
|
209
|
+
"length",
|
|
210
|
+
]);
|
|
211
|
+
return {
|
|
212
|
+
kind: "minLength",
|
|
213
|
+
value: parse_number(identifier, text),
|
|
214
|
+
};
|
|
215
|
+
},
|
|
216
|
+
maxLength: (identifier, metadata, text, output) => {
|
|
217
|
+
validate(identifier, metadata, output, "maxLength", "string", [
|
|
218
|
+
"length",
|
|
219
|
+
]);
|
|
220
|
+
return {
|
|
221
|
+
kind: "maxLength",
|
|
222
|
+
value: parse_number(identifier, text),
|
|
223
|
+
};
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
}
|
|
200
227
|
|
|
201
228
|
function parse_number(identifier: () => string, str: string): number {
|
|
202
229
|
const value: number = Number(str);
|
|
@@ -206,7 +233,17 @@ function parse_number(identifier: () => string, str: string): number {
|
|
|
206
233
|
}
|
|
207
234
|
|
|
208
235
|
const LABEL = "Error on typia.MetadataTagFactory.generate()";
|
|
209
|
-
const FORMATS
|
|
236
|
+
const FORMATS: Map<string, IMetadataTag.IFormat["value"]> = new Map([
|
|
237
|
+
["uuid", "uuid"],
|
|
238
|
+
["email", "email"],
|
|
239
|
+
["url", "url"],
|
|
240
|
+
["ipv4", "ipv4"],
|
|
241
|
+
["ipv6", "ipv6"],
|
|
242
|
+
["date", "date"],
|
|
243
|
+
["datetime", "datetime"],
|
|
244
|
+
["date-time", "datetime"],
|
|
245
|
+
["dateTime", "datetime"],
|
|
246
|
+
]);
|
|
210
247
|
|
|
211
248
|
const WRONG_TYPE = (
|
|
212
249
|
tag: string,
|
|
@@ -87,7 +87,7 @@ export namespace TypeFactory {
|
|
|
87
87
|
function explore_name(name: string, decl: ts.Node): string {
|
|
88
88
|
return ts.isModuleBlock(decl)
|
|
89
89
|
? explore_name(
|
|
90
|
-
`${decl.parent.name.
|
|
90
|
+
`${decl.parent.name.getFullText().trim()}.${name}`,
|
|
91
91
|
decl.parent.parent,
|
|
92
92
|
)
|
|
93
93
|
: name;
|
|
@@ -40,7 +40,7 @@ export namespace TypiaFileFactory {
|
|
|
40
40
|
const program: ts.Program = ts.createProgram(
|
|
41
41
|
await (async () => {
|
|
42
42
|
const container: string[] = [];
|
|
43
|
-
await gather(container)(props.input)(props.output);
|
|
43
|
+
await gather(props)(container)(props.input)(props.output);
|
|
44
44
|
return container;
|
|
45
45
|
})(),
|
|
46
46
|
config.compilerOptions,
|
|
@@ -99,19 +99,22 @@ export namespace TypiaFileFactory {
|
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
const gather =
|
|
102
|
-
(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
(props: IProps) =>
|
|
103
|
+
(container: string[]) =>
|
|
104
|
+
(from: string) =>
|
|
105
|
+
async (to: string) => {
|
|
106
|
+
if (from === props.output) return;
|
|
107
|
+
else if (fs.existsSync(to) === false) await fs.promises.mkdir(to);
|
|
108
|
+
|
|
109
|
+
for (const file of await fs.promises.readdir(from)) {
|
|
106
110
|
const next: string = path.join(from, file);
|
|
107
111
|
const stat: fs.Stats = await fs.promises.stat(next);
|
|
108
112
|
|
|
109
113
|
if (stat.isDirectory()) {
|
|
110
|
-
await gather(container)(next)(path.join(to, file));
|
|
114
|
+
await gather(props)(container)(next)(path.join(to, file));
|
|
111
115
|
continue;
|
|
112
116
|
} else if (file.substring(file.length - 3) === ".ts")
|
|
113
117
|
container.push(next);
|
|
114
118
|
}
|
|
115
|
-
return container;
|
|
116
119
|
};
|
|
117
120
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Customizable } from "../typings/Customizable";
|
|
2
|
+
|
|
3
|
+
export const $dictionary = (() => {
|
|
4
|
+
const glob: {
|
|
5
|
+
__typia_custom_validator: Map<
|
|
6
|
+
`${string}:${keyof Customizable}`,
|
|
7
|
+
(tagText: string) => (value: any) => boolean
|
|
8
|
+
>;
|
|
9
|
+
} =
|
|
10
|
+
typeof global === "object" &&
|
|
11
|
+
typeof global.process === "object" &&
|
|
12
|
+
typeof global.process.versions === "object" &&
|
|
13
|
+
typeof global.process.versions.node !== "undefined"
|
|
14
|
+
? (global as any)
|
|
15
|
+
: (window as any);
|
|
16
|
+
return (glob.__typia_custom_validator ??= new Map());
|
|
17
|
+
})();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Customizable } from "../typings/Customizable";
|
|
2
|
+
|
|
3
|
+
import { $dictionary } from "./$dictionary";
|
|
4
|
+
|
|
5
|
+
export function $is_custom<Type extends keyof Customizable>(
|
|
6
|
+
name: string,
|
|
7
|
+
type: Type,
|
|
8
|
+
text: string,
|
|
9
|
+
value: Customizable[Type],
|
|
10
|
+
): boolean {
|
|
11
|
+
const validator = $dictionary.get(`${name}:${type}`);
|
|
12
|
+
if (validator === undefined) return true;
|
|
13
|
+
return validator(text)(value);
|
|
14
|
+
}
|
|
@@ -6,6 +6,9 @@ import { $any } from "./$any";
|
|
|
6
6
|
import { $every } from "./$every";
|
|
7
7
|
import { $guard } from "./$guard";
|
|
8
8
|
import { $is_between } from "./$is_between";
|
|
9
|
+
import { $is_custom } from "./$is_custom";
|
|
10
|
+
import { $is_date } from "./$is_date";
|
|
11
|
+
import { $is_datetime } from "./$is_datetime";
|
|
9
12
|
import { $is_email } from "./$is_email";
|
|
10
13
|
import { $is_ipv4 } from "./$is_ipv4";
|
|
11
14
|
import { $is_ipv6 } from "./$is_ipv6";
|
|
@@ -29,6 +32,9 @@ export namespace Namespace {
|
|
|
29
32
|
is_ipv4: $is_ipv4,
|
|
30
33
|
is_ipv6: $is_ipv6,
|
|
31
34
|
is_between: $is_between,
|
|
35
|
+
is_date: $is_date,
|
|
36
|
+
is_datetime: $is_datetime,
|
|
37
|
+
is_custom: $is_custom,
|
|
32
38
|
});
|
|
33
39
|
|
|
34
40
|
export const assert = (method: string) => ({
|
|
@@ -1,42 +1,59 @@
|
|
|
1
1
|
export type IMetadataTag =
|
|
2
|
-
// ARRAY
|
|
3
|
-
| IMetadataTag.IItems
|
|
4
|
-
| IMetadataTag.IMinItems
|
|
5
|
-
| IMetadataTag.IMaxItems
|
|
6
|
-
// STRING
|
|
7
|
-
| IMetadataTag.IFormat
|
|
8
|
-
| IMetadataTag.IPattern
|
|
9
|
-
| IMetadataTag.ILength
|
|
10
|
-
| IMetadataTag.IMinLength
|
|
11
|
-
| IMetadataTag.IMaxLength
|
|
12
2
|
// NUMBER
|
|
13
|
-
| IMetadataTag.
|
|
14
|
-
| IMetadataTag.IBigintType
|
|
3
|
+
| IMetadataTag.IType
|
|
15
4
|
| IMetadataTag.IMinimum
|
|
16
5
|
| IMetadataTag.IMaximum
|
|
17
6
|
| IMetadataTag.IExclusiveMinimum
|
|
18
7
|
| IMetadataTag.IExclusiveMaximum
|
|
19
8
|
| IMetadataTag.IMultipleOf
|
|
20
9
|
| IMetadataTag.IStep
|
|
21
|
-
//
|
|
22
|
-
| IMetadataTag.
|
|
10
|
+
// STRING
|
|
11
|
+
| IMetadataTag.IFormat
|
|
12
|
+
| IMetadataTag.IPattern
|
|
13
|
+
| IMetadataTag.ILength
|
|
14
|
+
| IMetadataTag.IMinLength
|
|
15
|
+
| IMetadataTag.IMaxLength
|
|
16
|
+
// ARRAY
|
|
17
|
+
| IMetadataTag.IItems
|
|
18
|
+
| IMetadataTag.IMinItems
|
|
19
|
+
| IMetadataTag.IMaxItems;
|
|
23
20
|
|
|
24
21
|
export namespace IMetadataTag {
|
|
25
22
|
/* -----------------------------------------------------------
|
|
26
|
-
|
|
23
|
+
NUMBER
|
|
27
24
|
----------------------------------------------------------- */
|
|
28
|
-
export interface
|
|
29
|
-
kind: "
|
|
25
|
+
export interface IType {
|
|
26
|
+
kind: "type";
|
|
27
|
+
value: "int" | "uint";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface IMinimum {
|
|
31
|
+
kind: "minimum";
|
|
30
32
|
value: number;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
export interface
|
|
34
|
-
kind: "
|
|
35
|
+
export interface IMaximum {
|
|
36
|
+
kind: "maximum";
|
|
35
37
|
value: number;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
export interface
|
|
39
|
-
kind: "
|
|
40
|
+
export interface IExclusiveMinimum {
|
|
41
|
+
kind: "exclusiveMinimum";
|
|
42
|
+
value: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface IExclusiveMaximum {
|
|
46
|
+
kind: "exclusiveMaximum";
|
|
47
|
+
value: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IMultipleOf {
|
|
51
|
+
kind: "multipleOf";
|
|
52
|
+
value: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface IStep {
|
|
56
|
+
kind: "step";
|
|
40
57
|
value: number;
|
|
41
58
|
}
|
|
42
59
|
|
|
@@ -45,7 +62,7 @@ export namespace IMetadataTag {
|
|
|
45
62
|
----------------------------------------------------------- */
|
|
46
63
|
export interface IFormat {
|
|
47
64
|
kind: "format";
|
|
48
|
-
value: "uuid" | "email" | "url" | "ipv4" | "ipv6";
|
|
65
|
+
value: "uuid" | "email" | "url" | "ipv4" | "ipv6" | "date" | "datetime";
|
|
49
66
|
}
|
|
50
67
|
|
|
51
68
|
export interface IPattern {
|
|
@@ -69,61 +86,20 @@ export namespace IMetadataTag {
|
|
|
69
86
|
}
|
|
70
87
|
|
|
71
88
|
/* -----------------------------------------------------------
|
|
72
|
-
|
|
89
|
+
ARRAY
|
|
73
90
|
----------------------------------------------------------- */
|
|
74
|
-
export interface
|
|
75
|
-
kind: "
|
|
76
|
-
value:
|
|
77
|
-
| "int"
|
|
78
|
-
| "uint"
|
|
79
|
-
| "int32"
|
|
80
|
-
| "uint32"
|
|
81
|
-
| "int64"
|
|
82
|
-
| "uint64"
|
|
83
|
-
| "float"
|
|
84
|
-
| "double";
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface IMinimum {
|
|
88
|
-
kind: "minimum";
|
|
89
|
-
value: number;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface IMaximum {
|
|
93
|
-
kind: "maximum";
|
|
94
|
-
value: number;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface IExclusiveMinimum {
|
|
98
|
-
kind: "exclusiveMinimum";
|
|
99
|
-
value: number;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface IExclusiveMaximum {
|
|
103
|
-
kind: "exclusiveMaximum";
|
|
104
|
-
value: number;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface IMultipleOf {
|
|
108
|
-
kind: "multipleOf";
|
|
91
|
+
export interface IItems {
|
|
92
|
+
kind: "items";
|
|
109
93
|
value: number;
|
|
110
94
|
}
|
|
111
95
|
|
|
112
|
-
export interface
|
|
113
|
-
kind: "
|
|
96
|
+
export interface IMinItems {
|
|
97
|
+
kind: "minItems";
|
|
114
98
|
value: number;
|
|
115
99
|
}
|
|
116
100
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
----------------------------------------------------------- */
|
|
120
|
-
export interface IBigintType {
|
|
121
|
-
kind: "type";
|
|
122
|
-
value: "int64" | "uint64";
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export interface ISign {
|
|
126
|
-
include: boolean;
|
|
101
|
+
export interface IMaxItems {
|
|
102
|
+
kind: "maxItems";
|
|
127
103
|
value: number;
|
|
128
104
|
}
|
|
129
105
|
}
|