@@ -3,28 +3,20 @@ import { connect, createConnectionAttempt } from 'mongodb-data-service';
33import type {
44 DataService ,
55 ConnectionAttempt ,
6- ConnectionOptions as ConnectionOptionsFromCurrentDS ,
6+ ConnectionOptions ,
77} from 'mongodb-data-service' ;
88import ConnectionString from 'mongodb-connection-string-url' ;
99import { EventEmitter } from 'events' ;
1010import type { MongoClientOptions } from 'mongodb' ;
1111import { v4 as uuidv4 } from 'uuid' ;
1212import { cloneDeep , merge } from 'lodash' ;
1313import { mongoLogId } from 'mongodb-log-writer' ;
14- import type {
15- ConnectionInfo as ConnectionInfoFromLegacyDS ,
16- ConnectionOptions as ConnectionOptionsFromLegacyDS ,
17- } from 'mongodb-data-service-legacy' ;
18- import {
19- extractSecrets ,
20- convertConnectionModelToInfo ,
21- } from 'mongodb-data-service-legacy' ;
14+ import { extractSecrets } from '@mongodb-js/connection-info' ;
2215import { adjustConnectionOptionsBeforeConnect } from '@mongodb-js/connection-form' ;
2316
2417import { CONNECTION_STATUS } from './views/webview-app/extension-app-message-constants' ;
2518import { createLogger } from './logging' ;
2619import formatError from './utils/formatError' ;
27- import type LegacyConnectionModel from './views/webview-app/legacy/connection-model/legacy-connection-model' ;
2820import type { StorageController } from './storage' ;
2921import type { StatusView } from './views' ;
3022import type TelemetryService from './telemetry/telemetryService' ;
@@ -75,13 +67,6 @@ type RecursivePartial<T> = {
7567 : T [ P ] ;
7668} ;
7769
78- export function launderConnectionOptionTypeFromLegacyToCurrent (
79- opts : ConnectionOptionsFromLegacyDS
80- ) : ConnectionOptionsFromCurrentDS {
81- // Ensure that, at most, the types for OIDC mismatch here.
82- return opts as Omit < typeof opts , 'oidc' > ;
83- }
84-
8570export default class ConnectionController {
8671 // This is a map of connection ids to their configurations.
8772 // These connections can be saved on the session (runtime),
@@ -244,25 +229,19 @@ export default class ConnectionController {
244229 ) ;
245230 }
246231
247- parseNewConnection (
248- rawConnectionModel : LegacyConnectionModel
249- ) : ConnectionInfoFromLegacyDS {
250- return convertConnectionModelToInfo ( {
251- ...rawConnectionModel ,
252- appname : `${ packageJSON . name } ${ packageJSON . version } ` , // Override the default connection appname.
253- } ) ;
254- }
255-
256232 async saveNewConnectionAndConnect (
257- originalConnectionInfo : ConnectionInfoFromLegacyDS ,
233+ connection : {
234+ connectionOptions : ConnectionOptions ;
235+ id : string ;
236+ } ,
258237 connectionType : ConnectionTypes
259238 ) : Promise < ConnectionAttemptResult > {
260239 const savedConnectionWithoutSecrets =
261- await this . _connectionStorage . saveNewConnection ( originalConnectionInfo ) ;
240+ await this . _connectionStorage . saveNewConnection ( connection ) ;
262241
263242 this . _connections [ savedConnectionWithoutSecrets . id ] = {
264243 ...savedConnectionWithoutSecrets ,
265- connectionOptions : originalConnectionInfo . connectionOptions , // The connection options with secrets.
244+ connectionOptions : connection . connectionOptions , // The connection options with secrets.
266245 } ;
267246
268247 log . info (
@@ -326,9 +305,7 @@ export default class ConnectionController {
326305 let dataService ;
327306 try {
328307 const connectionOptions = adjustConnectionOptionsBeforeConnect ( {
329- connectionOptions : launderConnectionOptionTypeFromLegacyToCurrent (
330- connectionInfo . connectionOptions
331- ) ,
308+ connectionOptions : connectionInfo . connectionOptions ,
332309 defaultAppName : packageJSON . name ,
333310 notifyDeviceFlow : undefined ,
334311 preferences : {
0 commit comments