@nestia/migrate 0.7.5 → 0.7.7
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 +9 -2
- package/lib/MigrateApplication.js +21 -12
- package/lib/MigrateApplication.js.map +1 -1
- package/lib/analyzers/MigrateAnalyzer.d.ts +2 -3
- package/lib/analyzers/MigrateAnalyzer.js +2 -6
- package/lib/analyzers/MigrateAnalyzer.js.map +1 -1
- package/lib/analyzers/MigrateControllerAnalyzer.d.ts +5 -0
- package/lib/analyzers/{ControllerAnalyzer.js → MigrateControllerAnalyzer.js} +31 -20
- package/lib/analyzers/MigrateControllerAnalyzer.js.map +1 -0
- package/lib/analyzers/{MethodAnalyzer.d.ts → MigrateMethodAnalyzer.d.ts} +3 -3
- package/lib/analyzers/{MethodAnalyzer.js → MigrateMethodAnalyzer.js} +40 -39
- package/lib/analyzers/MigrateMethodAnalyzer.js.map +1 -0
- package/lib/archivers/{FileArchiver.d.ts → MigrateFileArchiver.d.ts} +1 -1
- package/lib/archivers/{FileArchiver.js → MigrateFileArchiver.js} +6 -6
- package/lib/archivers/MigrateFileArchiver.js.map +1 -0
- package/lib/bundles/SDK_TEMPLATE.js +0 -5
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/executable/bundle.js +1 -0
- package/lib/executable/bundle.js.map +1 -1
- package/lib/internal/MigrateCommander.js +3 -3
- package/lib/internal/MigrateCommander.js.map +1 -1
- package/lib/module.d.ts +8 -0
- package/lib/module.js +8 -0
- package/lib/module.js.map +1 -1
- package/lib/programmers/{ApiFileProgrammer.d.ts → MigrateApiFileProgrammer.d.ts} +3 -3
- package/lib/programmers/MigrateApiFileProgrammer.js +28 -0
- package/lib/programmers/MigrateApiFileProgrammer.js.map +1 -0
- package/lib/programmers/MigrateApiFunctionProgrammer.d.ts +15 -0
- package/lib/programmers/{ApiFunctionProgrammer.js → MigrateApiFunctionProgrammer.js} +10 -10
- package/lib/programmers/MigrateApiFunctionProgrammer.js.map +1 -0
- package/lib/programmers/{ApiNamespaceProgrammer.d.ts → MigrateApiNamespaceProgrammer.d.ts} +4 -4
- package/lib/programmers/{ApiNamespaceProgrammer.js → MigrateApiNamespaceProgrammer.js} +19 -19
- package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -0
- package/lib/programmers/{ApiProgrammer.d.ts → MigrateApiProgrammer.d.ts} +1 -1
- package/lib/programmers/{ApiProgrammer.js → MigrateApiProgrammer.js} +27 -22
- package/lib/programmers/MigrateApiProgrammer.js.map +1 -0
- package/lib/programmers/{ApiSimulatationProgrammer.d.ts → MigrateApiSimulatationProgrammer.d.ts} +4 -4
- package/lib/programmers/{ApiSimulatationProgrammer.js → MigrateApiSimulatationProgrammer.js} +16 -16
- package/lib/programmers/MigrateApiSimulatationProgrammer.js.map +1 -0
- package/lib/programmers/{DtoProgrammer.d.ts → MigrateDtoProgrammer.d.ts} +3 -3
- package/lib/programmers/{DtoProgrammer.js → MigrateDtoProgrammer.js} +8 -8
- package/lib/programmers/MigrateDtoProgrammer.js.map +1 -0
- package/lib/programmers/{ImportProgrammer.d.ts → MigrateImportProgrammer.d.ts} +3 -3
- package/lib/programmers/{ImportProgrammer.js → MigrateImportProgrammer.js} +12 -10
- package/lib/programmers/MigrateImportProgrammer.js.map +1 -0
- package/lib/programmers/{NestControllerProgrammer.d.ts → MigrateNestControllerProgrammer.d.ts} +1 -1
- package/lib/programmers/{NestControllerProgrammer.js → MigrateNestControllerProgrammer.js} +11 -11
- package/lib/programmers/MigrateNestControllerProgrammer.js.map +1 -0
- package/lib/programmers/{NestMethodProgrammer.d.ts → MigrateNestMethodProgrammer.d.ts} +3 -3
- package/lib/programmers/{NestMethodProgrammer.js → MigrateNestMethodProgrammer.js} +13 -11
- package/lib/programmers/MigrateNestMethodProgrammer.js.map +1 -0
- package/lib/programmers/{NestModuleProgrammer.d.ts → MigrateNestModuleProgrammer.d.ts} +1 -1
- package/lib/programmers/{NestModuleProgrammer.js → MigrateNestModuleProgrammer.js} +8 -8
- package/lib/programmers/MigrateNestModuleProgrammer.js.map +1 -0
- package/lib/programmers/{NestProgrammer.d.ts → MigrateNestProgrammer.d.ts} +1 -1
- package/lib/programmers/{NestProgrammer.js → MigrateNestProgrammer.js} +17 -15
- package/lib/programmers/MigrateNestProgrammer.js.map +1 -0
- package/lib/programmers/MigrateSchemaProgrammer.d.ts +7 -0
- package/lib/programmers/{SchemaProgrammer.js → MigrateSchemaProgrammer.js} +23 -23
- package/lib/programmers/MigrateSchemaProgrammer.js.map +1 -0
- package/lib/structures/IMigrateDto.d.ts +1 -1
- package/lib/structures/IMigrateProgram.d.ts +20 -4
- package/lib/structures/IMigrateRoute.d.ts +2 -1
- package/lib/structures/ISwaggerComponents.d.ts +1 -1
- package/lib/structures/ISwaggerRoute.d.ts +1 -1
- package/lib/structures/{ISwaggeSchema.js → ISwaggerSchema.js} +1 -1
- package/lib/structures/ISwaggerSchema.js.map +1 -0
- package/lib/utils/FilePrinter.d.ts +1 -1
- package/lib/utils/FilePrinter.js +1 -1
- package/lib/utils/FilePrinter.js.map +1 -1
- package/lib/utils/{JsonTypeChecker.d.ts → SwaggerTypeChecker.d.ts} +2 -2
- package/lib/utils/SwaggerTypeChecker.js +34 -0
- package/lib/utils/SwaggerTypeChecker.js.map +1 -0
- package/package.json +68 -68
- package/src/MigrateApplication.ts +35 -16
- package/src/analyzers/MigrateAnalyzer.ts +6 -10
- package/src/analyzers/{ControllerAnalyzer.ts → MigrateControllerAnalyzer.ts} +39 -23
- package/src/analyzers/{MethodAnalyzer.ts → MigrateMethodAnalyzer.ts} +45 -42
- package/src/archivers/{FileArchiver.ts → MigrateFileArchiver.ts} +1 -1
- package/src/bundles/SDK_TEMPLATE.ts +0 -5
- package/src/executable/bundle.ts +1 -0
- package/src/executable/migrate.ts +7 -7
- package/src/internal/MigrateCommander.ts +3 -4
- package/src/internal/MigrateInquirer.ts +79 -79
- package/src/module.ts +14 -4
- package/src/programmers/{ApiFileProgrammer.ts → MigrateApiFileProgrammer.ts} +9 -9
- package/src/programmers/{ApiFunctionProgrammer.ts → MigrateApiFunctionProgrammer.ts} +10 -10
- package/src/programmers/{ApiNamespaceProgrammer.ts → MigrateApiNamespaceProgrammer.ts} +33 -21
- package/src/programmers/{ApiProgrammer.ts → MigrateApiProgrammer.ts} +44 -40
- package/src/programmers/{ApiSimulatationProgrammer.ts → MigrateApiSimulatationProgrammer.ts} +15 -15
- package/src/programmers/{DtoProgrammer.ts → MigrateDtoProgrammer.ts} +12 -8
- package/src/programmers/{ImportProgrammer.ts → MigrateImportProgrammer.ts} +16 -16
- package/src/programmers/{NestControllerProgrammer.ts → MigrateNestControllerProgrammer.ts} +8 -6
- package/src/programmers/{NestMethodProgrammer.ts → MigrateNestMethodProgrammer.ts} +18 -12
- package/src/programmers/{NestModuleProgrammer.ts → MigrateNestModuleProgrammer.ts} +3 -3
- package/src/programmers/{NestProgrammer.ts → MigrateNestProgrammer.ts} +21 -21
- package/src/programmers/{SchemaProgrammer.ts → MigrateSchemaProgrammer.ts} +29 -27
- package/src/structures/IMigrateDto.ts +1 -1
- package/src/structures/IMigrateProgram.ts +25 -9
- package/src/structures/IMigrateRoute.ts +2 -1
- package/src/structures/ISwaggerComponents.ts +1 -1
- package/src/structures/ISwaggerInfo.ts +80 -80
- package/src/structures/ISwaggerRoute.ts +1 -1
- package/src/structures/{ISwaggeSchema.ts → ISwaggerSchema.ts} +90 -90
- package/src/utils/FilePrinter.ts +1 -1
- package/src/utils/SetupWizard.ts +12 -12
- package/src/utils/StringUtil.ts +60 -60
- package/src/utils/{JsonTypeChecker.ts → SwaggerTypeChecker.ts} +5 -5
- package/lib/IMigrateConfig.d.ts +0 -4
- package/lib/IMigrateConfig.js +0 -3
- package/lib/IMigrateConfig.js.map +0 -1
- package/lib/analyzers/ControllerAnalyzer.d.ts +0 -5
- package/lib/analyzers/ControllerAnalyzer.js.map +0 -1
- package/lib/analyzers/MethodAnalyzer.js.map +0 -1
- package/lib/archivers/FileArchiver.js.map +0 -1
- package/lib/programmers/ApiFileProgrammer.js +0 -28
- package/lib/programmers/ApiFileProgrammer.js.map +0 -1
- package/lib/programmers/ApiFunctionProgrammer.d.ts +0 -15
- package/lib/programmers/ApiFunctionProgrammer.js.map +0 -1
- package/lib/programmers/ApiNamespaceProgrammer.js.map +0 -1
- package/lib/programmers/ApiProgrammer.js.map +0 -1
- package/lib/programmers/ApiSimulatationProgrammer.js.map +0 -1
- package/lib/programmers/DtoProgrammer.js.map +0 -1
- package/lib/programmers/ImportProgrammer.js.map +0 -1
- package/lib/programmers/NestControllerProgrammer.js.map +0 -1
- package/lib/programmers/NestMethodProgrammer.js.map +0 -1
- package/lib/programmers/NestModuleProgrammer.js.map +0 -1
- package/lib/programmers/NestProgrammer.js.map +0 -1
- package/lib/programmers/SchemaProgrammer.d.ts +0 -7
- package/lib/programmers/SchemaProgrammer.js.map +0 -1
- package/lib/structures/ISwaggeSchema.js.map +0 -1
- package/lib/utils/JsonTypeChecker.js +0 -34
- package/lib/utils/JsonTypeChecker.js.map +0 -1
- package/src/IMigrateConfig.ts +0 -4
- /package/lib/structures/{ISwaggeSchema.d.ts → ISwaggerSchema.d.ts} +0 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SwaggerSwaggerChecker = void 0;
|
4
|
+
var SwaggerSwaggerChecker;
|
5
|
+
(function (SwaggerSwaggerChecker) {
|
6
|
+
SwaggerSwaggerChecker.isAnyOf = (schema) => schema.anyOf !== undefined;
|
7
|
+
SwaggerSwaggerChecker.isOneOf = (schema) => schema.oneOf !== undefined;
|
8
|
+
SwaggerSwaggerChecker.isNullOnly = (schema) => schema.type === "null";
|
9
|
+
SwaggerSwaggerChecker.isBoolean = (schema) => schema.type === "boolean";
|
10
|
+
SwaggerSwaggerChecker.isInteger = (schema) => schema.type === "integer";
|
11
|
+
SwaggerSwaggerChecker.isNumber = (schema) => schema.type === "number";
|
12
|
+
SwaggerSwaggerChecker.isString = (schema) => schema.type === "string";
|
13
|
+
SwaggerSwaggerChecker.isArray = (schema) => schema.type === "array";
|
14
|
+
SwaggerSwaggerChecker.isObject = (schema) => schema.type === "object";
|
15
|
+
SwaggerSwaggerChecker.isReference = (schema) => schema.$ref !== undefined;
|
16
|
+
SwaggerSwaggerChecker.isUnknown = (schema) => schema.type === undefined &&
|
17
|
+
!SwaggerSwaggerChecker.isAnyOf(schema) &&
|
18
|
+
!SwaggerSwaggerChecker.isOneOf(schema) &&
|
19
|
+
!SwaggerSwaggerChecker.isReference(schema);
|
20
|
+
SwaggerSwaggerChecker.isNullable = (components) => (schema) => {
|
21
|
+
var _a;
|
22
|
+
if (SwaggerSwaggerChecker.isAnyOf(schema))
|
23
|
+
return schema.anyOf.some(SwaggerSwaggerChecker.isNullable(components));
|
24
|
+
else if (SwaggerSwaggerChecker.isOneOf(schema))
|
25
|
+
return schema.oneOf.some(SwaggerSwaggerChecker.isNullable(components));
|
26
|
+
else if (SwaggerSwaggerChecker.isReference(schema)) {
|
27
|
+
const $id = schema.$ref.replace("#/components/schemas/", "");
|
28
|
+
const target = ((_a = components.schemas) !== null && _a !== void 0 ? _a : {})[$id];
|
29
|
+
return target === undefined ? false : SwaggerSwaggerChecker.isNullable(components)(target);
|
30
|
+
}
|
31
|
+
return schema.nullable === true;
|
32
|
+
};
|
33
|
+
})(SwaggerSwaggerChecker || (exports.SwaggerSwaggerChecker = SwaggerSwaggerChecker = {}));
|
34
|
+
//# sourceMappingURL=SwaggerTypeChecker.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"SwaggerTypeChecker.js","sourceRoot":"","sources":["../../src/utils/SwaggerTypeChecker.ts"],"names":[],"mappings":";;;AAGA,IAAiB,qBAAqB,CA+DrC;AA/DD,WAAiB,qBAAqB;IACvB,6BAAO,GAAG,CACrB,MAAsB,EACW,EAAE,CAAE,MAAc,CAAC,KAAK,KAAK,SAAS,CAAC;IAE7D,6BAAO,GAAG,CACrB,MAAsB,EACW,EAAE,CAAE,MAAc,CAAC,KAAK,KAAK,SAAS,CAAC;IAE7D,gCAAU,GAAG,CACxB,MAAsB,EACc,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,MAAM,CAAC;IAE5D,+BAAS,GAAG,CACvB,MAAsB,EACa,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,SAAS,CAAC;IAE9D,+BAAS,GAAG,CACvB,MAAsB,EACa,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,SAAS,CAAC;IAE9D,8BAAQ,GAAG,CACtB,MAAsB,EACY,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,QAAQ,CAAC;IAE5D,8BAAQ,GAAG,CACtB,MAAsB,EACY,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,QAAQ,CAAC;IAE5D,6BAAO,GAAG,CACrB,MAAsB,EACW,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,OAAO,CAAC;IAE1D,8BAAQ,GAAG,CACtB,MAAsB,EACY,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,QAAQ,CAAC;IAE5D,iCAAW,GAAG,CACzB,MAAsB,EACe,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,SAAS,CAAC;IAEhE,+BAAS,GAAG,CACvB,MAAsB,EACa,EAAE,CACpC,MAAc,CAAC,IAAI,KAAK,SAAS;QAClC,CAAC,sBAAA,OAAO,CAAC,MAAM,CAAC;QAChB,CAAC,sBAAA,OAAO,CAAC,MAAM,CAAC;QAChB,CAAC,sBAAA,WAAW,CAAC,MAAM,CAAC,CAAC;IAEV,gCAAU,GACrB,CAAC,UAA8B,EAAE,EAAE,CACnC,CAAC,MAAsB,EAAW,EAAE;;QAClC,IAAI,qBAAqB,CAAC,OAAO,CAAC,MAAM,CAAC;YACvC,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAA,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;aAC9C,IAAI,qBAAqB,CAAC,OAAO,CAAC,MAAM,CAAC;YAC5C,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAA,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;aAC9C,IAAI,qBAAqB,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;YACnD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAG,CAAC,MAAA,UAAU,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;YAC/C,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,sBAAA,UAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;QACvE,CAAC;QACD,OAAQ,MAAiC,CAAC,QAAQ,KAAK,IAAI,CAAC;IAC9D,CAAC,CAAC;AACN,CAAC,EA/DgB,qBAAqB,qCAArB,qBAAqB,QA+DrC"}
|
package/package.json
CHANGED
@@ -1,68 +1,68 @@
|
|
1
|
-
{
|
2
|
-
"name": "@nestia/migrate",
|
3
|
-
"version": "0.7.
|
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
|
-
"prepare": "ts-patch install && typia patch && npm run bundle",
|
15
|
-
"test": "node lib/test"
|
16
|
-
},
|
17
|
-
"repository": {
|
18
|
-
"type": "git",
|
19
|
-
"url": "https://github.com/samchon/nestia"
|
20
|
-
},
|
21
|
-
"keywords": [
|
22
|
-
"migration",
|
23
|
-
"swagger",
|
24
|
-
"NestJS",
|
25
|
-
"nestia"
|
26
|
-
],
|
27
|
-
"author": "Jeongho Nam",
|
28
|
-
"license": "MIT",
|
29
|
-
"bugs": {
|
30
|
-
"url": "https://github.com/samchon/nestia/issues"
|
31
|
-
},
|
32
|
-
"homepage": "https://github.com/samchon/nestia#readme",
|
33
|
-
"devDependencies": {
|
34
|
-
"@nestia/core": "2.5.4",
|
35
|
-
"@nestia/fetcher": "2.5.4",
|
36
|
-
"@nestjs/common": "^10.3.1",
|
37
|
-
"@nestjs/core": "^10.3.1",
|
38
|
-
"@nestjs/platform-express": "^10.3.1",
|
39
|
-
"@nestjs/platform-fastify": "^10.3.1",
|
40
|
-
"@types/express": "^4.17.21",
|
41
|
-
"@types/inquirer": "^9.0.7",
|
42
|
-
"@types/node": "^20.3.3",
|
43
|
-
"dotenv": "^16.3.1",
|
44
|
-
"dotenv-expand": "^10.0.0",
|
45
|
-
"rimraf": "^5.0.1",
|
46
|
-
"serialize-error": "^4.1.0",
|
47
|
-
"source-map-support": "^0.5.21",
|
48
|
-
"ts-node": "^10.9.1",
|
49
|
-
"ts-patch": "^3.1.0",
|
50
|
-
"tstl": "^2.5.13",
|
51
|
-
"typescript-transform-paths": "^3.4.6"
|
52
|
-
},
|
53
|
-
"dependencies": {
|
54
|
-
"commander": "10.0.0",
|
55
|
-
"inquirer": "8.2.5",
|
56
|
-
"typescript": "^5.3.3",
|
57
|
-
"typia": "^5.4.5"
|
58
|
-
},
|
59
|
-
"files": [
|
60
|
-
"lib",
|
61
|
-
"src",
|
62
|
-
"!lib/test",
|
63
|
-
"!src/test",
|
64
|
-
"package.json",
|
65
|
-
"README.md",
|
66
|
-
"LICENSE"
|
67
|
-
]
|
68
|
-
}
|
1
|
+
{
|
2
|
+
"name": "@nestia/migrate",
|
3
|
+
"version": "0.7.7",
|
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
|
+
"prepare": "ts-patch install && typia patch && npm run bundle",
|
15
|
+
"test": "node lib/test"
|
16
|
+
},
|
17
|
+
"repository": {
|
18
|
+
"type": "git",
|
19
|
+
"url": "https://github.com/samchon/nestia"
|
20
|
+
},
|
21
|
+
"keywords": [
|
22
|
+
"migration",
|
23
|
+
"swagger",
|
24
|
+
"NestJS",
|
25
|
+
"nestia"
|
26
|
+
],
|
27
|
+
"author": "Jeongho Nam",
|
28
|
+
"license": "MIT",
|
29
|
+
"bugs": {
|
30
|
+
"url": "https://github.com/samchon/nestia/issues"
|
31
|
+
},
|
32
|
+
"homepage": "https://github.com/samchon/nestia#readme",
|
33
|
+
"devDependencies": {
|
34
|
+
"@nestia/core": "2.5.4",
|
35
|
+
"@nestia/fetcher": "2.5.4",
|
36
|
+
"@nestjs/common": "^10.3.1",
|
37
|
+
"@nestjs/core": "^10.3.1",
|
38
|
+
"@nestjs/platform-express": "^10.3.1",
|
39
|
+
"@nestjs/platform-fastify": "^10.3.1",
|
40
|
+
"@types/express": "^4.17.21",
|
41
|
+
"@types/inquirer": "^9.0.7",
|
42
|
+
"@types/node": "^20.3.3",
|
43
|
+
"dotenv": "^16.3.1",
|
44
|
+
"dotenv-expand": "^10.0.0",
|
45
|
+
"rimraf": "^5.0.1",
|
46
|
+
"serialize-error": "^4.1.0",
|
47
|
+
"source-map-support": "^0.5.21",
|
48
|
+
"ts-node": "^10.9.1",
|
49
|
+
"ts-patch": "^3.1.0",
|
50
|
+
"tstl": "^2.5.13",
|
51
|
+
"typescript-transform-paths": "^3.4.6"
|
52
|
+
},
|
53
|
+
"dependencies": {
|
54
|
+
"commander": "10.0.0",
|
55
|
+
"inquirer": "8.2.5",
|
56
|
+
"typescript": "^5.3.3",
|
57
|
+
"typia": "^5.4.5"
|
58
|
+
},
|
59
|
+
"files": [
|
60
|
+
"lib",
|
61
|
+
"src",
|
62
|
+
"!lib/test",
|
63
|
+
"!src/test",
|
64
|
+
"package.json",
|
65
|
+
"README.md",
|
66
|
+
"LICENSE"
|
67
|
+
]
|
68
|
+
}
|
@@ -3,33 +3,52 @@ import typia from "typia";
|
|
3
3
|
import { MigrateAnalyzer } from "./analyzers/MigrateAnalyzer";
|
4
4
|
import { NEST_TEMPLATE } from "./bundles/NEST_TEMPLATE";
|
5
5
|
import { SDK_TEMPLATE } from "./bundles/SDK_TEMPLATE";
|
6
|
-
import {
|
7
|
-
import {
|
6
|
+
import { IMigrateProgram } from "./module";
|
7
|
+
import { MigrateApiProgrammer } from "./programmers/MigrateApiProgrammer";
|
8
|
+
import { MigrateNestProgrammer } from "./programmers/MigrateNestProgrammer";
|
8
9
|
import { IMigrateFile } from "./structures/IMigrateFile";
|
9
10
|
import { ISwagger } from "./structures/ISwagger";
|
10
11
|
|
11
12
|
export class MigrateApplication {
|
12
|
-
public
|
13
|
-
|
13
|
+
public readonly swagger: ISwagger;
|
14
|
+
|
15
|
+
public constructor(swagger: ISwagger) {
|
16
|
+
this.swagger = typia.assert(swagger);
|
14
17
|
}
|
15
18
|
|
16
|
-
public nest(simulate: boolean):
|
17
|
-
const program = MigrateAnalyzer.analyze({
|
19
|
+
public nest(simulate: boolean): MigrateApplication.IOutput {
|
20
|
+
const program: IMigrateProgram = MigrateAnalyzer.analyze({
|
18
21
|
mode: "nest",
|
19
22
|
simulate,
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
swagger: this.swagger,
|
24
|
+
dictionary: new Map(),
|
25
|
+
});
|
26
|
+
return {
|
27
|
+
program,
|
28
|
+
files: [
|
29
|
+
...NEST_TEMPLATE,
|
30
|
+
...MigrateNestProgrammer.write(program),
|
31
|
+
...MigrateApiProgrammer.write(program),
|
32
|
+
],
|
33
|
+
};
|
26
34
|
}
|
27
35
|
|
28
|
-
public sdk(simulate: boolean):
|
29
|
-
const program = MigrateAnalyzer.analyze({
|
36
|
+
public sdk(simulate: boolean): MigrateApplication.IOutput {
|
37
|
+
const program: IMigrateProgram = MigrateAnalyzer.analyze({
|
30
38
|
mode: "sdk",
|
31
39
|
simulate,
|
32
|
-
|
33
|
-
|
40
|
+
swagger: this.swagger,
|
41
|
+
dictionary: new Map(),
|
42
|
+
});
|
43
|
+
return {
|
44
|
+
program,
|
45
|
+
files: [...SDK_TEMPLATE, ...MigrateApiProgrammer.write(program)],
|
46
|
+
};
|
47
|
+
}
|
48
|
+
}
|
49
|
+
export namespace MigrateApplication {
|
50
|
+
export interface IOutput {
|
51
|
+
program: IMigrateProgram;
|
52
|
+
files: IMigrateFile[];
|
34
53
|
}
|
35
54
|
}
|
@@ -1,13 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import { ControllerAnalyzer } from "./ControllerAnalyzer";
|
1
|
+
import { IMigrateProgram } from "../structures/IMigrateProgram";
|
2
|
+
import { MigrateControllerAnalyzer } from "./MigrateControllerAnalyzer";
|
4
3
|
|
5
4
|
export namespace MigrateAnalyzer {
|
6
|
-
export const analyze =
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
swagger,
|
11
|
-
controllers: ControllerAnalyzer.analyze(swagger),
|
12
|
-
});
|
5
|
+
export const analyze = (props: IMigrateProgram.IProps): IMigrateProgram => ({
|
6
|
+
...props,
|
7
|
+
controllers: MigrateControllerAnalyzer.analyze(props),
|
8
|
+
});
|
13
9
|
}
|
@@ -1,38 +1,49 @@
|
|
1
1
|
import { Escaper } from "typia/lib/utils/Escaper";
|
2
2
|
|
3
|
-
import { ISwagger } from "../module";
|
4
3
|
import { IMigrateController } from "../structures/IMigrateController";
|
4
|
+
import { IMigrateProgram } from "../structures/IMigrateProgram";
|
5
5
|
import { IMigrateRoute } from "../structures/IMigrateRoute";
|
6
|
+
import { ISwaggerRoute } from "../structures/ISwaggerRoute";
|
6
7
|
import { MapUtil } from "../utils/MapUtil";
|
7
8
|
import { StringUtil } from "../utils/StringUtil";
|
8
|
-
import {
|
9
|
+
import { MigrateMethodAnalzyer } from "./MigrateMethodAnalyzer";
|
9
10
|
|
10
|
-
export namespace
|
11
|
-
export const analyze = (
|
12
|
-
|
11
|
+
export namespace MigrateControllerAnalyzer {
|
12
|
+
export const analyze = (
|
13
|
+
props: IMigrateProgram.IProps,
|
14
|
+
): IMigrateController[] => {
|
15
|
+
interface IEntry {
|
16
|
+
endpoint: ISwaggerRoute;
|
17
|
+
route: IMigrateRoute;
|
18
|
+
}
|
19
|
+
const endpoints: Map<string, IEntry[]> = new Map();
|
13
20
|
|
14
21
|
// GATHER ROUTES
|
15
|
-
for (const [path, collection] of Object.entries(swagger.paths)) {
|
22
|
+
for (const [path, collection] of Object.entries(props.swagger.paths)) {
|
16
23
|
// PREPARE DIRECTORIES
|
17
24
|
const location: string = StringUtil.splitWithNormalization(path)
|
18
25
|
.filter((str) => str[0] !== "{" && str[0] !== ":")
|
19
26
|
.join("/");
|
20
|
-
for (const s of sequence(location)) MapUtil.take(
|
27
|
+
for (const s of sequence(location)) MapUtil.take(endpoints)(s)(() => []);
|
21
28
|
|
22
29
|
// INSERT ROUTES TO THE LAST DIRECTORY
|
23
|
-
const routes:
|
30
|
+
const routes: IEntry[] = MapUtil.take(endpoints)(location)(() => []);
|
24
31
|
for (const [method, value] of Object.entries(collection)) {
|
25
|
-
const r: IMigrateRoute | null =
|
32
|
+
const r: IMigrateRoute | null = MigrateMethodAnalzyer.analyze(props)({
|
26
33
|
path,
|
27
34
|
method,
|
28
35
|
})(value);
|
29
|
-
if (r
|
36
|
+
if (r === null) continue;
|
37
|
+
routes.push({
|
38
|
+
endpoint: value,
|
39
|
+
route: r,
|
40
|
+
});
|
30
41
|
}
|
31
42
|
}
|
32
43
|
|
33
44
|
// ABSORB STANDALONE ROUTES
|
34
|
-
const emended: Map<string,
|
35
|
-
[...
|
45
|
+
const emended: Map<string, IEntry[]> = new Map(
|
46
|
+
[...endpoints.entries()].sort((a, b) => a[0].localeCompare(b[0])),
|
36
47
|
);
|
37
48
|
for (const [location, routes] of emended) {
|
38
49
|
if (routes.length !== 1) continue;
|
@@ -51,20 +62,26 @@ export namespace ControllerAnalyzer {
|
|
51
62
|
.filter(([_l, routes]) => !!routes.length)
|
52
63
|
.map(([location, routes]) => {
|
53
64
|
const prefix: string = StringUtil.commonPrefix(
|
54
|
-
routes.map((
|
65
|
+
routes.map((e) => e.route.path),
|
55
66
|
);
|
56
|
-
for (const
|
57
|
-
|
58
|
-
|
67
|
+
for (const e of routes)
|
68
|
+
e.route.path = StringUtil.reJoinWithDecimalParameters(
|
69
|
+
e.route.path.replace(prefix, ""),
|
59
70
|
);
|
60
71
|
const controller: IMigrateController = {
|
61
72
|
name: StringUtil.pascal(location) + "Controller",
|
62
73
|
path: StringUtil.reJoinWithDecimalParameters(prefix),
|
63
74
|
location: "src/controllers/" + location,
|
64
|
-
routes,
|
75
|
+
routes: routes.map((e) => e.route),
|
65
76
|
};
|
66
77
|
if (controller.name === "Controller") controller.name = "__Controller";
|
67
78
|
emend(controller);
|
79
|
+
|
80
|
+
for (const e of routes)
|
81
|
+
props.dictionary.set(e.endpoint, {
|
82
|
+
controller,
|
83
|
+
route: e.route,
|
84
|
+
});
|
68
85
|
return controller;
|
69
86
|
});
|
70
87
|
};
|
@@ -113,11 +130,10 @@ export namespace ControllerAnalyzer {
|
|
113
130
|
method.parameters.map((p) => p.key),
|
114
131
|
)(spec.key);
|
115
132
|
}
|
116
|
-
controller.routes.forEach(
|
117
|
-
|
118
|
-
(
|
119
|
-
|
120
|
-
|
121
|
-
);
|
133
|
+
controller.routes.forEach((r, i) => {
|
134
|
+
r.name = StringUtil.escapeDuplicate(
|
135
|
+
controller.routes.filter((_r, j) => i !== j).map((x) => x.name),
|
136
|
+
)(r.name);
|
137
|
+
});
|
122
138
|
};
|
123
139
|
}
|
@@ -1,22 +1,22 @@
|
|
1
1
|
import { Escaper } from "typia/lib/utils/Escaper";
|
2
2
|
|
3
|
-
import { ISwagger } from "../module";
|
3
|
+
import { IMigrateProgram, ISwagger } from "../module";
|
4
4
|
import { IMigrateRoute } from "../structures/IMigrateRoute";
|
5
|
-
import { ISwaggerSchema } from "../structures/
|
5
|
+
import { ISwaggerSchema } from "../structures/ISwaggerSchema";
|
6
6
|
import { ISwaggerRoute } from "../structures/ISwaggerRoute";
|
7
|
-
import { SwaggerTypeChecker } from "../utils/JsonTypeChecker";
|
8
7
|
import { StringUtil } from "../utils/StringUtil";
|
8
|
+
import { SwaggerSwaggerChecker } from "../utils/SwaggerTypeChecker";
|
9
9
|
|
10
|
-
export namespace
|
10
|
+
export namespace MigrateMethodAnalzyer {
|
11
11
|
export const analyze =
|
12
|
-
(
|
13
|
-
(
|
12
|
+
(props: Omit<IMigrateProgram.IProps, "dictionary">) =>
|
13
|
+
(endpoint: { path: string; method: string }) =>
|
14
14
|
(route: ISwaggerRoute): IMigrateRoute | null => {
|
15
15
|
const body = emplaceBodySchema("request")(
|
16
|
-
emplaceReference(swagger)("body"),
|
16
|
+
emplaceReference(props.swagger)("body"),
|
17
17
|
)(route.requestBody);
|
18
18
|
const success = emplaceBodySchema("response")(
|
19
|
-
emplaceReference(swagger)("response"),
|
19
|
+
emplaceReference(props.swagger)("response"),
|
20
20
|
)(route.responses?.["201"] ?? route.responses?.["200"]);
|
21
21
|
|
22
22
|
const failures: string[] = [];
|
@@ -28,11 +28,13 @@ export namespace MethodAnalzyer {
|
|
28
28
|
failures.push(
|
29
29
|
`supports only "application/json", "application/x-www-form-urlencoded" and "text/plain" content type in the response body.`,
|
30
30
|
);
|
31
|
-
if (SUPPORTED_METHODS.has(
|
32
|
-
failures.push(
|
31
|
+
if (SUPPORTED_METHODS.has(endpoint.method.toUpperCase()) === false)
|
32
|
+
failures.push(
|
33
|
+
`does not support ${endpoint.method.toUpperCase()} method.`,
|
34
|
+
);
|
33
35
|
if (failures.length) {
|
34
36
|
console.log(
|
35
|
-
`Failed to migrate ${
|
37
|
+
`Failed to migrate ${endpoint.method.toUpperCase()} ${endpoint.path}`,
|
36
38
|
...failures.map((f) => ` - ${f}`),
|
37
39
|
);
|
38
40
|
return null;
|
@@ -46,11 +48,11 @@ export namespace MethodAnalzyer {
|
|
46
48
|
|
47
49
|
const objects = parameters
|
48
50
|
.map((p) =>
|
49
|
-
|
51
|
+
SwaggerSwaggerChecker.isObject(p.schema)
|
50
52
|
? p.schema
|
51
|
-
:
|
52
|
-
|
53
|
-
(swagger.components.schemas ?? {})[
|
53
|
+
: SwaggerSwaggerChecker.isReference(p.schema) &&
|
54
|
+
SwaggerSwaggerChecker.isObject(
|
55
|
+
(props.swagger.components.schemas ?? {})[
|
54
56
|
p.schema.$ref.replace(`#/components/schemas/`, ``)
|
55
57
|
] ?? {},
|
56
58
|
)
|
@@ -60,24 +62,24 @@ export namespace MethodAnalzyer {
|
|
60
62
|
.filter((s) => !!s);
|
61
63
|
const primitives = parameters.filter(
|
62
64
|
(p) =>
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
SwaggerSwaggerChecker.isBoolean(p.schema) ||
|
66
|
+
SwaggerSwaggerChecker.isNumber(p.schema) ||
|
67
|
+
SwaggerSwaggerChecker.isInteger(p.schema) ||
|
68
|
+
SwaggerSwaggerChecker.isString(p.schema) ||
|
69
|
+
SwaggerSwaggerChecker.isArray(p.schema),
|
68
70
|
);
|
69
71
|
if (objects.length === 1 && primitives.length === 0) return objects[0];
|
70
72
|
else if (objects.length > 1)
|
71
73
|
throw new Error(
|
72
74
|
`Error on nestia.migrate.RouteProgrammer.analze(): ${type} typed parameters must be only one object type - ${StringUtil.capitalize(
|
73
|
-
|
74
|
-
)} "${
|
75
|
+
endpoint.method,
|
76
|
+
)} "${endpoint.path}".`,
|
75
77
|
);
|
76
78
|
|
77
79
|
const dto: ISwaggerSchema.IObject | null = objects[0]
|
78
|
-
?
|
80
|
+
? SwaggerSwaggerChecker.isObject(objects[0])
|
79
81
|
? objects[0]
|
80
|
-
: ((swagger.components.schemas ?? {})[
|
82
|
+
: ((props.swagger.components.schemas ?? {})[
|
81
83
|
(objects[0] as ISwaggerSchema.IReference).$ref.replace(
|
82
84
|
`#/components/schemas/`,
|
83
85
|
``,
|
@@ -86,9 +88,9 @@ export namespace MethodAnalzyer {
|
|
86
88
|
: null;
|
87
89
|
const entire: ISwaggerSchema.IObject[] = [
|
88
90
|
...objects.map((o) =>
|
89
|
-
|
91
|
+
SwaggerSwaggerChecker.isObject(o)
|
90
92
|
? o
|
91
|
-
: (swagger.components.schemas?.[
|
93
|
+
: (props.swagger.components.schemas?.[
|
92
94
|
o.$ref.replace(`#/components/schemas/`, ``)
|
93
95
|
]! as ISwaggerSchema.IObject),
|
94
96
|
),
|
@@ -112,10 +114,10 @@ export namespace MethodAnalzyer {
|
|
112
114
|
];
|
113
115
|
return parameters.length === 0
|
114
116
|
? null
|
115
|
-
: emplaceReference(swagger)(
|
116
|
-
StringUtil.pascal(`I/Api/${
|
117
|
+
: emplaceReference(props.swagger)(
|
118
|
+
StringUtil.pascal(`I/Api/${endpoint.path}`) +
|
117
119
|
"." +
|
118
|
-
StringUtil.pascal(`${
|
120
|
+
StringUtil.pascal(`${endpoint.method}/${type}`),
|
119
121
|
)({
|
120
122
|
type: "object",
|
121
123
|
properties: Object.fromEntries([
|
@@ -144,7 +146,7 @@ export namespace MethodAnalzyer {
|
|
144
146
|
});
|
145
147
|
|
146
148
|
const parameterNames: string[] = StringUtil.splitWithNormalization(
|
147
|
-
|
149
|
+
endpoint.path,
|
148
150
|
)
|
149
151
|
.filter((str) => str[0] === "{" || str[0] === ":")
|
150
152
|
.map((str) =>
|
@@ -155,16 +157,17 @@ export namespace MethodAnalzyer {
|
|
155
157
|
(route.parameters ?? []).filter((p) => p.in === "path").length
|
156
158
|
) {
|
157
159
|
console.log(
|
158
|
-
`Failed to migrate ${
|
159
|
-
|
160
|
+
`Failed to migrate ${endpoint.method.toUpperCase()} ${
|
161
|
+
endpoint.path
|
160
162
|
}: number of path parameters are not matched with its full path.`,
|
161
163
|
);
|
162
164
|
return null;
|
163
165
|
}
|
164
166
|
return {
|
165
167
|
name: "@lazy",
|
166
|
-
path:
|
167
|
-
method:
|
168
|
+
path: endpoint.path,
|
169
|
+
method: endpoint.method,
|
170
|
+
accessor: ["@lazy"],
|
168
171
|
headers: headers
|
169
172
|
? {
|
170
173
|
key: "headers",
|
@@ -256,16 +259,16 @@ export namespace MethodAnalzyer {
|
|
256
259
|
};
|
257
260
|
|
258
261
|
const isNotObjectLiteral = (schema: ISwaggerSchema): boolean =>
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
(
|
262
|
+
SwaggerSwaggerChecker.isReference(schema) ||
|
263
|
+
SwaggerSwaggerChecker.isBoolean(schema) ||
|
264
|
+
SwaggerSwaggerChecker.isNumber(schema) ||
|
265
|
+
SwaggerSwaggerChecker.isString(schema) ||
|
266
|
+
SwaggerSwaggerChecker.isUnknown(schema) ||
|
267
|
+
(SwaggerSwaggerChecker.isAnyOf(schema) &&
|
265
268
|
schema.anyOf.every(isNotObjectLiteral)) ||
|
266
|
-
(
|
269
|
+
(SwaggerSwaggerChecker.isOneOf(schema) &&
|
267
270
|
schema.oneOf.every(isNotObjectLiteral)) ||
|
268
|
-
(
|
271
|
+
(SwaggerSwaggerChecker.isArray(schema) && isNotObjectLiteral(schema.items));
|
269
272
|
|
270
273
|
const emplaceBodySchema =
|
271
274
|
(from: "request" | "response") =>
|
@@ -1,9 +1,4 @@
|
|
1
1
|
export const SDK_TEMPLATE = [
|
2
|
-
{
|
3
|
-
"location": ".github/workflows",
|
4
|
-
"file": "build.yml",
|
5
|
-
"content": "name: build\r\non: [push, pull_request]\r\n\r\njobs:\r\n Ubuntu:\r\n runs-on: ubuntu-latest\r\n steps:\r\n - uses: actions/checkout@v4\r\n - uses: actions/setup-node@v4\r\n with:\r\n node-version: 20.x\r\n - uses: pnpm/action-setup@v2\r\n with:\r\n version: 8\r\n\r\n - name: Install\r\n run: pnpm install\r\n\r\n - name: Build\r\n run: npm run build\r\n"
|
6
|
-
},
|
7
2
|
{
|
8
3
|
"location": "",
|
9
4
|
"file": ".gitignore",
|
package/src/executable/bundle.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
import { MigrateCommander } from "../internal/MigrateCommander";
|
3
|
-
|
4
|
-
MigrateCommander.main().catch((exp) => {
|
5
|
-
console.error(exp);
|
6
|
-
process.exit(-1);
|
7
|
-
});
|
1
|
+
#!/usr/bin/env node
|
2
|
+
import { MigrateCommander } from "../internal/MigrateCommander";
|
3
|
+
|
4
|
+
MigrateCommander.main().catch((exp) => {
|
5
|
+
console.error(exp);
|
6
|
+
process.exit(-1);
|
7
|
+
});
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import fs from "fs";
|
2
2
|
import path from "path";
|
3
3
|
|
4
|
-
import {
|
4
|
+
import { MigrateFileArchiver } from "../archivers/MigrateFileArchiver";
|
5
5
|
import { MigrateApplication } from "../module";
|
6
|
-
import { IMigrateFile } from "../structures/IMigrateFile";
|
7
6
|
import { ISwagger } from "../structures/ISwagger";
|
8
7
|
import { MigrateInquirer } from "./MigrateInquirer";
|
9
8
|
|
@@ -34,11 +33,11 @@ export namespace MigrateCommander {
|
|
34
33
|
})();
|
35
34
|
|
36
35
|
const app: MigrateApplication = new MigrateApplication(swagger);
|
37
|
-
const files
|
36
|
+
const { files } =
|
38
37
|
options.mode === "nest"
|
39
38
|
? app.nest(options.simulate)
|
40
39
|
: app.sdk(options.simulate);
|
41
|
-
await
|
40
|
+
await MigrateFileArchiver.archive({
|
42
41
|
mkdir: fs.promises.mkdir,
|
43
42
|
writeFile: (file, content) =>
|
44
43
|
fs.promises.writeFile(file, content, "utf-8"),
|