diff --git a/.eslintrc.js b/.eslintrc.js index 9f51e455..90d7d881 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -33,6 +33,7 @@ module.exports = { rules: { "import/order": "error", "import/namespace": "off", + "import/no-unresolved": ["error", { ignore: ["^inversify$"] }], "@typescript-eslint/typedef": "off", "@typescript-eslint/naming-convention": "off", "@typescript-eslint/explicit-function-return-type": "off", diff --git a/jest.config.js b/jest.config.js index 058f7b66..123d3b63 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,7 +4,11 @@ module.exports = { transform: { "^.+\\.tsx?$": "ts-jest", + "^.+\\.js$": "ts-jest", }, + transformIgnorePatterns: [ + "/node_modules/(?!(inversify|@inversifyjs)/)", + ], testEnvironment: "node", moduleFileExtensions: ["ts", "js", "json", "node"], moduleNameMapper: {}, diff --git a/lib/generator/exampleGenerator.ts b/lib/generator/exampleGenerator.ts index 42d90d1c..4a00cf78 100644 --- a/lib/generator/exampleGenerator.ts +++ b/lib/generator/exampleGenerator.ts @@ -275,9 +275,9 @@ export default class Generator { type pathNode = string | number; type pathNodes = pathNode[]; - const requestPaths = _.paths(example.parameters, { pathFormat: "array" }).map((v) => - (v as pathNode[]).reverse() - ); + const requestPaths: pathNodes[] = ( + _.paths(example.parameters, { pathFormat: "array" }) as pathNode[][] + ).map((v) => v.reverse()); /** * construct a inverted index , the key is leaf property key, value is reverse of the path from the root to the leaf property. @@ -315,7 +315,7 @@ export default class Generator { */ const res = _.mapValuesDeep( example.responses, - (value, key, parentValue, context) => { + (value: any, key: string | number, parentValue: any, context: any) => { if (!parentValue) { log.warn(`parent is null`); } diff --git a/package-lock.json b/package-lock.json index c6e06460..c3847ea5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "difflib": "0.2.4", "fast-json-stable-stringify": "^2.1.0", "glob": "^13.0.0", - "inversify": "^7.10.1", + "inversify": "^8.1.0", "js-yaml": "^4.1.0", "json-pointer": "0.6.2", "json-schema-traverse": "0.4.1", @@ -1056,56 +1056,56 @@ "license": "BSD-3-Clause" }, "node_modules/@inversifyjs/common": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/@inversifyjs/common/-/common-1.5.2.tgz", - "integrity": "sha512-WlzR9xGadABS9gtgZQ+luoZ8V6qm4Ii6RQfcfC9Ho2SOlE6ZuemFo7PKJvKI0ikm8cmKbU8hw5UK6E4qovH21w==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@inversifyjs/common/-/common-2.0.1.tgz", + "integrity": "sha512-pJAR4IAcT2jkYfZ9bD9XhtUDBLJRr8QOiSjb+2XyaHru6DLvu0VD2Id2iP7+tVRKkEe3XFUwDUEdKxcYlF699Q==", "license": "MIT" }, "node_modules/@inversifyjs/container": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/@inversifyjs/container/-/container-1.15.0.tgz", - "integrity": "sha512-U2xYsPrJTz5za2TExi5lg8qOWf8TEVBpN+pQM7B8BVA2rajtbRE9A66SLRHk8c1eGXmg+0K4Hdki6tWAsSQBUA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@inversifyjs/container/-/container-2.0.1.tgz", + "integrity": "sha512-xoZU4Mha5Vo+U04xWUnD01QbpQMNoIh0nUEFlb965E3rIneUbsYYiXeLUoKl57BjXjErsOL0q8o3mXi1si8rBA==", "license": "MIT", "dependencies": { - "@inversifyjs/common": "1.5.2", - "@inversifyjs/core": "9.2.0", - "@inversifyjs/plugin": "0.2.0", - "@inversifyjs/reflect-metadata-utils": "1.4.1" + "@inversifyjs/common": "2.0.1", + "@inversifyjs/core": "10.0.1", + "@inversifyjs/plugin": "0.3.1", + "@inversifyjs/reflect-metadata-utils": "1.5.0" }, "peerDependencies": { "reflect-metadata": "~0.2.2" } }, "node_modules/@inversifyjs/core": { - "version": "9.2.0", - "resolved": "https://registry.npmjs.org/@inversifyjs/core/-/core-9.2.0.tgz", - "integrity": "sha512-Nm7BR6KmpgshIHpVQWuEDehqRVb6GBm8LFEuhc2s4kSZWrArZ15RmXQzROLk4m+hkj4kMXgvMm5Qbopot/D6Sg==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@inversifyjs/core/-/core-10.0.1.tgz", + "integrity": "sha512-z+DHdTbHFETivPLPRgowz9wWhHA4FNYqQnKhPyDCz7zX9H/PIDcK4gZIF1YNaf5Uc2bd1nehSlVgfaTzVbb0AA==", "license": "MIT", "dependencies": { - "@inversifyjs/common": "1.5.2", - "@inversifyjs/prototype-utils": "0.1.3", - "@inversifyjs/reflect-metadata-utils": "1.4.1" + "@inversifyjs/common": "2.0.1", + "@inversifyjs/prototype-utils": "0.2.1", + "@inversifyjs/reflect-metadata-utils": "1.5.0" } }, "node_modules/@inversifyjs/plugin": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@inversifyjs/plugin/-/plugin-0.2.0.tgz", - "integrity": "sha512-R/JAdkTSD819pV1zi0HP54mWHyX+H2m8SxldXRgPQarS3ySV4KPyRdosWcfB8Se0JJZWZLHYiUNiS6JvMWSPjw==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@inversifyjs/plugin/-/plugin-0.3.1.tgz", + "integrity": "sha512-ByklTw731fydBCTMwMpkmwm+lv0U+JWm9NEqRsz3n5KzAC5Om2XtLjqzEC2w+8Ote3gVC3Qxsx6YmG9XLIZpvg==", "license": "MIT" }, "node_modules/@inversifyjs/prototype-utils": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@inversifyjs/prototype-utils/-/prototype-utils-0.1.3.tgz", - "integrity": "sha512-EzRamZzNgE9Sn3QtZ8NncNa2lpPMZfspqbK6BWFguWnOpK8ymp2TUuH46ruFHZhrHKnknPd7fG22ZV7iF517TQ==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@inversifyjs/prototype-utils/-/prototype-utils-0.2.1.tgz", + "integrity": "sha512-53cVE3cw+RxnSkGlg+jOFNSox2owJF9Fv3HgFKe4f+4aPullscltIiio88QRkx2Sc5yo3VlqPsXQFGw2CVJZnw==", "license": "MIT", "dependencies": { - "@inversifyjs/common": "1.5.2" + "@inversifyjs/common": "2.0.1" } }, "node_modules/@inversifyjs/reflect-metadata-utils": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/@inversifyjs/reflect-metadata-utils/-/reflect-metadata-utils-1.4.1.tgz", - "integrity": "sha512-Cp77C4d2wLaHXiUB7iH6Cxb7i1lD/YDuTIHLTDzKINqGSz0DCSoL/Dg2wVkW/6Qx03r/yQMLJ+32Agl32N2X8g==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@inversifyjs/reflect-metadata-utils/-/reflect-metadata-utils-1.5.0.tgz", + "integrity": "sha512-NpJVbRbuQ6Ao2vO+aw96un3oHDFCwXI0+pplsFt0Jh0gyR8DWk4m7ml/GBNMjdbeKVW/QgJ2S6NGXjk042uwqg==", "license": "MIT", "peerDependencies": { "reflect-metadata": "~0.2.2" @@ -5504,14 +5504,14 @@ } }, "node_modules/inversify": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/inversify/-/inversify-7.11.0.tgz", - "integrity": "sha512-yZDprSSr8TyVeMGI/AOV4ws6gwjX22hj9Z8/oHAVpJORY6WRFTcUzhnZtibBUHEw2U8ArvHcR+i863DplQ3Cwg==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/inversify/-/inversify-8.1.0.tgz", + "integrity": "sha512-LeMjL2MKHM0E8UmKo2ilRvdxG3o0pLZPYFjkaHwcjcFIrhzBGetphNkaWJ6YaM78uC1gK9v45i1R7CkCJDvG4Q==", "license": "MIT", "dependencies": { - "@inversifyjs/common": "1.5.2", - "@inversifyjs/container": "1.15.0", - "@inversifyjs/core": "9.2.0" + "@inversifyjs/common": "2.0.1", + "@inversifyjs/container": "2.0.1", + "@inversifyjs/core": "10.0.1" } }, "node_modules/is-array-buffer": { diff --git a/package.json b/package.json index 690f3c90..c7f7aebf 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "difflib": "0.2.4", "fast-json-stable-stringify": "^2.1.0", "glob": "^13.0.0", - "inversify": "^7.10.1", + "inversify": "^8.1.0", "js-yaml": "^4.1.0", "json-pointer": "0.6.2", "json-schema-traverse": "0.4.1", diff --git a/tsconfig.json b/tsconfig.json index 8531a9db..66ef046b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { /* Basic Options */ "target": "es2018" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */, - "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, + "module": "node20" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ @@ -37,7 +37,7 @@ "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, /* Module Resolution Options */ - "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + "moduleResolution": "node16", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */