typia 6.7.2 → 6.8.0-dev.20240811
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/lib/programmers/internal/application_bigint.d.ts +1 -0
- package/lib/programmers/internal/application_bigint.js +14 -0
- package/lib/programmers/internal/application_bigint.js.map +1 -0
- package/lib/programmers/internal/application_v30_schema.js +10 -12
- package/lib/programmers/internal/application_v30_schema.js.map +1 -1
- package/lib/programmers/internal/application_v31_constant.js +3 -1
- package/lib/programmers/internal/application_v31_constant.js.map +1 -1
- package/lib/programmers/internal/application_v31_schema.js +10 -12
- package/lib/programmers/internal/application_v31_schema.js.map +1 -1
- package/lib/tags/Constant.d.ts +2 -2
- package/lib/tags/Default.d.ts +5 -1
- package/lib/tags/ExclusiveMaximum.d.ts +9 -5
- package/lib/tags/ExclusiveMinimum.d.ts +9 -5
- package/lib/tags/JsonSchemaPlugin.d.ts +1 -1
- package/lib/tags/Maximum.d.ts +8 -5
- package/lib/tags/Minimum.d.ts +8 -5
- package/lib/tags/MultipleOf.d.ts +7 -4
- package/package.json +2 -2
- package/src/factories/CommentFactory.ts +79 -79
- package/src/factories/MetadataCollection.ts +274 -274
- package/src/factories/MetadataFactory.ts +272 -272
- package/src/factories/StatementFactory.ts +74 -74
- package/src/factories/TypeFactory.ts +118 -118
- package/src/factories/internal/metadata/emplace_metadata_array_type.ts +42 -42
- package/src/factories/internal/metadata/emplace_metadata_object.ts +176 -176
- package/src/factories/internal/metadata/iterate_metadata.ts +94 -94
- package/src/factories/internal/metadata/iterate_metadata_array.ts +63 -63
- package/src/factories/internal/metadata/iterate_metadata_atomic.ts +62 -62
- package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_constant.ts +76 -76
- package/src/factories/internal/metadata/iterate_metadata_intersection.ts +213 -213
- package/src/factories/internal/metadata/iterate_metadata_map.ts +50 -50
- package/src/factories/internal/metadata/iterate_metadata_native.ts +220 -220
- package/src/factories/internal/metadata/iterate_metadata_object.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_set.ts +41 -41
- package/src/factories/internal/metadata/iterate_metadata_template.ts +44 -44
- package/src/factories/internal/metadata/iterate_metadata_union.ts +27 -27
- package/src/programmers/internal/application_bigint.ts +25 -0
- package/src/programmers/internal/application_v30_alias.ts +52 -52
- package/src/programmers/internal/application_v30_object.ts +149 -149
- package/src/programmers/internal/application_v30_schema.ts +162 -159
- package/src/programmers/internal/application_v30_tuple.ts +33 -33
- package/src/programmers/internal/application_v31_constant.ts +4 -1
- package/src/programmers/internal/application_v31_schema.ts +159 -157
- package/src/programmers/json/JsonApplicationProgrammer.ts +82 -82
- package/src/schemas/metadata/IMetadataConstantValue.ts +11 -11
- package/src/schemas/metadata/IMetadataTemplate.ts +7 -7
- package/src/tags/Constant.ts +2 -2
- package/src/tags/Default.ts +7 -3
- package/src/tags/ExclusiveMaximum.ts +12 -6
- package/src/tags/ExclusiveMinimum.ts +12 -6
- package/src/tags/JsonSchemaPlugin.ts +1 -1
- package/src/tags/Maximum.ts +9 -8
- package/src/tags/Minimum.ts +9 -8
- package/src/tags/MultipleOf.ts +9 -8
- package/src/tags/Type.ts +32 -32
- package/src/transformers/FileTransformer.ts +91 -91
- package/src/transformers/features/CreateRandomTransformer.ts +40 -40
- package/src/transformers/features/RandomTransformer.ts +44 -44
- package/src/transformers/features/json/JsonApplicationTransformer.ts +124 -124
- package/src/transformers/features/misc/MiscLiteralsTransformer.ts +32 -32
- package/src/transformers/features/protobuf/ProtobufMessageTransformer.ts +33 -33
- package/src/transformers/features/reflect/ReflectMetadataTransformer.ts +62 -62
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataAtomic } from "../../../schemas/metadata/MetadataAtomic";
|
|
5
|
-
|
|
6
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
7
|
-
|
|
8
|
-
const same = (type: ts.Type | null) => {
|
|
9
|
-
if (type === null) return () => false;
|
|
10
|
-
return (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const iterate_metadata_atomic = (
|
|
14
|
-
meta: Metadata,
|
|
15
|
-
type: ts.Type,
|
|
16
|
-
): boolean => {
|
|
17
|
-
// PREPARE INTERNAL FUNCTIONS
|
|
18
|
-
const filter = same(type);
|
|
19
|
-
const check = (info: IAtomicInfo) => {
|
|
20
|
-
if (filter(info.atomic) || filter(info.literal)) {
|
|
21
|
-
ArrayUtil.add(
|
|
22
|
-
meta.atomics,
|
|
23
|
-
MetadataAtomic.create({ type: info.name, tags: [] }),
|
|
24
|
-
(x, y) => x.type === y.type,
|
|
25
|
-
);
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// CHECK EACH TYPES
|
|
32
|
-
return ATOMICS.some((info) => check(info));
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const ATOMICS: IAtomicInfo[] = [
|
|
36
|
-
{
|
|
37
|
-
name: "boolean",
|
|
38
|
-
atomic: ts.TypeFlags.BooleanLike,
|
|
39
|
-
literal: ts.TypeFlags.BooleanLiteral,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: "number",
|
|
43
|
-
atomic: ts.TypeFlags.NumberLike,
|
|
44
|
-
literal: ts.TypeFlags.NumberLiteral,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: "bigint",
|
|
48
|
-
atomic: ts.TypeFlags.BigInt,
|
|
49
|
-
literal: ts.TypeFlags.BigIntLiteral,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: "string",
|
|
53
|
-
atomic: ts.TypeFlags.StringLike,
|
|
54
|
-
literal: ts.TypeFlags.StringLiteral,
|
|
55
|
-
},
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
interface IAtomicInfo {
|
|
59
|
-
name: "boolean" | "number" | "bigint" | "string";
|
|
60
|
-
atomic: ts.TypeFlags;
|
|
61
|
-
literal: ts.TypeFlags;
|
|
62
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataAtomic } from "../../../schemas/metadata/MetadataAtomic";
|
|
5
|
+
|
|
6
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
7
|
+
|
|
8
|
+
const same = (type: ts.Type | null) => {
|
|
9
|
+
if (type === null) return () => false;
|
|
10
|
+
return (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const iterate_metadata_atomic = (
|
|
14
|
+
meta: Metadata,
|
|
15
|
+
type: ts.Type,
|
|
16
|
+
): boolean => {
|
|
17
|
+
// PREPARE INTERNAL FUNCTIONS
|
|
18
|
+
const filter = same(type);
|
|
19
|
+
const check = (info: IAtomicInfo) => {
|
|
20
|
+
if (filter(info.atomic) || filter(info.literal)) {
|
|
21
|
+
ArrayUtil.add(
|
|
22
|
+
meta.atomics,
|
|
23
|
+
MetadataAtomic.create({ type: info.name, tags: [] }),
|
|
24
|
+
(x, y) => x.type === y.type,
|
|
25
|
+
);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// CHECK EACH TYPES
|
|
32
|
+
return ATOMICS.some((info) => check(info));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const ATOMICS: IAtomicInfo[] = [
|
|
36
|
+
{
|
|
37
|
+
name: "boolean",
|
|
38
|
+
atomic: ts.TypeFlags.BooleanLike,
|
|
39
|
+
literal: ts.TypeFlags.BooleanLiteral,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "number",
|
|
43
|
+
atomic: ts.TypeFlags.NumberLike,
|
|
44
|
+
literal: ts.TypeFlags.NumberLiteral,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "bigint",
|
|
48
|
+
atomic: ts.TypeFlags.BigInt,
|
|
49
|
+
literal: ts.TypeFlags.BigIntLiteral,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "string",
|
|
53
|
+
atomic: ts.TypeFlags.StringLike,
|
|
54
|
+
literal: ts.TypeFlags.StringLiteral,
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
interface IAtomicInfo {
|
|
59
|
+
name: "boolean" | "number" | "bigint" | "string";
|
|
60
|
+
atomic: ts.TypeFlags;
|
|
61
|
+
literal: ts.TypeFlags;
|
|
62
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { Writable } from "../../../typings/Writable";
|
|
6
|
-
|
|
7
|
-
import { TypeFactory } from "../../TypeFactory";
|
|
8
|
-
|
|
9
|
-
export const iterate_metadata_coalesce = (
|
|
10
|
-
meta: Metadata,
|
|
11
|
-
type: ts.Type,
|
|
12
|
-
): boolean => {
|
|
13
|
-
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
14
|
-
if (filter(ts.TypeFlags.Unknown) || filter(ts.TypeFlags.Any)) {
|
|
15
|
-
Writable(meta).any = true;
|
|
16
|
-
return true;
|
|
17
|
-
} else if (filter(ts.TypeFlags.Null)) {
|
|
18
|
-
Writable(meta).nullable = true;
|
|
19
|
-
return true;
|
|
20
|
-
} else if (
|
|
21
|
-
filter(ts.TypeFlags.Undefined) ||
|
|
22
|
-
filter(ts.TypeFlags.Never) ||
|
|
23
|
-
filter(ts.TypeFlags.Void) ||
|
|
24
|
-
filter(ts.TypeFlags.VoidLike)
|
|
25
|
-
) {
|
|
26
|
-
Writable(meta).required = false;
|
|
27
|
-
return true;
|
|
28
|
-
} else if (TypeFactory.isFunction(type) === true) {
|
|
29
|
-
Writable(meta).functional = true;
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
return false;
|
|
33
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { Writable } from "../../../typings/Writable";
|
|
6
|
+
|
|
7
|
+
import { TypeFactory } from "../../TypeFactory";
|
|
8
|
+
|
|
9
|
+
export const iterate_metadata_coalesce = (
|
|
10
|
+
meta: Metadata,
|
|
11
|
+
type: ts.Type,
|
|
12
|
+
): boolean => {
|
|
13
|
+
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
14
|
+
if (filter(ts.TypeFlags.Unknown) || filter(ts.TypeFlags.Any)) {
|
|
15
|
+
Writable(meta).any = true;
|
|
16
|
+
return true;
|
|
17
|
+
} else if (filter(ts.TypeFlags.Null)) {
|
|
18
|
+
Writable(meta).nullable = true;
|
|
19
|
+
return true;
|
|
20
|
+
} else if (
|
|
21
|
+
filter(ts.TypeFlags.Undefined) ||
|
|
22
|
+
filter(ts.TypeFlags.Never) ||
|
|
23
|
+
filter(ts.TypeFlags.Void) ||
|
|
24
|
+
filter(ts.TypeFlags.VoidLike)
|
|
25
|
+
) {
|
|
26
|
+
Writable(meta).required = false;
|
|
27
|
+
return true;
|
|
28
|
+
} else if (TypeFactory.isFunction(type) === true) {
|
|
29
|
+
Writable(meta).functional = true;
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataConstant } from "../../../schemas/metadata/MetadataConstant";
|
|
5
|
-
import { MetadataConstantValue } from "../../../schemas/metadata/MetadataConstantValue";
|
|
6
|
-
|
|
7
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
8
|
-
|
|
9
|
-
import { CommentFactory } from "../../CommentFactory";
|
|
10
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
11
|
-
|
|
12
|
-
export const iterate_metadata_constant =
|
|
13
|
-
(checker: ts.TypeChecker) =>
|
|
14
|
-
(options: MetadataFactory.IOptions) =>
|
|
15
|
-
(meta: Metadata, type: ts.Type): boolean => {
|
|
16
|
-
if (!options.constant) return false;
|
|
17
|
-
|
|
18
|
-
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
19
|
-
const comment = () => {
|
|
20
|
-
if (!filter(ts.TypeFlags.EnumLiteral)) return {};
|
|
21
|
-
return {
|
|
22
|
-
jsDocTags: type.symbol?.getJsDocTags(),
|
|
23
|
-
description: type.symbol
|
|
24
|
-
? CommentFactory.description(type.symbol) ?? null
|
|
25
|
-
: undefined,
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
if (type.isLiteral()) {
|
|
29
|
-
const value: string | number | bigint =
|
|
30
|
-
typeof type.value === "object"
|
|
31
|
-
? BigInt(`${type.value.negative ? "-" : ""}${type.value.base10Value}`)
|
|
32
|
-
: type.value;
|
|
33
|
-
const constant: MetadataConstant = ArrayUtil.take(
|
|
34
|
-
meta.constants,
|
|
35
|
-
(elem) => elem.type === typeof value,
|
|
36
|
-
() =>
|
|
37
|
-
MetadataConstant.create({
|
|
38
|
-
type: typeof value as "number",
|
|
39
|
-
values: [],
|
|
40
|
-
}),
|
|
41
|
-
);
|
|
42
|
-
ArrayUtil.add(
|
|
43
|
-
constant.values,
|
|
44
|
-
MetadataConstantValue.create({
|
|
45
|
-
value,
|
|
46
|
-
tags: [],
|
|
47
|
-
...comment(),
|
|
48
|
-
}),
|
|
49
|
-
(a, b) => a.value === b.value,
|
|
50
|
-
);
|
|
51
|
-
return true;
|
|
52
|
-
} else if (filter(ts.TypeFlags.BooleanLiteral)) {
|
|
53
|
-
comment();
|
|
54
|
-
const value: boolean = checker.typeToString(type) === "true";
|
|
55
|
-
const constant: MetadataConstant = ArrayUtil.take(
|
|
56
|
-
meta.constants,
|
|
57
|
-
(elem) => elem.type === "boolean",
|
|
58
|
-
() =>
|
|
59
|
-
MetadataConstant.create({
|
|
60
|
-
type: "boolean",
|
|
61
|
-
values: [],
|
|
62
|
-
}),
|
|
63
|
-
);
|
|
64
|
-
ArrayUtil.add(
|
|
65
|
-
constant.values,
|
|
66
|
-
MetadataConstantValue.create({
|
|
67
|
-
value,
|
|
68
|
-
tags: [],
|
|
69
|
-
...comment(),
|
|
70
|
-
}),
|
|
71
|
-
(a, b) => a.value === b.value,
|
|
72
|
-
);
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
return false;
|
|
76
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataConstant } from "../../../schemas/metadata/MetadataConstant";
|
|
5
|
+
import { MetadataConstantValue } from "../../../schemas/metadata/MetadataConstantValue";
|
|
6
|
+
|
|
7
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
8
|
+
|
|
9
|
+
import { CommentFactory } from "../../CommentFactory";
|
|
10
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
11
|
+
|
|
12
|
+
export const iterate_metadata_constant =
|
|
13
|
+
(checker: ts.TypeChecker) =>
|
|
14
|
+
(options: MetadataFactory.IOptions) =>
|
|
15
|
+
(meta: Metadata, type: ts.Type): boolean => {
|
|
16
|
+
if (!options.constant) return false;
|
|
17
|
+
|
|
18
|
+
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
19
|
+
const comment = () => {
|
|
20
|
+
if (!filter(ts.TypeFlags.EnumLiteral)) return {};
|
|
21
|
+
return {
|
|
22
|
+
jsDocTags: type.symbol?.getJsDocTags(),
|
|
23
|
+
description: type.symbol
|
|
24
|
+
? CommentFactory.description(type.symbol) ?? null
|
|
25
|
+
: undefined,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
if (type.isLiteral()) {
|
|
29
|
+
const value: string | number | bigint =
|
|
30
|
+
typeof type.value === "object"
|
|
31
|
+
? BigInt(`${type.value.negative ? "-" : ""}${type.value.base10Value}`)
|
|
32
|
+
: type.value;
|
|
33
|
+
const constant: MetadataConstant = ArrayUtil.take(
|
|
34
|
+
meta.constants,
|
|
35
|
+
(elem) => elem.type === typeof value,
|
|
36
|
+
() =>
|
|
37
|
+
MetadataConstant.create({
|
|
38
|
+
type: typeof value as "number",
|
|
39
|
+
values: [],
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
ArrayUtil.add(
|
|
43
|
+
constant.values,
|
|
44
|
+
MetadataConstantValue.create({
|
|
45
|
+
value,
|
|
46
|
+
tags: [],
|
|
47
|
+
...comment(),
|
|
48
|
+
}),
|
|
49
|
+
(a, b) => a.value === b.value,
|
|
50
|
+
);
|
|
51
|
+
return true;
|
|
52
|
+
} else if (filter(ts.TypeFlags.BooleanLiteral)) {
|
|
53
|
+
comment();
|
|
54
|
+
const value: boolean = checker.typeToString(type) === "true";
|
|
55
|
+
const constant: MetadataConstant = ArrayUtil.take(
|
|
56
|
+
meta.constants,
|
|
57
|
+
(elem) => elem.type === "boolean",
|
|
58
|
+
() =>
|
|
59
|
+
MetadataConstant.create({
|
|
60
|
+
type: "boolean",
|
|
61
|
+
values: [],
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
ArrayUtil.add(
|
|
65
|
+
constant.values,
|
|
66
|
+
MetadataConstantValue.create({
|
|
67
|
+
value,
|
|
68
|
+
tags: [],
|
|
69
|
+
...comment(),
|
|
70
|
+
}),
|
|
71
|
+
(a, b) => a.value === b.value,
|
|
72
|
+
);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
};
|