@nestia/migrate 11.0.0-dev.20260312 → 11.0.0-dev.20260313

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 (136) hide show
  1. package/package.json +5 -5
  2. package/src/NestiaMigrateApplication.ts +4 -1
  3. package/src/archivers/NestiaMigrateFileArchiver.ts +28 -28
  4. package/src/bundles/NEST_TEMPLATE.ts +1 -1
  5. package/src/bundles/SDK_TEMPLATE.ts +1 -1
  6. package/src/executable/migrate.ts +7 -7
  7. package/src/index.ts +4 -4
  8. package/src/programmers/NestiaMigrateApiProgrammer.ts +107 -107
  9. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +65 -65
  10. package/src/programmers/NestiaMigrateNestProgrammer.ts +88 -88
  11. package/src/structures/INestiaMigrateConfig.ts +19 -19
  12. package/src/structures/INestiaMigrateFile.ts +5 -5
  13. package/src/structures/INestiaMigrateSchema.ts +4 -4
  14. package/src/utils/MapUtil.ts +13 -13
  15. package/src/utils/SetupWizard.ts +12 -12
  16. package/src/utils/openapi-down-convert/RefVisitor.ts +134 -134
  17. package/src/utils/openapi-down-convert/converter.ts +536 -536
  18. package/lib/NestiaMigrateApplication.d.ts +0 -24
  19. package/lib/NestiaMigrateApplication.js +0 -21136
  20. package/lib/NestiaMigrateApplication.js.map +0 -1
  21. package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +0 -5
  22. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +0 -46
  23. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +0 -1
  24. package/lib/archivers/NestiaMigrateFileArchiver.d.ts +0 -8
  25. package/lib/archivers/NestiaMigrateFileArchiver.js +0 -36
  26. package/lib/archivers/NestiaMigrateFileArchiver.js.map +0 -1
  27. package/lib/bundles/NEST_TEMPLATE.d.ts +0 -1
  28. package/lib/bundles/NEST_TEMPLATE.js +0 -55
  29. package/lib/bundles/NEST_TEMPLATE.js.map +0 -1
  30. package/lib/bundles/SDK_TEMPLATE.d.ts +0 -1
  31. package/lib/bundles/SDK_TEMPLATE.js +0 -27
  32. package/lib/bundles/SDK_TEMPLATE.js.map +0 -1
  33. package/lib/executable/NestiaMigrateCommander.d.ts +0 -4
  34. package/lib/executable/NestiaMigrateCommander.js +0 -125
  35. package/lib/executable/NestiaMigrateCommander.js.map +0 -1
  36. package/lib/executable/NestiaMigrateInquirer.d.ts +0 -12
  37. package/lib/executable/NestiaMigrateInquirer.js +0 -91
  38. package/lib/executable/NestiaMigrateInquirer.js.map +0 -1
  39. package/lib/executable/migrate.d.ts +0 -2
  40. package/lib/executable/migrate.js +0 -9
  41. package/lib/executable/migrate.js.map +0 -1
  42. package/lib/factories/TypeLiteralFactory.d.ts +0 -4
  43. package/lib/factories/TypeLiteralFactory.js +0 -35
  44. package/lib/factories/TypeLiteralFactory.js.map +0 -1
  45. package/lib/index.d.ts +0 -3
  46. package/lib/index.js +0 -42
  47. package/lib/index.js.map +0 -1
  48. package/lib/index.mjs +0 -21834
  49. package/lib/index.mjs.map +0 -1
  50. package/lib/module.d.ts +0 -5
  51. package/lib/module.js +0 -22
  52. package/lib/module.js.map +0 -1
  53. package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +0 -13
  54. package/lib/programmers/NestiaMigrateApiFileProgrammer.js +0 -40
  55. package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +0 -1
  56. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +0 -14
  57. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +0 -180
  58. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +0 -1
  59. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +0 -15
  60. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +0 -223
  61. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +0 -1
  62. package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +0 -4
  63. package/lib/programmers/NestiaMigrateApiProgrammer.js +0 -82
  64. package/lib/programmers/NestiaMigrateApiProgrammer.js.map +0 -1
  65. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +0 -15
  66. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +0 -140
  67. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +0 -1
  68. package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +0 -4
  69. package/lib/programmers/NestiaMigrateApiStartProgrammer.js +0 -79
  70. package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +0 -1
  71. package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +0 -15
  72. package/lib/programmers/NestiaMigrateDtoProgrammer.js +0 -65
  73. package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +0 -1
  74. package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +0 -15
  75. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +0 -80
  76. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +0 -1
  77. package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +0 -4
  78. package/lib/programmers/NestiaMigrateE2eProgrammer.js +0 -32
  79. package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +0 -1
  80. package/lib/programmers/NestiaMigrateImportProgrammer.d.ts +0 -18
  81. package/lib/programmers/NestiaMigrateImportProgrammer.js +0 -65
  82. package/lib/programmers/NestiaMigrateImportProgrammer.js.map +0 -1
  83. package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +0 -12
  84. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +0 -46
  85. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +0 -1
  86. package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +0 -16
  87. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +0 -221
  88. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +0 -1
  89. package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +0 -5
  90. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +0 -29
  91. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +0 -1
  92. package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +0 -4
  93. package/lib/programmers/NestiaMigrateNestProgrammer.js +0 -65
  94. package/lib/programmers/NestiaMigrateNestProgrammer.js.map +0 -1
  95. package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +0 -10
  96. package/lib/programmers/NestiaMigrateSchemaProgrammer.js +0 -339
  97. package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +0 -1
  98. package/lib/structures/INestiaMigrateConfig.d.ts +0 -15
  99. package/lib/structures/INestiaMigrateConfig.js +0 -3
  100. package/lib/structures/INestiaMigrateConfig.js.map +0 -1
  101. package/lib/structures/INestiaMigrateContext.d.ts +0 -7
  102. package/lib/structures/INestiaMigrateContext.js +0 -3
  103. package/lib/structures/INestiaMigrateContext.js.map +0 -1
  104. package/lib/structures/INestiaMigrateController.d.ts +0 -7
  105. package/lib/structures/INestiaMigrateController.js +0 -3
  106. package/lib/structures/INestiaMigrateController.js.map +0 -1
  107. package/lib/structures/INestiaMigrateDto.d.ts +0 -7
  108. package/lib/structures/INestiaMigrateDto.js +0 -3
  109. package/lib/structures/INestiaMigrateDto.js.map +0 -1
  110. package/lib/structures/INestiaMigrateFile.d.ts +0 -5
  111. package/lib/structures/INestiaMigrateFile.js +0 -3
  112. package/lib/structures/INestiaMigrateFile.js.map +0 -1
  113. package/lib/structures/INestiaMigrateProgram.d.ts +0 -9
  114. package/lib/structures/INestiaMigrateProgram.js +0 -3
  115. package/lib/structures/INestiaMigrateProgram.js.map +0 -1
  116. package/lib/structures/INestiaMigrateSchema.d.ts +0 -4
  117. package/lib/structures/INestiaMigrateSchema.js +0 -3
  118. package/lib/structures/INestiaMigrateSchema.js.map +0 -1
  119. package/lib/utils/FilePrinter.d.ts +0 -9
  120. package/lib/utils/FilePrinter.js +0 -35
  121. package/lib/utils/FilePrinter.js.map +0 -1
  122. package/lib/utils/MapUtil.d.ts +0 -3
  123. package/lib/utils/MapUtil.js +0 -15
  124. package/lib/utils/MapUtil.js.map +0 -1
  125. package/lib/utils/SetupWizard.d.ts +0 -3
  126. package/lib/utils/SetupWizard.js +0 -18
  127. package/lib/utils/SetupWizard.js.map +0 -1
  128. package/lib/utils/StringUtil.d.ts +0 -6
  129. package/lib/utils/StringUtil.js +0 -108
  130. package/lib/utils/StringUtil.js.map +0 -1
  131. package/lib/utils/openapi-down-convert/RefVisitor.d.ts +0 -52
  132. package/lib/utils/openapi-down-convert/RefVisitor.js +0 -102
  133. package/lib/utils/openapi-down-convert/RefVisitor.js.map +0 -1
  134. package/lib/utils/openapi-down-convert/converter.d.ts +0 -146
  135. package/lib/utils/openapi-down-convert/converter.js +0 -441
  136. package/lib/utils/openapi-down-convert/converter.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestia/migrate",
