Skip to content

Commit 4d6d58b

Browse files
committed
Pick options off of MongoClientOptions
1 parent 43e5925 commit 4d6d58b

File tree

2 files changed

+60
-64
lines changed

2 files changed

+60
-64
lines changed

src/mongo_client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export interface MongoURIOptions extends Pick<WriteConcernOptions, 'journal' | '
8181
/** Comma-delimited string of compressors to enable network compression for communication between this client and a mongod/mongos instance. */
8282
compressors?: string;
8383
/** An integer that specifies the compression level if using zlib for network compression. */
84-
zlibCompressionLevel?: number;
84+
zlibCompressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
8585
/** The maximum number of connections in the connection pool. */
8686
maxPoolSize?: number;
8787
/** The minimum number of connections in the connection pool. */

src/mongo_client_options.ts

Lines changed: 59 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import type { MongoCredentials } from './cmap/auth/mongo_credentials';
2-
import type { CompressorName } from './cmap/wire_protocol/compression';
3-
import type { AutoEncryptionOptions } from './deps';
4-
import type { Logger } from './logger';
5-
import type { DriverInfo, MongoClientOptions, PkFactory } from './mongo_client';
2+
import type { MongoClientOptions } from './mongo_client';
63
import type { ReadConcern } from './read_concern';
74
import type { ReadPreference } from './read_preference';
85
import type { WriteConcern } from './write_concern';
@@ -20,79 +17,78 @@ import { URL } from 'url';
2017
export interface MongoOptions
2118
extends Required<BSONSerializeOptions>,
2219
Omit<ConnectionOptions, 'port'>,
23-
Omit<TLSConnectionOptions, 'port'> {
20+
Omit<TLSConnectionOptions, 'port'>,
21+
Required<
22+
Pick<
23+
MongoClientOptions,
24+
| 'autoEncryption'
25+
| 'compression'
26+
| 'compressors'
27+
| 'connectTimeoutMS'
28+
| 'dbName'
29+
| 'directConnection'
30+
| 'domainsEnabled'
31+
| 'driverInfo'
32+
| 'forceServerObjectId'
33+
| 'gssapiServiceName'
34+
| 'ha'
35+
| 'haInterval'
36+
| 'heartbeatFrequencyMS'
37+
| 'keepAlive'
38+
| 'keepAliveInitialDelay'
39+
| 'localThresholdMS'
40+
| 'logger'
41+
| 'maxIdleTimeMS'
42+
| 'maxPoolSize'
43+
| 'minPoolSize'
44+
| 'monitorCommands'
45+
| 'noDelay'
46+
| 'numberOfRetries'
47+
| 'pkFactory'
48+
| 'promiseLibrary'
49+
| 'raw'
50+
| 'reconnectInterval'
51+
| 'reconnectTries'
52+
| 'replicaSet'
53+
| 'retryReads'
54+
| 'retryWrites'
55+
| 'serverSelectionTimeoutMS'
56+
| 'serverSelectionTryOnce'
57+
| 'socketTimeoutMS'
58+
| 'tlsAllowInvalidCertificates'
59+
| 'tlsAllowInvalidHostnames'
60+
| 'tlsInsecure'
61+
| 'waitQueueMultiple'
62+
| 'waitQueueTimeoutMS'
63+
| 'zlibCompressionLevel'
64+
>
65+
> {
2466
hosts: { host: string; port: number }[];
2567
srv: boolean;
26-
27-
autoEncryption: AutoEncryptionOptions;
2868
credentials: MongoCredentials;
29-
compression: CompressorName;
30-
compressors: CompressorName[];
31-
connectTimeoutMS: number;
32-
dbName: string;
33-
directConnection: boolean;
34-
domainsEnabled: boolean;
35-
driverInfo: DriverInfo;
36-
forceServerObjectId: boolean;
37-
gssapiServiceName: string;
38-
ha: boolean;
39-
haInterval: number;
40-
heartbeatFrequencyMS: number;
41-
keepAlive: boolean;
42-
keepAliveInitialDelay: number;
43-
localThresholdMS: number;
44-
logger: Logger;
45-
maxIdleTimeMS: number;
46-
47-
// poolSize: number;
48-
maxPoolSize: number;
49-
50-
maxStalenessSeconds: number;
51-
52-
// minSize: number;
53-
minPoolSize: number;
54-
55-
monitorCommands: boolean;
56-
noDelay: boolean;
57-
numberOfRetries: number;
58-
pkFactory: PkFactory;
59-
promiseLibrary: PromiseConstructorLike;
60-
raw: boolean;
61-
readConcern: ReadConcern;
6269
readPreference: ReadPreference;
63-
reconnectInterval: number;
64-
reconnectTries: number;
65-
replicaSet: string;
66-
retryReads: boolean;
67-
retryWrites: boolean;
68-
serverSelectionTimeoutMS: number;
69-
serverSelectionTryOnce: boolean;
70-
socketTimeoutMS: number;
70+
readConcern: ReadConcern;
71+
writeConcern: WriteConcern;
7172

7273
/**
74+
* # NOTE ABOUT TLS Options
75+
*
7376
* If set TLS enabled, equivalent to setting the ssl option.
7477
*
7578
* ### Additional options:
7679
*
77-
* | nodejs option | MongoDB equivalent | type |
78-
* |:---------------------|----------------------------------------------------|:---------------------------------------|
79-
* | `ca` | sslCA, tlsCAFile | `string \| Buffer \| Buffer[]` |
80-
* | `crl` | sslCRL | `string \| Buffer \| Buffer[]` |
81-
* | `cert` | sslCert, tlsCertificateFile, tlsCertificateKeyFile | `string \| Buffer \| Buffer[]` |
82-
* | `key` | sslKey, tlsCertificateKeyFile | `string \| Buffer \| KeyObject[]` |
83-
* | `passphrase` | sslPass, tlsCertificateKeyFilePassword | `string` |
84-
* | `rejectUnauthorized` | sslValidate | `boolean` |
80+
* | nodejs option | MongoDB equivalent | type |
81+
* |:---------------------|--------------------------------------------------------- |:---------------------------------------|
82+
* | `ca` | `sslCA`, `tlsCAFile` | `string \| Buffer \| Buffer[]` |
83+
* | `crl` | `sslCRL` | `string \| Buffer \| Buffer[]` |
84+
* | `cert` | `sslCert`, `tlsCertificateFile`, `tlsCertificateKeyFile` | `string \| Buffer \| Buffer[]` |
85+
* | `key` | `sslKey`, `tlsCertificateKeyFile` | `string \| Buffer \| KeyObject[]` |
86+
* | `passphrase` | `sslPass`, `tlsCertificateKeyFilePassword` | `string` |
87+
* | `rejectUnauthorized` | `sslValidate` | `boolean` |
8588
*
8689
*/
8790
tls: boolean;
88-
tlsAllowInvalidCertificates: boolean;
89-
tlsAllowInvalidHostnames: boolean;
90-
tlsInsecure: boolean;
9191

92-
waitQueueMultiple: number;
93-
waitQueueTimeoutMS: number;
94-
writeConcern: WriteConcern;
95-
zlibCompressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
9692
/**
9793
* Turn these options into a reusable options dictionary
9894
*/

0 commit comments

Comments
 (0)