mongodb 6.20.0 → 7.0.0-dev.20251107.sha.5db818c2

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 (151) hide show
  1. package/README.md +17 -18
  2. package/lib/bulk/common.js +7 -9
  3. package/lib/bulk/common.js.map +1 -1
  4. package/lib/change_stream.js +84 -38
  5. package/lib/change_stream.js.map +1 -1
  6. package/lib/client-side-encryption/auto_encrypter.js +2 -4
  7. package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
  8. package/lib/client-side-encryption/client_encryption.js +2 -3
  9. package/lib/client-side-encryption/client_encryption.js.map +1 -1
  10. package/lib/client-side-encryption/errors.js +3 -1
  11. package/lib/client-side-encryption/errors.js.map +1 -1
  12. package/lib/client-side-encryption/mongocryptd_manager.js +1 -1
  13. package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -1
  14. package/lib/cmap/auth/aws_temporary_credentials.js +10 -58
  15. package/lib/cmap/auth/aws_temporary_credentials.js.map +1 -1
  16. package/lib/cmap/auth/mongo_credentials.js +0 -15
  17. package/lib/cmap/auth/mongo_credentials.js.map +1 -1
  18. package/lib/cmap/auth/mongodb_aws.js +2 -7
  19. package/lib/cmap/auth/mongodb_aws.js.map +1 -1
  20. package/lib/cmap/auth/providers.js +0 -1
  21. package/lib/cmap/auth/providers.js.map +1 -1
  22. package/lib/cmap/connect.js +1 -1
  23. package/lib/cmap/connect.js.map +1 -1
  24. package/lib/cmap/connection.js +28 -27
  25. package/lib/cmap/connection.js.map +1 -1
  26. package/lib/cmap/connection_pool.js +59 -59
  27. package/lib/cmap/connection_pool.js.map +1 -1
  28. package/lib/cmap/errors.js +1 -1
  29. package/lib/cmap/errors.js.map +1 -1
  30. package/lib/cmap/handshake/client_metadata.js +7 -5
  31. package/lib/cmap/handshake/client_metadata.js.map +1 -1
  32. package/lib/cmap/metrics.js +3 -3
  33. package/lib/cmap/metrics.js.map +1 -1
  34. package/lib/cmap/wire_protocol/constants.js +3 -1
  35. package/lib/cmap/wire_protocol/constants.js.map +1 -1
  36. package/lib/cmap/wire_protocol/on_data.js +0 -1
  37. package/lib/cmap/wire_protocol/on_data.js.map +1 -1
  38. package/lib/cmap/wire_protocol/responses.js +2 -2
  39. package/lib/cmap/wire_protocol/responses.js.map +1 -1
  40. package/lib/collection.js +1 -1
  41. package/lib/collection.js.map +1 -1
  42. package/lib/connection_string.js +8 -10
  43. package/lib/connection_string.js.map +1 -1
  44. package/lib/cursor/abstract_cursor.js +17 -34
  45. package/lib/cursor/abstract_cursor.js.map +1 -1
  46. package/lib/cursor/change_stream_cursor.js +2 -2
  47. package/lib/cursor/change_stream_cursor.js.map +1 -1
  48. package/lib/cursor/find_cursor.js +37 -26
  49. package/lib/cursor/find_cursor.js.map +1 -1
  50. package/lib/cursor/run_command_cursor.js +1 -1
  51. package/lib/cursor/run_command_cursor.js.map +1 -1
  52. package/lib/db.js +6 -6
  53. package/lib/db.js.map +1 -1
  54. package/lib/error.js +2 -2
  55. package/lib/error.js.map +1 -1
  56. package/lib/gridfs/download.js +5 -5
  57. package/lib/gridfs/download.js.map +1 -1
  58. package/lib/gridfs/index.js +9 -9
  59. package/lib/gridfs/index.js.map +1 -1
  60. package/lib/gridfs/upload.js +2 -8
  61. package/lib/gridfs/upload.js.map +1 -1
  62. package/lib/index.js +2 -4
  63. package/lib/index.js.map +1 -1
  64. package/lib/mongo_client.js +58 -67
  65. package/lib/mongo_client.js.map +1 -1
  66. package/lib/mongo_client_auth_providers.js +0 -6
  67. package/lib/mongo_client_auth_providers.js.map +1 -1
  68. package/lib/mongo_logger.js.map +1 -1
  69. package/lib/mongo_types.js +1 -2
  70. package/lib/mongo_types.js.map +1 -1
  71. package/lib/operations/aggregate.js +0 -3
  72. package/lib/operations/aggregate.js.map +1 -1
  73. package/lib/operations/command.js.map +1 -1
  74. package/lib/operations/create_collection.js +0 -1
  75. package/lib/operations/create_collection.js.map +1 -1
  76. package/lib/operations/drop.js +8 -9
  77. package/lib/operations/drop.js.map +1 -1
  78. package/lib/operations/end_sessions.js +34 -0
  79. package/lib/operations/end_sessions.js.map +1 -0
  80. package/lib/operations/execute_operation.js +3 -1
  81. package/lib/operations/execute_operation.js.map +1 -1
  82. package/lib/operations/find.js.map +1 -1
  83. package/lib/read_preference.js +10 -14
  84. package/lib/read_preference.js.map +1 -1
  85. package/lib/sdam/server.js +14 -14
  86. package/lib/sdam/server.js.map +1 -1
  87. package/lib/sdam/srv_polling.js +2 -2
  88. package/lib/sdam/srv_polling.js.map +1 -1
  89. package/lib/sdam/topology.js +24 -68
  90. package/lib/sdam/topology.js.map +1 -1
  91. package/lib/sessions.js +5 -4
  92. package/lib/sessions.js.map +1 -1
  93. package/lib/transactions.js +2 -13
  94. package/lib/transactions.js.map +1 -1
  95. package/lib/utils.js +0 -14
  96. package/lib/utils.js.map +1 -1
  97. package/mongodb.d.ts +72 -239
  98. package/package.json +17 -20
  99. package/src/bulk/common.ts +9 -11
  100. package/src/change_stream.ts +85 -37
  101. package/src/client-side-encryption/auto_encrypter.ts +6 -12
  102. package/src/client-side-encryption/client_encryption.ts +5 -6
  103. package/src/client-side-encryption/errors.ts +3 -0
  104. package/src/cmap/auth/aws_temporary_credentials.ts +12 -70
  105. package/src/cmap/auth/mongo_credentials.ts +1 -20
  106. package/src/cmap/auth/mongodb_aws.ts +8 -17
  107. package/src/cmap/auth/providers.ts +0 -1
  108. package/src/cmap/connect.ts +1 -1
  109. package/src/cmap/connection.ts +14 -16
  110. package/src/cmap/connection_pool.ts +4 -13
  111. package/src/cmap/errors.ts +1 -1
  112. package/src/cmap/handshake/client_metadata.ts +18 -26
  113. package/src/cmap/wire_protocol/constants.ts +2 -0
  114. package/src/cmap/wire_protocol/on_data.ts +1 -2
  115. package/src/collection.ts +1 -1
  116. package/src/connection_string.ts +13 -20
  117. package/src/cursor/abstract_cursor.ts +12 -49
  118. package/src/cursor/change_stream_cursor.ts +2 -2
  119. package/src/cursor/find_cursor.ts +40 -27
  120. package/src/cursor/run_command_cursor.ts +1 -1
  121. package/src/error.ts +2 -2
  122. package/src/gridfs/download.ts +0 -4
  123. package/src/gridfs/upload.ts +0 -22
  124. package/src/index.ts +2 -8
  125. package/src/mongo_client.ts +68 -100
  126. package/src/mongo_client_auth_providers.ts +0 -8
  127. package/src/mongo_logger.ts +1 -1
  128. package/src/mongo_types.ts +1 -2
  129. package/src/operations/aggregate.ts +0 -6
  130. package/src/operations/command.ts +0 -12
  131. package/src/operations/create_collection.ts +0 -3
  132. package/src/operations/drop.ts +9 -11
  133. package/src/operations/end_sessions.ts +44 -0
  134. package/src/operations/execute_operation.ts +6 -2
  135. package/src/operations/find.ts +2 -11
  136. package/src/read_preference.ts +0 -9
  137. package/src/sdam/topology.ts +2 -60
  138. package/src/sessions.ts +2 -8
  139. package/src/transactions.ts +2 -17
  140. package/src/utils.ts +0 -18
  141. package/tsconfig.json +5 -7
  142. package/lib/beta.d.ts +0 -9224
  143. package/lib/beta.js +0 -21
  144. package/lib/beta.js.map +0 -1
  145. package/lib/client-side-encryption/crypto_callbacks.js +0 -81
  146. package/lib/client-side-encryption/crypto_callbacks.js.map +0 -1
  147. package/lib/resource_management.js +0 -58
  148. package/lib/resource_management.js.map +0 -1
  149. package/src/beta.ts +0 -22
  150. package/src/client-side-encryption/crypto_callbacks.ts +0 -87
  151. package/src/resource_management.ts +0 -74
