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,220 +1,220 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
6
|
-
|
|
7
|
-
import { TypeFactory } from "../../TypeFactory";
|
|
8
|
-
|
|
9
|
-
export const iterate_metadata_native =
|
|
10
|
-
(checker: ts.TypeChecker) =>
|
|
11
|
-
(meta: Metadata, type: ts.Type): boolean => {
|
|
12
|
-
const validator = validate(checker)(type);
|
|
13
|
-
const name: string = TypeFactory.getFullName(checker)(
|
|
14
|
-
type,
|
|
15
|
-
type.getSymbol(),
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const simple = SIMPLES.get(name);
|
|
19
|
-
if (simple && validator(simple)) {
|
|
20
|
-
ArrayUtil.set(meta.natives, name, (str) => str);
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
for (const generic of GENERICS)
|
|
25
|
-
if (
|
|
26
|
-
name.substring(0, generic.name.length) === generic.name &&
|
|
27
|
-
validator(generic)
|
|
28
|
-
) {
|
|
29
|
-
ArrayUtil.set(meta.natives, generic.name ?? name, (str) => str);
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
return false;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const validate =
|
|
36
|
-
(checker: ts.TypeChecker) => (type: ts.Type) => (info: IClassInfo) =>
|
|
37
|
-
(info.methods ?? []).every((method) => {
|
|
38
|
-
const returnType = TypeFactory.getReturnType(checker)(type)(method.name);
|
|
39
|
-
return (
|
|
40
|
-
returnType !== null &&
|
|
41
|
-
checker.typeToString(returnType) === method.return
|
|
42
|
-
);
|
|
43
|
-
}) &&
|
|
44
|
-
(info.properties ?? []).every((property) => {
|
|
45
|
-
const prop = checker.getPropertyOfType(type, property.name);
|
|
46
|
-
const propType = prop?.valueDeclaration
|
|
47
|
-
? checker.getTypeAtLocation(prop?.valueDeclaration)
|
|
48
|
-
: undefined;
|
|
49
|
-
return (
|
|
50
|
-
propType !== undefined &&
|
|
51
|
-
checker.typeToString(propType) === property.type
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const getBinaryProps = (className: string): IClassInfo => ({
|
|
56
|
-
name: className,
|
|
57
|
-
methods: [
|
|
58
|
-
...["indexOf", "lastIndexOf"].map((name) => ({
|
|
59
|
-
name,
|
|
60
|
-
return: "number",
|
|
61
|
-
})),
|
|
62
|
-
...["some", "every"].map((name) => ({
|
|
63
|
-
name,
|
|
64
|
-
return: "boolean",
|
|
65
|
-
})),
|
|
66
|
-
...["join", "toLocaleString"].map((name) => ({
|
|
67
|
-
name,
|
|
68
|
-
return: "string",
|
|
69
|
-
})),
|
|
70
|
-
...["reverse", "slice", "subarray"].map((name) => ({
|
|
71
|
-
name,
|
|
72
|
-
return: className,
|
|
73
|
-
})),
|
|
74
|
-
],
|
|
75
|
-
properties: ["BYTES_PER_ELEMENT", "length", "byteLength", "byteOffset"].map(
|
|
76
|
-
(name) => ({
|
|
77
|
-
name,
|
|
78
|
-
type: "number",
|
|
79
|
-
}),
|
|
80
|
-
),
|
|
81
|
-
});
|
|
82
|
-
const SIMPLES: Map<string, IClassInfo> = new Map([
|
|
83
|
-
[
|
|
84
|
-
"Date",
|
|
85
|
-
{
|
|
86
|
-
methods: ["getTime", "getFullYear", "getMonth", "getMinutes"].map(
|
|
87
|
-
(name) => ({
|
|
88
|
-
name,
|
|
89
|
-
return: "number",
|
|
90
|
-
}),
|
|
91
|
-
),
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
[
|
|
95
|
-
"Boolean",
|
|
96
|
-
{
|
|
97
|
-
methods: [
|
|
98
|
-
{
|
|
99
|
-
name: "valueOf",
|
|
100
|
-
return: "boolean",
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
[
|
|
106
|
-
"Number",
|
|
107
|
-
{
|
|
108
|
-
methods: [
|
|
109
|
-
...["toFixed", "toExponential", "toPrecision"].map((name) => ({
|
|
110
|
-
name,
|
|
111
|
-
return: "string",
|
|
112
|
-
})),
|
|
113
|
-
{ name: "valueOf", return: "number" },
|
|
114
|
-
],
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
[
|
|
118
|
-
"String",
|
|
119
|
-
{
|
|
120
|
-
methods: [
|
|
121
|
-
"charAt",
|
|
122
|
-
"concat",
|
|
123
|
-
"valueOf",
|
|
124
|
-
"trim",
|
|
125
|
-
"replace",
|
|
126
|
-
"substring",
|
|
127
|
-
].map((name) => ({ name, return: "string" })),
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
...[
|
|
131
|
-
"Uint8Array",
|
|
132
|
-
"Uint8ClampedArray",
|
|
133
|
-
"Uint16Array",
|
|
134
|
-
"Uint32Array",
|
|
135
|
-
"BigUint64Array",
|
|
136
|
-
"Int8Array",
|
|
137
|
-
"Int16Array",
|
|
138
|
-
"Int32Array",
|
|
139
|
-
"BigInt64Array",
|
|
140
|
-
"Float32Array",
|
|
141
|
-
"Float64Array",
|
|
142
|
-
].map((name) => [name, getBinaryProps(name)] as const),
|
|
143
|
-
...["ArrayBuffer", "SharedArrayBuffer"].map((className) => {
|
|
144
|
-
const info: IClassInfo = {
|
|
145
|
-
methods: [{ name: "slice", return: className }],
|
|
146
|
-
properties: [{ name: "byteLength", type: "number" }],
|
|
147
|
-
};
|
|
148
|
-
return [className, info] as const;
|
|
149
|
-
}),
|
|
150
|
-
...["Blob", "File"].map(
|
|
151
|
-
(className) =>
|
|
152
|
-
[
|
|
153
|
-
className,
|
|
154
|
-
{
|
|
155
|
-
methods: [
|
|
156
|
-
{ name: "arrayBuffer", return: "Promise<ArrayBuffer>" },
|
|
157
|
-
{ name: "slice", return: "Blob" },
|
|
158
|
-
{ name: "text", return: "Promise<string>" },
|
|
159
|
-
],
|
|
160
|
-
properties: [
|
|
161
|
-
{ name: "size", type: "number" },
|
|
162
|
-
{ name: "type", type: "string" },
|
|
163
|
-
],
|
|
164
|
-
},
|
|
165
|
-
] satisfies [string, IClassInfo],
|
|
166
|
-
),
|
|
167
|
-
[
|
|
168
|
-
"DataView",
|
|
169
|
-
{
|
|
170
|
-
methods: [
|
|
171
|
-
"getFloat32",
|
|
172
|
-
"getFloat64",
|
|
173
|
-
"getInt8",
|
|
174
|
-
"getInt16",
|
|
175
|
-
"getInt32",
|
|
176
|
-
"getUint8",
|
|
177
|
-
"getUint16",
|
|
178
|
-
"getUint32",
|
|
179
|
-
].map((name) => ({
|
|
180
|
-
name,
|
|
181
|
-
return: "number",
|
|
182
|
-
})),
|
|
183
|
-
},
|
|
184
|
-
],
|
|
185
|
-
[
|
|
186
|
-
"RegExp",
|
|
187
|
-
{
|
|
188
|
-
methods: [
|
|
189
|
-
{
|
|
190
|
-
name: "test",
|
|
191
|
-
return: "boolean",
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
]);
|
|
197
|
-
const GENERICS: Array<IClassInfo & { name: string }> = [
|
|
198
|
-
"WeakMap",
|
|
199
|
-
"WeakSet",
|
|
200
|
-
].map((name) => ({
|
|
201
|
-
name,
|
|
202
|
-
methods: ["has", "delete"].map((name) => ({
|
|
203
|
-
name,
|
|
204
|
-
return: "boolean",
|
|
205
|
-
})),
|
|
206
|
-
}));
|
|
207
|
-
|
|
208
|
-
interface IClassInfo {
|
|
209
|
-
name?: string;
|
|
210
|
-
methods?: IMethod[];
|
|
211
|
-
properties?: IProperty[];
|
|
212
|
-
}
|
|
213
|
-
interface IProperty {
|
|
214
|
-
name: string;
|
|
215
|
-
type: string;
|
|
216
|
-
}
|
|
217
|
-
interface IMethod {
|
|
218
|
-
name: string;
|
|
219
|
-
return: string;
|
|
220
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
6
|
+
|
|
7
|
+
import { TypeFactory } from "../../TypeFactory";
|
|
8
|
+
|
|
9
|
+
export const iterate_metadata_native =
|
|
10
|
+
(checker: ts.TypeChecker) =>
|
|
11
|
+
(meta: Metadata, type: ts.Type): boolean => {
|
|
12
|
+
const validator = validate(checker)(type);
|
|
13
|
+
const name: string = TypeFactory.getFullName(checker)(
|
|
14
|
+
type,
|
|
15
|
+
type.getSymbol(),
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const simple = SIMPLES.get(name);
|
|
19
|
+
if (simple && validator(simple)) {
|
|
20
|
+
ArrayUtil.set(meta.natives, name, (str) => str);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
for (const generic of GENERICS)
|
|
25
|
+
if (
|
|
26
|
+
name.substring(0, generic.name.length) === generic.name &&
|
|
27
|
+
validator(generic)
|
|
28
|
+
) {
|
|
29
|
+
ArrayUtil.set(meta.natives, generic.name ?? name, (str) => str);
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const validate =
|
|
36
|
+
(checker: ts.TypeChecker) => (type: ts.Type) => (info: IClassInfo) =>
|
|
37
|
+
(info.methods ?? []).every((method) => {
|
|
38
|
+
const returnType = TypeFactory.getReturnType(checker)(type)(method.name);
|
|
39
|
+
return (
|
|
40
|
+
returnType !== null &&
|
|
41
|
+
checker.typeToString(returnType) === method.return
|
|
42
|
+
);
|
|
43
|
+
}) &&
|
|
44
|
+
(info.properties ?? []).every((property) => {
|
|
45
|
+
const prop = checker.getPropertyOfType(type, property.name);
|
|
46
|
+
const propType = prop?.valueDeclaration
|
|
47
|
+
? checker.getTypeAtLocation(prop?.valueDeclaration)
|
|
48
|
+
: undefined;
|
|
49
|
+
return (
|
|
50
|
+
propType !== undefined &&
|
|
51
|
+
checker.typeToString(propType) === property.type
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const getBinaryProps = (className: string): IClassInfo => ({
|
|
56
|
+
name: className,
|
|
57
|
+
methods: [
|
|
58
|
+
...["indexOf", "lastIndexOf"].map((name) => ({
|
|
59
|
+
name,
|
|
60
|
+
return: "number",
|
|
61
|
+
})),
|
|
62
|
+
...["some", "every"].map((name) => ({
|
|
63
|
+
name,
|
|
64
|
+
return: "boolean",
|
|
65
|
+
})),
|
|
66
|
+
...["join", "toLocaleString"].map((name) => ({
|
|
67
|
+
name,
|
|
68
|
+
return: "string",
|
|
69
|
+
})),
|
|
70
|
+
...["reverse", "slice", "subarray"].map((name) => ({
|
|
71
|
+
name,
|
|
72
|
+
return: className,
|
|
73
|
+
})),
|
|
74
|
+
],
|
|
75
|
+
properties: ["BYTES_PER_ELEMENT", "length", "byteLength", "byteOffset"].map(
|
|
76
|
+
(name) => ({
|
|
77
|
+
name,
|
|
78
|
+
type: "number",
|
|
79
|
+
}),
|
|
80
|
+
),
|
|
81
|
+
});
|
|
82
|
+
const SIMPLES: Map<string, IClassInfo> = new Map([
|
|
83
|
+
[
|
|
84
|
+
"Date",
|
|
85
|
+
{
|
|
86
|
+
methods: ["getTime", "getFullYear", "getMonth", "getMinutes"].map(
|
|
87
|
+
(name) => ({
|
|
88
|
+
name,
|
|
89
|
+
return: "number",
|
|
90
|
+
}),
|
|
91
|
+
),
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
"Boolean",
|
|
96
|
+
{
|
|
97
|
+
methods: [
|
|
98
|
+
{
|
|
99
|
+
name: "valueOf",
|
|
100
|
+
return: "boolean",
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
"Number",
|
|
107
|
+
{
|
|
108
|
+
methods: [
|
|
109
|
+
...["toFixed", "toExponential", "toPrecision"].map((name) => ({
|
|
110
|
+
name,
|
|
111
|
+
return: "string",
|
|
112
|
+
})),
|
|
113
|
+
{ name: "valueOf", return: "number" },
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
"String",
|
|
119
|
+
{
|
|
120
|
+
methods: [
|
|
121
|
+
"charAt",
|
|
122
|
+
"concat",
|
|
123
|
+
"valueOf",
|
|
124
|
+
"trim",
|
|
125
|
+
"replace",
|
|
126
|
+
"substring",
|
|
127
|
+
].map((name) => ({ name, return: "string" })),
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
...[
|
|
131
|
+
"Uint8Array",
|
|
132
|
+
"Uint8ClampedArray",
|
|
133
|
+
"Uint16Array",
|
|
134
|
+
"Uint32Array",
|
|
135
|
+
"BigUint64Array",
|
|
136
|
+
"Int8Array",
|
|
137
|
+
"Int16Array",
|
|
138
|
+
"Int32Array",
|
|
139
|
+
"BigInt64Array",
|
|
140
|
+
"Float32Array",
|
|
141
|
+
"Float64Array",
|
|
142
|
+
].map((name) => [name, getBinaryProps(name)] as const),
|
|
143
|
+
...["ArrayBuffer", "SharedArrayBuffer"].map((className) => {
|
|
144
|
+
const info: IClassInfo = {
|
|
145
|
+
methods: [{ name: "slice", return: className }],
|
|
146
|
+
properties: [{ name: "byteLength", type: "number" }],
|
|
147
|
+
};
|
|
148
|
+
return [className, info] as const;
|
|
149
|
+
}),
|
|
150
|
+
...["Blob", "File"].map(
|
|
151
|
+
(className) =>
|
|
152
|
+
[
|
|
153
|
+
className,
|
|
154
|
+
{
|
|
155
|
+
methods: [
|
|
156
|
+
{ name: "arrayBuffer", return: "Promise<ArrayBuffer>" },
|
|
157
|
+
{ name: "slice", return: "Blob" },
|
|
158
|
+
{ name: "text", return: "Promise<string>" },
|
|
159
|
+
],
|
|
160
|
+
properties: [
|
|
161
|
+
{ name: "size", type: "number" },
|
|
162
|
+
{ name: "type", type: "string" },
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
] satisfies [string, IClassInfo],
|
|
166
|
+
),
|
|
167
|
+
[
|
|
168
|
+
"DataView",
|
|
169
|
+
{
|
|
170
|
+
methods: [
|
|
171
|
+
"getFloat32",
|
|
172
|
+
"getFloat64",
|
|
173
|
+
"getInt8",
|
|
174
|
+
"getInt16",
|
|
175
|
+
"getInt32",
|
|
176
|
+
"getUint8",
|
|
177
|
+
"getUint16",
|
|
178
|
+
"getUint32",
|
|
179
|
+
].map((name) => ({
|
|
180
|
+
name,
|
|
181
|
+
return: "number",
|
|
182
|
+
})),
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
[
|
|
186
|
+
"RegExp",
|
|
187
|
+
{
|
|
188
|
+
methods: [
|
|
189
|
+
{
|
|
190
|
+
name: "test",
|
|
191
|
+
return: "boolean",
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
]);
|
|
197
|
+
const GENERICS: Array<IClassInfo & { name: string }> = [
|
|
198
|
+
"WeakMap",
|
|
199
|
+
"WeakSet",
|
|
200
|
+
].map((name) => ({
|
|
201
|
+
name,
|
|
202
|
+
methods: ["has", "delete"].map((name) => ({
|
|
203
|
+
name,
|
|
204
|
+
return: "boolean",
|
|
205
|
+
})),
|
|
206
|
+
}));
|
|
207
|
+
|
|
208
|
+
interface IClassInfo {
|
|
209
|
+
name?: string;
|
|
210
|
+
methods?: IMethod[];
|
|
211
|
+
properties?: IProperty[];
|
|
212
|
+
}
|
|
213
|
+
interface IProperty {
|
|
214
|
+
name: string;
|
|
215
|
+
type: string;
|
|
216
|
+
}
|
|
217
|
+
interface IMethod {
|
|
218
|
+
name: string;
|
|
219
|
+
return: string;
|
|
220
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataObject } from "../../../schemas/metadata/MetadataObject";
|
|
5
|
-
|
|
6
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
7
|
-
|
|
8
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
9
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
10
|
-
import { emplace_metadata_object } from "./emplace_metadata_object";
|
|
11
|
-
|
|
12
|
-
export const iterate_metadata_object =
|
|
13
|
-
(checker: ts.TypeChecker) =>
|
|
14
|
-
(options: MetadataFactory.IOptions) =>
|
|
15
|
-
(collection: MetadataCollection) =>
|
|
16
|
-
(errors: MetadataFactory.IError[]) =>
|
|
17
|
-
(meta: Metadata, type: ts.Type, ensure: boolean = false): boolean => {
|
|
18
|
-
if (ensure === false) {
|
|
19
|
-
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
20
|
-
if (
|
|
21
|
-
!filter(ts.TypeFlags.Object) &&
|
|
22
|
-
!type.isIntersection() &&
|
|
23
|
-
(type as any).intrinsicName !== "object"
|
|
24
|
-
)
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const obj: MetadataObject = emplace_metadata_object(checker)(options)(
|
|
29
|
-
collection,
|
|
30
|
-
)(errors)(type, meta.nullable);
|
|
31
|
-
ArrayUtil.add(meta.objects, obj, (elem) => elem.name === obj.name);
|
|
32
|
-
return true;
|
|
33
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataObject } from "../../../schemas/metadata/MetadataObject";
|
|
5
|
+
|
|
6
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
7
|
+
|
|
8
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
9
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
10
|
+
import { emplace_metadata_object } from "./emplace_metadata_object";
|
|
11
|
+
|
|
12
|
+
export const iterate_metadata_object =
|
|
13
|
+
(checker: ts.TypeChecker) =>
|
|
14
|
+
(options: MetadataFactory.IOptions) =>
|
|
15
|
+
(collection: MetadataCollection) =>
|
|
16
|
+
(errors: MetadataFactory.IError[]) =>
|
|
17
|
+
(meta: Metadata, type: ts.Type, ensure: boolean = false): boolean => {
|
|
18
|
+
if (ensure === false) {
|
|
19
|
+
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
20
|
+
if (
|
|
21
|
+
!filter(ts.TypeFlags.Object) &&
|
|
22
|
+
!type.isIntersection() &&
|
|
23
|
+
(type as any).intrinsicName !== "object"
|
|
24
|
+
)
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const obj: MetadataObject = emplace_metadata_object(checker)(options)(
|
|
29
|
+
collection,
|
|
30
|
+
)(errors)(type, meta.nullable);
|
|
31
|
+
ArrayUtil.add(meta.objects, obj, (elem) => elem.name === obj.name);
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
6
|
-
|
|
7
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
8
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
9
|
-
import { TypeFactory } from "../../TypeFactory";
|
|
10
|
-
import { explore_metadata } from "./explore_metadata";
|
|
11
|
-
|
|
12
|
-
export const iterate_metadata_set =
|
|
13
|
-
(checker: ts.TypeChecker) =>
|
|
14
|
-
(options: MetadataFactory.IOptions) =>
|
|
15
|
-
(collection: MetadataCollection) =>
|
|
16
|
-
(errors: MetadataFactory.IError[]) =>
|
|
17
|
-
(
|
|
18
|
-
meta: Metadata,
|
|
19
|
-
type: ts.Type,
|
|
20
|
-
explore: MetadataFactory.IExplore,
|
|
21
|
-
): boolean => {
|
|
22
|
-
type = checker.getApparentType(type);
|
|
23
|
-
|
|
24
|
-
const name = TypeFactory.getFullName(checker)(type, type.getSymbol());
|
|
25
|
-
const generic = type.aliasSymbol
|
|
26
|
-
? type.aliasTypeArguments
|
|
27
|
-
: checker.getTypeArguments(type as ts.TypeReference);
|
|
28
|
-
if (name.substring(0, 4) !== "Set<" || generic?.length !== 1) return false;
|
|
29
|
-
|
|
30
|
-
const key: ts.Type = generic[0]!;
|
|
31
|
-
ArrayUtil.set(
|
|
32
|
-
meta.sets,
|
|
33
|
-
explore_metadata(checker)(options)(collection)(errors)(key, {
|
|
34
|
-
...explore,
|
|
35
|
-
escaped: false,
|
|
36
|
-
aliased: false,
|
|
37
|
-
}),
|
|
38
|
-
(elem) => elem.getName(),
|
|
39
|
-
);
|
|
40
|
-
return true;
|
|
41
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
6
|
+
|
|
7
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
8
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
9
|
+
import { TypeFactory } from "../../TypeFactory";
|
|
10
|
+
import { explore_metadata } from "./explore_metadata";
|
|
11
|
+
|
|
12
|
+
export const iterate_metadata_set =
|
|
13
|
+
(checker: ts.TypeChecker) =>
|
|
14
|
+
(options: MetadataFactory.IOptions) =>
|
|
15
|
+
(collection: MetadataCollection) =>
|
|
16
|
+
(errors: MetadataFactory.IError[]) =>
|
|
17
|
+
(
|
|
18
|
+
meta: Metadata,
|
|
19
|
+
type: ts.Type,
|
|
20
|
+
explore: MetadataFactory.IExplore,
|
|
21
|
+
): boolean => {
|
|
22
|
+
type = checker.getApparentType(type);
|
|
23
|
+
|
|
24
|
+
const name = TypeFactory.getFullName(checker)(type, type.getSymbol());
|
|
25
|
+
const generic = type.aliasSymbol
|
|
26
|
+
? type.aliasTypeArguments
|
|
27
|
+
: checker.getTypeArguments(type as ts.TypeReference);
|
|
28
|
+
if (name.substring(0, 4) !== "Set<" || generic?.length !== 1) return false;
|
|
29
|
+
|
|
30
|
+
const key: ts.Type = generic[0]!;
|
|
31
|
+
ArrayUtil.set(
|
|
32
|
+
meta.sets,
|
|
33
|
+
explore_metadata(checker)(options)(collection)(errors)(key, {
|
|
34
|
+
...explore,
|
|
35
|
+
escaped: false,
|
|
36
|
+
aliased: false,
|
|
37
|
+
}),
|
|
38
|
+
(elem) => elem.getName(),
|
|
39
|
+
);
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataTemplate } from "../../../schemas/metadata/MetadataTemplate";
|
|
5
|
-
|
|
6
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
7
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
8
|
-
import { MetadataHelper } from "./MetadataHelper";
|
|
9
|
-
import { explore_metadata } from "./explore_metadata";
|
|
10
|
-
|
|
11
|
-
export const iterate_metadata_template =
|
|
12
|
-
(checker: ts.TypeChecker) =>
|
|
13
|
-
(options: MetadataFactory.IOptions) =>
|
|
14
|
-
(collection: MetadataCollection) =>
|
|
15
|
-
(errors: MetadataFactory.IError[]) =>
|
|
16
|
-
(
|
|
17
|
-
meta: Metadata,
|
|
18
|
-
type: ts.Type,
|
|
19
|
-
explore: MetadataFactory.IExplore,
|
|
20
|
-
): boolean => {
|
|
21
|
-
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
22
|
-
if (!filter(ts.TypeFlags.TemplateLiteral)) return false;
|
|
23
|
-
|
|
24
|
-
const template: ts.TemplateLiteralType = type as ts.TemplateLiteralType;
|
|
25
|
-
const row: Metadata[] = [];
|
|
26
|
-
|
|
27
|
-
template.texts.forEach((text, i) => {
|
|
28
|
-
// TEXT LITERAL TYPE
|
|
29
|
-
if (text !== "") row.push(MetadataHelper.literal_to_metadata(text));
|
|
30
|
-
|
|
31
|
-
// BINDED TEMPLATE TYPE
|
|
32
|
-
const binded: ts.Type | undefined = template.types[i];
|
|
33
|
-
if (binded)
|
|
34
|
-
row.push(
|
|
35
|
-
explore_metadata(checker)(options)(collection)(errors)(binded, {
|
|
36
|
-
...explore,
|
|
37
|
-
escaped: false,
|
|
38
|
-
aliased: false,
|
|
39
|
-
}),
|
|
40
|
-
);
|
|
41
|
-
});
|
|
42
|
-
meta.templates.push(MetadataTemplate.create({ row, tags: undefined }));
|
|
43
|
-
return true;
|
|
44
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataTemplate } from "../../../schemas/metadata/MetadataTemplate";
|
|
5
|
+
|
|
6
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
7
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
8
|
+
import { MetadataHelper } from "./MetadataHelper";
|
|
9
|
+
import { explore_metadata } from "./explore_metadata";
|
|
10
|
+
|
|
11
|
+
export const iterate_metadata_template =
|
|
12
|
+
(checker: ts.TypeChecker) =>
|
|
13
|
+
(options: MetadataFactory.IOptions) =>
|
|
14
|
+
(collection: MetadataCollection) =>
|
|
15
|
+
(errors: MetadataFactory.IError[]) =>
|
|
16
|
+
(
|
|
17
|
+
meta: Metadata,
|
|
18
|
+
type: ts.Type,
|
|
19
|
+
explore: MetadataFactory.IExplore,
|
|
20
|
+
): boolean => {
|
|
21
|
+
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
22
|
+
if (!filter(ts.TypeFlags.TemplateLiteral)) return false;
|
|
23
|
+
|
|
24
|
+
const template: ts.TemplateLiteralType = type as ts.TemplateLiteralType;
|
|
25
|
+
const row: Metadata[] = [];
|
|
26
|
+
|
|
27
|
+
template.texts.forEach((text, i) => {
|
|
28
|
+
// TEXT LITERAL TYPE
|
|
29
|
+
if (text !== "") row.push(MetadataHelper.literal_to_metadata(text));
|
|
30
|
+
|
|
31
|
+
// BINDED TEMPLATE TYPE
|
|
32
|
+
const binded: ts.Type | undefined = template.types[i];
|
|
33
|
+
if (binded)
|
|
34
|
+
row.push(
|
|
35
|
+
explore_metadata(checker)(options)(collection)(errors)(binded, {
|
|
36
|
+
...explore,
|
|
37
|
+
escaped: false,
|
|
38
|
+
aliased: false,
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
meta.templates.push(MetadataTemplate.create({ row, tags: undefined }));
|
|
43
|
+
return true;
|
|
44
|
+
};
|