@nestia/sdk 2.6.3-dev.20240328 → 2.6.4-dev.20240401

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 (45) hide show
  1. package/lib/INestiaConfig.d.ts +14 -2
  2. package/lib/executable/internal/NestiaConfigLoader.js +31 -5
  3. package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
  4. package/lib/generates/SwaggerGenerator.d.ts +2 -0
  5. package/lib/generates/SwaggerGenerator.js +19 -3
  6. package/lib/generates/SwaggerGenerator.js.map +1 -1
  7. package/lib/structures/ISwagger.d.ts +5 -28
  8. package/lib/structures/ISwaggerServer.d.ts +15 -0
  9. package/lib/structures/ISwaggerServer.js +3 -0
  10. package/lib/structures/ISwaggerServer.js.map +1 -0
  11. package/lib/structures/ISwaggerTag.d.ts +9 -0
  12. package/lib/structures/ISwaggerTag.js +3 -0
  13. package/lib/structures/ISwaggerTag.js.map +1 -0
  14. package/package.json +3 -3
  15. package/src/INestiaConfig.ts +261 -248
  16. package/src/NestiaSdkApplication.ts +255 -255
  17. package/src/analyses/ExceptionAnalyzer.ts +148 -148
  18. package/src/analyses/ImportAnalyzer.ts +137 -137
  19. package/src/analyses/SecurityAnalyzer.ts +24 -24
  20. package/src/generates/CloneGenerator.ts +62 -62
  21. package/src/generates/E2eGenerator.ts +66 -66
  22. package/src/generates/SdkGenerator.ts +84 -84
  23. package/src/generates/SwaggerGenerator.ts +23 -3
  24. package/src/generates/internal/E2eFileProgrammer.ts +182 -182
  25. package/src/generates/internal/FilePrinter.ts +53 -53
  26. package/src/generates/internal/SdkAliasCollection.ts +152 -152
  27. package/src/generates/internal/SdkCloneProgrammer.ts +155 -155
  28. package/src/generates/internal/SdkFileProgrammer.ts +115 -115
  29. package/src/generates/internal/SdkFunctionProgrammer.ts +298 -298
  30. package/src/generates/internal/SdkImportWizard.ts +55 -55
  31. package/src/generates/internal/SdkNamespaceProgrammer.ts +510 -510
  32. package/src/generates/internal/SdkRouteProgrammer.ts +83 -83
  33. package/src/generates/internal/SdkSimulationProgrammer.ts +365 -365
  34. package/src/generates/internal/SdkTypeProgrammer.ts +385 -385
  35. package/src/generates/internal/SwaggerSchemaGenerator.ts +438 -438
  36. package/src/structures/IController.ts +94 -94
  37. package/src/structures/IRoute.ts +53 -53
  38. package/src/structures/ISwagger.ts +66 -91
  39. package/src/structures/ISwaggerRoute.ts +54 -54
  40. package/src/structures/ISwaggerSecurityScheme.ts +65 -65
  41. package/src/structures/ISwaggerServer.ts +16 -0
  42. package/src/structures/ISwaggerTag.ts +9 -0
  43. package/src/structures/ParamCategory.ts +1 -1
  44. package/src/structures/TypeEntry.ts +22 -22
  45. package/src/utils/StringUtil.ts +6 -6