@@ -150,8 +150,7 @@ export interface TopologyOptions extends BSONSerializeOptions, ServerOptions {
150
150
  /** Indicates that a client should directly connect to a node without attempting to discover its topology type */
151
151
  directConnection: boolean;
152
152
  loadBalanced: boolean;
153
- metadata: ClientMetadata;
154
- extendedMetadata: Promise<Document>;
153
+ metadata: Promise<ClientMetadata>;
155
154
  serverMonitoringMode: ServerMonitoringMode;
156
155
  /** MongoDB server API version */
157
156
  serverApi?: ServerApi;
@@ -393,10 +392,6 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
393
392
  return this.s.options.serverApi;
394
393
  }
395
394
 
396
- get capabilities(): ServerCapabilities {
397
- return new ServerCapabilities(this.lastHello());
398
- }
399
-
400
395
  /** Initiate server connect */
401
396
  async connect(options?: ConnectOptions): Promise<Topology> {
402
397
  this.connectionLock ??= this._connect(options);
@@ -470,7 +465,7 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
470
465
  );
471
466
 
472
467
  const skipPingOnConnect = this.s.options.__skipPingOnConnect === true;
473
- if (!skipPingOnConnect && this.s.credentials) {
468
+ if (!skipPingOnConnect) {
474
469
  const connection = await server.pool.checkOut({ timeoutContext: timeoutContext });
475
470
  server.pool.checkIn(connection);
476
471
  stateTransition(this, STATE_CONNECTED);
@@ -754,10 +749,6 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
754
749
  if (typeof callback === 'function') callback(undefined, true);
755
750
  }
756
751
 
757
- get clientMetadata(): ClientMetadata {
758
- return this.s.options.metadata;
759
- }
760
-
761
752
  isConnected(): boolean {
762
753
  return this.s.state === STATE_CONNECTED;
763
754
  }
@@ -1103,52 +1094,3 @@ function isStaleServerDescription(
1103
1094
  compareTopologyVersion(currentTopologyVersion, incomingServerDescription.topologyVersion) > 0
1104
1095
  );
1105
1096
  }
