@nestia/sdk 2.5.0-dev.20240130-3 → 2.5.0-dev.20240130-5
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/generates/CloneGenerator.js +11 -11
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +11 -11
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/FilePrinter.d.ts +10 -0
- package/lib/{utils/FormatUtil.js → generates/internal/FilePrinter.js} +17 -9
- package/lib/generates/internal/FilePrinter.js.map +1 -0
- package/lib/{utils → generates/internal}/ImportDictionary.d.ts +0 -1
- package/lib/{utils → generates/internal}/ImportDictionary.js +2 -39
- package/lib/generates/internal/ImportDictionary.js.map +1 -0
- package/lib/generates/internal/SdkAliasCollection.d.ts +1 -1
- package/lib/generates/internal/SdkAliasCollection.js +1 -1
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.js +15 -15
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkFunctionProgrammer.d.ts +1 -1
- package/lib/generates/internal/SdkFunctionProgrammer.js +1 -1
- package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkImportWizard.d.ts +1 -1
- package/lib/generates/internal/SdkInterfaceProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkInterfaceProgrammer.js +18 -17
- package/lib/generates/internal/SdkInterfaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkNamespaceProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkNamespaceProgrammer.js +13 -13
- package/lib/generates/internal/SdkNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkRouteProgrammer.d.ts +1 -1
- package/lib/generates/internal/SdkRouteProgrammer.js +3 -3
- package/lib/generates/internal/SdkRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkSimulationProgrammer.d.ts +1 -1
- package/lib/generates/internal/SdkSimulationProgrammer.js +1 -1
- package/lib/generates/internal/SdkSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkTypeProgrammer.js +89 -31
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/package.json +3 -3
- package/src/generates/CloneGenerator.ts +10 -20
- package/src/generates/internal/E2eFileProgrammer.ts +11 -24
- package/src/generates/internal/FilePrinter.ts +53 -0
- package/src/{utils → generates/internal}/ImportDictionary.ts +2 -50
- package/src/generates/internal/SdkAliasCollection.ts +2 -2
- package/src/generates/internal/SdkFileProgrammer.ts +16 -27
- package/src/generates/internal/SdkFunctionProgrammer.ts +2 -2
- package/src/generates/internal/SdkImportWizard.ts +1 -1
- package/src/generates/internal/SdkInterfaceProgrammer.ts +24 -23
- package/src/generates/internal/SdkNamespaceProgrammer.ts +14 -14
- package/src/generates/internal/SdkRouteProgrammer.ts +4 -7
- package/src/generates/internal/SdkSimulationProgrammer.ts +2 -2
- package/src/generates/internal/SdkTypeProgrammer.ts +155 -38
- package/lib/utils/FormatUtil.d.ts +0 -6
- package/lib/utils/FormatUtil.js.map +0 -1
- package/lib/utils/ImportDictionary.js.map +0 -1
- package/src/utils/FormatUtil.ts +0 -31
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
1
|
import ts from "typescript";
|
|
3
2
|
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
4
3
|
|
|
5
4
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
6
5
|
import { IRoute } from "../../structures/IRoute";
|
|
7
|
-
import {
|
|
8
|
-
import { ImportDictionary } from "
|
|
6
|
+
import { FilePrinter } from "./FilePrinter";
|
|
7
|
+
import { ImportDictionary } from "./ImportDictionary";
|
|
9
8
|
import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
10
9
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
11
10
|
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
@@ -35,26 +34,14 @@ export namespace E2eFileProgrammer {
|
|
|
35
34
|
});
|
|
36
35
|
|
|
37
36
|
const functor = generate_function(checker)(config)(importer)(route);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
[
|
|
47
|
-
...importer.toStatements(props.current),
|
|
48
|
-
FormatUtil.enter(),
|
|
49
|
-
functor,
|
|
50
|
-
],
|
|
51
|
-
ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
|
|
52
|
-
ts.NodeFlags.None,
|
|
53
|
-
),
|
|
54
|
-
),
|
|
55
|
-
),
|
|
56
|
-
"utf8",
|
|
57
|
-
);
|
|
37
|
+
await FilePrinter.write({
|
|
38
|
+
location: importer.file,
|
|
39
|
+
statements: [
|
|
40
|
+
...importer.toStatements(props.current),
|
|
41
|
+
FilePrinter.enter(),
|
|
42
|
+
functor,
|
|
43
|
+
],
|
|
44
|
+
});
|
|
58
45
|
};
|
|
59
46
|
|
|
60
47
|
const generate_function =
|
|
@@ -187,5 +174,5 @@ const getTypeName =
|
|
|
187
174
|
(importer: ImportDictionary) =>
|
|
188
175
|
(p: IRoute.IParameter | IRoute.IOutput) =>
|
|
189
176
|
p.metadata
|
|
190
|
-
? SdkTypeProgrammer.
|
|
177
|
+
? SdkTypeProgrammer.write(config)(importer)(p.metadata)
|
|
191
178
|
: ts.factory.createTypeReferenceNode(p.typeName);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { format } from "prettier";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
|
|
5
|
+
export namespace FilePrinter {
|
|
6
|
+
export const description = <Node extends ts.Node>(
|
|
7
|
+
node: Node,
|
|
8
|
+
comment: string,
|
|
9
|
+
): Node => {
|
|
10
|
+
if (comment.length === 0) return node;
|
|
11
|
+
ts.addSyntheticLeadingComment(
|
|
12
|
+
node,
|
|
13
|
+
ts.SyntaxKind.MultiLineCommentTrivia,
|
|
14
|
+
["*", ...comment.split("\n").map((str) => ` * ${str}`), ""].join("\n"),
|
|
15
|
+
true,
|
|
16
|
+
);
|
|
17
|
+
return node;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const enter = () =>
|
|
21
|
+
ts.factory.createExpressionStatement(ts.factory.createIdentifier("\n"));
|
|
22
|
+
|
|
23
|
+
export const write = async (props: {
|
|
24
|
+
location: string;
|
|
25
|
+
statements: ts.Statement[];
|
|
26
|
+
top?: string;
|
|
27
|
+
}): Promise<void> => {
|
|
28
|
+
const script: string = ts
|
|
29
|
+
.createPrinter()
|
|
30
|
+
.printFile(
|
|
31
|
+
ts.factory.createSourceFile(
|
|
32
|
+
props.statements,
|
|
33
|
+
ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
|
|
34
|
+
ts.NodeFlags.None,
|
|
35
|
+
),
|
|
36
|
+
);
|
|
37
|
+
await fs.promises.writeFile(
|
|
38
|
+
props.location,
|
|
39
|
+
await beautify((props.top ?? "") + script),
|
|
40
|
+
"utf8",
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const beautify = async (script: string): Promise<string> => {
|
|
45
|
+
try {
|
|
46
|
+
return await format(script, {
|
|
47
|
+
parser: "typescript",
|
|
48
|
+
});
|
|
49
|
+
} catch {
|
|
50
|
+
return script;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -4,7 +4,7 @@ import { HashSet } from "tstl/container/HashSet";
|
|
|
4
4
|
import { Pair } from "tstl/utility/Pair";
|
|
5
5
|
import ts from "typescript";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { FilePrinter } from "./FilePrinter";
|
|
8
8
|
|
|
9
9
|
export class ImportDictionary {
|
|
10
10
|
private readonly components_: HashMap<Pair<string, boolean>, IComposition> =
|
|
@@ -119,58 +119,10 @@ export class ImportDictionary {
|
|
|
119
119
|
enroll((str) => str.indexOf(NODE_MODULES) === -1)(internal);
|
|
120
120
|
return [
|
|
121
121
|
...external,
|
|
122
|
-
...(external.length && internal.length ? [
|
|
122
|
+
...(external.length && internal.length ? [FilePrinter.enter()] : []),
|
|
123
123
|
...internal,
|
|
124
124
|
];
|
|
125
125
|
}
|
|
126
|
-
|
|
127
|
-
public toScript(outDir: string): string {
|
|
128
|
-
const external: string[] = [];
|
|
129
|
-
const internal: string[] = [];
|
|
130
|
-
|
|
131
|
-
const locator = (str: string) => {
|
|
132
|
-
const location: string = path.relative(outDir, str).split("\\").join("/");
|
|
133
|
-
const index: number = location.lastIndexOf(NODE_MODULES);
|
|
134
|
-
return index === -1
|
|
135
|
-
? location.startsWith("..")
|
|
136
|
-
? location
|
|
137
|
-
: `./${location}`
|
|
138
|
-
: location.substring(index + NODE_MODULES.length);
|
|
139
|
-
};
|
|
140
|
-
const enroll =
|
|
141
|
-
(filter: (str: string) => boolean) => (container: string[]) => {
|
|
142
|
-
const compositions: IComposition[] = this.components_
|
|
143
|
-
.toJSON()
|
|
144
|
-
.filter((c) => filter(c.second.location))
|
|
145
|
-
.map((e) => ({
|
|
146
|
-
...e.second,
|
|
147
|
-
location: locator(e.second.location),
|
|
148
|
-
}))
|
|
149
|
-
.sort((a, b) => a.location.localeCompare(b.location));
|
|
150
|
-
for (const c of compositions) {
|
|
151
|
-
const brackets: string[] = [];
|
|
152
|
-
if (c.default) brackets.push(c.name ?? c.location);
|
|
153
|
-
if (c.elements.empty() === false)
|
|
154
|
-
brackets.push(
|
|
155
|
-
`{ ${c.elements
|
|
156
|
-
.toJSON()
|
|
157
|
-
.sort((a, b) => a.localeCompare(b))
|
|
158
|
-
.join(", ")} }`,
|
|
159
|
-
);
|
|
160
|
-
container.push(
|
|
161
|
-
`import ${c.type ? "type " : ""}${brackets.join(", ")} from "${
|
|
162
|
-
c.location
|
|
163
|
-
}";`,
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
enroll((str) => str.indexOf(NODE_MODULES) !== -1)(external);
|
|
169
|
-
enroll((str) => str.indexOf(NODE_MODULES) === -1)(internal);
|
|
170
|
-
|
|
171
|
-
if (external.length && internal.length) external.push("");
|
|
172
|
-
return [...external, ...internal].join("\n");
|
|
173
|
-
}
|
|
174
126
|
}
|
|
175
127
|
export namespace ImportDictionary {
|
|
176
128
|
export interface IExternalProps {
|
|
@@ -2,7 +2,7 @@ import ts from "typescript";
|
|
|
2
2
|
|
|
3
3
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
4
4
|
import { IRoute } from "../../structures/IRoute";
|
|
5
|
-
import { ImportDictionary } from "
|
|
5
|
+
import { ImportDictionary } from "./ImportDictionary";
|
|
6
6
|
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
7
7
|
|
|
8
8
|
export namespace SdkAliasCollection {
|
|
@@ -11,7 +11,7 @@ export namespace SdkAliasCollection {
|
|
|
11
11
|
(importer: ImportDictionary) =>
|
|
12
12
|
(p: IRoute.IParameter | IRoute.IOutput): ts.TypeNode =>
|
|
13
13
|
p.metadata
|
|
14
|
-
? SdkTypeProgrammer.
|
|
14
|
+
? SdkTypeProgrammer.write(config)(importer)(p.metadata)
|
|
15
15
|
: ts.factory.createTypeReferenceNode(p.typeName);
|
|
16
16
|
|
|
17
17
|
export const headers =
|
|
@@ -3,9 +3,9 @@ import ts from "typescript";
|
|
|
3
3
|
|
|
4
4
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
5
5
|
import { IRoute } from "../../structures/IRoute";
|
|
6
|
-
import { FormatUtil } from "../../utils/FormatUtil";
|
|
7
|
-
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
8
6
|
import { MapUtil } from "../../utils/MapUtil";
|
|
7
|
+
import { FilePrinter } from "./FilePrinter";
|
|
8
|
+
import { ImportDictionary } from "./ImportDictionary";
|
|
9
9
|
import { SdkRouteDirectory } from "./SdkRouteDirectory";
|
|
10
10
|
import { SdkRouteProgrammer } from "./SdkRouteProgrammer";
|
|
11
11
|
|
|
@@ -69,7 +69,7 @@ export namespace SdkFileProgrammer {
|
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
if (statements.length && directory.routes.length)
|
|
72
|
-
statements.push(
|
|
72
|
+
statements.push(FilePrinter.enter());
|
|
73
73
|
|
|
74
74
|
// ITERATE ROUTES
|
|
75
75
|
const importer: ImportDictionary = new ImportDictionary(
|
|
@@ -97,7 +97,7 @@ export namespace SdkFileProgrammer {
|
|
|
97
97
|
...SdkRouteProgrammer.generate(checker)(config)(importer)(route),
|
|
98
98
|
);
|
|
99
99
|
if (i !== directory.routes.length - 1)
|
|
100
|
-
statements.push(
|
|
100
|
+
statements.push(FilePrinter.enter());
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
// FINALIZE THE CONTENT
|
|
@@ -105,31 +105,20 @@ export namespace SdkFileProgrammer {
|
|
|
105
105
|
statements.push(
|
|
106
106
|
...importer.toStatements(outDir),
|
|
107
107
|
...(!importer.empty() && statements.length
|
|
108
|
-
? [
|
|
108
|
+
? [FilePrinter.enter()]
|
|
109
109
|
: []),
|
|
110
110
|
...statements.splice(0, statements.length),
|
|
111
111
|
);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
ts.factory.createSourceFile(
|
|
124
|
-
statements,
|
|
125
|
-
ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
|
|
126
|
-
ts.NodeFlags.None,
|
|
127
|
-
),
|
|
128
|
-
);
|
|
129
|
-
await fs.promises.writeFile(
|
|
130
|
-
importer.file,
|
|
131
|
-
await FormatUtil.beautify(script),
|
|
132
|
-
"utf8",
|
|
133
|
-
);
|
|
112
|
+
await FilePrinter.write({
|
|
113
|
+
location: importer.file,
|
|
114
|
+
statements,
|
|
115
|
+
top:
|
|
116
|
+
"/**\n" +
|
|
117
|
+
" * @packageDocumentation\n" +
|
|
118
|
+
` * @module ${directory.module}\n` +
|
|
119
|
+
" * @nestia Generated by Nestia - https://github.com/samchon/nestia \n" +
|
|
120
|
+
" */\n" +
|
|
121
|
+
"//================================================================\n",
|
|
122
|
+
});
|
|
134
123
|
};
|
|
135
124
|
}
|
|
@@ -5,7 +5,7 @@ import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
|
5
5
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
6
6
|
import { IController } from "../../structures/IController";
|
|
7
7
|
import { IRoute } from "../../structures/IRoute";
|
|
8
|
-
import { ImportDictionary } from "
|
|
8
|
+
import { ImportDictionary } from "./ImportDictionary";
|
|
9
9
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
10
10
|
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
11
11
|
|
|
@@ -215,5 +215,5 @@ const getTypeName =
|
|
|
215
215
|
(importer: ImportDictionary) =>
|
|
216
216
|
(p: IRoute.IParameter | IRoute.IOutput) =>
|
|
217
217
|
p.metadata
|
|
218
|
-
? SdkTypeProgrammer.
|
|
218
|
+
? SdkTypeProgrammer.write(config)(importer)(p.metadata)
|
|
219
219
|
: ts.factory.createTypeReferenceNode(p.typeName);
|
|
@@ -11,9 +11,9 @@ import { Escaper } from "typia/lib/utils/Escaper";
|
|
|
11
11
|
|
|
12
12
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
13
13
|
import { IRoute } from "../../structures/IRoute";
|
|
14
|
-
import { FormatUtil } from "../../utils/FormatUtil";
|
|
15
|
-
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
16
14
|
import { MapUtil } from "../../utils/MapUtil";
|
|
15
|
+
import { FilePrinter } from "./FilePrinter";
|
|
16
|
+
import { ImportDictionary } from "./ImportDictionary";
|
|
17
17
|
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
18
18
|
|
|
19
19
|
export namespace SdkInterfaceProgrammer {
|
|
@@ -25,7 +25,7 @@ export namespace SdkInterfaceProgrammer {
|
|
|
25
25
|
| ((importer: ImportDictionary) => ts.TypeAliasDeclaration);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export const
|
|
28
|
+
export const write =
|
|
29
29
|
(checker: ts.TypeChecker) =>
|
|
30
30
|
(config: INestiaConfig) =>
|
|
31
31
|
(routes: IRoute[]): Map<string, IModule> => {
|
|
@@ -60,12 +60,13 @@ export namespace SdkInterfaceProgrammer {
|
|
|
60
60
|
const dict: Map<string, IModule> = new Map();
|
|
61
61
|
for (const alias of collection.aliases())
|
|
62
62
|
prepare(dict)(alias.name)((importer) =>
|
|
63
|
-
|
|
63
|
+
write_alias(config)(importer)(alias),
|
|
64
64
|
);
|
|
65
65
|
for (const object of collection.objects())
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
if (object.name !== "__type" && !object.name.startsWith("__type."))
|
|
67
|
+
prepare(dict)(object.name)((importer) =>
|
|
68
|
+
write_object(config)(importer)(object),
|
|
69
|
+
);
|
|
69
70
|
return dict;
|
|
70
71
|
};
|
|
71
72
|
|
|
@@ -88,53 +89,53 @@ export namespace SdkInterfaceProgrammer {
|
|
|
88
89
|
return modulo!;
|
|
89
90
|
};
|
|
90
91
|
|
|
91
|
-
const
|
|
92
|
+
const write_alias =
|
|
92
93
|
(config: INestiaConfig) =>
|
|
93
94
|
(importer: ImportDictionary) =>
|
|
94
95
|
(alias: MetadataAlias): ts.TypeAliasDeclaration =>
|
|
95
|
-
|
|
96
|
+
FilePrinter.description(
|
|
96
97
|
ts.factory.createTypeAliasDeclaration(
|
|
97
98
|
[ts.factory.createToken(ts.SyntaxKind.ExportKeyword)],
|
|
98
99
|
alias.name.split(".").at(-1)!,
|
|
99
100
|
[],
|
|
100
|
-
SdkTypeProgrammer.
|
|
101
|
+
SdkTypeProgrammer.write(config)(importer)(alias.value),
|
|
101
102
|
),
|
|
102
103
|
writeComment([])(alias.description, alias.jsDocTags),
|
|
103
104
|
);
|
|
104
105
|
|
|
105
|
-
const
|
|
106
|
+
const write_object =
|
|
106
107
|
(config: INestiaConfig) =>
|
|
107
108
|
(importer: ImportDictionary) =>
|
|
108
109
|
(object: MetadataObject): ts.TypeAliasDeclaration => {
|
|
109
110
|
const regular = object.properties.filter((p) => p.key.isSoleLiteral());
|
|
110
111
|
const dynamic = object.properties.filter((p) => !p.key.isSoleLiteral());
|
|
111
|
-
return
|
|
112
|
+
return FilePrinter.description(
|
|
112
113
|
ts.factory.createTypeAliasDeclaration(
|
|
113
114
|
[ts.factory.createToken(ts.SyntaxKind.ExportKeyword)],
|
|
114
115
|
object.name.split(".").at(-1)!,
|
|
115
116
|
[],
|
|
116
117
|
regular.length && dynamic.length
|
|
117
118
|
? ts.factory.createIntersectionTypeNode([
|
|
118
|
-
|
|
119
|
-
...dynamic.map(
|
|
119
|
+
write_regular(config)(importer)(regular),
|
|
120
|
+
...dynamic.map(write_dynamic(config)(importer)),
|
|
120
121
|
])
|
|
121
122
|
: dynamic.length
|
|
122
123
|
? ts.factory.createIntersectionTypeNode(
|
|
123
|
-
dynamic.map(
|
|
124
|
+
dynamic.map(write_dynamic(config)(importer)),
|
|
124
125
|
)
|
|
125
|
-
:
|
|
126
|
+
: write_regular(config)(importer)(regular),
|
|
126
127
|
),
|
|
127
128
|
writeComment([])(object.description ?? null, object.jsDocTags),
|
|
128
129
|
);
|
|
129
130
|
};
|
|
130
131
|
|
|
131
|
-
const
|
|
132
|
+
const write_regular =
|
|
132
133
|
(config: INestiaConfig) =>
|
|
133
134
|
(importer: ImportDictionary) =>
|
|
134
135
|
(properties: MetadataProperty[]): ts.TypeLiteralNode =>
|
|
135
136
|
ts.factory.createTypeLiteralNode(
|
|
136
137
|
properties.map((p) =>
|
|
137
|
-
|
|
138
|
+
FilePrinter.description(
|
|
138
139
|
ts.factory.createPropertySignature(
|
|
139
140
|
undefined,
|
|
140
141
|
Escaper.variable(String(p.key.constants[0].values[0]))
|
|
@@ -147,19 +148,19 @@ export namespace SdkInterfaceProgrammer {
|
|
|
147
148
|
p.value.isRequired() === false
|
|
148
149
|
? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
|
|
149
150
|
: undefined,
|
|
150
|
-
SdkTypeProgrammer.
|
|
151
|
+
SdkTypeProgrammer.write(config)(importer)(p.value),
|
|
151
152
|
),
|
|
152
153
|
writeComment(p.value.atomics)(p.description, p.jsDocTags),
|
|
153
154
|
),
|
|
154
155
|
),
|
|
155
156
|
);
|
|
156
157
|
|
|
157
|
-
const
|
|
158
|
+
const write_dynamic =
|
|
158
159
|
(config: INestiaConfig) =>
|
|
159
160
|
(importer: ImportDictionary) =>
|
|
160
161
|
(property: MetadataProperty): ts.TypeLiteralNode =>
|
|
161
162
|
ts.factory.createTypeLiteralNode([
|
|
162
|
-
|
|
163
|
+
FilePrinter.description(
|
|
163
164
|
ts.factory.createIndexSignature(
|
|
164
165
|
undefined,
|
|
165
166
|
[
|
|
@@ -168,10 +169,10 @@ export namespace SdkInterfaceProgrammer {
|
|
|
168
169
|
undefined,
|
|
169
170
|
ts.factory.createIdentifier("key"),
|
|
170
171
|
undefined,
|
|
171
|
-
SdkTypeProgrammer.
|
|
172
|
+
SdkTypeProgrammer.write(config)(importer)(property.key),
|
|
172
173
|
),
|
|
173
174
|
],
|
|
174
|
-
SdkTypeProgrammer.
|
|
175
|
+
SdkTypeProgrammer.write(config)(importer)(property.value),
|
|
175
176
|
),
|
|
176
177
|
writeComment(property.value.atomics)(
|
|
177
178
|
property.description,
|
|
@@ -9,15 +9,15 @@ import { Escaper } from "typia/lib/utils/Escaper";
|
|
|
9
9
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
10
10
|
import { IController } from "../../structures/IController";
|
|
11
11
|
import { IRoute } from "../../structures/IRoute";
|
|
12
|
-
import {
|
|
13
|
-
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
12
|
+
import { ImportDictionary } from "./ImportDictionary";
|
|
14
13
|
import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
15
14
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
16
15
|
import { SdkSimulationProgrammer } from "./SdkSimulationProgrammer";
|
|
17
16
|
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
17
|
+
import { FilePrinter } from "./FilePrinter";
|
|
18
18
|
|
|
19
19
|
export namespace SdkNamespaceProgrammer {
|
|
20
|
-
export const
|
|
20
|
+
export const write =
|
|
21
21
|
(checker: ts.TypeChecker) =>
|
|
22
22
|
(config: INestiaConfig) =>
|
|
23
23
|
(importer: ImportDictionary) =>
|
|
@@ -29,16 +29,16 @@ export namespace SdkNamespaceProgrammer {
|
|
|
29
29
|
input: IRoute.IParameter | undefined;
|
|
30
30
|
},
|
|
31
31
|
): ts.ModuleDeclaration => {
|
|
32
|
-
const types =
|
|
32
|
+
const types = write_types(checker)(config)(importer)(route, props);
|
|
33
33
|
return ts.factory.createModuleDeclaration(
|
|
34
34
|
[ts.factory.createToken(ts.SyntaxKind.ExportKeyword)],
|
|
35
35
|
ts.factory.createIdentifier(route.name),
|
|
36
36
|
ts.factory.createModuleBlock([
|
|
37
37
|
...types,
|
|
38
|
-
...(types.length ? [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
...(types.length ? [FilePrinter.enter()] : []),
|
|
39
|
+
write_metadata(importer)(route, props),
|
|
40
|
+
FilePrinter.enter(),
|
|
41
|
+
write_path(config)(importer)(route, props),
|
|
42
42
|
...(config.simulate
|
|
43
43
|
? [
|
|
44
44
|
SdkSimulationProgrammer.random(checker)(config)(importer)(
|
|
@@ -51,14 +51,14 @@ export namespace SdkNamespaceProgrammer {
|
|
|
51
51
|
]
|
|
52
52
|
: []),
|
|
53
53
|
...(config.json && props.input?.category === "body"
|
|
54
|
-
? [
|
|
54
|
+
? [write_stringify(config)(importer)]
|
|
55
55
|
: []),
|
|
56
56
|
]),
|
|
57
57
|
ts.NodeFlags.Namespace,
|
|
58
58
|
);
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
const
|
|
61
|
+
const write_types =
|
|
62
62
|
(checker: ts.TypeChecker) =>
|
|
63
63
|
(config: INestiaConfig) =>
|
|
64
64
|
(importer: ImportDictionary) =>
|
|
@@ -103,7 +103,7 @@ export namespace SdkNamespaceProgrammer {
|
|
|
103
103
|
return array;
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
const
|
|
106
|
+
const write_metadata =
|
|
107
107
|
(importer: ImportDictionary) =>
|
|
108
108
|
(
|
|
109
109
|
route: IRoute,
|
|
@@ -184,7 +184,7 @@ export namespace SdkNamespaceProgrammer {
|
|
|
184
184
|
),
|
|
185
185
|
);
|
|
186
186
|
|
|
187
|
-
const
|
|
187
|
+
const write_path =
|
|
188
188
|
(config: INestiaConfig) =>
|
|
189
189
|
(importer: ImportDictionary) =>
|
|
190
190
|
(
|
|
@@ -440,7 +440,7 @@ export namespace SdkNamespaceProgrammer {
|
|
|
440
440
|
);
|
|
441
441
|
};
|
|
442
442
|
|
|
443
|
-
const
|
|
443
|
+
const write_stringify =
|
|
444
444
|
(config: INestiaConfig) =>
|
|
445
445
|
(importer: ImportDictionary): ts.VariableStatement =>
|
|
446
446
|
constant("stringify")(
|
|
@@ -503,5 +503,5 @@ const getType =
|
|
|
503
503
|
(importer: ImportDictionary) =>
|
|
504
504
|
(p: IRoute.IParameter | IRoute.IOutput) =>
|
|
505
505
|
p.metadata
|
|
506
|
-
? SdkTypeProgrammer.
|
|
506
|
+
? SdkTypeProgrammer.write(config)(importer)(p.metadata)
|
|
507
507
|
: ts.factory.createTypeReferenceNode(p.typeName);
|
|
@@ -3,10 +3,10 @@ import { IJsDocTagInfo } from "typia";
|
|
|
3
3
|
|
|
4
4
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
5
5
|
import { IRoute } from "../../structures/IRoute";
|
|
6
|
-
import {
|
|
7
|
-
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
6
|
+
import { ImportDictionary } from "./ImportDictionary";
|
|
8
7
|
import { SdkFunctionProgrammer } from "./SdkFunctionProgrammer";
|
|
9
8
|
import { SdkNamespaceProgrammer } from "./SdkNamespaceProgrammer";
|
|
9
|
+
import { FilePrinter } from "./FilePrinter";
|
|
10
10
|
|
|
11
11
|
export namespace SdkRouteProgrammer {
|
|
12
12
|
export const generate =
|
|
@@ -24,14 +24,11 @@ export namespace SdkRouteProgrammer {
|
|
|
24
24
|
input: route.parameters.find((p) => p.category === "body"),
|
|
25
25
|
};
|
|
26
26
|
return [
|
|
27
|
-
|
|
27
|
+
FilePrinter.description(
|
|
28
28
|
SdkFunctionProgrammer.generate(config)(importer)(route, props),
|
|
29
29
|
describe(route),
|
|
30
30
|
),
|
|
31
|
-
SdkNamespaceProgrammer.
|
|
32
|
-
route,
|
|
33
|
-
props,
|
|
34
|
-
),
|
|
31
|
+
SdkNamespaceProgrammer.write(checker)(config)(importer)(route, props),
|
|
35
32
|
];
|
|
36
33
|
};
|
|
37
34
|
|
|
@@ -7,7 +7,7 @@ import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
|
|
7
7
|
|
|
8
8
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
9
9
|
import { IRoute } from "../../structures/IRoute";
|
|
10
|
-
import { ImportDictionary } from "
|
|
10
|
+
import { ImportDictionary } from "./ImportDictionary";
|
|
11
11
|
import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
12
12
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
13
13
|
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
@@ -353,5 +353,5 @@ const getTypeName =
|
|
|
353
353
|
(importer: ImportDictionary) =>
|
|
354
354
|
(p: IRoute.IParameter | IRoute.IOutput) =>
|
|
355
355
|
p.metadata
|
|
356
|
-
? SdkTypeProgrammer.
|
|
356
|
+
? SdkTypeProgrammer.write(config)(importer)(p.metadata)
|
|
357
357
|
: ts.factory.createTypeReferenceNode(p.typeName);
|