@nestia/sdk 1.0.0 → 1.0.2
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 +70 -70
- package/lib/INestiaConfig.d.ts +28 -9
- package/lib/analyses/ControllerAnalyzer.js +21 -1
- package/lib/analyses/ControllerAnalyzer.js.map +1 -1
- package/lib/executable/internal/NestiaSdkConfig.js +168 -14
- package/lib/executable/internal/NestiaSdkConfig.js.map +1 -1
- package/lib/executable/sdk.js +16 -16
- package/lib/generates/FunctionGenerator.js +35 -15
- package/lib/generates/FunctionGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.d.ts +1 -1
- package/lib/generates/SwaggerGenerator.js +36 -16
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/structures/IRoute.d.ts +8 -0
- package/lib/structures/ISwaggerDocument.d.ts +95 -0
- package/lib/structures/{ISwagger.js → ISwaggerDocument.js} +1 -1
- package/lib/structures/ISwaggerDocument.js.map +1 -0
- package/package.json +3 -3
- package/src/INestiaConfig.ts +147 -120
- package/src/NestiaSdkApplication.ts +183 -183
- package/src/analyses/ControllerAnalyzer.ts +223 -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 +322 -287
- package/src/generates/SdkGenerator.ts +50 -50
- package/src/generates/SwaggerGenerator.ts +422 -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 +33 -29
- package/src/structures/ISwaggerDocument.ts +117 -0
- 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
- package/lib/structures/ISwagger.d.ts +0 -48
- package/lib/structures/ISwagger.js.map +0 -1
- package/src/structures/ISwagger.ts +0 -55
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import { INestiaSdkConfiguration } from "@nestia/sdk";
|
|
2
|
-
|
|
3
|
-
export const NESTIA_CONFIG: INestiaSdkConfiguration = {
|
|
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 assert parameter types or not.
|
|
18
|
-
*
|
|
19
|
-
* If you configure this property to be `true`, all of the function parameters would be
|
|
20
|
-
* checked through the [typia](https://github.com/samchon/typia#runtime-type-checkers).
|
|
21
|
-
* This option would make your SDK library slower, but would enahcne the type safety even
|
|
22
|
-
* in the runtime level.
|
|
23
|
-
*
|
|
24
|
-
* @default false
|
|
25
|
-
*/
|
|
26
|
-
// assert: true,
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Whether to optimize JSON string conversion 2x faster or not.
|
|
30
|
-
*
|
|
31
|
-
* If you configure this property to be `true`, the SDK library would utilize the
|
|
32
|
-
* [typia](https://github.com/samchon/typia#fastest-json-string-converter)
|
|
33
|
-
* and the JSON string conversion speed really be 2x faster.
|
|
34
|
-
*
|
|
35
|
-
* @default false
|
|
36
|
-
*/
|
|
37
|
-
// json: true,
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Whether to wrap DTO by primitive type.
|
|
41
|
-
*
|
|
42
|
-
* If you don't configure this property as `false`, all of DTOs in the
|
|
43
|
-
* SDK library would be automatically wrapped by {@link Primitive} type.
|
|
44
|
-
*
|
|
45
|
-
* For refenrece, if a DTO type be capsuled by the {@link Primitive} type,
|
|
46
|
-
* all of methods in the DTO type would be automatically erased. Also, if
|
|
47
|
-
* the DTO has a `toJSON()` method, the DTO type would be automatically
|
|
48
|
-
* converted to return type of the `toJSON()` method.
|
|
49
|
-
*
|
|
50
|
-
* @default true
|
|
51
|
-
*/
|
|
52
|
-
// primitive: false,
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Building `swagger.json` is also possible.
|
|
56
|
-
*
|
|
57
|
-
* If not specified, you can't build the `swagger.json`.
|
|
58
|
-
*/
|
|
59
|
-
swagger: {
|
|
60
|
-
/**
|
|
61
|
-
* Output path of the `swagger.json`.
|
|
62
|
-
*
|
|
63
|
-
* If you've configured only directory, the file name would be the `swagger.json`.
|
|
64
|
-
* Otherwise you've configured the full path with file name and extension, the
|
|
65
|
-
* `swagger.json` file would be renamed to it.
|
|
66
|
-
*/
|
|
67
|
-
output: "dist/swagger.json",
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
export default NESTIA_CONFIG;
|
|
1
|
+
import { INestiaSdkConfiguration } from "@nestia/sdk";
|
|
2
|
+
|
|
3
|
+
export const NESTIA_CONFIG: INestiaSdkConfiguration = {
|
|
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 assert parameter types or not.
|
|
18
|
+
*
|
|
19
|
+
* If you configure this property to be `true`, all of the function parameters would be
|
|
20
|
+
* checked through the [typia](https://github.com/samchon/typia#runtime-type-checkers).
|
|
21
|
+
* This option would make your SDK library slower, but would enahcne the type safety even
|
|
22
|
+
* in the runtime level.
|
|
23
|
+
*
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
// assert: true,
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Whether to optimize JSON string conversion 2x faster or not.
|
|
30
|
+
*
|
|
31
|
+
* If you configure this property to be `true`, the SDK library would utilize the
|
|
32
|
+
* [typia](https://github.com/samchon/typia#fastest-json-string-converter)
|
|
33
|
+
* and the JSON string conversion speed really be 2x faster.
|
|
34
|
+
*
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
// json: true,
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether to wrap DTO by primitive type.
|
|
41
|
+
*
|
|
42
|
+
* If you don't configure this property as `false`, all of DTOs in the
|
|
43
|
+
* SDK library would be automatically wrapped by {@link Primitive} type.
|
|
44
|
+
*
|
|
45
|
+
* For refenrece, if a DTO type be capsuled by the {@link Primitive} type,
|
|
46
|
+
* all of methods in the DTO type would be automatically erased. Also, if
|
|
47
|
+
* the DTO has a `toJSON()` method, the DTO type would be automatically
|
|
48
|
+
* converted to return type of the `toJSON()` method.
|
|
49
|
+
*
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
// primitive: false,
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Building `swagger.json` is also possible.
|
|
56
|
+
*
|
|
57
|
+
* If not specified, you can't build the `swagger.json`.
|
|
58
|
+
*/
|
|
59
|
+
swagger: {
|
|
60
|
+
/**
|
|
61
|
+
* Output path of the `swagger.json`.
|
|
62
|
+
*
|
|
63
|
+
* If you've configured only directory, the file name would be the `swagger.json`.
|
|
64
|
+
* Otherwise you've configured the full path with file name and extension, the
|
|
65
|
+
* `swagger.json` file would be renamed to it.
|
|
66
|
+
*/
|
|
67
|
+
output: "dist/swagger.json",
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
export default NESTIA_CONFIG;
|
package/lib/INestiaConfig.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
+
import { ISwaggerDocument } from "./structures/ISwaggerDocument";
|
|
2
3
|
import type { StripEnums } from "./utils/StripEnums";
|
|
3
4
|
/**
|
|
4
5
|
* Definition for the `nestia.config.ts` file.
|
|
@@ -40,20 +41,20 @@ export interface INestiaConfig {
|
|
|
40
41
|
/**
|
|
41
42
|
* Whether to assert parameter types or not.
|
|
42
43
|
*
|
|
43
|
-
* If you configure this property to be `true`, all of the function parameters
|
|
44
|
-
* checked through
|
|
45
|
-
* This option would make your SDK library slower, but would enahcne the type safety
|
|
46
|
-
* in the runtime level.
|
|
44
|
+
* If you configure this property to be `true`, all of the function parameters
|
|
45
|
+
* would be checked through [typia](https://github.com/samchon/typia#runtime-validators).
|
|
46
|
+
* This option would make your SDK library slower, but would enahcne the type safety
|
|
47
|
+
* even in the runtime level.
|
|
47
48
|
*
|
|
48
49
|
* @default false
|
|
49
50
|
*/
|
|
50
51
|
assert?: boolean;
|
|
51
52
|
/**
|
|
52
|
-
* Whether to optimize JSON string conversion
|
|
53
|
+
* Whether to optimize JSON string conversion 10x faster or not.
|
|
53
54
|
*
|
|
54
55
|
* If you configure this property to be `true`, the SDK library would utilize the
|
|
55
|
-
* [typia](https://github.com/samchon/typia#
|
|
56
|
-
* and the JSON string conversion speed really be
|
|
56
|
+
* [typia](https://github.com/samchon/typia#enhanced-json)
|
|
57
|
+
* and the JSON string conversion speed really be 10x faster.
|
|
57
58
|
*
|
|
58
59
|
* @default false
|
|
59
60
|
*/
|
|
@@ -77,7 +78,7 @@ export interface INestiaConfig {
|
|
|
77
78
|
*
|
|
78
79
|
* If not specified, you can't build the `swagger.json`.
|
|
79
80
|
*/
|
|
80
|
-
swagger?: INestiaConfig.
|
|
81
|
+
swagger?: INestiaConfig.ISwaggerConfig;
|
|
81
82
|
}
|
|
82
83
|
export declare namespace INestiaConfig {
|
|
83
84
|
/**
|
|
@@ -97,7 +98,7 @@ export declare namespace INestiaConfig {
|
|
|
97
98
|
/**
|
|
98
99
|
* Building `swagger.json` is also possible.
|
|
99
100
|
*/
|
|
100
|
-
interface
|
|
101
|
+
interface ISwaggerConfig {
|
|
101
102
|
/**
|
|
102
103
|
* Output path of the `swagger.json`.
|
|
103
104
|
*
|
|
@@ -106,5 +107,23 @@ export declare namespace INestiaConfig {
|
|
|
106
107
|
* `swagger.json` file would be renamed to it.
|
|
107
108
|
*/
|
|
108
109
|
output: string;
|
|
110
|
+
/**
|
|
111
|
+
* Security schemes.
|
|
112
|
+
*/
|
|
113
|
+
security?: Record<string, ISwaggerConfig.ISecurityScheme>;
|
|
114
|
+
}
|
|
115
|
+
namespace ISwaggerConfig {
|
|
116
|
+
type ISecurityScheme = IApiKey | Exclude<ISwaggerDocument.ISecurityScheme, ISwaggerDocument.ISecurityScheme.IApiKey>;
|
|
117
|
+
interface IApiKey {
|
|
118
|
+
type: "apiKey";
|
|
119
|
+
/**
|
|
120
|
+
* @default header
|
|
121
|
+
*/
|
|
122
|
+
in?: "header" | "query" | "cookie";
|
|
123
|
+
/**
|
|
124
|
+
* @default Authorization
|
|
125
|
+
*/
|
|
126
|
+
name?: string;
|
|
127
|
+
}
|
|
109
128
|
}
|
|
110
129
|
}
|
|
@@ -68,9 +68,29 @@ var ControllerAnalyzer;
|
|
|
68
68
|
.toJSON()
|
|
69
69
|
.map((pair) => [pair.first, pair.second.toJSON()]);
|
|
70
70
|
// CONSTRUCT COMMON DATA
|
|
71
|
+
const tags = signature.getJsDocTags();
|
|
71
72
|
const common = Object.assign(Object.assign({}, func), { parameters,
|
|
72
73
|
output,
|
|
73
|
-
imports, symbol: `${controller.name}.${func.name}()`, comments: signature.getDocumentationComment(undefined), tags:
|
|
74
|
+
imports, symbol: `${controller.name}.${func.name}()`, comments: signature.getDocumentationComment(undefined), tags, setHeaders: tags
|
|
75
|
+
.filter((t) => {
|
|
76
|
+
var _a;
|
|
77
|
+
return ((_a = t.text) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
78
|
+
t.text[0].text &&
|
|
79
|
+
(t.name === "setHeader" || t.name === "assignHeaders");
|
|
80
|
+
})
|
|
81
|
+
.map((t) => {
|
|
82
|
+
var _a;
|
|
83
|
+
return t.name === "setHeader"
|
|
84
|
+
? {
|
|
85
|
+
type: "setter",
|
|
86
|
+
source: t.text[0].text.split(" ")[0].trim(),
|
|
87
|
+
target: (_a = t.text[0].text.split(" ")[1]) === null || _a === void 0 ? void 0 : _a.trim(),
|
|
88
|
+
}
|
|
89
|
+
: {
|
|
90
|
+
type: "assigner",
|
|
91
|
+
source: t.text[0].text,
|
|
92
|
+
};
|
|
93
|
+
}) });
|
|
74
94
|
// CONFIGURE PATHS
|
|
75
95
|
const pathList = [];
|
|
76
96
|
for (const controllerPath of controller.paths)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControllerAnalyzer.js","sourceRoot":"","sources":["../../src/analyses/ControllerAnalyzer.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAiD;AACjD,4DAA4B;AAK5B,uDAAoD;AACpD,qDAAkD;AAClD,iDAA8C;AAE9C,IAAiB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"ControllerAnalyzer.js","sourceRoot":"","sources":["../../src/analyses/ControllerAnalyzer.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAiD;AACjD,4DAA4B;AAK5B,uDAAoD;AACpD,qDAAkD;AAClD,iDAA8C;AAE9C,IAAiB,kBAAkB,CAoNlC;AApND,WAAiB,kBAAkB;IAC/B,SAAgB,OAAO,CACnB,OAAuB,EACvB,UA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,KAAK,CAAC,SAAS;YAC1B,IAAI,EAAE,+BAAc,CAAC,OAAO,CACxB,OAAO,EACP,WAAW,EACX,UAAU,EACV,IAAI,CACP;SACJ,CAAC;IACN,CAAC;AACL,CAAC,EApNgB,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAoNlC"}
|
|
@@ -75,23 +75,15 @@ var NestiaSdkConfig;
|
|
|
75
75
|
path: path + ".input",
|
|
76
76
|
expected: "(Array<string> | Resolve<INestiaConfig.IInput> | string)",
|
|
77
77
|
value: input.input
|
|
78
|
-
})) && ("string" === typeof input.input || (Array.isArray(input.input) || $guard(exceptionable, {
|
|
79
|
-
path: path + ".input",
|
|
80
|
-
expected: "(Array<string> | Resolve<INestiaConfig.IInput> | string)",
|
|
81
|
-
value: input.input
|
|
82
|
-
})) && input.input.every((elem, index1) => "string" === typeof elem || $guard(exceptionable, {
|
|
78
|
+
})) && ("string" === typeof input.input || (Array.isArray(input.input) && input.input.every((elem, index1) => "string" === typeof elem || $guard(exceptionable, {
|
|
83
79
|
path: path + ".input[" + index1 + "]",
|
|
84
80
|
expected: "string",
|
|
85
81
|
value: elem
|
|
86
|
-
})) ||
|
|
87
|
-
path: path + ".input",
|
|
88
|
-
expected: "(Array<string> | Resolve<INestiaConfig.IInput> | string)",
|
|
89
|
-
value: input.input
|
|
90
|
-
})) && $ao1(input.input, path + ".input", true && exceptionable)) && (undefined === input.output || "string" === typeof input.output || $guard(exceptionable, {
|
|
82
|
+
})) || "object" === typeof input.input && null !== input.input && $ao1(input.input, path + ".input", true && exceptionable))) && (undefined === input.output || "string" === typeof input.output || $guard(exceptionable, {
|
|
91
83
|
path: path + ".output",
|
|
92
84
|
expected: "(string | undefined)",
|
|
93
85
|
value: input.output
|
|
94
|
-
})) && (undefined === input.compilerOptions || ("object" === typeof input.compilerOptions && null !== input.compilerOptions || $guard(exceptionable, {
|
|
86
|
+
})) && (undefined === input.compilerOptions || ("object" === typeof input.compilerOptions && null !== input.compilerOptions && false === Array.isArray(input.compilerOptions) || $guard(exceptionable, {
|
|
95
87
|
path: path + ".compilerOptions",
|
|
96
88
|
expected: "(Resolve<StripEnums<ts.CompilerOptions>> | undefined)",
|
|
97
89
|
value: input.compilerOptions
|
|
@@ -109,7 +101,7 @@ var NestiaSdkConfig;
|
|
|
109
101
|
value: input.primitive
|
|
110
102
|
})) && (undefined === input.swagger || ("object" === typeof input.swagger && null !== input.swagger || $guard(exceptionable, {
|
|
111
103
|
path: path + ".swagger",
|
|
112
|
-
expected: "(Resolve<INestiaConfig.
|
|
104
|
+
expected: "(Resolve<INestiaConfig.ISwaggerConfig> | undefined)",
|
|
113
105
|
value: input.swagger
|
|
114
106
|
})) && $ao4(input.swagger, path + ".swagger", true && exceptionable));
|
|
115
107
|
const $ao1 = (input, path, exceptionable) => (Array.isArray(input.include) || $guard(exceptionable, {
|
|
@@ -345,7 +337,7 @@ var NestiaSdkConfig;
|
|
|
345
337
|
path: path + ".outFile",
|
|
346
338
|
expected: "(string | undefined)",
|
|
347
339
|
value: input.outFile
|
|
348
|
-
})) && (undefined === input.paths || ("object" === typeof input.paths && null !== input.paths || $guard(exceptionable, {
|
|
340
|
+
})) && (undefined === input.paths || ("object" === typeof input.paths && null !== input.paths && false === Array.isArray(input.paths) || $guard(exceptionable, {
|
|
349
341
|
path: path + ".paths",
|
|
350
342
|
expected: "(Resolve<ts.MapLike<Array<string>>> | undefined)",
|
|
351
343
|
value: input.paths
|
|
@@ -521,11 +513,173 @@ var NestiaSdkConfig;
|
|
|
521
513
|
}));
|
|
522
514
|
return true;
|
|
523
515
|
});
|
|
524
|
-
const $ao4 = (input, path, exceptionable) => "string" === typeof input.output || $guard(exceptionable, {
|
|
516
|
+
const $ao4 = (input, path, exceptionable) => ("string" === typeof input.output || $guard(exceptionable, {
|
|
525
517
|
path: path + ".output",
|
|
526
518
|
expected: "string",
|
|
527
519
|
value: input.output
|
|
520
|
+
})) && (undefined === input.security || ("object" === typeof input.security && null !== input.security && false === Array.isArray(input.security) || $guard(exceptionable, {
|
|
521
|
+
path: path + ".security",
|
|
522
|
+
expected: "(Resolve<Record<string, INestiaConfig.ISwaggerConfig.ISecurityScheme>> | undefined)",
|
|
523
|
+
value: input.security
|
|
524
|
+
})) && $ao5(input.security, path + ".security", true && exceptionable));
|
|
525
|
+
const $ao5 = (input, path, exceptionable) => false === exceptionable || Object.keys(input).every(key => {
|
|
526
|
+
const value = input[key];
|
|
527
|
+
if (undefined === value)
|
|
528
|
+
return true;
|
|
529
|
+
if (RegExp(/(.*)/).test(key))
|
|
530
|
+
return ("object" === typeof value && null !== value || $guard(exceptionable, {
|
|
531
|
+
path: path + $join(key),
|
|
532
|
+
expected: "(Resolve<INestiaConfig.ISwaggerConfig.IApiKey> | Resolve<ISwaggerDocument.ISecurityScheme.IHttpBasic> | Resolve<ISwaggerDocument.ISecurityScheme.IHttpBearer> | Resolve<ISwaggerDocument.ISecurityScheme.IOAuth2> | Resolve<ISwaggerDocument.ISecurityScheme.IOpenId>)",
|
|
533
|
+
value: value
|
|
534
|
+
})) && $au0(value, path + $join(key), true && exceptionable);
|
|
535
|
+
return true;
|
|
536
|
+
});
|
|
537
|
+
const $ao6 = (input, path, exceptionable) => ("http" === input.type || $guard(exceptionable, {
|
|
538
|
+
path: path + ".type",
|
|
539
|
+
expected: "\"http\"",
|
|
540
|
+
value: input.type
|
|
541
|
+
})) && ("basic" === input.schema || $guard(exceptionable, {
|
|
542
|
+
path: path + ".schema",
|
|
543
|
+
expected: "\"basic\"",
|
|
544
|
+
value: input.schema
|
|
545
|
+
}));
|
|
546
|
+
const $ao7 = (input, path, exceptionable) => ("http" === input.type || $guard(exceptionable, {
|
|
547
|
+
path: path + ".type",
|
|
548
|
+
expected: "\"http\"",
|
|
549
|
+
value: input.type
|
|
550
|
+
})) && ("bearer" === input.scheme || $guard(exceptionable, {
|
|
551
|
+
path: path + ".scheme",
|
|
552
|
+
expected: "\"bearer\"",
|
|
553
|
+
value: input.scheme
|
|
554
|
+
})) && (undefined === input.bearerFormat || "string" === typeof input.bearerFormat || $guard(exceptionable, {
|
|
555
|
+
path: path + ".bearerFormat",
|
|
556
|
+
expected: "(string | undefined)",
|
|
557
|
+
value: input.bearerFormat
|
|
558
|
+
}));
|
|
559
|
+
const $ao8 = (input, path, exceptionable) => ("openIdConnect" === input.type || $guard(exceptionable, {
|
|
560
|
+
path: path + ".type",
|
|
561
|
+
expected: "\"openIdConnect\"",
|
|
562
|
+
value: input.type
|
|
563
|
+
})) && ("string" === typeof input.openIdConnectUrl || $guard(exceptionable, {
|
|
564
|
+
path: path + ".openIdConnectUrl",
|
|
565
|
+
expected: "string",
|
|
566
|
+
value: input.openIdConnectUrl
|
|
567
|
+
}));
|
|
568
|
+
const $ao9 = (input, path, exceptionable) => ("oauth2" === input.type || $guard(exceptionable, {
|
|
569
|
+
path: path + ".type",
|
|
570
|
+
expected: "\"oauth2\"",
|
|
571
|
+
value: input.type
|
|
572
|
+
})) && (("object" === typeof input.flows && null !== input.flows && false === Array.isArray(input.flows) || $guard(exceptionable, {
|
|
573
|
+
path: path + ".flows",
|
|
574
|
+
expected: "Resolve<ISwaggerDocument.ISecurityScheme.IOAuth2.IFlowSet>",
|
|
575
|
+
value: input.flows
|
|
576
|
+
})) && $ao10(input.flows, path + ".flows", true && exceptionable)) && (undefined === input.description || "string" === typeof input.description || $guard(exceptionable, {
|
|
577
|
+
path: path + ".description",
|
|
578
|
+
expected: "(string | undefined)",
|
|
579
|
+
value: input.description
|
|
580
|
+
}));
|
|
581
|
+
const $ao10 = (input, path, exceptionable) => (undefined === input.authorizationCode || ("object" === typeof input.authorizationCode && null !== input.authorizationCode || $guard(exceptionable, {
|
|
582
|
+
path: path + ".authorizationCode",
|
|
583
|
+
expected: "(Resolve<ISwaggerDocument.ISecurityScheme.IOAuth2.IFlow> | undefined)",
|
|
584
|
+
value: input.authorizationCode
|
|
585
|
+
})) && $ao11(input.authorizationCode, path + ".authorizationCode", true && exceptionable)) && (undefined === input.implicit || ("object" === typeof input.implicit && null !== input.implicit || $guard(exceptionable, {
|
|
586
|
+
path: path + ".implicit",
|
|
587
|
+
expected: "(Resolve<Omit<ISwaggerDocument.ISecurityScheme.IOAuth2.IFlow, \"tokenUrl\">> | undefined)",
|
|
588
|
+
value: input.implicit
|
|
589
|
+
})) && $ao13(input.implicit, path + ".implicit", true && exceptionable)) && (undefined === input.password || ("object" === typeof input.password && null !== input.password || $guard(exceptionable, {
|
|
590
|
+
path: path + ".password",
|
|
591
|
+
expected: "(Resolve<Omit<ISwaggerDocument.ISecurityScheme.IOAuth2.IFlow, \"authorizationUrl\">> | undefined)",
|
|
592
|
+
value: input.password
|
|
593
|
+
})) && $ao14(input.password, path + ".password", true && exceptionable)) && (undefined === input.clientCredentials || ("object" === typeof input.clientCredentials && null !== input.clientCredentials || $guard(exceptionable, {
|
|
594
|
+
path: path + ".clientCredentials",
|
|
595
|
+
expected: "(Resolve<Omit<ISwaggerDocument.ISecurityScheme.IOAuth2.IFlow, \"authorizationUrl\">> | undefined)",
|
|
596
|
+
value: input.clientCredentials
|
|
597
|
+
})) && $ao14(input.clientCredentials, path + ".clientCredentials", true && exceptionable));
|
|
598
|
+
const $ao11 = (input, path, exceptionable) => ("string" === typeof input.authorizationUrl || $guard(exceptionable, {
|
|
599
|
+
path: path + ".authorizationUrl",
|
|
600
|
+
expected: "string",
|
|
601
|
+
value: input.authorizationUrl
|
|
602
|
+
})) && ("string" === typeof input.tokenUrl || $guard(exceptionable, {
|
|
603
|
+
path: path + ".tokenUrl",
|
|
604
|
+
expected: "string",
|
|
605
|
+
value: input.tokenUrl
|
|
606
|
+
})) && ("string" === typeof input.refreshUrl || $guard(exceptionable, {
|
|
607
|
+
path: path + ".refreshUrl",
|
|
608
|
+
expected: "string",
|
|
609
|
+
value: input.refreshUrl
|
|
610
|
+
})) && (undefined === input.scopes || ("object" === typeof input.scopes && null !== input.scopes && false === Array.isArray(input.scopes) || $guard(exceptionable, {
|
|
611
|
+
path: path + ".scopes",
|
|
612
|
+
expected: "(Resolve<Record<string, string>> | undefined)",
|
|
613
|
+
value: input.scopes
|
|
614
|
+
})) && $ao12(input.scopes, path + ".scopes", true && exceptionable));
|
|
615
|
+
const $ao12 = (input, path, exceptionable) => false === exceptionable || Object.keys(input).every(key => {
|
|
616
|
+
const value = input[key];
|
|
617
|
+
if (undefined === value)
|
|
618
|
+
return true;
|
|
619
|
+
if (RegExp(/(.*)/).test(key))
|
|
620
|
+
return "string" === typeof value || $guard(exceptionable, {
|
|
621
|
+
path: path + $join(key),
|
|
622
|
+
expected: "string",
|
|
623
|
+
value: value
|
|
624
|
+
});
|
|
625
|
+
return true;
|
|
528
626
|
});
|
|
627
|
+
const $ao13 = (input, path, exceptionable) => ("string" === typeof input.authorizationUrl || $guard(exceptionable, {
|
|
628
|
+
path: path + ".authorizationUrl",
|
|
629
|
+
expected: "string",
|
|
630
|
+
value: input.authorizationUrl
|
|
631
|
+
})) && ("string" === typeof input.refreshUrl || $guard(exceptionable, {
|
|
632
|
+
path: path + ".refreshUrl",
|
|
633
|
+
expected: "string",
|
|
634
|
+
value: input.refreshUrl
|
|
635
|
+
})) && (undefined === input.scopes || ("object" === typeof input.scopes && null !== input.scopes && false === Array.isArray(input.scopes) || $guard(exceptionable, {
|
|
636
|
+
path: path + ".scopes",
|
|
637
|
+
expected: "(Resolve<Record<string, string>> | undefined)",
|
|
638
|
+
value: input.scopes
|
|
639
|
+
})) && $ao12(input.scopes, path + ".scopes", true && exceptionable));
|
|
640
|
+
const $ao14 = (input, path, exceptionable) => ("string" === typeof input.tokenUrl || $guard(exceptionable, {
|
|
641
|
+
path: path + ".tokenUrl",
|
|
642
|
+
expected: "string",
|
|
643
|
+
value: input.tokenUrl
|
|
644
|
+
})) && ("string" === typeof input.refreshUrl || $guard(exceptionable, {
|
|
645
|
+
path: path + ".refreshUrl",
|
|
646
|
+
expected: "string",
|
|
647
|
+
value: input.refreshUrl
|
|
648
|
+
})) && (undefined === input.scopes || ("object" === typeof input.scopes && null !== input.scopes && false === Array.isArray(input.scopes) || $guard(exceptionable, {
|
|
649
|
+
path: path + ".scopes",
|
|
650
|
+
expected: "(Resolve<Record<string, string>> | undefined)",
|
|
651
|
+
value: input.scopes
|
|
652
|
+
})) && $ao12(input.scopes, path + ".scopes", true && exceptionable));
|
|
653
|
+
const $ao15 = (input, path, exceptionable) => ("apiKey" === input.type || $guard(exceptionable, {
|
|
654
|
+
path: path + ".type",
|
|
655
|
+
expected: "\"apiKey\"",
|
|
656
|
+
value: input.type
|
|
657
|
+
})) && (undefined === input["in"] || "header" === input["in"] || "query" === input["in"] || "cookie" === input["in"] || $guard(exceptionable, {
|
|
658
|
+
path: path + "[\"in\"]",
|
|
659
|
+
expected: "(\"cookie\" | \"header\" | \"query\" | undefined)",
|
|
660
|
+
value: input["in"]
|
|
661
|
+
})) && (undefined === input.name || "string" === typeof input.name || $guard(exceptionable, {
|
|
662
|
+
path: path + ".name",
|
|
663
|
+
expected: "(string | undefined)",
|
|
664
|
+
value: input.name
|
|
665
|
+
}));
|
|
666
|
+
const $au0 = (input, path, exceptionable) => (() => {
|
|
667
|
+
if (undefined !== input.schema)
|
|
668
|
+
return $ao6(input, path, true && exceptionable);
|
|
669
|
+
if (undefined !== input.scheme)
|
|
670
|
+
return $ao7(input, path, true && exceptionable);
|
|
671
|
+
if ("openIdConnect" === input.type)
|
|
672
|
+
return $ao8(input, path, true && exceptionable);
|
|
673
|
+
if ("oauth2" === input.type)
|
|
674
|
+
return $ao9(input, path, true && exceptionable);
|
|
675
|
+
if ("apiKey" === input.type)
|
|
676
|
+
return $ao15(input, path, true && exceptionable);
|
|
677
|
+
return $guard(exceptionable, {
|
|
678
|
+
path: path,
|
|
679
|
+
expected: "(ISwaggerDocument.ISecurityScheme.IHttpBasic | ISwaggerDocument.ISecurityScheme.IHttpBearer | ISwaggerDocument.ISecurityScheme.IOpenId | ISwaggerDocument.ISecurityScheme.IOAuth2 | INestiaConfig.ISwaggerConfig.IApiKey)",
|
|
680
|
+
value: input
|
|
681
|
+
});
|
|
682
|
+
})();
|
|
529
683
|
return ("object" === typeof input && null !== input || $guard(true, {
|
|
530
684
|
path: path + "",
|
|
531
685
|
expected: "Resolve<INestiaConfig>",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaSdkConfig.js","sourceRoot":"","sources":["../../../src/executable/internal/NestiaSdkConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,gDAAkC;AAClC,qDAAkD;AAClD,iCAA+B;AAI/B,IAAiB,eAAe,CA0B/B;AA1BD,WAAiB,eAAe;IAC5B,SAAgB,GAAG;QACf,OAAO,SAAS,CAAC,GAAG,EAAE,CAAC;IAC3B,CAAC;IAFe,mBAAG,MAElB,CAAA;IAED,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,GAAS,EAAE;;QACvC,IAAI,YAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,KAAK;YAAE,OAAO,IAAI,CAAC;QAE7D,MAAM,CAAC,QAAQ,CAAC;YACZ,IAAI,EAAE,KAAK;YACX,eAAe,EAAE;gBACb,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,IAAI;aACf;SACJ,CAAC,CAAC;QAEH,MAAM,MAAM,GACR,YAAa,cAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,0DAAC,CAAC;QACnD,IAAI,OAAO,MAAM,KAAK,QAAQ;YAC1B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QAExE,MAAM,MAAM,GACR,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;QACjE,MAAM,MAAM,GAAkB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QACjE;2BAAO,cAAM;0BAAN,cAAM
|
|
1
|
+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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAAC,MAAM,EAAE;IAC1B,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,EA1BgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QA0B/B"}
|
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);
|
|
@@ -19,6 +19,7 @@ var FunctionGenerator;
|
|
|
19
19
|
BODY
|
|
20
20
|
--------------------------------------------------------- */
|
|
21
21
|
function body(route, query, input, config) {
|
|
22
|
+
var _a;
|
|
22
23
|
// FETCH ARGUMENTS WITH REQUST BODY
|
|
23
24
|
const parameters = filter_parameters(route, query);
|
|
24
25
|
const fetchArguments = [
|
|
@@ -37,15 +38,31 @@ var FunctionGenerator;
|
|
|
37
38
|
.map((param) => ` typia.assert<typeof ${param.name}>(${param.name});`)
|
|
38
39
|
.join("\n") + "\n\n"
|
|
39
40
|
: "";
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
assertions +
|
|
43
|
-
" return Fetcher.fetch\n" +
|
|
41
|
+
// FUNCTION CALL STATEMENT
|
|
42
|
+
const caller = "Fetcher.fetch\n" +
|
|
44
43
|
" (\n" +
|
|
45
44
|
fetchArguments.map((param) => ` ${param}`).join(",\n") +
|
|
46
45
|
"\n" +
|
|
47
|
-
" )
|
|
48
|
-
|
|
46
|
+
" )";
|
|
47
|
+
if (route.setHeaders.length === 0)
|
|
48
|
+
return `{\n${assertions} return ${caller};\n}`;
|
|
49
|
+
// SET HEADERS
|
|
50
|
+
const content = [
|
|
51
|
+
`{\n`,
|
|
52
|
+
assertions,
|
|
53
|
+
` const output: ${route.name}.Output = await ${caller};\n`,
|
|
54
|
+
"\n",
|
|
55
|
+
` // configure header(s)\n`,
|
|
56
|
+
` connection.headers ??= {};\n`,
|
|
57
|
+
];
|
|
58
|
+
for (const header of route.setHeaders) {
|
|
59
|
+
if (header.type === "assigner")
|
|
60
|
+
content.push(" ", `Object.assign(connection.headers, ${access("output", header.source)});\n`);
|
|
61
|
+
else
|
|
62
|
+
content.push(" ", `${access("connection.headers", (_a = header.target) !== null && _a !== void 0 ? _a : header.source)} = ${access("output", header.source)};\n`);
|
|
63
|
+
}
|
|
64
|
+
content.push("\n", " return output;\n", "}");
|
|
65
|
+
return content.join("");
|
|
49
66
|
}
|
|
50
67
|
function filter_parameters(route, query) {
|
|
51
68
|
const parameters = route.parameters.filter((param) => param.category === "param" ||
|
|
@@ -54,6 +71,9 @@ var FunctionGenerator;
|
|
|
54
71
|
parameters.push(query);
|
|
55
72
|
return parameters;
|
|
56
73
|
}
|
|
74
|
+
function access(x, y) {
|
|
75
|
+
return y[0] === "[" ? `${x}${y}` : `${x}.${y}`;
|
|
76
|
+
}
|
|
57
77
|
/* ---------------------------------------------------------
|
|
58
78
|
HEAD & TAIL
|
|
59
79
|
--------------------------------------------------------- */
|
|
@@ -122,7 +142,7 @@ var FunctionGenerator;
|
|
|
122
142
|
comments.map((str) => ` * ${str}`).join("\n") +
|
|
123
143
|
"\n" +
|
|
124
144
|
" */\n" +
|
|
125
|
-
`export function ${route.name}\n` +
|
|
145
|
+
`export${route.setHeaders ? " async" : ""} function ${route.name}\n` +
|
|
126
146
|
` (\n` +
|
|
127
147
|
`${parameters.map((str) => ` ${str}`).join(",\n")}\n` +
|
|
128
148
|
` ): Promise<${output}>`);
|
|
@@ -166,7 +186,7 @@ var FunctionGenerator;
|
|
|
166
186
|
(route.method === "POST" ||
|
|
167
187
|
route.method === "PUT" ||
|
|
168
188
|
route.method === "PATCH")
|
|
169
|
-
? ` export const stringify = (input: Input) => typia.
|
|
189
|
+
? ` export const stringify = (input: Input) => typia.assertStringify(input);\n`
|
|
170
190
|
: "") +
|
|
171
191
|
"}");
|
|
172
192
|
}
|
|
@@ -181,14 +201,14 @@ var FunctionGenerator;
|
|
|
181
201
|
if (query !== undefined && queryParams.length === 0)
|
|
182
202
|
return wrapper(`${query.name} as any`);
|
|
183
203
|
else if (query === undefined)
|
|
184
|
-
return wrapper(`
|
|
185
|
-
{
|
|
186
|
-
${rest_query_parameters(queryParams)}
|
|
204
|
+
return wrapper(`
|
|
205
|
+
{
|
|
206
|
+
${rest_query_parameters(queryParams)}
|
|
187
207
|
} as any`);
|
|
188
|
-
return wrapper(`
|
|
189
|
-
{
|
|
190
|
-
...${query.name},
|
|
191
|
-
${rest_query_parameters(queryParams)},
|
|
208
|
+
return wrapper(`
|
|
209
|
+
{
|
|
210
|
+
...${query.name},
|
|
211
|
+
${rest_query_parameters(queryParams)},
|
|
192
212
|
} as any`);
|
|
193
213
|
}
|
|
194
214
|
function rest_query_parameters(parameters) {
|