mongodb 6.12.0 → 6.13.0-dev.20250201.sha.35c703e3

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 (95) 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_aws.js +1 -1
  13. package/lib/cmap/auth/mongodb_aws.js.map +1 -1
  14. package/lib/cmap/auth/mongodb_oidc.js +1 -1
  15. package/lib/cmap/auth/mongodb_oidc.js.map +1 -1
  16. package/lib/cmap/command_monitoring_events.js +9 -50
  17. package/lib/cmap/command_monitoring_events.js.map +1 -1
  18. package/lib/cmap/connection.js +28 -22
  19. package/lib/cmap/connection.js.map +1 -1
  20. package/lib/cmap/connection_pool.js +88 -117
  21. package/lib/cmap/connection_pool.js.map +1 -1
  22. package/lib/cmap/wire_protocol/on_data.js +6 -1
  23. package/lib/cmap/wire_protocol/on_data.js.map +1 -1
  24. package/lib/collection.js.map +1 -1
  25. package/lib/connection_string.js +68 -86
  26. package/lib/connection_string.js.map +1 -1
  27. package/lib/cursor/abstract_cursor.js +47 -18
  28. package/lib/cursor/abstract_cursor.js.map +1 -1
  29. package/lib/cursor/aggregation_cursor.js +2 -1
  30. package/lib/cursor/aggregation_cursor.js.map +1 -1
  31. package/lib/cursor/find_cursor.js +2 -1
  32. package/lib/cursor/find_cursor.js.map +1 -1
  33. package/lib/cursor/list_collections_cursor.js +2 -1
  34. package/lib/cursor/list_collections_cursor.js.map +1 -1
  35. package/lib/db.js +2 -1
  36. package/lib/db.js.map +1 -1
  37. package/lib/encrypter.js +5 -9
  38. package/lib/encrypter.js.map +1 -1
  39. package/lib/error.js +10 -18
  40. package/lib/error.js.map +1 -1
  41. package/lib/index.js +5 -2
  42. package/lib/index.js.map +1 -1
  43. package/lib/mongo_client.js +46 -26
  44. package/lib/mongo_client.js.map +1 -1
  45. package/lib/mongo_logger.js +102 -3
  46. package/lib/mongo_logger.js.map +1 -1
  47. package/lib/operations/execute_operation.js +9 -5
  48. package/lib/operations/execute_operation.js.map +1 -1
  49. package/lib/operations/list_collections.js.map +1 -1
  50. package/lib/operations/operation.js +4 -5
  51. package/lib/operations/operation.js.map +1 -1
  52. package/lib/sdam/monitor.js +25 -31
  53. package/lib/sdam/monitor.js.map +1 -1
  54. package/lib/sdam/server.js +27 -17
  55. package/lib/sdam/server.js.map +1 -1
  56. package/lib/sdam/topology.js +20 -19
  57. package/lib/sdam/topology.js.map +1 -1
  58. package/lib/sessions.js +24 -48
  59. package/lib/sessions.js.map +1 -1
  60. package/lib/utils.js +64 -44
  61. package/lib/utils.js.map +1 -1
  62. package/mongodb.d.ts +176 -108
  63. package/package.json +2 -2
  64. package/src/bulk/common.ts +6 -9
  65. package/src/change_stream.ts +21 -33
  66. package/src/client-side-encryption/auto_encrypter.ts +12 -8
  67. package/src/client-side-encryption/client_encryption.ts +6 -4
  68. package/src/client-side-encryption/state_machine.ts +80 -36
  69. package/src/cmap/auth/mongodb_aws.ts +1 -1
  70. package/src/cmap/auth/mongodb_oidc.ts +1 -1
  71. package/src/cmap/command_monitoring_events.ts +10 -55
  72. package/src/cmap/connection.ts +37 -29
  73. package/src/cmap/connection_pool.ts +121 -145
  74. package/src/cmap/wire_protocol/on_data.ts +9 -2
  75. package/src/collection.ts +15 -8
  76. package/src/connection_string.ts +74 -99
  77. package/src/cursor/abstract_cursor.ts +71 -23
  78. package/src/cursor/aggregation_cursor.ts +5 -3
  79. package/src/cursor/find_cursor.ts +5 -3
  80. package/src/cursor/list_collections_cursor.ts +5 -3
  81. package/src/db.ts +11 -7
  82. package/src/encrypter.ts +6 -11
  83. package/src/error.ts +11 -23
  84. package/src/index.ts +3 -3
  85. package/src/mongo_client.ts +78 -47
  86. package/src/mongo_logger.ts +158 -11
  87. package/src/mongo_types.ts +38 -0
  88. package/src/operations/execute_operation.ts +11 -6
  89. package/src/operations/list_collections.ts +4 -1
  90. package/src/operations/operation.ts +8 -9
  91. package/src/sdam/monitor.ts +30 -38
  92. package/src/sdam/server.ts +33 -20
  93. package/src/sdam/topology.ts +29 -26
  94. package/src/sessions.ts +37 -58
  95. package/src/utils.ts +79 -43
