@nestia/migrate 12.0.0 → 12.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/lib/bundles/NEST_TEMPLATE.js +1 -1
- package/lib/bundles/NEST_TEMPLATE.mjs +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +1 -1
- package/lib/bundles/SDK_TEMPLATE.mjs +1 -1
- package/lib/programmers/NestiaMigrateApiProgrammer.js +7 -0
- package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiProgrammer.mjs +7 -0
- package/lib/programmers/NestiaMigrateApiStartProgrammer.js +23 -12
- package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiStartProgrammer.mjs +6 -5
- package/lib/programmers/NestiaMigrateImportProgrammer.js +2 -2
- package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateImportProgrammer.mjs +3 -3
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +1 -1
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.mjs +1 -1
- package/package.json +5 -5
- package/src/bundles/NEST_TEMPLATE.ts +1 -1
- package/src/bundles/SDK_TEMPLATE.ts +1 -1
- package/src/programmers/NestiaMigrateApiProgrammer.ts +7 -0
- package/src/programmers/NestiaMigrateApiStartProgrammer.ts +34 -26
- package/src/programmers/NestiaMigrateImportProgrammer.ts +3 -3
- package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +1 -1
- package/src/structures/INestiaMigrateConfig.ts +0 -1
|
@@ -52,7 +52,7 @@ exports.NEST_TEMPLATE = {
|
|
|
52
52
|
"packages/backend/test/webpack.ts": "import { DynamicExecutor } from \"@nestia/e2e\";\nimport cp from \"node:child_process\";\nimport { sleep_for } from \"tstl\";\n\nimport { MyConfiguration } from \"../src/MyConfiguration\";\nimport { MyGlobal } from \"../src/MyGlobal\";\nimport { TestAutomation } from \"./helpers/TestAutomation\";\nimport { TestAutomationStdio } from \"./helpers/TestAutomationStdio\";\n\nconst wait = async (): Promise<void> => {\n while (true)\n try {\n await fetch(`http://localhost:${MyConfiguration.API_PORT()}/dsafdsafsd`);\n return;\n } catch (exp) {\n await sleep_for(100);\n }\n};\n\nconst main = async (): Promise<void> => {\n MyGlobal.testing = true;\n\n const report: DynamicExecutor.IReport = await TestAutomation.execute({\n open: async () => {\n const backend: cp.ChildProcess = cp.fork(\n `${MyConfiguration.ROOT}/dist/server.js`,\n {\n cwd: `${MyConfiguration.ROOT}/dist`,\n },\n );\n await wait();\n return backend;\n },\n close: async (backend) => {\n backend.kill();\n },\n options: await TestAutomationStdio.getOptions(),\n onComplete: TestAutomationStdio.onComplete,\n });\n TestAutomationStdio.report(report);\n};\nmain().catch((exp: unknown) => {\n console.log(exp);\n process.exit(-1);\n});\n",
|
|
53
53
|
"packages/backend/tsconfig.json": "{\n \"extends\": \"../../config/tsconfig.json\",\n \"compilerOptions\": {\n \"outDir\": \"lib\",\n \"rootDir\": \"src\",\n \"experimentalDecorators\": true,\n \"emitDecoratorMetadata\": true\n },\n \"include\": [\"src\"]\n}\n",
|
|
54
54
|
"packages/backend/webpack.config.js": "const path = require(\"path\");\n\nconst CopyWebpackPlugin = require(\"copy-webpack-plugin\");\nconst WriteFilePlugin = require(\"write-file-webpack-plugin\");\nconst { IgnorePlugin } = require(\"webpack\");\n\nconst lazyImports = [\n \"@modelcontextprotocol/sdk\",\n \"@fastify/static\",\n \"@fastify/view\",\n \"@nestjs/microservices\",\n \"@nestjs/websockets\",\n \"class-transformer\",\n \"class-validator\",\n];\n\n// @reference https://tech-blog.s-yoshiki.com/entry/297\nmodule.exports = {\n // CUSTOMIZE HERE\n entry: {\n server: \"./lib/executable/server.js\",\n },\n output: {\n path: path.join(__dirname, \"dist\"),\n filename: \"[name].js\",\n },\n optimization: {\n minimize: true,\n },\n\n // JUST KEEP THEM\n mode: \"production\",\n target: \"node\",\n plugins: [\n new CopyWebpackPlugin({\n patterns: [\n {\n from: \".env\",\n to: \"[name][ext]\",\n },\n ],\n }),\n new WriteFilePlugin(),\n new IgnorePlugin({\n checkResource: (resource) => {\n if (lazyImports.some((modulo) => resource.startsWith(modulo))) {\n try {\n require.resolve(resource);\n } catch (err) {\n return true;\n }\n }\n return false;\n },\n }),\n ],\n};\n",
|
|
55
|
-
"pnpm-workspace.yaml": "packages:\n - \"config\"\n - \"packages/*\"\ncatalogs:\n samchon:\n \"@nestia/benchmark\": ^12.
|
|
55
|
+
"pnpm-workspace.yaml": "packages:\n - \"config\"\n - \"packages/*\"\ncatalogs:\n samchon:\n \"@nestia/benchmark\": ^12.1.0\n \"@nestia/core\": ^12.1.0\n \"@nestia/e2e\": ^12.1.0\n \"@nestia/fetcher\": ^12.1.0\n \"@nestia/sdk\": ^12.1.0\n nestia: ^12.1.0\n tgrid: ^1.2.1\n tstl: ^3.0.0\n typia: ^13.2.0\n rolldown:\n rolldown: ^1.1.5\n utils:\n rimraf: ^6.1.3\n uuid: ^13.0.0\n typescript:\n \"@ttsc/lint\": ^0.18.2\n \"@ttsc/paths\": ^0.18.2\n \"@ttsc/unplugin\": ^0.20.0\n ttsc: ^0.20.0\n typescript: ^7.0.2\n",
|
|
56
56
|
"typos.toml": "[default]\nlocale = 'en-us'\nextend-ignore-re = [\n \"(?Rm)^.*(<!--|#|//)\\\\s*spellchecker:disable-line(-->|\\n)?$\",\n \"(?s)(<!--|#|//)\\\\s*spellchecker:off\\\\s*(-->|\\n).*?(<!--|#|//)\\\\s*spellchecker:on\",\n]\n\n[default.extend-words]\nJeongho = \"Jeongho\"\nNam = \"Nam\"\ntypia = \"typia\"\n\n[files]\nextend-exclude = [\"*.json\"]"
|
|
57
57
|
};
|
|
58
58
|
//# sourceMappingURL=NEST_TEMPLATE.js.map
|
|
@@ -50,7 +50,7 @@ const NEST_TEMPLATE = {
|
|
|
50
50
|
"packages/backend/test/webpack.ts": "import { DynamicExecutor } from \"@nestia/e2e\";\nimport cp from \"node:child_process\";\nimport { sleep_for } from \"tstl\";\n\nimport { MyConfiguration } from \"../src/MyConfiguration\";\nimport { MyGlobal } from \"../src/MyGlobal\";\nimport { TestAutomation } from \"./helpers/TestAutomation\";\nimport { TestAutomationStdio } from \"./helpers/TestAutomationStdio\";\n\nconst wait = async (): Promise<void> => {\n while (true)\n try {\n await fetch(`http://localhost:${MyConfiguration.API_PORT()}/dsafdsafsd`);\n return;\n } catch (exp) {\n await sleep_for(100);\n }\n};\n\nconst main = async (): Promise<void> => {\n MyGlobal.testing = true;\n\n const report: DynamicExecutor.IReport = await TestAutomation.execute({\n open: async () => {\n const backend: cp.ChildProcess = cp.fork(\n `${MyConfiguration.ROOT}/dist/server.js`,\n {\n cwd: `${MyConfiguration.ROOT}/dist`,\n },\n );\n await wait();\n return backend;\n },\n close: async (backend) => {\n backend.kill();\n },\n options: await TestAutomationStdio.getOptions(),\n onComplete: TestAutomationStdio.onComplete,\n });\n TestAutomationStdio.report(report);\n};\nmain().catch((exp: unknown) => {\n console.log(exp);\n process.exit(-1);\n});\n",
|
|
51
51
|
"packages/backend/tsconfig.json": "{\n \"extends\": \"../../config/tsconfig.json\",\n \"compilerOptions\": {\n \"outDir\": \"lib\",\n \"rootDir\": \"src\",\n \"experimentalDecorators\": true,\n \"emitDecoratorMetadata\": true\n },\n \"include\": [\"src\"]\n}\n",
|
|
52
52
|
"packages/backend/webpack.config.js": "const path = require(\"path\");\n\nconst CopyWebpackPlugin = require(\"copy-webpack-plugin\");\nconst WriteFilePlugin = require(\"write-file-webpack-plugin\");\nconst { IgnorePlugin } = require(\"webpack\");\n\nconst lazyImports = [\n \"@modelcontextprotocol/sdk\",\n \"@fastify/static\",\n \"@fastify/view\",\n \"@nestjs/microservices\",\n \"@nestjs/websockets\",\n \"class-transformer\",\n \"class-validator\",\n];\n\n// @reference https://tech-blog.s-yoshiki.com/entry/297\nmodule.exports = {\n // CUSTOMIZE HERE\n entry: {\n server: \"./lib/executable/server.js\",\n },\n output: {\n path: path.join(__dirname, \"dist\"),\n filename: \"[name].js\",\n },\n optimization: {\n minimize: true,\n },\n\n // JUST KEEP THEM\n mode: \"production\",\n target: \"node\",\n plugins: [\n new CopyWebpackPlugin({\n patterns: [\n {\n from: \".env\",\n to: \"[name][ext]\",\n },\n ],\n }),\n new WriteFilePlugin(),\n new IgnorePlugin({\n checkResource: (resource) => {\n if (lazyImports.some((modulo) => resource.startsWith(modulo))) {\n try {\n require.resolve(resource);\n } catch (err) {\n return true;\n }\n }\n return false;\n },\n }),\n ],\n};\n",
|
|
53
|
-
"pnpm-workspace.yaml": "packages:\n - \"config\"\n - \"packages/*\"\ncatalogs:\n samchon:\n \"@nestia/benchmark\": ^12.
|
|
53
|
+
"pnpm-workspace.yaml": "packages:\n - \"config\"\n - \"packages/*\"\ncatalogs:\n samchon:\n \"@nestia/benchmark\": ^12.1.0\n \"@nestia/core\": ^12.1.0\n \"@nestia/e2e\": ^12.1.0\n \"@nestia/fetcher\": ^12.1.0\n \"@nestia/sdk\": ^12.1.0\n nestia: ^12.1.0\n tgrid: ^1.2.1\n tstl: ^3.0.0\n typia: ^13.2.0\n rolldown:\n rolldown: ^1.1.5\n utils:\n rimraf: ^6.1.3\n uuid: ^13.0.0\n typescript:\n \"@ttsc/lint\": ^0.18.2\n \"@ttsc/paths\": ^0.18.2\n \"@ttsc/unplugin\": ^0.20.0\n ttsc: ^0.20.0\n typescript: ^7.0.2\n",
|
|
54
54
|
"typos.toml": "[default]\nlocale = 'en-us'\nextend-ignore-re = [\n \"(?Rm)^.*(<!--|#|//)\\\\s*spellchecker:disable-line(-->|\\n)?$\",\n \"(?s)(<!--|#|//)\\\\s*spellchecker:off\\\\s*(-->|\\n).*?(<!--|#|//)\\\\s*spellchecker:on\",\n]\n\n[default.extend-words]\nJeongho = \"Jeongho\"\nNam = \"Nam\"\ntypia = \"typia\"\n\n[files]\nextend-exclude = [\"*.json\"]"
|
|
55
55
|
};
|
|
56
56
|
//#endregion
|
|
@@ -8,7 +8,7 @@ exports.SDK_TEMPLATE = {
|
|
|
8
8
|
"LICENSE": "MIT License\n\nCopyright (c) 2024 Jeongho Nam\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
|
|
9
9
|
"README.md": "# Software Development Kit\nThis is a SDK library generated by [`@nestia/migrate`](https://nestia.io/docs/migrate) or [`@nestia/editor`](https://nestia.io/docs/editor).\n\nWith this SDK library, you can easily and safely interact with backend server.\n\nJust import and call some API functions like gif image below:\n\n\n\n> Left is server code, and right is client code utilizing the SDK\n\n\n\n\n## How to Test\n```bash\npnpm install\npnpm run start # run only \"test/start.ts\" file\npnpm run test # everything under the \"test/features\" directory\npnpm run test:simulate # \"test/features\" with mockup simulation mode\n```\n\nIf you run `pnpm run start` command, only [test/start.ts](test/start.ts) file would be executed.\n\nOtherwise you run `pnpm run test` command instead, run everything in the [test/features](test/features) directory.\n\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`).\n\n```bash\npnpm dlx @nestia/migrate\n? Migration mode (Use arrow keys):\n NestJS\n > SDK\n? Swagger file location: assets/input/clickhouse.json\n? Output directory path: assets/output/clickhouse-sdk-manual\n? Mokup Simulator: true\n? E2E Test Functions: true\n```\n\n\n\n\n## Deploy\n```bash\npnpm install\npnpm run deploy\n```\n\nJust run `pnpm run deploy` command, then your SDK library would be published.\n\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.\n\n-----------\n\n> ## What [`Nestia`](https://nestia.io) is:\n> \n> \n> [](https://github.com/samchon/nestia/blob/master/LICENSE)\n> [](https://www.npmjs.com/package/@nestia/core)\n> [](https://www.npmjs.com/package/@nestia/core)\n> [](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)\n> [](https://nestia.io/docs/)\n> \n> Nestia is a set of helper libraries for NestJS, supporting below features:\n> \n> - `@nestia/core`: Super-fast decorators\n> - `@nestia/sdk`:\n> - Swagger generator evolved than ever\n> - SDK library generator for clients\n> - Mockup Simulator for client applications\n> - Automatic E2E test functions generator\n> - `@nestia/migrate`: Migration from Swagger to NestJS\n> - `@nestia/editor`: Online TypeScript Swagger Editor\n> - `nestia`: Just CLI (command line interface) tool\n> \n>> **Note**\n>> \n>> - **Only one line** required, with pure TypeScript type\n>> - Enhance performance **30x** up\n>> - Runtime validator is **20,000x faster** than `class-validator`\n>> - JSON serialization is **200x faster** than `class-transformer`\n>> - Software Development Kit\n>> - SDK is a collection of `fetch` functions with type definitions like [tRPC](https://> trpc.io/)\n>> - Mockup simulator means embedded backend simulator in SDK\n>> - similar with [msw](https://mswjs.io/), but fully automated\n",
|
|
10
10
|
"hello.js": "function print(command, description) {\n return console.log(`\\x1b[1m${command}\\x1b[2m: ${description}\\x1b[0m`);\n}\n\nconsole.log(\"-----------------------------------------\");\nconsole.log(\"\\x1b[7mGenerated by \\x1b[2m@nestia/editor\\x1b[0m\");\nconsole.log(\"\");\nconsole.log(\" - \\x1b[36mhttps://nestia.io/docs/editor\\x1b[0m\");\nconsole.log(\" - \\x1b[36mhttps://github.com/samchon/nestia\\x1b[0m\");\nconsole.log(\"-----------------------------------------\");\n\nprint(\"pnpm run start\", \"Run only test/start.ts\");\nprint(\"pnpm run test\", \"Run every test/features/**/*.ts files\");\nprint(\"pnpm run test:simulate\", \"Test with mockup simulator\");\n",
|
|
11
|
-
"package.json": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"src/index.ts\",\n \"exports\": {\n \".\": \"./src/index.ts\",\n \"./lib/*\": \"./src/*.ts\",\n \"./package.json\": \"./package.json\"\n },\n \"publishConfig\": {\n \"main\": \"lib/index.mjs\",\n \"module\": \"lib/index.mjs\",\n \"types\": \"lib/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./lib/index.d.ts\",\n \"import\": \"./lib/index.mjs\",\n \"default\": \"./lib/index.js\"\n },\n \"./lib/*\": {\n \"types\": \"./lib/*.d.ts\",\n \"import\": \"./lib/*.mjs\",\n \"default\": \"./lib/*.js\"\n },\n \"./package.json\": \"./package.json\"\n }\n },\n \"scripts\": {\n \"build\": \"rimraf lib && ttsc && rolldown -c\",\n \"build:test\": \"rimraf bin && ttsc --project test/tsconfig.json\",\n \"deploy\": \"pnpm run build && pnpm publish\",\n \"dev\": \"pnpm run build:test --watch\",\n \"hello\": \"node hello\",\n \"start\": \"ttsx test/start.ts\",\n \"swagger\": \"ttsx test/swagger.ts\",\n \"test\": \"ttsx test/index.ts\",\n \"test:simulate\": \"ttsx test/index.ts --simulate true\"\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\": \"^12.
|
|
11
|
+
"package.json": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"src/index.ts\",\n \"exports\": {\n \".\": \"./src/index.ts\",\n \"./lib/*\": \"./src/*.ts\",\n \"./package.json\": \"./package.json\"\n },\n \"publishConfig\": {\n \"main\": \"lib/index.mjs\",\n \"module\": \"lib/index.mjs\",\n \"types\": \"lib/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./lib/index.d.ts\",\n \"import\": \"./lib/index.mjs\",\n \"default\": \"./lib/index.js\"\n },\n \"./lib/*\": {\n \"types\": \"./lib/*.d.ts\",\n \"import\": \"./lib/*.mjs\",\n \"default\": \"./lib/*.js\"\n },\n \"./package.json\": \"./package.json\"\n }\n },\n \"scripts\": {\n \"build\": \"rimraf lib && ttsc && rolldown -c\",\n \"build:test\": \"rimraf bin && ttsc --project test/tsconfig.json\",\n \"deploy\": \"pnpm run build && pnpm publish\",\n \"dev\": \"pnpm run build:test --watch\",\n \"hello\": \"node hello\",\n \"start\": \"ttsx test/start.ts\",\n \"swagger\": \"ttsx test/swagger.ts\",\n \"test\": \"ttsx test/index.ts\",\n \"test:simulate\": \"ttsx test/index.ts --simulate true\"\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\": \"^12.1.0\",\n \"tgrid\": \"^1.2.1\",\n \"typia\": \"^13.2.0\"\n },\n \"devDependencies\": {\n \"@nestia/e2e\": \"^12.1.0\",\n \"@ttsc/unplugin\": \"^0.18.2\",\n \"@types/express\": \"^4.17.21\",\n \"@types/swagger-ui-express\": \"^4.1.6\",\n \"chalk\": \"4.1.2\",\n \"express\": \"^4.19.2\",\n \"rimraf\": \"^5.0.5\",\n \"rolldown\": \"^1.1.5\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"tinyglobby\": \"^0.2.17\",\n \"ttsc\": \"^0.18.2\",\n \"typescript\": \"^7.0.2\",\n \"@nestia/core\": \"^12.1.0\"\n },\n \"packageManager\": \"pnpm@10.19.0\"\n}",
|
|
12
12
|
"rolldown.config.mjs": "import ttsc from \"@ttsc/unplugin/rolldown\";\nimport path from \"node:path\";\nimport { globSync } from \"tinyglobby\";\n\nexport default {\n input: globSync(\"./src/**/*.ts\"),\n external: (id) => !id.startsWith(\".\") && !path.isAbsolute(id),\n output: {\n dir: \"./lib\",\n format: \"esm\",\n sourcemap: true,\n entryFileNames: \"[name].mjs\",\n preserveModules: true,\n preserveModulesRoot: \"src\",\n },\n plugins: [ttsc()],\n};\n",
|
|
13
13
|
"src/HttpError.ts": "export { HttpError } from \"@nestia/fetcher\";\n",
|
|
14
14
|
"src/IConnection.ts": "export type { IConnection } from \"@nestia/fetcher\";\n",
|
|
@@ -6,7 +6,7 @@ const SDK_TEMPLATE = {
|
|
|
6
6
|
"LICENSE": "MIT License\n\nCopyright (c) 2024 Jeongho Nam\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
|
|
7
7
|
"README.md": "# Software Development Kit\nThis is a SDK library generated by [`@nestia/migrate`](https://nestia.io/docs/migrate) or [`@nestia/editor`](https://nestia.io/docs/editor).\n\nWith this SDK library, you can easily and safely interact with backend server.\n\nJust import and call some API functions like gif image below:\n\n\n\n> Left is server code, and right is client code utilizing the SDK\n\n\n\n\n## How to Test\n```bash\npnpm install\npnpm run start # run only \"test/start.ts\" file\npnpm run test # everything under the \"test/features\" directory\npnpm run test:simulate # \"test/features\" with mockup simulation mode\n```\n\nIf you run `pnpm run start` command, only [test/start.ts](test/start.ts) file would be executed.\n\nOtherwise you run `pnpm run test` command instead, run everything in the [test/features](test/features) directory.\n\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`).\n\n```bash\npnpm dlx @nestia/migrate\n? Migration mode (Use arrow keys):\n NestJS\n > SDK\n? Swagger file location: assets/input/clickhouse.json\n? Output directory path: assets/output/clickhouse-sdk-manual\n? Mokup Simulator: true\n? E2E Test Functions: true\n```\n\n\n\n\n## Deploy\n```bash\npnpm install\npnpm run deploy\n```\n\nJust run `pnpm run deploy` command, then your SDK library would be published.\n\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.\n\n-----------\n\n> ## What [`Nestia`](https://nestia.io) is:\n> \n> \n> [](https://github.com/samchon/nestia/blob/master/LICENSE)\n> [](https://www.npmjs.com/package/@nestia/core)\n> [](https://www.npmjs.com/package/@nestia/core)\n> [](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)\n> [](https://nestia.io/docs/)\n> \n> Nestia is a set of helper libraries for NestJS, supporting below features:\n> \n> - `@nestia/core`: Super-fast decorators\n> - `@nestia/sdk`:\n> - Swagger generator evolved than ever\n> - SDK library generator for clients\n> - Mockup Simulator for client applications\n> - Automatic E2E test functions generator\n> - `@nestia/migrate`: Migration from Swagger to NestJS\n> - `@nestia/editor`: Online TypeScript Swagger Editor\n> - `nestia`: Just CLI (command line interface) tool\n> \n>> **Note**\n>> \n>> - **Only one line** required, with pure TypeScript type\n>> - Enhance performance **30x** up\n>> - Runtime validator is **20,000x faster** than `class-validator`\n>> - JSON serialization is **200x faster** than `class-transformer`\n>> - Software Development Kit\n>> - SDK is a collection of `fetch` functions with type definitions like [tRPC](https://> trpc.io/)\n>> - Mockup simulator means embedded backend simulator in SDK\n>> - similar with [msw](https://mswjs.io/), but fully automated\n",
|
|
8
8
|
"hello.js": "function print(command, description) {\n return console.log(`\\x1b[1m${command}\\x1b[2m: ${description}\\x1b[0m`);\n}\n\nconsole.log(\"-----------------------------------------\");\nconsole.log(\"\\x1b[7mGenerated by \\x1b[2m@nestia/editor\\x1b[0m\");\nconsole.log(\"\");\nconsole.log(\" - \\x1b[36mhttps://nestia.io/docs/editor\\x1b[0m\");\nconsole.log(\" - \\x1b[36mhttps://github.com/samchon/nestia\\x1b[0m\");\nconsole.log(\"-----------------------------------------\");\n\nprint(\"pnpm run start\", \"Run only test/start.ts\");\nprint(\"pnpm run test\", \"Run every test/features/**/*.ts files\");\nprint(\"pnpm run test:simulate\", \"Test with mockup simulator\");\n",
|
|
9
|
-
"package.json": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"src/index.ts\",\n \"exports\": {\n \".\": \"./src/index.ts\",\n \"./lib/*\": \"./src/*.ts\",\n \"./package.json\": \"./package.json\"\n },\n \"publishConfig\": {\n \"main\": \"lib/index.mjs\",\n \"module\": \"lib/index.mjs\",\n \"types\": \"lib/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./lib/index.d.ts\",\n \"import\": \"./lib/index.mjs\",\n \"default\": \"./lib/index.js\"\n },\n \"./lib/*\": {\n \"types\": \"./lib/*.d.ts\",\n \"import\": \"./lib/*.mjs\",\n \"default\": \"./lib/*.js\"\n },\n \"./package.json\": \"./package.json\"\n }\n },\n \"scripts\": {\n \"build\": \"rimraf lib && ttsc && rolldown -c\",\n \"build:test\": \"rimraf bin && ttsc --project test/tsconfig.json\",\n \"deploy\": \"pnpm run build && pnpm publish\",\n \"dev\": \"pnpm run build:test --watch\",\n \"hello\": \"node hello\",\n \"start\": \"ttsx test/start.ts\",\n \"swagger\": \"ttsx test/swagger.ts\",\n \"test\": \"ttsx test/index.ts\",\n \"test:simulate\": \"ttsx test/index.ts --simulate true\"\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\": \"^12.
|
|
9
|
+
"package.json": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"src/index.ts\",\n \"exports\": {\n \".\": \"./src/index.ts\",\n \"./lib/*\": \"./src/*.ts\",\n \"./package.json\": \"./package.json\"\n },\n \"publishConfig\": {\n \"main\": \"lib/index.mjs\",\n \"module\": \"lib/index.mjs\",\n \"types\": \"lib/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./lib/index.d.ts\",\n \"import\": \"./lib/index.mjs\",\n \"default\": \"./lib/index.js\"\n },\n \"./lib/*\": {\n \"types\": \"./lib/*.d.ts\",\n \"import\": \"./lib/*.mjs\",\n \"default\": \"./lib/*.js\"\n },\n \"./package.json\": \"./package.json\"\n }\n },\n \"scripts\": {\n \"build\": \"rimraf lib && ttsc && rolldown -c\",\n \"build:test\": \"rimraf bin && ttsc --project test/tsconfig.json\",\n \"deploy\": \"pnpm run build && pnpm publish\",\n \"dev\": \"pnpm run build:test --watch\",\n \"hello\": \"node hello\",\n \"start\": \"ttsx test/start.ts\",\n \"swagger\": \"ttsx test/swagger.ts\",\n \"test\": \"ttsx test/index.ts\",\n \"test:simulate\": \"ttsx test/index.ts --simulate true\"\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\": \"^12.1.0\",\n \"tgrid\": \"^1.2.1\",\n \"typia\": \"^13.2.0\"\n },\n \"devDependencies\": {\n \"@nestia/e2e\": \"^12.1.0\",\n \"@ttsc/unplugin\": \"^0.18.2\",\n \"@types/express\": \"^4.17.21\",\n \"@types/swagger-ui-express\": \"^4.1.6\",\n \"chalk\": \"4.1.2\",\n \"express\": \"^4.19.2\",\n \"rimraf\": \"^5.0.5\",\n \"rolldown\": \"^1.1.5\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"tinyglobby\": \"^0.2.17\",\n \"ttsc\": \"^0.18.2\",\n \"typescript\": \"^7.0.2\",\n \"@nestia/core\": \"^12.1.0\"\n },\n \"packageManager\": \"pnpm@10.19.0\"\n}",
|
|
10
10
|
"rolldown.config.mjs": "import ttsc from \"@ttsc/unplugin/rolldown\";\nimport path from \"node:path\";\nimport { globSync } from \"tinyglobby\";\n\nexport default {\n input: globSync(\"./src/**/*.ts\"),\n external: (id) => !id.startsWith(\".\") && !path.isAbsolute(id),\n output: {\n dir: \"./lib\",\n format: \"esm\",\n sourcemap: true,\n entryFileNames: \"[name].mjs\",\n preserveModules: true,\n preserveModulesRoot: \"src\",\n },\n plugins: [ttsc()],\n};\n",
|
|
11
11
|
"src/HttpError.ts": "export { HttpError } from \"@nestia/fetcher\";\n",
|
|
12
12
|
"src/IConnection.ts": "export type { IConnection } from \"@nestia/fetcher\";\n",
|
|
@@ -11,6 +11,13 @@ var NestiaMigrateApiProgrammer;
|
|
|
11
11
|
(function (NestiaMigrateApiProgrammer) {
|
|
12
12
|
NestiaMigrateApiProgrammer.write = (ctx) => {
|
|
13
13
|
const dict = new tstl_1.HashMap((x) => (0, tstl_1.hash)(x.join(".")), (x, y) => x.length === y.length && x.join(".") === y.join("."));
|
|
14
|
+
dict.take([], () => ({
|
|
15
|
+
config: ctx.config,
|
|
16
|
+
components: ctx.application.document().components,
|
|
17
|
+
namespace: [],
|
|
18
|
+
routes: [],
|
|
19
|
+
children: new Set(),
|
|
20
|
+
}));
|
|
14
21
|
for (const route of ctx.application.routes) {
|
|
15
22
|
const namespace = route.accessor.slice(0, -1);
|
|
16
23
|
let last = dict.take(namespace, () => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateApiProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateApiProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AAC/D,+BAAqC;AAIrC,sDAAmD;AACnD,qFAAkF;AAClF,6EAA0E;AAC1E,mFAAgF;AAEhF,IAAiB,0BAA0B,
|
|
1
|
+
{"version":3,"file":"NestiaMigrateApiProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateApiProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AA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UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;QACzE,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,QAAQ,GAAmB,EAAE,CAAC;YACpC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC1C,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YAC7C,MAAM,CAAC,IAAI,CACT,iBAAO,CAAC,uBAAuB,CAC7B,CAAC,iBAAO,CAAC,cAAc,CAAC,oBAAU,CAAC,aAAa,CAAC,CAAC,EAClD,iBAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,EACrC,iBAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EACnC,mBAAS,CAAC,SAAS,CACpB,CACF,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,yBAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QACnC,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC,EAxGgB,0BAA0B,aAA1B,0BAA0B,GAA1B,0BAA0B,QAwG1C"}
|
|
@@ -9,6 +9,13 @@ let NestiaMigrateApiProgrammer;
|
|
|
9
9
|
(function(_NestiaMigrateApiProgrammer) {
|
|
10
10
|
_NestiaMigrateApiProgrammer.write = (ctx) => {
|
|
11
11
|
const dict = new HashMap((x) => hash(x.join(".")), (x, y) => x.length === y.length && x.join(".") === y.join("."));
|
|
12
|
+
dict.take([], () => ({
|
|
13
|
+
config: ctx.config,
|
|
14
|
+
components: ctx.application.document().components,
|
|
15
|
+
namespace: [],
|
|
16
|
+
routes: [],
|
|
17
|
+
children: /* @__PURE__ */ new Set()
|
|
18
|
+
}));
|
|
12
19
|
for (const route of ctx.application.routes) {
|
|
13
20
|
const namespace = route.accessor.slice(0, -1);
|
|
14
21
|
let last = dict.take(namespace, () => ({
|
|
@@ -11,14 +11,19 @@ var NestiaMigrateApiStartProgrammer;
|
|
|
11
11
|
(function (NestiaMigrateApiStartProgrammer) {
|
|
12
12
|
NestiaMigrateApiStartProgrammer.write = (context) => {
|
|
13
13
|
const importer = new NestiaMigrateImportProgrammer_1.NestiaMigrateImportProgrammer();
|
|
14
|
-
const
|
|
14
|
+
const route = pick(context.application.routes);
|
|
15
|
+
const main = writeMain(context, importer, route);
|
|
15
16
|
const statements = [
|
|
16
17
|
...importer.toStatements((name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`),
|
|
17
18
|
FilePrinter_1.FilePrinter.newLine(),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
...(route === undefined
|
|
20
|
+
? []
|
|
21
|
+
: [
|
|
22
|
+
factory_1.factory.createImportDeclaration(undefined, factory_1.factory.createImportClause(undefined, undefined, factory_1.factory.createNamedImports([
|
|
23
|
+
factory_1.factory.createImportSpecifier(false, undefined, factory_1.factory.createIdentifier("TestGlobal")),
|
|
24
|
+
])), factory_1.factory.createStringLiteral("./TestGlobal")),
|
|
25
|
+
FilePrinter_1.FilePrinter.newLine(),
|
|
26
|
+
]),
|
|
22
27
|
main,
|
|
23
28
|
factory_1.factory.createExpressionStatement(writeStarter()),
|
|
24
29
|
];
|
|
@@ -29,13 +34,17 @@ var NestiaMigrateApiStartProgrammer;
|
|
|
29
34
|
const writeMain = (ctx, importer, route) => StatementFactory_1.StatementFactory.constant({
|
|
30
35
|
name: "main",
|
|
31
36
|
value: factory_1.factory.createArrowFunction([factory_1.factory.createToken(factory_1.SyntaxKind.AsyncKeyword)], undefined, [], undefined, undefined, factory_1.factory.createBlock([
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
...(route === undefined
|
|
38
|
+
? []
|
|
39
|
+
: [
|
|
40
|
+
writeConnection(ctx, importer),
|
|
41
|
+
...NestiaMigrateE2eFileProgrammer_1.NestiaMigrateE2eFunctionProgrammer.writeBody({
|
|
42
|
+
config: ctx.config,
|
|
43
|
+
components: ctx.application.document().components,
|
|
44
|
+
importer,
|
|
45
|
+
route,
|
|
46
|
+
}),
|
|
47
|
+
]),
|
|
39
48
|
], true)),
|
|
40
49
|
});
|
|
41
50
|
const writeConnection = (ctx, importer) => { var _a, _b, _c; return factory_1.factory.createVariableStatement(undefined, factory_1.factory.createVariableDeclarationList([
|
|
@@ -67,6 +76,8 @@ var NestiaMigrateApiStartProgrammer;
|
|
|
67
76
|
]);
|
|
68
77
|
})(NestiaMigrateApiStartProgrammer || (exports.NestiaMigrateApiStartProgrammer = NestiaMigrateApiStartProgrammer = {}));
|
|
69
78
|
const pick = (array) => {
|
|
79
|
+
if (array.length === 0)
|
|
80
|
+
return undefined;
|
|
70
81
|
const rand = Math.random() * array.length;
|
|
71
82
|
const index = Math.min(array.length - 1, Math.floor(rand));
|
|
72
83
|
return array[index];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateApiStartProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateApiStartProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AAG/D,sEAAmE;AACnE,oEAAiE;AAGjE,sDAAmD;AACnD,qFAAsF;AACtF,mFAAgF;AAEhF,IAAiB,+BAA+B,
|
|
1
|
+
{"version":3,"file":"NestiaMigrateApiStartProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateApiStartProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AAG/D,sEAAmE;AACnE,oEAAiE;AAGjE,sDAAmD;AACnD,qFAAsF;AACtF,mFAAgF;AAEhF,IAAiB,+BAA+B,CA2L/C;AA3LD,WAAiB,+BAA+B;IACjC,qCAAK,GAAG,CACnB,OAA8B,EACN,EAAE;QAC1B,MAAM,QAAQ,GACZ,IAAI,6DAA6B,EAAE,CAAC;QACtC,MAAM,KAAK,G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AAC,GAAG,CAAC,CAClC;aACF,CACF,CACF;SACF,EACD,IAAI,CACL,CACF;KACF,CACF,CAAC;AACN,CAAC,EA3LgB,+BAA+B,aAA/B,+BAA+B,GAA/B,+BAA+B,QA2L/C;AAED,MAAM,IAAI,GAAG,CAAI,KAAU,EAAiB,EAAE;IAC5C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,IAAI,GAAW,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC;IAClD,MAAM,KAAK,GAAW,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACnE,OAAO,KAAK,CAAC,KAAK,CAAE,CAAC;AACvB,CAAC,CAAC"}
|
|
@@ -9,12 +9,12 @@ let NestiaMigrateApiStartProgrammer;
|
|
|
9
9
|
(function(_NestiaMigrateApiStartProgrammer) {
|
|
10
10
|
_NestiaMigrateApiStartProgrammer.write = (context) => {
|
|
11
11
|
const importer = new NestiaMigrateImportProgrammer();
|
|
12
|
-
const
|
|
12
|
+
const route = pick(context.application.routes);
|
|
13
|
+
const main = writeMain(context, importer, route);
|
|
13
14
|
const statements = [
|
|
14
15
|
...importer.toStatements((name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`),
|
|
15
16
|
FilePrinter.newLine(),
|
|
16
|
-
factory.createImportDeclaration(void 0, factory.createImportClause(
|
|
17
|
-
FilePrinter.newLine(),
|
|
17
|
+
...route === void 0 ? [] : [factory.createImportDeclaration(void 0, factory.createImportClause(void 0, void 0, factory.createNamedImports([factory.createImportSpecifier(false, void 0, factory.createIdentifier("TestGlobal"))])), factory.createStringLiteral("./TestGlobal")), FilePrinter.newLine()],
|
|
18
18
|
main,
|
|
19
19
|
factory.createExpressionStatement(writeStarter())
|
|
20
20
|
];
|
|
@@ -22,12 +22,12 @@ let NestiaMigrateApiStartProgrammer;
|
|
|
22
22
|
};
|
|
23
23
|
const writeMain = (ctx, importer, route) => StatementFactory.constant({
|
|
24
24
|
name: "main",
|
|
25
|
-
value: factory.createArrowFunction([factory.createToken(SyntaxKind.AsyncKeyword)], void 0, [], void 0, void 0, factory.createBlock([writeConnection(ctx, importer), ...NestiaMigrateE2eFunctionProgrammer.writeBody({
|
|
25
|
+
value: factory.createArrowFunction([factory.createToken(SyntaxKind.AsyncKeyword)], void 0, [], void 0, void 0, factory.createBlock([...route === void 0 ? [] : [writeConnection(ctx, importer), ...NestiaMigrateE2eFunctionProgrammer.writeBody({
|
|
26
26
|
config: ctx.config,
|
|
27
27
|
components: ctx.application.document().components,
|
|
28
28
|
importer,
|
|
29
29
|
route
|
|
30
|
-
})], true))
|
|
30
|
+
})]], true))
|
|
31
31
|
});
|
|
32
32
|
const writeConnection = (ctx, importer) => factory.createVariableStatement(void 0, factory.createVariableDeclarationList([factory.createVariableDeclaration("connection", void 0, factory.createTypeReferenceNode(factory.createQualifiedName(factory.createIdentifier(importer.external({
|
|
33
33
|
type: "default",
|
|
@@ -41,6 +41,7 @@ let NestiaMigrateApiStartProgrammer;
|
|
|
41
41
|
const writeStarter = () => factory.createCallExpression(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("main"), void 0, void 0), "catch"), void 0, [factory.createArrowFunction(void 0, void 0, [IdentifierFactory.parameter("exp")], void 0, void 0, factory.createBlock([factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("console"), "log"), void 0, [factory.createIdentifier("exp")])), factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("process"), "exit"), void 0, [factory.createPrefixMinus(factory.createNumericLiteral("1"))]))], true))]);
|
|
42
42
|
})(NestiaMigrateApiStartProgrammer || (NestiaMigrateApiStartProgrammer = {}));
|
|
43
43
|
const pick = (array) => {
|
|
44
|
+
if (array.length === 0) return void 0;
|
|
44
45
|
const rand = Math.random() * array.length;
|
|
45
46
|
return array[Math.min(array.length - 1, Math.floor(rand))];
|
|
46
47
|
};
|
|
@@ -49,7 +49,7 @@ class NestiaMigrateImportProgrammer {
|
|
|
49
49
|
if (current === undefined || name !== current.split(".")[0])
|
|
50
50
|
MapUtil_1.MapUtil.take(modules)(dtoPath(name))(() => []).push(name);
|
|
51
51
|
return [
|
|
52
|
-
...[...this.external_.entries()].map(([library, props]) => factory_1.factory.createImportDeclaration(undefined, factory_1.factory.createImportClause(
|
|
52
|
+
...[...this.external_.entries()].map(([library, props]) => factory_1.factory.createImportDeclaration(undefined, factory_1.factory.createImportClause(undefined, props.default !== null
|
|
53
53
|
? factory_1.factory.createIdentifier(props.default)
|
|
54
54
|
: undefined, props.instances.size
|
|
55
55
|
? factory_1.factory.createNamedImports([...props.instances].map((i) => factory_1.factory.createImportSpecifier(false, undefined, factory_1.factory.createIdentifier(i))))
|
|
@@ -61,7 +61,7 @@ class NestiaMigrateImportProgrammer {
|
|
|
61
61
|
// DTO files declare pure types, and generated code references them
|
|
62
62
|
// only in type positions — keep the clause type-only so emitted
|
|
63
63
|
// JS never loads the DTO module at runtime.
|
|
64
|
-
factory_1.factory.createImportClause(
|
|
64
|
+
factory_1.factory.createImportClause(factory_1.SyntaxKind.TypeKeyword, undefined, factory_1.factory.createNamedImports(names.map((name) => factory_1.factory.createImportSpecifier(false, undefined, factory_1.factory.createIdentifier(name))))), factory_1.factory.createStringLiteral(specifier))),
|
|
65
65
|
];
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateImportProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateImportProgrammer.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"NestiaMigrateImportProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateImportProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAEpD,wEAAqE;AAErE,sDAA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IAAI;gBAClB,CAAC,CAAC,iBAAO,CAAC,kBAAkB,CACxB,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC7B,iBAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,iBAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAC5B,CACF,CACF;gBACH,CAAC,CAAC,SAAS,CACd,EACD,iBAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,CACrC,CACF;YACD,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI;gBACxC,CAAC,CAAC,CAAC,yBAAW,CAAC,OAAO,EAAE,CAAC;gBACzB,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,CACnD,iBAAO,CAAC,uBAAuB,CAC7B,SAAS;YACT,mEAAmE;YACnE,gEAAgE;YAChE,4CAA4C;YAC5C,iBAAO,CAAC,kBAAkB,CACxB,oBAAU,CAAC,WAAW,EACtB,SAAS,EACT,iBAAO,CAAC,kBAAkB,CACxB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACjB,iBAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,iBAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAC/B,CACF,CACF,CACF,EACD,iBAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,CACvC,CACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FilePrinter } from "../utils/FilePrinter.mjs";
|
|
2
2
|
import { TypeLiteralFactory } from "../factories/TypeLiteralFactory.mjs";
|
|
3
3
|
import { MapUtil } from "../utils/MapUtil.mjs";
|
|
4
|
-
import { factory } from "@ttsc/factory";
|
|
4
|
+
import { SyntaxKind, factory } from "@ttsc/factory";
|
|
5
5
|
//#region src/programmers/NestiaMigrateImportProgrammer.ts
|
|
6
6
|
var NestiaMigrateImportProgrammer = class {
|
|
7
7
|
constructor() {
|
|
@@ -38,9 +38,9 @@ var NestiaMigrateImportProgrammer = class {
|
|
|
38
38
|
const modules = /* @__PURE__ */ new Map();
|
|
39
39
|
for (const name of this.dtos_) if (current === void 0 || name !== current.split(".")[0]) MapUtil.take(modules)(dtoPath(name))(() => []).push(name);
|
|
40
40
|
return [
|
|
41
|
-
...[...this.external_.entries()].map(([library, props]) => factory.createImportDeclaration(void 0, factory.createImportClause(
|
|
41
|
+
...[...this.external_.entries()].map(([library, props]) => factory.createImportDeclaration(void 0, factory.createImportClause(void 0, props.default !== null ? factory.createIdentifier(props.default) : void 0, props.instances.size ? factory.createNamedImports([...props.instances].map((i) => factory.createImportSpecifier(false, void 0, factory.createIdentifier(i)))) : void 0), factory.createStringLiteral(library))),
|
|
42
42
|
...this.external_.size && this.dtos_.size ? [FilePrinter.newLine()] : [],
|
|
43
|
-
...[...modules.entries()].map(([specifier, names]) => factory.createImportDeclaration(void 0, factory.createImportClause(
|
|
43
|
+
...[...modules.entries()].map(([specifier, names]) => factory.createImportDeclaration(void 0, factory.createImportClause(SyntaxKind.TypeKeyword, void 0, factory.createNamedImports(names.map((name) => factory.createImportSpecifier(false, void 0, factory.createIdentifier(name))))), factory.createStringLiteral(specifier)))
|
|
44
44
|
];
|
|
45
45
|
}
|
|
46
46
|
};
|
|
@@ -20,7 +20,7 @@ var NestiaMigrateNestModuleProgrammer;
|
|
|
20
20
|
], "MyModule", undefined, undefined, []),
|
|
21
21
|
];
|
|
22
22
|
})(NestiaMigrateNestModuleProgrammer || (exports.NestiaMigrateNestModuleProgrammer = NestiaMigrateNestModuleProgrammer = {}));
|
|
23
|
-
const $import = (file) => (instance) => factory_1.factory.createImportDeclaration(undefined, factory_1.factory.createImportClause(
|
|
23
|
+
const $import = (file) => (instance) => factory_1.factory.createImportDeclaration(undefined, factory_1.factory.createImportClause(undefined, undefined, factory_1.factory.createNamedImports([
|
|
24
24
|
factory_1.factory.createImportSpecifier(false, undefined, factory_1.factory.createIdentifier(instance)),
|
|
25
25
|
])), factory_1.factory.createStringLiteral(file));
|
|
26
26
|
//# sourceMappingURL=NestiaMigrateNestModuleProgrammer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateNestModuleProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateNestModuleProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAIpD,sDAAmD;AAEnD,IAAiB,iCAAiC,CAwCjD;AAxCD,WAAiB,iCAAiC;IACnC,uCAAK,GAAG,CACnB,WAAuC,EACvB,EAAE,CAAC;QACnB,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC;QACnC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,yBAAW,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACvB,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CACjE;QACD,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,yBAAW,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,iBAAO,CAAC,sBAAsB,CAC5B;YACE,iBAAO,CAAC,eAAe,CACrB,iBAAO,CAAC,oBAAoB,CAC1B,iBAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAClC,SAAS,EACT;gBACE,iBAAO,CAAC,6BAA6B,CACnC;oBACE,iBAAO,CAAC,wBAAwB,CAC9B,iBAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,EACvC,iBAAO,CAAC,4BAA4B,CAClC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EACxD,IAAI,CACL,CACF;iBACF,EACD,IAAI,CACL;aACF,CACF,CACF;YACD,iBAAO,CAAC,WAAW,CAAC,oBAAU,CAAC,aAAa,CAAC;SAC9C,EACD,UAAU,EACV,SAAS,EACT,SAAS,EACT,EAAE,CACH;KACF,CAAC;AACJ,CAAC,EAxCgB,iCAAiC,aAAjC,iCAAiC,GAAjC,iCAAiC,QAwCjD;AAED,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CACrD,iBAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,iBAAO,CAAC,kBAAkB,CACxB,
|
|
1
|
+
{"version":3,"file":"NestiaMigrateNestModuleProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateNestModuleProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAIpD,sDAAmD;AAEnD,IAAiB,iCAAiC,CAwCjD;AAxCD,WAAiB,iCAAiC;IACnC,uCAAK,GAAG,CACnB,WAAuC,EACvB,EAAE,CAAC;QACnB,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC;QACnC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,yBAAW,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACvB,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,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|
factory.createClassDeclaration([factory.createDecorator(factory.createCallExpression(factory.createIdentifier("Module"), void 0, [factory.createObjectLiteralExpression([factory.createPropertyAssignment(factory.createIdentifier("controllers"), factory.createArrayLiteralExpression(controllers.map((c) => factory.createIdentifier(c.name)), true))], true)])), factory.createToken(SyntaxKind.ExportKeyword)], "MyModule", void 0, void 0, [])
|
|
12
12
|
];
|
|
13
13
|
})(NestiaMigrateNestModuleProgrammer || (NestiaMigrateNestModuleProgrammer = {}));
|
|
14
|
-
const $import = (file) => (instance) => factory.createImportDeclaration(void 0, factory.createImportClause(
|
|
14
|
+
const $import = (file) => (instance) => factory.createImportDeclaration(void 0, factory.createImportClause(void 0, void 0, factory.createNamedImports([factory.createImportSpecifier(false, void 0, factory.createIdentifier(instance))])), factory.createStringLiteral(file));
|
|
15
15
|
//#endregion
|
|
16
16
|
export { NestiaMigrateNestModuleProgrammer };
|
|
17
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/migrate",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "Migration program from swagger to NestJS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
47
|
-
"@ttsc/factory": "^0.
|
|
48
|
-
"@typia/interface": "^13.0
|
|
49
|
-
"@typia/utils": "^13.0
|
|
47
|
+
"@ttsc/factory": "^0.20.0",
|
|
48
|
+
"@typia/interface": "^13.2.0",
|
|
49
|
+
"@typia/utils": "^13.2.0",
|
|
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
|
-
"typia": "^13.0
|
|
55
|
+
"typia": "^13.2.0"
|
|
56
56
|
},
|
|
57
57
|
"files": [
|
|
58
58
|
"lib",
|
|
@@ -49,6 +49,6 @@ export const NEST_TEMPLATE: Record<string, string> = {
|
|
|
49
49
|
"packages/backend/test/webpack.ts": "import { DynamicExecutor } from \"@nestia/e2e\";\nimport cp from \"node:child_process\";\nimport { sleep_for } from \"tstl\";\n\nimport { MyConfiguration } from \"../src/MyConfiguration\";\nimport { MyGlobal } from \"../src/MyGlobal\";\nimport { TestAutomation } from \"./helpers/TestAutomation\";\nimport { TestAutomationStdio } from \"./helpers/TestAutomationStdio\";\n\nconst wait = async (): Promise<void> => {\n while (true)\n try {\n await fetch(`http://localhost:${MyConfiguration.API_PORT()}/dsafdsafsd`);\n return;\n } catch (exp) {\n await sleep_for(100);\n }\n};\n\nconst main = async (): Promise<void> => {\n MyGlobal.testing = true;\n\n const report: DynamicExecutor.IReport = await TestAutomation.execute({\n open: async () => {\n const backend: cp.ChildProcess = cp.fork(\n `${MyConfiguration.ROOT}/dist/server.js`,\n {\n cwd: `${MyConfiguration.ROOT}/dist`,\n },\n );\n await wait();\n return backend;\n },\n close: async (backend) => {\n backend.kill();\n },\n options: await TestAutomationStdio.getOptions(),\n onComplete: TestAutomationStdio.onComplete,\n });\n TestAutomationStdio.report(report);\n};\nmain().catch((exp: unknown) => {\n console.log(exp);\n process.exit(-1);\n});\n",
|
|
50
50
|
"packages/backend/tsconfig.json": "{\n \"extends\": \"../../config/tsconfig.json\",\n \"compilerOptions\": {\n \"outDir\": \"lib\",\n \"rootDir\": \"src\",\n \"experimentalDecorators\": true,\n \"emitDecoratorMetadata\": true\n },\n \"include\": [\"src\"]\n}\n",
|
|
51
51
|
"packages/backend/webpack.config.js": "const path = require(\"path\");\n\nconst CopyWebpackPlugin = require(\"copy-webpack-plugin\");\nconst WriteFilePlugin = require(\"write-file-webpack-plugin\");\nconst { IgnorePlugin } = require(\"webpack\");\n\nconst lazyImports = [\n \"@modelcontextprotocol/sdk\",\n \"@fastify/static\",\n \"@fastify/view\",\n \"@nestjs/microservices\",\n \"@nestjs/websockets\",\n \"class-transformer\",\n \"class-validator\",\n];\n\n// @reference https://tech-blog.s-yoshiki.com/entry/297\nmodule.exports = {\n // CUSTOMIZE HERE\n entry: {\n server: \"./lib/executable/server.js\",\n },\n output: {\n path: path.join(__dirname, \"dist\"),\n filename: \"[name].js\",\n },\n optimization: {\n minimize: true,\n },\n\n // JUST KEEP THEM\n mode: \"production\",\n target: \"node\",\n plugins: [\n new CopyWebpackPlugin({\n patterns: [\n {\n from: \".env\",\n to: \"[name][ext]\",\n },\n ],\n }),\n new WriteFilePlugin(),\n new IgnorePlugin({\n checkResource: (resource) => {\n if (lazyImports.some((modulo) => resource.startsWith(modulo))) {\n try {\n require.resolve(resource);\n } catch (err) {\n return true;\n }\n }\n return false;\n },\n }),\n ],\n};\n",
|
|
52
|
-
"pnpm-workspace.yaml": "packages:\n - \"config\"\n - \"packages/*\"\ncatalogs:\n samchon:\n \"@nestia/benchmark\": ^12.
|
|
52
|
+
"pnpm-workspace.yaml": "packages:\n - \"config\"\n - \"packages/*\"\ncatalogs:\n samchon:\n \"@nestia/benchmark\": ^12.1.0\n \"@nestia/core\": ^12.1.0\n \"@nestia/e2e\": ^12.1.0\n \"@nestia/fetcher\": ^12.1.0\n \"@nestia/sdk\": ^12.1.0\n nestia: ^12.1.0\n tgrid: ^1.2.1\n tstl: ^3.0.0\n typia: ^13.2.0\n rolldown:\n rolldown: ^1.1.5\n utils:\n rimraf: ^6.1.3\n uuid: ^13.0.0\n typescript:\n \"@ttsc/lint\": ^0.18.2\n \"@ttsc/paths\": ^0.18.2\n \"@ttsc/unplugin\": ^0.20.0\n ttsc: ^0.20.0\n typescript: ^7.0.2\n",
|
|
53
53
|
"typos.toml": "[default]\nlocale = 'en-us'\nextend-ignore-re = [\n \"(?Rm)^.*(<!--|#|//)\\\\s*spellchecker:disable-line(-->|\\n)?$\",\n \"(?s)(<!--|#|//)\\\\s*spellchecker:off\\\\s*(-->|\\n).*?(<!--|#|//)\\\\s*spellchecker:on\",\n]\n\n[default.extend-words]\nJeongho = \"Jeongho\"\nNam = \"Nam\"\ntypia = \"typia\"\n\n[files]\nextend-exclude = [\"*.json\"]"
|
|
54
54
|
}
|
|
@@ -5,7 +5,7 @@ export const SDK_TEMPLATE: Record<string, string> = {
|
|
|
5
5
|
"LICENSE": "MIT License\n\nCopyright (c) 2024 Jeongho Nam\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
|
|
6
6
|
"README.md": "# Software Development Kit\nThis is a SDK library generated by [`@nestia/migrate`](https://nestia.io/docs/migrate) or [`@nestia/editor`](https://nestia.io/docs/editor).\n\nWith this SDK library, you can easily and safely interact with backend server.\n\nJust import and call some API functions like gif image below:\n\n\n\n> Left is server code, and right is client code utilizing the SDK\n\n\n\n\n## How to Test\n```bash\npnpm install\npnpm run start # run only \"test/start.ts\" file\npnpm run test # everything under the \"test/features\" directory\npnpm run test:simulate # \"test/features\" with mockup simulation mode\n```\n\nIf you run `pnpm run start` command, only [test/start.ts](test/start.ts) file would be executed.\n\nOtherwise you run `pnpm run test` command instead, run everything in the [test/features](test/features) directory.\n\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`).\n\n```bash\npnpm dlx @nestia/migrate\n? Migration mode (Use arrow keys):\n NestJS\n > SDK\n? Swagger file location: assets/input/clickhouse.json\n? Output directory path: assets/output/clickhouse-sdk-manual\n? Mokup Simulator: true\n? E2E Test Functions: true\n```\n\n\n\n\n## Deploy\n```bash\npnpm install\npnpm run deploy\n```\n\nJust run `pnpm run deploy` command, then your SDK library would be published.\n\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.\n\n-----------\n\n> ## What [`Nestia`](https://nestia.io) is:\n> \n> \n> [](https://github.com/samchon/nestia/blob/master/LICENSE)\n> [](https://www.npmjs.com/package/@nestia/core)\n> [](https://www.npmjs.com/package/@nestia/core)\n> [](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)\n> [](https://nestia.io/docs/)\n> \n> Nestia is a set of helper libraries for NestJS, supporting below features:\n> \n> - `@nestia/core`: Super-fast decorators\n> - `@nestia/sdk`:\n> - Swagger generator evolved than ever\n> - SDK library generator for clients\n> - Mockup Simulator for client applications\n> - Automatic E2E test functions generator\n> - `@nestia/migrate`: Migration from Swagger to NestJS\n> - `@nestia/editor`: Online TypeScript Swagger Editor\n> - `nestia`: Just CLI (command line interface) tool\n> \n>> **Note**\n>> \n>> - **Only one line** required, with pure TypeScript type\n>> - Enhance performance **30x** up\n>> - Runtime validator is **20,000x faster** than `class-validator`\n>> - JSON serialization is **200x faster** than `class-transformer`\n>> - Software Development Kit\n>> - SDK is a collection of `fetch` functions with type definitions like [tRPC](https://> trpc.io/)\n>> - Mockup simulator means embedded backend simulator in SDK\n>> - similar with [msw](https://mswjs.io/), but fully automated\n",
|
|
7
7
|
"hello.js": "function print(command, description) {\n return console.log(`\\x1b[1m${command}\\x1b[2m: ${description}\\x1b[0m`);\n}\n\nconsole.log(\"-----------------------------------------\");\nconsole.log(\"\\x1b[7mGenerated by \\x1b[2m@nestia/editor\\x1b[0m\");\nconsole.log(\"\");\nconsole.log(\" - \\x1b[36mhttps://nestia.io/docs/editor\\x1b[0m\");\nconsole.log(\" - \\x1b[36mhttps://github.com/samchon/nestia\\x1b[0m\");\nconsole.log(\"-----------------------------------------\");\n\nprint(\"pnpm run start\", \"Run only test/start.ts\");\nprint(\"pnpm run test\", \"Run every test/features/**/*.ts files\");\nprint(\"pnpm run test:simulate\", \"Test with mockup simulator\");\n",
|
|
8
|
-
"package.json": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"src/index.ts\",\n \"exports\": {\n \".\": \"./src/index.ts\",\n \"./lib/*\": \"./src/*.ts\",\n \"./package.json\": \"./package.json\"\n },\n \"publishConfig\": {\n \"main\": \"lib/index.mjs\",\n \"module\": \"lib/index.mjs\",\n \"types\": \"lib/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./lib/index.d.ts\",\n \"import\": \"./lib/index.mjs\",\n \"default\": \"./lib/index.js\"\n },\n \"./lib/*\": {\n \"types\": \"./lib/*.d.ts\",\n \"import\": \"./lib/*.mjs\",\n \"default\": \"./lib/*.js\"\n },\n \"./package.json\": \"./package.json\"\n }\n },\n \"scripts\": {\n \"build\": \"rimraf lib && ttsc && rolldown -c\",\n \"build:test\": \"rimraf bin && ttsc --project test/tsconfig.json\",\n \"deploy\": \"pnpm run build && pnpm publish\",\n \"dev\": \"pnpm run build:test --watch\",\n \"hello\": \"node hello\",\n \"start\": \"ttsx test/start.ts\",\n \"swagger\": \"ttsx test/swagger.ts\",\n \"test\": \"ttsx test/index.ts\",\n \"test:simulate\": \"ttsx test/index.ts --simulate true\"\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\": \"^12.
|
|
8
|
+
"package.json": "{\n \"name\": \"@ORGANIZATION/PROJECT-api\",\n \"version\": \"0.1.0\",\n \"description\": \"SDK library generated by Nestia\",\n \"main\": \"src/index.ts\",\n \"exports\": {\n \".\": \"./src/index.ts\",\n \"./lib/*\": \"./src/*.ts\",\n \"./package.json\": \"./package.json\"\n },\n \"publishConfig\": {\n \"main\": \"lib/index.mjs\",\n \"module\": \"lib/index.mjs\",\n \"types\": \"lib/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./lib/index.d.ts\",\n \"import\": \"./lib/index.mjs\",\n \"default\": \"./lib/index.js\"\n },\n \"./lib/*\": {\n \"types\": \"./lib/*.d.ts\",\n \"import\": \"./lib/*.mjs\",\n \"default\": \"./lib/*.js\"\n },\n \"./package.json\": \"./package.json\"\n }\n },\n \"scripts\": {\n \"build\": \"rimraf lib && ttsc && rolldown -c\",\n \"build:test\": \"rimraf bin && ttsc --project test/tsconfig.json\",\n \"deploy\": \"pnpm run build && pnpm publish\",\n \"dev\": \"pnpm run build:test --watch\",\n \"hello\": \"node hello\",\n \"start\": \"ttsx test/start.ts\",\n \"swagger\": \"ttsx test/swagger.ts\",\n \"test\": \"ttsx test/index.ts\",\n \"test:simulate\": \"ttsx test/index.ts --simulate true\"\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\": \"^12.1.0\",\n \"tgrid\": \"^1.2.1\",\n \"typia\": \"^13.2.0\"\n },\n \"devDependencies\": {\n \"@nestia/e2e\": \"^12.1.0\",\n \"@ttsc/unplugin\": \"^0.18.2\",\n \"@types/express\": \"^4.17.21\",\n \"@types/swagger-ui-express\": \"^4.1.6\",\n \"chalk\": \"4.1.2\",\n \"express\": \"^4.19.2\",\n \"rimraf\": \"^5.0.5\",\n \"rolldown\": \"^1.1.5\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"tinyglobby\": \"^0.2.17\",\n \"ttsc\": \"^0.18.2\",\n \"typescript\": \"^7.0.2\",\n \"@nestia/core\": \"^12.1.0\"\n },\n \"packageManager\": \"pnpm@10.19.0\"\n}",
|
|
9
9
|
"rolldown.config.mjs": "import ttsc from \"@ttsc/unplugin/rolldown\";\nimport path from \"node:path\";\nimport { globSync } from \"tinyglobby\";\n\nexport default {\n input: globSync(\"./src/**/*.ts\"),\n external: (id) => !id.startsWith(\".\") && !path.isAbsolute(id),\n output: {\n dir: \"./lib\",\n format: \"esm\",\n sourcemap: true,\n entryFileNames: \"[name].mjs\",\n preserveModules: true,\n preserveModulesRoot: \"src\",\n },\n plugins: [ttsc()],\n};\n",
|
|
10
10
|
"src/HttpError.ts": "export { HttpError } from \"@nestia/fetcher\";\n",
|
|
11
11
|
"src/IConnection.ts": "export type { IConnection } from \"@nestia/fetcher\";\n",
|
|
@@ -15,6 +15,13 @@ export namespace NestiaMigrateApiProgrammer {
|
|
|
15
15
|
(x) => hash(x.join(".")),
|
|
16
16
|
(x, y) => x.length === y.length && x.join(".") === y.join("."),
|
|
17
17
|
);
|
|
18
|
+
dict.take([], () => ({
|
|
19
|
+
config: ctx.config,
|
|
20
|
+
components: ctx.application.document().components,
|
|
21
|
+
namespace: [],
|
|
22
|
+
routes: [],
|
|
23
|
+
children: new Set(),
|
|
24
|
+
}));
|
|
18
25
|
for (const route of ctx.application.routes) {
|
|
19
26
|
const namespace: string[] = route.accessor.slice(0, -1);
|
|
20
27
|
let last: NestiaMigrateApiFileProgrammer.IProps = dict.take(
|
|
@@ -15,32 +15,35 @@ export namespace NestiaMigrateApiStartProgrammer {
|
|
|
15
15
|
): Record<string, string> => {
|
|
16
16
|
const importer: NestiaMigrateImportProgrammer =
|
|
17
17
|
new NestiaMigrateImportProgrammer();
|
|
18
|
-
const
|
|
19
|
-
context,
|
|
20
|
-
importer,
|
|
21
|
-
pick(context.application.routes),
|
|
18
|
+
const route: IHttpMigrateRoute | undefined = pick(
|
|
19
|
+
context.application.routes,
|
|
22
20
|
);
|
|
21
|
+
const main: ts.VariableStatement = writeMain(context, importer, route);
|
|
23
22
|
const statements: ts.Statement[] = [
|
|
24
23
|
...importer.toStatements(
|
|
25
24
|
(name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,
|
|
26
25
|
),
|
|
27
26
|
FilePrinter.newLine(),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
undefined,
|
|
33
|
-
factory.createNamedImports([
|
|
34
|
-
factory.createImportSpecifier(
|
|
35
|
-
false,
|
|
27
|
+
...(route === undefined
|
|
28
|
+
? []
|
|
29
|
+
: [
|
|
30
|
+
factory.createImportDeclaration(
|
|
36
31
|
undefined,
|
|
37
|
-
factory.
|
|
32
|
+
factory.createImportClause(
|
|
33
|
+
undefined,
|
|
34
|
+
undefined,
|
|
35
|
+
factory.createNamedImports([
|
|
36
|
+
factory.createImportSpecifier(
|
|
37
|
+
false,
|
|
38
|
+
undefined,
|
|
39
|
+
factory.createIdentifier("TestGlobal"),
|
|
40
|
+
),
|
|
41
|
+
]),
|
|
42
|
+
),
|
|
43
|
+
factory.createStringLiteral("./TestGlobal"),
|
|
38
44
|
),
|
|
45
|
+
FilePrinter.newLine(),
|
|
39
46
|
]),
|
|
40
|
-
),
|
|
41
|
-
factory.createStringLiteral("./TestGlobal"),
|
|
42
|
-
),
|
|
43
|
-
FilePrinter.newLine(),
|
|
44
47
|
main,
|
|
45
48
|
factory.createExpressionStatement(writeStarter()),
|
|
46
49
|
];
|
|
@@ -52,7 +55,7 @@ export namespace NestiaMigrateApiStartProgrammer {
|
|
|
52
55
|
const writeMain = (
|
|
53
56
|
ctx: INestiaMigrateContext,
|
|
54
57
|
importer: NestiaMigrateImportProgrammer,
|
|
55
|
-
route: IHttpMigrateRoute,
|
|
58
|
+
route: IHttpMigrateRoute | undefined,
|
|
56
59
|
): ts.VariableStatement =>
|
|
57
60
|
StatementFactory.constant({
|
|
58
61
|
name: "main",
|
|
@@ -64,13 +67,17 @@ export namespace NestiaMigrateApiStartProgrammer {
|
|
|
64
67
|
undefined,
|
|
65
68
|
factory.createBlock(
|
|
66
69
|
[
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
...(route === undefined
|
|
71
|
+
? []
|
|
72
|
+
: [
|
|
73
|
+
writeConnection(ctx, importer),
|
|
74
|
+
...NestiaMigrateE2eFunctionProgrammer.writeBody({
|
|
75
|
+
config: ctx.config,
|
|
76
|
+
components: ctx.application.document().components,
|
|
77
|
+
importer,
|
|
78
|
+
route,
|
|
79
|
+
}),
|
|
80
|
+
]),
|
|
74
81
|
],
|
|
75
82
|
true,
|
|
76
83
|
),
|
|
@@ -191,7 +198,8 @@ export namespace NestiaMigrateApiStartProgrammer {
|
|
|
191
198
|
);
|
|
192
199
|
}
|
|
193
200
|
|
|
194
|
-
const pick = <T>(array: T[]): T => {
|
|
201
|
+
const pick = <T>(array: T[]): T | undefined => {
|
|
202
|
+
if (array.length === 0) return undefined;
|
|
195
203
|
const rand: number = Math.random() * array.length;
|
|
196
204
|
const index: number = Math.min(array.length - 1, Math.floor(rand));
|
|
197
205
|
return array[index]!;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { factory } from "@ttsc/factory";
|
|
1
|
+
import { SyntaxKind, factory } from "@ttsc/factory";
|
|
2
2
|
|
|
3
3
|
import { TypeLiteralFactory } from "../factories/TypeLiteralFactory";
|
|
4
4
|
import ts from "../internal/ts";
|
|
@@ -67,7 +67,7 @@ export class NestiaMigrateImportProgrammer {
|
|
|
67
67
|
factory.createImportDeclaration(
|
|
68
68
|
undefined,
|
|
69
69
|
factory.createImportClause(
|
|
70
|
-
|
|
70
|
+
undefined,
|
|
71
71
|
props.default !== null
|
|
72
72
|
? factory.createIdentifier(props.default)
|
|
73
73
|
: undefined,
|
|
@@ -96,7 +96,7 @@ export class NestiaMigrateImportProgrammer {
|
|
|
96
96
|
// only in type positions — keep the clause type-only so emitted
|
|
97
97
|
// JS never loads the DTO module at runtime.
|
|
98
98
|
factory.createImportClause(
|
|
99
|
-
|
|
99
|
+
SyntaxKind.TypeKeyword,
|
|
100
100
|
undefined,
|
|
101
101
|
factory.createNamedImports(
|
|
102
102
|
names.map((name) =>
|