typia 3.5.0-dev.20221222 → 3.5.0-dev.20230124
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 +5 -2
- package/lib/executable/internal/TypiaSetupWizard.d.ts +6 -2
- package/lib/executable/internal/TypiaSetupWizard.js +23 -22
- package/lib/executable/internal/TypiaSetupWizard.js.map +1 -1
- package/lib/executable/typia.js +11 -10
- package/lib/executable/typia.js.map +1 -1
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.d.ts +1 -0
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js +20 -0
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js.map +1 -1
- package/lib/factories/internal/protocols/iterate_protocol_map.d.ts +2 -1
- package/lib/factories/internal/protocols/iterate_protocol_map.js +7 -4
- package/lib/factories/internal/protocols/iterate_protocol_map.js.map +1 -1
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js +3 -3
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js.map +1 -1
- package/lib/factories/internal/protocols/iterate_protocol_repeated.d.ts +2 -1
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js +5 -4
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js.map +1 -1
- package/lib/messages/IProtocolMap.d.ts +5 -0
- package/lib/messages/IProtocolMap.js +3 -0
- package/lib/messages/IProtocolMap.js.map +1 -0
- package/lib/messages/IProtocolProperty.d.ts +2 -1
- package/lib/metadata/Metadata.d.ts +1 -0
- package/lib/metadata/Metadata.js +145 -51
- package/lib/metadata/Metadata.js.map +1 -1
- package/lib/programmers/AssertProgrammer.js +1 -1
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +1 -0
- package/lib/programmers/CheckerProgrammer.js +147 -138
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/MessageProgrammer.js +7 -2
- package/lib/programmers/MessageProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +1 -1
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/UnionExplorer.d.ts +23 -29
- package/lib/programmers/helpers/UnionExplorer.js +29 -41
- package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
- package/lib/programmers/internal/application_array.js +29 -27
- package/lib/programmers/internal/application_array.js.map +1 -1
- package/lib/programmers/internal/application_object.js +96 -31
- package/lib/programmers/internal/application_object.js.map +1 -1
- package/lib/programmers/internal/application_schema.js +28 -136
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/internal/application_tuple.js +3 -2
- package/lib/programmers/internal/application_tuple.js.map +1 -1
- package/lib/programmers/internal/check_array.js +4 -32
- package/lib/programmers/internal/check_array.js.map +1 -1
- package/lib/programmers/internal/check_array_length.d.ts +1 -0
- package/lib/programmers/internal/check_array_length.js +47 -0
- package/lib/programmers/internal/check_array_length.js.map +1 -0
- package/lib/programmers/internal/check_union_array_like.d.ts +21 -0
- package/lib/programmers/internal/check_union_array_like.js +83 -0
- package/lib/programmers/internal/check_union_array_like.js.map +1 -0
- package/lib/programmers/internal/check_union_tuple.d.ts +1 -0
- package/lib/programmers/internal/check_union_tuple.js +11 -0
- package/lib/programmers/internal/check_union_tuple.js.map +1 -0
- package/lib/schemas/IJsonComponents.d.ts +4 -2
- package/lib/schemas/IJsonSchema.d.ts +2 -0
- package/package.json +4 -4
- package/src/IValidation.ts +21 -21
- package/src/Primitive.ts +82 -82
- package/src/TypeGuardError.ts +36 -36
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/internal/TypiaSetupWizard.ts +30 -21
- package/src/executable/typia.ts +48 -46
- package/src/factories/CommentFactory.ts +10 -10
- package/src/factories/ExpressionFactory.ts +66 -66
- package/src/factories/IdentifierFactory.ts +72 -72
- package/src/factories/LiteralFactory.ts +44 -44
- package/src/factories/StatementFactory.ts +60 -60
- package/src/factories/TemplateFactory.ts +56 -56
- package/src/factories/TypeFactory.ts +101 -101
- package/src/factories/ValueFactory.ts +12 -12
- package/src/factories/internal/protocols/ProtocolMetadataUtil.ts +20 -0
- package/src/factories/internal/protocols/iterate_protocol_map.ts +9 -3
- package/src/factories/internal/protocols/iterate_protocol_metadata.ts +17 -4
- package/src/factories/internal/protocols/iterate_protocol_repeated.ts +14 -5
- package/src/functional/$every.ts +11 -11
- package/src/functional/$guard.ts +35 -35
- package/src/functional/$is_email.ts +5 -5
- package/src/functional/$is_ipv4.ts +5 -5
- package/src/functional/$is_ipv6.ts +5 -5
- package/src/functional/$is_url.ts +5 -5
- package/src/functional/$is_uuid.ts +5 -5
- package/src/functional/$join.ts +50 -50
- package/src/functional/$report.ts +15 -15
- package/src/functional/$rest.ts +3 -3
- package/src/functional/$string.ts +37 -37
- package/src/functional/$tail.ts +6 -6
- package/src/index.ts +4 -4
- package/src/messages/IProtocolMap.ts +5 -0
- package/src/messages/IProtocolProperty.ts +3 -1
- package/src/metadata/IJsDocTagInfo.ts +10 -10
- package/src/metadata/IMetadata.ts +25 -25
- package/src/metadata/IMetadataApplication.ts +7 -7
- package/src/metadata/IMetadataConstant.ts +16 -16
- package/src/metadata/IMetadataEntry.ts +6 -6
- package/src/metadata/IMetadataObject.ts +29 -29
- package/src/metadata/IMetadataProperty.ts +11 -11
- package/src/metadata/Metadata.ts +64 -7
- package/src/metadata/MetadataConstant.ts +3 -3
- package/src/metadata/MetadataObject.ts +131 -131
- package/src/metadata/MetadataProperty.ts +64 -64
- package/src/programmers/ApplicationProgrammer.ts +55 -55
- package/src/programmers/AssertProgrammer.ts +1 -1
- package/src/programmers/CheckerProgrammer.ts +252 -200
- package/src/programmers/FeatureProgrammer.ts +327 -327
- package/src/programmers/MessageProgrammer.ts +9 -2
- package/src/programmers/ValidateProgrammer.ts +1 -1
- package/src/programmers/helpers/AtomicPredicator.ts +15 -15
- package/src/programmers/helpers/FunctionImporeter.ts +31 -31
- package/src/programmers/helpers/IExpressionEntry.ts +10 -10
- package/src/programmers/helpers/StringifyJoinder.ts +111 -111
- package/src/programmers/helpers/StringifyPredicator.ts +18 -18
- package/src/programmers/helpers/UnionExplorer.ts +274 -437
- package/src/programmers/helpers/UnionPredicator.ts +81 -81
- package/src/programmers/internal/application_array.ts +47 -45
- package/src/programmers/internal/application_boolean.ts +17 -17
- package/src/programmers/internal/application_constant.ts +29 -29
- package/src/programmers/internal/application_default_string.ts +32 -32
- package/src/programmers/internal/application_native.ts +29 -29
- package/src/programmers/internal/application_number.ts +76 -76
- package/src/programmers/internal/application_object.ts +153 -103
- package/src/programmers/internal/application_schema.ts +15 -68
- package/src/programmers/internal/application_string.ts +49 -49
- package/src/programmers/internal/application_templates.ts +27 -27
- package/src/programmers/internal/application_tuple.ts +29 -25
- package/src/programmers/internal/check_array.ts +22 -44
- package/src/programmers/internal/check_array_length.ts +45 -0
- package/src/programmers/internal/check_dynamic_properties.ts +146 -146
- package/src/programmers/internal/check_everything.ts +25 -25
- package/src/programmers/internal/check_length.ts +46 -46
- package/src/programmers/internal/check_native.ts +9 -9
- package/src/programmers/internal/check_object.ts +42 -42
- package/src/programmers/internal/check_string.ts +24 -24
- package/src/programmers/internal/check_string_tags.ts +63 -63
- package/src/programmers/internal/check_template.ts +50 -50
- package/src/programmers/internal/check_union_array_like.ts +242 -0
- package/src/programmers/internal/check_union_tuple.ts +33 -0
- package/src/programmers/internal/decode_union_object.ts +73 -73
- package/src/programmers/internal/feature_object_entries.ts +49 -49
- package/src/programmers/internal/metadata_to_pattern.ts +31 -31
- package/src/programmers/internal/stringify_dynamic_properties.ts +164 -164
- package/src/programmers/internal/stringify_native.ts +8 -8
- package/src/programmers/internal/stringify_regular_properties.ts +81 -81
- package/src/programmers/internal/template_to_pattern.ts +15 -15
- package/src/schemas/IJsonApplication.ts +9 -9
- package/src/schemas/IJsonComponents.ts +26 -24
- package/src/schemas/IJsonSchema.ts +2 -0
- package/src/transform.ts +20 -20
- package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
- package/src/transformers/FileTransformer.ts +49 -49
- package/src/transformers/IProject.ts +11 -11
- package/src/transformers/NodeTransformer.ts +19 -19
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +1 -0
- package/src/transformers/features/miscellaneous/MetadataTransformer.ts +55 -55
- package/src/transformers/features/parsers/AssertParseTransformer.ts +36 -36
- package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +32 -32
- package/src/transformers/features/parsers/CreateIsParseTransformer.ts +32 -32
- package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +32 -32
- package/src/transformers/features/parsers/IsParseTransformer.ts +36 -36
- package/src/transformers/features/parsers/ValidateParseTransformer.ts +36 -36
- package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +38 -38
- package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +32 -32
- package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +32 -32
- package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +31 -31
- package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +32 -32
- package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +38 -38
- package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +38 -38
- package/src/transformers/features/validators/AssertTransformer.ts +43 -43
- package/src/transformers/features/validators/CreateAssertTransformer.ts +35 -35
- package/src/transformers/features/validators/CreateIsTransformer.ts +35 -35
- package/src/transformers/features/validators/CreateValidateTransformer.ts +35 -35
- package/src/transformers/features/validators/IsTransformer.ts +43 -43
- package/src/transformers/features/validators/ValidateTransformer.ts +43 -43
- package/src/typings/Atomic.ts +17 -17
- package/src/typings/ClassProperties.ts +5 -5
- package/src/typings/OmitNever.ts +3 -3
- package/src/typings/SpecialFields.ts +3 -3
- package/src/typings/Writable.ts +11 -11
- package/src/utils/ArrayUtil.ts +49 -49
- package/src/utils/Escaper.ts +50 -50
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/PatternUtil.ts +30 -30
- package/src/utils/Singleton.ts +17 -17
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
import { ClassProperties } from "../typings/ClassProperties";
|
|
2
|
-
|
|
3
|
-
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
4
|
-
import { IMetadataObject } from "./IMetadataObject";
|
|
5
|
-
import { MetadataProperty } from "./MetadataProperty";
|
|
6
|
-
|
|
7
|
-
export class MetadataObject {
|
|
8
|
-
public readonly name: string;
|
|
9
|
-
public readonly properties: Array<MetadataProperty>;
|
|
10
|
-
public readonly description: string | undefined;
|
|
11
|
-
public readonly jsDocTags: IJsDocTagInfo[];
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
public readonly index: number;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
public validated: boolean;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
public recursive: boolean;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
public nullables: boolean[] = [];
|
|
32
|
-
|
|
33
|
-
/* -----------------------------------------------------------
|
|
34
|
-
CONSTRUCTORS
|
|
35
|
-
----------------------------------------------------------- */
|
|
36
|
-
/**
|
|
37
|
-
* @hidden
|
|
38
|
-
*/
|
|
39
|
-
private constructor(props: ClassProperties<MetadataObject>) {
|
|
40
|
-
this.name = props.name;
|
|
41
|
-
this.properties = props.properties;
|
|
42
|
-
this.description = props.description;
|
|
43
|
-
this.jsDocTags = props.jsDocTags;
|
|
44
|
-
|
|
45
|
-
this.index = props.index;
|
|
46
|
-
this.validated = props.validated;
|
|
47
|
-
this.recursive = false;
|
|
48
|
-
this.nullables = [];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
public static create(props: ClassProperties<MetadataObject>) {
|
|
55
|
-
return new MetadataObject(props);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @internal
|
|
60
|
-
*/
|
|
61
|
-
public static _From_without_properties(
|
|
62
|
-
obj: IMetadataObject,
|
|
63
|
-
): MetadataObject {
|
|
64
|
-
return this.create({
|
|
65
|
-
name: obj.name,
|
|
66
|
-
properties: [],
|
|
67
|
-
description: obj.description,
|
|
68
|
-
jsDocTags: obj.jsDocTags,
|
|
69
|
-
|
|
70
|
-
index: obj.index,
|
|
71
|
-
validated: obj.validated,
|
|
72
|
-
recursive: obj.recursive,
|
|
73
|
-
nullables: obj.nullables.slice(),
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @internal
|
|
79
|
-
*/
|
|
80
|
-
public _Is_simple(): boolean {
|
|
81
|
-
return (
|
|
82
|
-
this.properties.length < 4 &&
|
|
83
|
-
this.properties.every(
|
|
84
|
-
(property) =>
|
|
85
|
-
property.key.isSoleLiteral() &&
|
|
86
|
-
property.value.size() === 1 &&
|
|
87
|
-
property.value.atomics.length === 1 &&
|
|
88
|
-
property.value.nullable === false &&
|
|
89
|
-
property.value.required === true,
|
|
90
|
-
)
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
public toJSON(): IMetadataObject {
|
|
95
|
-
return {
|
|
96
|
-
name: this.name,
|
|
97
|
-
properties: this.properties.map((property) => property.toJSON()),
|
|
98
|
-
description: this.description,
|
|
99
|
-
jsDocTags: this.jsDocTags,
|
|
100
|
-
|
|
101
|
-
index: this.index,
|
|
102
|
-
validated: this.validated,
|
|
103
|
-
recursive: this.recursive,
|
|
104
|
-
nullables: this.nullables.slice(),
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @internal
|
|
111
|
-
*/
|
|
112
|
-
export namespace MetadataObject {
|
|
113
|
-
export function intersects(x: MetadataObject, y: MetadataObject): boolean {
|
|
114
|
-
return x.properties.some(
|
|
115
|
-
(prop) =>
|
|
116
|
-
y.properties.find((oppo) => prop.key === oppo.key) !==
|
|
117
|
-
undefined,
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export function covers(x: MetadataObject, y: MetadataObject): boolean {
|
|
122
|
-
return (
|
|
123
|
-
x.properties.length >= y.properties.length &&
|
|
124
|
-
x.properties.every(
|
|
125
|
-
(prop) =>
|
|
126
|
-
y.properties.find((oppo) => prop.key === oppo.key) !==
|
|
127
|
-
undefined,
|
|
128
|
-
)
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
1
|
+
import { ClassProperties } from "../typings/ClassProperties";
|
|
2
|
+
|
|
3
|
+
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
4
|
+
import { IMetadataObject } from "./IMetadataObject";
|
|
5
|
+
import { MetadataProperty } from "./MetadataProperty";
|
|
6
|
+
|
|
7
|
+
export class MetadataObject {
|
|
8
|
+
public readonly name: string;
|
|
9
|
+
public readonly properties: Array<MetadataProperty>;
|
|
10
|
+
public readonly description: string | undefined;
|
|
11
|
+
public readonly jsDocTags: IJsDocTagInfo[];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
public readonly index: number;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
public validated: boolean;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
public recursive: boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
public nullables: boolean[] = [];
|
|
32
|
+
|
|
33
|
+
/* -----------------------------------------------------------
|
|
34
|
+
CONSTRUCTORS
|
|
35
|
+
----------------------------------------------------------- */
|
|
36
|
+
/**
|
|
37
|
+
* @hidden
|
|
38
|
+
*/
|
|
39
|
+
private constructor(props: ClassProperties<MetadataObject>) {
|
|
40
|
+
this.name = props.name;
|
|
41
|
+
this.properties = props.properties;
|
|
42
|
+
this.description = props.description;
|
|
43
|
+
this.jsDocTags = props.jsDocTags;
|
|
44
|
+
|
|
45
|
+
this.index = props.index;
|
|
46
|
+
this.validated = props.validated;
|
|
47
|
+
this.recursive = false;
|
|
48
|
+
this.nullables = [];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
public static create(props: ClassProperties<MetadataObject>) {
|
|
55
|
+
return new MetadataObject(props);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
public static _From_without_properties(
|
|
62
|
+
obj: IMetadataObject,
|
|
63
|
+
): MetadataObject {
|
|
64
|
+
return this.create({
|
|
65
|
+
name: obj.name,
|
|
66
|
+
properties: [],
|
|
67
|
+
description: obj.description,
|
|
68
|
+
jsDocTags: obj.jsDocTags,
|
|
69
|
+
|
|
70
|
+
index: obj.index,
|
|
71
|
+
validated: obj.validated,
|
|
72
|
+
recursive: obj.recursive,
|
|
73
|
+
nullables: obj.nullables.slice(),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
public _Is_simple(): boolean {
|
|
81
|
+
return (
|
|
82
|
+
this.properties.length < 4 &&
|
|
83
|
+
this.properties.every(
|
|
84
|
+
(property) =>
|
|
85
|
+
property.key.isSoleLiteral() &&
|
|
86
|
+
property.value.size() === 1 &&
|
|
87
|
+
property.value.atomics.length === 1 &&
|
|
88
|
+
property.value.nullable === false &&
|
|
89
|
+
property.value.required === true,
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public toJSON(): IMetadataObject {
|
|
95
|
+
return {
|
|
96
|
+
name: this.name,
|
|
97
|
+
properties: this.properties.map((property) => property.toJSON()),
|
|
98
|
+
description: this.description,
|
|
99
|
+
jsDocTags: this.jsDocTags,
|
|
100
|
+
|
|
101
|
+
index: this.index,
|
|
102
|
+
validated: this.validated,
|
|
103
|
+
recursive: this.recursive,
|
|
104
|
+
nullables: this.nullables.slice(),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
export namespace MetadataObject {
|
|
113
|
+
export function intersects(x: MetadataObject, y: MetadataObject): boolean {
|
|
114
|
+
return x.properties.some(
|
|
115
|
+
(prop) =>
|
|
116
|
+
y.properties.find((oppo) => prop.key === oppo.key) !==
|
|
117
|
+
undefined,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function covers(x: MetadataObject, y: MetadataObject): boolean {
|
|
122
|
+
return (
|
|
123
|
+
x.properties.length >= y.properties.length &&
|
|
124
|
+
x.properties.every(
|
|
125
|
+
(prop) =>
|
|
126
|
+
y.properties.find((oppo) => prop.key === oppo.key) !==
|
|
127
|
+
undefined,
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { ClassProperties } from "../typings/ClassProperties";
|
|
2
|
-
|
|
3
|
-
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
4
|
-
import { IMetadataProperty } from "./IMetadataProperty";
|
|
5
|
-
import { IMetadataTag } from "./IMetadataTag";
|
|
6
|
-
import { Metadata } from "./Metadata";
|
|
7
|
-
import { MetadataObject } from "./MetadataObject";
|
|
8
|
-
|
|
9
|
-
export class MetadataProperty {
|
|
10
|
-
public readonly key: Metadata;
|
|
11
|
-
public readonly value: Metadata;
|
|
12
|
-
public readonly description: string | undefined;
|
|
13
|
-
public readonly tags: IMetadataTag[];
|
|
14
|
-
public readonly jsDocTags: IJsDocTagInfo[];
|
|
15
|
-
|
|
16
|
-
/* -----------------------------------------------------------
|
|
17
|
-
CONSTRUCTORS
|
|
18
|
-
----------------------------------------------------------- */
|
|
19
|
-
/**
|
|
20
|
-
* @hidden
|
|
21
|
-
*/
|
|
22
|
-
private constructor(props: ClassProperties<MetadataProperty>) {
|
|
23
|
-
this.key = props.key;
|
|
24
|
-
this.value = props.value;
|
|
25
|
-
this.description = props.description;
|
|
26
|
-
this.tags = props.tags;
|
|
27
|
-
this.jsDocTags = props.jsDocTags;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
public static create(
|
|
34
|
-
props: ClassProperties<MetadataProperty>,
|
|
35
|
-
): MetadataProperty {
|
|
36
|
-
return new MetadataProperty(props);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
|
-
public static _From(
|
|
43
|
-
property: IMetadataProperty,
|
|
44
|
-
objects: Map<string, MetadataObject>,
|
|
45
|
-
) {
|
|
46
|
-
return this.create({
|
|
47
|
-
key: Metadata._From(property.key, objects),
|
|
48
|
-
value: Metadata._From(property.value, objects),
|
|
49
|
-
description: property.description,
|
|
50
|
-
tags: property.tags.slice(),
|
|
51
|
-
jsDocTags: property.jsDocTags.slice(),
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public toJSON(): IMetadataProperty {
|
|
56
|
-
return {
|
|
57
|
-
key: this.key.toJSON(),
|
|
58
|
-
value: this.value.toJSON(),
|
|
59
|
-
description: this.description,
|
|
60
|
-
tags: this.tags,
|
|
61
|
-
jsDocTags: this.jsDocTags,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
import { ClassProperties } from "../typings/ClassProperties";
|
|
2
|
+
|
|
3
|
+
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
4
|
+
import { IMetadataProperty } from "./IMetadataProperty";
|
|
5
|
+
import { IMetadataTag } from "./IMetadataTag";
|
|
6
|
+
import { Metadata } from "./Metadata";
|
|
7
|
+
import { MetadataObject } from "./MetadataObject";
|
|
8
|
+
|
|
9
|
+
export class MetadataProperty {
|
|
10
|
+
public readonly key: Metadata;
|
|
11
|
+
public readonly value: Metadata;
|
|
12
|
+
public readonly description: string | undefined;
|
|
13
|
+
public readonly tags: IMetadataTag[];
|
|
14
|
+
public readonly jsDocTags: IJsDocTagInfo[];
|
|
15
|
+
|
|
16
|
+
/* -----------------------------------------------------------
|
|
17
|
+
CONSTRUCTORS
|
|
18
|
+
----------------------------------------------------------- */
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
private constructor(props: ClassProperties<MetadataProperty>) {
|
|
23
|
+
this.key = props.key;
|
|
24
|
+
this.value = props.value;
|
|
25
|
+
this.description = props.description;
|
|
26
|
+
this.tags = props.tags;
|
|
27
|
+
this.jsDocTags = props.jsDocTags;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
public static create(
|
|
34
|
+
props: ClassProperties<MetadataProperty>,
|
|
35
|
+
): MetadataProperty {
|
|
36
|
+
return new MetadataProperty(props);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
public static _From(
|
|
43
|
+
property: IMetadataProperty,
|
|
44
|
+
objects: Map<string, MetadataObject>,
|
|
45
|
+
) {
|
|
46
|
+
return this.create({
|
|
47
|
+
key: Metadata._From(property.key, objects),
|
|
48
|
+
value: Metadata._From(property.value, objects),
|
|
49
|
+
description: property.description,
|
|
50
|
+
tags: property.tags.slice(),
|
|
51
|
+
jsDocTags: property.jsDocTags.slice(),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public toJSON(): IMetadataProperty {
|
|
56
|
+
return {
|
|
57
|
+
key: this.key.toJSON(),
|
|
58
|
+
value: this.value.toJSON(),
|
|
59
|
+
description: this.description,
|
|
60
|
+
tags: this.tags,
|
|
61
|
+
jsDocTags: this.jsDocTags,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { Metadata } from "../metadata/Metadata";
|
|
2
|
-
import { IJsonApplication } from "../schemas/IJsonApplication";
|
|
3
|
-
import { IJsonComponents } from "../schemas/IJsonComponents";
|
|
4
|
-
import { IJsonSchema } from "../schemas/IJsonSchema";
|
|
5
|
-
|
|
6
|
-
import { application_schema } from "./internal/application_schema";
|
|
7
|
-
|
|
8
|
-
export namespace ApplicationProgrammer {
|
|
9
|
-
export const AJV_PREFIX = "components#/schemas";
|
|
10
|
-
export const SWAGGER_PREFIX = "#/components/schemas";
|
|
11
|
-
|
|
12
|
-
export interface IOptions {
|
|
13
|
-
purpose: "swagger" | "ajv";
|
|
14
|
-
prefix: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
export namespace IOptions {
|
|
21
|
-
export function complement(options?: Partial<IOptions>): IOptions {
|
|
22
|
-
const purpose: "swagger" | "ajv" = options?.purpose ?? "swagger";
|
|
23
|
-
return {
|
|
24
|
-
purpose,
|
|
25
|
-
prefix:
|
|
26
|
-
options?.prefix ||
|
|
27
|
-
(purpose === "swagger" ? SWAGGER_PREFIX : AJV_PREFIX),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function generate(
|
|
33
|
-
metadatas: Array<Metadata>,
|
|
34
|
-
options?: Partial<IOptions>,
|
|
35
|
-
): IJsonApplication {
|
|
36
|
-
const fullOptions: IOptions = IOptions.complement(options);
|
|
37
|
-
const components: IJsonComponents = {
|
|
38
|
-
schemas: {},
|
|
39
|
-
};
|
|
40
|
-
const generator = application_schema(fullOptions)(components)(true);
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
schemas: metadatas.map((meta, i) => {
|
|
44
|
-
const schema: IJsonSchema | null = generator(meta, {});
|
|
45
|
-
if (schema === null)
|
|
46
|
-
throw new Error(
|
|
47
|
-
`Error on typia.application(): invalid type on argument - (${meta.getName()}, ${i})`,
|
|
48
|
-
);
|
|
49
|
-
return schema;
|
|
50
|
-
}),
|
|
51
|
-
components,
|
|
52
|
-
...fullOptions,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
import { Metadata } from "../metadata/Metadata";
|
|
2
|
+
import { IJsonApplication } from "../schemas/IJsonApplication";
|
|
3
|
+
import { IJsonComponents } from "../schemas/IJsonComponents";
|
|
4
|
+
import { IJsonSchema } from "../schemas/IJsonSchema";
|
|
5
|
+
|
|
6
|
+
import { application_schema } from "./internal/application_schema";
|
|
7
|
+
|
|
8
|
+
export namespace ApplicationProgrammer {
|
|
9
|
+
export const AJV_PREFIX = "components#/schemas";
|
|
10
|
+
export const SWAGGER_PREFIX = "#/components/schemas";
|
|
11
|
+
|
|
12
|
+
export interface IOptions {
|
|
13
|
+
purpose: "swagger" | "ajv";
|
|
14
|
+
prefix: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export namespace IOptions {
|
|
21
|
+
export function complement(options?: Partial<IOptions>): IOptions {
|
|
22
|
+
const purpose: "swagger" | "ajv" = options?.purpose ?? "swagger";
|
|
23
|
+
return {
|
|
24
|
+
purpose,
|
|
25
|
+
prefix:
|
|
26
|
+
options?.prefix ||
|
|
27
|
+
(purpose === "swagger" ? SWAGGER_PREFIX : AJV_PREFIX),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function generate(
|
|
33
|
+
metadatas: Array<Metadata>,
|
|
34
|
+
options?: Partial<IOptions>,
|
|
35
|
+
): IJsonApplication {
|
|
36
|
+
const fullOptions: IOptions = IOptions.complement(options);
|
|
37
|
+
const components: IJsonComponents = {
|
|
38
|
+
schemas: {},
|
|
39
|
+
};
|
|
40
|
+
const generator = application_schema(fullOptions)(components)(true);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
schemas: metadatas.map((meta, i) => {
|
|
44
|
+
const schema: IJsonSchema | null = generator(meta, {});
|
|
45
|
+
if (schema === null)
|
|
46
|
+
throw new Error(
|
|
47
|
+
`Error on typia.application(): invalid type on argument - (${meta.getName()}, ${i})`,
|
|
48
|
+
);
|
|
49
|
+
return schema;
|
|
50
|
+
}),
|
|
51
|
+
components,
|
|
52
|
+
...fullOptions,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -280,7 +280,7 @@ export namespace AssertProgrammer {
|
|
|
280
280
|
(equals: boolean) =>
|
|
281
281
|
(importer: FunctionImporter): CheckerProgrammer.IConfig.Combiner =>
|
|
282
282
|
(explore: CheckerProgrammer.IExplore) => {
|
|
283
|
-
if (explore.tracable === false
|
|
283
|
+
if (explore.tracable === false)
|
|
284
284
|
return IsProgrammer.CONFIG({
|
|
285
285
|
object: assert_object(equals)(importer),
|
|
286
286
|
numeric: true,
|