package/mongodb.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.
@@ -76,6 +116,8 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
76
116
  get loadBalanced(): boolean;
77
117
  /* Excluded from this release type: [Symbol.asyncDispose] */
78
118
  /* Excluded from this release type: asyncDispose */
119
+ /** Adds cursor to client's tracking so it will be closed by MongoClient.close() */
120
+ private trackCursor;
79
121
  /** Returns current buffered documents length */
80
122
  bufferedCount(): number;
81
123
  /** Returns current buffered documents */
@@ -1103,9 +1145,9 @@ export declare class ChangeStream<TSchema extends Document = Document, TChange e
1103
1145
  type: symbol;
1104
1146
  /* Excluded from this release type: cursor */
1105
1147
  streamOptions?: CursorStreamOptions;
1106
- /* Excluded from this release type: [kCursorStream] */
1107
- /* Excluded from this release type: [kClosed] */
1108
- /* Excluded from this release type: [kMode] */
1148
+ /* Excluded from this release type: cursorStream */
1149
+ /* Excluded from this release type: isClosed */
1150
+ /* Excluded from this release type: mode */
1109
1151
  /** @event */
1110
1152
  static readonly RESPONSE: "response";
1111
1153
  /** @event */
@@ -1138,7 +1180,6 @@ export declare class ChangeStream<TSchema extends Document = Document, TChange e
1138
1180
  */
1139
1181
  private contextOwner;
1140
1182
  /* Excluded from this release type: __constructor */
1141
- /* Excluded from this release type: cursorStream */
1142
1183
  /** The cached resume token that is used to resume after the most recently returned change. */
1143
1184
  get resumeToken(): ResumeToken;
1144
1185
  /** Check if there is any document still available in the Change Stream */
@@ -2233,11 +2274,11 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
2233
2274
  defaultTransactionOptions: TransactionOptions;
2234
2275
  transaction: Transaction;
2235
2276
  /* Excluded from this release type: commitAttempted */
2236
- /* Excluded from this release type: [kServerSession] */
2237
- /* Excluded from this release type: [kSnapshotTime] */
2238
- /* Excluded from this release type: [kSnapshotEnabled] */
2239
- /* Excluded from this release type: [kPinnedConnection] */
2240
- /* Excluded from this release type: [kTxnNumberIncrement] */
2277
+ readonly snapshotEnabled: boolean;
2278
+ /* Excluded from this release type: _serverSession */
2279
+ /* Excluded from this release type: snapshotTime */
2280
+ /* Excluded from this release type: pinnedConnection */
2281
+ /* Excluded from this release type: txnNumberIncrement */
2241
2282
  /**
2242
2283
  * @experimental
2243
2284
  * Specifies the time an operation in a given `ClientSession` will run until it throws a timeout error
@@ -2248,10 +2289,7 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
2248
2289
  /** The server id associated with this session */
2249
2290
  get id(): ServerSessionId | undefined;
2250
2291
  get serverSession(): ServerSession;
2251
- /** Whether or not this session is configured for snapshot reads */
2252
- get snapshotEnabled(): boolean;
2253
2292
  get loadBalanced(): boolean;
