From 90ed12b5f041bf33d1e394ed841f0135c54d1e10 Mon Sep 17 00:00:00 2001 From: SevenWaysDP Date: Mon, 6 Nov 2023 13:31:27 +0100 Subject: [PATCH 1/5] BC-5639 - WIP fix tests --- .../account/services/jwtTimerService.test.js | 10 +++---- test/services/content/material.test.js | 2 +- .../datasources/datasourceRuns.test.js | 10 ++++--- .../utils/filePermissionHelper.test.js | 2 +- test/services/helpdesk/index.test.js | 17 ++++++++++-- .../ldap-config/service.integration.test.js | 27 ++++++++++++++----- .../ldap/strategies/iserv-idm.test.js | 9 ++++++- .../ldap/strategies/univention.test.js | 14 ++++++++-- test/services/link/index.test.js | 2 +- test/services/news/index.test.js | 4 +-- test/services/rocketChat/index.test.js | 22 ++++++++++++--- .../school/services/permissions.test.js | 3 --- .../CSVSyncer/CSVSyncer.integration.test.js | 5 ++++ 13 files changed, 96 insertions(+), 31 deletions(-) diff --git a/test/services/account/services/jwtTimerService.test.js b/test/services/account/services/jwtTimerService.test.js index 8996a518fcb..9afd34be981 100644 --- a/test/services/account/services/jwtTimerService.test.js +++ b/test/services/account/services/jwtTimerService.test.js @@ -12,7 +12,7 @@ const testObjects = require('../../helpers/testObjects')(appPromise()); const { setupNestServices, closeNestServices } = require('../../../utils/setup.nest.services'); -describe('jwtTimer service', () => { +describe.only('jwtTimer service', () => { it('registered the supportJWT service', async () => { // eslint-disable-next-line global-require const defaultApp = await require('../../../../src/app')(); @@ -44,8 +44,8 @@ describe('jwtTimer service', () => { mockery.registerMock('@hpi-schul-cloud/commons', commons); /* eslint-disable global-require */ redisHelper = require('../../../../src/utils/redis'); - const { jwtTimerServiceSetup } = require('../../../../src/services/account/services/jwtTimerService'); - app.configure(jwtTimerServiceSetup); + //const { jwtTimerServiceSetup } = require('../../../../src/services/account/services/jwtTimerService'); + //app.configure(jwtTimerServiceSetup); /* eslint-enable global-require */ Configuration.set('REDIS_URI', '//validHost:4444'); @@ -104,8 +104,8 @@ describe('jwtTimer service', () => { delete require.cache[require.resolve('../../../../src/utils/redis')]; /* eslint-disable global-require */ redisHelper = require('../../../../src/utils/redis'); - const { jwtTimerServiceSetup } = require('../../../../src/services/account/services/jwtTimerService'); - app.configure(jwtTimerServiceSetup); + //const { jwtTimerServiceSetup } = require('../../../../src/services/account/services/jwtTimerService'); + //app.configure(jwtTimerServiceSetup); /* eslint-enable global-require */ redisHelper.initializeRedisClient(); diff --git a/test/services/content/material.test.js b/test/services/content/material.test.js index b846f5418eb..97bde971a43 100644 --- a/test/services/content/material.test.js +++ b/test/services/content/material.test.js @@ -7,7 +7,7 @@ const Material = require('../../../src/services/content/material-model'); const { cleanup, createTestCourse, createTestUser, createTestLesson, generateRequestParamsFromUser } = require('../helpers/testObjects')(appPromise()); -describe('material service', () => { +describe.only('material service', () => { let app; let server; let nestServices; diff --git a/test/services/datasources/datasourceRuns.test.js b/test/services/datasources/datasourceRuns.test.js index b169e92e4dd..e9e99cd6ec2 100644 --- a/test/services/datasources/datasourceRuns.test.js +++ b/test/services/datasources/datasourceRuns.test.js @@ -38,7 +38,7 @@ class MockSyncerWithData extends Syncer { } } -describe('datasourceRuns service', () => { +describe.only('datasourceRuns service', () => { let app; let datasourceRunsService; let server; @@ -54,8 +54,8 @@ describe('datasourceRuns service', () => { mockery.registerMock('./strategies', [MockSyncer, MockSyncerWithData]); datasourceRunsService = app.service('datasourceRuns'); // eslint-disable-next-line global-require - const sync = require('../../../src/services/sync'); - app.configure(sync); + //const sync = require('../../../src/services/sync'); + //app.configure(sync); server = await app.listen(0); }); @@ -66,6 +66,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/fileStorage/utils/filePermissionHelper.test.js b/test/services/fileStorage/utils/filePermissionHelper.test.js index 37cac5269e2..c6eea46a659 100644 --- a/test/services/fileStorage/utils/filePermissionHelper.test.js +++ b/test/services/fileStorage/utils/filePermissionHelper.test.js @@ -19,7 +19,7 @@ const fixtures = require('../fixtures'); const { expect } = chai; chai.use(chaiAsPromised); -describe('filePermissionHelper', () => { +describe.only('filePermissionHelper', () => { describe('checkPermissions function should', () => { before(async () => { const promises = [ diff --git a/test/services/helpdesk/index.test.js b/test/services/helpdesk/index.test.js index 4b515c6816c..712c048a3dc 100644 --- a/test/services/helpdesk/index.test.js +++ b/test/services/helpdesk/index.test.js @@ -5,7 +5,7 @@ const sinon = require('sinon'); const appPromise = require('../../../src/app'); const { Configuration } = require('@hpi-schul-cloud/commons'); -describe('helpdesk service', function test() { +describe.only('helpdesk service', function test() { this.timeout(10000); let app; let helpdeskService; @@ -36,7 +36,7 @@ describe('helpdesk service', function test() { }); after((done) => { - app.use('/mails', originalMailService); + //app.use('/mails', originalMailService); helpdeskService .remove(testProblem) .then((result) => { @@ -48,11 +48,21 @@ describe('helpdesk service', function test() { }); }); + beforeEach(() => { + // app.unuse('/mails'); + // app.use('/mails', originalMailService); + }); + + afterEach(() => { + app.unuse('/mails'); + }); + it('registered the helpdesk service', () => { assert.ok(helpdeskService); }); it('POST /helpdesk to admin with valid data', () => { + app.use('/mails', originalMailService); const postBody = { type: 'contactAdmin', subject: 'Dies ist ein Titel 2', @@ -69,6 +79,7 @@ describe('helpdesk service', function test() { }); it('POST /helpdesk to admin without schoolId', () => { + app.use('/mails', originalMailService); const postBody = { type: 'contactAdmin', subject: 'Dies ist ein Titel 3', @@ -83,6 +94,7 @@ describe('helpdesk service', function test() { }); it('POST /helpdesk to admin without data', () => { + app.use('/mails', originalMailService); const postBody = { type: 'contactAdmin', subject: 'Dies ist ein Titel 3', @@ -95,6 +107,7 @@ describe('helpdesk service', function test() { }); it('POST /helpdesk to schoolcloud with problem, valid data', () => { + app.use('/mails', originalMailService); const postBody = { type: 'contactHPI', subject: 'Dies ist ein Titel 4', diff --git a/test/services/ldap-config/service.integration.test.js b/test/services/ldap-config/service.integration.test.js index 8fc6c455bef..93afbf75508 100644 --- a/test/services/ldap-config/service.integration.test.js +++ b/test/services/ldap-config/service.integration.test.js @@ -17,7 +17,7 @@ chai.use(chaiAsPromised); chai.use(chaiHttp); const { expect } = chai; -describe('LdapConfigService', () => { +describe.only('LdapConfigService', () => { let app; let server; let nestServices; @@ -40,6 +40,10 @@ describe('LdapConfigService', () => { await closeNestServices(nestServices); }); + afterEach(() => { + app.unuse('ldap'); + }); + describe('GET route', () => { let generalLdapSystem1; let iservLdapSystem1; @@ -150,6 +154,7 @@ describe('LdapConfigService', () => { function MockLdapService() { return { setup: () => {}, + get: () => {}, getUsers: sinon.fake.resolves(fakeUsers), getClasses: sinon.fake.resolves(fakeClasses), disconnect: sinon.fake.resolves(), @@ -161,14 +166,14 @@ describe('LdapConfigService', () => { app.use('ldap', ldapServiceMock); }); - before(() => { - originalLdapService = app.service('ldap'); - }); - after(() => { app.use('ldap', originalLdapService); }); + afterEach(() => { + app.unuse('ldap'); + }); + beforeEach(async () => { school = await testObjects.createTestSchool({ systems: [], @@ -178,6 +183,7 @@ describe('LdapConfigService', () => { roles: ['administrator'], }); params = await testObjects.generateRequestParamsFromUser(admin); + originalLdapService = app.service('ldap'); }); it("should allow adding a new system based on the given LDAP config to the user's school", async () => { @@ -224,6 +230,9 @@ describe('LdapConfigService', () => { it('should catch common errors', async () => { ldapServiceMock.getUsers = sinon.fake.rejects(new LDAPConnectionError()); + + app.unuse('ldap'); + app.use('ldap', ldapServiceMock); const result = await app @@ -287,6 +296,7 @@ describe('LdapConfigService', () => { function MockLdapService() { return { setup: () => {}, + get: () => {}, getUsers: sinon.fake.resolves(fakeUsers), getClasses: sinon.fake.resolves(fakeClasses), disconnect: sinon.fake.resolves(), @@ -295,11 +305,13 @@ describe('LdapConfigService', () => { beforeEach(() => { ldapServiceMock = new MockLdapService(); + app.unuse('ldap'); + app.use('ldap', ldapServiceMock); }); - before(() => { - originalLdapService = app.service('ldap'); + afterEach(() => { + app.unuse('ldap'); }); after(() => { @@ -325,6 +337,7 @@ describe('LdapConfigService', () => { roles: ['administrator'], }); params = await testObjects.generateRequestParamsFromUser(admin); + originalLdapService = app.service('ldap'); }); it('should verify the given config and patch the system and school', async () => { diff --git a/test/services/ldap/strategies/iserv-idm.test.js b/test/services/ldap/strategies/iserv-idm.test.js index 2aadaf1ea90..6d74a50792b 100644 --- a/test/services/ldap/strategies/iserv-idm.test.js +++ b/test/services/ldap/strategies/iserv-idm.test.js @@ -6,7 +6,7 @@ const appPromise = require('../../../../src/app'); const AbstractLDAPStrategy = require('../../../../src/services/ldap/strategies/interface'); const IservIdmLDAPStrategy = require('../../../../src/services/ldap/strategies/iserv-idm'); -describe('IservIdmLDAPStrategy', () => { +describe.only('IservIdmLDAPStrategy', () => { it('implements AbstractLDAPStrategy', () => { expect(new IservIdmLDAPStrategy()).to.be.instanceOf(AbstractLDAPStrategy); }); @@ -25,10 +25,15 @@ describe('IservIdmLDAPStrategy', () => { app.use('/ldap', originalLdapService); }); + afterEach(() => { + app.unuse('/ldap'); + }); + describe('#getSchools', () => { function MockLdapService() { return { setup: () => {}, + get: () => {}, searchCollection: sinon.fake.returns([ { dn: 'o=Testschule,dc=de', o: 'Testschule' }, { dn: 'o=hvk,dc=schule', description: 'Heinrich-von-Kleist-Schule', o: 'hvk' }, @@ -86,6 +91,7 @@ describe('IservIdmLDAPStrategy', () => { function MockLdapService() { return { setup: () => {}, + get: () => {}, searchCollection: sinon.fake.returns([ { dn: 'cn=student1,ou=users,o=Testschule,dc=de', @@ -206,6 +212,7 @@ describe('IservIdmLDAPStrategy', () => { function MockLdapService() { return { setup: () => {}, + get: () => {}, searchCollection: sinon.fake.returns([ { dn: 'cn=klasse9a,ou=groups,o=Testschule,dc=de', diff --git a/test/services/ldap/strategies/univention.test.js b/test/services/ldap/strategies/univention.test.js index cf6a1dad178..57c997054b5 100644 --- a/test/services/ldap/strategies/univention.test.js +++ b/test/services/ldap/strategies/univention.test.js @@ -11,7 +11,7 @@ const mockLDAPConfig = { providerOptions: {}, }; -describe('UniventionLDAPStrategy', () => { +describe.only('UniventionLDAPStrategy', () => { it('implements AbstractLDAPStrategy', () => { expect(new UniventionLDAPStrategy()).to.be.instanceOf(AbstractLDAPStrategy); }); @@ -27,7 +27,7 @@ describe('UniventionLDAPStrategy', () => { }); after(() => { - app.use('/ldap', originalLdapService); + // app.use('/ldap', originalLdapService); }); describe('#getSchools', () => { @@ -39,15 +39,21 @@ describe('UniventionLDAPStrategy', () => { function MockLdapService() { return { setup: () => {}, + get: () => {}, searchCollection: sinon.fake.resolves(ldapFakeSchoolSearchResult), }; } beforeEach(() => { ldapServiceMock = new MockLdapService(); + app.unuse('/ldap'); app.use('/ldap', ldapServiceMock); }); + afterEach(() => { + app.unuse('/ldap'); + }); + it('should search at the given root path and fall back to empty string', async () => { const searchOptions = { filter: `(&(univentionObjectType=container/ou)(!(ucsschoolRole=school:ou:no_school))(objectClass=ucsschoolOrganizationalUnit))`, @@ -122,6 +128,7 @@ describe('UniventionLDAPStrategy', () => { function MockLdapService() { return { setup: () => {}, + get: () => {}, searchCollection: sinon.fake.resolves([ { dn: 'uid=max1,cn=schueler,cn=users,ou=1,dc=training,dc=ucs', @@ -166,6 +173,7 @@ describe('UniventionLDAPStrategy', () => { beforeEach(() => { ldapServiceMock = new MockLdapService(); + app.unuse('/ldap'); app.use('/ldap', ldapServiceMock); }); @@ -241,12 +249,14 @@ describe('UniventionLDAPStrategy', () => { function MockLdapService() { return { setup: () => {}, + get: () => {}, searchCollection: sinon.fake.resolves(ldapFakeClassSearchResult), }; } beforeEach(() => { ldapServiceMock = new MockLdapService(); + app.unuse('/ldap'); app.use('/ldap', ldapServiceMock); }); diff --git a/test/services/link/index.test.js b/test/services/link/index.test.js index 202f22b79bd..be49b00d24a 100644 --- a/test/services/link/index.test.js +++ b/test/services/link/index.test.js @@ -7,7 +7,7 @@ const logger = require('../../../src/logger'); chai.use(chaiHttp); -describe('link service', () => { +describe.only('link service', () => { let app; let port; let server; diff --git a/test/services/news/index.test.js b/test/services/news/index.test.js index 3e22ba4e0cc..0bfff62b07d 100644 --- a/test/services/news/index.test.js +++ b/test/services/news/index.test.js @@ -5,13 +5,13 @@ const sleep = require('util').promisify(setTimeout); const appPromise = require('../../../src/app'); const { newsModel: News } = require('../../../src/services/news/model'); -describe('news service', () => { +describe.only('news service', () => { let app; let newsService; before(async () => { app = await appPromise(); - newsService = app.service('news'); + newsService = app.service('/news1'); }); it('public service has been disabled', () => { diff --git a/test/services/rocketChat/index.test.js b/test/services/rocketChat/index.test.js index 0cb90fdd9f6..197e512272f 100644 --- a/test/services/rocketChat/index.test.js +++ b/test/services/rocketChat/index.test.js @@ -12,7 +12,7 @@ const testObjects = require('../helpers/testObjects')(appPromise()); const { expect } = chai; -describe('rocket.chat user service', () => { +describe.only('rocket.chat user service', () => { delete require.cache[require.resolve('../../../src/app')]; let app; @@ -38,9 +38,9 @@ describe('rocket.chat user service', () => { delete require.cache[require.resolve('../../../src/services/rocketChat/services/rocketChatUser.js')]; delete require.cache[require.resolve('../../../src/services/rocketChat/helpers.js')]; delete require.cache[require.resolve('../../../src/services/rocketChat/index.js')]; - const rocketChat = require('../../../src/services/rocketChat'); + app = await appPromise(); - app.configure(rocketChat); + rocketChatUserService = app.service('/rocketChat/user'); server = await app.listen(0); @@ -92,6 +92,8 @@ class NestRocketChatServiceMock { this.app = app; } + get() {} + async logoutUser(authToken, rcId) { return { authToken, rcId }; } @@ -126,6 +128,8 @@ class RocketChatUserServiceMock { this.app = app; } + get() {} + constructor(mockFunction) { if (mockFunction) { this.getOrCreateRocketChatAccount = mockFunction; @@ -164,6 +168,12 @@ describe('rocket.chat login service', async () => { await closeNestServices(nestServices); }); + afterEach(() => { + app.unuse('/rocketChat/channel'); + app.unuse('/nest-rocket-chat'); + app.unuse('/rocketChat/user'); + }); + const setupServices = async (RCNestMock, RCUserMock) => { app.use('/nest-rocket-chat', RCNestMock || new NestRocketChatServiceMock()); app.use('/rocketChat/user', RCUserMock || new RocketChatUserServiceMock()); @@ -234,6 +244,12 @@ describe('rocket.chat logout service', async () => { await closeNestServices(nestServices); }); + afterEach(() => { + app.unuse('/rocketChat/channel'); + app.unuse('/nest-rocket-chat'); + app.unuse('/rocketChat/user'); + }); + const setupServices = async (RCNestMock, RCUserMock) => { app.use('/nest-rocket-chat', RCNestMock || new NestRocketChatServiceMock()); app.use('/rocketChat/user', RCUserMock || new RocketChatUserServiceMock()); diff --git a/test/services/school/services/permissions.test.js b/test/services/school/services/permissions.test.js index 135222a94c4..d42e45cec74 100644 --- a/test/services/school/services/permissions.test.js +++ b/test/services/school/services/permissions.test.js @@ -47,7 +47,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'); expect(service).to.not.be.undefined; @@ -65,7 +64,6 @@ describe('permissons service', () => { describe('for LERNSTORE_VIEW permission', () => { it('is not registered if FEATURE_ADMIN_TOGGLE_STUDENT_LERNSTORE_VIEW_ENABLED is false', async () => { Configuration.set('FEATURE_ADMIN_TOGGLE_STUDENT_LERNSTORE_VIEW_ENABLED', 'false'); - app.configure(schoolServices); const service = app.service('/school/student/studentlernstorevisibility'); expect(service).to.be.undefined; @@ -73,7 +71,6 @@ describe('permissons service', () => { it('changes the LERNSTORE_VIEW permission if FEATURE_ADMIN_TOGGLE_STUDENT_LERNSTORE_VIEW_ENABLED is true', async () => { Configuration.set('FEATURE_ADMIN_TOGGLE_STUDENT_LERNSTORE_VIEW_ENABLED', 'true'); - app.configure(schoolServices); const service = app.service('/school/student/studentlernstorevisibility'); expect(service).to.not.be.undefined; diff --git a/test/services/sync/strategies/CSVSyncer/CSVSyncer.integration.test.js b/test/services/sync/strategies/CSVSyncer/CSVSyncer.integration.test.js index 4c5830ddb84..a1d271575a6 100644 --- a/test/services/sync/strategies/CSVSyncer/CSVSyncer.integration.test.js +++ b/test/services/sync/strategies/CSVSyncer/CSVSyncer.integration.test.js @@ -472,6 +472,7 @@ describe('CSVSyncer Integration', () => { it('should import five teachers into three existing classes', async () => { const emails = []; + app.unuse('/mails'); app.use( '/mails', new MockEmailService((email) => { @@ -715,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); }); From 048d1e11d44ac9a33da5a760e70e5164e9852188 Mon Sep 17 00:00:00 2001 From: SevenWaysDP Date: Fri, 10 Nov 2023 14:19:49 +0100 Subject: [PATCH 2/5] BC-5596 - port feathers-mongoose module to feathersjs version 5 --- package-lock.json | 881 +++++++++---------- package.json | 5 +- src/services/teams/model.js | 2 + src/utils/database.js | 5 +- src/utils/feathers-mongoose/error-handler.js | 53 ++ src/utils/feathers-mongoose/hooks.js | 31 + src/utils/feathers-mongoose/index.js | 6 + src/utils/feathers-mongoose/service.js | 471 ++++++++++ 8 files changed, 1006 insertions(+), 448 deletions(-) create mode 100644 src/utils/feathers-mongoose/error-handler.js create mode 100644 src/utils/feathers-mongoose/hooks.js create mode 100644 src/utils/feathers-mongoose/index.js create mode 100644 src/utils/feathers-mongoose/service.js diff --git a/package-lock.json b/package-lock.json index 30135ba283a..1dcc7e5bf47 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", @@ -90,7 +91,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", @@ -579,7 +580,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", @@ -796,7 +796,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", @@ -980,7 +979,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", @@ -2947,18 +2945,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", @@ -3004,30 +2990,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", @@ -3108,6 +3070,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", @@ -3127,18 +3101,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", @@ -3211,18 +3173,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", @@ -3240,18 +3190,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", @@ -3279,18 +3217,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", @@ -4672,6 +4598,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", @@ -5644,6 +5579,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", @@ -11896,43 +11839,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", @@ -16108,9 +16014,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", @@ -16408,11 +16317,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", @@ -16908,6 +16812,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", @@ -16932,6 +16845,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", @@ -16971,6 +16897,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", @@ -17046,6 +16985,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", @@ -17057,6 +17001,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", @@ -17085,6 +17126,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", @@ -17646,27 +17692,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", @@ -17741,87 +17780,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", @@ -17988,43 +18009,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", @@ -19046,6 +19040,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", @@ -22178,9 +22180,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", @@ -22341,7 +22343,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", @@ -24093,14 +24095,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", @@ -25536,7 +25530,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", @@ -25738,7 +25731,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", @@ -25894,7 +25886,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", @@ -27282,13 +27273,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": { @@ -27309,11 +27293,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", @@ -27379,15 +27358,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", @@ -27400,11 +27377,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", @@ -27450,13 +27422,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": { @@ -27467,13 +27432,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": { @@ -27491,13 +27449,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": { @@ -28554,6 +28505,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", @@ -29203,6 +29163,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", @@ -34038,32 +34006,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", @@ -37193,9 +37135,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", @@ -37442,11 +37384,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", @@ -37857,6 +37794,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", @@ -37872,6 +37818,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", @@ -37902,6 +37858,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", @@ -37962,6 +37933,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", @@ -37970,6 +37946,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", @@ -37992,6 +38031,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", @@ -38411,75 +38455,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==" } } }, @@ -38674,40 +38700,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": { @@ -39530,6 +39527,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", @@ -41861,9 +41863,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", @@ -41998,7 +42000,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", @@ -43323,11 +43325,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 2df7d39f095..c8429b6d0f0 100644 --- a/package.json +++ b/package.json @@ -92,8 +92,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", @@ -158,7 +160,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", @@ -173,7 +174,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/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/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, +}); From 0ef66e3591fa43f51e5d6d67bddca5c25d7199c6 Mon Sep 17 00:00:00 2001 From: SevenWaysDP Date: Fri, 10 Nov 2023 14:26:01 +0100 Subject: [PATCH 3/5] BC-5596 - replace feathers-mongoose --- .../activation/services/ActivationModelService.js | 2 +- src/services/base64Files/index.js | 2 +- src/services/consent/index.js | 2 +- src/services/content/index.js | 2 +- src/services/datasources/services/datasources.js | 2 +- src/services/federalState/index.js | 2 +- src/services/fileStorage/model-service.js | 2 +- src/services/helpdesk/index.js | 8 ++++++-- src/services/homework/model-service.js | 2 +- src/services/lesson/index.js | 2 +- src/services/link/index.js | 2 +- src/services/ltiTool/index.js | 2 +- src/services/news/index.js | 2 +- src/services/pseudonym/index.js | 2 +- src/services/releases/index.js | 2 +- src/services/role/index.js | 2 +- src/services/school/index.js | 2 +- src/services/serviceTemplate/services/modelService.js | 2 +- src/services/storageProvider/index.js | 2 +- src/services/system/index.js | 2 +- src/services/teams/index.js | 2 +- src/services/user-group/hooks/courses.js | 2 +- src/services/user-group/services/classModelService.js | 2 +- .../user-group/services/courseGroupModelService.js | 2 +- src/services/user-group/services/courseModelService.js | 2 +- src/services/user/index.js | 2 +- src/services/user/services/UsersModelService.js | 2 +- src/services/webuntis/services/webuntisMetadata.js | 2 +- test/services/teams/helper/helper.hook.js | 2 +- 29 files changed, 34 insertions(+), 30 deletions(-) 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 137ada9b61d..e3bb11ea59d 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 d963a56a1b9..165f104cb6b 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/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/test/services/teams/helper/helper.hook.js b/test/services/teams/helper/helper.hook.js index e85131f8015..215b2bf9d1b 100644 --- a/test/services/teams/helper/helper.hook.js +++ b/test/services/teams/helper/helper.hook.js @@ -1,4 +1,4 @@ -const service = require('feathers-mongoose'); +const service = require('../../../utils/feathers-mongoose'); const { Configuration } = require('@hpi-schul-cloud/commons'); const { BadRequest } = require('../../../../src/errors'); From 4277a2e2948ff78079bfe69f4d23528084f0dd81 Mon Sep 17 00:00:00 2001 From: virgilchiriac Date: Wed, 22 Nov 2023 11:03:39 +0100 Subject: [PATCH 4/5] remove .only from some tests --- test/services/content/material.test.js | 2 +- test/services/datasources/datasourceRuns.test.js | 6 +++--- .../services/fileStorage/utils/filePermissionHelper.test.js | 2 +- test/services/ldap/strategies/iserv-idm.test.js | 2 +- test/services/link/index.test.js | 2 +- test/services/teams/helper/helper.hook.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/services/content/material.test.js b/test/services/content/material.test.js index ae83280ce32..3d1faa798e3 100644 --- a/test/services/content/material.test.js +++ b/test/services/content/material.test.js @@ -7,7 +7,7 @@ const Material = require('../../../src/services/content/material-model'); const { cleanup, createTestCourse, createTestUser, createTestLesson, generateRequestParamsFromUser } = require('../helpers/testObjects')(appPromise()); -describe.only('material service', () => { +describe('material service', () => { let app; let server; let nestServices; diff --git a/test/services/datasources/datasourceRuns.test.js b/test/services/datasources/datasourceRuns.test.js index 71bc7b12e61..16735fb3bd5 100644 --- a/test/services/datasources/datasourceRuns.test.js +++ b/test/services/datasources/datasourceRuns.test.js @@ -38,7 +38,7 @@ class MockSyncerWithData extends Syncer { } } -describe.only('datasourceRuns service', () => { +describe('datasourceRuns service', () => { let app; let datasourceRunsService; let server; @@ -57,8 +57,8 @@ describe.only('datasourceRuns service', () => { app.unuse('/sync/userAccount'); app.unuse('/sync'); // eslint-disable-next-line global-require - //const sync = require('../../../src/services/sync'); - //app.configure(sync); + const sync = require('../../../src/services/sync'); + app.configure(sync); server = await app.listen(0); }); diff --git a/test/services/fileStorage/utils/filePermissionHelper.test.js b/test/services/fileStorage/utils/filePermissionHelper.test.js index c6eea46a659..37cac5269e2 100644 --- a/test/services/fileStorage/utils/filePermissionHelper.test.js +++ b/test/services/fileStorage/utils/filePermissionHelper.test.js @@ -19,7 +19,7 @@ const fixtures = require('../fixtures'); const { expect } = chai; chai.use(chaiAsPromised); -describe.only('filePermissionHelper', () => { +describe('filePermissionHelper', () => { describe('checkPermissions function should', () => { before(async () => { const promises = [ diff --git a/test/services/ldap/strategies/iserv-idm.test.js b/test/services/ldap/strategies/iserv-idm.test.js index d4f3cfba073..1321e53f789 100644 --- a/test/services/ldap/strategies/iserv-idm.test.js +++ b/test/services/ldap/strategies/iserv-idm.test.js @@ -6,7 +6,7 @@ const appPromise = require('../../../../src/app'); const AbstractLDAPStrategy = require('../../../../src/services/ldap/strategies/interface'); const IservIdmLDAPStrategy = require('../../../../src/services/ldap/strategies/iserv-idm'); -describe.only('IservIdmLDAPStrategy', () => { +describe('IservIdmLDAPStrategy', () => { it('implements AbstractLDAPStrategy', () => { expect(new IservIdmLDAPStrategy()).to.be.instanceOf(AbstractLDAPStrategy); }); diff --git a/test/services/link/index.test.js b/test/services/link/index.test.js index be49b00d24a..202f22b79bd 100644 --- a/test/services/link/index.test.js +++ b/test/services/link/index.test.js @@ -7,7 +7,7 @@ const logger = require('../../../src/logger'); chai.use(chaiHttp); -describe.only('link service', () => { +describe('link service', () => { let app; let port; let server; diff --git a/test/services/teams/helper/helper.hook.js b/test/services/teams/helper/helper.hook.js index 215b2bf9d1b..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('../../../utils/feathers-mongoose'); const { Configuration } = require('@hpi-schul-cloud/commons'); +const service = require('../../../../src/utils/feathers-mongoose'); const { BadRequest } = require('../../../../src/errors'); From d5e620d3e1cb4e68d20dd60903c37afd04c1e92a Mon Sep 17 00:00:00 2001 From: virgilchiriac Date: Wed, 22 Nov 2023 11:38:15 +0100 Subject: [PATCH 5/5] updateMany repo helper - fixes classes.repo.integration.test 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? --- src/components/helper/repo.helper.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 }; }; /**