@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.
Files changed (51) hide show
  1. package/assets/config/nestia.config.ts +70 -70
  2. package/lib/INestiaConfig.d.ts +13 -0
  3. package/lib/executable/internal/NestiaSdkConfig.js +6 -2
  4. package/lib/executable/internal/NestiaSdkConfig.js.map +1 -1
  5. package/lib/executable/sdk.js +11 -11
  6. package/lib/generates/SwaggerGenerator.js +9 -9
  7. package/lib/generates/internal/DistributionComposer.js +1 -1
  8. package/lib/generates/internal/DistributionComposer.js.map +1 -1
  9. package/lib/generates/internal/E2eFileProgrammer.js +12 -12
  10. package/lib/generates/internal/SdkFileProgrammer.js +3 -1
  11. package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
  12. package/lib/generates/internal/SdkFunctionProgrammer.js +24 -43
  13. package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
  14. package/package.json +4 -4
  15. package/src/INestiaConfig.ts +204 -190
  16. package/src/NestiaSdkApplication.ts +262 -262
  17. package/src/analyses/ControllerAnalyzer.ts +261 -261
  18. package/src/analyses/GenericAnalyzer.ts +53 -53
  19. package/src/analyses/ImportAnalyzer.ts +164 -164
  20. package/src/analyses/PathAnalyzer.ts +58 -58
  21. package/src/analyses/ReflectAnalyzer.ts +321 -321
  22. package/src/executable/internal/CommandParser.ts +15 -15
  23. package/src/executable/internal/NestiaConfigCompilerOptions.ts +18 -18
  24. package/src/executable/internal/NestiaSdkCommand.ts +156 -156
  25. package/src/executable/internal/NestiaSdkConfig.ts +36 -36
  26. package/src/executable/internal/nestia.config.getter.ts +12 -12
  27. package/src/executable/sdk.ts +70 -70
  28. package/src/generates/E2eGenerator.ts +67 -67
  29. package/src/generates/SdkGenerator.ts +56 -56
  30. package/src/generates/SwaggerGenerator.ts +504 -504
  31. package/src/generates/internal/DistributionComposer.ts +98 -97
  32. package/src/generates/internal/E2eFileProgrammer.ts +135 -135
  33. package/src/generates/internal/SdkFileProgrammer.ts +148 -144
  34. package/src/generates/internal/SdkFunctionProgrammer.ts +30 -52
  35. package/src/generates/internal/SdkRouteDirectory.ts +21 -21
  36. package/src/index.ts +4 -4
  37. package/src/module.ts +2 -2
  38. package/src/structures/IController.ts +31 -31
  39. package/src/structures/IRoute.ts +39 -39
  40. package/src/structures/ISwaggerDocument.ts +120 -120
  41. package/src/structures/ITypeTuple.ts +6 -6
  42. package/src/structures/MethodType.ts +11 -11
  43. package/src/structures/ParamCategory.ts +1 -1
  44. package/src/structures/TypeEntry.ts +22 -22
  45. package/src/utils/ArrayUtil.ts +26 -26
  46. package/src/utils/FileRetriever.ts +22 -22
  47. package/src/utils/ImportDictionary.ts +56 -56
  48. package/src/utils/MapUtil.ts +14 -14
  49. package/src/utils/NestiaConfigUtil.ts +21 -21
  50. package/src/utils/SourceFinder.ts +60 -60
  51. package/src/utils/StripEnums.ts +10 -10
