@nestia/sdk 2.4.2 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/NestiaSdkApplication.js +2 -6
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/analyses/AccessorAnalyzer.js.map +1 -1
- package/lib/analyses/ConfigAnalyzer.js +4 -8
- package/lib/analyses/ConfigAnalyzer.js.map +1 -1
- package/lib/analyses/ControllerAnalyzer.js +6 -8
- package/lib/analyses/ControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/GenericAnalyzer.js +1 -2
- package/lib/analyses/GenericAnalyzer.js.map +1 -1
- package/lib/analyses/ImportAnalyzer.js +4 -4
- package/lib/analyses/ImportAnalyzer.js.map +1 -1
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectAnalyzer.js +7 -8
- package/lib/analyses/ReflectAnalyzer.js.map +1 -1
- package/lib/analyses/SecurityAnalyzer.js.map +1 -1
- package/lib/executable/internal/CommandParser.js.map +1 -1
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
- package/lib/executable/sdk.js +11 -11
- package/lib/executable/sdk.js.map +1 -1
- package/lib/generates/E2eGenerator.js.map +1 -1
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.js +5 -11
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +2 -8
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkDtoGenerator.js +3 -9
- package/lib/generates/internal/SdkDtoGenerator.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.js +4 -4
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkFunctionProgrammer.js +12 -20
- package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkImportWizard.js.map +1 -1
- package/lib/generates/internal/SdkRouteDirectory.js +1 -3
- package/lib/generates/internal/SdkRouteDirectory.js.map +1 -1
- package/lib/generates/internal/SdkSimulationProgrammer.js +5 -7
- package/lib/generates/internal/SdkSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeDefiner.js +2 -5
- package/lib/generates/internal/SdkTypeDefiner.js.map +1 -1
- package/lib/generates/internal/SwaggerSchemaGenerator.js +29 -44
- package/lib/generates/internal/SwaggerSchemaGenerator.js.map +1 -1
- package/lib/generates/internal/SwaggerSchemaValidator.js +3 -9
- package/lib/generates/internal/SwaggerSchemaValidator.js.map +1 -1
- package/lib/structures/MethodType.js +1 -7
- package/lib/structures/MethodType.js.map +1 -1
- package/lib/structures/TypeEntry.js.map +1 -1
- package/lib/utils/ArrayUtil.js.map +1 -1
- package/lib/utils/FileRetriever.js.map +1 -1
- package/lib/utils/ImportDictionary.js +1 -4
- package/lib/utils/ImportDictionary.js.map +1 -1
- package/lib/utils/MapUtil.js.map +1 -1
- package/lib/utils/PathUtil.js.map +1 -1
- package/lib/utils/SourceFinder.js.map +1 -1
- package/package.json +4 -7
- package/src/INestiaConfig.ts +234 -234
- package/src/NestiaSdkApplication.ts +253 -268
- package/src/analyses/AccessorAnalyzer.ts +60 -60
- package/src/analyses/ConfigAnalyzer.ts +147 -164
- package/src/analyses/ControllerAnalyzer.ts +379 -399
- package/src/analyses/ExceptionAnalyzer.ts +115 -124
- package/src/analyses/GenericAnalyzer.ts +51 -57
- package/src/analyses/ImportAnalyzer.ts +138 -159
- package/src/analyses/PathAnalyzer.ts +98 -100
- package/src/analyses/ReflectAnalyzer.ts +425 -433
- package/src/analyses/SecurityAnalyzer.ts +20 -20
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/internal/NestiaConfigLoader.ts +67 -68
- package/src/executable/internal/NestiaSdkCommand.ts +60 -64
- package/src/executable/sdk.ts +73 -73
- package/src/generates/E2eGenerator.ts +64 -67
- package/src/generates/SdkGenerator.ts +96 -100
- package/src/generates/SwaggerGenerator.ts +372 -410
- package/src/generates/internal/E2eFileProgrammer.ts +123 -129
- package/src/generates/internal/SdkDistributionComposer.ts +91 -91
- package/src/generates/internal/SdkDtoGenerator.ts +424 -450
- package/src/generates/internal/SdkFileProgrammer.ts +106 -111
- package/src/generates/internal/SdkFunctionProgrammer.ts +466 -501
- package/src/generates/internal/SdkImportWizard.ts +55 -55
- package/src/generates/internal/SdkRouteDirectory.ts +17 -19
- package/src/generates/internal/SdkSimulationProgrammer.ts +133 -142
- package/src/generates/internal/SdkTypeDefiner.ts +119 -124
- package/src/generates/internal/SwaggerSchemaGenerator.ts +382 -401
- package/src/generates/internal/SwaggerSchemaValidator.ts +198 -210
- package/src/index.ts +4 -4
- package/src/module.ts +2 -2
- package/src/structures/IController.ts +79 -81
- package/src/structures/IErrorReport.ts +6 -6
- package/src/structures/INestiaProject.ts +13 -13
- package/src/structures/INormalizedInput.ts +20 -20
- package/src/structures/IRoute.ts +40 -41
- package/src/structures/ISwagger.ts +91 -91
- package/src/structures/ISwaggerComponents.ts +29 -29
- package/src/structures/ISwaggerError.ts +8 -8
- package/src/structures/ISwaggerInfo.ts +80 -80
- package/src/structures/ISwaggerLazyProperty.ts +7 -7
- package/src/structures/ISwaggerLazySchema.ts +7 -7
- package/src/structures/ISwaggerRoute.ts +51 -51
- package/src/structures/ISwaggerSecurityScheme.ts +65 -65
- package/src/structures/ITypeTuple.ts +6 -6
- package/src/structures/MethodType.ts +5 -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/FileRetriever.ts +22 -22
- package/src/utils/ImportDictionary.ts +125 -128
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/PathUtil.ts +10 -10
- package/src/utils/SourceFinder.ts +66 -70
- package/src/utils/StripEnums.ts +5 -10
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { IJsonSchema } from "typia";
|
|
2
|
-
import { IJsDocTagInfo } from "typia/lib/schemas/metadata/IJsDocTagInfo";
|
|
3
|
-
|
|
4
|
-
export interface ISwaggerRoute {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
export namespace ISwaggerRoute {
|
|
19
|
-
|
|
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
|
-
}
|
|
1
|
+
import { IJsonSchema } from "typia";
|
|
2
|
+
import { IJsDocTagInfo } from "typia/lib/schemas/metadata/IJsDocTagInfo";
|
|
3
|
+
|
|
4
|
+
export interface ISwaggerRoute {
|
|
5
|
+
deprecated?: boolean;
|
|
6
|
+
security?: Record<string, string[]>[];
|
|
7
|
+
operationId?: string;
|
|
8
|
+
tags: string[];
|
|
9
|
+
parameters: ISwaggerRoute.IParameter[];
|
|
10
|
+
requestBody?: ISwaggerRoute.IRequestBody;
|
|
11
|
+
responses: ISwaggerRoute.IResponseBody;
|
|
12
|
+
summary?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
"x-nestia-method": string;
|
|
15
|
+
"x-nestia-namespace": string;
|
|
16
|
+
"x-nestia-jsDocTags"?: IJsDocTagInfo[];
|
|
17
|
+
}
|
|
18
|
+
export namespace ISwaggerRoute {
|
|
19
|
+
export interface IParameter {
|
|
20
|
+
name: string;
|
|
21
|
+
in: string;
|
|
22
|
+
schema: IJsonSchema;
|
|
23
|
+
required: boolean;
|
|
24
|
+
description?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface IRequestBody {
|
|
27
|
+
description?: string;
|
|
28
|
+
content: IContent;
|
|
29
|
+
required: true;
|
|
30
|
+
"x-nestia-encrypted": boolean;
|
|
31
|
+
}
|
|
32
|
+
export type IResponseBody = Record<
|
|
33
|
+
string,
|
|
34
|
+
{
|
|
35
|
+
description: string;
|
|
36
|
+
content?: IContent;
|
|
37
|
+
"x-nestia-encrypted"?: boolean;
|
|
38
|
+
}
|
|
39
|
+
>;
|
|
40
|
+
export interface IContent {
|
|
41
|
+
"application/x-www-form-urlencoded"?: {
|
|
42
|
+
schema: IJsonSchema;
|
|
43
|
+
};
|
|
44
|
+
"application/json"?: {
|
|
45
|
+
schema: IJsonSchema;
|
|
46
|
+
};
|
|
47
|
+
"text/plain"?: {
|
|
48
|
+
schema: IJsonSchema;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Security scheme of Swagger Documents.
|
|
3
|
-
*
|
|
4
|
-
* `ISwaggerSecurityScheme` is a data structure representing content of
|
|
5
|
-
* `securitySchemes` in `swagger.json` file. It is composed with 5 types of security
|
|
6
|
-
* schemes as an union type like below.
|
|
7
|
-
*
|
|
8
|
-
* @reference https://swagger.io/specification/#security-scheme-object
|
|
9
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
10
|
-
*/
|
|
11
|
-
export type ISwaggerSecurityScheme =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export namespace ISwaggerSecurityScheme {
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Security scheme of Swagger Documents.
|
|
3
|
+
*
|
|
4
|
+
* `ISwaggerSecurityScheme` is a data structure representing content of
|
|
5
|
+
* `securitySchemes` in `swagger.json` file. It is composed with 5 types of security
|
|
6
|
+
* schemes as an union type like below.
|
|
7
|
+
*
|
|
8
|
+
* @reference https://swagger.io/specification/#security-scheme-object
|
|
9
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
10
|
+
*/
|
|
11
|
+
export type ISwaggerSecurityScheme =
|
|
12
|
+
| ISwaggerSecurityScheme.IHttpBasic
|
|
13
|
+
| ISwaggerSecurityScheme.IHttpBearer
|
|
14
|
+
| ISwaggerSecurityScheme.IApiKey
|
|
15
|
+
| ISwaggerSecurityScheme.IOpenId
|
|
16
|
+
| ISwaggerSecurityScheme.IOAuth2;
|
|
17
|
+
export namespace ISwaggerSecurityScheme {
|
|
18
|
+
export interface IHttpBasic {
|
|
19
|
+
type: "http";
|
|
20
|
+
scheme: "basic";
|
|
21
|
+
}
|
|
22
|
+
export interface IHttpBearer {
|
|
23
|
+
type: "http";
|
|
24
|
+
scheme: "bearer";
|
|
25
|
+
bearerFormat?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface IApiKey {
|
|
28
|
+
type: "apiKey";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @default header
|
|
32
|
+
*/
|
|
33
|
+
in?: "header" | "query" | "cookie";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @default Authorization
|
|
37
|
+
*/
|
|
38
|
+
name?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface IOpenId {
|
|
42
|
+
type: "openIdConnect";
|
|
43
|
+
openIdConnectUrl: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface IOAuth2 {
|
|
47
|
+
type: "oauth2";
|
|
48
|
+
flows: IOAuth2.IFlowSet;
|
|
49
|
+
description?: string;
|
|
50
|
+
}
|
|
51
|
+
export namespace IOAuth2 {
|
|
52
|
+
export interface IFlowSet {
|
|
53
|
+
authorizationCode?: IFlow;
|
|
54
|
+
implicit?: Omit<IFlow, "tokenUrl">;
|
|
55
|
+
password?: Omit<IFlow, "authorizationUrl">;
|
|
56
|
+
clientCredentials?: Omit<IFlow, "authorizationUrl">;
|
|
57
|
+
}
|
|
58
|
+
export interface IFlow {
|
|
59
|
+
authorizationUrl: string;
|
|
60
|
+
tokenUrl: string;
|
|
61
|
+
refreshUrl: string;
|
|
62
|
+
scopes?: Record<string, string>;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
export interface ITypeTuple {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
export interface ITypeTuple {
|
|
4
|
+
type: ts.Type;
|
|
5
|
+
typeName: string;
|
|
6
|
+
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
export type MethodType = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
2
|
-
|
|
3
|
-
export namespace MethodType {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"POST",
|
|
7
|
-
"PUT",
|
|
8
|
-
"PATCH",
|
|
9
|
-
"DELETE",
|
|
10
|
-
];
|
|
11
|
-
}
|
|
1
|
+
export type MethodType = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
2
|
+
|
|
3
|
+
export namespace MethodType {
|
|
4
|
+
export const VALUES: MethodType[] = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
5
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type ParamCategory = "param" | "query" | "body" | "headers";
|
|
1
|
+
export type ParamCategory = "param" | "query" | "body" | "headers";
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { hash } from "tstl/functional/hash";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
|
|
4
|
-
export class TypeEntry {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
1
|
+
import { hash } from "tstl/functional/hash";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
|
|
4
|
+
export class TypeEntry {
|
|
5
|
+
public constructor(
|
|
6
|
+
public readonly type: ts.Type,
|
|
7
|
+
public readonly nullable: boolean,
|
|
8
|
+
public readonly required: boolean,
|
|
9
|
+
) {}
|
|
10
|
+
|
|
11
|
+
public equals(obj: TypeEntry): boolean {
|
|
12
|
+
return (
|
|
13
|
+
this.type === obj.type &&
|
|
14
|
+
this.nullable === obj.nullable &&
|
|
15
|
+
this.required === obj.required
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public hashCode(): number {
|
|
20
|
+
return hash(this.type, this.nullable, this.required);
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/utils/ArrayUtil.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
export namespace ArrayUtil {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
1
|
+
export namespace ArrayUtil {
|
|
2
|
+
export function has<T>(array: T[], ...items: T[]): boolean {
|
|
3
|
+
return items.every(
|
|
4
|
+
(elem) => array.find((org) => org === elem) !== undefined,
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export async function asyncMap<Input, Output>(
|
|
9
|
+
array: Input[],
|
|
10
|
+
closure: (input: Input) => Promise<Output>,
|
|
11
|
+
): Promise<Output[]> {
|
|
12
|
+
const ret: Output[] = [];
|
|
13
|
+
for (const elem of array) ret.push(await closure(elem));
|
|
14
|
+
return ret;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function asyncFilter<Input>(
|
|
18
|
+
array: Input[],
|
|
19
|
+
closure: (input: Input) => Promise<boolean>,
|
|
20
|
+
): Promise<Input[]> {
|
|
21
|
+
const ret: Input[] = [];
|
|
22
|
+
for (const elem of array)
|
|
23
|
+
if ((await closure(elem)) === true) ret.push(elem);
|
|
24
|
+
return ret;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
export namespace FileRetriever {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export namespace FileRetriever {
|
|
5
|
+
export const directory =
|
|
6
|
+
(name: string) =>
|
|
7
|
+
(dir: string, depth: number = 0): string | null => {
|
|
8
|
+
const location: string = path.join(dir, name);
|
|
9
|
+
if (fs.existsSync(location)) return dir;
|
|
10
|
+
else if (depth > 2) return null;
|
|
11
|
+
return directory(name)(path.join(dir, ".."), depth + 1);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const file =
|
|
15
|
+
(name: string) =>
|
|
16
|
+
(directory: string, depth: number = 0): string | null => {
|
|
17
|
+
const location: string = path.join(directory, name);
|
|
18
|
+
if (fs.existsSync(location)) return location;
|
|
19
|
+
else if (depth > 2) return null;
|
|
20
|
+
return file(name)(path.join(directory, ".."), depth + 1);
|
|
21
|
+
};
|
|
22
|
+
}
|