Skip to content

Commit 973a923

Browse files
committed
feat: bump mongosh APIs to latest VSCODE-240
Also includes the change from #219 and bumps mongodb-connection-model to a version that depends on the 3.x driver directly instead of using it as a peer dependency, and minor drive-by things I’ve noticed (use `mongodb` itself only for typed imports, use `assert.strictEqual` where it gives a better error message, adjust types in preparation for a 4.0 driver update).
1 parent dca852c commit 973a923

File tree

9 files changed

+732
-2043
lines changed

9 files changed

+732
-2043
lines changed

package-lock.json

Lines changed: 715 additions & 2009 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -867,10 +867,10 @@
867867
"@iconify-icons/codicon": "^1.1.5",
868868
"@iconify/react": "^1.1.3",
869869
"@leafygreen-ui/toggle": "3.0.1",
870-
"@mongosh/browser-runtime-electron": "^0.6.1",
871-
"@mongosh/i18n": "^0.8.0",
872-
"@mongosh/service-provider-server": "^0.6.1",
873-
"@mongosh/shell-api": "^0.6.1",
870+
"@mongosh/browser-runtime-electron": "^0.15.0",
871+
"@mongosh/i18n": "^0.15.0",
872+
"@mongosh/service-provider-server": "^0.15.0",
873+
"@mongosh/shell-api": "^0.15.0",
874874
"analytics-node": "^3.5.0",
875875
"bson": "^4.2.0",
876876
"classnames": "^2.2.6",
@@ -879,7 +879,7 @@
879879
"micromatch": "^4.0.2",
880880
"mongodb": "^3.6.3",
881881
"mongodb-cloud-info": "^1.1.2",
882-
"mongodb-connection-model": "^19.0.2",
882+
"mongodb-connection-model": "^20.2.0",
883883
"mongodb-data-service": "^19.0.0",
884884
"mongodb-ns": "^2.2.0",
885885
"mongodb-schema": "^8.2.5",

src/language/mongoDBService.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CompletionItemKind, CancellationToken, Connection, CompletionItem, Mark
44
import fs from 'fs';
55
import path from 'path';
66
import { signatures } from '@mongosh/shell-api';
7-
import Translator from '@mongosh/i18n/lib/translator';
7+
import translator from '@mongosh/i18n';
88
import { Worker as WorkerThreads } from 'worker_threads';
99