@@ -1,94 +1,94 @@
1
- import type { VERSION_NEUTRAL, VersionValue } from "@nestjs/common/interfaces";
2
-
3
- import type { ParamCategory } from "./ParamCategory";
4
-
5
- export interface IController {
6
- target: Function;
7
- file: string;
8
- name: string;
9
- prefixes: string[];
10
- paths: string[];
11
- versions:
12
- | Array<Exclude<VersionValue, Array<string | typeof VERSION_NEUTRAL>>>
13
- | undefined;
14
- functions: IController.IFunction[];
15
- security: Record<string, string[]>[];
16
- swaggerTgas: string[];
17
- }
18
-
19
- export namespace IController {
20
- export interface IFunction {
21
- target: Function;
22
- name: string;
23
- method: string;
24
- paths: string[];
25
- versions:
26
- | Array<Exclude<VersionValue, Array<string | typeof VERSION_NEUTRAL>>>
27
- | undefined;
28
- encrypted: boolean;
29
- parameters: IParameter[];
30
- status?: number;
31
- type?: string;
32
- contentType: "application/json" | "text/plain";
33
- security: Record<string, string[]>[];
34
- exceptions: Record<
35
- number | "2XX" | "3XX" | "4XX" | "5XX",
36
- IController.IException
37
- >;
38
- swaggerTags: string[];
39
- }
40
-
41
- export type IParameter =
42
- | ICommonParameter
43
- | IQueryParameter
44
- | IHeadersParameter
45
- | IBodyParameter
46
- | IPathParameter;
47
- export interface ICommonParameter {
48
- custom: false;
49
- category: ParamCategory;
50
- index: number;
51
- name: string;
52
- field: string | undefined;
53
- }
54
- export interface IHeadersParameter {
55
- custom: true;
56
- category: "headers";
57
- index: number;
58
- name: string;
59
- field: string | undefined;
60
- }
61
- export interface IQueryParameter {
62
- custom: true;
63
- category: "query";
64
- index: number;
65
- name: string;
66
- field: string | undefined;
67
- }
68
- export interface IBodyParameter {
69
- custom: true;
70
- category: "body";
71
- index: number;
72
- name: string;
73
- field: string | undefined;
74
- encrypted: boolean;
75
- contentType:
76
- | "application/json"
77
- | "application/x-www-form-urlencoded"
78
- | "multipart/form-data"
79
- | "text/plain";
80
- }
81
- export interface IPathParameter {
82
- custom: true;
83
- category: "param";
84
- index: number;
85
- name: string;
86
- field: string | undefined;
87
- }
88
-
89
- export interface IException {
90
- type: string;
91
- status: number | "2XX" | "3XX" | "4XX" | "5XX";
92
- description: string | undefined;
93
- }
94
- }
1
+ import type { VERSION_NEUTRAL, VersionValue } from "@nestjs/common/interfaces";
2
+
3
+ import type { ParamCategory } from "./ParamCategory";
4
+
5
+ export interface IController {
6
+ target: Function;
7
+ file: string;
8
+ name: string;
9
+ prefixes: string[];
10
+ paths: string[];
11
+ versions:
12
+ | Array<Exclude<VersionValue, Array<string | typeof VERSION_NEUTRAL>>>
13
+ | undefined;
14
+ functions: IController.IFunction[];
15
+ security: Record<string, string[]>[];
16
+ swaggerTgas: string[];
17
+ }
18
+
19
+ export namespace IController {
20
+ export interface IFunction {
21
+ target: Function;
22
+ name: string;
23
+ method: string;
24
+ paths: string[];
25
+ versions:
26
+ | Array<Exclude<VersionValue, Array<string | typeof VERSION_NEUTRAL>>>
27
+ | undefined;
28
+ encrypted: boolean;
29
+ parameters: IParameter[];
30
+ status?: number;
31
+ type?: string;
32
+ contentType: "application/json" | "text/plain";
33
+ security: Record<string, string[]>[];
34
+ exceptions: Record<
35
+ number | "2XX" | "3XX" | "4XX" | "5XX",
36
+ IController.IException
37
+ >;
38
+ swaggerTags: string[];
39
+ }
40
+
41
+ export type IParameter =
42
+ | ICommonParameter
43
+ | IQueryParameter
44
+ | IHeadersParameter
45
+ | IBodyParameter
46
+ | IPathParameter;
47
+ export interface ICommonParameter {
48
+ custom: false;
49
+ category: ParamCategory;
50
+ index: number;
51
+ name: string;
52
+ field: string | undefined;
53
+ }
54
+ export interface IHeadersParameter {
55
+ custom: true;
56
+ category: "headers";
57
+ index: number;
58
+ name: string;
59
+ field: string | undefined;
60
+ }
61
+ export interface IQueryParameter {
62
+ custom: true;
63
+ category: "query";
64
+ index: number;
65
+ name: string;
66
+ field: string | undefined;
67
+ }
68
+ export interface IBodyParameter {
69
+ custom: true;
70
+ category: "body";
71
+ index: number;
72
+ name: string;
73
+ field: string | undefined;
74
+ encrypted: boolean;
75
+ contentType:
76
+ | "application/json"
77
+ | "application/x-www-form-urlencoded"
78
+ | "multipart/form-data"
79
+ | "text/plain";
80
+ }
81
+ export interface IPathParameter {
82
+ custom: true;
83
+ category: "param";
84
+ index: number;
85
+ name: string;
86
+ field: string | undefined;
87
+ }
88
+
89
+ export interface IException {
90
+ type: string;
91
+ status: number | "2XX" | "3XX" | "4XX" | "5XX";
92
+ description: string | undefined;
93
+ }
94
+ }
@@ -1,53 +1,53 @@
1
- import ts from "typescript";
2
- import { Metadata } from "typia/lib/schemas/metadata/Metadata";
3
-
4
- import { IController } from "./IController";
5
-
6
- export interface IRoute {
7
- controller: Function;
8
- name: string;
9
- method: string;
10
- path: string;
11
- encrypted: boolean;
12
- status?: number;
13
-
14
- accessors: string[];
15
- parameters: IRoute.IParameter[];
16
- imports: [string, string[]][];
17
- output: IRoute.IOutput;
18
-
19
- location: string;
20
- target: {
21
- class: Function;
22
- function: Function;
23
- };
24
- description?: string;
25
- operationId?: string;
26
- jsDocTags: ts.JSDocTagInfo[];
27
- setHeaders: Array<
28
- | { type: "setter"; source: string; target?: string }
29
- | { type: "assigner"; source: string }
30
- >;
31
- security: Record<string, string[]>[];
32
- exceptions: Record<number | "2XX" | "3XX" | "4XX" | "5XX", IRoute.IOutput>;
33
- swaggerTags: string[];
34
- }
35
-
36
- export namespace IRoute {
37
- export type IParameter = IController.IParameter & {
38
- optional: boolean;
39
- type: ts.Type;
40
- typeName: string;
41
- metadata?: Metadata;
42
- };
43
- export interface IOutput {
44
- type: ts.Type;
45
- typeName: string;
46
- metadata?: Metadata;
47
- description?: string;
48
- contentType:
49
- | "application/x-www-form-urlencoded"
50
- | "application/json"
51
- | "text/plain";
52
- }
53
- }
1
+ import ts from "typescript";
2
+ import { Metadata } from "typia/lib/schemas/metadata/Metadata";
3
+
4
+ import { IController } from "./IController";
5
+
6
+ export interface IRoute {
7
+ controller: Function;
8
+ name: string;
9
+ method: string;
10
+ path: string;
11
+ encrypted: boolean;
12
+ status?: number;
13
+
14
+ accessors: string[];
15
+ parameters: IRoute.IParameter[];
16
+ imports: [string, string[]][];
17
+ output: IRoute.IOutput;
18
+
19
+ location: string;
20
+ target: {
21
+ class: Function;
22
+ function: Function;
23
+ };
24
+ description?: string;
25
+ operationId?: string;
26
+ jsDocTags: ts.JSDocTagInfo[];
27
+ setHeaders: Array<
28
+ | { type: "setter"; source: string; target?: string }
29
+ | { type: "assigner"; source: string }
30
+ >;
31
+ security: Record<string, string[]>[];
32
+ exceptions: Record<number | "2XX" | "3XX" | "4XX" | "5XX", IRoute.IOutput>;
33
+ swaggerTags: string[];
34
+ }
35
+
36
+ export namespace IRoute {
37
+ export type IParameter = IController.IParameter & {
38
+ optional: boolean;
39
+ type: ts.Type;
40
+ typeName: string;
41
+ metadata?: Metadata;
42
+ };
43
+ export interface IOutput {
44
+ type: ts.Type;
45
+ typeName: string;
46
+ metadata?: Metadata;
47
+ description?: string;
48
+ contentType:
49
+ | "application/x-www-form-urlencoded"
50
+ | "application/json"
51
+ | "text/plain";
52
+ }
53
+ }
@@ -1,91 +1,66 @@
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 uri
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 uri
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
+ import { ISwaggerServer } from "./ISwaggerServer";
5
+ import { ISwaggerTag } from "./ISwaggerTag";
6
+
7
+ /**
8
+ * Swagger Document.
9
+ *
10
+ * `ISwagger` is a data structure representing content of `swagger.json` file
11
+ * generated by Nestia. Note that, this is not an universal structure, but a dedicated
12
+ * structure only for Nestia.
13
+ *
14
+ * @author Jeongho Nam - https://github.com/samchon
15
+ */
16
+ export interface ISwagger {
17
+ /**
18
+ * The version of the OpenAPI document.
19
+ *
20
+ * Nestia always generate OpenAPI 3.0.x document.
21
+ */
22
+ openapi: `3.0.${number}`;
23
+
24
+ /**
25
+ * List of servers that provide the API.
26
+ */
27
+ servers: ISwaggerServer[];
28
+
29
+ /**
30
+ * Information about the API.
31
+ */
32
+ info: ISwaggerInfo;
33
+
34
+ /**
35
+ * The available paths and operations for the API.
36
+ *
37
+ * The 1st key is the path, and the 2nd key is the HTTP method.
38
+ */
39
+ paths: Record<string, Record<string, ISwaggerRoute>>;
40
+
41
+ /**
42
+ * An object to hold reusable data structures.
43
+ *
44
+ * It stores both DTO schemas and security schemes.
45
+ *
46
+ * For reference, `nestia` defines every object and alias types as reusable DTO
47
+ * schemas. The alias type means that defined by `type` keyword in TypeScript.
48
+ */
49
+ components: ISwaggerComponents;
50
+
51
+ /**
52
+ * List of tags.
53
+ */
54
+ tags: ISwaggerTag[];
55
+
56
+ // /**
57
+ // * A declaration of which security mechanisms can be used across the API.
58
+ // *
59
+ // * When this property be configured, it would be overwritten in every API routes.
60
+ // *
61
+ // * For reference, key means the name of security scheme and value means the `scopes`.
62
+ // * The `scopes` can be used only when target security scheme is `oauth2` type,
63
+ // * especially for {@link ISwaggerSecurityScheme.IOAuth2.IFlow.scopes} property.
64
+ // */
65
+ // security?: Record<string, string[]>[];
66
+ }
@@ -1,54 +1,54 @@
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
- "multipart/form-data"?: {
51
- schema: IJsonSchema;
52
- };
53
- }
54
- }
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
+ "multipart/form-data"?: {
51
+ schema: IJsonSchema;
52
+ };
53
+ }
54
+ }