mongodb 6.19.0-dev.20250906.sha.82d6ce6a → 6.19.0-dev.20250910.sha.b813c858

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 (65) hide show
  1. package/lib/beta.d.ts +22 -10
  2. package/lib/change_stream.js +5 -1
  3. package/lib/change_stream.js.map +1 -1
  4. package/lib/cmap/wire_protocol/constants.js +5 -3
  5. package/lib/cmap/wire_protocol/constants.js.map +1 -1
  6. package/lib/mongo_client.js.map +1 -1
  7. package/lib/operations/aggregate.js +2 -1
  8. package/lib/operations/aggregate.js.map +1 -1
  9. package/lib/operations/client_bulk_write/client_bulk_write.js +2 -1
  10. package/lib/operations/client_bulk_write/client_bulk_write.js.map +1 -1
  11. package/lib/operations/command.js +6 -0
  12. package/lib/operations/command.js.map +1 -1
  13. package/lib/operations/count.js +1 -1
  14. package/lib/operations/count.js.map +1 -1
  15. package/lib/operations/delete.js +9 -3
  16. package/lib/operations/delete.js.map +1 -1
  17. package/lib/operations/distinct.js +6 -1
  18. package/lib/operations/distinct.js.map +1 -1
  19. package/lib/operations/estimated_document_count.js +2 -1
  20. package/lib/operations/estimated_document_count.js.map +1 -1
  21. package/lib/operations/find.js +2 -1
  22. package/lib/operations/find.js.map +1 -1
  23. package/lib/operations/find_and_modify.js +2 -1
  24. package/lib/operations/find_and_modify.js.map +1 -1
  25. package/lib/operations/indexes.js +4 -3
  26. package/lib/operations/indexes.js.map +1 -1
  27. package/lib/operations/insert.js +10 -2
  28. package/lib/operations/insert.js.map +1 -1
  29. package/lib/operations/list_collections.js +2 -1
  30. package/lib/operations/list_collections.js.map +1 -1
  31. package/lib/operations/operation.js +2 -1
  32. package/lib/operations/operation.js.map +1 -1
  33. package/lib/operations/update.js +12 -4
  34. package/lib/operations/update.js.map +1 -1
  35. package/lib/utils.js +22 -17
  36. package/lib/utils.js.map +1 -1
  37. package/mongodb.d.ts +22 -10
  38. package/package.json +1 -1
  39. package/src/change_stream.ts +5 -1
  40. package/src/cmap/wire_protocol/constants.ts +4 -2
  41. package/src/mongo_client.ts +6 -1
  42. package/src/operations/aggregate.ts +2 -1
  43. package/src/operations/client_bulk_write/client_bulk_write.ts +2 -1
  44. package/src/operations/command.ts +18 -1
  45. package/src/operations/count.ts +1 -1
  46. package/src/operations/create_collection.ts +1 -1
  47. package/src/operations/delete.ts +9 -3
  48. package/src/operations/distinct.ts +6 -1
  49. package/src/operations/drop.ts +1 -1
  50. package/src/operations/estimated_document_count.ts +2 -1
  51. package/src/operations/find.ts +2 -1
  52. package/src/operations/find_and_modify.ts +2 -1
  53. package/src/operations/indexes.ts +5 -4
  54. package/src/operations/insert.ts +10 -2
  55. package/src/operations/list_collections.ts +2 -1
  56. package/src/operations/list_databases.ts +1 -1
  57. package/src/operations/operation.ts +2 -1
  58. package/src/operations/profiling_level.ts +1 -1
  59. package/src/operations/remove_user.ts +1 -1
  60. package/src/operations/rename.ts +1 -1
  61. package/src/operations/set_profiling_level.ts +1 -1
  62. package/src/operations/stats.ts +1 -1
  63. package/src/operations/update.ts +12 -4
  64. package/src/operations/validate_collection.ts +1 -1
  65. package/src/utils.ts +23 -17
@@ -11,7 +11,7 @@ import { executeOperation } from './execute_operation';
11
11
  import { Aspect, defineAspects } from './operation';
12
12
 
13
13
  /** @public */
