mongodb 6.12.0 → 6.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/lib/beta.d.ts +176 -108
  2. package/lib/bulk/common.js +5 -7
  3. package/lib/bulk/common.js.map +1 -1
  4. package/lib/change_stream.js +16 -26
  5. package/lib/change_stream.js.map +1 -1
  6. package/lib/client-side-encryption/auto_encrypter.js +4 -2
  7. package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
  8. package/lib/client-side-encryption/client_encryption.js +4 -4
  9. package/lib/client-side-encryption/client_encryption.js.map +1 -1
  10. package/lib/client-side-encryption/state_machine.js +56 -30
  11. package/lib/client-side-encryption/state_machine.js.map +1 -1
  12. package/lib/cmap/auth/mongodb_oidc.js +1 -1
  13. package/lib/cmap/auth/mongodb_oidc.js.map +1 -1
  14. package/lib/cmap/command_monitoring_events.js +9 -50
  15. package/lib/cmap/command_monitoring_events.js.map +1 -1
  16. package/lib/cmap/connection.js +28 -22
  17. package/lib/cmap/connection.js.map +1 -1
  18. package/lib/cmap/connection_pool.js +88 -117
  19. package/lib/cmap/connection_pool.js.map +1 -1
  20. package/lib/cmap/wire_protocol/on_data.js +6 -1
  21. package/lib/cmap/wire_protocol/on_data.js.map +1 -1
  22. package/lib/collection.js.map +1 -1
  23. package/lib/connection_string.js +68 -86
  24. package/lib/connection_string.js.map +1 -1
  25. package/lib/cursor/abstract_cursor.js +47 -18
  26. package/lib/cursor/abstract_cursor.js.map +1 -1
  27. package/lib/cursor/aggregation_cursor.js +2 -1
  28. package/lib/cursor/aggregation_cursor.js.map +1 -1
  29. package/lib/cursor/find_cursor.js +2 -1
  30. package/lib/cursor/find_cursor.js.map +1 -1
  31. package/lib/cursor/list_collections_cursor.js +2 -1
  32. package/lib/cursor/list_collections_cursor.js.map +1 -1
  33. package/lib/db.js +2 -1
  34. package/lib/db.js.map +1 -1
  35. package/lib/encrypter.js +5 -9
  36. package/lib/encrypter.js.map +1 -1
  37. package/lib/error.js +10 -18
  38. package/lib/error.js.map +1 -1
  39. package/lib/index.js +5 -2
  40. package/lib/index.js.map +1 -1
  41. package/lib/mongo_client.js +46 -26
  42. package/lib/mongo_client.js.map +1 -1
  43. package/lib/mongo_logger.js +102 -3
  44. package/lib/mongo_logger.js.map +1 -1
  45. package/lib/operations/execute_operation.js +9 -5
  46. package/lib/operations/execute_operation.js.map +1 -1
  47. package/lib/operations/list_collections.js.map +1 -1
  48. package/lib/operations/operation.js +4 -5
  49. package/lib/operations/operation.js.map +1 -1
  50. package/lib/sdam/monitor.js +25 -31
  51. package/lib/sdam/monitor.js.map +1 -1
  52. package/lib/sdam/server.js +27 -17
  53. package/lib/sdam/server.js.map +1 -1
  54. package/lib/sdam/topology.js +20 -19
  55. package/lib/sdam/topology.js.map +1 -1
  56. package/lib/sessions.js +24 -48
  57. package/lib/sessions.js.map +1 -1
  58. package/lib/utils.js +64 -44
  59. package/lib/utils.js.map +1 -1
  60. package/mongodb.d.ts +176 -108
  61. package/package.json +1 -1
  62. package/src/bulk/common.ts +6 -9
  63. package/src/change_stream.ts +21 -33
  64. package/src/client-side-encryption/auto_encrypter.ts +12 -8
  65. package/src/client-side-encryption/client_encryption.ts +6 -4
  66. package/src/client-side-encryption/state_machine.ts +80 -36
  67. package/src/cmap/auth/mongodb_oidc.ts +1 -1
  68. package/src/cmap/command_monitoring_events.ts +10 -55
  69. package/src/cmap/connection.ts +37 -29
  70. package/src/cmap/connection_pool.ts +121 -145
  71. package/src/cmap/wire_protocol/on_data.ts +9 -2
  72. package/src/collection.ts +15 -8
  73. package/src/connection_string.ts +74 -99
  74. package/src/cursor/abstract_cursor.ts +71 -23
  75. package/src/cursor/aggregation_cursor.ts +5 -3
  76. package/src/cursor/find_cursor.ts +5 -3
  77. package/src/cursor/list_collections_cursor.ts +5 -3
  78. package/src/db.ts +11 -7
  79. package/src/encrypter.ts +6 -11
  80. package/src/error.ts +11 -23
  81. package/src/index.ts +3 -3
  82. package/src/mongo_client.ts +78 -47
  83. package/src/mongo_logger.ts +158 -11
  84. package/src/mongo_types.ts +38 -0
  85. package/src/operations/execute_operation.ts +11 -6
  86. package/src/operations/list_collections.ts +4 -1
  87. package/src/operations/operation.ts +8 -9
  88. package/src/sdam/monitor.ts +30 -38
  89. package/src/sdam/server.ts +33 -20
  90. package/src/sdam/topology.ts +29 -26
  91. package/src/sessions.ts +37 -58
  92. package/src/utils.ts +79 -43
