@nestia/sdk 0.2.0 → 1.0.1
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/assets/config/nestia.config.ts +79 -70
- package/lib/INestiaConfig.d.ts +18 -14
- package/lib/executable/sdk.js +16 -16
- package/lib/generates/FunctionGenerator.js +9 -9
- package/lib/generates/FunctionGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.js +9 -9
- package/package.json +3 -3
- package/src/INestiaConfig.ts +124 -120
- package/src/NestiaSdkApplication.ts +183 -183
- package/src/analyses/ControllerAnalyzer.ts +203 -203
- package/src/analyses/GenericAnalyzer.ts +53 -53
- package/src/analyses/ImportAnalyzer.ts +143 -143
- package/src/analyses/PathAnalyzer.ts +58 -58
- package/src/analyses/ReflectAnalyzer.ts +279 -279
- package/src/analyses/SourceFinder.ts +59 -59
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/internal/NestiaConfigCompilerOptions.ts +18 -18
- package/src/executable/internal/NestiaSdkCommand.ts +174 -174
- package/src/executable/internal/NestiaSdkConfig.ts +35 -35
- package/src/executable/internal/nestia.config.getter.ts +12 -12
- package/src/executable/sdk.ts +74 -74
- package/src/generates/FileGenerator.ts +156 -156
- package/src/generates/FunctionGenerator.ts +284 -287
- package/src/generates/SdkGenerator.ts +50 -50
- package/src/generates/SwaggerGenerator.ts +393 -393
- package/src/index.ts +3 -3
- package/src/module.ts +2 -2
- package/src/structures/IController.ts +27 -27
- package/src/structures/IRoute.ts +29 -29
- package/src/structures/ISwagger.ts +55 -55
- package/src/structures/ITypeTuple.ts +6 -6
- package/src/structures/MethodType.ts +11 -11
- package/src/structures/ParamCategory.ts +1 -1
- package/src/structures/TypeEntry.ts +22 -22
- package/src/utils/ArrayUtil.ts +26 -26
- package/src/utils/ImportDictionary.ts +56 -56
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/StripEnums.ts +10 -10
|
@@ -1,70 +1,79 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export const NESTIA_CONFIG:
|
|
4
|
-
/**
|
|
5
|
-
* List of files or directories containing the NestJS controller classes.
|
|
6
|
-
*/
|
|
7
|
-
input: "src/controllers",
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Output directory that SDK would be placed in.
|
|
11
|
-
*
|
|
12
|
-
* If not configured, you can't build the SDK library.
|
|
13
|
-
*/
|
|
14
|
-
output: "src/api",
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Whether to
|
|
18
|
-
*
|
|
19
|
-
* If you configure this property to be `true`, all of the function parameters would be
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
import type { INestiaConfig } from "@nestia/sdk";
|
|
2
|
+
|
|
3
|
+
export const NESTIA_CONFIG: INestiaConfig = {
|
|
4
|
+
/**
|
|
5
|
+
* List of files or directories containing the NestJS controller classes.
|
|
6
|
+
*/
|
|
7
|
+
input: "src/controllers",
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Output directory that SDK would be placed in.
|
|
11
|
+
*
|
|
12
|
+
* If not configured, you can't build the SDK library.
|
|
13
|
+
*/
|
|
14
|
+
output: "src/api",
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Whether to validate parameter types or not.
|
|
18
|
+
*
|
|
19
|
+
* If you configure this property to be `true`, all of the function parameters would be
|
|
20
|
+
* validate through the [`typia.assert()`](https://github.com/samchon/typia). function.
|
|
21
|
+
*
|
|
22
|
+
* This option would make your SDK library a little bit slower, but would enahcne the
|
|
23
|
+
* type safety even in the runtime level.
|
|
24
|
+
*
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
// assert: false,
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Enhance `JSON.stringify()` function.
|
|
31
|
+
*
|
|
32
|
+
* If you configure this property to be `true`, SDK library would utilize
|
|
33
|
+
* [`typia.assertStringify()`](https://github.com/samchon/typia) function
|
|
34
|
+
* when constructing `application/json` typed request body.
|
|
35
|
+
*
|
|
36
|
+
* The [`typia.assertStringify()`](https://github.com/samchon/typia) function
|
|
37
|
+
* is about 8x faster than the native `JSON.stringify()` function and even
|
|
38
|
+
* type safe through validation.
|
|
39
|
+
*
|
|
40
|
+
* Otherwise, you don't configure this property or set to be `false`,
|
|
41
|
+
* just the native `JSON.stringify()` function would be used.
|
|
42
|
+
*
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
// json: true,
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Whether to wrap DTO by primitive type.
|
|
49
|
+
*
|
|
50
|
+
* If you don't configure this property as `false`, all of DTOs in the
|
|
51
|
+
* SDK library would be automatically wrapped by {@link typia.Primitive}
|
|
52
|
+
* type.
|
|
53
|
+
*
|
|
54
|
+
* For refenrece, if a DTO type be capsuled by the {@link typia.Primitive}
|
|
55
|
+
* type, all of methods in the DTO type would be automatically erased.
|
|
56
|
+
* Also, if the DTO has a `toJSON()` method, the DTO type would be
|
|
57
|
+
* automatically converted to return type of the `toJSON()` method.
|
|
58
|
+
*
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
// primitive: false,
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Building `swagger.json` is also possible.
|
|
65
|
+
*
|
|
66
|
+
* If not specified, you can't build the `swagger.json`.
|
|
67
|
+
*/
|
|
68
|
+
swagger: {
|
|
69
|
+
/**
|
|
70
|
+
* Output path of the `swagger.json`.
|
|
71
|
+
*
|
|
72
|
+
* If you've configured only directory, the file name would be the `swagger.json`.
|
|
73
|
+
* Otherwise you've configured the full path with file name and extension, the
|
|
74
|
+
* `swagger.json` file would be renamed to it.
|
|
75
|
+
*/
|
|
76
|
+
output: "dist/swagger.json",
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
export default NESTIA_CONFIG;
|
package/lib/INestiaConfig.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
1
|
+
import type ts from "typescript";
|
|
2
2
|
import type { StripEnums } from "./utils/StripEnums";
|
|
3
3
|
/**
|
|
4
4
|
* Definition for the `nestia.config.ts` file.
|
|
@@ -38,22 +38,25 @@ export interface INestiaConfig {
|
|
|
38
38
|
*/
|
|
39
39
|
compilerOptions?: StripEnums<ts.CompilerOptions>;
|
|
40
40
|
/**
|
|
41
|
-
* Whether to
|
|
41
|
+
* Whether to validate parameter types or not.
|
|
42
42
|
*
|
|
43
43
|
* If you configure this property to be `true`, all of the function parameters would be
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
44
|
+
* validate through the [`typia.assert()`](https://github.com/samchon/typia). function.
|
|
45
|
+
*
|
|
46
|
+
* This option would make your SDK library a little bit slower, but would enahcne the
|
|
47
|
+
* type safety even in the runtime level.
|
|
47
48
|
*
|
|
48
49
|
* @default false
|
|
49
50
|
*/
|
|
50
51
|
assert?: boolean;
|
|
51
52
|
/**
|
|
52
|
-
* Whether to
|
|
53
|
+
* Whether to validate parameter types or not.
|
|
54
|
+
*
|
|
55
|
+
* If you configure this property to be `true`, all of the function parameters would be
|
|
56
|
+
* validate through the [`typia.assert()`](https://github.com/samchon/typia). function.
|
|
53
57
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* and the JSON string conversion speed really be 2x faster.
|
|
58
|
+
* This option would make your SDK library a little bit slower, but would enahcne the
|
|
59
|
+
* type safety even in the runtime level.
|
|
57
60
|
*
|
|
58
61
|
* @default false
|
|
59
62
|
*/
|
|
@@ -62,12 +65,13 @@ export interface INestiaConfig {
|
|
|
62
65
|
* Whether to wrap DTO by primitive type.
|
|
63
66
|
*
|
|
64
67
|
* If you don't configure this property as `false`, all of DTOs in the
|
|
65
|
-
* SDK library would be automatically wrapped by {@link Primitive}
|
|
68
|
+
* SDK library would be automatically wrapped by {@link typia.Primitive}
|
|
69
|
+
* type.
|
|
66
70
|
*
|
|
67
|
-
* For refenrece, if a DTO type be capsuled by the {@link Primitive}
|
|
68
|
-
* all of methods in the DTO type would be automatically erased.
|
|
69
|
-
* the DTO has a `toJSON()` method, the DTO type would be
|
|
70
|
-
* converted to return type of the `toJSON()` method.
|
|
71
|
+
* For refenrece, if a DTO type be capsuled by the {@link typia.Primitive}
|
|
72
|
+
* type, all of methods in the DTO type would be automatically erased.
|
|
73
|
+
* Also, if the DTO has a `toJSON()` method, the DTO type would be
|
|
74
|
+
* automatically converted to return type of the `toJSON()` method.
|
|
71
75
|
*
|
|
72
76
|
* @default true
|
|
73
77
|
*/
|
package/lib/executable/sdk.js
CHANGED
|
@@ -40,22 +40,22 @@ const child_process_1 = __importDefault(require("child_process"));
|
|
|
40
40
|
const fs_1 = __importDefault(require("fs"));
|
|
41
41
|
const process_1 = __importDefault(require("process"));
|
|
42
42
|
const CommandParser_1 = require("./internal/CommandParser");
|
|
43
|
-
const USAGE = `Wrong command has been detected. Use like below:
|
|
44
|
-
|
|
45
|
-
npx @nestia/sdk [command] [options?]
|
|
46
|
-
|
|
47
|
-
1. npx @nestia/sdk dependencies --manager (npm|pnpm|yarn)
|
|
48
|
-
- npx @nestia/sdk dependencies
|
|
49
|
-
- npx @nestia/sdk dependencies --manager pnpm
|
|
50
|
-
2. npx @nestia/sdk init
|
|
51
|
-
3. npx @nestia/sdk sdk <input> --out <output>
|
|
52
|
-
- npx @nestia/sdk sdk # when "nestia.config.ts" be configured
|
|
53
|
-
- npx @nestia/sdk sdk src/controllers --out src/api
|
|
54
|
-
- npx @nestia/sdk sdk src/**/*.controller.ts --out src/api
|
|
55
|
-
4. npx @nestia/sdk swagger <input> --out <output>
|
|
56
|
-
- npx @nestia/sdk swagger # when "nestia.config.ts" be configured
|
|
57
|
-
- npx @nestia/sdk swagger src/controllers --out src/api
|
|
58
|
-
- npx @nestia/sdk swagger src/**/*.controller.ts --out src/api
|
|
43
|
+
const USAGE = `Wrong command has been detected. Use like below:
|
|
44
|
+
|
|
45
|
+
npx @nestia/sdk [command] [options?]
|
|
46
|
+
|
|
47
|
+
1. npx @nestia/sdk dependencies --manager (npm|pnpm|yarn)
|
|
48
|
+
- npx @nestia/sdk dependencies
|
|
49
|
+
- npx @nestia/sdk dependencies --manager pnpm
|
|
50
|
+
2. npx @nestia/sdk init
|
|
51
|
+
3. npx @nestia/sdk sdk <input> --out <output>
|
|
52
|
+
- npx @nestia/sdk sdk # when "nestia.config.ts" be configured
|
|
53
|
+
- npx @nestia/sdk sdk src/controllers --out src/api
|
|
54
|
+
- npx @nestia/sdk sdk src/**/*.controller.ts --out src/api
|
|
55
|
+
4. npx @nestia/sdk swagger <input> --out <output>
|
|
56
|
+
- npx @nestia/sdk swagger # when "nestia.config.ts" be configured
|
|
57
|
+
- npx @nestia/sdk swagger src/controllers --out src/api
|
|
58
|
+
- npx @nestia/sdk swagger src/**/*.controller.ts --out src/api
|
|
59
59
|
`;
|
|
60
60
|
function halt(desc) {
|
|
61
61
|
console.error(desc);
|
|
@@ -34,7 +34,7 @@ var FunctionGenerator;
|
|
|
34
34
|
}
|
|
35
35
|
const assertions = config.assert === true && route.parameters.length !== 0
|
|
36
36
|
? route.parameters
|
|
37
|
-
.map((param) => ` typia.assert
|
|
37
|
+
.map((param) => ` typia.assert(${param.name});`)
|
|
38
38
|
.join("\n") + "\n\n"
|
|
39
39
|
: "";
|
|
40
40
|
// RETURNS WITH FINALIZATION
|
|
@@ -166,7 +166,7 @@ var FunctionGenerator;
|
|
|
166
166
|
(route.method === "POST" ||
|
|
167
167
|
route.method === "PUT" ||
|
|
168
168
|
route.method === "PATCH")
|
|
169
|
-
? ` export const stringify =
|
|
169
|
+
? ` export const stringify = typia.createAssertStringify<Input>();\n`
|
|
170
170
|
: "") +
|
|
171
171
|
"}");
|
|
172
172
|
}
|
|
@@ -181,14 +181,14 @@ var FunctionGenerator;
|
|
|
181
181
|
if (query !== undefined && queryParams.length === 0)
|
|
182
182
|
return wrapper(`${query.name} as any`);
|
|
183
183
|
else if (query === undefined)
|
|
184
|
-
return wrapper(`
|
|
185
|
-
{
|
|
186
|
-
${rest_query_parameters(queryParams)}
|
|
184
|
+
return wrapper(`
|
|
185
|
+
{
|
|
186
|
+
${rest_query_parameters(queryParams)}
|
|
187
187
|
} as any`);
|
|
188
|
-
return wrapper(`
|
|
189
|
-
{
|
|
190
|
-
...${query.name},
|
|
191
|
-
${rest_query_parameters(queryParams)},
|
|
188
|
+
return wrapper(`
|
|
189
|
+
{
|
|
190
|
+
...${query.name},
|
|
191
|
+
${rest_query_parameters(queryParams)},
|
|
192
192
|
} as any`);
|
|
193
193
|
}
|
|
194
194
|
function rest_query_parameters(parameters) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionGenerator.js","sourceRoot":"","sources":["../../src/generates/FunctionGenerator.ts"],"names":[],"mappings":";;;AAAA,kDAA+C;AAC/C,4CAAyC;AAEzC,qDAAkD;AAKlD,IAAiB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"FunctionGenerator.js","sourceR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AAC,KAAK,CAAC,KAAK,CACpC,KAAK,KAAK,CAAC,IAAI,EAAE,CAC1B;aACA,IAAI,CAAC,MAAM,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;AACL,CAAC,EAnRgB,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAmRjC"}
|
|
@@ -229,15 +229,15 @@ const warning = new VariadicSingleton_1.VariadicSingleton((encrypted) => {
|
|
|
229
229
|
: `[EncryptedRoute.${method[0].toUpperCase()}.${method
|
|
230
230
|
.substring(1)
|
|
231
231
|
.toLowerCase()}](https://github.com/samchon/@nestia/core#encryptedroute)`;
|
|
232
|
-
return `## Warning
|
|
233
|
-
${summary}
|
|
234
|
-
|
|
235
|
-
The ${type} body data would be encrypted as "AES-128(256) / CBC mode / PKCS#5 Padding / Base64 Encoding", through the ${component} component.
|
|
236
|
-
|
|
237
|
-
Therefore, just utilize this swagger editor only for referencing. If you need to call the real API, using [SDK](https://github.com/samchon/nestia#software-development-kit) would be much better.
|
|
238
|
-
|
|
239
|
-
-----------------
|
|
240
|
-
|
|
232
|
+
return `## Warning
|
|
233
|
+
${summary}
|
|
234
|
+
|
|
235
|
+
The ${type} body data would be encrypted as "AES-128(256) / CBC mode / PKCS#5 Padding / Base64 Encoding", through the ${component} component.
|
|
236
|
+
|
|
237
|
+
Therefore, just utilize this swagger editor only for referencing. If you need to call the real API, using [SDK](https://github.com/samchon/nestia#software-development-kit) would be much better.
|
|
238
|
+
|
|
239
|
+
-----------------
|
|
240
|
+
|
|
241
241
|
`;
|
|
242
242
|
});
|
|
243
243
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Nestia SDK and Swagger generator",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/samchon/nestia",
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@nestia/core": "^0.
|
|
36
|
-
"@nestia/fetcher": "^0.
|
|
35
|
+
"@nestia/core": "^1.0.0",
|
|
36
|
+
"@nestia/fetcher": "^1.0.0",
|
|
37
37
|
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
|
|
38
38
|
"@types/cli": "^0.11.21",
|
|
39
39
|
"@types/express": "^4.17.15",
|
package/src/INestiaConfig.ts
CHANGED
|
@@ -1,120 +1,124 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import type { StripEnums } from "./utils/StripEnums";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Definition for the `nestia.config.ts` file.
|
|
7
|
-
*
|
|
8
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
9
|
-
*/
|
|
10
|
-
export interface INestiaConfig {
|
|
11
|
-
/**
|
|
12
|
-
* List of files or directories containing the NestJS controller classes.
|
|
13
|
-
*/
|
|
14
|
-
input: string | string[] | INestiaConfig.IInput;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Output directory that SDK would be placed in.
|
|
18
|
-
*
|
|
19
|
-
* If not configured, you can't build the SDK library.
|
|
20
|
-
*/
|
|
21
|
-
output?: string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Compiler options for the TypeScript.
|
|
25
|
-
*
|
|
26
|
-
* If you've omitted this property or the assigned property cannot fully cover the
|
|
27
|
-
* `tsconfig.json`, the properties from the `tsconfig.json` would be assigned to here.
|
|
28
|
-
* Otherwise, this property has been configured and it's detailed values are different
|
|
29
|
-
* with the `tsconfig.json`, this property values would be used instead.
|
|
30
|
-
*
|
|
31
|
-
* ```typescript
|
|
32
|
-
* import ts from "typescript";
|
|
33
|
-
*
|
|
34
|
-
* const tsconfig: ts.TsConfig;
|
|
35
|
-
* const nestiaConfig: IConfiguration;
|
|
36
|
-
*
|
|
37
|
-
* const compilerOptions: ts.CompilerOptions = {
|
|
38
|
-
* ...tsconfig.compilerOptions,
|
|
39
|
-
* ...(nestiaConfig.compilerOptions || {})
|
|
40
|
-
* }
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
compilerOptions?: StripEnums<ts.CompilerOptions>;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Whether to
|
|
47
|
-
*
|
|
48
|
-
* If you configure this property to be `true`, all of the function parameters would be
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
*
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
1
|
+
import type ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import type { StripEnums } from "./utils/StripEnums";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Definition for the `nestia.config.ts` file.
|
|
7
|
+
*
|
|
8
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
9
|
+
*/
|
|
10
|
+
export interface INestiaConfig {
|
|
11
|
+
/**
|
|
12
|
+
* List of files or directories containing the NestJS controller classes.
|
|
13
|
+
*/
|
|
14
|
+
input: string | string[] | INestiaConfig.IInput;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Output directory that SDK would be placed in.
|
|
18
|
+
*
|
|
19
|
+
* If not configured, you can't build the SDK library.
|
|
20
|
+
*/
|
|
21
|
+
output?: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Compiler options for the TypeScript.
|
|
25
|
+
*
|
|
26
|
+
* If you've omitted this property or the assigned property cannot fully cover the
|
|
27
|
+
* `tsconfig.json`, the properties from the `tsconfig.json` would be assigned to here.
|
|
28
|
+
* Otherwise, this property has been configured and it's detailed values are different
|
|
29
|
+
* with the `tsconfig.json`, this property values would be used instead.
|
|
30
|
+
*
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import ts from "typescript";
|
|
33
|
+
*
|
|
34
|
+
* const tsconfig: ts.TsConfig;
|
|
35
|
+
* const nestiaConfig: IConfiguration;
|
|
36
|
+
*
|
|
37
|
+
* const compilerOptions: ts.CompilerOptions = {
|
|
38
|
+
* ...tsconfig.compilerOptions,
|
|
39
|
+
* ...(nestiaConfig.compilerOptions || {})
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
compilerOptions?: StripEnums<ts.CompilerOptions>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether to validate parameter types or not.
|
|
47
|
+
*
|
|
48
|
+
* If you configure this property to be `true`, all of the function parameters would be
|
|
49
|
+
* validate through the [`typia.assert()`](https://github.com/samchon/typia). function.
|
|
50
|
+
*
|
|
51
|
+
* This option would make your SDK library a little bit slower, but would enahcne the
|
|
52
|
+
* type safety even in the runtime level.
|
|
53
|
+
*
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
assert?: boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Whether to validate parameter types or not.
|
|
60
|
+
*
|
|
61
|
+
* If you configure this property to be `true`, all of the function parameters would be
|
|
62
|
+
* validate through the [`typia.assert()`](https://github.com/samchon/typia). function.
|
|
63
|
+
*
|
|
64
|
+
* This option would make your SDK library a little bit slower, but would enahcne the
|
|
65
|
+
* type safety even in the runtime level.
|
|
66
|
+
*
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
json?: boolean;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Whether to wrap DTO by primitive type.
|
|
73
|
+
*
|
|
74
|
+
* If you don't configure this property as `false`, all of DTOs in the
|
|
75
|
+
* SDK library would be automatically wrapped by {@link typia.Primitive}
|
|
76
|
+
* type.
|
|
77
|
+
*
|
|
78
|
+
* For refenrece, if a DTO type be capsuled by the {@link typia.Primitive}
|
|
79
|
+
* type, all of methods in the DTO type would be automatically erased.
|
|
80
|
+
* Also, if the DTO has a `toJSON()` method, the DTO type would be
|
|
81
|
+
* automatically converted to return type of the `toJSON()` method.
|
|
82
|
+
*
|
|
83
|
+
* @default true
|
|
84
|
+
*/
|
|
85
|
+
primitive?: boolean;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Building `swagger.json` is also possible.
|
|
89
|
+
*
|
|
90
|
+
* If not specified, you can't build the `swagger.json`.
|
|
91
|
+
*/
|
|
92
|
+
swagger?: INestiaConfig.ISwagger;
|
|
93
|
+
}
|
|
94
|
+
export namespace INestiaConfig {
|
|
95
|
+
/**
|
|
96
|
+
* List of files or directories to include or exclude to specifying the NestJS
|
|
97
|
+
* controllers.
|
|
98
|
+
*/
|
|
99
|
+
export interface IInput {
|
|
100
|
+
/**
|
|
101
|
+
* List of files or directories containing the NestJS controller classes.
|
|
102
|
+
*/
|
|
103
|
+
include: string[];
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* List of files or directories to be excluded.
|
|
107
|
+
*/
|
|
108
|
+
exclude?: string[];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Building `swagger.json` is also possible.
|
|
113
|
+
*/
|
|
114
|
+
export interface ISwagger {
|
|
115
|
+
/**
|
|
116
|
+
* Output path of the `swagger.json`.
|
|
117
|
+
*
|
|
118
|
+
* If you've configured only directory, the file name would be the `swagger.json`.
|
|
119
|
+
* Otherwise you've configured the full path with file name and extension, the
|
|
120
|
+
* `swagger.json` file would be renamed to it.
|
|
121
|
+
*/
|
|
122
|
+
output: string;
|
|
123
|
+
}
|
|
124
|
+
}
|