44 Collection ,
55 GridFSBucket ,
66 Document ,
7- HostAddress
7+ HostAddress ,
8+ ServerApiVersion
89} from '../../../src/index' ;
910import { ReadConcern } from '../../../src/read_concern' ;
1011import { WriteConcern } from '../../../src/write_concern' ;
@@ -30,7 +31,7 @@ import type {
3031 CommandStartedEvent ,
3132 CommandSucceededEvent
3233} from '../../../src/cmap/command_monitoring_events' ;
33- import { patchCollectionOptions , patchDbOptions } from './unified-utils' ;
34+ import { makeConnectionString , patchCollectionOptions , patchDbOptions } from './unified-utils' ;
3435import { expect } from 'chai' ;
3536import { TestConfiguration , trace } from './runner' ;
3637
@@ -53,7 +54,7 @@ export type CmapEvent =
5354
5455function serverApiConfig ( ) {
5556 if ( process . env . MONGODB_API_VERSION ) {
56- return { version : process . env . MONGODB_API_VERSION } ;
57+ return { version : process . env . MONGODB_API_VERSION as ServerApiVersion } ;
5758 }
5859}
5960
@@ -102,12 +103,12 @@ export class UnifiedMongoClient extends MongoClient {
102103 connectionCheckedInEvent : 'connectionCheckedIn'
103104 } as const ;
104105
105- constructor ( url : string , description : ClientEntity ) {
106- super ( url , {
106+ constructor ( uri : string , description : ClientEntity ) {
107+ super ( uri , {
107108 monitorCommands : true ,
108- ...description . uriOptions ,
109109 serverApi : description . serverApi ? description . serverApi : serverApiConfig ( )
110110 } ) ;
111+
111112 this . commandEvents = [ ] ;
112113 this . cmapEvents = [ ] ;
113114 this . failPoints = [ ] ;
@@ -329,7 +330,10 @@ export class EntitiesMap<E = Entity> extends Map<string, E> {
329330 const useMultipleMongoses =
330331 ( config . topologyType === 'LoadBalanced' || config . topologyType === 'Sharded' ) &&
331332 entity . client . useMultipleMongoses ;
332- const uri = config . url ( { useMultipleMongoses } ) ;
333+ const uri = makeConnectionString (
334+ config . url ( { useMultipleMongoses } ) ,
335+ entity . client . uriOptions
336+ ) ;
333337 const client = new UnifiedMongoClient ( uri , entity . client ) ;
334338 await client . connect ( ) ;
335339 map . set ( entity . client . id , client ) ;
0 commit comments