mongodb 6.8.2 → 6.9.0-dev.20240917.sha.20396e1b

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 (252) hide show
  1. package/README.md +14 -1
  2. package/lib/beta.d.ts +7940 -0
  3. package/lib/beta.js +21 -0
  4. package/lib/beta.js.map +1 -0
  5. package/lib/bson.js +5 -5
  6. package/lib/bson.js.map +1 -1
  7. package/lib/bulk/common.js +16 -21
  8. package/lib/bulk/common.js.map +1 -1
  9. package/lib/bulk/ordered.js.map +1 -1
  10. package/lib/bulk/unordered.js.map +1 -1
  11. package/lib/change_stream.js +10 -8
  12. package/lib/change_stream.js.map +1 -1
  13. package/lib/client-side-encryption/auto_encrypter.js +14 -3
  14. package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
  15. package/lib/client-side-encryption/client_encryption.js +25 -7
  16. package/lib/client-side-encryption/client_encryption.js.map +1 -1
  17. package/lib/client-side-encryption/crypto_callbacks.js +6 -6
  18. package/lib/client-side-encryption/crypto_callbacks.js.map +1 -1
  19. package/lib/client-side-encryption/mongocryptd_manager.js +9 -5
  20. package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -1
  21. package/lib/client-side-encryption/providers/aws.js +1 -2
  22. package/lib/client-side-encryption/providers/aws.js.map +1 -1
  23. package/lib/client-side-encryption/providers/azure.js +5 -5
  24. package/lib/client-side-encryption/providers/azure.js.map +1 -1
  25. package/lib/client-side-encryption/providers/gcp.js +1 -2
  26. package/lib/client-side-encryption/providers/gcp.js.map +1 -1
  27. package/lib/client-side-encryption/providers/index.js +2 -3
  28. package/lib/client-side-encryption/providers/index.js.map +1 -1
  29. package/lib/client-side-encryption/state_machine.js +9 -4
  30. package/lib/client-side-encryption/state_machine.js.map +1 -1
  31. package/lib/cmap/auth/auth_provider.js.map +1 -1
  32. package/lib/cmap/auth/aws_temporary_credentials.js.map +1 -1
  33. package/lib/cmap/auth/gssapi.js +4 -4
  34. package/lib/cmap/auth/gssapi.js.map +1 -1
  35. package/lib/cmap/auth/mongo_credentials.js +2 -7
  36. package/lib/cmap/auth/mongo_credentials.js.map +1 -1
  37. package/lib/cmap/auth/mongodb_aws.js.map +1 -1
  38. package/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js.map +1 -1
  39. package/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js.map +1 -1
  40. package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +0 -2
  41. package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -1
  42. package/lib/cmap/auth/mongodb_oidc/command_builders.js +2 -3
  43. package/lib/cmap/auth/mongodb_oidc/command_builders.js.map +1 -1
  44. package/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js.map +1 -1
  45. package/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js.map +1 -1
  46. package/lib/cmap/auth/mongodb_oidc/machine_workflow.js +0 -2
  47. package/lib/cmap/auth/mongodb_oidc/machine_workflow.js.map +1 -1
  48. package/lib/cmap/auth/mongodb_oidc/token_cache.js.map +1 -1
  49. package/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js.map +1 -1
  50. package/lib/cmap/auth/mongodb_oidc.js.map +1 -1
  51. package/lib/cmap/auth/plain.js.map +1 -1
  52. package/lib/cmap/auth/scram.js.map +1 -1
  53. package/lib/cmap/auth/x509.js.map +1 -1
  54. package/lib/cmap/command_monitoring_events.js.map +1 -1
  55. package/lib/cmap/commands.js +62 -5
  56. package/lib/cmap/commands.js.map +1 -1
  57. package/lib/cmap/connect.js +10 -7
  58. package/lib/cmap/connect.js.map +1 -1
  59. package/lib/cmap/connection.js +3 -5
  60. package/lib/cmap/connection.js.map +1 -1
  61. package/lib/cmap/connection_pool.js +11 -9
  62. package/lib/cmap/connection_pool.js.map +1 -1
  63. package/lib/cmap/connection_pool_events.js +7 -3
  64. package/lib/cmap/connection_pool_events.js.map +1 -1
  65. package/lib/cmap/handshake/client_metadata.js +5 -5
  66. package/lib/cmap/handshake/client_metadata.js.map +1 -1
  67. package/lib/cmap/metrics.js +1 -1
  68. package/lib/cmap/metrics.js.map +1 -1
  69. package/lib/cmap/stream_description.js.map +1 -1
  70. package/lib/cmap/wire_protocol/compression.js +5 -5
  71. package/lib/cmap/wire_protocol/compression.js.map +1 -1
  72. package/lib/cmap/wire_protocol/constants.js +4 -4
  73. package/lib/cmap/wire_protocol/on_data.js +1 -2
  74. package/lib/cmap/wire_protocol/on_data.js.map +1 -1
  75. package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -1
  76. package/lib/cmap/wire_protocol/responses.js +4 -4
  77. package/lib/cmap/wire_protocol/responses.js.map +1 -1
  78. package/lib/cmap/wire_protocol/shared.js +2 -3
  79. package/lib/cmap/wire_protocol/shared.js.map +1 -1
  80. package/lib/collection.js.map +1 -1
  81. package/lib/connection_string.js +12 -6
  82. package/lib/connection_string.js.map +1 -1
  83. package/lib/constants.js +1 -0
  84. package/lib/constants.js.map +1 -1
  85. package/lib/cursor/abstract_cursor.js +21 -6
  86. package/lib/cursor/abstract_cursor.js.map +1 -1
  87. package/lib/cursor/aggregation_cursor.js +1 -1
  88. package/lib/cursor/aggregation_cursor.js.map +1 -1
  89. package/lib/cursor/change_stream_cursor.js.map +1 -1
  90. package/lib/cursor/find_cursor.js +3 -3
  91. package/lib/cursor/find_cursor.js.map +1 -1
  92. package/lib/db.js +2 -2
  93. package/lib/db.js.map +1 -1
  94. package/lib/deps.js +16 -8
  95. package/lib/deps.js.map +1 -1
  96. package/lib/encrypter.js.map +1 -1
  97. package/lib/error.js +19 -14
  98. package/lib/error.js.map +1 -1
  99. package/lib/explain.js +6 -6
  100. package/lib/explain.js.map +1 -1
  101. package/lib/gridfs/download.js +1 -4
  102. package/lib/gridfs/download.js.map +1 -1
  103. package/lib/gridfs/index.js +1 -1
  104. package/lib/gridfs/index.js.map +1 -1
  105. package/lib/gridfs/upload.js +0 -4
  106. package/lib/gridfs/upload.js.map +1 -1
  107. package/lib/index.js +4 -2
  108. package/lib/index.js.map +1 -1
  109. package/lib/mongo_client.js +15 -1
  110. package/lib/mongo_client.js.map +1 -1
  111. package/lib/mongo_client_auth_providers.js +6 -2
  112. package/lib/mongo_client_auth_providers.js.map +1 -1
  113. package/lib/mongo_logger.js +8 -8
  114. package/lib/mongo_logger.js.map +1 -1
  115. package/lib/mongo_types.js +1 -0
  116. package/lib/mongo_types.js.map +1 -1
  117. package/lib/operations/aggregate.js +1 -0
  118. package/lib/operations/aggregate.js.map +1 -1
  119. package/lib/operations/bulk_write.js.map +1 -1
  120. package/lib/operations/client_bulk_write/command_builder.js +198 -0
  121. package/lib/operations/client_bulk_write/command_builder.js.map +1 -0
  122. package/lib/operations/client_bulk_write/common.js +3 -0
  123. package/lib/operations/client_bulk_write/common.js.map +1 -0
  124. package/lib/operations/collections.js.map +1 -1
  125. package/lib/operations/command.js +1 -1
  126. package/lib/operations/command.js.map +1 -1
  127. package/lib/operations/count.js.map +1 -1
  128. package/lib/operations/create_collection.js.map +1 -1
  129. package/lib/operations/delete.js +2 -2
  130. package/lib/operations/delete.js.map +1 -1
  131. package/lib/operations/distinct.js.map +1 -1
  132. package/lib/operations/drop.js.map +1 -1
  133. package/lib/operations/estimated_document_count.js.map +1 -1
  134. package/lib/operations/execute_operation.js +111 -109
  135. package/lib/operations/execute_operation.js.map +1 -1
  136. package/lib/operations/find.js.map +1 -1
  137. package/lib/operations/find_and_modify.js +2 -8
  138. package/lib/operations/find_and_modify.js.map +1 -1
  139. package/lib/operations/get_more.js.map +1 -1
  140. package/lib/operations/indexes.js.map +1 -1
  141. package/lib/operations/insert.js.map +1 -1
  142. package/lib/operations/is_capped.js.map +1 -1
  143. package/lib/operations/kill_cursors.js.map +1 -1
  144. package/lib/operations/list_collections.js.map +1 -1
  145. package/lib/operations/list_databases.js.map +1 -1
  146. package/lib/operations/operation.js +5 -5
  147. package/lib/operations/operation.js.map +1 -1
  148. package/lib/operations/options_operation.js.map +1 -1
  149. package/lib/operations/profiling_level.js.map +1 -1
  150. package/lib/operations/search_indexes/drop.js.map +1 -1
  151. package/lib/operations/set_profiling_level.js.map +1 -1
  152. package/lib/operations/stats.js.map +1 -1
  153. package/lib/operations/update.js +2 -2
  154. package/lib/operations/update.js.map +1 -1
  155. package/lib/operations/validate_collection.js.map +1 -1
  156. package/lib/read_concern.js.map +1 -1
  157. package/lib/read_preference.js +1 -1
  158. package/lib/read_preference.js.map +1 -1
  159. package/lib/resource_management.js +58 -0
  160. package/lib/resource_management.js.map +1 -0
  161. package/lib/sdam/common.js +3 -3
  162. package/lib/sdam/common.js.map +1 -1
  163. package/lib/sdam/monitor.js +1 -5
  164. package/lib/sdam/monitor.js.map +1 -1
  165. package/lib/sdam/server.js +2 -2
  166. package/lib/sdam/server.js.map +1 -1
  167. package/lib/sdam/server_description.js +3 -3
  168. package/lib/sdam/server_description.js.map +1 -1
  169. package/lib/sdam/server_selection.js +5 -5
  170. package/lib/sdam/server_selection.js.map +1 -1
  171. package/lib/sdam/srv_polling.js +2 -3
  172. package/lib/sdam/srv_polling.js.map +1 -1
  173. package/lib/sdam/topology.js +1 -1
  174. package/lib/sdam/topology.js.map +1 -1
  175. package/lib/sdam/topology_description.js.map +1 -1
  176. package/lib/sessions.js +221 -218
  177. package/lib/sessions.js.map +1 -1
  178. package/lib/sort.js +2 -3
  179. package/lib/sort.js.map +1 -1
  180. package/lib/timeout.js +0 -1
  181. package/lib/timeout.js.map +1 -1
  182. package/lib/transactions.js +2 -2
  183. package/lib/transactions.js.map +1 -1
  184. package/lib/utils.js +54 -54
  185. package/lib/utils.js.map +1 -1
  186. package/lib/write_concern.js +2 -2
  187. package/lib/write_concern.js.map +1 -1
  188. package/mongodb.d.ts +191 -148
  189. package/package.json +27 -28
  190. package/src/beta.ts +22 -0
  191. package/src/bson.ts +1 -2
  192. package/src/bulk/common.ts +18 -18
  193. package/src/change_stream.ts +33 -15
  194. package/src/client-side-encryption/auto_encrypter.ts +18 -82
  195. package/src/client-side-encryption/client_encryption.ts +51 -54
  196. package/src/client-side-encryption/mongocryptd_manager.ts +10 -6
  197. package/src/client-side-encryption/state_machine.ts +28 -6
  198. package/src/cmap/auth/gssapi.ts +1 -1
  199. package/src/cmap/auth/mongo_credentials.ts +2 -8
  200. package/src/cmap/auth/mongodb_aws.ts +2 -2
  201. package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +2 -2
  202. package/src/cmap/auth/mongodb_oidc/machine_workflow.ts +2 -2
  203. package/src/cmap/commands.ts +70 -5
  204. package/src/cmap/connect.ts +4 -1
  205. package/src/cmap/connection.ts +2 -2
  206. package/src/cmap/connection_pool.ts +17 -9
  207. package/src/cmap/connection_pool_events.ts +34 -2
  208. package/src/cmap/handshake/client_metadata.ts +1 -1
  209. package/src/cmap/wire_protocol/constants.ts +4 -4
  210. package/src/cmap/wire_protocol/shared.ts +1 -2
  211. package/src/collection.ts +16 -15
  212. package/src/connection_string.ts +10 -3
  213. package/src/constants.ts +1 -0
  214. package/src/cursor/abstract_cursor.ts +38 -13
  215. package/src/cursor/aggregation_cursor.ts +8 -6
  216. package/src/cursor/find_cursor.ts +2 -2
  217. package/src/db.ts +1 -1
  218. package/src/deps.ts +8 -1
  219. package/src/error.ts +33 -14
  220. package/src/explain.ts +47 -11
  221. package/src/gridfs/download.ts +28 -4
  222. package/src/gridfs/upload.ts +1 -6
  223. package/src/index.ts +11 -2
  224. package/src/mongo_client.ts +29 -5
  225. package/src/mongo_client_auth_providers.ts +8 -2
  226. package/src/mongo_logger.ts +5 -3
  227. package/src/mongo_types.ts +69 -68
  228. package/src/operations/aggregate.ts +2 -1
  229. package/src/operations/bulk_write.ts +2 -2
  230. package/src/operations/client_bulk_write/command_builder.ts +283 -0
  231. package/src/operations/client_bulk_write/common.ts +146 -0
  232. package/src/operations/command.ts +1 -1
  233. package/src/operations/execute_operation.ts +137 -131
  234. package/src/operations/find_and_modify.ts +2 -7
  235. package/src/operations/insert.ts +3 -4
  236. package/src/operations/operation.ts +7 -10
  237. package/src/operations/search_indexes/drop.ts +4 -1
  238. package/src/resource_management.ts +74 -0
  239. package/src/sdam/monitor.ts +3 -5
  240. package/src/sdam/server.ts +1 -1
  241. package/src/sdam/server_description.ts +5 -6
  242. package/src/sdam/srv_polling.ts +1 -2
  243. package/src/sessions.ts +291 -277
  244. package/src/sort.ts +1 -1
  245. package/src/timeout.ts +0 -1
  246. package/src/transactions.ts +1 -2
  247. package/src/utils.ts +25 -9
  248. package/src/write_concern.ts +2 -2
  249. package/tsconfig.json +2 -1
  250. package/lib/cmap/auth/mongocr.js +0 -35
  251. package/lib/cmap/auth/mongocr.js.map +0 -1
  252. package/src/cmap/auth/mongocr.ts +0 -38
