mongodb 6.17.0 → 6.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +1 -3
  2. package/lib/beta.d.ts +68 -22
  3. package/lib/bulk/common.js.map +1 -1
  4. package/lib/change_stream.js.map +1 -1
  5. package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
  6. package/lib/client-side-encryption/state_machine.js +1 -5
  7. package/lib/client-side-encryption/state_machine.js.map +1 -1
  8. package/lib/cmap/command_monitoring_events.js +2 -0
  9. package/lib/cmap/command_monitoring_events.js.map +1 -1
  10. package/lib/cmap/commands.js +10 -8
  11. package/lib/cmap/commands.js.map +1 -1
  12. package/lib/cmap/connection_pool.js +6 -2
  13. package/lib/cmap/connection_pool.js.map +1 -1
  14. package/lib/cmap/handshake/client_metadata.js +18 -1
  15. package/lib/cmap/handshake/client_metadata.js.map +1 -1
  16. package/lib/cmap/wire_protocol/compression.js.map +1 -1
  17. package/lib/cmap/wire_protocol/on_data.js +4 -0
  18. package/lib/cmap/wire_protocol/on_data.js.map +1 -1
  19. package/lib/cmap/wire_protocol/on_demand/document.js +16 -15
  20. package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -1
  21. package/lib/cmap/wire_protocol/responses.js +11 -4
  22. package/lib/cmap/wire_protocol/responses.js.map +1 -1
  23. package/lib/connection_string.js +4 -5
  24. package/lib/connection_string.js.map +1 -1
  25. package/lib/cursor/abstract_cursor.js +45 -33
  26. package/lib/cursor/abstract_cursor.js.map +1 -1
  27. package/lib/cursor/run_command_cursor.js +3 -0
  28. package/lib/cursor/run_command_cursor.js.map +1 -1
  29. package/lib/index.js.map +1 -1
  30. package/lib/mongo_client.js +12 -0
  31. package/lib/mongo_client.js.map +1 -1
  32. package/lib/mongo_types.js +4 -1
  33. package/lib/mongo_types.js.map +1 -1
  34. package/lib/operations/command.js.map +1 -1
  35. package/lib/operations/distinct.js +1 -0
  36. package/lib/operations/distinct.js.map +1 -1
  37. package/lib/operations/rename.js.map +1 -1
  38. package/lib/operations/run_command.js.map +1 -1
  39. package/lib/operations/search_indexes/create.js.map +1 -1
  40. package/lib/operations/search_indexes/drop.js.map +1 -1
  41. package/lib/operations/search_indexes/update.js.map +1 -1
  42. package/lib/sessions.js.map +1 -1
  43. package/lib/transactions.js +9 -1
  44. package/lib/transactions.js.map +1 -1
  45. package/lib/utils.js +0 -1
  46. package/lib/utils.js.map +1 -1
  47. package/lib/write_concern.js +2 -4
  48. package/lib/write_concern.js.map +1 -1
  49. package/mongodb.d.ts +68 -22
  50. package/package.json +3 -3
  51. package/src/bulk/common.ts +3 -5
  52. package/src/change_stream.ts +38 -13
  53. package/src/client-side-encryption/auto_encrypter.ts +0 -1
  54. package/src/client-side-encryption/state_machine.ts +8 -10
  55. package/src/cmap/command_monitoring_events.ts +4 -0
  56. package/src/cmap/commands.ts +31 -16
  57. package/src/cmap/connection_pool.ts +6 -2
  58. package/src/cmap/handshake/client_metadata.ts +37 -4
  59. package/src/cmap/wire_protocol/compression.ts +2 -1
  60. package/src/cmap/wire_protocol/on_data.ts +5 -0
  61. package/src/cmap/wire_protocol/on_demand/document.ts +19 -14
  62. package/src/cmap/wire_protocol/responses.ts +8 -8
  63. package/src/connection_string.ts +5 -5
  64. package/src/cursor/abstract_cursor.ts +67 -44
  65. package/src/cursor/run_command_cursor.ts +7 -1
  66. package/src/index.ts +2 -0
  67. package/src/mongo_client.ts +48 -5
  68. package/src/mongo_types.ts +4 -1
  69. package/src/operations/command.ts +4 -0
  70. package/src/operations/distinct.ts +1 -0
  71. package/src/operations/rename.ts +8 -5
  72. package/src/operations/run_command.ts +17 -4
  73. package/src/operations/search_indexes/create.ts +6 -4
  74. package/src/operations/search_indexes/drop.ts +6 -4
  75. package/src/operations/search_indexes/update.ts +8 -5
  76. package/src/sessions.ts +1 -0
  77. package/src/transactions.ts +10 -1
  78. package/src/utils.ts +8 -8
  79. package/src/write_concern.ts +2 -4
  80. package/tsconfig.json +2 -1
