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.
- package/lib/beta.d.ts +29 -5
- package/lib/beta.js +0 -1
- package/lib/beta.js.map +1 -1
- package/lib/bson.js.map +1 -1
- package/lib/bulk/common.js +9 -11
- package/lib/bulk/common.js.map +1 -1
- package/lib/change_stream.js +0 -6
- package/lib/change_stream.js.map +1 -1
- package/lib/client-side-encryption/mongocryptd_manager.js +1 -1
- package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -1
- package/lib/cmap/auth/gssapi.js +1 -1
- package/lib/cmap/auth/gssapi.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +0 -2
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js +0 -2
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js.map +1 -1
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connection.js +0 -2
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +0 -1
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/handshake/client_metadata.js +1 -1
- package/lib/cmap/handshake/client_metadata.js.map +1 -1
- package/lib/cmap/wire_protocol/shared.js.map +1 -1
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +0 -2
- package/lib/connection_string.js.map +1 -1
- package/lib/constants.js +1 -0
- package/lib/constants.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +0 -5
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/deps.js +8 -0
- package/lib/deps.js.map +1 -1
- package/lib/error.js +2 -1
- package/lib/error.js.map +1 -1
- package/lib/gridfs/download.js +0 -3
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/upload.js +0 -4
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/mongo_logger.js +0 -3
- package/lib/mongo_logger.js.map +1 -1
- package/lib/mongo_types.js +1 -0
- package/lib/mongo_types.js.map +1 -1
- package/lib/operations/aggregate.js +1 -0
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/client_bulk_write/command_builder.js +198 -0
- package/lib/operations/client_bulk_write/command_builder.js.map +1 -0
- package/lib/operations/client_bulk_write/common.js +3 -0
- package/lib/operations/client_bulk_write/common.js.map +1 -0
- package/lib/operations/execute_operation.js +2 -1
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find_and_modify.js +1 -1
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/operation.js +1 -1
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/search_indexes/drop.js.map +1 -1
- package/lib/resource_management.js +4 -4
- package/lib/resource_management.js.map +1 -1
- package/lib/sdam/monitor.js +1 -5
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/srv_polling.js +1 -2
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sessions.js +1 -1
- package/lib/sessions.js.map +1 -1
- package/lib/sort.js +1 -1
- package/lib/sort.js.map +1 -1
- package/lib/timeout.js +0 -1
- package/lib/timeout.js.map +1 -1
- package/lib/transactions.js.map +1 -1
- package/lib/utils.js +0 -1
- package/lib/utils.js.map +1 -1
- package/lib/write_concern.js.map +1 -1
- package/mongodb.d.ts +29 -5
- package/package.json +23 -25
- package/src/beta.ts +1 -1
- package/src/bson.ts +1 -2
- package/src/bulk/common.ts +12 -9
- package/src/change_stream.ts +10 -11
- package/src/client-side-encryption/mongocryptd_manager.ts +1 -1
- package/src/cmap/auth/gssapi.ts +1 -1
- package/src/cmap/auth/mongodb_aws.ts +2 -2
- package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +2 -2
- package/src/cmap/auth/mongodb_oidc/machine_workflow.ts +2 -2
- package/src/cmap/commands.ts +5 -1
- package/src/cmap/connection.ts +2 -2
- package/src/cmap/connection_pool.ts +0 -1
- package/src/cmap/handshake/client_metadata.ts +1 -1
- package/src/cmap/wire_protocol/shared.ts +1 -2
- package/src/collection.ts +13 -12
- package/src/connection_string.ts +1 -2
- package/src/constants.ts +1 -0
- package/src/cursor/abstract_cursor.ts +0 -5
- package/src/cursor/aggregation_cursor.ts +6 -4
- package/src/deps.ts +8 -1
- package/src/error.ts +2 -3
- package/src/gridfs/download.ts +1 -3
- package/src/gridfs/upload.ts +1 -6
- package/src/mongo_logger.ts +2 -3
- package/src/mongo_types.ts +69 -68
- package/src/operations/aggregate.ts +2 -1
- package/src/operations/client_bulk_write/command_builder.ts +283 -0
- package/src/operations/client_bulk_write/common.ts +146 -0
- package/src/operations/execute_operation.ts +6 -4
- package/src/operations/find_and_modify.ts +1 -1
- package/src/operations/insert.ts +1 -2
- package/src/operations/operation.ts +5 -8
- package/src/operations/search_indexes/drop.ts +4 -1
- package/src/resource_management.ts +4 -4
- package/src/sdam/monitor.ts +3 -5
- package/src/sdam/server_description.ts +5 -6
- package/src/sdam/srv_polling.ts +1 -2
- package/src/sessions.ts +1 -1
- package/src/sort.ts +1 -1
- package/src/timeout.ts +0 -1
- package/src/transactions.ts +1 -2
- package/src/utils.ts +9 -4
- 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
|
|
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:
|
|
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(
|
|
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-
|
|
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-
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
64
64
|
const { ClientSession } = require('./sessions');
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
|
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-
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
68
68
|
const { ChangeStream } = require('./change_stream');
|
|
69
69
|
|
|
70
70
|
configureResourceManagement(MongoClient.prototype);
|
package/src/sdam/monitor.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
266
|
-
|
|
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
|
-
|
|
273
|
-
|
|
271
|
+
? newTv.counter
|
|
272
|
+
: Long.fromNumber(newTv.counter);
|
|
274
273
|
|
|
275
274
|
return currentCounter.compare(newCounter);
|
|
276
275
|
}
|
package/src/sdam/srv_polling.ts
CHANGED
|
@@ -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
|
|
119
|
+
} catch {
|
|
121
120
|
this.failure();
|
|
122
121
|
return;
|
|
123
122
|
}
|
package/src/sessions.ts
CHANGED
package/src/sort.ts
CHANGED
package/src/timeout.ts
CHANGED
package/src/transactions.ts
CHANGED
|
@@ -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
|
|
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(
|
|
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(
|
|
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'
|
|
1004
|
+
export const MONGODB_WARNING_CODE = 'MONGODB DRIVER';
|
|
1000
1005
|
|
|
1001
1006
|
/** @internal */
|
|
1002
1007
|
export function emitWarning(message: string): void {
|
package/src/write_concern.ts
CHANGED
|
@@ -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
|
-
|
|
173
|
-
|
|
172
|
+
? response
|
|
173
|
+
: null;
|
|
174
174
|
|
|
175
175
|
if (writeConcernError != null) {
|
|
176
176
|
throw new MongoWriteConcernError(writeConcernError as any);
|