typia 3.4.21 → 3.4.23
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 +57 -23
- package/lib/programmers/AssertProgrammer.js +79 -70
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.d.ts +1 -0
- package/lib/programmers/IsProgrammer.js +4 -0
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +68 -59
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/OptionPredicator.d.ts +1 -0
- package/lib/programmers/helpers/OptionPredicator.js +4 -0
- package/lib/programmers/helpers/OptionPredicator.js.map +1 -1
- package/lib/programmers/internal/application_schema.js +23 -21
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/internal/check_dynamic_properties.js +5 -0
- package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
- package/lib/programmers/internal/check_object.d.ts +1 -0
- package/lib/programmers/internal/check_object.js.map +1 -1
- package/lib/transformers/ITransformOptions.d.ts +10 -0
- package/package.json +2 -2
- 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/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/functional/$every.ts +11 -11
- 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/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/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 +36 -29
- package/src/programmers/IsProgrammer.ts +5 -0
- package/src/programmers/ValidateProgrammer.ts +36 -29
- 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/OptionPredicator.ts +4 -0
- package/src/programmers/helpers/StringifyJoinder.ts +111 -111
- package/src/programmers/helpers/StringifyPredicator.ts +18 -18
- package/src/programmers/helpers/UnionPredicator.ts +81 -81
- package/src/programmers/internal/application_array.ts +47 -47
- 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_schema.ts +9 -6
- 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 -29
- package/src/programmers/internal/check_dynamic_properties.ts +164 -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 +43 -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/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 -26
- 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/ITransformOptions.ts +11 -0
- package/src/transformers/NodeTransformer.ts +19 -19
- 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,16 +1,16 @@
|
|
|
1
|
-
import { Atomic } from "../typings/Atomic";
|
|
2
|
-
|
|
3
|
-
export type IMetadataConstant =
|
|
4
|
-
| IMetadataConstant.IBase<"boolean", boolean>
|
|
5
|
-
| IMetadataConstant.IBase<"number", number>
|
|
6
|
-
| IMetadataConstant.IBase<"string", string>
|
|
7
|
-
| IMetadataConstant.IBase<"bigint", bigint>;
|
|
8
|
-
export namespace IMetadataConstant {
|
|
9
|
-
export interface IBase<
|
|
10
|
-
Type extends Atomic.Literal,
|
|
11
|
-
Value extends Atomic.Type,
|
|
12
|
-
> {
|
|
13
|
-
type: Type;
|
|
14
|
-
values: Value[];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
import { Atomic } from "../typings/Atomic";
|
|
2
|
+
|
|
3
|
+
export type IMetadataConstant =
|
|
4
|
+
| IMetadataConstant.IBase<"boolean", boolean>
|
|
5
|
+
| IMetadataConstant.IBase<"number", number>
|
|
6
|
+
| IMetadataConstant.IBase<"string", string>
|
|
7
|
+
| IMetadataConstant.IBase<"bigint", bigint>;
|
|
8
|
+
export namespace IMetadataConstant {
|
|
9
|
+
export interface IBase<
|
|
10
|
+
Type extends Atomic.Literal,
|
|
11
|
+
Value extends Atomic.Type,
|
|
12
|
+
> {
|
|
13
|
+
type: Type;
|
|
14
|
+
values: Value[];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IMetadata } from "./IMetadata";
|
|
2
|
-
|
|
3
|
-
export interface IMetadataEntry {
|
|
4
|
-
key: IMetadata;
|
|
5
|
-
value: IMetadata;
|
|
6
|
-
}
|
|
1
|
+
import { IMetadata } from "./IMetadata";
|
|
2
|
+
|
|
3
|
+
export interface IMetadataEntry {
|
|
4
|
+
key: IMetadata;
|
|
5
|
+
value: IMetadata;
|
|
6
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
2
|
-
import { IMetadataProperty } from "./IMetadataProperty";
|
|
3
|
-
|
|
4
|
-
export interface IMetadataObject {
|
|
5
|
-
name: string;
|
|
6
|
-
properties: IMetadataProperty[];
|
|
7
|
-
description?: string;
|
|
8
|
-
jsDocTags: IJsDocTagInfo[];
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
index: number;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
validated: boolean;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
recursive: boolean;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
nullables: boolean[];
|
|
29
|
-
}
|
|
1
|
+
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
2
|
+
import { IMetadataProperty } from "./IMetadataProperty";
|
|
3
|
+
|
|
4
|
+
export interface IMetadataObject {
|
|
5
|
+
name: string;
|
|
6
|
+
properties: IMetadataProperty[];
|
|
7
|
+
description?: string;
|
|
8
|
+
jsDocTags: IJsDocTagInfo[];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
index: number;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
validated: boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
recursive: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
nullables: boolean[];
|
|
29
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
2
|
-
import { IMetadata } from "./IMetadata";
|
|
3
|
-
import { IMetadataTag } from "./IMetadataTag";
|
|
4
|
-
|
|
5
|
-
export interface IMetadataProperty {
|
|
6
|
-
key: IMetadata;
|
|
7
|
-
value: IMetadata;
|
|
8
|
-
description?: string;
|
|
9
|
-
tags: IMetadataTag[];
|
|
10
|
-
jsDocTags: IJsDocTagInfo[];
|
|
11
|
-
}
|
|
1
|
+
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
2
|
+
import { IMetadata } from "./IMetadata";
|
|
3
|
+
import { IMetadataTag } from "./IMetadataTag";
|
|
4
|
+
|
|
5
|
+
export interface IMetadataProperty {
|
|
6
|
+
key: IMetadata;
|
|
7
|
+
value: IMetadata;
|
|
8
|
+
description?: string;
|
|
9
|
+
tags: IMetadataTag[];
|
|
10
|
+
jsDocTags: IJsDocTagInfo[];
|
|
11
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IMetadataConstant } from "./IMetadataConstant";
|
|
2
|
-
|
|
3
|
-
export import MetadataConstant = IMetadataConstant;
|
|
1
|
+
import { IMetadataConstant } from "./IMetadataConstant";
|
|
2
|
+
|
|
3
|
+
export import MetadataConstant = IMetadataConstant;
|
|
@@ -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
|
+
}
|