@nestia/migrate 7.3.1 → 7.3.3

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.
@@ -13,11 +13,11 @@ export const NEST_TEMPLATE: Record<string, string> = {
13
13
  "docs/benchmarks/AMD Ryzen 9 7940HS w Radeon 780M Graphics.md": "# Benchmark Report\n> Generated by [`@nestia/benchmark`](https://github.com/samchon/nestia)\n\n - Specifications\n - CPU: AMD Ryzen 9 7940HS w/ Radeon 780M Graphics \n - RAM: 31 GB\n - NodeJS Version: v20.10.0\n - Backend Server: 1 core / 1 thread\n - Arguments\n - Count: 40,000\n - Threads: 4\n - Simultaneous: 32\n - Time\n - Start: 2024-10-29T19:14:35.941Z\n - Complete: 2024-10-29T19:16:11.418Z\n - Elapsed: 95,477 ms\n\nType | Count | Success | Mean. | Stdev. | Minimum | Maximum\n----|----|----|----|----|----|----\nTotal | 41,586 | 41,586 | 69.24 | 73.05 | 5 | 546\n\n> Unit: milliseconds\n\n## Memory Consumptions\n```mermaid\nxychart-beta\n x-axis \"Time (second)\"\n y-axis \"Memory (MB)\"\n line \"Resident Set Size\" [122, 156, 159, 142, 154, 165, 184, 185, 187, 189, 200, 205, 209, 217, 221, 225, 229, 224, 230, 235, 242, 250, 256, 262, 267, 272, 234, 237, 249, 259, 266, 273, 285, 292, 291, 216, 225, 235, 243, 200, 208, 214, 186, 186, 171, 177, 187, 199, 185, 192, 205, 171, 180, 158, 170, 179, 163, 163, 176, 188, 193, 202, 213, 219, 230, 239, 256, 265, 283, 301, 240, 249, 257, 267, 284, 282, 290, 202, 213, 166, 178, 188, 200, 203, 208, 180, 191, 199, 175]\n line \"Heap Total\" [85, 116, 120, 103, 114, 124, 146, 146, 147, 148, 158, 166, 170, 176, 180, 184, 187, 185, 190, 195, 203, 211, 217, 222, 225, 229, 194, 197, 209, 218, 225, 232, 241, 249, 247, 176, 185, 194, 202, 160, 168, 173, 146, 146, 130, 136, 146, 158, 145, 151, 165, 129, 139, 116, 128, 137, 120, 123, 136, 148, 152, 161, 172, 179, 189, 198, 215, 223, 241, 257, 200, 209, 216, 227, 244, 242, 249, 163, 174, 127, 136, 147, 159, 162, 166, 138, 150, 158, 132]\n line \"Heap Used + External\" [69, 94, 62, 82, 88, 107, 71, 83, 93, 107, 136, 72, 76, 85, 92, 106, 139, 48, 68, 69, 86, 95, 108, 116, 140, 175, 67, 74, 88, 112, 125, 136, 142, 169, 180, 91, 104, 105, 121, 60, 71, 91, 64, 74, 86, 110, 121, 135, 76, 82, 103, 70, 93, 66, 91, 107, 76, 75, 95, 101, 115, 127, 136, 154, 165, 168, 196, 193, 214, 232, 84, 94, 101, 118, 145, 147, 149, 86, 96, 72, 90, 112, 126, 133, 132, 78, 87, 107, 88]\n line \"Heap Used Only\" [66, 89, 59, 78, 83, 100, 68, 79, 88, 101, 129, 68, 72, 80, 86, 100, 131, 45, 64, 65, 81, 90, 103, 110, 133, 168, 64, 71, 84, 108, 120, 130, 136, 162, 173, 88, 100, 101, 117, 58, 68, 87, 61, 71, 83, 107, 118, 130, 73, 79, 99, 67, 89, 63, 88, 103, 74, 72, 91, 98, 111, 123, 132, 149, 160, 163, 190, 187, 208, 225, 81, 90, 97, 114, 140, 143, 145, 83, 93, 70, 87, 108, 122, 130, 128, 76, 84, 104, 85]\n```\n\n> - 🟦 Resident Set Size\n> - 🟢 Heap Total\n> - 🔴 Heap Used + External\n> - 🟡 Heap Used Only\n\n## Endpoints\nType | Count | Success | Mean. | Stdev. | Minimum | Maximum\n----|----|----|----|----|----|----\nPATCH /bbs/articles/:section | 6,439 | 6,439 | 108.37 | 76.56 | 6 | 546\nPUT /bbs/articles/:section/:id | 380 | 380 | 78.52 | 69.03 | 6 | 296\nGET /bbs/articles/:section/:id | 917 | 917 | 77.65 | 69.84 | 6 | 463\nDELETE /bbs/articles/:section/:id | 201 | 201 | 73.89 | 63.55 | 7 | 307\nPOST /bbs/articles/:section | 33,649 | 33,649 | 61.39 | 70.04 | 5 | 546\n\n> Unit: milliseconds\n\n## Failures\nMethod | Path | Count | Failures\n-------|------|-------|----------",
14
14
  "nest-cli.json": "{\n \"$schema\": \"https://json.schemastore.org/nest-cli\",\n \"collection\": \"@nestjs/schematics\",\n \"sourceRoot\": \"src\",\n \"entryFile\": \"executable/server\",\n \"compilerOptions\": {\n \"deleteOutDir\": true\n }\n}\n",
15
15
  "nestia.config.ts": "// nestia configuration file\nimport type sdk from \"@nestia/sdk\";\nimport { NestFactory } from \"@nestjs/core\";\n\nimport { MyModule } from \"./src/MyModule\";\n\nconst NESTIA_CONFIG: sdk.INestiaConfig = {\n input: () => NestFactory.create(MyModule),\n output: \"src/api\",\n swagger: {\n output: \"packages/api/swagger.json\",\n servers: [\n {\n url: \"http://localhost:37001\",\n description: \"Local Server\",\n },\n ],\n beautify: true,\n },\n distribute: \"packages/api\",\n keyword: true,\n simulate: true,\n primitive: false,\n};\nexport default NESTIA_CONFIG;\n",
16
- "package.json": "{\n \"private\": true,\n \"name\": \"@ORGANIZATION/PROJECT\",\n \"version\": \"0.1.0\",\n \"description\": \"Starter kit of Nestia\",\n \"main\": \"lib/index.js\",\n \"scripts\": {\n \"benchmark\": \"node bin/test/benchmark\",\n \"test\": \"node bin/test\",\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------BUILDS------------------------\": \"\",\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\n \"build:api\": \"rimraf packages/api/lib && nestia all && rimraf packages/api/lib && tsc -p packages/api/tsconfig.json && rollup -c packages/api/rollup.config.js\",\n \"build:main\": \"rimraf lib && tsc\",\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\n \"build:swagger\": \"npx nestia swagger\",\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\n \"dev\": \"npm run build:test -- --watch\",\n \"eslint\": \"eslint src && eslint test\",\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\n \"prepare\": \"ts-patch install && ts-node build/env.ts\",\n \"prettier\": \"prettier src --write && prettier test --write\",\n \"------------------------WEBPACK------------------------\": \"\",\n \"webpack\": \"rimraf dist && webpack\",\n \"webpack:start\": \"cd dist && node dist/server\",\n \"webpack:test\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------DEPLOYS------------------------\": \"\",\n \"package:api\": \"npm run build:api && cd packages/api && npm publish\",\n \"start\": \"node lib/executable/server\",\n \"start:dev\": \"nest start --watch\",\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia-start\"\n },\n \"keywords\": [\n \"nestia\",\n \"template\",\n \"boilerplate\"\n ],\n \"author\": \"AUTHOR\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\n },\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\n \"devDependencies\": {\n \"@autobe/interface\": \"^0.10.6\",\n \"@nestia/benchmark\": \"^7.3.1\",\n \"@nestia/e2e\": \"^7.3.1\",\n \"@nestia/sdk\": \"^7.3.1\",\n \"@nestjs/cli\": \"^11.0.7\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^11.1.6\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/cli\": \"^0.11.21\",\n \"@types/cli-progress\": \"^3.11.5\",\n \"@types/express\": \"^4.17.21\",\n \"@types/inquirer\": \"^8.2.5\",\n \"@types/node\": \"^18.11.0\",\n \"@types/uuid\": \"^8.3.4\",\n \"@typescript-eslint/eslint-plugin\": \"^8.1.0\",\n \"@typescript-eslint/parser\": \"^8.1.0\",\n \"chalk\": \"^4.1.2\",\n \"cli\": \"^1.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"copy-webpack-plugin\": \"^11.0.0\",\n \"eslint-plugin-deprecation\": \"^3.0.0\",\n \"express\": \"^4.18.2\",\n \"nestia\": \"^7.3.1\",\n \"prettier\": \"^3.2.4\",\n \"prettier-plugin-prisma\": \"^5.0.0\",\n \"rimraf\": \"^3.0.2\",\n \"rollup\": \"^4.18.0\",\n \"source-map-support\": \"^0.5.21\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"ts-loader\": \"^9.5.1\",\n \"ts-node\": \"^10.9.1\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.8.3\",\n \"typescript-transform-paths\": \"^3.5.5\",\n \"webpack\": \"^5.89.0\",\n \"webpack-cli\": \"^5.1.4\",\n \"write-file-webpack-plugin\": \"^4.5.1\"\n },\n \"dependencies\": {\n \"@nestia/core\": \"^7.3.1\",\n \"@nestia/fetcher\": \"^7.3.1\",\n \"@nestjs/common\": \"^11.1.5\",\n \"@nestjs/core\": \"^11.1.5\",\n \"@nestjs/platform-express\": \"^11.1.5\",\n \"commander\": \"10.0.0\",\n \"dotenv\": \"^16.3.1\",\n \"dotenv-expand\": \"^10.0.0\",\n \"inquirer\": \"8.2.5\",\n \"serialize-error\": \"^4.1.0\",\n \"tgrid\": \"^1.1.0\",\n \"tstl\": \"^3.0.0\",\n \"typia\": \"^9.6.0\",\n \"uuid\": \"^9.0.0\"\n },\n \"stackblitz\": {\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test -- --simultaneous 1\"\n }\n}",
16
+ "package.json": "{\n \"private\": true,\n \"name\": \"@ORGANIZATION/PROJECT\",\n \"version\": \"0.1.0\",\n \"description\": \"Starter kit of Nestia\",\n \"main\": \"lib/index.js\",\n \"scripts\": {\n \"benchmark\": \"node bin/test/benchmark\",\n \"test\": \"node bin/test\",\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------BUILDS------------------------\": \"\",\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\n \"build:api\": \"rimraf packages/api/lib && nestia all && rimraf packages/api/lib && tsc -p packages/api/tsconfig.json && rollup -c packages/api/rollup.config.js\",\n \"build:main\": \"rimraf lib && tsc\",\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\n \"build:swagger\": \"npx nestia swagger\",\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\n \"dev\": \"npm run build:test -- --watch\",\n \"eslint\": \"eslint src && eslint test\",\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\n \"prepare\": \"ts-patch install && ts-node build/env.ts\",\n \"prettier\": \"prettier src --write && prettier test --write\",\n \"------------------------WEBPACK------------------------\": \"\",\n \"webpack\": \"rimraf dist && webpack\",\n \"webpack:start\": \"cd dist && node dist/server\",\n \"webpack:test\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------DEPLOYS------------------------\": \"\",\n \"package:api\": \"npm run build:api && cd packages/api && npm publish\",\n \"start\": \"node lib/executable/server\",\n \"start:dev\": \"nest start --watch\",\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia-start\"\n },\n \"keywords\": [\n \"nestia\",\n \"template\",\n \"boilerplate\"\n ],\n \"author\": \"AUTHOR\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\n },\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\n \"devDependencies\": {\n \"@autobe/interface\": \"^0.10.6\",\n \"@nestia/benchmark\": \"^7.3.3\",\n \"@nestia/e2e\": \"^7.3.3\",\n \"@nestia/sdk\": \"^7.3.3\",\n \"@nestjs/cli\": \"^11.0.10\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^11.1.6\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/cli\": \"^0.11.21\",\n \"@types/cli-progress\": \"^3.11.5\",\n \"@types/express\": \"^4.17.21\",\n \"@types/inquirer\": \"^8.2.5\",\n \"@types/node\": \"^18.11.0\",\n \"@types/uuid\": \"^8.3.4\",\n \"@typescript-eslint/eslint-plugin\": \"^8.1.0\",\n \"@typescript-eslint/parser\": \"^8.1.0\",\n \"chalk\": \"^4.1.2\",\n \"cli\": \"^1.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"copy-webpack-plugin\": \"^11.0.0\",\n \"eslint-plugin-deprecation\": \"^3.0.0\",\n \"express\": \"^4.18.2\",\n \"nestia\": \"^7.3.3\",\n \"prettier\": \"^3.2.4\",\n \"prettier-plugin-prisma\": \"^5.0.0\",\n \"rimraf\": \"^3.0.2\",\n \"rollup\": \"^4.18.0\",\n \"source-map-support\": \"^0.5.21\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"ts-loader\": \"^9.5.1\",\n \"ts-node\": \"^10.9.1\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.9.2\",\n \"typescript-transform-paths\": \"^3.5.5\",\n \"webpack\": \"^5.89.0\",\n \"webpack-cli\": \"^5.1.4\",\n \"write-file-webpack-plugin\": \"^4.5.1\"\n },\n \"dependencies\": {\n \"@nestia/core\": \"^7.3.3\",\n \"@nestia/fetcher\": \"^7.3.3\",\n \"@nestjs/common\": \"^11.1.6\",\n \"@nestjs/core\": \"^11.1.6\",\n \"@nestjs/platform-express\": \"^11.1.6\",\n \"commander\": \"10.0.0\",\n \"dotenv\": \"^16.3.1\",\n \"dotenv-expand\": \"^10.0.0\",\n \"inquirer\": \"8.2.5\",\n \"serialize-error\": \"^4.1.0\",\n \"tgrid\": \"^1.1.0\",\n \"tstl\": \"^3.0.0\",\n \"typia\": \"^9.7.1\",\n \"uuid\": \"^9.0.0\"\n },\n \"stackblitz\": {\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test -- --simultaneous 1\"\n }\n}",
17
17
  "packages/api/.gitignore": "lib/\nnode_modules/\n\nswagger.json\nopenai.json",
18
18
  "packages/api/LICENSE": "MIT License\n\nCopyright (c) 2021 ORGANIZATION\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.",
19
19
  "packages/api/README.md": "# SDK Library\nThis is a SDK library generated by [`nestia`](https://nestia.io).\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![nestia-sdk-demo](https://user-images.githubusercontent.com/13158709/215004990-368c589d-7101-404e-b81b-fbc936382f05.gif)\n\n> Left is server code, and right is client code utilizing the SDK\n\n\n\n\n# What [`Nestia`](https://nestia.io) is:\n![Nestia Logo](https://nestia.io/logo.png)\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/nestia/blob/master/LICENSE)\n[![npm version](https://img.shields.io/npm/v/@nestia/core.svg)](https://www.npmjs.com/package/@nestia/core)\n[![Downloads](https://img.shields.io/npm/dm/@nestia/core.svg)](https://www.npmjs.com/package/@nestia/core)\n[![Build Status](https://github.com/samchon/nestia/workflows/build/badge.svg)](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)\n[![Guide Documents](https://img.shields.io/badge/guide-documents-forestgreen)](https://nestia.io/docs/)\n\nNestia 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`: 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",
20
- "packages/api/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 \"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 \"package.json\",\n \"swagger.json\",\n \"openai.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}",
20
+ "packages/api/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 \"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 \"package.json\",\n \"swagger.json\",\n \"openai.json\",\n \"README.md\"\n ],\n \"dependencies\": {\n \"@nestia/fetcher\": \"^7.3.2\",\n \"tgrid\": \"^1.2.0\",\n \"typia\": \"^9.7.1\"\n }\n}",
21
21
  "packages/api/rollup.config.js": "const typescript = require(\"@rollup/plugin-typescript\");\nconst terser = require(\"@rollup/plugin-terser\");\n\nmodule.exports = {\n input: `${__dirname}/../../src/api/index.ts`,\n output: {\n dir: `${__dirname}/lib`,\n format: \"esm\",\n entryFileNames: \"[name].mjs\",\n sourcemap: true,\n },\n plugins: [\n typescript({\n tsconfig: `${__dirname}/tsconfig.json`,\n module: \"ESNext\",\n target: \"ESNext\",\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",
22
22
  "packages/api/tsconfig.json": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig to read more about this file */\n /* Projects */\n // \"incremental\": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */\n // \"composite\": true, /* Enable constraints that allow a TypeScript project to be used with project references. */\n // \"tsBuildInfoFile\": \"./.tsbuildinfo\", /* Specify the path to .tsbuildinfo incremental compilation file. */\n // \"disableSourceOfProjectReferenceRedirect\": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */\n // \"disableSolutionSearching\": true, /* Opt a project out of multi-project reference checking when editing. */\n // \"disableReferencedProjectLoad\": true, /* Reduce the number of projects loaded automatically by TypeScript. */\n /* Language and Environment */\n \"target\": \"ES5\", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */\n \"lib\": [\n \"DOM\",\n \"ES2015\"\n ], /* Specify a set of bundled library declaration files that describe the target runtime environment. */// \"jsx\": \"preserve\", /* Specify what JSX code is generated. */\n // \"experimentalDecorators\": true, /* Enable experimental support for TC39 stage 2 draft decorators. */\n // \"emitDecoratorMetadata\": true, /* Emit design-type metadata for decorated declarations in source files. */\n // \"jsxFactory\": \"\", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */\n // \"jsxFragmentFactory\": \"\", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */\n // \"jsxImportSource\": \"\", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */\n // \"reactNamespace\": \"\", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */\n // \"noLib\": true, /* Disable including any library files, including the default lib.d.ts. */\n // \"useDefineForClassFields\": true, /* Emit ECMAScript-standard-compliant class fields. */\n // \"moduleDetection\": \"auto\", /* Control what method is used to detect module-format JS files. */\n /* Modules */\n \"module\": \"commonjs\", /* Specify what module code is generated. */// \"rootDir\": \"./\", /* Specify the root folder within your source files. */\n // \"moduleResolution\": \"node\", /* Specify how TypeScript looks up a file from a given module specifier. */\n // \"baseUrl\": \"./\", /* Specify the base directory to resolve non-relative module names. */\n // \"paths\": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */\n // \"rootDirs\": [], /* Allow multiple folders to be treated as one when resolving modules. */\n // \"typeRoots\": [], /* Specify multiple folders that act like './node_modules/@types'. */\n // \"types\": [], /* Specify type package names to be included without being referenced in a source file. */\n // \"allowUmdGlobalAccess\": true, /* Allow accessing UMD globals from modules. */\n // \"moduleSuffixes\": [], /* List of file name suffixes to search when resolving a module. */\n // \"resolveJsonModule\": true, /* Enable importing .json files. */\n // \"noResolve\": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */\n /* JavaScript Support */\n // \"allowJs\": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */\n // \"checkJs\": true, /* Enable error reporting in type-checked JavaScript files. */\n // \"maxNodeModuleJsDepth\": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */\n /* Emit */\n \"declaration\": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */// \"declarationMap\": true, /* Create sourcemaps for d.ts files. */\n // \"emitDeclarationOnly\": true, /* Only output d.ts files and not JavaScript files. */\n \"sourceMap\": true, /* Create source map files for emitted JavaScript files. */// \"outFile\": \"./\", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */\n \"outDir\": \"./lib\", /* Specify an output folder for all emitted files. */// \"removeComments\": true, /* Disable emitting comments. */\n // \"noEmit\": true, /* Disable emitting files from a compilation. */\n // \"importHelpers\": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */\n // \"importsNotUsedAsValues\": \"remove\", /* Specify emit/checking behavior for imports that are only used for types. */\n \"downlevelIteration\": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */// \"sourceRoot\": \"\", /* Specify the root path for debuggers to find the reference source code. */\n // \"mapRoot\": \"\", /* Specify the location where debugger should locate map files instead of generated locations. */\n // \"inlineSourceMap\": true, /* Include sourcemap files inside the emitted JavaScript. */\n // \"inlineSources\": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */\n // \"emitBOM\": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */\n \"newLine\": \"lf\", /* Set the newline character for emitting files. */// \"stripInternal\": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */\n // \"noEmitHelpers\": true, /* Disable generating custom helper functions like '__extends' in compiled output. */\n // \"noEmitOnError\": true, /* Disable emitting files if any type checking errors are reported. */\n // \"preserveConstEnums\": true, /* Disable erasing 'const enum' declarations in generated code. */\n // \"declarationDir\": \"./\", /* Specify the output directory for generated declaration files. */\n // \"preserveValueImports\": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */\n /* Interop Constraints */\n // \"isolatedModules\": true, /* Ensure that each file can be safely transpiled without relying on other imports. */\n // \"allowSyntheticDefaultImports\": true, /* Allow 'import x from y' when a module doesn't have a default export. */\n \"esModuleInterop\": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */// \"preserveSymlinks\": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */\n \"forceConsistentCasingInFileNames\": true, /* Ensure that casing is correct in imports. *//* Type Checking */\n \"strict\": true, /* Enable all strict type-checking options. */// \"noImplicitAny\": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */\n // \"strictNullChecks\": true, /* When type checking, take into account 'null' and 'undefined'. */\n // \"strictFunctionTypes\": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */\n // \"strictBindCallApply\": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */\n // \"strictPropertyInitialization\": true, /* Check for class properties that are declared but not set in the constructor. */\n // \"noImplicitThis\": true, /* Enable error reporting when 'this' is given the type 'any'. */\n // \"useUnknownInCatchVariables\": true, /* Default catch clause variables as 'unknown' instead of 'any'. */\n // \"alwaysStrict\": true, /* Ensure 'use strict' is always emitted. */\n // \"noUnusedLocals\": true, /* Enable error reporting when local variables aren't read. */\n // \"noUnusedParameters\": true, /* Raise an error when a function parameter isn't read. */\n // \"exactOptionalPropertyTypes\": true, /* Interpret optional property types as written, rather than adding 'undefined'. */\n // \"noImplicitReturns\": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */\n // \"noFallthroughCasesInSwitch\": true, /* Enable error reporting for fallthrough cases in switch statements. */\n // \"noUncheckedIndexedAccess\": true, /* Add 'undefined' to a type when accessed using an index. */\n // \"noImplicitOverride\": true, /* Ensure overriding members in derived classes are marked with an override modifier. */\n // \"noPropertyAccessFromIndexSignature\": true, /* Enforces using indexed accessors for keys declared using an indexed type. */\n // \"allowUnusedLabels\": true, /* Disable error reporting for unused labels. */\n // \"allowUnreachableCode\": true, /* Disable error reporting for unreachable code. */\n /* Completeness */\n // \"skipDefaultLibCheck\": true, /* Skip type checking .d.ts files that are included with TypeScript. */\n \"skipLibCheck\": true, /* Skip type checking all .d.ts files. */\n \"plugins\": [\n {\n \"transform\": \"typia/lib/transform\"\n }\n ],\n \"strictNullChecks\": true\n },\n \"include\": [\n \"../../src/api\"\n ]\n}",
23
23
  "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: [\n \"<THIRD_PARTY_MODULES>\",\n \"^@ORGANIZATION/PROJECT-api(.*)$\",\n \"^[./]\",\n ],\n importOrderSeparation: true,\n importOrderSortSpecifiers: true,\n importOrderParserPlugins: [\"decorators-legacy\", \"typescript\"],\n};\n",
@@ -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![nestia-sdk-demo](https://user-images.githubusercontent.com/13158709/215004990-368c589d-7101-404e-b81b-fbc936382f05.gif)\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> ![Nestia Logo](https://nestia.io/logo.png)\n> \n> [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/nestia/blob/master/LICENSE)\n> [![npm version](https://img.shields.io/npm/v/@nestia/core.svg)](https://www.npmjs.com/package/@nestia/core)\n> [![Downloads](https://img.shields.io/npm/dm/@nestia/core.svg)](https://www.npmjs.com/package/@nestia/core)\n> [![Build Status](https://github.com/samchon/nestia/workflows/build/badge.svg)](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)\n> [![Guide Documents](https://img.shields.io/badge/guide-documents-forestgreen)](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.3.1\",\n \"tgrid\": \"^1.2.0\",\n \"typia\": \"^9.6.0\"\n },\n \"devDependencies\": {\n \"@nestia/e2e\": \"^7.3.1\",\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}",
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.3\",\n \"tgrid\": \"^1.2.0\",\n \"typia\": \"^9.7.1\"\n },\n \"devDependencies\": {\n \"@nestia/e2e\": \"^7.3.3\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^11.1.6\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/express\": \"^4.17.21\",\n \"@types/inquirer\": \"8.2.5\",\n \"@types/swagger-ui-express\": \"^4.1.6\",\n \"chalk\": \"4.1.2\",\n \"commander\": \"^10.0.0\",\n \"express\": \"^4.19.2\",\n \"inquirer\": \"8.2.5\",\n \"prettier\": \"^3.2.5\",\n \"rimraf\": \"^5.0.5\",\n \"rollup\": \"^4.13.2\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"ts-node\": \"^10.9.2\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.9.2\",\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",
@@ -447,9 +447,12 @@ export namespace NestiaMigrateSchemaProgrammer {
447
447
  );
448
448
  }
449
449
  const createNode = (text: string) => ts.factory.createTypeReferenceNode(text);
450
+
450
451
  const writeComment = (schema: OpenApi.IJsonSchema): string =>
451
452
  [
452
- ...(schema.description?.length ? [schema.description] : []),
453
+ ...(schema.description?.length
454
+ ? [eraseCommentTags(schema.description)]
455
+ : []),
453
456
  ...(schema.description?.length &&
454
457
  (schema.title !== undefined || schema.deprecated === true)
455
458
  ? [""]
@@ -460,6 +463,14 @@ const writeComment = (schema: OpenApi.IJsonSchema): string =>
460
463
  .join("\n")
461
464
  .split("*/")
462
465
  .join("*\\/");
466
+
467
+ const eraseCommentTags = (description: string): string => {
468
+ const lines: string[] = description.split("\n");
469
+ return lines
470
+ .filter((s) => COMMENT_TAGS.every((tag) => !s.includes(tag)))
471
+ .join("\n");
472
+ };
473
+
463
474
  const writePlugin = (props: {
464
475
  importer: NestiaMigrateImportProgrammer;
465
476
  regular: string[];
@@ -473,3 +484,25 @@ const writePlugin = (props: {
473
484
  if (Object.keys(extra).length !== 0)
474
485
  props.intersection.push(props.importer.tag("JsonSchemaPlugin", extra));
475
486
  };
487
+
488
+ const COMMENT_TAGS = [
489
+ // string
490
+ "@format",
491
+ "@pattern",
492
+ "@length",
493
+ "@minLength",
494
+ "@maxLength",
495
+ "@contentMediaType",
496
+ // number
497
+ "@type",
498
+ "@minimum",
499
+ "@maximum",
500
+ "@exclusiveMinimum",
501
+ "@exclusiveMaximum",
502
+ "@multipleOf",
503
+ // array
504
+ "@items",
505
+ "@minItems",
506
+ "@maxItems",
507
+ "@uniqueItems",
508
+ ];
@@ -1,44 +1,33 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
 
3
3
  /**
4
- * Recursively walk a JSON object and invoke a callback function
5
- * on each `{ "$ref" : "path" }` object found
4
+ * Recursively walk a JSON object and invoke a callback function on each `{
5
+ * "$ref" : "path" }` object found
6
6
  */
7
7
 
8
8
  /**
9
- * Represents a JSON Reference object, such as
10
- * `{"$ref": "#/components/schemas/problemResponse" }`
9
+ * Represents a JSON Reference object, such as `{"$ref":
10
+ * "#/components/schemas/problemResponse" }`
11
11
  */
12
12
  export interface RefObject {
13
13
  $ref: string;
14
14
  }
15
15
 
16
- /**
17
- * JsonNode represents a node within the OpenAPI object
18
- */
16
+ /** JsonNode represents a node within the OpenAPI object */
19
17
  export type JsonNode = object | [] | string | boolean | null | number;
20
18
 
21
19
  /** A JSON Schema object in an API def */
22
20
  export type SchemaObject = object;
23
21
 
24
- /**
25
- * Function signature for the visitRefObjects callback
26
- */
22
+ /** Function signature for the visitRefObjects callback */
27
23
  export type RefVisitor = (node: RefObject) => JsonNode;
28
- /**
29
- * Function signature for the visitSchemaObjects callback
30
- */
24
+ /** Function signature for the visitSchemaObjects callback */
31
25
  export type SchemaVisitor = (node: SchemaObject) => SchemaObject;
32
26
 
33
- /**
34
- /**
35
- * Function signature for the walkObject callback
36
- */
27
+ /** /** Function signature for the walkObject callback */
37
28
  export type ObjectVisitor = (node: object) => JsonNode;
38
29
 
39
- /**
40
- * Test if a JSON node is a `{ $ref: "uri" }` object
41
- */
30
+ /** Test if a JSON node is a `{ $ref: "uri" }` object */
42
31
  export function isRef(node: any): boolean {
43
32
  return (
44
33
  node !== null &&
@@ -50,10 +39,12 @@ export function isRef(node: any): boolean {
50
39
 
51
40
  /**
52
41
  * Walk a JSON object and apply `schemaCallback` when a JSON schema is found.
53
- * JSON Schema objects are items in components/schemas or in an item named `schema`
54
- * @param node a node in the OpenAPI document
55
- * @param schemaCallback the function to call on JSON schema objects
56
- * @return the modified (annotated) node
42
+ * JSON Schema objects are items in components/schemas or in an item named
43
+ * `schema`
44
+ *
45
+ * @param node A node in the OpenAPI document
46
+ * @param schemaCallback The function to call on JSON schema objects
47
+ * @returns The modified (annotated) node
57
48
  */
58
49
  export function visitSchemaObjects(
59
50
  node: any,
@@ -81,10 +72,12 @@ export function visitSchemaObjects(
81
72
  }
82
73
 
83
74
  /**
84
- * Walk a JSON object and apply `refCallback` when a JSON `{$ref: url }` is found
85
- * @param node a node in the OpenAPI document
86
- * @param refCallback the function to call on JSON `$ref` objects
87
- * @return the modified (annotated) node
75
+ * Walk a JSON object and apply `refCallback` when a JSON `{$ref: url }` is
76
+ * found
77
+ *
78
+ * @param node A node in the OpenAPI document
79
+ * @param refCallback The function to call on JSON `$ref` objects
80
+ * @returns The modified (annotated) node
88
81
  */
89
82
  export function visitRefObjects(node: any, refCallback: RefVisitor): any {
90
83
  const objectVisitor = (node: object): JsonNode => {
@@ -97,11 +90,13 @@ export function visitRefObjects(node: any, refCallback: RefVisitor): any {
97
90
  }
98
91
 
99
92
  /**
100
- * Walk a JSON object or array and apply objectCallback when a JSON object is found
101
- * @param node a node in the OpenAPI document
102
- * @param objectCallback the function to call on JSON objects
103
- * @param nav tracks where we are in the original document
104
- * @return the modified (annotated) node
93
+ * Walk a JSON object or array and apply objectCallback when a JSON object is
94
+ * found
95
+ *
96
+ * @param node A node in the OpenAPI document
97
+ * @param objectCallback The function to call on JSON objects
98
+ * @param nav Tracks where we are in the original document
99
+ * @returns The modified (annotated) node
105
100
  */
106
101
  export function walkObject(
107
102
  node: object,
@@ -19,30 +19,29 @@ interface OpenAPI3 {
19
19
 
20
20
  /** Options for the converter instantiation */
21
21
  export interface ConverterOptions {
22
- /** if `true`, log conversion transformations to stderr */
22
+ /** If `true`, log conversion transformations to stderr */
23
23
  verbose?: boolean;
24
- /** if `true`, remove `id` values in schema examples, to bypass
25
- * [Spectral issue 2081](https://github.com/stoplightio/spectral/issues/2081)
24
+ /**
25
+ * If `true`, remove `id` values in schema examples, to bypass [Spectral issue
26
+ * 2081](https://github.com/stoplightio/spectral/issues/2081)
26
27
  */
27
28
  deleteExampleWithId?: boolean;
28
29
  /** If `true`, replace a `$ref` object that has siblings into an `allOf` */
29
30
  allOfTransform?: boolean;
30
31
 
31
- /**
32
- * The authorizationUrl for openIdConnect -> oauth2 transformation
33
- */
32
+ /** The authorizationUrl for openIdConnect -> oauth2 transformation */
34
33
  authorizationUrl?: string;
35
34
  /** The tokenUrl for openIdConnect -> oauth2 transformation */
36
35
  tokenUrl?: string;
37
- /** Name of YAML/JSON file with scope descriptions.
38
- * This is a simple map in the format
39
- * `{ scope1: "description of scope1", ... }`
36
+ /**
37
+ * Name of YAML/JSON file with scope descriptions. This is a simple map in the
38
+ * format `{ scope1: "description of scope1", ... }`
40
39
  */
41
40
  scopeDescriptionFile?: string;
42
- /** Earlier versions of the tool converted $comment to x-comment
43
- * in JSON Schemas. The tool now deletes $comment values by default.
44
- * Use this option to preserve the conversion and not delete
45
- * comments.
41
+ /**
42
+ * Earlier versions of the tool converted $comment to x-comment in JSON
43
+ * Schemas. The tool now deletes $comment values by default. Use this option
44
+ * to preserve the conversion and not delete comments.
46
45
  */
47
46
  convertSchemaComments?: boolean;
48
47
  }
@@ -61,7 +60,9 @@ export class Converter {
61
60
 
62
61
  /**
63
62
  * Construct a new Converter
64
- * @throws Error if the scopeDescriptionFile (if specified) cannot be read or parsed as YAML/JSON
63
+ *
64
+ * @throws Error if the scopeDescriptionFile (if specified) cannot be read or
65
+ * parsed as YAML/JSON
65
66
  */
66
67
  constructor(openapiDocument: object, options?: ConverterOptions) {
67
68
  this.openapi30 = Converter.deepClone(openapiDocument) as OpenAPI3;
@@ -75,7 +76,9 @@ export class Converter {
75
76
  this.convertSchemaComments = !!options?.convertSchemaComments;
76
77
  }
77
78
 
78
- /** Load the scopes.yaml file and save in this.scopeDescriptions
79
+ /**
80
+ * Load the scopes.yaml file and save in this.scopeDescriptions
81
+ *
79
82
  * @throws Error if the file cannot be read or parsed as YAML/JSON
80
83
  */
81
84
  private loadScopeDescriptions(scopeDescriptionFile?: string) {
@@ -85,8 +88,9 @@ export class Converter {
85
88
  }
86
89
 
87
90
  /**
88
- * Log a message to console.warn stream if verbose is true
89
- * @param message parameters for console.warn
91
+ * Log a message to console.warn stream if verbose is true
92
+ *
93
+ * @param message Parameters for console.warn
90
94
  */
91
95
  private log(...message: any[]) {
92
96
  if (this.verbose) {
@@ -95,9 +99,10 @@ export class Converter {
95
99
  }
96
100
 
97
101
  /**
98
- * Log a message to console.warn stream. Prefix the message string with `Warning: `
99
- * if it does not already have that text.
100
- * @param message parameters for console.warn
102
+ * Log a message to console.warn stream. Prefix the message string with
103
+ * `Warning: ` if it does not already have that text.
104
+ *
105
+ * @param message Parameters for console.warn
101
106
  */
102
107
  private warn(...message: any[]) {
103
108
  if (!message[0].startsWith("Warning")) {
@@ -107,10 +112,11 @@ export class Converter {
107
112
  }
108
113
 
109
114
  /**
110
- * Log an error message to `console.error` stream. Prefix the message string with `Error: `
111
- * if it does not already start with `'Error'`. Increments the `returnCode`, causing
112
- * the CLI to throw an Error when done.
113
- * @param message parameters for `console.error`
115
+ * Log an error message to `console.error` stream. Prefix the message string
116
+ * with `Error: ` if it does not already start with `'Error'`. Increments the
117
+ * `returnCode`, causing the CLI to throw an Error when done.
118
+ *
119
+ * @param message Parameters for `console.error`
114
120
  */
115
121
  private error(...message: any[]) {
116
122
  if (!message[0].startsWith("Error")) {
@@ -122,7 +128,8 @@ export class Converter {
122
128
 
123
129
  /**
124
130
  * Convert the OpenAPI document to 3.0
125
- * @returns the converted document. The input is not modified.
131
+ *
132
+ * @returns The converted document. The input is not modified.
126
133
  */
127
134
  public convert(): object {
128
135
  this.log("Converting from OpenAPI 3.1 to 3.0");
@@ -153,8 +160,8 @@ export class Converter {
153
160
 
154
161
  /**
155
162
  * OpenAPI 3.1 uses JSON Schema 2020-12 which allows schema `examples`;
156
- * OpenAPI 3.0 uses JSON Scheme Draft 7 which only allows `example`.
157
- * Replace all `examples` with `example`, using `examples[0]`
163
+ * OpenAPI 3.0 uses JSON Scheme Draft 7 which only allows `example`. Replace
164
+ * all `examples` with `example`, using `examples[0]`
158
165
  */
159
166
  convertJsonSchemaExamples() {
160
167
  const schemaVisitor: SchemaVisitor = (schema: any): SchemaObject => {
@@ -205,9 +212,9 @@ export class Converter {
205
212
  }
206
213
 
207
214
  /**
208
- * OpenAPI 3.1 uses JSON Schema 2020-12 which allows `const`
209
- * OpenAPI 3.0 uses JSON Scheme Draft 7 which only allows `enum`.
210
- * Replace all `const: value` with `enum: [ value ]`
215
+ * OpenAPI 3.1 uses JSON Schema 2020-12 which allows `const` OpenAPI 3.0 uses
216
+ * JSON Scheme Draft 7 which only allows `enum`. Replace all `const: value`
217
+ * with `enum: [ value ]`
211
218
  */
212
219
  convertConstToEnum() {
213
220
  const schemaVisitor: SchemaVisitor = (schema: any): SchemaObject => {
@@ -223,8 +230,8 @@ export class Converter {
223
230
  }
224
231
 
225
232
  /**
226
- * Convert 2-element type arrays containing 'null' to
227
- * string type and `nullable: true`
233
+ * Convert 2-element type arrays containing 'null' to string type and
234
+ * `nullable: true`
228
235
  */
229
236
  convertNullableTypeArray() {
230
237
  const schemaVisitor: SchemaVisitor = (schema: any): SchemaObject => {
@@ -298,15 +305,15 @@ export class Converter {
298
305
 
299
306
  /**
300
307
  * Convert
301
- * ```
302
- * contentMediaType: 'application/octet-stream'
303
- * ```
304
- * to
305
- * ```
306
- * format: binary
307
- * ```
308
- * in `type: string` schemas.
309
- * Warn if schema has a `format` already and it is not `binary`.
308
+ *
309
+ * contentMediaType: "application/octet-stream";
310
+ *
311
+ * To
312
+ *
313
+ * format: binary;
314
+ *
315
+ * In `type: string` schemas. Warn if schema has a `format` already and it is
316
+ * not `binary`.
310
317
  */
311
318
  convertJsonSchemaContentMediaType() {
312
319
  const schemaVisitor: SchemaVisitor = (schema: any): SchemaObject => {
@@ -342,15 +349,15 @@ export class Converter {
342
349
 
343
350
  /**
344
351
  * Convert
345
- * ```
346
- * contentEncoding: base64
347
- * ```
348
- * to
349
- * ```
350
- * format: byte
351
- * ```
352
- * in `type: string` schemas. It is an error if the schema has a `format` already
353
- * and it is not `byte`.
352
+ *
353
+ * contentEncoding: base64;
354
+ *
355
+ * To
356
+ *
357
+ * format: byte;
358
+ *
359
+ * In `type: string` schemas. It is an error if the schema has a `format`
360
+ * already and it is not `byte`.
354
361
  */
355
362
  convertJsonSchemaContentEncoding() {
356
363
  const schemaVisitor: SchemaVisitor = (schema: any): SchemaObject => {
@@ -394,11 +401,10 @@ export class Converter {
394
401
  }
395
402
 
396
403
  /**
397
- * OpenAPI 3.1 defines a new `openIdConnect` security scheme.
398
- * Down-convert the scheme to `oauth2` / authorization code flow.
399
- * Collect all the scopes used in any security requirements within
400
- * operations and add them to the scheme. Also define the
401
- * URLs to the `authorizationUrl` and `tokenUrl` of `oauth2`.
404
+ * OpenAPI 3.1 defines a new `openIdConnect` security scheme. Down-convert the
405
+ * scheme to `oauth2` / authorization code flow. Collect all the scopes used
406
+ * in any security requirements within operations and add them to the scheme.
407
+ * Also define the URLs to the `authorizationUrl` and `tokenUrl` of `oauth2`.
402
408
  */
403
409
  convertSecuritySchemes() {
404
410
  const oauth2Scopes = (schemeName: string): object => {
@@ -454,9 +460,11 @@ export class Converter {
454
460
  }
455
461
 
456
462
  /**
457
- * Find remaining OpenAPI 3.0 [Reference Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)
458
- * and down convert them to [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03) objects
459
- * with _only_ a `$ref` property.
463
+ * Find remaining OpenAPI 3.0 [Reference
464
+ * Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)
465
+ * and down convert them to [JSON
466
+ * Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03)
467
+ * objects with _only_ a `$ref` property.
460
468
  */
461
469
  simplifyNonSchemaRef() {
462
470
  visitRefObjects(this.openapi30, (node: any): JsonNode => {
@@ -489,10 +497,11 @@ export class Converter {
489
497
 
490
498
  convertSchemaRef() {
491
499
  /**
492
- * In a JSON Schema, replace `{ blah blah, $ref: "uri"}`
493
- * with `{ blah blah, allOf: [ $ref: "uri" ]}`
494
- * @param object an object that may contain JSON schemas (directly
495
- * or in sub-objects)
500
+ * In a JSON Schema, replace `{ blah blah, $ref: "uri"}` with `{ blah blah,
501
+ * allOf: [ $ref: "uri" ]}`
502
+ *
503
+ * @param object An object that may contain JSON schemas (directly or in
504
+ * sub-objects)
496
505
  */
497
506
  const simplifyRefObjectsInSchemas = (
498
507
  object: SchemaObject,