@nestia/sdk 2.5.0-dev.20240130-7 → 2.5.0-dev.20240131

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.
Files changed (63) hide show
  1. package/lib/NestiaSdkApplication.js +10 -8
  2. package/lib/NestiaSdkApplication.js.map +1 -1
  3. package/lib/analyses/ControllerAnalyzer.js +7 -2
  4. package/lib/analyses/ControllerAnalyzer.js.map +1 -1
  5. package/lib/analyses/ExceptionAnalyzer.js +3 -1
  6. package/lib/analyses/ExceptionAnalyzer.js.map +1 -1
  7. package/lib/executable/sdk.js +11 -11
  8. package/lib/generates/CloneGenerator.js +2 -0
  9. package/lib/generates/CloneGenerator.js.map +1 -1
  10. package/lib/generates/internal/E2eFileProgrammer.js +3 -1
  11. package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
  12. package/lib/generates/internal/SdkCloneProgrammer.js +4 -1
  13. package/lib/generates/internal/SdkCloneProgrammer.js.map +1 -1
  14. package/lib/generates/internal/SdkTypeProgrammer.js +4 -1
  15. package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
  16. package/package.json +3 -3
  17. package/src/NestiaSdkApplication.ts +15 -13
  18. package/src/analyses/AccessorAnalyzer.ts +60 -60
  19. package/src/analyses/ConfigAnalyzer.ts +147 -147
  20. package/src/analyses/ControllerAnalyzer.ts +399 -390
  21. package/src/analyses/ExceptionAnalyzer.ts +119 -115
  22. package/src/analyses/GenericAnalyzer.ts +51 -51
  23. package/src/analyses/ImportAnalyzer.ts +138 -138
  24. package/src/analyses/PathAnalyzer.ts +110 -110
  25. package/src/analyses/ReflectAnalyzer.ts +464 -464
  26. package/src/analyses/SecurityAnalyzer.ts +20 -20
  27. package/src/executable/internal/CommandParser.ts +15 -15
  28. package/src/executable/internal/NestiaConfigLoader.ts +67 -67
  29. package/src/executable/internal/NestiaSdkCommand.ts +60 -60
  30. package/src/executable/sdk.ts +73 -73
  31. package/src/generates/CloneGenerator.ts +1 -0
  32. package/src/generates/internal/E2eFileProgrammer.ts +5 -1
  33. package/src/generates/internal/SdkCloneProgrammer.ts +6 -1
  34. package/src/generates/internal/SdkDistributionComposer.ts +91 -91
  35. package/src/generates/internal/SdkImportWizard.ts +55 -55
  36. package/src/generates/internal/SdkRouteDirectory.ts +17 -17
  37. package/src/generates/internal/SdkTypeProgrammer.ts +6 -1
  38. package/src/generates/internal/SwaggerSchemaGenerator.ts +444 -444
  39. package/src/generates/internal/SwaggerSchemaValidator.ts +198 -198
  40. package/src/index.ts +4 -4
  41. package/src/module.ts +2 -2
  42. package/src/structures/IController.ts +91 -91
  43. package/src/structures/IErrorReport.ts +6 -6
  44. package/src/structures/INestiaProject.ts +13 -13
  45. package/src/structures/INormalizedInput.ts +20 -20
  46. package/src/structures/IRoute.ts +52 -52
  47. package/src/structures/ISwaggerComponents.ts +29 -29
  48. package/src/structures/ISwaggerError.ts +8 -8
  49. package/src/structures/ISwaggerInfo.ts +80 -80
  50. package/src/structures/ISwaggerLazyProperty.ts +7 -7
  51. package/src/structures/ISwaggerLazySchema.ts +7 -7
  52. package/src/structures/ISwaggerRoute.ts +51 -51
  53. package/src/structures/ISwaggerSecurityScheme.ts +65 -65
  54. package/src/structures/ITypeTuple.ts +6 -6
  55. package/src/structures/MethodType.ts +5 -5
  56. package/src/structures/ParamCategory.ts +1 -1
  57. package/src/structures/TypeEntry.ts +22 -22
  58. package/src/utils/ArrayUtil.ts +26 -26
  59. package/src/utils/FileRetriever.ts +22 -22
  60. package/src/utils/MapUtil.ts +14 -14
  61. package/src/utils/PathUtil.ts +10 -10
  62. package/src/utils/SourceFinder.ts +66 -66
  63. package/src/utils/StripEnums.ts +5 -5