2254
- /* Excluded from this release type: pinnedConnection */
2255
2293
  /* Excluded from this release type: pin */
2256
2294
  /* Excluded from this release type: unpin */
2257
2295
  get isPinned(): boolean;
@@ -2704,18 +2742,18 @@ export declare class Collection<TSchema extends Document = Document> {
2704
2742
  */
2705
2743
  findOne(): Promise<WithId<TSchema> | null>;
2706
2744
  findOne(filter: Filter<TSchema>): Promise<WithId<TSchema> | null>;
2707
- findOne(filter: Filter<TSchema>, options: Omit<FindOptions, 'timeoutMode'>): Promise<WithId<TSchema> | null>;
2745
+ findOne(filter: Filter<TSchema>, options: Omit<FindOptions, 'timeoutMode'> & Abortable): Promise<WithId<TSchema> | null>;
2708
2746
  findOne<T = TSchema>(): Promise<T | null>;
2709
2747
  findOne<T = TSchema>(filter: Filter<TSchema>): Promise<T | null>;
2710
- findOne<T = TSchema>(filter: Filter<TSchema>, options?: Omit<FindOptions, 'timeoutMode'>): Promise<T | null>;
2748
+ findOne<T = TSchema>(filter: Filter<TSchema>, options?: Omit<FindOptions, 'timeoutMode'> & Abortable): Promise<T | null>;
2711
2749
  /**
2712
2750
  * Creates a cursor for a filter that can be used to iterate over results from MongoDB
2713
2751
  *
2714
2752
  * @param filter - The filter predicate. If unspecified, then all documents in the collection will match the predicate
2715
2753
  */
2716
2754
  find(): FindCursor<WithId<TSchema>>;
2717
- find(filter: Filter<TSchema>, options?: FindOptions): FindCursor<WithId<TSchema>>;
2718
- find<T extends Document>(filter: Filter<TSchema>, options?: FindOptions): FindCursor<T>;
2755
+ find(filter: Filter<TSchema>, options?: FindOptions & Abortable): FindCursor<WithId<TSchema>>;
2756
+ find<T extends Document>(filter: Filter<TSchema>, options?: FindOptions & Abortable): FindCursor<T>;
2719
2757
  /**
2720
2758
  * Returns the options of the collection.
2721
2759
  *
@@ -2870,7 +2908,7 @@ export declare class Collection<TSchema extends Document = Document> {
2870
2908
  * @see https://www.mongodb.com/docs/manual/reference/operator/query/center/#op._S_center
2871
2909
  * @see https://www.mongodb.com/docs/manual/reference/operator/query/centerSphere/#op._S_centerSphere
2872
2910
  */
2873
- countDocuments(filter?: Filter<TSchema>, options?: CountDocumentsOptions): Promise<number>;
2911
+ countDocuments(filter?: Filter<TSchema>, options?: CountDocumentsOptions & Abortable): Promise<number>;
2874
2912
  /**
2875
2913
  * The distinct command returns a list of distinct values for the given key across a collection.
2876
2914
  *
@@ -2947,7 +2985,7 @@ export declare class Collection<TSchema extends Document = Document> {
2947
2985
  * @param pipeline - An array of aggregation pipelines to execute
2948
2986
  * @param options - Optional settings for the command
2949
2987
  */
2950
- aggregate<T extends Document = Document>(pipeline?: Document[], options?: AggregateOptions): AggregationCursor<T>;
2988
+ aggregate<T extends Document = Document>(pipeline?: Document[], options?: AggregateOptions & Abortable): AggregationCursor<T>;
2951
2989
  /**
2952
2990
  * Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this collection.
2953
2991
  *
@@ -3834,7 +3872,7 @@ export declare class Db {
3834
3872
  * @param command - The command to run
3835
3873
  * @param options - Optional settings for the command
3836
3874
  */
3837
- command(command: Document, options?: RunCommandOptions): Promise<Document>;
3875
+ command(command: Document, options?: RunCommandOptions & Abortable): Promise<Document>;
3838
3876
  /**
3839
3877
  * Execute an aggregation framework pipeline against the database.
3840
3878
  *
@@ -3867,11 +3905,11 @@ export declare class Db {
3867
3905
  */
3868
3906
  listCollections(filter: Document, options: Exclude<ListCollectionsOptions, 'nameOnly'> & {
3869
3907
  nameOnly: true;
3870
- }): ListCollectionsCursor<Pick<CollectionInfo, 'name' | 'type'>>;
3908
+ } & Abortable): ListCollectionsCursor<Pick<CollectionInfo, 'name' | 'type'>>;
3871
3909
  listCollections(filter: Document, options: Exclude<ListCollectionsOptions, 'nameOnly'> & {
3872
3910
  nameOnly: false;
3873
- }): ListCollectionsCursor<CollectionInfo>;
3874
- listCollections<T extends Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo = Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo>(filter?: Document, options?: ListCollectionsOptions): ListCollectionsCursor<T>;
3911
+ } & Abortable): ListCollectionsCursor<CollectionInfo>;
3912
+ listCollections<T extends Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo = Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo>(filter?: Document, options?: ListCollectionsOptions & Abortable): ListCollectionsCursor<T>;
3875
3913
  /**
3876
3914
  * Rename a collection.
3877
3915
  *
@@ -5157,30 +5195,8 @@ export declare type Join<T extends unknown[], D extends string> = T extends [] ?
5157
5195
 
5158
5196
  /* Excluded from this release type: JSTypeOf */
