@nestia/migrate 0.10.0 → 0.11.0
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/MigrateApplication.d.ts +3 -1
- package/lib/MigrateApplication.js +1558 -1601
- package/lib/MigrateApplication.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +1 -1
- package/lib/internal/MigrateCommander.js +1 -1
- package/lib/internal/MigrateCommander.js.map +1 -1
- package/lib/structures/ISwaggerV20.d.ts +8 -0
- package/lib/structures/ISwaggerV20.js +3 -0
- package/lib/structures/ISwaggerV20.js.map +1 -0
- package/lib/structures/ISwaggerV31.d.ts +9 -0
- package/lib/structures/ISwaggerV31.js +3 -0
- package/lib/structures/ISwaggerV31.js.map +1 -0
- package/lib/utils/OpenApiConverter.d.ts +7 -0
- package/lib/utils/OpenApiConverter.js +3132 -0
- package/lib/utils/OpenApiConverter.js.map +1 -0
- package/package.json +78 -74
- package/src/MigrateApplication.ts +17 -8
- package/src/internal/MigrateCommander.ts +1 -1
- package/src/structures/ISwagger.ts +23 -23
- package/src/structures/ISwaggerV20.ts +10 -0
- package/src/structures/ISwaggerV31.ts +10 -0
- package/src/utils/OpenApiConverter.ts +20 -0
- package/lib/utils/SwaggerExplorer.d.ts +0 -0
- package/lib/utils/SwaggerExplorer.js +0 -2
- package/lib/utils/SwaggerExplorer.js.map +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"OpenApiConverter.js","sourceRoot":"","sources":["../../src/utils/OpenApiConverter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sEAA4C;AAC5C,kDAA0B;AAE1B,wEAA2E;AAM3E,IAAiB,gBAAgB,CAUhC;AAVD,WAAiB,gBAAgB;IAClB,qBAAI,GAAG,CAAO,OAAoB,EAAqB,EAAE;QACpE,MAAM,MAAM,GAAG,MAAM,yBAAa,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC3D;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAAW,SAAS,CAAC,OAAO,EAAc,EAAE;IACjE,CAAC,CAAC;AACJ,CAAC,EAVgB,gBAAgB,gCAAhB,gBAAgB,QAUhC"}
|
package/package.json
CHANGED
@@ -1,74 +1,78 @@
|
|
1
|
-
{
|
2
|
-
"name": "@nestia/migrate",
|
3
|
-
"version": "0.
|
4
|
-
"description": "Migration program from swagger to NestJS",
|
5
|
-
"main": "lib/index.js",
|
6
|
-
"typings": "lib/index.d.ts",
|
7
|
-
"bin": {
|
8
|
-
"@nestia/migrate": "lib/executable/migrate.js"
|
9
|
-
},
|
10
|
-
"scripts": {
|
11
|
-
"build": "rimraf lib && tsc",
|
12
|
-
"bundle": "ts-node src/executable/bundle.ts",
|
13
|
-
"dev": "npm run build -- --watch",
|
14
|
-
"package:next": "npm publish --access public --tag next",
|
15
|
-
"prepare": "ts-patch install && typia patch && npm run bundle",
|
16
|
-
"test": "node lib/test"
|
17
|
-
},
|
18
|
-
"repository": {
|
19
|
-
"type": "git",
|
20
|
-
"url": "https://github.com/samchon/nestia"
|
21
|
-
},
|
22
|
-
"keywords": [
|
23
|
-
"migration",
|
24
|
-
"swagger",
|
25
|
-
"NestJS",
|
26
|
-
"nestia",
|
27
|
-
"SDK",
|
28
|
-
"Mockup Simulator"
|
29
|
-
],
|
30
|
-
"author": "Jeongho Nam",
|
31
|
-
"license": "MIT",
|
32
|
-
"bugs": {
|
33
|
-
"url": "https://github.com/samchon/nestia/issues"
|
34
|
-
},
|
35
|
-
"homepage": "https://nestia.io",
|
36
|
-
"devDependencies": {
|
37
|
-
"@nestia/core": "^2.
|
38
|
-
"@nestia/e2e": "^0.4.1",
|
39
|
-
"@nestia/fetcher": "^2.
|
40
|
-
"@nestjs/common": "^10.3.
|
41
|
-
"@nestjs/core": "^10.3.
|
42
|
-
"@nestjs/platform-express": "^10.3.
|
43
|
-
"@nestjs/platform-fastify": "^10.3.
|
44
|
-
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
45
|
-
"@types/express": "^4.17.21",
|
46
|
-
"@types/inquirer": "^9.0.7",
|
47
|
-
"@types/node": "^20.3.3",
|
48
|
-
"
|
49
|
-
"dotenv
|
50
|
-
"
|
51
|
-
"
|
52
|
-
"
|
53
|
-
"
|
54
|
-
"ts-
|
55
|
-
"
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
"
|
60
|
-
"
|
61
|
-
"
|
62
|
-
"
|
63
|
-
"
|
64
|
-
|
65
|
-
|
66
|
-
"
|
67
|
-
"
|
68
|
-
|
69
|
-
|
70
|
-
"
|
71
|
-
"
|
72
|
-
"
|
73
|
-
|
74
|
-
|
1
|
+
{
|
2
|
+
"name": "@nestia/migrate",
|
3
|
+
"version": "0.11.0",
|
4
|
+
"description": "Migration program from swagger to NestJS",
|
5
|
+
"main": "lib/index.js",
|
6
|
+
"typings": "lib/index.d.ts",
|
7
|
+
"bin": {
|
8
|
+
"@nestia/migrate": "lib/executable/migrate.js"
|
9
|
+
},
|
10
|
+
"scripts": {
|
11
|
+
"build": "rimraf lib && tsc",
|
12
|
+
"bundle": "ts-node src/executable/bundle.ts",
|
13
|
+
"dev": "npm run build -- --watch",
|
14
|
+
"package:next": "npm publish --access public --tag next",
|
15
|
+
"prepare": "ts-patch install && typia patch && npm run bundle",
|
16
|
+
"test": "node lib/test"
|
17
|
+
},
|
18
|
+
"repository": {
|
19
|
+
"type": "git",
|
20
|
+
"url": "https://github.com/samchon/nestia"
|
21
|
+
},
|
22
|
+
"keywords": [
|
23
|
+
"migration",
|
24
|
+
"swagger",
|
25
|
+
"NestJS",
|
26
|
+
"nestia",
|
27
|
+
"SDK",
|
28
|
+
"Mockup Simulator"
|
29
|
+
],
|
30
|
+
"author": "Jeongho Nam",
|
31
|
+
"license": "MIT",
|
32
|
+
"bugs": {
|
33
|
+
"url": "https://github.com/samchon/nestia/issues"
|
34
|
+
},
|
35
|
+
"homepage": "https://nestia.io",
|
36
|
+
"devDependencies": {
|
37
|
+
"@nestia/core": "^2.6.0",
|
38
|
+
"@nestia/e2e": "^0.4.1",
|
39
|
+
"@nestia/fetcher": "^2.6.0",
|
40
|
+
"@nestjs/common": "^10.3.5",
|
41
|
+
"@nestjs/core": "^10.3.5",
|
42
|
+
"@nestjs/platform-express": "^10.3.5",
|
43
|
+
"@nestjs/platform-fastify": "^10.3.5",
|
44
|
+
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
45
|
+
"@types/express": "^4.17.21",
|
46
|
+
"@types/inquirer": "^9.0.7",
|
47
|
+
"@types/node": "^20.3.3",
|
48
|
+
"@types/swagger2openapi": "^7.0.4",
|
49
|
+
"dotenv": "^16.3.1",
|
50
|
+
"dotenv-expand": "^10.0.0",
|
51
|
+
"rimraf": "^5.0.1",
|
52
|
+
"serialize-error": "^4.1.0",
|
53
|
+
"source-map-support": "^0.5.21",
|
54
|
+
"ts-node": "^10.9.1",
|
55
|
+
"ts-patch": "^3.1.0",
|
56
|
+
"typescript-transform-paths": "^3.4.6"
|
57
|
+
},
|
58
|
+
"dependencies": {
|
59
|
+
"@apiture/openapi-down-convert": "^0.13.0",
|
60
|
+
"commander": "10.0.0",
|
61
|
+
"inquirer": "8.2.5",
|
62
|
+
"openapi-types": "^12.1.3",
|
63
|
+
"prettier": "^3.2.5",
|
64
|
+
"swagger2openapi": "^7.0.8",
|
65
|
+
"tstl": "^2.5.13",
|
66
|
+
"typescript": "^5.4.2",
|
67
|
+
"typia": "^5.5.7"
|
68
|
+
},
|
69
|
+
"files": [
|
70
|
+
"lib",
|
71
|
+
"src",
|
72
|
+
"!lib/test",
|
73
|
+
"!src/test",
|
74
|
+
"package.json",
|
75
|
+
"README.md",
|
76
|
+
"LICENSE"
|
77
|
+
]
|
78
|
+
}
|
@@ -10,19 +10,28 @@ import { MigrateNestProgrammer } from "./programmers/MigrateNestProgrammer";
|
|
10
10
|
import { IMigrateFile } from "./structures/IMigrateFile";
|
11
11
|
import { IMigrateProgram } from "./structures/IMigrateProgram";
|
12
12
|
import { ISwagger } from "./structures/ISwagger";
|
13
|
+
import { ISwaggerV20 } from "./structures/ISwaggerV20";
|
14
|
+
import { ISwaggerV31 } from "./structures/ISwaggerV31";
|
15
|
+
import { OpenApiConverter } from "./utils/OpenApiConverter";
|
13
16
|
|
14
17
|
export class MigrateApplication {
|
15
18
|
private constructor(public readonly swagger: ISwagger) {}
|
16
19
|
|
17
|
-
public static create(
|
20
|
+
public static async create(
|
21
|
+
swagger: ISwagger | ISwaggerV20 | ISwaggerV31,
|
22
|
+
): Promise<IValidation<MigrateApplication>> {
|
23
|
+
swagger = typia.is<ISwaggerV20.IVersion>(swagger)
|
24
|
+
? await OpenApiConverter.v2_0(swagger)
|
25
|
+
: typia.is<ISwaggerV31.IVersion>(swagger)
|
26
|
+
? OpenApiConverter.v3_1(swagger)
|
27
|
+
: swagger;
|
18
28
|
const result = typia.validate<ISwagger>(swagger);
|
19
|
-
if (result.success)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
return result;
|
29
|
+
if (result.success === false) return result;
|
30
|
+
return {
|
31
|
+
success: true,
|
32
|
+
data: new MigrateApplication(swagger),
|
33
|
+
errors: [],
|
34
|
+
};
|
26
35
|
}
|
27
36
|
|
28
37
|
public nest(config: MigrateApplication.IConfig): MigrateApplication.IOutput {
|
@@ -35,7 +35,7 @@ export namespace MigrateCommander {
|
|
35
35
|
})();
|
36
36
|
|
37
37
|
const result: IValidation<MigrateApplication> =
|
38
|
-
MigrateApplication.create(swagger);
|
38
|
+
await MigrateApplication.create(swagger);
|
39
39
|
if (result.success === false) {
|
40
40
|
console.log(result.errors);
|
41
41
|
throw new Error(
|
@@ -1,23 +1,23 @@
|
|
1
|
-
import { ISwaggerComponents } from "./ISwaggerComponents";
|
2
|
-
import { ISwaggerInfo } from "./ISwaggerInfo";
|
3
|
-
import { ISwaggerRoute } from "./ISwaggerRoute";
|
4
|
-
|
5
|
-
export interface ISwagger {
|
6
|
-
openapi: `3.0.${number}`;
|
7
|
-
info: ISwaggerInfo;
|
8
|
-
servers: ISwagger.IServer[];
|
9
|
-
|
10
|
-
components: ISwaggerComponents;
|
11
|
-
paths: Record<string, ISwagger.IPath>;
|
12
|
-
security?: Record<string, string[]>[];
|
13
|
-
}
|
14
|
-
export namespace ISwagger {
|
15
|
-
export interface IServer {
|
16
|
-
url: string;
|
17
|
-
description?: string;
|
18
|
-
}
|
19
|
-
export type IPath = Record<
|
20
|
-
"get" | "post" | "patch" | "put" | "delete",
|
21
|
-
ISwaggerRoute | undefined
|
22
|
-
>;
|
23
|
-
}
|
1
|
+
import { ISwaggerComponents } from "./ISwaggerComponents";
|
2
|
+
import { ISwaggerInfo } from "./ISwaggerInfo";
|
3
|
+
import { ISwaggerRoute } from "./ISwaggerRoute";
|
4
|
+
|
5
|
+
export interface ISwagger {
|
6
|
+
openapi: `3.0.${number}`;
|
7
|
+
info: ISwaggerInfo;
|
8
|
+
servers: ISwagger.IServer[];
|
9
|
+
|
10
|
+
components: ISwaggerComponents;
|
11
|
+
paths: Record<string, ISwagger.IPath>;
|
12
|
+
security?: Record<string, string[]>[];
|
13
|
+
}
|
14
|
+
export namespace ISwagger {
|
15
|
+
export interface IServer {
|
16
|
+
url: string;
|
17
|
+
description?: string;
|
18
|
+
}
|
19
|
+
export type IPath = Record<
|
20
|
+
"get" | "post" | "patch" | "put" | "delete",
|
21
|
+
ISwaggerRoute | undefined
|
22
|
+
>;
|
23
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import V2_0Converter from "swagger2openapi";
|
2
|
+
import typia from "typia";
|
3
|
+
|
4
|
+
import { Converter as V3_1Converter } from "@apiture/openapi-down-convert";
|
5
|
+
|
6
|
+
import { ISwagger } from "../structures/ISwagger";
|
7
|
+
import { ISwaggerV20 } from "../structures/ISwaggerV20";
|
8
|
+
import { ISwaggerV31 } from "../structures/ISwaggerV31";
|
9
|
+
|
10
|
+
export namespace OpenApiConverter {
|
11
|
+
export const v2_0 = async (swagger: ISwaggerV20): Promise<ISwagger> => {
|
12
|
+
const output = await V2_0Converter.convertObj(swagger, {});
|
13
|
+
return typia.assert<ISwagger>(output.openapi);
|
14
|
+
};
|
15
|
+
|
16
|
+
export const v3_1 = (swagger: ISwaggerV31): ISwagger => {
|
17
|
+
const converter = new V3_1Converter(swagger);
|
18
|
+
return typia.assert<ISwagger>(converter.convert() as ISwagger);
|
19
|
+
};
|
20
|
+
}
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"SwaggerExplorer.js","sourceRoot":"","sources":["../../src/utils/SwaggerExplorer.ts"],"names":[],"mappings":""}
|