diff --git a/.mocharc.json b/.mocharc.json index 31cd61864..d92ea3d94 100644 --- a/.mocharc.json +++ b/.mocharc.json @@ -2,6 +2,5 @@ "require": ["ts-node/register"], "bail": true, "timeout": 5000, - "bail": true, "exit": true } diff --git a/package-lock.json b/package-lock.json index 8052708e7..60c959a42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -104,8 +104,7 @@ "husky": "^4.3.8", "lint-staged": "^10.5.4", "mocha": "^9.1.2", - "msw": "^1.3.2", - "node-request-interceptor": "^0.6.3", + "msw": "^2.2.3", "nyc": "^15.1.0", "oclif": "4.0.2", "pkg": "^5.8.1", @@ -1340,6 +1339,22 @@ "node": ">=6.9.0" } }, + "node_modules/@bundled-es-modules/cookie": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@bundled-es-modules/cookie/-/cookie-2.0.0.tgz", + "integrity": "sha512-Or6YHg/kamKHpxULAdSqhGqnWFneIXu1NKvvfBBzKGwpVsYuFIQ5aBPHDnnoR3ghW1nvSkALd+EF9iMtY7Vjxw==", + "dependencies": { + "cookie": "^0.5.0" + } + }, + "node_modules/@bundled-es-modules/statuses": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@bundled-es-modules/statuses/-/statuses-1.0.1.tgz", + "integrity": "sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==", + "dependencies": { + "statuses": "^2.0.1" + } + }, "node_modules/@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -1523,6 +1538,106 @@ "resolved": "packages/notification", "link": true }, + "node_modules/@inquirer/confirm": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-3.1.0.tgz", + "integrity": "sha512-nH5mxoTEoqk6WpoBz80GMpDSm9jH5V9AF8n+JZAZfMzd9gHeEG9w1o3KawPRR72lfzpP+QxBHLkOKLEApwhDiQ==", + "dependencies": { + "@inquirer/core": "^7.1.0", + "@inquirer/type": "^1.2.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/core": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-7.1.0.tgz", + "integrity": "sha512-FRCiDiU54XHt5B/D8hX4twwZuzSP244ANHbu3R7CAsJfiv1dUOz24ePBgCZjygEjDUi6BWIJuk4eWLKJ7LATUw==", + "dependencies": { + "@inquirer/type": "^1.2.1", + "@types/mute-stream": "^0.0.4", + "@types/node": "^20.11.26", + "@types/wrap-ansi": "^3.0.0", + "ansi-escapes": "^4.3.2", + "chalk": "^4.1.2", + "cli-spinners": "^2.9.2", + "cli-width": "^4.1.0", + "figures": "^3.2.0", + "mute-stream": "^1.0.0", + "run-async": "^3.0.0", + "signal-exit": "^4.1.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^6.2.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/core/node_modules/@types/node": { + "version": "20.11.27", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.27.tgz", + "integrity": "sha512-qyUZfMnCg1KEz57r7pzFtSGt49f6RPkPBis3Vo4PbS7roQEDn22hiHzl/Lo1q4i4hDEgBJmBF/NTNg2XR0HbFg==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@inquirer/core/node_modules/cli-width": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", + "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", + "engines": { + "node": ">= 12" + } + }, + "node_modules/@inquirer/core/node_modules/mute-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz", + "integrity": "sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/@inquirer/core/node_modules/run-async": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-3.0.0.tgz", + "integrity": "sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/@inquirer/core/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@inquirer/core/node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@inquirer/type": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-1.2.1.tgz", + "integrity": "sha512-xwMfkPAxeo8Ji/IxfUSqzRi0/+F2GIqJmpc5/thelgMGsjNZcjDDRBO9TLXT1s/hdx/mK5QbVIvgoLIFgXhTMQ==", + "engines": { + "node": ">=18" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -1825,50 +1940,33 @@ } }, "node_modules/@mswjs/cookies": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/@mswjs/cookies/-/cookies-0.2.2.tgz", - "integrity": "sha512-mlN83YSrcFgk7Dm1Mys40DLssI1KdJji2CMKN8eOlBqsTADYzj2+jWzsANsUTFbxDMWPD5e9bfA1RGqBpS3O1g==", - "dependencies": { - "@types/set-cookie-parser": "^2.4.0", - "set-cookie-parser": "^2.4.6" - }, + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@mswjs/cookies/-/cookies-1.1.0.tgz", + "integrity": "sha512-0ZcCVQxifZmhwNBoQIrystCb+2sWBY2Zw8lpfJBPCHGCA/HWqehITeCRVIv4VMy8MPlaHo2w2pTHFV2pFfqKPw==", "engines": { - "node": ">=14" + "node": ">=18" } }, "node_modules/@mswjs/interceptors": { - "version": "0.17.10", - "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.17.10.tgz", - "integrity": "sha512-N8x7eSLGcmUFNWZRxT1vsHvypzIRgQYdG0rJey/rZCy6zT/30qDt8Joj7FxzGNLSwXbeZqJOMqDurp7ra4hgbw==", + "version": "0.25.16", + "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.25.16.tgz", + "integrity": "sha512-8QC8JyKztvoGAdPgyZy49c9vSHHAZjHagwl4RY9E8carULk8ym3iTaiawrT1YoLF/qb449h48f71XDPgkUSOUg==", "dependencies": { - "@open-draft/until": "^1.0.3", - "@types/debug": "^4.1.7", - "@xmldom/xmldom": "^0.8.3", - "debug": "^4.3.3", - "headers-polyfill": "3.2.5", + "@open-draft/deferred-promise": "^2.2.0", + "@open-draft/logger": "^0.3.0", + "@open-draft/until": "^2.0.0", + "is-node-process": "^1.2.0", "outvariant": "^1.2.1", - "strict-event-emitter": "^0.2.4", - "web-encoding": "^1.1.5" + "strict-event-emitter": "^0.5.1" }, "engines": { - "node": ">=14" - } - }, - "node_modules/@mswjs/interceptors/node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "engines": { - "node": ">=0.8.x" + "node": ">=18" } }, - "node_modules/@mswjs/interceptors/node_modules/strict-event-emitter": { - "version": "0.2.8", - "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.2.8.tgz", - "integrity": "sha512-KDf/ujU8Zud3YaLtMCcTI4xkZlZVIYxTLr+XIULexP+77EEVWixeXroLUXQXiVtH4XH2W7jr/3PT1v3zBuvc3A==", - "dependencies": { - "events": "^3.3.0" - } + "node_modules/@mswjs/interceptors/node_modules/@open-draft/until": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz", + "integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==" }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", @@ -35542,10 +35640,19 @@ "@octokit/openapi-types": "^12.11.0" } }, - "node_modules/@open-draft/until": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-1.0.3.tgz", - "integrity": "sha512-Aq58f5HiWdyDlFffbbSjAlv596h/cOnt2DO1w3DOC7OJ5EHs0hd/nycJfiu9RJbT6Yk6F1knnRRXNSpxoIVZ9Q==" + "node_modules/@open-draft/deferred-promise": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz", + "integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==" + }, + "node_modules/@open-draft/logger": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@open-draft/logger/-/logger-0.3.0.tgz", + "integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==", + "dependencies": { + "is-node-process": "^1.2.0", + "outvariant": "^1.4.0" + } }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", @@ -36794,17 +36901,9 @@ } }, "node_modules/@types/cookie": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", - "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" - }, - "node_modules/@types/debug": { - "version": "4.1.12", - "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", - "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", - "dependencies": { - "@types/ms": "*" - } + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==" }, "node_modules/@types/expect": { "version": "1.20.4", @@ -36874,11 +36973,6 @@ "integrity": "sha512-46VLdbWI8Sc+hPexQ6NLNR2YpoDyDZIpASHkJQ2Yr+Kf9Giw6LdCTkwOdsnHKPQeh7xTjTmSnxbE8qpxYuCiHA==", "dev": true }, - "node_modules/@types/js-levenshtein": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@types/js-levenshtein/-/js-levenshtein-1.1.3.tgz", - "integrity": "sha512-jd+Q+sD20Qfu9e2aEXogiO3vpOC1PYJOUdyN9gvs4Qrvkg4wF43L5OhqrPeokdv8TL0/mXoYfpkcoGZMNN2pkQ==" - }, "node_modules/@types/js-yaml": { "version": "4.0.9", "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz", @@ -36936,10 +37030,13 @@ "integrity": "sha512-VmSX8yXZwS80/sDSlXJfGVMj5Q/fRlYxQWndOPRa7TIDfdKnXDjbwZxQ8h+rWgk/7HXA4Ga2c+w+X2U5jRDPnw==", "dev": true }, - "node_modules/@types/ms": { - "version": "0.7.34", - "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", - "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" + "node_modules/@types/mute-stream": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@types/mute-stream/-/mute-stream-0.0.4.tgz", + "integrity": "sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow==", + "dependencies": { + "@types/node": "*" + } }, "node_modules/@types/node": { "version": "18.19.24", @@ -37037,14 +37134,6 @@ "@types/node": "*" } }, - "node_modules/@types/set-cookie-parser": { - "version": "2.4.7", - "resolved": "https://registry.npmjs.org/@types/set-cookie-parser/-/set-cookie-parser-2.4.7.tgz", - "integrity": "sha512-+ge/loa0oTozxip6zmhRIk8Z/boU51wl9Q6QdLZcokIGMzY5lFXYy/x7Htj2HTC6/KZP1hUbZ1ekx8DYXICvWg==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/sinon": { "version": "10.0.20", "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.20.tgz", @@ -37079,6 +37168,11 @@ "@types/node": "*" } }, + "node_modules/@types/statuses": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.5.tgz", + "integrity": "sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A==" + }, "node_modules/@types/tz-offset": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/@types/tz-offset/-/tz-offset-0.0.3.tgz", @@ -37130,6 +37224,11 @@ "@types/webidl-conversions": "*" } }, + "node_modules/@types/wrap-ansi": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz", + "integrity": "sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g==" + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "6.21.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz", @@ -37356,20 +37455,6 @@ "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", "dev": true }, - "node_modules/@xmldom/xmldom": { - "version": "0.8.10", - "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.10.tgz", - "integrity": "sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw==", - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/@zxing/text-encoding": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/@zxing/text-encoding/-/text-encoding-0.9.0.tgz", - "integrity": "sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA==", - "optional": true - }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -37833,6 +37918,7 @@ "version": "1.0.7", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", + "dev": true, "dependencies": { "possible-typed-array-names": "^1.0.0" }, @@ -38610,7 +38696,8 @@ "node_modules/chardet": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==" + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true }, "node_modules/check-error": { "version": "1.0.3", @@ -38754,6 +38841,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dev": true, "dependencies": { "restore-cursor": "^3.1.0" }, @@ -38843,6 +38931,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", + "dev": true, "engines": { "node": ">= 10" } @@ -38862,6 +38951,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", + "dev": true, "engines": { "node": ">=0.8" } @@ -39404,6 +39494,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", + "dev": true, "dependencies": { "clone": "^1.0.2" }, @@ -40672,6 +40763,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "dev": true, "dependencies": { "chardet": "^0.7.0", "iconv-lite": "^0.4.24", @@ -41246,6 +41338,7 @@ "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, "dependencies": { "is-callable": "^1.1.3" } @@ -41893,6 +41986,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, "dependencies": { "has-symbols": "^1.0.3" }, @@ -41961,15 +42055,9 @@ } }, "node_modules/headers-polyfill": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-3.2.5.tgz", - "integrity": "sha512-tUCGvt191vNSQgttSyJoibR+VO+I6+iCHIUdhzEMJKE+EAL8BwCN7fUOZlY4ofOelNHsK+gEjxB/B+9N3EWtdA==" - }, - "node_modules/headers-utils": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/headers-utils/-/headers-utils-1.2.5.tgz", - "integrity": "sha512-DAzV5P/pk3wTU/8TLZN+zFTDv4Xa1QDTU8pRvovPetcOMbmqq8CwsAvZBLPZHH6usxyy31zMp7I4aCYb6XIf6w==", - "dev": true + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-4.0.2.tgz", + "integrity": "sha512-EWGTfnTqAO2L/j5HZgoM/3z82L7necsJ0pO9Tp0X1wil3PDLrkypTBRgVO2ExehEEvUycejZD3FuRaXpZZc3kw==" }, "node_modules/helmet": { "version": "4.6.0", @@ -42336,6 +42424,7 @@ "version": "8.2.6", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.2.6.tgz", "integrity": "sha512-M1WuAmb7pn9zdFRtQYk26ZBoY043Sse0wVDdk4Bppr+JOXyQYybdtvK+l9wUibhtjdjvtoiNy8tk+EgsYIUqKg==", + "dev": true, "dependencies": { "ansi-escapes": "^4.2.1", "chalk": "^4.1.1", @@ -42361,6 +42450,7 @@ "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -42451,6 +42541,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", + "dev": true, "dependencies": { "call-bind": "^1.0.2", "has-tostringtag": "^1.0.0" @@ -42541,6 +42632,7 @@ "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true, "engines": { "node": ">= 0.4" }, @@ -42608,6 +42700,7 @@ "version": "1.0.10", "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", + "dev": true, "dependencies": { "has-tostringtag": "^1.0.0" }, @@ -42633,6 +42726,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", + "dev": true, "engines": { "node": ">=8" } @@ -42852,6 +42946,7 @@ "version": "1.1.13", "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.13.tgz", "integrity": "sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==", + "dev": true, "dependencies": { "which-typed-array": "^1.1.14" }, @@ -42872,6 +42967,7 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, "engines": { "node": ">=10" }, @@ -43168,14 +43264,6 @@ "node": ">=10" } }, - "node_modules/js-levenshtein": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz", - "integrity": "sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -43586,6 +43674,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, "dependencies": { "chalk": "^4.1.0", "is-unicode-supported": "^0.1.0" @@ -44514,43 +44603,41 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/msw": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/msw/-/msw-1.3.2.tgz", - "integrity": "sha512-wKLhFPR+NitYTkQl5047pia0reNGgf0P6a1eTnA5aNlripmiz0sabMvvHcicE8kQ3/gZcI0YiPFWmYfowfm3lA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/msw/-/msw-2.2.3.tgz", + "integrity": "sha512-84CoNCkcJ/EvY8Tv0tD/6HKVd4S5HyGowHjM5W12K8Wgryp4fikqS7IaTOceyQgP5dNedxo2icTLDXo7dkpxCg==", "hasInstallScript": true, "dependencies": { - "@mswjs/cookies": "^0.2.2", - "@mswjs/interceptors": "^0.17.10", - "@open-draft/until": "^1.0.3", - "@types/cookie": "^0.4.1", - "@types/js-levenshtein": "^1.1.1", - "chalk": "^4.1.1", - "chokidar": "^3.4.2", - "cookie": "^0.4.2", + "@bundled-es-modules/cookie": "^2.0.0", + "@bundled-es-modules/statuses": "^1.0.1", + "@inquirer/confirm": "^3.0.0", + "@mswjs/cookies": "^1.1.0", + "@mswjs/interceptors": "^0.25.16", + "@open-draft/until": "^2.1.0", + "@types/cookie": "^0.6.0", + "@types/statuses": "^2.0.4", + "chalk": "^4.1.2", "graphql": "^16.8.1", - "headers-polyfill": "3.2.5", - "inquirer": "^8.2.0", + "headers-polyfill": "^4.0.2", "is-node-process": "^1.2.0", - "js-levenshtein": "^1.1.6", - "node-fetch": "^2.6.7", - "outvariant": "^1.4.0", + "outvariant": "^1.4.2", "path-to-regexp": "^6.2.0", - "strict-event-emitter": "^0.4.3", - "type-fest": "^2.19.0", - "yargs": "^17.3.1" + "strict-event-emitter": "^0.5.1", + "type-fest": "^4.9.0", + "yargs": "^17.7.2" }, "bin": { "msw": "cli/index.js" }, "engines": { - "node": ">=14" + "node": ">=18" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/mswjs" }, "peerDependencies": { - "typescript": ">= 4.4.x <= 5.2.x" + "typescript": ">= 4.7.x" }, "peerDependenciesMeta": { "typescript": { @@ -44558,6 +44645,11 @@ } } }, + "node_modules/msw/node_modules/@open-draft/until": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz", + "integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==" + }, "node_modules/msw/node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", @@ -44571,25 +44663,17 @@ "node": ">=12" } }, - "node_modules/msw/node_modules/cookie": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", - "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", - "engines": { - "node": ">= 0.6" - } - }, "node_modules/msw/node_modules/path-to-regexp": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz", "integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw==" }, "node_modules/msw/node_modules/type-fest": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", - "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.12.0.tgz", + "integrity": "sha512-5Y2/pp2wtJk8o08G0CMkuFPCO354FGwk/vbidxrdhRGZfd0tFnb4Qb8anp9XxXriwBgVPjdWbKpGl4J9lJY2jQ==", "engines": { - "node": ">=12.20" + "node": ">=16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -44675,7 +44759,8 @@ "node_modules/mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", - "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", + "dev": true }, "node_modules/nanoid": { "version": "3.3.1", @@ -44959,24 +45044,6 @@ "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", "dev": true }, - "node_modules/node-request-interceptor": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/node-request-interceptor/-/node-request-interceptor-0.6.3.tgz", - "integrity": "sha512-8I2V7H2Ch0NvW7qWcjmS0/9Lhr0T6x7RD6PDirhvWEkUQvy83x8BA4haYMr09r/rig7hcgYSjYh6cd4U7G1vLA==", - "dev": true, - "dependencies": { - "@open-draft/until": "^1.0.3", - "debug": "^4.3.0", - "headers-utils": "^1.2.0", - "strict-event-emitter": "^0.1.0" - } - }, - "node_modules/node-request-interceptor/node_modules/strict-event-emitter": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.1.0.tgz", - "integrity": "sha512-8hSYfU+WKLdNcHVXJ0VxRXiPESalzRe7w1l8dg9+/22Ry+iZQUoQuoJ27R30GMD1TiyYINWsIEGY05WrskhSKw==", - "dev": true - }, "node_modules/nodemailer": { "version": "6.9.11", "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.11.tgz", @@ -45888,6 +45955,7 @@ "version": "5.4.1", "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", + "dev": true, "dependencies": { "bl": "^4.1.0", "chalk": "^4.1.0", @@ -45925,6 +45993,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -46809,6 +46878,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", "integrity": "sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==", + "dev": true, "engines": { "node": ">= 0.4" } @@ -47796,6 +47866,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dev": true, "dependencies": { "onetime": "^5.1.0", "signal-exit": "^3.0.2" @@ -47846,6 +47917,7 @@ "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", + "dev": true, "engines": { "node": ">=0.12.0" } @@ -47876,6 +47948,7 @@ "version": "7.8.1", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "dev": true, "dependencies": { "tslib": "^2.1.0" } @@ -48090,11 +48163,6 @@ "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" }, - "node_modules/set-cookie-parser": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz", - "integrity": "sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==" - }, "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", @@ -48927,9 +48995,9 @@ } }, "node_modules/strict-event-emitter": { - "version": "0.4.6", - "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.4.6.tgz", - "integrity": "sha512-12KWeb+wixJohmnwNFerbyiBrAlq5qJLwIt38etRtKtmmHyDSoGlIqFE9wx+4IwG0aDjI7GV8tc8ZccjWZZtTg==" + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz", + "integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==" }, "node_modules/strict-uri-encode": { "version": "2.0.0", @@ -49343,12 +49411,14 @@ "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", + "dev": true }, "node_modules/tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, "dependencies": { "os-tmpdir": "~1.0.2" }, @@ -50223,6 +50293,7 @@ "version": "0.12.5", "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", + "dev": true, "dependencies": { "inherits": "^2.0.3", "is-arguments": "^1.0.4", @@ -50354,21 +50425,11 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", + "dev": true, "dependencies": { "defaults": "^1.0.3" } }, - "node_modules/web-encoding": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/web-encoding/-/web-encoding-1.1.5.tgz", - "integrity": "sha512-HYLeVCdJ0+lBYV2FvNZmv3HJ2Nt0QYXqZojk3d9FJOLkwnuhzM9tmamh8d7HPM8QqjKH8DeHkFTx+CFlWpZZDA==", - "dependencies": { - "util": "^0.12.3" - }, - "optionalDependencies": { - "@zxing/text-encoding": "0.9.0" - } - }, "node_modules/web-resource-inliner": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/web-resource-inliner/-/web-resource-inliner-6.0.1.tgz", @@ -50506,6 +50567,7 @@ "version": "1.1.15", "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.15.tgz", "integrity": "sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==", + "dev": true, "dependencies": { "available-typed-arrays": "^1.0.7", "call-bind": "^1.0.7", @@ -51879,7 +51941,7 @@ }, "packages/notification": { "name": "@hyperjumptech/monika-notification", - "version": "1.16.0", + "version": "1.16.1", "license": "MIT", "dependencies": { "@sendgrid/mail": "^7.4.2", @@ -51891,7 +51953,7 @@ "form-data": "^4.0.0", "joi": "^17.4.0", "mailgen": "^2.0.15", - "msw": "^1.3.2", + "msw": "^2.2.3", "nodemailer": "6.9.4", "pino": "8.14.1", "sqlite": "4.2.1", diff --git a/package.json b/package.json index 33d3a6f45..d2dd7e9a2 100644 --- a/package.json +++ b/package.json @@ -146,8 +146,7 @@ "husky": "^4.3.8", "lint-staged": "^10.5.4", "mocha": "^9.1.2", - "msw": "^1.3.2", - "node-request-interceptor": "^0.6.3", + "msw": "^2.2.3", "nyc": "^15.1.0", "oclif": "4.0.2", "pkg": "^5.8.1", diff --git a/packages/notification/channel/__test__/pagerduty.test.ts b/packages/notification/channel/__test__/pagerduty.test.ts index d493c0c09..be8e243b8 100644 --- a/packages/notification/channel/__test__/pagerduty.test.ts +++ b/packages/notification/channel/__test__/pagerduty.test.ts @@ -23,7 +23,7 @@ **********************************************************************************/ import { expect } from 'chai' -import { rest } from 'msw' +import { type DefaultBodyType, HttpResponse, http } from 'msw' import { setupServer } from 'msw/node' import type { NotificationMessage } from '../../channel' import { send, validator } from '../pagerduty' @@ -59,22 +59,26 @@ describe('PagerDuty notification', () => { }) describe('send the event', () => { - let body = {} + let body: DefaultBodyType = {} const server = setupServer( - rest.post( + http.post( 'https://events.pagerduty.com/v2/enqueue', - async (req, res, ctx) => { - body = await req.json() + async ({ request }) => { + body = await request.json() - return res(ctx.status(202)) + return new HttpResponse(null, { + status: 202, + }) } ), - rest.post( + http.post( 'https://events.pagerduty.com/v2/enqueue', - async (req, res, ctx) => { - body = await req.json() + async ({ request }) => { + body = await request.json() - return res(ctx.status(202)) + return new HttpResponse(null, { + status: 202, + }) } ) ) diff --git a/packages/notification/channel/__test__/webhook.test.ts b/packages/notification/channel/__test__/webhook.test.ts index 085c34a40..07ae9cd5a 100644 --- a/packages/notification/channel/__test__/webhook.test.ts +++ b/packages/notification/channel/__test__/webhook.test.ts @@ -23,7 +23,7 @@ **********************************************************************************/ import { expect } from 'chai' -import { rest } from 'msw' +import { type DefaultBodyType, HttpResponse, http } from 'msw' import { setupServer } from 'msw/node' import { validateNotification } from '../../validator/notification' @@ -75,12 +75,14 @@ describe('notificationChecker - webhookNotification', () => { describe('Webhook Notification', () => { describe('Send', () => { - let body = {} + let body: DefaultBodyType = {} const server = setupServer( - rest.post('https://example.com', async (req, res, ctx) => { - body = await req.json() + http.post('https://example.com', async ({ request }) => { + body = await request.json() - return res(ctx.status(200)) + return new HttpResponse(null, { + status: 200, + }) }) ) diff --git a/packages/notification/package.json b/packages/notification/package.json index b316fd9a5..c839713fe 100644 --- a/packages/notification/package.json +++ b/packages/notification/package.json @@ -1,6 +1,6 @@ { "name": "@hyperjumptech/monika-notification", - "version": "1.16.0", + "version": "1.16.1", "description": "notification package for monika", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,7 +30,7 @@ "form-data": "^4.0.0", "joi": "^17.4.0", "mailgen": "^2.0.15", - "msw": "^1.3.2", + "msw": "^2.2.3", "nodemailer": "6.9.4", "pino": "8.14.1", "sqlite": "4.2.1", diff --git a/src/components/probe/index.test.ts b/src/components/probe/index.test.ts index 1718817b7..7ce1bd629 100644 --- a/src/components/probe/index.test.ts +++ b/src/components/probe/index.test.ts @@ -23,7 +23,7 @@ **********************************************************************************/ import { expect } from '@oclif/test' -import { rest } from 'msw' +import { HttpResponse, http } from 'msw' import { setupServer } from 'msw/node' import sinon from 'sinon' import mariadb from 'mariadb' @@ -44,14 +44,22 @@ let notificationAlert: Record< Record> > = {} const server = setupServer( - rest.get('https://example.com', (_, res, ctx) => res(ctx.status(200))), - rest.post('https://example.com/webhook', async (req, res, ctx) => { - const requestBody = await req.json() + http.get( + 'https://example.com', + () => + new HttpResponse(null, { + status: 200, + }) + ), + http.post('https://example.com/webhook', async ({ request }) => { + const requestBody = (await request.json()) as Record if (requestBody?.body?.url) { - notificationAlert[requestBody.body.url] = requestBody + notificationAlert[requestBody?.body?.url] = requestBody } - return res(ctx.status(200)) + return new HttpResponse(null, { + status: 200, + }) }) ) diff --git a/src/components/probe/prober/http/index.test.ts b/src/components/probe/prober/http/index.test.ts index 6dba353d3..741ec4760 100644 --- a/src/components/probe/prober/http/index.test.ts +++ b/src/components/probe/prober/http/index.test.ts @@ -24,7 +24,7 @@ import { expect } from '@oclif/test' import { AxiosError } from 'axios' -import { rest } from 'msw' +import { HttpResponse, http } from 'msw' import { setupServer } from 'msw/node' import sinon from 'sinon' import * as httpRequest from '../../../../utils/http' @@ -42,17 +42,21 @@ let notificationAlert: Record< Record> > = {} const server = setupServer( - rest.get('https://example.com', (_, res, ctx) => { + http.get('https://example.com', () => { urlRequestTotal += 1 - return res(ctx.status(200)) + return new HttpResponse(null, { + status: 200, + }) }), - rest.post('https://example.com/webhook', async (req, res, ctx) => { - const requestBody = await req.json() + http.post('https://example.com/webhook', async ({ request }) => { + const requestBody = (await request.json()) as Record if (requestBody?.body?.url) { notificationAlert[requestBody.body.url] = requestBody } - return res(ctx.status(200)) + return new HttpResponse(null, { + status: 200, + }) }) ) const probes: Probe[] = [ @@ -252,9 +256,11 @@ describe('HTTP Probe processing', () => { it('should send incident notification when assertion fails', async () => { // arrange server.use( - rest.get('https://example.com', (_, res, ctx) => { + http.get('https://example.com', () => { urlRequestTotal += 1 - return res(ctx.status(404)) + return new HttpResponse(null, { + status: 404, + }) }) ) const probe = { @@ -305,9 +311,11 @@ describe('HTTP Probe processing', () => { it('should send recovery notification', async () => { // arrange server.use( - rest.get('https://example.com', (_, res, ctx) => { + http.get('https://example.com', () => { urlRequestTotal += 1 - return res(ctx.status(404)) + return new HttpResponse(null, { + status: 404, + }) }) ) const probe = { diff --git a/src/components/probe/prober/http/request.test.ts b/src/components/probe/prober/http/request.test.ts index 293fc5b9a..8d0f193a7 100644 --- a/src/components/probe/prober/http/request.test.ts +++ b/src/components/probe/prober/http/request.test.ts @@ -23,7 +23,7 @@ **********************************************************************************/ import { expect } from '@oclif/test' -import { rest } from 'msw' +import { HttpResponse, http } from 'msw' import { setupServer } from 'msw/node' import type { @@ -48,20 +48,20 @@ describe('probingHTTP', () => { it('should render correct headers', async () => { // arrange const tokens = ['1', '2'] - let verifyHeader: Record = {} + let verifyHeader = new Headers() let sentToken = '' server.use( - rest.get('http://localhost:4000/get_key', async (_, res, ctx) => { + http.get('http://localhost:4000/get_key', async () => { const token = tokens.pop() as string sentToken = token - return res(ctx.json({ token })) + return HttpResponse.json({ token }) }), - rest.post('http://localhost:4000/verify', async (req, res, ctx) => { - verifyHeader = req.headers.all() + http.post('http://localhost:4000/verify', async ({ request }) => { + verifyHeader = request.headers - return res(ctx.json({ verified: true })) + return HttpResponse.json({ verified: true }) }) ) @@ -97,7 +97,7 @@ describe('probingHTTP', () => { responses.push(resp) if (j !== 0) { results.push({ - sentToken: verifyHeader.authorization, + sentToken: verifyHeader.get('authorization'), expectedToken: sentToken, }) } @@ -113,14 +113,18 @@ describe('probingHTTP', () => { it('should submit correct form', async () => { server.use( - rest.post('http://localhost:4000/login', async (req, res, ctx) => { - const reqBody = await req.text() + http.post('http://localhost:4000/login', async ({ request }) => { + const reqBody = await request.text() if (reqBody !== 'username=example%40example.com&password=example') { - return res(ctx.status(400)) + return new HttpResponse(null, { + status: 400, + }) } - return res(ctx.status(200)) + return new HttpResponse(null, { + status: 200, + }) }) ) const request = { @@ -143,19 +147,23 @@ describe('probingHTTP', () => { it('should send request with multipart/form-data content-type', async () => { // arrange server.use( - rest.post('https://example.com', async (req, res, ctx) => { - const { headers } = req - const reqBody = await req.text() + http.post('https://example.com', async ({ request }) => { + const { headers } = request + const reqBody = await request.text() if ( !headers.get('content-type')?.startsWith('multipart/form-data') || !reqBody.includes('john@example.com') || !reqBody.includes('drowssap') ) { - return res(ctx.status(400)) + return new HttpResponse(null, { + status: 400, + }) } - return res(ctx.status(200)) + return new HttpResponse(null, { + status: 200, + }) }) ) const request: RequestConfig = { @@ -179,9 +187,9 @@ describe('probingHTTP', () => { it('should send request with text-plain content-type', async () => { // arrange server.use( - rest.post('https://example.com', async (req, res, ctx) => { - const { headers } = req - const body = await req.text() + http.post('https://example.com', async ({ request }) => { + const { headers } = request + const body = await request.text() if ( headers.get('content-type') !== 'text/plain' || @@ -190,10 +198,14 @@ describe('probingHTTP', () => { console.error(headers.get('content-type')) console.error(body) - return res(ctx.status(400)) + return new HttpResponse(null, { + status: 400, + }) } - return res(ctx.status(200)) + return new HttpResponse(null, { + status: 200, + }) }) ) const request: RequestConfig = { @@ -217,9 +229,9 @@ describe('probingHTTP', () => { it('should send request with text/yaml content-type', async () => { // arrange server.use( - rest.post('https://example.com', async (req, res, ctx) => { - const { headers } = req - const body = await req.text() + http.post('https://example.com', async ({ request }) => { + const { headers } = request + const body = await request.text() if ( headers.get('content-type') !== 'text/yaml' || @@ -228,10 +240,14 @@ describe('probingHTTP', () => { console.error(headers.get('content-type')) console.error(body) - return res(ctx.status(400)) + return new HttpResponse(null, { + status: 400, + }) } - return res(ctx.status(200)) + return new HttpResponse(null, { + status: 200, + }) }) ) const request: RequestConfig = { @@ -255,9 +271,9 @@ describe('probingHTTP', () => { it('should send request with application/xml content-type', async () => { // arrange server.use( - rest.post('https://example.com', async (req, res, ctx) => { - const { headers } = req - const body = await req.text() + http.post('https://example.com', async ({ request }) => { + const { headers } = request + const body = await request.text() if ( headers.get('content-type') !== 'application/xml' || @@ -266,10 +282,14 @@ describe('probingHTTP', () => { console.error(headers.get('content-type')) console.error(JSON.stringify(body)) - return res(ctx.status(400)) + return new HttpResponse(null, { + status: 400, + }) } - return res(ctx.status(200)) + return new HttpResponse(null, { + status: 200, + }) }) ) const request: RequestConfig = { @@ -293,9 +313,9 @@ describe('probingHTTP', () => { it('should send request with text-plain content-type even with allowUnauthorized option', async () => { // arrange server.use( - rest.post('https://example.com', async (req, res, ctx) => { - const { headers } = req - const body = await req.text() + http.post('https://example.com', async ({ request }) => { + const { headers } = request + const body = await request.text() if ( headers.get('content-type') !== 'text/plain' || @@ -304,10 +324,14 @@ describe('probingHTTP', () => { console.error(headers.get('content-type')) console.error(body) - return res(ctx.status(400)) + return new HttpResponse(null, { + status: 400, + }) } - return res(ctx.status(200)) + return new HttpResponse(null, { + status: 200, + }) }) ) const request: RequestConfig = { diff --git a/src/components/probe/prober/index.test.ts b/src/components/probe/prober/index.test.ts index 6e7242538..e47af500f 100644 --- a/src/components/probe/prober/index.test.ts +++ b/src/components/probe/prober/index.test.ts @@ -22,7 +22,7 @@ * SOFTWARE. * **********************************************************************************/ -import { rest } from 'msw' +import { type DefaultBodyType, HttpResponse, http } from 'msw' import { setupServer } from 'msw/node' import { expect } from '@oclif/test' @@ -34,15 +34,19 @@ import { getIncidents } from '../../incident' describe('Prober', () => { describe('Initial incident state', () => { let probeRequestTotal = 0 - let webhookBody: Record | null = null + let webhookBody: DefaultBodyType = null const server = setupServer( - rest.get('https://example.com', (_, res, ctx) => { + http.get('https://example.com', () => { probeRequestTotal++ - return res(ctx.status(200)) + return new HttpResponse(null, { + status: 200, + }) }), - rest.post('https://example.com/webhook', async (req, res, ctx) => { - webhookBody = await req.json() - return res(ctx.status(202)) + http.post('https://example.com/webhook', async ({ request }) => { + webhookBody = await request.json() + return new HttpResponse(null, { + status: 202, + }) }) ) @@ -260,9 +264,11 @@ describe('Prober', () => { it('should not send incident notification if recovered_at is null and target is not healthy', async () => { // arrange server.use( - rest.get('https://example.com', (_, res, ctx) => { + http.get('https://example.com', () => { probeRequestTotal++ - return res(ctx.status(404)) + return new HttpResponse(null, { + status: 404, + }) }) ) const proberMetadata: ProberMetadata = { @@ -371,9 +377,11 @@ describe('Prober', () => { it('should send incident notification if recovered_at is not null and target is not healthy', async () => { // arrange server.use( - rest.get('https://example.com', (_, res, ctx) => { + http.get('https://example.com', () => { probeRequestTotal++ - return res(ctx.status(404)) + return new HttpResponse(null, { + status: 404, + }) }) ) const proberMetadata: ProberMetadata = { diff --git a/src/symon/index.test.ts b/src/symon/index.test.ts index 1ee4fd3b9..366d09e5a 100644 --- a/src/symon/index.test.ts +++ b/src/symon/index.test.ts @@ -23,7 +23,7 @@ **********************************************************************************/ import { expect } from '@oclif/test' -import { rest } from 'msw' +import { type DefaultBodyType, HttpResponse, http } from 'msw' import { setupServer } from 'msw/node' import { monikaFlagsDefaultValue, type MonikaFlags } from '../flag' @@ -60,46 +60,38 @@ const config: Config = { ], } const server = setupServer( - rest.get('http://ip-api.com/json/192.168.1.1', (_, res, ctx) => - res( - ctx.json({ - city: 'jakarta', - isp: 'hyperjump', - country: 'Indonesia', - }) - ) + http.get('http://ip-api.com/json/192.168.1.1', () => + HttpResponse.json({ + city: 'jakarta', + isp: 'hyperjump', + country: 'Indonesia', + }) ), - rest.post( - 'http://localhost:4000/api/v1/monika/client-handshake', - (_, res, ctx) => - res( - ctx.json({ - statusCode: 'ok', - message: 'Successfully handshaked with Symon', - data: { - monikaId: '1234', - }, - }) - ) + http.post('http://localhost:4000/api/v1/monika/client-handshake', () => + HttpResponse.json({ + statusCode: 'ok', + message: 'Successfully handshaked with Symon', + data: { + monikaId: '1234', + }, + }) ), - rest.get('http://localhost:4000/api/v1/monika/1234/probes', (_, res, ctx) => - res( - ctx.set('etag', config.version || ''), - ctx.json({ + http.get('http://localhost:4000/api/v1/monika/1234/probes', () => + HttpResponse.json( + { statusCode: 'ok', message: 'Successfully get probes configuration', data: config.probes, - }) + }, + { headers: { etag: config.version || '' } } ) ), - rest.get('https://example.com', (_, res, ctx) => res(ctx.json({}))), - rest.get('http://localhost:4000/api/v1/monika/report', (_, res, ctx) => - res( - ctx.json({ - statusCode: 'ok', - message: 'Successfully report to Symon', - }) - ) + http.get('https://example.com', () => HttpResponse.json({})), + http.get('http://localhost:4000/api/v1/monika/report', () => + HttpResponse.json({ + statusCode: 'ok', + message: 'Successfully report to Symon', + }) ) ) @@ -139,23 +131,21 @@ describe('Symon initiate', () => { symonKey: 'random-key', } as MonikaFlags, }) - let body: Record = {} + let body: DefaultBodyType = {} // mock the outgoing requests server.use( - rest.post( + http.post( 'http://localhost:4000/api/v1/monika/client-handshake', - async (req, res, ctx) => { - body = await req.json() - - return res( - ctx.json({ - statusCode: 'ok', - message: 'Successfully handshaked with Symon', - data: { - monikaId: '1234', - }, - }) - ) + async ({ request }) => { + body = await request.json() + + return HttpResponse.json({ + statusCode: 'ok', + message: 'Successfully handshaked with Symon', + data: { + monikaId: '1234', + }, + }) } ) ) @@ -200,20 +190,16 @@ describe('Symon initiate', () => { it('should throw an error if the request to get probes is failed', async () => { // arrange server.use( - rest.post( - 'http://localhost:4000/api/v1/monika/client-handshake', - (_, res, ctx) => - res( - ctx.json({ - statusCode: 'ok', - message: 'Successfully handshaked with Symon', - data: { - monikaId: '1234', - }, - }) - ) + http.post('http://localhost:4000/api/v1/monika/client-handshake', () => + HttpResponse.json({ + statusCode: 'ok', + message: 'Successfully handshaked with Symon', + data: { + monikaId: '1234', + }, + }) ), - rest.get('http://localhost:4000/api/v1/monika/1234/probes', () => { + http.get('http://localhost:4000/api/v1/monika/1234/probes', () => { throw new Error('Failed') }) ) @@ -239,19 +225,17 @@ describe('Symon initiate', () => { it('should send event to Symon when incident or recovery happens', async () => { // arrange - let body: Record = {} + let body: DefaultBodyType = {} server.use( - rest.post( + http.post( 'http://localhost:4000/api/v1/monika/events', - async (req, res, ctx) => { - body = await req.json() - - return res( - ctx.json({ - message: 'Successfully send incident event to Symon', - data: null, - }) - ) + async ({ request }) => { + body = await request.json() + + return HttpResponse.json({ + message: 'Successfully send incident event to Symon', + data: null, + }) } ) ) @@ -297,15 +281,11 @@ describe('Symon initiate', () => { alerts: [], } server.use( - rest.get( - 'http://localhost:4000/api/v1/monika/1234/probe-changes', - (_, res, ctx) => - res( - ctx.json({ - message: 'Successfully get probe changes', - data: [{ type: 'add', probe: newProbe }], - }) - ) + http.get('http://localhost:4000/api/v1/monika/1234/probe-changes', () => + HttpResponse.json({ + message: 'Successfully get probe changes', + data: [{ type: 'add', probe: newProbe }], + }) ) ) const symonGetProbesIntervalMs = 100 @@ -346,22 +326,18 @@ describe('Symon initiate', () => { it('should update a probe', async () => { // arrange server.use( - rest.get( - 'http://localhost:4000/api/v1/monika/1234/probe-changes', - (_, res, ctx) => - res( - ctx.json({ - message: 'Successfully get probe changes', - data: [ - { - type: 'update', - // eslint-disable-next-line camelcase - probe_id: '1', - probe: { ...findProbe('1'), interval: 2 }, - }, - ], - }) - ) + http.get('http://localhost:4000/api/v1/monika/1234/probe-changes', () => + HttpResponse.json({ + message: 'Successfully get probe changes', + data: [ + { + type: 'update', + // eslint-disable-next-line camelcase + probe_id: '1', + probe: { ...findProbe('1'), interval: 2 }, + }, + ], + }) ) ) const symonGetProbesIntervalMs = 100 @@ -403,22 +379,18 @@ describe('Symon initiate', () => { it('should delete a probe', async () => { // arrange server.use( - rest.get( - 'http://localhost:4000/api/v1/monika/1234/probe-changes', - (_, res, ctx) => - res( - ctx.json({ - message: 'Successfully get probe changes', - data: [ - { - type: 'delete', - // eslint-disable-next-line camelcase - probe_id: '1', - probe: {}, - }, - ], - }) - ) + http.get('http://localhost:4000/api/v1/monika/1234/probe-changes', () => + HttpResponse.json({ + message: 'Successfully get probe changes', + data: [ + { + type: 'delete', + // eslint-disable-next-line camelcase + probe_id: '1', + probe: {}, + }, + ], + }) ) ) const symonGetProbesIntervalMs = 100 @@ -459,22 +431,18 @@ describe('Symon initiate', () => { it('should disable a probe', async () => { // arrange server.use( - rest.get( - 'http://localhost:4000/api/v1/monika/1234/probe-changes', - (_, res, ctx) => - res( - ctx.json({ - message: 'Successfully get probe changes', - data: [ - { - type: 'disabled', - // eslint-disable-next-line camelcase - probe_id: '1', - probe: {}, - }, - ], - }) - ) + http.get('http://localhost:4000/api/v1/monika/1234/probe-changes', () => + HttpResponse.json({ + message: 'Successfully get probe changes', + data: [ + { + type: 'disabled', + // eslint-disable-next-line camelcase + probe_id: '1', + probe: {}, + }, + ], + }) ) ) diff --git a/test/others/hide-ip.test.ts b/test/others/hide-ip.test.ts index dab3a58ce..9164d838b 100644 --- a/test/others/hide-ip.test.ts +++ b/test/others/hide-ip.test.ts @@ -23,29 +23,17 @@ **********************************************************************************/ import { test } from '@oclif/test' -import path from 'path' -import chai from 'chai' -import spies from 'chai-spies' +import { resolve } from 'node:path' import cmd from '../../src/commands/monika' import sinon from 'sinon' import * as IpUtil from '../../src/utils/public-ip' -import { RequestInterceptor } from 'node-request-interceptor' -import withDefaultInterceptors from 'node-request-interceptor/lib/presets/default' - -const { resolve } = path -chai.use(spies) - -let interceptor: RequestInterceptor describe('Monika should hide ip unless verbose', () => { let getPublicIPStub: sinon.SinonStub let getPublicNetworkInfoStub: sinon.SinonStub beforeEach(() => { - interceptor = new RequestInterceptor(withDefaultInterceptors) - getPublicIPStub = sinon.stub(IpUtil, 'getPublicIp' as never) - getPublicNetworkInfoStub = sinon .stub(IpUtil, 'getPublicNetworkInfo' as never) .callsFake(async () => ({ @@ -56,23 +44,8 @@ describe('Monika should hide ip unless verbose', () => { privateIp: '7.6.5.4', publicIp: '1.2.3.4', })) - - interceptor.use((req) => { - // mock the call to get isp and city - if (req.url.origin === 'http://localhost:3000') { - return { - status: 200, - body: JSON.stringify({ - statusCode: 'ok', - message: 'Successfully handshaked with Symon', - data: { - monikaId: '1234', - }, - }), - } - } - }) }) + afterEach(() => { getPublicIPStub.restore() getPublicNetworkInfoStub.restore()