@nestia/sdk 2.4.3 → 2.4.4

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 (70) hide show
  1. package/lib/INestiaConfig.d.ts +13 -0
  2. package/lib/analyses/ControllerAnalyzer.js +12 -1
  3. package/lib/analyses/ControllerAnalyzer.js.map +1 -1
  4. package/lib/analyses/PathAnalyzer.d.ts +2 -2
  5. package/lib/analyses/PathAnalyzer.js +27 -11
  6. package/lib/analyses/PathAnalyzer.js.map +1 -1
  7. package/lib/analyses/ReflectAnalyzer.js +11 -2
  8. package/lib/analyses/ReflectAnalyzer.js.map +1 -1
  9. package/lib/executable/internal/NestiaConfigLoader.js +5 -1
  10. package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
  11. package/lib/executable/sdk.js +11 -11
  12. package/lib/generates/SwaggerGenerator.js +16 -22
  13. package/lib/generates/SwaggerGenerator.js.map +1 -1
  14. package/lib/generates/internal/SwaggerSchemaGenerator.js +22 -15
  15. package/lib/generates/internal/SwaggerSchemaGenerator.js.map +1 -1
  16. package/lib/structures/ISwaggerComponents.d.ts +1 -1
  17. package/lib/structures/ISwaggerRoute.d.ts +3 -3
  18. package/package.json +5 -5
  19. package/src/INestiaConfig.ts +248 -234
  20. package/src/NestiaSdkApplication.ts +253 -253
  21. package/src/analyses/AccessorAnalyzer.ts +60 -60
  22. package/src/analyses/ConfigAnalyzer.ts +147 -147
  23. package/src/analyses/ControllerAnalyzer.ts +390 -379
  24. package/src/analyses/ExceptionAnalyzer.ts +115 -115
  25. package/src/analyses/GenericAnalyzer.ts +51 -51
  26. package/src/analyses/ImportAnalyzer.ts +138 -138
  27. package/src/analyses/PathAnalyzer.ts +110 -98
  28. package/src/analyses/ReflectAnalyzer.ts +11 -6
  29. package/src/analyses/SecurityAnalyzer.ts +20 -20
  30. package/src/executable/internal/CommandParser.ts +15 -15
  31. package/src/executable/internal/NestiaConfigLoader.ts +67 -67
  32. package/src/executable/internal/NestiaSdkCommand.ts +60 -60
  33. package/src/executable/sdk.ts +73 -73
  34. package/src/generates/E2eGenerator.ts +64 -64
  35. package/src/generates/SdkGenerator.ts +96 -96
  36. package/src/generates/SwaggerGenerator.ts +376 -372
  37. package/src/generates/internal/E2eFileProgrammer.ts +123 -123
  38. package/src/generates/internal/SdkDistributionComposer.ts +91 -91
  39. package/src/generates/internal/SdkDtoGenerator.ts +424 -424
  40. package/src/generates/internal/SdkFileProgrammer.ts +106 -106
  41. package/src/generates/internal/SdkImportWizard.ts +55 -55
  42. package/src/generates/internal/SdkRouteDirectory.ts +17 -17
  43. package/src/generates/internal/SdkSimulationProgrammer.ts +133 -133
  44. package/src/generates/internal/SdkTypeDefiner.ts +119 -119
  45. package/src/generates/internal/SwaggerSchemaGenerator.ts +18 -2
  46. package/src/generates/internal/SwaggerSchemaValidator.ts +198 -198
  47. package/src/index.ts +4 -4
  48. package/src/module.ts +2 -2
  49. package/src/structures/IErrorReport.ts +6 -6
  50. package/src/structures/INestiaProject.ts +13 -13
  51. package/src/structures/INormalizedInput.ts +20 -20
  52. package/src/structures/ISwagger.ts +91 -91
  53. package/src/structures/ISwaggerComponents.ts +29 -29
  54. package/src/structures/ISwaggerError.ts +8 -8
  55. package/src/structures/ISwaggerInfo.ts +80 -80
  56. package/src/structures/ISwaggerLazyProperty.ts +7 -7
  57. package/src/structures/ISwaggerLazySchema.ts +7 -7
  58. package/src/structures/ISwaggerRoute.ts +51 -51
  59. package/src/structures/ISwaggerSecurityScheme.ts +65 -65
  60. package/src/structures/ITypeTuple.ts +6 -6
  61. package/src/structures/MethodType.ts +5 -5
  62. package/src/structures/ParamCategory.ts +1 -1
  63. package/src/structures/TypeEntry.ts +22 -22
  64. package/src/utils/ArrayUtil.ts +26 -26
  65. package/src/utils/FileRetriever.ts +22 -22
  66. package/src/utils/ImportDictionary.ts +125 -125
  67. package/src/utils/MapUtil.ts +14 -14
  68. package/src/utils/PathUtil.ts +10 -10
  69. package/src/utils/SourceFinder.ts +66 -66
  70. package/src/utils/StripEnums.ts +5 -5
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,6 +1,6 @@
1
- export interface IErrorReport {
2
- file: string;
3
- controller: string;
4
- function: string | null;
5
- message: string;
6
- }
1
+ export interface IErrorReport {
2
+ file: string;
3
+ controller: string;
4
+ function: string | null;
5
+ message: string;
6
+ }
@@ -1,13 +1,13 @@
1
- import ts from "typescript";
2
-
3
- import { INestiaConfig } from "../INestiaConfig";
4
- import { IErrorReport } from "./IErrorReport";
5
- import { INormalizedInput } from "./INormalizedInput";
6
-
7
- export interface INestiaProject {
8
- config: INestiaConfig;
9
- input: INormalizedInput;
10
- checker: ts.TypeChecker;
11
- errors: IErrorReport[];
12
- warnings: IErrorReport[];
13
- }
1
+ import ts from "typescript";
2
+
3
+ import { INestiaConfig } from "../INestiaConfig";
4
+ import { IErrorReport } from "./IErrorReport";
5
+ import { INormalizedInput } from "./INormalizedInput";
6
+
7
+ export interface INestiaProject {
8
+ config: INestiaConfig;
9
+ input: INormalizedInput;
10
+ checker: ts.TypeChecker;
11
+ errors: IErrorReport[];
12
+ warnings: IErrorReport[];
13
+ }
@@ -1,20 +1,20 @@
1
- import { RouteInfo, VersionValue } from "@nestjs/common/interfaces";
2
-
3
- export interface INormalizedInput {
4
- include: INormalizedInput.IInput[];
5
- globalPrefix?: {
6
- prefix: string;
7
- exclude?: Array<string | RouteInfo>;
8
- };
9
- versioning?: {
10
- prefix: string;
11
- defaultVersion?: VersionValue;
12
- };
13
- }
14
- export namespace INormalizedInput {
15
- export interface IInput {
16
- paths: string[];
17
- file: string;
18
- controller?: Function;
19
- }
20
- }
1
+ import { RouteInfo, VersionValue } from "@nestjs/common/interfaces";
2
+
3
+ export interface INormalizedInput {
4
+ include: INormalizedInput.IInput[];
5
+ globalPrefix?: {
6
+ prefix: string;
7
+ exclude?: Array<string | RouteInfo>;
8
+ };
9
+ versioning?: {
10
+ prefix: string;
11
+ defaultVersion?: VersionValue;
12
+ };
13
+ }
14
+ export namespace INormalizedInput {
15
+ export interface IInput {
16
+ paths: string[];
17
+ file: string;
18
+ controller?: Function;
19
+ }
20
+ }
@@ -1,91 +1,91 @@
1
- import { ISwaggerComponents } from "./ISwaggerComponents";
2
- import { ISwaggerInfo } from "./ISwaggerInfo";
3
- import { ISwaggerRoute } from "./ISwaggerRoute";
4
-
5
- /**
6
- * Swagger Document.
7
- *
8
- * `ISwagger` is a data structure representing content of `swagger.json` file
9
- * generated by Nestia. Note that, this is not an universal structure, but a dedicated
10
- * structure only for Nestia.
11
- *
12
- * @author Jeongho Nam - https://github.com/samchon
13
- */
14
- export interface ISwagger {
15
- /**
16
- * The version of the OpenAPI document.
17
- *
18
- * Nestia always generate OpenAPI 3.0.x document.
19
- */
20
- openapi: `3.0.${number}`;
21
-
22
- /**
23
- * List of servers that provide the API.
24
- */
25
- servers: ISwagger.IServer[];
26
-
27
- /**
28
- * Information about the API.
29
- */
30
- info: ISwaggerInfo;
31
-
32
- /**
33
- * The available paths and operations for the API.
34
- *
35
- * The 1st key is the path, and the 2nd key is the HTTP method.
36
- */
37
- paths: Record<string, Record<string, ISwaggerRoute>>;
38
-
39
- /**
40
- * An object to hold reusable data structures.
41
- *
42
- * It stores both DTO schemas and security schemes.
43
- *
44
- * For reference, `nestia` defines every object and alias types as reusable DTO
45
- * schemas. The alias type means that defined by `type` keyword in TypeScript.
46
- */
47
- components: ISwaggerComponents;
48
-
49
- // /**
50
- // * A declaration of which security mechanisms can be used across the API.
51
- // *
52
- // * When this property be configured, it would be overwritten in every API routes.
53
- // *
54
- // * For reference, key means the name of security scheme and value means the `scopes`.
55
- // * The `scopes` can be used only when target security scheme is `oauth2` type,
56
- // * especially for {@link ISwaggerSecurityScheme.IOAuth2.IFlow.scopes} property.
57
- // */
58
- // security?: Record<string, string[]>[];
59
- }
60
- export namespace ISwagger {
61
- /**
62
- * Remote server definition.
63
- */
64
- export interface IServer {
65
- /**
66
- * A URL to the target host.
67
- *
68
- * @format url
69
- */
70
- url: string;
71
-
72
- /**
73
- * An optional string describing the target server.
74
- */
75
- description?: string;
76
- }
77
-
78
- export interface IExternalDocs {
79
- /**
80
- * The URL for target documentation.
81
- *
82
- * @format url
83
- */
84
- url: string;
85
-
86
- /**
87
- * A short description of the target documentation.
88
- */
89
- description?: string;
90
- }
91
- }
1
+ import { ISwaggerComponents } from "./ISwaggerComponents";
2
+ import { ISwaggerInfo } from "./ISwaggerInfo";
3
+ import { ISwaggerRoute } from "./ISwaggerRoute";
4
+
5
+ /**
6
+ * Swagger Document.
7
+ *
8
+ * `ISwagger` is a data structure representing content of `swagger.json` file
9
+ * generated by Nestia. Note that, this is not an universal structure, but a dedicated
10
+ * structure only for Nestia.
11
+ *
12
+ * @author Jeongho Nam - https://github.com/samchon
13
+ */
14
+ export interface ISwagger {
15
+ /**
16
+ * The version of the OpenAPI document.
17
+ *
18
+ * Nestia always generate OpenAPI 3.0.x document.
19
+ */
20
+ openapi: `3.0.${number}`;
21
+
22
+ /**
23
+ * List of servers that provide the API.
24
+ */
25
+ servers: ISwagger.IServer[];
26
+
27
+ /**
28
+ * Information about the API.
29
+ */
30
+ info: ISwaggerInfo;
31
+
32
+ /**
33
+ * The available paths and operations for the API.
34
+ *
35
+ * The 1st key is the path, and the 2nd key is the HTTP method.
36
+ */
37
+ paths: Record<string, Record<string, ISwaggerRoute>>;
38
+
39
+ /**
40
+ * An object to hold reusable data structures.
41
+ *
42
+ * It stores both DTO schemas and security schemes.
43
+ *
44
+ * For reference, `nestia` defines every object and alias types as reusable DTO
45
+ * schemas. The alias type means that defined by `type` keyword in TypeScript.
46
+ */
47
+ components: ISwaggerComponents;
48
+
49
+ // /**
50
+ // * A declaration of which security mechanisms can be used across the API.
51
+ // *
52
+ // * When this property be configured, it would be overwritten in every API routes.
53
+ // *
54
+ // * For reference, key means the name of security scheme and value means the `scopes`.
55
+ // * The `scopes` can be used only when target security scheme is `oauth2` type,
56
+ // * especially for {@link ISwaggerSecurityScheme.IOAuth2.IFlow.scopes} property.
57
+ // */
58
+ // security?: Record<string, string[]>[];
59
+ }
60
+ export namespace ISwagger {
61
+ /**
62
+ * Remote server definition.
63
+ */
64
+ export interface IServer {
65
+ /**
66
+ * A URL to the target host.
67
+ *
68
+ * @format url
69
+ */
70
+ url: string;
71
+
72
+ /**
73
+ * An optional string describing the target server.
74
+ */
75
+ description?: string;
76
+ }
77
+
78
+ export interface IExternalDocs {
79
+ /**
80
+ * The URL for target documentation.
81
+ *
82
+ * @format url
83
+ */
84
+ url: string;
85
+
86
+ /**
87
+ * A short description of the target documentation.
88
+ */
89
+ description?: string;
90
+ }
91
+ }
@@ -1,29 +1,29 @@
1
- import { IJsonComponents } from "typia";
2
-
3
- import { ISwaggerSecurityScheme } from "./ISwaggerSecurityScheme";
4
-
5
- /**
6
- * Reusable components in Swagger.
7
- *
8
- * `ISwaggerComponents` is a data structure representing content of `components` object
9
- * in `swagger.json` file generated by Nestia. Note that, this is not an universal
10
- * structure, but a dedicated structure only for Nestia.
11
- *
12
- * @author Jeongho Nam - https://github.com/samchon
13
- */
14
- export interface ISwaggerComponents {
15
- /**
16
- * An object to hold reusable DTO schemas.
17
- *
18
- * For reference, `nestia` stores every object and alias types as reusable DTO
19
- * schemas. The alias type means that defined by `type` keyword in TypeScript.
20
- */
21
- schemas?: Record<string, IJsonComponents.IObject | IJsonComponents.IAlias>;
22
-
23
- /**
24
- * An object to hold reusable security schemes.
25
- *
26
- * This property be configured by user in `nestia.config.ts` file.
27
- */
28
- securitySchemes?: Record<string, ISwaggerSecurityScheme>;
29
- }
1
+ import { IJsonComponents } from "typia";
2
+
3
+ import { ISwaggerSecurityScheme } from "./ISwaggerSecurityScheme";
4
+
5
+ /**
6
+ * Reusable components in Swagger.
7
+ *
8
+ * `ISwaggerComponents` is a data structure representing content of `components` object
9
+ * in `swagger.json` file generated by Nestia. Note that, this is not an universal
10
+ * structure, but a dedicated structure only for Nestia.
11
+ *
12
+ * @author Jeongho Nam - https://github.com/samchon
13
+ */
14
+ export interface ISwaggerComponents {
15
+ /**
16
+ * An object to hold reusable DTO schemas.
17
+ *
18
+ * For reference, `nestia` stores every object and alias types as reusable DTO
19
+ * schemas. The alias type means that defined by `type` keyword in TypeScript.
20
+ */
21
+ schemas?: Record<string, IJsonComponents.IAlias>;
22
+
23
+ /**
24
+ * An object to hold reusable security schemes.
25
+ *
26
+ * This property be configured by user in `nestia.config.ts` file.
27
+ */
28
+ securitySchemes?: Record<string, ISwaggerSecurityScheme>;
29
+ }
@@ -1,8 +1,8 @@
1
- import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
2
-
3
- import { IRoute } from "./IRoute";
4
-
5
- export interface ISwaggerError extends MetadataFactory.IError {
6
- route: IRoute;
7
- from: string;
8
- }
1
+ import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
2
+
3
+ import { IRoute } from "./IRoute";
4
+
5
+ export interface ISwaggerError extends MetadataFactory.IError {
6
+ route: IRoute;
7
+ from: string;
8
+ }
@@ -1,80 +1,80 @@
1
- /**
2
- * Information about the API.
3
- *
4
- * @author Samchon
5
- */
6
- export interface ISwaggerInfo {
7
- /**
8
- * The title of the API.
9
- */
10
- title: string;
11
-
12
- /**
13
- * A short description of the API.
14
- */
15
- description?: string;
16
-
17
- /**
18
- * A URL to the Terms of Service for the API.
19
- *
20
- * @format url
21
- */
22
- termsOfService?: string;
23
-
24
- /**
25
- * The contact information for the exposed API.
26
- */
27
- contact?: ISwaggerInfo.IContact;
28
-
29
- /**
30
- * The license information for the exposed API.
31
- */
32
- license?: ISwaggerInfo.ILicense;
33
-
34
- /**
35
- * Version of the API.
36
- */
37
- version: string;
38
- }
39
- export namespace ISwaggerInfo {
40
- /**
41
- * Contact information for the exposed API.
42
- */
43
- export interface IContact {
44
- /**
45
- * The identifying name of the contact person/organization.
46
- */
47
- name?: string;
48
-
49
- /**
50
- * The URL pointing to the contact information.
51
- *
52
- * @format url
53
- */
54
- url?: string;
55
-
56
- /**
57
- * The email address of the contact person/organization.
58
- *
59
- * @format email
60
- */
61
- email?: string;
62
- }
63
-
64
- /**
65
- * License information for the exposed API.
66
- */
67
- export interface ILicense {
68
- /**
69
- * The license name used for the API.
70
- */
71
- name: string;
72
-
73
- /**
74
- * A URL to the license used for the API.
75
- *
76
- * @format url
77
- */
78
- url?: string;
79
- }
80
- }
1
+ /**
2
+ * Information about the API.
3
+ *
4
+ * @author Samchon
5
+ */
6
+ export interface ISwaggerInfo {
7
+ /**
8
+ * The title of the API.
9
+ */
10
+ title: string;
11
+
12
+ /**
13
+ * A short description of the API.
14
+ */
15
+ description?: string;
16
+
17
+ /**
18
+ * A URL to the Terms of Service for the API.
19
+ *
20
+ * @format url
21
+ */
22
+ termsOfService?: string;
23
+
24
+ /**
25
+ * The contact information for the exposed API.
26
+ */
27
+ contact?: ISwaggerInfo.IContact;
28
+
29
+ /**
30
+ * The license information for the exposed API.
31
+ */
32
+ license?: ISwaggerInfo.ILicense;
33
+
34
+ /**
35
+ * Version of the API.
36
+ */
37
+ version: string;
38
+ }
39
+ export namespace ISwaggerInfo {
40
+ /**
41
+ * Contact information for the exposed API.
42
+ */
43
+ export interface IContact {
44
+ /**
45
+ * The identifying name of the contact person/organization.
46
+ */
47
+ name?: string;
48
+
49
+ /**
50
+ * The URL pointing to the contact information.
51
+ *
52
+ * @format url
53
+ */
54
+ url?: string;
55
+
56
+ /**
57
+ * The email address of the contact person/organization.
58
+ *
59
+ * @format email
60
+ */
61
+ email?: string;
62
+ }
63
+
64
+ /**
65
+ * License information for the exposed API.
66
+ */
67
+ export interface ILicense {
68
+ /**
69
+ * The license name used for the API.
70
+ */
71
+ name: string;
72
+
73
+ /**
74
+ * A URL to the license used for the API.
75
+ *
76
+ * @format url
77
+ */
78
+ url?: string;
79
+ }
80
+ }
@@ -1,7 +1,7 @@
1
- import { IJsonSchema } from "typia";
2
-
3
- export interface ISwaggerLazyProperty {
4
- schema: IJsonSchema;
5
- object: string;
6
- property: string;
7
- }
1
+ import { IJsonSchema } from "typia";
2
+
3
+ export interface ISwaggerLazyProperty {
4
+ schema: IJsonSchema;
5
+ object: string;
6
+ property: string;
7
+ }
@@ -1,7 +1,7 @@
1
- import { IJsonSchema } from "typia";
2
- import { Metadata } from "typia/lib/schemas/metadata/Metadata";
3
-
4
- export interface ISwaggerLazySchema {
5
- metadata: Metadata;
6
- schema: IJsonSchema;
7
- }
1
+ import { IJsonSchema } from "typia";
2
+ import { Metadata } from "typia/lib/schemas/metadata/Metadata";
3
+
4
+ export interface ISwaggerLazySchema {
5
+ metadata: Metadata;
6
+ schema: IJsonSchema;
7
+ }
@@ -1,51 +1,51 @@
1
- import { IJsonSchema } from "typia";
2
- import { IJsDocTagInfo } from "typia/lib/schemas/metadata/IJsDocTagInfo";
3
-
4
- export interface ISwaggerRoute {
5
- deprecated?: boolean;
6
- security?: Record<string, string[]>[];
7
- operationId?: string;
8
- tags: string[];
9
- parameters: ISwaggerRoute.IParameter[];
10
- requestBody?: ISwaggerRoute.IRequestBody;
11
- responses: ISwaggerRoute.IResponseBody;
12
- summary?: string;
13
- description?: string;
14
- "x-nestia-method": string;
15
- "x-nestia-namespace": string;
16
- "x-nestia-jsDocTags"?: IJsDocTagInfo[];
17
- }
18
- export namespace ISwaggerRoute {
19
- export interface IParameter {
20
- name: string;
21
- in: string;
22
- schema: IJsonSchema;
23
- required: boolean;
24
- description?: string;
25
- }
26
- export interface IRequestBody {
27
- description?: string;
28
- content: IContent;
29
- required: true;
30
- "x-nestia-encrypted": boolean;
31
- }
32
- export type IResponseBody = Record<
33
- string,
34
- {
35
- description: string;
36
- content?: IContent;
37
- "x-nestia-encrypted"?: boolean;
38
- }
39
- >;
40
- export interface IContent {
41
- "application/x-www-form-urlencoded"?: {
42
- schema: IJsonSchema;
43
- };
44
- "application/json"?: {
45
- schema: IJsonSchema;
46
- };
47
- "text/plain"?: {
48
- schema: IJsonSchema;
49
- };
50
- }
51
- }
1
+ import { IJsonSchema } from "typia";
2
+ import { IJsDocTagInfo } from "typia/lib/schemas/metadata/IJsDocTagInfo";
3
+
4
+ export interface ISwaggerRoute {
5
+ deprecated?: boolean;
6
+ security?: Record<string, string[]>[];
7
+ operationId?: string;
8
+ tags: string[];
9
+ parameters: ISwaggerRoute.IParameter[];
10
+ requestBody?: ISwaggerRoute.IRequestBody;
11
+ responses: ISwaggerRoute.IResponseBody;
12
+ summary?: string;
13
+ description?: string;
14
+ "x-nestia-method"?: string;
15
+ "x-nestia-namespace"?: string;
16
+ "x-nestia-jsDocTags"?: IJsDocTagInfo[];
17
+ }
18
+ export namespace ISwaggerRoute {
19
+ export interface IParameter {
20
+ name: string;
21
+ in: string;
22
+ schema: IJsonSchema;
23
+ required: boolean;
24
+ description?: string;
25
+ }
26
+ export interface IRequestBody {
27
+ description?: string;
28
+ content: IContent;
29
+ required: true;
30
+ "x-nestia-encrypted"?: boolean;
31
+ }
32
+ export type IResponseBody = Record<
33
+ string,
34
+ {
35
+ description: string;
36
+ content?: IContent;
37
+ "x-nestia-encrypted"?: boolean;
38
+ }
39
+ >;
40
+ export interface IContent {
41
+ "application/x-www-form-urlencoded"?: {
42
+ schema: IJsonSchema;
43
+ };
44
+ "application/json"?: {
45
+ schema: IJsonSchema;
46
+ };
47
+ "text/plain"?: {
48
+ schema: IJsonSchema;
49
+ };
50
+ }
51
+ }