package/mongodb.d.ts CHANGED
@@ -1,15 +1,37 @@
1
- /// <reference types="node" />
2
-
3
- import type { DeserializeOptions,ObjectIdLike , SerializeOptions } from 'bson';
4
- import { Binary , BSON , BSONRegExp , BSONSymbol , BSONType , Code , DBRef , Decimal128 , deserialize , Document , Double , Int32 , Long , MaxKey , MinKey , ObjectId , serialize , Timestamp , UUID } from 'bson';
1
+ import type { ObjectIdLike } from 'bson';
2
+ import type { DeserializeOptions } from 'bson';
3
+ import type { SerializeOptions } from 'bson';
4
+ import { Binary } from 'bson';
5
+ import { BSON } from 'bson';
6
+ import { BSONRegExp } from 'bson';
7
+ import { BSONSymbol } from 'bson';
8
+ import { BSONType } from 'bson';
9
+ import { Code } from 'bson';
10
+ import { DBRef } from 'bson';
11
+ import { Decimal128 } from 'bson';
12
+ import { deserialize } from 'bson';
13
+ import { Document } from 'bson';
14
+ import { Double } from 'bson';
15
+ import { Int32 } from 'bson';
16
+ import { Long } from 'bson';
17
+ import { MaxKey } from 'bson';
18
+ import { MinKey } from 'bson';
19
+ import { ObjectId } from 'bson';
20
+ import { serialize } from 'bson';
21
+ import { Timestamp } from 'bson';
22
+ import { UUID } from 'bson';
5
23
  import type { SrvRecord } from 'dns';
