@nestia/sdk 1.0.1 → 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 +16 -25
- package/lib/INestiaConfig.d.ts +36 -21
- 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/generates/FunctionGenerator.js +29 -9
- package/lib/generates/FunctionGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.d.ts +1 -1
- package/lib/generates/SwaggerGenerator.js +27 -7
- 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 +44 -21
- package/src/analyses/ControllerAnalyzer.ts +21 -1
- package/src/generates/FunctionGenerator.ts +49 -11
- package/src/generates/SwaggerGenerator.ts +47 -18
- package/src/structures/IRoute.ts +4 -0
- package/src/structures/ISwaggerDocument.ts +117 -0
- package/lib/structures/ISwagger.d.ts +0 -48
- package/lib/structures/ISwagger.js.map +0 -1
- package/src/structures/ISwagger.ts +0 -55
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { INestiaSdkConfiguration } from "@nestia/sdk";
|
|
2
2
|
|
|
3
|
-
export const NESTIA_CONFIG:
|
|
3
|
+
export const NESTIA_CONFIG: INestiaSdkConfiguration = {
|
|
4
4
|
/**
|
|
5
5
|
* List of files or directories containing the NestJS controller classes.
|
|
6
6
|
*/
|
|
@@ -14,31 +14,23 @@ export const NESTIA_CONFIG: INestiaConfig = {
|
|
|
14
14
|
output: "src/api",
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Whether to
|
|
17
|
+
* Whether to assert parameter types or not.
|
|
18
18
|
*
|
|
19
19
|
* If you configure this property to be `true`, all of the function parameters would be
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* type safety even in the runtime level.
|
|
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.
|
|
24
23
|
*
|
|
25
24
|
* @default false
|
|
26
25
|
*/
|
|
27
|
-
// assert:
|
|
26
|
+
// assert: true,
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
|
-
*
|
|
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.
|
|
29
|
+
* Whether to optimize JSON string conversion 2x faster or not.
|
|
39
30
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
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.
|
|
42
34
|
*
|
|
43
35
|
* @default false
|
|
44
36
|
*/
|
|
@@ -48,13 +40,12 @@ export const NESTIA_CONFIG: INestiaConfig = {
|
|
|
48
40
|
* Whether to wrap DTO by primitive type.
|
|
49
41
|
*
|
|
50
42
|
* If you don't configure this property as `false`, all of DTOs in the
|
|
51
|
-
* SDK library would be automatically wrapped by {@link
|
|
52
|
-
* type.
|
|
43
|
+
* SDK library would be automatically wrapped by {@link Primitive} type.
|
|
53
44
|
*
|
|
54
|
-
* For refenrece, if a DTO type be capsuled by the {@link
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
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.
|
|
58
49
|
*
|
|
59
50
|
* @default true
|
|
60
51
|
*/
|
package/lib/INestiaConfig.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
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.
|
|
@@ -38,25 +39,22 @@ export interface INestiaConfig {
|
|
|
38
39
|
*/
|
|
39
40
|
compilerOptions?: StripEnums<ts.CompilerOptions>;
|
|
40
41
|
/**
|
|
41
|
-
* Whether to
|
|
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
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* type safety even 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.
|
|
48
48
|
*
|
|
49
49
|
* @default false
|
|
50
50
|
*/
|
|
51
51
|
assert?: boolean;
|
|
52
52
|
/**
|
|
53
|
-
* Whether to
|
|
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
|
+
* Whether to optimize JSON string conversion 10x faster or not.
|
|
57
54
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
55
|
+
* If you configure this property to be `true`, the SDK library would utilize the
|
|
56
|
+
* [typia](https://github.com/samchon/typia#enhanced-json)
|
|
57
|
+
* and the JSON string conversion speed really be 10x faster.
|
|
60
58
|
*
|
|
61
59
|
* @default false
|
|
62
60
|
*/
|
|
@@ -65,13 +63,12 @@ export interface INestiaConfig {
|
|
|
65
63
|
* Whether to wrap DTO by primitive type.
|
|
66
64
|
*
|
|
67
65
|
* If you don't configure this property as `false`, all of DTOs in the
|
|
68
|
-
* SDK library would be automatically wrapped by {@link
|
|
69
|
-
* type.
|
|
66
|
+
* SDK library would be automatically wrapped by {@link Primitive} type.
|
|
70
67
|
*
|
|
71
|
-
* For refenrece, if a DTO type be capsuled by the {@link
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
68
|
+
* For refenrece, if a DTO type be capsuled by the {@link Primitive} type,
|
|
69
|
+
* all of methods in the DTO type would be automatically erased. Also, if
|
|
70
|
+
* the DTO has a `toJSON()` method, the DTO type would be automatically
|
|
71
|
+
* converted to return type of the `toJSON()` method.
|
|
75
72
|
*
|
|
76
73
|
* @default true
|
|
77
74
|
*/
|
|
@@ -81,7 +78,7 @@ export interface INestiaConfig {
|
|
|
81
78
|
*
|
|
82
79
|
* If not specified, you can't build the `swagger.json`.
|
|
83
80
|
*/
|
|
84
|
-
swagger?: INestiaConfig.
|
|
81
|
+
swagger?: INestiaConfig.ISwaggerConfig;
|
|
85
82
|
}
|
|
86
83
|
export declare namespace INestiaConfig {
|
|
87
84
|
/**
|
|
@@ -101,7 +98,7 @@ export declare namespace INestiaConfig {
|
|
|
101
98
|
/**
|
|
102
99
|
* Building `swagger.json` is also possible.
|
|
103
100
|
*/
|
|
104
|
-
interface
|
|
101
|
+
interface ISwaggerConfig {
|
|
105
102
|
/**
|
|
106
103
|
* Output path of the `swagger.json`.
|
|
107
104
|
*
|
|
@@ -110,5 +107,23 @@ export declare namespace INestiaConfig {
|
|
|
110
107
|
* `swagger.json` file would be renamed to it.
|
|
111
108
|
*/
|
|
112
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
|
+
}
|
|
113
128
|
}
|
|
114
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,UAAyB,EACzB,UAAuB;QAEvB,wBAAwB;QACxB,MAAM,GAAG,GAAa,EAAE,CAAC;QACzB,oBAAE,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE;;YACjC,IACI,oBAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC;gBAC3B,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,WAAW,MAAK,UAAU,CAAC,IAAI,EAC5C;gBACE,yBAAyB;gBACzB,GAAG,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;gBAC5D,OAAO;aACV;QACL,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACf,CAAC;IAlBe,0BAAO,UAkBtB,CAAA;IAED;;gEAE4D;IAC5D,SAAS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AC;IAED;;gEAE4D;IAC5D,SAAS,kBAAkB,CACvB,OAAuB,EACvB,WAAuC,EACvC,UAAqC,EACrC,UAAuB,EACvB,QAAgB,EAChB,KAA6B,EAC7B,MAAiB;QAEjB,MAAM,IAAI,GAAY,OAAO,CAAC,yBAAyB,CACnD,MAAM,EACN,MAAM,CAAC,gBAAiB,CAC3B,CAAC;QACF,MAAM,IAAI,GAAW,MAAM,CAAC,cAAc,EAAE,CAAC,QAAQ,EAAE,CAAC;QAExD,gCAAgC;QAChC,IAAI,KAAK,CAAC,QAAQ,KAAK,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE;YACxD,MAAM,MAAM,GAAW,GAAG,UAAU,CAAC,IAAI,IAAI,QAAQ,IAAI,CAAC;YAC1D,MAAM,IAAI,KAAK,CACX,YAAY,MAAM,sDAAsD;gBACpE,wBAAwB,MAAM,IAAI,IAAI,iBAAiB;gBACvD,mEAAmE,CAC1E,CAAC;SACL;QAED,OAAO;YACH,IAAI;YACJ,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS,EAAE,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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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAAC,MAAM,EAAE;IAC1B,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,EA1BgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QA0B/B"}
|
|
@@ -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 = [
|
|
@@ -34,18 +35,34 @@ var FunctionGenerator;
|
|
|
34
35
|
}
|
|
35
36
|
const assertions = config.assert === true && route.parameters.length !== 0
|
|
36
37
|
? route.parameters
|
|
37
|
-
.map((param) => ` typia.assert(${param.name});`)
|
|
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 = typia.
|
|
189
|
+
? ` export const stringify = (input: Input) => typia.assertStringify(input);\n`
|
|
170
190
|
: "") +
|
|
171
191
|
"}");
|
|
172
192
|
}
|
|
@@ -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","sourceRoot":"","sources":["../../src/generates/FunctionGenerator.ts"],"names":[],"mappings":";;;AAAA,kDAA+C;AAC/C,4CAAyC;AAEzC,qDAAkD;AAKlD,IAAiB,iBAAiB,CAyTjC;AAzTD,WAAiB,iBAAiB;IAC9B,SAAgB,QAAQ,CAAC,MAAqB,EAAE,KAAa;QACzD,MAAM,KAAK,GAAkC,KAAK,CAAC,UAAU,CAAC,IAAI,CAC9D,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,OAAO,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,CACrE,CAAC;QACF,MAAM,KAAK,GAAkC,KAAK,CAAC,UAAU,CAAC,IAAI,CAC9D,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,MAAM,CACvC,CAAC;QAEF,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;aACpB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;aACtD,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;aACtB,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAZe,0BAAQ,WAYvB,CAAA;IAED;;gEAE4D;IAC5D,SAAS,IAAI,CACT,KAAa,EACb,KAAoC,EACpC,KAAoC,EACpC,MAAqB;;QAErB,mCAAmC;QACnC,MAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACnD,MAAM,cAAc,GAAa;YAC7B,YAAY;YACZ,GAAG,KAAK,CAAC,IAAI,YAAY;YACzB,GAAG,KAAK,C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,CAAC,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,EAzTgB,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAyTjC"}
|
|
@@ -2,5 +2,5 @@ import ts from "typescript";
|
|
|
2
2
|
import { INestiaConfig } from "../INestiaConfig";
|
|
3
3
|
import { IRoute } from "../structures/IRoute";
|
|
4
4
|
export declare namespace SwaggerGenerator {
|
|
5
|
-
function generate(checker: ts.TypeChecker, config: INestiaConfig.
|
|
5
|
+
function generate(checker: ts.TypeChecker, config: INestiaConfig.ISwaggerConfig, routeList: IRoute[]): Promise<void>;
|
|
6
6
|
}
|