14
- export interface DropCollectionOptions extends CommandOperationOptions {
14
+ export interface DropCollectionOptions extends Omit<CommandOperationOptions, 'rawData'> {
15
15
  /** @experimental */
16
16
  encryptedFields?: Document;
17
17
  }
@@ -56,5 +56,6 @@ export class EstimatedDocumentCountOperation extends CommandOperation<number> {
56
56
  defineAspects(EstimatedDocumentCountOperation, [
57
57
  Aspect.READ_OPERATION,
58
58
  Aspect.RETRYABLE,
59
- Aspect.CURSOR_CREATING
59
+ Aspect.CURSOR_CREATING,
60
+ Aspect.SUPPORTS_RAW_DATA
60
61
  ]);
@@ -258,5 +258,6 @@ defineAspects(FindOperation, [
258
258
  Aspect.READ_OPERATION,
259
259
  Aspect.RETRYABLE,
260
260
  Aspect.EXPLAINABLE,
261
- Aspect.CURSOR_CREATING
261
+ Aspect.CURSOR_CREATING,
262
+ Aspect.SUPPORTS_RAW_DATA
262
263
  ]);
@@ -314,5 +314,6 @@ export class FindOneAndUpdateOperation extends FindAndModifyOperation {
314
314
  defineAspects(FindAndModifyOperation, [
315
315
  Aspect.WRITE_OPERATION,
316
316
  Aspect.RETRYABLE,
317
- Aspect.EXPLAINABLE
317
+ Aspect.EXPLAINABLE,
318
+ Aspect.SUPPORTS_RAW_DATA
318
319
  ]);
@@ -368,7 +368,7 @@ export class ListIndexesOperation extends CommandOperation<CursorResponse> {
368
368
  * This allows typescript to delete the key but will
369
369
  * not allow a writeConcern to be assigned as a property on options.
370
370
  */
371
- override options: ListIndexesOptions & { writeConcern?: never };
371
+ override options: ListIndexesOptions & { writeConcern?: never; rawData?: boolean };
372
372
  collectionNamespace: MongoDBNamespace;
373
373
 
374
374
  constructor(collection: Collection, options?: ListIndexesOptions) {
@@ -409,7 +409,8 @@ export class ListIndexesOperation extends CommandOperation<CursorResponse> {
409
409
  defineAspects(ListIndexesOperation, [
410
410
  Aspect.READ_OPERATION,
411
411
  Aspect.RETRYABLE,
412
- Aspect.CURSOR_CREATING
412
+ Aspect.CURSOR_CREATING,
413
+ Aspect.SUPPORTS_RAW_DATA
413
414
  ]);
414
- defineAspects(CreateIndexesOperation, [Aspect.WRITE_OPERATION]);
415
- defineAspects(DropIndexOperation, [Aspect.WRITE_OPERATION]);
415
+ defineAspects(CreateIndexesOperation, [Aspect.WRITE_OPERATION, Aspect.SUPPORTS_RAW_DATA]);
416
+ defineAspects(DropIndexOperation, [Aspect.WRITE_OPERATION, Aspect.SUPPORTS_RAW_DATA]);
@@ -96,5 +96,13 @@ export interface InsertManyResult<TSchema = Document> {
96
96
  insertedIds: { [key: number]: InferIdType<TSchema> };
97
97
  }
98
98
 
99
- defineAspects(InsertOperation, [Aspect.RETRYABLE, Aspect.WRITE_OPERATION]);
100
- defineAspects(InsertOneOperation, [Aspect.RETRYABLE, Aspect.WRITE_OPERATION]);
99
+ defineAspects(InsertOperation, [
100
+ Aspect.RETRYABLE,
101
+ Aspect.WRITE_OPERATION,
102
+ Aspect.SUPPORTS_RAW_DATA
103
+ ]);
104
+ defineAspects(InsertOneOperation, [
105
+ Aspect.RETRYABLE,
106
+ Aspect.WRITE_OPERATION,
107
+ Aspect.SUPPORTS_RAW_DATA
108
+ ]);
@@ -103,5 +103,6 @@ export interface CollectionInfo extends Document {
103
103
  defineAspects(ListCollectionsOperation, [
104
104
  Aspect.READ_OPERATION,
105
105
  Aspect.RETRYABLE,
106
- Aspect.CURSOR_CREATING
106
+ Aspect.CURSOR_CREATING,
107
+ Aspect.SUPPORTS_RAW_DATA
107
108
  ]);
@@ -16,7 +16,7 @@ export interface ListDatabasesResult {
16
16
  }
17
17
 
18
18
  /** @public */
19
- export interface ListDatabasesOptions extends CommandOperationOptions {
19
+ export interface ListDatabasesOptions extends Omit<CommandOperationOptions, 'rawData'> {
20
20
  /** A query predicate that determines which databases are listed */
21
21
  filter?: Document;
22
22
  /** A flag to indicate whether the command should return just the database names, or return both database names and size information */
@@ -16,7 +16,8 @@ export const Aspect = {
16
16
  SKIP_COLLATION: Symbol('SKIP_COLLATION'),
17
17
  CURSOR_CREATING: Symbol('CURSOR_CREATING'),
18
18
  MUST_SELECT_SAME_SERVER: Symbol('MUST_SELECT_SAME_SERVER'),
19
- COMMAND_BATCHING: Symbol('COMMAND_BATCHING')
19
+ COMMAND_BATCHING: Symbol('COMMAND_BATCHING'),
20
+ SUPPORTS_RAW_DATA: Symbol('SUPPORTS_RAW_DATA')
20
21
  } as const;
21
22
 
22
23
  /** @public */
@@ -6,7 +6,7 @@ import { MongoUnexpectedServerResponseError } from '../error';
6
6
  import { CommandOperation, type CommandOperationOptions } from './command';
7
7
 
8
8
  /** @public */
9
- export type ProfilingLevelOptions = CommandOperationOptions;
9
+ export type ProfilingLevelOptions = Omit<CommandOperationOptions, 'rawData'>;
10
10
 
11
11
  class ProfilingLevelResponse extends MongoDBResponse {
12
12
  get was() {
@@ -6,7 +6,7 @@ import { CommandOperation, type CommandOperationOptions } from './command';
6
6
  import { Aspect, defineAspects } from './operation';
7
7
 
8
8
  /** @public */
9
- export type RemoveUserOptions = CommandOperationOptions;
9
+ export type RemoveUserOptions = Omit<CommandOperationOptions, 'rawData'>;
10
10
 
11
11
  /** @internal */
12
12
  export class RemoveUserOperation extends CommandOperation<boolean> {
@@ -8,7 +8,7 @@ import { CommandOperation, type CommandOperationOptions } from './command';
8
8
  import { Aspect, defineAspects } from './operation';
9
9
 
10
10
  /** @public */
11
- export interface RenameOptions extends CommandOperationOptions {
11
+ export interface RenameOptions extends Omit<CommandOperationOptions, 'rawData'> {
12
12
  /** Drop the target name collection if it previously exists. */
13
13
  dropTarget?: boolean;
14
14
  /** Unclear */
@@ -19,7 +19,7 @@ export const ProfilingLevel = Object.freeze({
19
19
  export type ProfilingLevel = (typeof ProfilingLevel)[keyof typeof ProfilingLevel];
20
20
 
21
21
  /** @public */
22
- export type SetProfilingLevelOptions = CommandOperationOptions;
22
+ export type SetProfilingLevelOptions = Omit<CommandOperationOptions, 'rawData'>;
23
23
 
24
24
  /** @internal */
25
25
  export class SetProfilingLevelOperation extends CommandOperation<ProfilingLevel> {
@@ -6,7 +6,7 @@ import { CommandOperation, type CommandOperationOptions } from './command';
6
6
  import { Aspect, defineAspects } from './operation';
7
7
 
8
8
  /** @public */
9
- export interface DbStatsOptions extends CommandOperationOptions {
9
+ export interface DbStatsOptions extends Omit<CommandOperationOptions, 'rawData'> {
10
10
  /** Divide the returned sizes by scale value. */
11
11
  scale?: number;
12
12
  }
@@ -291,20 +291,28 @@ export function makeUpdateStatement(
291
291
  return op;
292
292
  }
293
293
 
294
- defineAspects(UpdateOperation, [Aspect.RETRYABLE, Aspect.WRITE_OPERATION, Aspect.SKIP_COLLATION]);
294
+ defineAspects(UpdateOperation, [
295
+ Aspect.RETRYABLE,
296
+ Aspect.WRITE_OPERATION,
297
+ Aspect.SKIP_COLLATION,
298
+ Aspect.SUPPORTS_RAW_DATA
299
+ ]);
295
300
  defineAspects(UpdateOneOperation, [
296
301
  Aspect.RETRYABLE,
297
302
  Aspect.WRITE_OPERATION,
298
303
  Aspect.EXPLAINABLE,
299
- Aspect.SKIP_COLLATION
304
+ Aspect.SKIP_COLLATION,
305
+ Aspect.SUPPORTS_RAW_DATA
300
306
  ]);
301
307
  defineAspects(UpdateManyOperation, [
302
308
  Aspect.WRITE_OPERATION,
303
309
  Aspect.EXPLAINABLE,
304
- Aspect.SKIP_COLLATION
310
+ Aspect.SKIP_COLLATION,
311
+ Aspect.SUPPORTS_RAW_DATA
305
312
  ]);
306
313
  defineAspects(ReplaceOneOperation, [
307
314
  Aspect.RETRYABLE,
308
315
  Aspect.WRITE_OPERATION,
309
- Aspect.SKIP_COLLATION
316
+ Aspect.SKIP_COLLATION,
317
+ Aspect.SUPPORTS_RAW_DATA
310
318
  ]);
@@ -7,7 +7,7 @@ import type { ClientSession } from '../sessions';
7
7
  import { CommandOperation, type CommandOperationOptions } from './command';
8
8
 
9
9
  /** @public */
10
- export interface ValidateCollectionOptions extends CommandOperationOptions {
10
+ export interface ValidateCollectionOptions extends Omit<CommandOperationOptions, 'rawData'> {
11
11
  /** Validates a collection in the background, without interrupting read or write traffic (only in MongoDB 4.4+) */
12
12
  background?: boolean;
13
13
  }
package/src/utils.ts CHANGED
@@ -359,34 +359,40 @@ export function uuidV4(): Buffer {
359
359
  * A helper function for determining `maxWireVersion` between legacy and new topology instances
360
360
  * @internal
361
361
  */
362
- export function maxWireVersion(topologyOrServer?: Connection | Topology | Server): number {
363
- if (topologyOrServer) {
364
- if (topologyOrServer.loadBalanced || topologyOrServer.serverApi?.version) {
365
- // Since we do not have a monitor in the load balanced mode,
366
- // we assume the load-balanced server is always pointed at the latest mongodb version.
367
- // There is a risk that for on-prem deployments
368
- // that don't upgrade immediately that this could alert to the
369
- // application that a feature is available that is actually not.
370
- // We also return the max supported wire version for serverAPI.
362
+ export function maxWireVersion(handshakeAware?: Connection | Topology | Server): number {
363
+ if (handshakeAware) {
364
+ if (handshakeAware.hello) {
365
+ return handshakeAware.hello.maxWireVersion;
366
+ }
367
+
368
+ if (handshakeAware.serverApi?.version) {
369
+ // We return the max supported wire version for serverAPI.
371
370
  return MAX_SUPPORTED_WIRE_VERSION;
372
371
  }
373
- if (topologyOrServer.hello) {
374
- return topologyOrServer.hello.maxWireVersion;
372
+ // This is the fallback case for load balanced mode. If we are building commands the
373
+ // object being checked will be a connection, and we will have a hello response on
374
+ // it. For other cases, such as retryable writes, the object will be a server or
375
+ // topology, and there will be no hello response on those objects, so we return
376
+ // the max wire version so we support retryability. Once we have a min supported
377
+ // wire version of 9, then the needsRetryableWriteLabel() check can remove the
378
+ // usage of passing the wire version into it.
379
+ if (handshakeAware.loadBalanced) {
380
+ return MAX_SUPPORTED_WIRE_VERSION;
375
381
  }
376
382
 
377
- if ('lastHello' in topologyOrServer && typeof topologyOrServer.lastHello === 'function') {
378
- const lastHello = topologyOrServer.lastHello();
383
+ if ('lastHello' in handshakeAware && typeof handshakeAware.lastHello === 'function') {
384
+ const lastHello = handshakeAware.lastHello();
379
385
  if (lastHello) {
380
386
  return lastHello.maxWireVersion;
381
387
  }
382
388
  }
383
389
 
384
390
  if (
385
- topologyOrServer.description &&
386
- 'maxWireVersion' in topologyOrServer.description &&
387
- topologyOrServer.description.maxWireVersion != null
391
+ handshakeAware.description &&
392
+ 'maxWireVersion' in handshakeAware.description &&
393
+ handshakeAware.description.maxWireVersion != null
388
394
  ) {
389
- return topologyOrServer.description.maxWireVersion;
395
+ return handshakeAware.description.maxWireVersion;
390
396
  }
391
397
  }
392
398