diff --git a/package-lock.json b/package-lock.json index 0b8442f61f8..39e1828b426 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,10 @@ "license": "AGPL-3.0", "dependencies": { "@aws-sdk/lib-storage": "^3.100.0", + "@feathersjs/adapter-commons": "^5.0.11", "@feathersjs/authentication": "^5.0.11", "@feathersjs/authentication-local": "^5.0.11", + "@feathersjs/commons": "^5.0.11", "@feathersjs/configuration": "^5.0.11", "@feathersjs/errors": "^5.0.11", "@feathersjs/express": "^5.0.11", @@ -75,7 +77,6 @@ "express-openapi-validator": "^4.13.2", "express-session": "^1.17.3", "feathers-hooks-common": "^8.1.1", - "feathers-mongoose": "^6.3.0", "feathers-swagger": "^3.0.0", "file-type": "^18.5.0", "freeport": "^1.0.5", @@ -92,7 +93,7 @@ "mixwith": "^0.1.1", "moment": "^2.19.2", "mongodb-uri": "^0.9.7", - "mongoose": "^5.13.20", + "mongoose": "^6.5.4", "mongoose-delete": "^0.5.4", "mongoose-id-validator": "^0.6.0", "mongoose-lean-virtuals": "^0.8.1", @@ -581,7 +582,6 @@ "version": "3.352.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.352.0.tgz", "integrity": "sha512-qXqg7V/DpHu8oyEq22LMskCoHYZU6+ds9gaArwc3SjPwQN/UM6CpIUHtTtxevLEYr7nI5iMIPBBrEcoKOJefxg==", - "dev": true, "optional": true, "dependencies": { "@aws-crypto/sha256-browser": "3.0.0", @@ -798,7 +798,6 @@ "version": "3.352.0", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.352.0.tgz", "integrity": "sha512-395bdedGD0pangBT6dyyrTvtDRxr3lqbi8lfuJR/+7bpMIEJKVhF5D6IAgdjRDpASDRHUPhHuWzR3Qa9RHAcNA==", - "dev": true, "optional": true, "dependencies": { "@aws-sdk/client-cognito-identity": "3.352.0", @@ -982,7 +981,6 @@ "version": "3.352.0", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-providers/-/credential-providers-3.352.0.tgz", "integrity": "sha512-hV6NO7+xzf3CPEsKZRsYflR05eNMvgVvOXFgQnOucUc85Kxt2XTSoH/HFtkolXDbxjA2Hku1pdaRG7qBzbiJHg==", - "dev": true, "optional": true, "dependencies": { "@aws-sdk/client-cognito-identity": "3.352.0", @@ -2949,18 +2947,6 @@ "url": "https://opencollective.com/feathers" } }, - "node_modules/@feathersjs/adapter-commons/node_modules/@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==", - "engines": { - "node": ">= 12" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/daffl" - } - }, "node_modules/@feathersjs/authentication": { "version": "5.0.11", "resolved": "https://registry.npmjs.org/@feathersjs/authentication/-/authentication-5.0.11.tgz", @@ -3006,30 +2992,6 @@ "url": "https://github.com/sponsors/daffl" } }, - "node_modules/@feathersjs/authentication-local/node_modules/@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==", - "engines": { - "node": ">= 12" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/daffl" - } - }, - "node_modules/@feathersjs/authentication/node_modules/@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==", - "engines": { - "node": ">= 12" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/daffl" - } - }, "node_modules/@feathersjs/authentication/node_modules/@feathersjs/schema": { "version": "5.0.11", "resolved": "https://registry.npmjs.org/@feathersjs/schema/-/schema-5.0.11.tgz", @@ -3110,6 +3072,18 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/@feathersjs/commons": { + "version": "5.0.11", + "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", + "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==", + "engines": { + "node": ">= 12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/daffl" + } + }, "node_modules/@feathersjs/configuration": { "version": "5.0.11", "resolved": "https://registry.npmjs.org/@feathersjs/configuration/-/configuration-5.0.11.tgz", @@ -3129,18 +3103,6 @@ "url": "https://github.com/sponsors/daffl" } }, - "node_modules/@feathersjs/configuration/node_modules/@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==", - "engines": { - "node": ">= 12" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/daffl" - } - }, "node_modules/@feathersjs/configuration/node_modules/@feathersjs/schema": { "version": "5.0.11", "resolved": "https://registry.npmjs.org/@feathersjs/schema/-/schema-5.0.11.tgz", @@ -3213,18 +3175,6 @@ "url": "https://github.com/sponsors/daffl" } }, - "node_modules/@feathersjs/express/node_modules/@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==", - "engines": { - "node": ">= 12" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/daffl" - } - }, "node_modules/@feathersjs/feathers": { "version": "5.0.11", "resolved": "https://registry.npmjs.org/@feathersjs/feathers/-/feathers-5.0.11.tgz", @@ -3242,18 +3192,6 @@ "url": "https://github.com/sponsors/daffl" } }, - "node_modules/@feathersjs/feathers/node_modules/@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==", - "engines": { - "node": ">= 12" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/daffl" - } - }, "node_modules/@feathersjs/hooks": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@feathersjs/hooks/-/hooks-0.8.1.tgz", @@ -3281,18 +3219,6 @@ "url": "https://github.com/sponsors/daffl" } }, - "node_modules/@feathersjs/transport-commons/node_modules/@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==", - "engines": { - "node": ">= 12" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/daffl" - } - }, "node_modules/@golevelup/nestjs-common": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@golevelup/nestjs-common/-/nestjs-common-2.0.0.tgz", @@ -4674,6 +4600,15 @@ "@nestjs/core": "^8.0.0 || ^9.0.0 || ^10.0.0" } }, + "node_modules/@mongodb-js/saslprep": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.1.tgz", + "integrity": "sha512-t7c5K033joZZMspnHg/gWPE4kandgc2OxE74aYOtGKfgB9VPuVJPix0H6fhmm2erj5PBJ21mqcx34lpIGtUCsQ==", + "optional": true, + "dependencies": { + "sparse-bitfield": "^3.0.3" + } + }, "node_modules/@nestjs/axios": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.0.tgz", @@ -5646,6 +5581,14 @@ "@types/node": "*" } }, + "node_modules/@types/bson": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@types/bson/-/bson-4.0.5.tgz", + "integrity": "sha512-vVLwMUqhYJSQ/WKcE60eFqcyuWse5fGH+NMAXHuKrUAPoryq3ATxk5o4bgYNtg5aOM4APVg7Hnb3ASqUYG0PKg==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/busboy": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@types/busboy/-/busboy-1.5.0.tgz", @@ -12031,43 +11974,6 @@ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, - "node_modules/feathers-mongoose": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/feathers-mongoose/-/feathers-mongoose-6.3.0.tgz", - "integrity": "sha512-TjTnrAo0J9u9QqIwoRyB2XnHk8S/Ylxf6o6M+IrqRd/wBQ/AGS5NG3bu6OWdezjBMlteTRqwstdTybV3pTtX6g==", - "deprecated": "Upgrade feathers-mongoose to version 8.1.0 or later for important usability and security improvements. See https://crow.docs.feathersjs.com/guides/migrating.html#database-adapters for more information. An upgrade to Feathers 4 is recommended but not required.", - "dependencies": { - "@feathersjs/commons": "^1.3.0", - "@feathersjs/errors": "^3.3.4", - "lodash.omit": "^4.5.0", - "uberproto": "^2.0.4" - }, - "engines": { - "node": ">= 6" - }, - "peerDependencies": { - "mongoose": "^5.3.14" - } - }, - "node_modules/feathers-mongoose/node_modules/@feathersjs/commons": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-1.4.4.tgz", - "integrity": "sha512-ZPpzyZA3CPfoa9AuFv3BJUI/ubzaaXixp8T/pqeMFPT6DOaU/6oF7lz1RxwimzfJNna4gy/HByt0EoLSI3BKWg==", - "engines": { - "node": ">= 6" - } - }, - "node_modules/feathers-mongoose/node_modules/@feathersjs/errors": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/@feathersjs/errors/-/errors-3.3.6.tgz", - "integrity": "sha512-VCohY/AQU13xYyZGl6rfdUgE+2bjaI76a4aEb6reIphHKgb4mnjYlg2PzS1/hcU1qUNi515kY9yQa5HsE7J1dQ==", - "dependencies": { - "debug": "^4.0.0" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/feathers-swagger": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/feathers-swagger/-/feathers-swagger-3.0.0.tgz", @@ -16308,9 +16214,12 @@ "dev": true }, "node_modules/kareem": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.2.tgz", - "integrity": "sha512-STHz9P7X2L4Kwn72fA4rGyqyXdmrMSdxqHx9IXon/FXluXieaFA6KJ2upcHAHxQPQ0LeM/OjLrhFxifHewOALQ==" + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz", + "integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA==", + "engines": { + "node": ">=12.0.0" + } }, "node_modules/kleur": { "version": "3.0.3", @@ -16595,11 +16504,6 @@ "integrity": "sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==", "dev": true }, - "node_modules/lodash.omit": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.omit/-/lodash.omit-4.5.0.tgz", - "integrity": "sha1-brGa5aHuHdnfC5aeZs4Lf6MLXmA=" - }, "node_modules/lodash.once": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", @@ -17095,6 +16999,15 @@ "migrate": "src/cli.js" } }, + "node_modules/migrate-mongoose/node_modules/@types/mongodb": { + "version": "3.6.20", + "resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.6.20.tgz", + "integrity": "sha512-WcdpPJCakFzcWWD9juKoZbRtQxKIMYF/JIAM4JrNHrMcnJL6/a2NWjXxW7fo9hxboxxkg+icff8d7+WIEvKgYQ==", + "dependencies": { + "@types/bson": "*", + "@types/node": "*" + } + }, "node_modules/migrate-mongoose/node_modules/ansi-escapes": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", @@ -17119,6 +17032,19 @@ "node": ">=0.10.0" } }, + "node_modules/migrate-mongoose/node_modules/bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" + }, + "node_modules/migrate-mongoose/node_modules/bson": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.6.tgz", + "integrity": "sha512-EvVNVeGo4tHxwi8L6bPj3y3itEvStdwvvlojVxxbyYfoaxJ6keLgrTuKdyfEAszFK+H3olzBuafE0yoh0D1gdg==", + "engines": { + "node": ">=0.6.19" + } + }, "node_modules/migrate-mongoose/node_modules/camelcase": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", @@ -17158,6 +17084,19 @@ "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz", "integrity": "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==" }, + "node_modules/migrate-mongoose/node_modules/debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/migrate-mongoose/node_modules/debug/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, "node_modules/migrate-mongoose/node_modules/dotenv": { "version": "8.6.0", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz", @@ -17233,6 +17172,11 @@ "node": ">=0.10.0" } }, + "node_modules/migrate-mongoose/node_modules/kareem": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.2.tgz", + "integrity": "sha512-STHz9P7X2L4Kwn72fA4rGyqyXdmrMSdxqHx9IXon/FXluXieaFA6KJ2upcHAHxQPQ0LeM/OjLrhFxifHewOALQ==" + }, "node_modules/migrate-mongoose/node_modules/mkdirp": { "version": "0.5.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", @@ -17244,6 +17188,103 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/migrate-mongoose/node_modules/mongodb": { + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.7.4.tgz", + "integrity": "sha512-K5q8aBqEXMwWdVNh94UQTwZ6BejVbFhh1uB6c5FKtPE9eUMZPUO3sRZdgIEcHSrAWmxzpG/FeODDKL388sqRmw==", + "dependencies": { + "bl": "^2.2.1", + "bson": "^1.1.4", + "denque": "^1.4.1", + "optional-require": "^1.1.8", + "safe-buffer": "^5.1.2" + }, + "engines": { + "node": ">=4" + }, + "optionalDependencies": { + "saslprep": "^1.0.0" + }, + "peerDependenciesMeta": { + "aws4": { + "optional": true + }, + "bson-ext": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "mongodb-extjson": { + "optional": true + }, + "snappy": { + "optional": true + } + } + }, + "node_modules/migrate-mongoose/node_modules/mongodb/node_modules/optional-require": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/optional-require/-/optional-require-1.1.8.tgz", + "integrity": "sha512-jq83qaUb0wNg9Krv1c5OQ+58EK+vHde6aBPzLvPPqJm89UQWsvSuFy9X/OSNJnFeSOKo7btE0n8Nl2+nE+z5nA==", + "dependencies": { + "require-at": "^1.0.6" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/migrate-mongoose/node_modules/mongoose": { + "version": "5.13.21", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.13.21.tgz", + "integrity": "sha512-EvSrXrCBogenxY131qKasFcT1Pj+9Pg5AXj17vQ8S1mOEArK3CpOx965u1wTIrdnQ7DjFC+SRwPxNcqUjMAVyQ==", + "dependencies": { + "@types/bson": "1.x || 4.0.x", + "@types/mongodb": "^3.5.27", + "bson": "^1.1.4", + "kareem": "2.3.2", + "mongodb": "3.7.4", + "mongoose-legacy-pluralize": "1.0.2", + "mpath": "0.8.4", + "mquery": "3.2.5", + "ms": "2.1.2", + "optional-require": "1.0.x", + "regexp-clone": "1.0.0", + "safe-buffer": "5.2.1", + "sift": "13.5.2", + "sliced": "1.0.1" + }, + "engines": { + "node": ">=4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mongoose" + } + }, + "node_modules/migrate-mongoose/node_modules/mquery": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.5.tgz", + "integrity": "sha512-VjOKHHgU84wij7IUoZzFRU07IAxd5kWJaDmyUzQlbjHjyoeK5TNeeo8ZsFDtTYnSgpW6n/nMNIHvE3u8Lbrf4A==", + "dependencies": { + "bluebird": "3.5.1", + "debug": "3.1.0", + "regexp-clone": "^1.0.0", + "safe-buffer": "5.1.2", + "sliced": "1.0.1" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/migrate-mongoose/node_modules/mquery/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, "node_modules/migrate-mongoose/node_modules/onetime": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", @@ -17272,6 +17313,11 @@ "once": "^1.3.0" } }, + "node_modules/migrate-mongoose/node_modules/sift": { + "version": "13.5.2", + "resolved": "https://registry.npmjs.org/sift/-/sift-13.5.2.tgz", + "integrity": "sha512-+gxdEOMA2J+AI+fVsCqeNn7Tgx3M9ZN9jdi95939l1IJ8cZsqS8sqpJyOkic2SJk+1+98Uwryt/gL6XDaV+UZA==" + }, "node_modules/migrate-mongoose/node_modules/string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -17833,27 +17879,20 @@ } }, "node_modules/mongoose": { - "version": "5.13.20", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.13.20.tgz", - "integrity": "sha512-TjGFa/XnJYt+wLmn8y9ssjyO2OhBMeEBtOHb9iJM16EWu2Du6L1Q6zSiEK2ziyYQM8agb4tumNIQFzqbxId7MA==", - "dependencies": { - "@types/bson": "1.x || 4.0.x", - "@types/mongodb": "^3.5.27", - "bson": "^1.1.4", - "kareem": "2.3.2", - "mongodb": "3.7.4", - "mongoose-legacy-pluralize": "1.0.2", - "mpath": "0.8.4", - "mquery": "3.2.5", - "ms": "2.1.2", - "optional-require": "1.0.x", - "regexp-clone": "1.0.0", - "safe-buffer": "5.2.1", - "sift": "13.5.2", - "sliced": "1.0.1" + "version": "6.12.3", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.12.3.tgz", + "integrity": "sha512-MNJymaaXali7w7rHBxVUoQ3HzHHMk/7I/+yeeoSa4rUzdjZwIWQznBNvVgc0A8ghuJwsuIkb5LyLV6gSjGjWyQ==", + "dependencies": { + "bson": "^4.7.2", + "kareem": "2.5.1", + "mongodb": "4.17.1", + "mpath": "0.9.0", + "mquery": "4.0.3", + "ms": "2.1.3", + "sift": "16.0.1" }, "engines": { - "node": ">=4.0.0" + "node": ">=12.0.0" }, "funding": { "type": "opencollective", @@ -17928,87 +17967,69 @@ "mongoose": ">= 4.4.0" } }, - "node_modules/mongoose/node_modules/@types/bson": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/@types/bson/-/bson-4.0.5.tgz", - "integrity": "sha512-vVLwMUqhYJSQ/WKcE60eFqcyuWse5fGH+NMAXHuKrUAPoryq3ATxk5o4bgYNtg5aOM4APVg7Hnb3ASqUYG0PKg==", + "node_modules/mongoose/node_modules/bson": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz", + "integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==", "dependencies": { - "@types/node": "*" + "buffer": "^5.6.0" + }, + "engines": { + "node": ">=6.9.0" } }, - "node_modules/mongoose/node_modules/@types/mongodb": { - "version": "3.6.20", - "resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.6.20.tgz", - "integrity": "sha512-WcdpPJCakFzcWWD9juKoZbRtQxKIMYF/JIAM4JrNHrMcnJL6/a2NWjXxW7fo9hxboxxkg+icff8d7+WIEvKgYQ==", + "node_modules/mongoose/node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "dependencies": { - "@types/bson": "*", - "@types/node": "*" - } - }, - "node_modules/mongoose/node_modules/bson": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.6.tgz", - "integrity": "sha512-EvVNVeGo4tHxwi8L6bPj3y3itEvStdwvvlojVxxbyYfoaxJ6keLgrTuKdyfEAszFK+H3olzBuafE0yoh0D1gdg==", - "engines": { - "node": ">=0.6.19" + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" } }, "node_modules/mongoose/node_modules/mongodb": { - "version": "3.7.4", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.7.4.tgz", - "integrity": "sha512-K5q8aBqEXMwWdVNh94UQTwZ6BejVbFhh1uB6c5FKtPE9eUMZPUO3sRZdgIEcHSrAWmxzpG/FeODDKL388sqRmw==", + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.17.1.tgz", + "integrity": "sha512-MBuyYiPUPRTqfH2dV0ya4dcr2E5N52ocBuZ8Sgg/M030nGF78v855B3Z27mZJnp8PxjnUquEnAtjOsphgMZOlQ==", "dependencies": { - "bl": "^2.2.1", - "bson": "^1.1.4", - "denque": "^1.4.1", - "optional-require": "^1.1.8", - "safe-buffer": "^5.1.2" + "bson": "^4.7.2", + "mongodb-connection-string-url": "^2.6.0", + "socks": "^2.7.1" }, "engines": { - "node": ">=4" + "node": ">=12.9.0" }, "optionalDependencies": { - "saslprep": "^1.0.0" - }, - "peerDependenciesMeta": { - "aws4": { - "optional": true - }, - "bson-ext": { - "optional": true - }, - "kerberos": { - "optional": true - }, - "mongodb-client-encryption": { - "optional": true - }, - "mongodb-extjson": { - "optional": true - }, - "snappy": { - "optional": true - } + "@aws-sdk/credential-providers": "^3.186.0", + "@mongodb-js/saslprep": "^1.1.0" } }, - "node_modules/mongoose/node_modules/mongodb/node_modules/optional-require": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/optional-require/-/optional-require-1.1.8.tgz", - "integrity": "sha512-jq83qaUb0wNg9Krv1c5OQ+58EK+vHde6aBPzLvPPqJm89UQWsvSuFy9X/OSNJnFeSOKo7btE0n8Nl2+nE+z5nA==", - "dependencies": { - "require-at": "^1.0.6" - }, + "node_modules/mongoose/node_modules/mpath": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", + "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==", "engines": { - "node": ">=4" + "node": ">=4.0.0" } }, - "node_modules/mongoose/node_modules/optional-require": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/optional-require/-/optional-require-1.0.3.tgz", - "integrity": "sha512-RV2Zp2MY2aeYK5G+B/Sps8lW5NHAzE5QClbFP15j+PWmP+T9PxlJXBOOLoSAdgwFvS4t0aMR4vpedMkbHfh0nA==", - "engines": { - "node": ">=4" - } + "node_modules/mongoose/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, "node_modules/moodle-client": { "version": "0.5.2", @@ -18175,43 +18196,16 @@ } }, "node_modules/mquery": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.5.tgz", - "integrity": "sha512-VjOKHHgU84wij7IUoZzFRU07IAxd5kWJaDmyUzQlbjHjyoeK5TNeeo8ZsFDtTYnSgpW6n/nMNIHvE3u8Lbrf4A==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-4.0.3.tgz", + "integrity": "sha512-J5heI+P08I6VJ2Ky3+33IpCdAvlYGTSUjwTPxkAr8i8EoduPMBX2OY/wa3IKZIQl7MU4SbFk8ndgSKyB/cl1zA==", "dependencies": { - "bluebird": "3.5.1", - "debug": "3.1.0", - "regexp-clone": "^1.0.0", - "safe-buffer": "5.1.2", - "sliced": "1.0.1" + "debug": "4.x" }, "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/mquery/node_modules/bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" - }, - "node_modules/mquery/node_modules/debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dependencies": { - "ms": "2.0.0" + "node": ">=12.0.0" } }, - "node_modules/mquery/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "node_modules/mquery/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, "node_modules/mri": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/mri/-/mri-1.1.4.tgz", @@ -19262,6 +19256,14 @@ "resolved": "https://registry.npmjs.org/chardet/-/chardet-1.6.0.tgz", "integrity": "sha512-+QOTw3otC4+FxdjK9RopGpNOglADbr4WPFi0SonkO99JbpkTPbMxmdm4NenhF5Zs+4gPXLI1+y2uazws5TMe8w==" }, + "node_modules/optional-require": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/optional-require/-/optional-require-1.0.3.tgz", + "integrity": "sha512-RV2Zp2MY2aeYK5G+B/Sps8lW5NHAzE5QClbFP15j+PWmP+T9PxlJXBOOLoSAdgwFvS4t0aMR4vpedMkbHfh0nA==", + "engines": { + "node": ">=4" + } + }, "node_modules/optionator": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", @@ -22401,9 +22403,9 @@ } }, "node_modules/sift": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/sift/-/sift-13.5.2.tgz", - "integrity": "sha512-+gxdEOMA2J+AI+fVsCqeNn7Tgx3M9ZN9jdi95939l1IJ8cZsqS8sqpJyOkic2SJk+1+98Uwryt/gL6XDaV+UZA==" + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/sift/-/sift-16.0.1.tgz", + "integrity": "sha512-Wv6BjQ5zbhW7VFefWusVP33T/EM0vYikCaQ2qR8yULbsilAT8/wQaXvuQ3ptGLpoKx+lihJE3y2UTgKDyyNHZQ==" }, "node_modules/signal-exit": { "version": "3.0.7", @@ -22564,7 +22566,7 @@ "node_modules/sliced": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", - "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" + "integrity": "sha512-VZBmZP8WU3sMOZm1bdgTadsQbcscK0UM8oKxKVBs4XAhUo2Xxzm/OFMGBkPusxw9xL3Uy8LrzEqGqJhclsr0yA==" }, "node_modules/smart-buffer": { "version": "4.2.0", @@ -24393,14 +24395,6 @@ "node": ">=4.2.0" } }, - "node_modules/uberproto": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/uberproto/-/uberproto-2.0.6.tgz", - "integrity": "sha512-68H97HffZoFaa3HFtpstahWorN9dSp5uTU6jo3GjIQ6JkJBR3hC2Nx/e/HFOoYHdUyT/Z1MRWfxN1EiQJZUyCQ==", - "engines": { - "node": "*" - } - }, "node_modules/uid": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/uid/-/uid-2.0.2.tgz", @@ -25835,7 +25829,6 @@ "version": "3.352.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.352.0.tgz", "integrity": "sha512-qXqg7V/DpHu8oyEq22LMskCoHYZU6+ds9gaArwc3SjPwQN/UM6CpIUHtTtxevLEYr7nI5iMIPBBrEcoKOJefxg==", - "dev": true, "optional": true, "requires": { "@aws-crypto/sha256-browser": "3.0.0", @@ -26037,7 +26030,6 @@ "version": "3.352.0", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.352.0.tgz", "integrity": "sha512-395bdedGD0pangBT6dyyrTvtDRxr3lqbi8lfuJR/+7bpMIEJKVhF5D6IAgdjRDpASDRHUPhHuWzR3Qa9RHAcNA==", - "dev": true, "optional": true, "requires": { "@aws-sdk/client-cognito-identity": "3.352.0", @@ -26193,7 +26185,6 @@ "version": "3.352.0", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-providers/-/credential-providers-3.352.0.tgz", "integrity": "sha512-hV6NO7+xzf3CPEsKZRsYflR05eNMvgVvOXFgQnOucUc85Kxt2XTSoH/HFtkolXDbxjA2Hku1pdaRG7qBzbiJHg==", - "dev": true, "optional": true, "requires": { "@aws-sdk/client-cognito-identity": "3.352.0", @@ -27581,13 +27572,6 @@ "@feathersjs/commons": "^5.0.11", "@feathersjs/errors": "^5.0.11", "@feathersjs/feathers": "^5.0.11" - }, - "dependencies": { - "@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==" - } } }, "@feathersjs/authentication": { @@ -27608,11 +27592,6 @@ "uuid": "^9.0.1" }, "dependencies": { - "@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==" - }, "@feathersjs/schema": { "version": "5.0.11", "resolved": "https://registry.npmjs.org/@feathersjs/schema/-/schema-5.0.11.tgz", @@ -27678,15 +27657,13 @@ "@feathersjs/feathers": "^5.0.11", "bcryptjs": "^2.4.3", "lodash": "^4.17.21" - }, - "dependencies": { - "@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==" - } } }, + "@feathersjs/commons": { + "version": "5.0.11", + "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", + "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==" + }, "@feathersjs/configuration": { "version": "5.0.11", "resolved": "https://registry.npmjs.org/@feathersjs/configuration/-/configuration-5.0.11.tgz", @@ -27699,11 +27676,6 @@ "config": "^3.3.9" }, "dependencies": { - "@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==" - }, "@feathersjs/schema": { "version": "5.0.11", "resolved": "https://registry.npmjs.org/@feathersjs/schema/-/schema-5.0.11.tgz", @@ -27749,13 +27721,6 @@ "compression": "^1.7.4", "cors": "^2.8.5", "express": "^4.18.2" - }, - "dependencies": { - "@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==" - } } }, "@feathersjs/feathers": { @@ -27766,13 +27731,6 @@ "@feathersjs/commons": "^5.0.11", "@feathersjs/hooks": "^0.8.1", "events": "^3.3.0" - }, - "dependencies": { - "@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==" - } } }, "@feathersjs/hooks": { @@ -27790,13 +27748,6 @@ "@feathersjs/feathers": "^5.0.11", "encodeurl": "^1.0.2", "lodash": "^4.17.21" - }, - "dependencies": { - "@feathersjs/commons": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-5.0.11.tgz", - "integrity": "sha512-szeB4WbAercNwKvC8v6lHqnh+zqKEMXYihv4M/w0yNorC7qgW9+s0nclUnxhfggO7A7QZ9YtxE79aKgal+l08Q==" - } } }, "@golevelup/nestjs-common": { @@ -28853,6 +28804,15 @@ "integrity": "sha512-TrCdPsM7DApxrK3avBbijT6/6Er4TZhtiQ+qlMqtqva13vMCG4HiF2vIWGrKJbFukkLRuhOfZlES+KZ9Y1Lx2A==", "requires": {} }, + "@mongodb-js/saslprep": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.1.tgz", + "integrity": "sha512-t7c5K033joZZMspnHg/gWPE4kandgc2OxE74aYOtGKfgB9VPuVJPix0H6fhmm2erj5PBJ21mqcx34lpIGtUCsQ==", + "optional": true, + "requires": { + "sparse-bitfield": "^3.0.3" + } + }, "@nestjs/axios": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.0.tgz", @@ -29502,6 +29462,14 @@ "@types/node": "*" } }, + "@types/bson": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@types/bson/-/bson-4.0.5.tgz", + "integrity": "sha512-vVLwMUqhYJSQ/WKcE60eFqcyuWse5fGH+NMAXHuKrUAPoryq3ATxk5o4bgYNtg5aOM4APVg7Hnb3ASqUYG0PKg==", + "requires": { + "@types/node": "*" + } + }, "@types/busboy": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@types/busboy/-/busboy-1.5.0.tgz", @@ -34435,32 +34403,6 @@ } } }, - "feathers-mongoose": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/feathers-mongoose/-/feathers-mongoose-6.3.0.tgz", - "integrity": "sha512-TjTnrAo0J9u9QqIwoRyB2XnHk8S/Ylxf6o6M+IrqRd/wBQ/AGS5NG3bu6OWdezjBMlteTRqwstdTybV3pTtX6g==", - "requires": { - "@feathersjs/commons": "^1.3.0", - "@feathersjs/errors": "^3.3.4", - "lodash.omit": "^4.5.0", - "uberproto": "^2.0.4" - }, - "dependencies": { - "@feathersjs/commons": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/@feathersjs/commons/-/commons-1.4.4.tgz", - "integrity": "sha512-ZPpzyZA3CPfoa9AuFv3BJUI/ubzaaXixp8T/pqeMFPT6DOaU/6oF7lz1RxwimzfJNna4gy/HByt0EoLSI3BKWg==" - }, - "@feathersjs/errors": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/@feathersjs/errors/-/errors-3.3.6.tgz", - "integrity": "sha512-VCohY/AQU13xYyZGl6rfdUgE+2bjaI76a4aEb6reIphHKgb4mnjYlg2PzS1/hcU1qUNi515kY9yQa5HsE7J1dQ==", - "requires": { - "debug": "^4.0.0" - } - } - } - }, "feathers-swagger": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/feathers-swagger/-/feathers-swagger-3.0.0.tgz", @@ -37623,9 +37565,9 @@ "dev": true }, "kareem": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.2.tgz", - "integrity": "sha512-STHz9P7X2L4Kwn72fA4rGyqyXdmrMSdxqHx9IXon/FXluXieaFA6KJ2upcHAHxQPQ0LeM/OjLrhFxifHewOALQ==" + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz", + "integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA==" }, "kleur": { "version": "3.0.3", @@ -37862,11 +37804,6 @@ "integrity": "sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==", "dev": true }, - "lodash.omit": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.omit/-/lodash.omit-4.5.0.tgz", - "integrity": "sha1-brGa5aHuHdnfC5aeZs4Lf6MLXmA=" - }, "lodash.once": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", @@ -38277,6 +38214,15 @@ "yargs": "^4.8.1" }, "dependencies": { + "@types/mongodb": { + "version": "3.6.20", + "resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.6.20.tgz", + "integrity": "sha512-WcdpPJCakFzcWWD9juKoZbRtQxKIMYF/JIAM4JrNHrMcnJL6/a2NWjXxW7fo9hxboxxkg+icff8d7+WIEvKgYQ==", + "requires": { + "@types/bson": "*", + "@types/node": "*" + } + }, "ansi-escapes": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", @@ -38292,6 +38238,16 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" + }, + "bson": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.6.tgz", + "integrity": "sha512-EvVNVeGo4tHxwi8L6bPj3y3itEvStdwvvlojVxxbyYfoaxJ6keLgrTuKdyfEAszFK+H3olzBuafE0yoh0D1gdg==" + }, "camelcase": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", @@ -38322,6 +38278,21 @@ "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz", "integrity": "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==" }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + }, + "dependencies": { + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + } + } + }, "dotenv": { "version": "8.6.0", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz", @@ -38382,6 +38353,11 @@ "number-is-nan": "^1.0.0" } }, + "kareem": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.2.tgz", + "integrity": "sha512-STHz9P7X2L4Kwn72fA4rGyqyXdmrMSdxqHx9IXon/FXluXieaFA6KJ2upcHAHxQPQ0LeM/OjLrhFxifHewOALQ==" + }, "mkdirp": { "version": "0.5.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", @@ -38390,6 +38366,69 @@ "minimist": "^1.2.5" } }, + "mongodb": { + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.7.4.tgz", + "integrity": "sha512-K5q8aBqEXMwWdVNh94UQTwZ6BejVbFhh1uB6c5FKtPE9eUMZPUO3sRZdgIEcHSrAWmxzpG/FeODDKL388sqRmw==", + "requires": { + "bl": "^2.2.1", + "bson": "^1.1.4", + "denque": "^1.4.1", + "optional-require": "^1.1.8", + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" + }, + "dependencies": { + "optional-require": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/optional-require/-/optional-require-1.1.8.tgz", + "integrity": "sha512-jq83qaUb0wNg9Krv1c5OQ+58EK+vHde6aBPzLvPPqJm89UQWsvSuFy9X/OSNJnFeSOKo7btE0n8Nl2+nE+z5nA==", + "requires": { + "require-at": "^1.0.6" + } + } + } + }, + "mongoose": { + "version": "5.13.21", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.13.21.tgz", + "integrity": "sha512-EvSrXrCBogenxY131qKasFcT1Pj+9Pg5AXj17vQ8S1mOEArK3CpOx965u1wTIrdnQ7DjFC+SRwPxNcqUjMAVyQ==", + "requires": { + "@types/bson": "1.x || 4.0.x", + "@types/mongodb": "^3.5.27", + "bson": "^1.1.4", + "kareem": "2.3.2", + "mongodb": "3.7.4", + "mongoose-legacy-pluralize": "1.0.2", + "mpath": "0.8.4", + "mquery": "3.2.5", + "ms": "2.1.2", + "optional-require": "1.0.x", + "regexp-clone": "1.0.0", + "safe-buffer": "5.2.1", + "sift": "13.5.2", + "sliced": "1.0.1" + } + }, + "mquery": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.5.tgz", + "integrity": "sha512-VjOKHHgU84wij7IUoZzFRU07IAxd5kWJaDmyUzQlbjHjyoeK5TNeeo8ZsFDtTYnSgpW6n/nMNIHvE3u8Lbrf4A==", + "requires": { + "bluebird": "3.5.1", + "debug": "3.1.0", + "regexp-clone": "^1.0.0", + "safe-buffer": "5.1.2", + "sliced": "1.0.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, "onetime": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", @@ -38412,6 +38451,11 @@ "once": "^1.3.0" } }, + "sift": { + "version": "13.5.2", + "resolved": "https://registry.npmjs.org/sift/-/sift-13.5.2.tgz", + "integrity": "sha512-+gxdEOMA2J+AI+fVsCqeNn7Tgx3M9ZN9jdi95939l1IJ8cZsqS8sqpJyOkic2SJk+1+98Uwryt/gL6XDaV+UZA==" + }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -38831,75 +38875,57 @@ "integrity": "sha1-D3ca0W9IOuZfQoeWlCjp+8SqYYE=" }, "mongoose": { - "version": "5.13.20", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.13.20.tgz", - "integrity": "sha512-TjGFa/XnJYt+wLmn8y9ssjyO2OhBMeEBtOHb9iJM16EWu2Du6L1Q6zSiEK2ziyYQM8agb4tumNIQFzqbxId7MA==", - "requires": { - "@types/bson": "1.x || 4.0.x", - "@types/mongodb": "^3.5.27", - "bson": "^1.1.4", - "kareem": "2.3.2", - "mongodb": "3.7.4", - "mongoose-legacy-pluralize": "1.0.2", - "mpath": "0.8.4", - "mquery": "3.2.5", - "ms": "2.1.2", - "optional-require": "1.0.x", - "regexp-clone": "1.0.0", - "safe-buffer": "5.2.1", - "sift": "13.5.2", - "sliced": "1.0.1" + "version": "6.12.3", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.12.3.tgz", + "integrity": "sha512-MNJymaaXali7w7rHBxVUoQ3HzHHMk/7I/+yeeoSa4rUzdjZwIWQznBNvVgc0A8ghuJwsuIkb5LyLV6gSjGjWyQ==", + "requires": { + "bson": "^4.7.2", + "kareem": "2.5.1", + "mongodb": "4.17.1", + "mpath": "0.9.0", + "mquery": "4.0.3", + "ms": "2.1.3", + "sift": "16.0.1" }, "dependencies": { - "@types/bson": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/@types/bson/-/bson-4.0.5.tgz", - "integrity": "sha512-vVLwMUqhYJSQ/WKcE60eFqcyuWse5fGH+NMAXHuKrUAPoryq3ATxk5o4bgYNtg5aOM4APVg7Hnb3ASqUYG0PKg==", + "bson": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz", + "integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==", "requires": { - "@types/node": "*" + "buffer": "^5.6.0" } }, - "@types/mongodb": { - "version": "3.6.20", - "resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.6.20.tgz", - "integrity": "sha512-WcdpPJCakFzcWWD9juKoZbRtQxKIMYF/JIAM4JrNHrMcnJL6/a2NWjXxW7fo9hxboxxkg+icff8d7+WIEvKgYQ==", + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", "requires": { - "@types/bson": "*", - "@types/node": "*" + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" } }, - "bson": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.6.tgz", - "integrity": "sha512-EvVNVeGo4tHxwi8L6bPj3y3itEvStdwvvlojVxxbyYfoaxJ6keLgrTuKdyfEAszFK+H3olzBuafE0yoh0D1gdg==" - }, "mongodb": { - "version": "3.7.4", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.7.4.tgz", - "integrity": "sha512-K5q8aBqEXMwWdVNh94UQTwZ6BejVbFhh1uB6c5FKtPE9eUMZPUO3sRZdgIEcHSrAWmxzpG/FeODDKL388sqRmw==", + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.17.1.tgz", + "integrity": "sha512-MBuyYiPUPRTqfH2dV0ya4dcr2E5N52ocBuZ8Sgg/M030nGF78v855B3Z27mZJnp8PxjnUquEnAtjOsphgMZOlQ==", "requires": { - "bl": "^2.2.1", - "bson": "^1.1.4", - "denque": "^1.4.1", - "optional-require": "^1.1.8", - "safe-buffer": "^5.1.2", - "saslprep": "^1.0.0" - }, - "dependencies": { - "optional-require": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/optional-require/-/optional-require-1.1.8.tgz", - "integrity": "sha512-jq83qaUb0wNg9Krv1c5OQ+58EK+vHde6aBPzLvPPqJm89UQWsvSuFy9X/OSNJnFeSOKo7btE0n8Nl2+nE+z5nA==", - "requires": { - "require-at": "^1.0.6" - } - } + "@aws-sdk/credential-providers": "^3.186.0", + "@mongodb-js/saslprep": "^1.1.0", + "bson": "^4.7.2", + "mongodb-connection-string-url": "^2.6.0", + "socks": "^2.7.1" } }, - "optional-require": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/optional-require/-/optional-require-1.0.3.tgz", - "integrity": "sha512-RV2Zp2MY2aeYK5G+B/Sps8lW5NHAzE5QClbFP15j+PWmP+T9PxlJXBOOLoSAdgwFvS4t0aMR4vpedMkbHfh0nA==" + "mpath": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", + "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==" + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" } } }, @@ -39094,40 +39120,11 @@ } }, "mquery": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.5.tgz", - "integrity": "sha512-VjOKHHgU84wij7IUoZzFRU07IAxd5kWJaDmyUzQlbjHjyoeK5TNeeo8ZsFDtTYnSgpW6n/nMNIHvE3u8Lbrf4A==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-4.0.3.tgz", + "integrity": "sha512-J5heI+P08I6VJ2Ky3+33IpCdAvlYGTSUjwTPxkAr8i8EoduPMBX2OY/wa3IKZIQl7MU4SbFk8ndgSKyB/cl1zA==", "requires": { - "bluebird": "3.5.1", - "debug": "3.1.0", - "regexp-clone": "^1.0.0", - "safe-buffer": "5.1.2", - "sliced": "1.0.1" - }, - "dependencies": { - "bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - } + "debug": "4.x" } }, "mri": { @@ -39973,6 +39970,11 @@ } } }, + "optional-require": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/optional-require/-/optional-require-1.0.3.tgz", + "integrity": "sha512-RV2Zp2MY2aeYK5G+B/Sps8lW5NHAzE5QClbFP15j+PWmP+T9PxlJXBOOLoSAdgwFvS4t0aMR4vpedMkbHfh0nA==" + }, "optionator": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", @@ -42311,9 +42313,9 @@ } }, "sift": { - "version": "13.5.2", - "resolved": "https://registry.npmjs.org/sift/-/sift-13.5.2.tgz", - "integrity": "sha512-+gxdEOMA2J+AI+fVsCqeNn7Tgx3M9ZN9jdi95939l1IJ8cZsqS8sqpJyOkic2SJk+1+98Uwryt/gL6XDaV+UZA==" + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/sift/-/sift-16.0.1.tgz", + "integrity": "sha512-Wv6BjQ5zbhW7VFefWusVP33T/EM0vYikCaQ2qR8yULbsilAT8/wQaXvuQ3ptGLpoKx+lihJE3y2UTgKDyyNHZQ==" }, "signal-exit": { "version": "3.0.7", @@ -42448,7 +42450,7 @@ "sliced": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", - "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" + "integrity": "sha512-VZBmZP8WU3sMOZm1bdgTadsQbcscK0UM8oKxKVBs4XAhUo2Xxzm/OFMGBkPusxw9xL3Uy8LrzEqGqJhclsr0yA==" }, "smart-buffer": { "version": "4.2.0", @@ -43826,11 +43828,6 @@ "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true }, - "uberproto": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/uberproto/-/uberproto-2.0.6.tgz", - "integrity": "sha512-68H97HffZoFaa3HFtpstahWorN9dSp5uTU6jo3GjIQ6JkJBR3hC2Nx/e/HFOoYHdUyT/Z1MRWfxN1EiQJZUyCQ==" - }, "uid": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/uid/-/uid-2.0.2.tgz", diff --git a/package.json b/package.json index 679361a3dbd..42be7f9a9cb 100644 --- a/package.json +++ b/package.json @@ -95,8 +95,10 @@ }, "dependencies": { "@aws-sdk/lib-storage": "^3.100.0", + "@feathersjs/adapter-commons": "^5.0.11", "@feathersjs/authentication": "^5.0.11", "@feathersjs/authentication-local": "^5.0.11", + "@feathersjs/commons": "^5.0.11", "@feathersjs/configuration": "^5.0.11", "@feathersjs/errors": "^5.0.11", "@feathersjs/express": "^5.0.11", @@ -161,7 +163,6 @@ "express-openapi-validator": "^4.13.2", "express-session": "^1.17.3", "feathers-hooks-common": "^8.1.1", - "feathers-mongoose": "^6.3.0", "feathers-swagger": "^3.0.0", "file-type": "^18.5.0", "freeport": "^1.0.5", @@ -178,7 +179,7 @@ "mixwith": "^0.1.1", "moment": "^2.19.2", "mongodb-uri": "^0.9.7", - "mongoose": "^5.13.20", + "mongoose": "^6.5.4", "mongoose-delete": "^0.5.4", "mongoose-id-validator": "^0.6.0", "mongoose-lean-virtuals": "^0.8.1", diff --git a/src/components/helper/repo.helper.js b/src/components/helper/repo.helper.js index 92c4521ff2c..02061e26073 100644 --- a/src/components/helper/repo.helper.js +++ b/src/components/helper/repo.helper.js @@ -1,17 +1,21 @@ const { error } = require('../../logger'); /** - * Converts an mongoose update many result to an internal TO + * TODO Check this https://mongoosejs.com/docs/6.x/docs/api/query.html#query_Query-updateMany + * the given example references nModified, so why must we change it to modifiedCount? + * + * + * * Converts an mongoose update many result to an internal TO * @param {*} param0 * @param {1|0} param0.ok 0 for error * @param {Integer} param0.n Number of elements matched the given filter - * @param {Integer} param0.nModified Number of elements updated + * @param {Integer} param0.modifiedCount Number of elements updated */ -const updateManyResult = ({ ok, n, nModified }) => { +const updateManyResult = ({ ok, n, modifiedCount }) => { if (ok !== 1) { - error('mongoose updateMany has failed', { ok, n, nModified }); + error('mongoose updateMany has failed', { ok, n, modifiedCount }); } - return { success: ok === 1, modifiedDocuments: nModified }; + return { success: ok === 1, modifiedDocuments: modifiedCount }; }; /** diff --git a/src/services/activation/services/ActivationModelService.js b/src/services/activation/services/ActivationModelService.js index 37bfaec2781..7efe9ac0fa0 100644 --- a/src/services/activation/services/ActivationModelService.js +++ b/src/services/activation/services/ActivationModelService.js @@ -1,4 +1,4 @@ -const feathersMongooseService = require('feathers-mongoose'); +const feathersMongooseService = require('../../../utils/feathers-mongoose'); const auth = require('@feathersjs/authentication'); const { iff, isProvider, disallow } = require('feathers-hooks-common'); const { activationModel } = require('../model'); diff --git a/src/services/base64Files/index.js b/src/services/base64Files/index.js index 7a5897daff1..f0673140a0b 100644 --- a/src/services/base64Files/index.js +++ b/src/services/base64Files/index.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); diff --git a/src/services/consent/index.js b/src/services/consent/index.js index dcd4c5a8433..4ab900242fc 100644 --- a/src/services/consent/index.js +++ b/src/services/consent/index.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); diff --git a/src/services/content/index.js b/src/services/content/index.js index c05741f58b3..b78c93b07a8 100644 --- a/src/services/content/index.js +++ b/src/services/content/index.js @@ -1,5 +1,5 @@ // eslint-disable-next-line max-classes-per-file -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); const material = require('./material-model'); diff --git a/src/services/datasources/services/datasources.js b/src/services/datasources/services/datasources.js index b29c0670ab1..a3600b66815 100644 --- a/src/services/datasources/services/datasources.js +++ b/src/services/datasources/services/datasources.js @@ -1,5 +1,5 @@ const Ajv = require('ajv'); -const service = require('feathers-mongoose'); +const service = require('../../../utils/feathers-mongoose'); const { authenticate } = require('@feathersjs/authentication'); const { iff, isProvider, validateSchema, disallow } = require('feathers-hooks-common'); const { datasourceModel } = require('../model'); diff --git a/src/services/federalState/index.js b/src/services/federalState/index.js index a66242f1b8d..79008b44fb4 100644 --- a/src/services/federalState/index.js +++ b/src/services/federalState/index.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); diff --git a/src/services/fileStorage/model-service.js b/src/services/fileStorage/model-service.js index 9281a5fcac2..3a79dd12c65 100644 --- a/src/services/fileStorage/model-service.js +++ b/src/services/fileStorage/model-service.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { FileModel } = require('./model'); const hooks = require('./hooks/model-hooks'); diff --git a/src/services/helpdesk/index.js b/src/services/helpdesk/index.js index d75f8dc5e0f..60d9eea5108 100644 --- a/src/services/helpdesk/index.js +++ b/src/services/helpdesk/index.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); @@ -9,7 +9,11 @@ const { BODYPARSER_JSON_LIMIT, MAXIMUM_ALLOWABLE_TOTAL_ATTACHMENTS_SIZE_BYTE } = if (BODYPARSER_JSON_LIMIT === undefined) { /* eslint-disable-next-line */ - logger.warning(`please set the environment variable BODYPARSER_JSON_LIMIT to min. '${Math.ceil(1.36*(MAXIMUM_ALLOWABLE_TOTAL_ATTACHMENTS_SIZE_BYTE/1024/1024))}mb' for helpdesk to work correctly! (Currently: ${BODYPARSER_JSON_LIMIT})`); + logger.warning( + `please set the environment variable BODYPARSER_JSON_LIMIT to min. '${Math.ceil( + 1.36 * (MAXIMUM_ALLOWABLE_TOTAL_ATTACHMENTS_SIZE_BYTE / 1024 / 1024) + )}mb' for helpdesk to work correctly! (Currently: ${BODYPARSER_JSON_LIMIT})` + ); } module.exports = function () { diff --git a/src/services/homework/model-service.js b/src/services/homework/model-service.js index a0a8c84a966..d4de4a34427 100644 --- a/src/services/homework/model-service.js +++ b/src/services/homework/model-service.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { homeworkModel, submissionModel } = require('./model'); const hooks = require('./hooks'); const submissionHooks = require('./hooks/submissions'); diff --git a/src/services/lesson/index.js b/src/services/lesson/index.js index 752e743d852..048afe8359e 100644 --- a/src/services/lesson/index.js +++ b/src/services/lesson/index.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); diff --git a/src/services/link/index.js b/src/services/link/index.js index 38e78a10a5a..3a4263d3295 100644 --- a/src/services/link/index.js +++ b/src/services/link/index.js @@ -1,7 +1,7 @@ /* eslint-disable max-classes-per-file */ const { Configuration } = require('@hpi-schul-cloud/commons'); const queryString = require('qs'); -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); const { BadRequest } = require('@feathersjs/errors'); diff --git a/src/services/ltiTool/index.js b/src/services/ltiTool/index.js index 37c870c7b14..db48d0d7c10 100644 --- a/src/services/ltiTool/index.js +++ b/src/services/ltiTool/index.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { authenticate } = require('@feathersjs/authentication'); const fs = require('fs'); const jwt = require('jsonwebtoken'); diff --git a/src/services/news/index.js b/src/services/news/index.js index 35c851b9f80..629a51d796a 100644 --- a/src/services/news/index.js +++ b/src/services/news/index.js @@ -4,7 +4,7 @@ * The public API has been moved to apps/server/src/modules/news */ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { newsModel } = require('./model'); const newsModelHooks = require('./hooks/newsModel.hooks'); diff --git a/src/services/pseudonym/index.js b/src/services/pseudonym/index.js index c0a977a2752..e8a40ad302d 100644 --- a/src/services/pseudonym/index.js +++ b/src/services/pseudonym/index.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); diff --git a/src/services/releases/index.js b/src/services/releases/index.js index d6b931d77c2..81df3d14343 100644 --- a/src/services/releases/index.js +++ b/src/services/releases/index.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const request = require('request-promise-native'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); diff --git a/src/services/role/index.js b/src/services/role/index.js index 971c2486619..2e5d1b94da4 100644 --- a/src/services/role/index.js +++ b/src/services/role/index.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); diff --git a/src/services/school/index.js b/src/services/school/index.js index 24e626af831..b897ce13440 100644 --- a/src/services/school/index.js +++ b/src/services/school/index.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { Configuration } = require('@hpi-schul-cloud/commons'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); diff --git a/src/services/serviceTemplate/services/modelService.js b/src/services/serviceTemplate/services/modelService.js index 804c76cfa7a..a7f8e0297da 100644 --- a/src/services/serviceTemplate/services/modelService.js +++ b/src/services/serviceTemplate/services/modelService.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../../utils/feathers-mongoose'); const Ajv = require('ajv'); const auth = require('@feathersjs/authentication'); const { iff, isProvider, validateSchema, disallow } = require('feathers-hooks-common'); diff --git a/src/services/storageProvider/index.js b/src/services/storageProvider/index.js index d5e59683324..aa362c2f6a3 100644 --- a/src/services/storageProvider/index.js +++ b/src/services/storageProvider/index.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); diff --git a/src/services/system/index.js b/src/services/system/index.js index cf4970f7b51..e59dc795ce3 100644 --- a/src/services/system/index.js +++ b/src/services/system/index.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); diff --git a/src/services/teams/index.js b/src/services/teams/index.js index e26b26cbaf4..693b7c37a90 100644 --- a/src/services/teams/index.js +++ b/src/services/teams/index.js @@ -1,5 +1,5 @@ // eslint-disable-next-line max-classes-per-file -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { Configuration } = require('@hpi-schul-cloud/commons'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); diff --git a/src/services/teams/model.js b/src/services/teams/model.js index c433f299842..1d56a0bdb9a 100644 --- a/src/services/teams/model.js +++ b/src/services/teams/model.js @@ -51,6 +51,8 @@ const teamsSchema = getUserGroupSchema({ color: { type: String, default: '#ACACAC' }, features: [{ type: String, enum: Object.values(TEAM_FEATURES) }], filePermission: [permissionSchema], + // https://mongoosejs.com/docs/migrating_to_6.html#strictpopulate + ltiToolIds: [{ type: Schema.Types.ObjectId, required: true, ref: 'ltiTool' }], }); /* diff --git a/src/services/user-group/hooks/courses.js b/src/services/user-group/hooks/courses.js index 92a5b987a7c..62c1121a0db 100644 --- a/src/services/user-group/hooks/courses.js +++ b/src/services/user-group/hooks/courses.js @@ -1,6 +1,6 @@ const _ = require('lodash'); const { Configuration } = require('@hpi-schul-cloud/commons/lib'); -const { service } = require('feathers-mongoose'); +const { service } = require('../../../utils/feathers-mongoose'); const { BadRequest } = require('../../../errors'); const globalHooks = require('../../../hooks'); diff --git a/src/services/user-group/services/classModelService.js b/src/services/user-group/services/classModelService.js index 3a4aa5c96f3..96fa7cbb34d 100644 --- a/src/services/user-group/services/classModelService.js +++ b/src/services/user-group/services/classModelService.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../../utils/feathers-mongoose'); const { iff, isProvider, disallow } = require('feathers-hooks-common'); const auth = require('@feathersjs/authentication'); diff --git a/src/services/user-group/services/courseGroupModelService.js b/src/services/user-group/services/courseGroupModelService.js index 81ab7697b78..454cc3690f5 100644 --- a/src/services/user-group/services/courseGroupModelService.js +++ b/src/services/user-group/services/courseGroupModelService.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../../utils/feathers-mongoose'); const { iff, isProvider, disallow } = require('feathers-hooks-common'); const auth = require('@feathersjs/authentication'); diff --git a/src/services/user-group/services/courseModelService.js b/src/services/user-group/services/courseModelService.js index e8ede1e5243..4c8a35ae248 100644 --- a/src/services/user-group/services/courseModelService.js +++ b/src/services/user-group/services/courseModelService.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../../utils/feathers-mongoose'); const { iff, isProvider, disallow } = require('feathers-hooks-common'); const auth = require('@feathersjs/authentication'); diff --git a/src/services/user/index.js b/src/services/user/index.js index 4a56589e573..bef4f3234a5 100644 --- a/src/services/user/index.js +++ b/src/services/user/index.js @@ -1,5 +1,5 @@ const hooks = require('feathers-hooks-common'); -const service = require('feathers-mongoose'); +const service = require('../../utils/feathers-mongoose'); const { static: staticContent } = require('@feathersjs/express'); const path = require('path'); diff --git a/src/services/user/services/UsersModelService.js b/src/services/user/services/UsersModelService.js index 55fae6a34a1..51024b949bf 100644 --- a/src/services/user/services/UsersModelService.js +++ b/src/services/user/services/UsersModelService.js @@ -1,6 +1,6 @@ -const feathersMongooseService = require('feathers-mongoose'); const auth = require('@feathersjs/authentication'); const { iff, isProvider, disallow } = require('feathers-hooks-common'); +const feathersMongooseService = require('../../../utils/feathers-mongoose'); const { userModel } = require('../model'); const { addDates: addConsentDate } = require('../hooks/consent'); const { enableQuery, enableQueryAfter, resolveToIds } = require('../../../hooks'); diff --git a/src/services/webuntis/services/webuntisMetadata.js b/src/services/webuntis/services/webuntisMetadata.js index b5ec308709d..a2e72cc146f 100644 --- a/src/services/webuntis/services/webuntisMetadata.js +++ b/src/services/webuntis/services/webuntisMetadata.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../../utils/feathers-mongoose'); // const Ajv = require('ajv'); const auth = require('@feathersjs/authentication'); const { iff, isProvider, /* validateSchema, */ disallow } = require('feathers-hooks-common'); diff --git a/src/utils/database.js b/src/utils/database.js index d7a4cca56ba..552389821e4 100644 --- a/src/utils/database.js +++ b/src/utils/database.js @@ -88,11 +88,8 @@ function connect() { const mongooseOptions = { autoIndex: NODE_ENV !== ENVIRONMENTS.PRODUCTION, - poolSize: MONGOOSE_CONNECTION_POOL_SIZE, + minPoolSize: MONGOOSE_CONNECTION_POOL_SIZE, //https://mongoosejs.com/docs/migrating_to_6.html#mongodb-driver-40 ?? useNewUrlParser: true, - useFindAndModify: false, - useCreateIndex: true, - useUnifiedTopology: true, }; addAuthenticationToMongooseOptions(options.username, options.password, mongooseOptions); diff --git a/src/utils/feathers-mongoose/error-handler.js b/src/utils/feathers-mongoose/error-handler.js new file mode 100644 index 00000000000..013da28ac88 --- /dev/null +++ b/src/utils/feathers-mongoose/error-handler.js @@ -0,0 +1,53 @@ +const errors = require('@feathersjs/errors'); + +const ERROR = Symbol('feathers-mongoose/error'); + +const wrap = (error, original) => Object.assign(error, { [ERROR]: original }); + +exports.ERROR = ERROR; + +exports.errorHandler = (error) => { + if (error.code === 11000 || error.code === 11001) { + // NOTE (EK): Error parsing as discussed in this github thread + // https://github.com/Automattic/mongoose/issues/2129 + const match1 = error.message.match(/_?([a-zA-Z]*)_?\d?\s*dup key/i); + const match2 = error.message.match(/\s*dup key:\s*\{\s*:\s*"?(.*?)"?\s*\}/i); + + const key = match1 ? match1[1] : 'path'; + let value = match2 ? match2[1] : 'value'; + + if (value === 'null') { + value = null; + } else if (value === 'undefined') { + value = undefined; + } + + error.message = `${key}: ${value} already exists.`; + error.errors = { + [key]: value, + }; + + return Promise.reject(wrap(new errors.Conflict(error), error)); + } + + if (error.name) { + switch (error.name) { + case 'ValidationError': + case 'ValidatorError': + case 'CastError': + case 'VersionError': + return Promise.reject(wrap(new errors.BadRequest(error), error)); + case 'OverwriteModelError': + return Promise.reject(wrap(new errors.Conflict(error), error)); + case 'MissingSchemaError': + case 'DivergentArrayError': + return Promise.reject(wrap(new errors.GeneralError(error), error)); + case 'MongoError': + return Promise.reject(wrap(new errors.GeneralError(error), error)); + default: + return Promise.reject(wrap(new errors.GeneralError(error), error)); + } + } + + return Promise.reject(error); +}; diff --git a/src/utils/feathers-mongoose/hooks.js b/src/utils/feathers-mongoose/hooks.js new file mode 100644 index 00000000000..2c6367a9f61 --- /dev/null +++ b/src/utils/feathers-mongoose/hooks.js @@ -0,0 +1,31 @@ +exports.toObject = + (options = {}, dataField = 'data') => + (hook) => { + // Only perform this if it's used as an after hook. + if (hook.result) { + const data = hook.result[dataField] || hook.result; + let res; + + // Handle multiple mongoose models + if (Array.isArray(data)) { + res = data.map((obj) => { + if (typeof obj.toObject === 'function') { + return obj.toObject(options); + } + + return obj; + }); + } else if (typeof data.toObject === 'function') { + // Handle single mongoose models + res = data.toObject(options); + } + // If our data is transformed set it to appropriate location on the hook + if (res) { + if (hook.result[dataField]) { + hook.result[dataField] = res; + } else { + hook.result = res; + } + } + } + }; diff --git a/src/utils/feathers-mongoose/index.js b/src/utils/feathers-mongoose/index.js new file mode 100644 index 00000000000..4ab5b01461f --- /dev/null +++ b/src/utils/feathers-mongoose/index.js @@ -0,0 +1,6 @@ +const hooks = require('./hooks'); +const service = require('./service'); + +Object.assign(service, { hooks, service }); + +module.exports = service; diff --git a/src/utils/feathers-mongoose/service.js b/src/utils/feathers-mongoose/service.js new file mode 100644 index 00000000000..0a08d17fe02 --- /dev/null +++ b/src/utils/feathers-mongoose/service.js @@ -0,0 +1,471 @@ +/* eslint-disable promise/no-nesting */ +/* eslint-disable no-param-reassign */ +/* eslint-disable no-shadow */ +/* eslint-disable no-underscore-dangle */ +/* +This is a port of the deprecated feathers-mongoose module to work with the new feathers version 5. +Codebase clone from https://github.com/feathersjs-ecosystem/feathers-mongoose +*/ + +const { _ } = require('@feathersjs/commons'); +const { AdapterBase, select, getLimit } = require('@feathersjs/adapter-commons'); +const errors = require('@feathersjs/errors'); +const { ObjectId } = require('bson'); + +const { ERROR, errorHandler } = require('./error-handler'); + +// Create the service. +class Service extends AdapterBase { + constructor(options) { + if (!options.Model || !options.Model.modelName) { + throw new Error('You must provide a Mongoose Model'); + } + + const { whitelist = ['$regex', '$populate', '$exists', '$elemMatch'] } = options; + + super({ + id: '_id', + filters: { + $populate(value) { + return value; + }, + ...options.filters, + }, + queryModifierKey: 'queryModifier', + ...options, + whitelist: whitelist.concat('$and'), + }); + + this.discriminatorKey = this.Model.schema.options.discriminatorKey; + this.discriminators = {}; + (options.discriminators || []).forEach((element) => { + if (element.modelName) { + this.discriminators[element.modelName] = element; + } + }); + this.lean = options.lean === undefined ? true : options.lean; + this.overwrite = options.overwrite !== false; + this.useEstimatedDocumentCount = !!options.useEstimatedDocumentCount; + } + + get Model() { + return this.options.Model; + } + + _getQueryModifier(params) { + if (typeof params[this.options.queryModifierKey] === 'function') { + return params[this.options.queryModifierKey]; + } + if (params[this.options.queryModifierKey] !== false) { + if (typeof this.options.queryModifier === 'function') { + return this.options.queryModifier; + } + } + return () => {}; + } + + _getOrFind(id, params = {}) { + if (id === null) { + return this._find(params); + } + + return this._get(id, params); + } + + _find(params = {}) { + const { filters, query } = this.filterQuery(params); + const { paginate } = this.getOptions(params); + const discriminator = (params.query || {})[this.discriminatorKey] || this.discriminatorKey; + const model = this.discriminators[discriminator] || this.Model; + const q = model.find(query).lean(this.lean); + + // $select uses a specific find syntax, so it has to come first. + if (Array.isArray(filters.$select)) { + q.select( + filters.$select.reduce( + (res, key) => + Object.assign(res, { + [key]: 1, + }), + {} + ) + ); + } else if (typeof filters.$select === 'string' || typeof filters.$select === 'object') { + q.select(filters.$select); + } + + // Handle $sort + if (filters.$sort) { + q.sort(filters.$sort); + } + + // Handle collation + if (params.collation) { + q.collation(params.collation); + } + + // Handle $limit + if (typeof filters.$limit !== 'undefined') { + q.limit(filters.$limit); + } + + // Handle $skip + if (filters.$skip) { + q.skip(filters.$skip); + } + + // Handle $populate + if (filters.$populate && this.options.whitelist.includes('$populate')) { + q.populate(filters.$populate); + } + + this._getQueryModifier(params)(q, params); + + let executeQuery = (total) => + q + .session(params.mongoose && params.mongoose.session) + .exec() + .then((data) => { + return { + total, + limit: filters.$limit, + skip: filters.$skip || 0, + data, + }; + }); + + if (filters.$limit === 0) { + executeQuery = (total) => + Promise.resolve({ + total, + limit: filters.$limit, + skip: filters.$skip || 0, + data: [], + }); + } + + if (paginate && paginate.default) { + return model + .where(query) + [this.useEstimatedDocumentCount ? 'estimatedDocumentCount' : 'countDocuments']() + .session(params.mongoose && params.mongoose.session) + .exec() + .then(executeQuery); + } + + return executeQuery().then((page) => page.data); + } + + _get(id, params = {}) { + const { query, filters } = this.filterQuery(params); + + query.$and = (query.$and || []).concat([{ [this.id]: id }]); + + const discriminator = query[this.discriminatorKey] || this.discriminatorKey; + const model = this.discriminators[discriminator] || this.Model; + let modelQuery = model.findOne(query); + + // Handle $populate + if (filters.$populate && this.options.whitelist.includes('$populate')) { + modelQuery = modelQuery.populate(filters.$populate); + } + + // Handle $select + if (filters.$select && filters.$select.length) { + const fields = { [this.id]: 1 }; + + for (const key of filters.$select) { + fields[key] = 1; + } + + modelQuery.select(fields); + } else if (filters.$select && typeof filters.$select === 'object') { + modelQuery.select(filters.$select); + } + + this._getQueryModifier(params)(modelQuery, params); + + return modelQuery + .session(params.mongoose && params.mongoose.session) + .lean(this.lean) + .exec() + .then((data) => { + if (!data) { + throw new errors.NotFound(`No record found for id '${id}'`); + } + + return data; + }) + .catch(errorHandler); + } + + _create(_data, params = {}) { + const discriminator = (params.query || {})[this.discriminatorKey] || this.discriminatorKey; + const model = this.discriminators[discriminator] || this.Model; + const { query: { $populate } = {} } = params; + const isMulti = Array.isArray(_data); + const data = isMulti ? _data : [_data]; + + return model + .create(data, params.mongoose) + .then((results) => { + if (results === undefined) { + return []; + } + if ($populate && this.options.whitelist.includes('$populate')) { + return Promise.all(results.map((result) => this.Model.populate(result, $populate))); + } + + return results; + }) + .then((results) => { + if (this.lean) { + results = results.map((item) => (item.toObject ? item.toObject() : item)); + } + + return isMulti ? results : results[0]; + }) + .then(select(params, this.id)) + .catch(errorHandler); + } + + _update(id, data, params = {}) { + if (id === null) { + return Promise.reject(new errors.BadRequest('Not replacing multiple records. Did you mean `patch`?')); + } + + // Handle case where data might be a mongoose model + if (typeof data.toObject === 'function') { + data = data.toObject(); + } + + const { query, filters } = this.filterQuery(params); + const options = { + new: true, + overwrite: this.overwrite, + runValidators: true, + context: 'query', + setDefaultsOnInsert: true, + ...params.mongoose, + }; + + query.$and = (query.$and || []).concat({ [this.id]: id }); + + if (this.id === '_id') { + // We can not update default mongo ids + data = _.omit(data, this.id); + } else { + // If not using the default Mongo _id field set the id to its + // previous value. This prevents orphaned documents. + data = { ...data, [this.id]: id }; + } + + const discriminator = query[this.discriminatorKey] || this.discriminatorKey; + const model = this.discriminators[discriminator] || this.Model; + let modelQuery = model.findOneAndUpdate(query, data, options); + + if (filters.$populate && this.options.whitelist.includes('$populate')) { + modelQuery = modelQuery.populate(filters.$populate); + } + + return modelQuery + .lean(this.lean) + .exec() + .then((result) => { + if (result === null) { + throw new errors.NotFound(`No record found for id '${id}'`); + } + + return result; + }) + .then(select(params, this.id)) + .catch(errorHandler); + } + + _patch(id, data, params = {}) { + const { query } = this.filterQuery(params); + const mapIds = (data) => (Array.isArray(data) ? data.map((current) => current[this.id]) : [data[this.id]]); + + // By default we will just query for the one id. For multi patch + // we create a list of the ids of all items that will be changed + // to re-query them after the update + const ids = this._getOrFind(id, { ...params, paginate: false }).then(mapIds); + + // Handle case where data might be a mongoose model + if (typeof data.toObject === 'function') { + data = data.toObject(); + } + + // ensure we are working on a copy + data = { ...data }; + + // If we are updating multiple records + const options = { + multi: id === null, + runValidators: true, + context: 'query', + ...params.mongoose, + }; + + if (id !== null) { + query.$and = (query.$and || []).concat({ [this.id]: id }); + } + + if (this.id === '_id') { + // We can not update default mongo ids + delete data[this.id]; + } else if (id !== null) { + // If not using the default Mongo _id field set the id to its + // previous value. This prevents orphaned documents. + data[this.id] = id; + } + + // NOTE (EK): We need this shitty hack because update doesn't + // return a promise properly when runValidators is true. WTF! + try { + return ids + .then((idList) => { + const { query: { $populate } = {} } = params; + // Create a new query that re-queries all ids that + // were originally changed + const updatedQuery = { [this.id]: { $in: idList } }; + const findParams = { + ...params, + paginate: false, + query: + $populate && this.options.whitelist.includes('$populate') + ? Object.assign(updatedQuery, { $populate }) + : updatedQuery, + }; + + // If params.query.$populate was provided, remove it + // from the query sent to mongoose. + const discriminator = query[this.discriminatorKey] || this.discriminatorKey; + const model = this.discriminators[discriminator] || this.Model; + return model + .updateMany(query, data, options) + .lean(this.lean) + .exec() + .then((writeResult) => { + if (options.writeResult) { + return writeResult; + } + if (writeResult.upsertedCount > 0) { + return this._getOrFind(id, { ...params, paginate: false }); + } + + if ('upserted' in writeResult) { + return this._getOrFind(id, { + ...params, + query: { [this.id]: { $in: writeResult.upserted.map((doc) => doc._id) } }, + paginate: false, + }); + } + + return this._getOrFind(id, findParams); + }); + }) + .then(select(params, this.id)) + .catch(errorHandler); + } catch (e) { + return errorHandler(e); + } + } + + _remove(id, params = {}) { + const { query } = this.filterQuery(params); + + if (params.collation) { + query.collation = params.collation; + } + + const findParams = { ...params, paginate: false, query }; + + if (id !== null) { + query.$and = (query.$and || []).concat({ [this.id]: id }); + } + + // NOTE (EK): First fetch the record(s) so that we can return + // it/them when we delete it/them. + return this._getOrFind(id, findParams) + .then((data) => { + if (id !== null) { + return this.Model.deleteOne(query, params.mongoose) + .lean(this.lean) + .exec() + .then(() => data) + .then(select(params, this.id)); + } + + return this.Model.deleteMany(query, params.mongoose) + .lean(this.lean) + .exec() + .then(() => data) + .then(select(params, this.id)); + }) + .catch(errorHandler); + } + + get(id, params = {}) { + return this._get(id, params); + } + + find(params = {}) { + return this._find(params); + } + + create(data, params = {}) { + return this._create(data, params); + } + + update(id, data, params = {}) { + return this._update(id, data, params); + } + + patch(id, data, params = {}) { + return this._patch(id, data, params); + } + + remove(id, params = {}) { + return this._remove(id, params); + } + + getObjectId(id) { + if (this.options.disableObjectify) { + return id; + } + + if (this.id === '_id' && ObjectId.isValid(id)) { + id = new ObjectId(id.toString()); + } + + return id; + } + + filterQuery(params) { + const options = this.getOptions(params); + const { $select, $sort, $limit: _limit, $skip = 0, $populate, ...query } = params.query || {}; + const $limit = getLimit(_limit, options.paginate); + + if (query[this.id]) { + query[this.id] = this.getObjectId(query[this.id]); + } + + const results = { + filters: { $select, $sort, $limit, $skip, $populate }, + query, + }; + + return results; + } +} + +function init(options) { + return new Service(options); +} + +module.exports = Object.assign(init, { + default: init, + ERROR, + Service, +}); diff --git a/test/services/datasources/datasourceRuns.test.js b/test/services/datasources/datasourceRuns.test.js index 06601b206d2..16735fb3bd5 100644 --- a/test/services/datasources/datasourceRuns.test.js +++ b/test/services/datasources/datasourceRuns.test.js @@ -69,6 +69,10 @@ describe('datasourceRuns service', () => { await closeNestServices(nestServices); }); + afterEach(() => { + app.unuse('/sync/userAccounts'); + }); + it('registered the datasourceRuns service', () => { expect(datasourceRunsService).to.not.be.undefined; }); diff --git a/test/services/ldap/strategies/iserv-idm.test.js b/test/services/ldap/strategies/iserv-idm.test.js index adb089e396c..1321e53f789 100644 --- a/test/services/ldap/strategies/iserv-idm.test.js +++ b/test/services/ldap/strategies/iserv-idm.test.js @@ -26,6 +26,10 @@ describe('IservIdmLDAPStrategy', () => { app.use('/ldap', originalLdapService); }); + afterEach(() => { + app.unuse('/ldap'); + }); + describe('#getSchools', () => { function MockLdapService() { return { diff --git a/test/services/school/services/permissions.test.js b/test/services/school/services/permissions.test.js index 1709d3bc138..2c4bfb38d32 100644 --- a/test/services/school/services/permissions.test.js +++ b/test/services/school/services/permissions.test.js @@ -57,7 +57,6 @@ describe('permissons service', () => { it('changes the STUDENT_LIST permission if TEACHER_STUDENT_VISIBILITY__IS_CONFIGURABLE is true', async () => { Configuration.set('TEACHER_STUDENT_VISIBILITY__IS_CONFIGURABLE', 'true'); - app.configure(schoolServices); const service = app.service('/school/teacher/studentvisibility'); diff --git a/test/services/sync/strategies/CSVSyncer/CSVSyncer.integration.test.js b/test/services/sync/strategies/CSVSyncer/CSVSyncer.integration.test.js index 44d52e13220..2a1f86e598a 100644 --- a/test/services/sync/strategies/CSVSyncer/CSVSyncer.integration.test.js +++ b/test/services/sync/strategies/CSVSyncer/CSVSyncer.integration.test.js @@ -716,6 +716,10 @@ describe('CSVSyncer Integration', () => { app.use('/mails', new MailService()); }); + afterEach(() => { + app.unuse('/mails'); + }); + it('should be accepted for execution', () => { expect(CSVSyncer.params(scenarioParams, scenarioData)).to.not.equal(false); }); diff --git a/test/services/teams/helper/helper.hook.js b/test/services/teams/helper/helper.hook.js index e85131f8015..12dd02c62de 100644 --- a/test/services/teams/helper/helper.hook.js +++ b/test/services/teams/helper/helper.hook.js @@ -1,5 +1,5 @@ -const service = require('feathers-mongoose'); const { Configuration } = require('@hpi-schul-cloud/commons'); +const service = require('../../../../src/utils/feathers-mongoose'); const { BadRequest } = require('../../../../src/errors');