1106
-
1107
- /**
1108
- * @public
1109
- * @deprecated This class will be removed as dead code in the next major version.
1110
- */
1111
- export class ServerCapabilities {
1112
- maxWireVersion: number;
1113
- minWireVersion: number;
1114
-
1115
- constructor(hello: Document) {
1116
- this.minWireVersion = hello.minWireVersion || 0;
1117
- this.maxWireVersion = hello.maxWireVersion || 0;
1118
- }
1119
-
1120
- get hasAggregationCursor(): boolean {
1121
- return true;
1122
- }
1123
-
1124
- get hasWriteCommands(): boolean {
1125
- return true;
1126
- }
1127
- get hasTextSearch(): boolean {
1128
- return true;
1129
- }
1130
-
1131
- get hasAuthCommands(): boolean {
1132
- return true;
1133
- }
1134
-
1135
- get hasListCollectionsCommand(): boolean {
1136
- return true;
1137
- }
1138
-
1139
- get hasListIndexesCommand(): boolean {
1140
- return true;
1141
- }
1142
-
1143
- get supportsSnapshotReads(): boolean {
1144
- return this.maxWireVersion >= 13;
1145
- }
1146
-
1147
- get commandsTakeWriteConcern(): boolean {
1148
- return true;
1149
- }
1150
-
1151
- get commandsTakeCollation(): boolean {
1152
- return true;
1153
- }
1154
- }
package/src/sessions.ts CHANGED
@@ -26,7 +26,6 @@ import { executeOperation } from './operations/execute_operation';
26
26
  import { RunCommandOperation } from './operations/run_command';
