typia 3.6.2 → 3.6.4
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 +2 -1
- package/lib/factories/internal/metadata/emplace_metadata_object.js +8 -7
- package/lib/factories/internal/metadata/emplace_metadata_object.js.map +1 -1
- package/lib/functional/$is_uuid.js +1 -1
- package/lib/functional/$is_uuid.js.map +1 -1
- package/lib/module.d.ts +2 -2
- package/package.json +1 -1
- package/src/executable/setup/ArgumentParser.ts +91 -91
- package/src/executable/setup/FileRetriever.ts +33 -33
- package/src/executable/setup/PackageManager.ts +92 -92
- package/src/executable/setup/PluginConfigurator.ts +99 -99
- package/src/factories/internal/metadata/emplace_metadata_object.ts +142 -140
- package/src/functional/$is_uuid.ts +1 -2
- package/src/module.ts +1946 -1946
- package/src/programmers/AssertCloneProgrammer.ts +70 -70
- package/src/programmers/AssertParseProgrammer.ts +65 -65
- package/src/programmers/AssertProgrammer.ts +232 -232
- package/src/programmers/AssertPruneProgrammer.ts +67 -67
- package/src/programmers/AssertStringifyProgrammer.ts +71 -71
- package/src/programmers/CheckerProgrammer.ts +893 -893
- package/src/programmers/CloneProgrammer.ts +386 -386
- package/src/programmers/FeatureProgrammer.ts +505 -505
- package/src/programmers/IsCloneProgrammer.ts +80 -80
- package/src/programmers/IsParseProgrammer.ts +74 -74
- package/src/programmers/IsPruneProgrammer.ts +75 -75
- package/src/programmers/IsStringifyProgrammer.ts +81 -81
- package/src/programmers/PruneProgrammer.ts +341 -341
- package/src/programmers/RandomProgrammer.ts +391 -391
- package/src/programmers/StringifyProgrammer.ts +795 -795
- package/src/programmers/ValidateCloneProgrammer.ts +90 -90
- package/src/programmers/ValidateParseProgrammer.ts +69 -69
- package/src/programmers/ValidateProgrammer.ts +266 -266
- package/src/programmers/ValidatePruneProgrammer.ts +83 -83
- package/src/programmers/ValidateStringifyProgrammer.ts +89 -89
- package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateRandomGenerator.ts +42 -42
- package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/PruneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/RandomTransformer.ts +48 -48
- package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +9 -9
- package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +9 -9
- package/src/transformers/features/parsers/AssertParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/CreateIsParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/IsParseTransformer.ts +9 -9
- package/src/transformers/features/parsers/ValidateParseTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +10 -10
- package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +11 -11
- package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/StringifyTransformer.ts +9 -9
- package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +10 -10
- package/src/transformers/features/validators/AssertTransformer.ts +11 -11
- package/src/transformers/features/validators/CreateAssertTransformer.ts +12 -12
- package/src/transformers/features/validators/CreateIsTransformer.ts +10 -10
- package/src/transformers/features/validators/CreateValidateTransformer.ts +12 -12
- package/src/transformers/features/validators/IsTransformer.ts +10 -10
- package/src/transformers/features/validators/ValidateTransformer.ts +11 -11
- package/src/transformers/internal/GenericTransformer.ts +99 -99
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import type Comment from "comment-json";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
import { TypiaSetupWizard } from "../TypiaSetupWizard";
|
|
6
|
-
import { FileRetriever } from "./FileRetriever";
|
|
7
|
-
import { PackageManager } from "./PackageManager";
|
|
8
|
-
|
|
9
|
-
export namespace PluginConfigurator {
|
|
10
|
-
export async function configure(
|
|
11
|
-
pack: PackageManager,
|
|
12
|
-
args: TypiaSetupWizard.IArguments,
|
|
13
|
-
): Promise<void> {
|
|
14
|
-
// INSTALL COMMENT-JSON
|
|
15
|
-
const installed: boolean = pack.install({
|
|
16
|
-
dev: true,
|
|
17
|
-
modulo: "comment-json",
|
|
18
|
-
version: "4.2.3",
|
|
19
|
-
silent: true,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// DO CONFIGURE
|
|
23
|
-
const error: Error | null = await (async () => {
|
|
24
|
-
try {
|
|
25
|
-
await _Configure(pack, args);
|
|
26
|
-
return null;
|
|
27
|
-
} catch (exp) {
|
|
28
|
-
return exp as Error;
|
|
29
|
-
}
|
|
30
|
-
})();
|
|
31
|
-
|
|
32
|
-
// REMOVE IT
|
|
33
|
-
if (installed)
|
|
34
|
-
pack.erase({
|
|
35
|
-
modulo: "comment-json",
|
|
36
|
-
silent: true,
|
|
37
|
-
});
|
|
38
|
-
if (error !== null) throw error;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function _Configure(
|
|
42
|
-
pack: PackageManager,
|
|
43
|
-
args: TypiaSetupWizard.IArguments,
|
|
44
|
-
): Promise<void> {
|
|
45
|
-
// GET COMPILER-OPTIONS
|
|
46
|
-
const Comment: typeof import("comment-json") =
|
|
47
|
-
await FileRetriever.require(
|
|
48
|
-
path.join("node_modules", "comment-json"),
|
|
49
|
-
)(pack.directory);
|
|
50
|
-
|
|
51
|
-
const config: Comment.CommentObject = Comment.parse(
|
|
52
|
-
await fs.promises.readFile(args.project!, "utf8"),
|
|
53
|
-
) as Comment.CommentObject;
|
|
54
|
-
const compilerOptions = config.compilerOptions as
|
|
55
|
-
| Comment.CommentObject
|
|
56
|
-
| undefined;
|
|
57
|
-
if (compilerOptions === undefined)
|
|
58
|
-
throw new Error(
|
|
59
|
-
`${args.project} file does not have "compilerOptions" property.`,
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
// PREPARE PLUGINS
|
|
63
|
-
const plugins: Comment.CommentArray<Comment.CommentObject> = (() => {
|
|
64
|
-
const plugins = compilerOptions.plugins as
|
|
65
|
-
| Comment.CommentArray<Comment.CommentObject>
|
|
66
|
-
| undefined;
|
|
67
|
-
if (plugins === undefined)
|
|
68
|
-
return (compilerOptions.plugins = [] as any);
|
|
69
|
-
else if (!Array.isArray(plugins))
|
|
70
|
-
throw new Error(
|
|
71
|
-
`"plugins" property of ${args.project} must be array type.`,
|
|
72
|
-
);
|
|
73
|
-
return plugins;
|
|
74
|
-
})();
|
|
75
|
-
|
|
76
|
-
const strict: boolean = compilerOptions.strict === true;
|
|
77
|
-
const oldbie: Comment.CommentObject | undefined = plugins.find(
|
|
78
|
-
(p) =>
|
|
79
|
-
typeof p === "object" &&
|
|
80
|
-
p !== null &&
|
|
81
|
-
p.transform === "typia/lib/transform",
|
|
82
|
-
);
|
|
83
|
-
if (strict === true && oldbie !== undefined) return;
|
|
84
|
-
|
|
85
|
-
// DO CONFIGURE
|
|
86
|
-
compilerOptions.strict = true;
|
|
87
|
-
if (oldbie === undefined)
|
|
88
|
-
plugins.push(
|
|
89
|
-
Comment.parse(`
|
|
90
|
-
{
|
|
91
|
-
"transform": "typia/lib/transform"
|
|
92
|
-
}`) as Comment.CommentObject,
|
|
93
|
-
);
|
|
94
|
-
await fs.promises.writeFile(
|
|
95
|
-
args.project!,
|
|
96
|
-
Comment.stringify(config, null, 2),
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
1
|
+
import type Comment from "comment-json";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
import { TypiaSetupWizard } from "../TypiaSetupWizard";
|
|
6
|
+
import { FileRetriever } from "./FileRetriever";
|
|
7
|
+
import { PackageManager } from "./PackageManager";
|
|
8
|
+
|
|
9
|
+
export namespace PluginConfigurator {
|
|
10
|
+
export async function configure(
|
|
11
|
+
pack: PackageManager,
|
|
12
|
+
args: TypiaSetupWizard.IArguments,
|
|
13
|
+
): Promise<void> {
|
|
14
|
+
// INSTALL COMMENT-JSON
|
|
15
|
+
const installed: boolean = pack.install({
|
|
16
|
+
dev: true,
|
|
17
|
+
modulo: "comment-json",
|
|
18
|
+
version: "4.2.3",
|
|
19
|
+
silent: true,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// DO CONFIGURE
|
|
23
|
+
const error: Error | null = await (async () => {
|
|
24
|
+
try {
|
|
25
|
+
await _Configure(pack, args);
|
|
26
|
+
return null;
|
|
27
|
+
} catch (exp) {
|
|
28
|
+
return exp as Error;
|
|
29
|
+
}
|
|
30
|
+
})();
|
|
31
|
+
|
|
32
|
+
// REMOVE IT
|
|
33
|
+
if (installed)
|
|
34
|
+
pack.erase({
|
|
35
|
+
modulo: "comment-json",
|
|
36
|
+
silent: true,
|
|
37
|
+
});
|
|
38
|
+
if (error !== null) throw error;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function _Configure(
|
|
42
|
+
pack: PackageManager,
|
|
43
|
+
args: TypiaSetupWizard.IArguments,
|
|
44
|
+
): Promise<void> {
|
|
45
|
+
// GET COMPILER-OPTIONS
|
|
46
|
+
const Comment: typeof import("comment-json") =
|
|
47
|
+
await FileRetriever.require(
|
|
48
|
+
path.join("node_modules", "comment-json"),
|
|
49
|
+
)(pack.directory);
|
|
50
|
+
|
|
51
|
+
const config: Comment.CommentObject = Comment.parse(
|
|
52
|
+
await fs.promises.readFile(args.project!, "utf8"),
|
|
53
|
+
) as Comment.CommentObject;
|
|
54
|
+
const compilerOptions = config.compilerOptions as
|
|
55
|
+
| Comment.CommentObject
|
|
56
|
+
| undefined;
|
|
57
|
+
if (compilerOptions === undefined)
|
|
58
|
+
throw new Error(
|
|
59
|
+
`${args.project} file does not have "compilerOptions" property.`,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// PREPARE PLUGINS
|
|
63
|
+
const plugins: Comment.CommentArray<Comment.CommentObject> = (() => {
|
|
64
|
+
const plugins = compilerOptions.plugins as
|
|
65
|
+
| Comment.CommentArray<Comment.CommentObject>
|
|
66
|
+
| undefined;
|
|
67
|
+
if (plugins === undefined)
|
|
68
|
+
return (compilerOptions.plugins = [] as any);
|
|
69
|
+
else if (!Array.isArray(plugins))
|
|
70
|
+
throw new Error(
|
|
71
|
+
`"plugins" property of ${args.project} must be array type.`,
|
|
72
|
+
);
|
|
73
|
+
return plugins;
|
|
74
|
+
})();
|
|
75
|
+
|
|
76
|
+
const strict: boolean = compilerOptions.strict === true;
|
|
77
|
+
const oldbie: Comment.CommentObject | undefined = plugins.find(
|
|
78
|
+
(p) =>
|
|
79
|
+
typeof p === "object" &&
|
|
80
|
+
p !== null &&
|
|
81
|
+
p.transform === "typia/lib/transform",
|
|
82
|
+
);
|
|
83
|
+
if (strict === true && oldbie !== undefined) return;
|
|
84
|
+
|
|
85
|
+
// DO CONFIGURE
|
|
86
|
+
compilerOptions.strict = true;
|
|
87
|
+
if (oldbie === undefined)
|
|
88
|
+
plugins.push(
|
|
89
|
+
Comment.parse(`
|
|
90
|
+
{
|
|
91
|
+
"transform": "typia/lib/transform"
|
|
92
|
+
}`) as Comment.CommentObject,
|
|
93
|
+
);
|
|
94
|
+
await fs.promises.writeFile(
|
|
95
|
+
args.project!,
|
|
96
|
+
Comment.stringify(config, null, 2),
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -1,140 +1,142 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
-
import { MetadataObject } from "../../../metadata/MetadataObject";
|
|
5
|
-
import { MetadataProperty } from "../../../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 { MetadataTagFactory } from "../../MetadataTagFactory";
|
|
15
|
-
import { MetadataHelper } from "./MetadataHelper";
|
|
16
|
-
import { explore_metadata } from "./explore_metadata";
|
|
17
|
-
|
|
18
|
-
export const emplace_metadata_object =
|
|
19
|
-
(checker: ts.TypeChecker) =>
|
|
20
|
-
(options: MetadataFactory.IOptions) =>
|
|
21
|
-
(collection: MetadataCollection) =>
|
|
22
|
-
(parent: ts.Type, nullable: boolean): MetadataObject => {
|
|
23
|
-
// EMPLACE OBJECT
|
|
24
|
-
const [obj, newbie] = collection.emplace(checker, parent);
|
|
25
|
-
ArrayUtil.add(obj.nullables, nullable, (elem) => elem === nullable);
|
|
26
|
-
if (newbie === false) return obj;
|
|
27
|
-
|
|
28
|
-
// PREPARE ASSETS
|
|
29
|
-
const isClass: boolean = parent.isClass();
|
|
30
|
-
const pred: (node: ts.Declaration) => boolean = isClass
|
|
31
|
-
? (node) => {
|
|
32
|
-
const kind: ts.SyntaxKind | undefined = node
|
|
33
|
-
.getChildren()[0]
|
|
34
|
-
?.getChildren()[0]?.kind;
|
|
35
|
-
return (
|
|
36
|
-
kind !== ts.SyntaxKind.PrivateKeyword &&
|
|
37
|
-
kind !== ts.SyntaxKind.ProtectedKeyword &&
|
|
38
|
-
(ts.isParameter(node) ||
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
: (node) =>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
)(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
+
import { MetadataObject } from "../../../metadata/MetadataObject";
|
|
5
|
+
import { MetadataProperty } from "../../../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 { MetadataTagFactory } from "../../MetadataTagFactory";
|
|
15
|
+
import { MetadataHelper } from "./MetadataHelper";
|
|
16
|
+
import { explore_metadata } from "./explore_metadata";
|
|
17
|
+
|
|
18
|
+
export const emplace_metadata_object =
|
|
19
|
+
(checker: ts.TypeChecker) =>
|
|
20
|
+
(options: MetadataFactory.IOptions) =>
|
|
21
|
+
(collection: MetadataCollection) =>
|
|
22
|
+
(parent: ts.Type, nullable: boolean): MetadataObject => {
|
|
23
|
+
// EMPLACE OBJECT
|
|
24
|
+
const [obj, newbie] = collection.emplace(checker, parent);
|
|
25
|
+
ArrayUtil.add(obj.nullables, nullable, (elem) => elem === nullable);
|
|
26
|
+
if (newbie === false) return obj;
|
|
27
|
+
|
|
28
|
+
// PREPARE ASSETS
|
|
29
|
+
const isClass: boolean = parent.isClass();
|
|
30
|
+
const pred: (node: ts.Declaration) => boolean = isClass
|
|
31
|
+
? (node) => {
|
|
32
|
+
const kind: ts.SyntaxKind | undefined = node
|
|
33
|
+
.getChildren()[0]
|
|
34
|
+
?.getChildren()[0]?.kind;
|
|
35
|
+
return (
|
|
36
|
+
kind !== ts.SyntaxKind.PrivateKeyword &&
|
|
37
|
+
kind !== ts.SyntaxKind.ProtectedKeyword &&
|
|
38
|
+
(ts.isParameter(node) || isProperty(node))
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
: (node) => isProperty(node);
|
|
42
|
+
|
|
43
|
+
const insert =
|
|
44
|
+
(key: Metadata) =>
|
|
45
|
+
(value: Metadata) =>
|
|
46
|
+
(identifier: () => string) =>
|
|
47
|
+
(
|
|
48
|
+
symbol: ts.Symbol | undefined,
|
|
49
|
+
filter?: (doc: ts.JSDocTagInfo) => boolean,
|
|
50
|
+
): MetadataProperty => {
|
|
51
|
+
// COMMENTS AND TAGS
|
|
52
|
+
const description: string | undefined =
|
|
53
|
+
CommentFactory.generate(
|
|
54
|
+
symbol?.getDocumentationComment(checker) || [],
|
|
55
|
+
) || undefined;
|
|
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
|
+
tags: MetadataTagFactory.generate(
|
|
67
|
+
() => identifier(),
|
|
68
|
+
value,
|
|
69
|
+
jsDocTags,
|
|
70
|
+
),
|
|
71
|
+
});
|
|
72
|
+
obj.properties.push(property);
|
|
73
|
+
return property;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
//----
|
|
77
|
+
// REGULAR PROPERTIES
|
|
78
|
+
//----
|
|
79
|
+
for (const prop of parent.getApparentProperties()) {
|
|
80
|
+
// CHECK INTERNAL TAG
|
|
81
|
+
if (
|
|
82
|
+
(prop.getJsDocTags(checker) || []).find(
|
|
83
|
+
(tag) => tag.name === "internal",
|
|
84
|
+
) !== undefined
|
|
85
|
+
)
|
|
86
|
+
continue;
|
|
87
|
+
|
|
88
|
+
// CHECK NODE IS A FORMAL PROPERTY
|
|
89
|
+
const [node, type] = (() => {
|
|
90
|
+
const node = (prop.getDeclarations() || [])[0] as
|
|
91
|
+
| ts.PropertyDeclaration
|
|
92
|
+
| undefined;
|
|
93
|
+
const type: ts.Type | undefined = node
|
|
94
|
+
? checker.getTypeOfSymbolAtLocation(prop, node)
|
|
95
|
+
: "getTypeOfPropertyOfType" in checker
|
|
96
|
+
? (checker as any).getTypeOfPropertyOfType(
|
|
97
|
+
parent,
|
|
98
|
+
prop.name,
|
|
99
|
+
)
|
|
100
|
+
: undefined;
|
|
101
|
+
return [node, type];
|
|
102
|
+
})();
|
|
103
|
+
if ((node && pred(node) === false) || type === undefined) continue;
|
|
104
|
+
|
|
105
|
+
// GET EXACT TYPE
|
|
106
|
+
const key: Metadata = MetadataHelper.literal_to_metadata(prop.name);
|
|
107
|
+
const value: Metadata = explore_metadata(checker)(options)(
|
|
108
|
+
collection,
|
|
109
|
+
)(type, false);
|
|
110
|
+
|
|
111
|
+
// INSERT WITH REQUIRED CONFIGURATION
|
|
112
|
+
if (node?.questionToken) Writable(value).required = false;
|
|
113
|
+
insert(key)(value)(() => `${obj.name}.${prop.name}`)(prop);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//----
|
|
117
|
+
// DYNAMIC PROPERTIES
|
|
118
|
+
//----
|
|
119
|
+
for (const index of checker.getIndexInfosOfType(parent)) {
|
|
120
|
+
// GET EXACT TYPE
|
|
121
|
+
const analyzer = (type: ts.Type) =>
|
|
122
|
+
explore_metadata(checker)(options)(collection)(type, false);
|
|
123
|
+
const key: Metadata = analyzer(index.keyType);
|
|
124
|
+
const value: Metadata = analyzer(index.type);
|
|
125
|
+
|
|
126
|
+
// INSERT WITH REQUIRED CONFIGURATION
|
|
127
|
+
insert(key)(value)(() => `${obj.name}[${key.getName()}]`)(
|
|
128
|
+
index.declaration?.parent
|
|
129
|
+
? checker.getSymbolAtLocation(index.declaration.parent)
|
|
130
|
+
: undefined,
|
|
131
|
+
(doc) => doc.name !== "default",
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return obj;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const isProperty = (node: ts.Declaration) =>
|
|
139
|
+
ts.isPropertyDeclaration(node) ||
|
|
140
|
+
ts.isPropertyAssignment(node) ||
|
|
141
|
+
ts.isPropertySignature(node) ||
|
|
142
|
+
ts.isTypeLiteralNode(node);
|