Merge pull request #15331 from overleaf/csh-issue-11625-mongo-ug-5-contacts

Upgrade mongodb module for contacts from 4.12.1 to 6.1.0

GitOrigin-RevId: 22c4544b21363d82dcf3215c660e4412bb179fe8
This commit is contained in:
Christopher Hoskin 2023-10-23 09:21:16 +01:00 committed by Copybot
parent 0572535a7e
commit 6a118d9439
5 changed files with 90 additions and 77 deletions

145
package-lock.json generated
View file

@ -37729,7 +37729,7 @@
"body-parser": "^1.19.0",
"bunyan": "^1.8.15",
"express": "^4.18.2",
"mongodb": "^4.12.1",
"mongodb": "^6.1.0",
"request": "~2.88.2",
"underscore": "~1.13.1"
},
@ -37743,37 +37743,11 @@
}
},
"services/contacts/node_modules/bson": {
"version": "4.7.2",
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz",
"integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==",
"dependencies": {
"buffer": "^5.6.0"
},
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz",
"integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==",
"engines": {
"node": ">=6.9.0"
}
},
"services/contacts/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": {
"base64-js": "^1.3.1",
"ieee754": "^1.1.13"
"node": ">=16.20.1"
}
},
"services/contacts/node_modules/diff": {
@ -37785,21 +37759,63 @@
"node": ">=0.3.1"
}
},
"services/contacts/node_modules/mongodb": {
"version": "4.17.1",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.17.1.tgz",
"integrity": "sha512-MBuyYiPUPRTqfH2dV0ya4dcr2E5N52ocBuZ8Sgg/M030nGF78v855B3Z27mZJnp8PxjnUquEnAtjOsphgMZOlQ==",
"services/contacts/node_modules/gcp-metadata": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz",
"integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==",
"optional": true,
"peer": true,
"dependencies": {
"bson": "^4.7.2",
"mongodb-connection-string-url": "^2.6.0",
"socks": "^2.7.1"
"gaxios": "^5.0.0",
"json-bigint": "^1.0.0"
},
"engines": {
"node": ">=12.9.0"
"node": ">=12"
}
},
"services/contacts/node_modules/mongodb": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz",
"integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==",
"dependencies": {
"@mongodb-js/saslprep": "^1.1.0",
"bson": "^6.1.0",
"mongodb-connection-string-url": "^2.6.0"
},
"optionalDependencies": {
"@aws-sdk/credential-providers": "^3.186.0",
"@mongodb-js/saslprep": "^1.1.0"
"engines": {
"node": ">=16.20.1"
},
"peerDependencies": {
"@aws-sdk/credential-providers": "^3.188.0",
"@mongodb-js/zstd": "^1.1.0",
"gcp-metadata": "^5.2.0",
"kerberos": "^2.0.1",
"mongodb-client-encryption": ">=6.0.0 <7",
"snappy": "^7.2.2",
"socks": "^2.7.1"
},
"peerDependenciesMeta": {
"@aws-sdk/credential-providers": {
"optional": true
},
"@mongodb-js/zstd": {
"optional": true
},
"gcp-metadata": {
"optional": true
},
"kerberos": {
"optional": true
},
"mongodb-client-encryption": {
"optional": true
},
"snappy": {
"optional": true
},
"socks": {
"optional": true
}
}
},
"services/contacts/node_modules/sinon": {
@ -46188,7 +46204,7 @@
"esmock": "^2.1.0",
"express": "^4.18.2",
"mocha": "^10.2.0",
"mongodb": "^4.12.1",
"mongodb": "^6.1.0",
"request": "~2.88.2",
"sinon": "~9.0.1",
"sinon-chai": "^3.7.0",
@ -46196,21 +46212,9 @@
},
"dependencies": {
"bson": {
"version": "4.7.2",
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz",
"integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==",
"requires": {
"buffer": "^5.6.0"
}
},
"buffer": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
"requires": {
"base64-js": "^1.3.1",
"ieee754": "^1.1.13"
}
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz",
"integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q=="
},
"diff": {
"version": "4.0.2",
@ -46218,16 +46222,25 @@
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
"dev": true
},
"mongodb": {
"version": "4.17.1",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.17.1.tgz",
"integrity": "sha512-MBuyYiPUPRTqfH2dV0ya4dcr2E5N52ocBuZ8Sgg/M030nGF78v855B3Z27mZJnp8PxjnUquEnAtjOsphgMZOlQ==",
"gcp-metadata": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz",
"integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==",
"optional": true,
"peer": true,
"requires": {
"gaxios": "^5.0.0",
"json-bigint": "^1.0.0"
}
},
"mongodb": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz",
"integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==",
"requires": {
"@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"
"bson": "^6.1.0",
"mongodb-connection-string-url": "^2.6.0"
}
},
"sinon": {

View file

@ -2,7 +2,7 @@ import { db, ObjectId } from './mongodb.js'
export async function touchContact(userId, contactId) {
await db.contacts.updateOne(
{ user_id: ObjectId(userId.toString()) },
{ user_id: new ObjectId(userId.toString()) },
{
$inc: {
[`contacts.${contactId}.n`]: 1,
@ -17,7 +17,7 @@ export async function touchContact(userId, contactId) {
export async function getContacts(userId) {
const user = await db.contacts.findOne({
user_id: ObjectId(userId.toString()),
user_id: new ObjectId(userId.toString()),
})
return user?.contacts

View file

@ -24,7 +24,7 @@
"body-parser": "^1.19.0",
"bunyan": "^1.8.15",
"express": "^4.18.2",
"mongodb": "^4.12.1",
"mongodb": "^6.1.0",
"request": "~2.88.2",
"underscore": "~1.13.1"
},

View file

@ -22,7 +22,7 @@ describe('Getting Contacts', function () {
describe('with no contacts', function () {
beforeEach(function () {
this.user_id = ObjectId().toString()
this.user_id = new ObjectId().toString()
})
it('should return an empty array', function (done) {
@ -46,10 +46,10 @@ describe('Getting Contacts', function () {
describe('with contacts', function () {
beforeEach(function (done) {
this.user_id = ObjectId().toString()
this.contact_id_1 = ObjectId().toString()
this.contact_id_2 = ObjectId().toString()
this.contact_id_3 = ObjectId().toString()
this.user_id = new ObjectId().toString()
this.contact_id_1 = new ObjectId().toString()
this.contact_id_2 = new ObjectId().toString()
this.contact_id_3 = new ObjectId().toString()
const touchContact = (userId, contactId, cb) =>
request(

View file

@ -16,8 +16,8 @@ describe('ContactManager', function () {
},
})
this.user_id = ObjectId().toString()
this.contact_id = ObjectId().toString()
this.user_id = new ObjectId().toString()
this.contact_id = new ObjectId().toString()
})
afterEach(function () {
@ -62,7 +62,7 @@ describe('ContactManager', function () {
this.contact_id
)
).to.be.rejectedWith(
'Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer'
'input must be a 24 character hex string, 12 byte Uint8Array, or an integer'
)
})
})