3
- "version": "11.0.0-dev.20260312",
3
+ "version": "11.0.0-dev.20260313",
4
4
  "description": "Migration program from swagger to NestJS",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -44,16 +44,16 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@trivago/prettier-plugin-sort-imports": "^4.3.0",
47
- "@typia/core": "12.0.0-dev.20260312-2",
48
- "@typia/interface": "12.0.0-dev.20260312-2",
49
- "@typia/utils": "12.0.0-dev.20260312-2",
47
+ "@typia/core": "12.0.0-dev.20260313",
48
+ "@typia/interface": "12.0.0-dev.20260313",
49
+ "@typia/utils": "12.0.0-dev.20260313",
50
50
  "commander": "10.0.0",
51
51
  "inquirer": "8.2.5",
52
52
  "prettier": "^3.8.1",
53
53
  "prettier-plugin-jsdoc": "^1.8.0",
54
54
  "tstl": "^3.0.0",
55
55
  "typescript": "~5.9.3",
56
- "typia": "12.0.0-dev.20260312-2"
56
+ "typia": "12.0.0-dev.20260313"
57
57
  },
58
58
  "files": [
59
59
  "lib",
@@ -147,7 +147,10 @@ const createContext = (
147
147
  ): INestiaMigrateContext => {
148
148
  return {
149
149
  mode,
150
- application,
150
+ application: {
151
+ ...application,
152
+ routes: application.routes.filter((r) => r.method !== "query"),
153
+ },
151
154
  config,
152
155
  };
153
156
  };
@@ -1,28 +1,28 @@
1
- import { VariadicSingleton } from "tstl";
2
-
3
- export namespace NestiaMigrateFileArchiver {
4
- export const archive = async (props: {
5
- mkdir: (path: string) => Promise<void>;
6
- writeFile: (path: string, content: string) => Promise<void>;
7
- root: string;
8
- files: Record<string, string>;
9
- }): Promise<void> => {
10
- const mkdir = new VariadicSingleton(
11
- async (location: string): Promise<void> => {
12
- try {
13
- await props.mkdir(`${props.root}/${location}`);
14
- } catch {}
15
- },
16
- );
17
- const iterate = async (location: string): Promise<void> => {
18
- const sequence: string[] = location
19
- .split("/")
20
- .map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
21
- for (const s of sequence) await mkdir.get(s);
22
- };
23
- for (const [key, value] of Object.entries(props.files)) {
24
- await iterate(key.split("/").slice(0, -1).join("/"));
25
- await props.writeFile(`${props.root}/${key}`, value);
26
- }
27
- };
28
- }
1
+ import { VariadicSingleton } from "tstl";
2
+
3
+ export namespace NestiaMigrateFileArchiver {
4
+ export const archive = async (props: {
5
+ mkdir: (path: string) => Promise<void>;
6
+ writeFile: (path: string, content: string) => Promise<void>;
7
+ root: string;
8
+ files: Record<string, string>;
9
+ }): Promise<void> => {
10
+ const mkdir = new VariadicSingleton(
11
+ async (location: string): Promise<void> => {
12
+ try {
13
+ await props.mkdir(`${props.root}/${location}`);
14
+ } catch {}
15
+ },
16
+ );
17
+ const iterate = async (location: string): Promise<void> => {
18
+ const sequence: string[] = location
19
+ .split("/")
20
+ .map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
21
+ for (const s of sequence) await mkdir.get(s);
22
+ };
23
+ for (const [key, value] of Object.entries(props.files)) {
24
+ await iterate(key.split("/").slice(0, -1).join("/"));
25
+ await props.writeFile(`${props.root}/${key}`, value);
26
+ }
27
+ };
28
+ }
@@ -12,7 +12,7 @@ export const NEST_TEMPLATE: Record<string, string> = {
12
12
  "LICENSE": "MIT License\r\n\r\nCopyright (c) 2022 Jeongho Nam\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n",
13
13
  "nest-cli.json": "{\r\n \"$schema\": \"https://json.schemastore.org/nest-cli\",\r\n \"collection\": \"@nestjs/schematics\",\r\n \"sourceRoot\": \"src\",\r\n \"entryFile\": \"executable/server\",\r\n \"compilerOptions\": {\r\n \"deleteOutDir\": true\r\n }\r\n}\r\n",
14
14
  "nestia.config.ts": "// nestia configuration file\r\nimport type sdk from \"@nestia/sdk\";\r\nimport { NestFactory } from \"@nestjs/core\";\r\n\r\nimport { MyModule } from \"./src/MyModule\";\r\n\r\nconst NESTIA_CONFIG: sdk.INestiaConfig = {\r\n input: () => NestFactory.create(MyModule),\r\n output: \"src/api\",\r\n swagger: {\r\n output: \"packages/api/swagger.json\",\r\n servers: [\r\n {\r\n url: \"http://localhost:37001\",\r\n description: \"Local Server\",\r\n },\r\n ],\r\n beautify: true,\r\n },\r\n distribute: \"packages/api\",\r\n keyword: true,\r\n simulate: true,\r\n primitive: false,\r\n};\r\nexport default NESTIA_CONFIG;\r\n",
15
- "package.json": "{\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 && ts-node build/env.ts\",\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:dev\": \"nest start --watch\",\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 \"@autobe/interface\": \"^0.10.6\",\n \"@nestia/benchmark\": \"^11.0.0-dev.20260312\",\n \"@nestia/e2e\": \"^11.0.0-dev.20260312\",\n \"@nestjs/cli\": \"^11.0.16\",\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\": \"^11.0.0-dev.20260312\",\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.9.3\",\n \"typescript-transform-paths\": \"^3.5.6\",\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\": \"^11.0.0-dev.20260312\",\n \"@nestia/fetcher\": \"^11.0.0-dev.20260312\",\n \"@nestia/sdk\": \"^11.0.0-dev.20260312\",\n \"@nestjs/common\": \"^11.1.12\",\n \"@nestjs/core\": \"^11.1.12\",\n \"@nestjs/platform-express\": \"^11.1.12\",\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.1.0\",\n \"tstl\": \"^3.0.0\",\n \"typia\": \"^11.0.3\",\n \"uuid\": \"^9.0.0\"\n },\n \"stackblitz\": {\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test -- --simultaneous 1\"\n }\n}",
15
+ "package.json": "{\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 && ts-node build/env.ts\",\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:dev\": \"nest start --watch\",\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 \"@autobe/interface\": \"^0.10.6\",\n \"@nestia/benchmark\": \"^11.0.0-dev.20260313\",\n \"@nestia/e2e\": \"^11.0.0-dev.20260313\",\n \"@nestjs/cli\": \"^11.0.16\",\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\": \"^11.0.0-dev.20260313\",\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.9.3\",\n \"typescript-transform-paths\": \"^3.5.6\",\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\": \"^11.0.0-dev.20260313\",\n \"@nestia/fetcher\": \"^11.0.0-dev.20260313\",\n \"@nestia/sdk\": \"^11.0.0-dev.20260313\",\n \"@nestjs/common\": \"^11.1.12\",\n \"@nestjs/core\": \"^11.1.12\",\n \"@nestjs/platform-express\": \"^11.1.12\",\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.1.0\",\n \"tstl\": \"^3.0.0\",\n \"typia\": \"^11.0.3\",\n \"uuid\": \"^9.0.0\"\n },\n \"stackblitz\": {\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test -- --simultaneous 1\"\n }\n}",
16
16
  "packages/api/.gitignore": "lib/\r\nnode_modules/\r\n\r\nswagger.json\r\nopenai.json",
17
17
  "packages/api/LICENSE": "MIT License\r\n\r\nCopyright (c) 2021 ORGANIZATION\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.",
18
18
  "packages/api/package.json": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"SDK library generated by Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"module\": \"lib/index.mjs\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia\"\r\n },\r\n \"author\": \"Jeongho Nam\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia/issues\"\r\n },\r\n \"homepage\": \"https://nestia.io\",\r\n \"files\": [\r\n \"lib\",\r\n \"package.json\",\r\n \"swagger.json\",\r\n \"openai.json\",\r\n \"README.md\"\r\n ],\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^10.0.2\",\r\n \"tgrid\": \"^1.2.1\",\r\n \"typia\": \"^11.0.3\"\r\n }\r\n}",
@@ -4,7 +4,7 @@ export const SDK_TEMPLATE: Record<string, string> = {
4
4
  ".vscode/settings.json": "{\r\n \"editor.tabSize\": 2,\r\n \"editor.formatOnSave\": true,\r\n \"[javascript][typescript]\": {\r\n \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\r\n \"editor.codeActionsOnSave\": {\r\n \"source.fixAll.eslint\": \"explicit\"\r\n },\r\n },\r\n}",
5
5
  "hello.js": "function print(command, description) {\r\n return console.log(`\\x1b[1m${command}\\x1b[2m: ${description}\\x1b[0m`);\r\n}\r\n\r\nconsole.log(\"-----------------------------------------\");\r\nconsole.log(\"\\x1b[7mGenerated by \\x1b[2m@nestia/editor\\x1b[0m\");\r\nconsole.log(\"\");\r\nconsole.log(\" - \\x1b[36mhttps://nestia.io/docs/editor\\x1b[0m\");\r\nconsole.log(\" - \\x1b[36mhttps://github.com/samchon/nestia\\x1b[0m\");\r\nconsole.log(\"-----------------------------------------\");\r\n\r\nprint(\"npm run start\", \"Run only test/start.ts\");\r\nprint(\"npm run test\", \"Run every test/features/**/*.ts files\");\r\nprint(\"npm run test:simulate\", \"Test with mockup simulator\");\r\n",
6
6
  "LICENSE": "MIT License\r\n\r\nCopyright (c) 2024 Jeongho Nam\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n",
7
- "package.json": "{\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\": \"^11.0.0-dev.20260312\",\n \"tgrid\": \"^1.2.1\",\n \"typia\": \"^11.0.3\"\n },\n \"devDependencies\": {\n \"@nestia/e2e\": \"^11.0.0-dev.20260312\",\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.9.3\",\n \"typescript-transform-paths\": \"^3.5.6\"\n }\n}",
7
+ "package.json": "{\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\": \"^11.0.0-dev.20260313\",\n \"tgrid\": \"^1.2.1\",\n \"typia\": \"^11.0.3\"\n },\n \"devDependencies\": {\n \"@nestia/e2e\": \"^11.0.0-dev.20260313\",\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.9.3\",\n \"typescript-transform-paths\": \"^3.5.6\"\n }\n}",
8
8
  "prettier.config.js": "module.exports = {\r\n // DEFAULT CONFIGURATIONS\r\n parser: \"typescript\",\r\n printWidth: 80,\r\n semi: true,\r\n tabWidth: 2,\r\n trailingComma: \"all\",\r\n\r\n // PLUG-IN CONFIGURATIONS\r\n plugins: [\"@trivago/prettier-plugin-sort-imports\"],\r\n importOrder: [\"<THIRD_PARTY_MODULES>\", \"^[./]\"],\r\n importOrderSeparation: true,\r\n importOrderSortSpecifiers: true,\r\n importOrderParserPlugins: [\"decorators-legacy\", \"typescript\", \"jsx\"],\r\n};\r\n",
9
9
  "README.md": "# Software Development Kit\r\nThis is a SDK library generated by [`@nestia/migrate`](https://nestia.io/docs/migrate) or [`@nestia/editor`](https://nestia.io/docs/editor).\r\n\r\nWith this SDK library, you can easily and safely interact with backend server.\r\n\r\nJust import and call some API functions like gif image below:\r\n\r\n![nestia-sdk-demo](https://user-images.githubusercontent.com/13158709/215004990-368c589d-7101-404e-b81b-fbc936382f05.gif)\r\n\r\n> Left is server code, and right is client code utilizing the SDK\r\n\r\n\r\n\r\n\r\n## How to Test\r\n```bash\r\nnpm install\r\nnpm start # run only \"test/start.ts\" file\r\nnpm run test # everything under the \"test/features\" directory\r\nnpm run test:simulate # \"test/features\" with mockup simulation mode\r\n```\r\n\r\nIf you run `npm start` command, only [test/start.ts](test/start.ts) file would be executed.\r\n\r\nOtherwise you run `npm run test` command instead, run everything in the [test/features](test/features) directory.\r\n\r\nFor reference, the [test/features](test/features) directory and E2E test functions (for each API endpoints) would be automatically composed only when you've configured the \"E2E test function generation mode\" of the `@nestia/migrate` (or `@nestia/editor`).\r\n\r\n```bash\r\nnpm install -g @nestia/migrate\r\nnpx @nestia/migrate\r\n? Migration mode (Use arrow keys):\r\n NestJS\r\n > SDK\r\n? Swagger file location: assets/input/clickhouse.json\r\n? Output directory path: assets/output/clickhouse-sdk-manual\r\n? Mokup Simulator: true\r\n? E2E Test Functions: true\r\n```\r\n\r\n\r\n\r\n\r\n## Deploy\r\n```bash\r\nnpm install\r\nnpm run deploy\r\n```\r\n\r\nJust run `npm run deploy` command, then your SDK library would be published.\r\n\r\nBy the way, the initial package name of this template repository is `@ORGANIZATION/PROJECT-api`. I think it would better to change the word to your own organization and project name. If you're utilizing `VsCode`, you can do it through `Edit > Replace in Files` (*Ctrl + Shift + H*) feature.\r\n\r\n-----------\r\n\r\n> ## What [`Nestia`](https://nestia.io) is:\r\n> ![Nestia Logo](https://nestia.io/logo.png)\r\n> \r\n> [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/nestia/blob/master/LICENSE)\r\n> [![npm version](https://img.shields.io/npm/v/@nestia/core.svg)](https://www.npmjs.com/package/@nestia/core)\r\n> [![Downloads](https://img.shields.io/npm/dm/@nestia/core.svg)](https://www.npmjs.com/package/@nestia/core)\r\n> [![Build Status](https://github.com/samchon/nestia/workflows/build/badge.svg)](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)\r\n> [![Guide Documents](https://img.shields.io/badge/guide-documents-forestgreen)](https://nestia.io/docs/)\r\n> \r\n> Nestia is a set of helper libraries for NestJS, supporting below features:\r\n> \r\n> - `@nestia/core`: Super-fast decorators\r\n> - `@nestia/sdk`:\r\n> - Swagger generator evolved than ever\r\n> - SDK library generator for clients\r\n> - Mockup Simulator for client applications\r\n> - Automatic E2E test functions generator\r\n> - `@nestia/migrate`: Migration from Swagger to NestJS\r\n> - `@nestia/editor`: Online TypeScript Swagger Editor\r\n> - `nestia`: Just CLI (command line interface) tool\r\n> \r\n>> **Note**\r\n>> \r\n>> - **Only one line** required, with pure TypeScript type\r\n>> - Enhance performance **30x** up\r\n>> - Runtime validator is **20,000x faster** than `class-validator`\r\n>> - JSON serialization is **200x faster** than `class-transformer`\r\n>> - Software Development Kit\r\n>> - SDK is a collection of `fetch` functions with type definitions like [tRPC](https://> trpc.io/)\r\n>> - Mockup simulator means embedded backend simulator in SDK\r\n>> - similar with [msw](https://mswjs.io/), but fully automated",
10
10
  "rollup.config.js": "const typescript = require(\"@rollup/plugin-typescript\");\r\nconst terser = require(\"@rollup/plugin-terser\");\r\n\r\nmodule.exports = {\r\n input: \"./src/index.ts\",\r\n output: {\r\n dir: \"lib\",\r\n format: \"esm\",\r\n entryFileNames: \"[name].mjs\",\r\n sourcemap: true,\r\n },\r\n plugins: [\r\n typescript({\r\n tsconfig: \"tsconfig.json\",\r\n module: \"ES2020\",\r\n target: \"ES2020\",\r\n }),\r\n terser({\r\n format: {\r\n comments: \"some\",\r\n beautify: true,\r\n ecma: \"2020\",\r\n },\r\n compress: false,\r\n mangle: false,\r\n module: true,\r\n }),\r\n ],\r\n};\r\n",
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env node
2
- import { NestiaMigrateCommander } from "./NestiaMigrateCommander";
3
-
4
- NestiaMigrateCommander.main().catch((exp) => {
5
- console.error(exp);
6
- process.exit(-1);
7
- });
1
+ #!/usr/bin/env node
2
+ import { NestiaMigrateCommander } from "./NestiaMigrateCommander";
3
+
4
+ NestiaMigrateCommander.main().catch((exp) => {
5
+ console.error(exp);
6
+ process.exit(-1);
7
+ });
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as migrate from "./module";
2
-
3
- export default migrate;
4
- export * from "./module";
1
+ import * as migrate from "./module";
2
+
3
+ export default migrate;
4
+ export * from "./module";
@@ -1,107 +1,107 @@
1
- import { HashMap, hash } from "tstl";
2
- import ts from "typescript";
3
-
4
- import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
5
- import { FilePrinter } from "../utils/FilePrinter";
6
- import { NestiaMigrateApiFileProgrammer } from "./NestiaMigrateApiFileProgrammer";
7
- import { NestiaMigrateDtoProgrammer } from "./NestiaMigrateDtoProgrammer";
8
- import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
9
-
10
- export namespace NestiaMigrateApiProgrammer {
11
- export const write = (ctx: INestiaMigrateContext): Record<string, string> => {
12
- const dict: HashMap<string[], NestiaMigrateApiFileProgrammer.IProps> =
13
- new HashMap(
14
- (x) => hash(x.join(".")),
15
- (x, y) => x.length === y.length && x.join(".") === y.join("."),
16
- );
17
- for (const route of ctx.application.routes) {
18
- const namespace: string[] = route.accessor.slice(0, -1);
19
- let last: NestiaMigrateApiFileProgrammer.IProps = dict.take(
20
- namespace,
21
- () => ({
22
- config: ctx.config,
23
- components: ctx.application.document().components,
24
- namespace,
25
- routes: [],
26
- children: new Set(),
27
- }),
28
- );
29
- last.routes.push(route);
30
- namespace.forEach((_s, i, array) => {
31
- const partial: string[] = namespace.slice(0, array.length - i - 1);
32
- const props: NestiaMigrateApiFileProgrammer.IProps = dict.take(
33
- partial,
34
- () => ({
35
- config: ctx.config,
36
- components: ctx.application.document().components,
37
- namespace: partial,
38
- children: new Set(),
39
- routes: [],
40
- }),
41
- );
42
- props.children.add(last.namespace.at(-1)!);
43
- last = props;
44
- });
45
- }
46
-
47
- // DO GENERATE
48
- const files: Record<string, string> = Object.fromEntries(
49
- dict.toJSON().map(({ second: value }) => [
50
- `src/${ctx.mode === "nest" ? "api/" : ""}functional/${[...value.namespace, "index.ts"].join("/")}`,
51
- FilePrinter.write({
52
- statements: NestiaMigrateApiFileProgrammer.write({
53
- ...value,
54
- config: ctx.config,
55
- components: ctx.application.document().components,
56
- }),
57
- }),
58
- ]),
59
- );
60
- if (ctx.mode === "sdk")
61
- for (const [key, value] of NestiaMigrateDtoProgrammer.compose({
62
- config: ctx.config,
63
- components: ctx.application.document().components,
64
- }).entries())
65
- files[`src/structures/${key}.ts`] = FilePrinter.write({
66
- statements: writeDtoFile(key, value),
67
- });
68
- return files;
69
- };
70
-
71
- const writeDtoFile = (
72
- key: string,
73
- modulo: NestiaMigrateDtoProgrammer.IModule,
74
- ): ts.Statement[] => {
75
- const importer = new NestiaMigrateImportProgrammer();
76
- const statements: ts.Statement[] = iterate(importer, modulo);
77
- if (statements.length === 0) return [];
78
- return [
79
- ...importer.toStatements((name) => `./${name}`, key),
80
- ...(importer.empty() ? [] : [FilePrinter.newLine()]),
81
- ...statements,
82
- ];
83
- };
84
-
85
- const iterate = (
86
- importer: NestiaMigrateImportProgrammer,
87
- modulo: NestiaMigrateDtoProgrammer.IModule,
88
- ): ts.Statement[] => {
89
- const output: ts.Statement[] = [];
90
- if (modulo.programmer !== null) output.push(modulo.programmer(importer));
91
- if (modulo.children.size !== 0) {
92
- const internal: ts.Statement[] = [];
93
- for (const child of modulo.children.values())
94
- internal.push(...iterate(importer, child));
95
- output.push(
96
- ts.factory.createModuleDeclaration(
97
- [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
98
- ts.factory.createIdentifier(modulo.name),
99
- ts.factory.createModuleBlock(internal),
100
- ts.NodeFlags.Namespace,
101
- ),
102
- );
103
- }
104
- output.push(FilePrinter.newLine());
105
- return output;
106
- };
107
- }
1
+ import { HashMap, hash } from "tstl";
2
+ import ts from "typescript";
3
+
4
+ import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
5
+ import { FilePrinter } from "../utils/FilePrinter";
6
+ import { NestiaMigrateApiFileProgrammer } from "./NestiaMigrateApiFileProgrammer";
7
+ import { NestiaMigrateDtoProgrammer } from "./NestiaMigrateDtoProgrammer";
8
+ import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
9
+
10
+ export namespace NestiaMigrateApiProgrammer {
11
+ export const write = (ctx: INestiaMigrateContext): Record<string, string> => {
12
+ const dict: HashMap<string[], NestiaMigrateApiFileProgrammer.IProps> =
13
+ new HashMap(
14
+ (x) => hash(x.join(".")),
15
+ (x, y) => x.length === y.length && x.join(".") === y.join("."),
16
+ );
17
+ for (const route of ctx.application.routes) {
18
+ const namespace: string[] = route.accessor.slice(0, -1);
19
+ let last: NestiaMigrateApiFileProgrammer.IProps = dict.take(
20
+ namespace,
21
+ () => ({
22
+ config: ctx.config,
23
+ components: ctx.application.document().components,
24
+ namespace,
25
+ routes: [],
26
+ children: new Set(),
27
+ }),
28
+ );
29
+ last.routes.push(route);
30
+ namespace.forEach((_s, i, array) => {
31
+ const partial: string[] = namespace.slice(0, array.length - i - 1);
32
+ const props: NestiaMigrateApiFileProgrammer.IProps = dict.take(
33
+ partial,
34
+ () => ({
35
+ config: ctx.config,
36
+ components: ctx.application.document().components,
37
+ namespace: partial,
38
+ children: new Set(),
39
+ routes: [],
40
+ }),
41
+ );
42
+ props.children.add(last.namespace.at(-1)!);
43
+ last = props;
44
+ });
45
+ }
46
+
47
+ // DO GENERATE
48
+ const files: Record<string, string> = Object.fromEntries(
49
+ dict.toJSON().map(({ second: value }) => [
50
+ `src/${ctx.mode === "nest" ? "api/" : ""}functional/${[...value.namespace, "index.ts"].join("/")}`,
51
+ FilePrinter.write({
52
+ statements: NestiaMigrateApiFileProgrammer.write({
53
+ ...value,
54
+ config: ctx.config,
55
+ components: ctx.application.document().components,
56
+ }),
57
+ }),
58
+ ]),
59
+ );
60
+ if (ctx.mode === "sdk")
61
+ for (const [key, value] of NestiaMigrateDtoProgrammer.compose({
62
+ config: ctx.config,
63
+ components: ctx.application.document().components,
64
+ }).entries())
65
+ files[`src/structures/${key}.ts`] = FilePrinter.write({
66
+ statements: writeDtoFile(key, value),
67
+ });
68
+ return files;
69
+ };
70
+
71
+ const writeDtoFile = (
72
+ key: string,
73
+ modulo: NestiaMigrateDtoProgrammer.IModule,
74
+ ): ts.Statement[] => {
75
+ const importer = new NestiaMigrateImportProgrammer();
76
+ const statements: ts.Statement[] = iterate(importer, modulo);
77
+ if (statements.length === 0) return [];
78
+ return [
79
+ ...importer.toStatements((name) => `./${name}`, key),
80
+ ...(importer.empty() ? [] : [FilePrinter.newLine()]),
81
+ ...statements,
82
+ ];
83
+ };
84
+
85
+ const iterate = (
86
+ importer: NestiaMigrateImportProgrammer,
87
+ modulo: NestiaMigrateDtoProgrammer.IModule,
88
+ ): ts.Statement[] => {
89
+ const output: ts.Statement[] = [];
90
+ if (modulo.programmer !== null) output.push(modulo.programmer(importer));
91
+ if (modulo.children.size !== 0) {
92
+ const internal: ts.Statement[] = [];
93
+ for (const child of modulo.children.values())
94
+ internal.push(...iterate(importer, child));
95
+ output.push(
96
+ ts.factory.createModuleDeclaration(
97
+ [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
98
+ ts.factory.createIdentifier(modulo.name),
99
+ ts.factory.createModuleBlock(internal),
100
+ ts.NodeFlags.Namespace,
101
+ ),
102
+ );
103
+ }
104
+ output.push(FilePrinter.newLine());
105
+ return output;
106
+ };
107
+ }
@@ -1,65 +1,65 @@
1
- import ts from "typescript";
2
-
3
- import { INestiaMigrateController } from "../structures/INestiaMigrateController";
4
- import { FilePrinter } from "../utils/FilePrinter";
5
-
6
- export namespace NestiaMigrateNestModuleProgrammer {
7
- export const write = (
8
- controllers: INestiaMigrateController[],
9
- ): ts.Statement[] => [
10
- $import("@nestjs/common")("Module"),
11
- ...(controllers.length ? [FilePrinter.newLine()] : []),
12
- ...controllers.map((c) =>
13
- $import(`${c.location.replace("src/", "./")}/${c.name}`)(c.name),
14
- ),
15
- ...(controllers.length ? [FilePrinter.newLine()] : []),
16
- ts.factory.createClassDeclaration(
17
- [
18
- ts.factory.createDecorator(
19
- ts.factory.createCallExpression(
20
- ts.factory.createIdentifier("Module"),
21
- undefined,
22
- [
23
- ts.factory.createObjectLiteralExpression(
24
- [
25
- ts.factory.createPropertyAssignment(
26
- ts.factory.createIdentifier("controllers"),
27
- ts.factory.createArrayLiteralExpression(
28
- controllers.map((c) =>
29
- ts.factory.createIdentifier(c.name),
30
- ),
31
- true,
32
- ),
33
- ),
34
- ],
35
- true,
36
- ),
37
- ],
38
- ),
39
- ),
40
- ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
41
- ],
42
- "MyModule",
43
- undefined,
44
- undefined,
45
- [],
46
- ),
47
- ];
48
- }
49
-
50
- const $import = (file: string) => (instance: string) =>
51
- ts.factory.createImportDeclaration(
52
- undefined,
53
- ts.factory.createImportClause(
54
- false,
55
- undefined,
56
- ts.factory.createNamedImports([
57
- ts.factory.createImportSpecifier(
58
- false,
59
- undefined,
60
- ts.factory.createIdentifier(instance),
61
- ),
62
- ]),
63
- ),
64
- ts.factory.createStringLiteral(file),
65
- );
1
+ import ts from "typescript";
2
+
3
+ import { INestiaMigrateController } from "../structures/INestiaMigrateController";
4
+ import { FilePrinter } from "../utils/FilePrinter";
5
+
6
+ export namespace NestiaMigrateNestModuleProgrammer {
7
+ export const write = (
8
+ controllers: INestiaMigrateController[],
9
+ ): ts.Statement[] => [
10
+ $import("@nestjs/common")("Module"),
11
+ ...(controllers.length ? [FilePrinter.newLine()] : []),
12
+ ...controllers.map((c) =>
13
+ $import(`${c.location.replace("src/", "./")}/${c.name}`)(c.name),
14
+ ),
15
+ ...(controllers.length ? [FilePrinter.newLine()] : []),
16
+ ts.factory.createClassDeclaration(
17
+ [
18
+ ts.factory.createDecorator(
19
+ ts.factory.createCallExpression(
20
+ ts.factory.createIdentifier("Module"),
21
+ undefined,
22
+ [
23
+ ts.factory.createObjectLiteralExpression(
24
+ [
25
+ ts.factory.createPropertyAssignment(
26
+ ts.factory.createIdentifier("controllers"),
27
+ ts.factory.createArrayLiteralExpression(
28
+ controllers.map((c) =>
29
+ ts.factory.createIdentifier(c.name),
30
+ ),
31
+ true,
32
+ ),
33
+ ),
34
+ ],
35
+ true,
36
+ ),
37
+ ],
38
+ ),
39
+ ),
40
+ ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
41
+ ],
42
+ "MyModule",
43
+ undefined,
44
+ undefined,
45
+ [],
46
+ ),
47
+ ];
48
+ }
49
+
50
+ const $import = (file: string) => (instance: string) =>
51
+ ts.factory.createImportDeclaration(
52
+ undefined,
53
+ ts.factory.createImportClause(
54
+ false,
55
+ undefined,
56
+ ts.factory.createNamedImports([
57
+ ts.factory.createImportSpecifier(
58
+ false,
59
+ undefined,
60
+ ts.factory.createIdentifier(instance),
61
+ ),
62
+ ]),
63
+ ),
64
+ ts.factory.createStringLiteral(file),
65
+ );