6
24
  import { EventEmitter } from 'events';
7
- import type { Socket , TcpNetConnectOpts } from 'net';
8
- import { Readable , Writable } from 'stream';
9
- import type { ConnectionOptions as ConnectionOptions_2 , TLSSocket , TLSSocketOptions } from 'tls';
25
+ import type { Socket } from 'net';
26
+ import type { TcpNetConnectOpts } from 'net';
27
+ import { Readable } from 'stream';
28
+ import { Writable } from 'stream';
29
+ import type { ConnectionOptions as ConnectionOptions_2 } from 'tls';
30
+ import type { TLSSocket } from 'tls';
31
+ import type { TLSSocketOptions } from 'tls';
10
32
 
11
33
  /** @public */
12
- export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends AbstractCursorEvents = AbstractCursorEvents> extends TypedEventEmitter<CursorEvents> {
34
+ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends AbstractCursorEvents = AbstractCursorEvents> extends TypedEventEmitter<CursorEvents> implements AsyncDisposable_2 {
13
35
  /* Excluded from this release type: cursorId */
14
36
  /* Excluded from this release type: cursorSession */
15
37
  /* Excluded from this release type: selectedServer */
@@ -51,10 +73,12 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
51
73
  */
52
74
  get killed(): boolean;
53
75
  get loadBalanced(): boolean;
76
+ /* Excluded from this release type: [Symbol.asyncDispose] */
77
+ /* Excluded from this release type: asyncDispose */
54
78
  /** Returns current buffered documents length */
55
79
  bufferedCount(): number;
56
80
  /** Returns current buffered documents */
57
- readBufferedDocuments(number?: number): TSchema[];
81
+ readBufferedDocuments(number?: number): NonNullable<TSchema>[];
58
82
  [Symbol.asyncIterator](): AsyncGenerator<TSchema, void, void>;
59
83
  stream(options?: CursorStreamOptions): Readable & AsyncIterable<TSchema>;
60
84
  hasNext(): Promise<boolean>;
@@ -73,6 +97,9 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
73
97
  * @deprecated - Will be removed in a future release. Use for await...of instead.
74
98
  */
75
99
  forEach(iterator: (doc: TSchema) => boolean | void): Promise<void>;
100
+ /**
101
+ * Frees any client-side resources used by the cursor.
102
+ */
76
103
  close(): Promise<void>;
77
104
  /**
78
105
  * Returns an array of documents. The caller is responsible for making sure that there
@@ -378,7 +405,7 @@ export declare class AggregationCursor<TSchema = any> extends AbstractCursor<TSc
378
405
  map<T>(transform: (doc: TSchema) => T): AggregationCursor<T>;
379
406
  /* Excluded from this release type: _initialize */
380
407
  /** Execute the explain for the cursor */
381
- explain(verbosity?: ExplainVerbosityLike): Promise<Document>;
408
+ explain(verbosity?: ExplainVerbosityLike | ExplainCommandOptions): Promise<Document>;
382
409
  /** Add a stage to the aggregation pipeline
383
410
  * @example
384
411
  * ```
@@ -501,6 +528,15 @@ export declare type ArrayOperator<Type> = {
501
528
  $sort?: Sort;
502
529
  };
503
530
 
531
+ /**
532
+ * @public
533
+ */
534
+ declare interface AsyncDisposable_2 {
535
+ /* Excluded from this release type: [Symbol.asyncDispose] */
536
+ /* Excluded from this release type: asyncDispose */
537
+ }
538
+ export { AsyncDisposable_2 as AsyncDisposable }
539
+
504
540
  /** @public */
505
541
  export declare interface Auth {
506
542
  /** The username for auth */
@@ -589,77 +625,7 @@ export declare interface AutoEncryptionOptions {
589
625
  /** The namespace where keys are stored in the key vault */
590
626
  keyVaultNamespace?: string;
591
627
  /** Configuration options that are used by specific KMS providers during key generation, encryption, and decryption. */
592
- kmsProviders?: {
593
- /** Configuration options for using 'aws' as your KMS provider */
594
- aws?: {
595
- /** The access key used for the AWS KMS provider */
596
- accessKeyId: string;
597
- /** The secret access key used for the AWS KMS provider */
598
- secretAccessKey: string;
599
- /**
600
- * An optional AWS session token that will be used as the
601
- * X-Amz-Security-Token header for AWS requests.
602
- */
603
- sessionToken?: string;
604
- } | Record<string, never>;
605
- /** Configuration options for using 'local' as your KMS provider */
606
- local?: {
607
- /**
608
- * The master key used to encrypt/decrypt data keys.
609
- * A 96-byte long Buffer or base64 encoded string.
610
- */
611
- key: Buffer | string;
612
- };
613
- /** Configuration options for using 'azure' as your KMS provider */
614
- azure?: {
615
- /** The tenant ID identifies the organization for the account */
616
- tenantId: string;
617
- /** The client ID to authenticate a registered application */
618
- clientId: string;
619
- /** The client secret to authenticate a registered application */
620
- clientSecret: string;
621
- /**
622
- * If present, a host with optional port. E.g. "example.com" or "example.com:443".
623
- * This is optional, and only needed if customer is using a non-commercial Azure instance
624
- * (e.g. a government or China account, which use different URLs).
625
- * Defaults to "login.microsoftonline.com"
626
- */
627
- identityPlatformEndpoint?: string | undefined;
628
- } | {
629
- /**
630
- * If present, an access token to authenticate with Azure.
631
- */
632
- accessToken: string;
633
- } | Record<string, never>;
634
- /** Configuration options for using 'gcp' as your KMS provider */
635
- gcp?: {
636
- /** The service account email to authenticate */
637
- email: string;
638
- /** A PKCS#8 encrypted key. This can either be a base64 string or a binary representation */
639
- privateKey: string | Buffer;
640
- /**
641
- * If present, a host with optional port. E.g. "example.com" or "example.com:443".
642
- * Defaults to "oauth2.googleapis.com"
643
- */
644
- endpoint?: string | undefined;
645
- } | {
646
- /**
647
- * If present, an access token to authenticate with GCP.
648
- */
649
- accessToken: string;
650
- } | Record<string, never>;
651
- /**
652
- * Configuration options for using 'kmip' as your KMS provider
653
- */
654
- kmip?: {
655
- /**
656
- * The output endpoint string.
657
- * The endpoint consists of a hostname and port separated by a colon.
658
- * E.g. "example.com:123". A port is always present.
659
- */
660
- endpoint?: string;
661
- };
662
- };
628
+ kmsProviders?: KMSProviders;
663
629
  /**
664
630
  * A map of namespaces to a local JSON schema for encryption
665
631
  *
@@ -951,6 +917,7 @@ export declare abstract class BulkOperationBase {
951
917
  find(selector: Document): FindOperators;
952
918
  /** Specifies a raw operation to perform in the bulk write. */
953
919
  raw(op: AnyBulkWriteOperation): this;
920
+ get length(): number;
954
921
  get bsonOptions(): BSONSerializeOptions;
955
922
  get writeConcern(): WriteConcern | undefined;
956
923
  get batches(): Batch[];
@@ -1058,7 +1025,9 @@ export declare class CancellationToken extends TypedEventEmitter<{
1058
1025
  * Creates a new Change Stream instance. Normally created using {@link Collection#watch|Collection.watch()}.
1059
1026
  * @public
1060
1027
  */
1061
- export declare class ChangeStream<TSchema extends Document = Document, TChange extends Document = ChangeStreamDocument<TSchema>> extends TypedEventEmitter<ChangeStreamEvents<TSchema, TChange>> {
1028
+ export declare class ChangeStream<TSchema extends Document = Document, TChange extends Document = ChangeStreamDocument<TSchema>> extends TypedEventEmitter<ChangeStreamEvents<TSchema, TChange>> implements AsyncDisposable_2 {
1029
+ /* Excluded from this release type: [Symbol.asyncDispose] */
1030
+ /* Excluded from this release type: asyncDispose */
1062
1031
  pipeline: Document[];
1063
1032
  /**
1064
1033
  * @remarks WriteConcern can still be present on the options because
@@ -1117,7 +1086,9 @@ export declare class ChangeStream<TSchema extends Document = Document, TChange e
1117
1086
  [Symbol.asyncIterator](): AsyncGenerator<TChange, void, void>;
1118
1087
  /** Is the cursor closed */
1119
1088
  get closed(): boolean;
1120
- /** Close the Change Stream */
1089
+ /**
1090
+ * Frees the internal resources used by the change stream.
1091
+ */
1121
1092
  close(): Promise<void>;
1122
1093
  /**
1123
1094
  * Return a modified Readable stream including a possible transform method.
@@ -1773,9 +1744,7 @@ export declare class ClientEncryption {
1773
1744
  /**
1774
1745
  * Encrypts a Match Expression or Aggregate Expression to query a range index.
1775
1746
  *
1776
- * Only supported when queryType is "rangePreview" and algorithm is "RangePreview".
1777
- *
1778
- * @experimental The Range algorithm is experimental only. It is not intended for production use. It is subject to breaking changes.
1747
+ * Only supported when queryType is "range" and algorithm is "Range".
1779
1748
  *
1780
1749
  * @param expression - a BSON document of one of the following forms:
1781
1750
  * 1. A Match Expression of this form:
@@ -1847,36 +1816,7 @@ export declare interface ClientEncryptionEncryptOptions {
1847
1816
  /**
1848
1817
  * The algorithm to use for encryption.
1849
1818
  */
1850
- algorithm: 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic' | 'AEAD_AES_256_CBC_HMAC_SHA_512-Random' | 'Indexed' | 'Unindexed' | 'RangePreview';
1851
- /**
1852
- * The id of the Binary dataKey to use for encryption
1853
- */
1854
- keyId?: Binary;
1855
- /**
1856
- * A unique string name corresponding to an already existing dataKey.
1857
- */
1858
- keyAltName?: string;
1859
- /** The contention factor. */
1860
- contentionFactor?: bigint | number;
1861
- /**
1862
- * The query type supported. Only the queryType `equality` is stable.
1863
- *
1864
- * @experimental Public Technical Preview: The queryType `rangePreview` is experimental.
1865
- */
1866
- queryType?: 'equality' | 'rangePreview';
1867
- /** @experimental Public Technical Preview: The index options for a Queryable Encryption field supporting "rangePreview" queries.*/
1868
- rangeOptions?: RangeOptions;
1869
- }
1870
-
1871
- /**
1872
- * @public
1873
- * Options to provide when encrypting data.
1874
- */
1875
- export declare interface ClientEncryptionEncryptOptions {
1876
- /**
1877
- * The algorithm to use for encryption.
1878
- */
1879
- algorithm: 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic' | 'AEAD_AES_256_CBC_HMAC_SHA_512-Random' | 'Indexed' | 'Unindexed' | 'RangePreview';
1819
+ algorithm: 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic' | 'AEAD_AES_256_CBC_HMAC_SHA_512-Random' | 'Indexed' | 'Unindexed' | 'Range';
1880
1820
  /**
1881
1821
  * The id of the Binary dataKey to use for encryption
1882
1822
  */
@@ -1888,12 +1828,10 @@ export declare interface ClientEncryptionEncryptOptions {
1888
1828
  /** The contention factor. */
1889
1829
  contentionFactor?: bigint | number;
1890
1830
  /**
1891
- * The query type supported. Only the queryType `equality` is stable.
1892
- *
1893
- * @experimental Public Technical Preview: The queryType `rangePreview` is experimental.
1831
+ * The query type.
1894
1832
  */
1895
- queryType?: 'equality' | 'rangePreview';
1896
- /** @experimental Public Technical Preview: The index options for a Queryable Encryption field supporting "rangePreview" queries.*/
1833
+ queryType?: 'equality' | 'range';
1834
+ /** The index options for a Queryable Encryption field supporting "range" queries.*/
1897
1835
  rangeOptions?: RangeOptions;
1898
1836
  }
1899
1837
 
@@ -1942,6 +1880,13 @@ export declare interface ClientEncryptionRewrapManyDataKeyResult {
1942
1880
  bulkWriteResult?: BulkWriteResult;
1943
1881
  }
1944
1882
 
1883
+ /**
1884
+ * @public
1885
+ *
1886
+ * Socket options to use for KMS requests.
1887
+ */
1888
+ export declare type ClientEncryptionSocketOptions = Pick<MongoClientOptions, 'autoSelectFamily' | 'autoSelectFamilyAttemptTimeout'>;
1889
+
1945
1890
  /**
1946
1891
  * @public
1947
1892
  *
@@ -2001,7 +1946,7 @@ export declare interface ClientMetadataOptions {
2001
1946
  * NOTE: not meant to be instantiated directly.
2002
1947
  * @public
2003
1948
  */
2004
- export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
1949
+ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents> implements AsyncDisposable_2 {
2005
1950
  /* Excluded from this release type: client */
2006
1951
  /* Excluded from this release type: sessionPool */
2007
1952
  hasEnded: boolean;
@@ -2033,11 +1978,16 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
2033
1978
  /* Excluded from this release type: unpin */
2034
1979
  get isPinned(): boolean;
2035
1980
  /**
2036
- * Ends this session on the server
1981
+ * Frees any client-side resources held by the current session. If a session is in a transaction,
1982
+ * the transaction is aborted.
1983
+ *
1984
+ * Does not end the session on the server.
2037
1985
  *
2038
1986
  * @param options - Optional settings. Currently reserved for future use
2039
1987
  */
2040
1988
  endSession(options?: EndSessionOptions): Promise<void>;
1989
+ /* Excluded from this release type: [Symbol.asyncDispose] */
1990
+ /* Excluded from this release type: asyncDispose */
2041
1991
  /**
2042
1992
  * Advances the operationTime for a ClientSession.
2043
1993
  *
@@ -2272,7 +2222,7 @@ export declare class Collection<TSchema extends Document = Document> {
2272
2222
  * @param docs - The documents to insert
2273
2223
  * @param options - Optional settings for the command
2274
2224
  */
2275
- insertMany(docs: OptionalUnlessRequiredId<TSchema>[], options?: BulkWriteOptions): Promise<InsertManyResult<TSchema>>;
2225
+ insertMany(docs: ReadonlyArray<OptionalUnlessRequiredId<TSchema>>, options?: BulkWriteOptions): Promise<InsertManyResult<TSchema>>;
2276
2226
  /**
2277
2227
  * Perform a bulkWrite operation without a fluent API
2278
2228
  *
@@ -2292,7 +2242,7 @@ export declare class Collection<TSchema extends Document = Document> {
2292
2242
  * @param options - Optional settings for the command
2293
2243
  * @throws MongoDriverError if operations is not an array
2294
2244
  */
2295
- bulkWrite(operations: AnyBulkWriteOperation<TSchema>[], options?: BulkWriteOptions): Promise<BulkWriteResult>;
2245
+ bulkWrite(operations: ReadonlyArray<AnyBulkWriteOperation<TSchema>>, options?: BulkWriteOptions): Promise<BulkWriteResult>;
2296
2246
  /**
2297
2247
  * Update a single document in a collection
2298
2248
  *
@@ -2879,6 +2829,8 @@ export declare type CompressorName = keyof typeof Compressor;
2879
2829
  /** @public */
2880
2830
  export declare type Condition<T> = AlternativeType<T> | FilterOperators<AlternativeType<T>>;
2881
2831
 
2832
+ /* Excluded from this release type: configureExplicitResourceManagement */
2833
+
2882
2834
  /* Excluded from this release type: Connection */
2883
2835
 
2884
2836
  /* Excluded from this release type: CONNECTION_CHECK_OUT_FAILED */
@@ -2924,6 +2876,14 @@ export declare class ConnectionCheckedOutEvent extends ConnectionPoolMonitoringE
2924
2876
  /** The id of the connection */
2925
2877
  connectionId: number | '<monitor>';
2926
2878
  /* Excluded from this release type: name */
2879
+ /**
2880
+ * The time it took to check out the connection.
2881
+ * More specifically, the time elapsed between
2882
+ * emitting a `ConnectionCheckOutStartedEvent`
2883
+ * and emitting this event as part of the same checking out.
2884
+ *
2885
+ */
2886
+ durationMS: number;
2927
2887
  /* Excluded from this release type: __constructor */
2928
2888
  }
2929
2889
 
@@ -2937,6 +2897,13 @@ export declare class ConnectionCheckOutFailedEvent extends ConnectionPoolMonitor
2937
2897
  reason: string;
2938
2898
  /* Excluded from this release type: error */
2939
2899
  /* Excluded from this release type: name */
2900
+ /**
2901
+ * The time it took to check out the connection.
2902
+ * More specifically, the time elapsed between
2903
+ * emitting a `ConnectionCheckOutStartedEvent`
2904
+ * and emitting this event as part of the same check out.
2905
+ */
2906
+ durationMS: number;
2940
2907
  /* Excluded from this release type: __constructor */
2941
2908
  }
2942
2909
 
@@ -3112,6 +3079,18 @@ export declare class ConnectionPoolReadyEvent extends ConnectionPoolMonitoringEv
3112
3079
  export declare class ConnectionReadyEvent extends ConnectionPoolMonitoringEvent {
3113
3080
  /** The id of the connection */
3114
3081
  connectionId: number | '<monitor>';
3082
+ /**
3083
+ * The time it took to establish the connection.
3084
+ * In accordance with the definition of establishment of a connection
3085
+ * specified by `ConnectionPoolOptions.maxConnecting`,
3086
+ * it is the time elapsed between emitting a `ConnectionCreatedEvent`
3087
+ * and emitting this event as part of the same checking out.
3088
+ *
3089
+ * Naturally, when establishing a connection is part of checking out,
3090
+ * this duration is not greater than
3091
+ * `ConnectionCheckedOutEvent.duration`.
3092
+ */
3093
+ durationMS: number;
3115
3094
  /* Excluded from this release type: name */
3116
3095
  /* Excluded from this release type: __constructor */
3117
3096
  }
@@ -3354,7 +3333,7 @@ export declare class Db {
3354
3333
  */
3355
3334
  command(command: Document, options?: RunCommandOptions): Promise<Document>;
3356
3335
  /**
3357
- * Execute an aggregation framework pipeline against the database, needs MongoDB \>= 3.6
3336
+ * Execute an aggregation framework pipeline against the database.
3358
3337
  *
3359
3338
  * @param pipeline - An array of aggregation stages to be executed
3360
3339
  * @param options - Optional settings for the command
@@ -3647,9 +3626,45 @@ export declare type EventsDescription = Record<string, GenericListener>;
3647
3626
  /* Excluded from this release type: Explain */
3648
3627
 
3649
3628
  /** @public */
3629
+ export declare interface ExplainCommandOptions {
3630
+ /** The explain verbosity for the command. */
3631
+ verbosity: ExplainVerbosity;
3632
+ /** The maxTimeMS setting for the command. */
3633
+ maxTimeMS?: number;
3634
+ }
3635
+
3636
+ /**
3637
+ * @public
3638
+ *
3639
+ * When set, this configures an explain command. Valid values are boolean (for legacy compatibility,
3640
+ * see {@link ExplainVerbosityLike}), a string containing the explain verbosity, or an object containing the verbosity and
3641
+ * an optional maxTimeMS.
3642
+ *
3643
+ * Examples of valid usage:
3644
+ *
3645
+ * ```typescript
3646
+ * collection.find({ name: 'john doe' }, { explain: true });
3647
+ * collection.find({ name: 'john doe' }, { explain: false });
3648
+ * collection.find({ name: 'john doe' }, { explain: 'queryPlanner' });
3649
+ * collection.find({ name: 'john doe' }, { explain: { verbosity: 'queryPlanner' } });
3650
+ * ```
3651
+ *
3652
+ * maxTimeMS can be configured to limit the amount of time the server
3653
+ * spends executing an explain by providing an object:
3654
+ *
3655
+ * ```typescript
3656
+ * // limits the `explain` command to no more than 2 seconds
3657
+ * collection.find({ name: 'john doe' }, {
3658
+ * explain: {
3659
+ * verbosity: 'queryPlanner',
3660
+ * maxTimeMS: 2000
3661
+ * }
3662
+ * });
3663
+ * ```
3664
+ */
3650
3665
  export declare interface ExplainOptions {
3651
3666
  /** Specifies the verbosity mode for the explain output. */
3652
- explain?: ExplainVerbosityLike;
3667
+ explain?: ExplainVerbosityLike | ExplainCommandOptions;
3653
3668
  }
3654
3669
 
3655
3670
  /** @public */
@@ -3665,8 +3680,7 @@ export declare type ExplainVerbosity = string;
3665
3680
 
3666
3681
  /**
3667
3682
  * For backwards compatibility, true is interpreted as "allPlansExecution"
3668
- * and false as "queryPlanner". Prior to server version 3.6, aggregate()
3669
- * ignores the verbosity parameter and executes in "queryPlanner".
3683
+ * and false as "queryPlanner".
3670
3684
  * @public
3671
3685
  */
3672
3686
  export declare type ExplainVerbosityLike = ExplainVerbosity | boolean;
@@ -3736,7 +3750,7 @@ export declare class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
3736
3750
  */
3737
3751
  count(options?: CountOptions): Promise<number>;
3738
3752
  /** Execute the explain for the cursor */
3739
- explain(verbosity?: ExplainVerbosityLike): Promise<Document>;
3753
+ explain(verbosity?: ExplainVerbosityLike | ExplainCommandOptions): Promise<Document>;
3740
3754
  /** Set the cursor query */
3741
3755
  filter(filter: Document): this;
3742
3756
  /**
@@ -4663,10 +4677,10 @@ export declare interface KMSProviders {
4663
4677
  /* Excluded from this release type: kWaitQueue_2 */
4664
4678
 
4665
4679
  /** @public */
4666
- export declare const LEGAL_TCP_SOCKET_OPTIONS: readonly ["family", "hints", "localAddress", "localPort", "lookup"];
4680
+ export declare const LEGAL_TCP_SOCKET_OPTIONS: readonly ["autoSelectFamily", "autoSelectFamilyAttemptTimeout", "family", "hints", "localAddress", "localPort", "lookup"];
4667
4681
 
4668
4682
  /** @public */
4669
- export declare const LEGAL_TLS_SOCKET_OPTIONS: readonly ["ALPNProtocols", "ca", "cert", "checkServerIdentity", "ciphers", "crl", "ecdhCurve", "key", "minDHSize", "passphrase", "pfx", "rejectUnauthorized", "secureContext", "secureProtocol", "servername", "session"];
4683
+ export declare const LEGAL_TLS_SOCKET_OPTIONS: readonly ["allowPartialTrustChain", "ALPNProtocols", "ca", "cert", "checkServerIdentity", "ciphers", "crl", "ecdhCurve", "key", "minDHSize", "passphrase", "pfx", "rejectUnauthorized", "secureContext", "secureProtocol", "servername", "session"];
4670
4684
 
4671
4685
  /* Excluded from this release type: List */
4672
4686
 
@@ -4967,13 +4981,15 @@ export declare class MongoChangeStreamError extends MongoRuntimeError {
4967
4981
  * await client.insertOne({ name: 'spot', kind: 'dog' });
4968
4982
  * ```
4969
4983
  */
4970
- export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> {
4984
+ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> implements AsyncDisposable_2 {
4971
4985
  /* Excluded from this release type: s */
4972
4986
  /* Excluded from this release type: topology */
4973
4987
  /* Excluded from this release type: mongoLogger */
4974
4988
  /* Excluded from this release type: connectionLock */
4975
4989
  /* Excluded from this release type: [kOptions] */
4976
4990
  constructor(url: string, options?: MongoClientOptions);
4991
+ /* Excluded from this release type: [Symbol.asyncDispose] */
4992
+ /* Excluded from this release type: asyncDispose */
4977
4993
  /* Excluded from this release type: checkForNonGenuineHosts */
4978
4994
  /** @see MongoOptions */
4979
4995
  get options(): Readonly<MongoOptions>;
@@ -4993,7 +5009,15 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> {
4993
5009
  connect(): Promise<this>;
4994
5010
  /* Excluded from this release type: _connect */
4995
5011
  /**
4996
- * Close the client and its underlying connections
5012
+ * Cleans up client-side resources used by the MongoCLient and . This includes:
5013
+ *
5014
+ * - Closes all open, unused connections (see note).
5015
+ * - Ends all in-use sessions with {@link ClientSession#endSession|ClientSession.endSession()}.
5016
+ * - Ends all unused sessions server-side.
5017
+ * - Cleans up any resources being used for auto encryption if auto encryption is enabled.
5018
+ *
5019
+ * @remarks Any in-progress operations are not killed and any connections used by in progress operations
5020
+ * will be cleaned up lazily as operations finish.
4997
5021
  *
4998
5022
  * @param force - Force close, emitting no events
4999
5023
  */
@@ -6244,15 +6268,7 @@ export declare class MongoWriteConcernError extends MongoServerError {
6244
6268
  *
6245
6269
  * @public
6246
6270
  **/
6247
- constructor(result: {
6248
- writeConcernError: {
6249
- code: number;
6250
- errmsg: string;
6251
- codeName?: string;
6252
- errInfo?: Document;
6253
- };
6254
- errorLabels?: string[];
6255
- });
6271
+ constructor(result: WriteConcernErrorResult);
6256
6272
  get name(): string;
6257
6273
  }
6258
6274
 
@@ -6504,14 +6520,19 @@ export declare type PushOperator<TSchema> = ({
6504
6520
 
6505
6521
  /**
6506
6522
  * @public
6507
- * RangeOptions specifies index options for a Queryable Encryption field supporting "rangePreview" queries.
6508
- * min, max, sparsity, and range must match the values set in the encryptedFields of the destination collection.
6523
+ * RangeOptions specifies index options for a Queryable Encryption field supporting "range" queries.
6524
+ * min, max, sparsity, trimFactor and range must match the values set in the encryptedFields of the destination collection.
6509
6525
  * For double and decimal128, min/max/precision must all be set, or all be unset.
6510
6526
  */
6511
6527
  export declare interface RangeOptions {
6528
+ /** min is the minimum value for the encrypted index. Required if precision is set. */
6512
6529
  min?: any;
6530
+ /** max is the minimum value for the encrypted index. Required if precision is set. */
6513
6531
  max?: any;
6514
- sparsity: Long;
6532
+ /** sparsity may be used to tune performance. must be non-negative. When omitted, a default value is used. */
6533
+ sparsity?: Long | bigint;
6534
+ /** trimFactor may be used to tune performance. must be non-negative. When omitted, a default value is used. */
6535
+ trimFactor?: Int32 | number;
6515
6536
  precision?: number;
6516
6537
  }
6517
6538
 
@@ -7254,10 +7275,15 @@ export declare type StrictUpdateFilter<TSchema> = {
7254
7275
  export declare type SupportedNodeConnectionOptions = SupportedTLSConnectionOptions & SupportedTLSSocketOptions & SupportedSocketOptions;
7255
7276
 
7256
7277
  /** @public */
7257
- export declare type SupportedSocketOptions = Pick<TcpNetConnectOpts, (typeof LEGAL_TCP_SOCKET_OPTIONS)[number]>;
7278
+ export declare type SupportedSocketOptions = Pick<TcpNetConnectOpts & {
7279
+ autoSelectFamily?: boolean;
7280
+ autoSelectFamilyAttemptTimeout?: number;
7281
+ }, (typeof LEGAL_TCP_SOCKET_OPTIONS)[number]>;
7258
7282
 
7259
7283
  /** @public */
7260
- export declare type SupportedTLSConnectionOptions = Pick<ConnectionOptions_2, Extract<keyof ConnectionOptions_2, (typeof LEGAL_TLS_SOCKET_OPTIONS)[number]>>;
7284
+ export declare type SupportedTLSConnectionOptions = Pick<ConnectionOptions_2 & {
7285
+ allowPartialTrustChain?: boolean;
7286
+ }, (typeof LEGAL_TLS_SOCKET_OPTIONS)[number]>;
7261
7287
 
7262
7288
  /** @public */
7263
7289
  export declare type SupportedTLSSocketOptions = Pick<TLSSocketOptions, Extract<keyof TLSSocketOptions, (typeof LEGAL_TLS_SOCKET_OPTIONS)[number]>>;
@@ -7787,6 +7813,23 @@ export declare interface WriteConcernErrorData {
7787
7813
  errInfo?: Document;
7788
7814
  }
7789
7815
 
7816
+ /**
7817
+ * The type of the result property of MongoWriteConcernError
7818
+ * @public
7819
+ */
7820
+ export declare interface WriteConcernErrorResult {
7821
+ writeConcernError: {
7822
+ code: number;
7823
+ errmsg: string;
7824
+ codeName?: string;
7825
+ errInfo?: Document;
7826
+ };
7827
+ ok: number;
7828
+ code?: number;
7829
+ errorLabels?: string[];
7830
+ [x: string | number]: unknown;
7831
+ }
7832
+
7790
7833
  /** @public */
7791
7834
  export declare interface WriteConcernOptions {
7792
7835
  /** Write Concern as an object */