@nestia/migrate 0.8.1 → 0.8.2-dev.20240217

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/README.md CHANGED
@@ -25,8 +25,8 @@ Nestia is a set of helper libraries for NestJS, supporting below features:
25
25
  > - Runtime validator is **20,000x faster** than `class-validator`
26
26
  > - JSON serialization is **200x faster** than `class-transformer`
27
27
  > - Software Development Kit
28
- > - SDK is a collection of `fetch` functions with type definitions like [tRPC](https://trpc.io/)
29
- > - Mockup simulator means embedded backend simulator in SDK
28
+ > - Collection of typed `fetch` functions with DTO structures like [tRPC](https://trpc.io/)
29
+ > - Mockup simulator means embedded backend simulator in the SDK
30
30
  > - similar with [msw](https://mswjs.io/), but fully automated
31
31
 
32
32
  ![nestia-sdk-demo](https://user-images.githubusercontent.com/13158709/215004990-368c589d-7101-404e-b81b-fbc936382f05.gif)
@@ -59,7 +59,7 @@ Check out the document in the [website](https://nestia.io/docs/):
59
59
  - [TypedRoute](https://nestia.io/docs/core/TypedRoute/)
60
60
  - [TypedBody](https://nestia.io/docs/core/TypedBody/)
61
61
  - [TypedParam](https://nestia.io/docs/core/TypedParam/)
62
- - [TypedQuery](https://nestia.io/docs/core/TypedRoute/)
62
+ - [TypedQuery](https://nestia.io/docs/core/TypedQuery/)
63
63
  - [TypedHeaders](https://nestia.io/docs/core/TypedHeaders/)
64
64
  - [TypedException](https://nestia.io/docs/core/TypedException/)
65
65
  - Generators
package/package.json CHANGED
@@ -1,71 +1,73 @@
1
- {
2
- "name": "@nestia/migrate",
3
- "version": "0.8.1",
4
- "description": "Migration program from swagger to NestJS",
5
- "main": "lib/index.js",
6
- "typings": "lib/index.d.ts",
7
- "bin": {
8
- "@nestia/migrate": "lib/executable/migrate.js"
9
- },
10
- "scripts": {
11
- "build": "rimraf lib && tsc",
12
- "bundle": "ts-node src/executable/bundle.ts",
13
- "dev": "npm run build -- --watch",
14
- "prepare": "ts-patch install && typia patch && npm run bundle",
15
- "test": "node lib/test"
16
- },
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/samchon/nestia"
20
- },
21
- "keywords": [
22
- "migration",
23
- "swagger",
24
- "NestJS",
25
- "nestia"
26
- ],
27
- "author": "Jeongho Nam",
28
- "license": "MIT",
29
- "bugs": {
30
- "url": "https://github.com/samchon/nestia/issues"
31
- },
32
- "homepage": "https://nestia.io",
33
- "devDependencies": {
34
- "@nestia/core": "^2.5.8",
35
- "@nestia/e2e": "^0.4.1",
36
- "@nestia/fetcher": "^2.5.8",
37
- "@nestjs/common": "^10.3.3",
38
- "@nestjs/core": "^10.3.3",
39
- "@nestjs/platform-express": "^10.3.3",
40
- "@nestjs/platform-fastify": "^10.3.3",
41
- "@trivago/prettier-plugin-sort-imports": "^4.3.0",
42
- "@types/express": "^4.17.21",
43
- "@types/inquirer": "^9.0.7",
44
- "@types/node": "^20.3.3",
45
- "dotenv": "^16.3.1",
46
- "dotenv-expand": "^10.0.0",
47
- "rimraf": "^5.0.1",
48
- "serialize-error": "^4.1.0",
49
- "source-map-support": "^0.5.21",
50
- "ts-node": "^10.9.1",
51
- "ts-patch": "^3.1.0",
52
- "typescript-transform-paths": "^3.4.6"
53
- },
54
- "dependencies": {
55
- "commander": "10.0.0",
56
- "inquirer": "8.2.5",
57
- "prettier": "^3.2.5",
58
- "tstl": "^2.5.13",
59
- "typescript": "^5.3.3",
60
- "typia": "^5.4.9"
61
- },
62
- "files": [
63
- "lib",
64
- "src",
65
- "!lib/test",
66
- "!src/test",
67
- "package.json",
68
- "README.md",
69
- "LICENSE"
70
- ]
71
- }
1
+ {
2
+ "name": "@nestia/migrate",
3
+ "version": "0.8.2-dev.20240217",
4
+ "description": "Migration program from swagger to NestJS",
5
+ "main": "lib/index.js",
6
+ "typings": "lib/index.d.ts",
7
+ "bin": {
8
+ "@nestia/migrate": "lib/executable/migrate.js"
9
+ },
10
+ "scripts": {
11
+ "build": "rimraf lib && tsc",
12
+ "bundle": "ts-node src/executable/bundle.ts",
13
+ "dev": "npm run build -- --watch",
14
+ "prepare": "ts-patch install && typia patch && npm run bundle",
15
+ "test": "node lib/test"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/samchon/nestia"
20
+ },
21
+ "keywords": [
22
+ "migration",
23
+ "swagger",
24
+ "NestJS",
25
+ "nestia",
26
+ "SDK",
27
+ "Mockup Simulator"
28
+ ],
29
+ "author": "Jeongho Nam",
30
+ "license": "MIT",
31
+ "bugs": {
32
+ "url": "https://github.com/samchon/nestia/issues"
33
+ },
34
+ "homepage": "https://nestia.io",
35
+ "devDependencies": {
36
+ "@nestia/core": "^2.5.8",
37
+ "@nestia/e2e": "^0.4.1",
38
+ "@nestia/fetcher": "^2.5.8",
39
+ "@nestjs/common": "^10.3.3",
40
+ "@nestjs/core": "^10.3.3",
41
+ "@nestjs/platform-express": "^10.3.3",
42
+ "@nestjs/platform-fastify": "^10.3.3",
43
+ "@trivago/prettier-plugin-sort-imports": "^4.3.0",
44
+ "@types/express": "^4.17.21",
45
+ "@types/inquirer": "^9.0.7",
46
+ "@types/node": "^20.3.3",
47
+ "dotenv": "^16.3.1",
48
+ "dotenv-expand": "^10.0.0",
49
+ "rimraf": "^5.0.1",
50
+ "serialize-error": "^4.1.0",
51
+ "source-map-support": "^0.5.21",
52
+ "ts-node": "^10.9.1",
53
+ "ts-patch": "^3.1.0",
54
+ "typescript-transform-paths": "^3.4.6"
55
+ },
56
+ "dependencies": {
57
+ "commander": "10.0.0",
58
+ "inquirer": "8.2.5",
59
+ "prettier": "^3.2.5",
60
+ "tstl": "^2.5.13",
61
+ "typescript": "^5.3.3",
62
+ "typia": "^5.4.9"
63
+ },
64
+ "files": [
65
+ "lib",
66
+ "src",
67
+ "!lib/test",
68
+ "!src/test",
69
+ "package.json",
70
+ "README.md",
71
+ "LICENSE"
72
+ ]
73
+ }
@@ -3,12 +3,12 @@ import typia from "typia";
3
3
  import { MigrateAnalyzer } from "./analyzers/MigrateAnalyzer";
4
4
  import { NEST_TEMPLATE } from "./bundles/NEST_TEMPLATE";
5
5
  import { SDK_TEMPLATE } from "./bundles/SDK_TEMPLATE";
6
- import { IMigrateProgram } from "./module";
7
6
  import { MigrateApiProgrammer } from "./programmers/MigrateApiProgrammer";
8
7
  import { MigrateApiStartProgrammer } from "./programmers/MigrateApiStartProgrammer";
9
8
  import { MigrateE2eProgrammer } from "./programmers/MigrateE2eProgrammer";
10
9
  import { MigrateNestProgrammer } from "./programmers/MigrateNestProgrammer";
11
10
  import { IMigrateFile } from "./structures/IMigrateFile";
11
+ import { IMigrateProgram } from "./structures/IMigrateProgram";
12
12
  import { ISwagger } from "./structures/ISwagger";
13
13
 
14
14
  export class MigrateApplication {
@@ -1,7 +1,8 @@
1
1
  import { Escaper } from "typia/lib/utils/Escaper";
2
2
 
3
- import { IMigrateProgram, ISwagger } from "../module";
3
+ import { IMigrateProgram } from "../structures/IMigrateProgram";
4
4
  import { IMigrateRoute } from "../structures/IMigrateRoute";
5
+ import { ISwagger } from "../structures/ISwagger";
5
6
  import { ISwaggerRoute } from "../structures/ISwaggerRoute";
6
7
  import { ISwaggerSchema } from "../structures/ISwaggerSchema";
7
8
  import { StringUtil } from "../utils/StringUtil";
@@ -2,8 +2,8 @@ import fs from "fs";
2
2
  import path from "path";
3
3
  import { format } from "prettier";
4
4
 
5
+ import { MigrateApplication } from "../MigrateApplication";
5
6
  import { MigrateFileArchiver } from "../archivers/MigrateFileArchiver";
6
- import { MigrateApplication } from "../module";
7
7
  import { ISwagger } from "../structures/ISwagger";
8
8
  import { MigrateInquirer } from "./MigrateInquirer";
9
9
 
@@ -1,86 +1,86 @@
1
- import commander from "commander";
2
- import inquirer from "inquirer";
3
-
4
- export namespace MigrateInquirer {
5
- export interface IOutput {
6
- mode: "nest" | "sdk";
7
- input: string;
8
- output: string;
9
- simulate: boolean;
10
- e2e: boolean;
11
- }
12
-
13
- export const parse = async (): Promise<IOutput> => {
14
- // PREPARE ASSETS
15
- commander.program.option("--mode [nest/sdk]", "migration mode");
16
- commander.program.option(
17
- "--input [swagger.json]",
18
- "location of target swagger.json file",
19
- );
20
- commander.program.option("--output [directory]", "output directory path");
21
- commander.program.option("--simulate", "Mockup simulator");
22
- commander.program.option("--e2e [boolean]", "Generate E2E tests");
23
-
24
- // INTERNAL PROCEDURES
25
- const questioned = { value: false };
26
- const action = (closure: (options: Partial<IOutput>) => Promise<IOutput>) =>
27
- new Promise<IOutput>((resolve, reject) => {
28
- commander.program.action(async (options) => {
29
- try {
30
- resolve(await closure(options));
31
- } catch (exp) {
32
- reject(exp);
33
- }
34
- });
35
- commander.program.parseAsync().catch(reject);
36
- });
37
- const select =
38
- (name: string) =>
39
- (message: string) =>
40
- async <Choice extends string>(
41
- choices: Choice[],
42
- filter?: (value: string) => Choice,
43
- ): Promise<Choice> => {
44
- questioned.value = true;
45
- return (
46
- await inquirer.createPromptModule()({
47
- type: "list",
48
- name: name,
49
- message: message,
50
- choices: choices,
51
- filter,
52
- })
53
- )[name];
54
- };
55
- const input = (name: string) => async (message: string) =>
56
- (
57
- await inquirer.createPromptModule()({
58
- type: "input",
59
- name,
60
- message,
61
- })
62
- )[name];
63
-
64
- // DO CONSTRUCT
65
- return action(async (partial) => {
66
- partial.mode ??= await select("mode")("Migration mode")(
67
- ["NestJS" as "nest", "SDK" as "sdk"],
68
- (value) => (value === "NestJS" ? "nest" : "sdk"),
69
- );
70
- partial.input ??= await input("input")("Swagger file location");
71
- partial.output ??= await input("output")("Output directory path");
72
- if (partial.simulate)
73
- partial.simulate = (partial.simulate as any) === "true";
74
- else
75
- partial.simulate =
76
- (await select("simulate")("Mokup Simulator")(["true", "false"])) ===
77
- "true";
78
- if (partial.e2e) partial.e2e = (partial.e2e as any) === "true";
79
- else
80
- partial.e2e =
81
- (await select("e2e")("Generate E2E tests")(["true", "false"])) ===
82
- "true";
83
- return partial as IOutput;
84
- });
85
- };
86
- }
1
+ import commander from "commander";
2
+ import inquirer from "inquirer";
3
+
4
+ export namespace MigrateInquirer {
5
+ export interface IOutput {
6
+ mode: "nest" | "sdk";
7
+ input: string;
8
+ output: string;
9
+ simulate: boolean;
10
+ e2e: boolean;
11
+ }
12
+
13
+ export const parse = async (): Promise<IOutput> => {
14
+ // PREPARE ASSETS
15
+ commander.program.option("--mode [nest/sdk]", "migration mode");
16
+ commander.program.option(
17
+ "--input [swagger.json]",
18
+ "location of target swagger.json file",
19
+ );
20
+ commander.program.option("--output [directory]", "output directory path");
21
+ commander.program.option("--simulate", "Mockup simulator");
22
+ commander.program.option("--e2e [boolean]", "Generate E2E tests");
23
+
24
+ // INTERNAL PROCEDURES
25
+ const questioned = { value: false };
26
+ const action = (closure: (options: Partial<IOutput>) => Promise<IOutput>) =>
27
+ new Promise<IOutput>((resolve, reject) => {
28
+ commander.program.action(async (options) => {
29
+ try {
30
+ resolve(await closure(options));
31
+ } catch (exp) {
32
+ reject(exp);
33
+ }
34
+ });
35
+ commander.program.parseAsync().catch(reject);
36
+ });
37
+ const select =
38
+ (name: string) =>
39
+ (message: string) =>
40
+ async <Choice extends string>(
41
+ choices: Choice[],
42
+ filter?: (value: string) => Choice,
43
+ ): Promise<Choice> => {
44
+ questioned.value = true;
45
+ return (
46
+ await inquirer.createPromptModule()({
47
+ type: "list",
48
+ name: name,
49
+ message: message,
50
+ choices: choices,
51
+ filter,
52
+ })
53
+ )[name];
54
+ };
55
+ const input = (name: string) => async (message: string) =>
56
+ (
57
+ await inquirer.createPromptModule()({
58
+ type: "input",
59
+ name,
60
+ message,
61
+ })
62
+ )[name];
63
+
64
+ // DO CONSTRUCT
65
+ return action(async (partial) => {
66
+ partial.mode ??= await select("mode")("Migration mode")(
67
+ ["NestJS" as "nest", "SDK" as "sdk"],
68
+ (value) => (value === "NestJS" ? "nest" : "sdk"),
69
+ );
70
+ partial.input ??= await input("input")("Swagger file location");
71
+ partial.output ??= await input("output")("Output directory path");
72
+ if (partial.simulate)
73
+ partial.simulate = (partial.simulate as any) === "true";
74
+ else
75
+ partial.simulate =
76
+ (await select("simulate")("Mokup Simulator")(["true", "false"])) ===
77
+ "true";
78
+ if (partial.e2e) partial.e2e = (partial.e2e as any) === "true";
79
+ else
80
+ partial.e2e =
81
+ (await select("e2e")("Generate E2E tests")(["true", "false"])) ===
82
+ "true";
83
+ return partial as IOutput;
84
+ });
85
+ };
86
+ }
@@ -1,7 +1,7 @@
1
1
  import ts from "typescript";
2
2
 
3
- import { IMigrateProgram } from "../module";
4
3
  import { IMigrateController } from "../structures/IMigrateController";
4
+ import { IMigrateProgram } from "../structures/IMigrateProgram";
5
5
  import { IMigrateRoute } from "../structures/IMigrateRoute";
6
6
  import { ISwaggerComponents } from "../structures/ISwaggerComponents";
7
7
  import { MigrateApiFunctionProgrammer } from "./MigrateApiFunctionProgrammer";
@@ -1,8 +1,8 @@
1
1
  import ts from "typescript";
2
2
  import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
3
3
 
4
- import { IMigrateProgram } from "../module";
5
4
  import { IMigrateController } from "../structures/IMigrateController";
5
+ import { IMigrateProgram } from "../structures/IMigrateProgram";
6
6
  import { IMigrateRoute } from "../structures/IMigrateRoute";
7
7
  import { ISwaggerComponents } from "../structures/ISwaggerComponents";
8
8
  import { FilePrinter } from "../utils/FilePrinter";
@@ -2,8 +2,8 @@ import { HashMap, IPointer, hash } from "tstl";
2
2
  import ts from "typescript";
3
3
  import { Escaper } from "typia/lib/utils/Escaper";
4
4
 
5
- import { IMigrateProgram } from "../module";
6
5
  import { IMigrateFile } from "../structures/IMigrateFile";
6
+ import { IMigrateProgram } from "../structures/IMigrateProgram";
7
7
  import { FilePrinter } from "../utils/FilePrinter";
8
8
  import { StringUtil } from "../utils/StringUtil";
9
9
  import { MigrateApiFileProgrammer } from "./MigrateApiFileProgrammer";
@@ -1,8 +1,8 @@
1
1
  import ts from "typescript";
2
2
  import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
3
3
 
4
- import { ISwaggerComponents } from "../module";
5
4
  import { IMigrateRoute } from "../structures/IMigrateRoute";
5
+ import { ISwaggerComponents } from "../structures/ISwaggerComponents";
6
6
  import { MigrateImportProgrammer } from "./MigrateImportProgrammer";
7
7
  import { MigrateSchemaProgrammer } from "./MigrateSchemaProgrammer";
8
8
 
@@ -1,8 +1,9 @@
1
1
  import ts from "typescript";
2
2
 
3
- import { IMigrateProgram, ISwaggerComponents } from "../module";
4
3
  import { IMigrateFile } from "../structures/IMigrateFile";
4
+ import { IMigrateProgram } from "../structures/IMigrateProgram";
5
5
  import { IMigrateRoute } from "../structures/IMigrateRoute";
6
+ import { ISwaggerComponents } from "../structures/ISwaggerComponents";
6
7
  import { FilePrinter } from "../utils/FilePrinter";
7
8
  import { MigrateE2eFunctionProgrammer } from "./MigrateE2eFileProgrammer";
8
9
  import { MigrateImportProgrammer } from "./MigrateImportProgrammer";