@nestia/migrate 7.2.3 → 7.3.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/NestiaMigrateApplication.js +12 -12
- package/lib/bundles/NEST_TEMPLATE.js +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +1 -1
- package/lib/index.mjs +16 -16
- package/lib/index.mjs.map +1 -1
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +13 -10
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +1 -2
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -1
- package/lib/structures/INestiaMigrateConfig.d.ts +2 -2
- package/package.json +6 -6
- package/src/bundles/NEST_TEMPLATE.ts +1 -1
- package/src/bundles/SDK_TEMPLATE.ts +1 -1
- package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +4 -1
- package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +27 -28
- package/src/structures/INestiaMigrateConfig.ts +5 -2
@@ -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\nnpm install\nnpm start # run only \"test/start.ts\" file\nnpm run test # everything under the \"test/features\" directory\nnpm run test:simulate # \"test/features\" with mockup simulation mode\n```\n\nIf you run `npm start` command, only [test/start.ts](test/start.ts) file would be executed.\n\nOtherwise you run `npm 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\nnpm install -g @nestia/migrate\nnpx @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\nnpm install\nnpm run deploy\n```\n\nJust run `npm 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",
|
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(\"npm run start\", \"Run only test/start.ts\");\nprint(\"npm run test\", \"Run every test/features/**/*.ts files\");\nprint(\"npm 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\": \"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\": \"^7.
|
8
|
+
"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\": \"^7.3.0\",\n \"tgrid\": \"^1.2.0\",\n \"typia\": \"^9.6.0\"\n },\n \"devDependencies\": {\n \"@nestia/e2e\": \"^7.3.0\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^11.1.6\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/express\": \"^4.17.21\",\n \"@types/inquirer\": \"8.2.5\",\n \"@types/swagger-ui-express\": \"^4.1.6\",\n \"chalk\": \"4.1.2\",\n \"commander\": \"^10.0.0\",\n \"express\": \"^4.19.2\",\n \"inquirer\": \"8.2.5\",\n \"prettier\": \"^3.2.5\",\n \"rimraf\": \"^5.0.5\",\n \"rollup\": \"^4.13.2\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"ts-node\": \"^10.9.2\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.8.3\",\n \"typescript-transform-paths\": \"^3.5.5\"\n }\n}",
|
9
9
|
"prettier.config.js": "module.exports = {\n // DEFAULT CONFIGURATIONS\n parser: \"typescript\",\n printWidth: 80,\n semi: true,\n tabWidth: 2,\n trailingComma: \"all\",\n\n // PLUG-IN CONFIGURATIONS\n plugins: [\"@trivago/prettier-plugin-sort-imports\"],\n importOrder: [\"<THIRD_PARTY_MODULES>\", \"^[./]\"],\n importOrderSeparation: true,\n importOrderSortSpecifiers: true,\n importOrderParserPlugins: [\"decorators-legacy\", \"typescript\", \"jsx\"],\n};\n",
|
10
10
|
"rollup.config.js": "const typescript = require(\"@rollup/plugin-typescript\");\nconst terser = require(\"@rollup/plugin-terser\");\n\nmodule.exports = {\n input: \"./src/index.ts\",\n output: {\n dir: \"lib\",\n format: \"esm\",\n entryFileNames: \"[name].mjs\",\n sourcemap: true,\n },\n plugins: [\n typescript({\n tsconfig: \"tsconfig.json\",\n module: \"ES2020\",\n target: \"ES2020\",\n }),\n terser({\n format: {\n comments: \"some\",\n beautify: true,\n ecma: \"2020\",\n },\n compress: false,\n mangle: false,\n module: true,\n }),\n ],\n};\n",
|
11
11
|
"src/HttpError.ts": "export { HttpError } from \"@nestia/fetcher\";\n",
|
@@ -41,7 +41,10 @@ export namespace NestiaMigrateNestControllerProgrammer {
|
|
41
41
|
props.controller.routes
|
42
42
|
.map((route, index) => [
|
43
43
|
...(index !== 0 ? [FilePrinter.newLine() as any] : []),
|
44
|
-
|
44
|
+
(
|
45
|
+
props.config.programmer?.controllerMethod ??
|
46
|
+
NestiaMigrateNestMethodProgrammer.write
|
47
|
+
)({
|
45
48
|
config: props.config,
|
46
49
|
components: props.components,
|
47
50
|
controller: props.controller,
|
@@ -42,38 +42,37 @@ export namespace NestiaMigrateNestMethodProgrammer {
|
|
42
42
|
undefined,
|
43
43
|
writeParameters(ctx),
|
44
44
|
ts.factory.createTypeReferenceNode("Promise", [output]),
|
45
|
-
|
46
|
-
|
47
|
-
[
|
48
|
-
...
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
ts.factory.
|
55
|
-
ts.factory.createIdentifier(str),
|
56
|
-
),
|
45
|
+
ts.factory.createBlock(
|
46
|
+
[
|
47
|
+
...[
|
48
|
+
...ctx.route.parameters.map((p) => p.key),
|
49
|
+
...(ctx.route.headers ? ["headers"] : []),
|
50
|
+
...(ctx.route.query ? ["query"] : []),
|
51
|
+
...(ctx.route.body ? ["body"] : []),
|
52
|
+
].map((str) =>
|
53
|
+
ts.factory.createExpressionStatement(
|
54
|
+
ts.factory.createIdentifier(str),
|
57
55
|
),
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
),
|
68
|
-
"random",
|
56
|
+
),
|
57
|
+
ts.factory.createReturnStatement(
|
58
|
+
ts.factory.createCallExpression(
|
59
|
+
IdentifierFactory.access(
|
60
|
+
ts.factory.createIdentifier(
|
61
|
+
ctx.importer.external({
|
62
|
+
type: "default",
|
63
|
+
library: "typia",
|
64
|
+
name: "typia",
|
65
|
+
}),
|
69
66
|
),
|
70
|
-
|
71
|
-
undefined,
|
67
|
+
"random",
|
72
68
|
),
|
69
|
+
[output],
|
70
|
+
undefined,
|
73
71
|
),
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
),
|
73
|
+
],
|
74
|
+
true,
|
75
|
+
),
|
77
76
|
);
|
78
77
|
return FilePrinter.description(
|
79
78
|
method,
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import { IHttpMigrateRoute } from "@samchon/openapi";
|
2
1
|
import ts from "typescript";
|
3
2
|
|
3
|
+
import { NestiaMigrateNestMethodProgrammer } from "../programmers/NestiaMigrateNestMethodProgrammer";
|
4
|
+
|
4
5
|
export interface INestiaMigrateConfig {
|
5
6
|
simulate: boolean;
|
6
7
|
e2e: boolean;
|
@@ -11,6 +12,8 @@ export interface INestiaMigrateConfig {
|
|
11
12
|
value: string;
|
12
13
|
};
|
13
14
|
programmer?: {
|
14
|
-
controllerMethod?: (
|
15
|
+
controllerMethod?: (
|
16
|
+
ctx: NestiaMigrateNestMethodProgrammer.IContext,
|
17
|
+
) => ts.MethodDeclaration;
|
15
18
|
};
|
16
19
|
}
|