27
27
  import { ReadConcernLevel } from './read_concern';
28
28
  import { ReadPreference } from './read_preference';
29
- import { type AsyncDisposable, configureResourceManagement } from './resource_management';
30
29
  import { _advanceClusterTime, type ClusterTime, TopologyType } from './sdam/common';
31
30
  import { TimeoutContext } from './timeout';
32
31
  import {
@@ -118,7 +117,7 @@ export class ClientSession
118
117
  /** @internal */
119
118
  owner?: symbol | AbstractCursor;
120
119
  defaultTransactionOptions: TransactionOptions;
121
- /** @deprecated - Will be made internal in the next major release */
120
+ /** @internal */
122
121
  transaction: Transaction;
123
122
  /**
124
123
  * @internal
@@ -289,13 +288,10 @@ export class ClientSession
289
288
  }
290
289
  }
291
290
  /**
292
- * @beta
293
291
  * @experimental
294
292
  * An alias for {@link ClientSession.endSession|ClientSession.endSession()}.
295
293
  */
296
- declare [Symbol.asyncDispose]: () => Promise<void>;
297
- /** @internal */
298
- async asyncDispose() {
294
+ async [Symbol.asyncDispose]() {
299
295
  await this.endSession({ force: true });
300
296
  }
301
297
 
@@ -823,8 +819,6 @@ export class ClientSession
823
819
  }
824
820
  }
825
821
 