5159
5197
 
5160
- /* Excluded from this release type: kBeforeHandshake */
5161
-
5162
- /* Excluded from this release type: kCancellationToken */
5163
-
5164
- /* Excluded from this release type: kCancellationToken_2 */
5165
-
5166
- /* Excluded from this release type: kCancelled */
5167
-
5168
- /* Excluded from this release type: kCancelled_2 */
5169
-
5170
- /* Excluded from this release type: kCheckedOut */
5171
-
5172
- /* Excluded from this release type: kClosed */
5173
-
5174
- /* Excluded from this release type: kConnectionCounter */
5175
-
5176
- /* Excluded from this release type: kConnections */
5177
-
5178
- /* Excluded from this release type: kCursorStream */
5179
-
5180
5198
  /* Excluded from this release type: kDecorateResult */
5181
5199
 
5182
- /* Excluded from this release type: kErrorLabels */
5183
-
5184
5200
  /** @public */
5185
5201
  export declare type KeysOfAType<TSchema, Type> = {
5186
5202
  [key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? key : never;
@@ -5191,14 +5207,6 @@ export declare type KeysOfOtherType<TSchema, Type> = {
5191
5207
  [key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? never : key;
5192
5208
  }[keyof TSchema];
5193
5209
 
5194
- /* Excluded from this release type: kGeneration */
5195
-
5196
- /* Excluded from this release type: kInternalClient */
5197
-
5198
- /* Excluded from this release type: kMetrics */
5199
-
5200
- /* Excluded from this release type: kMinPoolSizeTimer */
5201
-
5202
5210
  /**
5203
5211
  * @public
5204
5212
  * Configuration options for making a KMIP encryption key
@@ -5232,10 +5240,6 @@ export declare interface KMIPKMSProviderConfiguration {
5232
5240
  endpoint?: string;
5233
5241
  }
5234
5242
 
5235
- /* Excluded from this release type: kMode */
5236
-
5237
- /* Excluded from this release type: kMonitorId */
5238
-
5239
5243
  /**
5240
5244
  * @public
5241
5245
  * Configuration options that are used by specific KMS providers during key generation, encryption, and decryption.
@@ -5270,38 +5274,6 @@ export declare interface KMSProviders {
5270
5274
  [key: `gcp:${string}`]: GCPKMSProviderConfiguration;
5271
5275
  }
5272
5276
 
5273
- /* Excluded from this release type: kOptions */
5274
-
5275
- /* Excluded from this release type: kPending */
5276
-
5277
- /* Excluded from this release type: kPinnedConnection */
5278
-
5279
- /* Excluded from this release type: kPoolState */
5280
-
5281
- /* Excluded from this release type: kProcessingWaitQueue */
5282
-
5283
- /* Excluded from this release type: kServer */
5284
-
5285
- /* Excluded from this release type: kServer_2 */
5286
-
5287
- /* Excluded from this release type: kServerError */
5288
-
5289
- /* Excluded from this release type: kServerSession */
5290
-
5291
- /* Excluded from this release type: kServiceGenerations */
5292
-
5293
- /* Excluded from this release type: kSession */
5294
-
5295
- /* Excluded from this release type: kSnapshotEnabled */
5296
-
5297
- /* Excluded from this release type: kSnapshotTime */
5298
-
5299
- /* Excluded from this release type: kTxnNumberIncrement */
5300
-
5301
- /* Excluded from this release type: kWaitQueue */
5302
-
5303
- /* Excluded from this release type: kWaitQueue_2 */
5304
-
5305
5277
  /* Excluded from this release type: LegacyTimeoutContext */
5306
5278
 
5307
5279
  /* Excluded from this release type: LegacyTimeoutContextOptions */
@@ -5318,14 +5290,14 @@ export declare const LEGAL_TLS_SOCKET_OPTIONS: readonly ["allowPartialTrustChain
5318
5290
  export declare class ListCollectionsCursor<T extends Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo = Pick<CollectionInfo, 'name' | 'type'> | CollectionInfo> extends AbstractCursor<T> {
5319
5291
  parent: Db;
5320
5292
  filter: Document;
5321
- options?: ListCollectionsOptions;
5322
- constructor(db: Db, filter: Document, options?: ListCollectionsOptions);
5293
+ options?: ListCollectionsOptions & Abortable;
5294
+ constructor(db: Db, filter: Document, options?: ListCollectionsOptions & Abortable);
5323
5295
  clone(): ListCollectionsCursor<T>;
5324
5296
  /* Excluded from this release type: _initialize */
5325
5297
  }
5326
5298
 
5327
5299
  /** @public */
5328
- export declare interface ListCollectionsOptions extends Omit<CommandOperationOptions, 'writeConcern'> {
5300
+ export declare interface ListCollectionsOptions extends Omit<CommandOperationOptions, 'writeConcern'>, Abortable {
5329
5301
  /** Since 4.0: If true, will only return the collection name in the response, and will omit additional info */
5330
5302
  nameOnly?: boolean;
5331
5303
  /** 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. */
@@ -5391,9 +5363,29 @@ export declare interface LocalKMSProviderConfiguration {
5391
5363
  key: Binary | Uint8Array | string;
5392
5364
  }
5393
5365
 
5394
- /* Excluded from this release type: Log */
5366
+ /** @public */
5367
+ export declare interface Log extends Record<string, any> {
5368
+ t: Date;
5369
+ c: MongoLoggableComponent;
5370
+ s: SeverityLevel;
5371
+ message?: string;
5372
+ }
5395
5373
 
5396
- /* Excluded from this release type: LogComponentSeveritiesClientOptions */
5374
+ /** @public */
5375
+ export declare interface LogComponentSeveritiesClientOptions {
5376
+ /** Optional severity level for command component */
5377
+ command?: SeverityLevel;
5378
+ /** Optional severity level for topology component */
5379
+ topology?: SeverityLevel;
5380
+ /** Optional severity level for server selection component */
5381
+ serverSelection?: SeverityLevel;
5382
+ /** Optional severity level for connection component */
5383
+ connection?: SeverityLevel;
5384
+ /** Optional severity level for client component */
5385
+ client?: SeverityLevel;
5386
+ /** Optional default severity level to be used if any of the above are unset */
5387
+ default?: SeverityLevel;
5388
+ }
5397
5389
 
5398
5390
  /* Excluded from this release type: LogConvertible */
5399
5391
 
@@ -5620,13 +5612,15 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5620
5612
  /* Excluded from this release type: topology */
5621
5613
  /* Excluded from this release type: mongoLogger */
5622
5614
  /* Excluded from this release type: connectionLock */
5623
- /* Excluded from this release type: [kOptions] */
5615
+ /* Excluded from this release type: closeLock */
5616
+ /**
5617
+ * The consolidate, parsed, transformed and merged options.
5618
+ */
5619
+ readonly options: Readonly<Omit<MongoOptions, 'monitorCommands' | 'ca' | 'crl' | 'key' | 'cert'>> & Pick<MongoOptions, 'monitorCommands' | 'ca' | 'crl' | 'key' | 'cert'>;
5624
5620
  constructor(url: string, options?: MongoClientOptions);
5625
5621
  /* Excluded from this release type: [Symbol.asyncDispose] */
5626
5622
  /* Excluded from this release type: asyncDispose */
5627
5623
  /* Excluded from this release type: checkForNonGenuineHosts */
5628
- /** @see MongoOptions */
5629
- get options(): Readonly<MongoOptions>;
5630
5624
  get serverApi(): Readonly<ServerApi | undefined>;
5631
5625
  /* Excluded from this release type: monitorCommands */
5632
5626
  /* Excluded from this release type: monitorCommands */
@@ -5653,6 +5647,10 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5653
5647
  * This means the time to setup the `MongoClient` does not count against `timeoutMS`.
5654
5648
  * If you are using `timeoutMS` we recommend connecting your client explicitly in advance of any operation to avoid this inconsistent execution time.
5655
5649
  *
5650
+ * @remarks
5651
+ * The driver will look up corresponding SRV and TXT records if the connection string starts with `mongodb+srv://`.
5652
+ * If those look ups throw a DNS Timeout error, the driver will retry the look up once.
5653
+ *
5656
5654
  * @see docs.mongodb.org/manual/reference/connection-string/
5657
5655
  */
5658
5656
  connect(): Promise<this>;
@@ -5671,6 +5669,7 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5671
5669
  * @param force - Force close, emitting no events
5672
5670
  */
5673
5671
  close(force?: boolean): Promise<void>;
5672
+ private _close;
5674
5673
  /**
5675
5674
  * Create a new Db instance sharing the current socket connections.
5676
5675
  *
@@ -5691,6 +5690,10 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
5691
5690
  * @remarks
5692
5691
  * The programmatically provided options take precedence over the URI options.
5693
5692
  *
5693
+ * @remarks
5694
+ * The driver will look up corresponding SRV and TXT records if the connection string starts with `mongodb+srv://`.
5695
+ * If those look ups throw a DNS Timeout error, the driver will retry the look up once.
5696
+ *
5694
5697
  * @see https://www.mongodb.com/docs/manual/reference/connection-string/
5695
5698
  */
5696
5699
  static connect(url: string, options?: MongoClientOptions): Promise<MongoClient>;
@@ -6018,12 +6021,25 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
6018
6021
  proxyPassword?: string;
6019
6022
  /** Instructs the driver monitors to use a specific monitoring mode */
6020
6023
  serverMonitoringMode?: ServerMonitoringMode;
6024
+ /**
6025
+ * @public
6026
+ * Specifies the destination of the driver's logging. The default is stderr.
6027
+ */
6028
+ mongodbLogPath?: 'stderr' | 'stdout' | MongoDBLogWritable;
6029
+ /**
6030
+ * @public
6031
+ * Enable logging level per component or use `default` to control any unset components.
6032
+ */
6033
+ mongodbLogComponentSeverities?: LogComponentSeveritiesClientOptions;
6034
+ /**
6035
+ * @public
6036
+ * All BSON documents are stringified to EJSON. This controls the maximum length of those strings.
6037
+ * It is defaulted to 1000.
6038
+ */
6039
+ mongodbLogMaxDocumentLength?: number;
6021
6040
  /* Excluded from this release type: srvPoller */
6022
6041
  /* Excluded from this release type: connectionType */
6023
- /* Excluded from this release type: mongodbLogPath */
6024
- /* Excluded from this release type: mongodbLogComponentSeverities */
6025
- /* Excluded from this release type: mongodbLogMaxDocumentLength */
6026
- /* Excluded from this release type: __index */
6042
+ /* Excluded from this release type: __skipPingOnConnect */
6027
6043
  }
6028
6044
 
6029
6045
  /* Excluded from this release type: MongoClientPrivate */
@@ -6267,7 +6283,30 @@ export declare class MongoDBCollectionNamespace extends MongoDBNamespace {
6267
6283
  static fromString(namespace?: string): MongoDBCollectionNamespace;
6268
6284
  }
6269
6285
 
6270
- /* Excluded from this release type: MongoDBLogWritable */
6286
+ /**
6287
+ * @public
6288
+ *
6289
+ * A custom destination for structured logging messages.
6290
+ */
6291
+ export declare interface MongoDBLogWritable {
6292
+ /**
6293
+ * This function will be called for every enabled log message.
6294
+ *
6295
+ * It can be sync or async:
6296
+ * - If it is synchronous it will block the driver from proceeding until this method returns.
6297
+ * - If it is asynchronous the driver will not await the returned promise. It will attach fulfillment handling (`.then`).
6298
+ * If the promise rejects the logger will write an error message to stderr and stop functioning.
6299
+ * If the promise resolves the driver proceeds to the next log message (or waits for new ones to occur).
6300
+ *
6301
+ * Tips:
6302
+ * - We recommend writing an async `write` function that _never_ rejects.
6303
+ * Instead handle logging errors as necessary to your use case and make the write function a noop, until it can be recovered.
6304
+ * - The Log messages are structured but **subject to change** since the intended purpose is informational.
6305
+ * Program against this defensively and err on the side of stringifying whatever is passed in to write in some form or another.
6306
+ *
6307
+ */
6308
+ write(log: Log): PromiseLike<unknown> | unknown;
6309
+ }
6271
6310
 
6272
6311
  /** @public */
6273
6312
  export declare class MongoDBNamespace {
@@ -6344,7 +6383,8 @@ export declare class MongoDriverError extends MongoError {
6344
6383
  * mongodb-client-encryption has a dependency on this error, it uses the constructor with a string argument
6345
6384
  */
6346
6385
  export declare class MongoError extends Error {
6347
- /* Excluded from this release type: [kErrorLabels] */
6386
+ /* Excluded from this release type: errorLabelSet */
6387
+ get errorLabels(): string[];
6348
6388
  /**
6349
6389
  * This is a number in MongoServerError and a string in MongoDriverError
6350
6390
  * @privateRemarks
@@ -6380,7 +6420,6 @@ export declare class MongoError extends Error {
6380
6420
  */
6381
6421
  hasErrorLabel(label: string): boolean;
6382
6422
  addErrorLabel(label: string): void;
6383
- get errorLabels(): string[];
6384
6423
  }
6385
6424
 
6386
6425
  /** @public */
@@ -6538,7 +6577,17 @@ export declare class MongoKerberosError extends MongoRuntimeError {
6538
6577
  get name(): string;
6539
6578
  }
6540
6579
 
6541
- /* Excluded from this release type: MongoLoggableComponent */
6580
+ /** @public */
6581
+ export declare const MongoLoggableComponent: Readonly<{
6582
+ readonly COMMAND: "command";
6583
+ readonly TOPOLOGY: "topology";
6584
+ readonly SERVER_SELECTION: "serverSelection";
6585
+ readonly CONNECTION: "connection";
6586
+ readonly CLIENT: "client";
6587
+ }>;
6588
+
6589
+ /** @public */
6590
+ export declare type MongoLoggableComponent = (typeof MongoLoggableComponent)[keyof typeof MongoLoggableComponent];
6542
6591
 
6543
6592
  /* Excluded from this release type: MongoLogger */
6544
6593
 
@@ -6606,7 +6655,7 @@ export declare class MongoMissingDependencyError extends MongoAPIError {
6606
6655
  * @category Error
6607
6656
  */
6608
6657
  export declare class MongoNetworkError extends MongoError {
6609
- /* Excluded from this release type: [kBeforeHandshake] */
6658
+ /* Excluded from this release type: beforeHandshake */
6610
6659
  /**
6611
6660
  * **Do not use this constructor!**
6612
6661
  *
@@ -6807,10 +6856,10 @@ export declare interface MongoOptions extends Required<Pick<MongoClientOptions,
6807
6856
  tlsCAFile?: string;
6808
6857
  tlsCRLFile?: string;
6809
6858
  tlsCertificateKeyFile?: string;
6810
- /* Excluded from this release type: __index */
6811
6859
  /* Excluded from this release type: mongoLoggerOptions */
6812
6860
  /* Excluded from this release type: mongodbLogPath */
6813
6861
  timeoutMS?: number;
6862
+ /* Excluded from this release type: __skipPingOnConnect */
6814
6863
  }
6815
6864
 
6816
6865
  /**
@@ -8057,7 +8106,26 @@ export declare type SetFields<TSchema> = ({
8057
8106
  /** @public */
8058
8107
  export declare type SetProfilingLevelOptions = CommandOperationOptions;
8059
8108
 
8060
- /* Excluded from this release type: SeverityLevel */
8109
+ /**
8110
+ * @public
8111
+ * Severity levels align with unix syslog.
8112
+ * Most typical driver functions will log to debug.
8113
+ */
8114
+ export declare const SeverityLevel: Readonly<{
8115
+ readonly EMERGENCY: "emergency";
8116
+ readonly ALERT: "alert";
8117
+ readonly CRITICAL: "critical";
8118
+ readonly ERROR: "error";
8119
+ readonly WARNING: "warn";
8120
+ readonly NOTICE: "notice";
8121
+ readonly INFORMATIONAL: "info";
8122
+ readonly DEBUG: "debug";
8123
+ readonly TRACE: "trace";
8124
+ readonly OFF: "off";
8125
+ }>;
8126
+
8127
+ /** @public */
8128
+ export declare type SeverityLevel = (typeof SeverityLevel)[keyof typeof SeverityLevel];
8061
8129
 
8062
8130
  /** @public */
8063
8131
  export declare type Sort = string | Exclude<SortDirection, {
@@ -8697,7 +8765,7 @@ export declare class WriteConcern {
8697
8765
  * @category Error
8698
8766
  */
8699
8767
  export declare class WriteConcernError {
8700
- /* Excluded from this release type: [kServerError] */
8768
+ /* Excluded from this release type: serverError */
8701
8769
  constructor(error: WriteConcernErrorData);
8702
8770
  /** Write concern error code. */
8703
8771
  get code(): number | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb",
3
- "version": "6.12.0",
3
+ "version": "6.13.0-dev.20250201.sha.35c703e3",
4
4
  "description": "The official MongoDB driver for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -176,4 +176,4 @@
176
176
  "moduleResolution": "node"
177
177
  }
178
178
  }
179
- }
179
+ }
@@ -30,9 +30,6 @@ import {
30
30
  } from '../utils';
31
31
  import { WriteConcern } from '../write_concern';
32
32
 
33
- /** @internal */
34
- const kServerError = Symbol('serverError');
35
-
36
33
  /** @public */
37
34
  export const BatchType = Object.freeze({
38
35
  INSERT: 1,
@@ -315,29 +312,29 @@ export interface WriteConcernErrorData {
315
312
  */
316
313
  export class WriteConcernError {
317
314
  /** @internal */
318
- [kServerError]: WriteConcernErrorData;
315
+ private serverError: WriteConcernErrorData;
319
316
 
320
317
  constructor(error: WriteConcernErrorData) {
321
- this[kServerError] = error;
318
+ this.serverError = error;
322
319
  }
323
320
 
324
321
  /** Write concern error code. */
325
322
  get code(): number | undefined {
326
- return this[kServerError].code;
323
+ return this.serverError.code;
327
324
  }
328
325
 
329
326
  /** Write concern error message. */
330
327
  get errmsg(): string | undefined {
331
- return this[kServerError].errmsg;
328
+ return this.serverError.errmsg;
332
329
  }
333
330
 
334
331
  /** Write concern error info. */
335
332
  get errInfo(): Document | undefined {
336
- return this[kServerError].errInfo;
333
+ return this.serverError.errInfo;
337
334
  }
338
335
 
339
336
  toJSON(): WriteConcernErrorData {
340
- return this[kServerError];
337
+ return this.serverError;
341
338
  }
342
339
 
343
340
  toString(): string {