@nestia/migrate 4.4.2 → 4.5.1

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.
Files changed (34) hide show
  1. package/lib/MigrateApplication.js +285 -269
  2. package/lib/MigrateApplication.js.map +1 -1
  3. package/lib/analyzers/{MigrateAnalyzer.d.ts → MigrateApplicationAnalyzer.d.ts} +1 -1
  4. package/lib/analyzers/MigrateApplicationAnalyzer.js +12 -0
  5. package/lib/analyzers/MigrateApplicationAnalyzer.js.map +1 -0
  6. package/lib/analyzers/MigrateControllerAnalyzer.d.ts +3 -1
  7. package/lib/analyzers/MigrateControllerAnalyzer.js +34 -24
  8. package/lib/analyzers/MigrateControllerAnalyzer.js.map +1 -1
  9. package/lib/bundles/NEST_TEMPLATE.js +2 -2
  10. package/lib/bundles/SDK_TEMPLATE.js +1 -1
  11. package/lib/index.mjs +335 -302
  12. package/lib/index.mjs.map +1 -1
  13. package/lib/module.d.ts +1 -1
  14. package/lib/module.js +1 -1
  15. package/lib/module.js.map +1 -1
  16. package/lib/programmers/MigrateNestControllerProgrammer.js +1 -1
  17. package/lib/programmers/MigrateNestControllerProgrammer.js.map +1 -1
  18. package/lib/programmers/MigrateNestMethodProgrammer.d.ts +2 -1
  19. package/lib/programmers/MigrateNestMethodProgrammer.js +14 -4
  20. package/lib/programmers/MigrateNestMethodProgrammer.js.map +1 -1
  21. package/lib/programmers/MigrateNestProgrammer.js +3 -1
  22. package/lib/programmers/MigrateNestProgrammer.js.map +1 -1
  23. package/package.json +4 -4
  24. package/src/MigrateApplication.ts +3 -3
  25. package/src/analyzers/{MigrateAnalyzer.ts → MigrateApplicationAnalyzer.ts} +1 -1
  26. package/src/analyzers/MigrateControllerAnalyzer.ts +41 -30
  27. package/src/bundles/NEST_TEMPLATE.ts +2 -2
  28. package/src/bundles/SDK_TEMPLATE.ts +1 -1
  29. package/src/module.ts +1 -1
  30. package/src/programmers/MigrateNestControllerProgrammer.ts +1 -1
  31. package/src/programmers/MigrateNestMethodProgrammer.ts +24 -2
  32. package/src/programmers/MigrateNestProgrammer.ts +3 -1
  33. package/lib/analyzers/MigrateAnalyzer.js +0 -12
  34. package/lib/analyzers/MigrateAnalyzer.js.map +0 -1
@@ -5,36 +5,47 @@ import { MapUtil } from "../utils/MapUtil";
5
5
  import { StringUtil } from "../utils/StringUtil";
6
6
 