826
- configureResourceManagement(ClientSession.prototype);
827
-
828
822
  const NON_DETERMINISTIC_WRITE_CONCERN_ERRORS = new Set([
829
823
  'CannotSatisfyWriteConcern',
830
824
  'UnknownReplWriteConcern',
@@ -73,21 +73,15 @@ export interface TransactionOptions extends Omit<CommandOperationOptions, 'timeo
73
73
  }
74
74
 
75
75
  /**
76
- * @public
77
- * @deprecated - Will be made internal in a future major release.
78
- * A class maintaining state related to a server transaction. Internal Only
76
+ * @internal
79
77
  */
80
78
  export class Transaction {
81
- /** @internal */
82
79
  state: TxnState;
83
- /** @deprecated - Will be made internal in a future major release. */
84
80
  options: TransactionOptions;
85
- /** @internal */
86
81
  _pinnedServer?: Server;
87
- /** @internal */
88
82
  _recoveryToken?: Document;
89
83
 
90
- /** Create a transaction @internal */
84
+ /** Create a transaction */
91
85
  constructor(options?: TransactionOptions) {
92
86
  options = options ?? {};
93
87
  this.state = TxnState.NO_TRANSACTION;
@@ -119,23 +113,19 @@ export class Transaction {
119
113
  this._recoveryToken = undefined;
120
114
  }
121
115
 
122
- /** @internal */
123
116
  get server(): Server | undefined {
124
117
  return this._pinnedServer;
125
118
  }
126
119
 
127
- /** @deprecated - Will be made internal in a future major release. */
128
120
  get recoveryToken(): Document | undefined {
129
121
  return this._recoveryToken;
130
122
  }
131
123
 
132
- /** @deprecated - Will be made internal in a future major release. */
133
124
  get isPinned(): boolean {
134
125
  return !!this.server;
135
126
  }
136
127
 
137
128
  /**
138
- * @deprecated - Will be made internal in a future major release.
139
129
  * @returns Whether the transaction has started
140
130
  */
141
131
  get isStarting(): boolean {
@@ -143,20 +133,17 @@ export class Transaction {
143
133
  }
144
134
 
145
135
  /**
146
- * @deprecated - Will be made internal in a future major release.
147
136
  * @returns Whether this session is presently in a transaction
148
137
  */
149
138
  get isActive(): boolean {
150
139
  return ACTIVE_STATES.has(this.state);
151
140
  }
152
141
 
153
- /** @deprecated - Will be made internal in a future major release. */
154
142
  get isCommitted(): boolean {
155
143
  return COMMITTED_STATES.has(this.state);
156
144
  }
157
145
  /**
158
146
  * Transition the transaction in the state machine
159
- * @internal
160
147
  * @param nextState - The new state to transition to
161
148
  */
162
149
  transition(nextState: TxnState): void {
@@ -178,14 +165,12 @@ export class Transaction {
178
165
  );
179
166
  }
180
167
 
181
- /** @internal */
182
168
  pinServer(server: Server): void {
183
169
  if (this.isActive) {
184
170
  this._pinnedServer = server;
185
171
  }
186
172
  }
187
173
 
188
- /** @internal */
189
174
  unpinServer(): void {
190
175
  this._pinnedServer = undefined;
191
176
  }
package/src/utils.ts CHANGED
@@ -153,24 +153,6 @@ export function filterOptions(options: AnyOptions, names: ReadonlyArray<string>)
153
153
  return filterOptions;
154
154
  }
155
155
 
156
- interface HasRetryableWrites {
157
- retryWrites?: boolean;
158
- }
159
- /**
160
- * Applies retryWrites: true to a command if retryWrites is set on the command's database.
161
- * @internal
162
- *
163
- * @param target - The target command to which we will apply retryWrites.
164
- * @param db - The database from which we can inherit a retryWrites value.
165
- */
166
- export function applyRetryableWrites<T extends HasRetryableWrites>(target: T, db?: Db): T {
167
- if (db && db.s.options?.retryWrites) {
168
- target.retryWrites = true;
169
- }
170
-
171
- return target;
172
- }
173
-
174
156
  /**
175
157
  * Applies a write concern to a command based on well defined inheritance rules, optionally
176
158
  * detecting support for the write concern in the first place.
package/tsconfig.json CHANGED
@@ -4,15 +4,12 @@
4
4
  "checkJs": false,
5
5
  "strict": true,
6
6
  "alwaysStrict": true,
7
- "target": "ES2021",
7
+ "target": "ES2023",
8
8
  "module": "commonJS",
9
9
  "moduleResolution": "node",
10
10
  "skipLibCheck": true,
11
11
  "lib": [
12
- "es2021",
13
- "ES2022.Error",
14
- "ES2022.Object",
15
- "esnext.disposable"
12
+ "es2023"
16
13
  ],
17
14
  // We don't make use of tslib helpers, all syntax used is supported by target engine
18
15
  "importHelpers": false,
@@ -36,7 +33,8 @@
36
33
  "noImplicitOverride": true,
37
34
  "noImplicitReturns": true,
38
35
  // TODO(NODE-3659): Enable useUnknownInCatchVariables and add type assertions or remove unnecessary catch blocks
39
- "useUnknownInCatchVariables": false
36
+ "useUnknownInCatchVariables": false,
37
+ "useDefineForClassFields": false
40
38
  },
41
39
  "ts-node": {
42
40
  "transpileOnly": true,
@@ -45,4 +43,4 @@
45
43
  "include": [
46
44
  "src/**/*"
47
45
  ]
48
- }
46
+ }