@@ -21,11 +21,13 @@ export interface SearchIndexDescription extends Document {
21
21
 
22
22
  /** @internal */
23
23
  export class CreateSearchIndexesOperation extends AbstractOperation<string[]> {
24
- constructor(
25
- private readonly collection: Collection,
26
- private readonly descriptions: ReadonlyArray<SearchIndexDescription>
27
- ) {
24
+ private readonly collection: Collection;
25
+ private readonly descriptions: ReadonlyArray<SearchIndexDescription>;
26
+
27
+ constructor(collection: Collection, descriptions: ReadonlyArray<SearchIndexDescription>) {
28
28
  super();
29
+ this.collection = collection;
30
+ this.descriptions = descriptions;
29
31
  }
30
32
 
31
33
  override get commandName() {
@@ -8,11 +8,13 @@ import { AbstractOperation } from '../operation';
8
8
 
9
9
  /** @internal */
10
10
  export class DropSearchIndexOperation extends AbstractOperation<void> {
11
- constructor(
12
- private readonly collection: Collection,
13
- private readonly name: string
14
- ) {
11
+ private readonly collection: Collection;
12
+ private readonly name: string;
13
+
14
+ constructor(collection: Collection, name: string) {
15
15
  super();
16
+ this.collection = collection;
17
+ this.name = name;
16
18
  }
17
19
 
18
20
  override get commandName() {
@@ -7,12 +7,15 @@ import { AbstractOperation } from '../operation';
7
7
 
8
8
  /** @internal */
9
9
  export class UpdateSearchIndexOperation extends AbstractOperation<void> {
10
- constructor(
11
- private readonly collection: Collection,
12
- private readonly name: string,
13
- private readonly definition: Document
14
- ) {
10
+ private readonly collection: Collection;
11
+ private readonly name: string;
12
+ private readonly definition: Document;
13
+
14
+ constructor(collection: Collection, name: string, definition: Document) {
15
15
  super();
16
+ this.collection = collection;
17
+ this.name = name;
18
+ this.definition = definition;
16
19
  }
17
20
 
18
21
  override get commandName() {
package/src/sessions.ts CHANGED
@@ -121,6 +121,7 @@ export class ClientSession
121
121
  /** @internal */
122
122
  owner?: symbol | AbstractCursor;
123
123
  defaultTransactionOptions: TransactionOptions;
124
+ /** @deprecated - Will be made internal in the next major release */
124
125
  transaction: Transaction;
125
126
  /**
126
127
  * @internal
@@ -74,11 +74,13 @@ export interface TransactionOptions extends Omit<CommandOperationOptions, 'timeo
74
74
 
75
75
  /**
76
76
  * @public
77
+ * @deprecated - Will be made internal in a future major release.
77
78
  * A class maintaining state related to a server transaction. Internal Only
78
79
  */
79
80
  export class Transaction {
80
81
  /** @internal */
81
82
  state: TxnState;
83
+ /** @deprecated - Will be made internal in a future major release. */
82
84
  options: TransactionOptions;
83
85
  /** @internal */
84
86
  _pinnedServer?: Server;
@@ -122,26 +124,33 @@ export class Transaction {
122
124
  return this._pinnedServer;
123
125
  }
124
126
 
127
+ /** @deprecated - Will be made internal in a future major release. */
125
128
  get recoveryToken(): Document | undefined {
126
129
  return this._recoveryToken;
127
130
  }
128
131
 
132
+ /** @deprecated - Will be made internal in a future major release. */
129
133
  get isPinned(): boolean {
130
134
  return !!this.server;
131
135
  }
132
136
 
133
- /** @returns Whether the transaction has started */
137
+ /**
138
+ * @deprecated - Will be made internal in a future major release.
139
+ * @returns Whether the transaction has started
140
+ */
134
141
  get isStarting(): boolean {
135
142
  return this.state === TxnState.STARTING_TRANSACTION;
136
143
  }
137
144
 
138
145
  /**
146
+ * @deprecated - Will be made internal in a future major release.
139
147
  * @returns Whether this session is presently in a transaction
140
148
  */
141
149
  get isActive(): boolean {
142
150
  return ACTIVE_STATES.has(this.state);
143
151
  }
144
152
 
153
+ /** @deprecated - Will be made internal in a future major release. */
145
154
  get isCommitted(): boolean {
146
155
  return COMMITTED_STATES.has(this.state);
147
156
  }
package/src/utils.ts CHANGED
@@ -281,16 +281,16 @@ export function ns(ns: string): MongoDBNamespace {
281
281
 
282
282
  /** @public */
283
283
  export class MongoDBNamespace {
284
+ db: string;
285
+ collection?: string;
284
286
  /**
285
287
  * Create a namespace object
286
288
  *
287
289
  * @param db - database name
288
290
  * @param collection - collection name
289
291
  */
290
- constructor(
291
- public db: string,
292
- public collection?: string
293
- ) {
292
+ constructor(db: string, collection?: string) {
293
+ this.db = db;
294
294
  this.collection = collection === '' ? undefined : collection;
295
295
  }
296
296
 
@@ -322,11 +322,11 @@ export class MongoDBNamespace {
322
322
  * used in scenarios where this can be guaranteed.
323
323
  */
324
324
  export class MongoDBCollectionNamespace extends MongoDBNamespace {
325
- constructor(
326
- db: string,
327
- override collection: string
328
- ) {
325
+ override collection: string;
326
+
327
+ constructor(db: string, collection: string) {
329
328
  super(db, collection);
329
+ this.collection = collection;
330
330
  }
331
331
 
332
332
  static override fromString(namespace?: string): MongoDBCollectionNamespace {
@@ -143,6 +143,7 @@ export class WriteConcern {
143
143
  const parentOpts: WriteConcern | WriteConcernSettings | undefined =
144
144
  inherit instanceof WriteConcern ? inherit : inherit.writeConcern;
145
145
 
146
+ const mergedOpts = { ...parentOpts, ...opts } as WriteConcernSettings;
146
147
  const {
147
148
  w = undefined,
148
149
  wtimeout = undefined,
@@ -150,10 +151,7 @@ export class WriteConcern {
150
151
  fsync = undefined,
151
152
  journal = undefined,
152
153
  wtimeoutMS = undefined
153
- } = {
154
- ...parentOpts,
155
- ...opts
156
- };
154
+ } = mergedOpts;
157
155
  if (
158
156
  w != null ||
159
157
  wtimeout != null ||
package/tsconfig.json CHANGED
@@ -11,7 +11,8 @@
11
11
  "lib": [
12
12
  "es2021",
13
13
  "ES2022.Error",
14
- "ES2022.Object"
14
+ "ES2022.Object",
15
+ "esnext.disposable"
15
16
  ],
16
17
  // We don't make use of tslib helpers, all syntax used is supported by target engine
17
18
  "importHelpers": false,