@digipair/skill-mongodb 0.136.0 → 0.136.1
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/dist/index.esm.js +493 -472
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -22858,14 +22858,14 @@ function indent(str, spaces) {
|
|
|
22858
22858
|
var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
|
|
22859
22859
|
// match is required
|
|
22860
22860
|
if (!match) {
|
|
22861
|
-
return nextMatch = nextMatch1,
|
|
22861
|
+
return nextMatch = nextMatch1, i = i1, tokens = tokens1, {
|
|
22862
22862
|
v: nextMatch1
|
|
22863
22863
|
};
|
|
22864
22864
|
}
|
|
22865
22865
|
var token = match.token, offset = match.offset;
|
|
22866
22866
|
i1 += offset;
|
|
22867
22867
|
if (token === ' ') {
|
|
22868
|
-
return nextMatch = nextMatch1,
|
|
22868
|
+
return nextMatch = nextMatch1, i = i1, tokens = tokens1, "continue";
|
|
22869
22869
|
}
|
|
22870
22870
|
tokens1 = _to_consumable_array$4(tokens1).concat([
|
|
22871
22871
|
token
|
|
@@ -22884,7 +22884,7 @@ function indent(str, spaces) {
|
|
|
22884
22884
|
if (contextKeys.some(function(el) {
|
|
22885
22885
|
return el.startsWith(name);
|
|
22886
22886
|
})) {
|
|
22887
|
-
return nextMatch = nextMatch1,
|
|
22887
|
+
return nextMatch = nextMatch1, i = i1, tokens = tokens1, "continue";
|
|
22888
22888
|
}
|
|
22889
22889
|
if (dateTimeIdentifiers.some(function(el) {
|
|
22890
22890
|
return el === name;
|
|
@@ -22903,9 +22903,9 @@ function indent(str, spaces) {
|
|
|
22903
22903
|
if (dateTimeIdentifiers.some(function(el) {
|
|
22904
22904
|
return el.startsWith(name);
|
|
22905
22905
|
})) {
|
|
22906
|
-
return nextMatch = nextMatch1,
|
|
22906
|
+
return nextMatch = nextMatch1, i = i1, tokens = tokens1, "continue";
|
|
22907
22907
|
}
|
|
22908
|
-
return nextMatch = nextMatch1,
|
|
22908
|
+
return nextMatch = nextMatch1, i = i1, tokens = tokens1, {
|
|
22909
22909
|
v: nextMatch1
|
|
22910
22910
|
};
|
|
22911
22911
|
};
|
|
@@ -51327,7 +51327,7 @@ Object.defineProperty(document, "__esModule", {
|
|
|
51327
51327
|
value: true
|
|
51328
51328
|
});
|
|
51329
51329
|
document.OnDemandDocument = void 0;
|
|
51330
|
-
const bson_1$
|
|
51330
|
+
const bson_1$9 = bson$2;
|
|
51331
51331
|
const BSONElementOffset = {
|
|
51332
51332
|
type: 0,
|
|
51333
51333
|
nameOffset: 1,
|
|
@@ -51348,7 +51348,7 @@ const BSONElementOffset = {
|
|
|
51348
51348
|
this.bson = bson;
|
|
51349
51349
|
this.offset = offset;
|
|
51350
51350
|
this.isArray = isArray;
|
|
51351
|
-
this.elements = elements ?? (0, bson_1$
|
|
51351
|
+
this.elements = elements ?? (0, bson_1$9.parseToElementsToArray)(this.bson, offset);
|
|
51352
51352
|
}
|
|
51353
51353
|
/** Only supports basic latin strings */ isElementName(name, element) {
|
|
51354
51354
|
const nameLength = element[BSONElementOffset.nameLength];
|
|
@@ -51419,45 +51419,45 @@ const BSONElementOffset = {
|
|
|
51419
51419
|
return null;
|
|
51420
51420
|
}
|
|
51421
51421
|
switch(as){
|
|
51422
|
-
case bson_1$
|
|
51423
|
-
case bson_1$
|
|
51422
|
+
case bson_1$9.BSONType.null:
|
|
51423
|
+
case bson_1$9.BSONType.undefined:
|
|
51424
51424
|
return null;
|
|
51425
|
-
case bson_1$
|
|
51426
|
-
return (0, bson_1$
|
|
51427
|
-
case bson_1$
|
|
51428
|
-
return (0, bson_1$
|
|
51429
|
-
case bson_1$
|
|
51430
|
-
return (0, bson_1$
|
|
51431
|
-
case bson_1$
|
|
51425
|
+
case bson_1$9.BSONType.double:
|
|
51426
|
+
return (0, bson_1$9.getFloat64LE)(this.bson, offset);
|
|
51427
|
+
case bson_1$9.BSONType.int:
|
|
51428
|
+
return (0, bson_1$9.getInt32LE)(this.bson, offset);
|
|
51429
|
+
case bson_1$9.BSONType.long:
|
|
51430
|
+
return (0, bson_1$9.getBigInt64LE)(this.bson, offset);
|
|
51431
|
+
case bson_1$9.BSONType.bool:
|
|
51432
51432
|
return Boolean(this.bson[offset]);
|
|
51433
|
-
case bson_1$
|
|
51434
|
-
return new bson_1$
|
|
51435
|
-
case bson_1$
|
|
51436
|
-
return new bson_1$
|
|
51437
|
-
case bson_1$
|
|
51438
|
-
return (0, bson_1$
|
|
51439
|
-
case bson_1$
|
|
51433
|
+
case bson_1$9.BSONType.objectId:
|
|
51434
|
+
return new bson_1$9.ObjectId(this.bson.subarray(offset, offset + 12));
|
|
51435
|
+
case bson_1$9.BSONType.timestamp:
|
|
51436
|
+
return new bson_1$9.Timestamp((0, bson_1$9.getBigInt64LE)(this.bson, offset));
|
|
51437
|
+
case bson_1$9.BSONType.string:
|
|
51438
|
+
return (0, bson_1$9.toUTF8)(this.bson, offset + 4, offset + length - 1, false);
|
|
51439
|
+
case bson_1$9.BSONType.binData:
|
|
51440
51440
|
{
|
|
51441
|
-
const totalBinarySize = (0, bson_1$
|
|
51441
|
+
const totalBinarySize = (0, bson_1$9.getInt32LE)(this.bson, offset);
|
|
51442
51442
|
const subType = this.bson[offset + 4];
|
|
51443
51443
|
if (subType === 2) {
|
|
51444
|
-
const subType2BinarySize = (0, bson_1$
|
|
51445
|
-
if (subType2BinarySize < 0) throw new bson_1$
|
|
51446
|
-
if (subType2BinarySize > totalBinarySize - 4) throw new bson_1$
|
|
51447
|
-
if (subType2BinarySize < totalBinarySize - 4) throw new bson_1$
|
|
51448
|
-
return new bson_1$
|
|
51444
|
+
const subType2BinarySize = (0, bson_1$9.getInt32LE)(this.bson, offset + 1 + 4);
|
|
51445
|
+
if (subType2BinarySize < 0) throw new bson_1$9.BSONError('Negative binary type element size found for subtype 0x02');
|
|
51446
|
+
if (subType2BinarySize > totalBinarySize - 4) throw new bson_1$9.BSONError('Binary type with subtype 0x02 contains too long binary size');
|
|
51447
|
+
if (subType2BinarySize < totalBinarySize - 4) throw new bson_1$9.BSONError('Binary type with subtype 0x02 contains too short binary size');
|
|
51448
|
+
return new bson_1$9.Binary(this.bson.subarray(offset + 1 + 4 + 4, offset + 1 + 4 + 4 + subType2BinarySize), 2);
|
|
51449
51449
|
}
|
|
51450
|
-
return new bson_1$
|
|
51450
|
+
return new bson_1$9.Binary(this.bson.subarray(offset + 1 + 4, offset + 1 + 4 + totalBinarySize), subType);
|
|
51451
51451
|
}
|
|
51452
|
-
case bson_1$
|
|
51452
|
+
case bson_1$9.BSONType.date:
|
|
51453
51453
|
// Pretend this is correct.
|
|
51454
|
-
return new Date(Number((0, bson_1$
|
|
51455
|
-
case bson_1$
|
|
51454
|
+
return new Date(Number((0, bson_1$9.getBigInt64LE)(this.bson, offset)));
|
|
51455
|
+
case bson_1$9.BSONType.object:
|
|
51456
51456
|
return new OnDemandDocument(this.bson, offset);
|
|
51457
|
-
case bson_1$
|
|
51457
|
+
case bson_1$9.BSONType.array:
|
|
51458
51458
|
return new OnDemandDocument(this.bson, offset, true);
|
|
51459
51459
|
default:
|
|
51460
|
-
throw new bson_1$
|
|
51460
|
+
throw new bson_1$9.BSONError(`Unsupported BSON type: ${as}`);
|
|
51461
51461
|
}
|
|
51462
51462
|
}
|
|
51463
51463
|
/**
|
|
@@ -51483,7 +51483,7 @@ const BSONElementOffset = {
|
|
|
51483
51483
|
const element = this.getElement(name);
|
|
51484
51484
|
if (element == null) {
|
|
51485
51485
|
if (required === true) {
|
|
51486
|
-
throw new bson_1$
|
|
51486
|
+
throw new bson_1$9.BSONError(`BSON element "${name}" is missing`);
|
|
51487
51487
|
} else {
|
|
51488
51488
|
return null;
|
|
51489
51489
|
}
|
|
@@ -51492,7 +51492,7 @@ const BSONElementOffset = {
|
|
|
51492
51492
|
const value = this.toJSValue(element.element, as);
|
|
51493
51493
|
if (value == null) {
|
|
51494
51494
|
if (required === true) {
|
|
51495
|
-
throw new bson_1$
|
|
51495
|
+
throw new bson_1$9.BSONError(`BSON element "${name}" is missing`);
|
|
51496
51496
|
} else {
|
|
51497
51497
|
return null;
|
|
51498
51498
|
}
|
|
@@ -51503,13 +51503,13 @@ const BSONElementOffset = {
|
|
|
51503
51503
|
return element.value;
|
|
51504
51504
|
}
|
|
51505
51505
|
getNumber(name, required) {
|
|
51506
|
-
const maybeBool = this.get(name, bson_1$
|
|
51506
|
+
const maybeBool = this.get(name, bson_1$9.BSONType.bool);
|
|
51507
51507
|
const bool = maybeBool == null ? null : maybeBool ? 1 : 0;
|
|
51508
|
-
const maybeLong = this.get(name, bson_1$
|
|
51508
|
+
const maybeLong = this.get(name, bson_1$9.BSONType.long);
|
|
51509
51509
|
const long = maybeLong == null ? null : Number(maybeLong);
|
|
51510
|
-
const result = bool ?? long ?? this.get(name, bson_1$
|
|
51510
|
+
const result = bool ?? long ?? this.get(name, bson_1$9.BSONType.int) ?? this.get(name, bson_1$9.BSONType.double);
|
|
51511
51511
|
if (required === true && result == null) {
|
|
51512
|
-
throw new bson_1$
|
|
51512
|
+
throw new bson_1$9.BSONError(`BSON element "${name}" is missing`);
|
|
51513
51513
|
}
|
|
51514
51514
|
return result;
|
|
51515
51515
|
}
|
|
@@ -51517,14 +51517,14 @@ const BSONElementOffset = {
|
|
|
51517
51517
|
* Deserialize this object, DOES NOT cache result so avoid multiple invocations
|
|
51518
51518
|
* @param options - BSON deserialization options
|
|
51519
51519
|
*/ toObject(options) {
|
|
51520
|
-
return (0, bson_1$
|
|
51520
|
+
return (0, bson_1$9.deserialize)(this.bson, {
|
|
51521
51521
|
...options,
|
|
51522
51522
|
index: this.offset,
|
|
51523
51523
|
allowObjectSmallerThanBufferSize: true
|
|
51524
51524
|
});
|
|
51525
51525
|
}
|
|
51526
51526
|
/** Returns this document's bytes only */ toBytes() {
|
|
51527
|
-
const size = (0, bson_1$
|
|
51527
|
+
const size = (0, bson_1$9.getInt32LE)(this.bson, this.offset);
|
|
51528
51528
|
return this.bson.subarray(this.offset, this.offset + size);
|
|
51529
51529
|
}
|
|
51530
51530
|
};
|
|
@@ -53097,8 +53097,8 @@ Object.defineProperty(timeout, "__esModule", {
|
|
|
53097
53097
|
});
|
|
53098
53098
|
timeout.LegacyTimeoutContext = timeout.CSOTTimeoutContext = timeout.TimeoutContext = timeout.Timeout = timeout.TimeoutError = void 0;
|
|
53099
53099
|
const timers_1$1 = require$$0$2;
|
|
53100
|
-
const error_1$
|
|
53101
|
-
const utils_1$
|
|
53100
|
+
const error_1$y = error$1;
|
|
53101
|
+
const utils_1$q = requireUtils$2();
|
|
53102
53102
|
/** @internal */ let TimeoutError = class TimeoutError extends Error {
|
|
53103
53103
|
get name() {
|
|
53104
53104
|
return 'TimeoutError';
|
|
@@ -53131,12 +53131,12 @@ timeout.TimeoutError = TimeoutError;
|
|
|
53131
53131
|
const unref = !!options?.unref;
|
|
53132
53132
|
const rejection = options?.rejection;
|
|
53133
53133
|
if (duration < 0) {
|
|
53134
|
-
throw new error_1$
|
|
53134
|
+
throw new error_1$y.MongoInvalidArgumentError('Cannot create a Timeout with a negative duration');
|
|
53135
53135
|
}
|
|
53136
53136
|
let reject;
|
|
53137
53137
|
super((_, promiseReject)=>{
|
|
53138
53138
|
reject = promiseReject;
|
|
53139
|
-
executor(utils_1$
|
|
53139
|
+
executor(utils_1$q.noop, promiseReject);
|
|
53140
53140
|
});
|
|
53141
53141
|
this.ended = null;
|
|
53142
53142
|
this.timedOut = false;
|
|
@@ -53174,7 +53174,7 @@ timeout.TimeoutError = TimeoutError;
|
|
|
53174
53174
|
// This method is invoked when someone wants to throw immediately instead of await the result of this promise
|
|
53175
53175
|
// Since they won't be handling the rejection from the promise (because we're about to throw here)
|
|
53176
53176
|
// attach handling to prevent this from bubbling up to Node.js
|
|
53177
|
-
this.then(undefined, utils_1$
|
|
53177
|
+
this.then(undefined, utils_1$q.squashError);
|
|
53178
53178
|
throw new TimeoutError('Timed out', {
|
|
53179
53179
|
duration: this.duration
|
|
53180
53180
|
});
|
|
@@ -53206,7 +53206,7 @@ function isCSOTTimeoutContextOptions(v) {
|
|
|
53206
53206
|
if (options.session?.timeoutContext != null) return options.session?.timeoutContext;
|
|
53207
53207
|
if (isCSOTTimeoutContextOptions(options)) return new CSOTTimeoutContext(options);
|
|
53208
53208
|
else if (isLegacyTimeoutContextOptions(options)) return new LegacyTimeoutContext(options);
|
|
53209
|
-
else throw new error_1$
|
|
53209
|
+
else throw new error_1$y.MongoRuntimeError('Unrecognized options');
|
|
53210
53210
|
}
|
|
53211
53211
|
};
|
|
53212
53212
|
timeout.TimeoutContext = TimeoutContext;
|
|
@@ -53234,8 +53234,8 @@ timeout.TimeoutContext = TimeoutContext;
|
|
|
53234
53234
|
// check for undefined
|
|
53235
53235
|
if (typeof this._serverSelectionTimeout !== 'object' || this._serverSelectionTimeout?.cleared) {
|
|
53236
53236
|
const { remainingTimeMS, serverSelectionTimeoutMS } = this;
|
|
53237
|
-
if (remainingTimeMS <= 0) return Timeout.reject(new error_1$
|
|
53238
|
-
const usingServerSelectionTimeoutMS = serverSelectionTimeoutMS !== 0 && (0, utils_1$
|
|
53237
|
+
if (remainingTimeMS <= 0) return Timeout.reject(new error_1$y.MongoOperationTimeoutError(`Timed out in server selection after ${this.timeoutMS}ms`));
|
|
53238
|
+
const usingServerSelectionTimeoutMS = serverSelectionTimeoutMS !== 0 && (0, utils_1$q.csotMin)(remainingTimeMS, serverSelectionTimeoutMS) === serverSelectionTimeoutMS;
|
|
53239
53239
|
if (usingServerSelectionTimeoutMS) {
|
|
53240
53240
|
this._serverSelectionTimeout = Timeout.expires(serverSelectionTimeoutMS);
|
|
53241
53241
|
} else {
|
|
@@ -53254,7 +53254,7 @@ timeout.TimeoutContext = TimeoutContext;
|
|
|
53254
53254
|
// null or Timeout
|
|
53255
53255
|
this._connectionCheckoutTimeout = this._serverSelectionTimeout;
|
|
53256
53256
|
} else {
|
|
53257
|
-
throw new error_1$
|
|
53257
|
+
throw new error_1$y.MongoRuntimeError('Unreachable. If you are seeing this error, please file a ticket on the NODE driver project on Jira');
|
|
53258
53258
|
}
|
|
53259
53259
|
}
|
|
53260
53260
|
return this._connectionCheckoutTimeout;
|
|
@@ -53263,13 +53263,13 @@ timeout.TimeoutContext = TimeoutContext;
|
|
|
53263
53263
|
const { remainingTimeMS } = this;
|
|
53264
53264
|
if (!Number.isFinite(remainingTimeMS)) return null;
|
|
53265
53265
|
if (remainingTimeMS > 0) return Timeout.expires(remainingTimeMS);
|
|
53266
|
-
return Timeout.reject(new error_1$
|
|
53266
|
+
return Timeout.reject(new error_1$y.MongoOperationTimeoutError('Timed out before socket write'));
|
|
53267
53267
|
}
|
|
53268
53268
|
get timeoutForSocketRead() {
|
|
53269
53269
|
const { remainingTimeMS } = this;
|
|
53270
53270
|
if (!Number.isFinite(remainingTimeMS)) return null;
|
|
53271
53271
|
if (remainingTimeMS > 0) return Timeout.expires(remainingTimeMS);
|
|
53272
|
-
return Timeout.reject(new error_1$
|
|
53272
|
+
return Timeout.reject(new error_1$y.MongoOperationTimeoutError('Timed out before socket read'));
|
|
53273
53273
|
}
|
|
53274
53274
|
refresh() {
|
|
53275
53275
|
this.start = Math.trunc(performance.now());
|
|
@@ -53287,7 +53287,7 @@ timeout.TimeoutContext = TimeoutContext;
|
|
|
53287
53287
|
* If the context has not expired, returns the `remainingTimeMS`
|
|
53288
53288
|
**/ getRemainingTimeMSOrThrow(message) {
|
|
53289
53289
|
const { remainingTimeMS } = this;
|
|
53290
|
-
if (remainingTimeMS <= 0) throw new error_1$
|
|
53290
|
+
if (remainingTimeMS <= 0) throw new error_1$y.MongoOperationTimeoutError(message ?? `Expired after ${this.timeoutMS}ms`);
|
|
53291
53291
|
return remainingTimeMS;
|
|
53292
53292
|
}
|
|
53293
53293
|
/**
|
|
@@ -53532,10 +53532,10 @@ Object.defineProperty(command, "__esModule", {
|
|
|
53532
53532
|
});
|
|
53533
53533
|
command.CommandOperation = void 0;
|
|
53534
53534
|
const constants_1$3 = constants$4;
|
|
53535
|
-
const error_1$
|
|
53535
|
+
const error_1$x = error$1;
|
|
53536
53536
|
const explain_1 = explain;
|
|
53537
53537
|
const read_concern_1 = read_concern;
|
|
53538
|
-
const utils_1$
|
|
53538
|
+
const utils_1$p = requireUtils$2();
|
|
53539
53539
|
const write_concern_1 = requireWrite_concern();
|
|
53540
53540
|
const operation_1$i = operation;
|
|
53541
53541
|
/** @internal */ let CommandOperation = class CommandOperation extends operation_1$i.AbstractOperation {
|
|
@@ -53547,9 +53547,9 @@ const operation_1$i = operation;
|
|
|
53547
53547
|
// as a parent?
|
|
53548
53548
|
const dbNameOverride = options?.dbName || options?.authdb;
|
|
53549
53549
|
if (dbNameOverride) {
|
|
53550
|
-
this.ns = new utils_1$
|
|
53550
|
+
this.ns = new utils_1$p.MongoDBNamespace(dbNameOverride, '$cmd');
|
|
53551
53551
|
} else {
|
|
53552
|
-
this.ns = parent ? parent.s.namespace.withCollection('$cmd') : new utils_1$
|
|
53552
|
+
this.ns = parent ? parent.s.namespace.withCollection('$cmd') : new utils_1$p.MongoDBNamespace('admin', '$cmd');
|
|
53553
53553
|
}
|
|
53554
53554
|
this.readConcern = read_concern_1.ReadConcern.fromOptions(options);
|
|
53555
53555
|
this.writeConcern = write_concern_1.WriteConcern.fromOptions(options);
|
|
@@ -53557,7 +53557,7 @@ const operation_1$i = operation;
|
|
|
53557
53557
|
this.explain = explain_1.Explain.fromOptions(options);
|
|
53558
53558
|
if (this.explain) (0, explain_1.validateExplainTimeoutOptions)(this.options, this.explain);
|
|
53559
53559
|
} else if (options?.explain != null) {
|
|
53560
|
-
throw new error_1$
|
|
53560
|
+
throw new error_1$x.MongoInvalidArgumentError(`Option "explain" is not supported on this command`);
|
|
53561
53561
|
}
|
|
53562
53562
|
}
|
|
53563
53563
|
get canRetryWrite() {
|
|
@@ -53578,7 +53578,7 @@ const operation_1$i = operation;
|
|
|
53578
53578
|
buildCommand(connection, session) {
|
|
53579
53579
|
const command = this.buildCommandDocument(connection, session);
|
|
53580
53580
|
const inTransaction = this.session && this.session.inTransaction();
|
|
53581
|
-
if (this.readConcern && (0, utils_1$
|
|
53581
|
+
if (this.readConcern && (0, utils_1$p.commandSupportsReadConcern)(command) && !inTransaction) {
|
|
53582
53582
|
Object.assign(command, {
|
|
53583
53583
|
readConcern: this.readConcern
|
|
53584
53584
|
});
|
|
@@ -53594,7 +53594,7 @@ const operation_1$i = operation;
|
|
|
53594
53594
|
if (typeof this.options.maxTimeMS === 'number') {
|
|
53595
53595
|
command.maxTimeMS = this.options.maxTimeMS;
|
|
53596
53596
|
}
|
|
53597
|
-
if (this.options.rawData != null && this.hasAspect(operation_1$i.Aspect.SUPPORTS_RAW_DATA) && (0, utils_1$
|
|
53597
|
+
if (this.options.rawData != null && this.hasAspect(operation_1$i.Aspect.SUPPORTS_RAW_DATA) && (0, utils_1$p.maxWireVersion)(connection) >= constants_1$3.MIN_SUPPORTED_RAW_DATA_WIRE_VERSION) {
|
|
53598
53598
|
command.rawData = this.options.rawData;
|
|
53599
53599
|
}
|
|
53600
53600
|
if (this.hasAspect(operation_1$i.Aspect.EXPLAINABLE) && this.explain) {
|
|
@@ -53713,14 +53713,14 @@ Object.defineProperty(execute_operation, "__esModule", {
|
|
|
53713
53713
|
});
|
|
53714
53714
|
execute_operation.executeOperation = executeOperation;
|
|
53715
53715
|
execute_operation.autoConnect = autoConnect;
|
|
53716
|
-
const error_1$
|
|
53717
|
-
const read_preference_1
|
|
53716
|
+
const error_1$w = error$1;
|
|
53717
|
+
const read_preference_1 = read_preference;
|
|
53718
53718
|
const server_selection_1 = server_selection;
|
|
53719
53719
|
const timeout_1$1 = timeout;
|
|
53720
|
-
const utils_1$
|
|
53720
|
+
const utils_1$o = requireUtils$2();
|
|
53721
53721
|
const aggregate_1 = aggregate;
|
|
53722
53722
|
const operation_1$h = operation;
|
|
53723
|
-
const MMAPv1_RETRY_WRITES_ERROR_CODE = error_1$
|
|
53723
|
+
const MMAPv1_RETRY_WRITES_ERROR_CODE = error_1$w.MONGODB_ERROR_CODES.IllegalOperation;
|
|
53724
53724
|
const MMAPv1_RETRY_WRITES_ERROR_MESSAGE = 'This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.';
|
|
53725
53725
|
/**
|
|
53726
53726
|
* Executes the given operation with provided arguments.
|
|
@@ -53744,9 +53744,9 @@ const MMAPv1_RETRY_WRITES_ERROR_MESSAGE = 'This MongoDB deployment does not supp
|
|
|
53744
53744
|
*/ async function executeOperation(client, operation, timeoutContext) {
|
|
53745
53745
|
if (!(operation instanceof operation_1$h.AbstractOperation)) {
|
|
53746
53746
|
// TODO(NODE-3483): Extend MongoRuntimeError
|
|
53747
|
-
throw new error_1$
|
|
53747
|
+
throw new error_1$w.MongoRuntimeError('This method requires a valid operation instance');
|
|
53748
53748
|
}
|
|
53749
|
-
const topology = client.topology == null ? await (0, utils_1$
|
|
53749
|
+
const topology = client.topology == null ? await (0, utils_1$o.abortable)(autoConnect(client), operation.options) : client.topology;
|
|
53750
53750
|
// The driver sessions spec mandates that we implicitly create sessions for operations
|
|
53751
53751
|
// that are not explicitly provided with a session.
|
|
53752
53752
|
let session = operation.session;
|
|
@@ -53758,18 +53758,18 @@ const MMAPv1_RETRY_WRITES_ERROR_MESSAGE = 'This MongoDB deployment does not supp
|
|
|
53758
53758
|
explicit: false
|
|
53759
53759
|
});
|
|
53760
53760
|
} else if (session.hasEnded) {
|
|
53761
|
-
throw new error_1$
|
|
53761
|
+
throw new error_1$w.MongoExpiredSessionError('Use of expired sessions is not permitted');
|
|
53762
53762
|
} else if (session.snapshotEnabled && !topology.capabilities.supportsSnapshotReads) {
|
|
53763
|
-
throw new error_1$
|
|
53763
|
+
throw new error_1$w.MongoCompatibilityError('Snapshot reads require MongoDB 5.0 or later');
|
|
53764
53764
|
} else if (session.client !== client) {
|
|
53765
|
-
throw new error_1$
|
|
53765
|
+
throw new error_1$w.MongoInvalidArgumentError('ClientSession must be from the same MongoClient');
|
|
53766
53766
|
}
|
|
53767
53767
|
operation.session ??= session;
|
|
53768
|
-
const readPreference = operation.readPreference ?? read_preference_1
|
|
53768
|
+
const readPreference = operation.readPreference ?? read_preference_1.ReadPreference.primary;
|
|
53769
53769
|
const inTransaction = !!session?.inTransaction();
|
|
53770
53770
|
const hasReadAspect = operation.hasAspect(operation_1$h.Aspect.READ_OPERATION);
|
|
53771
|
-
if (inTransaction && !readPreference.equals(read_preference_1
|
|
53772
|
-
throw new error_1$
|
|
53771
|
+
if (inTransaction && !readPreference.equals(read_preference_1.ReadPreference.primary) && (hasReadAspect || operation.commandName === 'runCommand')) {
|
|
53772
|
+
throw new error_1$w.MongoTransactionError(`Read preference in a transaction must be primary, not: ${readPreference.mode}`);
|
|
53773
53773
|
}
|
|
53774
53774
|
if (session?.isPinned && session.transaction.isCommitted && !operation.bypassPinningCheck) {
|
|
53775
53775
|
session.unpin();
|
|
@@ -53799,13 +53799,13 @@ const MMAPv1_RETRY_WRITES_ERROR_MESSAGE = 'This MongoDB deployment does not supp
|
|
|
53799
53799
|
*/ async function autoConnect(client) {
|
|
53800
53800
|
if (client.topology == null) {
|
|
53801
53801
|
if (client.s.hasBeenClosed) {
|
|
53802
|
-
throw new error_1$
|
|
53802
|
+
throw new error_1$w.MongoNotConnectedError('Client must be connected before running operations');
|
|
53803
53803
|
}
|
|
53804
53804
|
client.s.options.__skipPingOnConnect = true;
|
|
53805
53805
|
try {
|
|
53806
53806
|
await client.connect();
|
|
53807
53807
|
if (client.topology == null) {
|
|
53808
|
-
throw new error_1$
|
|
53808
|
+
throw new error_1$w.MongoRuntimeError('client.connect did not create a topology but also did not throw');
|
|
53809
53809
|
}
|
|
53810
53810
|
return client.topology;
|
|
53811
53811
|
} finally{
|
|
@@ -53855,7 +53855,7 @@ const MMAPv1_RETRY_WRITES_ERROR_MESSAGE = 'This MongoDB deployment does not supp
|
|
|
53855
53855
|
const hasWriteAspect = operation.hasAspect(operation_1$h.Aspect.WRITE_OPERATION);
|
|
53856
53856
|
const inTransaction = session?.inTransaction() ?? false;
|
|
53857
53857
|
const willRetryRead = topology.s.options.retryReads && !inTransaction && operation.canRetryRead;
|
|
53858
|
-
const willRetryWrite = topology.s.options.retryWrites && !inTransaction && (0, utils_1$
|
|
53858
|
+
const willRetryWrite = topology.s.options.retryWrites && !inTransaction && (0, utils_1$o.supportsRetryableWrites)(server) && operation.canRetryWrite;
|
|
53859
53859
|
const willRetry = operation.hasAspect(operation_1$h.Aspect.RETRYABLE) && session != null && (hasReadAspect && willRetryRead || hasWriteAspect && willRetryWrite);
|
|
53860
53860
|
if (hasWriteAspect && willRetryWrite && session != null) {
|
|
53861
53861
|
operation.options.willRetryWrite = true;
|
|
@@ -53867,7 +53867,7 @@ const MMAPv1_RETRY_WRITES_ERROR_MESSAGE = 'This MongoDB deployment does not supp
|
|
|
53867
53867
|
for(let tries = 0; tries < maxTries; tries++){
|
|
53868
53868
|
if (previousOperationError) {
|
|
53869
53869
|
if (hasWriteAspect && previousOperationError.code === MMAPv1_RETRY_WRITES_ERROR_CODE) {
|
|
53870
|
-
throw new error_1$
|
|
53870
|
+
throw new error_1$w.MongoServerError({
|
|
53871
53871
|
message: MMAPv1_RETRY_WRITES_ERROR_MESSAGE,
|
|
53872
53872
|
errmsg: MMAPv1_RETRY_WRITES_ERROR_MESSAGE,
|
|
53873
53873
|
originalError: previousOperationError
|
|
@@ -53876,11 +53876,11 @@ const MMAPv1_RETRY_WRITES_ERROR_MESSAGE = 'This MongoDB deployment does not supp
|
|
|
53876
53876
|
if (operation.hasAspect(operation_1$h.Aspect.COMMAND_BATCHING) && !operation.canRetryWrite) {
|
|
53877
53877
|
throw previousOperationError;
|
|
53878
53878
|
}
|
|
53879
|
-
if (hasWriteAspect && !(0, error_1$
|
|
53880
|
-
if (hasReadAspect && !(0, error_1$
|
|
53879
|
+
if (hasWriteAspect && !(0, error_1$w.isRetryableWriteError)(previousOperationError)) throw previousOperationError;
|
|
53880
|
+
if (hasReadAspect && !(0, error_1$w.isRetryableReadError)(previousOperationError)) {
|
|
53881
53881
|
throw previousOperationError;
|
|
53882
53882
|
}
|
|
53883
|
-
if (previousOperationError instanceof error_1$
|
|
53883
|
+
if (previousOperationError instanceof error_1$w.MongoNetworkError && operation.hasAspect(operation_1$h.Aspect.CURSOR_CREATING) && session != null && session.isPinned && !session.inTransaction()) {
|
|
53884
53884
|
session.unpin({
|
|
53885
53885
|
force: true,
|
|
53886
53886
|
forceClear: true
|
|
@@ -53892,8 +53892,8 @@ const MMAPv1_RETRY_WRITES_ERROR_MESSAGE = 'This MongoDB deployment does not supp
|
|
|
53892
53892
|
previousServer,
|
|
53893
53893
|
signal: operation.options.signal
|
|
53894
53894
|
});
|
|
53895
|
-
if (hasWriteAspect && !(0, utils_1$
|
|
53896
|
-
throw new error_1$
|
|
53895
|
+
if (hasWriteAspect && !(0, utils_1$o.supportsRetryableWrites)(server)) {
|
|
53896
|
+
throw new error_1$w.MongoUnexpectedServerResponseError('Selected server does not support retryable writes');
|
|
53897
53897
|
}
|
|
53898
53898
|
}
|
|
53899
53899
|
operation.server = server;
|
|
@@ -53909,8 +53909,8 @@ const MMAPv1_RETRY_WRITES_ERROR_MESSAGE = 'This MongoDB deployment does not supp
|
|
|
53909
53909
|
return operation.handleError(error);
|
|
53910
53910
|
}
|
|
53911
53911
|
} catch (operationError) {
|
|
53912
|
-
if (!(operationError instanceof error_1$
|
|
53913
|
-
if (previousOperationError != null && operationError.hasErrorLabel(error_1$
|
|
53912
|
+
if (!(operationError instanceof error_1$w.MongoError)) throw operationError;
|
|
53913
|
+
if (previousOperationError != null && operationError.hasErrorLabel(error_1$w.MongoErrorLabel.NoWritesPerformed)) {
|
|
53914
53914
|
throw previousOperationError;
|
|
53915
53915
|
}
|
|
53916
53916
|
previousServer = server.description;
|
|
@@ -53919,7 +53919,7 @@ const MMAPv1_RETRY_WRITES_ERROR_MESSAGE = 'This MongoDB deployment does not supp
|
|
|
53919
53919
|
timeoutContext.clear();
|
|
53920
53920
|
}
|
|
53921
53921
|
}
|
|
53922
|
-
throw previousOperationError ?? new error_1$
|
|
53922
|
+
throw previousOperationError ?? new error_1$w.MongoRuntimeError('Tried to propagate retryability error, but no error was found.');
|
|
53923
53923
|
}
|
|
53924
53924
|
|
|
53925
53925
|
var list_databases = {};
|
|
@@ -53929,7 +53929,7 @@ Object.defineProperty(list_databases, "__esModule", {
|
|
|
53929
53929
|
});
|
|
53930
53930
|
list_databases.ListDatabasesOperation = void 0;
|
|
53931
53931
|
const responses_1$i = requireResponses();
|
|
53932
|
-
const utils_1$
|
|
53932
|
+
const utils_1$n = requireUtils$2();
|
|
53933
53933
|
const command_1$e = command;
|
|
53934
53934
|
const operation_1$g = operation;
|
|
53935
53935
|
/** @internal */ let ListDatabasesOperation = class ListDatabasesOperation extends command_1$e.CommandOperation {
|
|
@@ -53937,7 +53937,7 @@ const operation_1$g = operation;
|
|
|
53937
53937
|
super(db, options);
|
|
53938
53938
|
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1$i.MongoDBResponse;
|
|
53939
53939
|
this.options = options ?? {};
|
|
53940
|
-
this.ns = new utils_1$
|
|
53940
|
+
this.ns = new utils_1$n.MongoDBNamespace('admin', '$cmd');
|
|
53941
53941
|
}
|
|
53942
53942
|
get commandName() {
|
|
53943
53943
|
return 'listDatabases';
|
|
@@ -53957,7 +53957,7 @@ const operation_1$g = operation;
|
|
|
53957
53957
|
}
|
|
53958
53958
|
// we check for undefined specifically here to allow falsy values
|
|
53959
53959
|
// eslint-disable-next-line no-restricted-syntax
|
|
53960
|
-
if ((0, utils_1$
|
|
53960
|
+
if ((0, utils_1$n.maxWireVersion)(connection) >= 9 && this.options.comment !== undefined) {
|
|
53961
53961
|
cmd.comment = this.options.comment;
|
|
53962
53962
|
}
|
|
53963
53963
|
return cmd;
|
|
@@ -54057,7 +54057,7 @@ Object.defineProperty(validate_collection, "__esModule", {
|
|
|
54057
54057
|
});
|
|
54058
54058
|
validate_collection.ValidateCollectionOperation = void 0;
|
|
54059
54059
|
const responses_1$f = requireResponses();
|
|
54060
|
-
const error_1$
|
|
54060
|
+
const error_1$v = error$1;
|
|
54061
54061
|
const command_1$c = command;
|
|
54062
54062
|
/** @internal */ let ValidateCollectionOperation = class ValidateCollectionOperation extends command_1$c.CommandOperation {
|
|
54063
54063
|
constructor(admin, collectionName, options){
|
|
@@ -54078,9 +54078,9 @@ const command_1$c = command;
|
|
|
54078
54078
|
}
|
|
54079
54079
|
handleOk(response) {
|
|
54080
54080
|
const result = super.handleOk(response);
|
|
54081
|
-
if (result.result != null && typeof result.result !== 'string') throw new error_1$
|
|
54082
|
-
if (result.result != null && result.result.match(/exception|corrupt/) != null) throw new error_1$
|
|
54083
|
-
if (result.valid != null && !result.valid) throw new error_1$
|
|
54081
|
+
if (result.result != null && typeof result.result !== 'string') throw new error_1$v.MongoUnexpectedServerResponseError('Error with validation data');
|
|
54082
|
+
if (result.result != null && result.result.match(/exception|corrupt/) != null) throw new error_1$v.MongoUnexpectedServerResponseError(`Invalid collection ${this.collectionName}`);
|
|
54083
|
+
if (result.valid != null && !result.valid) throw new error_1$v.MongoUnexpectedServerResponseError(`Invalid collection ${this.collectionName}`);
|
|
54084
54084
|
return response;
|
|
54085
54085
|
}
|
|
54086
54086
|
};
|
|
@@ -54090,13 +54090,13 @@ Object.defineProperty(admin, "__esModule", {
|
|
|
54090
54090
|
value: true
|
|
54091
54091
|
});
|
|
54092
54092
|
admin.Admin = void 0;
|
|
54093
|
-
const bson_1$
|
|
54093
|
+
const bson_1$8 = bson$2;
|
|
54094
54094
|
const execute_operation_1 = execute_operation;
|
|
54095
54095
|
const list_databases_1 = list_databases;
|
|
54096
54096
|
const remove_user_1 = remove_user;
|
|
54097
54097
|
const run_command_1 = run_command;
|
|
54098
54098
|
const validate_collection_1 = validate_collection;
|
|
54099
|
-
const utils_1$
|
|
54099
|
+
const utils_1$m = requireUtils$2();
|
|
54100
54100
|
/**
|
|
54101
54101
|
* The **Admin** class is an internal class that allows convenient access to
|
|
54102
54102
|
* the admin functionality and commands for MongoDB.
|
|
@@ -54146,8 +54146,8 @@ const utils_1$n = requireUtils$2();
|
|
|
54146
54146
|
* @param command - The command to execute
|
|
54147
54147
|
* @param options - Optional settings for the command
|
|
54148
54148
|
*/ async command(command, options) {
|
|
54149
|
-
return await (0, execute_operation_1.executeOperation)(this.s.db.client, new run_command_1.RunCommandOperation(new utils_1$
|
|
54150
|
-
...(0, bson_1$
|
|
54149
|
+
return await (0, execute_operation_1.executeOperation)(this.s.db.client, new run_command_1.RunCommandOperation(new utils_1$m.MongoDBNamespace('admin'), command, {
|
|
54150
|
+
...(0, bson_1$8.resolveBSONOptions)(options),
|
|
54151
54151
|
session: options?.session,
|
|
54152
54152
|
readPreference: options?.readPreference,
|
|
54153
54153
|
timeoutMS: options?.timeoutMS ?? this.s.db.timeoutMS
|
|
@@ -54242,8 +54242,8 @@ Object.defineProperty(_delete, "__esModule", {
|
|
|
54242
54242
|
_delete.DeleteManyOperation = _delete.DeleteOneOperation = _delete.DeleteOperation = void 0;
|
|
54243
54243
|
_delete.makeDeleteStatement = makeDeleteStatement;
|
|
54244
54244
|
const responses_1$e = requireResponses();
|
|
54245
|
-
const error_1$
|
|
54246
|
-
const utils_1$
|
|
54245
|
+
const error_1$u = error$1;
|
|
54246
|
+
const utils_1$l = requireUtils$2();
|
|
54247
54247
|
const command_1$b = command;
|
|
54248
54248
|
const operation_1$d = operation;
|
|
54249
54249
|
/** @internal */ let DeleteOperation = class DeleteOperation extends command_1$b.CommandOperation {
|
|
@@ -54280,9 +54280,9 @@ const operation_1$d = operation;
|
|
|
54280
54280
|
command.comment = options.comment;
|
|
54281
54281
|
}
|
|
54282
54282
|
const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0;
|
|
54283
|
-
if (unacknowledgedWrite && (0, utils_1$
|
|
54283
|
+
if (unacknowledgedWrite && (0, utils_1$l.maxWireVersion)(connection) < 9) {
|
|
54284
54284
|
if (this.statements.find((o)=>o.hint)) {
|
|
54285
|
-
throw new error_1$
|
|
54285
|
+
throw new error_1$u.MongoCompatibilityError(`hint for the delete command is only supported on MongoDB 4.4+`);
|
|
54286
54286
|
}
|
|
54287
54287
|
}
|
|
54288
54288
|
return command;
|
|
@@ -54302,8 +54302,8 @@ let DeleteOneOperation = class DeleteOneOperation extends DeleteOperation {
|
|
|
54302
54302
|
const res = super.handleOk(response);
|
|
54303
54303
|
// @ts-expect-error Explain commands have broken TS
|
|
54304
54304
|
if (this.explain) return res;
|
|
54305
|
-
if (res.code) throw new error_1$
|
|
54306
|
-
if (res.writeErrors) throw new error_1$
|
|
54305
|
+
if (res.code) throw new error_1$u.MongoServerError(res);
|
|
54306
|
+
if (res.writeErrors) throw new error_1$u.MongoServerError(res.writeErrors[0]);
|
|
54307
54307
|
return {
|
|
54308
54308
|
acknowledged: this.writeConcern?.w !== 0,
|
|
54309
54309
|
deletedCount: res.n
|
|
@@ -54321,8 +54321,8 @@ let DeleteManyOperation = class DeleteManyOperation extends DeleteOperation {
|
|
|
54321
54321
|
const res = super.handleOk(response);
|
|
54322
54322
|
// @ts-expect-error Explain commands have broken TS
|
|
54323
54323
|
if (this.explain) return res;
|
|
54324
|
-
if (res.code) throw new error_1$
|
|
54325
|
-
if (res.writeErrors) throw new error_1$
|
|
54324
|
+
if (res.code) throw new error_1$u.MongoServerError(res);
|
|
54325
|
+
if (res.writeErrors) throw new error_1$u.MongoServerError(res.writeErrors[0]);
|
|
54326
54326
|
return {
|
|
54327
54327
|
acknowledged: this.writeConcern?.w !== 0,
|
|
54328
54328
|
deletedCount: res.n
|
|
@@ -54369,8 +54369,8 @@ Object.defineProperty(insert, "__esModule", {
|
|
|
54369
54369
|
});
|
|
54370
54370
|
insert.InsertOneOperation = insert.InsertOperation = void 0;
|
|
54371
54371
|
const responses_1$d = requireResponses();
|
|
54372
|
-
const error_1$
|
|
54373
|
-
const utils_1$
|
|
54372
|
+
const error_1$t = error$1;
|
|
54373
|
+
const utils_1$k = requireUtils$2();
|
|
54374
54374
|
const command_1$a = command;
|
|
54375
54375
|
const operation_1$c = operation;
|
|
54376
54376
|
/** @internal */ let InsertOperation = class InsertOperation extends command_1$a.CommandOperation {
|
|
@@ -54410,15 +54410,15 @@ insert.InsertOperation = InsertOperation;
|
|
|
54410
54410
|
let InsertOneOperation = class InsertOneOperation extends InsertOperation {
|
|
54411
54411
|
constructor(collection, doc, options){
|
|
54412
54412
|
super(collection.s.namespace, [
|
|
54413
|
-
(0, utils_1$
|
|
54413
|
+
(0, utils_1$k.maybeAddIdToDocuments)(collection, doc, options)
|
|
54414
54414
|
], options);
|
|
54415
54415
|
}
|
|
54416
54416
|
handleOk(response) {
|
|
54417
54417
|
const res = super.handleOk(response);
|
|
54418
|
-
if (res.code) throw new error_1$
|
|
54418
|
+
if (res.code) throw new error_1$t.MongoServerError(res);
|
|
54419
54419
|
if (res.writeErrors) {
|
|
54420
54420
|
// This should be a WriteError but we can't change it now because of error hierarchy
|
|
54421
|
-
throw new error_1$
|
|
54421
|
+
throw new error_1$t.MongoServerError(res.writeErrors[0]);
|
|
54422
54422
|
}
|
|
54423
54423
|
return {
|
|
54424
54424
|
acknowledged: this.writeConcern?.w !== 0,
|
|
@@ -54446,7 +54446,7 @@ Object.defineProperty(sort, "__esModule", {
|
|
|
54446
54446
|
value: true
|
|
54447
54447
|
});
|
|
54448
54448
|
sort.formatSort = formatSort;
|
|
54449
|
-
const error_1$
|
|
54449
|
+
const error_1$s = error$1;
|
|
54450
54450
|
/** @internal */ function prepareDirection(direction = 1) {
|
|
54451
54451
|
const value = `${direction}`.toLowerCase();
|
|
54452
54452
|
if (isMeta(direction)) return direction;
|
|
@@ -54460,7 +54460,7 @@ const error_1$t = error$1;
|
|
|
54460
54460
|
case '-1':
|
|
54461
54461
|
return -1;
|
|
54462
54462
|
default:
|
|
54463
|
-
throw new error_1$
|
|
54463
|
+
throw new error_1$s.MongoInvalidArgumentError(`Invalid sort direction: ${JSON.stringify(direction)}`);
|
|
54464
54464
|
}
|
|
54465
54465
|
}
|
|
54466
54466
|
/** @internal */ function isMeta(t) {
|
|
@@ -54533,7 +54533,7 @@ function isReadonlyArray(value) {
|
|
|
54533
54533
|
]
|
|
54534
54534
|
]); // 'fieldName'
|
|
54535
54535
|
if (typeof sort !== 'object') {
|
|
54536
|
-
throw new error_1$
|
|
54536
|
+
throw new error_1$s.MongoInvalidArgumentError(`Invalid sort format: ${JSON.stringify(sort)} Sort must be a valid object`);
|
|
54537
54537
|
}
|
|
54538
54538
|
if (!isReadonlyArray(sort)) {
|
|
54539
54539
|
if (isMap(sort)) return mapToMap(sort); // Map<fieldName, SortDirection>
|
|
@@ -54552,9 +54552,9 @@ Object.defineProperty(update$1, "__esModule", {
|
|
|
54552
54552
|
update$1.ReplaceOneOperation = update$1.UpdateManyOperation = update$1.UpdateOneOperation = update$1.UpdateOperation = void 0;
|
|
54553
54553
|
update$1.makeUpdateStatement = makeUpdateStatement;
|
|
54554
54554
|
const responses_1$c = requireResponses();
|
|
54555
|
-
const error_1$
|
|
54555
|
+
const error_1$r = error$1;
|
|
54556
54556
|
const sort_1$1 = sort;
|
|
54557
|
-
const utils_1$
|
|
54557
|
+
const utils_1$j = requireUtils$2();
|
|
54558
54558
|
const command_1$9 = command;
|
|
54559
54559
|
const operation_1$b = operation;
|
|
54560
54560
|
/**
|
|
@@ -54607,16 +54607,16 @@ update$1.UpdateOperation = UpdateOperation;
|
|
|
54607
54607
|
multi: false
|
|
54608
54608
|
})
|
|
54609
54609
|
], options);
|
|
54610
|
-
if (!(0, utils_1$
|
|
54611
|
-
throw new error_1$
|
|
54610
|
+
if (!(0, utils_1$j.hasAtomicOperators)(update, options)) {
|
|
54611
|
+
throw new error_1$r.MongoInvalidArgumentError('Update document requires atomic operators');
|
|
54612
54612
|
}
|
|
54613
54613
|
}
|
|
54614
54614
|
handleOk(response) {
|
|
54615
54615
|
const res = super.handleOk(response);
|
|
54616
54616
|
// @ts-expect-error Explain typing is broken
|
|
54617
54617
|
if (this.explain != null) return res;
|
|
54618
|
-
if (res.code) throw new error_1$
|
|
54619
|
-
if (res.writeErrors) throw new error_1$
|
|
54618
|
+
if (res.code) throw new error_1$r.MongoServerError(res);
|
|
54619
|
+
if (res.writeErrors) throw new error_1$r.MongoServerError(res.writeErrors[0]);
|
|
54620
54620
|
return {
|
|
54621
54621
|
acknowledged: this.writeConcern?.w !== 0,
|
|
54622
54622
|
modifiedCount: res.nModified ?? res.n,
|
|
@@ -54635,16 +54635,16 @@ update$1.UpdateOneOperation = UpdateOneOperation;
|
|
|
54635
54635
|
multi: true
|
|
54636
54636
|
})
|
|
54637
54637
|
], options);
|
|
54638
|
-
if (!(0, utils_1$
|
|
54639
|
-
throw new error_1$
|
|
54638
|
+
if (!(0, utils_1$j.hasAtomicOperators)(update, options)) {
|
|
54639
|
+
throw new error_1$r.MongoInvalidArgumentError('Update document requires atomic operators');
|
|
54640
54640
|
}
|
|
54641
54641
|
}
|
|
54642
54642
|
handleOk(response) {
|
|
54643
54643
|
const res = super.handleOk(response);
|
|
54644
54644
|
// @ts-expect-error Explain typing is broken
|
|
54645
54645
|
if (this.explain != null) return res;
|
|
54646
|
-
if (res.code) throw new error_1$
|
|
54647
|
-
if (res.writeErrors) throw new error_1$
|
|
54646
|
+
if (res.code) throw new error_1$r.MongoServerError(res);
|
|
54647
|
+
if (res.writeErrors) throw new error_1$r.MongoServerError(res.writeErrors[0]);
|
|
54648
54648
|
return {
|
|
54649
54649
|
acknowledged: this.writeConcern?.w !== 0,
|
|
54650
54650
|
modifiedCount: res.nModified ?? res.n,
|
|
@@ -54663,16 +54663,16 @@ update$1.UpdateManyOperation = UpdateManyOperation;
|
|
|
54663
54663
|
multi: false
|
|
54664
54664
|
})
|
|
54665
54665
|
], options);
|
|
54666
|
-
if ((0, utils_1$
|
|
54667
|
-
throw new error_1$
|
|
54666
|
+
if ((0, utils_1$j.hasAtomicOperators)(replacement)) {
|
|
54667
|
+
throw new error_1$r.MongoInvalidArgumentError('Replacement document must not contain atomic operators');
|
|
54668
54668
|
}
|
|
54669
54669
|
}
|
|
54670
54670
|
handleOk(response) {
|
|
54671
54671
|
const res = super.handleOk(response);
|
|
54672
54672
|
// @ts-expect-error Explain typing is broken
|
|
54673
54673
|
if (this.explain != null) return res;
|
|
54674
|
-
if (res.code) throw new error_1$
|
|
54675
|
-
if (res.writeErrors) throw new error_1$
|
|
54674
|
+
if (res.code) throw new error_1$r.MongoServerError(res);
|
|
54675
|
+
if (res.writeErrors) throw new error_1$r.MongoServerError(res.writeErrors[0]);
|
|
54676
54676
|
return {
|
|
54677
54677
|
acknowledged: this.writeConcern?.w !== 0,
|
|
54678
54678
|
modifiedCount: res.nModified ?? res.n,
|
|
@@ -54685,10 +54685,10 @@ update$1.UpdateManyOperation = UpdateManyOperation;
|
|
|
54685
54685
|
update$1.ReplaceOneOperation = ReplaceOneOperation;
|
|
54686
54686
|
function makeUpdateStatement(filter, update, options) {
|
|
54687
54687
|
if (filter == null || typeof filter !== 'object') {
|
|
54688
|
-
throw new error_1$
|
|
54688
|
+
throw new error_1$r.MongoInvalidArgumentError('Selector must be a valid JavaScript object');
|
|
54689
54689
|
}
|
|
54690
54690
|
if (update == null || typeof update !== 'object') {
|
|
54691
|
-
throw new error_1$
|
|
54691
|
+
throw new error_1$r.MongoInvalidArgumentError('Document must be a valid JavaScript object');
|
|
54692
54692
|
}
|
|
54693
54693
|
const op = {
|
|
54694
54694
|
q: filter,
|
|
@@ -55544,9 +55544,9 @@ Object.defineProperty(ordered, "__esModule", {
|
|
|
55544
55544
|
});
|
|
55545
55545
|
ordered.OrderedBulkOperation = void 0;
|
|
55546
55546
|
const BSON$2 = bson$2;
|
|
55547
|
-
const error_1$
|
|
55548
|
-
const common_1$
|
|
55549
|
-
/** @public */ let OrderedBulkOperation = class OrderedBulkOperation extends common_1$
|
|
55547
|
+
const error_1$q = error$1;
|
|
55548
|
+
const common_1$3 = common$1;
|
|
55549
|
+
/** @public */ let OrderedBulkOperation = class OrderedBulkOperation extends common_1$3.BulkOperationBase {
|
|
55550
55550
|
/** @internal */ constructor(collection, options){
|
|
55551
55551
|
super(collection, options, true);
|
|
55552
55552
|
}
|
|
@@ -55560,10 +55560,10 @@ const common_1$5 = common$1;
|
|
|
55560
55560
|
});
|
|
55561
55561
|
// Throw error if the doc is bigger than the max BSON size
|
|
55562
55562
|
if (bsonSize >= this.s.maxBsonObjectSize) // TODO(NODE-3483): Change this to MongoBSONError
|
|
55563
|
-
throw new error_1$
|
|
55563
|
+
throw new error_1$q.MongoInvalidArgumentError(`Document is larger than the maximum size ${this.s.maxBsonObjectSize}`);
|
|
55564
55564
|
// Create a new batch object if we don't have a current one
|
|
55565
55565
|
if (this.s.currentBatch == null) {
|
|
55566
|
-
this.s.currentBatch = new common_1$
|
|
55566
|
+
this.s.currentBatch = new common_1$3.Batch(batchType, this.s.currentIndex);
|
|
55567
55567
|
}
|
|
55568
55568
|
const maxKeySize = this.s.maxKeySize;
|
|
55569
55569
|
// Check if we need to create a new batch
|
|
@@ -55575,12 +55575,12 @@ const common_1$5 = common$1;
|
|
|
55575
55575
|
// Save the batch to the execution stack
|
|
55576
55576
|
this.s.batches.push(this.s.currentBatch);
|
|
55577
55577
|
// Create a new batch
|
|
55578
|
-
this.s.currentBatch = new common_1$
|
|
55578
|
+
this.s.currentBatch = new common_1$3.Batch(batchType, this.s.currentIndex);
|
|
55579
55579
|
// Reset the current size trackers
|
|
55580
55580
|
this.s.currentBatchSize = 0;
|
|
55581
55581
|
this.s.currentBatchSizeBytes = 0;
|
|
55582
55582
|
}
|
|
55583
|
-
if (batchType === common_1$
|
|
55583
|
+
if (batchType === common_1$3.BatchType.INSERT) {
|
|
55584
55584
|
this.s.bulkResult.insertedIds.push({
|
|
55585
55585
|
index: this.s.currentIndex,
|
|
55586
55586
|
_id: document._id
|
|
@@ -55588,7 +55588,7 @@ const common_1$5 = common$1;
|
|
|
55588
55588
|
}
|
|
55589
55589
|
// We have an array of documents
|
|
55590
55590
|
if (Array.isArray(document)) {
|
|
55591
|
-
throw new error_1$
|
|
55591
|
+
throw new error_1$q.MongoInvalidArgumentError('Operation passed in cannot be an Array');
|
|
55592
55592
|
}
|
|
55593
55593
|
this.s.currentBatch.originalIndexes.push(this.s.currentIndex);
|
|
55594
55594
|
this.s.currentBatch.operations.push(document);
|
|
@@ -55607,9 +55607,9 @@ Object.defineProperty(unordered, "__esModule", {
|
|
|
55607
55607
|
});
|
|
55608
55608
|
unordered.UnorderedBulkOperation = void 0;
|
|
55609
55609
|
const BSON$1 = bson$2;
|
|
55610
|
-
const error_1$
|
|
55611
|
-
const common_1$
|
|
55612
|
-
/** @public */ let UnorderedBulkOperation = class UnorderedBulkOperation extends common_1$
|
|
55610
|
+
const error_1$p = error$1;
|
|
55611
|
+
const common_1$2 = common$1;
|
|
55612
|
+
/** @public */ let UnorderedBulkOperation = class UnorderedBulkOperation extends common_1$2.BulkOperationBase {
|
|
55613
55613
|
/** @internal */ constructor(collection, options){
|
|
55614
55614
|
super(collection, options, false);
|
|
55615
55615
|
}
|
|
@@ -55630,22 +55630,22 @@ const common_1$4 = common$1;
|
|
|
55630
55630
|
// Throw error if the doc is bigger than the max BSON size
|
|
55631
55631
|
if (bsonSize >= this.s.maxBsonObjectSize) {
|
|
55632
55632
|
// TODO(NODE-3483): Change this to MongoBSONError
|
|
55633
|
-
throw new error_1$
|
|
55633
|
+
throw new error_1$p.MongoInvalidArgumentError(`Document is larger than the maximum size ${this.s.maxBsonObjectSize}`);
|
|
55634
55634
|
}
|
|
55635
55635
|
// Holds the current batch
|
|
55636
55636
|
this.s.currentBatch = undefined;
|
|
55637
55637
|
// Get the right type of batch
|
|
55638
|
-
if (batchType === common_1$
|
|
55638
|
+
if (batchType === common_1$2.BatchType.INSERT) {
|
|
55639
55639
|
this.s.currentBatch = this.s.currentInsertBatch;
|
|
55640
|
-
} else if (batchType === common_1$
|
|
55640
|
+
} else if (batchType === common_1$2.BatchType.UPDATE) {
|
|
55641
55641
|
this.s.currentBatch = this.s.currentUpdateBatch;
|
|
55642
|
-
} else if (batchType === common_1$
|
|
55642
|
+
} else if (batchType === common_1$2.BatchType.DELETE) {
|
|
55643
55643
|
this.s.currentBatch = this.s.currentRemoveBatch;
|
|
55644
55644
|
}
|
|
55645
55645
|
const maxKeySize = this.s.maxKeySize;
|
|
55646
55646
|
// Create a new batch object if we don't have a current one
|
|
55647
55647
|
if (this.s.currentBatch == null) {
|
|
55648
|
-
this.s.currentBatch = new common_1$
|
|
55648
|
+
this.s.currentBatch = new common_1$2.Batch(batchType, this.s.currentIndex);
|
|
55649
55649
|
}
|
|
55650
55650
|
// Check if we need to create a new batch
|
|
55651
55651
|
if (// New batch if we exceed the max batch op size
|
|
@@ -55656,25 +55656,25 @@ const common_1$4 = common$1;
|
|
|
55656
55656
|
// Save the batch to the execution stack
|
|
55657
55657
|
this.s.batches.push(this.s.currentBatch);
|
|
55658
55658
|
// Create a new batch
|
|
55659
|
-
this.s.currentBatch = new common_1$
|
|
55659
|
+
this.s.currentBatch = new common_1$2.Batch(batchType, this.s.currentIndex);
|
|
55660
55660
|
}
|
|
55661
55661
|
// We have an array of documents
|
|
55662
55662
|
if (Array.isArray(document)) {
|
|
55663
|
-
throw new error_1$
|
|
55663
|
+
throw new error_1$p.MongoInvalidArgumentError('Operation passed in cannot be an Array');
|
|
55664
55664
|
}
|
|
55665
55665
|
this.s.currentBatch.operations.push(document);
|
|
55666
55666
|
this.s.currentBatch.originalIndexes.push(this.s.currentIndex);
|
|
55667
55667
|
this.s.currentIndex = this.s.currentIndex + 1;
|
|
55668
55668
|
// Save back the current Batch to the right type
|
|
55669
|
-
if (batchType === common_1$
|
|
55669
|
+
if (batchType === common_1$2.BatchType.INSERT) {
|
|
55670
55670
|
this.s.currentInsertBatch = this.s.currentBatch;
|
|
55671
55671
|
this.s.bulkResult.insertedIds.push({
|
|
55672
55672
|
index: this.s.bulkResult.insertedIds.length,
|
|
55673
55673
|
_id: document._id
|
|
55674
55674
|
});
|
|
55675
|
-
} else if (batchType === common_1$
|
|
55675
|
+
} else if (batchType === common_1$2.BatchType.UPDATE) {
|
|
55676
55676
|
this.s.currentUpdateBatch = this.s.currentBatch;
|
|
55677
|
-
} else if (batchType === common_1$
|
|
55677
|
+
} else if (batchType === common_1$2.BatchType.DELETE) {
|
|
55678
55678
|
this.s.currentRemoveBatch = this.s.currentBatch;
|
|
55679
55679
|
}
|
|
55680
55680
|
// Update current batch size
|
|
@@ -56381,7 +56381,7 @@ Object.defineProperty(mongo_types, "__esModule", {
|
|
|
56381
56381
|
mongo_types.CancellationToken = mongo_types.TypedEventEmitter = void 0;
|
|
56382
56382
|
const events_1 = require$$0$5;
|
|
56383
56383
|
const mongo_logger_1 = mongo_logger;
|
|
56384
|
-
const utils_1$
|
|
56384
|
+
const utils_1$i = requireUtils$2();
|
|
56385
56385
|
/**
|
|
56386
56386
|
* Typescript type safe event emitter
|
|
56387
56387
|
* @public
|
|
@@ -56422,7 +56422,7 @@ mongo_types.TypedEventEmitter = TypedEventEmitter;
|
|
|
56422
56422
|
*/ let CancellationToken = class CancellationToken extends TypedEventEmitter {
|
|
56423
56423
|
constructor(...args){
|
|
56424
56424
|
super(...args);
|
|
56425
|
-
this.on('error', utils_1$
|
|
56425
|
+
this.on('error', utils_1$i.noop);
|
|
56426
56426
|
}
|
|
56427
56427
|
};
|
|
56428
56428
|
mongo_types.CancellationToken = CancellationToken;
|
|
@@ -62480,7 +62480,7 @@ deps.getGcpMetadata = getGcpMetadata;
|
|
|
62480
62480
|
deps.getSnappy = getSnappy;
|
|
62481
62481
|
deps.getSocks = getSocks;
|
|
62482
62482
|
deps.getMongoDBClientEncryption = getMongoDBClientEncryption;
|
|
62483
|
-
const error_1$
|
|
62483
|
+
const error_1$o = error$1;
|
|
62484
62484
|
function makeErrorModule(error) {
|
|
62485
62485
|
const props = error ? {
|
|
62486
62486
|
kModuleError: error
|
|
@@ -62504,7 +62504,7 @@ function getKerberos() {
|
|
|
62504
62504
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
62505
62505
|
kerberos = require('kerberos');
|
|
62506
62506
|
} catch (error) {
|
|
62507
|
-
kerberos = makeErrorModule(new error_1$
|
|
62507
|
+
kerberos = makeErrorModule(new error_1$o.MongoMissingDependencyError('Optional module `kerberos` not found. Please install it to enable kerberos authentication', {
|
|
62508
62508
|
cause: error,
|
|
62509
62509
|
dependencyName: 'kerberos'
|
|
62510
62510
|
}));
|
|
@@ -62517,7 +62517,7 @@ function getZstdLibrary() {
|
|
|
62517
62517
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
62518
62518
|
ZStandard = require('@mongodb-js/zstd');
|
|
62519
62519
|
} catch (error) {
|
|
62520
|
-
ZStandard = makeErrorModule(new error_1$
|
|
62520
|
+
ZStandard = makeErrorModule(new error_1$o.MongoMissingDependencyError('Optional module `@mongodb-js/zstd` not found. Please install it to enable zstd compression', {
|
|
62521
62521
|
cause: error,
|
|
62522
62522
|
dependencyName: 'zstd'
|
|
62523
62523
|
}));
|
|
@@ -62531,7 +62531,7 @@ function getAwsCredentialProvider() {
|
|
|
62531
62531
|
const credentialProvider = require('@aws-sdk/credential-providers');
|
|
62532
62532
|
return credentialProvider;
|
|
62533
62533
|
} catch (error) {
|
|
62534
|
-
return makeErrorModule(new error_1$
|
|
62534
|
+
return makeErrorModule(new error_1$o.MongoMissingDependencyError('Optional module `@aws-sdk/credential-providers` not found.' + ' Please install it to enable getting aws credentials via the official sdk.', {
|
|
62535
62535
|
cause: error,
|
|
62536
62536
|
dependencyName: '@aws-sdk/credential-providers'
|
|
62537
62537
|
}));
|
|
@@ -62544,7 +62544,7 @@ function getGcpMetadata() {
|
|
|
62544
62544
|
const credentialProvider = require('gcp-metadata');
|
|
62545
62545
|
return credentialProvider;
|
|
62546
62546
|
} catch (error) {
|
|
62547
|
-
return makeErrorModule(new error_1$
|
|
62547
|
+
return makeErrorModule(new error_1$o.MongoMissingDependencyError('Optional module `gcp-metadata` not found.' + ' Please install it to enable getting gcp credentials via the official sdk.', {
|
|
62548
62548
|
cause: error,
|
|
62549
62549
|
dependencyName: 'gcp-metadata'
|
|
62550
62550
|
}));
|
|
@@ -62557,7 +62557,7 @@ function getSnappy() {
|
|
|
62557
62557
|
const value = require('snappy');
|
|
62558
62558
|
return value;
|
|
62559
62559
|
} catch (error) {
|
|
62560
|
-
const kModuleError = new error_1$
|
|
62560
|
+
const kModuleError = new error_1$o.MongoMissingDependencyError('Optional module `snappy` not found. Please install it to enable snappy compression', {
|
|
62561
62561
|
cause: error,
|
|
62562
62562
|
dependencyName: 'snappy'
|
|
62563
62563
|
});
|
|
@@ -62573,7 +62573,7 @@ function getSocks() {
|
|
|
62573
62573
|
const value = requireBuild();
|
|
62574
62574
|
return value;
|
|
62575
62575
|
} catch (error) {
|
|
62576
|
-
const kModuleError = new error_1$
|
|
62576
|
+
const kModuleError = new error_1$o.MongoMissingDependencyError('Optional module `socks` not found. Please install it to connections over a SOCKS5 proxy', {
|
|
62577
62577
|
cause: error,
|
|
62578
62578
|
dependencyName: 'socks'
|
|
62579
62579
|
});
|
|
@@ -62589,7 +62589,7 @@ function loadAws4() {
|
|
|
62589
62589
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
62590
62590
|
aws4 = requireAws4();
|
|
62591
62591
|
} catch (error) {
|
|
62592
|
-
aws4 = makeErrorModule(new error_1$
|
|
62592
|
+
aws4 = makeErrorModule(new error_1$o.MongoMissingDependencyError('Optional module `aws4` not found. Please install it to enable AWS authentication', {
|
|
62593
62593
|
cause: error,
|
|
62594
62594
|
dependencyName: 'aws4'
|
|
62595
62595
|
}));
|
|
@@ -62605,7 +62605,7 @@ function loadAws4() {
|
|
|
62605
62605
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
62606
62606
|
mongodbClientEncryption = require('mongodb-client-encryption');
|
|
62607
62607
|
} catch (error) {
|
|
62608
|
-
const kModuleError = new error_1$
|
|
62608
|
+
const kModuleError = new error_1$o.MongoMissingDependencyError('Optional module `mongodb-client-encryption` not found. Please install it to use auto encryption or ClientEncryption.', {
|
|
62609
62609
|
cause: error,
|
|
62610
62610
|
dependencyName: 'mongodb-client-encryption'
|
|
62611
62611
|
});
|
|
@@ -62622,7 +62622,7 @@ Object.defineProperty(auth_provider, "__esModule", {
|
|
|
62622
62622
|
value: true
|
|
62623
62623
|
});
|
|
62624
62624
|
auth_provider.AuthProvider = auth_provider.AuthContext = void 0;
|
|
62625
|
-
const error_1$
|
|
62625
|
+
const error_1$n = error$1;
|
|
62626
62626
|
/**
|
|
62627
62627
|
* Context used during authentication
|
|
62628
62628
|
* @internal
|
|
@@ -62652,7 +62652,7 @@ auth_provider.AuthContext = AuthContext;
|
|
|
62652
62652
|
* @param context - The shared auth context.
|
|
62653
62653
|
*/ async reauth(context) {
|
|
62654
62654
|
if (context.reauthenticating) {
|
|
62655
|
-
throw new error_1$
|
|
62655
|
+
throw new error_1$n.MongoRuntimeError('Reauthentication already in progress.');
|
|
62656
62656
|
}
|
|
62657
62657
|
try {
|
|
62658
62658
|
context.reauthenticating = true;
|
|
@@ -63024,9 +63024,9 @@ client_metadata.addContainerMetadata = addContainerMetadata;
|
|
|
63024
63024
|
client_metadata.getFAASEnv = getFAASEnv;
|
|
63025
63025
|
const os = require$$0$9;
|
|
63026
63026
|
const process$1 = require$$1$2;
|
|
63027
|
-
const bson_1$
|
|
63028
|
-
const error_1$
|
|
63029
|
-
const utils_1$
|
|
63027
|
+
const bson_1$7 = bson$2;
|
|
63028
|
+
const error_1$m = error$1;
|
|
63029
|
+
const utils_1$h = requireUtils$2();
|
|
63030
63030
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
63031
63031
|
const NODE_DRIVER_VERSION = require$$5.version;
|
|
63032
63032
|
/** @internal */ function isDriverInfoEqual(info1, info2) {
|
|
@@ -63046,7 +63046,7 @@ const NODE_DRIVER_VERSION = require$$5.version;
|
|
|
63046
63046
|
/** Only adds key/value if the bsonByteLength is less than MAX_SIZE */ ifItFitsItSits(key, value) {
|
|
63047
63047
|
// The BSON byteLength of the new element is the same as serializing it to its own document
|
|
63048
63048
|
// subtracting the document size int32 and the null terminator.
|
|
63049
|
-
const newElementSize = bson_1$
|
|
63049
|
+
const newElementSize = bson_1$7.BSON.serialize(new Map().set(key, value)).byteLength - 5;
|
|
63050
63050
|
if (newElementSize + this.documentSize > this.maxSize) {
|
|
63051
63051
|
return false;
|
|
63052
63052
|
}
|
|
@@ -63055,7 +63055,7 @@ const NODE_DRIVER_VERSION = require$$5.version;
|
|
|
63055
63055
|
return true;
|
|
63056
63056
|
}
|
|
63057
63057
|
toObject() {
|
|
63058
|
-
return bson_1$
|
|
63058
|
+
return bson_1$7.BSON.deserialize(bson_1$7.BSON.serialize(this.document), {
|
|
63059
63059
|
promoteLongs: false,
|
|
63060
63060
|
promoteBuffers: false,
|
|
63061
63061
|
promoteValues: false,
|
|
@@ -63094,7 +63094,7 @@ client_metadata.LimitedSizeDocument = LimitedSizeDocument;
|
|
|
63094
63094
|
}
|
|
63095
63095
|
}
|
|
63096
63096
|
if (!metadataDocument.ifItFitsItSits('driver', driverInfo)) {
|
|
63097
|
-
throw new error_1$
|
|
63097
|
+
throw new error_1$m.MongoInvalidArgumentError('Unable to include driverInfo name and version, metadata cannot exceed 512 bytes');
|
|
63098
63098
|
}
|
|
63099
63099
|
let runtimeInfo = getRuntimeInfo();
|
|
63100
63100
|
// This is where we handle additional driver info added after client construction.
|
|
@@ -63104,7 +63104,7 @@ client_metadata.LimitedSizeDocument = LimitedSizeDocument;
|
|
|
63104
63104
|
}
|
|
63105
63105
|
}
|
|
63106
63106
|
if (!metadataDocument.ifItFitsItSits('platform', runtimeInfo)) {
|
|
63107
|
-
throw new error_1$
|
|
63107
|
+
throw new error_1$m.MongoInvalidArgumentError('Unable to include driverInfo platform, metadata cannot exceed 512 bytes');
|
|
63108
63108
|
}
|
|
63109
63109
|
// Note: order matters, os.type is last so it will be removed last if we're at maxSize
|
|
63110
63110
|
const osInfo = new Map().set('name', process$1.platform).set('architecture', process$1.arch).set('version', os.release()).set('type', os.type());
|
|
@@ -63130,7 +63130,7 @@ client_metadata.LimitedSizeDocument = LimitedSizeDocument;
|
|
|
63130
63130
|
let dockerPromise;
|
|
63131
63131
|
/** @internal */ async function getContainerMetadata() {
|
|
63132
63132
|
const containerMetadata = {};
|
|
63133
|
-
dockerPromise ??= (0, utils_1$
|
|
63133
|
+
dockerPromise ??= (0, utils_1$h.fileIsAccessible)('/.dockerenv');
|
|
63134
63134
|
const isDocker = await dockerPromise;
|
|
63135
63135
|
const { KUBERNETES_SERVICE_HOST = '' } = process$1.env;
|
|
63136
63136
|
const isKubernetes = KUBERNETES_SERVICE_HOST.length > 0 ? true : false;
|
|
@@ -63189,7 +63189,7 @@ let dockerPromise;
|
|
|
63189
63189
|
faasEnv.set('region', AWS_REGION);
|
|
63190
63190
|
}
|
|
63191
63191
|
if (AWS_LAMBDA_FUNCTION_MEMORY_SIZE.length > 0 && Number.isInteger(+AWS_LAMBDA_FUNCTION_MEMORY_SIZE)) {
|
|
63192
|
-
faasEnv.set('memory_mb', new bson_1$
|
|
63192
|
+
faasEnv.set('memory_mb', new bson_1$7.Int32(AWS_LAMBDA_FUNCTION_MEMORY_SIZE));
|
|
63193
63193
|
}
|
|
63194
63194
|
faasEnv.set('name', 'aws.lambda');
|
|
63195
63195
|
return faasEnv;
|
|
@@ -63203,10 +63203,10 @@ let dockerPromise;
|
|
|
63203
63203
|
faasEnv.set('region', FUNCTION_REGION);
|
|
63204
63204
|
}
|
|
63205
63205
|
if (FUNCTION_MEMORY_MB.length > 0 && Number.isInteger(+FUNCTION_MEMORY_MB)) {
|
|
63206
|
-
faasEnv.set('memory_mb', new bson_1$
|
|
63206
|
+
faasEnv.set('memory_mb', new bson_1$7.Int32(FUNCTION_MEMORY_MB));
|
|
63207
63207
|
}
|
|
63208
63208
|
if (FUNCTION_TIMEOUT_SEC.length > 0 && Number.isInteger(+FUNCTION_TIMEOUT_SEC)) {
|
|
63209
|
-
faasEnv.set('timeout_sec', new bson_1$
|
|
63209
|
+
faasEnv.set('timeout_sec', new bson_1$7.Int32(FUNCTION_TIMEOUT_SEC));
|
|
63210
63210
|
}
|
|
63211
63211
|
faasEnv.set('name', 'gcp.func');
|
|
63212
63212
|
return faasEnv;
|
|
@@ -118302,11 +118302,11 @@ Object.defineProperty(errors$1, "__esModule", {
|
|
|
118302
118302
|
value: true
|
|
118303
118303
|
});
|
|
118304
118304
|
errors$1.MongoCryptKMSRequestNetworkTimeoutError = errors$1.MongoCryptAzureKMSRequestError = errors$1.MongoCryptCreateEncryptedCollectionError = errors$1.MongoCryptCreateDataKeyError = errors$1.MongoCryptInvalidArgumentError = errors$1.MongoCryptError = void 0;
|
|
118305
|
-
const error_1$
|
|
118305
|
+
const error_1$l = error$1;
|
|
118306
118306
|
/**
|
|
118307
118307
|
* @public
|
|
118308
118308
|
* An error indicating that something went wrong specifically with MongoDB Client Encryption
|
|
118309
|
-
*/ let MongoCryptError = class MongoCryptError extends error_1$
|
|
118309
|
+
*/ let MongoCryptError = class MongoCryptError extends error_1$l.MongoError {
|
|
118310
118310
|
/**
|
|
118311
118311
|
* **Do not use this constructor!**
|
|
118312
118312
|
*
|
|
@@ -118439,8 +118439,8 @@ Object.defineProperty(aws_temporary_credentials, "__esModule", {
|
|
|
118439
118439
|
});
|
|
118440
118440
|
aws_temporary_credentials.LegacyAWSTemporaryCredentialProvider = aws_temporary_credentials.AWSSDKCredentialProvider = aws_temporary_credentials.AWSTemporaryCredentialProvider = void 0;
|
|
118441
118441
|
const deps_1$2 = deps;
|
|
118442
|
-
const error_1$
|
|
118443
|
-
const utils_1$
|
|
118442
|
+
const error_1$k = error$1;
|
|
118443
|
+
const utils_1$g = requireUtils$2();
|
|
118444
118444
|
const AWS_RELATIVE_URI = 'http://169.254.170.2';
|
|
118445
118445
|
const AWS_EC2_URI = 'http://169.254.169.254';
|
|
118446
118446
|
const AWS_EC2_PATH = '/latest/meta-data/iam/security-credentials';
|
|
@@ -118536,7 +118536,7 @@ aws_temporary_credentials.AWSTemporaryCredentialProvider = AWSTemporaryCredentia
|
|
|
118536
118536
|
Expiration: creds.expiration
|
|
118537
118537
|
};
|
|
118538
118538
|
} catch (error) {
|
|
118539
|
-
throw new error_1$
|
|
118539
|
+
throw new error_1$k.MongoAWSError(error.message, {
|
|
118540
118540
|
cause: error
|
|
118541
118541
|
});
|
|
118542
118542
|
}
|
|
@@ -118552,11 +118552,11 @@ aws_temporary_credentials.AWSSDKCredentialProvider = AWSSDKCredentialProvider;
|
|
|
118552
118552
|
// If the environment variable AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
|
|
118553
118553
|
// is set then drivers MUST assume that it was set by an AWS ECS agent
|
|
118554
118554
|
if (process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI) {
|
|
118555
|
-
return await (0, utils_1$
|
|
118555
|
+
return await (0, utils_1$g.request)(`${AWS_RELATIVE_URI}${process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI}`);
|
|
118556
118556
|
}
|
|
118557
118557
|
// Otherwise assume we are on an EC2 instance
|
|
118558
118558
|
// get a token
|
|
118559
|
-
const token = await (0, utils_1$
|
|
118559
|
+
const token = await (0, utils_1$g.request)(`${AWS_EC2_URI}/latest/api/token`, {
|
|
118560
118560
|
method: 'PUT',
|
|
118561
118561
|
json: false,
|
|
118562
118562
|
headers: {
|
|
@@ -118564,14 +118564,14 @@ aws_temporary_credentials.AWSSDKCredentialProvider = AWSSDKCredentialProvider;
|
|
|
118564
118564
|
}
|
|
118565
118565
|
});
|
|
118566
118566
|
// get role name
|
|
118567
|
-
const roleName = await (0, utils_1$
|
|
118567
|
+
const roleName = await (0, utils_1$g.request)(`${AWS_EC2_URI}/${AWS_EC2_PATH}`, {
|
|
118568
118568
|
json: false,
|
|
118569
118569
|
headers: {
|
|
118570
118570
|
'X-aws-ec2-metadata-token': token
|
|
118571
118571
|
}
|
|
118572
118572
|
});
|
|
118573
118573
|
// get temp credentials
|
|
118574
|
-
const creds = await (0, utils_1$
|
|
118574
|
+
const creds = await (0, utils_1$g.request)(`${AWS_EC2_URI}/${AWS_EC2_PATH}/${roleName}`, {
|
|
118575
118575
|
headers: {
|
|
118576
118576
|
'X-aws-ec2-metadata-token': token
|
|
118577
118577
|
}
|
|
@@ -119924,7 +119924,7 @@ Object.defineProperty(mongocryptd_manager, "__esModule", {
|
|
|
119924
119924
|
value: true
|
|
119925
119925
|
});
|
|
119926
119926
|
mongocryptd_manager.MongocryptdManager = void 0;
|
|
119927
|
-
const error_1$
|
|
119927
|
+
const error_1$j = error$1;
|
|
119928
119928
|
/**
|
|
119929
119929
|
* @internal
|
|
119930
119930
|
* An internal class that handles spawning a mongocryptd.
|
|
@@ -119983,7 +119983,7 @@ const error_1$k = error$1;
|
|
|
119983
119983
|
return result;
|
|
119984
119984
|
} catch (err) {
|
|
119985
119985
|
// If we are not bypassing spawning, then we should retry once on a MongoTimeoutError (server selection error)
|
|
119986
|
-
const shouldSpawn = err instanceof error_1$
|
|
119986
|
+
const shouldSpawn = err instanceof error_1$j.MongoNetworkTimeoutError && !this.bypassSpawn;
|
|
119987
119987
|
if (!shouldSpawn) {
|
|
119988
119988
|
throw err;
|
|
119989
119989
|
}
|
|
@@ -121606,22 +121606,22 @@ Object.defineProperty(server_description, "__esModule", {
|
|
|
121606
121606
|
server_description.ServerDescription = void 0;
|
|
121607
121607
|
server_description.parseServerType = parseServerType;
|
|
121608
121608
|
server_description.compareTopologyVersion = compareTopologyVersion;
|
|
121609
|
-
const bson_1$
|
|
121610
|
-
const error_1$
|
|
121611
|
-
const utils_1$
|
|
121612
|
-
const common_1$
|
|
121609
|
+
const bson_1$6 = bson$2;
|
|
121610
|
+
const error_1$i = error$1;
|
|
121611
|
+
const utils_1$f = requireUtils$2();
|
|
121612
|
+
const common_1$1 = common$2;
|
|
121613
121613
|
const WRITABLE_SERVER_TYPES = new Set([
|
|
121614
|
-
common_1$
|
|
121615
|
-
common_1$
|
|
121616
|
-
common_1$
|
|
121617
|
-
common_1$
|
|
121614
|
+
common_1$1.ServerType.RSPrimary,
|
|
121615
|
+
common_1$1.ServerType.Standalone,
|
|
121616
|
+
common_1$1.ServerType.Mongos,
|
|
121617
|
+
common_1$1.ServerType.LoadBalancer
|
|
121618
121618
|
]);
|
|
121619
121619
|
const DATA_BEARING_SERVER_TYPES = new Set([
|
|
121620
|
-
common_1$
|
|
121621
|
-
common_1$
|
|
121622
|
-
common_1$
|
|
121623
|
-
common_1$
|
|
121624
|
-
common_1$
|
|
121620
|
+
common_1$1.ServerType.RSPrimary,
|
|
121621
|
+
common_1$1.ServerType.RSSecondary,
|
|
121622
|
+
common_1$1.ServerType.Mongos,
|
|
121623
|
+
common_1$1.ServerType.Standalone,
|
|
121624
|
+
common_1$1.ServerType.LoadBalancer
|
|
121625
121625
|
]);
|
|
121626
121626
|
/**
|
|
121627
121627
|
* The client's view of a single server, based on the most recent hello outcome.
|
|
@@ -121637,9 +121637,9 @@ const DATA_BEARING_SERVER_TYPES = new Set([
|
|
|
121637
121637
|
* @param hello - An optional hello response for this server
|
|
121638
121638
|
*/ constructor(address, hello, options = {}){
|
|
121639
121639
|
if (address == null || address === '') {
|
|
121640
|
-
throw new error_1$
|
|
121640
|
+
throw new error_1$i.MongoRuntimeError('ServerDescription must be provided with a non-empty address');
|
|
121641
121641
|
}
|
|
121642
|
-
this.address = typeof address === 'string' ? utils_1$
|
|
121642
|
+
this.address = typeof address === 'string' ? utils_1$f.HostAddress.fromString(address).toString() // Use HostAddress to normalize
|
|
121643
121643
|
: address.toString();
|
|
121644
121644
|
this.type = parseServerType(hello, options);
|
|
121645
121645
|
this.hosts = hello?.hosts?.map((host)=>host.toLowerCase()) ?? [];
|
|
@@ -121650,7 +121650,7 @@ const DATA_BEARING_SERVER_TYPES = new Set([
|
|
|
121650
121650
|
this.maxWireVersion = hello?.maxWireVersion ?? 0;
|
|
121651
121651
|
this.roundTripTime = options?.roundTripTime ?? -1;
|
|
121652
121652
|
this.minRoundTripTime = options?.minRoundTripTime ?? 0;
|
|
121653
|
-
this.lastUpdateTime = (0, utils_1$
|
|
121653
|
+
this.lastUpdateTime = (0, utils_1$f.now)();
|
|
121654
121654
|
this.lastWriteDate = hello?.lastWrite?.lastWriteDate ?? 0;
|
|
121655
121655
|
// NOTE: This actually builds the stack string instead of holding onto the getter and all its
|
|
121656
121656
|
// associated references. This is done to prevent a memory leak.
|
|
@@ -121671,13 +121671,13 @@ const DATA_BEARING_SERVER_TYPES = new Set([
|
|
|
121671
121671
|
this.iscryptd = Boolean(hello?.iscryptd);
|
|
121672
121672
|
}
|
|
121673
121673
|
get hostAddress() {
|
|
121674
|
-
return utils_1$
|
|
121674
|
+
return utils_1$f.HostAddress.fromString(this.address);
|
|
121675
121675
|
}
|
|
121676
121676
|
get allHosts() {
|
|
121677
121677
|
return this.hosts.concat(this.arbiters).concat(this.passives);
|
|
121678
121678
|
}
|
|
121679
121679
|
/** Is this server available for reads*/ get isReadable() {
|
|
121680
|
-
return this.type === common_1$
|
|
121680
|
+
return this.type === common_1$1.ServerType.RSSecondary || this.isWritable;
|
|
121681
121681
|
}
|
|
121682
121682
|
/** Is this server data bearing */ get isDataBearing() {
|
|
121683
121683
|
return DATA_BEARING_SERVER_TYPES.has(this.type);
|
|
@@ -121700,39 +121700,39 @@ const DATA_BEARING_SERVER_TYPES = new Set([
|
|
|
121700
121700
|
// Despite using the comparator that would determine a nullish topologyVersion as greater than
|
|
121701
121701
|
// for equality we should only always perform direct equality comparison
|
|
121702
121702
|
const topologyVersionsEqual = this.topologyVersion === other?.topologyVersion || compareTopologyVersion(this.topologyVersion, other?.topologyVersion) === 0;
|
|
121703
|
-
const electionIdsEqual = this.electionId != null && other?.electionId != null ? (0, utils_1$
|
|
121704
|
-
return other != null && other.iscryptd === this.iscryptd && (0, utils_1$
|
|
121703
|
+
const electionIdsEqual = this.electionId != null && other?.electionId != null ? (0, utils_1$f.compareObjectId)(this.electionId, other.electionId) === 0 : this.electionId === other?.electionId;
|
|
121704
|
+
return other != null && other.iscryptd === this.iscryptd && (0, utils_1$f.errorStrictEqual)(this.error, other.error) && this.type === other.type && this.minWireVersion === other.minWireVersion && (0, utils_1$f.arrayStrictEqual)(this.hosts, other.hosts) && tagsStrictEqual(this.tags, other.tags) && this.setName === other.setName && this.setVersion === other.setVersion && electionIdsEqual && this.primary === other.primary && this.logicalSessionTimeoutMinutes === other.logicalSessionTimeoutMinutes && topologyVersionsEqual;
|
|
121705
121705
|
}
|
|
121706
121706
|
};
|
|
121707
121707
|
server_description.ServerDescription = ServerDescription;
|
|
121708
121708
|
// Parses a `hello` message and determines the server type
|
|
121709
121709
|
function parseServerType(hello, options) {
|
|
121710
121710
|
if (options?.loadBalanced) {
|
|
121711
|
-
return common_1$
|
|
121711
|
+
return common_1$1.ServerType.LoadBalancer;
|
|
121712
121712
|
}
|
|
121713
121713
|
if (!hello || !hello.ok) {
|
|
121714
|
-
return common_1$
|
|
121714
|
+
return common_1$1.ServerType.Unknown;
|
|
121715
121715
|
}
|
|
121716
121716
|
if (hello.isreplicaset) {
|
|
121717
|
-
return common_1$
|
|
121717
|
+
return common_1$1.ServerType.RSGhost;
|
|
121718
121718
|
}
|
|
121719
121719
|
if (hello.msg && hello.msg === 'isdbgrid') {
|
|
121720
|
-
return common_1$
|
|
121720
|
+
return common_1$1.ServerType.Mongos;
|
|
121721
121721
|
}
|
|
121722
121722
|
if (hello.setName) {
|
|
121723
121723
|
if (hello.hidden) {
|
|
121724
|
-
return common_1$
|
|
121724
|
+
return common_1$1.ServerType.RSOther;
|
|
121725
121725
|
} else if (hello.isWritablePrimary) {
|
|
121726
|
-
return common_1$
|
|
121726
|
+
return common_1$1.ServerType.RSPrimary;
|
|
121727
121727
|
} else if (hello.secondary) {
|
|
121728
|
-
return common_1$
|
|
121728
|
+
return common_1$1.ServerType.RSSecondary;
|
|
121729
121729
|
} else if (hello.arbiterOnly) {
|
|
121730
|
-
return common_1$
|
|
121730
|
+
return common_1$1.ServerType.RSArbiter;
|
|
121731
121731
|
} else {
|
|
121732
|
-
return common_1$
|
|
121732
|
+
return common_1$1.ServerType.RSOther;
|
|
121733
121733
|
}
|
|
121734
121734
|
}
|
|
121735
|
-
return common_1$
|
|
121735
|
+
return common_1$1.ServerType.Standalone;
|
|
121736
121736
|
}
|
|
121737
121737
|
function tagsStrictEqual(tags, tags2) {
|
|
121738
121738
|
const tagsKeys = Object.keys(tags);
|
|
@@ -121763,191 +121763,205 @@ function tagsStrictEqual(tags, tags2) {
|
|
|
121763
121763
|
return -1;
|
|
121764
121764
|
}
|
|
121765
121765
|
// TODO(NODE-2674): Preserve int64 sent from MongoDB
|
|
121766
|
-
const currentCounter = typeof currentTv.counter === 'bigint' ? bson_1$
|
|
121767
|
-
const newCounter = typeof newTv.counter === 'bigint' ? bson_1$
|
|
121766
|
+
const currentCounter = typeof currentTv.counter === 'bigint' ? bson_1$6.Long.fromBigInt(currentTv.counter) : bson_1$6.Long.isLong(currentTv.counter) ? currentTv.counter : bson_1$6.Long.fromNumber(currentTv.counter);
|
|
121767
|
+
const newCounter = typeof newTv.counter === 'bigint' ? bson_1$6.Long.fromBigInt(newTv.counter) : bson_1$6.Long.isLong(newTv.counter) ? newTv.counter : bson_1$6.Long.fromNumber(newTv.counter);
|
|
121768
121768
|
return currentCounter.compare(newCounter);
|
|
121769
121769
|
}
|
|
121770
121770
|
|
|
121771
|
-
|
|
121772
|
-
|
|
121773
|
-
|
|
121774
|
-
|
|
121775
|
-
|
|
121776
|
-
|
|
121777
|
-
|
|
121778
|
-
|
|
121779
|
-
|
|
121780
|
-
|
|
121781
|
-
|
|
121782
|
-
|
|
121783
|
-
|
|
121784
|
-
|
|
121785
|
-
|
|
121786
|
-
|
|
121787
|
-
|
|
121788
|
-
|
|
121789
|
-
|
|
121790
|
-
|
|
121791
|
-
|
|
121792
|
-
|
|
121793
|
-
|
|
121794
|
-
|
|
121795
|
-
|
|
121796
|
-
|
|
121797
|
-
|
|
121798
|
-
|
|
121799
|
-
|
|
121800
|
-
|
|
121801
|
-
|
|
121802
|
-
|
|
121803
|
-
|
|
121804
|
-
|
|
121805
|
-
|
|
121806
|
-
|
|
121807
|
-
|
|
121808
|
-
|
|
121809
|
-
|
|
121810
|
-
|
|
121811
|
-
|
|
121812
|
-
|
|
121813
|
-
|
|
121814
|
-
|
|
121815
|
-
|
|
121816
|
-
|
|
121817
|
-
|
|
121818
|
-
|
|
121819
|
-
|
|
121820
|
-
|
|
121821
|
-
|
|
121822
|
-
|
|
121823
|
-
|
|
121824
|
-
|
|
121825
|
-
|
|
121826
|
-
|
|
121827
|
-
|
|
121828
|
-
|
|
121829
|
-
|
|
121830
|
-
|
|
121831
|
-
|
|
121771
|
+
var hasRequiredStream_description;
|
|
121772
|
+
|
|
121773
|
+
function requireStream_description () {
|
|
121774
|
+
if (hasRequiredStream_description) return stream_description;
|
|
121775
|
+
hasRequiredStream_description = 1;
|
|
121776
|
+
Object.defineProperty(stream_description, "__esModule", {
|
|
121777
|
+
value: true
|
|
121778
|
+
});
|
|
121779
|
+
stream_description.StreamDescription = void 0;
|
|
121780
|
+
const bson_1 = bson$2;
|
|
121781
|
+
const common_1 = common$2;
|
|
121782
|
+
const server_description_1 = server_description;
|
|
121783
|
+
const RESPONSE_FIELDS = [
|
|
121784
|
+
'minWireVersion',
|
|
121785
|
+
'maxWireVersion',
|
|
121786
|
+
'maxBsonObjectSize',
|
|
121787
|
+
'maxMessageSizeBytes',
|
|
121788
|
+
'maxWriteBatchSize',
|
|
121789
|
+
'logicalSessionTimeoutMinutes'
|
|
121790
|
+
];
|
|
121791
|
+
/** @public */ let StreamDescription = class StreamDescription {
|
|
121792
|
+
constructor(address, options){
|
|
121793
|
+
this.hello = null;
|
|
121794
|
+
this.address = address;
|
|
121795
|
+
this.type = common_1.ServerType.Unknown;
|
|
121796
|
+
this.minWireVersion = undefined;
|
|
121797
|
+
this.maxWireVersion = undefined;
|
|
121798
|
+
this.maxBsonObjectSize = 16777216;
|
|
121799
|
+
this.maxMessageSizeBytes = 48000000;
|
|
121800
|
+
this.maxWriteBatchSize = 100000;
|
|
121801
|
+
this.logicalSessionTimeoutMinutes = options?.logicalSessionTimeoutMinutes;
|
|
121802
|
+
this.loadBalanced = !!options?.loadBalanced;
|
|
121803
|
+
this.compressors = options && options.compressors && Array.isArray(options.compressors) ? options.compressors : [];
|
|
121804
|
+
this.serverConnectionId = null;
|
|
121805
|
+
}
|
|
121806
|
+
receiveResponse(response) {
|
|
121807
|
+
if (response == null) {
|
|
121808
|
+
return;
|
|
121809
|
+
}
|
|
121810
|
+
this.hello = response;
|
|
121811
|
+
this.type = (0, server_description_1.parseServerType)(response);
|
|
121812
|
+
if ('connectionId' in response) {
|
|
121813
|
+
this.serverConnectionId = this.parseServerConnectionID(response.connectionId);
|
|
121814
|
+
} else {
|
|
121815
|
+
this.serverConnectionId = null;
|
|
121816
|
+
}
|
|
121817
|
+
for (const field of RESPONSE_FIELDS){
|
|
121818
|
+
if (response[field] != null) {
|
|
121819
|
+
this[field] = response[field];
|
|
121820
|
+
}
|
|
121821
|
+
// testing case
|
|
121822
|
+
if ('__nodejs_mock_server__' in response) {
|
|
121823
|
+
this.__nodejs_mock_server__ = response['__nodejs_mock_server__'];
|
|
121824
|
+
}
|
|
121825
|
+
}
|
|
121826
|
+
if (response.compression) {
|
|
121827
|
+
this.compressor = this.compressors.filter((c)=>response.compression?.includes(c))[0];
|
|
121828
|
+
}
|
|
121829
|
+
}
|
|
121830
|
+
/* @internal */ parseServerConnectionID(serverConnectionId) {
|
|
121831
|
+
// Connection ids are always integral, so it's safe to coerce doubles as well as
|
|
121832
|
+
// any integral type.
|
|
121833
|
+
return bson_1.Long.isLong(serverConnectionId) ? serverConnectionId.toBigInt() : BigInt(serverConnectionId);
|
|
121834
|
+
}
|
|
121835
|
+
};
|
|
121836
|
+
stream_description.StreamDescription = StreamDescription;
|
|
121837
|
+
return stream_description;
|
|
121838
|
+
}
|
|
121832
121839
|
|
|
121833
121840
|
var on_data = {};
|
|
121834
121841
|
|
|
121835
|
-
|
|
121836
|
-
|
|
121837
|
-
|
|
121838
|
-
|
|
121839
|
-
|
|
121840
|
-
|
|
121841
|
-
|
|
121842
|
-
|
|
121843
|
-
|
|
121844
|
-
|
|
121845
|
-
|
|
121846
|
-
|
|
121847
|
-
|
|
121848
|
-
|
|
121849
|
-
|
|
121850
|
-
|
|
121851
|
-
|
|
121852
|
-
|
|
121853
|
-
|
|
121854
|
-
|
|
121855
|
-
|
|
121856
|
-
|
|
121857
|
-
|
|
121858
|
-
|
|
121859
|
-
|
|
121860
|
-
|
|
121861
|
-
|
|
121862
|
-
|
|
121863
|
-
|
|
121864
|
-
|
|
121865
|
-
|
|
121866
|
-
|
|
121867
|
-
|
|
121868
|
-
|
|
121869
|
-
|
|
121870
|
-
|
|
121871
|
-
|
|
121872
|
-
|
|
121873
|
-
|
|
121874
|
-
|
|
121875
|
-
|
|
121876
|
-
|
|
121877
|
-
|
|
121878
|
-
|
|
121879
|
-
|
|
121880
|
-
|
|
121881
|
-
|
|
121882
|
-
|
|
121883
|
-
|
|
121884
|
-
|
|
121885
|
-
|
|
121886
|
-
|
|
121887
|
-
|
|
121888
|
-
|
|
121889
|
-
|
|
121890
|
-
|
|
121891
|
-
|
|
121892
|
-
|
|
121893
|
-
|
|
121894
|
-
|
|
121895
|
-
|
|
121896
|
-
|
|
121897
|
-
|
|
121898
|
-
|
|
121899
|
-
|
|
121900
|
-
|
|
121901
|
-
|
|
121902
|
-
|
|
121903
|
-
|
|
121904
|
-
|
|
121905
|
-
|
|
121906
|
-
|
|
121907
|
-
|
|
121908
|
-
|
|
121909
|
-
|
|
121910
|
-
|
|
121911
|
-
|
|
121912
|
-
|
|
121913
|
-
|
|
121914
|
-
|
|
121915
|
-
|
|
121916
|
-
|
|
121917
|
-
|
|
121918
|
-
|
|
121919
|
-
|
|
121920
|
-
|
|
121921
|
-
|
|
121922
|
-
|
|
121923
|
-
|
|
121924
|
-
|
|
121925
|
-
|
|
121926
|
-
|
|
121927
|
-
|
|
121928
|
-
|
|
121929
|
-
|
|
121930
|
-
|
|
121931
|
-
|
|
121932
|
-
|
|
121933
|
-
|
|
121934
|
-
|
|
121935
|
-
|
|
121936
|
-
|
|
121937
|
-
|
|
121938
|
-
|
|
121939
|
-
|
|
121940
|
-
|
|
121941
|
-
|
|
121942
|
-
|
|
121943
|
-
|
|
121944
|
-
|
|
121945
|
-
|
|
121946
|
-
|
|
121947
|
-
|
|
121948
|
-
|
|
121949
|
-
|
|
121950
|
-
|
|
121842
|
+
var hasRequiredOn_data;
|
|
121843
|
+
|
|
121844
|
+
function requireOn_data () {
|
|
121845
|
+
if (hasRequiredOn_data) return on_data;
|
|
121846
|
+
hasRequiredOn_data = 1;
|
|
121847
|
+
Object.defineProperty(on_data, "__esModule", {
|
|
121848
|
+
value: true
|
|
121849
|
+
});
|
|
121850
|
+
on_data.onData = onData;
|
|
121851
|
+
const utils_1 = requireUtils$2();
|
|
121852
|
+
/**
|
|
121853
|
+
* onData is adapted from Node.js' events.on helper
|
|
121854
|
+
* https://nodejs.org/api/events.html#eventsonemitter-eventname-options
|
|
121855
|
+
*
|
|
121856
|
+
* Returns an AsyncIterator that iterates each 'data' event emitted from emitter.
|
|
121857
|
+
* It will reject upon an error event.
|
|
121858
|
+
*/ function onData(emitter, { timeoutContext, signal }) {
|
|
121859
|
+
signal?.throwIfAborted();
|
|
121860
|
+
// Setup pending events and pending promise lists
|
|
121861
|
+
/**
|
|
121862
|
+
* When the caller has not yet called .next(), we store the
|
|
121863
|
+
* value from the event in this list. Next time they call .next()
|
|
121864
|
+
* we pull the first value out of this list and resolve a promise with it.
|
|
121865
|
+
*/ const unconsumedEvents = new utils_1.List();
|
|
121866
|
+
/**
|
|
121867
|
+
* When there has not yet been an event, a new promise will be created
|
|
121868
|
+
* and implicitly stored in this list. When an event occurs we take the first
|
|
121869
|
+
* promise in this list and resolve it.
|
|
121870
|
+
*/ const unconsumedPromises = new utils_1.List();
|
|
121871
|
+
/**
|
|
121872
|
+
* Stored an error created by an error event.
|
|
121873
|
+
* This error will turn into a rejection for the subsequent .next() call
|
|
121874
|
+
*/ let error = null;
|
|
121875
|
+
/** Set to true only after event listeners have been removed. */ let finished = false;
|
|
121876
|
+
const iterator = {
|
|
121877
|
+
next () {
|
|
121878
|
+
// First, we consume all unread events
|
|
121879
|
+
const value = unconsumedEvents.shift();
|
|
121880
|
+
if (value != null) {
|
|
121881
|
+
return Promise.resolve({
|
|
121882
|
+
value,
|
|
121883
|
+
done: false
|
|
121884
|
+
});
|
|
121885
|
+
}
|
|
121886
|
+
// Then we error, if an error happened
|
|
121887
|
+
// This happens one time if at all, because after 'error'
|
|
121888
|
+
// we stop listening
|
|
121889
|
+
if (error != null) {
|
|
121890
|
+
const p = Promise.reject(error);
|
|
121891
|
+
// Only the first element errors
|
|
121892
|
+
error = null;
|
|
121893
|
+
return p;
|
|
121894
|
+
}
|
|
121895
|
+
// If the iterator is finished, resolve to done
|
|
121896
|
+
if (finished) return closeHandler();
|
|
121897
|
+
// Wait until an event happens
|
|
121898
|
+
const { promise, resolve, reject } = (0, utils_1.promiseWithResolvers)();
|
|
121899
|
+
unconsumedPromises.push({
|
|
121900
|
+
resolve,
|
|
121901
|
+
reject
|
|
121902
|
+
});
|
|
121903
|
+
return promise;
|
|
121904
|
+
},
|
|
121905
|
+
return () {
|
|
121906
|
+
return closeHandler();
|
|
121907
|
+
},
|
|
121908
|
+
throw (err) {
|
|
121909
|
+
errorHandler(err);
|
|
121910
|
+
return Promise.resolve({
|
|
121911
|
+
value: undefined,
|
|
121912
|
+
done: true
|
|
121913
|
+
});
|
|
121914
|
+
},
|
|
121915
|
+
[Symbol.asyncIterator] () {
|
|
121916
|
+
return this;
|
|
121917
|
+
},
|
|
121918
|
+
// Note this should currently not be used, but is required by the AsyncGenerator interface.
|
|
121919
|
+
async [Symbol.asyncDispose] () {
|
|
121920
|
+
await closeHandler();
|
|
121921
|
+
}
|
|
121922
|
+
};
|
|
121923
|
+
// Adding event handlers
|
|
121924
|
+
emitter.on('data', eventHandler);
|
|
121925
|
+
emitter.on('error', errorHandler);
|
|
121926
|
+
const abortListener = (0, utils_1.addAbortListener)(signal, function() {
|
|
121927
|
+
errorHandler(this.reason);
|
|
121928
|
+
});
|
|
121929
|
+
const timeoutForSocketRead = timeoutContext?.timeoutForSocketRead;
|
|
121930
|
+
timeoutForSocketRead?.throwIfExpired();
|
|
121931
|
+
timeoutForSocketRead?.then(undefined, errorHandler);
|
|
121932
|
+
return iterator;
|
|
121933
|
+
function eventHandler(value) {
|
|
121934
|
+
const promise = unconsumedPromises.shift();
|
|
121935
|
+
if (promise != null) promise.resolve({
|
|
121936
|
+
value,
|
|
121937
|
+
done: false
|
|
121938
|
+
});
|
|
121939
|
+
else unconsumedEvents.push(value);
|
|
121940
|
+
}
|
|
121941
|
+
function errorHandler(err) {
|
|
121942
|
+
const promise = unconsumedPromises.shift();
|
|
121943
|
+
if (promise != null) promise.reject(err);
|
|
121944
|
+
else error = err;
|
|
121945
|
+
void closeHandler();
|
|
121946
|
+
}
|
|
121947
|
+
function closeHandler() {
|
|
121948
|
+
// Adding event handlers
|
|
121949
|
+
emitter.off('data', eventHandler);
|
|
121950
|
+
emitter.off('error', errorHandler);
|
|
121951
|
+
abortListener?.[utils_1.kDispose]();
|
|
121952
|
+
finished = true;
|
|
121953
|
+
timeoutForSocketRead?.clear();
|
|
121954
|
+
const doneResult = {
|
|
121955
|
+
value: undefined,
|
|
121956
|
+
done: finished
|
|
121957
|
+
};
|
|
121958
|
+
for (const promise of unconsumedPromises){
|
|
121959
|
+
promise.resolve(doneResult);
|
|
121960
|
+
}
|
|
121961
|
+
return Promise.resolve(doneResult);
|
|
121962
|
+
}
|
|
121963
|
+
}
|
|
121964
|
+
return on_data;
|
|
121951
121965
|
}
|
|
121952
121966
|
|
|
121953
121967
|
var shared = {};
|
|
@@ -121960,9 +121974,9 @@ Object.defineProperty(topology_description, "__esModule", {
|
|
|
121960
121974
|
topology_description.TopologyDescription = void 0;
|
|
121961
121975
|
const bson_1$5 = bson$2;
|
|
121962
121976
|
const WIRE_CONSTANTS = constants$4;
|
|
121963
|
-
const error_1$
|
|
121977
|
+
const error_1$h = error$1;
|
|
121964
121978
|
const utils_1$e = requireUtils$2();
|
|
121965
|
-
const common_1
|
|
121979
|
+
const common_1 = common$2;
|
|
121966
121980
|
const server_description_1 = server_description;
|
|
121967
121981
|
// constants related to compatibility checks
|
|
121968
121982
|
const MIN_SUPPORTED_SERVER_VERSION = WIRE_CONSTANTS.MIN_SUPPORTED_SERVER_VERSION;
|
|
@@ -121970,17 +121984,17 @@ const MAX_SUPPORTED_SERVER_VERSION = WIRE_CONSTANTS.MAX_SUPPORTED_SERVER_VERSION
|
|
|
121970
121984
|
const MIN_SUPPORTED_WIRE_VERSION = WIRE_CONSTANTS.MIN_SUPPORTED_WIRE_VERSION;
|
|
121971
121985
|
const MAX_SUPPORTED_WIRE_VERSION = WIRE_CONSTANTS.MAX_SUPPORTED_WIRE_VERSION;
|
|
121972
121986
|
const MONGOS_OR_UNKNOWN = new Set([
|
|
121973
|
-
common_1
|
|
121974
|
-
common_1
|
|
121987
|
+
common_1.ServerType.Mongos,
|
|
121988
|
+
common_1.ServerType.Unknown
|
|
121975
121989
|
]);
|
|
121976
121990
|
const MONGOS_OR_STANDALONE = new Set([
|
|
121977
|
-
common_1
|
|
121978
|
-
common_1
|
|
121991
|
+
common_1.ServerType.Mongos,
|
|
121992
|
+
common_1.ServerType.Standalone
|
|
121979
121993
|
]);
|
|
121980
121994
|
const NON_PRIMARY_RS_MEMBERS = new Set([
|
|
121981
|
-
common_1
|
|
121982
|
-
common_1
|
|
121983
|
-
common_1
|
|
121995
|
+
common_1.ServerType.RSSecondary,
|
|
121996
|
+
common_1.ServerType.RSArbiter,
|
|
121997
|
+
common_1.ServerType.RSOther
|
|
121984
121998
|
]);
|
|
121985
121999
|
/**
|
|
121986
122000
|
* Representation of a deployment of servers
|
|
@@ -121990,7 +122004,7 @@ const NON_PRIMARY_RS_MEMBERS = new Set([
|
|
|
121990
122004
|
* Create a TopologyDescription
|
|
121991
122005
|
*/ constructor(topologyType, serverDescriptions = null, setName = null, maxSetVersion = null, maxElectionId = null, commonWireVersion = null, options = null){
|
|
121992
122006
|
options = options ?? {};
|
|
121993
|
-
this.type = topologyType ?? common_1
|
|
122007
|
+
this.type = topologyType ?? common_1.TopologyType.Unknown;
|
|
121994
122008
|
this.servers = serverDescriptions ?? new Map();
|
|
121995
122009
|
this.stale = false;
|
|
121996
122010
|
this.compatible = true;
|
|
@@ -122003,7 +122017,7 @@ const NON_PRIMARY_RS_MEMBERS = new Set([
|
|
|
122003
122017
|
// determine server compatibility
|
|
122004
122018
|
for (const serverDescription of this.servers.values()){
|
|
122005
122019
|
// Load balancer mode is always compatible.
|
|
122006
|
-
if (serverDescription.type === common_1
|
|
122020
|
+
if (serverDescription.type === common_1.ServerType.Unknown || serverDescription.type === common_1.ServerType.LoadBalancer) {
|
|
122007
122021
|
continue;
|
|
122008
122022
|
}
|
|
122009
122023
|
if (serverDescription.minWireVersion > MAX_SUPPORTED_WIRE_VERSION) {
|
|
@@ -122102,7 +122116,7 @@ const NON_PRIMARY_RS_MEMBERS = new Set([
|
|
|
122102
122116
|
}
|
|
122103
122117
|
}
|
|
122104
122118
|
if (typeof serverDescription.setName === 'string' && typeof setName === 'string' && serverDescription.setName !== setName) {
|
|
122105
|
-
if (topologyType === common_1
|
|
122119
|
+
if (topologyType === common_1.TopologyType.Single) {
|
|
122106
122120
|
// "Single" Topology with setName mismatch is direct connection usage, mark unknown do not remove
|
|
122107
122121
|
serverDescription = new server_description_1.ServerDescription(address);
|
|
122108
122122
|
} else {
|
|
@@ -122111,30 +122125,30 @@ const NON_PRIMARY_RS_MEMBERS = new Set([
|
|
|
122111
122125
|
}
|
|
122112
122126
|
// update the actual server description
|
|
122113
122127
|
serverDescriptions.set(address, serverDescription);
|
|
122114
|
-
if (topologyType === common_1
|
|
122128
|
+
if (topologyType === common_1.TopologyType.Single) {
|
|
122115
122129
|
// once we are defined as single, that never changes
|
|
122116
|
-
return new TopologyDescription(common_1
|
|
122130
|
+
return new TopologyDescription(common_1.TopologyType.Single, serverDescriptions, setName, maxSetVersion, maxElectionId, commonWireVersion, {
|
|
122117
122131
|
heartbeatFrequencyMS: this.heartbeatFrequencyMS,
|
|
122118
122132
|
localThresholdMS: this.localThresholdMS
|
|
122119
122133
|
});
|
|
122120
122134
|
}
|
|
122121
|
-
if (topologyType === common_1
|
|
122122
|
-
if (serverType === common_1
|
|
122135
|
+
if (topologyType === common_1.TopologyType.Unknown) {
|
|
122136
|
+
if (serverType === common_1.ServerType.Standalone && this.servers.size !== 1) {
|
|
122123
122137
|
serverDescriptions.delete(address);
|
|
122124
122138
|
} else {
|
|
122125
122139
|
topologyType = topologyTypeForServerType(serverType);
|
|
122126
122140
|
}
|
|
122127
122141
|
}
|
|
122128
|
-
if (topologyType === common_1
|
|
122142
|
+
if (topologyType === common_1.TopologyType.Sharded) {
|
|
122129
122143
|
if (!MONGOS_OR_UNKNOWN.has(serverType)) {
|
|
122130
122144
|
serverDescriptions.delete(address);
|
|
122131
122145
|
}
|
|
122132
122146
|
}
|
|
122133
|
-
if (topologyType === common_1
|
|
122147
|
+
if (topologyType === common_1.TopologyType.ReplicaSetNoPrimary) {
|
|
122134
122148
|
if (MONGOS_OR_STANDALONE.has(serverType)) {
|
|
122135
122149
|
serverDescriptions.delete(address);
|
|
122136
122150
|
}
|
|
122137
|
-
if (serverType === common_1
|
|
122151
|
+
if (serverType === common_1.ServerType.RSPrimary) {
|
|
122138
122152
|
const result = updateRsFromPrimary(serverDescriptions, serverDescription, setName, maxSetVersion, maxElectionId);
|
|
122139
122153
|
topologyType = result[0];
|
|
122140
122154
|
setName = result[1];
|
|
@@ -122146,11 +122160,11 @@ const NON_PRIMARY_RS_MEMBERS = new Set([
|
|
|
122146
122160
|
setName = result[1];
|
|
122147
122161
|
}
|
|
122148
122162
|
}
|
|
122149
|
-
if (topologyType === common_1
|
|
122163
|
+
if (topologyType === common_1.TopologyType.ReplicaSetWithPrimary) {
|
|
122150
122164
|
if (MONGOS_OR_STANDALONE.has(serverType)) {
|
|
122151
122165
|
serverDescriptions.delete(address);
|
|
122152
122166
|
topologyType = checkHasPrimary(serverDescriptions);
|
|
122153
|
-
} else if (serverType === common_1
|
|
122167
|
+
} else if (serverType === common_1.ServerType.RSPrimary) {
|
|
122154
122168
|
const result = updateRsFromPrimary(serverDescriptions, serverDescription, setName, maxSetVersion, maxElectionId);
|
|
122155
122169
|
topologyType = result[0];
|
|
122156
122170
|
setName = result[1];
|
|
@@ -122177,7 +122191,7 @@ const NON_PRIMARY_RS_MEMBERS = new Set([
|
|
|
122177
122191
|
/**
|
|
122178
122192
|
* Determines if the topology description has any known servers
|
|
122179
122193
|
*/ get hasKnownServers() {
|
|
122180
|
-
return Array.from(this.servers.values()).some((sd)=>sd.type !== common_1
|
|
122194
|
+
return Array.from(this.servers.values()).some((sd)=>sd.type !== common_1.ServerType.Unknown);
|
|
122181
122195
|
}
|
|
122182
122196
|
/**
|
|
122183
122197
|
* Determines if this topology description has a data-bearing server available.
|
|
@@ -122202,17 +122216,17 @@ const NON_PRIMARY_RS_MEMBERS = new Set([
|
|
|
122202
122216
|
topology_description.TopologyDescription = TopologyDescription;
|
|
122203
122217
|
function topologyTypeForServerType(serverType) {
|
|
122204
122218
|
switch(serverType){
|
|
122205
|
-
case common_1
|
|
122206
|
-
return common_1
|
|
122207
|
-
case common_1
|
|
122208
|
-
return common_1
|
|
122209
|
-
case common_1
|
|
122210
|
-
return common_1
|
|
122211
|
-
case common_1
|
|
122212
|
-
case common_1
|
|
122213
|
-
return common_1
|
|
122219
|
+
case common_1.ServerType.Standalone:
|
|
122220
|
+
return common_1.TopologyType.Single;
|
|
122221
|
+
case common_1.ServerType.Mongos:
|
|
122222
|
+
return common_1.TopologyType.Sharded;
|
|
122223
|
+
case common_1.ServerType.RSPrimary:
|
|
122224
|
+
return common_1.TopologyType.ReplicaSetWithPrimary;
|
|
122225
|
+
case common_1.ServerType.RSOther:
|
|
122226
|
+
case common_1.ServerType.RSSecondary:
|
|
122227
|
+
return common_1.TopologyType.ReplicaSetNoPrimary;
|
|
122214
122228
|
default:
|
|
122215
|
-
return common_1
|
|
122229
|
+
return common_1.TopologyType.Unknown;
|
|
122216
122230
|
}
|
|
122217
122231
|
}
|
|
122218
122232
|
function updateRsFromPrimary(serverDescriptions, serverDescription, setName = null, maxSetVersion = null, maxElectionId = null) {
|
|
@@ -122244,7 +122258,7 @@ function updateRsFromPrimary(serverDescriptions, serverDescription, setName = nu
|
|
|
122244
122258
|
// Stale primary
|
|
122245
122259
|
// replace serverDescription with a default ServerDescription of type "Unknown"
|
|
122246
122260
|
serverDescriptions.set(serverDescription.address, new server_description_1.ServerDescription(serverDescription.address, undefined, {
|
|
122247
|
-
error: new error_1$
|
|
122261
|
+
error: new error_1$h.MongoStalePrimaryError(setVersionElectionIdMismatch(serverDescription, maxSetVersion, maxElectionId))
|
|
122248
122262
|
}));
|
|
122249
122263
|
return [
|
|
122250
122264
|
checkHasPrimary(serverDescriptions),
|
|
@@ -122260,7 +122274,7 @@ function updateRsFromPrimary(serverDescriptions, serverDescription, setName = nu
|
|
|
122260
122274
|
if (maxSetVersion > serverDescription.setVersion || (0, utils_1$e.compareObjectId)(maxElectionId, electionId) > 0) {
|
|
122261
122275
|
// this primary is stale, we must remove it
|
|
122262
122276
|
serverDescriptions.set(serverDescription.address, new server_description_1.ServerDescription(serverDescription.address, undefined, {
|
|
122263
|
-
error: new error_1$
|
|
122277
|
+
error: new error_1$h.MongoStalePrimaryError(setVersionElectionIdMismatch(serverDescription, maxSetVersion, maxElectionId))
|
|
122264
122278
|
}));
|
|
122265
122279
|
return [
|
|
122266
122280
|
checkHasPrimary(serverDescriptions),
|
|
@@ -122278,10 +122292,10 @@ function updateRsFromPrimary(serverDescriptions, serverDescription, setName = nu
|
|
|
122278
122292
|
}
|
|
122279
122293
|
// We've heard from the primary. Is it the same primary as before?
|
|
122280
122294
|
for (const [address, server] of serverDescriptions){
|
|
122281
|
-
if (server.type === common_1
|
|
122295
|
+
if (server.type === common_1.ServerType.RSPrimary && server.address !== serverDescription.address) {
|
|
122282
122296
|
// Reset old primary's type to Unknown.
|
|
122283
122297
|
serverDescriptions.set(address, new server_description_1.ServerDescription(server.address, undefined, {
|
|
122284
|
-
error: new error_1$
|
|
122298
|
+
error: new error_1$h.MongoStalePrimaryError('primary marked stale due to discovery of newer primary')
|
|
122285
122299
|
}));
|
|
122286
122300
|
break;
|
|
122287
122301
|
}
|
|
@@ -122308,7 +122322,7 @@ function updateRsFromPrimary(serverDescriptions, serverDescription, setName = nu
|
|
|
122308
122322
|
function updateRsWithPrimaryFromMember(serverDescriptions, serverDescription, setName = null) {
|
|
122309
122323
|
if (setName == null) {
|
|
122310
122324
|
// TODO(NODE-3483): should be an appropriate runtime error
|
|
122311
|
-
throw new error_1$
|
|
122325
|
+
throw new error_1$h.MongoRuntimeError('Argument "setName" is required if connected to a replica set');
|
|
122312
122326
|
}
|
|
122313
122327
|
if (setName !== serverDescription.setName || serverDescription.me && serverDescription.address !== serverDescription.me) {
|
|
122314
122328
|
serverDescriptions.delete(serverDescription.address);
|
|
@@ -122316,7 +122330,7 @@ function updateRsWithPrimaryFromMember(serverDescriptions, serverDescription, se
|
|
|
122316
122330
|
return checkHasPrimary(serverDescriptions);
|
|
122317
122331
|
}
|
|
122318
122332
|
function updateRsNoPrimaryFromMember(serverDescriptions, serverDescription, setName = null) {
|
|
122319
|
-
const topologyType = common_1
|
|
122333
|
+
const topologyType = common_1.TopologyType.ReplicaSetNoPrimary;
|
|
122320
122334
|
setName = setName ?? serverDescription.setName;
|
|
122321
122335
|
if (setName !== serverDescription.setName) {
|
|
122322
122336
|
serverDescriptions.delete(serverDescription.address);
|
|
@@ -122340,47 +122354,54 @@ function updateRsNoPrimaryFromMember(serverDescriptions, serverDescription, setN
|
|
|
122340
122354
|
}
|
|
122341
122355
|
function checkHasPrimary(serverDescriptions) {
|
|
122342
122356
|
for (const serverDescription of serverDescriptions.values()){
|
|
122343
|
-
if (serverDescription.type === common_1
|
|
122344
|
-
return common_1
|
|
122357
|
+
if (serverDescription.type === common_1.ServerType.RSPrimary) {
|
|
122358
|
+
return common_1.TopologyType.ReplicaSetWithPrimary;
|
|
122345
122359
|
}
|
|
122346
122360
|
}
|
|
122347
|
-
return common_1
|
|
122361
|
+
return common_1.TopologyType.ReplicaSetNoPrimary;
|
|
122348
122362
|
}
|
|
122349
122363
|
|
|
122350
|
-
|
|
122351
|
-
|
|
122352
|
-
|
|
122353
|
-
|
|
122354
|
-
|
|
122355
|
-
|
|
122356
|
-
|
|
122357
|
-
|
|
122358
|
-
|
|
122359
|
-
|
|
122360
|
-
|
|
122361
|
-
|
|
122362
|
-
|
|
122363
|
-
|
|
122364
|
-
|
|
122365
|
-
|
|
122366
|
-
|
|
122367
|
-
|
|
122368
|
-
|
|
122369
|
-
}
|
|
122370
|
-
|
|
122371
|
-
|
|
122372
|
-
|
|
122373
|
-
|
|
122374
|
-
|
|
122375
|
-
|
|
122376
|
-
|
|
122377
|
-
|
|
122378
|
-
|
|
122379
|
-
|
|
122380
|
-
|
|
122381
|
-
|
|
122382
|
-
|
|
122383
|
-
|
|
122364
|
+
var hasRequiredShared;
|
|
122365
|
+
|
|
122366
|
+
function requireShared () {
|
|
122367
|
+
if (hasRequiredShared) return shared;
|
|
122368
|
+
hasRequiredShared = 1;
|
|
122369
|
+
Object.defineProperty(shared, "__esModule", {
|
|
122370
|
+
value: true
|
|
122371
|
+
});
|
|
122372
|
+
shared.getReadPreference = getReadPreference;
|
|
122373
|
+
shared.isSharded = isSharded;
|
|
122374
|
+
const error_1 = error$1;
|
|
122375
|
+
const read_preference_1 = read_preference;
|
|
122376
|
+
const common_1 = common$2;
|
|
122377
|
+
const topology_description_1 = topology_description;
|
|
122378
|
+
function getReadPreference(options) {
|
|
122379
|
+
// Default to command version of the readPreference.
|
|
122380
|
+
let readPreference = options?.readPreference ?? read_preference_1.ReadPreference.primary;
|
|
122381
|
+
if (typeof readPreference === 'string') {
|
|
122382
|
+
readPreference = read_preference_1.ReadPreference.fromString(readPreference);
|
|
122383
|
+
}
|
|
122384
|
+
if (!(readPreference instanceof read_preference_1.ReadPreference)) {
|
|
122385
|
+
throw new error_1.MongoInvalidArgumentError('Option "readPreference" must be a ReadPreference instance');
|
|
122386
|
+
}
|
|
122387
|
+
return readPreference;
|
|
122388
|
+
}
|
|
122389
|
+
function isSharded(topologyOrServer) {
|
|
122390
|
+
if (topologyOrServer == null) {
|
|
122391
|
+
return false;
|
|
122392
|
+
}
|
|
122393
|
+
if (topologyOrServer.description && topologyOrServer.description.type === common_1.ServerType.Mongos) {
|
|
122394
|
+
return true;
|
|
122395
|
+
}
|
|
122396
|
+
// NOTE: This is incredibly inefficient, and should be removed once command construction
|
|
122397
|
+
// happens based on `Server` not `Topology`.
|
|
122398
|
+
if (topologyOrServer.description && topologyOrServer.description instanceof topology_description_1.TopologyDescription) {
|
|
122399
|
+
const servers = Array.from(topologyOrServer.description.servers.values());
|
|
122400
|
+
return servers.some((server)=>server.type === common_1.ServerType.Mongos);
|
|
122401
|
+
}
|
|
122402
|
+
return false;
|
|
122403
|
+
}
|
|
122404
|
+
return shared;
|
|
122384
122405
|
}
|
|
122385
122406
|
|
|
122386
122407
|
var hasRequiredConnection;
|
|
@@ -122407,11 +122428,11 @@ function requireConnection () {
|
|
|
122407
122428
|
const utils_1 = requireUtils$2();
|
|
122408
122429
|
const command_monitoring_events_1 = command_monitoring_events;
|
|
122409
122430
|
const commands_1 = requireCommands();
|
|
122410
|
-
const stream_description_1 =
|
|
122431
|
+
const stream_description_1 = requireStream_description();
|
|
122411
122432
|
const compression_1 = requireCompression();
|
|
122412
|
-
const on_data_1 =
|
|
122433
|
+
const on_data_1 = requireOn_data();
|
|
122413
122434
|
const responses_1 = requireResponses();
|
|
122414
|
-
const shared_1 =
|
|
122435
|
+
const shared_1 = requireShared();
|
|
122415
122436
|
/** @internal */ function hasSessionSupport(conn) {
|
|
122416
122437
|
const description = conn.description;
|
|
122417
122438
|
return description.logicalSessionTimeoutMinutes != null;
|