typia 4.1.8-dev.20230726 → 4.1.8
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/package.json +1 -1
- package/src/factories/MetadataCollection.ts +255 -255
- package/src/factories/MetadataFactory.ts +30 -30
- package/src/factories/MetadataTagFactory.ts +355 -355
- package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
- package/src/factories/internal/metadata/emend_metadata_atomics.ts +33 -33
- package/src/factories/internal/metadata/emplace_metadata_alias.ts +40 -40
- package/src/factories/internal/metadata/emplace_metadata_array.ts +34 -34
- package/src/factories/internal/metadata/emplace_metadata_object.ts +136 -136
- package/src/factories/internal/metadata/emplace_metadata_tuple.ts +50 -50
- package/src/factories/internal/metadata/explore_metadata.ts +40 -40
- package/src/factories/internal/metadata/iterate_metadata.ts +81 -81
- package/src/factories/internal/metadata/iterate_metadata_alias.ts +30 -30
- package/src/factories/internal/metadata/iterate_metadata_array.ts +24 -24
- package/src/factories/internal/metadata/iterate_metadata_atomic.ts +59 -59
- package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_collection.ts +133 -133
- package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
- package/src/factories/internal/metadata/iterate_metadata_intersection.ts +83 -83
- package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
- package/src/factories/internal/metadata/iterate_metadata_native.ts +219 -219
- package/src/factories/internal/metadata/iterate_metadata_object.ts +43 -43
- package/src/factories/internal/metadata/iterate_metadata_resolve.ts +49 -49
- package/src/factories/internal/metadata/iterate_metadata_set.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_sort.ts +69 -69
- package/src/factories/internal/metadata/iterate_metadata_tag.ts +31 -31
- package/src/factories/internal/metadata/iterate_metadata_template.ts +38 -38
- package/src/factories/internal/metadata/iterate_metadata_tuple.ts +24 -24
- package/src/factories/internal/metadata/iterate_metadata_union.ts +24 -24
- package/src/functional/$number.ts +12 -12
- package/src/metadata/ICommentTag.ts +4 -4
- package/src/metadata/IJsDocTagInfo.ts +10 -10
- package/src/metadata/IMetadata.ts +28 -28
- package/src/metadata/IMetadataAlias.ts +14 -14
- package/src/metadata/IMetadataApplication.ts +7 -7
- package/src/metadata/IMetadataArray.ts +10 -10
- package/src/metadata/IMetadataCollection.ts +11 -11
- package/src/metadata/IMetadataConstant.ts +16 -16
- package/src/metadata/IMetadataDictionary.ts +14 -14
- package/src/metadata/IMetadataEntry.ts +6 -6
- package/src/metadata/IMetadataObject.ts +18 -18
- package/src/metadata/IMetadataProperty.ts +11 -11
- package/src/metadata/IMetadataResolved.ts +6 -6
- package/src/metadata/IMetadataTag.ts +105 -105
- package/src/metadata/IMetadataTuple.ts +10 -10
- package/src/metadata/Metadata.ts +605 -605
- package/src/metadata/MetadataAlias.ts +66 -66
- package/src/metadata/MetadataArray.ts +55 -55
- package/src/metadata/MetadataConstant.ts +3 -3
- package/src/metadata/MetadataObject.ts +129 -129
- package/src/metadata/MetadataProperty.ts +64 -64
- package/src/metadata/MetadataResolved.ts +51 -51
- package/src/metadata/MetadataTuple.ts +53 -53
- package/src/module.ts +2038 -2038
- package/src/programmers/ApplicationProgrammer.ts +47 -47
- package/src/programmers/AssertCloneProgrammer.ts +71 -71
- package/src/programmers/AssertParseProgrammer.ts +66 -66
- package/src/programmers/AssertPruneProgrammer.ts +68 -68
- package/src/programmers/AssertStringifyProgrammer.ts +66 -66
- package/src/programmers/CheckerProgrammer.ts +1182 -1182
- package/src/programmers/CloneProgrammer.ts +587 -587
- package/src/programmers/FeatureProgrammer.ts +495 -495
- package/src/programmers/IsCloneProgrammer.ts +78 -78
- package/src/programmers/IsParseProgrammer.ts +72 -72
- package/src/programmers/IsProgrammer.ts +239 -239
- package/src/programmers/IsPruneProgrammer.ts +73 -73
- package/src/programmers/IsStringifyProgrammer.ts +76 -76
- package/src/programmers/LiteralsProgrammer.ts +63 -63
- package/src/programmers/PruneProgrammer.ts +542 -542
- package/src/programmers/RandomProgrammer.ts +581 -581
- package/src/programmers/StringifyProgrammer.ts +978 -978
- package/src/programmers/ValidateCloneProgrammer.ts +85 -85
- package/src/programmers/ValidateParseProgrammer.ts +70 -70
- package/src/programmers/ValidatePruneProgrammer.ts +78 -78
- package/src/programmers/ValidateStringifyProgrammer.ts +84 -84
- package/src/programmers/helpers/AtomicPredicator.ts +31 -31
- package/src/programmers/helpers/IExpressionEntry.ts +12 -12
- package/src/programmers/helpers/PruneJoiner.ts +143 -143
- package/src/programmers/helpers/RandomJoiner.ts +173 -173
- package/src/programmers/helpers/RandomRanger.ts +216 -216
- package/src/programmers/helpers/StringifyPredicator.ts +13 -13
- package/src/programmers/helpers/UnionExplorer.ts +301 -301
- package/src/programmers/helpers/UnionPredicator.ts +81 -81
- package/src/programmers/internal/application_alias.ts +66 -66
- package/src/programmers/internal/application_array.ts +30 -30
- package/src/programmers/internal/application_constant.ts +26 -26
- package/src/programmers/internal/application_default.ts +17 -17
- package/src/programmers/internal/application_default_string.ts +33 -33
- package/src/programmers/internal/application_native.ts +39 -39
- package/src/programmers/internal/application_number.ts +74 -74
- package/src/programmers/internal/application_object.ts +162 -162
- package/src/programmers/internal/application_resolved.ts +55 -55
- package/src/programmers/internal/application_schema.ts +157 -157
- package/src/programmers/internal/application_string.ts +44 -44
- package/src/programmers/internal/application_templates.ts +25 -25
- package/src/programmers/internal/application_tuple.ts +57 -57
- package/src/programmers/internal/check_array.ts +30 -30
- package/src/programmers/internal/check_array_length.ts +35 -35
- package/src/programmers/internal/check_bigint.ts +82 -82
- package/src/programmers/internal/check_custom.ts +31 -31
- package/src/programmers/internal/check_number.ts +177 -177
- package/src/programmers/internal/check_string.ts +25 -25
- package/src/programmers/internal/check_string_tags.ts +67 -67
- package/src/programmers/internal/check_template.ts +56 -56
- package/src/programmers/internal/check_union_array_like.ts +329 -329
- package/src/programmers/internal/decode_union_object.ts +73 -73
- package/src/programmers/internal/feature_object_entries.ts +63 -63
- package/src/programmers/internal/get_comment_tags.ts +23 -23
- package/src/programmers/internal/metadata_to_pattern.ts +34 -34
- package/src/programmers/internal/prune_object_properties.ts +60 -60
- package/src/programmers/internal/random_custom.ts +29 -29
- package/src/programmers/internal/stringify_regular_properties.ts +83 -83
- package/src/programmers/internal/template_to_pattern.ts +15 -15
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +16 -16
- package/src/schemas/IJsonApplication.ts +8 -8
- package/src/schemas/IJsonComponents.ts +33 -33
- package/src/schemas/IJsonSchema.ts +133 -133
- package/src/transformers/CallExpressionTransformer.ts +179 -179
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +104 -104
- package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateRandomTransformer.ts +39 -39
- package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/LiteralsTransformer.ts +28 -28
- package/src/transformers/features/miscellaneous/MetadataTransformer.ts +53 -53
- package/src/transformers/features/miscellaneous/PruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/RandomTransformer.ts +42 -42
- package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +9 -9
- package/src/transformers/features/parsers/AssertParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/CreateIsParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/IsParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/ValidateParseTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +10 -10
- package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +12 -12
- package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +12 -12
- package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/StringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +10 -10
- package/src/transformers/features/validators/AssertTransformer.ts +11 -11
- package/src/transformers/features/validators/CreateAssertTransformer.ts +13 -13
- package/src/transformers/features/validators/CreateIsTransformer.ts +11 -11
- package/src/transformers/features/validators/CreateValidateTransformer.ts +13 -13
- package/src/transformers/features/validators/IsTransformer.ts +11 -11
- package/src/transformers/features/validators/ValidateTransformer.ts +11 -11
|
@@ -1,157 +1,157 @@
|
|
|
1
|
-
import { Metadata } from "../../metadata/Metadata";
|
|
2
|
-
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
3
|
-
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
4
|
-
|
|
5
|
-
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
6
|
-
import { AtomicPredicator } from "../helpers/AtomicPredicator";
|
|
7
|
-
import { application_alias } from "./application_alias";
|
|
8
|
-
import { application_array } from "./application_array";
|
|
9
|
-
import { application_boolean } from "./application_boolean";
|
|
10
|
-
import { application_constant } from "./application_constant";
|
|
11
|
-
import { application_native } from "./application_native";
|
|
12
|
-
import { application_number } from "./application_number";
|
|
13
|
-
import { application_object } from "./application_object";
|
|
14
|
-
import { application_resolved } from "./application_resolved";
|
|
15
|
-
import { application_string } from "./application_string";
|
|
16
|
-
import { application_templates } from "./application_templates";
|
|
17
|
-
import { application_tuple } from "./application_tuple";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
export const application_schema =
|
|
23
|
-
(options: ApplicationProgrammer.IOptions) =>
|
|
24
|
-
<BlockNever extends boolean>(blockNever: BlockNever) =>
|
|
25
|
-
(components: IJsonComponents) =>
|
|
26
|
-
(meta: Metadata) =>
|
|
27
|
-
(
|
|
28
|
-
attribute: IJsonSchema.IAttribute,
|
|
29
|
-
): BlockNever extends true ? IJsonSchema | null : IJsonSchema => {
|
|
30
|
-
// VULNERABLE CASE
|
|
31
|
-
if (meta.any === true)
|
|
32
|
-
return {
|
|
33
|
-
...attribute,
|
|
34
|
-
type: undefined,
|
|
35
|
-
};
|
|
36
|
-
else if (meta.nullable && meta.empty())
|
|
37
|
-
return { type: "null", ...attribute };
|
|
38
|
-
|
|
39
|
-
//----
|
|
40
|
-
// GATHER UNION SCHEMAS
|
|
41
|
-
//----
|
|
42
|
-
const union: IJsonSchema[] = [];
|
|
43
|
-
if (meta.nullable && options.purpose !== "swagger")
|
|
44
|
-
union.push({
|
|
45
|
-
...attribute,
|
|
46
|
-
type: "null",
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const insert =
|
|
50
|
-
meta.nullable && options.purpose === "swagger"
|
|
51
|
-
? (s: IJsonSchema) =>
|
|
52
|
-
union.push({
|
|
53
|
-
...s,
|
|
54
|
-
nullable: (s as IJsonSchema.ISignificant<any>).type
|
|
55
|
-
? true
|
|
56
|
-
: undefined,
|
|
57
|
-
} as IJsonSchema)
|
|
58
|
-
: (schema: IJsonSchema) => union.push(schema);
|
|
59
|
-
|
|
60
|
-
// toJSON() METHOD
|
|
61
|
-
if (meta.resolved !== null)
|
|
62
|
-
union.push(
|
|
63
|
-
...application_resolved(options)(blockNever)(components)(
|
|
64
|
-
meta.resolved,
|
|
65
|
-
)(attribute),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
// ATOMIC TYPES
|
|
69
|
-
if (meta.templates.length && AtomicPredicator.template(meta))
|
|
70
|
-
insert(application_templates(meta)(attribute));
|
|
71
|
-
for (const constant of meta.constants)
|
|
72
|
-
if (constant.type === "bigint") throw new Error(NO_BIGINT);
|
|
73
|
-
else if (
|
|
74
|
-
(constant.type === "string" && meta.templates.length) ||
|
|
75
|
-
AtomicPredicator.constant(meta)(constant.type) === false
|
|
76
|
-
)
|
|
77
|
-
continue;
|
|
78
|
-
else insert(application_constant(constant)(attribute));
|
|
79
|
-
for (const type of meta.atomics)
|
|
80
|
-
if (type === "bigint") throw new Error(NO_BIGINT);
|
|
81
|
-
else if (AtomicPredicator.atomic(meta)(type) === false) continue;
|
|
82
|
-
else
|
|
83
|
-
insert(
|
|
84
|
-
type === "string"
|
|
85
|
-
? application_string(meta)(attribute)
|
|
86
|
-
: type === "boolean"
|
|
87
|
-
? application_boolean(attribute)
|
|
88
|
-
: application_number(attribute),
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
// ARRAY
|
|
92
|
-
for (const array of meta.arrays)
|
|
93
|
-
insert(application_array(options)(components)(array)(attribute));
|
|
94
|
-
|
|
95
|
-
// TUPLE
|
|
96
|
-
for (const tuple of meta.tuples)
|
|
97
|
-
insert(application_tuple(options)(components)(tuple)(attribute));
|
|
98
|
-
|
|
99
|
-
// NATIVES
|
|
100
|
-
for (const native of meta.natives)
|
|
101
|
-
if (AtomicPredicator.native(native))
|
|
102
|
-
insert(
|
|
103
|
-
native === "String"
|
|
104
|
-
? application_string(meta)(attribute)
|
|
105
|
-
: native === "Boolean"
|
|
106
|
-
? application_boolean(attribute)
|
|
107
|
-
: application_number(attribute),
|
|
108
|
-
);
|
|
109
|
-
else
|
|
110
|
-
insert(
|
|
111
|
-
application_native(options)(components)(native)({
|
|
112
|
-
nullable: meta.nullable,
|
|
113
|
-
attribute,
|
|
114
|
-
}),
|
|
115
|
-
);
|
|
116
|
-
if (meta.sets.length)
|
|
117
|
-
insert(
|
|
118
|
-
application_native(options)(components)(`Set`)({
|
|
119
|
-
nullable: meta.nullable,
|
|
120
|
-
attribute,
|
|
121
|
-
}),
|
|
122
|
-
);
|
|
123
|
-
if (meta.maps.length)
|
|
124
|
-
insert(
|
|
125
|
-
application_native(options)(components)(`Map`)({
|
|
126
|
-
nullable: meta.nullable,
|
|
127
|
-
attribute,
|
|
128
|
-
}),
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
// OBJECT
|
|
132
|
-
for (const obj of meta.objects)
|
|
133
|
-
insert(application_object(options)(components)(obj)(meta.nullable));
|
|
134
|
-
|
|
135
|
-
// ALIASES
|
|
136
|
-
for (const alias of meta.aliases)
|
|
137
|
-
insert(
|
|
138
|
-
application_alias(options)(blockNever)(components)(alias)(
|
|
139
|
-
meta.nullable,
|
|
140
|
-
),
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
//----
|
|
144
|
-
// RETURNS
|
|
145
|
-
//----
|
|
146
|
-
if (union.length === 0)
|
|
147
|
-
return blockNever === true
|
|
148
|
-
? null!
|
|
149
|
-
: {
|
|
150
|
-
...attribute,
|
|
151
|
-
type: undefined,
|
|
152
|
-
};
|
|
153
|
-
else if (union.length === 1) return union[0]!;
|
|
154
|
-
return { oneOf: union, ...attribute };
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const NO_BIGINT = "Error on typia.application(): does not allow bigint type.";
|
|
1
|
+
import { Metadata } from "../../metadata/Metadata";
|
|
2
|
+
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
3
|
+
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
4
|
+
|
|
5
|
+
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
6
|
+
import { AtomicPredicator } from "../helpers/AtomicPredicator";
|
|
7
|
+
import { application_alias } from "./application_alias";
|
|
8
|
+
import { application_array } from "./application_array";
|
|
9
|
+
import { application_boolean } from "./application_boolean";
|
|
10
|
+
import { application_constant } from "./application_constant";
|
|
11
|
+
import { application_native } from "./application_native";
|
|
12
|
+
import { application_number } from "./application_number";
|
|
13
|
+
import { application_object } from "./application_object";
|
|
14
|
+
import { application_resolved } from "./application_resolved";
|
|
15
|
+
import { application_string } from "./application_string";
|
|
16
|
+
import { application_templates } from "./application_templates";
|
|
17
|
+
import { application_tuple } from "./application_tuple";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export const application_schema =
|
|
23
|
+
(options: ApplicationProgrammer.IOptions) =>
|
|
24
|
+
<BlockNever extends boolean>(blockNever: BlockNever) =>
|
|
25
|
+
(components: IJsonComponents) =>
|
|
26
|
+
(meta: Metadata) =>
|
|
27
|
+
(
|
|
28
|
+
attribute: IJsonSchema.IAttribute,
|
|
29
|
+
): BlockNever extends true ? IJsonSchema | null : IJsonSchema => {
|
|
30
|
+
// VULNERABLE CASE
|
|
31
|
+
if (meta.any === true)
|
|
32
|
+
return {
|
|
33
|
+
...attribute,
|
|
34
|
+
type: undefined,
|
|
35
|
+
};
|
|
36
|
+
else if (meta.nullable && meta.empty())
|
|
37
|
+
return { type: "null", ...attribute };
|
|
38
|
+
|
|
39
|
+
//----
|
|
40
|
+
// GATHER UNION SCHEMAS
|
|
41
|
+
//----
|
|
42
|
+
const union: IJsonSchema[] = [];
|
|
43
|
+
if (meta.nullable && options.purpose !== "swagger")
|
|
44
|
+
union.push({
|
|
45
|
+
...attribute,
|
|
46
|
+
type: "null",
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const insert =
|
|
50
|
+
meta.nullable && options.purpose === "swagger"
|
|
51
|
+
? (s: IJsonSchema) =>
|
|
52
|
+
union.push({
|
|
53
|
+
...s,
|
|
54
|
+
nullable: (s as IJsonSchema.ISignificant<any>).type
|
|
55
|
+
? true
|
|
56
|
+
: undefined,
|
|
57
|
+
} as IJsonSchema)
|
|
58
|
+
: (schema: IJsonSchema) => union.push(schema);
|
|
59
|
+
|
|
60
|
+
// toJSON() METHOD
|
|
61
|
+
if (meta.resolved !== null)
|
|
62
|
+
union.push(
|
|
63
|
+
...application_resolved(options)(blockNever)(components)(
|
|
64
|
+
meta.resolved,
|
|
65
|
+
)(attribute),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// ATOMIC TYPES
|
|
69
|
+
if (meta.templates.length && AtomicPredicator.template(meta))
|
|
70
|
+
insert(application_templates(meta)(attribute));
|
|
71
|
+
for (const constant of meta.constants)
|
|
72
|
+
if (constant.type === "bigint") throw new Error(NO_BIGINT);
|
|
73
|
+
else if (
|
|
74
|
+
(constant.type === "string" && meta.templates.length) ||
|
|
75
|
+
AtomicPredicator.constant(meta)(constant.type) === false
|
|
76
|
+
)
|
|
77
|
+
continue;
|
|
78
|
+
else insert(application_constant(constant)(attribute));
|
|
79
|
+
for (const type of meta.atomics)
|
|
80
|
+
if (type === "bigint") throw new Error(NO_BIGINT);
|
|
81
|
+
else if (AtomicPredicator.atomic(meta)(type) === false) continue;
|
|
82
|
+
else
|
|
83
|
+
insert(
|
|
84
|
+
type === "string"
|
|
85
|
+
? application_string(meta)(attribute)
|
|
86
|
+
: type === "boolean"
|
|
87
|
+
? application_boolean(attribute)
|
|
88
|
+
: application_number(attribute),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
// ARRAY
|
|
92
|
+
for (const array of meta.arrays)
|
|
93
|
+
insert(application_array(options)(components)(array)(attribute));
|
|
94
|
+
|
|
95
|
+
// TUPLE
|
|
96
|
+
for (const tuple of meta.tuples)
|
|
97
|
+
insert(application_tuple(options)(components)(tuple)(attribute));
|
|
98
|
+
|
|
99
|
+
// NATIVES
|
|
100
|
+
for (const native of meta.natives)
|
|
101
|
+
if (AtomicPredicator.native(native))
|
|
102
|
+
insert(
|
|
103
|
+
native === "String"
|
|
104
|
+
? application_string(meta)(attribute)
|
|
105
|
+
: native === "Boolean"
|
|
106
|
+
? application_boolean(attribute)
|
|
107
|
+
: application_number(attribute),
|
|
108
|
+
);
|
|
109
|
+
else
|
|
110
|
+
insert(
|
|
111
|
+
application_native(options)(components)(native)({
|
|
112
|
+
nullable: meta.nullable,
|
|
113
|
+
attribute,
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
if (meta.sets.length)
|
|
117
|
+
insert(
|
|
118
|
+
application_native(options)(components)(`Set`)({
|
|
119
|
+
nullable: meta.nullable,
|
|
120
|
+
attribute,
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
123
|
+
if (meta.maps.length)
|
|
124
|
+
insert(
|
|
125
|
+
application_native(options)(components)(`Map`)({
|
|
126
|
+
nullable: meta.nullable,
|
|
127
|
+
attribute,
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
// OBJECT
|
|
132
|
+
for (const obj of meta.objects)
|
|
133
|
+
insert(application_object(options)(components)(obj)(meta.nullable));
|
|
134
|
+
|
|
135
|
+
// ALIASES
|
|
136
|
+
for (const alias of meta.aliases)
|
|
137
|
+
insert(
|
|
138
|
+
application_alias(options)(blockNever)(components)(alias)(
|
|
139
|
+
meta.nullable,
|
|
140
|
+
),
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
//----
|
|
144
|
+
// RETURNS
|
|
145
|
+
//----
|
|
146
|
+
if (union.length === 0)
|
|
147
|
+
return blockNever === true
|
|
148
|
+
? null!
|
|
149
|
+
: {
|
|
150
|
+
...attribute,
|
|
151
|
+
type: undefined,
|
|
152
|
+
};
|
|
153
|
+
else if (union.length === 1) return union[0]!;
|
|
154
|
+
return { oneOf: union, ...attribute };
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const NO_BIGINT = "Error on typia.application(): does not allow bigint type.";
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { IMetadataTag } from "../../metadata/IMetadataTag";
|
|
2
|
-
import { Metadata } from "../../metadata/Metadata";
|
|
3
|
-
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
4
|
-
|
|
5
|
-
import { application_default_string } from "./application_default_string";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export const application_string =
|
|
11
|
-
(meta: Metadata) =>
|
|
12
|
-
(attribute: IJsonSchema.IAttribute): IJsonSchema.IString => {
|
|
13
|
-
const output: IJsonSchema.IString = {
|
|
14
|
-
...attribute,
|
|
15
|
-
type: "string",
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// FORMAT TAG OF METADATA
|
|
19
|
-
const formatJsdocTag = attribute["x-typia-jsDocTags"]?.find(
|
|
20
|
-
(tag) => tag.name === "format",
|
|
21
|
-
);
|
|
22
|
-
if (formatJsdocTag?.text?.length)
|
|
23
|
-
output.format = formatJsdocTag?.text.map((t) => t.text).join(" ");
|
|
24
|
-
|
|
25
|
-
// REGULAR TAGS COMPATIBLE WITH JSON-SCHEMA
|
|
26
|
-
for (const tag of attribute["x-typia-metaTags"] ?? []) {
|
|
27
|
-
// RANGE
|
|
28
|
-
if (tag.kind === "minLength") output.minLength = tag.value;
|
|
29
|
-
else if (tag.kind === "maxLength") output.maxLength = tag.value;
|
|
30
|
-
// FORMAT AND PATTERN
|
|
31
|
-
else if (tag.kind === "format")
|
|
32
|
-
output.format = emendFormat(tag.value);
|
|
33
|
-
else if (tag.kind === "pattern") output.pattern = tag.value;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// DEFAULT CONFIGURATION
|
|
37
|
-
output.default = application_default_string(meta)(attribute)(output);
|
|
38
|
-
|
|
39
|
-
// RETURNS
|
|
40
|
-
return output;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const emendFormat = (tag: IMetadataTag.IFormat["value"]) =>
|
|
44
|
-
tag === "datetime" ? "date-time" : tag;
|
|
1
|
+
import { IMetadataTag } from "../../metadata/IMetadataTag";
|
|
2
|
+
import { Metadata } from "../../metadata/Metadata";
|
|
3
|
+
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
4
|
+
|
|
5
|
+
import { application_default_string } from "./application_default_string";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export const application_string =
|
|
11
|
+
(meta: Metadata) =>
|
|
12
|
+
(attribute: IJsonSchema.IAttribute): IJsonSchema.IString => {
|
|
13
|
+
const output: IJsonSchema.IString = {
|
|
14
|
+
...attribute,
|
|
15
|
+
type: "string",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// FORMAT TAG OF METADATA
|
|
19
|
+
const formatJsdocTag = attribute["x-typia-jsDocTags"]?.find(
|
|
20
|
+
(tag) => tag.name === "format",
|
|
21
|
+
);
|
|
22
|
+
if (formatJsdocTag?.text?.length)
|
|
23
|
+
output.format = formatJsdocTag?.text.map((t) => t.text).join(" ");
|
|
24
|
+
|
|
25
|
+
// REGULAR TAGS COMPATIBLE WITH JSON-SCHEMA
|
|
26
|
+
for (const tag of attribute["x-typia-metaTags"] ?? []) {
|
|
27
|
+
// RANGE
|
|
28
|
+
if (tag.kind === "minLength") output.minLength = tag.value;
|
|
29
|
+
else if (tag.kind === "maxLength") output.maxLength = tag.value;
|
|
30
|
+
// FORMAT AND PATTERN
|
|
31
|
+
else if (tag.kind === "format")
|
|
32
|
+
output.format = emendFormat(tag.value);
|
|
33
|
+
else if (tag.kind === "pattern") output.pattern = tag.value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// DEFAULT CONFIGURATION
|
|
37
|
+
output.default = application_default_string(meta)(attribute)(output);
|
|
38
|
+
|
|
39
|
+
// RETURNS
|
|
40
|
+
return output;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const emendFormat = (tag: IMetadataTag.IFormat["value"]) =>
|
|
44
|
+
tag === "datetime" ? "date-time" : tag;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Metadata } from "../../metadata/Metadata";
|
|
2
|
-
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
3
|
-
|
|
4
|
-
import { application_default_string } from "./application_default_string";
|
|
5
|
-
import { metadata_to_pattern } from "./metadata_to_pattern";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export const application_templates =
|
|
11
|
-
(meta: Metadata) =>
|
|
12
|
-
(attribute: IJsonSchema.IAttribute): IJsonSchema.IString => {
|
|
13
|
-
// CONSTRUCT PATTERN
|
|
14
|
-
const output: IJsonSchema.IString = {
|
|
15
|
-
type: "string",
|
|
16
|
-
...attribute,
|
|
17
|
-
};
|
|
18
|
-
output.pattern = metadata_to_pattern(true)(meta);
|
|
19
|
-
|
|
20
|
-
// DEFAULT VALUE
|
|
21
|
-
output.default = application_default_string(meta)(attribute)(output);
|
|
22
|
-
|
|
23
|
-
// RETURNS
|
|
24
|
-
return output;
|
|
25
|
-
};
|
|
1
|
+
import { Metadata } from "../../metadata/Metadata";
|
|
2
|
+
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
3
|
+
|
|
4
|
+
import { application_default_string } from "./application_default_string";
|
|
5
|
+
import { metadata_to_pattern } from "./metadata_to_pattern";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export const application_templates =
|
|
11
|
+
(meta: Metadata) =>
|
|
12
|
+
(attribute: IJsonSchema.IAttribute): IJsonSchema.IString => {
|
|
13
|
+
// CONSTRUCT PATTERN
|
|
14
|
+
const output: IJsonSchema.IString = {
|
|
15
|
+
type: "string",
|
|
16
|
+
...attribute,
|
|
17
|
+
};
|
|
18
|
+
output.pattern = metadata_to_pattern(true)(meta);
|
|
19
|
+
|
|
20
|
+
// DEFAULT VALUE
|
|
21
|
+
output.default = application_default_string(meta)(attribute)(output);
|
|
22
|
+
|
|
23
|
+
// RETURNS
|
|
24
|
+
return output;
|
|
25
|
+
};
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { Metadata } from "../../metadata/Metadata";
|
|
2
|
-
import { MetadataTuple } from "../../metadata/MetadataTuple";
|
|
3
|
-
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
4
|
-
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
5
|
-
|
|
6
|
-
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
7
|
-
import { application_schema } from "./application_schema";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export const application_tuple =
|
|
13
|
-
(options: ApplicationProgrammer.IOptions) =>
|
|
14
|
-
(components: IJsonComponents) =>
|
|
15
|
-
(tuple: MetadataTuple) =>
|
|
16
|
-
(
|
|
17
|
-
attribute: IJsonSchema.IAttribute,
|
|
18
|
-
): IJsonSchema.ITuple | IJsonSchema.IArray => {
|
|
19
|
-
const schema: IJsonSchema.ITuple = {
|
|
20
|
-
type: "array",
|
|
21
|
-
items: tuple.elements.map((meta, i) =>
|
|
22
|
-
application_schema(options)(false)(components)(
|
|
23
|
-
meta.rest ?? meta,
|
|
24
|
-
)({
|
|
25
|
-
...attribute,
|
|
26
|
-
"x-typia-rest":
|
|
27
|
-
i === tuple.elements.length - 1 && meta.rest !== null,
|
|
28
|
-
"x-typia-required": meta.required,
|
|
29
|
-
"x-typia-optional": meta.optional,
|
|
30
|
-
}),
|
|
31
|
-
),
|
|
32
|
-
...attribute,
|
|
33
|
-
minItems: !!tuple.elements.at(-1)?.rest
|
|
34
|
-
? tuple.elements.length - 1
|
|
35
|
-
: tuple.elements.filter((x) => !x.optional).length,
|
|
36
|
-
maxItems: !!tuple.elements.at(-1)?.rest
|
|
37
|
-
? undefined
|
|
38
|
-
: tuple.elements.length,
|
|
39
|
-
};
|
|
40
|
-
if (options.purpose === "ajv")
|
|
41
|
-
if (tuple.elements.length === 0) return schema;
|
|
42
|
-
else if (!tuple.elements.at(-1)?.rest) return schema;
|
|
43
|
-
|
|
44
|
-
const wrapper: IJsonSchema.IArray = {
|
|
45
|
-
...schema,
|
|
46
|
-
items: application_schema(options)(false)(components)(
|
|
47
|
-
tuple.elements.reduce(
|
|
48
|
-
(x, y) => Metadata.merge(x.rest ?? x, y.rest ?? y),
|
|
49
|
-
Metadata.initialize(),
|
|
50
|
-
),
|
|
51
|
-
)(tuple.recursive ? {} : attribute),
|
|
52
|
-
"x-typia-tuple": schema,
|
|
53
|
-
minItems: schema.minItems,
|
|
54
|
-
maxItems: schema.maxItems,
|
|
55
|
-
};
|
|
56
|
-
return wrapper;
|
|
57
|
-
};
|
|
1
|
+
import { Metadata } from "../../metadata/Metadata";
|
|
2
|
+
import { MetadataTuple } from "../../metadata/MetadataTuple";
|
|
3
|
+
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
4
|
+
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
5
|
+
|
|
6
|
+
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
7
|
+
import { application_schema } from "./application_schema";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export const application_tuple =
|
|
13
|
+
(options: ApplicationProgrammer.IOptions) =>
|
|
14
|
+
(components: IJsonComponents) =>
|
|
15
|
+
(tuple: MetadataTuple) =>
|
|
16
|
+
(
|
|
17
|
+
attribute: IJsonSchema.IAttribute,
|
|
18
|
+
): IJsonSchema.ITuple | IJsonSchema.IArray => {
|
|
19
|
+
const schema: IJsonSchema.ITuple = {
|
|
20
|
+
type: "array",
|
|
21
|
+
items: tuple.elements.map((meta, i) =>
|
|
22
|
+
application_schema(options)(false)(components)(
|
|
23
|
+
meta.rest ?? meta,
|
|
24
|
+
)({
|
|
25
|
+
...attribute,
|
|
26
|
+
"x-typia-rest":
|
|
27
|
+
i === tuple.elements.length - 1 && meta.rest !== null,
|
|
28
|
+
"x-typia-required": meta.required,
|
|
29
|
+
"x-typia-optional": meta.optional,
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
...attribute,
|
|
33
|
+
minItems: !!tuple.elements.at(-1)?.rest
|
|
34
|
+
? tuple.elements.length - 1
|
|
35
|
+
: tuple.elements.filter((x) => !x.optional).length,
|
|
36
|
+
maxItems: !!tuple.elements.at(-1)?.rest
|
|
37
|
+
? undefined
|
|
38
|
+
: tuple.elements.length,
|
|
39
|
+
};
|
|
40
|
+
if (options.purpose === "ajv")
|
|
41
|
+
if (tuple.elements.length === 0) return schema;
|
|
42
|
+
else if (!tuple.elements.at(-1)?.rest) return schema;
|
|
43
|
+
|
|
44
|
+
const wrapper: IJsonSchema.IArray = {
|
|
45
|
+
...schema,
|
|
46
|
+
items: application_schema(options)(false)(components)(
|
|
47
|
+
tuple.elements.reduce(
|
|
48
|
+
(x, y) => Metadata.merge(x.rest ?? x, y.rest ?? y),
|
|
49
|
+
Metadata.initialize(),
|
|
50
|
+
),
|
|
51
|
+
)(tuple.recursive ? {} : attribute),
|
|
52
|
+
"x-typia-tuple": schema,
|
|
53
|
+
minItems: schema.minItems,
|
|
54
|
+
maxItems: schema.maxItems,
|
|
55
|
+
};
|
|
56
|
+
return wrapper;
|
|
57
|
+
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { ExpressionFactory } from "../../factories/ExpressionFactory";
|
|
4
|
-
import { IdentifierFactory } from "../../factories/IdentifierFactory";
|
|
5
|
-
|
|
6
|
-
import { IJsDocTagInfo } from "../../metadata/IJsDocTagInfo";
|
|
7
|
-
import { IMetadataTag } from "../../metadata/IMetadataTag";
|
|
8
|
-
|
|
9
|
-
import { FunctionImporter } from "../helpers/FunctionImporeter";
|
|
10
|
-
import { ICheckEntry } from "../helpers/ICheckEntry";
|
|
11
|
-
import { check_array_length } from "./check_array_length";
|
|
12
|
-
import { check_custom } from "./check_custom";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
export const check_array =
|
|
18
|
-
(importer: FunctionImporter) =>
|
|
19
|
-
(metaTags: IMetadataTag[]) =>
|
|
20
|
-
(jsDocTags: IJsDocTagInfo[]) =>
|
|
21
|
-
(input: ts.Expression): ICheckEntry => ({
|
|
22
|
-
expression: ExpressionFactory.isArray(input),
|
|
23
|
-
tags: [
|
|
24
|
-
...check_array_length(metaTags)(
|
|
25
|
-
IdentifierFactory.access(input)("length"),
|
|
26
|
-
),
|
|
27
|
-
...check_custom("array", "Array")(importer)(jsDocTags)(input),
|
|
28
|
-
// check custom array for legacy (3.7.0)
|
|
29
|
-
],
|
|
30
|
-
});
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { ExpressionFactory } from "../../factories/ExpressionFactory";
|
|
4
|
+
import { IdentifierFactory } from "../../factories/IdentifierFactory";
|
|
5
|
+
|
|
6
|
+
import { IJsDocTagInfo } from "../../metadata/IJsDocTagInfo";
|
|
7
|
+
import { IMetadataTag } from "../../metadata/IMetadataTag";
|
|
8
|
+
|
|
9
|
+
import { FunctionImporter } from "../helpers/FunctionImporeter";
|
|
10
|
+
import { ICheckEntry } from "../helpers/ICheckEntry";
|
|
11
|
+
import { check_array_length } from "./check_array_length";
|
|
12
|
+
import { check_custom } from "./check_custom";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export const check_array =
|
|
18
|
+
(importer: FunctionImporter) =>
|
|
19
|
+
(metaTags: IMetadataTag[]) =>
|
|
20
|
+
(jsDocTags: IJsDocTagInfo[]) =>
|
|
21
|
+
(input: ts.Expression): ICheckEntry => ({
|
|
22
|
+
expression: ExpressionFactory.isArray(input),
|
|
23
|
+
tags: [
|
|
24
|
+
...check_array_length(metaTags)(
|
|
25
|
+
IdentifierFactory.access(input)("length"),
|
|
26
|
+
),
|
|
27
|
+
...check_custom("array", "Array")(importer)(jsDocTags)(input),
|
|
28
|
+
// check custom array for legacy (3.7.0)
|
|
29
|
+
],
|
|
30
|
+
});
|