package/lib/beta.d.ts CHANGED
@@ -30,6 +30,44 @@ import type { ConnectionOptions as ConnectionOptions_2 } from 'tls';
30
30
  import type { TLSSocket } from 'tls';
31
31
  import type { TLSSocketOptions } from 'tls';
32
32
 
33
+ /** @public */
34
+ export declare type Abortable = {
35
+ /**
36
+ * @experimental
37
+ * When provided, the corresponding `AbortController` can be used to abort an asynchronous action.
38
+ *
39
+ * The `signal.reason` value is used as the error thrown.
40
+ *
41
+ * @remarks
42
+ * **NOTE:** If an abort signal aborts an operation while the driver is writing to the underlying
43
+ * socket or reading the response from the server, the socket will be closed.
44
+ * If signals are aborted at a high rate during socket read/writes this can lead to a high rate of connection reestablishment.
45
+ *
46
+ * We plan to mitigate this in a future release, please follow NODE-6062 (`timeoutMS` expiration suffers the same limitation).
47
+ *
48
+ * AbortSignals are likely a best fit for human interactive interruption (ex. ctrl-C) where the frequency
49
+ * of cancellation is reasonably low. If a signal is programmatically aborted for 100s of operations you can empty
50
+ * the driver's connection pool.
51
+ *
52
+ * @example
53
+ * ```js
54
+ * const controller = new AbortController();
55
+ * const { signal } = controller;
56
+ * process.on('SIGINT', () => controller.abort(new Error('^C pressed')));
57
+ *
58
+ * try {
59
+ * const res = await fetch('...', { signal });
60
+ * await collection.findOne(await res.json(), { signal });
61
+ * catch (error) {
62
+ * if (error === signal.reason) {
63
+ * // signal abort error handling
64
+ * }
65
+ * }
66
+ * ```
67
+ */
68
+ signal?: AbortSignal | undefined;
69
+ };
70
+
33
71
  /** @public */
