@@ -11,7 +11,7 @@ import { UUID } from 'mongodb';
1111
1212import connect from './connect' ;
1313import type { ConnectionOptions } from './connection-options' ;
14- import type DataService from './data-service' ;
14+ import type { DataServiceImpl , default as DataService } from './data-service' ;
1515import { redactConnectionOptions } from './redact' ;
1616import { runCommand } from './run-command' ;
1717import { MongoLogWriter } from 'mongodb-log-writer' ;
@@ -37,7 +37,7 @@ const buildConnectionString = (
3737 username : string | undefined ,
3838 password : string | undefined ,
3939 host : string | undefined ,
40- params ?: MongoClientOptions
40+ params ?: Partial < Record < keyof MongoClientOptions , string > >
4141) : string => {
4242 if ( ! username || ! password || ! host ) {
4343 return '' ;
@@ -135,7 +135,7 @@ describe('connect', function () {
135135 return this . skip ( ) ;
136136 }
137137
138- let dataService : DataService ;
138+ let dataService : DataService | undefined ;
139139
140140 try {
141141 dataService = await connect ( {
@@ -147,11 +147,14 @@ describe('connect', function () {
147147 const explainPlan = await dataService . explainFind ( 'test.test' , { } , { } ) ;
148148
149149 const targetHost = explainPlan ?. serverInfo ?. host ;
150+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
150151 const replSetStatus : any = await runCommand (
151- dataService [ '_database' ] ( 'admin' , 'META' ) ,
152+ ( dataService as DataServiceImpl ) [ '_database' ] ( 'admin' , 'META' ) ,
153+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
152154 { replSetGetStatus : 1 } as any
153155 ) ;
154- const targetHostStatus = replSetStatus ?. members . find ( ( member ) =>
156+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
157+ const targetHostStatus = replSetStatus ?. members . find ( ( member : any ) =>
155158 member . name . startsWith ( targetHost )
156159 ) ;
157160
@@ -166,7 +169,7 @@ describe('connect', function () {
166169 return this . skip ( ) ;
167170 }
168171
169- let dataService : DataService ;
172+ let dataService : DataService | undefined ;
170173
171174 try {
172175 dataService = await connect ( {
@@ -177,18 +180,23 @@ describe('connect', function () {
177180
178181 const explainPlan = await dataService . explainFind ( 'test.test' , { } , { } ) ;
179182
183+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
180184 const replSetGetConfig : any = await runCommand (
181- dataService [ '_database' ] ( 'admin' , 'META' ) ,
185+ ( dataService as DataServiceImpl ) [ '_database' ] ( 'admin' , 'META' ) ,
186+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
182187 { replSetGetConfig : 1 } as any
183188 ) ;
184189
185- const analtyticsNode = replSetGetConfig ?. config ?. members . find (
186- ( member ) => member ?. tags . nodeType === 'ANALYTICS'
190+ const analyticsNode = replSetGetConfig ?. config ?. members . find (
191+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
192+ ( member : any ) => member ?. tags . nodeType === 'ANALYTICS'
187193 ) ;
188194
195+ expect ( explainPlan ?. serverInfo ?. host ) . to . exist ;
196+
189197 // test that queries are routed to the analytics node
190198 expect ( explainPlan ?. serverInfo ?. host ) . to . be . equal (
191- analtyticsNode ?. host . split ( ':' ) [ 0 ]
199+ analyticsNode ?. host . split ( ':' ) [ 0 ]
192200 ) ;
193201 } finally {
194202 await dataService ?. disconnect ( ) ;
@@ -694,7 +702,7 @@ async function connectAndGetAuthInfo(connectionOptions: ConnectionOptions) {
694702 : undefined ,
695703 } ) ;
696704 const connectionStatus = await runCommand (
697- dataService [ '_database' ] ( 'admin' , 'META' ) ,
705+ ( dataService as DataServiceImpl ) [ '_database' ] ( 'admin' , 'META' ) ,
698706 { connectionStatus : 1 }
699707 ) ;
700708
0 commit comments