@nestia/migrate 0.1.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/.prettierignore +3 -0
- package/.vscode/settings.json +10 -0
- package/lib/NestiaMigrateApplication.d.ts +18 -0
- package/lib/NestiaMigrateApplication.js +1330 -0
- package/lib/NestiaMigrateApplication.js.map +1 -0
- package/lib/archivers/FileArchiver.d.ts +8 -0
- package/lib/archivers/FileArchiver.js +35 -0
- package/lib/archivers/FileArchiver.js.map +1 -0
- package/lib/bundles/TEMPLATE.d.ts +5 -0
- package/lib/bundles/TEMPLATE.js +261 -0
- package/lib/bundles/TEMPLATE.js.map +1 -0
- package/lib/executable/bundle.d.ts +1 -0
- package/lib/executable/bundle.js +75 -0
- package/lib/executable/bundle.js.map +1 -0
- package/lib/executable/migrate.d.ts +2 -0
- package/lib/executable/migrate.js +65 -0
- package/lib/executable/migrate.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +32 -0
- package/lib/index.js.map +1 -0
- package/lib/module.d.ts +3 -0
- package/lib/module.js +20 -0
- package/lib/module.js.map +1 -0
- package/lib/programmers/ControllerProgrammer.d.ts +6 -0
- package/lib/programmers/ControllerProgrammer.js +119 -0
- package/lib/programmers/ControllerProgrammer.js.map +1 -0
- package/lib/programmers/DtoProgrammer.d.ts +6 -0
- package/lib/programmers/DtoProgrammer.js +95 -0
- package/lib/programmers/DtoProgrammer.js.map +1 -0
- package/lib/programmers/MigrateProgrammer.d.ts +7 -0
- package/lib/programmers/MigrateProgrammer.js +31 -0
- package/lib/programmers/MigrateProgrammer.js.map +1 -0
- package/lib/programmers/RouteProgrammer.d.ts +11 -0
- package/lib/programmers/RouteProgrammer.js +199 -0
- package/lib/programmers/RouteProgrammer.js.map +1 -0
- package/lib/programmers/SchemaProgrammer.d.ts +4 -0
- package/lib/programmers/SchemaProgrammer.js +163 -0
- package/lib/programmers/SchemaProgrammer.js.map +1 -0
- package/lib/structures/IMigrateController.d.ts +7 -0
- package/lib/structures/IMigrateController.js +3 -0
- package/lib/structures/IMigrateController.js.map +1 -0
- package/lib/structures/IMigrateDto.d.ts +7 -0
- package/lib/structures/IMigrateDto.js +3 -0
- package/lib/structures/IMigrateDto.js.map +1 -0
- package/lib/structures/IMigrateFile.d.ts +5 -0
- package/lib/structures/IMigrateFile.js +3 -0
- package/lib/structures/IMigrateFile.js.map +1 -0
- package/lib/structures/IMigrateProgram.d.ts +6 -0
- package/lib/structures/IMigrateProgram.js +3 -0
- package/lib/structures/IMigrateProgram.js.map +1 -0
- package/lib/structures/IMigrateRoute.d.ts +19 -0
- package/lib/structures/IMigrateRoute.js +3 -0
- package/lib/structures/IMigrateRoute.js.map +1 -0
- package/lib/structures/IMigrateSchema.d.ts +4 -0
- package/lib/structures/IMigrateSchema.js +3 -0
- package/lib/structures/IMigrateSchema.js.map +1 -0
- package/lib/structures/ISwaggeSchema.d.ts +72 -0
- package/lib/structures/ISwaggeSchema.js +3 -0
- package/lib/structures/ISwaggeSchema.js.map +1 -0
- package/lib/structures/ISwagger.d.ts +22 -0
- package/lib/structures/ISwagger.js +3 -0
- package/lib/structures/ISwagger.js.map +1 -0
- package/lib/structures/ISwaggerComponents.d.ts +6 -0
- package/lib/structures/ISwaggerComponents.js +3 -0
- package/lib/structures/ISwaggerComponents.js.map +1 -0
- package/lib/structures/ISwaggerRoute.d.ts +38 -0
- package/lib/structures/ISwaggerRoute.js +3 -0
- package/lib/structures/ISwaggerRoute.js.map +1 -0
- package/lib/structures/ISwaggerSecurity.d.ts +40 -0
- package/lib/structures/ISwaggerSecurity.js +3 -0
- package/lib/structures/ISwaggerSecurity.js.map +1 -0
- package/lib/test/index.d.ts +1 -0
- package/lib/test/index.js +45 -0
- package/lib/test/index.js.map +1 -0
- package/lib/utils/JsonTypeChecker.d.ts +13 -0
- package/lib/utils/JsonTypeChecker.js +20 -0
- package/lib/utils/JsonTypeChecker.js.map +1 -0
- package/lib/utils/MapUtil.d.ts +3 -0
- package/lib/utils/MapUtil.js +15 -0
- package/lib/utils/MapUtil.js.map +1 -0
- package/lib/utils/SetupWizard.d.ts +3 -0
- package/lib/utils/SetupWizard.js +21 -0
- package/lib/utils/SetupWizard.js.map +1 -0
- package/lib/utils/StringUtil.d.ts +9 -0
- package/lib/utils/StringUtil.js +41 -0
- package/lib/utils/StringUtil.js.map +1 -0
- package/package.json +43 -0
- package/prettier.config.js +15 -0
- package/src/NestiaMigrateApplication.ts +51 -0
- package/src/archivers/FileArchiver.ts +38 -0
- package/src/bundles/TEMPLATE.ts +257 -0
- package/src/executable/bundle.ts +74 -0
- package/src/executable/migrate.ts +58 -0
- package/src/index.ts +4 -0
- package/src/module.ts +4 -0
- package/src/programmers/ControllerProgrammer.ts +159 -0
- package/src/programmers/DtoProgrammer.ts +122 -0
- package/src/programmers/MigrateProgrammer.ts +31 -0
- package/src/programmers/RouteProgrammer.ts +264 -0
- package/src/programmers/SchemaProgrammer.ts +215 -0
- package/src/structures/IMigrateController.ts +8 -0
- package/src/structures/IMigrateDto.ts +8 -0
- package/src/structures/IMigrateFile.ts +5 -0
- package/src/structures/IMigrateProgram.ts +7 -0
- package/src/structures/IMigrateRoute.ts +20 -0
- package/src/structures/IMigrateSchema.ts +4 -0
- package/src/structures/ISwaggeSchema.ts +85 -0
- package/src/structures/ISwagger.ts +24 -0
- package/src/structures/ISwaggerComponents.ts +7 -0
- package/src/structures/ISwaggerRoute.ts +42 -0
- package/src/structures/ISwaggerSecurity.ts +47 -0
- package/src/test/index.ts +38 -0
- package/src/utils/JsonTypeChecker.ts +48 -0
- package/src/utils/MapUtil.ts +13 -0
- package/src/utils/SetupWizard.ts +15 -0
- package/src/utils/StringUtil.ts +49 -0
- package/tsconfig.json +81 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
import { ISwaggerSchema } from "./ISwaggeSchema";
|
2
|
+
export interface ISwaggerRoute {
|
3
|
+
parameters: ISwaggerRoute.IParameter[];
|
4
|
+
requestBody?: ISwaggerRoute.IRequestBody;
|
5
|
+
responses: ISwaggerRoute.IResponseBody;
|
6
|
+
summary?: string;
|
7
|
+
description?: string;
|
8
|
+
deprecated?: boolean;
|
9
|
+
tags: string[];
|
10
|
+
}
|
11
|
+
export declare namespace ISwaggerRoute {
|
12
|
+
interface IParameter {
|
13
|
+
name: string;
|
14
|
+
in: "path" | "query" | "header" | "cookie";
|
15
|
+
schema: ISwaggerSchema;
|
16
|
+
required: boolean;
|
17
|
+
description: string;
|
18
|
+
}
|
19
|
+
interface IRequestBody {
|
20
|
+
description: string;
|
21
|
+
content: IContent;
|
22
|
+
required: true;
|
23
|
+
"x-nestia-encrypted": boolean;
|
24
|
+
}
|
25
|
+
type IResponseBody = Record<string, {
|
26
|
+
description: string;
|
27
|
+
content?: IContent;
|
28
|
+
"x-nestia-encrypted"?: boolean;
|
29
|
+
}>;
|
30
|
+
interface IContent {
|
31
|
+
"text/plain"?: {
|
32
|
+
schema: ISwaggerSchema.IString;
|
33
|
+
};
|
34
|
+
"application/json"?: {
|
35
|
+
schema: ISwaggerSchema;
|
36
|
+
};
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ISwaggerRoute.js","sourceRoot":"","sources":["../../src/structures/ISwaggerRoute.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
export type ISwaggerSecurity = ISwaggerSecurity.IHttpBasic | ISwaggerSecurity.IHttpBearer | ISwaggerSecurity.IApiKey | ISwaggerSecurity.IOpenId | ISwaggerSecurity.IOAuth2;
|
2
|
+
export declare namespace ISwaggerSecurity {
|
3
|
+
interface IHttpBasic {
|
4
|
+
type: "http";
|
5
|
+
schema: "basic";
|
6
|
+
}
|
7
|
+
interface IHttpBearer {
|
8
|
+
type: "http";
|
9
|
+
scheme: "bearer";
|
10
|
+
bearerFormat?: string;
|
11
|
+
}
|
12
|
+
interface IApiKey {
|
13
|
+
type: "apiKey";
|
14
|
+
in: "header" | "query" | "cookie";
|
15
|
+
name: string;
|
16
|
+
}
|
17
|
+
interface IOpenId {
|
18
|
+
type: "openIdConnect";
|
19
|
+
openIdConnectUrl: string;
|
20
|
+
}
|
21
|
+
interface IOAuth2 {
|
22
|
+
type: "oauth2";
|
23
|
+
flows: IOAuth2.IFlowSet;
|
24
|
+
description?: string;
|
25
|
+
}
|
26
|
+
namespace IOAuth2 {
|
27
|
+
interface IFlowSet {
|
28
|
+
authorizationCode?: IFlow;
|
29
|
+
implicit?: Omit<IFlow, "tokenUrl">;
|
30
|
+
password?: Omit<IFlow, "authorizationUrl">;
|
31
|
+
clientCredentials?: Omit<IFlow, "authorizationUrl">;
|
32
|
+
}
|
33
|
+
interface IFlow {
|
34
|
+
authorizationUrl: string;
|
35
|
+
tokenUrl: string;
|
36
|
+
refreshUrl: string;
|
37
|
+
scopes?: Record<string, string>;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ISwaggerSecurity.js","sourceRoot":"","sources":["../../src/structures/ISwaggerSecurity.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
16
|
+
const module_1 = require("../module");
|
17
|
+
const SetupWizard_1 = require("../utils/SetupWizard");
|
18
|
+
const INPUT = __dirname + "/../../assets/input";
|
19
|
+
const OUTPUT = __dirname + "/../../assets/output";
|
20
|
+
const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
21
|
+
if (fs_1.default.existsSync(OUTPUT))
|
22
|
+
yield fs_1.default.promises.rm(OUTPUT, { recursive: true });
|
23
|
+
yield fs_1.default.promises.mkdir(OUTPUT);
|
24
|
+
const directory = yield fs_1.default.promises.readdir(INPUT);
|
25
|
+
for (const file of directory) {
|
26
|
+
const location = `${INPUT}/${file}`;
|
27
|
+
if (!location.endsWith(".json"))
|
28
|
+
continue;
|
29
|
+
const swagger = JSON.parse(yield fs_1.default.promises.readFile(location, "utf8"));
|
30
|
+
const app = new module_1.NestiaMigrateApplication(swagger);
|
31
|
+
app.analyze();
|
32
|
+
const project = `${OUTPUT}/${file.replace(".json", "")}`;
|
33
|
+
yield fs_1.default.promises.mkdir(project);
|
34
|
+
yield app.generate({
|
35
|
+
mkdir: fs_1.default.promises.mkdir,
|
36
|
+
writeFile: (path, content) => fs_1.default.promises.writeFile(path, content, "utf8"),
|
37
|
+
})(project);
|
38
|
+
yield SetupWizard_1.SetupWizard.setup(project);
|
39
|
+
}
|
40
|
+
});
|
41
|
+
main().catch((exp) => {
|
42
|
+
console.error(exp);
|
43
|
+
process.exit(-1);
|
44
|
+
});
|
45
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,4CAAoB;AAEpB,sCAA+D;AAC/D,sDAAmD;AAEnD,MAAM,KAAK,GAAG,SAAS,GAAG,qBAAqB,CAAC;AAChD,MAAM,MAAM,GAAG,SAAS,GAAG,sBA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CAAC;KACpC;AACL,CAAC,CAAA,CAAC;AACF,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { ISwaggerSchema } from "../structures/ISwaggeSchema";
|
2
|
+
export declare namespace JsonTypeChecker {
|
3
|
+
const isAnyOf: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IAnyOf;
|
4
|
+
const isOneOf: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IOneOf;
|
5
|
+
const isBoolean: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IBoolean;
|
6
|
+
const isInteger: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IInteger;
|
7
|
+
const isNumber: (schema: ISwaggerSchema) => schema is ISwaggerSchema.INumber;
|
8
|
+
const isString: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IString;
|
9
|
+
const isArray: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IArray;
|
10
|
+
const isObject: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IObject;
|
11
|
+
const isReference: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IReference;
|
12
|
+
const isUnknown: (schema: ISwaggerSchema) => schema is ISwaggerSchema.IUnknown;
|
13
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.JsonTypeChecker = void 0;
|
4
|
+
var JsonTypeChecker;
|
5
|
+
(function (JsonTypeChecker) {
|
6
|
+
JsonTypeChecker.isAnyOf = (schema) => schema.anyOf !== undefined;
|
7
|
+
JsonTypeChecker.isOneOf = (schema) => schema.oneOf !== undefined;
|
8
|
+
JsonTypeChecker.isBoolean = (schema) => schema.type === "boolean";
|
9
|
+
JsonTypeChecker.isInteger = (schema) => schema.type === "integer";
|
10
|
+
JsonTypeChecker.isNumber = (schema) => schema.type === "number";
|
11
|
+
JsonTypeChecker.isString = (schema) => schema.type === "string";
|
12
|
+
JsonTypeChecker.isArray = (schema) => schema.type === "array";
|
13
|
+
JsonTypeChecker.isObject = (schema) => schema.type === "object";
|
14
|
+
JsonTypeChecker.isReference = (schema) => schema.$ref !== undefined;
|
15
|
+
JsonTypeChecker.isUnknown = (schema) => schema.type === undefined &&
|
16
|
+
!JsonTypeChecker.isAnyOf(schema) &&
|
17
|
+
!JsonTypeChecker.isOneOf(schema) &&
|
18
|
+
!JsonTypeChecker.isReference(schema);
|
19
|
+
})(JsonTypeChecker || (exports.JsonTypeChecker = JsonTypeChecker = {}));
|
20
|
+
//# sourceMappingURL=JsonTypeChecker.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"JsonTypeChecker.js","sourceRoot":"","sources":["../../src/utils/JsonTypeChecker.ts"],"names":[],"mappings":";;;AAEA,IAAiB,eAAe,CA6C/B;AA7CD,WAAiB,eAAe;IACf,uBAAO,GAAG,CACnB,MAAsB,EACS,EAAE,CAAE,MAAc,CAAC,KAAK,KAAK,SAAS,CAAC;IAE7D,uBAAO,GAAG,CACnB,MAAsB,EACS,EAAE,CAAE,MAAc,CAAC,KAAK,KAAK,SAAS,CAAC;IAE7D,yBAAS,GAAG,CACrB,MAAsB,EACW,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,SAAS,CAAC;IAE9D,yBAAS,GAAG,CACrB,MAAsB,EACW,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,SAAS,CAAC;IAE9D,wBAAQ,GAAG,CACpB,MAAsB,EACU,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,QAAQ,CAAC;IAE5D,wBAAQ,GAAG,CACpB,MAAsB,EACU,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,QAAQ,CAAC;IAE5D,uBAAO,GAAG,CACnB,MAAsB,EACS,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,OAAO,CAAC;IAE1D,wBAAQ,GAAG,CACpB,MAAsB,EACU,EAAE,CAAE,MAAc,CAAC,IAAI,KAAK,QAAQ,CAAC;IAE5D,2BAAW,GAAG,CACvB,MAAsB,EACa,EAAE,CACpC,MAAc,CAAC,IAAI,KAAK,SAAS,CAAC;IAE1B,yBAAS,GAAG,CACrB,MAAsB,EACW,EAAE,CAClC,MAAc,CAAC,IAAI,KAAK,SAAS;QAClC,CAAC,gBAAA,OAAO,CAAC,MAAM,CAAC;QAChB,CAAC,gBAAA,OAAO,CAAC,MAAM,CAAC;QAChB,CAAC,gBAAA,WAAW,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC,EA7CgB,eAAe,+BAAf,eAAe,QA6C/B"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MapUtil = void 0;
|
4
|
+
var MapUtil;
|
5
|
+
(function (MapUtil) {
|
6
|
+
MapUtil.take = (dict) => (key) => (generator) => {
|
7
|
+
const oldbie = dict.get(key);
|
8
|
+
if (oldbie)
|
9
|
+
return oldbie;
|
10
|
+
const value = generator();
|
11
|
+
dict.set(key, value);
|
12
|
+
return value;
|
13
|
+
};
|
14
|
+
})(MapUtil || (exports.MapUtil = MapUtil = {}));
|
15
|
+
//# sourceMappingURL=MapUtil.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MapUtil.js","sourceRoot":"","sources":["../../src/utils/MapUtil.ts"],"names":[],"mappings":";;;AAAA,IAAiB,OAAO,CAYvB;AAZD,WAAiB,OAAO;IACP,YAAI,GACb,CAAS,IAAiB,EAAE,EAAE,CAC9B,CAAC,GAAQ,EAAE,EAAE,CACb,CAAC,SAAkB,EAAK,EAAE;QACtB,MAAM,MAAM,GAAkB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAE1B,MAAM,KAAK,GAAM,SAAS,EAAE,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC;AACV,CAAC,EAZgB,OAAO,uBAAP,OAAO,QAYvB"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.SetupWizard = void 0;
|
7
|
+
const child_process_1 = __importDefault(require("child_process"));
|
8
|
+
var SetupWizard;
|
9
|
+
(function (SetupWizard) {
|
10
|
+
SetupWizard.setup = (output) => {
|
11
|
+
execute(output)("npm install");
|
12
|
+
execute(output)("npx nestia e2e", "npm run build:sdk");
|
13
|
+
execute(output)("npm run build:test");
|
14
|
+
execute(output)("npm run test");
|
15
|
+
};
|
16
|
+
const execute = (cwd) => (command, fake) => {
|
17
|
+
console.log(fake !== null && fake !== void 0 ? fake : command);
|
18
|
+
child_process_1.default.execSync(command, { cwd, stdio: "inherit" });
|
19
|
+
};
|
20
|
+
})(SetupWizard || (exports.SetupWizard = SetupWizard = {}));
|
21
|
+
//# sourceMappingURL=SetupWizard.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"SetupWizard.js","sourceRoot":"","sources":["../../src/utils/SetupWizard.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA+B;AAE/B,IAAiB,WAAW,CAY3B;AAZD,WAAiB,WAAW;IACX,iBAAK,GAAG,CAAC,MAAc,EAAE,EAAE;QACpC,OAAO,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC;QAC/B,OAAO,CAAC,MAAM,CAAC,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC;QACvD,OAAO,CAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,CAAC;QACtC,OAAO,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,CAAC;IACpC,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,OAAe,EAAE,IAAa,EAAE,EAAE;QAChE,OAAO,CAAC,GAAG,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,OAAO,CAAC,CAAC;QAC7B,uBAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACpD,CAAC,CAAC;AACN,CAAC,EAZgB,WAAW,2BAAX,WAAW,QAY3B"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export declare namespace StringUtil {
|
2
|
+
const capitalize: (str: string) => string;
|
3
|
+
const pascal: (path: string) => string;
|
4
|
+
const camel: (path: string) => string;
|
5
|
+
const split: (path: string) => string[];
|
6
|
+
const reJoinWithoutParameters: (path: string) => string;
|
7
|
+
const normalize: (str: string) => string;
|
8
|
+
const commonPrefix: (strs: string[]) => string;
|
9
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.StringUtil = void 0;
|
4
|
+
var StringUtil;
|
5
|
+
(function (StringUtil) {
|
6
|
+
StringUtil.capitalize = (str) => str[0].toUpperCase() + str.slice(1).toLowerCase();
|
7
|
+
StringUtil.pascal = (path) => StringUtil.split(path)
|
8
|
+
.filter((str) => str[0] !== "{")
|
9
|
+
.map(StringUtil.capitalize)
|
10
|
+
.join("");
|
11
|
+
StringUtil.camel = (path) => StringUtil.split(path)
|
12
|
+
.map((str, i) => (i === 0 ? str : StringUtil.capitalize(str)))
|
13
|
+
.join("");
|
14
|
+
StringUtil.split = (path) => path
|
15
|
+
.split("/")
|
16
|
+
.map((str) => StringUtil.normalize(str.trim()))
|
17
|
+
.filter((str) => !!str.length);
|
18
|
+
StringUtil.reJoinWithoutParameters = (path) => StringUtil.split(path)
|
19
|
+
.map((str) => str[0] === "{" && str[str.length - 1] === "}"
|
20
|
+
? `:${str.substring(1, str.length - 1)}`
|
21
|
+
: str)
|
22
|
+
.join("/");
|
23
|
+
StringUtil.normalize = (str) => str.split(".").join("_").split("-").join("_");
|
24
|
+
StringUtil.commonPrefix = (strs) => {
|
25
|
+
if (strs.length === 0)
|
26
|
+
return "";
|
27
|
+
let prefix = strs[0];
|
28
|
+
for (let i = 1; i < strs.length; i++) {
|
29
|
+
while (strs[i].indexOf(prefix) !== 0) {
|
30
|
+
prefix = prefix.substring(0, prefix.length - 1);
|
31
|
+
if (prefix === "")
|
32
|
+
return "";
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return prefix
|
36
|
+
.split("/")
|
37
|
+
.filter((str) => str[0] !== "{" || str[str.length - 1] === "}")
|
38
|
+
.join("/");
|
39
|
+
};
|
40
|
+
})(StringUtil || (exports.StringUtil = StringUtil = {}));
|
41
|
+
//# sourceMappingURL=StringUtil.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"StringUtil.js","sourceRoot":"","sources":["../../src/utils/StringUtil.ts"],"names":[],"mappings":";;;AAAA,IAAiB,UAAU,CAgD1B;AAhDD,WAAiB,UAAU;IACV,qBAAU,GAAG,CAAC,GAAW,EAAE,EAAE,CACtC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAEzC,iBAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CACnC,WAAA,KAAK,CAAC,IAAI,CAAC;SACN,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;SAC/B,GAAG,CAAC,WAAA,UAAU,CAAC;SACf,IAAI,CAAC,EAAE,CAAC,CAAC;IAEL,gBAAK,G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QAEjC,IAAI,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAClC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;gBAClC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAChD,IAAI,MAAM,KAAK,EAAE;oBAAE,OAAO,EAAE,CAAC;aAChC;SACJ;QACD,OAAO,MAAM;aACR,KAAK,CAAC,GAAG,CAAC;aACV,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC;aAC9D,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC,CAAC;AACN,CAAC,EAhDgB,UAAU,0BAAV,UAAU,QAgD1B"}
|
package/package.json
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
{
|
2
|
+
"name": "@nestia/migrate",
|
3
|
+
"version": "0.1.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
|
+
"dev": "npm run build -- --watch",
|
13
|
+
"prepare": "ts-patch install && ts-node src/executable/bundle.ts"
|
14
|
+
},
|
15
|
+
"repository": {
|
16
|
+
"type": "git",
|
17
|
+
"url": "https://github.com/samchon/nestia"
|
18
|
+
},
|
19
|
+
"keywords": [
|
20
|
+
"migration",
|
21
|
+
"swagger",
|
22
|
+
"NestJS",
|
23
|
+
"nestia"
|
24
|
+
],
|
25
|
+
"author": "Jeongho Nam",
|
26
|
+
"license": "MIT",
|
27
|
+
"bugs": {
|
28
|
+
"url": "https://github.com/samchon/nestia/issues"
|
29
|
+
},
|
30
|
+
"homepage": "https://github.com/samchon/nestia#readme",
|
31
|
+
"devDependencies": {
|
32
|
+
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
33
|
+
"@types/node": "^20.3.3",
|
34
|
+
"prettier": "^2.8.8",
|
35
|
+
"rimraf": "^5.0.1",
|
36
|
+
"ts-node": "^10.9.1",
|
37
|
+
"ts-patch": "^3.0.1",
|
38
|
+
"typescript": "^5.1.6"
|
39
|
+
},
|
40
|
+
"dependencies": {
|
41
|
+
"typia": "^4.1.3"
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module.exports = {
|
2
|
+
parser: "typescript",
|
3
|
+
printWidth: 80,
|
4
|
+
semi: true,
|
5
|
+
tabWidth: 4,
|
6
|
+
trailingComma: "all",
|
7
|
+
importOrder: [
|
8
|
+
"<THIRD_PARTY_MODULES>",
|
9
|
+
"typia(.*)$",
|
10
|
+
"^[./]",
|
11
|
+
],
|
12
|
+
importOrderSeparation: true,
|
13
|
+
importOrderSortSpecifiers: true,
|
14
|
+
importOrderParserPlugins: ["decorators-legacy", "typescript"],
|
15
|
+
};
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import typia from "typia";
|
2
|
+
|
3
|
+
import { FileArchiver } from "./archivers/FileArchiver";
|
4
|
+
import { TEMPLATE } from "./bundles/TEMPLATE";
|
5
|
+
import { MigrateProgrammer } from "./programmers/MigrateProgrammer";
|
6
|
+
import { IMigrateFile } from "./structures/IMigrateFile";
|
7
|
+
import { IMigrateProgram } from "./structures/IMigrateProgram";
|
8
|
+
import { ISwagger } from "./structures/ISwagger";
|
9
|
+
|
10
|
+
export class NestiaMigrateApplication {
|
11
|
+
public readonly swagger: ISwagger;
|
12
|
+
private program: IMigrateProgram | null;
|
13
|
+
private files: IMigrateFile[] | null;
|
14
|
+
|
15
|
+
public constructor(swagger: ISwagger) {
|
16
|
+
this.swagger = typia.assert(swagger);
|
17
|
+
this.program = null;
|
18
|
+
this.files = null;
|
19
|
+
}
|
20
|
+
|
21
|
+
public analyze(): IMigrateProgram {
|
22
|
+
if (this.program === null)
|
23
|
+
this.program = MigrateProgrammer.analyze(this.swagger);
|
24
|
+
return this.program;
|
25
|
+
}
|
26
|
+
|
27
|
+
public write(): IMigrateFile[] {
|
28
|
+
if (this.files === null) {
|
29
|
+
const program: IMigrateProgram = this.analyze();
|
30
|
+
this.files = MigrateProgrammer.write(program);
|
31
|
+
}
|
32
|
+
return this.files;
|
33
|
+
}
|
34
|
+
|
35
|
+
public generate =
|
36
|
+
(archiver: NestiaMigrateApplication.IArchiver) =>
|
37
|
+
async (output: string): Promise<void> => {
|
38
|
+
const program: IMigrateProgram = this.analyze();
|
39
|
+
const files: IMigrateFile[] = MigrateProgrammer.write(program);
|
40
|
+
await FileArchiver.archive(archiver)(output)([
|
41
|
+
...files,
|
42
|
+
...TEMPLATE,
|
43
|
+
]);
|
44
|
+
};
|
45
|
+
}
|
46
|
+
export namespace NestiaMigrateApplication {
|
47
|
+
export interface IArchiver {
|
48
|
+
mkdir: (path: string) => Promise<void>;
|
49
|
+
writeFile: (path: string, content: string) => Promise<void>;
|
50
|
+
}
|
51
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { IMigrateFile } from "../structures/IMigrateFile";
|
2
|
+
|
3
|
+
export namespace FileArchiver {
|
4
|
+
export interface IOperator {
|
5
|
+
mkdir(path: string): Promise<void>;
|
6
|
+
writeFile(path: string, content: string): Promise<void>;
|
7
|
+
}
|
8
|
+
|
9
|
+
export const archive =
|
10
|
+
(operator: IOperator) =>
|
11
|
+
(output: string) =>
|
12
|
+
async (files: IMigrateFile[]): Promise<void> => {
|
13
|
+
const visited: Set<string> = new Set();
|
14
|
+
for (const f of files) {
|
15
|
+
await mkdir(operator.mkdir)(output)(visited)(f.location);
|
16
|
+
await operator.writeFile(
|
17
|
+
[output, f.location, f.file].join("/"),
|
18
|
+
f.content,
|
19
|
+
);
|
20
|
+
}
|
21
|
+
};
|
22
|
+
|
23
|
+
const mkdir =
|
24
|
+
(creator: (path: string) => Promise<void>) =>
|
25
|
+
(output: string) =>
|
26
|
+
(visited: Set<string>) =>
|
27
|
+
async (path: string): Promise<void> => {
|
28
|
+
const sequence: string[] = path
|
29
|
+
.split("/")
|
30
|
+
.map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
|
31
|
+
for (const s of sequence)
|
32
|
+
if (visited.has(s) === false)
|
33
|
+
try {
|
34
|
+
await creator([output, s].join("/"));
|
35
|
+
visited.add(s);
|
36
|
+
} catch {}
|
37
|
+
};
|
38
|
+
}
|