34
72
  export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends AbstractCursorEvents = AbstractCursorEvents> extends TypedEventEmitter<CursorEvents> implements AsyncDisposable_2 {
35
73
  /* Excluded from this release type: cursorId */
@@ -47,6 +85,8 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
47
85
  /** @event */
48
86
  static readonly CLOSE: "close";
49
87
  /* Excluded from this release type: deserializationOptions */
88
+ protected signal: AbortSignal | undefined;
89
+ private abortListener;
50
90
  /* Excluded from this release type: __constructor */
51
91
  /**
52
92
  * The cursor has no id until it receives a response from the initial cursor creating command.
@@ -81,6 +121,8 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
81
121
  */
82
122
  [Symbol.asyncDispose]: () => Promise<void>;
83
123
  /* Excluded from this release type: asyncDispose */
124
+ /** Adds cursor to client's tracking so it will be closed by MongoClient.close() */
125
+ private trackCursor;
84
126
  /** Returns current buffered documents length */
85
127
  bufferedCount(): number;
86
128
  /** Returns current buffered documents */
@@ -1117,9 +1159,9 @@ export declare class ChangeStream<TSchema extends Document = Document, TChange e
1117
1159
  type: symbol;
1118
1160
  /* Excluded from this release type: cursor */
1119
1161
  streamOptions?: CursorStreamOptions;
1120
- /* Excluded from this release type: [kCursorStream] */
1121
- /* Excluded from this release type: [kClosed] */
1122
- /* Excluded from this release type: [kMode] */
1162
+ /* Excluded from this release type: cursorStream */
1163
+ /* Excluded from this release type: isClosed */
1164
+ /* Excluded from this release type: mode */
1123
1165
  /** @event */
1124
1166
  static readonly RESPONSE: "response";
1125
1167
  /** @event */
@@ -1152,7 +1194,6 @@ export declare class ChangeStream<TSchema extends Document = Document, TChange e
1152
1194
  */
1153
1195
  private contextOwner;
1154
1196
  /* Excluded from this release type: __constructor */
1155
- /* Excluded from this release type: cursorStream */
1156
1197
  /** The cached resume token that is used to resume after the most recently returned change. */
1157
1198
  get resumeToken(): ResumeToken;
1158
1199
  /** Check if there is any document still available in the Change Stream */
@@ -2247,11 +2288,11 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
2247
2288
  defaultTransactionOptions: TransactionOptions;
2248
2289
  transaction: Transaction;
2249
2290
  /* Excluded from this release type: commitAttempted */
2250
- /* Excluded from this release type: [kServerSession] */
2251
- /* Excluded from this release type: [kSnapshotTime] */
2252
- /* Excluded from this release type: [kSnapshotEnabled] */
2253
- /* Excluded from this release type: [kPinnedConnection] */
2254
- /* Excluded from this release type: [kTxnNumberIncrement] */
2291
+ readonly snapshotEnabled: boolean;
2292
+ /* Excluded from this release type: _serverSession */
2293
+ /* Excluded from this release type: snapshotTime */
2294
+ /* Excluded from this release type: pinnedConnection */
2295
+ /* Excluded from this release type: txnNumberIncrement */
2255
2296
  /**
2256
2297
  * @experimental
2257
2298
  * Specifies the time an operation in a given `ClientSession` will run until it throws a timeout error
@@ -2262,10 +2303,7 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
2262
2303
  /** The server id associated with this session */
2263
2304
  get id(): ServerSessionId | undefined;
2264
2305
  get serverSession(): ServerSession;
2265
- /** Whether or not this session is configured for snapshot reads */
2266
- get snapshotEnabled(): boolean;
2267
2306
  get loadBalanced(): boolean;
2268
- /* Excluded from this release type: pinnedConnection */
2269
2307
  /* Excluded from this release type: pin */
2270
2308
  /* Excluded from this release type: unpin */
2271
2309
  get isPinned(): boolean;
@@ -2723,18 +2761,18 @@ export declare class Collection<TSchema extends Document = Document> {
2723
2761
  */
2724
2762
  findOne(): Promise<WithId<TSchema> | null>;
2725
2763
  findOne(filter: Filter<TSchema>): Promise<WithId<TSchema> | null>;
2726
- findOne(filter: Filter<TSchema>, options: Omit<FindOptions, 'timeoutMode'>): Promise<WithId<TSchema> | null>;
2764
+ findOne(filter: Filter<TSchema>, options: Omit<FindOptions, 'timeoutMode'> & Abortable): Promise<WithId<TSchema> | null>;
2727
2765
  findOne<T = TSchema>(): Promise<T | null>;
2728
2766
  findOne<T = TSchema>(filter: Filter<TSchema>): Promise<T | null>;
2729
- findOne<T = TSchema>(filter: Filter<TSchema>, options?: Omit<FindOptions, 'timeoutMode'>): Promise<T | null>;
2767
+ findOne<T = TSchema>(filter: Filter<TSchema>, options?: Omit<FindOptions, 'timeoutMode'> & Abortable): Promise<T | null>;
2730
2768
  /**
2731
2769
  * Creates a cursor for a filter that can be used to iterate over results from MongoDB
2732
2770
  *
2733
2771
  * @param filter - The filter predicate. If unspecified, then all documents in the collection will match the predicate
2734
2772
  */
2735
2773
  find(): FindCursor<WithId<TSchema>>;
2736
- find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<WithId<TSchema>>;
2737
- find<T extends Document>(filter: Filter<TSchema>, options?: FindOptions): FindCursor<T>;
2774
+ find(filter: Filter<TSchema>, options?: FindOptions & Abortable): FindCursor<WithId<TSchema>>;
2775
+ find<T extends Document>(filter: Filter<TSchema>, options?: FindOptions & Abortable): FindCursor<T>;
2738
2776
  /**
2739
2777
  * Returns the options of the collection.
2740
2778
  *
@@ -2889,7 +2927,7 @@ export declare class Collection<TSchema extends Document = Document> {
2889
2927
  * @see https://www.mongodb.com/docs/manual/reference/operator/query/center/#op._S_center
2890
2928
  * @see https://www.mongodb.com/docs/manual/reference/operator/query/centerSphere/#op._S_centerSphere
2891
2929
  */
2892
- countDocuments(filter?: Filter<TSchema>, options?: CountDocumentsOptions): Promise<number>;
2930
+ countDocuments(filter?: Filter<TSchema>, options?: CountDocumentsOptions & Abortable): Promise<number>;
2893
2931
  /**
2894
2932
  * The distinct command returns a list of distinct values for the given key across a collection.
2895
2933
  *
@@ -2966,7 +3004,7 @@ export declare class Collection<TSchema extends Document = Document> {
2966
3004
  * @param pipeline - An array of aggregation pipelines to execute
2967
3005
  * @param options - Optional settings for the command
2968
3006
  */
2969
- aggregate<T extends Document = Document>(pipeline?: Document[], options?: AggregateOptions): AggregationCursor<T>;
3007
+ aggregate<T extends Document = Document>(pipeline?: Document[], options?: AggregateOptions & Abortable): AggregationCursor<T>;
2970
3008
  /**
2971
3009
  * Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this collection.
2972
3010
  *
@@ -3876,7 +3914,7 @@ export declare class Db {
3876
3914
  * @param command - The command to run
3877
3915
  * @param options - Optional settings for the command
3878
3916
  */
3879
- command(command: Document, options?: RunCommandOptions): Promise<Document>;
3917
+ command(command: Document, options?: RunCommandOptions & Abortable): Promise<Document>;
3880
3918
  /**
3881
3919
  * Execute an aggregation framework pipeline against the database.
3882
3920
  *
@@ -3909,11 +3947,11 @@ export declare class Db {
3909
3947
  */
3910
3948
  listCollections(filter: Document, options: Exclude<ListCollectionsOptions, 'nameOnly'> & {
3911
3949
  nameOnly: true;
3912
- }): ListCollectionsCursor<Pick<CollectionInfo, 'name' | 'type'>>;
3950
+ } & Abortable): ListCollectionsCursor<Pick<CollectionInfo, 'name' | 'type'>>;
3913
3951
  listCollections(filter: Document, options: Exclude<ListCollectionsOptions, 'nameOnly'> & {
3914
3952
  nameOnly: false;
3915
- }): ListCollectionsCursor<CollectionInfo>;
3916
- listCollections<T extends Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo = Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo>(filter?: Document, options?: ListCollectionsOptions): ListCollectionsCursor<T>;
3953
+ } & Abortable): ListCollectionsCursor<CollectionInfo>;
3954
+ listCollections<T extends Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo = Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo>(filter?: Document, options?: ListCollectionsOptions & Abortable): ListCollectionsCursor<T>;
3917
3955
  /**
3918
3956
  * Rename a collection.
3919
3957
  *
@@ -5199,30 +5237,8 @@ export declare type Join<T extends unknown[], D extends string> = T extends [] ?
5199
5237
 
5200
5238
  /* Excluded from this release type: JSTypeOf */