@@ -1,91 +1,91 @@
1
- import cp from "child_process";
2
- import fs from "fs";
3
- import path from "path";
4
-
5
- import { INestiaConfig } from "../../INestiaConfig";
6
-
7
- export namespace SdkDistributionComposer {
8
- export const compose = async (config: INestiaConfig) => {
9
- if (!fs.existsSync(config.distribute!))
10
- await fs.promises.mkdir(config.distribute!);
11
-
12
- const root: string = process.cwd();
13
- const output: string = path.resolve(config.output!);
14
- process.chdir(config.distribute!);
15
-
16
- const exit = () => process.chdir(root);
17
- if (await configured()) return exit();
18
-
19
- // COPY FILES
20
- console.log("Composing SDK distribution environments...");
21
- for (const file of await fs.promises.readdir(BUNDLE))
22
- await fs.promises.copyFile(`${BUNDLE}/${file}`, file);
23
-
24
- // CONFIGURE PATHS
25
- for (const file of ["package.json", "tsconfig.json"])
26
- await replace({ root, output })(file);
27
-
28
- // INSTALL PACKAGES
29
- const versions: IDependencies = await dependencies();
30
- execute("npm install --save-dev rimraf");
31
- execute(
32
- `npm install --save @nestia/fetcher@${versions["@nestia/fetcher"]}`,
33
- );
34
- execute(`npm install --save typia@${versions["typia"]}`);
35
- execute("npx typia setup --manager npm");
36
-
37
- exit();
38
- };
39
-
40
- const configured = async (): Promise<boolean> =>
41
- ["package.json", "tsconfig.json"].every(fs.existsSync) &&
42
- (await (async () => {
43
- const content = JSON.parse(
44
- await fs.promises.readFile("package.json", "utf8"),
45
- );
46
- return !!content.dependencies?.["@nestia/fetcher"];
47
- })());
48
-
49
- const execute = (command: string) => {
50
- console.log(` - ${command}`);
51
- cp.execSync(command, { stdio: "ignore" });
52
- };
53
-
54
- const replace =
55
- (props: { root: string; output: string }) =>
56
- async (file: string): Promise<void> => {
57
- const relative = (from: string) => (to: string) =>
58
- path.relative(from, to).split("\\").join("/");
59
- const root: string = relative(process.cwd())(props.root);
60
- const output: string = relative(process.cwd())(props.output);
61
- const current: string = relative(props.root)(process.cwd());
62
-
63
- const content: string = await fs.promises.readFile(file, "utf8");
64
- await fs.promises.writeFile(
65
- file,
66
- content
67
- .split("${root}")
68
- .join(root)
69
- .split("${output}")
70
- .join(output)
71
- .split("${current}")
72
- .join(current),
73
- "utf8",
74
- );
75
- };
76
-
77
- const dependencies = async () => {
78
- const content: string = await fs.promises.readFile(
79
- __dirname + "/../../../package.json",
80
- "utf8",
81
- );
82
- const json: { dependencies: IDependencies } = JSON.parse(content);
83
- return json.dependencies;
84
- };
85
- }
86
-
87
- interface IDependencies {
88
- "@nestia/fetcher": string;
89
- typia: string;
90
- }
91
- const BUNDLE = __dirname + "/../../../assets/bundle/distribute";
1
+ import cp from "child_process";
2
+ import fs from "fs";
3
+ import path from "path";
4
+
5
+ import { INestiaConfig } from "../../INestiaConfig";
6
+
7
+ export namespace SdkDistributionComposer {
8
+ export const compose = async (config: INestiaConfig) => {
9
+ if (!fs.existsSync(config.distribute!))
10
+ await fs.promises.mkdir(config.distribute!);
11
+
12
+ const root: string = process.cwd();
13
+ const output: string = path.resolve(config.output!);
14
+ process.chdir(config.distribute!);
15
+
16
+ const exit = () => process.chdir(root);
17
+ if (await configured()) return exit();
18
+
19
+ // COPY FILES
20
+ console.log("Composing SDK distribution environments...");
21
+ for (const file of await fs.promises.readdir(BUNDLE))
22
+ await fs.promises.copyFile(`${BUNDLE}/${file}`, file);
23
+
24
+ // CONFIGURE PATHS
25
+ for (const file of ["package.json", "tsconfig.json"])
26
+ await replace({ root, output })(file);
27
+
28
+ // INSTALL PACKAGES
29
+ const versions: IDependencies = await dependencies();
30
+ execute("npm install --save-dev rimraf");
31
+ execute(
32
+ `npm install --save @nestia/fetcher@${versions["@nestia/fetcher"]}`,
33
+ );
34
+ execute(`npm install --save typia@${versions["typia"]}`);
35
+ execute("npx typia setup --manager npm");
36
+
37
+ exit();
38
+ };
39
+
40
+ const configured = async (): Promise<boolean> =>
41
+ ["package.json", "tsconfig.json"].every(fs.existsSync) &&
42
+ (await (async () => {
43
+ const content = JSON.parse(
44
+ await fs.promises.readFile("package.json", "utf8"),
45
+ );
46
+ return !!content.dependencies?.["@nestia/fetcher"];
47
+ })());
48
+
49
+ const execute = (command: string) => {
50
+ console.log(` - ${command}`);
51
+ cp.execSync(command, { stdio: "ignore" });
52
+ };
53
+
54
+ const replace =
55
+ (props: { root: string; output: string }) =>
56
+ async (file: string): Promise<void> => {
57
+ const relative = (from: string) => (to: string) =>
58
+ path.relative(from, to).split("\\").join("/");
59
+ const root: string = relative(process.cwd())(props.root);
60
+ const output: string = relative(process.cwd())(props.output);
61
+ const current: string = relative(props.root)(process.cwd());
62
+
63
+ const content: string = await fs.promises.readFile(file, "utf8");
64
+ await fs.promises.writeFile(
65
+ file,
66
+ content
67
+ .split("${root}")
68
+ .join(root)
69
+ .split("${output}")
70
+ .join(output)
71
+ .split("${current}")
72
+ .join(current),
73
+ "utf8",
74
+ );
75
+ };
76
+
77
+ const dependencies = async () => {
78
+ const content: string = await fs.promises.readFile(
79
+ __dirname + "/../../../package.json",
80
+ "utf8",
81
+ );
82
+ const json: { dependencies: IDependencies } = JSON.parse(content);
83
+ return json.dependencies;
84
+ };
85
+ }
86
+
87
+ interface IDependencies {
88
+ "@nestia/fetcher": string;
89
+ typia: string;
90
+ }
91
+ const BUNDLE = __dirname + "/../../../assets/bundle/distribute";
@@ -1,55 +1,55 @@
1
- import { ImportDictionary } from "./ImportDictionary";
2
-
3
- export namespace SdkImportWizard {
4
- export const Fetcher = (encrypted: boolean) =>
5
- encrypted ? EncryptedFetcher : PlainFetcher;
6
-
7
- export const HttpError = (importer: ImportDictionary) =>
8
- importer.external({
9
- type: true,
10
- library: "@nestia/fetcher",
11
- instance: "HttpError",
12
- });
13
-
14
- export const IConnection = (importer: ImportDictionary) =>
15
- importer.external({
16
- type: true,
17
- library: "@nestia/fetcher",
18
- instance: "IConnection",
19
- });
20
-
21
- export const Primitive = (importer: ImportDictionary) =>
22
- importer.external({
23
- type: true,
24
- library: "@nestia/fetcher",
25
- instance: "Primitive",
26
- });
27
-
28
- export const Resolved = (importer: ImportDictionary) =>
29
- importer.external({
30
- type: true,
31
- library: "@nestia/fetcher",
32
- instance: "Resolved",
33
- });
34
-
35
- export const typia = (importer: ImportDictionary) =>
36
- importer.external({
37
- type: false,
38
- library: "typia",
39
- instance: null,
40
- });
41
- }
42
-
43
- const PlainFetcher = (importer: ImportDictionary) =>
44
- importer.external({
45
- type: false,
46
- library: "@nestia/fetcher/lib/PlainFetcher",
47
- instance: "PlainFetcher",
48
- });
49
-
50
- const EncryptedFetcher = (importer: ImportDictionary) =>
51
- importer.external({
52
- type: false,
53
- library: "@nestia/fetcher/lib/EncryptedFetcher",
54
- instance: "EncryptedFetcher",
55
- });
1
+ import { ImportDictionary } from "./ImportDictionary";
2
+
3
+ export namespace SdkImportWizard {
4
+ export const Fetcher = (encrypted: boolean) =>
5
+ encrypted ? EncryptedFetcher : PlainFetcher;
6
+
7
+ export const HttpError = (importer: ImportDictionary) =>
8
+ importer.external({
9
+ type: true,
10
+ library: "@nestia/fetcher",
11
+ instance: "HttpError",
12
+ });
13
+
14
+ export const IConnection = (importer: ImportDictionary) =>
15
+ importer.external({
16
+ type: true,
17
+ library: "@nestia/fetcher",
18
+ instance: "IConnection",
19
+ });
20
+
21
+ export const Primitive = (importer: ImportDictionary) =>
22
+ importer.external({
23
+ type: true,
24
+ library: "@nestia/fetcher",
25
+ instance: "Primitive",
26
+ });
27
+
28
+ export const Resolved = (importer: ImportDictionary) =>
29
+ importer.external({
30
+ type: true,
31
+ library: "@nestia/fetcher",
32
+ instance: "Resolved",
33
+ });
34
+
35
+ export const typia = (importer: ImportDictionary) =>
36
+ importer.external({
37
+ type: false,
38
+ library: "typia",
39
+ instance: null,
40
+ });
41
+ }
42
+
43
+ const PlainFetcher = (importer: ImportDictionary) =>
44
+ importer.external({
45
+ type: false,
46
+ library: "@nestia/fetcher/lib/PlainFetcher",
47
+ instance: "PlainFetcher",
48
+ });
49
+
50
+ const EncryptedFetcher = (importer: ImportDictionary) =>
51
+ importer.external({
52
+ type: false,
53
+ library: "@nestia/fetcher/lib/EncryptedFetcher",
54
+ instance: "EncryptedFetcher",
55
+ });
@@ -1,17 +1,17 @@
1
- import { IRoute } from "../../structures/IRoute";
2
-
3
- export class SdkRouteDirectory {
4
- public readonly module: string;
5
- public readonly children: Map<string, SdkRouteDirectory>;
6
- public readonly routes: IRoute[];
7
-
8
- public constructor(
9
- readonly parent: SdkRouteDirectory | null,
10
- readonly name: string,
11
- ) {
12
- this.children = new Map();
13
- this.routes = [];
14
- this.module =
15
- this.parent !== null ? `${this.parent.module}.${name}` : `api.${name}`;
16
- }
17
- }
1
+ import { IRoute } from "../../structures/IRoute";
2
+
3
+ export class SdkRouteDirectory {
4
+ public readonly module: string;
5
+ public readonly children: Map<string, SdkRouteDirectory>;
6
+ public readonly routes: IRoute[];
7
+
8
+ public constructor(
9
+ readonly parent: SdkRouteDirectory | null,
10
+ readonly name: string,
11
+ ) {
12
+ this.children = new Map();
13
+ this.routes = [];
14
+ this.module =
15
+ this.parent !== null ? `${this.parent.module}.${name}` : `api.${name}`;
16
+ }
17
+ }
@@ -47,7 +47,12 @@ export namespace SdkTypeProgrammer {
47
47
  for (const array of meta.arrays)
48
48
  union.push(write_array(config)(importer)(array));
49
49
  for (const object of meta.objects)
50
- if (object.name === "__type" || object.name.startsWith("__type."))
50
+ if (
51
+ object.name === "__type" ||
52
+ object.name.startsWith("__type.") ||
53
+ object.name === "__object" ||
54
+ object.name.startsWith("__object.")
55
+ )
51
56
  union.push(write_object(config)(importer)(object));
52
57
  else union.push(write_alias(config)(importer)(object));
53
58
  for (const alias of meta.aliases)