@nestia/migrate 0.7.0-dev.20240201 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bundles/NEST_TEMPLATE.js +2 -7
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +1 -6
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/executable/migrate.js +2 -2
- package/lib/executable/migrate.js.map +1 -1
- package/lib/internal/MigrateCommander.d.ts +1 -7
- package/lib/internal/MigrateCommander.js +39 -50
- package/lib/internal/MigrateCommander.js.map +1 -1
- package/lib/internal/MigrateInquirer.d.ts +9 -0
- package/lib/internal/MigrateInquirer.js +72 -0
- package/lib/internal/MigrateInquirer.js.map +1 -0
- package/lib/programmers/ApiFunctionProgrammer.js +1 -1
- package/lib/programmers/ApiSimulatationProgrammer.js +1 -1
- package/package.json +68 -68
- package/src/MigrateApplication.ts +35 -35
- package/src/archivers/FileArchiver.ts +38 -38
- package/src/bundles/NEST_TEMPLATE.ts +2 -7
- package/src/bundles/SDK_TEMPLATE.ts +1 -6
- package/src/executable/bundle.ts +102 -102
- package/src/executable/migrate.ts +7 -7
- package/src/module.ts +4 -4
- package/src/programmers/ApiFunctionProgrammer.ts +1 -1
- package/src/programmers/ApiSimulatationProgrammer.ts +1 -1
- package/src/programmers/DtoProgrammer.ts +74 -74
- package/src/programmers/ImportProgrammer.ts +114 -114
- package/src/programmers/NestControllerProgrammer.ts +48 -48
- package/src/programmers/NestProgrammer.ts +74 -74
- package/src/structures/IMigrateProgram.ts +9 -9
- package/src/structures/IMigrateRoute.ts +44 -44
- package/src/utils/JsonTypeChecker.ts +67 -67
- package/src/utils/SetupWizard.ts +12 -12
- package/src/utils/StringUtil.ts +60 -60
- package/lib/bundles/TEMPLATE.d.ts +0 -5
- package/lib/bundles/TEMPLATE.js +0 -166
- package/lib/bundles/TEMPLATE.js.map +0 -1
- package/lib/internal/MigrateCli.d.ts +0 -3
- package/lib/internal/MigrateCli.js +0 -59
- package/lib/internal/MigrateCli.js.map +0 -1
@@ -55,7 +55,7 @@ exports.NEST_TEMPLATE = [
|
|
55
55
|
{
|
56
56
|
"location": "",
|
57
57
|
"file": "package.json",
|
58
|
-
"content": "{\r\n \"private\": true,\r\n \"name\": \"@ORGANIZATION/PROJECT\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"Starter kit of Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"scripts\": {\r\n \"test\": \"node bin/test\",\r\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\r\n \"------------------------BUILDS------------------------\": \"\",\r\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\r\n \"build:api\": \"rimraf packages/api/lib && npm run build:sdk && tsc -p packages/api/tsconfig.json\",\r\n \"build:main\": \"rimraf lib && tsc\",\r\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\r\n \"build:swagger\": \"npx nestia swagger\",\r\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\r\n \"dev\": \"npm run build:test -- --watch\",\r\n \"eslint\": \"eslint src && eslint test\",\r\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\r\n \"prepare\": \"ts-patch install && typia patch\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"------------------------WEBPACK------------------------\": \"\",\r\n \"webpack\": \"rimraf dist && webpack\",\r\n \"webpack:start\": \"cd dist && node dist/server\",\r\n \"------------------------DEPLOYS------------------------\": \"\",\r\n \"package:api\": \"npm run build:swagger && npm run build:api && cd packages/api && npm publish\",\r\n \"start\": \"node lib/executable/server\",\r\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-start\"\r\n },\r\n \"keywords\": [\r\n \"nestia\",\r\n \"template\",\r\n \"boilerplate\"\r\n ],\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.4.1\",\r\n \"@nestia/sdk\": \"^2.
|
58
|
+
"content": "{\r\n \"private\": true,\r\n \"name\": \"@ORGANIZATION/PROJECT\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"Starter kit of Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"scripts\": {\r\n \"test\": \"node bin/test\",\r\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\r\n \"------------------------BUILDS------------------------\": \"\",\r\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\r\n \"build:api\": \"rimraf packages/api/lib && npm run build:sdk && tsc -p packages/api/tsconfig.json\",\r\n \"build:main\": \"rimraf lib && tsc\",\r\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\r\n \"build:swagger\": \"npx nestia swagger\",\r\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\r\n \"dev\": \"npm run build:test -- --watch\",\r\n \"eslint\": \"eslint src && eslint test\",\r\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\r\n \"prepare\": \"ts-patch install && typia patch\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"------------------------WEBPACK------------------------\": \"\",\r\n \"webpack\": \"rimraf dist && webpack\",\r\n \"webpack:start\": \"cd dist && node dist/server\",\r\n \"------------------------DEPLOYS------------------------\": \"\",\r\n \"package:api\": \"npm run build:swagger && npm run build:api && cd packages/api && npm publish\",\r\n \"start\": \"node lib/executable/server\",\r\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-start\"\r\n },\r\n \"keywords\": [\r\n \"nestia\",\r\n \"template\",\r\n \"boilerplate\"\r\n ],\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.4.1\",\r\n \"@nestia/sdk\": \"^2.5.0\",\r\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\r\n \"@types/cli\": \"^0.11.21\",\r\n \"@types/express\": \"^4.17.21\",\r\n \"@types/inquirer\": \"^8.2.5\",\r\n \"@types/node\": \"^18.11.0\",\r\n \"@types/uuid\": \"^8.3.4\",\r\n \"@typescript-eslint/eslint-plugin\": \"^6.19.1\",\r\n \"@typescript-eslint/parser\": \"^6.19.1\",\r\n \"chalk\": \"^4.1.0\",\r\n \"cli\": \"^1.0.1\",\r\n \"copy-webpack-plugin\": \"^11.0.0\",\r\n \"eslint-plugin-deprecation\": \"^2.0.0\",\r\n \"express\": \"^4.18.2\",\r\n \"nestia\": \"^5.2.1\",\r\n \"prettier\": \"^3.2.4\",\r\n \"prettier-plugin-prisma\": \"^5.0.0\",\r\n \"rimraf\": \"^3.0.2\",\r\n \"source-map-support\": \"^0.5.21\",\r\n \"swagger-ui-express\": \"^5.0.0\",\r\n \"ts-loader\": \"^9.5.1\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.2\",\r\n \"typescript\": \"^5.3.2\",\r\n \"typescript-transform-paths\": \"^3.4.6\",\r\n \"webpack\": \"^5.89.0\",\r\n \"webpack-cli\": \"^5.1.4\",\r\n \"write-file-webpack-plugin\": \"^4.5.1\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/core\": \"^2.5.0\",\r\n \"@nestia/fetcher\": \"^2.5.0\",\r\n \"@nestjs/common\": \"^10.3.0\",\r\n \"@nestjs/core\": \"^10.3.0\",\r\n \"@nestjs/platform-fastify\": \"^10.3.0\",\r\n \"commander\": \"10.0.0\",\r\n \"dotenv\": \"^16.3.1\",\r\n \"dotenv-expand\": \"^10.0.0\",\r\n \"inquirer\": \"8.2.5\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^5.4.1\",\r\n \"uuid\": \"^9.0.0\"\r\n },\r\n \"stackblitz\": {\r\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test\"\r\n }\r\n}"
|
59
59
|
},
|
60
60
|
{
|
61
61
|
"location": "packages/api",
|
@@ -70,7 +70,7 @@ exports.NEST_TEMPLATE = [
|
|
70
70
|
{
|
71
71
|
"location": "packages/api",
|
72
72
|
"file": "package.json",
|
73
|
-
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"SDK library generated by Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"scripts\": {\r\n \"build\": \"npm run build:sdk && npm run compile\",\r\n \"build:sdk\": \"rimraf ../../src/api/functional && cd ../.. && npx nestia sdk && cd packages/api\",\r\n \"compile\": \"rimraf lib && tsc\",\r\n \"deploy\": \"npm run build && npm publish\",\r\n \"prepare\": \"ts-patch install && typia patch\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia\"\r\n },\r\n \"author\": \"Jeongho Nam\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia/issues\"\r\n },\r\n \"homepage\": \"https://nestia.io\",\r\n \"files\": [\r\n \"lib\",\r\n \"swagger.json\",\r\n \"package.json\",\r\n \"README.md\"\r\n ],\r\n \"devDependencies\": {\r\n \"rimraf\": \"^5.0.5\",\r\n \"ts-node\": \"^10.9.2\",\r\n \"ts-patch\": \"^3.1.2\",\r\n \"typescript\": \"^5.3.3\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^2.
|
73
|
+
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"SDK library generated by Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"scripts\": {\r\n \"build\": \"npm run build:sdk && npm run compile\",\r\n \"build:sdk\": \"rimraf ../../src/api/functional && cd ../.. && npx nestia sdk && cd packages/api\",\r\n \"compile\": \"rimraf lib && tsc\",\r\n \"deploy\": \"npm run build && npm publish\",\r\n \"prepare\": \"ts-patch install && typia patch\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia\"\r\n },\r\n \"author\": \"Jeongho Nam\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia/issues\"\r\n },\r\n \"homepage\": \"https://nestia.io\",\r\n \"files\": [\r\n \"lib\",\r\n \"swagger.json\",\r\n \"package.json\",\r\n \"README.md\"\r\n ],\r\n \"devDependencies\": {\r\n \"rimraf\": \"^5.0.5\",\r\n \"ts-node\": \"^10.9.2\",\r\n \"ts-patch\": \"^3.1.2\",\r\n \"typescript\": \"^5.3.3\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^2.5.0\",\r\n \"typia\": \"^5.4.1\"\r\n }\r\n}"
|
74
74
|
},
|
75
75
|
{
|
76
76
|
"location": "packages/api",
|
@@ -132,11 +132,6 @@ exports.NEST_TEMPLATE = [
|
|
132
132
|
"file": "IPage.ts",
|
133
133
|
"content": "import { tags } from \"typia\";\r\n\r\n/**\r\n * A page.\r\n *\r\n * Collection of records with pagination indformation.\r\n *\r\n * @author Samchon\r\n */\r\nexport interface IPage<T extends object> {\r\n /**\r\n * Page information.\r\n */\r\n pagination: IPage.IPagination;\r\n\r\n /**\r\n * List of records.\r\n */\r\n data: T[];\r\n}\r\nexport namespace IPage {\r\n /**\r\n * Page information.\r\n */\r\n export interface IPagination {\r\n /**\r\n * Current page number.\r\n */\r\n current: number & tags.Type<\"uint32\">;\r\n\r\n /**\r\n * Limitation of records per a page.\r\n *\r\n * @default 100\r\n */\r\n limit: number & tags.Type<\"uint32\">;\r\n\r\n /**\r\n * Count of total records in database.\r\n */\r\n records: number & tags.Type<\"uint32\">;\r\n\r\n /**\r\n * Number of total pages.\r\n *\r\n * Equal to {@link records} / {@link limit} with ceiling.\r\n */\r\n pages: number & tags.Type<\"uint32\">;\r\n }\r\n\r\n /**\r\n * Page request data\r\n */\r\n export interface IRequest {\r\n /**\r\n * Page number.\r\n */\r\n page?: number & tags.Type<\"uint32\">;\r\n\r\n /**\r\n * Limitation of records per a page.\r\n */\r\n limit?: number & tags.Type<\"uint32\">;\r\n }\r\n\r\n /**\r\n * Sorting column specialization.\r\n *\r\n * The plus means ascending order and the minus means descending order.\r\n */\r\n export type Sort<Literal extends string> = Array<\r\n `-${Literal}` | `+${Literal}`\r\n >;\r\n}\r\n"
|
134
134
|
},
|
135
|
-
{
|
136
|
-
"location": "src/api/utils",
|
137
|
-
"file": "NestiaSimulator.ts",
|
138
|
-
"content": "import { HttpError } from \"@nestia/fetcher\";\r\n\r\nimport typia from \"typia\";\r\n\r\nexport namespace NestiaSimulator {\r\n export interface IProps {\r\n host: string;\r\n path: string;\r\n method: \"GET\" | \"POST\" | \"PATCH\" | \"PUT\" | \"DELETE\";\r\n contentType: string;\r\n }\r\n\r\n export const assert = (props: IProps) => {\r\n return {\r\n param: param(props),\r\n query: query(props),\r\n body: body(props),\r\n };\r\n };\r\n const param =\r\n (props: IProps) =>\r\n (name: string) =>\r\n <T>(task: () => T): void => {\r\n validate(\r\n (exp) => `URL parameter \"${name}\" is not ${exp.expected} type.`,\r\n )(props)(task);\r\n };\r\n\r\n const query =\r\n (props: IProps) =>\r\n <T>(task: () => T): void =>\r\n validate(\r\n () =>\r\n \"Request query parameters are not following the promised type.\",\r\n )(props)(task);\r\n\r\n const body =\r\n (props: IProps) =>\r\n <T>(task: () => T): void =>\r\n validate(() => \"Request body is not following the promised type.\")(\r\n props,\r\n )(task);\r\n\r\n const validate =\r\n (message: (exp: typia.TypeGuardError) => string, path?: string) =>\r\n (props: IProps) =>\r\n <T>(task: () => T): void => {\r\n try {\r\n task();\r\n } catch (exp) {\r\n if (typia.is<typia.TypeGuardError>(exp))\r\n throw new HttpError(\r\n props.method,\r\n props.host + props.path,\r\n 400,\r\n {\r\n \"Content-Type\": props.contentType,\r\n },\r\n JSON.stringify({\r\n method: exp.method,\r\n path: path ?? exp.path,\r\n expected: exp.expected,\r\n value: exp.value,\r\n message: message(exp),\r\n }),\r\n );\r\n throw exp;\r\n }\r\n };\r\n}\r\n"
|
139
|
-
},
|
140
135
|
{
|
141
136
|
"location": "src/executable",
|
142
137
|
"file": "server.ts",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"NEST_TEMPLATE.js","sourceRoot":"","sources":["../../src/bundles/NEST_TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IAC3B;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,+CAA+C;KAC3D;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,m1BAAm1B;KAC/1B;IACD;QACE,UAAU,EAAE,SAAS;QACrB,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,qrBAAqrB;KACjsB;IACD;QACE,UAAU,EAAE,mBAAmB;QAC/B,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,yrBAAyrB;KACrsB;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,iHAAiH;KAC7H;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,iBAAiB;QACzB,SAAS,EAAE,iIAAiI;KAC7I;IACD;QACE,UAAU,EAAE,SAAS;QACrB,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,irCAAirC;KAC7rC;IACD;QACE,UAAU,EAAE,SAAS;QACrB,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,qRAAqR;KACjS;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,inCAAinC;KAC7nC;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,kBAAkB;QAC1B,SAAS,EAAE,oqBAAoqB;KAChrB;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,
|
1
|
+
{"version":3,"file":"NEST_TEMPLATE.js","sourceRoot":"","sources":["../../src/bundles/NEST_TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IAC3B;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,+CAA+C;KAC3D;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,m1BAAm1B;KAC/1B;IACD;QACE,UAAU,EAAE,SAAS;QACrB,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,qrBAAqrB;KACjsB;IACD;QACE,UAAU,EAAE,mBAAmB;QAC/B,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,yrBAAyrB;KACrsB;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,iHAAiH;KAC7H;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,iBAAiB;QACzB,SAAS,EAAE,iIAAiI;KAC7I;IACD;QACE,UAAU,EAAE,SAAS;QACrB,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,irCAAirC;KAC7rC;IACD;QACE,UAAU,EAAE,SAAS;QACrB,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,qRAAqR;KACjS;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,inCAAinC;KAC7nC;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EA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MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,y8XAAy8X;KACr9X;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,mBAAmB;QAC3B,SAAS,EAAE,g1DAAg1D;KAC51D;CACF,CAAA"}
|
@@ -15,7 +15,7 @@ exports.SDK_TEMPLATE = [
|
|
15
15
|
{
|
16
16
|
"location": "",
|
17
17
|
"file": "package.json",
|
18
|
-
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"SDK library generated by Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"scripts\": {\r\n \"build\": \"rimraf lib && tsc\",\r\n \"prepare\": \"ts-patch install && typia patch\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia\"\r\n },\r\n \"author\": \"Jeongho Nam\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia/issues\"\r\n },\r\n \"homepage\": \"https://nestia.io\",\r\n \"files\": [\r\n \"lib\",\r\n \"swagger.json\",\r\n \"package.json\",\r\n \"README.md\"\r\n ],\r\n \"devDependencies\": {\r\n \"rimraf\": \"^5.0.5\",\r\n \"ts-node\": \"^10.9.2\",\r\n \"ts-patch\": \"^3.1.2\",\r\n \"typescript\": \"^5.3.3\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^2.
|
18
|
+
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"SDK library generated by Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"scripts\": {\r\n \"build\": \"rimraf lib && tsc\",\r\n \"prepare\": \"ts-patch install && typia patch\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia\"\r\n },\r\n \"author\": \"Jeongho Nam\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia/issues\"\r\n },\r\n \"homepage\": \"https://nestia.io\",\r\n \"files\": [\r\n \"lib\",\r\n \"swagger.json\",\r\n \"package.json\",\r\n \"README.md\"\r\n ],\r\n \"devDependencies\": {\r\n \"rimraf\": \"^5.0.5\",\r\n \"ts-node\": \"^10.9.2\",\r\n \"ts-patch\": \"^3.1.2\",\r\n \"typescript\": \"^5.3.3\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^2.5.0\",\r\n \"typia\": \"^5.4.1\"\r\n }\r\n}"
|
19
19
|
},
|
20
20
|
{
|
21
21
|
"location": "",
|
@@ -47,11 +47,6 @@ exports.SDK_TEMPLATE = [
|
|
47
47
|
"file": "Primitive.ts",
|
48
48
|
"content": "export type { Primitive } from \"@nestia/fetcher\";\r\n"
|
49
49
|
},
|
50
|
-
{
|
51
|
-
"location": "src/utils",
|
52
|
-
"file": "NestiaSimulator.ts",
|
53
|
-
"content": "import { HttpError } from \"@nestia/fetcher\";\r\n\r\nimport typia from \"typia\";\r\n\r\nexport namespace NestiaSimulator {\r\n export interface IProps {\r\n host: string;\r\n path: string;\r\n method: \"GET\" | \"POST\" | \"PATCH\" | \"PUT\" | \"DELETE\";\r\n contentType: string;\r\n }\r\n\r\n export const assert = (props: IProps) => {\r\n return {\r\n param: param(props),\r\n query: query(props),\r\n body: body(props),\r\n };\r\n };\r\n const param =\r\n (props: IProps) =>\r\n (name: string) =>\r\n <T>(task: () => T): void => {\r\n validate(\r\n (exp) => `URL parameter \"${name}\" is not ${exp.expected} type.`,\r\n )(props)(task);\r\n };\r\n\r\n const query =\r\n (props: IProps) =>\r\n <T>(task: () => T): void =>\r\n validate(\r\n () =>\r\n \"Request query parameters are not following the promised type.\",\r\n )(props)(task);\r\n\r\n const body =\r\n (props: IProps) =>\r\n <T>(task: () => T): void =>\r\n validate(() => \"Request body is not following the promised type.\")(\r\n props,\r\n )(task);\r\n\r\n const validate =\r\n (message: (exp: typia.TypeGuardError) => string, path?: string) =>\r\n (props: IProps) =>\r\n <T>(task: () => T): void => {\r\n try {\r\n task();\r\n } catch (exp) {\r\n if (typia.is<typia.TypeGuardError>(exp))\r\n throw new HttpError(\r\n props.method,\r\n props.host + props.path,\r\n 400,\r\n {\r\n \"Content-Type\": props.contentType,\r\n },\r\n JSON.stringify({\r\n method: exp.method,\r\n path: path ?? exp.path,\r\n expected: exp.expected,\r\n value: exp.value,\r\n message: message(exp),\r\n }),\r\n );\r\n throw exp;\r\n }\r\n };\r\n}\r\n"
|
54
|
-
},
|
55
50
|
{
|
56
51
|
"location": "",
|
57
52
|
"file": "tsconfig.json",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SDK_TEMPLATE.js","sourceRoot":"","sources":["../../src/bundles/SDK_TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IAC1B;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,2EAA2E;KACvF;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,inCAAinC;KAC7nC;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,2/BAA2/B;KACvgC;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,mmEAAmmE;KAC/mE;IACD;QACE,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,oDAAoD;KAChE;IACD;QACE,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,2DAA2D;KACvE;IACD;QACE,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,kGAAkG;KAC9G;IACD;QACE,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,kIAAkI;KAC9I;IACD;QACE,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,yDAAyD;KACrE;IACD;QACE,UAAU,EAAE,
|
1
|
+
{"version":3,"file":"SDK_TEMPLATE.js","sourceRoot":"","sources":["../../src/bundles/SDK_TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IAC1B;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,2EAA2E;KACvF;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,inCAAinC;KAC7nC;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,2/BAA2/B;KACvgC;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,mmEAAmmE;KAC/mE;IACD;QACE,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,oDAAoD;KAChE;IACD;QACE,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,2DAA2D;KACvE;IACD;QACE,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,kGAAkG;KAC9G;IACD;QACE,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,kIAAkI;KAC9I;IACD;QACE,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,yDAAyD;KACrE;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,6sWAA6sW;KACztW;CACF,CAAA"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
"use strict";
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
const
|
5
|
-
|
4
|
+
const MigrateCommander_1 = require("../internal/MigrateCommander");
|
5
|
+
MigrateCommander_1.MigrateCommander.main().catch((exp) => {
|
6
6
|
console.error(exp);
|
7
7
|
process.exit(-1);
|
8
8
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/executable/migrate.ts"],"names":[],"mappings":";;;AACA,
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/executable/migrate.ts"],"names":[],"mappings":";;;AACA,mEAAgE;AAEhE,mCAAgB,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACpC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC"}
|
@@ -13,58 +13,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
exports.MigrateCommander = void 0;
|
16
|
-
const
|
17
|
-
const
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
17
|
+
const path_1 = __importDefault(require("path"));
|
18
|
+
const FileArchiver_1 = require("../archivers/FileArchiver");
|
19
|
+
const module_1 = require("../module");
|
20
|
+
const MigrateInquirer_1 = require("./MigrateInquirer");
|
18
21
|
var MigrateCommander;
|
19
22
|
(function (MigrateCommander) {
|
20
|
-
MigrateCommander.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
return (yield inquirer_1.default.createPromptModule()({
|
51
|
-
type: "input",
|
52
|
-
name,
|
53
|
-
message,
|
54
|
-
}))[name];
|
55
|
-
});
|
56
|
-
// DO CONSTRUCT
|
57
|
-
return action((partial) => __awaiter(this, void 0, void 0, function* () {
|
58
|
-
var _a, _b, _c;
|
59
|
-
(_a = partial.mode) !== null && _a !== void 0 ? _a : (partial.mode = yield select("mode")("Migration mode")(["NestJS", "SDK"], (value) => (value === "NestJS" ? "nest" : "sdk")));
|
60
|
-
(_b = partial.input) !== null && _b !== void 0 ? _b : (partial.input = yield input("input")("Swagger file location"));
|
61
|
-
(_c = partial.output) !== null && _c !== void 0 ? _c : (partial.output = yield input("output")("Output directory path"));
|
62
|
-
if (partial.simulate)
|
63
|
-
partial.simulate = partial.simulate === "true";
|
64
|
-
else
|
65
|
-
partial.simulate = yield select("simulate")("Mokup Simulator")(["true", "false"], (str) => str === "Y");
|
66
|
-
return partial;
|
67
|
-
}));
|
23
|
+
MigrateCommander.main = () => __awaiter(this, void 0, void 0, function* () {
|
24
|
+
const resolve = (str) => str ? path_1.default.resolve(str).split("\\").join("/") : undefined;
|
25
|
+
const options = yield MigrateInquirer_1.MigrateInquirer.parse();
|
26
|
+
// VALIDATE OUTPUT DIRECTORY
|
27
|
+
const parent = resolve(options.output + "/..");
|
28
|
+
if (fs_1.default.existsSync(options.output))
|
29
|
+
halt("Output directory alreay exists.");
|
30
|
+
else if (fs_1.default.existsSync(parent) === false)
|
31
|
+
halt("Output directory's parent directory does not exist.");
|
32
|
+
else if (fs_1.default.statSync(parent).isDirectory() === false)
|
33
|
+
halt("Output directory's parent is not a directory.");
|
34
|
+
// READ SWAGGER
|
35
|
+
const swagger = (() => {
|
36
|
+
if (fs_1.default.existsSync(options.input) === false)
|
37
|
+
halt("Unable to find the input swagger.json file.");
|
38
|
+
const stats = fs_1.default.statSync(options.input);
|
39
|
+
if (stats.isFile() === false)
|
40
|
+
halt("The input swagger.json is not a file.");
|
41
|
+
const content = fs_1.default.readFileSync(options.input, "utf-8");
|
42
|
+
const swagger = JSON.parse(content);
|
43
|
+
return swagger;
|
44
|
+
})();
|
45
|
+
const app = new module_1.MigrateApplication(swagger);
|
46
|
+
const files = options.mode === "nest"
|
47
|
+
? app.nest(options.simulate)
|
48
|
+
: app.sdk(options.simulate);
|
49
|
+
yield FileArchiver_1.FileArchiver.archive({
|
50
|
+
mkdir: fs_1.default.promises.mkdir,
|
51
|
+
writeFile: (file, content) => fs_1.default.promises.writeFile(file, content, "utf-8"),
|
52
|
+
})(options.output)(files);
|
68
53
|
});
|
54
|
+
const halt = (desc) => {
|
55
|
+
console.error(desc);
|
56
|
+
process.exit(-1);
|
57
|
+
};
|
69
58
|
})(MigrateCommander || (exports.MigrateCommander = MigrateCommander = {}));
|
70
59
|
//# sourceMappingURL=MigrateCommander.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MigrateCommander.js","sourceRoot":"","sources":["../../src/internal/MigrateCommander.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
1
|
+
{"version":3,"file":"MigrateCommander.js","sourceRoot":"","sources":["../../src/internal/MigrateCommander.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,4DAAyD;AACzD,sCAA+C;AAG/C,uDAAoD;AAEpD,IAAiB,gBAAgB,CA0ChC;AA1CD,WAAiB,gBAAgB;IAClB,qBAAI,GAAG,GAAwB,EAAE;QAC5C,MAAM,OAAO,GAAG,CAAC,GAAuB,EAAE,EAAE,CAC1C,GAAG,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5D,MAAM,OAAO,GAA4B,MAAM,iCAAe,CAAC,KAAK,EAAE,CAAC;QAEvE,4BAA4B;QAC5B,M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B,KAAK,EAAE,YAAE,CAAC,QAAQ,CAAC,KAAK;YACxB,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAC3B,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;SAChD,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC,CAAA,CAAC;IAEF,MAAM,IAAI,GAAG,CAAC,IAAY,EAAS,EAAE;QACnC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC,EA1CgB,gBAAgB,gCAAhB,gBAAgB,QA0ChC"}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.MigrateInquirer = void 0;
|
16
|
+
const commander_1 = __importDefault(require("commander"));
|
17
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
18
|
+
var MigrateInquirer;
|
19
|
+
(function (MigrateInquirer) {
|
20
|
+
MigrateInquirer.parse = () => __awaiter(this, void 0, void 0, function* () {
|
21
|
+
// PREPARE ASSETS
|
22
|
+
commander_1.default.program.option("--mode [nest/sdk]", "migration mode");
|
23
|
+
commander_1.default.program.option("--input [swagger.json]", "location of target swagger.json file");
|
24
|
+
commander_1.default.program.option("--output [directory]", "output directory path");
|
25
|
+
commander_1.default.program.option("--simulate", "Mockup simulator");
|
26
|
+
// INTERNAL PROCEDURES
|
27
|
+
const questioned = { value: false };
|
28
|
+
const action = (closure) => new Promise((resolve, reject) => {
|
29
|
+
commander_1.default.program.action((options) => __awaiter(this, void 0, void 0, function* () {
|
30
|
+
try {
|
31
|
+
resolve(yield closure(options));
|
32
|
+
}
|
33
|
+
catch (exp) {
|
34
|
+
reject(exp);
|
35
|
+
}
|
36
|
+
}));
|
37
|
+
commander_1.default.program.parseAsync().catch(reject);
|
38
|
+
});
|
39
|
+
const select = (name) => (message) => (choices, filter) => __awaiter(this, void 0, void 0, function* () {
|
40
|
+
questioned.value = true;
|
41
|
+
return (yield inquirer_1.default.createPromptModule()({
|
42
|
+
type: "list",
|
43
|
+
name: name,
|
44
|
+
message: message,
|
45
|
+
choices: choices,
|
46
|
+
filter,
|
47
|
+
}))[name];
|
48
|
+
});
|
49
|
+
const input = (name) => (message) => __awaiter(this, void 0, void 0, function* () {
|
50
|
+
return (yield inquirer_1.default.createPromptModule()({
|
51
|
+
type: "input",
|
52
|
+
name,
|
53
|
+
message,
|
54
|
+
}))[name];
|
55
|
+
});
|
56
|
+
// DO CONSTRUCT
|
57
|
+
return action((partial) => __awaiter(this, void 0, void 0, function* () {
|
58
|
+
var _a, _b, _c;
|
59
|
+
(_a = partial.mode) !== null && _a !== void 0 ? _a : (partial.mode = yield select("mode")("Migration mode")(["NestJS", "SDK"], (value) => (value === "NestJS" ? "nest" : "sdk")));
|
60
|
+
(_b = partial.input) !== null && _b !== void 0 ? _b : (partial.input = yield input("input")("Swagger file location"));
|
61
|
+
(_c = partial.output) !== null && _c !== void 0 ? _c : (partial.output = yield input("output")("Output directory path"));
|
62
|
+
if (partial.simulate)
|
63
|
+
partial.simulate = partial.simulate === "true";
|
64
|
+
else
|
65
|
+
partial.simulate =
|
66
|
+
(yield select("simulate")("Mokup Simulator")(["true", "false"])) ===
|
67
|
+
"true";
|
68
|
+
return partial;
|
69
|
+
}));
|
70
|
+
});
|
71
|
+
})(MigrateInquirer || (exports.MigrateInquirer = MigrateInquirer = {}));
|
72
|
+
//# sourceMappingURL=MigrateInquirer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MigrateInquirer.js","sourceRoot":"","sources":["../../src/internal/MigrateInquirer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAkC;AAClC,wDAAgC;AAEhC,IAAiB,eAAe,CA2E/B;AA3ED,WAAiB,eAAe;IAQjB,qBAAK,GAAG,GAA2B,EAAE;QAChD,iBAAiB;QACjB,mBAAS,CAAC,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;QAChE,mBAAS,CAAC,OAAO,CAAC,MAAM,CACtB,wBAAwB,EACxB,sCAAsC,CACvC,CAAC;QACF,mBAAS,CAAC,OAAO,CAAC,MAAM,CAAC,sBAAsB,EAAE,uBAAuB,CAAC,CAAC;QAC1E,mBAAS,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;QAE3D,sBAAsB;QACtB,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACpC,MAAM,MAAM,GAAG,CAAC,OAAwD,EAAE,EAAE,CAC1E,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACvC,mBAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAO,OAAO,EAAE,EAAE;gBACzC,IAAI,CAAC;oBACH,OAAO,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;gBAClC,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC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OAAO,CAAC,CAAC,uBAAuB,CAAC,EAAC;YAChE,MAAA,OAAO,CAAC,MAAM,oCAAd,OAAO,CAAC,MAAM,GAAK,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC,uBAAuB,CAAC,EAAC;YAClE,IAAI,OAAO,CAAC,QAAQ;gBAClB,OAAO,CAAC,QAAQ,GAAI,OAAO,CAAC,QAAgB,KAAK,MAAM,CAAC;;gBAExD,OAAO,CAAC,QAAQ;oBACd,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;wBAChE,MAAM,CAAC;YACX,OAAO,OAAkB,CAAC;QAC5B,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAA,CAAC;AACJ,CAAC,EA3EgB,eAAe,+BAAf,eAAe,QA2E/B"}
|
@@ -19,7 +19,7 @@ var ApiFunctionProgrammer;
|
|
19
19
|
ApiFunctionProgrammer.writeParameterDeclarations = (components) => (importer) => (props) => [
|
20
20
|
IdentifierFactory_1.IdentifierFactory.parameter("connection", typescript_1.default.factory.createTypeReferenceNode(importer.external({
|
21
21
|
type: "instance",
|
22
|
-
library: "@nestia/
|
22
|
+
library: "@nestia/fetcher",
|
23
23
|
name: "IConnection",
|
24
24
|
}), props.route.headers
|
25
25
|
? [typescript_1.default.factory.createTypeReferenceNode(`${props.alias}.Headers`)]
|
@@ -109,7 +109,7 @@ var ApiSimulatationProgrammer;
|
|
109
109
|
})))("is"), [
|
110
110
|
typescript_1.default.factory.createTypeReferenceNode(importer.external({
|
111
111
|
type: "instance",
|
112
|
-
library: "@nestia/
|
112
|
+
library: "@nestia/fetcher",
|
113
113
|
name: "HttpError",
|
114
114
|
})),
|
115
115
|
], [typescript_1.default.factory.createIdentifier("exp")])), typescript_1.default.factory.createThrowStatement(typescript_1.default.factory.createIdentifier("exp"))),
|
package/package.json
CHANGED
@@ -1,68 +1,68 @@
|
|
1
|
-
{
|
2
|
-
"name": "@nestia/migrate",
|
3
|
-
"version": "0.7.
|
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://github.com/samchon/nestia#readme",
|
33
|
-
"devDependencies": {
|
34
|
-
"@nestia/core": "2.5.0
|
35
|
-
"@nestia/fetcher": "2.5.0
|
36
|
-
"@nestjs/common": "^10.3.1",
|
37
|
-
"@nestjs/core": "^10.3.1",
|
38
|
-
"@nestjs/platform-express": "^10.3.1",
|
39
|
-
"@nestjs/platform-fastify": "^10.3.1",
|
40
|
-
"@types/express": "^4.17.21",
|
41
|
-
"@types/inquirer": "^9.0.7",
|
42
|
-
"@types/node": "^20.3.3",
|
43
|
-
"dotenv": "^16.3.1",
|
44
|
-
"dotenv-expand": "^10.0.0",
|
45
|
-
"rimraf": "^5.0.1",
|
46
|
-
"serialize-error": "^4.1.0",
|
47
|
-
"source-map-support": "^0.5.21",
|
48
|
-
"ts-node": "^10.9.1",
|
49
|
-
"ts-patch": "^3.1.0",
|
50
|
-
"tstl": "^2.5.13",
|
51
|
-
"typescript-transform-paths": "^3.4.6"
|
52
|
-
},
|
53
|
-
"dependencies": {
|
54
|
-
"commander": "10.0.0",
|
55
|
-
"inquirer": "8.2.5",
|
56
|
-
"typescript": "^5.3.3",
|
57
|
-
"typia": "^5.4.1"
|
58
|
-
},
|
59
|
-
"files": [
|
60
|
-
"lib",
|
61
|
-
"src",
|
62
|
-
"!lib/test",
|
63
|
-
"!src/test",
|
64
|
-
"package.json",
|
65
|
-
"README.md",
|
66
|
-
"LICENSE"
|
67
|
-
]
|
68
|
-
}
|
1
|
+
{
|
2
|
+
"name": "@nestia/migrate",
|
3
|
+
"version": "0.7.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://github.com/samchon/nestia#readme",
|
33
|
+
"devDependencies": {
|
34
|
+
"@nestia/core": "^2.5.0",
|
35
|
+
"@nestia/fetcher": "^2.5.0",
|
36
|
+
"@nestjs/common": "^10.3.1",
|
37
|
+
"@nestjs/core": "^10.3.1",
|
38
|
+
"@nestjs/platform-express": "^10.3.1",
|
39
|
+
"@nestjs/platform-fastify": "^10.3.1",
|
40
|
+
"@types/express": "^4.17.21",
|
41
|
+
"@types/inquirer": "^9.0.7",
|
42
|
+
"@types/node": "^20.3.3",
|
43
|
+
"dotenv": "^16.3.1",
|
44
|
+
"dotenv-expand": "^10.0.0",
|
45
|
+
"rimraf": "^5.0.1",
|
46
|
+
"serialize-error": "^4.1.0",
|
47
|
+
"source-map-support": "^0.5.21",
|
48
|
+
"ts-node": "^10.9.1",
|
49
|
+
"ts-patch": "^3.1.0",
|
50
|
+
"tstl": "^2.5.13",
|
51
|
+
"typescript-transform-paths": "^3.4.6"
|
52
|
+
},
|
53
|
+
"dependencies": {
|
54
|
+
"commander": "10.0.0",
|
55
|
+
"inquirer": "8.2.5",
|
56
|
+
"typescript": "^5.3.3",
|
57
|
+
"typia": "^5.4.1"
|
58
|
+
},
|
59
|
+
"files": [
|
60
|
+
"lib",
|
61
|
+
"src",
|
62
|
+
"!lib/test",
|
63
|
+
"!src/test",
|
64
|
+
"package.json",
|
65
|
+
"README.md",
|
66
|
+
"LICENSE"
|
67
|
+
]
|
68
|
+
}
|
@@ -1,35 +1,35 @@
|
|
1
|
-
import typia from "typia";
|
2
|
-
|
3
|
-
import { MigrateAnalyzer } from "./analyzers/MigrateAnalyzer";
|
4
|
-
import { NEST_TEMPLATE } from "./bundles/NEST_TEMPLATE";
|
5
|
-
import { SDK_TEMPLATE } from "./bundles/SDK_TEMPLATE";
|
6
|
-
import { ApiProgrammer } from "./programmers/ApiProgrammer";
|
7
|
-
import { NestProgrammer } from "./programmers/NestProgrammer";
|
8
|
-
import { IMigrateFile } from "./structures/IMigrateFile";
|
9
|
-
import { ISwagger } from "./structures/ISwagger";
|
10
|
-
|
11
|
-
export class MigrateApplication {
|
12
|
-
public constructor(public readonly swagger: ISwagger) {
|
13
|
-
typia.assert(swagger);
|
14
|
-
}
|
15
|
-
|
16
|
-
public nest(simulate: boolean): IMigrateFile[] {
|
17
|
-
const program = MigrateAnalyzer.analyze({
|
18
|
-
mode: "nest",
|
19
|
-
simulate,
|
20
|
-
})(this.swagger);
|
21
|
-
return [
|
22
|
-
...NEST_TEMPLATE,
|
23
|
-
...NestProgrammer.write(program),
|
24
|
-
...ApiProgrammer.write(program),
|
25
|
-
];
|
26
|
-
}
|
27
|
-
|
28
|
-
public sdk(simulate: boolean): IMigrateFile[] {
|
29
|
-
const program = MigrateAnalyzer.analyze({
|
30
|
-
mode: "sdk",
|
31
|
-
simulate,
|
32
|
-
})(this.swagger);
|
33
|
-
return [...SDK_TEMPLATE, ...ApiProgrammer.write(program)];
|
34
|
-
}
|
35
|
-
}
|
1
|
+
import typia from "typia";
|
2
|
+
|
3
|
+
import { MigrateAnalyzer } from "./analyzers/MigrateAnalyzer";
|
4
|
+
import { NEST_TEMPLATE } from "./bundles/NEST_TEMPLATE";
|
5
|
+
import { SDK_TEMPLATE } from "./bundles/SDK_TEMPLATE";
|
6
|
+
import { ApiProgrammer } from "./programmers/ApiProgrammer";
|
7
|
+
import { NestProgrammer } from "./programmers/NestProgrammer";
|
8
|
+
import { IMigrateFile } from "./structures/IMigrateFile";
|
9
|
+
import { ISwagger } from "./structures/ISwagger";
|
10
|
+
|
11
|
+
export class MigrateApplication {
|
12
|
+
public constructor(public readonly swagger: ISwagger) {
|
13
|
+
typia.assert(swagger);
|
14
|
+
}
|
15
|
+
|
16
|
+
public nest(simulate: boolean): IMigrateFile[] {
|
17
|
+
const program = MigrateAnalyzer.analyze({
|
18
|
+
mode: "nest",
|
19
|
+
simulate,
|
20
|
+
})(this.swagger);
|
21
|
+
return [
|
22
|
+
...NEST_TEMPLATE,
|
23
|
+
...NestProgrammer.write(program),
|
24
|
+
...ApiProgrammer.write(program),
|
25
|
+
];
|
26
|
+
}
|
27
|
+
|
28
|
+
public sdk(simulate: boolean): IMigrateFile[] {
|
29
|
+
const program = MigrateAnalyzer.analyze({
|
30
|
+
mode: "sdk",
|
31
|
+
simulate,
|
32
|
+
})(this.swagger);
|
33
|
+
return [...SDK_TEMPLATE, ...ApiProgrammer.write(program)];
|
34
|
+
}
|
35
|
+
}
|