@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,67 +1,67 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
import { INestiaConfig } from "../INestiaConfig";
|
|
5
|
-
import { IRoute } from "../structures/IRoute";
|
|
6
|
-
import { NestiaConfigUtil } from "../utils/NestiaConfigUtil";
|
|
7
|
-
import { E2eFileProgrammer } from "./internal/E2eFileProgrammer";
|
|
8
|
-
|
|
9
|
-
export namespace E2eGenerator {
|
|
10
|
-
export const generate =
|
|
11
|
-
(config: INestiaConfig) =>
|
|
12
|
-
async (routeList: IRoute[]): Promise<void> => {
|
|
13
|
-
console.log("Generating E2E Test Functions");
|
|
14
|
-
|
|
15
|
-
// PREPARE DIRECTORIES
|
|
16
|
-
const output: string = path.resolve(config.e2e!);
|
|
17
|
-
await mkdir(output);
|
|
18
|
-
await mkdir(path.join(output, "features"));
|
|
19
|
-
await mkdir(path.join(output, "features", "api"));
|
|
20
|
-
await mkdir(path.join(output, "features", "api", "automated"));
|
|
21
|
-
|
|
22
|
-
// GENERATE TEST INDEX FILE
|
|
23
|
-
await index(config)(path.join(config.e2e!, "index.ts"));
|
|
24
|
-
|
|
25
|
-
// GENERATE EACH TEST FILES
|
|
26
|
-
for (const route of routeList)
|
|
27
|
-
await E2eFileProgrammer.generate(config)({
|
|
28
|
-
api: path.resolve(config.output!),
|
|
29
|
-
current: path.join(output, "features", "api", "automated"),
|
|
30
|
-
})(route);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const index =
|
|
34
|
-
(config: INestiaConfig) =>
|
|
35
|
-
async (output: string): Promise<void> => {
|
|
36
|
-
if (fs.existsSync(output)) return;
|
|
37
|
-
|
|
38
|
-
const location: string = path.join(
|
|
39
|
-
__dirname,
|
|
40
|
-
"..",
|
|
41
|
-
"..",
|
|
42
|
-
"assets",
|
|
43
|
-
"bundle",
|
|
44
|
-
"e2e",
|
|
45
|
-
"index.ts",
|
|
46
|
-
);
|
|
47
|
-
const content: string = await fs.promises.readFile(
|
|
48
|
-
location,
|
|
49
|
-
"utf8",
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
await fs.promises.writeFile(
|
|
53
|
-
output,
|
|
54
|
-
content.replace(
|
|
55
|
-
"${input}",
|
|
56
|
-
JSON.stringify(NestiaConfigUtil.input(config.input)),
|
|
57
|
-
),
|
|
58
|
-
"utf8",
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const mkdir = async (location: string): Promise<void> => {
|
|
64
|
-
try {
|
|
65
|
-
await fs.promises.mkdir(location);
|
|
66
|
-
} catch {}
|
|
67
|
-
};
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import { INestiaConfig } from "../INestiaConfig";
|
|
5
|
+
import { IRoute } from "../structures/IRoute";
|
|
6
|
+
import { NestiaConfigUtil } from "../utils/NestiaConfigUtil";
|
|
7
|
+
import { E2eFileProgrammer } from "./internal/E2eFileProgrammer";
|
|
8
|
+
|
|
9
|
+
export namespace E2eGenerator {
|
|
10
|
+
export const generate =
|
|
11
|
+
(config: INestiaConfig) =>
|
|
12
|
+
async (routeList: IRoute[]): Promise<void> => {
|
|
13
|
+
console.log("Generating E2E Test Functions");
|
|
14
|
+
|
|
15
|
+
// PREPARE DIRECTORIES
|
|
16
|
+
const output: string = path.resolve(config.e2e!);
|
|
17
|
+
await mkdir(output);
|
|
18
|
+
await mkdir(path.join(output, "features"));
|
|
19
|
+
await mkdir(path.join(output, "features", "api"));
|
|
20
|
+
await mkdir(path.join(output, "features", "api", "automated"));
|
|
21
|
+
|
|
22
|
+
// GENERATE TEST INDEX FILE
|
|
23
|
+
await index(config)(path.join(config.e2e!, "index.ts"));
|
|
24
|
+
|
|
25
|
+
// GENERATE EACH TEST FILES
|
|
26
|
+
for (const route of routeList)
|
|
27
|
+
await E2eFileProgrammer.generate(config)({
|
|
28
|
+
api: path.resolve(config.output!),
|
|
29
|
+
current: path.join(output, "features", "api", "automated"),
|
|
30
|
+
})(route);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const index =
|
|
34
|
+
(config: INestiaConfig) =>
|
|
35
|
+
async (output: string): Promise<void> => {
|
|
36
|
+
if (fs.existsSync(output)) return;
|
|
37
|
+
|
|
38
|
+
const location: string = path.join(
|
|
39
|
+
__dirname,
|
|
40
|
+
"..",
|
|
41
|
+
"..",
|
|
42
|
+
"assets",
|
|
43
|
+
"bundle",
|
|
44
|
+
"e2e",
|
|
45
|
+
"index.ts",
|
|
46
|
+
);
|
|
47
|
+
const content: string = await fs.promises.readFile(
|
|
48
|
+
location,
|
|
49
|
+
"utf8",
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
await fs.promises.writeFile(
|
|
53
|
+
output,
|
|
54
|
+
content.replace(
|
|
55
|
+
"${input}",
|
|
56
|
+
JSON.stringify(NestiaConfigUtil.input(config.input)),
|
|
57
|
+
),
|
|
58
|
+
"utf8",
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const mkdir = async (location: string): Promise<void> => {
|
|
64
|
+
try {
|
|
65
|
+
await fs.promises.mkdir(location);
|
|
66
|
+
} catch {}
|
|
67
|
+
};
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import NodePath from "path";
|
|
3
|
-
|
|
4
|
-
import { INestiaConfig } from "../INestiaConfig";
|
|
5
|
-
import { IRoute } from "../structures/IRoute";
|
|
6
|
-
import { DistributionComposer } from "./internal/DistributionComposer";
|
|
7
|
-
import { SdkFileProgrammer } from "./internal/SdkFileProgrammer";
|
|
8
|
-
|
|
9
|
-
export namespace SdkGenerator {
|
|
10
|
-
export const generate =
|
|
11
|
-
(config: INestiaConfig) =>
|
|
12
|
-
async (routes: IRoute[]): Promise<void> => {
|
|
13
|
-
console.log("Generating SDK Library");
|
|
14
|
-
|
|
15
|
-
// PREPARE NEW DIRECTORIES
|
|
16
|
-
try {
|
|
17
|
-
await fs.promises.mkdir(config.output!);
|
|
18
|
-
} catch {}
|
|
19
|
-
|
|
20
|
-
// BUNDLING
|
|
21
|
-
const bundle: string[] = await fs.promises.readdir(BUNDLE_PATH);
|
|
22
|
-
for (const file of bundle) {
|
|
23
|
-
const current: string = `${BUNDLE_PATH}/${file}`;
|
|
24
|
-
const stats: fs.Stats = await fs.promises.stat(current);
|
|
25
|
-
|
|
26
|
-
if (stats.isFile() === true) {
|
|
27
|
-
const content: string = await fs.promises.readFile(
|
|
28
|
-
current,
|
|
29
|
-
"utf8",
|
|
30
|
-
);
|
|
31
|
-
if (fs.existsSync(`${config.output}/${file}`) === false)
|
|
32
|
-
await fs.promises.writeFile(
|
|
33
|
-
`${config.output}/${file}`,
|
|
34
|
-
content,
|
|
35
|
-
"utf8",
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// FUNCTIONAL
|
|
41
|
-
await SdkFileProgrammer.generate(config)(routes);
|
|
42
|
-
|
|
43
|
-
// DISTRIBUTION
|
|
44
|
-
if (config.distribute !== undefined)
|
|
45
|
-
await DistributionComposer.compose(config);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const BUNDLE_PATH = NodePath.join(
|
|
49
|
-
__dirname,
|
|
50
|
-
"..",
|
|
51
|
-
"..",
|
|
52
|
-
"assets",
|
|
53
|
-
"bundle",
|
|
54
|
-
"api",
|
|
55
|
-
);
|
|
56
|
-
}
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import NodePath from "path";
|
|
3
|
+
|
|
4
|
+
import { INestiaConfig } from "../INestiaConfig";
|
|
5
|
+
import { IRoute } from "../structures/IRoute";
|
|
6
|
+
import { DistributionComposer } from "./internal/DistributionComposer";
|
|
7
|
+
import { SdkFileProgrammer } from "./internal/SdkFileProgrammer";
|
|
8
|
+
|
|
9
|
+
export namespace SdkGenerator {
|
|
10
|
+
export const generate =
|
|
11
|
+
(config: INestiaConfig) =>
|
|
12
|
+
async (routes: IRoute[]): Promise<void> => {
|
|
13
|
+
console.log("Generating SDK Library");
|
|
14
|
+
|
|
15
|
+
// PREPARE NEW DIRECTORIES
|
|
16
|
+
try {
|
|
17
|
+
await fs.promises.mkdir(config.output!);
|
|
18
|
+
} catch {}
|
|
19
|
+
|
|
20
|
+
// BUNDLING
|
|
21
|
+
const bundle: string[] = await fs.promises.readdir(BUNDLE_PATH);
|
|
22
|
+
for (const file of bundle) {
|
|
23
|
+
const current: string = `${BUNDLE_PATH}/${file}`;
|
|
24
|
+
const stats: fs.Stats = await fs.promises.stat(current);
|
|
25
|
+
|
|
26
|
+
if (stats.isFile() === true) {
|
|
27
|
+
const content: string = await fs.promises.readFile(
|
|
28
|
+
current,
|
|
29
|
+
"utf8",
|
|
30
|
+
);
|
|
31
|
+
if (fs.existsSync(`${config.output}/${file}`) === false)
|
|
32
|
+
await fs.promises.writeFile(
|
|
33
|
+
`${config.output}/${file}`,
|
|
34
|
+
content,
|
|
35
|
+
"utf8",
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// FUNCTIONAL
|
|
41
|
+
await SdkFileProgrammer.generate(config)(routes);
|
|
42
|
+
|
|
43
|
+
// DISTRIBUTION
|
|
44
|
+
if (config.distribute !== undefined)
|
|
45
|
+
await DistributionComposer.compose(config);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const BUNDLE_PATH = NodePath.join(
|
|
49
|
+
__dirname,
|
|
50
|
+
"..",
|
|
51
|
+
"..",
|
|
52
|
+
"assets",
|
|
53
|
+
"bundle",
|
|
54
|
+
"api",
|
|
55
|
+
);
|
|
56
|
+
}
|