7
7
  export namespace MigrateControllerAnalyzer {
8
- export const analyze = (
9
- routes: IHttpMigrateRoute[],
10
- ): IHttpMigrateController[] => {
11
- const endpoints: Map<string, IHttpMigrateRoute[]> = new Map();
12
- for (const r of routes) {
13
- const location: string = r.emendedPath
14
- .split("/")
15
- .filter((s) => s[0] !== ":")
16
- .join("/");
17
- MapUtil.take(endpoints)(location)(() => []).push(r);
18
- }
19
- const total: IHttpMigrateController[] = [...endpoints.entries()]
20
- .filter(([_l, routes]) => !!routes.length)
21
- .map(([path, routes]) => {
22
- const name: string =
23
- routes[0].accessor.slice(0, -1).map(StringUtil.capitalize).join("") +
8
+ export const analyze = (props: {
9
+ routes: IHttpMigrateRoute[];
10
+ }): IHttpMigrateController[] => {
11
+ const collection: Map<string, IHttpMigrateController> = new Map();
12
+ for (const route of props.routes) {
13
+ const name: string =
14
+ route.operation()["x-samchon-controller"] ??
15
+ (route.accessor.length <= 1
16
+ ? "__App"
17
+ : route.accessor.slice(0, -1).map(StringUtil.capitalize).join("")) +
24
18
  "Controller";
25
- const location: string = routes[0].accessor.slice(0, -2).join("/");
26
- return {
27
- name,
28
- path,
29
- location: "src/controllers/" + location,
30
- routes,
31
- };
32
- });
33
- for (const c of total)
34
- if (c.name === "Controller")
35
- c.name = StringUtil.escapeDuplicate([...total.map((c) => c.name)])(
36
- "AppController",
37
- );
38
- return total;
19
+ MapUtil.take(collection)(name)(() => ({
20
+ name,
21
+ path: "@lazy",
22
+ location: "@lazy",
23
+ routes: [],
24
+ })).routes.push(route);
25
+ }
26
+
27
+ const controllers: IHttpMigrateController[] = [...collection.values()];
28
+ for (const col of controllers) {
29
+ const splitPath = (r: IHttpMigrateRoute): string[] =>
30
+ r.emendedPath.split("/");
31
+ const splitLocation = (r: IHttpMigrateRoute): string[] =>
32
+ splitPath(r).filter((s) => s[0] !== ":");
33
+
34
+ const minPath: string[] = splitPath(col.routes[0]);
35
+ const minLocation: string[] = splitLocation(col.routes[0]);
36
+ for (const r of col.routes.slice(1)) {
37
+ minPath.splice(getSplitIndex(minPath, splitPath(r)));
38
+ minLocation.splice(getSplitIndex(minLocation, splitLocation(r)));
39
+ }
40
+ col.path = minPath.join("/");
41
+ col.location = "src/controllers/" + minLocation.join("/");
42
+ }
43
+ return controllers;
39
44
  };
40
45
  }
46
+
47
+ const getSplitIndex = (x: string[], y: string[]) => {
48
+ const n: number = Math.min(x.length, y.length);
49
+ for (let i: number = 0; i < n; ++i) if (x[i] !== y[i]) return i;
50
+ return n;
51
+ };
@@ -57,7 +57,7 @@ export const NEST_TEMPLATE = [
57
57
  {
58
58
  "location": "",
59
59
  "file": "package.json",
60
- "content": "{\n \"private\": true,\n \"name\": \"@ORGANIZATION/PROJECT\",\n \"version\": \"0.1.0\",\n \"description\": \"Starter kit of Nestia\",\n \"main\": \"lib/index.js\",\n \"scripts\": {\n \"benchmark\": \"node bin/test/benchmark\",\n \"test\": \"node bin/test\",\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------BUILDS------------------------\": \"\",\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\n \"build:api\": \"rimraf packages/api/lib && nestia all && rimraf packages/api/lib && tsc -p packages/api/tsconfig.json && rollup -c packages/api/rollup.config.js\",\n \"build:main\": \"rimraf lib && tsc\",\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\n \"build:swagger\": \"npx nestia swagger\",\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\n \"dev\": \"npm run build:test -- --watch\",\n \"eslint\": \"eslint src && eslint test\",\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\n \"prepare\": \"ts-patch install && typia patch\",\n \"prettier\": \"prettier src --write && prettier test --write\",\n \"------------------------WEBPACK------------------------\": \"\",\n \"webpack\": \"rimraf dist && webpack\",\n \"webpack:start\": \"cd dist && node dist/server\",\n \"webpack:test\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------DEPLOYS------------------------\": \"\",\n \"package:api\": \"npm run build:api && cd packages/api && npm publish\",\n \"start\": \"node lib/executable/server\",\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia-start\"\n },\n \"keywords\": [\n \"nestia\",\n \"template\",\n \"boilerplate\"\n ],\n \"author\": \"AUTHOR\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\n },\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\n \"devDependencies\": {\n \"@nestia/benchmark\": \"^0.3.0\",\n \"@nestia/e2e\": \"^0.7.0\",\n \"@nestia/sdk\": \"^4.4.2\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^11.1.6\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/cli\": \"^0.11.21\",\n \"@types/cli-progress\": \"^3.11.5\",\n \"@types/express\": \"^4.17.21\",\n \"@types/inquirer\": \"^8.2.5\",\n \"@types/node\": \"^18.11.0\",\n \"@types/uuid\": \"^8.3.4\",\n \"@typescript-eslint/eslint-plugin\": \"^8.1.0\",\n \"@typescript-eslint/parser\": \"^8.1.0\",\n \"chalk\": \"^4.1.2\",\n \"cli\": \"^1.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"copy-webpack-plugin\": \"^11.0.0\",\n \"eslint-plugin-deprecation\": \"^3.0.0\",\n \"express\": \"^4.18.2\",\n \"nestia\": \"^6.3.1\",\n \"prettier\": \"^3.2.4\",\n \"prettier-plugin-prisma\": \"^5.0.0\",\n \"rimraf\": \"^3.0.2\",\n \"rollup\": \"^4.18.0\",\n \"source-map-support\": \"^0.5.21\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"ts-loader\": \"^9.5.1\",\n \"ts-node\": \"^10.9.1\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.7.2\",\n \"typescript-transform-paths\": \"^3.5.2\",\n \"webpack\": \"^5.89.0\",\n \"webpack-cli\": \"^5.1.4\",\n \"write-file-webpack-plugin\": \"^4.5.1\"\n },\n \"dependencies\": {\n \"@nestia/core\": \"^4.4.2\",\n \"@nestia/fetcher\": \"^4.4.2\",\n \"@nestjs/common\": \"^10.4.15\",\n \"@nestjs/core\": \"^10.4.15\",\n \"@nestjs/platform-express\": \"^10.4.15\",\n \"commander\": \"10.0.0\",\n \"dotenv\": \"^16.3.1\",\n \"dotenv-expand\": \"^10.0.0\",\n \"inquirer\": \"8.2.5\",\n \"serialize-error\": \"^4.1.0\",\n \"tgrid\": \"^1.0.2\",\n \"tstl\": \"^3.0.0\",\n \"typia\": \"^7.4.1\",\n \"uuid\": \"^9.0.0\"\n },\n \"stackblitz\": {\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test\"\n }\n}"
60
+ "content": "{\n \"private\": true,\n \"name\": \"@ORGANIZATION/PROJECT\",\n \"version\": \"0.1.0\",\n \"description\": \"Starter kit of Nestia\",\n \"main\": \"lib/index.js\",\n \"scripts\": {\n \"benchmark\": \"node bin/test/benchmark\",\n \"test\": \"node bin/test\",\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------BUILDS------------------------\": \"\",\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\n \"build:api\": \"rimraf packages/api/lib && nestia all && rimraf packages/api/lib && tsc -p packages/api/tsconfig.json && rollup -c packages/api/rollup.config.js\",\n \"build:main\": \"rimraf lib && tsc\",\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\n \"build:swagger\": \"npx nestia swagger\",\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\n \"dev\": \"npm run build:test -- --watch\",\n \"eslint\": \"eslint src && eslint test\",\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\n \"prepare\": \"ts-patch install && typia patch\",\n \"prettier\": \"prettier src --write && prettier test --write\",\n \"------------------------WEBPACK------------------------\": \"\",\n \"webpack\": \"rimraf dist && webpack\",\n \"webpack:start\": \"cd dist && node dist/server\",\n \"webpack:test\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------DEPLOYS------------------------\": \"\",\n \"package:api\": \"npm run build:api && cd packages/api && npm publish\",\n \"start\": \"node lib/executable/server\",\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia-start\"\n },\n \"keywords\": [\n \"nestia\",\n \"template\",\n \"boilerplate\"\n ],\n \"author\": \"AUTHOR\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\n },\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\n \"devDependencies\": {\n \"@nestia/benchmark\": \"^0.3.0\",\n \"@nestia/e2e\": \"^0.7.0\",\n \"@nestia/sdk\": \"^4.5.1\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^11.1.6\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/cli\": \"^0.11.21\",\n \"@types/cli-progress\": \"^3.11.5\",\n \"@types/express\": \"^4.17.21\",\n \"@types/inquirer\": \"^8.2.5\",\n \"@types/node\": \"^18.11.0\",\n \"@types/uuid\": \"^8.3.4\",\n \"@typescript-eslint/eslint-plugin\": \"^8.1.0\",\n \"@typescript-eslint/parser\": \"^8.1.0\",\n \"chalk\": \"^4.1.2\",\n \"cli\": \"^1.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"copy-webpack-plugin\": \"^11.0.0\",\n \"eslint-plugin-deprecation\": \"^3.0.0\",\n \"express\": \"^4.18.2\",\n \"nestia\": \"^6.3.1\",\n \"prettier\": \"^3.2.4\",\n \"prettier-plugin-prisma\": \"^5.0.0\",\n \"rimraf\": \"^3.0.2\",\n \"rollup\": \"^4.18.0\",\n \"source-map-support\": \"^0.5.21\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"ts-loader\": \"^9.5.1\",\n \"ts-node\": \"^10.9.1\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.7.2\",\n \"typescript-transform-paths\": \"^3.5.2\",\n \"webpack\": \"^5.89.0\",\n \"webpack-cli\": \"^5.1.4\",\n \"write-file-webpack-plugin\": \"^4.5.1\"\n },\n \"dependencies\": {\n \"@nestia/core\": \"^4.5.1\",\n \"@nestia/fetcher\": \"^4.5.1\",\n \"@nestjs/common\": \"^10.4.15\",\n \"@nestjs/core\": \"^10.4.15\",\n \"@nestjs/platform-express\": \"^10.4.15\",\n \"commander\": \"10.0.0\",\n \"dotenv\": \"^16.3.1\",\n \"dotenv-expand\": \"^10.0.0\",\n \"inquirer\": \"8.2.5\",\n \"serialize-error\": \"^4.1.0\",\n \"tgrid\": \"^1.0.2\",\n \"tstl\": \"^3.0.0\",\n \"typia\": \"^7.5.0\",\n \"uuid\": \"^9.0.0\"\n },\n \"stackblitz\": {\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test\"\n }\n}"
61
61
  },
62
62
  {
63
63
  "location": "packages/api",
@@ -77,7 +77,7 @@ export const NEST_TEMPLATE = [
77
77
  {
78
78
  "location": "packages/api",
79
79
  "file": "package.json",
80
- "content": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"lib/index.js\",\n \"module\": \"lib/index.mjs\",\n \"typings\": \"lib/index.d.ts\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia\"\n },\n \"author\": \"Jeongho Nam\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia/issues\"\n },\n \"homepage\": \"https://nestia.io\",\n \"files\": [\n \"lib\",\n \"package.json\",\n \"swagger.json\",\n \"openai.json\",\n \"README.md\"\n ],\n \"dependencies\": {\n \"@nestia/fetcher\": \"^4.4.2\",\n \"tgrid\": \"^1.1.0\",\n \"typia\": \"^7.4.1\"\n }\n}"
80
+ "content": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"lib/index.js\",\n \"module\": \"lib/index.mjs\",\n \"typings\": \"lib/index.d.ts\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia\"\n },\n \"author\": \"Jeongho Nam\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia/issues\"\n },\n \"homepage\": \"https://nestia.io\",\n \"files\": [\n \"lib\",\n \"package.json\",\n \"swagger.json\",\n \"openai.json\",\n \"README.md\"\n ],\n \"dependencies\": {\n \"@nestia/fetcher\": \"^4.5.1\",\n \"tgrid\": \"^1.1.0\",\n \"typia\": \"^7.5.0\"\n }\n}"
81
81
  },
82
82
  {
83
83
  "location": "packages/api",
@@ -32,7 +32,7 @@ export const SDK_TEMPLATE = [
32
32
  {
33
33
  "location": "",
34
34
  "file": "package.json",
35
- "content": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"lib/index.js\",\n \"module\": \"lib/index.mjs\",\n \"typings\": \"lib/index.d.ts\",\n \"scripts\": {\n \"build\": \"rimraf lib && tsc && rollup -c\",\n \"build:test\": \"rimraf bin && tsc --project test/tsconfig.json\",\n \"deploy\": \"npm run build && npm publish\",\n \"dev\": \"npm run build:test -- --watch\",\n \"hello\": \"node hello\",\n \"prepare\": \"ts-patch install && typia patch\",\n \"start\": \"ts-node test/start.ts\",\n \"swagger\": \"ts-node test/swagger.ts\",\n \"test\": \"ts-node test/index.ts\",\n \"test:simulate\": \"ts-node test/index.ts --simulate true\",\n \"test:manual\": \"ts-node test/manual.ts\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia\"\n },\n \"author\": \"Jeongho Nam\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia/issues\"\n },\n \"homepage\": \"https://nestia.io\",\n \"files\": [\n \"lib\",\n \"swagger.json\",\n \"package.json\",\n \"README.md\"\n ],\n \"dependencies\": {\n \"@nestia/fetcher\": \"^4.4.2\",\n \"tgrid\": \"^1.1.0\",\n \"typia\": \"^7.4.1\"\n },\n \"devDependencies\": {\n \"@nestia/e2e\": \"^0.7.0\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^11.1.6\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/express\": \"^4.17.21\",\n \"@types/inquirer\": \"8.2.5\",\n \"@types/swagger-ui-express\": \"^4.1.6\",\n \"chalk\": \"4.1.2\",\n \"commander\": \"^10.0.0\",\n \"express\": \"^4.19.2\",\n \"inquirer\": \"8.2.5\",\n \"prettier\": \"^3.2.5\",\n \"rimraf\": \"^5.0.5\",\n \"rollup\": \"^4.13.2\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"ts-node\": \"^10.9.2\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.7.2\",\n \"typescript-transform-paths\": \"^3.5.2\"\n }\n}"
35
+ "content": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"lib/index.js\",\n \"module\": \"lib/index.mjs\",\n \"typings\": \"lib/index.d.ts\",\n \"scripts\": {\n \"build\": \"rimraf lib && tsc && rollup -c\",\n \"build:test\": \"rimraf bin && tsc --project test/tsconfig.json\",\n \"deploy\": \"npm run build && npm publish\",\n \"dev\": \"npm run build:test -- --watch\",\n \"hello\": \"node hello\",\n \"prepare\": \"ts-patch install && typia patch\",\n \"start\": \"ts-node test/start.ts\",\n \"swagger\": \"ts-node test/swagger.ts\",\n \"test\": \"ts-node test/index.ts\",\n \"test:simulate\": \"ts-node test/index.ts --simulate true\",\n \"test:manual\": \"ts-node test/manual.ts\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia\"\n },\n \"author\": \"Jeongho Nam\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia/issues\"\n },\n \"homepage\": \"https://nestia.io\",\n \"files\": [\n \"lib\",\n \"swagger.json\",\n \"package.json\",\n \"README.md\"\n ],\n \"dependencies\": {\n \"@nestia/fetcher\": \"^4.5.1\",\n \"tgrid\": \"^1.1.0\",\n \"typia\": \"^7.5.0\"\n },\n \"devDependencies\": {\n \"@nestia/e2e\": \"^0.7.0\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^11.1.6\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/express\": \"^4.17.21\",\n \"@types/inquirer\": \"8.2.5\",\n \"@types/swagger-ui-express\": \"^4.1.6\",\n \"chalk\": \"4.1.2\",\n \"commander\": \"^10.0.0\",\n \"express\": \"^4.19.2\",\n \"inquirer\": \"8.2.5\",\n \"prettier\": \"^3.2.5\",\n \"rimraf\": \"^5.0.5\",\n \"rollup\": \"^4.13.2\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"ts-node\": \"^10.9.2\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.7.2\",\n \"typescript-transform-paths\": \"^3.5.2\"\n }\n}"
36
36
  },
37
37
  {
38
38
  "location": "",
package/src/module.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from "./MigrateApplication";
2
2
 
3
- export * from "./analyzers/MigrateAnalyzer";
3
+ export * from "./analyzers/MigrateApplicationAnalyzer";
4
4
 
5
5
  export * from "./archivers/MigrateFileArchiver";
6
6
 
@@ -33,7 +33,7 @@ export namespace MigrateNestControllerProgrammer {
33
33
  [],
34
34
  [],
35
35
  controller.routes.map(
36
- MigrateNestMethodProgrammer.write(components)(importer),
36
+ MigrateNestMethodProgrammer.write(components)(importer)(controller),
37
37
  ),
38
38
  );
39
39
  return [
@@ -5,6 +5,7 @@ import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
5
5
  import { LiteralFactory } from "typia/lib/factories/LiteralFactory";
6
6
  import { TypeFactory } from "typia/lib/factories/TypeFactory";
7
7
 
8
+ import { IHttpMigrateController } from "../structures/IHttpMigrateController";
8
9
  import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute";
9
10
  import { FilePrinter } from "../utils/FilePrinter";
10
11
  import { StringUtil } from "../utils/StringUtil";
@@ -15,6 +16,7 @@ export namespace MigrateNestMethodProgrammer {
15
16
  export const write =
16
17
  (components: OpenApi.IComponents) =>
17
18
  (importer: MigrateImportProgrammer) =>
19
+ (controller: IHttpMigrateController) =>
18
20
  (route: IHttpMigrateRoute): ts.MethodDeclaration => {
19
21
  const output: ts.TypeNode = route.success
20
22
  ? MigrateSchemaProgrammer.write(components)(importer)(
@@ -24,7 +26,7 @@ export namespace MigrateNestMethodProgrammer {
24
26
 
25
27
  const method: ts.MethodDeclaration = ts.factory.createMethodDeclaration(
26
28
  [
27
- ...writeMethodDecorators(components)(importer)(route),
29
+ ...writeMethodDecorators(components)(importer)(controller)(route),
28
30
  ts.factory.createToken(ts.SyntaxKind.PublicKeyword),
29
31
  ts.factory.createToken(ts.SyntaxKind.AsyncKeyword),
30
32
  ],
@@ -78,6 +80,7 @@ export namespace MigrateNestMethodProgrammer {
78
80
  const writeMethodDecorators =
79
81
  (components: OpenApi.IComponents) =>
80
82
  (importer: MigrateImportProgrammer) =>
83
+ (controller: IHttpMigrateController) =>
81
84
  (route: IHttpMigrateRoute): ts.Decorator[] => {
82
85
  const external =
83
86
  (lib: string) =>
@@ -99,7 +102,24 @@ export namespace MigrateNestMethodProgrammer {
99
102
  ),
100
103
  );
101
104
 
105
+ // HUMAN-ONLY
106
+ if (route.operation()["x-samchon-human"] === true)
107
+ decorators.push(
108
+ ts.factory.createDecorator(
109
+ ts.factory.createCallExpression(
110
+ external("@nestia/core")("HumanRoute"),
111
+ undefined,
112
+ undefined,
113
+ ),
114
+ ),
115
+ );
116
+
102
117
  // ROUTER
118
+ const localPath: string = route.emendedPath
119
+ .slice(controller.path.length)
120
+ .split("/")
121
+ .filter((str) => !!str.length)
122
+ .join("/");
103
123
  const router = (instance: string) =>
104
124
  ts.factory.createDecorator(
105
125
  ts.factory.createCallExpression(
@@ -108,7 +128,9 @@ export namespace MigrateNestMethodProgrammer {
108
128
  StringUtil.capitalize(route.method),
109
129
  ),
110
130
  [],
111
- [ts.factory.createStringLiteral(route.path)],
131
+ localPath.length
132
+ ? [ts.factory.createStringLiteral(localPath)]
133
+ : undefined,
112
134
  ),
113
135
  );
114
136
  if (route.success?.["x-nestia-encrypted"])
@@ -13,7 +13,9 @@ import { MigrateNestModuleProgrammer } from "./MigrateNestModuleProgrammer";
13
13
  export namespace MigrateNestProgrammer {
14
14
  export const write = (program: IHttpMigrateProgram): IHttpMigrateFile[] => {
15
15
  const controllers: IHttpMigrateController[] =
16
- MigrateControllerAnalyzer.analyze(program.routes);
16
+ MigrateControllerAnalyzer.analyze({
17
+ routes: program.routes,
18
+ });
17
19
  return [
18
20
  {
19
21
  location: "src",
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MigrateAnalyzer = void 0;
4
- const openapi_1 = require("@samchon/openapi");
5
- var MigrateAnalyzer;
6
- (function (MigrateAnalyzer) {
7
- MigrateAnalyzer.analyze = (props) => {
8
- const application = openapi_1.HttpMigration.application(props.document);
9
- return Object.assign(Object.assign({}, props), { routes: application.routes, errors: application.errors });
10
- };
11
- })(MigrateAnalyzer || (exports.MigrateAnalyzer = MigrateAnalyzer = {}));
12
- //# sourceMappingURL=MigrateAnalyzer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MigrateAnalyzer.js","sourceRoot":"","sources":["../../src/analyzers/MigrateAnalyzer.ts"],"names":[],"mappings":";;;AAAA,8CAA0E;AAI1E,IAAiB,eAAe,CAa/B;AAbD,WAAiB,eAAe;IACjB,uBAAO,GAAG,CACrB,KAAiC,EACZ,EAAE;QACvB,MAAM,WAAW,GAA4B,uBAAa,CAAC,WAAW,CACpE,KAAK,CAAC,QAAQ,CACf,CAAC;QACF,uCACK,KAAK,KACR,MAAM,EAAE,WAAW,CAAC,MAAM,EAC1B,MAAM,EAAE,WAAW,CAAC,MAAM,IAC1B;IACJ,CAAC,CAAC;AACJ,CAAC,EAbgB,eAAe,+BAAf,eAAe,QAa/B"}