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,176 +1,176 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataObject } from "../../../schemas/metadata/MetadataObject";
|
|
5
|
-
import { MetadataProperty } from "../../../schemas/metadata/MetadataProperty";
|
|
6
|
-
|
|
7
|
-
import { Writable } from "../../../typings/Writable";
|
|
8
|
-
|
|
9
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
10
|
-
|
|
11
|
-
import { CommentFactory } from "../../CommentFactory";
|
|
12
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
13
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
14
|
-
import { MetadataHelper } from "./MetadataHelper";
|
|
15
|
-
import { explore_metadata } from "./explore_metadata";
|
|
16
|
-
import { iterate_metadata_coalesce } from "./iterate_metadata_coalesce";
|
|
17
|
-
|
|
18
|
-
export const emplace_metadata_object =
|
|
19
|
-
(checker: ts.TypeChecker) =>
|
|
20
|
-
(options: MetadataFactory.IOptions) =>
|
|
21
|
-
(collection: MetadataCollection) =>
|
|
22
|
-
(errors: MetadataFactory.IError[]) =>
|
|
23
|
-
(parent: ts.Type, nullable: boolean): MetadataObject => {
|
|
24
|
-
// EMPLACE OBJECT
|
|
25
|
-
const [obj, newbie] = collection.emplace(checker, parent);
|
|
26
|
-
ArrayUtil.add(obj.nullables, nullable, (elem) => elem === nullable);
|
|
27
|
-
|
|
28
|
-
if (newbie === false) return obj;
|
|
29
|
-
|
|
30
|
-
// PREPARE ASSETS
|
|
31
|
-
const isClass: boolean = parent.isClass();
|
|
32
|
-
const pred: (node: ts.Declaration) => boolean = isClass
|
|
33
|
-
? (node) => {
|
|
34
|
-
const kind: ts.SyntaxKind | undefined = node
|
|
35
|
-
.getChildren()[0]
|
|
36
|
-
?.getChildren()[0]?.kind;
|
|
37
|
-
return (
|
|
38
|
-
kind !== ts.SyntaxKind.PrivateKeyword &&
|
|
39
|
-
kind !== ts.SyntaxKind.ProtectedKeyword &&
|
|
40
|
-
isProperty(node)
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
: (node) => isProperty(node);
|
|
44
|
-
|
|
45
|
-
const insert =
|
|
46
|
-
(key: Metadata) =>
|
|
47
|
-
(value: Metadata) =>
|
|
48
|
-
(
|
|
49
|
-
symbol: ts.Symbol | undefined,
|
|
50
|
-
filter?: (doc: ts.JSDocTagInfo) => boolean,
|
|
51
|
-
): MetadataProperty => {
|
|
52
|
-
// COMMENTS AND TAGS
|
|
53
|
-
const description: string | null = symbol
|
|
54
|
-
? CommentFactory.description(symbol) ?? null
|
|
55
|
-
: null;
|
|
56
|
-
const jsDocTags: ts.JSDocTagInfo[] = (
|
|
57
|
-
symbol?.getJsDocTags() ?? []
|
|
58
|
-
).filter(filter ?? (() => true));
|
|
59
|
-
|
|
60
|
-
// THE PROPERTY
|
|
61
|
-
const property = MetadataProperty.create({
|
|
62
|
-
key,
|
|
63
|
-
value,
|
|
64
|
-
description,
|
|
65
|
-
jsDocTags,
|
|
66
|
-
});
|
|
67
|
-
obj.properties.push(property);
|
|
68
|
-
return property;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
//----
|
|
72
|
-
// REGULAR PROPERTIES
|
|
73
|
-
//----
|
|
74
|
-
for (const prop of parent.getApparentProperties()) {
|
|
75
|
-
// CHECK INTERNAL TAG
|
|
76
|
-
if (
|
|
77
|
-
(prop.getJsDocTags(checker) ?? []).find(
|
|
78
|
-
(tag) => tag.name === "internal",
|
|
79
|
-
) !== undefined
|
|
80
|
-
)
|
|
81
|
-
continue;
|
|
82
|
-
|
|
83
|
-
// CHECK NODE IS A FORMAL PROPERTY
|
|
84
|
-
const [node, type] = (() => {
|
|
85
|
-
const node = prop.getDeclarations()?.[0] as
|
|
86
|
-
| ts.PropertyDeclaration
|
|
87
|
-
| undefined;
|
|
88
|
-
const type: ts.Type | undefined = node
|
|
89
|
-
? checker.getTypeOfSymbolAtLocation(prop, node)
|
|
90
|
-
: checker.getTypeOfPropertyOfType(parent, prop.name);
|
|
91
|
-
return [node, type];
|
|
92
|
-
})();
|
|
93
|
-
if ((node && pred(node) === false) || type === undefined) continue;
|
|
94
|
-
|
|
95
|
-
// GET EXACT TYPE
|
|
96
|
-
const key: Metadata = MetadataHelper.literal_to_metadata(prop.name);
|
|
97
|
-
const value: Metadata = explore_metadata(checker)(options)(collection)(
|
|
98
|
-
errors,
|
|
99
|
-
)(type, {
|
|
100
|
-
top: false,
|
|
101
|
-
object: obj,
|
|
102
|
-
property: prop.name,
|
|
103
|
-
nested: null,
|
|
104
|
-
escaped: false,
|
|
105
|
-
aliased: false,
|
|
106
|
-
});
|
|
107
|
-
Writable(value).optional = (prop.flags & ts.SymbolFlags.Optional) !== 0;
|
|
108
|
-
insert(key)(value)(prop);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//----
|
|
112
|
-
// DYNAMIC PROPERTIES
|
|
113
|
-
//----
|
|
114
|
-
for (const index of checker.getIndexInfosOfType(parent)) {
|
|
115
|
-
// GET EXACT TYPE
|
|
116
|
-
const analyzer = (type: ts.Type) => (property: {} | null) =>
|
|
117
|
-
explore_metadata(checker)(options)(collection)(errors)(type, {
|
|
118
|
-
top: false,
|
|
119
|
-
object: obj,
|
|
120
|
-
property,
|
|
121
|
-
nested: null,
|
|
122
|
-
escaped: false,
|
|
123
|
-
aliased: false,
|
|
124
|
-
});
|
|
125
|
-
const key: Metadata = analyzer(index.keyType)(null);
|
|
126
|
-
const value: Metadata = analyzer(index.type)({});
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
key.atomics.length +
|
|
130
|
-
key.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0) +
|
|
131
|
-
key.templates.length +
|
|
132
|
-
key.natives.filter(
|
|
133
|
-
(type) =>
|
|
134
|
-
type === "Boolean" ||
|
|
135
|
-
type === "BigInt" ||
|
|
136
|
-
type === "Number" ||
|
|
137
|
-
type === "String",
|
|
138
|
-
).length !==
|
|
139
|
-
key.size()
|
|
140
|
-
)
|
|
141
|
-
errors.push({
|
|
142
|
-
name: key.getName(),
|
|
143
|
-
explore: {
|
|
144
|
-
top: false,
|
|
145
|
-
object: obj,
|
|
146
|
-
property: "[key]",
|
|
147
|
-
nested: null,
|
|
148
|
-
escaped: false,
|
|
149
|
-
aliased: false,
|
|
150
|
-
},
|
|
151
|
-
messages: [],
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// INSERT WITH REQUIRED CONFIGURATION
|
|
155
|
-
insert(key)(value)(
|
|
156
|
-
index.declaration?.parent
|
|
157
|
-
? checker.getSymbolAtLocation(index.declaration.parent)
|
|
158
|
-
: undefined,
|
|
159
|
-
(doc) => doc.name !== "default",
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
return obj;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const isProperty = (node: ts.Declaration) =>
|
|
166
|
-
ts.isParameter(node) ||
|
|
167
|
-
ts.isPropertyDeclaration(node) ||
|
|
168
|
-
ts.isPropertyAssignment(node) ||
|
|
169
|
-
ts.isPropertySignature(node) ||
|
|
170
|
-
ts.isTypeLiteralNode(node);
|
|
171
|
-
|
|
172
|
-
const iterate_optional_coalesce = (meta: Metadata, type: ts.Type): void => {
|
|
173
|
-
if (type.isUnionOrIntersection())
|
|
174
|
-
type.types.forEach((child) => iterate_optional_coalesce(meta, child));
|
|
175
|
-
else iterate_metadata_coalesce(meta, type);
|
|
176
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataObject } from "../../../schemas/metadata/MetadataObject";
|
|
5
|
+
import { MetadataProperty } from "../../../schemas/metadata/MetadataProperty";
|
|
6
|
+
|
|
7
|
+
import { Writable } from "../../../typings/Writable";
|
|
8
|
+
|
|
9
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
10
|
+
|
|
11
|
+
import { CommentFactory } from "../../CommentFactory";
|
|
12
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
13
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
14
|
+
import { MetadataHelper } from "./MetadataHelper";
|
|
15
|
+
import { explore_metadata } from "./explore_metadata";
|
|
16
|
+
import { iterate_metadata_coalesce } from "./iterate_metadata_coalesce";
|
|
17
|
+
|
|
18
|
+
export const emplace_metadata_object =
|
|
19
|
+
(checker: ts.TypeChecker) =>
|
|
20
|
+
(options: MetadataFactory.IOptions) =>
|
|
21
|
+
(collection: MetadataCollection) =>
|
|
22
|
+
(errors: MetadataFactory.IError[]) =>
|
|
23
|
+
(parent: ts.Type, nullable: boolean): MetadataObject => {
|
|
24
|
+
// EMPLACE OBJECT
|
|
25
|
+
const [obj, newbie] = collection.emplace(checker, parent);
|
|
26
|
+
ArrayUtil.add(obj.nullables, nullable, (elem) => elem === nullable);
|
|
27
|
+
|
|
28
|
+
if (newbie === false) return obj;
|
|
29
|
+
|
|
30
|
+
// PREPARE ASSETS
|
|
31
|
+
const isClass: boolean = parent.isClass();
|
|
32
|
+
const pred: (node: ts.Declaration) => boolean = isClass
|
|
33
|
+
? (node) => {
|
|
34
|
+
const kind: ts.SyntaxKind | undefined = node
|
|
35
|
+
.getChildren()[0]
|
|
36
|
+
?.getChildren()[0]?.kind;
|
|
37
|
+
return (
|
|
38
|
+
kind !== ts.SyntaxKind.PrivateKeyword &&
|
|
39
|
+
kind !== ts.SyntaxKind.ProtectedKeyword &&
|
|
40
|
+
isProperty(node)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
: (node) => isProperty(node);
|
|
44
|
+
|
|
45
|
+
const insert =
|
|
46
|
+
(key: Metadata) =>
|
|
47
|
+
(value: Metadata) =>
|
|
48
|
+
(
|
|
49
|
+
symbol: ts.Symbol | undefined,
|
|
50
|
+
filter?: (doc: ts.JSDocTagInfo) => boolean,
|
|
51
|
+
): MetadataProperty => {
|
|
52
|
+
// COMMENTS AND TAGS
|
|
53
|
+
const description: string | null = symbol
|
|
54
|
+
? CommentFactory.description(symbol) ?? null
|
|
55
|
+
: null;
|
|
56
|
+
const jsDocTags: ts.JSDocTagInfo[] = (
|
|
57
|
+
symbol?.getJsDocTags() ?? []
|
|
58
|
+
).filter(filter ?? (() => true));
|
|
59
|
+
|
|
60
|
+
// THE PROPERTY
|
|
61
|
+
const property = MetadataProperty.create({
|
|
62
|
+
key,
|
|
63
|
+
value,
|
|
64
|
+
description,
|
|
65
|
+
jsDocTags,
|
|
66
|
+
});
|
|
67
|
+
obj.properties.push(property);
|
|
68
|
+
return property;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//----
|
|
72
|
+
// REGULAR PROPERTIES
|
|
73
|
+
//----
|
|
74
|
+
for (const prop of parent.getApparentProperties()) {
|
|
75
|
+
// CHECK INTERNAL TAG
|
|
76
|
+
if (
|
|
77
|
+
(prop.getJsDocTags(checker) ?? []).find(
|
|
78
|
+
(tag) => tag.name === "internal",
|
|
79
|
+
) !== undefined
|
|
80
|
+
)
|
|
81
|
+
continue;
|
|
82
|
+
|
|
83
|
+
// CHECK NODE IS A FORMAL PROPERTY
|
|
84
|
+
const [node, type] = (() => {
|
|
85
|
+
const node = prop.getDeclarations()?.[0] as
|
|
86
|
+
| ts.PropertyDeclaration
|
|
87
|
+
| undefined;
|
|
88
|
+
const type: ts.Type | undefined = node
|
|
89
|
+
? checker.getTypeOfSymbolAtLocation(prop, node)
|
|
90
|
+
: checker.getTypeOfPropertyOfType(parent, prop.name);
|
|
91
|
+
return [node, type];
|
|
92
|
+
})();
|
|
93
|
+
if ((node && pred(node) === false) || type === undefined) continue;
|
|
94
|
+
|
|
95
|
+
// GET EXACT TYPE
|
|
96
|
+
const key: Metadata = MetadataHelper.literal_to_metadata(prop.name);
|
|
97
|
+
const value: Metadata = explore_metadata(checker)(options)(collection)(
|
|
98
|
+
errors,
|
|
99
|
+
)(type, {
|
|
100
|
+
top: false,
|
|
101
|
+
object: obj,
|
|
102
|
+
property: prop.name,
|
|
103
|
+
nested: null,
|
|
104
|
+
escaped: false,
|
|
105
|
+
aliased: false,
|
|
106
|
+
});
|
|
107
|
+
Writable(value).optional = (prop.flags & ts.SymbolFlags.Optional) !== 0;
|
|
108
|
+
insert(key)(value)(prop);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//----
|
|
112
|
+
// DYNAMIC PROPERTIES
|
|
113
|
+
//----
|
|
114
|
+
for (const index of checker.getIndexInfosOfType(parent)) {
|
|
115
|
+
// GET EXACT TYPE
|
|
116
|
+
const analyzer = (type: ts.Type) => (property: {} | null) =>
|
|
117
|
+
explore_metadata(checker)(options)(collection)(errors)(type, {
|
|
118
|
+
top: false,
|
|
119
|
+
object: obj,
|
|
120
|
+
property,
|
|
121
|
+
nested: null,
|
|
122
|
+
escaped: false,
|
|
123
|
+
aliased: false,
|
|
124
|
+
});
|
|
125
|
+
const key: Metadata = analyzer(index.keyType)(null);
|
|
126
|
+
const value: Metadata = analyzer(index.type)({});
|
|
127
|
+
|
|
128
|
+
if (
|
|
129
|
+
key.atomics.length +
|
|
130
|
+
key.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0) +
|
|
131
|
+
key.templates.length +
|
|
132
|
+
key.natives.filter(
|
|
133
|
+
(type) =>
|
|
134
|
+
type === "Boolean" ||
|
|
135
|
+
type === "BigInt" ||
|
|
136
|
+
type === "Number" ||
|
|
137
|
+
type === "String",
|
|
138
|
+
).length !==
|
|
139
|
+
key.size()
|
|
140
|
+
)
|
|
141
|
+
errors.push({
|
|
142
|
+
name: key.getName(),
|
|
143
|
+
explore: {
|
|
144
|
+
top: false,
|
|
145
|
+
object: obj,
|
|
146
|
+
property: "[key]",
|
|
147
|
+
nested: null,
|
|
148
|
+
escaped: false,
|
|
149
|
+
aliased: false,
|
|
150
|
+
},
|
|
151
|
+
messages: [],
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// INSERT WITH REQUIRED CONFIGURATION
|
|
155
|
+
insert(key)(value)(
|
|
156
|
+
index.declaration?.parent
|
|
157
|
+
? checker.getSymbolAtLocation(index.declaration.parent)
|
|
158
|
+
: undefined,
|
|
159
|
+
(doc) => doc.name !== "default",
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
return obj;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const isProperty = (node: ts.Declaration) =>
|
|
166
|
+
ts.isParameter(node) ||
|
|
167
|
+
ts.isPropertyDeclaration(node) ||
|
|
168
|
+
ts.isPropertyAssignment(node) ||
|
|
169
|
+
ts.isPropertySignature(node) ||
|
|
170
|
+
ts.isTypeLiteralNode(node);
|
|
171
|
+
|
|
172
|
+
const iterate_optional_coalesce = (meta: Metadata, type: ts.Type): void => {
|
|
173
|
+
if (type.isUnionOrIntersection())
|
|
174
|
+
type.types.forEach((child) => iterate_optional_coalesce(meta, child));
|
|
175
|
+
else iterate_metadata_coalesce(meta, type);
|
|
176
|
+
};
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
6
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
7
|
-
import { TypeFactory } from "../../TypeFactory";
|
|
8
|
-
import { iterate_metadata_alias } from "./iterate_metadata_alias";
|
|
9
|
-
import { iterate_metadata_array } from "./iterate_metadata_array";
|
|
10
|
-
import { iterate_metadata_atomic } from "./iterate_metadata_atomic";
|
|
11
|
-
import { iterate_metadata_coalesce } from "./iterate_metadata_coalesce";
|
|
12
|
-
import { iterate_metadata_constant } from "./iterate_metadata_constant";
|
|
13
|
-
import { iterate_metadata_escape } from "./iterate_metadata_escape";
|
|
14
|
-
import { iterate_metadata_intersection } from "./iterate_metadata_intersection";
|
|
15
|
-
import { iterate_metadata_map } from "./iterate_metadata_map";
|
|
16
|
-
import { iterate_metadata_native } from "./iterate_metadata_native";
|
|
17
|
-
import { iterate_metadata_object } from "./iterate_metadata_object";
|
|
18
|
-
import { iterate_metadata_set } from "./iterate_metadata_set";
|
|
19
|
-
import { iterate_metadata_template } from "./iterate_metadata_template";
|
|
20
|
-
import { iterate_metadata_tuple } from "./iterate_metadata_tuple";
|
|
21
|
-
import { iterate_metadata_union } from "./iterate_metadata_union";
|
|
22
|
-
|
|
23
|
-
export const iterate_metadata =
|
|
24
|
-
(checker: ts.TypeChecker) =>
|
|
25
|
-
(options: MetadataFactory.IOptions) =>
|
|
26
|
-
(collection: MetadataCollection) =>
|
|
27
|
-
(errors: MetadataFactory.IError[]) =>
|
|
28
|
-
(meta: Metadata, type: ts.Type, explore: MetadataFactory.IExplore): void => {
|
|
29
|
-
if (type.isTypeParameter() === true) {
|
|
30
|
-
errors.push({
|
|
31
|
-
name: TypeFactory.getFullName(checker)(type),
|
|
32
|
-
explore: { ...explore },
|
|
33
|
-
messages: ["non-specified generic argument found."],
|
|
34
|
-
});
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
// CHECK SPECIAL CASES
|
|
38
|
-
else if (
|
|
39
|
-
(explore.aliased !== true &&
|
|
40
|
-
iterate_metadata_alias(checker)(options)(collection)(errors)(
|
|
41
|
-
meta,
|
|
42
|
-
type,
|
|
43
|
-
explore,
|
|
44
|
-
)) ||
|
|
45
|
-
iterate_metadata_intersection(checker)(options)(collection)(errors)(
|
|
46
|
-
meta,
|
|
47
|
-
type,
|
|
48
|
-
explore,
|
|
49
|
-
) ||
|
|
50
|
-
iterate_metadata_union(checker)(options)(collection)(errors)(
|
|
51
|
-
meta,
|
|
52
|
-
type,
|
|
53
|
-
explore,
|
|
54
|
-
) ||
|
|
55
|
-
iterate_metadata_escape(checker)(options)(collection)(errors)(
|
|
56
|
-
meta,
|
|
57
|
-
type,
|
|
58
|
-
explore,
|
|
59
|
-
)
|
|
60
|
-
)
|
|
61
|
-
return;
|
|
62
|
-
|
|
63
|
-
// ITERATE CASES
|
|
64
|
-
iterate_metadata_coalesce(meta, type) ||
|
|
65
|
-
iterate_metadata_constant(checker)(options)(meta, type) ||
|
|
66
|
-
iterate_metadata_template(checker)(options)(collection)(errors)(
|
|
67
|
-
meta,
|
|
68
|
-
type,
|
|
69
|
-
explore,
|
|
70
|
-
) ||
|
|
71
|
-
iterate_metadata_atomic(meta, type) ||
|
|
72
|
-
iterate_metadata_tuple(checker)(options)(collection)(errors)(
|
|
73
|
-
meta,
|
|
74
|
-
type as ts.TupleType,
|
|
75
|
-
explore,
|
|
76
|
-
) ||
|
|
77
|
-
iterate_metadata_array(checker)(options)(collection)(errors)(
|
|
78
|
-
meta,
|
|
79
|
-
type,
|
|
80
|
-
explore,
|
|
81
|
-
) ||
|
|
82
|
-
iterate_metadata_native(checker)(meta, type) ||
|
|
83
|
-
iterate_metadata_map(checker)(options)(collection)(errors)(
|
|
84
|
-
meta,
|
|
85
|
-
type,
|
|
86
|
-
explore,
|
|
87
|
-
) ||
|
|
88
|
-
iterate_metadata_set(checker)(options)(collection)(errors)(
|
|
89
|
-
meta,
|
|
90
|
-
type,
|
|
91
|
-
explore,
|
|
92
|
-
) ||
|
|
93
|
-
iterate_metadata_object(checker)(options)(collection)(errors)(meta, type);
|
|
94
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
6
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
7
|
+
import { TypeFactory } from "../../TypeFactory";
|
|
8
|
+
import { iterate_metadata_alias } from "./iterate_metadata_alias";
|
|
9
|
+
import { iterate_metadata_array } from "./iterate_metadata_array";
|
|
10
|
+
import { iterate_metadata_atomic } from "./iterate_metadata_atomic";
|
|
11
|
+
import { iterate_metadata_coalesce } from "./iterate_metadata_coalesce";
|
|
12
|
+
import { iterate_metadata_constant } from "./iterate_metadata_constant";
|
|
13
|
+
import { iterate_metadata_escape } from "./iterate_metadata_escape";
|
|
14
|
+
import { iterate_metadata_intersection } from "./iterate_metadata_intersection";
|
|
15
|
+
import { iterate_metadata_map } from "./iterate_metadata_map";
|
|
16
|
+
import { iterate_metadata_native } from "./iterate_metadata_native";
|
|
17
|
+
import { iterate_metadata_object } from "./iterate_metadata_object";
|
|
18
|
+
import { iterate_metadata_set } from "./iterate_metadata_set";
|
|
19
|
+
import { iterate_metadata_template } from "./iterate_metadata_template";
|
|
20
|
+
import { iterate_metadata_tuple } from "./iterate_metadata_tuple";
|
|
21
|
+
import { iterate_metadata_union } from "./iterate_metadata_union";
|
|
22
|
+
|
|
23
|
+
export const iterate_metadata =
|
|
24
|
+
(checker: ts.TypeChecker) =>
|
|
25
|
+
(options: MetadataFactory.IOptions) =>
|
|
26
|
+
(collection: MetadataCollection) =>
|
|
27
|
+
(errors: MetadataFactory.IError[]) =>
|
|
28
|
+
(meta: Metadata, type: ts.Type, explore: MetadataFactory.IExplore): void => {
|
|
29
|
+
if (type.isTypeParameter() === true) {
|
|
30
|
+
errors.push({
|
|
31
|
+
name: TypeFactory.getFullName(checker)(type),
|
|
32
|
+
explore: { ...explore },
|
|
33
|
+
messages: ["non-specified generic argument found."],
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// CHECK SPECIAL CASES
|
|
38
|
+
else if (
|
|
39
|
+
(explore.aliased !== true &&
|
|
40
|
+
iterate_metadata_alias(checker)(options)(collection)(errors)(
|
|
41
|
+
meta,
|
|
42
|
+
type,
|
|
43
|
+
explore,
|
|
44
|
+
)) ||
|
|
45
|
+
iterate_metadata_intersection(checker)(options)(collection)(errors)(
|
|
46
|
+
meta,
|
|
47
|
+
type,
|
|
48
|
+
explore,
|
|
49
|
+
) ||
|
|
50
|
+
iterate_metadata_union(checker)(options)(collection)(errors)(
|
|
51
|
+
meta,
|
|
52
|
+
type,
|
|
53
|
+
explore,
|
|
54
|
+
) ||
|
|
55
|
+
iterate_metadata_escape(checker)(options)(collection)(errors)(
|
|
56
|
+
meta,
|
|
57
|
+
type,
|
|
58
|
+
explore,
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
return;
|
|
62
|
+
|
|
63
|
+
// ITERATE CASES
|
|
64
|
+
iterate_metadata_coalesce(meta, type) ||
|
|
65
|
+
iterate_metadata_constant(checker)(options)(meta, type) ||
|
|
66
|
+
iterate_metadata_template(checker)(options)(collection)(errors)(
|
|
67
|
+
meta,
|
|
68
|
+
type,
|
|
69
|
+
explore,
|
|
70
|
+
) ||
|
|
71
|
+
iterate_metadata_atomic(meta, type) ||
|
|
72
|
+
iterate_metadata_tuple(checker)(options)(collection)(errors)(
|
|
73
|
+
meta,
|
|
74
|
+
type as ts.TupleType,
|
|
75
|
+
explore,
|
|
76
|
+
) ||
|
|
77
|
+
iterate_metadata_array(checker)(options)(collection)(errors)(
|
|
78
|
+
meta,
|
|
79
|
+
type,
|
|
80
|
+
explore,
|
|
81
|
+
) ||
|
|
82
|
+
iterate_metadata_native(checker)(meta, type) ||
|
|
83
|
+
iterate_metadata_map(checker)(options)(collection)(errors)(
|
|
84
|
+
meta,
|
|
85
|
+
type,
|
|
86
|
+
explore,
|
|
87
|
+
) ||
|
|
88
|
+
iterate_metadata_set(checker)(options)(collection)(errors)(
|
|
89
|
+
meta,
|
|
90
|
+
type,
|
|
91
|
+
explore,
|
|
92
|
+
) ||
|
|
93
|
+
iterate_metadata_object(checker)(options)(collection)(errors)(meta, type);
|
|
94
|
+
};
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataArray } from "../../../schemas/metadata/MetadataArray";
|
|
5
|
-
import { MetadataArrayType } from "../../../schemas/metadata/MetadataArrayType";
|
|
6
|
-
|
|
7
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
8
|
-
|
|
9
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
10
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
11
|
-
import { emplace_metadata_array_type } from "./emplace_metadata_array_type";
|
|
12
|
-
|
|
13
|
-
export const iterate_metadata_array =
|
|
14
|
-
(checker: ts.TypeChecker) =>
|
|
15
|
-
(options: MetadataFactory.IOptions) =>
|
|
16
|
-
(collection: MetadataCollection) =>
|
|
17
|
-
(errors: MetadataFactory.IError[]) =>
|
|
18
|
-
(
|
|
19
|
-
meta: Metadata,
|
|
20
|
-
alias: ts.Type,
|
|
21
|
-
explore: MetadataFactory.IExplore,
|
|
22
|
-
): boolean => {
|
|
23
|
-
const array: ts.Type | null =
|
|
24
|
-
checker.isArrayType(alias) === false
|
|
25
|
-
? find_array_extended(checker)(new Map())(alias)
|
|
26
|
-
: alias;
|
|
27
|
-
if (array === null) return false;
|
|
28
|
-
|
|
29
|
-
const arrayType: MetadataArrayType = emplace_metadata_array_type(checker)(
|
|
30
|
-
options,
|
|
31
|
-
)(collection)(errors)(alias, array, meta.nullable, explore);
|
|
32
|
-
ArrayUtil.add(
|
|
33
|
-
meta.arrays,
|
|
34
|
-
MetadataArray.create({
|
|
35
|
-
type: arrayType,
|
|
36
|
-
tags: [],
|
|
37
|
-
}),
|
|
38
|
-
(elem) => elem.type.name === arrayType.name,
|
|
39
|
-
);
|
|
40
|
-
return true;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const find_array_extended =
|
|
44
|
-
(checker: ts.TypeChecker) =>
|
|
45
|
-
(memory: Map<ts.Type, ts.Type | null>) =>
|
|
46
|
-
(type: ts.Type): ts.Type | null => {
|
|
47
|
-
const cached = memory.get(type);
|
|
48
|
-
if (cached !== undefined) return null;
|
|
49
|
-
|
|
50
|
-
memory.set(type, null);
|
|
51
|
-
const res: ts.Type | null = (() => {
|
|
52
|
-
if (type.isClassOrInterface() === false) return null;
|
|
53
|
-
for (const t of type.resolvedBaseTypes ?? [])
|
|
54
|
-
if (checker.isArrayType(t)) return t;
|
|
55
|
-
else {
|
|
56
|
-
const res: ts.Type | null = find_array_extended(checker)(memory)(t);
|
|
57
|
-
if (res !== null) return res;
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
})();
|
|
61
|
-
memory.set(type, res);
|
|
62
|
-
return res;
|
|
63
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataArray } from "../../../schemas/metadata/MetadataArray";
|
|
5
|
+
import { MetadataArrayType } from "../../../schemas/metadata/MetadataArrayType";
|
|
6
|
+
|
|
7
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
8
|
+
|
|
9
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
10
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
11
|
+
import { emplace_metadata_array_type } from "./emplace_metadata_array_type";
|
|
12
|
+
|
|
13
|
+
export const iterate_metadata_array =
|
|
14
|
+
(checker: ts.TypeChecker) =>
|
|
15
|
+
(options: MetadataFactory.IOptions) =>
|
|
16
|
+
(collection: MetadataCollection) =>
|
|
17
|
+
(errors: MetadataFactory.IError[]) =>
|
|
18
|
+
(
|
|
19
|
+
meta: Metadata,
|
|
20
|
+
alias: ts.Type,
|
|
21
|
+
explore: MetadataFactory.IExplore,
|
|
22
|
+
): boolean => {
|
|
23
|
+
const array: ts.Type | null =
|
|
24
|
+
checker.isArrayType(alias) === false
|
|
25
|
+
? find_array_extended(checker)(new Map())(alias)
|
|
26
|
+
: alias;
|
|
27
|
+
if (array === null) return false;
|
|
28
|
+
|
|
29
|
+
const arrayType: MetadataArrayType = emplace_metadata_array_type(checker)(
|
|
30
|
+
options,
|
|
31
|
+
)(collection)(errors)(alias, array, meta.nullable, explore);
|
|
32
|
+
ArrayUtil.add(
|
|
33
|
+
meta.arrays,
|
|
34
|
+
MetadataArray.create({
|
|
35
|
+
type: arrayType,
|
|
36
|
+
tags: [],
|
|
37
|
+
}),
|
|
38
|
+
(elem) => elem.type.name === arrayType.name,
|
|
39
|
+
);
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const find_array_extended =
|
|
44
|
+
(checker: ts.TypeChecker) =>
|
|
45
|
+
(memory: Map<ts.Type, ts.Type | null>) =>
|
|
46
|
+
(type: ts.Type): ts.Type | null => {
|
|
47
|
+
const cached = memory.get(type);
|
|
48
|
+
if (cached !== undefined) return null;
|
|
49
|
+
|
|
50
|
+
memory.set(type, null);
|
|
51
|
+
const res: ts.Type | null = (() => {
|
|
52
|
+
if (type.isClassOrInterface() === false) return null;
|
|
53
|
+
for (const t of type.resolvedBaseTypes ?? [])
|
|
54
|
+
if (checker.isArrayType(t)) return t;
|
|
55
|
+
else {
|
|
56
|
+
const res: ts.Type | null = find_array_extended(checker)(memory)(t);
|
|
57
|
+
if (res !== null) return res;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
})();
|
|
61
|
+
memory.set(type, res);
|
|
62
|
+
return res;
|
|
63
|
+
};
|