Merge pull request #1205 from microsoft/nat/updateMongodb

Update Mongodb to latest driver
This commit is contained in:
Nathan 2019-10-01 11:12:36 -07:00 коммит произвёл GitHub
Родитель 63fab62660 076979aefd
Коммит cecedc4e63
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 53 добавлений и 86 удалений

86
package-lock.json сгенерированный
Просмотреть файл

@ -5,9 +5,9 @@
"requires": true,
"dependencies": {
"@types/bson": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@types/bson/-/bson-1.0.11.tgz",
"integrity": "sha512-j+UcCWI+FsbI5/FQP/Kj2CXyplWAz39ktHFkXk84h7dNblKRSoNJs95PZFRd96NQGqsPEPgeclqnznWZr14ZDA==",
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@types/bson/-/bson-4.0.0.tgz",
"integrity": "sha512-pq/rqJwJWkbS10crsG5bgnrisL8pML79KlMKQMoQwLUjlPAkrUHMvHJ3oGwE7WHR61Lv/nadMwXVAD2b+fpD8Q==",
"dev": true,
"requires": {
"@types/node": "*"
@ -333,20 +333,19 @@
"dev": true
},
"@types/mongodb": {
"version": "2.2.23",
"resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-2.2.23.tgz",
"integrity": "sha512-zK2txG9cGIxHZLRKq59mmb4uYbfl/b+G3RcSuW7HHEvUj/O0gsRLgprQu6n/Gn5Mh+PbnAIgrgh4Zhj+OjsRBQ==",
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.3.3.tgz",
"integrity": "sha512-ymI6OZB4kqaSgLDFn7PYGNC+BmwbKPuw88F+gr9SGyAltcSKI6nYf+rj8hrHEsypnjtT5rA+dnmjXdPSgXgSgQ==",
"dev": true,
"requires": {
"@types/bson": "*",
"@types/events": "*",
"@types/node": "*"
}
},
"@types/node": {
"version": "6.14.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-6.14.2.tgz",
"integrity": "sha512-JWB3xaVfsfnFY8Ofc9rTB/op0fqqTSqy4vBcVk1LuRJvta7KTX+D//fCkiTMeLGhdr2EbFZzQjC97gvmPilk9Q==",
"version": "12.7.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.8.tgz",
"integrity": "sha512-FMdVn84tJJdV+xe+53sYiZS4R5yn1mAIxfj+DVoNiQjTYz1+OYmjwEZr1ev9nU0axXwda0QDbYl06QHanRVH3A==",
"dev": true
},
"@types/socket.io": {
@ -1592,11 +1591,6 @@
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
"dev": true
},
"buffer-shims": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz",
"integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E="
},
"buffer-xor": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
@ -2997,11 +2991,6 @@
"es6-symbol": "^3.1.1"
}
},
"es6-promise": {
"version": "3.2.1",
"resolved": "http://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz",
"integrity": "sha1-7FYjOGgDKQkgcXDDlEjiREndH8Q="
},
"es6-promisify": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz",
@ -6074,53 +6063,22 @@
"integrity": "sha512-3IE39bHVqFbWWaPOMHZF98Q9c3LDKGTmypMiTM2QygGXXElkFWIH7GxfmlwmY2vwa+wmNsoYZmG2iusf1ZjJoA=="
},
"mongodb": {
"version": "2.2.36",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.36.tgz",
"integrity": "sha512-P2SBLQ8Z0PVx71ngoXwo12+FiSfbNfGOClAao03/bant5DgLNkOPAck5IaJcEk4gKlQhDEURzfR3xuBG1/B+IA==",
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.3.2.tgz",
"integrity": "sha512-fqJt3iywelk4yKu/lfwQg163Bjpo5zDKhXiohycvon4iQHbrfflSAz9AIlRE6496Pm/dQKQK5bMigdVo2s6gBg==",
"requires": {
"es6-promise": "3.2.1",
"mongodb-core": "2.1.20",
"readable-stream": "2.2.7"
"bson": "^1.1.1",
"require_optional": "^1.0.1",
"safe-buffer": "^5.1.2"
},
"dependencies": {
"process-nextick-args": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
"integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M="
},
"readable-stream": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz",
"integrity": "sha1-BwV6y+JGeyIELTb5jFrVBwVOlbE=",
"requires": {
"buffer-shims": "~1.0.0",
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "~1.0.0",
"process-nextick-args": "~1.0.6",
"string_decoder": "~1.0.0",
"util-deprecate": "~1.0.1"
}
},
"string_decoder": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
"requires": {
"safe-buffer": "~5.1.0"
}
"bson": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz",
"integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg=="
}
}
},
"mongodb-core": {
"version": "2.1.20",
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.20.tgz",
"integrity": "sha512-IN57CX5/Q1bhDq6ShAR6gIv4koFsZP7L8WOK1S0lR0pVDQaScffSMV5jxubLsmZ7J+UdqmykKw4r9hG3XQEGgQ==",
"requires": {
"bson": "~1.0.4",
"require_optional": "~1.0.0"
}
},
"mongodb-extended-json": {
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/mongodb-extended-json/-/mongodb-extended-json-1.10.1.tgz",
@ -8886,9 +8844,9 @@
"dev": true
},
"typescript": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.2.tgz",
"integrity": "sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==",
"version": "3.6.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.3.tgz",
"integrity": "sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==",
"dev": true
},
"uc.micro": {

Просмотреть файл

@ -900,8 +900,8 @@
"@types/glob": "^7.1.1",
"@types/keytar": "4.0.1",
"@types/mocha": "^5.2.5",
"@types/mongodb": "^2.2.9",
"@types/node": "^6.0.40",
"@types/mongodb": "^3.3.2",
"@types/node": "^12.7.8",
"@types/socket.io": "^1.4.32",
"@types/socket.io-client": "^1.4.32",
"antlr4ts-cli": "^0.4.0-alpha.4",
@ -932,7 +932,7 @@
"event-stream": "3.3.4",
"fs-extra": "^4.0.2",
"gremlin": "^2.6.0",
"mongodb": "^2.2.25",
"mongodb": "^3.3.2",
"mongodb-extended-json": "^1.10.0",
"ms-rest": "^2.2.1",
"node-uuid": "1.4.8",

Просмотреть файл

@ -76,3 +76,6 @@ export const defaultStoredProcedure =
export const emptyPartitionKeyValue = {};
export let emulatorPassword = 'C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==';
// https://docs.mongodb.com/manual/mongo/#working-with-the-mongo-shell
export const testDb: string = 'test';

Просмотреть файл

@ -6,6 +6,7 @@
import { EventEmitter } from 'events';
import * as gremlin from "gremlin";
import * as http from 'http';
import { AddressInfo } from 'net';
import * as io from 'socket.io';
import * as vscode from 'vscode';
import { callWithTelemetryAndErrorHandling, IActionContext } from 'vscode-azureextensionui';
@ -96,7 +97,7 @@ export class GraphViewServer extends EventEmitter {
this._httpServer.listen(
0, // dynamnically pick an unused port
() => {
this._port = this._httpServer.address().port;
this._port = (<AddressInfo>this._httpServer.address()).port;
console.log(`** GraphViewServer listening to port ${this._port} for ${this.configuration.gremlinEndpoint ? this.configuration.gremlinEndpoint.host : this.configuration.documentEndpoint}/${this._configuration.databaseName}/${this._configuration.graphName}`);
resolve();
});

Просмотреть файл

@ -11,7 +11,7 @@ import * as io from 'socket.io';
export class GraphViewServerSocket {
constructor(private _socket: io.Socket) { }
public onClientMessage(event: ClientMessage, listener: Function): void {
public onClientMessage(event: ClientMessage, listener: (...args) => unknown): void {
this._socket.on(event, listener);
}

Просмотреть файл

@ -3,15 +3,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Db, MongoClient, MongoClientOptions } from 'mongodb';
import { MongoClient, MongoClientOptions } from 'mongodb';
import { Links } from '../constants';
// Can't call appendExtensionUserAgent() here because languageClient.ts can't take a dependency on vscode-azureextensionui and hence vscode, so have
// to pass the user agent string in
export async function connectToMongoClient(connectionString: string, extensionUserAgent: string): Promise<Db> {
export async function connectToMongoClient(connectionString: string, extensionUserAgent: string): Promise<MongoClient> {
// appname appears to be the correct equivalent to user-agent for mongo
let options: MongoClientOptions = <MongoClientOptions>{
appname: extensionUserAgent
appname: extensionUserAgent,
// https://github.com/lmammino/mongo-uri-builder/issues/2
useNewUrlParser: true
};
try {

Просмотреть файл

@ -3,8 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ReplSet } from "mongodb";
import { MongoClient, Mongos, ReplSet, Server } from "mongodb";
import { appendExtensionUserAgent } from "vscode-azureextensionui";
import { testDb } from "../constants";
import { ParsedConnectionString } from "../ParsedConnectionString";
import { connectToMongoClient } from "./connectToMongoClient";
@ -48,18 +49,18 @@ export async function parseMongoConnectionString(connectionString: string): Prom
let host: string;
let port: string;
const db = await connectToMongoClient(connectionString, appendExtensionUserAgent());
const serverConfig = db.serverConfig;
const mongoClient: MongoClient = await connectToMongoClient(connectionString, appendExtensionUserAgent());
const serverConfig: Server | ReplSet | Mongos = mongoClient.db(testDb).serverConfig;
// Azure CosmosDB comes back as a ReplSet
if (serverConfig instanceof ReplSet) {
// get the first connection string from the seedlist for the ReplSet
// get the first connection string from the servers for the ReplSet
// this may not be best solution, but the connection (below) gives
// the replicaset host name, which is different than what is in the connection string
// "s" is not part of ReplSet static definition but can't find any official documentation on it. Yet it is definitely there at runtime. Grandfathering in.
// tslint:disable-next-line:no-any
let rs: any = serverConfig;
host = rs.s.replset.s.seedlist[0].host;
port = rs.s.replset.s.seedlist[0].port;
host = rs.s.options.servers[0].host;
port = rs.s.options.servers[0].port;
} else {
host = serverConfig['host'];
port = serverConfig['port'];

Просмотреть файл

@ -4,11 +4,11 @@
*--------------------------------------------------------------------------------------------*/
import { DatabaseAccount } from 'azure-arm-cosmosdb/lib/models';
import { Db } from 'mongodb';
import { MongoClient } from 'mongodb';
import * as vscode from 'vscode';
import { appendExtensionUserAgent, AzureParentTreeItem, AzureTreeItem, ICreateChildImplContext, parseError } from 'vscode-azureextensionui';
import { deleteCosmosDBAccount } from '../../commands/deleteCosmosDBAccount';
import { getThemedIconPath, Links } from '../../constants';
import { getThemedIconPath, Links, testDb } from '../../constants';
import { ext } from '../../extensionVariables';
import { connectToMongoClient } from '../connectToMongoClient';
import { getDatabaseNameFromConnectionString } from '../mongoConnectionStrings';
@ -49,7 +49,7 @@ export class MongoAccountTreeItem extends AzureParentTreeItem<IMongoTreeRoot> {
}
public async loadMoreChildrenImpl(_clearCache: boolean): Promise<AzureTreeItem<IMongoTreeRoot>[]> {
let db: Db | undefined;
let mongoClient: MongoClient | undefined;
try {
let databases: IDatabaseInfo[];
@ -57,7 +57,8 @@ export class MongoAccountTreeItem extends AzureParentTreeItem<IMongoTreeRoot> {
throw new Error('Missing connection string');
}
db = await connectToMongoClient(this.connectionString, appendExtensionUserAgent());
mongoClient = await connectToMongoClient(this.connectionString, appendExtensionUserAgent());
let databaseInConnectionString = getDatabaseNameFromConnectionString(this.connectionString);
if (databaseInConnectionString && !this.root.isEmulator) { // emulator violates the connection string format
// If the database is in the connection string, that's all we connect to (we might not even have permissions to list databases)
@ -66,7 +67,8 @@ export class MongoAccountTreeItem extends AzureParentTreeItem<IMongoTreeRoot> {
empty: false
}];
} else {
let result: { databases: IDatabaseInfo[] } = await db.admin().listDatabases();
// https://mongodb.github.io/node-mongodb-native/3.1/api/index.html
let result: { databases: IDatabaseInfo[] } = await mongoClient.db(testDb).admin().listDatabases();
databases = result.databases;
}
return databases
@ -80,8 +82,8 @@ export class MongoAccountTreeItem extends AzureParentTreeItem<IMongoTreeRoot> {
throw error;
}
finally {
if (db) {
db.close();
if (mongoClient) {
mongoClient.close();
}
}
}

Просмотреть файл

@ -28,7 +28,7 @@ let config = dev.getDefaultWebpackConfig({
'require_optional',
'gremlin',
'socket.io',
'mongodb-core',
'mongodb',
// Needed by graphClient.html
'd3'