@@ -126,7 +126,7 @@ const DEFAULT_BASE_OPTIONS = Object.freeze({
126
126
* @param clientOptions {MongoClientOptions}
127
127
* @param mClient {MongoClient}
128
128
*/
129
- export async function connectMongoClient ( uri : string , clientOptions : MongoClientOptions , mClient = MongoClient ) : Promise < MongoClient | void > {
129
+ export async function connectMongoClient ( uri : string , clientOptions : MongoClientOptions , mClient = MongoClient ) : Promise < MongoClient > {
130
130
if ( clientOptions . autoEncryption !== undefined &&
131
131
! clientOptions . autoEncryption . bypassAutoEncryption ) {
132
132
// connect first without autoEncryptionOptions
@@ -135,11 +135,11 @@ export async function connectMongoClient(uri: string, clientOptions: MongoClient
135
135
const client = await mClient . connect ( uri , optionsWithoutFLE ) ;
136
136
const buildInfo = await client . db ( 'admin' ) . admin ( ) . command ( { buildInfo : 1 } ) ;
137
137
if (
138
- ! ( buildInfo . gitVersion && buildInfo . gitVersion . match ( / e n t e r p r i s e / ) ) &&
139
- ! ( buildInfo . modules && buildInfo . modules . indexOf ( ' enterprise' ) !== - 1 )
138
+ ! ( buildInfo . modules ?. includes ( ' enterprise' ) ) &&
139
+ ! ( buildInfo . gitVersion ?. match ( / e n t e r p r i s e / ) )
140
140
) {
141
141
await client . close ( ) ;
142
- throw new MongoshRuntimeError ( 'Cannot turn on automatic encryption for connections to non-enterprise hosts ' ) ;
142
+ throw new MongoshRuntimeError ( 'Automatic encryption is only available with Atlas and MongoDB Enterprise ' ) ;
143
143
}
144
144
await client . close ( ) ;
145
145
}
@@ -173,7 +173,7 @@ class CliServiceProvider extends ServiceProviderCore implements ServiceProvider
173
173
await connectMongoClient (
174
174
uri ,
175
175
clientOptions
176
- ) as MongoClient :
176
+ ) :
177
177
new MongoClient ( uri || 'mongodb://nodb/' , clientOptions ) ;
178
178
179
179
return new CliServiceProvider ( mongoClient , clientOptions , uri ) ;
@@ -223,7 +223,7 @@ class CliServiceProvider extends ServiceProviderCore implements ServiceProvider
223
223
const mongoClient = await connectMongoClient (
224
224
uri ,
225
225
clientOptions
226
- ) as MongoClient ;
226
+ ) ;
227
227
return new CliServiceProvider ( mongoClient , uri ) ;
228
228
}
229
229
@@ -1054,7 +1054,7 @@ class CliServiceProvider extends ServiceProviderCore implements ServiceProvider
1054
1054
const mc = await connectMongoClient (
1055
1055
this . uri as string ,
1056
1056
clientOptions
1057
- ) as MongoClient ;
1057
+ ) ;
1058
1058
try {
1059
1059
await this . mongoClient . close ( ) ;
1060
1060
// eslint-disable-next-line no-empty
@@ -1123,7 +1123,7 @@ class CliServiceProvider extends ServiceProviderCore implements ServiceProvider
1123
1123
const mc = await connectMongoClient (
1124
1124
this . uri as string ,
1125
1125
clientOptions
1126
- ) as MongoClient ;
1126
+ ) ;
1127
1127
try {
1128
1128
await this . mongoClient . close ( ) ;
1129
1129
// eslint-disable-next-line no-empty
0 commit comments