5201
5239
 
5202
- /* Excluded from this release type: kBeforeHandshake */
5203
-
5204
- /* Excluded from this release type: kCancellationToken */
5205
-
5206
- /* Excluded from this release type: kCancellationToken_2 */
5207
-
5208
- /* Excluded from this release type: kCancelled */
5209
-
5210
- /* Excluded from this release type: kCancelled_2 */
5211
-
5212
- /* Excluded from this release type: kCheckedOut */
5213
-
5214
- /* Excluded from this release type: kClosed */
5215
-
5216
- /* Excluded from this release type: kConnectionCounter */
5217
-
5218
- /* Excluded from this release type: kConnections */
5219
-
5220
- /* Excluded from this release type: kCursorStream */
5221
-
5222
5240
  /* Excluded from this release type: kDecorateResult */
5223
5241
 
5224
- /* Excluded from this release type: kErrorLabels */
5225
-
5226
5242
  /** @public */
5227
5243
  export declare type KeysOfAType<TSchema, Type> = {
5228
5244
  [key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? key : never;
@@ -5233,14 +5249,6 @@ export declare type KeysOfOtherType<TSchema, Type> = {
5233
5249
  [key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? never : key;
5234
5250
  }[keyof TSchema];
5235
5251
 
5236
- /* Excluded from this release type: kGeneration */
5237
-
5238
- /* Excluded from this release type: kInternalClient */
5239
-
5240
- /* Excluded from this release type: kMetrics */
5241
-
5242
- /* Excluded from this release type: kMinPoolSizeTimer */
5243
-
5244
5252
  /**
5245
5253
  * @public
5246
5254
  * Configuration options for making a KMIP encryption key
@@ -5274,10 +5282,6 @@ export declare interface KMIPKMSProviderConfiguration {
5274
5282
  endpoint?: string;
5275
5283
  }
5276
5284
 
5277
- /* Excluded from this release type: kMode */
5278
-
5279
- /* Excluded from this release type: kMonitorId */
5280
-
5281
5285
  /**
5282
5286
  * @public
5283
5287
  * Configuration options that are used by specific KMS providers during key generation, encryption, and decryption.
@@ -5312,38 +5316,6 @@ export declare interface KMSProviders {
5312
5316
  [key: `gcp:${string}`]: GCPKMSProviderConfiguration;
5313
5317
  }
5314
5318
 
5315
- /* Excluded from this release type: kOptions */
5316
-
5317
- /* Excluded from this release type: kPending */
5318
-
5319
- /* Excluded from this release type: kPinnedConnection */
5320
-
5321
- /* Excluded from this release type: kPoolState */
5322
-
5323
- /* Excluded from this release type: kProcessingWaitQueue */
5324
-
5325
- /* Excluded from this release type: kServer */
5326
-
5327
- /* Excluded from this release type: kServer_2 */
5328
-
5329
- /* Excluded from this release type: kServerError */
5330
-
5331
- /* Excluded from this release type: kServerSession */
5332
-
5333
- /* Excluded from this release type: kServiceGenerations */
5334
-
5335
- /* Excluded from this release type: kSession */
5336
-
5337
- /* Excluded from this release type: kSnapshotEnabled */
5338
-
5339
- /* Excluded from this release type: kSnapshotTime */
5340
-
5341
- /* Excluded from this release type: kTxnNumberIncrement */
5342
-
5343
- /* Excluded from this release type: kWaitQueue */
5344
-
5345
- /* Excluded from this release type: kWaitQueue_2 */
5346
-
5347
5319
  /* Excluded from this release type: LegacyTimeoutContext */
5348
5320
 
5349
5321
  /* Excluded from this release type: LegacyTimeoutContextOptions */
@@ -5360,14 +5332,14 @@ export declare const LEGAL_TLS_SOCKET_OPTIONS: readonly ["allowPartialTrustChain
5360
5332
  export declare class ListCollectionsCursor<T extends Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo = Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo> extends AbstractCursor<T> {
5361
5333
  parent: Db;
5362
5334
  filter: Document;
5363
- options?: ListCollectionsOptions;
5364
- constructor(db: Db, filter: Document, options?: ListCollectionsOptions);
5335
+ options?: ListCollectionsOptions & Abortable;
5336
+ constructor(db: Db, filter: Document, options?: ListCollectionsOptions & Abortable);
5365
5337
  clone(): ListCollectionsCursor<T>;
5366
5338
  /* Excluded from this release type: _initialize */
5367
5339
  }
5368
5340
 
5369
5341
  /** @public */
5370
- export declare interface ListCollectionsOptions extends Omit<CommandOperationOptions, 'writeConcern'> {
5342
+ export declare interface ListCollectionsOptions extends Omit<CommandOperationOptions, 'writeConcern'>, Abortable {
5371
5343
  /** Since 4.0: If true, will only return the collection name in the response, and will omit additional info */
5372
5344
  nameOnly?: boolean;
5373
5345
  /** Since 4.0: If true and nameOnly is true, allows a user without the required privilege (i.e. listCollections action on the database) to run the command when access control is enforced. */
@@ -5433,9 +5405,29 @@ export declare interface LocalKMSProviderConfiguration {
5433
5405
  key: Binary | Uint8Array | string;
5434
5406
  }
5435
5407
 
5436
- /* Excluded from this release type: Log */
5408
+ /** @public */
5409
+ export declare interface Log extends Record<string, any> {
5410
+ t: Date;
5411
+ c: MongoLoggableComponent;
5412
+ s: SeverityLevel;
5413
+ message?: string;
5414
+ }
5437
5415
 
5438
- /* Excluded from this release type: LogComponentSeveritiesClientOptions */
5416
+ /** @public */
5417
+ export declare interface LogComponentSeveritiesClientOptions {
5418
+ /** Optional severity level for command component */
5419
+ command?: SeverityLevel;
5420
+ /** Optional severity level for topology component */
5421
+ topology?: SeverityLevel;
5422
+ /** Optional severity level for server selection component */
5423
+ serverSelection?: SeverityLevel;
5424
+ /** Optional severity level for connection component */
5425
+ connection?: SeverityLevel;
5426
+ /** Optional severity level for client component */
5427
+ client?: SeverityLevel;
5428
+ /** Optional default severity level to be used if any of the above are unset */
5429
+ default?: SeverityLevel;
5430
+ }
5439
5431
 
5440
5432
  /* Excluded from this release type: LogConvertible */
5441
5433
 
@@ -5662,7 +5654,11 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5662
5654
  /* Excluded from this release type: topology */
5663
5655
  /* Excluded from this release type: mongoLogger */
5664
5656
  /* Excluded from this release type: connectionLock */
5665
- /* Excluded from this release type: [kOptions] */
5657
+ /* Excluded from this release type: closeLock */
5658
+ /**
5659
+ * The consolidate, parsed, transformed and merged options.
5660
+ */
5661
+ readonly options: Readonly<Omit<MongoOptions, 'monitorCommands' | 'ca' | 'crl' | 'key' | 'cert'>> & Pick<MongoOptions, 'monitorCommands' | 'ca' | 'crl' | 'key' | 'cert'>;
5666
5662
  constructor(url: string, options?: MongoClientOptions);
5667
5663
  /**
5668
5664
  * @beta
@@ -5672,8 +5668,6 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5672
5668
  [Symbol.asyncDispose]: () => Promise<void>;
5673
5669
  /* Excluded from this release type: asyncDispose */
5674
5670
  /* Excluded from this release type: checkForNonGenuineHosts */
5675
- /** @see MongoOptions */
5676
- get options(): Readonly<MongoOptions>;
5677
5671
  get serverApi(): Readonly<ServerApi | undefined>;
5678
5672
  /* Excluded from this release type: monitorCommands */
5679
5673
  /* Excluded from this release type: monitorCommands */
@@ -5700,6 +5694,10 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5700
5694
  * This means the time to setup the `MongoClient` does not count against `timeoutMS`.
5701
5695
  * If you are using `timeoutMS` we recommend connecting your client explicitly in advance of any operation to avoid this inconsistent execution time.
5702
5696
  *
5697
+ * @remarks
5698
+ * The driver will look up corresponding SRV and TXT records if the connection string starts with `mongodb+srv://`.
5699
+ * If those look ups throw a DNS Timeout error, the driver will retry the look up once.
5700
+ *
5703
5701
  * @see docs.mongodb.org/manual/reference/connection-string/
5704
5702
  */
5705
5703
  connect(): Promise<this>;
@@ -5718,6 +5716,7 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5718
5716
  * @param force - Force close, emitting no events
5719
5717
  */
5720
5718
  close(force?: boolean): Promise<void>;
5719
+ private _close;
5721
5720
  /**
5722
5721
  * Create a new Db instance sharing the current socket connections.
5723
5722
  *
@@ -5738,6 +5737,10 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5738
5737
  * @remarks
5739
5738
  * The programmatically provided options take precedence over the URI options.
5740
5739
  *
5740
+ * @remarks
5741
+ * The driver will look up corresponding SRV and TXT records if the connection string starts with `mongodb+srv://`.
5742
+ * If those look ups throw a DNS Timeout error, the driver will retry the look up once.
5743
+ *
5741
5744
  * @see https://www.mongodb.com/docs/manual/reference/connection-string/
5742
5745
  */
5743
5746
  static connect(url: string, options?: MongoClientOptions): Promise<MongoClient>;
@@ -6065,12 +6068,25 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
6065
6068
  proxyPassword?: string;
6066
6069
  /** Instructs the driver monitors to use a specific monitoring mode */
6067
6070
  serverMonitoringMode?: ServerMonitoringMode;
6071
+ /**
6072
+ * @public
6073
+ * Specifies the destination of the driver's logging. The default is stderr.
6074
+ */
6075
+ mongodbLogPath?: 'stderr' | 'stdout' | MongoDBLogWritable;
6076
+ /**
6077
+ * @public
6078
+ * Enable logging level per component or use `default` to control any unset components.
6079
+ */
6080
+ mongodbLogComponentSeverities?: LogComponentSeveritiesClientOptions;
6081
+ /**
6082
+ * @public
6083
+ * All BSON documents are stringified to EJSON. This controls the maximum length of those strings.
6084
+ * It is defaulted to 1000.
6085
+ */
6086
+ mongodbLogMaxDocumentLength?: number;
6068
6087
  /* Excluded from this release type: srvPoller */
6069
6088
  /* Excluded from this release type: connectionType */
6070
- /* Excluded from this release type: mongodbLogPath */
6071
- /* Excluded from this release type: mongodbLogComponentSeverities */
6072
- /* Excluded from this release type: mongodbLogMaxDocumentLength */
6073
- /* Excluded from this release type: __index */
6089
+ /* Excluded from this release type: __skipPingOnConnect */
6074
6090
  }
6075
6091
 
6076
6092
  /* Excluded from this release type: MongoClientPrivate */
@@ -6314,7 +6330,30 @@ export declare class MongoDBCollectionNamespace extends MongoDBNamespace {
6314
6330
  static fromString(namespace?: string): MongoDBCollectionNamespace;
6315
6331
  }
6316
6332
 
6317
- /* Excluded from this release type: MongoDBLogWritable */
6333
+ /**
6334
+ * @public
6335
+ *
6336
+ * A custom destination for structured logging messages.
6337
+ */
6338
+ export declare interface MongoDBLogWritable {
6339
+ /**
6340
+ * This function will be called for every enabled log message.
6341
+ *
6342
+ * It can be sync or async:
6343
+ * - If it is synchronous it will block the driver from proceeding until this method returns.
6344
+ * - If it is asynchronous the driver will not await the returned promise. It will attach fulfillment handling (`.then`).
6345
+ * If the promise rejects the logger will write an error message to stderr and stop functioning.
6346
+ * If the promise resolves the driver proceeds to the next log message (or waits for new ones to occur).
6347
+ *
6348
+ * Tips:
6349
+ * - We recommend writing an async `write` function that _never_ rejects.
6350
+ * Instead handle logging errors as necessary to your use case and make the write function a noop, until it can be recovered.
6351
+ * - The Log messages are structured but **subject to change** since the intended purpose is informational.
6352
+ * Program against this defensively and err on the side of stringifying whatever is passed in to write in some form or another.
6353
+ *
6354
+ */
6355
+ write(log: Log): PromiseLike<unknown> | unknown;
6356
+ }
6318
6357
 
6319
6358
  /** @public */
6320
6359
  export declare class MongoDBNamespace {
@@ -6391,7 +6430,8 @@ export declare class MongoDriverError extends MongoError {
6391
6430
  * mongodb-client-encryption has a dependency on this error, it uses the constructor with a string argument
6392
6431
  */
6393
6432
  export declare class MongoError extends Error {
6394
- /* Excluded from this release type: [kErrorLabels] */
6433
+ /* Excluded from this release type: errorLabelSet */
6434
+ get errorLabels(): string[];
6395
6435
  /**
6396
6436
  * This is a number in MongoServerError and a string in MongoDriverError
6397
6437
  * @privateRemarks
@@ -6427,7 +6467,6 @@ export declare class MongoError extends Error {
6427
6467
  */
6428
6468
  hasErrorLabel(label: string): boolean;
6429
6469
  addErrorLabel(label: string): void;
6430
- get errorLabels(): string[];
6431
6470
  }
6432
6471
 
6433
6472
  /** @public */
@@ -6585,7 +6624,17 @@ export declare class MongoKerberosError extends MongoRuntimeError {
6585
6624
  get name(): string;
6586
6625
  }
6587
6626
 
6588
- /* Excluded from this release type: MongoLoggableComponent */
6627
+ /** @public */
6628
+ export declare const MongoLoggableComponent: Readonly<{
6629
+ readonly COMMAND: "command";
6630
+ readonly TOPOLOGY: "topology";
6631
+ readonly SERVER_SELECTION: "serverSelection";
6632
+ readonly CONNECTION: "connection";
6633
+ readonly CLIENT: "client";
6634
+ }>;
6635
+
6636
+ /** @public */
6637
+ export declare type MongoLoggableComponent = (typeof MongoLoggableComponent)[keyof typeof MongoLoggableComponent];
6589
6638
 
6590
6639
  /* Excluded from this release type: MongoLogger */
6591
6640
 
@@ -6653,7 +6702,7 @@ export declare class MongoMissingDependencyError extends MongoAPIError {
6653
6702
  * @category Error
6654
6703
  */
6655
6704
  export declare class MongoNetworkError extends MongoError {
6656
- /* Excluded from this release type: [kBeforeHandshake] */
6705
+ /* Excluded from this release type: beforeHandshake */
6657
6706
  /**
6658
6707
  * **Do not use this constructor!**
6659
6708
  *
@@ -6854,10 +6903,10 @@ export declare interface MongoOptions extends Required<Pick<MongoClientOptions,
6854
6903
  tlsCAFile?: string;
6855
6904
  tlsCRLFile?: string;
6856
6905
  tlsCertificateKeyFile?: string;
6857
- /* Excluded from this release type: __index */
6858
6906
  /* Excluded from this release type: mongoLoggerOptions */
6859
6907
  /* Excluded from this release type: mongodbLogPath */
6860
6908
  timeoutMS?: number;
6909
+ /* Excluded from this release type: __skipPingOnConnect */
6861
6910
  }
6862
6911
 
6863
6912
  /**
@@ -8104,7 +8153,26 @@ export declare type SetFields<TSchema> = ({
8104
8153
  /** @public */
8105
8154
  export declare type SetProfilingLevelOptions = CommandOperationOptions;
8106
8155
 
8107
- /* Excluded from this release type: SeverityLevel */
8156
+ /**
8157
+ * @public
8158
+ * Severity levels align with unix syslog.
8159
+ * Most typical driver functions will log to debug.
8160
+ */
8161
+ export declare const SeverityLevel: Readonly<{
8162
+ readonly EMERGENCY: "emergency";
8163
+ readonly ALERT: "alert";
8164
+ readonly CRITICAL: "critical";
8165
+ readonly ERROR: "error";
8166
+ readonly WARNING: "warn";
8167
+ readonly NOTICE: "notice";
8168
+ readonly INFORMATIONAL: "info";
8169
+ readonly DEBUG: "debug";
8170
+ readonly TRACE: "trace";
8171
+ readonly OFF: "off";
8172
+ }>;
8173
+
8174
+ /** @public */
8175
+ export declare type SeverityLevel = (typeof SeverityLevel)[keyof typeof SeverityLevel];
8108
8176
 
8109
8177
  /** @public */
8110
8178
  export declare type Sort = string | Exclude<SortDirection, {
@@ -8744,7 +8812,7 @@ export declare class WriteConcern {
8744
8812
  * @category Error
8745
8813
  */
8746
8814
  export declare class WriteConcernError {
8747
- /* Excluded from this release type: [kServerError] */
8815
+ /* Excluded from this release type: serverError */
8748
8816
  constructor(error: WriteConcernErrorData);
8749
8817
  /** Write concern error code. */
8750
8818
  get code(): number | undefined;
@@ -11,8 +11,6 @@ const operation_1 = require("../operations/operation");
11
11
  const update_1 = require("../operations/update");
12
12
  const utils_1 = require("../utils");
13
13
  const write_concern_1 = require("../write_concern");
14
- /** @internal */
15
- const kServerError = Symbol('serverError');
16
14
  /** @public */
17
15
  exports.BatchType = Object.freeze({
18
16
  INSERT: 1,
@@ -141,22 +139,22 @@ exports.BulkWriteResult = BulkWriteResult;
141
139
  */
142
140
  class WriteConcernError {
143
141
  constructor(error) {
144
- this[kServerError] = error;
142
+ this.serverError = error;
145
143
  }
146
144
  /** Write concern error code. */
147
145
  get code() {
148
- return this[kServerError].code;
146
+ return this.serverError.code;
149
147
  }
150
148
  /** Write concern error message. */
151
149
  get errmsg() {
152
- return this[kServerError].errmsg;
150
+ return this.serverError.errmsg;
153
151
  }
154
152
  /** Write concern error info. */
155
153
  get errInfo() {
156
- return this[kServerError].errInfo;
154
+ return this.serverError.errInfo;
157
155
  }
158
156
  toJSON() {
159
- return this[kServerError];
157
+ return this.serverError;
160
158
  }
161
159
  toString() {
162
160
  return `WriteConcernError(${this.errmsg})`;