mongodb 6.8.0-dev.20240822.sha.f5254030 → 6.8.0-dev.20240829.sha.6d65ae77

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 (121) hide show
  1. package/lib/beta.d.ts +29 -5
  2. package/lib/beta.js +0 -1
  3. package/lib/beta.js.map +1 -1
  4. package/lib/bson.js.map +1 -1
  5. package/lib/bulk/common.js +9 -11
  6. package/lib/bulk/common.js.map +1 -1
  7. package/lib/change_stream.js +0 -6
  8. package/lib/change_stream.js.map +1 -1
  9. package/lib/client-side-encryption/mongocryptd_manager.js +1 -1
  10. package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -1
  11. package/lib/cmap/auth/gssapi.js +1 -1
  12. package/lib/cmap/auth/gssapi.js.map +1 -1
  13. package/lib/cmap/auth/mongodb_aws.js.map +1 -1
  14. package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +0 -2
  15. package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -1
  16. package/lib/cmap/auth/mongodb_oidc/machine_workflow.js +0 -2
  17. package/lib/cmap/auth/mongodb_oidc/machine_workflow.js.map +1 -1
  18. package/lib/cmap/commands.js.map +1 -1
  19. package/lib/cmap/connection.js +0 -2
  20. package/lib/cmap/connection.js.map +1 -1
  21. package/lib/cmap/connection_pool.js +0 -1
  22. package/lib/cmap/connection_pool.js.map +1 -1
  23. package/lib/cmap/handshake/client_metadata.js +1 -1
  24. package/lib/cmap/handshake/client_metadata.js.map +1 -1
  25. package/lib/cmap/wire_protocol/shared.js.map +1 -1
  26. package/lib/collection.js.map +1 -1
  27. package/lib/connection_string.js +0 -2
  28. package/lib/connection_string.js.map +1 -1
  29. package/lib/constants.js +1 -0
  30. package/lib/constants.js.map +1 -1
  31. package/lib/cursor/abstract_cursor.js +0 -5
  32. package/lib/cursor/abstract_cursor.js.map +1 -1
  33. package/lib/cursor/aggregation_cursor.js.map +1 -1
  34. package/lib/deps.js +8 -0
  35. package/lib/deps.js.map +1 -1
  36. package/lib/error.js +2 -1
  37. package/lib/error.js.map +1 -1
  38. package/lib/gridfs/download.js +0 -3
  39. package/lib/gridfs/download.js.map +1 -1
  40. package/lib/gridfs/upload.js +0 -4
  41. package/lib/gridfs/upload.js.map +1 -1
  42. package/lib/mongo_logger.js +0 -3
  43. package/lib/mongo_logger.js.map +1 -1
  44. package/lib/mongo_types.js +1 -0
  45. package/lib/mongo_types.js.map +1 -1
  46. package/lib/operations/aggregate.js +1 -0
  47. package/lib/operations/aggregate.js.map +1 -1
  48. package/lib/operations/client_bulk_write/command_builder.js +198 -0
  49. package/lib/operations/client_bulk_write/command_builder.js.map +1 -0
  50. package/lib/operations/client_bulk_write/common.js +3 -0
  51. package/lib/operations/client_bulk_write/common.js.map +1 -0
  52. package/lib/operations/execute_operation.js +2 -1
  53. package/lib/operations/execute_operation.js.map +1 -1
  54. package/lib/operations/find_and_modify.js +1 -1
  55. package/lib/operations/find_and_modify.js.map +1 -1
  56. package/lib/operations/insert.js.map +1 -1
  57. package/lib/operations/operation.js +1 -1
  58. package/lib/operations/operation.js.map +1 -1
  59. package/lib/operations/search_indexes/drop.js.map +1 -1
  60. package/lib/resource_management.js +4 -4
  61. package/lib/resource_management.js.map +1 -1
  62. package/lib/sdam/monitor.js +1 -5
  63. package/lib/sdam/monitor.js.map +1 -1
  64. package/lib/sdam/server_description.js.map +1 -1
  65. package/lib/sdam/srv_polling.js +1 -2
  66. package/lib/sdam/srv_polling.js.map +1 -1
  67. package/lib/sessions.js +1 -1
  68. package/lib/sessions.js.map +1 -1
  69. package/lib/sort.js +1 -1
  70. package/lib/sort.js.map +1 -1
  71. package/lib/timeout.js +0 -1
  72. package/lib/timeout.js.map +1 -1
  73. package/lib/transactions.js.map +1 -1
  74. package/lib/utils.js +0 -1
  75. package/lib/utils.js.map +1 -1
  76. package/lib/write_concern.js.map +1 -1
  77. package/mongodb.d.ts +29 -5
  78. package/package.json +23 -25
  79. package/src/beta.ts +1 -1
  80. package/src/bson.ts +1 -2
  81. package/src/bulk/common.ts +12 -9
  82. package/src/change_stream.ts +10 -11
  83. package/src/client-side-encryption/mongocryptd_manager.ts +1 -1
  84. package/src/cmap/auth/gssapi.ts +1 -1
  85. package/src/cmap/auth/mongodb_aws.ts +2 -2
  86. package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +2 -2
  87. package/src/cmap/auth/mongodb_oidc/machine_workflow.ts +2 -2
  88. package/src/cmap/commands.ts +5 -1
  89. package/src/cmap/connection.ts +2 -2
  90. package/src/cmap/connection_pool.ts +0 -1
  91. package/src/cmap/handshake/client_metadata.ts +1 -1
  92. package/src/cmap/wire_protocol/shared.ts +1 -2
  93. package/src/collection.ts +13 -12
  94. package/src/connection_string.ts +1 -2
  95. package/src/constants.ts +1 -0
  96. package/src/cursor/abstract_cursor.ts +0 -5
  97. package/src/cursor/aggregation_cursor.ts +6 -4
  98. package/src/deps.ts +8 -1
  99. package/src/error.ts +2 -3
  100. package/src/gridfs/download.ts +1 -3
  101. package/src/gridfs/upload.ts +1 -6
  102. package/src/mongo_logger.ts +2 -3
  103. package/src/mongo_types.ts +69 -68
  104. package/src/operations/aggregate.ts +2 -1
  105. package/src/operations/client_bulk_write/command_builder.ts +283 -0
  106. package/src/operations/client_bulk_write/common.ts +146 -0
  107. package/src/operations/execute_operation.ts +6 -4
  108. package/src/operations/find_and_modify.ts +1 -1
  109. package/src/operations/insert.ts +1 -2
  110. package/src/operations/operation.ts +5 -8
  111. package/src/operations/search_indexes/drop.ts +4 -1
  112. package/src/resource_management.ts +4 -4
  113. package/src/sdam/monitor.ts +3 -5
  114. package/src/sdam/server_description.ts +5 -6
  115. package/src/sdam/srv_polling.ts +1 -2
  116. package/src/sessions.ts +1 -1
  117. package/src/sort.ts +1 -1
  118. package/src/timeout.ts +0 -1
  119. package/src/transactions.ts +1 -2
  120. package/src/utils.ts +9 -4
  121. package/src/write_concern.ts +2 -2
