diff --git a/package-lock.json b/package-lock.json index 9476285d8..9883d439e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,8 +52,7 @@ "path-to-regexp": "^6.2.1", "pluralize": "^8.0.0", "prop-types": "^15.8.1", - "query-string": "^7.1.1", - "querystring": "^0.2.1", + "qs": "^6.11.1", "randomcolor": "^0.6.2", "rangy": "^1.3.1", "rc-tabs": "^12.5.7", @@ -149,7 +148,6 @@ }, "node_modules/@ampproject/remapping": { "version": "2.1.2", - "dev": true, "license": "Apache-2.0", "dependencies": { "@jridgewell/trace-mapping": "^0.3.0" @@ -188,14 +186,12 @@ "version": "7.20.1", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.20.1.tgz", "integrity": "sha512-EWZ4mE2diW3QALKvDMiXnbZpRvlj+nayZ112nK93SnhqOtpdsbVD4W+2tEoT3YNBAG9RBR0ISY758ZkOgsn6pQ==", - "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { "version": "7.17.9", - "dev": true, "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.1.0", @@ -224,7 +220,6 @@ }, "node_modules/@babel/core/node_modules/semver": { "version": "6.3.0", - "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -322,7 +317,6 @@ "version": "7.20.0", "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.0.tgz", "integrity": "sha512-0jp//vDGp9e8hZzBc6N/KwA5ZK3Wsm/pfm4CrY7vzegkVxc65SgSn6wYOnwHe9Js9HRQ1YTCKLGPzDtaS3RoLQ==", - "dev": true, "dependencies": { "@babel/compat-data": "^7.20.0", "@babel/helper-validator-option": "^7.18.6", @@ -338,7 +332,6 @@ }, "node_modules/@babel/helper-compilation-targets/node_modules/semver": { "version": "6.3.0", - "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -470,7 +463,6 @@ "version": "7.20.2", "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.20.2.tgz", "integrity": "sha512-zvBKyJXRbmK07XhMuujYoJ48B5yvvmM6+wcpv6Ivj4Yg6qO7NOZOSnvZN9CRl1zz1Z4cKf8YejmCMh8clOoOeA==", - "dev": true, "dependencies": { "@babel/helper-environment-visitor": "^7.18.9", "@babel/helper-module-imports": "^7.18.6", @@ -541,7 +533,6 @@ "version": "7.20.2", "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz", "integrity": "sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA==", - "dev": true, "dependencies": { "@babel/types": "^7.20.2" }, @@ -588,7 +579,6 @@ }, "node_modules/@babel/helper-validator-option": { "version": "7.18.6", - "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -610,7 +600,6 @@ }, "node_modules/@babel/helpers": { "version": "7.17.9", - "dev": true, "license": "MIT", "dependencies": { "@babel/template": "^7.16.7", @@ -6253,6 +6242,18 @@ "dev": true, "license": "MIT" }, + "node_modules/body-parser/node_modules/qs": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==", + "dev": true, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/bonjour-service": { "version": "1.0.11", "dev": true, @@ -6314,7 +6315,6 @@ "version": "4.21.4", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.4.tgz", "integrity": "sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw==", - "dev": true, "funding": [ { "type": "opencollective", @@ -6404,7 +6404,6 @@ }, "node_modules/call-bind": { "version": "1.0.2", - "dev": true, "license": "MIT", "dependencies": { "function-bind": "^1.1.1", @@ -6469,7 +6468,6 @@ "version": "1.0.30001431", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001431.tgz", "integrity": "sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ==", - "dev": true, "funding": [ { "type": "opencollective", @@ -7811,13 +7809,6 @@ "dev": true, "license": "MIT" }, - "node_modules/decode-uri-component": { - "version": "0.2.0", - "license": "MIT", - "engines": { - "node": ">=0.10" - } - }, "node_modules/decompress-response": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", @@ -8224,8 +8215,7 @@ "node_modules/electron-to-chromium": { "version": "1.4.284", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz", - "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==", - "dev": true + "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==" }, "node_modules/emittery": { "version": "0.8.1", @@ -8401,7 +8391,6 @@ }, "node_modules/escalade": { "version": "3.1.1", - "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -9410,6 +9399,18 @@ "dev": true, "license": "MIT" }, + "node_modules/express/node_modules/qs": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==", + "dev": true, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/express/node_modules/safe-buffer": { "version": "5.2.1", "dev": true, @@ -9615,13 +9616,6 @@ "node": ">=8" } }, - "node_modules/filter-obj": { - "version": "1.1.0", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/finalhandler": { "version": "1.1.2", "dev": true, @@ -10022,7 +10016,6 @@ }, "node_modules/gensync": { "version": "1.0.0-beta.2", - "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -10039,7 +10032,6 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz", "integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==", - "dev": true, "dependencies": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -10305,7 +10297,6 @@ }, "node_modules/has-symbols": { "version": "1.0.3", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -13047,7 +13038,6 @@ }, "node_modules/json5": { "version": "2.2.1", - "dev": true, "license": "MIT", "bin": { "json5": "lib/cli.js" @@ -14237,8 +14227,7 @@ "node_modules/node-releases": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", - "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==", - "dev": true + "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==" }, "node_modules/nopt": { "version": "5.0.0", @@ -14357,7 +14346,6 @@ }, "node_modules/object-inspect": { "version": "1.12.2", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -14802,7 +14790,6 @@ }, "node_modules/picocolors": { "version": "1.0.0", - "dev": true, "license": "ISC" }, "node_modules/picomatch": { @@ -16355,37 +16342,17 @@ } }, "node_modules/qs": { - "version": "6.9.7", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/query-string": { - "version": "7.1.1", - "license": "MIT", + "version": "6.11.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.1.tgz", + "integrity": "sha512-0wsrzgTz/kAVIeuxSjnpGC56rzYtr6JT/2BwEvMaPhFIoYa1aGO8LbzuU1R0uUYQkLpWBTOj0l/CLAJB64J6nQ==", "dependencies": { - "decode-uri-component": "^0.2.0", - "filter-obj": "^1.1.0", - "split-on-first": "^1.0.0", - "strict-uri-encode": "^2.0.0" + "side-channel": "^1.0.4" }, "engines": { - "node": ">=6" + "node": ">=0.6" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/querystring": { - "version": "0.2.1", - "license": "MIT", - "engines": { - "node": ">=0.4.x" + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/queue-microtask": { @@ -18735,7 +18702,6 @@ }, "node_modules/side-channel": { "version": "1.0.4", - "dev": true, "license": "MIT", "dependencies": { "call-bind": "^1.0.0", @@ -18964,13 +18930,6 @@ "wbuf": "^1.7.3" } }, - "node_modules/split-on-first": { - "version": "1.1.0", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/sprintf-js": { "version": "1.0.3", "dev": true, @@ -19075,13 +19034,6 @@ "version": "1.1.5", "license": "MIT" }, - "node_modules/strict-uri-encode": { - "version": "2.0.0", - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/string_decoder": { "version": "1.1.1", "license": "MIT", @@ -20040,7 +19992,6 @@ }, "node_modules/tslib": { "version": "1.10.0", - "dev": true, "license": "Apache-2.0" }, "node_modules/tsutils": { @@ -20111,6 +20062,20 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/typescript": { + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "dev": true, + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/uglify-js": { "version": "3.13.10", "dev": true, @@ -20234,7 +20199,6 @@ "version": "1.0.10", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", "integrity": "sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==", - "dev": true, "funding": [ { "type": "opencollective", @@ -21482,7 +21446,6 @@ }, "@ampproject/remapping": { "version": "2.1.2", - "dev": true, "requires": { "@jridgewell/trace-mapping": "^0.3.0" } @@ -21505,12 +21468,10 @@ "@babel/compat-data": { "version": "7.20.1", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.20.1.tgz", - "integrity": "sha512-EWZ4mE2diW3QALKvDMiXnbZpRvlj+nayZ112nK93SnhqOtpdsbVD4W+2tEoT3YNBAG9RBR0ISY758ZkOgsn6pQ==", - "dev": true + "integrity": "sha512-EWZ4mE2diW3QALKvDMiXnbZpRvlj+nayZ112nK93SnhqOtpdsbVD4W+2tEoT3YNBAG9RBR0ISY758ZkOgsn6pQ==" }, "@babel/core": { "version": "7.17.9", - "dev": true, "requires": { "@ampproject/remapping": "^2.1.0", "@babel/code-frame": "^7.16.7", @@ -21530,8 +21491,7 @@ }, "dependencies": { "semver": { - "version": "6.3.0", - "dev": true + "version": "6.3.0" } } }, @@ -21594,7 +21554,6 @@ "version": "7.20.0", "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.0.tgz", "integrity": "sha512-0jp//vDGp9e8hZzBc6N/KwA5ZK3Wsm/pfm4CrY7vzegkVxc65SgSn6wYOnwHe9Js9HRQ1YTCKLGPzDtaS3RoLQ==", - "dev": true, "requires": { "@babel/compat-data": "^7.20.0", "@babel/helper-validator-option": "^7.18.6", @@ -21603,8 +21562,7 @@ }, "dependencies": { "semver": { - "version": "6.3.0", - "dev": true + "version": "6.3.0" } } }, @@ -21693,7 +21651,6 @@ "version": "7.20.2", "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.20.2.tgz", "integrity": "sha512-zvBKyJXRbmK07XhMuujYoJ48B5yvvmM6+wcpv6Ivj4Yg6qO7NOZOSnvZN9CRl1zz1Z4cKf8YejmCMh8clOoOeA==", - "dev": true, "requires": { "@babel/helper-environment-visitor": "^7.18.9", "@babel/helper-module-imports": "^7.18.6", @@ -21744,7 +21701,6 @@ "version": "7.20.2", "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz", "integrity": "sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA==", - "dev": true, "requires": { "@babel/types": "^7.20.2" } @@ -21773,8 +21729,7 @@ "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==" }, "@babel/helper-validator-option": { - "version": "7.18.6", - "dev": true + "version": "7.18.6" }, "@babel/helper-wrap-function": { "version": "7.18.9", @@ -21788,7 +21743,6 @@ }, "@babel/helpers": { "version": "7.17.9", - "dev": true, "requires": { "@babel/template": "^7.16.7", "@babel/traverse": "^7.17.9", @@ -23129,7 +23083,8 @@ } }, "@handsontable/react": { - "version": "11.0.1" + "version": "11.0.1", + "requires": {} }, "@hapi/hoek": { "version": "9.1.1" @@ -24073,7 +24028,8 @@ "version": "14.4.3", "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.4.3.tgz", "integrity": "sha512-kCUc5MEwaEMakkO5x7aoD+DLi02ehmEM2QCGWvNqAS1dV/fAvORWEjnjsEIvml59M7Y5kCkWN6fCCyPOe8OL6Q==", - "dev": true + "dev": true, + "requires": {} }, "@tippyjs/react": { "version": "4.2.6", @@ -24841,7 +24797,8 @@ "@vtaits/use-lazy-ref": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@vtaits/use-lazy-ref/-/use-lazy-ref-0.1.0.tgz", - "integrity": "sha512-/m5z3Df6I6i/B0lnv6pB2O1+X/nWVquqbnltq+irW1+Nhpv0PpeMzSNf9lTjzT/eHRZtH2fM1370AdYqc3FTyQ==" + "integrity": "sha512-/m5z3Df6I6i/B0lnv6pB2O1+X/nWVquqbnltq+irW1+Nhpv0PpeMzSNf9lTjzT/eHRZtH2fM1370AdYqc3FTyQ==", + "requires": {} }, "@webassemblyjs/ast": { "version": "1.11.1", @@ -25029,11 +24986,13 @@ }, "acorn-import-assertions": { "version": "1.8.0", - "dev": true + "dev": true, + "requires": {} }, "acorn-jsx": { "version": "5.3.2", - "dev": true + "dev": true, + "requires": {} }, "acorn-node": { "version": "1.8.2", @@ -25364,7 +25323,8 @@ }, "ajv-keywords": { "version": "3.5.2", - "dev": true + "dev": true, + "requires": {} }, "json-schema-traverse": { "version": "0.4.1", @@ -25412,7 +25372,8 @@ }, "babel-plugin-named-asset-import": { "version": "0.3.8", - "dev": true + "dev": true, + "requires": {} }, "babel-plugin-polyfill-corejs2": { "version": "0.3.3", @@ -25621,6 +25582,12 @@ "ms": { "version": "2.0.0", "dev": true + }, + "qs": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==", + "dev": true } } }, @@ -25640,7 +25607,8 @@ "bootstrap": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.2.tgz", - "integrity": "sha512-dEtzMTV71n6Fhmbg4fYJzQsw1N29hJKO1js5ackCgIpDcGid2ETMGC6zwSYw09v05Y+oRdQ9loC54zB1La3hHQ==" + "integrity": "sha512-dEtzMTV71n6Fhmbg4fYJzQsw1N29hJKO1js5ackCgIpDcGid2ETMGC6zwSYw09v05Y+oRdQ9loC54zB1La3hHQ==", + "requires": {} }, "brace-expansion": { "version": "1.1.11", @@ -25664,7 +25632,6 @@ "version": "4.21.4", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.4.tgz", "integrity": "sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw==", - "dev": true, "requires": { "caniuse-lite": "^1.0.30001400", "electron-to-chromium": "^1.4.251", @@ -25703,7 +25670,6 @@ }, "call-bind": { "version": "1.0.2", - "dev": true, "requires": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -25749,8 +25715,7 @@ "caniuse-lite": { "version": "1.0.30001431", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001431.tgz", - "integrity": "sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ==", - "dev": true + "integrity": "sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ==" }, "canvas": { "version": "2.10.2", @@ -26262,7 +26227,8 @@ }, "css-declaration-sorter": { "version": "6.2.2", - "dev": true + "dev": true, + "requires": {} }, "css-has-pseudo": { "version": "3.0.4", @@ -26345,7 +26311,8 @@ }, "css-prefers-color-scheme": { "version": "6.0.3", - "dev": true + "dev": true, + "requires": {} }, "css-select": { "version": "4.3.0", @@ -26443,7 +26410,8 @@ }, "cssnano-utils": { "version": "3.1.0", - "dev": true + "dev": true, + "requires": {} }, "csso": { "version": "4.2.0", @@ -26584,9 +26552,6 @@ "version": "10.3.1", "dev": true }, - "decode-uri-component": { - "version": "0.2.0" - }, "decompress-response": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", @@ -26863,8 +26828,7 @@ "electron-to-chromium": { "version": "1.4.284", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz", - "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==", - "dev": true + "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==" }, "emittery": { "version": "0.8.1", @@ -26994,8 +26958,7 @@ } }, "escalade": { - "version": "3.1.1", - "dev": true + "version": "3.1.1" }, "escape-html": { "version": "1.0.3", @@ -27170,7 +27133,8 @@ }, "eslint-config-prettier": { "version": "8.5.0", - "dev": true + "dev": true, + "requires": {} }, "eslint-config-react-app": { "version": "7.0.1", @@ -27446,7 +27410,8 @@ }, "eslint-plugin-react-hooks": { "version": "4.4.0", - "dev": true + "dev": true, + "requires": {} }, "eslint-plugin-testing-library": { "version": "5.3.1", @@ -27653,6 +27618,12 @@ "version": "0.1.7", "dev": true }, + "qs": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==", + "dev": true + }, "safe-buffer": { "version": "5.2.1", "dev": true @@ -27789,9 +27760,6 @@ "to-regex-range": "^5.0.1" } }, - "filter-obj": { - "version": "1.1.0" - }, "finalhandler": { "version": "1.1.2", "dev": true, @@ -27917,7 +27885,8 @@ }, "ajv-keywords": { "version": "3.5.2", - "dev": true + "dev": true, + "requires": {} }, "fs-extra": { "version": "9.1.0", @@ -28038,8 +28007,7 @@ } }, "gensync": { - "version": "1.0.0-beta.2", - "dev": true + "version": "1.0.0-beta.2" }, "get-caller-file": { "version": "2.0.5" @@ -28048,7 +28016,6 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz", "integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==", - "dev": true, "requires": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -28212,8 +28179,7 @@ } }, "has-symbols": { - "version": "1.0.3", - "dev": true + "version": "1.0.3" }, "has-tostringtag": { "version": "1.0.0", @@ -28426,7 +28392,8 @@ }, "icss-utils": { "version": "5.1.0", - "dev": true + "dev": true, + "requires": {} }, "idb": { "version": "6.1.5", @@ -28573,7 +28540,8 @@ "intro.js-react": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/intro.js-react/-/intro.js-react-0.7.0.tgz", - "integrity": "sha512-RvtmGqLijagV0ca6BZXtubfnfwfPHarfv39NEun2t9pGlL9WXBwA54CARj0if24OZ7eMmQqxpF0lBMbDNASLpA==" + "integrity": "sha512-RvtmGqLijagV0ca6BZXtubfnfwfPHarfv39NEun2t9pGlL9WXBwA54CARj0if24OZ7eMmQqxpF0lBMbDNASLpA==", + "requires": {} }, "invariant": { "version": "2.2.4", @@ -29520,7 +29488,8 @@ }, "jest-pnp-resolver": { "version": "1.2.2", - "dev": true + "dev": true, + "requires": {} }, "jest-regex-util": { "version": "27.5.1", @@ -30066,8 +30035,7 @@ } }, "json5": { - "version": "2.2.1", - "dev": true + "version": "2.2.1" }, "jsonfile": { "version": "6.1.0", @@ -30836,8 +30804,7 @@ "node-releases": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", - "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==", - "dev": true + "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==" }, "nopt": { "version": "5.0.0", @@ -30910,8 +30877,7 @@ "dev": true }, "object-inspect": { - "version": "1.12.2", - "dev": true + "version": "1.12.2" }, "object-keys": { "version": "1.1.1", @@ -31194,8 +31160,7 @@ "version": "2.1.0" }, "picocolors": { - "version": "1.0.0", - "dev": true + "version": "1.0.0" }, "picomatch": { "version": "2.3.1", @@ -31308,7 +31273,8 @@ }, "postcss-browser-comments": { "version": "4.0.0", - "dev": true + "dev": true, + "requires": {} }, "postcss-calc": { "version": "8.2.4", @@ -31407,7 +31373,8 @@ }, "postcss-custom-media": { "version": "8.0.0", - "dev": true + "dev": true, + "requires": {} }, "postcss-custom-properties": { "version": "12.1.7", @@ -31438,19 +31405,23 @@ }, "postcss-discard-comments": { "version": "5.1.1", - "dev": true + "dev": true, + "requires": {} }, "postcss-discard-duplicates": { "version": "5.1.0", - "dev": true + "dev": true, + "requires": {} }, "postcss-discard-empty": { "version": "5.1.1", - "dev": true + "dev": true, + "requires": {} }, "postcss-discard-overridden": { "version": "5.1.0", - "dev": true + "dev": true, + "requires": {} }, "postcss-double-position-gradients": { "version": "3.1.1", @@ -31481,7 +31452,8 @@ }, "postcss-flexbugs-fixes": { "version": "5.0.2", - "dev": true + "dev": true, + "requires": {} }, "postcss-focus-visible": { "version": "6.0.4", @@ -31499,11 +31471,13 @@ }, "postcss-font-variant": { "version": "5.0.0", - "dev": true + "dev": true, + "requires": {} }, "postcss-gap-properties": { "version": "3.0.3", - "dev": true + "dev": true, + "requires": {} }, "postcss-image-set-function": { "version": "4.0.6", @@ -31520,7 +31494,8 @@ }, "postcss-initial": { "version": "4.0.1", - "dev": true + "dev": true, + "requires": {} }, "postcss-js": { "version": "4.0.0", @@ -31586,11 +31561,13 @@ }, "postcss-logical": { "version": "5.0.4", - "dev": true + "dev": true, + "requires": {} }, "postcss-media-minmax": { "version": "5.0.0", - "dev": true + "dev": true, + "requires": {} }, "postcss-merge-longhand": { "version": "5.1.4", @@ -31668,7 +31645,8 @@ }, "postcss-modules-extract-imports": { "version": "3.0.0", - "dev": true + "dev": true, + "requires": {} }, "postcss-modules-local-by-default": { "version": "4.0.0", @@ -31718,7 +31696,8 @@ }, "postcss-normalize-charset": { "version": "5.1.0", - "dev": true + "dev": true, + "requires": {} }, "postcss-normalize-display-values": { "version": "5.1.0", @@ -31846,11 +31825,13 @@ }, "postcss-overflow-shorthand": { "version": "3.0.3", - "dev": true + "dev": true, + "requires": {} }, "postcss-page-break": { "version": "3.0.4", - "dev": true + "dev": true, + "requires": {} }, "postcss-place": { "version": "7.0.4", @@ -31950,7 +31931,8 @@ }, "postcss-replace-overflow-wrap": { "version": "4.0.0", - "dev": true + "dev": true, + "requires": {} }, "postcss-selector-not": { "version": "5.0.0", @@ -32122,21 +32104,13 @@ "dev": true }, "qs": { - "version": "6.9.7", - "dev": true - }, - "query-string": { - "version": "7.1.1", + "version": "6.11.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.1.tgz", + "integrity": "sha512-0wsrzgTz/kAVIeuxSjnpGC56rzYtr6JT/2BwEvMaPhFIoYa1aGO8LbzuU1R0uUYQkLpWBTOj0l/CLAJB64J6nQ==", "requires": { - "decode-uri-component": "^0.2.0", - "filter-obj": "^1.1.0", - "split-on-first": "^1.0.0", - "strict-uri-encode": "^2.0.0" + "side-channel": "^1.0.4" } }, - "querystring": { - "version": "0.2.1" - }, "queue-microtask": { "version": "1.2.3", "dev": true @@ -32353,7 +32327,8 @@ } }, "react-content-loader": { - "version": "6.2.0" + "version": "6.2.0", + "requires": {} }, "react-contexify": { "version": "6.0.0", @@ -32546,10 +32521,12 @@ "version": "3.2.0" }, "react-flip-move": { - "version": "3.0.4" + "version": "3.0.4", + "requires": {} }, "react-google-charts": { - "version": "4.0.0" + "version": "4.0.0", + "requires": {} }, "react-gravatar": { "version": "2.6.3", @@ -32671,7 +32648,8 @@ "pdfjs-dist": { "version": "2.11.338", "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.11.338.tgz", - "integrity": "sha512-Ti5VTB0VvSdtTtc7TG71ghMx0SEuNcEs4ghVuZxW0p6OqLjMc0xekZV1B+MmlxEG2Du2e5jgazucWIG/SXTcdA==" + "integrity": "sha512-Ti5VTB0VvSdtTtc7TG71ghMx0SEuNcEs4ghVuZxW0p6OqLjMc0xekZV1B+MmlxEG2Du2e5jgazucWIG/SXTcdA==", + "requires": {} } } }, @@ -32683,7 +32661,8 @@ } }, "react-range": { - "version": "1.8.14" + "version": "1.8.14", + "requires": {} }, "react-redux": { "version": "8.0.5", @@ -32915,7 +32894,8 @@ } }, "react-side-effect": { - "version": "2.1.1" + "version": "2.1.1", + "requires": {} }, "react-slick": { "version": "0.29.0", @@ -32939,7 +32919,8 @@ "version": "1.1.0" }, "react-table": { - "version": "7.8.0" + "version": "7.8.0", + "requires": {} }, "react-table-sticky": { "version": "1.1.3" @@ -32978,7 +32959,8 @@ } }, "react-universal-interface": { - "version": "0.6.2" + "version": "0.6.2", + "requires": {} }, "react-use": { "version": "17.4.0", @@ -33073,12 +33055,14 @@ "redux-first-history": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/redux-first-history/-/redux-first-history-5.1.1.tgz", - "integrity": "sha512-ujVHv+y9wC2rqavS5tLiSu6zkw+VYrEea+/ggwVTRuutadEtwxSRlaK19ry/PTLSQtFuUF1Xu+plL5erD4roVw==" + "integrity": "sha512-ujVHv+y9wC2rqavS5tLiSu6zkw+VYrEea+/ggwVTRuutadEtwxSRlaK19ry/PTLSQtFuUF1Xu+plL5erD4roVw==", + "requires": {} }, "redux-thunk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.4.2.tgz", - "integrity": "sha512-+P3TjtnP0k/FEjcBL5FZpoovtvrTNT/UXd4/sluaSyrURlSlhLSzEdfsTBW7WsKB6yPvgd7q/iZPICFjW4o57Q==" + "integrity": "sha512-+P3TjtnP0k/FEjcBL5FZpoovtvrTNT/UXd4/sluaSyrURlSlhLSzEdfsTBW7WsKB6yPvgd7q/iZPICFjW4o57Q==", + "requires": {} }, "regenerate": { "version": "1.4.2", @@ -33439,7 +33423,8 @@ }, "ajv-keywords": { "version": "3.5.2", - "dev": true + "dev": true, + "requires": {} }, "json-schema-traverse": { "version": "0.4.1", @@ -33667,7 +33652,6 @@ }, "side-channel": { "version": "1.0.4", - "dev": true, "requires": { "call-bind": "^1.0.0", "get-intrinsic": "^1.0.2", @@ -33818,9 +33802,6 @@ "wbuf": "^1.7.3" } }, - "split-on-first": { - "version": "1.1.0" - }, "sprintf-js": { "version": "1.0.3", "dev": true @@ -33897,9 +33878,6 @@ "strict-mode": { "version": "1.1.5" }, - "strict-uri-encode": { - "version": "2.0.0" - }, "string_decoder": { "version": "1.1.1", "requires": { @@ -34013,7 +33991,8 @@ }, "style-loader": { "version": "3.3.1", - "dev": true + "dev": true, + "requires": {} }, "styled-components": { "version": "5.3.6", @@ -34528,8 +34507,7 @@ } }, "tslib": { - "version": "1.10.0", - "dev": true + "version": "1.10.0" }, "tsutils": { "version": "3.21.0", @@ -34571,6 +34549,13 @@ "is-typedarray": "^1.0.0" } }, + "typescript": { + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "dev": true, + "peer": true + }, "uglify-js": { "version": "3.13.10", "dev": true, @@ -34644,7 +34629,6 @@ "version": "1.0.10", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", "integrity": "sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==", - "dev": true, "requires": { "escalade": "^3.1.1", "picocolors": "^1.0.0" @@ -34658,13 +34642,16 @@ } }, "use-composed-ref": { - "version": "1.3.0" + "version": "1.3.0", + "requires": {} }, "use-is-mounted-ref": { - "version": "1.5.0" + "version": "1.5.0", + "requires": {} }, "use-isomorphic-layout-effect": { - "version": "1.1.2" + "version": "1.1.2", + "requires": {} }, "use-latest": { "version": "1.2.1", @@ -34675,7 +34662,8 @@ "use-memo-one": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/use-memo-one/-/use-memo-one-1.1.3.tgz", - "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==" + "integrity": "sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==", + "requires": {} }, "use-resize-observer": { "version": "9.0.2", @@ -34686,7 +34674,8 @@ "use-sync-external-store": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", - "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==" + "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==", + "requires": {} }, "util": { "version": "0.12.5", @@ -35022,7 +35011,8 @@ }, "ws": { "version": "8.5.0", - "dev": true + "dev": true, + "requires": {} } } }, @@ -35402,7 +35392,8 @@ }, "ws": { "version": "7.5.7", - "dev": true + "dev": true, + "requires": {} }, "xml": { "version": "1.0.1", diff --git a/package.json b/package.json index 502264532..12c2d0ea9 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,7 @@ "path-to-regexp": "^6.2.1", "pluralize": "^8.0.0", "prop-types": "^15.8.1", - "query-string": "^7.1.1", - "querystring": "^0.2.1", + "qs": "^6.11.1", "randomcolor": "^0.6.2", "rangy": "^1.3.1", "rc-tabs": "^12.5.7", diff --git a/src/components/AddPaper/GeneralData/GeneralData.js b/src/components/AddPaper/GeneralData/GeneralData.js index a5ae1d220..3289066a1 100644 --- a/src/components/AddPaper/GeneralData/GeneralData.js +++ b/src/components/AddPaper/GeneralData/GeneralData.js @@ -32,7 +32,7 @@ import moment from 'moment'; import { Cite } from '@citation-js/core'; import { Steps } from 'intro.js-react'; import { useLocation } from 'react-router-dom'; -import queryString from 'query-string'; +import qs from 'qs'; import env from '@beam-australia/react-env'; import AutocompleteContentTypeTitle from 'components/AutocompleteContentTypeTitle/AutocompleteContentTypeTitle'; import Confirm from 'components/Confirmation/Confirmation'; @@ -161,7 +161,7 @@ const GeneralData = () => { }; useEffect(() => { - const entryParam = queryString.parse(location.search).entry; + const entryParam = qs.parse(location.search, { ignoreQueryPrefix: true }).entry; if (entryParam) { dispatch(updateGeneralData({ entry: entryParam })); handleLookupClick(entryParam); diff --git a/src/components/Comparison/hooks/helpers.js b/src/components/Comparison/hooks/helpers.js index 0bab763c5..29ee26457 100644 --- a/src/components/Comparison/hooks/helpers.js +++ b/src/components/Comparison/hooks/helpers.js @@ -1,4 +1,4 @@ -import queryString from 'query-string'; +import qs from 'qs'; import { getArrayParamFromQueryString, getParamFromQueryString } from 'utils'; import { isEmpty, uniq, without, flattenDepth, groupBy, flatten, last, find } from 'lodash'; import { DEFAULT_COMPARISON_METHOD } from 'constants/misc'; @@ -164,7 +164,7 @@ export const activatedContributionsToList = contributionsData => { }; export function getComparisonURLConfig(comparisonState) { - const params = queryString.stringify( + const params = qs.stringify( { contributions: activatedContributionsToList(comparisonState.contributions).join(','), properties: comparisonState.configuration.predicatesList.map(predicate => encodeURIComponent(predicate)).join(','), @@ -173,8 +173,7 @@ export function getComparisonURLConfig(comparisonState) { response_hash: comparisonState.configuration.responseHash, }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, encode: false, }, ); diff --git a/src/components/Comparison/hooks/useComparison.js b/src/components/Comparison/hooks/useComparison.js index be0945110..6991c5314 100644 --- a/src/components/Comparison/hooks/useComparison.js +++ b/src/components/Comparison/hooks/useComparison.js @@ -34,7 +34,7 @@ import { PREDICATES, CLASSES } from 'constants/graphSettings'; import { reverse } from 'named-urls'; import { uniq, without } from 'lodash'; import ROUTES from 'constants/routes.js'; -import queryString from 'query-string'; +import qs from 'qs'; import { useSelector, useDispatch } from 'react-redux'; import { getComparisonConfiguration, generateFilterControlData } from './helpers'; @@ -195,7 +195,7 @@ function useComparison({ id, isEmbeddedMode = false }) { _transpose = transpose, hasPreviousVersion = comparisonResource?.id || comparisonResource?.hasPreviousVersion?.id, }) => { - const qParams = queryString.stringify( + const qParams = qs.stringify( { contributions: _contributionsList.join(','), properties: _predicatesList.map(predicate => encodeURIComponent(predicate)).join(','), @@ -204,8 +204,8 @@ function useComparison({ id, isEmbeddedMode = false }) { hasPreviousVersion, }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, + arrayFormat: 'comma', encode: false, }, ); @@ -231,8 +231,10 @@ function useComparison({ id, isEmbeddedMode = false }) { * Parse previous version from query param */ useEffect(() => { - if (!comparisonId && queryString.parse(search)?.hasPreviousVersion) { - getResource(queryString.parse(search).hasPreviousVersion).then(prevVersion => dispatch(setHasPreviousVersion(prevVersion))); + if (!comparisonId && qs.parse(search, { ignoreQueryPrefix: true })?.hasPreviousVersion) { + getResource(qs.parse(search, { ignoreQueryPrefix: true }).hasPreviousVersion).then(prevVersion => + dispatch(setHasPreviousVersion(prevVersion)), + ); } }, [comparisonId, dispatch, search]); diff --git a/src/components/ContributionEditor/hooks/useContributionEditor.js b/src/components/ContributionEditor/hooks/useContributionEditor.js index 6d53db939..a87f7576c 100644 --- a/src/components/ContributionEditor/hooks/useContributionEditor.js +++ b/src/components/ContributionEditor/hooks/useContributionEditor.js @@ -4,7 +4,7 @@ import TableHeaderColumnFirst from 'components/ContributionEditor/TableHeaderCol import TableHeaderRow from 'components/ContributionEditor/TableHeaderRow'; import ROUTES from 'constants/routes'; import { sortBy, uniq, without } from 'lodash'; -import queryString from 'query-string'; +import qs from 'qs'; import { useCallback } from 'react'; import { useNavigate, useLocation } from 'react-router-dom'; @@ -12,12 +12,12 @@ const useContributionEditor = () => { const location = useLocation(); const navigate = useNavigate(); const getContributionIds = useCallback(() => { - const { contributions } = queryString.parse(location.search, { arrayFormat: 'comma' }); + const { contributions } = qs.parse(location.search, { comma: true, ignoreQueryPrefix: true }); const contributionIds = contributions && !Array.isArray(contributions) ? [contributions] : contributions; return without(uniq(contributionIds), undefined, null, '') ?? []; }, [location.search]); - const { hasPreviousVersion } = queryString.parse(location.search); + const { hasPreviousVersion } = qs.parse(location.search, { ignoreQueryPrefix: true }); const handleAddContributions = ids => { const idsQueryString = [...getContributionIds(), ...ids].join(','); diff --git a/src/components/DiffView/DiffView.js b/src/components/DiffView/DiffView.js index 09870f19a..37cb5b14b 100644 --- a/src/components/DiffView/DiffView.js +++ b/src/components/DiffView/DiffView.js @@ -3,16 +3,16 @@ import { FontAwesomeIcon as Icon } from '@fortawesome/react-fontawesome'; import { ContainerAnimated } from 'components/Comparison/styled'; import DiffTitle from 'components/DiffView/DiffTitle'; import useDiff from 'components/DiffView/useDiff'; +import TitleBar from 'components/TitleBar/TitleBar'; import { reverse } from 'named-urls'; -import React, { useEffect, useState } from 'react'; +import PropTypes from 'prop-types'; +import qs from 'qs'; +import { useEffect, useState } from 'react'; import ContentLoader from 'react-content-loader'; import ReactDiffViewer from 'react-diff-viewer'; -import { useParams, useNavigate } from 'react-router-dom'; +import { useNavigate, useParams } from 'react-router-dom'; import { useLocation } from 'react-use'; import { Alert, Button } from 'reactstrap'; -import queryString from 'query-string'; -import TitleBar from 'components/TitleBar/TitleBar'; -import PropTypes from 'prop-types'; const DiffView = ({ type, diffRoute, getData }) => { const { oldId, newId } = useParams(); @@ -26,7 +26,7 @@ const DiffView = ({ type, diffRoute, getData }) => { const { isOldIdHigherThanNewId } = useDiff(); const navigate = useNavigate(); const location = useLocation(); - const { switchedVersions } = queryString.parse(location.search); + const { switchedVersions } = qs.parse(location.search, { ignoreQueryPrefix: true }); useEffect(() => { document.title = `Compare ${type} versions - ORKG`; diff --git a/src/components/Observatory/IntegratedList.js b/src/components/Observatory/IntegratedList.js index 0f8a3fc4f..b10468bf3 100644 --- a/src/components/Observatory/IntegratedList.js +++ b/src/components/Observatory/IntegratedList.js @@ -10,7 +10,7 @@ import ContentLoader from 'react-content-loader'; import PropTypes from 'prop-types'; import { toast } from 'react-toastify'; import { useLocation } from 'react-router'; -import queryString from 'query-string'; +import qs from 'qs'; const DEFAULT_CLASSES_FILTER = [ { id: CLASSES.PAPER, label: 'Paper' }, @@ -24,7 +24,7 @@ const DEFAULT_CLASSES_FILTER = [ const IntegratedList = ({ id, slug, boxShadow }) => { const location = useLocation(); - const params = queryString.parse(location.search); + const params = qs.parse(location.search, { ignoreQueryPrefix: true }); const { items, sort, isLoading, hasNextPage, isLastPageReached, totalElements, page, classesFilter, handleLoadMore, setClassesFilter, setSort } = useObservatoryContent({ diff --git a/src/components/ResearchField/IntegratedList.js b/src/components/ResearchField/IntegratedList.js index 56f6fde33..e90050d3e 100644 --- a/src/components/ResearchField/IntegratedList.js +++ b/src/components/ResearchField/IntegratedList.js @@ -10,7 +10,7 @@ import ContentLoader from 'react-content-loader'; import PropTypes from 'prop-types'; import { toast } from 'react-toastify'; import { useLocation } from 'react-router-dom'; -import queryString from 'query-string'; +import qs from 'qs'; const DEFAULT_CLASSES_FILTER = [ { id: CLASSES.PAPER, label: 'Paper' }, @@ -24,7 +24,7 @@ const DEFAULT_CLASSES_FILTER = [ const IntegratedList = ({ id, slug, boxShadow }) => { const location = useLocation(); - const params = queryString.parse(location.search); + const params = qs.parse(location.search, { ignoreQueryPrefix: true }); const { items, diff --git a/src/components/ResearchProblem/IntegratedList.js b/src/components/ResearchProblem/IntegratedList.js index 5e235352a..2a8669bcf 100644 --- a/src/components/ResearchProblem/IntegratedList.js +++ b/src/components/ResearchProblem/IntegratedList.js @@ -10,7 +10,7 @@ import ContentLoader from 'react-content-loader'; import PropTypes from 'prop-types'; import { toast } from 'react-toastify'; import { useLocation } from 'react-router-dom'; -import queryString from 'query-string'; +import qs from 'qs'; const DEFAULT_CLASSES_FILTER = [ { id: CLASSES.PAPER, label: 'Paper' }, @@ -24,7 +24,7 @@ const DEFAULT_CLASSES_FILTER = [ const IntegratedList = ({ id, slug, boxShadow }) => { const location = useLocation(); - const params = queryString.parse(location.search); + const params = qs.parse(location.search, { ignoreQueryPrefix: true }); const { items, sort, isLoading, hasNextPage, isLastPageReached, totalElements, page, classesFilter, handleLoadMore, setClassesFilter, setSort } = useResearchProblemContent({ diff --git a/src/pages/ContributionEditor.js b/src/pages/ContributionEditor.js index aa5f33c52..13f3a038b 100644 --- a/src/pages/ContributionEditor.js +++ b/src/pages/ContributionEditor.js @@ -12,7 +12,7 @@ import CreateContributionModal from 'components/CreateContributionModal/CreateCo import CreatePaperModal from 'components/CreatePaperModal/CreatePaperModal'; import routes from 'constants/routes'; import { reverse } from 'named-urls'; -import queryString from 'query-string'; +import qs from 'qs'; import { useLocation, Link } from 'react-router-dom'; import { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; @@ -39,7 +39,7 @@ const ContributionEditor = () => { statementId => state.contributionEditor?.statements[statementId]?.created_by === env('PWC_USER_ID'), )?.length ?? 0, ); - const { hasPreviousVersion } = queryString.parse(location.search); + const { hasPreviousVersion } = qs.parse(location.search, { ignoreQueryPrefix: true }); useEffect(() => { document.title = 'Contribution editor - ORKG'; diff --git a/src/pages/Papers/ViewPaper.js b/src/pages/Papers/ViewPaper.js index ae97f4b01..b0da8b881 100644 --- a/src/pages/Papers/ViewPaper.js +++ b/src/pages/Papers/ViewPaper.js @@ -12,7 +12,7 @@ import PaperHeaderBar from 'components/ViewPaper/PaperHeaderBar/PaperHeaderBar'; import PaperMenuBar from 'components/ViewPaper/PaperHeaderBar/PaperMenuBar'; import moment from 'moment'; import NotFound from 'pages/NotFound'; -import queryString from 'query-string'; +import qs from 'qs'; import { useEffect, useState } from 'react'; import ContentLoader from 'react-content-loader'; import { Helmet } from 'react-helmet'; @@ -32,7 +32,7 @@ const ViewPaper = () => { paperId: resourceId, }); - let comingFromWizard = queryString.parse(location.search); + let comingFromWizard = qs.parse(location.search, { ignoreQueryPrefix: true }); comingFromWizard = comingFromWizard ? comingFromWizard.comingFromWizard === 'true' : false; useEffect(() => { diff --git a/src/services/backend/classes.js b/src/services/backend/classes.js index 36a8feb7c..2b7c46310 100644 --- a/src/services/backend/classes.js +++ b/src/services/backend/classes.js @@ -1,6 +1,6 @@ import { url } from 'constants/misc'; import { submitPostRequest, submitGetRequest } from 'network'; -import queryString from 'query-string'; +import qs from 'qs'; export const classesUrl = `${url}classes/`; @@ -19,11 +19,10 @@ export const getClasses = ({ returnContent = false, }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size, sort, exact, ...(q ? { q } : {}), uri }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); diff --git a/src/services/backend/comparisons.js b/src/services/backend/comparisons.js index 571494323..d5632b318 100644 --- a/src/services/backend/comparisons.js +++ b/src/services/backend/comparisons.js @@ -2,7 +2,7 @@ import { CLASSES, PREDICATES } from 'constants/graphSettings'; import { url } from 'constants/misc'; import { flatten, uniqBy } from 'lodash'; import { submitGetRequest } from 'network'; -import queryString from 'query-string'; +import qs from 'qs'; import { getResource } from 'services/backend/resources'; import { getStatementsByObjectAndPredicate, getStatementsBySubjectAndPredicate } from 'services/backend/statements'; import { filterObjectOfStatementsByPredicateAndClass, filterSubjectOfStatementsByPredicateAndClass } from 'utils'; @@ -69,6 +69,6 @@ export const getComparisonVersionsById = comparisonId => { }; export const getAuthorsByComparisonId = ({ id, page = 0, items = 9999 }) => { - const params = queryString.stringify({ page, size: items }); + const params = qs.stringify({ page, size: items }); return submitGetRequest(`${comparisonUrl}${encodeURIComponent(id)}/authors?${params}`); }; diff --git a/src/services/backend/observatories.js b/src/services/backend/observatories.js index a62fc355e..4525073f1 100644 --- a/src/services/backend/observatories.js +++ b/src/services/backend/observatories.js @@ -1,6 +1,6 @@ import { MISC } from 'constants/graphSettings'; import { url } from 'constants/misc'; -import queryString from 'query-string'; +import qs from 'qs'; import { submitGetRequest, submitPostRequest, submitPutRequest } from 'network'; import { getOrganization } from 'services/backend/organizations'; import { getOrganizationLogoUrl } from 'services/backend/organizations'; @@ -44,11 +44,10 @@ export const getContentByObservatoryIdAndClasses = ({ }) => { // Sort is not supported in this endpoint const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size: items, sort, featured, unlisted, classes: classes.join(',') }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${observatoriesUrl}${encodeURIComponent(id)}/class?${params}`); diff --git a/src/services/backend/papers.js b/src/services/backend/papers.js index 2c9765f0f..46082d588 100644 --- a/src/services/backend/papers.js +++ b/src/services/backend/papers.js @@ -4,7 +4,7 @@ import { getStatementsBySubjectAndPredicate, getStatementsByObjectAndPredicate } import { PREDICATES, CLASSES } from 'constants/graphSettings'; import { indexContribution } from 'services/similarity'; import { toast } from 'react-toastify'; -import queryString from 'query-string'; +import qs from 'qs'; export const papersUrl = `${url}papers/`; @@ -57,11 +57,10 @@ export const getPapersLinkedToResource = async ({ returnContent = false, }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { linkedTo: id, page, size, sort, desc }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); diff --git a/src/services/backend/predicates.js b/src/services/backend/predicates.js index dc16a1d2b..44be6cdd3 100644 --- a/src/services/backend/predicates.js +++ b/src/services/backend/predicates.js @@ -1,5 +1,5 @@ import { submitPostRequest, submitPutRequest, submitGetRequest } from 'network'; -import queryString from 'query-string'; +import qs from 'qs'; import { url } from 'constants/misc'; export const predicatesUrl = `${url}predicates/`; @@ -20,11 +20,10 @@ export const getPredicates = ({ returnContent = false, }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size, sort, exact, ...(q ? { q } : {}) }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); diff --git a/src/services/backend/problems.js b/src/services/backend/problems.js index 10d8cb4c4..01ff99062 100644 --- a/src/services/backend/problems.js +++ b/src/services/backend/problems.js @@ -1,28 +1,26 @@ import { url } from 'constants/misc'; import { submitGetRequest } from 'network'; -import queryString from 'query-string'; +import qs from 'qs'; export const problemsUrl = `${url}problems/`; export const getResearchFieldsByResearchProblemId = problemId => submitGetRequest(`${problemsUrl}${encodeURIComponent(problemId)}/fields`); export const getContributorsByResearchProblemId = ({ id, page = 0, items = 9999 }) => { - const params = queryString.stringify( + const params = qs.stringify( { page, size: items }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${problemsUrl}${encodeURIComponent(id)}/users?${params}`); }; export const getAuthorsByResearchProblemId = ({ id, page = 0, items = 9999 }) => { - const params = queryString.stringify( + const params = qs.stringify( { page, size: items }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${problemsUrl}${encodeURIComponent(id)}/authors?${params}`); @@ -40,11 +38,10 @@ export const getContentByResearchProblemIdAndClasses = ({ }) => { // Sort is not supported in this endpoint const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size: items, sort, featured, unlisted, classes: classes.join(',') }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${problemsUrl}${encodeURIComponent(id)}/?${params}`); diff --git a/src/services/backend/researchFields.js b/src/services/backend/researchFields.js index 67828995d..c4e62cd21 100644 --- a/src/services/backend/researchFields.js +++ b/src/services/backend/researchFields.js @@ -1,15 +1,14 @@ import { url } from 'constants/misc'; import { submitGetRequest } from 'network'; -import queryString from 'query-string'; +import qs from 'qs'; export const fieldsUrl = `${url}research-fields/`; export const getResearchProblemsByResearchFieldIdCountingPapers = ({ id, page = 0, items = 1 }) => { - const params = queryString.stringify( + const params = qs.stringify( { page, size: items }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${fieldsUrl}${encodeURIComponent(id)}/problems?${params}`); @@ -28,11 +27,10 @@ export const getContentByResearchFieldIdAndClasses = ({ }) => { // Sort is not supported in this endpoint const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size: items, sort, featured, unlisted, classes: classes.join(',') }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${fieldsUrl}${encodeURIComponent(id)}/${subfields ? 'subfields/' : ''}?${params}`); @@ -49,11 +47,10 @@ export const getPapersByResearchFieldId = ({ unlisted = null, }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size: items, sort, featured, unlisted }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${fieldsUrl}${encodeURIComponent(id)}/${subfields ? 'subfields/' : ''}papers?${params}`); @@ -70,11 +67,10 @@ export const getResearchProblemsByResearchFieldId = ({ unlisted = null, }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size: items, sort, featured, unlisted }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${fieldsUrl}${encodeURIComponent(id)}/${subfields ? 'subfields/' : ''}research-problems?${params}`); @@ -82,11 +78,10 @@ export const getResearchProblemsByResearchFieldId = ({ // This endpoint is not used anymore! export const getContributorsByResearchFieldId = ({ id, page = 0, items = 9999, subfields = true }) => { - const params = queryString.stringify( + const params = qs.stringify( { page, size: items }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${fieldsUrl}${encodeURIComponent(id)}/${subfields ? 'subfields/' : ''}contributors?${params}`).then(result => ({ diff --git a/src/services/backend/resources.js b/src/services/backend/resources.js index 7e600128e..7871ab58c 100644 --- a/src/services/backend/resources.js +++ b/src/services/backend/resources.js @@ -2,7 +2,7 @@ import { submitPostRequest, submitPutRequest, submitGetRequest, submitDeleteRequ import { getContributorInformationById } from 'services/backend/contributors'; import { classesUrl } from 'services/backend/classes'; import { MISC } from 'constants/graphSettings'; -import queryString from 'query-string'; +import qs from 'qs'; import { uniqBy } from 'lodash'; import { url } from 'constants/misc'; @@ -32,7 +32,7 @@ export const getResources = ({ returnContent = false, }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size, @@ -43,8 +43,7 @@ export const getResources = ({ ...(exclude ? { exclude } : {}), }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); @@ -52,11 +51,10 @@ export const getResources = ({ }; export const getContributorsByResourceId = ({ id, page = 0, size = 9999 }) => { - const params = queryString.stringify( + const params = qs.stringify( { page, size }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${resourcesUrl}${encodeURIComponent(id)}/contributors?${params}`).then(async contributors => { @@ -92,11 +90,10 @@ export const getResourcesByClass = async ({ unlisted = null, }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size, sort, desc, creator, exact, ...(q ? { q } : {}), verified, featured, unlisted }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); diff --git a/src/services/backend/statements.js b/src/services/backend/statements.js index b221e7869..7743d3c1e 100644 --- a/src/services/backend/statements.js +++ b/src/services/backend/statements.js @@ -1,6 +1,6 @@ import { url } from 'constants/misc'; import { submitGetRequest, submitPostRequest, submitDeleteRequest, submitPutRequest } from 'network'; -import queryString from 'query-string'; +import qs from 'qs'; import { PREDICATES, MISC, CLASSES, RESOURCES } from 'constants/graphSettings'; import { filterStatementsBySubjectId, getTemplateComponentData, filterObjectOfStatementsByPredicateAndClass, sortMethod } from 'utils'; @@ -52,7 +52,7 @@ export const updateStatements = (statementIds, { subject_id = null, predicate_id export const getAllStatements = ({ page = 0, items: size = 9999, sortBy = 'created_at', desc = true }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size, sort }, { skipNull: true, @@ -69,11 +69,10 @@ export const deleteStatementsByIds = ids => submitDeleteRequest(`${statementsUrl export const getStatementsBySubject = ({ id, page = 0, items: size = 9999, sortBy = 'created_at', desc = true }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size, sort }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); @@ -90,11 +89,10 @@ export const getStatementsBySubject = ({ id, page = 0, items: size = 9999, sortB * @return {Promise} Promise object */ export const getStatementsBundleBySubject = ({ id, maxLevel = 10, blacklist = [] }) => { - const params = queryString.stringify( + const params = qs.stringify( { maxLevel, blacklist: blacklist?.join(',') }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${statementsUrl}${encodeURIComponent(id)}/bundle/?${params}`); @@ -102,11 +100,10 @@ export const getStatementsBundleBySubject = ({ id, maxLevel = 10, blacklist = [] export const getStatementsBySubjects = ({ ids, page = 0, items: size = 9999, sortBy = 'created_at', desc = true }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { ids: ids.join(), page, size, sort }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${statementsUrl}subjects/?${params}`).then(res => @@ -119,11 +116,10 @@ export const getStatementsBySubjects = ({ ids, page = 0, items: size = 9999, sor export const getStatementsByObject = async ({ id, page = 0, items: size = 9999, sortBy = 'created_at', desc = true, returnContent = true }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size, sort }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); @@ -136,11 +132,10 @@ export const getStatementsByObject = async ({ id, page = 0, items: size = 9999, export const getStatementsByPredicate = ({ id, page = 0, items: size = 9999, sortBy = 'created_at', desc = true, returnContent = true }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size, sort }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); @@ -149,11 +144,10 @@ export const getStatementsByPredicate = ({ id, page = 0, items: size = 9999, sor export const getStatementsBySubjectAndPredicate = ({ subjectId, predicateId, page = 0, items: size = 9999, sortBy = 'created_at', desc = true }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size, sort }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); @@ -170,11 +164,10 @@ export const getStatementsByObjectAndPredicate = ({ returnContent = true, }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size, sort }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); @@ -184,11 +177,10 @@ export const getStatementsByObjectAndPredicate = ({ }; export const getStatementsByPredicateAndLiteral = ({ predicateId, literal, subjectClass = null, items: size = 9999 }) => { - const params = queryString.stringify( + const params = qs.stringify( { size, subjectClass }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${statementsUrl}predicate/${predicateId}/literal/${literal}/?${params}`).then(res => res.content); diff --git a/src/services/backend/stats.js b/src/services/backend/stats.js index 18a478dc7..96cac6ad0 100644 --- a/src/services/backend/stats.js +++ b/src/services/backend/stats.js @@ -1,6 +1,6 @@ import { url } from 'constants/misc'; import { submitGetRequest } from 'network'; -import queryString from 'query-string'; +import qs from 'qs'; export const statsUrl = `${url}stats/`; @@ -32,11 +32,10 @@ export const getTopContributors = ({ }) => { const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; if (researchFieldId) { - const params = queryString.stringify( + const params = qs.stringify( { days, sort }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${statsUrl}research-field/${researchFieldId}/${subfields ? 'subfields/' : ''}top/contributors?${params}`).then( @@ -50,11 +49,10 @@ export const getTopContributors = ({ }, ); } - const params = queryString.stringify( + const params = qs.stringify( { page, size, sort, days }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${statsUrl}top/contributors?${params}`).then(result => ({ @@ -68,11 +66,10 @@ export const getTopContributors = ({ export const getChangelogs = ({ researchFieldId = null, page = 0, items = 9999, sortBy = 'createdAt', desc = true }) => { const sort = sortBy ? `${sortBy},${desc ? 'desc' : 'asc'}` : null; - const params = queryString.stringify( + const params = qs.stringify( { page, size: items, sort }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${statsUrl}${researchFieldId ? `research-field/${researchFieldId}/` : ''}top/changelog?${params}`); @@ -80,11 +77,10 @@ export const getChangelogs = ({ researchFieldId = null, page = 0, items = 9999, export const getTopResearchProblems = ({ page = 0, items = 9999, sortBy = 'created_at', desc = true, subfields = true }) => { // const sort = `${sortBy},${desc ? 'desc' : 'asc'}`; - const params = queryString.stringify( + const params = qs.stringify( { page, size: items /* , sort, desc */ }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${statsUrl}top/research-problems?${params}`); diff --git a/src/services/cms/index.js b/src/services/cms/index.js index 70323a37e..354177b27 100644 --- a/src/services/cms/index.js +++ b/src/services/cms/index.js @@ -3,33 +3,111 @@ */ import env from '@beam-australia/react-env'; import { submitGetRequest } from 'network'; +import qs from 'qs'; export const url = env('CMS_URL'); export const getPageByUrl = _url => submitGetRequest(`${url}pages?filters[url]=${_url}`); -export const getAboutPage = id => submitGetRequest(`${url}about-pages/${id}?populate[category][fields][0]=id`); +export const getAboutPage = id => { + const query = qs.stringify( + { + populate: { category: { fields: ['id'] } }, + }, + { + encodeValuesOnly: true, + }, + ); + return submitGetRequest(`${url}about-pages/${id}?${query}`); +}; -export const getAboutPageCategories = () => submitGetRequest(`${url}about-page-categories?sort=order&fields[0]=label`).catch(() => []); +export const getAboutPageCategories = () => { + const query = qs.stringify( + { + sort: 'order', + fields: ['label'], + }, + { + encodeValuesOnly: true, + }, + ); + return submitGetRequest(`${url}about-page-categories?${query}`).catch(() => []); +}; -export const getAboutPages = (categoryId = null) => - submitGetRequest( - `${url}about-pages?sort=order&pagination[pageSize]=100&fields[0]=title,order&populate[category][fields][0]=id${ - categoryId ? `&filters[category][id][$eq]=${categoryId}` : '' - }`, - ).catch(() => []); +export const getAboutPages = (categoryId = null) => { + const query = qs.stringify( + { + sort: 'order', + pagination: { + pageSize: 100, + }, + fields: ['title', 'order'], + populate: { + category: { + fields: ['id'], + }, + }, -export const getHelpArticle = id => submitGetRequest(`${url}help-articles/${id}?populate[help_category][fields][0]=id,title`); + ...(categoryId + ? { + filters: { + category: { + id: { + $eq: categoryId, + }, + }, + }, + } + : {}), + }, + { + encodeValuesOnly: true, + }, + ); + + return submitGetRequest(`${url}about-pages?${query}`).catch(() => []); +}; + +export const getHelpArticle = id => { + const query = qs.stringify( + { populate: { help_category: { fields: ['id', 'title'] } } }, + { + encodeValuesOnly: true, + }, + ); + return submitGetRequest(`${url}help-articles/${id}?${query}`); +}; export const getHelpArticles = ({ where = '' }) => submitGetRequest(`${url}help-articles?${where}`); -export const getHelpCategories = () => - submitGetRequest(`${url}help-categories?sort=order&populate[help_articles][fields][0]=title,order&populate[help_articles][sort][0]=order`); +export const getHelpCategories = () => { + const query = qs.stringify( + { sort: 'order', populate: { help_articles: { fields: ['title', 'order'], sort: ['order'] } } }, + { + encodeValuesOnly: true, + }, + ); + return submitGetRequest(`${url}help-categories?${query}`); +}; -export const getHelpCategory = id => - submitGetRequest(`${url}help-categories/${id}?populate[help_articles][fields][0]=title,order&populate[help_articles][sort][0]=order`); +export const getHelpCategory = id => { + const query = qs.stringify( + { populate: { help_articles: { fields: ['title', 'order'], sort: ['order'] } } }, + { + encodeValuesOnly: true, + }, + ); + return submitGetRequest(`${url}help-categories/${id}?${query}`); +}; export const getHomeAlerts = () => submitGetRequest(`${url}home-alerts?sort=order`).catch(() => []); -export const getNewsCards = ({ limit = 10, sort = 'created_at' }) => - submitGetRequest(`${url}news-cards?pagination[pageSize]=${limit}&sort=${sort}`).catch(() => []); +export const getNewsCards = ({ limit = 10, sort = 'created_at' }) => { + const query = qs.stringify( + { pagination: { pageSize: limit }, sort }, + { + encodeValuesOnly: true, + }, + ); + return submitGetRequest(`${url}news-cards?${query}`).catch(() => []); +}; diff --git a/src/services/ols/index.js b/src/services/ols/index.js index 66e802eb4..32f1695f1 100644 --- a/src/services/ols/index.js +++ b/src/services/ols/index.js @@ -1,11 +1,11 @@ import { submitGetRequest } from 'network'; -import queryString from 'query-string'; +import qs from 'qs'; import env from '@beam-australia/react-env'; export const olsBaseUrl = env('OLS_BASE_URL'); export const selectTerms = ({ page = 0, pageSize = 10, type = 'ontology', q = null, ontology = null }) => { - const params = queryString.stringify( + const params = qs.stringify( { rows: pageSize, start: page * pageSize, @@ -15,8 +15,7 @@ export const selectTerms = ({ page = 0, pageSize = 10, type = 'ontology', q = nu fieldList: 'label,ontology_prefix,id,iri,description,short_form', }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); const options = []; @@ -46,11 +45,10 @@ export const selectTerms = ({ page = 0, pageSize = 10, type = 'ontology', q = nu }; export const getAllOntologies = ({ page = 0, pageSize = 10 }) => { - const params = queryString.stringify( + const params = qs.stringify( { page, size: pageSize }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); const options = []; @@ -74,11 +72,10 @@ export const getAllOntologies = ({ page = 0, pageSize = 10 }) => { }; export const getOntologyTerms = ({ ontology_id, page = 0, pageSize = 10 }) => { - const params = queryString.stringify( + const params = qs.stringify( { page, size: pageSize }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); const options = []; @@ -105,11 +102,10 @@ export const getOntologyTerms = ({ ontology_id, page = 0, pageSize = 10 }) => { }; export const getTermMatchingAcrossOntologies = ({ page = 0, pageSize = 10 }) => { - const params = queryString.stringify( + const params = qs.stringify( { page, size: pageSize }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); const options = []; diff --git a/src/services/similarity/index.js b/src/services/similarity/index.js index d12f04de6..f00924c9a 100644 --- a/src/services/similarity/index.js +++ b/src/services/similarity/index.js @@ -4,7 +4,7 @@ */ import { submitPostRequest, submitGetRequest } from 'network'; -import queryString from 'query-string'; +import qs from 'qs'; import env from '@beam-australia/react-env'; export const similarityServiceUrl = env('SIMILARITY_SERVICE_URL'); @@ -27,7 +27,7 @@ export const getLongLink = shortCode => submitGetRequest(`${similarityServiceUrl * @param {Boolean} save_response To return a response hash and save a copy of the result */ export const getComparison = ({ contributionIds = [], type = null, response_hash = null, save_response = false }) => { - const params = queryString.stringify( + const params = qs.stringify( { contributions: contributionIds.join(','), response_hash, @@ -35,8 +35,7 @@ export const getComparison = ({ contributionIds = [], type = null, response_hash save_response, }, { - skipNull: true, - skipEmptyString: true, + skipNulls: true, }, ); return submitGetRequest(`${comparisonUrl}?${params}`); diff --git a/src/utils.js b/src/utils.js index ad561c7b8..dc0be6229 100644 --- a/src/utils.js +++ b/src/utils.js @@ -5,7 +5,7 @@ import ROUTES from 'constants/routes'; import { isString, sortBy, uniqBy } from 'lodash'; import { unescape } from 'he'; import { reverse } from 'named-urls'; -import queryString from 'query-string'; +import qs from 'qs'; import { Cookies } from 'react-cookie'; import env from '@beam-australia/react-env'; import slugifyString from 'slugify'; @@ -20,9 +20,8 @@ const cookies = new Cookies(); * @param {String} param parameter name * @return {Array} the list of values */ - export function getArrayParamFromQueryString(locationSearch, param) { - const values = queryString.parse(locationSearch, { arrayFormat: 'comma' })[param]; + const values = qs.parse(locationSearch, { comma: true, ignoreQueryPrefix: true })[param]; if (!values) { return []; } @@ -40,9 +39,8 @@ export function getArrayParamFromQueryString(locationSearch, param) { * @param {Boolean} boolean return false instead of null * @return {String|Boolean} value */ - export function getParamFromQueryString(locationSearch, param, boolean = false) { - const value = queryString.parse(locationSearch)[param]; + const value = qs.parse(locationSearch, { ignoreQueryPrefix: true })[param]; if (!value) { return boolean ? false : null; }