@nestia/sdk 1.3.2 → 1.3.3
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/assets/config/nestia.config.ts +70 -70
- package/lib/INestiaConfig.d.ts +13 -0
- package/lib/executable/internal/NestiaSdkConfig.js +6 -2
- package/lib/executable/internal/NestiaSdkConfig.js.map +1 -1
- package/lib/executable/sdk.js +11 -11
- package/lib/generates/SwaggerGenerator.js +9 -9
- package/lib/generates/internal/DistributionComposer.js +1 -1
- package/lib/generates/internal/DistributionComposer.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +12 -12
- package/lib/generates/internal/SdkFileProgrammer.js +3 -1
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkFunctionProgrammer.js +24 -43
- package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
- package/package.json +4 -4
- package/src/INestiaConfig.ts +204 -190
- package/src/NestiaSdkApplication.ts +262 -262
- package/src/analyses/ControllerAnalyzer.ts +261 -261
- package/src/analyses/GenericAnalyzer.ts +53 -53
- package/src/analyses/ImportAnalyzer.ts +164 -164
- package/src/analyses/PathAnalyzer.ts +58 -58
- package/src/analyses/ReflectAnalyzer.ts +321 -321
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/internal/NestiaConfigCompilerOptions.ts +18 -18
- package/src/executable/internal/NestiaSdkCommand.ts +156 -156
- package/src/executable/internal/NestiaSdkConfig.ts +36 -36
- package/src/executable/internal/nestia.config.getter.ts +12 -12
- package/src/executable/sdk.ts +70 -70
- package/src/generates/E2eGenerator.ts +67 -67
- package/src/generates/SdkGenerator.ts +56 -56
- package/src/generates/SwaggerGenerator.ts +504 -504
- package/src/generates/internal/DistributionComposer.ts +98 -97
- package/src/generates/internal/E2eFileProgrammer.ts +135 -135
- package/src/generates/internal/SdkFileProgrammer.ts +148 -144
- package/src/generates/internal/SdkFunctionProgrammer.ts +30 -52
- package/src/generates/internal/SdkRouteDirectory.ts +21 -21
- package/src/index.ts +4 -4
- package/src/module.ts +2 -2
- package/src/structures/IController.ts +31 -31
- package/src/structures/IRoute.ts +39 -39
- package/src/structures/ISwaggerDocument.ts +120 -120
- package/src/structures/ITypeTuple.ts +6 -6
- package/src/structures/MethodType.ts +11 -11
- package/src/structures/ParamCategory.ts +1 -1
- package/src/structures/TypeEntry.ts +22 -22
- package/src/utils/ArrayUtil.ts +26 -26
- package/src/utils/FileRetriever.ts +22 -22
- package/src/utils/ImportDictionary.ts +56 -56
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/NestiaConfigUtil.ts +21 -21
- package/src/utils/SourceFinder.ts +60 -60
- package/src/utils/StripEnums.ts +10 -10
|
@@ -1,144 +1,148 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
|
|
3
|
-
import { INestiaConfig } from "../../INestiaConfig";
|
|
4
|
-
import { IRoute } from "../../structures/IRoute";
|
|
5
|
-
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
6
|
-
import { SdkFunctionProgrammer } from "./SdkFunctionProgrammer";
|
|
7
|
-
import { SdkRouteDirectory } from "./SdkRouteDirectory";
|
|
8
|
-
|
|
9
|
-
export namespace SdkFileProgrammer {
|
|
10
|
-
/* ---------------------------------------------------------
|
|
11
|
-
CONSTRUCTOR
|
|
12
|
-
--------------------------------------------------------- */
|
|
13
|
-
export const generate =
|
|
14
|
-
(config: INestiaConfig) =>
|
|
15
|
-
async (routeList: IRoute[]): Promise<void> => {
|
|
16
|
-
// CONSTRUCT FOLDER TREE
|
|
17
|
-
const root: SdkRouteDirectory = new SdkRouteDirectory(
|
|
18
|
-
null,
|
|
19
|
-
"functional",
|
|
20
|
-
);
|
|
21
|
-
for (const route of routeList) emplace(root)(route);
|
|
22
|
-
|
|
23
|
-
// RELOCATE FOR ONLY ONE CONTROLLER METHOD IN AN URL CASE
|
|
24
|
-
relocate(root);
|
|
25
|
-
|
|
26
|
-
// ITERATE FILES
|
|
27
|
-
await iterate(config)(root)(config.output + "/functional");
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const emplace =
|
|
31
|
-
(directory: SdkRouteDirectory) =>
|
|
32
|
-
(route: IRoute): void => {
|
|
33
|
-
// SEPARATE IDENTIFIERS
|
|
34
|
-
const identifiers: string[] = route.path
|
|
35
|
-
.split("/")
|
|
36
|
-
.filter((str) => str.length && str[0] !== ":")
|
|
37
|
-
.map((str) => str.split("-").join("_").split(".").join("_"));
|
|
38
|
-
|
|
39
|
-
// OPEN DIRECTORIES
|
|
40
|
-
for (const key of identifiers) {
|
|
41
|
-
directory = directory.directories.take(
|
|
42
|
-
key,
|
|
43
|
-
() => new SdkRouteDirectory(directory, key),
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// ADD ROUTE
|
|
48
|
-
directory.routes.push(route);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const relocate = (directory: SdkRouteDirectory): void => {
|
|
52
|
-
if (
|
|
53
|
-
directory.parent !== null &&
|
|
54
|
-
directory.directories.empty() &&
|
|
55
|
-
directory.routes.length === 1 &&
|
|
56
|
-
directory.name === directory.routes[0].name
|
|
57
|
-
) {
|
|
58
|
-
directory.parent.routes.push(directory.routes[0]);
|
|
59
|
-
directory.parent.directories.erase(directory.name);
|
|
60
|
-
} else if (directory.directories.empty() === false)
|
|
61
|
-
for (const it of directory.directories) relocate(it.second);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/* ---------------------------------------------------------
|
|
65
|
-
FILE ITERATOR
|
|
66
|
-
--------------------------------------------------------- */
|
|
67
|
-
const iterate =
|
|
68
|
-
(config: INestiaConfig) =>
|
|
69
|
-
(directory: SdkRouteDirectory) =>
|
|
70
|
-
async (outDir: string): Promise<void> => {
|
|
71
|
-
// CREATE A NEW DIRECTORY
|
|
72
|
-
try {
|
|
73
|
-
await fs.promises.mkdir(outDir);
|
|
74
|
-
} catch {}
|
|
75
|
-
|
|
76
|
-
// ITERATE CHILDREN
|
|
77
|
-
const content: string[] = [];
|
|
78
|
-
for (const it of directory.directories) {
|
|
79
|
-
await iterate(config)(it.second)(`${outDir}/${it.first}`);
|
|
80
|
-
content.push(`export * as ${it.first} from "./${it.first}";`);
|
|
81
|
-
}
|
|
82
|
-
if (content.length && directory.routes.length) content.push("");
|
|
83
|
-
|
|
84
|
-
// ITERATE ROUTES
|
|
85
|
-
const importDict: ImportDictionary = new ImportDictionary();
|
|
86
|
-
directory.routes.forEach((route, i) => {
|
|
87
|
-
for (const tuple of route.imports)
|
|
88
|
-
for (const instance of tuple[1])
|
|
89
|
-
importDict.emplace(tuple[0], false, instance);
|
|
90
|
-
|
|
91
|
-
content.push(SdkFunctionProgrammer.generate(config)(route));
|
|
92
|
-
if (i !== directory.routes.length - 1) content.push("");
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// FINALIZE THE CONTENT
|
|
96
|
-
if (directory.routes.length !== 0) {
|
|
97
|
-
const primitived: boolean =
|
|
98
|
-
config.primitive !== false &&
|
|
99
|
-
directory.routes.some(
|
|
100
|
-
(route) =>
|
|
101
|
-
route.output.name !== "void" ||
|
|
102
|
-
route.parameters.some(
|
|
103
|
-
(param) => param.category !== "param",
|
|
104
|
-
),
|
|
105
|
-
);
|
|
106
|
-
const asserted: boolean =
|
|
107
|
-
config.assert === true &&
|
|
108
|
-
directory.routes.some(
|
|
109
|
-
(route) => route.parameters.length !== 0,
|
|
110
|
-
);
|
|
111
|
-
const json: boolean =
|
|
112
|
-
config.json === true &&
|
|
113
|
-
directory.routes.some(
|
|
114
|
-
(route) =>
|
|
115
|
-
route.method === "POST" ||
|
|
116
|
-
route.method === "PUT" ||
|
|
117
|
-
route.method === "PATCH",
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
]
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
import { INestiaConfig } from "../../INestiaConfig";
|
|
4
|
+
import { IRoute } from "../../structures/IRoute";
|
|
5
|
+
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
6
|
+
import { SdkFunctionProgrammer } from "./SdkFunctionProgrammer";
|
|
7
|
+
import { SdkRouteDirectory } from "./SdkRouteDirectory";
|
|
8
|
+
|
|
9
|
+
export namespace SdkFileProgrammer {
|
|
10
|
+
/* ---------------------------------------------------------
|
|
11
|
+
CONSTRUCTOR
|
|
12
|
+
--------------------------------------------------------- */
|
|
13
|
+
export const generate =
|
|
14
|
+
(config: INestiaConfig) =>
|
|
15
|
+
async (routeList: IRoute[]): Promise<void> => {
|
|
16
|
+
// CONSTRUCT FOLDER TREE
|
|
17
|
+
const root: SdkRouteDirectory = new SdkRouteDirectory(
|
|
18
|
+
null,
|
|
19
|
+
"functional",
|
|
20
|
+
);
|
|
21
|
+
for (const route of routeList) emplace(root)(route);
|
|
22
|
+
|
|
23
|
+
// RELOCATE FOR ONLY ONE CONTROLLER METHOD IN AN URL CASE
|
|
24
|
+
relocate(root);
|
|
25
|
+
|
|
26
|
+
// ITERATE FILES
|
|
27
|
+
await iterate(config)(root)(config.output + "/functional");
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const emplace =
|
|
31
|
+
(directory: SdkRouteDirectory) =>
|
|
32
|
+
(route: IRoute): void => {
|
|
33
|
+
// SEPARATE IDENTIFIERS
|
|
34
|
+
const identifiers: string[] = route.path
|
|
35
|
+
.split("/")
|
|
36
|
+
.filter((str) => str.length && str[0] !== ":")
|
|
37
|
+
.map((str) => str.split("-").join("_").split(".").join("_"));
|
|
38
|
+
|
|
39
|
+
// OPEN DIRECTORIES
|
|
40
|
+
for (const key of identifiers) {
|
|
41
|
+
directory = directory.directories.take(
|
|
42
|
+
key,
|
|
43
|
+
() => new SdkRouteDirectory(directory, key),
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ADD ROUTE
|
|
48
|
+
directory.routes.push(route);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const relocate = (directory: SdkRouteDirectory): void => {
|
|
52
|
+
if (
|
|
53
|
+
directory.parent !== null &&
|
|
54
|
+
directory.directories.empty() &&
|
|
55
|
+
directory.routes.length === 1 &&
|
|
56
|
+
directory.name === directory.routes[0].name
|
|
57
|
+
) {
|
|
58
|
+
directory.parent.routes.push(directory.routes[0]);
|
|
59
|
+
directory.parent.directories.erase(directory.name);
|
|
60
|
+
} else if (directory.directories.empty() === false)
|
|
61
|
+
for (const it of directory.directories) relocate(it.second);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/* ---------------------------------------------------------
|
|
65
|
+
FILE ITERATOR
|
|
66
|
+
--------------------------------------------------------- */
|
|
67
|
+
const iterate =
|
|
68
|
+
(config: INestiaConfig) =>
|
|
69
|
+
(directory: SdkRouteDirectory) =>
|
|
70
|
+
async (outDir: string): Promise<void> => {
|
|
71
|
+
// CREATE A NEW DIRECTORY
|
|
72
|
+
try {
|
|
73
|
+
await fs.promises.mkdir(outDir);
|
|
74
|
+
} catch {}
|
|
75
|
+
|
|
76
|
+
// ITERATE CHILDREN
|
|
77
|
+
const content: string[] = [];
|
|
78
|
+
for (const it of directory.directories) {
|
|
79
|
+
await iterate(config)(it.second)(`${outDir}/${it.first}`);
|
|
80
|
+
content.push(`export * as ${it.first} from "./${it.first}";`);
|
|
81
|
+
}
|
|
82
|
+
if (content.length && directory.routes.length) content.push("");
|
|
83
|
+
|
|
84
|
+
// ITERATE ROUTES
|
|
85
|
+
const importDict: ImportDictionary = new ImportDictionary();
|
|
86
|
+
directory.routes.forEach((route, i) => {
|
|
87
|
+
for (const tuple of route.imports)
|
|
88
|
+
for (const instance of tuple[1])
|
|
89
|
+
importDict.emplace(tuple[0], false, instance);
|
|
90
|
+
|
|
91
|
+
content.push(SdkFunctionProgrammer.generate(config)(route));
|
|
92
|
+
if (i !== directory.routes.length - 1) content.push("");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// FINALIZE THE CONTENT
|
|
96
|
+
if (directory.routes.length !== 0) {
|
|
97
|
+
const primitived: boolean =
|
|
98
|
+
config.primitive !== false &&
|
|
99
|
+
directory.routes.some(
|
|
100
|
+
(route) =>
|
|
101
|
+
route.output.name !== "void" ||
|
|
102
|
+
route.parameters.some(
|
|
103
|
+
(param) => param.category !== "param",
|
|
104
|
+
),
|
|
105
|
+
);
|
|
106
|
+
const asserted: boolean =
|
|
107
|
+
config.assert === true &&
|
|
108
|
+
directory.routes.some(
|
|
109
|
+
(route) => route.parameters.length !== 0,
|
|
110
|
+
);
|
|
111
|
+
const json: boolean =
|
|
112
|
+
config.json === true &&
|
|
113
|
+
directory.routes.some(
|
|
114
|
+
(route) =>
|
|
115
|
+
route.method === "POST" ||
|
|
116
|
+
route.method === "PUT" ||
|
|
117
|
+
route.method === "PATCH",
|
|
118
|
+
);
|
|
119
|
+
const random: boolean =
|
|
120
|
+
config.random === true &&
|
|
121
|
+
directory.routes.some((s) => s.output.name !== "void");
|
|
122
|
+
|
|
123
|
+
const fetcher: string[] = ["Fetcher"];
|
|
124
|
+
if (primitived) fetcher.push("Primitive");
|
|
125
|
+
|
|
126
|
+
const head: string[] = [
|
|
127
|
+
`import { ${fetcher.join(", ")} } from "@nestia/fetcher";`,
|
|
128
|
+
`import type { IConnection } from "@nestia/fetcher";`,
|
|
129
|
+
];
|
|
130
|
+
if (asserted || json || random)
|
|
131
|
+
head.push(`import typia from "typia";`);
|
|
132
|
+
if (!importDict.empty())
|
|
133
|
+
head.push("", importDict.toScript(outDir));
|
|
134
|
+
|
|
135
|
+
content.push(...head, "", ...content.splice(0, content.length));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const script: string =
|
|
139
|
+
"/**\n" +
|
|
140
|
+
" * @packageDocumentation\n" +
|
|
141
|
+
` * @module ${directory.module}\n` +
|
|
142
|
+
" * @nestia Generated by Nestia - https://github.com/samchon/nestia \n" +
|
|
143
|
+
" */\n" +
|
|
144
|
+
"//================================================================\n" +
|
|
145
|
+
content.join("\n");
|
|
146
|
+
await fs.promises.writeFile(`${outDir}/index.ts`, script, "utf8");
|
|
147
|
+
};
|
|
148
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { Vector } from "tstl/container/Vector";
|
|
2
1
|
import { Pair } from "tstl/utility/Pair";
|
|
3
|
-
import ts from "typescript";
|
|
4
2
|
|
|
5
3
|
import { Escaper } from "typia/lib/utils/Escaper";
|
|
6
4
|
|
|
@@ -19,10 +17,10 @@ export namespace SdkFunctionProgrammer {
|
|
|
19
17
|
(param) => param.category === "body",
|
|
20
18
|
);
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
const [x, y, z] = [head, body, tail].map((closure) =>
|
|
21
|
+
closure(config)(route)({ query, input }),
|
|
22
|
+
);
|
|
23
|
+
return `${x} ${y}\n${z}`;
|
|
26
24
|
};
|
|
27
25
|
|
|
28
26
|
/* ---------------------------------------------------------
|
|
@@ -62,20 +60,34 @@ export namespace SdkFunctionProgrammer {
|
|
|
62
60
|
: "";
|
|
63
61
|
|
|
64
62
|
// FUNCTION CALL STATEMENT
|
|
65
|
-
const caller:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
const caller = (awa: boolean) => {
|
|
64
|
+
const random = () =>
|
|
65
|
+
route.output.name === "void"
|
|
66
|
+
? "undefined"
|
|
67
|
+
: `typia.random<${route.name}.Output>()`;
|
|
68
|
+
const fetch = (tab: string) =>
|
|
69
|
+
[
|
|
70
|
+
`${awa ? "await " : ""} Fetcher.fetch(`,
|
|
71
|
+
fetchArguments
|
|
72
|
+
.map((param) => `${tab} ${param}`)
|
|
73
|
+
.join(",\n"),
|
|
74
|
+
`${tab})`,
|
|
75
|
+
].join("\n");
|
|
76
|
+
if (!config.random) return fetch(" ".repeat(8));
|
|
77
|
+
return (
|
|
78
|
+
`connection.random\n` +
|
|
79
|
+
` ? ${random()}\n` +
|
|
80
|
+
` : ${fetch(" ".repeat(10))}`
|
|
81
|
+
);
|
|
82
|
+
};
|
|
71
83
|
if (route.setHeaders.length === 0)
|
|
72
|
-
return `{\n${assertions} return ${caller};\n}`;
|
|
84
|
+
return `{\n${assertions} return ${caller(false)};\n}`;
|
|
73
85
|
|
|
74
86
|
// SET HEADERS
|
|
75
87
|
const content: string[] = [
|
|
76
88
|
`{\n`,
|
|
77
89
|
assertions,
|
|
78
|
-
` const output: ${route.name}.Output =
|
|
90
|
+
` const output: ${route.name}.Output = ${caller(true)};\n`,
|
|
79
91
|
"\n",
|
|
80
92
|
` // configure header(s)\n`,
|
|
81
93
|
` connection.headers ??= {};\n`,
|
|
@@ -136,35 +148,6 @@ export namespace SdkFunctionProgrammer {
|
|
|
136
148
|
? route.description.split("\n")
|
|
137
149
|
: [];
|
|
138
150
|
|
|
139
|
-
// FILTER TAGS (VULNERABLE PARAMETERS WOULD BE REMOVED)
|
|
140
|
-
const tagList: ts.JSDocTagInfo[] = route.tags.slice();
|
|
141
|
-
if (tagList.length !== 0) {
|
|
142
|
-
const index: number = tagList.findIndex(
|
|
143
|
-
(t) => t.name === "param",
|
|
144
|
-
);
|
|
145
|
-
if (index !== -1) {
|
|
146
|
-
const capsule: Vector<ts.JSDocTagInfo> =
|
|
147
|
-
Vector.wrap(tagList);
|
|
148
|
-
capsule.insert(capsule.nth(index), {
|
|
149
|
-
name: "param",
|
|
150
|
-
text: [
|
|
151
|
-
{
|
|
152
|
-
kind: "parameterName",
|
|
153
|
-
text: "connection",
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
kind: "space",
|
|
157
|
-
text: " ",
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
kind: "text",
|
|
161
|
-
text: "connection Information of the remote HTTP(s) server with headers (+encryption password)",
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
151
|
// COMPLETE THE COMMENT
|
|
169
152
|
if (!!comments.length) comments.push("");
|
|
170
153
|
comments.push(
|
|
@@ -202,10 +185,7 @@ export namespace SdkFunctionProgrammer {
|
|
|
202
185
|
comments.map((str) => ` * ${str}`).join("\n") +
|
|
203
186
|
"\n" +
|
|
204
187
|
" */\n" +
|
|
205
|
-
`export${route.
|
|
206
|
-
route.name
|
|
207
|
-
}\n` +
|
|
208
|
-
` (\n` +
|
|
188
|
+
`export async function ${route.name} (\n` +
|
|
209
189
|
`${parameters.map((str) => ` ${str}`).join(",\n")}\n` +
|
|
210
190
|
` ): Promise<${output}>`
|
|
211
191
|
);
|
|
@@ -217,7 +197,7 @@ export namespace SdkFunctionProgrammer {
|
|
|
217
197
|
(props: {
|
|
218
198
|
query: IRoute.IParameter | undefined;
|
|
219
199
|
input: IRoute.IParameter | undefined;
|
|
220
|
-
}): string
|
|
200
|
+
}): string => {
|
|
221
201
|
// LIST UP TYPES
|
|
222
202
|
const types: Pair<string, string>[] = [];
|
|
223
203
|
if (props.query !== undefined)
|
|
@@ -238,8 +218,7 @@ export namespace SdkFunctionProgrammer {
|
|
|
238
218
|
});
|
|
239
219
|
|
|
240
220
|
return (
|
|
241
|
-
`export namespace ${route.name}\n` +
|
|
242
|
-
"{\n" +
|
|
221
|
+
`export namespace ${route.name} {\n` +
|
|
243
222
|
(types.length !== 0
|
|
244
223
|
? types
|
|
245
224
|
.map(
|
|
@@ -267,8 +246,7 @@ export namespace SdkFunctionProgrammer {
|
|
|
267
246
|
"\n" +
|
|
268
247
|
` export function path(${parameters
|
|
269
248
|
.map((param) => `${param.name}: ${param.type.name}`)
|
|
270
|
-
.join(", ")}): string\n` +
|
|
271
|
-
` {\n` +
|
|
249
|
+
.join(", ")}): string {\n` +
|
|
272
250
|
`${path};\n` +
|
|
273
251
|
` }\n` +
|
|
274
252
|
(config.json === true &&
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { HashMap } from "tstl";
|
|
2
|
-
|
|
3
|
-
import { IRoute } from "../../structures/IRoute";
|
|
4
|
-
|
|
5
|
-
export class SdkRouteDirectory {
|
|
6
|
-
public readonly module: string;
|
|
7
|
-
public readonly directories: HashMap<string, SdkRouteDirectory>;
|
|
8
|
-
public readonly routes: IRoute[];
|
|
9
|
-
|
|
10
|
-
public constructor(
|
|
11
|
-
readonly parent: SdkRouteDirectory | null,
|
|
12
|
-
readonly name: string,
|
|
13
|
-
) {
|
|
14
|
-
this.directories = new HashMap();
|
|
15
|
-
this.routes = [];
|
|
16
|
-
this.module =
|
|
17
|
-
this.parent !== null
|
|
18
|
-
? `${this.parent.module}.${name}`
|
|
19
|
-
: `api.${name}`;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
import { HashMap } from "tstl";
|
|
2
|
+
|
|
3
|
+
import { IRoute } from "../../structures/IRoute";
|
|
4
|
+
|
|
5
|
+
export class SdkRouteDirectory {
|
|
6
|
+
public readonly module: string;
|
|
7
|
+
public readonly directories: HashMap<string, SdkRouteDirectory>;
|
|
8
|
+
public readonly routes: IRoute[];
|
|
9
|
+
|
|
10
|
+
public constructor(
|
|
11
|
+
readonly parent: SdkRouteDirectory | null,
|
|
12
|
+
readonly name: string,
|
|
13
|
+
) {
|
|
14
|
+
this.directories = new HashMap();
|
|
15
|
+
this.routes = [];
|
|
16
|
+
this.module =
|
|
17
|
+
this.parent !== null
|
|
18
|
+
? `${this.parent.module}.${name}`
|
|
19
|
+
: `api.${name}`;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as nestia from "./module";
|
|
2
|
-
|
|
3
|
-
export * from "./module";
|
|
4
|
-
export default nestia;
|
|
1
|
+
import * as nestia from "./module";
|
|
2
|
+
|
|
3
|
+
export * from "./module";
|
|
4
|
+
export default nestia;
|
package/src/module.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./INestiaConfig";
|
|
2
|
-
export * from "./NestiaSdkApplication";
|
|
1
|
+
export * from "./INestiaConfig";
|
|
2
|
+
export * from "./NestiaSdkApplication";
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { ParamCategory } from "./ParamCategory";
|
|
2
|
-
|
|
3
|
-
export interface IController {
|
|
4
|
-
file: string;
|
|
5
|
-
name: string;
|
|
6
|
-
paths: string[];
|
|
7
|
-
functions: IController.IFunction[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export namespace IController {
|
|
11
|
-
export interface IFunction {
|
|
12
|
-
name: string;
|
|
13
|
-
method: string;
|
|
14
|
-
paths: string[];
|
|
15
|
-
encrypted: boolean;
|
|
16
|
-
parameters: IParameter[];
|
|
17
|
-
status?: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface IParameter {
|
|
21
|
-
name: string;
|
|
22
|
-
index: number;
|
|
23
|
-
field: string | undefined;
|
|
24
|
-
category: ParamCategory;
|
|
25
|
-
encrypted: boolean;
|
|
26
|
-
meta?: {
|
|
27
|
-
type: string;
|
|
28
|
-
nullable: boolean;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
import { ParamCategory } from "./ParamCategory";
|
|
2
|
+
|
|
3
|
+
export interface IController {
|
|
4
|
+
file: string;
|
|
5
|
+
name: string;
|
|
6
|
+
paths: string[];
|
|
7
|
+
functions: IController.IFunction[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export namespace IController {
|
|
11
|
+
export interface IFunction {
|
|
12
|
+
name: string;
|
|
13
|
+
method: string;
|
|
14
|
+
paths: string[];
|
|
15
|
+
encrypted: boolean;
|
|
16
|
+
parameters: IParameter[];
|
|
17
|
+
status?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface IParameter {
|
|
21
|
+
name: string;
|
|
22
|
+
index: number;
|
|
23
|
+
field: string | undefined;
|
|
24
|
+
category: ParamCategory;
|
|
25
|
+
encrypted: boolean;
|
|
26
|
+
meta?: {
|
|
27
|
+
type: string;
|
|
28
|
+
nullable: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/structures/IRoute.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { ITypeTuple } from "./ITypeTuple";
|
|
4
|
-
import { ParamCategory } from "./ParamCategory";
|
|
5
|
-
|
|
6
|
-
export interface IRoute {
|
|
7
|
-
name: string;
|
|
8
|
-
method: string;
|
|
9
|
-
path: string;
|
|
10
|
-
encrypted: boolean;
|
|
11
|
-
status?: number;
|
|
12
|
-
|
|
13
|
-
parameters: IRoute.IParameter[];
|
|
14
|
-
imports: [string, string[]][];
|
|
15
|
-
output: ITypeTuple;
|
|
16
|
-
|
|
17
|
-
symbol: string;
|
|
18
|
-
description?: string;
|
|
19
|
-
tags: ts.JSDocTagInfo[];
|
|
20
|
-
setHeaders: Array<
|
|
21
|
-
| { type: "setter"; source: string; target?: string }
|
|
22
|
-
| { type: "assigner"; source: string }
|
|
23
|
-
>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export namespace IRoute {
|
|
27
|
-
export interface IParameter {
|
|
28
|
-
name: string;
|
|
29
|
-
field: string | undefined;
|
|
30
|
-
category: ParamCategory;
|
|
31
|
-
encrypted: boolean;
|
|
32
|
-
type: ITypeTuple;
|
|
33
|
-
optional: boolean;
|
|
34
|
-
meta?: {
|
|
35
|
-
type: string;
|
|
36
|
-
nullable: boolean;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { ITypeTuple } from "./ITypeTuple";
|
|
4
|
+
import { ParamCategory } from "./ParamCategory";
|
|
5
|
+
|
|
6
|
+
export interface IRoute {
|
|
7
|
+
name: string;
|
|
8
|
+
method: string;
|
|
9
|
+
path: string;
|
|
10
|
+
encrypted: boolean;
|
|
11
|
+
status?: number;
|
|
12
|
+
|
|
13
|
+
parameters: IRoute.IParameter[];
|
|
14
|
+
imports: [string, string[]][];
|
|
15
|
+
output: ITypeTuple;
|
|
16
|
+
|
|
17
|
+
symbol: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
tags: ts.JSDocTagInfo[];
|
|
20
|
+
setHeaders: Array<
|
|
21
|
+
| { type: "setter"; source: string; target?: string }
|
|
22
|
+
| { type: "assigner"; source: string }
|
|
23
|
+
>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export namespace IRoute {
|
|
27
|
+
export interface IParameter {
|
|
28
|
+
name: string;
|
|
29
|
+
field: string | undefined;
|
|
30
|
+
category: ParamCategory;
|
|
31
|
+
encrypted: boolean;
|
|
32
|
+
type: ITypeTuple;
|
|
33
|
+
optional: boolean;
|
|
34
|
+
meta?: {
|
|
35
|
+
type: string;
|
|
36
|
+
nullable: boolean;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|