@nestia/sdk 1.4.15 → 1.4.17
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/lib/INestiaConfig.d.ts +4 -3
- package/lib/analyses/ReflectAnalyzer.js +12 -5
- package/lib/analyses/ReflectAnalyzer.js.map +1 -1
- package/lib/executable/internal/NestiaSdkConfig.js +129 -67
- package/lib/executable/internal/NestiaSdkConfig.js.map +1 -1
- package/lib/generates/SwaggerGenerator.js +187 -11
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +3 -1
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkFunctionProgrammer.js +21 -9
- package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkSimulationProgrammer.js +16 -6
- package/lib/generates/internal/SdkSimulationProgrammer.js.map +1 -1
- package/lib/structures/IController.d.ts +8 -1
- package/lib/structures/{ISwaggerDocument.d.ts → ISwagger.d.ts} +12 -16
- package/lib/structures/{ISwaggerDocument.js → ISwagger.js} +1 -1
- package/lib/structures/ISwagger.js.map +1 -0
- package/lib/structures/ISwaggerInfo.d.ts +71 -0
- package/lib/structures/ISwaggerInfo.js +3 -0
- package/lib/structures/ISwaggerInfo.js.map +1 -0
- package/lib/structures/ISwaggerRoute.d.ts +1 -1
- package/lib/structures/ParamCategory.d.ts +1 -1
- package/package.json +3 -3
- package/src/INestiaConfig.ts +4 -3
- package/src/analyses/ReflectAnalyzer.ts +13 -4
- package/src/generates/SwaggerGenerator.ts +73 -6
- package/src/generates/internal/E2eFileProgrammer.ts +3 -1
- package/src/generates/internal/SdkFunctionProgrammer.ts +34 -20
- package/src/generates/internal/SdkSimulationProgrammer.ts +32 -22
- package/src/structures/IController.ts +8 -0
- package/src/structures/{ISwaggerDocument.ts → ISwagger.ts} +12 -17
- package/src/structures/ISwaggerInfo.ts +80 -0
- package/src/structures/ISwaggerRoute.ts +1 -1
- package/src/structures/ParamCategory.ts +1 -1
- package/lib/structures/ISwaggerDocument.js.map +0 -1
|
@@ -12,27 +12,33 @@ export namespace SdkSimulationProgrammer {
|
|
|
12
12
|
`);`,
|
|
13
13
|
];
|
|
14
14
|
const body: string[] = [
|
|
15
|
-
...(route.parameters.
|
|
15
|
+
...(route.parameters.filter((p) => p.category !== "headers")
|
|
16
|
+
.length !== 0
|
|
17
|
+
? assert(route.parameters)
|
|
18
|
+
: []),
|
|
16
19
|
...(output ? returns() : []),
|
|
17
20
|
];
|
|
18
21
|
|
|
19
22
|
return [
|
|
20
23
|
`export const simulate = async (`,
|
|
21
24
|
` ${
|
|
22
|
-
route.parameters.
|
|
25
|
+
route.parameters.filter((p) => p.category !== "headers")
|
|
26
|
+
.length === 0 && route.output.name === "void"
|
|
23
27
|
? "_connection"
|
|
24
28
|
: "connection"
|
|
25
29
|
}: IConnection,`,
|
|
26
|
-
...route.parameters
|
|
27
|
-
(p) =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
...route.parameters
|
|
31
|
+
.filter((p) => p.category !== "headers")
|
|
32
|
+
.map(
|
|
33
|
+
(p) =>
|
|
34
|
+
` ${p.name}: ${
|
|
35
|
+
p.category === "query" || p.category === "body"
|
|
36
|
+
? `${route.name}.${
|
|
37
|
+
p.category === "query" ? "Query" : "Input"
|
|
38
|
+
}`
|
|
39
|
+
: p.type.name
|
|
40
|
+
},`,
|
|
41
|
+
),
|
|
36
42
|
`): Promise<${output ? "Output" : "void"}> => {`,
|
|
37
43
|
...body.map((l) => ` ${l}`),
|
|
38
44
|
`}`,
|
|
@@ -46,18 +52,22 @@ export namespace SdkSimulationProgrammer {
|
|
|
46
52
|
` method: METHOD,`,
|
|
47
53
|
` host: connection.host,`,
|
|
48
54
|
` path: path(${parameters
|
|
49
|
-
.filter((p) => p.category !== "body")
|
|
55
|
+
.filter((p) => p.category !== "body" && p.category !== "headers")
|
|
50
56
|
.map((p) => p.name)
|
|
51
57
|
.join(", ")})`,
|
|
52
58
|
`});`,
|
|
53
|
-
...parameters
|
|
54
|
-
p.category
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
...parameters
|
|
60
|
+
.filter((p) => p.category !== "headers")
|
|
61
|
+
.map((p) =>
|
|
62
|
+
p.category === "body"
|
|
63
|
+
? `assert.body(() => typia.assert(${p.name}));`
|
|
64
|
+
: p.category === "query"
|
|
65
|
+
? `assert.query(() => typia.assert(${p.name}));`
|
|
66
|
+
: p.category === "headers"
|
|
67
|
+
? `assert.headers(() => typia.assert(${p.name}));` // not yet
|
|
68
|
+
: `assert.param("${p.field}")("${
|
|
69
|
+
p.custom && p.meta ? p.meta.type : p.type.name
|
|
70
|
+
}")(() => typia.assert(${p.name}));`,
|
|
71
|
+
),
|
|
62
72
|
];
|
|
63
73
|
}
|
|
@@ -24,6 +24,7 @@ export namespace IController {
|
|
|
24
24
|
export type IParameter =
|
|
25
25
|
| ICommonParameter
|
|
26
26
|
| IQueryParameter
|
|
27
|
+
| IHeadersParameter
|
|
27
28
|
| IBodyParameter
|
|
28
29
|
| IPathParameter;
|
|
29
30
|
export interface ICommonParameter {
|
|
@@ -33,6 +34,13 @@ export namespace IController {
|
|
|
33
34
|
name: string;
|
|
34
35
|
field: string | undefined;
|
|
35
36
|
}
|
|
37
|
+
export interface IHeadersParameter {
|
|
38
|
+
custom: true;
|
|
39
|
+
category: "headers";
|
|
40
|
+
index: number;
|
|
41
|
+
name: string;
|
|
42
|
+
field: string | undefined;
|
|
43
|
+
}
|
|
36
44
|
export interface IQueryParameter {
|
|
37
45
|
custom: true;
|
|
38
46
|
category: "query";
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { ISwaggerComponents } from "./ISwaggerComponents";
|
|
2
|
+
import { ISwaggerInfo } from "./ISwaggerInfo";
|
|
2
3
|
import { ISwaggerRoute } from "./ISwaggerRoute";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Swagger Document.
|
|
6
7
|
*
|
|
7
|
-
* `
|
|
8
|
+
* `ISwagger` is a data structure representing content of `swagger.json` file
|
|
8
9
|
* generated by Nestia. Note that, this is not an universal structure, but a dedicated
|
|
9
10
|
* structure only for Nestia.
|
|
10
11
|
*
|
|
11
12
|
* @author Jeongho Nam - https://github.com/samchon
|
|
12
13
|
*/
|
|
13
|
-
export interface
|
|
14
|
+
export interface ISwagger {
|
|
14
15
|
/**
|
|
15
16
|
* The version of the OpenAPI document.
|
|
16
17
|
*
|
|
@@ -21,12 +22,12 @@ export interface ISwaggerDocument {
|
|
|
21
22
|
/**
|
|
22
23
|
* List of servers that provide the API.
|
|
23
24
|
*/
|
|
24
|
-
servers:
|
|
25
|
+
servers: ISwagger.IServer[];
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Information about the API.
|
|
28
29
|
*/
|
|
29
|
-
info:
|
|
30
|
+
info: ISwaggerInfo;
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* The available paths and operations for the API.
|
|
@@ -56,7 +57,7 @@ export interface ISwaggerDocument {
|
|
|
56
57
|
*/
|
|
57
58
|
security?: Record<string, string[]>[];
|
|
58
59
|
}
|
|
59
|
-
export namespace
|
|
60
|
+
export namespace ISwagger {
|
|
60
61
|
/**
|
|
61
62
|
* Remote server definition.
|
|
62
63
|
*/
|
|
@@ -74,22 +75,16 @@ export namespace ISwaggerDocument {
|
|
|
74
75
|
description?: string;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
* General information about the API.
|
|
79
|
-
*/
|
|
80
|
-
export interface IInfo {
|
|
81
|
-
/**
|
|
82
|
-
* Version of the API.
|
|
83
|
-
*/
|
|
84
|
-
version: string;
|
|
85
|
-
|
|
78
|
+
export interface IExternalDocs {
|
|
86
79
|
/**
|
|
87
|
-
* The
|
|
80
|
+
* The URL for target documentation.
|
|
81
|
+
*
|
|
82
|
+
* @format url
|
|
88
83
|
*/
|
|
89
|
-
|
|
84
|
+
url: string;
|
|
90
85
|
|
|
91
86
|
/**
|
|
92
|
-
* A short description of the
|
|
87
|
+
* A short description of the target documentation.
|
|
93
88
|
*/
|
|
94
89
|
description?: string;
|
|
95
90
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Information about the API.
|
|
3
|
+
*
|
|
4
|
+
* @author Samchon
|
|
5
|
+
*/
|
|
6
|
+
export interface ISwaggerInfo {
|
|
7
|
+
/**
|
|
8
|
+
* The title of the API.
|
|
9
|
+
*/
|
|
10
|
+
title: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A short description of the API.
|
|
14
|
+
*/
|
|
15
|
+
description?: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A URL to the Terms of Service for the API.
|
|
19
|
+
*
|
|
20
|
+
* @format url
|
|
21
|
+
*/
|
|
22
|
+
termsOfService?: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The contact information for the exposed API.
|
|
26
|
+
*/
|
|
27
|
+
contact?: ISwaggerInfo.IContact;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The license information for the exposed API.
|
|
31
|
+
*/
|
|
32
|
+
license?: ISwaggerInfo.ILicense;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Version of the API.
|
|
36
|
+
*/
|
|
37
|
+
version: string;
|
|
38
|
+
}
|
|
39
|
+
export namespace ISwaggerInfo {
|
|
40
|
+
/**
|
|
41
|
+
* Contact information for the exposed API.
|
|
42
|
+
*/
|
|
43
|
+
export interface IContact {
|
|
44
|
+
/**
|
|
45
|
+
* The identifying name of the contact person/organization.
|
|
46
|
+
*/
|
|
47
|
+
name?: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The URL pointing to the contact information.
|
|
51
|
+
*
|
|
52
|
+
* @format url
|
|
53
|
+
*/
|
|
54
|
+
url?: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The email address of the contact person/organization.
|
|
58
|
+
*
|
|
59
|
+
* @format email
|
|
60
|
+
*/
|
|
61
|
+
email?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* License information for the exposed API.
|
|
66
|
+
*/
|
|
67
|
+
export interface ILicense {
|
|
68
|
+
/**
|
|
69
|
+
* The license name used for the API.
|
|
70
|
+
*/
|
|
71
|
+
name: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A URL to the license used for the API.
|
|
75
|
+
*
|
|
76
|
+
* @format url
|
|
77
|
+
*/
|
|
78
|
+
url?: string;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type ParamCategory = "param" | "query" | "body";
|
|
1
|
+
export type ParamCategory = "param" | "query" | "body" | "headers";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ISwaggerDocument.js","sourceRoot":"","sources":["../../src/structures/ISwaggerDocument.ts"],"names":[],"mappings":""}
|