@@ -1,190 +1,204 @@
1
- import type ts from "typescript";
2
-
3
- import type { ISwaggerDocument } from "./structures/ISwaggerDocument";
4
- import type { StripEnums } from "./utils/StripEnums";
5
-
6
- /**
7
- * Definition for the `nestia.config.ts` file.
8
- *
9
- * @author Jeongho Nam - https://github.com/samchon
10
- */
11
- export interface INestiaConfig {
12
- /**
13
- * Building `swagger.json` is also possible.
14
- *
15
- * If not specified, you can't build the `swagger.json`.
16
- */
17
- swagger?: INestiaConfig.ISwaggerConfig;
18
-
19
- /**
20
- * List of files or directories containing the NestJS controller classes.
21
- */
22
- input: string | string[] | INestiaConfig.IInput;
23
-
24
- /**
25
- * Output directory that SDK would be placed in.
26
- *
27
- * If not configured, you can't build the SDK library.
28
- */
29
- output?: string;
30
-
31
- /**
32
- * Target directory that SDK distribution files would be placed in.
33
- *
34
- * If you configure this property and runs `npx nestia sdk` command,
35
- * distribution environments for the SDK library would be generated.
36
- *
37
- * After the SDK library generation, move to the `distribute` directory,
38
- * and runs `npm publish` command, then you can share SDK library with
39
- * other client (frontend) developers.
40
- *
41
- * Recommend to use `"packages/api"` value.
42
- */
43
- distribute?: string;
44
-
45
- /**
46
- * Target directory that e2e test functions would be placed in.
47
- *
48
- * If you configure this property and runs `npx nestia e2e` command,
49
- * `@nestia/sdk` will analyze your NestJS backend server code, and
50
- * generates e2e test functions for every API endpoints.
51
- *
52
- * If not configured, you can't run `npx nestia e2e` command.
53
- */
54
- e2e?: string;
55
-
56
- /**
57
- * Compiler options for the TypeScript.
58
- *
59
- * If you've omitted this property or the assigned property cannot fully cover the
60
- * `tsconfig.json`, the properties from the `tsconfig.json` would be assigned to here.
61
- * Otherwise, this property has been configured and it's detailed values are different
62
- * with the `tsconfig.json`, this property values would be used instead.
63
- *
64
- * ```typescript
65
- * import ts from "typescript";
66
- *
67
- * const tsconfig: ts.TsConfig;
68
- * const nestiaConfig: IConfiguration;
69
- *
70
- * const compilerOptions: ts.CompilerOptions = {
71
- * ...tsconfig.compilerOptions,
72
- * ...(nestiaConfig.compilerOptions ?? {})
73
- * }
74
- * ```
75
- */
76
- compilerOptions?: StripEnums<ts.CompilerOptions>;
77
-
78
- /**
79
- * Whether to assert parameter types or not.
80
- *
81
- * If you configure this property to be `true`, all of the function
82
- * parameters of SDK library would be checked through
83
- * [`typia.assert<T>()` function](https://typia.io/docs/validators/assert/).
84
- *
85
- * This option would make your SDK library compilation time a little bit slower,
86
- * but would enahcne the type safety even in the runtime level.
87
- *
88
- * @default false
89
- */
90
- assert?: boolean;
91
-
92
- /**
93
- * Whether to optimize JSON string conversion 10x faster or not.
94
- *
95
- * If you configure this property to be `true`, the SDK library would utilize the
96
- * [`typia.assertStringify<T>() function`](https://github.com/samchon/typia#enhanced-json)
97
- * to boost up JSON serialization speed and ensure type safety.
98
- *
99
- * This option would make your SDK library compilation time a little bit slower,
100
- * but would enhance JSON serialization speed 10x faster. Also, it can ensure type
101
- * safety even in the rumtime level.
102
- *
103
- * @default false
104
- */
105
- json?: boolean;
106
-
107
- /**
108
- * Whether to wrap DTO by primitive type.
109
- *
110
- * If you don't configure this property as `false`, all of DTOs in the
111
- * SDK library would be automatically wrapped by {@link Primitive} type.
112
- *
113
- * For refenrece, if a DTO type be capsuled by the {@link Primitive} type,
114
- * all of methods in the DTO type would be automatically erased. Also, if
115
- * the DTO has a `toJSON()` method, the DTO type would be automatically
116
- * converted to return type of the `toJSON()` method.
117
- *
118
- * @default true
119
- */
120
- primitive?: boolean;
121
- }
122
- export namespace INestiaConfig {
123
- /**
124
- * List of files or directories to include or exclude to specifying the NestJS
125
- * controllers.
126
- */
127
- export interface IInput {
128
- /**
129
- * List of files or directories containing the NestJS controller classes.
130
- */
131
- include: string[];
132
-
133
- /**
134
- * List of files or directories to be excluded.
135
- */
136
- exclude?: string[];
137
- }
138
-
139
- /**
140
- * Building `swagger.json` is also possible.
141
- */
142
- export interface ISwaggerConfig {
143
- /**
144
- * Output path of the `swagger.json`.
145
- *
146
- * If you've configured only directory, the file name would be the `swagger.json`.
147
- * Otherwise you've configured the full path with file name and extension, the
148
- * `swagger.json` file would be renamed to it.
149
- */
150
- output: string;
151
-
152
- /**
153
- * API information.
154
- *
155
- * If omitted, `package.json` content would be used instead.
156
- */
157
- info?: Partial<ISwaggerDocument.IInfo>;
158
-
159
- /**
160
- * List of server addresses.
161
- */
162
- servers?: ISwaggerDocument.IServer[];
163
-
164
- /**
165
- * Security schemes.
166
- */
167
- security?: Record<string, ISwaggerConfig.ISecurityScheme>;
168
- }
169
- export namespace ISwaggerConfig {
170
- export type ISecurityScheme =
171
- | IApiKey
172
- | Exclude<
173
- ISwaggerDocument.ISecurityScheme,
174
- ISwaggerDocument.ISecurityScheme.IApiKey
175
- >;
176
- export interface IApiKey {
177
- type: "apiKey";
178
-
179
- /**
180
- * @default header
181
- */
182
- in?: "header" | "query" | "cookie";
183
-
184
- /**
185
- * @default Authorization
186
- */
187
- name?: string;
188
- }
189
- }
190
- }
1
+ import type ts from "typescript";
2
+
3
+ import type { ISwaggerDocument } from "./structures/ISwaggerDocument";
4
+ import type { StripEnums } from "./utils/StripEnums";
5
+
6
+ /**
7
+ * Definition for the `nestia.config.ts` file.
8
+ *
9
+ * @author Jeongho Nam - https://github.com/samchon
10
+ */
11
+ export interface INestiaConfig {
12
+ /**
13
+ * Building `swagger.json` is also possible.
14
+ *
15
+ * If not specified, you can't build the `swagger.json`.
16
+ */
17
+ swagger?: INestiaConfig.ISwaggerConfig;
18
+
19
+ /**
20
+ * List of files or directories containing the NestJS controller classes.
21
+ */
22
+ input: string | string[] | INestiaConfig.IInput;
23
+
24
+ /**
25
+ * Output directory that SDK would be placed in.
26
+ *
27
+ * If not configured, you can't build the SDK library.
28
+ */
29
+ output?: string;
30
+
31
+ /**
32
+ * Target directory that SDK distribution files would be placed in.
33
+ *
34
+ * If you configure this property and runs `npx nestia sdk` command,
35
+ * distribution environments for the SDK library would be generated.
36
+ *
37
+ * After the SDK library generation, move to the `distribute` directory,
38
+ * and runs `npm publish` command, then you can share SDK library with
39
+ * other client (frontend) developers.
40
+ *
41
+ * Recommend to use `"packages/api"` value.
42
+ */
43
+ distribute?: string;
44
+
45
+ /**
46
+ * Target directory that e2e test functions would be placed in.
47
+ *
48
+ * If you configure this property and runs `npx nestia e2e` command,
49
+ * `@nestia/sdk` will analyze your NestJS backend server code, and
50
+ * generates e2e test functions for every API endpoints.
51
+ *
52
+ * If not configured, you can't run `npx nestia e2e` command.
53
+ */
54
+ e2e?: string;
55
+
56
+ /**
57
+ * Compiler options for the TypeScript.
58
+ *
59
+ * If you've omitted this property or the assigned property cannot fully cover the
60
+ * `tsconfig.json`, the properties from the `tsconfig.json` would be assigned to here.
61
+ * Otherwise, this property has been configured and it's detailed values are different
62
+ * with the `tsconfig.json`, this property values would be used instead.
63
+ *
64
+ * ```typescript
65
+ * import ts from "typescript";
66
+ *
67
+ * const tsconfig: ts.TsConfig;
68
+ * const nestiaConfig: IConfiguration;
69
+ *
70
+ * const compilerOptions: ts.CompilerOptions = {
71
+ * ...tsconfig.compilerOptions,
72
+ * ...(nestiaConfig.compilerOptions ?? {})
73
+ * }
74
+ * ```
75
+ */
76
+ compilerOptions?: StripEnums<ts.CompilerOptions>;
77
+
78
+ /**
79
+ * Whether to assert parameter types or not.
80
+ *
81
+ * If you configure this property to be `true`, all of the function
82
+ * parameters of SDK library would be checked through
83
+ * [`typia.assert<T>()` function](https://typia.io/docs/validators/assert/).
84
+ *
85
+ * This option would make your SDK library compilation time a little bit slower,
86
+ * but would enahcne the type safety even in the runtime level.
87
+ *
88
+ * @default false
89
+ */
90
+ assert?: boolean;
91
+
92
+ /**
93
+ * Whether to optimize JSON string conversion 10x faster or not.
94
+ *
95
+ * If you configure this property to be `true`, the SDK library would utilize the
96
+ * [`typia.assertStringify<T>() function`](https://github.com/samchon/typia#enhanced-json)
97
+ * to boost up JSON serialization speed and ensure type safety.
98
+ *
99
+ * This option would make your SDK library compilation time a little bit slower,
100
+ * but would enhance JSON serialization speed 10x faster. Also, it can ensure type
101
+ * safety even in the rumtime level.
102
+ *
103
+ * @default false
104
+ */
105
+ json?: boolean;
106
+
107
+ /**
108
+ * Whether to wrap DTO by primitive type.
109
+ *
110
+ * If you don't configure this property as `false`, all of DTOs in the
111
+ * SDK library would be automatically wrapped by {@link Primitive} type.
112
+ *
113
+ * For refenrece, if a DTO type be capsuled by the {@link Primitive} type,
114
+ * all of methods in the DTO type would be automatically erased. Also, if
115
+ * the DTO has a `toJSON()` method, the DTO type would be automatically
116
+ * converted to return type of the `toJSON()` method.
117
+ *
118
+ * @default true
119
+ */
120
+ primitive?: boolean;
121
+
122
+ /**
123
+ * Allow random data generation in SDK level.
124
+ *
125
+ * If you configure this property to be `true`, random data generator would be
126
+ * installed in the SDK library. Client developer can utilize the built-in
127
+ * random data generator, instead of communicating with the backend server,
128
+ * just by configuring {@link IConnection.random} property to be `true`.
129
+ *
130
+ * For reference, random generator would utilize `typia.random<T>()` function.
131
+ *
132
+ * @default false
133
+ */
134
+ random?: boolean;
135
+ }
136
+ export namespace INestiaConfig {
137
+ /**
138
+ * List of files or directories to include or exclude to specifying the NestJS
139
+ * controllers.
140
+ */
141
+ export interface IInput {
142
+ /**
143
+ * List of files or directories containing the NestJS controller classes.
144
+ */
145
+ include: string[];
146
+
147
+ /**
148
+ * List of files or directories to be excluded.
149
+ */
150
+ exclude?: string[];
151
+ }
152
+
153
+ /**
154
+ * Building `swagger.json` is also possible.
155
+ */
156
+ export interface ISwaggerConfig {
157
+ /**
158
+ * Output path of the `swagger.json`.
159
+ *
160
+ * If you've configured only directory, the file name would be the `swagger.json`.
161
+ * Otherwise you've configured the full path with file name and extension, the
162
+ * `swagger.json` file would be renamed to it.
163
+ */
164
+ output: string;
165
+
166
+ /**
167
+ * API information.
168
+ *
169
+ * If omitted, `package.json` content would be used instead.
170
+ */
171
+ info?: Partial<ISwaggerDocument.IInfo>;
172
+
173
+ /**
174
+ * List of server addresses.
175
+ */
176
+ servers?: ISwaggerDocument.IServer[];
177
+
178
+ /**
179
+ * Security schemes.
180
+ */
181
+ security?: Record<string, ISwaggerConfig.ISecurityScheme>;
182
+ }
183
+ export namespace ISwaggerConfig {
184
+ export type ISecurityScheme =
185
+ | IApiKey
186
+ | Exclude<
187
+ ISwaggerDocument.ISecurityScheme,
188
+ ISwaggerDocument.ISecurityScheme.IApiKey
189
+ >;
190
+ export interface IApiKey {
191
+ type: "apiKey";
192
+
193
+ /**
194
+ * @default header
195
+ */
196
+ in?: "header" | "query" | "cookie";
197
+
198
+ /**
199
+ * @default Authorization
200
+ */
201
+ name?: string;
202
+ }
203
+ }
204
+ }