diff --git a/package-lock.json b/package-lock.json index 3dd4876c..d003d5db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -55,10 +55,10 @@ "@types/lodash": "^4.17.7", "@types/node": "^20.14.13", "@types/supertest": "^6.0.2", - "@typescript-eslint/eslint-plugin": "^7.17.0", - "@typescript-eslint/parser": "^7.17.0", + "@typescript-eslint/eslint-plugin": "^7.18.0", + "@typescript-eslint/parser": "^7.18.0", "chance": "^1.1.12", - "cspell": "^8.12.1", + "cspell": "^8.13.0", "eslint": "8.57.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-typescript": "^18.0.0", @@ -78,7 +78,7 @@ "eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-switch-case": "^1.1.2", "eslint-plugin-unused-imports": "^4.0.1", - "husky": "^9.1.3", + "husky": "^9.1.4", "jest": "29.7.0", "jest-when": "^3.6.0", "lint-staged": "^15.2.7", @@ -566,30 +566,30 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.0.tgz", - "integrity": "sha512-P4fwKI2mjEb3ZU5cnMJzvRsRKGBUcs8jvxIoRmr6ufAY9Xk2Bz7JubRTTivkw55c7WQJfTECeqYVa+HZ0FzREg==", + "version": "7.25.2", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.2.tgz", + "integrity": "sha512-bYcppcpKBvX4znYaPEeFau03bp89ShqNMLs+rmdptMw+heSZh9+z84d2YG+K7cYLbWwzdjtDoW/uqZmPjulClQ==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.24.9", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.9.tgz", - "integrity": "sha512-5e3FI4Q3M3Pbr21+5xJwCv6ZT6KmGkI0vw3Tozy5ODAQFTIWe37iT8Cr7Ice2Ntb+M3iSKCEWMB1MBgKrW3whg==", + "version": "7.25.2", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.2.tgz", + "integrity": "sha512-BBt3opiCOxUr9euZ5/ro/Xv8/V7yJ5bjYMqG/C1YAo8MIKAnumZalCN+msbci3Pigy4lIQfPUpfMM27HMGaYEA==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.24.9", - "@babel/helper-compilation-targets": "^7.24.8", - "@babel/helper-module-transforms": "^7.24.9", - "@babel/helpers": "^7.24.8", - "@babel/parser": "^7.24.8", - "@babel/template": "^7.24.7", - "@babel/traverse": "^7.24.8", - "@babel/types": "^7.24.9", + "@babel/generator": "^7.25.0", + "@babel/helper-compilation-targets": "^7.25.2", + "@babel/helper-module-transforms": "^7.25.2", + "@babel/helpers": "^7.25.0", + "@babel/parser": "^7.25.0", + "@babel/template": "^7.25.0", + "@babel/traverse": "^7.25.2", + "@babel/types": "^7.25.2", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -629,12 +629,12 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.24.8.tgz", - "integrity": "sha512-oU+UoqCHdp+nWVDkpldqIQL/i/bvAv53tRqLG/s+cOXxe66zOYLU7ar/Xs3LdmBihrUMEUhwu6dMZwbNOYDwvw==", + "version": "7.25.2", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.2.tgz", + "integrity": "sha512-U2U5LsSaZ7TAt3cfaymQ8WHh0pxvdHoEk6HVpaexxixjyEquMh0L0YNJNM6CTGKMXV1iksi0iZkGw4AcFkPaaw==", "dev": true, "dependencies": { - "@babel/compat-data": "^7.24.8", + "@babel/compat-data": "^7.25.2", "@babel/helper-validator-option": "^7.24.8", "browserslist": "^4.23.1", "lru-cache": "^5.1.1", @@ -667,15 +667,15 @@ } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.0.tgz", - "integrity": "sha512-bIkOa2ZJYn7FHnepzr5iX9Kmz8FjIz4UKzJ9zhX3dnYuVW0xul9RuR3skBfoLu+FPTQw90EHW9rJsSZhyLQ3fQ==", + "version": "7.25.2", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.2.tgz", + "integrity": "sha512-BjyRAbix6j/wv83ftcVJmBt72QtHI56C7JXZoG2xATiLpmoC7dpd8WnkikExHDVPpi/3qCmO6WY1EaXOluiecQ==", "dev": true, "dependencies": { "@babel/helper-module-imports": "^7.24.7", "@babel/helper-simple-access": "^7.24.7", "@babel/helper-validator-identifier": "^7.24.7", - "@babel/traverse": "^7.25.0" + "@babel/traverse": "^7.25.2" }, "engines": { "node": ">=6.9.0" @@ -1036,16 +1036,16 @@ } }, "node_modules/@babel/traverse": { - "version": "7.25.1", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.1.tgz", - "integrity": "sha512-LrHHoWq08ZpmmFqBAzN+hUdWwy5zt7FGa/hVwMcOqW6OVtwqaoD5utfuGYU87JYxdZgLUvktAsn37j/sYR9siA==", + "version": "7.25.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.2.tgz", + "integrity": "sha512-s4/r+a7xTnny2O6FcZzqgT6nE4/GHEdcqj4qAeglbUOh0TeglEfmNJFAd/OLoVtGd6ZhAO8GCVvCNUO5t/VJVQ==", "dev": true, "dependencies": { "@babel/code-frame": "^7.24.7", "@babel/generator": "^7.25.0", "@babel/parser": "^7.25.0", "@babel/template": "^7.25.0", - "@babel/types": "^7.25.0", + "@babel/types": "^7.25.2", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -1063,9 +1063,9 @@ } }, "node_modules/@babel/types": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.0.tgz", - "integrity": "sha512-LcnxQSsd9aXOIgmmSpvZ/1yo46ra2ESYyqLcryaBZOghxy5qqOBjvCWP5JfkI8yl9rlxRgdLTTMCQQRcN2hdCg==", + "version": "7.25.2", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.2.tgz", + "integrity": "sha512-YTnYtra7W9e6/oAZEHj0bJehPRUlLH9/fbpT5LfB0NhQXyALCRkRs3zH9v07IYhkgpqX6Z78FnuccZr/l4Fs4Q==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.24.8", @@ -1334,16 +1334,16 @@ } }, "node_modules/@cspell/cspell-bundled-dicts": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-8.12.1.tgz", - "integrity": "sha512-55wCxlKwRsYCt8uWB65C0xiJ4bP43UE3b/GK01ekyz2fZ11mudMWGMrX/pdKwGIOXFfFqDz3DCRxFs+fHS58oA==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-8.13.0.tgz", + "integrity": "sha512-vtABTJeicWtd1bO74OB1IYSY/+nhK7S5yyW2GRcq1c9dEqRkgJNcYm8SUCm4EOH2oNGzeptjjGgR8emnvCiTfQ==", "dev": true, "dependencies": { "@cspell/dict-ada": "^4.0.2", "@cspell/dict-aws": "^4.0.3", "@cspell/dict-bash": "^4.1.3", - "@cspell/dict-companies": "^3.1.2", - "@cspell/dict-cpp": "^5.1.11", + "@cspell/dict-companies": "^3.1.3", + "@cspell/dict-cpp": "^5.1.12", "@cspell/dict-cryptocurrencies": "^5.0.0", "@cspell/dict-csharp": "^4.0.2", "@cspell/dict-css": "^4.0.12", @@ -1358,7 +1358,7 @@ "@cspell/dict-filetypes": "^3.0.4", "@cspell/dict-fonts": "^4.0.0", "@cspell/dict-fsharp": "^1.0.1", - "@cspell/dict-fullstack": "^3.1.8", + "@cspell/dict-fullstack": "^3.2.0", "@cspell/dict-gaming-terms": "^1.0.5", "@cspell/dict-git": "^3.0.0", "@cspell/dict-golang": "^6.0.9", @@ -1368,28 +1368,28 @@ "@cspell/dict-html-symbol-entities": "^4.0.0", "@cspell/dict-java": "^5.0.7", "@cspell/dict-julia": "^1.0.1", - "@cspell/dict-k8s": "^1.0.5", + "@cspell/dict-k8s": "^1.0.6", "@cspell/dict-latex": "^4.0.0", "@cspell/dict-lorem-ipsum": "^4.0.0", "@cspell/dict-lua": "^4.0.3", "@cspell/dict-makefile": "^1.0.0", "@cspell/dict-monkeyc": "^1.0.6", "@cspell/dict-node": "^5.0.1", - "@cspell/dict-npm": "^5.0.17", + "@cspell/dict-npm": "^5.0.18", "@cspell/dict-php": "^4.0.8", "@cspell/dict-powershell": "^5.0.5", "@cspell/dict-public-licenses": "^2.0.7", - "@cspell/dict-python": "^4.2.1", + "@cspell/dict-python": "^4.2.3", "@cspell/dict-r": "^2.0.1", "@cspell/dict-ruby": "^5.0.2", - "@cspell/dict-rust": "^4.0.4", + "@cspell/dict-rust": "^4.0.5", "@cspell/dict-scala": "^5.0.3", - "@cspell/dict-software-terms": "^4.0.0", + "@cspell/dict-software-terms": "^4.0.3", "@cspell/dict-sql": "^2.1.3", "@cspell/dict-svelte": "^1.0.2", "@cspell/dict-swift": "^2.0.1", "@cspell/dict-terraform": "^1.0.0", - "@cspell/dict-typescript": "^3.1.5", + "@cspell/dict-typescript": "^3.1.6", "@cspell/dict-vue": "^3.0.0" }, "engines": { @@ -1397,30 +1397,30 @@ } }, "node_modules/@cspell/cspell-json-reporter": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-json-reporter/-/cspell-json-reporter-8.12.1.tgz", - "integrity": "sha512-nO/3GTk3rBpLRBzkmcKFxbtEDd3FKXfQ5uTCpJ27XYVHYjlU+d4McOYYMClMhpFianVol2JCyberpGAj6bVgLg==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@cspell/cspell-json-reporter/-/cspell-json-reporter-8.13.0.tgz", + "integrity": "sha512-OR6+gxWImIOegn9Zi9zlnPZtZMWFToFD8l5bDbHMaScTDygB0IJNg9ZGxWGpxpbMXLNMiefAo5inJwF6LW9F3w==", "dev": true, "dependencies": { - "@cspell/cspell-types": "8.12.1" + "@cspell/cspell-types": "8.13.0" }, "engines": { "node": ">=18" } }, "node_modules/@cspell/cspell-pipe": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-pipe/-/cspell-pipe-8.12.1.tgz", - "integrity": "sha512-lh0zIm43r/Fj3sQWXc68msKnXNrfPOo8VvzL1hOP0v/j2eH61fvELH08/K+nQJ8cCutNZ4zhk9+KMDU4KmsMtw==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@cspell/cspell-pipe/-/cspell-pipe-8.13.0.tgz", + "integrity": "sha512-YukXZSSUUD5OqzThpyUUusXH7E+z2YViCVUwTb6bQ/DIHHEUIlTPSF8n/xGUmOR6XeQDBxqgNasTDB5AeRXPJg==", "dev": true, "engines": { "node": ">=18" } }, "node_modules/@cspell/cspell-resolver": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-resolver/-/cspell-resolver-8.12.1.tgz", - "integrity": "sha512-3HE04m7DS/6xYpWPN2QBGCHr26pvxHa78xYk+PjiPD2Q49ceqTNdFcZOYd+Wba8HbRXSukchSLhrTujmPEzqpw==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@cspell/cspell-resolver/-/cspell-resolver-8.13.0.tgz", + "integrity": "sha512-smUDfAQDrO5iodDe/7OL1i/fZhu8YrxNfbMCiazqLIYBhw2wrvS6LerBaM7HVUPZ8ZrdeYzIQ1wvEolsrJzuWw==", "dev": true, "dependencies": { "global-directory": "^4.0.1" @@ -1430,18 +1430,18 @@ } }, "node_modules/@cspell/cspell-service-bus": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-service-bus/-/cspell-service-bus-8.12.1.tgz", - "integrity": "sha512-UQPddS38dQ/FG00y2wginCzdS6yxryiGrWXSD/P59idCrYYDCYnI9pPsx4u10tmRkW1zJ+O7gGCsXw7xa5DAJQ==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@cspell/cspell-service-bus/-/cspell-service-bus-8.13.0.tgz", + "integrity": "sha512-370hfBsAFJQ5AJkD/aJF0NITu0kbABGpEkTvutkHAwoIedLp0vNMvlWja7CnFgXxAJOABROSwMXDjG8hLBkXOQ==", "dev": true, "engines": { "node": ">=18" } }, "node_modules/@cspell/cspell-types": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-8.12.1.tgz", - "integrity": "sha512-17POyyRgl7m7mMuv1qk2xX6E5bdT0F3247vloBCdUMyaVtmtN4uEiQ/jqU5vtW02vxlKjKS0HcTvKz4EVfSlzQ==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-8.13.0.tgz", + "integrity": "sha512-BnNPwycI/4v/9jFrMofUrUsYmI/Q5ZCE+HL0Yif+mS3r+twaE6Qpmtc9AnpBkLeXlUcY1aeQTASTD9smgGuxsQ==", "dev": true, "engines": { "node": ">=18" @@ -1769,9 +1769,9 @@ "dev": true }, "node_modules/@cspell/dynamic-import": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/@cspell/dynamic-import/-/dynamic-import-8.12.1.tgz", - "integrity": "sha512-18faXHALiMsXtG3v67qeyDhNRZVtkhX5Je2qw8iZQB/i61y0Mfm22iiZeXsKImrXbwP0acyhRkRA1sp1NaQmOw==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@cspell/dynamic-import/-/dynamic-import-8.13.0.tgz", + "integrity": "sha512-M1cIy6rqWs36M8HFghKsGz/m/WPpK7IIICBptCKoSc5F9VWCjq69UJKrhDMaMOAfJevrmomW5NqF4uhYxg7lNQ==", "dev": true, "dependencies": { "import-meta-resolve": "^4.1.0" @@ -1781,18 +1781,18 @@ } }, "node_modules/@cspell/strong-weak-map": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/@cspell/strong-weak-map/-/strong-weak-map-8.12.1.tgz", - "integrity": "sha512-0O5qGHRXoKl0+hXGdelox2awrCMr8LXObUcWwYbSih7HIm4DwhxMO4qjDFye1NdjW0P88yhpQ23J2ceSto9C5Q==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@cspell/strong-weak-map/-/strong-weak-map-8.13.0.tgz", + "integrity": "sha512-+SvzzupsnKm6+OfK8t2KL2uY0RzTDhjTVEaEIug8IgwlHSf4waYgQ2MJ4ZJPww7OvNEcBmUAeh6Z1+cwiqMycQ==", "dev": true, "engines": { "node": ">=18" } }, "node_modules/@cspell/url": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/@cspell/url/-/url-8.12.1.tgz", - "integrity": "sha512-mUYaDniHVLw0YXn2egT2e21MYubMAf+1LDeC0kkbg4VWNxSlC1Ksyv6pqhos495esaa8OCjizdIdnGSF6al9Rw==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@cspell/url/-/url-8.13.0.tgz", + "integrity": "sha512-+MEFtLb/VJK5WEwmtLCqfghkDBnPNK5XdUNt24tKfwinAlf4VSMxCmplqPwRjXVIbT5C4stSUY/ZrPadEWjw8Q==", "dev": true, "engines": { "node": ">=18.0" @@ -3658,16 +3658,16 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.17.0.tgz", - "integrity": "sha512-pyiDhEuLM3PuANxH7uNYan1AaFs5XE0zw1hq69JBvGvE7gSuEoQl1ydtEe/XQeoC3GQxLXyOVa5kNOATgM638A==", + "version": "7.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.18.0.tgz", + "integrity": "sha512-94EQTWZ40mzBc42ATNIBimBEDltSJ9RQHCC8vc/PDbxi4k8dVwUAv4o98dk50M1zB+JGFxp43FP7f8+FP8R6Sw==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "7.17.0", - "@typescript-eslint/type-utils": "7.17.0", - "@typescript-eslint/utils": "7.17.0", - "@typescript-eslint/visitor-keys": "7.17.0", + "@typescript-eslint/scope-manager": "7.18.0", + "@typescript-eslint/type-utils": "7.18.0", + "@typescript-eslint/utils": "7.18.0", + "@typescript-eslint/visitor-keys": "7.18.0", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -3691,15 +3691,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.17.0.tgz", - "integrity": "sha512-puiYfGeg5Ydop8eusb/Hy1k7QmOU6X3nvsqCgzrB2K4qMavK//21+PzNE8qeECgNOIoertJPUC1SpegHDI515A==", + "version": "7.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.18.0.tgz", + "integrity": "sha512-4Z+L8I2OqhZV8qA132M4wNL30ypZGYOQVBfMgxDH/K5UX0PNqTu1c6za9ST5r9+tavvHiTWmBnKzpCJ/GlVFtg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "7.17.0", - "@typescript-eslint/types": "7.17.0", - "@typescript-eslint/typescript-estree": "7.17.0", - "@typescript-eslint/visitor-keys": "7.17.0", + "@typescript-eslint/scope-manager": "7.18.0", + "@typescript-eslint/types": "7.18.0", + "@typescript-eslint/typescript-estree": "7.18.0", + "@typescript-eslint/visitor-keys": "7.18.0", "debug": "^4.3.4" }, "engines": { @@ -3719,13 +3719,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.17.0.tgz", - "integrity": "sha512-0P2jTTqyxWp9HiKLu/Vemr2Rg1Xb5B7uHItdVZ6iAenXmPo4SZ86yOPCJwMqpCyaMiEHTNqizHfsbmCFT1x9SA==", + "version": "7.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.18.0.tgz", + "integrity": "sha512-jjhdIE/FPF2B7Z1uzc6i3oWKbGcHb87Qw7AWj6jmEqNOfDFbJWtjt/XfwCpvNkpGWlcJaog5vTR+VV8+w9JflA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.17.0", - "@typescript-eslint/visitor-keys": "7.17.0" + "@typescript-eslint/types": "7.18.0", + "@typescript-eslint/visitor-keys": "7.18.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -3736,13 +3736,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.17.0.tgz", - "integrity": "sha512-XD3aaBt+orgkM/7Cei0XNEm1vwUxQ958AOLALzPlbPqb8C1G8PZK85tND7Jpe69Wualri81PLU+Zc48GVKIMMA==", + "version": "7.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.18.0.tgz", + "integrity": "sha512-XL0FJXuCLaDuX2sYqZUUSOJ2sG5/i1AAze+axqmLnSkNEVMVYLF+cbwlB2w8D1tinFuSikHmFta+P+HOofrLeA==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "7.17.0", - "@typescript-eslint/utils": "7.17.0", + "@typescript-eslint/typescript-estree": "7.18.0", + "@typescript-eslint/utils": "7.18.0", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -3763,9 +3763,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.17.0.tgz", - "integrity": "sha512-a29Ir0EbyKTKHnZWbNsrc/gqfIBqYPwj3F2M+jWE/9bqfEHg0AMtXzkbUkOG6QgEScxh2+Pz9OXe11jHDnHR7A==", + "version": "7.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.18.0.tgz", + "integrity": "sha512-iZqi+Ds1y4EDYUtlOOC+aUmxnE9xS/yCigkjA7XpTKV6nCBd3Hp/PRGGmdwnfkV2ThMyYldP1wRpm/id99spTQ==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -3776,13 +3776,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.17.0.tgz", - "integrity": "sha512-72I3TGq93t2GoSBWI093wmKo0n6/b7O4j9o8U+f65TVD0FS6bI2180X5eGEr8MA8PhKMvYe9myZJquUT2JkCZw==", + "version": "7.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.18.0.tgz", + "integrity": "sha512-aP1v/BSPnnyhMHts8cf1qQ6Q1IFwwRvAQGRvBFkWlo3/lH29OXA3Pts+c10nxRxIBrDnoMqzhgdwVe5f2D6OzA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.17.0", - "@typescript-eslint/visitor-keys": "7.17.0", + "@typescript-eslint/types": "7.18.0", + "@typescript-eslint/visitor-keys": "7.18.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -3804,15 +3804,15 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.17.0.tgz", - "integrity": "sha512-r+JFlm5NdB+JXc7aWWZ3fKSm1gn0pkswEwIYsrGPdsT2GjsRATAKXiNtp3vgAAO1xZhX8alIOEQnNMl3kbTgJw==", + "version": "7.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.18.0.tgz", + "integrity": "sha512-kK0/rNa2j74XuHVcoCZxdFBMF+aq/vH83CXAOHieC+2Gis4mF8jJXT5eAfyD3K0sAxtPuwxaIOIOvhwzVDt/kw==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "7.17.0", - "@typescript-eslint/types": "7.17.0", - "@typescript-eslint/typescript-estree": "7.17.0" + "@typescript-eslint/scope-manager": "7.18.0", + "@typescript-eslint/types": "7.18.0", + "@typescript-eslint/typescript-estree": "7.18.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -3826,12 +3826,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.17.0.tgz", - "integrity": "sha512-RVGC9UhPOCsfCdI9pU++K4nD7to+jTcMIbXTSOcrLqUEW6gF2pU1UUbYJKc9cvcRSK1UDeMJ7pdMxf4bhMpV/A==", + "version": "7.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.18.0.tgz", + "integrity": "sha512-cDF0/Gf81QpY3xYyJKDV14Zwdmid5+uuENhjH2EqFaF0ni+yAyq/LzMaIJdhNJXZI7uLzwIlA+V7oWoyn6Curg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.17.0", + "@typescript-eslint/types": "7.18.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -4477,9 +4477,9 @@ } }, "node_modules/axe-core": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.9.1.tgz", - "integrity": "sha512-QbUdXJVTpvUTHU7871ppZkdOLBeGUKBQWHkHrvN2V9IQWGMt61zf3B45BtzjxEJzYuj0JBjBZP/hmYS/R9pmAw==", + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.10.0.tgz", + "integrity": "sha512-Mr2ZakwQ7XUAjp7pAwQWRhhK8mQQ6JAaNWSjmjxil0R8BPioMtQsTLOolGYkji1rcL++3dCqZA3zWqpT+9Ew6g==", "dev": true, "engines": { "node": ">=4" @@ -4973,9 +4973,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001643", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001643.tgz", - "integrity": "sha512-ERgWGNleEilSrHM6iUz/zJNSQTP8Mr21wDWpdgvRwcTXGAq6jMtOUPP4dqFPTdKqZ2wKTdtB+uucZ3MRpAUSmg==", + "version": "1.0.30001644", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001644.tgz", + "integrity": "sha512-YGvlOZB4QhZuiis+ETS0VXR+MExbFf4fZYYeMTEE0aTQd/RdIjkTyZjLrbYVKnHzppDvnOhritRVv+i7Go6mHw==", "dev": true, "funding": [ { @@ -5784,23 +5784,24 @@ } }, "node_modules/cspell": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/cspell/-/cspell-8.12.1.tgz", - "integrity": "sha512-mdnUUPydxxdj/uyF84U/DvPiY/l58Z2IpNwTx3H9Uve9dfT0vRv/7jiFNAvK4hAfZQaMaE7DPC00ckywTI/XgA==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/cspell/-/cspell-8.13.0.tgz", + "integrity": "sha512-sByh0pN9NTBA9eGOsuN6r0c8vwD6LVwH4rhHfCMQ1Gjw5ckH9Obp8JxwrIM0fxm14EXQDcKaAewRfHYx2d1jRg==", "dev": true, "dependencies": { - "@cspell/cspell-json-reporter": "8.12.1", - "@cspell/cspell-pipe": "8.12.1", - "@cspell/cspell-types": "8.12.1", - "@cspell/dynamic-import": "8.12.1", - "@cspell/url": "8.12.1", + "@cspell/cspell-json-reporter": "8.13.0", + "@cspell/cspell-pipe": "8.13.0", + "@cspell/cspell-types": "8.13.0", + "@cspell/dynamic-import": "8.13.0", + "@cspell/url": "8.13.0", "chalk": "^5.3.0", "chalk-template": "^1.1.0", "commander": "^12.1.0", - "cspell-gitignore": "8.12.1", - "cspell-glob": "8.12.1", - "cspell-io": "8.12.1", - "cspell-lib": "8.12.1", + "cspell-dictionary": "8.13.0", + "cspell-gitignore": "8.13.0", + "cspell-glob": "8.13.0", + "cspell-io": "8.13.0", + "cspell-lib": "8.13.0", "fast-glob": "^3.3.2", "fast-json-stable-stringify": "^2.1.0", "file-entry-cache": "^9.0.0", @@ -5820,14 +5821,14 @@ } }, "node_modules/cspell-config-lib": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/cspell-config-lib/-/cspell-config-lib-8.12.1.tgz", - "integrity": "sha512-xEoKdb8hyturyiUXFdRgQotYegYe3OZS+Yc7JHnB75Ykt+Co2gtnu2M/Yb0yoqaHCXflVO6MITrKNaxricgqVw==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/cspell-config-lib/-/cspell-config-lib-8.13.0.tgz", + "integrity": "sha512-KsTzkv5OLb2PSDq+3yVeS6fCsLvqgEFDJ79I+3VZqWyAmixi2LZMdaobbXXItJRNiDuQ9RnbG2UM9smcJCQTUA==", "dev": true, "dependencies": { - "@cspell/cspell-types": "8.12.1", + "@cspell/cspell-types": "8.13.0", "comment-json": "^4.2.4", - "yaml": "^2.4.5" + "yaml": "^2.5.0" }, "engines": { "node": ">=18" @@ -5850,30 +5851,29 @@ } }, "node_modules/cspell-dictionary": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/cspell-dictionary/-/cspell-dictionary-8.12.1.tgz", - "integrity": "sha512-jYHEA48on6pBQYVUEzXV63wy5Ulx/QNUZcoiG3C0OmYIKjACTaEg02AMDOr+Eaj34E5v4pGEShzot4Qtt/aiNQ==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/cspell-dictionary/-/cspell-dictionary-8.13.0.tgz", + "integrity": "sha512-+ZmB7ReBkAba9S0CmYOMm6EVsqyNlRg8V7I0PP9ttMriaGJ4yO+9IIsn6wI79pYB4DaDNBxblLgs12eMWOlNeQ==", "dev": true, "dependencies": { - "@cspell/cspell-pipe": "8.12.1", - "@cspell/cspell-types": "8.12.1", - "cspell-trie-lib": "8.12.1", - "fast-equals": "^5.0.1", - "gensequence": "^7.0.0" + "@cspell/cspell-pipe": "8.13.0", + "@cspell/cspell-types": "8.13.0", + "cspell-trie-lib": "8.13.0", + "fast-equals": "^5.0.1" }, "engines": { "node": ">=18" } }, "node_modules/cspell-gitignore": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/cspell-gitignore/-/cspell-gitignore-8.12.1.tgz", - "integrity": "sha512-XlO87rdrab3VKU8e7+RGEfqEtYqo7ObgfZeYEAdJlwUXvqYxBzA11jDZAovDz/5jv0YfRMx6ch5t6+1zfSeBbQ==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/cspell-gitignore/-/cspell-gitignore-8.13.0.tgz", + "integrity": "sha512-tu3h6JbejYkGgn9VgW1VAoYchFg3tUtLAzL9oVnkPc58n7gwQpz1cLSKzGpmWyXzjFd6pX0aywnkcOBeWaudMQ==", "dev": true, "dependencies": { - "@cspell/url": "8.12.1", - "cspell-glob": "8.12.1", - "cspell-io": "8.12.1", + "@cspell/url": "8.13.0", + "cspell-glob": "8.13.0", + "cspell-io": "8.13.0", "find-up-simple": "^1.0.0" }, "bin": { @@ -5884,12 +5884,12 @@ } }, "node_modules/cspell-glob": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-8.12.1.tgz", - "integrity": "sha512-ZplEPLlNwj7luEKu/VudIaV+cGTQHExihGvAUxlIVMFURiAFMT5eH0UsQoCEpSevIEueO+slLUDy7rxwTwAGdQ==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-8.13.0.tgz", + "integrity": "sha512-4xghVAHGSwDEOB+OsXDmQoBVfo/NtUpxPlmd89vaZtqv1CmnlUzmglEb13jYx6oFydDaY+mSRKw2V0unATnpBA==", "dev": true, "dependencies": { - "@cspell/url": "8.12.1", + "@cspell/url": "8.13.0", "micromatch": "^4.0.7" }, "engines": { @@ -5897,13 +5897,13 @@ } }, "node_modules/cspell-grammar": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/cspell-grammar/-/cspell-grammar-8.12.1.tgz", - "integrity": "sha512-IAES553M5nuB/wtiWYayDX2/5OmDu2VmEcnV6SXNze8oop0oodSqr3h46rLy+m1EOOD8nenMa295N/dRPqTB/g==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/cspell-grammar/-/cspell-grammar-8.13.0.tgz", + "integrity": "sha512-vrfIO2LqZPPA7Pe8xPPJwXKiXq9nWJxH5JesdVFQZ+DtkklzC07J8OrGTFFo0/r9/CfQMNqqs0XbtRcoa+xRYg==", "dev": true, "dependencies": { - "@cspell/cspell-pipe": "8.12.1", - "@cspell/cspell-types": "8.12.1" + "@cspell/cspell-pipe": "8.13.0", + "@cspell/cspell-types": "8.13.0" }, "bin": { "cspell-grammar": "bin.mjs" @@ -5913,39 +5913,39 @@ } }, "node_modules/cspell-io": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-8.12.1.tgz", - "integrity": "sha512-uPjYQP/OKmA8B1XbJunUTBingtrb6IKkp7enyljsZEbtPRKSudP16QPacgyZLLb5rCVQXyexebGfQ182jmq7dg==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-8.13.0.tgz", + "integrity": "sha512-9rcHUWHmNum7w7eCVJrUZgvJpL30OAYum8Ij9NenqwGhim95tPQc2CtHZ2aibJ6G4c4Aape9ytSgNxoIYG97DQ==", "dev": true, "dependencies": { - "@cspell/cspell-service-bus": "8.12.1", - "@cspell/url": "8.12.1" + "@cspell/cspell-service-bus": "8.13.0", + "@cspell/url": "8.13.0" }, "engines": { "node": ">=18" } }, "node_modules/cspell-lib": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-8.12.1.tgz", - "integrity": "sha512-z2aZXnrip76zbH0j0ibTGux3mA71TMHtoEAd+n66so7Tx3QydUDAI0u7tzfbP3JyqL9ZWPlclQAfbutMUuzMBQ==", - "dev": true, - "dependencies": { - "@cspell/cspell-bundled-dicts": "8.12.1", - "@cspell/cspell-pipe": "8.12.1", - "@cspell/cspell-resolver": "8.12.1", - "@cspell/cspell-types": "8.12.1", - "@cspell/dynamic-import": "8.12.1", - "@cspell/strong-weak-map": "8.12.1", - "@cspell/url": "8.12.1", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-8.13.0.tgz", + "integrity": "sha512-WTVswCFQduFrEBKTj0EKB5GeEfMwQou23DEcudyWIc2sFoovYF0d/Fr6J69HbGIvwQq1ToPM4eayoQK0/Qn6Mg==", + "dev": true, + "dependencies": { + "@cspell/cspell-bundled-dicts": "8.13.0", + "@cspell/cspell-pipe": "8.13.0", + "@cspell/cspell-resolver": "8.13.0", + "@cspell/cspell-types": "8.13.0", + "@cspell/dynamic-import": "8.13.0", + "@cspell/strong-weak-map": "8.13.0", + "@cspell/url": "8.13.0", "clear-module": "^4.1.2", "comment-json": "^4.2.4", - "cspell-config-lib": "8.12.1", - "cspell-dictionary": "8.12.1", - "cspell-glob": "8.12.1", - "cspell-grammar": "8.12.1", - "cspell-io": "8.12.1", - "cspell-trie-lib": "8.12.1", + "cspell-config-lib": "8.13.0", + "cspell-dictionary": "8.13.0", + "cspell-glob": "8.13.0", + "cspell-grammar": "8.13.0", + "cspell-io": "8.13.0", + "cspell-trie-lib": "8.13.0", "env-paths": "^3.0.0", "fast-equals": "^5.0.1", "gensequence": "^7.0.0", @@ -5988,13 +5988,13 @@ } }, "node_modules/cspell-trie-lib": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-8.12.1.tgz", - "integrity": "sha512-a9QmGGUhparM9v184YsB+D0lSdzVgWDlLFEBjVLQJyvp43HErZjvcTPUojUypNQUEjxvksX0/C4pO5Wq8YUD8w==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-8.13.0.tgz", + "integrity": "sha512-3v9q5nUF0Y88bQQLmSXUcf7izsu+Dj/g5Dk0hqqykcsobqq4EN2dmfZH+Ej1Q5h3DCiwPemGb7IPg8pfqTHpAg==", "dev": true, "dependencies": { - "@cspell/cspell-pipe": "8.12.1", - "@cspell/cspell-types": "8.12.1", + "@cspell/cspell-pipe": "8.13.0", + "@cspell/cspell-types": "8.13.0", "gensequence": "^7.0.0" }, "engines": { @@ -6401,9 +6401,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.2.tgz", - "integrity": "sha512-kc4r3U3V3WLaaZqThjYz/Y6z8tJe+7K0bbjUVo3i+LWIypVdMx5nXCkwRe6SWbY6ILqLdc1rKcKmr3HoH7wjSQ==", + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.3.tgz", + "integrity": "sha512-QNdYSS5i8D9axWp/6XIezRObRHqaav/ur9z1VzCDUCH1XIFOr9WQk5xmgunhsTpjjgDy3oLxO/WMOVZlpUQrlA==", "dev": true }, "node_modules/emittery": { @@ -9221,9 +9221,9 @@ } }, "node_modules/husky": { - "version": "9.1.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.3.tgz", - "integrity": "sha512-ET3TQmQgdIu0pt+jKkpo5oGyg/4MQZpG6xcam5J5JyNJV+CBT23OBpCF15bKHKycRyMH9k6ONy8g2HdGIsSkMQ==", + "version": "9.1.4", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.4.tgz", + "integrity": "sha512-bho94YyReb4JV7LYWRWxZ/xr6TtOTt8cMfmQ39MQYJ7f/YE268s3GdghGwi+y4zAeqewE5zYLvuhV0M0ijsDEA==", "dev": true, "bin": { "husky": "bin.js" @@ -16281,13 +16281,13 @@ } }, "node_modules/which-builtin-type": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.1.3.tgz", - "integrity": "sha512-YmjsSMDBYsM1CaFiayOVT06+KJeXf0o5M/CAd4o1lTadFAtacTUM49zoYxr/oroopFDfhvN6iEcBxUyc3gvKmw==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.1.4.tgz", + "integrity": "sha512-bppkmBSsHFmIMSl8BO9TbsyzsvGjVoppt8xUiGzwiu/bhDCGxnpOKCxgqj6GuyHE0mINMDecBFPlOm2hzY084w==", "dev": true, "dependencies": { - "function.prototype.name": "^1.1.5", - "has-tostringtag": "^1.0.0", + "function.prototype.name": "^1.1.6", + "has-tostringtag": "^1.0.2", "is-async-function": "^2.0.0", "is-date-object": "^1.0.5", "is-finalizationregistry": "^1.0.2", @@ -16296,8 +16296,8 @@ "is-weakref": "^1.0.2", "isarray": "^2.0.5", "which-boxed-primitive": "^1.0.2", - "which-collection": "^1.0.1", - "which-typed-array": "^1.1.9" + "which-collection": "^1.0.2", + "which-typed-array": "^1.1.15" }, "engines": { "node": ">= 0.4" diff --git a/package.json b/package.json index 21b78f64..25503478 100644 --- a/package.json +++ b/package.json @@ -76,10 +76,10 @@ "@types/lodash": "^4.17.7", "@types/node": "^20.14.13", "@types/supertest": "^6.0.2", - "@typescript-eslint/eslint-plugin": "^7.17.0", - "@typescript-eslint/parser": "^7.17.0", + "@typescript-eslint/eslint-plugin": "^7.18.0", + "@typescript-eslint/parser": "^7.18.0", "chance": "^1.1.12", - "cspell": "^8.12.1", + "cspell": "^8.13.0", "eslint": "8.57.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-typescript": "^18.0.0", @@ -99,7 +99,7 @@ "eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-switch-case": "^1.1.2", "eslint-plugin-unused-imports": "^4.0.1", - "husky": "^9.1.3", + "husky": "^9.1.4", "jest": "29.7.0", "jest-when": "^3.6.0", "lint-staged": "^15.2.7", diff --git a/src/helper-modules/companies-house/companies-house.service.test.ts b/src/helper-modules/companies-house/companies-house.service.test.ts index 4e3ede16..b8a0e74a 100644 --- a/src/helper-modules/companies-house/companies-house.service.test.ts +++ b/src/helper-modules/companies-house/companies-house.service.test.ts @@ -132,7 +132,7 @@ describe('CompaniesHouseService', () => { await expect(getCompanyPromise).rejects.toHaveProperty('innerError', axiosError); }); - it(`throws a CompaniesHouseNotFoundException when the Companies House API returns a 404 response containing the error string 'company-profile-not-found'`, async () => { + it(`throws a CompaniesHouseNotFoundException when the Companies House API returns a 404 response status'`, async () => { const axiosError = new AxiosError(); axiosError.response = { data: getCompanyCompaniesHouseNotFoundResponse, diff --git a/src/helper-modules/companies-house/known-errors.ts b/src/helper-modules/companies-house/known-errors.ts index 95f9081e..a1b9be9c 100644 --- a/src/helper-modules/companies-house/known-errors.ts +++ b/src/helper-modules/companies-house/known-errors.ts @@ -1,5 +1,5 @@ import { HttpStatus } from '@nestjs/common'; -import { messageCheck, statusCheck } from '@ukef/helpers/response-status'; +import { messageCheck, statusCheck } from '@ukef/helpers/response-status.helper'; import { AxiosError } from 'axios'; import { CompaniesHouseInvalidAuthorizationException } from './exception/companies-house-invalid-authorization.exception'; @@ -11,7 +11,7 @@ export type KnownErrors = KnownError[]; type KnownError = { checkHasError: (error: Error) => boolean; throwError: (error: AxiosError) => never }; export const getCompanyMalformedAuthorizationHeaderKnownCompaniesHouseError = (): KnownError => ({ - checkHasError: (error) => statusCheck({ error, status: HttpStatus.UNAUTHORIZED }) && messageCheck({ error, search: 'Invalid Authorization header' }), + checkHasError: (error) => statusCheck({ error, status: HttpStatus.BAD_REQUEST }) && messageCheck({ error, search: 'Invalid Authorization header' }), throwError: (error) => { throw new CompaniesHouseMalformedAuthorizationHeaderException( `Invalid 'Authorization' header. Check that your 'Authorization' header is well-formed.`, diff --git a/src/helper-modules/companies-house/wrap-companies-house-http-error-callback.ts b/src/helper-modules/companies-house/wrap-companies-house-http-error-callback.ts index 9f031788..2fa6abf9 100644 --- a/src/helper-modules/companies-house/wrap-companies-house-http-error-callback.ts +++ b/src/helper-modules/companies-house/wrap-companies-house-http-error-callback.ts @@ -9,21 +9,25 @@ type CompaniesHouseHttpErrorCallback = (error: Error) => ObservableInput; export const createWrapCompaniesHouseHttpGetErrorCallback = ({ messageForUnknownError, knownErrors }: { messageForUnknownError: string; knownErrors: KnownErrors }): CompaniesHouseHttpErrorCallback => (error: Error) => { - if (error instanceof AxiosError && error.response && typeof error.response.data === 'object') { - const errorResponseData = error.response.data; - let errorMessage: string; + if (error instanceof AxiosError) { + let message: string; + const status: number = error?.response?.status; - if (typeof errorResponseData.error === 'string') { - errorMessage = errorResponseData.error; - } else if (errorResponseData.errors && errorResponseData.errors[0] && typeof errorResponseData.errors[0].error === 'string') { - errorMessage = errorResponseData.errors[0].error; + if (typeof error?.response?.data?.error === 'string') { + message = error.response.data.error; + } else if (error?.response?.data?.errors[0] && typeof error?.response?.data?.errors[0]?.error === 'string') { + message = error.response.data.errors[0].error; } - if (errorMessage) { - const errorMessageInLowerCase = errorMessage.toLowerCase(); - - knownErrors.forEach(({ caseInsensitiveSubstringToFind, throwError }) => { - if (errorMessageInLowerCase.includes(caseInsensitiveSubstringToFind.toLowerCase())) { + /** + * CH API will throw empty response body with `404` + * upon sending a valid non-existent 8 digit CRN. + * + * Otherwise `404` with an expected response body. + */ + if (message || status) { + knownErrors.forEach(({ checkHasError, throwError }) => { + if (checkHasError(error)) { return throwError(error); } }); diff --git a/src/helpers/index.ts b/src/helpers/index.ts index e764388e..4978de15 100644 --- a/src/helpers/index.ts +++ b/src/helpers/index.ts @@ -1,3 +1,3 @@ export * from './regex.helper'; -export * from './response-status'; +export * from './response-status.helper'; export * from './transform-interceptor.helper'; diff --git a/src/helpers/response-status.helper.test.ts b/src/helpers/response-status.helper.test.ts new file mode 100644 index 00000000..5bf0d42a --- /dev/null +++ b/src/helpers/response-status.helper.test.ts @@ -0,0 +1,66 @@ +import { HttpStatus } from '@nestjs/common'; +import { isAxiosError } from 'axios'; + +import { statusCheck } from './response-status.helper'; + +jest.mock('axios', () => ({ + isAxiosError: jest.fn(), +})); + +describe('statusCheck', () => { + beforeEach(() => { + (isAxiosError as unknown as jest.Mock).mockReturnValue(true); + }); + + it('should return true when isAxiosError is true and status matches', () => { + const error = { + response: { + status: HttpStatus.BAD_REQUEST, + }, + name: 'Bad request', + message: 'Bad request', + } as Error; + + const result = statusCheck({ error, status: HttpStatus.BAD_REQUEST }); + + expect(result).toBe(true); + }); + + it('should return false when isAxiosError is true but status does not match', () => { + const error = { + response: { + status: HttpStatus.BAD_REQUEST, + }, + name: 'Bad request', + message: 'Bad request', + } as Error; + + const result = statusCheck({ error, status: HttpStatus.NOT_FOUND }); + + expect(result).toBe(false); + }); + + it('should return false when isAxiosError is false', () => { + const error = { + response: { + status: HttpStatus.BAD_REQUEST, + }, + name: 'Bad request', + message: 'Bad request', + } as Error; + + (isAxiosError as unknown as jest.Mock).mockReturnValue(false); + + const result = statusCheck({ error, status: HttpStatus.BAD_REQUEST }); + + expect(result).toBe(false); + }); + + it('should return false when error does not have a response', () => { + const error = {} as Error; + + const result = statusCheck({ error, status: HttpStatus.BAD_REQUEST }); + + expect(result).toBe(false); + }); +}); diff --git a/src/helpers/response-status.ts b/src/helpers/response-status.helper.ts similarity index 80% rename from src/helpers/response-status.ts rename to src/helpers/response-status.helper.ts index fbc53cff..721c4b12 100644 --- a/src/helpers/response-status.ts +++ b/src/helpers/response-status.helper.ts @@ -15,12 +15,14 @@ export const statusCheck = ({ error, status }: { error: Error; status: HttpStatu */ export const messageCheck = ({ error, search }: { error: Error; search: string }): boolean => { if (!isAxiosError(error) || !error?.response?.data) { - return; + return false; } let message: string; - if (error?.response?.data?.errors?.length && typeof error?.response?.data?.errors[0]?.error === 'string') { + if (typeof error?.response?.data?.error === 'string') { + message = error.response.data.error; + } else if (error?.response?.data?.errors[0] && typeof error?.response?.data?.errors[0]?.error === 'string') { message = error.response.data.errors[0].error; } diff --git a/test/companies/get-company-by-registration-number.api-test.ts b/test/companies/get-company-by-registration-number.api-test.ts index 50b3f5e2..297fa234 100644 --- a/test/companies/get-company-by-registration-number.api-test.ts +++ b/test/companies/get-company-by-registration-number.api-test.ts @@ -97,16 +97,13 @@ describe('GET /companies?registrationNumber=', () => { }, ); - it(`returns a 404 response if the Companies House API returns a 404 response containing the error string 'company-profile-not-found'`, async () => { + it(`returns a 404 response if the Companies House API returns a 404 response status code`, async () => { requestToGetCompanyByRegistrationNumber(companiesHousePath).reply(404, getCompanyCompaniesHouseNotFoundResponse); const { status, body } = await api.get(mdmPath); expect(status).toBe(404); - expect(body).toStrictEqual({ - statusCode: 404, - message: 'Not found', - }); + expect(body).toStrictEqual({}); }); it('returns a 422 response if the Companies House API returns an overseas company', async () => { diff --git a/test/support/generator/get-company-generator.ts b/test/support/generator/get-company-generator.ts index 865293e1..922a883e 100644 --- a/test/support/generator/get-company-generator.ts +++ b/test/support/generator/get-company-generator.ts @@ -185,14 +185,7 @@ export class GetCompanyGenerator extends AbstractGenerator