@@ -17,11 +17,6 @@ export const Aspect = {
17
17
  /** @public */
18
18
  export type Hint = string | Document;
19
19
 
20
- // eslint-disable-next-line @typescript-eslint/ban-types
21
- export interface OperationConstructor extends Function {
22
- aspects?: Set<symbol>;
23
- }
24
-
25
20
  /** @public */
26
21
  export interface OperationOptions extends BSONSerializeOptions {
27
22
  /** Specify ClientSession for this command */
@@ -63,10 +58,12 @@ export abstract class AbstractOperation<TResult = any> {
63
58
 
64
59
  [kSession]: ClientSession | undefined;
65
60
 
61
+ static aspects?: Set<symbol>;
62
+
66
63
  constructor(options: OperationOptions = {}) {
67
64
  this.readPreference = this.hasAspect(Aspect.WRITE_OPERATION)
68
65
  ? ReadPreference.primary
69
- : ReadPreference.fromOptions(options) ?? ReadPreference.primary;
66
+ : (ReadPreference.fromOptions(options) ?? ReadPreference.primary);
70
67
 
71
68
  // Pull the BSON serialize options from the already-resolved options
72
69
  this.bsonOptions = resolveBSONOptions(options);
@@ -85,7 +82,7 @@ export abstract class AbstractOperation<TResult = any> {
85
82
  abstract execute(server: Server, session: ClientSession | undefined): Promise<TResult>;
86
83
 
87
84
  hasAspect(aspect: symbol): boolean {
88
- const ctor = this.constructor as OperationConstructor;
85
+ const ctor = this.constructor as { aspects?: Set<symbol> };
89
86
  if (ctor.aspects == null) {
90
87
  return false;
91
88
  }
@@ -111,7 +108,7 @@ export abstract class AbstractOperation<TResult = any> {
111
108
  }
112
109
 
113
110
  export function defineAspects(
114
- operation: OperationConstructor,
111
+ operation: { aspects?: Set<symbol> },
115
112
  aspects: symbol | symbol[] | Set<symbol>
116
113
  ): Set<symbol> {
117
114
  if (!Array.isArray(aspects) && !(aspects instanceof Set)) {
@@ -8,7 +8,10 @@ import { AbstractOperation } from '../operation';
8
8
 
9
9
  /** @internal */
10
10
  export class DropSearchIndexOperation extends AbstractOperation<void> {
11
- constructor(private readonly collection: Collection, private readonly name: string) {
11
+ constructor(
12
+ private readonly collection: Collection,
13
+ private readonly name: string
14
+ ) {
12
15
  super();
13
16
  }
14
17
 
@@ -58,13 +58,13 @@ export function configureExplicitResourceManagement() {
58
58
  // function, but keeping all resource-management related code together seemed preferable and I chose
59
59
  // lazy requiring of resources instead.
60
60
 
61
- // eslint-disable-next-line @typescript-eslint/no-var-requires
61
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
62
62
  const { MongoClient } = require('./mongo_client');
63
- // eslint-disable-next-line @typescript-eslint/no-var-requires
63
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
64
64
  const { ClientSession } = require('./sessions');
65
- // eslint-disable-next-line @typescript-eslint/no-var-requires
65
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
66
66
  const { AbstractCursor } = require('./cursor/abstract_cursor');
67
- // eslint-disable-next-line @typescript-eslint/no-var-requires
67
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
68
68
  const { ChangeStream } = require('./change_stream');
69
69
 
70
70
  configureResourceManagement(MongoClient.prototype);
@@ -308,7 +308,7 @@ function checkServer(monitor: Monitor, callback: Callback<Document | null>) {
308
308
  // duration
309
309
  const duration =
310
310
  isAwaitable && monitor.rttPinger
311
- ? monitor.rttPinger.latestRtt ?? calculateDurationInMs(start)
311
+ ? (monitor.rttPinger.latestRtt ?? calculateDurationInMs(start))
312
312
  : calculateDurationInMs(start);
313
313
 
314
314
  monitor.addRttSample(duration);
@@ -378,7 +378,7 @@ function checkServer(monitor: Monitor, callback: Callback<Document | null>) {
378
378
  awaited = false;
379
379
  connection
380
380
  .command(ns('admin.$cmd'), cmd, options)
381
- // eslint-disable-next-line github/no-then
381
+
382
382
  .then(onHeartbeatSucceeded, onHeartbeatFailed);
383
383
 
384
384
  return;
@@ -397,7 +397,6 @@ function checkServer(monitor: Monitor, callback: Callback<Document | null>) {
397
397
  connection.destroy();
398
398
  throw error;
399
399
  }
400
- // eslint-disable-next-line github/no-then
401
400
  })().then(
402
401
  connection => {
403
402
  if (isInCloseState(monitor)) {
@@ -547,7 +546,6 @@ export class RTTPinger {
547
546
 
548
547
  const connection = this.connection;
549
548
  if (connection == null) {
550
- // eslint-disable-next-line github/no-then
551
549
  connect(this.monitor.connectOptions).then(
552
550
  connection => {
553
551
  this.measureAndReschedule(start, connection);
@@ -561,7 +559,7 @@ export class RTTPinger {
561
559
 
562
560
  const commandName =
563
561
  connection.serverApi?.version || connection.helloOk ? 'hello' : LEGACY_HELLO_COMMAND;
564
- // eslint-disable-next-line github/no-then
562
+
565
563
  connection.command(ns('admin.$cmd'), { [commandName]: 1 }, undefined).then(
566
564
  () => this.measureAndReschedule(start),
567
565
  () => {
@@ -1,8 +1,7 @@
1
1
  import { type Document, Long, type ObjectId } from '../bson';
2
2
  import { type MongoError, MongoRuntimeError } from '../error';
3
3
  import { arrayStrictEqual, compareObjectId, errorStrictEqual, HostAddress, now } from '../utils';
4
- import type { ClusterTime } from './common';
5
- import { ServerType } from './common';
4
+ import { type ClusterTime, ServerType } from './common';
6
5
 
7
6
  const WRITABLE_SERVER_TYPES = new Set<ServerType>([
8
7
  ServerType.RSPrimary,
@@ -262,15 +261,15 @@ export function compareTopologyVersion(
262
261
  typeof currentTv.counter === 'bigint'
263
262
  ? Long.fromBigInt(currentTv.counter)
264
263
  : Long.isLong(currentTv.counter)
265
- ? currentTv.counter
266
- : Long.fromNumber(currentTv.counter);
264
+ ? currentTv.counter
265
+ : Long.fromNumber(currentTv.counter);
267
266
 
268
267
  const newCounter =
269
268
  typeof newTv.counter === 'bigint'
270
269
  ? Long.fromBigInt(newTv.counter)
271
270
  : Long.isLong(newTv.counter)
272
- ? newTv.counter
273
- : Long.fromNumber(newTv.counter);
271
+ ? newTv.counter
272
+ : Long.fromNumber(newTv.counter);
274
273
 
275
274
  return currentCounter.compare(newCounter);
276
275
  }
@@ -95,7 +95,6 @@ export class SrvPoller extends TypedEventEmitter<SrvPollerEvents> {
95
95
  }
96
96
 
97
97
  this._timeout = setTimeout(() => {
98
- // eslint-disable-next-line github/no-then
99
98
  this._poll().then(undefined, squashError);
100
99
  }, this.intervalMS);
101
100
  }
@@ -117,7 +116,7 @@ export class SrvPoller extends TypedEventEmitter<SrvPollerEvents> {
117
116
 
118
117
  try {
119
118
  srvRecords = await dns.promises.resolveSrv(this.srvAddress);
120
- } catch (dnsError) {
119
+ } catch {
121
120
  this.failure();
122
121
  return;
123
122
  }
package/src/sessions.ts CHANGED
@@ -592,7 +592,7 @@ export class ClientSession
592
592
  try {
593
593
  await executeOperation(this.client, operation);
594
594
  return;
595
- } catch (secondAbortError) {
595
+ } catch {
596
596
  // we do not retry the retry
597
597
  }
598
598
  }
package/src/sort.ts CHANGED
@@ -60,7 +60,7 @@ function isPair(t: Sort): t is [string, SortDirection] {
60
60
  try {
61
61
  prepareDirection(t[1]);
62
62
  return true;
63
- } catch (e) {
63
+ } catch {
64
64
  return false;
65
65
  }
66
66
  }
package/src/timeout.ts CHANGED
@@ -89,7 +89,6 @@ export class Timeout extends Promise<never> {
89
89
  Symbol.toStringTag in timeout &&
90
90
  timeout[Symbol.toStringTag] === 'MongoDBTimeout' &&
91
91
  'then' in timeout &&
92
- // eslint-disable-next-line github/no-then
93
92
  typeof timeout.then === 'function'
94
93
  );
95
94
  }
@@ -2,8 +2,7 @@ import type { Document } from './bson';
2
2
  import { MongoRuntimeError, MongoTransactionError } from './error';
3
3
  import type { CommandOperationOptions } from './operations/command';
4
4
  import { ReadConcern, type ReadConcernLike } from './read_concern';
5
- import type { ReadPreferenceLike } from './read_preference';
6
- import { ReadPreference } from './read_preference';
5
+ import { ReadPreference, type ReadPreferenceLike } from './read_preference';
7
6
  import type { Server } from './sdam/server';
8
7
  import { WriteConcern } from './write_concern';
9
8
 
package/src/utils.ts CHANGED
@@ -192,7 +192,6 @@ export function isPromiseLike<T = unknown>(value?: unknown): value is PromiseLik
192
192
  value != null &&
193
193
  typeof value === 'object' &&
194
194
  'then' in value &&
195
- // eslint-disable-next-line github/no-then
196
195
  typeof value.then === 'function'
197
196
  );
198
197
  }
@@ -301,7 +300,10 @@ export class MongoDBNamespace {
301
300
  * @param db - database name
302
301
  * @param collection - collection name
303
302
  */
304
- constructor(public db: string, public collection?: string) {
303
+ constructor(
304
+ public db: string,
305
+ public collection?: string
306
+ ) {
305
307
  this.collection = collection === '' ? undefined : collection;
306
308
  }
307
309
 
@@ -333,7 +335,10 @@ export class MongoDBNamespace {
333
335
  * used in scenarios where this can be guaranteed.
334
336
  */
335
337
  export class MongoDBCollectionNamespace extends MongoDBNamespace {
336
- constructor(db: string, override collection: string) {
338
+ constructor(
339
+ db: string,
340
+ override collection: string
341
+ ) {
337
342
  super(db, collection);
338
343
  }
339
344
 
@@ -996,7 +1001,7 @@ export const DEFAULT_PK_FACTORY = {
996
1001
  * })
997
1002
  * ```
998
1003
  */
999
- export const MONGODB_WARNING_CODE = 'MONGODB DRIVER' as const;
1004
+ export const MONGODB_WARNING_CODE = 'MONGODB DRIVER';
1000
1005
 
1001
1006
  /** @internal */
1002
1007
  export function emitWarning(message: string): void {
@@ -169,8 +169,8 @@ export function throwIfWriteConcernError(response: unknown): void {
169
169
  MongoDBResponse.is(response) && response.has('writeConcernError')
170
170
  ? response.toObject()
171
171
  : !MongoDBResponse.is(response) && 'writeConcernError' in response
172
- ? response
173
- : null;
172
+ ? response
173
+ : null;
174
174
 
175
175
  if (writeConcernError != null) {
176
176
  throw new MongoWriteConcernError(writeConcernError as any);