1010
import { CollectionItem } from '../types/collectionItemType';
@@ -399,7 +399,6 @@ export default class MongoDBService {
399399
// Get shell API symbols/methods completion from mongosh.
400400
_getShellCompletionItems(): ShellCompletionItem {
401401
const shellSymbols = {};
402-
const translator = new Translator();
403402

404403
Object.keys(signatures).map((symbol) => {
405404
shellSymbols[symbol] = Object.keys(

src/language/worker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
CliServiceProvider,
3-
NodeOptions
3+
MongoClientOptions
44
} from '@mongosh/service-provider-server';
55
import { CompletionItemKind } from 'vscode-languageserver';
66
import { EJSON } from 'bson';
@@ -21,7 +21,7 @@ type WorkerError = any | null;
2121
const executeAll = async (
2222
codeToEvaluate: string,
2323
connectionString: string,
24-
connectionOptions: NodeOptions
24+
connectionOptions: MongoClientOptions
2525
): Promise<[WorkerError, WorkerResult?]> => {
2626
try {
2727
// Instantiate a data service provider.

src/telemetry/connectionTelemetry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Document, MongoClient } from 'mongodb';
1+
import type { Document, MongoClient } from 'mongodb';
22
import { getCloudInfo } from 'mongodb-cloud-info';
33
import mongoDBBuildInfo from 'mongodb-build-info';
44

src/telemetry/telemetryService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as vscode from 'vscode';
33
import { config } from 'dotenv';
44
import fs from 'fs';
55
import SegmentAnalytics from 'analytics-node';
6-
import { MongoClient } from 'mongodb';
6+
import type { MongoClient } from 'mongodb';
77

88
import { ConnectionModel } from '../types/connectionModelType';
99
import { ConnectionTypes } from '../connectionController';

src/test/suite/commands/launchMongoShell.test.ts

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ suite('Commands Test Suite', () => {
9595

9696
const shellCommandText = fakeSendTerminalText.firstCall.args[0];
9797

98-
assert(
99-
shellCommandText === 'mongo $MDB_CONNECTION_STRING;',
100-
'Expected sendText to terminal to be equal mongo $MDB_CONNECTION_STRING;'
101-
);
98+
assert.strictEqual(shellCommandText, 'mongo $MDB_CONNECTION_STRING;');
10299
});
103100

104101
test('openMongoDBShell should open a terminal with ssh tunnel port injected', async () => {
@@ -126,10 +123,7 @@ suite('Commands Test Suite', () => {
126123

127124
const shellCommandText = fakeSendTerminalText.firstCall.args[0];
128125

129-
assert(
130-
shellCommandText === 'mongo $MDB_CONNECTION_STRING;',
131-
'Expected sendText to terminal to be equal mongo $MDB_CONNECTION_STRING;'
132-
);
126+
assert.strictEqual(shellCommandText, 'mongo $MDB_CONNECTION_STRING;');
133127
});
134128

135129
test('openMongoDBShell should open a terminal with ssl config injected', async () => {
@@ -160,10 +154,7 @@ suite('Commands Test Suite', () => {
160154

161155
const shellCommandText = fakeSendTerminalText.firstCall.args[0];
162156

163-
assert(
164-
shellCommandText === 'mongo --tls --tlsAllowInvalidHostnames --tlsCAFile="./path_to_some_file" $MDB_CONNECTION_STRING;',
165-
'Expected sendText to terminal to iclude tls options and ssl connection string'
166-
);
157+
assert.strictEqual(shellCommandText, 'mongo --tls --tlsAllowInvalidHostnames --tlsCAFile="./path_to_some_file" $MDB_CONNECTION_STRING;');
167158
});
168159

169160
test('openMongoDBShell should open a terminal with x509 config injected', async () => {
@@ -189,17 +180,11 @@ suite('Commands Test Suite', () => {
189180
const terminalOptions: vscode.TerminalOptions =
190181
createTerminalStub.firstCall.args[0];
191182

192-
assert(
193-
terminalOptions.env?.MDB_CONNECTION_STRING === driverUri,
194-
`Expected open terminal to set shell arg as driver url "${driverUri}" found "${terminalOptions.env?.MDB_CONNECTION_STRING}"`
195-
);
183+
assert.strictEqual(terminalOptions.env?.MDB_CONNECTION_STRING, driverUri);
196184

197185
const shellCommandText = fakeSendTerminalText.firstCall.args[0];
198186

199-
assert(
200-
shellCommandText === 'mongo --tls --tlsAllowInvalidHostnames --tlsCAFile="./path_to_ca" --tlsCertificateKeyFile="./path_to_cert" $MDB_CONNECTION_STRING;',
201-
'Expected sendText to terminal to iclude tls options and x509 connection string'
202-
);
187+
assert.strictEqual(shellCommandText, 'mongo --tls --tlsAllowInvalidHostnames --tlsCAFile="./path_to_ca" --tlsCertificateKeyFile="./path_to_cert" $MDB_CONNECTION_STRING;');
203188
});
204189
});
205190

@@ -235,7 +220,7 @@ suite('Commands Test Suite', () => {
235220
const shellCommandText = fakeSendTerminalText.firstCall.args[0];
236221
assert(
237222
shellCommandText.includes('$Env:MDB_CONNECTION_STRING'),
238-
'Expected sendText to terminal to use powershell env variable syntax'
223+
`Expected sendText to terminal (${shellCommandText}) to use powershell env variable syntax`
239224
);
240225
});
241226

src/test/suite/telemetry/connectionTelemetry.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ConnectionTypes } from '../../../connectionController';
1212

1313
suite('ConnectionTelemetry Controller Test Suite', () => {
1414
suite('with mock client', () => {
15-
const mockClient = {
15+
const mockClient: any = {
1616
db: () => ({
1717
command: () => ({})
1818
})

src/types/connectionOptionsType.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export type ConnectionOptions = {
77
password: string;
88
};
99
useUnifiedTopology?: boolean;
10-
connectWithNoPrimary?: boolean;
1110
useNewUrlParser?: boolean;
1211
port?: number;
1312
authSource?: string;

0 commit comments

Comments
 (0)