@nestia/sdk 2.5.0-dev.20240130 → 2.5.0-dev.20240130-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/lib/INestiaConfig.d.ts +0 -6
- package/lib/executable/internal/NestiaConfigLoader.js +2 -6
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/generates/SwaggerGenerator.js +8 -11
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.js +3 -1
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/structures/ISwagger.d.ts +1 -1
- package/package.json +3 -3
- package/src/INestiaConfig.ts +248 -255
- package/src/NestiaSdkApplication.ts +253 -253
- package/src/generates/E2eGenerator.ts +66 -66
- package/src/generates/SdkGenerator.ts +96 -96
- package/src/generates/SwaggerGenerator.ts +376 -378
- package/src/generates/internal/E2eFileProgrammer.ts +191 -191
- package/src/generates/internal/SdkAliasCollection.ts +145 -145
- package/src/generates/internal/SdkFileProgrammer.ts +135 -135
- package/src/generates/internal/SdkFunctionProgrammer.ts +219 -219
- package/src/generates/internal/SdkNamespaceProgrammer.ts +507 -507
- package/src/generates/internal/SdkRouteProgrammer.ts +86 -86
- package/src/generates/internal/SdkSimulationProgrammer.ts +357 -357
- package/src/generates/internal/SdkTypeProgrammer.ts +5 -1
- package/src/structures/ISwagger.ts +91 -91
- package/src/utils/FormatUtil.ts +31 -31
- package/src/utils/ImportDictionary.ts +197 -197
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import NodePath from "path";
|
|
3
|
-
import { IPointer } from "tstl";
|
|
4
|
-
import ts from "typescript";
|
|
5
|
-
|
|
6
|
-
import { INestiaConfig } from "../INestiaConfig";
|
|
7
|
-
import { IRoute } from "../structures/IRoute";
|
|
8
|
-
import { CloneGenerator } from "./CloneGenerator";
|
|
9
|
-
import { SdkDistributionComposer } from "./internal/SdkDistributionComposer";
|
|
10
|
-
import { SdkFileProgrammer } from "./internal/SdkFileProgrammer";
|
|
11
|
-
|
|
12
|
-
export namespace SdkGenerator {
|
|
13
|
-
export const generate =
|
|
14
|
-
(checker: ts.TypeChecker) =>
|
|
15
|
-
(config: INestiaConfig) =>
|
|
16
|
-
async (routes: IRoute[]): Promise<void> => {
|
|
17
|
-
console.log("Generating SDK Library");
|
|
18
|
-
|
|
19
|
-
// PREPARE NEW DIRECTORIES
|
|
20
|
-
try {
|
|
21
|
-
await fs.promises.mkdir(config.output!);
|
|
22
|
-
} catch {}
|
|
23
|
-
|
|
24
|
-
// BUNDLING
|
|
25
|
-
const bundle: string[] = await fs.promises.readdir(BUNDLE_PATH);
|
|
26
|
-
for (const file of bundle) {
|
|
27
|
-
const current: string = `${BUNDLE_PATH}/${file}`;
|
|
28
|
-
const target: string = `${config.output}/${file}`;
|
|
29
|
-
const stats: fs.Stats = await fs.promises.stat(current);
|
|
30
|
-
|
|
31
|
-
if (stats.isFile() === true) {
|
|
32
|
-
const content: string = await fs.promises.readFile(current, "utf8");
|
|
33
|
-
if (fs.existsSync(target) === false)
|
|
34
|
-
await fs.promises.writeFile(target, content, "utf8");
|
|
35
|
-
else if (BUNDLE_CHANGES[file] !== undefined) {
|
|
36
|
-
const r: IPointer<string> = {
|
|
37
|
-
value: await fs.promises.readFile(target, "utf8"),
|
|
38
|
-
};
|
|
39
|
-
for (const [before, after] of BUNDLE_CHANGES[file])
|
|
40
|
-
r.value = r.value.replace(before, after);
|
|
41
|
-
await fs.promises.writeFile(target, r.value, "utf8");
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (
|
|
46
|
-
config.simulate === true &&
|
|
47
|
-
routes.some((r) => !!r.parameters.length)
|
|
48
|
-
) {
|
|
49
|
-
try {
|
|
50
|
-
await fs.promises.mkdir(`${config.output}/utils`);
|
|
51
|
-
} catch {}
|
|
52
|
-
await fs.promises.copyFile(
|
|
53
|
-
`${BUNDLE_PATH}/utils/NestiaSimulator.ts`,
|
|
54
|
-
`${config.output}/utils/NestiaSimulator.ts`,
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// STRUCTURES
|
|
59
|
-
if (config.clone) await CloneGenerator.generate(checker)(config)(routes);
|
|
60
|
-
|
|
61
|
-
// FUNCTIONAL
|
|
62
|
-
await SdkFileProgrammer.generate(checker)(config)(routes);
|
|
63
|
-
|
|
64
|
-
// DISTRIBUTION
|
|
65
|
-
if (config.distribute !== undefined)
|
|
66
|
-
await SdkDistributionComposer.compose(config);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const BUNDLE_PATH = NodePath.join(
|
|
70
|
-
__dirname,
|
|
71
|
-
"..",
|
|
72
|
-
"..",
|
|
73
|
-
"assets",
|
|
74
|
-
"bundle",
|
|
75
|
-
"api",
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const BUNDLE_CHANGES: Record<string, [string, string][]> = {
|
|
80
|
-
"IConnection.ts": [
|
|
81
|
-
[
|
|
82
|
-
`export { IConnection } from "@nestia/fetcher"`,
|
|
83
|
-
`export type { IConnection } from "@nestia/fetcher"`,
|
|
84
|
-
],
|
|
85
|
-
],
|
|
86
|
-
"module.ts": [
|
|
87
|
-
[`export * from "./IConnection"`, `export type * from "./IConnection"`],
|
|
88
|
-
[`export * from "./Primitive"`, `export type * from "./Primitive"`],
|
|
89
|
-
],
|
|
90
|
-
"Primitive.ts": [
|
|
91
|
-
[
|
|
92
|
-
`export { Primitive } from "@nestia/fetcher"`,
|
|
93
|
-
`export type { Primitive } from "@nestia/fetcher"`,
|
|
94
|
-
],
|
|
95
|
-
],
|
|
96
|
-
};
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import NodePath from "path";
|
|
3
|
+
import { IPointer } from "tstl";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
|
|
6
|
+
import { INestiaConfig } from "../INestiaConfig";
|
|
7
|
+
import { IRoute } from "../structures/IRoute";
|
|
8
|
+
import { CloneGenerator } from "./CloneGenerator";
|
|
9
|
+
import { SdkDistributionComposer } from "./internal/SdkDistributionComposer";
|
|
10
|
+
import { SdkFileProgrammer } from "./internal/SdkFileProgrammer";
|
|
11
|
+
|
|
12
|
+
export namespace SdkGenerator {
|
|
13
|
+
export const generate =
|
|
14
|
+
(checker: ts.TypeChecker) =>
|
|
15
|
+
(config: INestiaConfig) =>
|
|
16
|
+
async (routes: IRoute[]): Promise<void> => {
|
|
17
|
+
console.log("Generating SDK Library");
|
|
18
|
+
|
|
19
|
+
// PREPARE NEW DIRECTORIES
|
|
20
|
+
try {
|
|
21
|
+
await fs.promises.mkdir(config.output!);
|
|
22
|
+
} catch {}
|
|
23
|
+
|
|
24
|
+
// BUNDLING
|
|
25
|
+
const bundle: string[] = await fs.promises.readdir(BUNDLE_PATH);
|
|
26
|
+
for (const file of bundle) {
|
|
27
|
+
const current: string = `${BUNDLE_PATH}/${file}`;
|
|
28
|
+
const target: string = `${config.output}/${file}`;
|
|
29
|
+
const stats: fs.Stats = await fs.promises.stat(current);
|
|
30
|
+
|
|
31
|
+
if (stats.isFile() === true) {
|
|
32
|
+
const content: string = await fs.promises.readFile(current, "utf8");
|
|
33
|
+
if (fs.existsSync(target) === false)
|
|
34
|
+
await fs.promises.writeFile(target, content, "utf8");
|
|
35
|
+
else if (BUNDLE_CHANGES[file] !== undefined) {
|
|
36
|
+
const r: IPointer<string> = {
|
|
37
|
+
value: await fs.promises.readFile(target, "utf8"),
|
|
38
|
+
};
|
|
39
|
+
for (const [before, after] of BUNDLE_CHANGES[file])
|
|
40
|
+
r.value = r.value.replace(before, after);
|
|
41
|
+
await fs.promises.writeFile(target, r.value, "utf8");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (
|
|
46
|
+
config.simulate === true &&
|
|
47
|
+
routes.some((r) => !!r.parameters.length)
|
|
48
|
+
) {
|
|
49
|
+
try {
|
|
50
|
+
await fs.promises.mkdir(`${config.output}/utils`);
|
|
51
|
+
} catch {}
|
|
52
|
+
await fs.promises.copyFile(
|
|
53
|
+
`${BUNDLE_PATH}/utils/NestiaSimulator.ts`,
|
|
54
|
+
`${config.output}/utils/NestiaSimulator.ts`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// STRUCTURES
|
|
59
|
+
if (config.clone) await CloneGenerator.generate(checker)(config)(routes);
|
|
60
|
+
|
|
61
|
+
// FUNCTIONAL
|
|
62
|
+
await SdkFileProgrammer.generate(checker)(config)(routes);
|
|
63
|
+
|
|
64
|
+
// DISTRIBUTION
|
|
65
|
+
if (config.distribute !== undefined)
|
|
66
|
+
await SdkDistributionComposer.compose(config);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const BUNDLE_PATH = NodePath.join(
|
|
70
|
+
__dirname,
|
|
71
|
+
"..",
|
|
72
|
+
"..",
|
|
73
|
+
"assets",
|
|
74
|
+
"bundle",
|
|
75
|
+
"api",
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const BUNDLE_CHANGES: Record<string, [string, string][]> = {
|
|
80
|
+
"IConnection.ts": [
|
|
81
|
+
[
|
|
82
|
+
`export { IConnection } from "@nestia/fetcher"`,
|
|
83
|
+
`export type { IConnection } from "@nestia/fetcher"`,
|
|
84
|
+
],
|
|
85
|
+
],
|
|
86
|
+
"module.ts": [
|
|
87
|
+
[`export * from "./IConnection"`, `export type * from "./IConnection"`],
|
|
88
|
+
[`export * from "./Primitive"`, `export type * from "./Primitive"`],
|
|
89
|
+
],
|
|
90
|
+
"Primitive.ts": [
|
|
91
|
+
[
|
|
92
|
+
`export { Primitive } from "@nestia/fetcher"`,
|
|
93
|
+
`export type { Primitive } from "@nestia/fetcher"`,
|
|
94
|
+
],
|
|
95
|
+
],
|
|
96
|
+
};
|