Commit
This commit is contained in:
commit
d1c8cae2c1
1417 changed files with 326736 additions and 0 deletions
90
node_modules/mongodb/lib/operations/aggregate.js
generated
vendored
Normal file
90
node_modules/mongodb/lib/operations/aggregate.js
generated
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AggregateOperation = exports.DB_AGGREGATE_COLLECTION = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../error");
|
||||
const write_concern_1 = require("../write_concern");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
exports.DB_AGGREGATE_COLLECTION = 1;
|
||||
/** @internal */
|
||||
class AggregateOperation extends command_1.CommandOperation {
|
||||
constructor(ns, pipeline, options) {
|
||||
super(undefined, { ...options, dbName: ns.db });
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.CursorResponse;
|
||||
this.options = { ...options };
|
||||
// Covers when ns.collection is null, undefined or the empty string, use DB_AGGREGATE_COLLECTION
|
||||
this.target = ns.collection || exports.DB_AGGREGATE_COLLECTION;
|
||||
this.pipeline = pipeline;
|
||||
// determine if we have a write stage, override read preference if so
|
||||
this.hasWriteStage = false;
|
||||
if (typeof options?.out === 'string') {
|
||||
this.pipeline = this.pipeline.concat({ $out: options.out });
|
||||
this.hasWriteStage = true;
|
||||
}
|
||||
else if (pipeline.length > 0) {
|
||||
const finalStage = pipeline[pipeline.length - 1];
|
||||
if (finalStage.$out || finalStage.$merge) {
|
||||
this.hasWriteStage = true;
|
||||
}
|
||||
}
|
||||
if (!this.hasWriteStage) {
|
||||
delete this.options.writeConcern;
|
||||
}
|
||||
if (options?.cursor != null && typeof options.cursor !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Cursor options must be an object');
|
||||
}
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = this.explain ? responses_1.ExplainedCursorResponse : responses_1.CursorResponse;
|
||||
}
|
||||
get commandName() {
|
||||
return 'aggregate';
|
||||
}
|
||||
get canRetryRead() {
|
||||
return !this.hasWriteStage;
|
||||
}
|
||||
addToPipeline(stage) {
|
||||
this.pipeline.push(stage);
|
||||
}
|
||||
buildCommandDocument() {
|
||||
const options = this.options;
|
||||
const command = { aggregate: this.target, pipeline: this.pipeline };
|
||||
if (this.hasWriteStage && this.writeConcern) {
|
||||
write_concern_1.WriteConcern.apply(command, this.writeConcern);
|
||||
}
|
||||
if (options.bypassDocumentValidation === true) {
|
||||
command.bypassDocumentValidation = options.bypassDocumentValidation;
|
||||
}
|
||||
if (typeof options.allowDiskUse === 'boolean') {
|
||||
command.allowDiskUse = options.allowDiskUse;
|
||||
}
|
||||
if (options.hint) {
|
||||
command.hint = options.hint;
|
||||
}
|
||||
if (options.let) {
|
||||
command.let = options.let;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (options.comment !== undefined) {
|
||||
command.comment = options.comment;
|
||||
}
|
||||
command.cursor = options.cursor || {};
|
||||
if (options.batchSize && !this.hasWriteStage) {
|
||||
command.cursor.batchSize = options.batchSize;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
handleOk(response) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
exports.AggregateOperation = AggregateOperation;
|
||||
(0, operation_1.defineAspects)(AggregateOperation, [
|
||||
operation_1.Aspect.READ_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.CURSOR_CREATING,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
//# sourceMappingURL=aggregate.js.map
|
||||
1
node_modules/mongodb/lib/operations/aggregate.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/aggregate.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"aggregate.js","sourceRoot":"","sources":["../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C;QAED,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QAC5B,CAAC;QAED,iEAAiE;QACjE,gDAAgD;QAChD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAClC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QACpC,CAAC;QAED,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;QACtC,IAAI,OAAO,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YAC7C,OAAO,CAAC,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QAC/C,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAEQ,QAAQ,CACf,QAAgE;QAEhE,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA/FD,gDA+FC;AAED,IAAA,yBAAa,EAAC,kBAAkB,EAAE;IAChC,kBAAM,CAAC,cAAc;IACrB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,WAAW;IAClB,kBAAM,CAAC,eAAe;IACtB,kBAAM,CAAC,iBAAiB;CACzB,CAAC,CAAC"}
|
||||
51
node_modules/mongodb/lib/operations/client_bulk_write/client_bulk_write.js
generated
vendored
Normal file
51
node_modules/mongodb/lib/operations/client_bulk_write/client_bulk_write.js
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ClientBulkWriteOperation = void 0;
|
||||
const responses_1 = require("../../cmap/wire_protocol/responses");
|
||||
const utils_1 = require("../../utils");
|
||||
const command_1 = require("../command");
|
||||
const operation_1 = require("../operation");
|
||||
/**
|
||||
* Executes a single client bulk write operation within a potential batch.
|
||||
* @internal
|
||||
*/
|
||||
class ClientBulkWriteOperation extends command_1.CommandOperation {
|
||||
get commandName() {
|
||||
return 'bulkWrite';
|
||||
}
|
||||
constructor(commandBuilder, options) {
|
||||
super(undefined, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.ClientBulkWriteCursorResponse;
|
||||
this.commandBuilder = commandBuilder;
|
||||
this.options = options;
|
||||
this.ns = new utils_1.MongoDBNamespace('admin', '$cmd');
|
||||
}
|
||||
resetBatch() {
|
||||
return this.commandBuilder.resetBatch();
|
||||
}
|
||||
get canRetryWrite() {
|
||||
return this.commandBuilder.isBatchRetryable;
|
||||
}
|
||||
handleOk(response) {
|
||||
return response;
|
||||
}
|
||||
buildCommandDocument(connection, _session) {
|
||||
const command = this.commandBuilder.buildBatch(connection.description.maxMessageSizeBytes, connection.description.maxWriteBatchSize, connection.description.maxBsonObjectSize);
|
||||
// Check _after_ the batch is built if we cannot retry it and override the option.
|
||||
if (!this.canRetryWrite) {
|
||||
this.options.willRetryWrite = false;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
}
|
||||
exports.ClientBulkWriteOperation = ClientBulkWriteOperation;
|
||||
// Skipping the collation as it goes on the individual ops.
|
||||
(0, operation_1.defineAspects)(ClientBulkWriteOperation, [
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.SKIP_COLLATION,
|
||||
operation_1.Aspect.CURSOR_CREATING,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.COMMAND_BATCHING,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
//# sourceMappingURL=client_bulk_write.js.map
|
||||
1
node_modules/mongodb/lib/operations/client_bulk_write/client_bulk_write.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/client_bulk_write/client_bulk_write.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"client_bulk_write.js","sourceRoot":"","sources":["../../../src/operations/client_bulk_write/client_bulk_write.ts"],"names":[],"mappings":";;;AACA,kEAAmF;AAEnF,uCAA+C;AAC/C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,CAAC,gBAAgB;IACvB,kBAAM,CAAC,iBAAiB;CACzB,CAAC,CAAC"}
|
||||
340
node_modules/mongodb/lib/operations/client_bulk_write/command_builder.js
generated
vendored
Normal file
340
node_modules/mongodb/lib/operations/client_bulk_write/command_builder.js
generated
vendored
Normal file
|
|
@ -0,0 +1,340 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.buildReplaceOneOperation = exports.buildUpdateManyOperation = exports.buildUpdateOneOperation = exports.buildDeleteManyOperation = exports.buildDeleteOneOperation = exports.buildInsertOneOperation = exports.ClientBulkWriteCommandBuilder = void 0;
|
||||
exports.buildOperation = buildOperation;
|
||||
const bson_1 = require("../../bson");
|
||||
const commands_1 = require("../../cmap/commands");
|
||||
const error_1 = require("../../error");
|
||||
const sort_1 = require("../../sort");
|
||||
const utils_1 = require("../../utils");
|
||||
/**
|
||||
* The bytes overhead for the extra fields added post command generation.
|
||||
*/
|
||||
const MESSAGE_OVERHEAD_BYTES = 1000;
|
||||
/** @internal */
|
||||
class ClientBulkWriteCommandBuilder {
|
||||
/**
|
||||
* Create the command builder.
|
||||
* @param models - The client write models.
|
||||
*/
|
||||
constructor(models, options, pkFactory) {
|
||||
this.models = models;
|
||||
this.options = options;
|
||||
this.pkFactory = pkFactory ?? utils_1.DEFAULT_PK_FACTORY;
|
||||
this.currentModelIndex = 0;
|
||||
this.previousModelIndex = 0;
|
||||
this.lastOperations = [];
|
||||
this.isBatchRetryable = true;
|
||||
}
|
||||
/**
|
||||
* Gets the errorsOnly value for the command, which is the inverse of the
|
||||
* user provided verboseResults option. Defaults to true.
|
||||
*/
|
||||
get errorsOnly() {
|
||||
if ('verboseResults' in this.options) {
|
||||
return !this.options.verboseResults;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Determines if there is another batch to process.
|
||||
* @returns True if not all batches have been built.
|
||||
*/
|
||||
hasNextBatch() {
|
||||
return this.currentModelIndex < this.models.length;
|
||||
}
|
||||
/**
|
||||
* When we need to retry a command we need to set the current
|
||||
* model index back to its previous value.
|
||||
*/
|
||||
resetBatch() {
|
||||
this.currentModelIndex = this.previousModelIndex;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Build a single batch of a client bulk write command.
|
||||
* @param maxMessageSizeBytes - The max message size in bytes.
|
||||
* @param maxWriteBatchSize - The max write batch size.
|
||||
* @returns The client bulk write command.
|
||||
*/
|
||||
buildBatch(maxMessageSizeBytes, maxWriteBatchSize, maxBsonObjectSize) {
|
||||
// We start by assuming the batch has no multi-updates, so it is retryable
|
||||
// until we find them.
|
||||
this.isBatchRetryable = true;
|
||||
let commandLength = 0;
|
||||
let currentNamespaceIndex = 0;
|
||||
const command = this.baseCommand();
|
||||
const namespaces = new Map();
|
||||
// In the case of retries we need to mark where we started this batch.
|
||||
this.previousModelIndex = this.currentModelIndex;
|
||||
while (this.currentModelIndex < this.models.length) {
|
||||
const model = this.models[this.currentModelIndex];
|
||||
const ns = model.namespace;
|
||||
const nsIndex = namespaces.get(ns);
|
||||
// Multi updates are not retryable.
|
||||
if (model.name === 'deleteMany' || model.name === 'updateMany') {
|
||||
this.isBatchRetryable = false;
|
||||
}
|
||||
if (nsIndex != null) {
|
||||
// Build the operation and serialize it to get the bytes buffer.
|
||||
const operation = buildOperation(model, nsIndex, this.pkFactory, this.options);
|
||||
let operationBuffer;
|
||||
try {
|
||||
operationBuffer = bson_1.BSON.serialize(operation);
|
||||
}
|
||||
catch (cause) {
|
||||
throw new error_1.MongoInvalidArgumentError(`Could not serialize operation to BSON`, { cause });
|
||||
}
|
||||
validateBufferSize('ops', operationBuffer, maxBsonObjectSize);
|
||||
// Check if the operation buffer can fit in the command. If it can,
|
||||
// then add the operation to the document sequence and increment the
|
||||
// current length as long as the ops don't exceed the maxWriteBatchSize.
|
||||
if (commandLength + operationBuffer.length < maxMessageSizeBytes &&
|
||||
command.ops.documents.length < maxWriteBatchSize) {
|
||||
// Pushing to the ops document sequence returns the total byte length of the document sequence.
|
||||
commandLength = MESSAGE_OVERHEAD_BYTES + command.ops.push(operation, operationBuffer);
|
||||
// Increment the builder's current model index.
|
||||
this.currentModelIndex++;
|
||||
}
|
||||
else {
|
||||
// The operation cannot fit in the current command and will need to
|
||||
// go in the next batch. Exit the loop.
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// The namespace is not already in the nsInfo so we will set it in the map, and
|
||||
// construct our nsInfo and ops documents and buffers.
|
||||
namespaces.set(ns, currentNamespaceIndex);
|
||||
const nsInfo = { ns: ns };
|
||||
const operation = buildOperation(model, currentNamespaceIndex, this.pkFactory, this.options);
|
||||
let nsInfoBuffer;
|
||||
let operationBuffer;
|
||||
try {
|
||||
nsInfoBuffer = bson_1.BSON.serialize(nsInfo);
|
||||
operationBuffer = bson_1.BSON.serialize(operation);
|
||||
}
|
||||
catch (cause) {
|
||||
throw new error_1.MongoInvalidArgumentError(`Could not serialize ns info to BSON`, { cause });
|
||||
}
|
||||
validateBufferSize('nsInfo', nsInfoBuffer, maxBsonObjectSize);
|
||||
validateBufferSize('ops', operationBuffer, maxBsonObjectSize);
|
||||
// Check if the operation and nsInfo buffers can fit in the command. If they
|
||||
// can, then add the operation and nsInfo to their respective document
|
||||
// sequences and increment the current length as long as the ops don't exceed
|
||||
// the maxWriteBatchSize.
|
||||
if (commandLength + nsInfoBuffer.length + operationBuffer.length < maxMessageSizeBytes &&
|
||||
command.ops.documents.length < maxWriteBatchSize) {
|
||||
// Pushing to the ops document sequence returns the total byte length of the document sequence.
|
||||
commandLength =
|
||||
MESSAGE_OVERHEAD_BYTES +
|
||||
command.nsInfo.push(nsInfo, nsInfoBuffer) +
|
||||
command.ops.push(operation, operationBuffer);
|
||||
// We've added a new namespace, increment the namespace index.
|
||||
currentNamespaceIndex++;
|
||||
// Increment the builder's current model index.
|
||||
this.currentModelIndex++;
|
||||
}
|
||||
else {
|
||||
// The operation cannot fit in the current command and will need to
|
||||
// go in the next batch. Exit the loop.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Set the last operations and return the command.
|
||||
this.lastOperations = command.ops.documents;
|
||||
return command;
|
||||
}
|
||||
baseCommand() {
|
||||
const command = {
|
||||
bulkWrite: 1,
|
||||
errorsOnly: this.errorsOnly,
|
||||
ordered: this.options.ordered ?? true,
|
||||
ops: new commands_1.DocumentSequence('ops'),
|
||||
nsInfo: new commands_1.DocumentSequence('nsInfo')
|
||||
};
|
||||
// Add bypassDocumentValidation if it was present in the options.
|
||||
if (this.options.bypassDocumentValidation != null) {
|
||||
command.bypassDocumentValidation = this.options.bypassDocumentValidation;
|
||||
}
|
||||
// Add let if it was present in the options.
|
||||
if (this.options.let) {
|
||||
command.let = this.options.let;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (this.options.comment !== undefined) {
|
||||
command.comment = this.options.comment;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
}
|
||||
exports.ClientBulkWriteCommandBuilder = ClientBulkWriteCommandBuilder;
|
||||
function validateBufferSize(name, buffer, maxBsonObjectSize) {
|
||||
if (buffer.length > maxBsonObjectSize) {
|
||||
throw new error_1.MongoInvalidArgumentError(`Client bulk write operation ${name} of length ${buffer.length} exceeds the max bson object size of ${maxBsonObjectSize}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Build the insert one operation.
|
||||
* @param model - The insert one model.
|
||||
* @param index - The namespace index.
|
||||
* @returns the operation.
|
||||
*/
|
||||
const buildInsertOneOperation = (model, index, pkFactory) => {
|
||||
const document = {
|
||||
insert: index,
|
||||
document: model.document
|
||||
};
|
||||
document.document._id = model.document._id ?? pkFactory.createPk();
|
||||
return document;
|
||||
};
|
||||
exports.buildInsertOneOperation = buildInsertOneOperation;
|
||||
/**
|
||||
* Build the delete one operation.
|
||||
* @param model - The insert many model.
|
||||
* @param index - The namespace index.
|
||||
* @returns the operation.
|
||||
*/
|
||||
const buildDeleteOneOperation = (model, index) => {
|
||||
return createDeleteOperation(model, index, false);
|
||||
};
|
||||
exports.buildDeleteOneOperation = buildDeleteOneOperation;
|
||||
/**
|
||||
* Build the delete many operation.
|
||||
* @param model - The delete many model.
|
||||
* @param index - The namespace index.
|
||||
* @returns the operation.
|
||||
*/
|
||||
const buildDeleteManyOperation = (model, index) => {
|
||||
return createDeleteOperation(model, index, true);
|
||||
};
|
||||
exports.buildDeleteManyOperation = buildDeleteManyOperation;
|
||||
/**
|
||||
* Creates a delete operation based on the parameters.
|
||||
*/
|
||||
function createDeleteOperation(model, index, multi) {
|
||||
const document = {
|
||||
delete: index,
|
||||
multi: multi,
|
||||
filter: model.filter
|
||||
};
|
||||
if (model.hint) {
|
||||
document.hint = model.hint;
|
||||
}
|
||||
if (model.collation) {
|
||||
document.collation = model.collation;
|
||||
}
|
||||
return document;
|
||||
}
|
||||
/**
|
||||
* Build the update one operation.
|
||||
* @param model - The update one model.
|
||||
* @param index - The namespace index.
|
||||
* @returns the operation.
|
||||
*/
|
||||
const buildUpdateOneOperation = (model, index, options) => {
|
||||
return createUpdateOperation(model, index, false, options);
|
||||
};
|
||||
exports.buildUpdateOneOperation = buildUpdateOneOperation;
|
||||
/**
|
||||
* Build the update many operation.
|
||||
* @param model - The update many model.
|
||||
* @param index - The namespace index.
|
||||
* @returns the operation.
|
||||
*/
|
||||
const buildUpdateManyOperation = (model, index, options) => {
|
||||
return createUpdateOperation(model, index, true, options);
|
||||
};
|
||||
exports.buildUpdateManyOperation = buildUpdateManyOperation;
|
||||
/**
|
||||
* Validate the update document.
|
||||
* @param update - The update document.
|
||||
*/
|
||||
function validateUpdate(update, options) {
|
||||
if (!(0, utils_1.hasAtomicOperators)(update, options)) {
|
||||
throw new error_1.MongoAPIError('Client bulk write update models must only contain atomic modifiers (start with $) and must not be empty.');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Creates a delete operation based on the parameters.
|
||||
*/
|
||||
function createUpdateOperation(model, index, multi, options) {
|
||||
// Update documents provided in UpdateOne and UpdateMany write models are
|
||||
// required only to contain atomic modifiers (i.e. keys that start with "$").
|
||||
// Drivers MUST throw an error if an update document is empty or if the
|
||||
// document's first key does not start with "$".
|
||||
validateUpdate(model.update, options);
|
||||
const document = {
|
||||
update: index,
|
||||
multi: multi,
|
||||
filter: model.filter,
|
||||
updateMods: model.update
|
||||
};
|
||||
if (model.hint) {
|
||||
document.hint = model.hint;
|
||||
}
|
||||
if (model.upsert) {
|
||||
document.upsert = model.upsert;
|
||||
}
|
||||
if (model.arrayFilters) {
|
||||
document.arrayFilters = model.arrayFilters;
|
||||
}
|
||||
if (model.collation) {
|
||||
document.collation = model.collation;
|
||||
}
|
||||
if (!multi && 'sort' in model && model.sort != null) {
|
||||
document.sort = (0, sort_1.formatSort)(model.sort);
|
||||
}
|
||||
return document;
|
||||
}
|
||||
/**
|
||||
* Build the replace one operation.
|
||||
* @param model - The replace one model.
|
||||
* @param index - The namespace index.
|
||||
* @returns the operation.
|
||||
*/
|
||||
const buildReplaceOneOperation = (model, index) => {
|
||||
if ((0, utils_1.hasAtomicOperators)(model.replacement)) {
|
||||
throw new error_1.MongoAPIError('Client bulk write replace models must not contain atomic modifiers (start with $) and must not be empty.');
|
||||
}
|
||||
const document = {
|
||||
update: index,
|
||||
multi: false,
|
||||
filter: model.filter,
|
||||
updateMods: model.replacement
|
||||
};
|
||||
if (model.hint) {
|
||||
document.hint = model.hint;
|
||||
}
|
||||
if (model.upsert) {
|
||||
document.upsert = model.upsert;
|
||||
}
|
||||
if (model.collation) {
|
||||
document.collation = model.collation;
|
||||
}
|
||||
if (model.sort != null) {
|
||||
document.sort = (0, sort_1.formatSort)(model.sort);
|
||||
}
|
||||
return document;
|
||||
};
|
||||
exports.buildReplaceOneOperation = buildReplaceOneOperation;
|
||||
/** @internal */
|
||||
function buildOperation(model, index, pkFactory, options) {
|
||||
switch (model.name) {
|
||||
case 'insertOne':
|
||||
return (0, exports.buildInsertOneOperation)(model, index, pkFactory);
|
||||
case 'deleteOne':
|
||||
return (0, exports.buildDeleteOneOperation)(model, index);
|
||||
case 'deleteMany':
|
||||
return (0, exports.buildDeleteManyOperation)(model, index);
|
||||
case 'updateOne':
|
||||
return (0, exports.buildUpdateOneOperation)(model, index, options);
|
||||
case 'updateMany':
|
||||
return (0, exports.buildUpdateManyOperation)(model, index, options);
|
||||
case 'replaceOne':
|
||||
return (0, exports.buildReplaceOneOperation)(model, index);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=command_builder.js.map
|
||||
1
node_modules/mongodb/lib/operations/client_bulk_write/command_builder.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/client_bulk_write/command_builder.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/mongodb/lib/operations/client_bulk_write/common.js
generated
vendored
Normal file
3
node_modules/mongodb/lib/operations/client_bulk_write/common.js
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=common.js.map
|
||||
1
node_modules/mongodb/lib/operations/client_bulk_write/common.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/client_bulk_write/common.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/operations/client_bulk_write/common.ts"],"names":[],"mappings":""}
|
||||
120
node_modules/mongodb/lib/operations/client_bulk_write/executor.js
generated
vendored
Normal file
120
node_modules/mongodb/lib/operations/client_bulk_write/executor.js
generated
vendored
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ClientBulkWriteExecutor = void 0;
|
||||
const abstract_cursor_1 = require("../../cursor/abstract_cursor");
|
||||
const client_bulk_write_cursor_1 = require("../../cursor/client_bulk_write_cursor");
|
||||
const error_1 = require("../../error");
|
||||
const timeout_1 = require("../../timeout");
|
||||
const utils_1 = require("../../utils");
|
||||
const write_concern_1 = require("../../write_concern");
|
||||
const execute_operation_1 = require("../execute_operation");
|
||||
const client_bulk_write_1 = require("./client_bulk_write");
|
||||
const command_builder_1 = require("./command_builder");
|
||||
const results_merger_1 = require("./results_merger");
|
||||
/**
|
||||
* Responsible for executing a client bulk write.
|
||||
* @internal
|
||||
*/
|
||||
class ClientBulkWriteExecutor {
|
||||
/**
|
||||
* Instantiate the executor.
|
||||
* @param client - The mongo client.
|
||||
* @param operations - The user supplied bulk write models.
|
||||
* @param options - The bulk write options.
|
||||
*/
|
||||
constructor(client, operations, options) {
|
||||
if (operations.length === 0) {
|
||||
throw new error_1.MongoClientBulkWriteExecutionError('No client bulk write models were provided.');
|
||||
}
|
||||
this.client = client;
|
||||
this.operations = operations;
|
||||
this.options = {
|
||||
ordered: true,
|
||||
bypassDocumentValidation: false,
|
||||
verboseResults: false,
|
||||
...options
|
||||
};
|
||||
// If no write concern was provided, we inherit one from the client.
|
||||
if (!this.options.writeConcern) {
|
||||
this.options.writeConcern = write_concern_1.WriteConcern.fromOptions(this.client.s.options);
|
||||
}
|
||||
if (this.options.writeConcern?.w === 0) {
|
||||
if (this.options.verboseResults) {
|
||||
throw new error_1.MongoInvalidArgumentError('Cannot request unacknowledged write concern and verbose results');
|
||||
}
|
||||
if (this.options.ordered) {
|
||||
throw new error_1.MongoInvalidArgumentError('Cannot request unacknowledged write concern and ordered writes');
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Execute the client bulk write. Will split commands into batches and exhaust the cursors
|
||||
* for each, then merge the results into one.
|
||||
* @returns The result.
|
||||
*/
|
||||
async execute() {
|
||||
// The command builder will take the user provided models and potential split the batch
|
||||
// into multiple commands due to size.
|
||||
const pkFactory = this.client.s.options.pkFactory;
|
||||
const commandBuilder = new command_builder_1.ClientBulkWriteCommandBuilder(this.operations, this.options, pkFactory);
|
||||
// Unacknowledged writes need to execute all batches and return { ok: 1}
|
||||
const resolvedOptions = (0, utils_1.resolveTimeoutOptions)(this.client, this.options);
|
||||
const context = timeout_1.TimeoutContext.create(resolvedOptions);
|
||||
if (this.options.writeConcern?.w === 0) {
|
||||
while (commandBuilder.hasNextBatch()) {
|
||||
const operation = new client_bulk_write_1.ClientBulkWriteOperation(commandBuilder, this.options);
|
||||
await (0, execute_operation_1.executeOperation)(this.client, operation, context);
|
||||
}
|
||||
return results_merger_1.ClientBulkWriteResultsMerger.unacknowledged();
|
||||
}
|
||||
else {
|
||||
const resultsMerger = new results_merger_1.ClientBulkWriteResultsMerger(this.options);
|
||||
// For each command will will create and exhaust a cursor for the results.
|
||||
while (commandBuilder.hasNextBatch()) {
|
||||
const cursorContext = new abstract_cursor_1.CursorTimeoutContext(context, Symbol());
|
||||
const options = {
|
||||
...this.options,
|
||||
timeoutContext: cursorContext,
|
||||
...(resolvedOptions.timeoutMS != null && { timeoutMode: abstract_cursor_1.CursorTimeoutMode.LIFETIME })
|
||||
};
|
||||
const cursor = new client_bulk_write_cursor_1.ClientBulkWriteCursor(this.client, commandBuilder, options);
|
||||
try {
|
||||
await resultsMerger.merge(cursor);
|
||||
}
|
||||
catch (error) {
|
||||
// Write concern errors are recorded in the writeConcernErrors field on MongoClientBulkWriteError.
|
||||
// When a write concern error is encountered, it should not terminate execution of the bulk write
|
||||
// for either ordered or unordered bulk writes. However, drivers MUST throw an exception at the end
|
||||
// of execution if any write concern errors were observed.
|
||||
if (error instanceof error_1.MongoServerError && !(error instanceof error_1.MongoClientBulkWriteError)) {
|
||||
// Server side errors need to be wrapped inside a MongoClientBulkWriteError, where the root
|
||||
// cause is the error property and a partial result is to be included.
|
||||
const bulkWriteError = new error_1.MongoClientBulkWriteError({
|
||||
message: 'Mongo client bulk write encountered an error during execution'
|
||||
});
|
||||
bulkWriteError.cause = error;
|
||||
bulkWriteError.partialResult = resultsMerger.bulkWriteResult;
|
||||
throw bulkWriteError;
|
||||
}
|
||||
else {
|
||||
// Client side errors are just thrown.
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If we have write concern errors or unordered write errors at the end we throw.
|
||||
if (resultsMerger.writeConcernErrors.length > 0 || resultsMerger.writeErrors.size > 0) {
|
||||
const error = new error_1.MongoClientBulkWriteError({
|
||||
message: 'Mongo client bulk write encountered errors during execution.'
|
||||
});
|
||||
error.writeConcernErrors = resultsMerger.writeConcernErrors;
|
||||
error.writeErrors = resultsMerger.writeErrors;
|
||||
error.partialResult = resultsMerger.bulkWriteResult;
|
||||
throw error;
|
||||
}
|
||||
return resultsMerger.bulkWriteResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.ClientBulkWriteExecutor = ClientBulkWriteExecutor;
|
||||
//# sourceMappingURL=executor.js.map
|
||||
1
node_modules/mongodb/lib/operations/client_bulk_write/executor.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/client_bulk_write/executor.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/operations/client_bulk_write/executor.ts"],"names":[],"mappings":";;;AACA,kEAAuF;AACvF,oFAA8E;AAC9E,uCAKqB;AAErB,2CAA+C;AAC/C,uCAAoD;AACpD,uDAAmD;AACnD,4DAAwD;AACxD,2DAA+D;AAC/D,uDAAkE;AAMlE,qDAAgE;AAEhE;;;GAGG;AACH,MAAa,uBAAuB;IAKlC;;;;;OAKG;IACH,YACE,MAAmB,EACnB,UAA4D,EAC5D,OAAgC;QAEhC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,0CAAkC,CAAC,4CAA4C,CAAC,CAAC;QAC7F,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG;YACb,OAAO,EAAE,IAAI;YACb,wBAAwB,EAAE,KAAK;YAC/B,cAAc,EAAE,KAAK;YACrB,GAAG,OAAO;SACX,CAAC;QAEF,oEAAoE;QACpE,IAAI,CAAC,IAAI,C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H,CAAC;YAED,iFAAiF;YACjF,IAAI,aAAa,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,IAAI,aAAa,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;gBACtF,MAAM,KAAK,GAAG,IAAI,iCAAyB,CAAC;oBAC1C,OAAO,EAAE,8DAA8D;iBACxE,CAAC,CAAC;gBACH,KAAK,CAAC,kBAAkB,GAAG,aAAa,CAAC,kBAAkB,CAAC;gBAC5D,KAAK,CAAC,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC;gBAC9C,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC,eAAe,CAAC;gBACpD,MAAM,KAAK,CAAC;YACd,CAAC;YAED,OAAO,aAAa,CAAC,eAAe,CAAC;QACvC,CAAC;IACH,CAAC;CACF;AAzHD,0DAyHC"}
|
||||
204
node_modules/mongodb/lib/operations/client_bulk_write/results_merger.js
generated
vendored
Normal file
204
node_modules/mongodb/lib/operations/client_bulk_write/results_merger.js
generated
vendored
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ClientBulkWriteResultsMerger = void 0;
|
||||
const __1 = require("../..");
|
||||
const error_1 = require("../../error");
|
||||
/**
|
||||
* Unacknowledged bulk writes are always the same.
|
||||
*/
|
||||
const UNACKNOWLEDGED = {
|
||||
acknowledged: false,
|
||||
insertedCount: 0,
|
||||
upsertedCount: 0,
|
||||
matchedCount: 0,
|
||||
modifiedCount: 0,
|
||||
deletedCount: 0,
|
||||
insertResults: undefined,
|
||||
updateResults: undefined,
|
||||
deleteResults: undefined
|
||||
};
|
||||
/**
|
||||
* Merges client bulk write cursor responses together into a single result.
|
||||
* @internal
|
||||
*/
|
||||
class ClientBulkWriteResultsMerger {
|
||||
/**
|
||||
* @returns The standard unacknowledged bulk write result.
|
||||
*/
|
||||
static unacknowledged() {
|
||||
return UNACKNOWLEDGED;
|
||||
}
|
||||
/**
|
||||
* Instantiate the merger.
|
||||
* @param options - The options.
|
||||
*/
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
this.currentBatchOffset = 0;
|
||||
this.writeConcernErrors = [];
|
||||
this.writeErrors = new Map();
|
||||
this.result = {
|
||||
acknowledged: true,
|
||||
insertedCount: 0,
|
||||
upsertedCount: 0,
|
||||
matchedCount: 0,
|
||||
modifiedCount: 0,
|
||||
deletedCount: 0,
|
||||
insertResults: undefined,
|
||||
updateResults: undefined,
|
||||
deleteResults: undefined
|
||||
};
|
||||
if (options.verboseResults) {
|
||||
this.result.insertResults = new Map();
|
||||
this.result.updateResults = new Map();
|
||||
this.result.deleteResults = new Map();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the bulk write result object.
|
||||
*/
|
||||
get bulkWriteResult() {
|
||||
return {
|
||||
acknowledged: this.result.acknowledged,
|
||||
insertedCount: this.result.insertedCount,
|
||||
upsertedCount: this.result.upsertedCount,
|
||||
matchedCount: this.result.matchedCount,
|
||||
modifiedCount: this.result.modifiedCount,
|
||||
deletedCount: this.result.deletedCount,
|
||||
insertResults: this.result.insertResults,
|
||||
updateResults: this.result.updateResults,
|
||||
deleteResults: this.result.deleteResults
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Merge the results in the cursor to the existing result.
|
||||
* @param currentBatchOffset - The offset index to the original models.
|
||||
* @param response - The cursor response.
|
||||
* @param documents - The documents in the cursor.
|
||||
* @returns The current result.
|
||||
*/
|
||||
async merge(cursor) {
|
||||
let writeConcernErrorResult;
|
||||
try {
|
||||
for await (const document of cursor) {
|
||||
// Only add to maps if ok: 1
|
||||
if (document.ok === 1) {
|
||||
if (this.options.verboseResults) {
|
||||
this.processDocument(cursor, document);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If an individual write error is encountered during an ordered bulk write, drivers MUST
|
||||
// record the error in writeErrors and immediately throw the exception. Otherwise, drivers
|
||||
// MUST continue to iterate the results cursor and execute any further bulkWrite batches.
|
||||
if (this.options.ordered) {
|
||||
const error = new error_1.MongoClientBulkWriteError({
|
||||
message: 'Mongo client ordered bulk write encountered a write error.'
|
||||
});
|
||||
error.writeErrors.set(document.idx + this.currentBatchOffset, {
|
||||
code: document.code,
|
||||
message: document.errmsg
|
||||
});
|
||||
error.partialResult = this.result;
|
||||
throw error;
|
||||
}
|
||||
else {
|
||||
this.writeErrors.set(document.idx + this.currentBatchOffset, {
|
||||
code: document.code,
|
||||
message: document.errmsg
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof __1.MongoWriteConcernError) {
|
||||
const result = error.result;
|
||||
writeConcernErrorResult = {
|
||||
insertedCount: result.nInserted,
|
||||
upsertedCount: result.nUpserted,
|
||||
matchedCount: result.nMatched,
|
||||
modifiedCount: result.nModified,
|
||||
deletedCount: result.nDeleted,
|
||||
writeConcernError: result.writeConcernError
|
||||
};
|
||||
if (this.options.verboseResults && result.cursor.firstBatch) {
|
||||
for (const document of result.cursor.firstBatch) {
|
||||
if (document.ok === 1) {
|
||||
this.processDocument(cursor, document);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
// Update the counts from the cursor response.
|
||||
if (cursor.response) {
|
||||
const response = cursor.response;
|
||||
this.incrementCounts(response);
|
||||
}
|
||||
// Increment the batch offset.
|
||||
this.currentBatchOffset += cursor.operations.length;
|
||||
}
|
||||
// If we have write concern errors ensure they are added.
|
||||
if (writeConcernErrorResult) {
|
||||
const writeConcernError = writeConcernErrorResult.writeConcernError;
|
||||
this.incrementCounts(writeConcernErrorResult);
|
||||
this.writeConcernErrors.push({
|
||||
code: writeConcernError.code,
|
||||
message: writeConcernError.errmsg
|
||||
});
|
||||
}
|
||||
return this.result;
|
||||
}
|
||||
/**
|
||||
* Process an individual document in the results.
|
||||
* @param cursor - The cursor.
|
||||
* @param document - The document to process.
|
||||
*/
|
||||
processDocument(cursor, document) {
|
||||
// Get the corresponding operation from the command.
|
||||
const operation = cursor.operations[document.idx];
|
||||
// Handle insert results.
|
||||
if ('insert' in operation) {
|
||||
this.result.insertResults?.set(document.idx + this.currentBatchOffset, {
|
||||
insertedId: operation.document._id
|
||||
});
|
||||
}
|
||||
// Handle update results.
|
||||
if ('update' in operation) {
|
||||
const result = {
|
||||
matchedCount: document.n,
|
||||
modifiedCount: document.nModified ?? 0,
|
||||
// Check if the bulk did actually upsert.
|
||||
didUpsert: document.upserted != null
|
||||
};
|
||||
if (document.upserted) {
|
||||
result.upsertedId = document.upserted._id;
|
||||
}
|
||||
this.result.updateResults?.set(document.idx + this.currentBatchOffset, result);
|
||||
}
|
||||
// Handle delete results.
|
||||
if ('delete' in operation) {
|
||||
this.result.deleteResults?.set(document.idx + this.currentBatchOffset, {
|
||||
deletedCount: document.n
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Increment the result counts.
|
||||
* @param document - The document with the results.
|
||||
*/
|
||||
incrementCounts(document) {
|
||||
this.result.insertedCount += document.insertedCount;
|
||||
this.result.upsertedCount += document.upsertedCount;
|
||||
this.result.matchedCount += document.matchedCount;
|
||||
this.result.modifiedCount += document.modifiedCount;
|
||||
this.result.deletedCount += document.deletedCount;
|
||||
}
|
||||
}
|
||||
exports.ClientBulkWriteResultsMerger = ClientBulkWriteResultsMerger;
|
||||
//# sourceMappingURL=results_merger.js.map
|
||||
1
node_modules/mongodb/lib/operations/client_bulk_write/results_merger.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/client_bulk_write/results_merger.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
83
node_modules/mongodb/lib/operations/command.js
generated
vendored
Normal file
83
node_modules/mongodb/lib/operations/command.js
generated
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CommandOperation = void 0;
|
||||
const constants_1 = require("../cmap/wire_protocol/constants");
|
||||
const error_1 = require("../error");
|
||||
const explain_1 = require("../explain");
|
||||
const read_concern_1 = require("../read_concern");
|
||||
const utils_1 = require("../utils");
|
||||
const write_concern_1 = require("../write_concern");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class CommandOperation extends operation_1.AbstractOperation {
|
||||
constructor(parent, options) {
|
||||
super(options);
|
||||
this.options = options ?? {};
|
||||
// NOTE: this was explicitly added for the add/remove user operations, it's likely
|
||||
// something we'd want to reconsider. Perhaps those commands can use `Admin`
|
||||
// as a parent?
|
||||
const dbNameOverride = options?.dbName || options?.authdb;
|
||||
if (dbNameOverride) {
|
||||
this.ns = new utils_1.MongoDBNamespace(dbNameOverride, '$cmd');
|
||||
}
|
||||
else {
|
||||
this.ns = parent
|
||||
? parent.s.namespace.withCollection('$cmd')
|
||||
: new utils_1.MongoDBNamespace('admin', '$cmd');
|
||||
}
|
||||
this.readConcern = read_concern_1.ReadConcern.fromOptions(options);
|
||||
this.writeConcern = write_concern_1.WriteConcern.fromOptions(options);
|
||||
if (this.hasAspect(operation_1.Aspect.EXPLAINABLE)) {
|
||||
this.explain = explain_1.Explain.fromOptions(options);
|
||||
if (this.explain)
|
||||
(0, explain_1.validateExplainTimeoutOptions)(this.options, this.explain);
|
||||
}
|
||||
else if (options?.explain != null) {
|
||||
throw new error_1.MongoInvalidArgumentError(`Option "explain" is not supported on this command`);
|
||||
}
|
||||
}
|
||||
get canRetryWrite() {
|
||||
if (this.hasAspect(operation_1.Aspect.EXPLAINABLE)) {
|
||||
return this.explain == null;
|
||||
}
|
||||
return super.canRetryWrite;
|
||||
}
|
||||
buildOptions(timeoutContext) {
|
||||
return {
|
||||
...this.options,
|
||||
...this.bsonOptions,
|
||||
timeoutContext,
|
||||
readPreference: this.readPreference,
|
||||
session: this.session
|
||||
};
|
||||
}
|
||||
buildCommand(connection, session) {
|
||||
const command = this.buildCommandDocument(connection, session);
|
||||
const inTransaction = this.session && this.session.inTransaction();
|
||||
if (this.readConcern && (0, utils_1.commandSupportsReadConcern)(command) && !inTransaction) {
|
||||
Object.assign(command, { readConcern: this.readConcern });
|
||||
}
|
||||
if (this.writeConcern && this.hasAspect(operation_1.Aspect.WRITE_OPERATION) && !inTransaction) {
|
||||
write_concern_1.WriteConcern.apply(command, this.writeConcern);
|
||||
}
|
||||
if (this.options.collation &&
|
||||
typeof this.options.collation === 'object' &&
|
||||
!this.hasAspect(operation_1.Aspect.SKIP_COLLATION)) {
|
||||
Object.assign(command, { collation: this.options.collation });
|
||||
}
|
||||
if (typeof this.options.maxTimeMS === 'number') {
|
||||
command.maxTimeMS = this.options.maxTimeMS;
|
||||
}
|
||||
if (this.options.rawData != null &&
|
||||
this.hasAspect(operation_1.Aspect.SUPPORTS_RAW_DATA) &&
|
||||
(0, utils_1.maxWireVersion)(connection) >= constants_1.MIN_SUPPORTED_RAW_DATA_WIRE_VERSION) {
|
||||
command.rawData = this.options.rawData;
|
||||
}
|
||||
if (this.hasAspect(operation_1.Aspect.EXPLAINABLE) && this.explain) {
|
||||
return (0, explain_1.decorateWithExplain)(command, this.explain);
|
||||
}
|
||||
return command;
|
||||
}
|
||||
}
|
||||
exports.CommandOperation = CommandOperation;
|
||||
//# sourceMappingURL=command.js.map
|
||||
1
node_modules/mongodb/lib/operations/command.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/command.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/operations/command.ts"],"names":[],"mappings":";;;AAEA,+DAAsF;AACtF,oCAAqD;AACrD,wCAKoB;AACpB,kDAA8C;AAK9C,oCAAwF;AACxF,oDAA0E;AAE1E,2CAA+E;AA4D/E,gBAAgB;AAChB,MAAsB,gBAAoB,SAAQ,6BAAoB;IAMpE,YAAY,MAAwB,EAAE,OAAiC;QACrE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAE7B,kFAAkF;QAClF,kFAAkF;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,CAAC,OAAO,IAAI,IAAI;YAC5B,IAAI,CAAC,SAAS,CAAC,kBAAM,CAAC,iBAAiB,CAAC;YACxC,IAAA,sBAAc,EAAC,UAAU,CAAC,IAAI,+CAAmC,EACjE,CAAC;YACD,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACzC,CAAC;QAED,IAAI,IAAI,CAAC,SAAS,CAAC,kBAAM,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACvD,OAAO,IAAA,6BAAmB,EAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACpD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA3FD,4CA2FC"}
|
||||
45
node_modules/mongodb/lib/operations/count.js
generated
vendored
Normal file
45
node_modules/mongodb/lib/operations/count.js
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CountOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class CountOperation extends command_1.CommandOperation {
|
||||
constructor(namespace, filter, options) {
|
||||
super({ s: { namespace: namespace } }, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options;
|
||||
this.collectionName = namespace.collection;
|
||||
this.query = filter;
|
||||
}
|
||||
get commandName() {
|
||||
return 'count';
|
||||
}
|
||||
buildCommandDocument(_connection, _session) {
|
||||
const options = this.options;
|
||||
const cmd = {
|
||||
count: this.collectionName,
|
||||
query: this.query
|
||||
};
|
||||
if (typeof options.limit === 'number') {
|
||||
cmd.limit = options.limit;
|
||||
}
|
||||
if (typeof options.skip === 'number') {
|
||||
cmd.skip = options.skip;
|
||||
}
|
||||
if (options.hint != null) {
|
||||
cmd.hint = options.hint;
|
||||
}
|
||||
if (typeof options.maxTimeMS === 'number') {
|
||||
cmd.maxTimeMS = options.maxTimeMS;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
handleOk(response) {
|
||||
return response.getNumber('n') ?? 0;
|
||||
}
|
||||
}
|
||||
exports.CountOperation = CountOperation;
|
||||
(0, operation_1.defineAspects)(CountOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.RETRYABLE, operation_1.Aspect.SUPPORTS_RAW_DATA]);
|
||||
//# sourceMappingURL=count.js.map
|
||||
1
node_modules/mongodb/lib/operations/count.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/count.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"count.js","sourceRoot":"","sources":["../../src/operations/count.ts"],"names":[],"mappings":";;;AAEA,+DAAkE;AAIlE,uCAA2E;AAC3E,2CAAoD;AAgBpD,gBAAgB;AAChB,MAAa,cAAe,SAAQ,0BAAwB;IAM1D,YAAY,SAA2B,EAAE,MAAgB,EAAE,OAAqB;QAC9E,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAA2B,EAAE,OAAO,CAAC,CAAC;QANlE,iCAA4B,GAAG,2BAAe,CAAC;QAQtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;IACtB,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,OAAgB,CAAC;IAC1B,CAAC;IAEQ,oBAAoB,CAAC,WAAuB,EAAE,QAAwB;QAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,MAAM,GAAG,GAAa;YACpB,KAAK,EAAE,IAAI,CAAC,cAAc;YAC1B,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;QAEF,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACtC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC1B,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YACzB,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC1B,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC1C,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACpC,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAEQ,QAAQ,CAAC,QAAgE;QAChF,OAAO,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF;AA/CD,wCA+CC;AAED,IAAA,yBAAa,EAAC,cAAc,EAAE,CAAC,kBAAM,CAAC,cAAc,EAAE,kBAAM,CAAC,SAAS,EAAE,kBAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC"}
|
||||
109
node_modules/mongodb/lib/operations/create_collection.js
generated
vendored
Normal file
109
node_modules/mongodb/lib/operations/create_collection.js
generated
vendored
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CreateCollectionOperation = void 0;
|
||||
exports.createCollections = createCollections;
|
||||
const constants_1 = require("../cmap/wire_protocol/constants");
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const collection_1 = require("../collection");
|
||||
const error_1 = require("../error");
|
||||
const timeout_1 = require("../timeout");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const execute_operation_1 = require("./execute_operation");
|
||||
const indexes_1 = require("./indexes");
|
||||
const operation_1 = require("./operation");
|
||||
const ILLEGAL_COMMAND_FIELDS = new Set([
|
||||
'w',
|
||||
'wtimeout',
|
||||
'timeoutMS',
|
||||
'j',
|
||||
'fsync',
|
||||
'pkFactory',
|
||||
'raw',
|
||||
'readPreference',
|
||||
'session',
|
||||
'readConcern',
|
||||
'writeConcern',
|
||||
'raw',
|
||||
'fieldsAsRaw',
|
||||
'useBigInt64',
|
||||
'promoteLongs',
|
||||
'promoteValues',
|
||||
'promoteBuffers',
|
||||
'bsonRegExp',
|
||||
'serializeFunctions',
|
||||
'ignoreUndefined',
|
||||
'enableUtf8Validation'
|
||||
]);
|
||||
/* @internal */
|
||||
const INVALID_QE_VERSION = 'Driver support of Queryable Encryption is incompatible with server. Upgrade server to use Queryable Encryption.';
|
||||
/** @internal */
|
||||
class CreateCollectionOperation extends command_1.CommandOperation {
|
||||
constructor(db, name, options = {}) {
|
||||
super(db, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options;
|
||||
this.db = db;
|
||||
this.name = name;
|
||||
}
|
||||
get commandName() {
|
||||
return 'create';
|
||||
}
|
||||
buildCommandDocument(_connection, _session) {
|
||||
const isOptionValid = ([k, v]) => v != null && typeof v !== 'function' && !ILLEGAL_COMMAND_FIELDS.has(k);
|
||||
return {
|
||||
create: this.name,
|
||||
...Object.fromEntries(Object.entries(this.options).filter(isOptionValid))
|
||||
};
|
||||
}
|
||||
handleOk(_response) {
|
||||
return new collection_1.Collection(this.db, this.name, this.options);
|
||||
}
|
||||
}
|
||||
exports.CreateCollectionOperation = CreateCollectionOperation;
|
||||
async function createCollections(db, name, options) {
|
||||
const timeoutContext = timeout_1.TimeoutContext.create({
|
||||
session: options.session,
|
||||
serverSelectionTimeoutMS: db.client.s.options.serverSelectionTimeoutMS,
|
||||
waitQueueTimeoutMS: db.client.s.options.waitQueueTimeoutMS,
|
||||
timeoutMS: options.timeoutMS
|
||||
});
|
||||
const encryptedFields = options.encryptedFields ??
|
||||
db.client.s.options.autoEncryption?.encryptedFieldsMap?.[`${db.databaseName}.${name}`];
|
||||
if (encryptedFields) {
|
||||
class CreateSupportingFLEv2CollectionOperation extends CreateCollectionOperation {
|
||||
buildCommandDocument(connection, session) {
|
||||
if (!connection.description.loadBalanced &&
|
||||
(0, utils_1.maxWireVersion)(connection) < constants_1.MIN_SUPPORTED_QE_WIRE_VERSION) {
|
||||
throw new error_1.MongoCompatibilityError(`${INVALID_QE_VERSION} The minimum server version required is ${constants_1.MIN_SUPPORTED_QE_SERVER_VERSION}`);
|
||||
}
|
||||
return super.buildCommandDocument(connection, session);
|
||||
}
|
||||
}
|
||||
// Create auxilliary collections for queryable encryption support.
|
||||
const escCollection = encryptedFields.escCollection ?? `enxcol_.${name}.esc`;
|
||||
const ecocCollection = encryptedFields.ecocCollection ?? `enxcol_.${name}.ecoc`;
|
||||
for (const collectionName of [escCollection, ecocCollection]) {
|
||||
const createOp = new CreateSupportingFLEv2CollectionOperation(db, collectionName, {
|
||||
clusteredIndex: {
|
||||
key: { _id: 1 },
|
||||
unique: true
|
||||
},
|
||||
session: options.session
|
||||
});
|
||||
await (0, execute_operation_1.executeOperation)(db.client, createOp, timeoutContext);
|
||||
}
|
||||
if (!options.encryptedFields) {
|
||||
options = { ...options, encryptedFields };
|
||||
}
|
||||
}
|
||||
const coll = await (0, execute_operation_1.executeOperation)(db.client, new CreateCollectionOperation(db, name, options), timeoutContext);
|
||||
if (encryptedFields) {
|
||||
// Create the required index for queryable encryption support.
|
||||
const createIndexOp = indexes_1.CreateIndexesOperation.fromIndexSpecification(db, name, { __safeContent__: 1 }, { session: options.session });
|
||||
await (0, execute_operation_1.executeOperation)(db.client, createIndexOp, timeoutContext);
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
(0, operation_1.defineAspects)(CreateCollectionOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
//# sourceMappingURL=create_collection.js.map
|
||||
1
node_modules/mongodb/lib/operations/create_collection.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/create_collection.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"create_collection.js","sourceRoot":"","sources":["../../src/operations/create_collection.ts"],"names":[],"mappings":";;;AAiJA,8CAsEC;AArND,+DAGyC;AACzC,+DAAkE;AAClE,8CAA2C;AAE3C,oCAAmD;AAGnD,wCAA4C;AAC5C,oCAA0C;AAC1C,uCAA2E;AAC3E,2DAAuD;AACvD,uCAAmD;AACnD,2CAAoD;AAEpD,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,GAAG;IACH,UAAU;IACV,WAAW;IACX,GAAG;IACH,OAAO;IACP,WAAW;IACX,KAAK;IACL,gBAAgB;IAChB,SAAS;IACT,aAAa;IACb,cAAc;IACd,KAAK;IACL,aAAa;IACb,aAAa;IACb,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,YAAY;IACZ,oBAAoB;IACpB,iBAAiB;IACjB,sBAAsB;CACvB,CAAC,CAAC;AAiEH,eAAe;AACf,MAAM,kBAAkB,GACtB,iHAAiH,CAAC;AAEpH,gBAAgB;AAChB,MAAa,yBAA0B,SAAQ,0BAA4B;IAMzE,YAAY,EAAM,EAAE,IAAY,EAAE,UAAmC,EAAE;QACrE,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QANZ,iCAA4B,GAAG,2BAAe,CAAC;QAQtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,QAAiB,CAAC;IAC3B,CAAC;IAEQ,oBAAoB,CAAC,WAAuB,EAAE,QAAwB;QAC7E,MAAM,aAAa,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAA0B,EAAE,EAAE,CACxD,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,UAAU,IAAI,CAA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E,aAAa,EAAE,cAAc,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,IAAsC,CAAC;AAChD,CAAC;AAED,IAAA,yBAAa,EAAC,yBAAyB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
||||
125
node_modules/mongodb/lib/operations/delete.js
generated
vendored
Normal file
125
node_modules/mongodb/lib/operations/delete.js
generated
vendored
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DeleteManyOperation = exports.DeleteOneOperation = exports.DeleteOperation = void 0;
|
||||
exports.makeDeleteStatement = makeDeleteStatement;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../error");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class DeleteOperation extends command_1.CommandOperation {
|
||||
constructor(ns, statements, options) {
|
||||
super(undefined, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options;
|
||||
this.ns = ns;
|
||||
this.statements = statements;
|
||||
}
|
||||
get commandName() {
|
||||
return 'delete';
|
||||
}
|
||||
get canRetryWrite() {
|
||||
if (super.canRetryWrite === false) {
|
||||
return false;
|
||||
}
|
||||
return this.statements.every(op => (op.limit != null ? op.limit > 0 : true));
|
||||
}
|
||||
buildCommandDocument(connection, _session) {
|
||||
const options = this.options;
|
||||
const ordered = typeof options.ordered === 'boolean' ? options.ordered : true;
|
||||
const command = {
|
||||
delete: this.ns.collection,
|
||||
deletes: this.statements,
|
||||
ordered
|
||||
};
|
||||
if (options.let) {
|
||||
command.let = options.let;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (options.comment !== undefined) {
|
||||
command.comment = options.comment;
|
||||
}
|
||||
const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0;
|
||||
if (unacknowledgedWrite && (0, utils_1.maxWireVersion)(connection) < 9) {
|
||||
if (this.statements.find((o) => o.hint)) {
|
||||
throw new error_1.MongoCompatibilityError(`hint for the delete command is only supported on MongoDB 4.4+`);
|
||||
}
|
||||
}
|
||||
return command;
|
||||
}
|
||||
}
|
||||
exports.DeleteOperation = DeleteOperation;
|
||||
class DeleteOneOperation extends DeleteOperation {
|
||||
constructor(ns, filter, options) {
|
||||
super(ns, [makeDeleteStatement(filter, { ...options, limit: 1 })], options);
|
||||
}
|
||||
handleOk(response) {
|
||||
const res = super.handleOk(response);
|
||||
// @ts-expect-error Explain commands have broken TS
|
||||
if (this.explain)
|
||||
return res;
|
||||
if (res.code)
|
||||
throw new error_1.MongoServerError(res);
|
||||
if (res.writeErrors)
|
||||
throw new error_1.MongoServerError(res.writeErrors[0]);
|
||||
return {
|
||||
acknowledged: this.writeConcern?.w !== 0,
|
||||
deletedCount: res.n
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.DeleteOneOperation = DeleteOneOperation;
|
||||
class DeleteManyOperation extends DeleteOperation {
|
||||
constructor(ns, filter, options) {
|
||||
super(ns, [makeDeleteStatement(filter, options)], options);
|
||||
}
|
||||
handleOk(response) {
|
||||
const res = super.handleOk(response);
|
||||
// @ts-expect-error Explain commands have broken TS
|
||||
if (this.explain)
|
||||
return res;
|
||||
if (res.code)
|
||||
throw new error_1.MongoServerError(res);
|
||||
if (res.writeErrors)
|
||||
throw new error_1.MongoServerError(res.writeErrors[0]);
|
||||
return {
|
||||
acknowledged: this.writeConcern?.w !== 0,
|
||||
deletedCount: res.n
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.DeleteManyOperation = DeleteManyOperation;
|
||||
function makeDeleteStatement(filter, options) {
|
||||
const op = {
|
||||
q: filter,
|
||||
limit: typeof options.limit === 'number' ? options.limit : 0
|
||||
};
|
||||
if (options.collation) {
|
||||
op.collation = options.collation;
|
||||
}
|
||||
if (options.hint) {
|
||||
op.hint = options.hint;
|
||||
}
|
||||
return op;
|
||||
}
|
||||
(0, operation_1.defineAspects)(DeleteOperation, [
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
(0, operation_1.defineAspects)(DeleteOneOperation, [
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.SKIP_COLLATION,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
(0, operation_1.defineAspects)(DeleteManyOperation, [
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.SKIP_COLLATION,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
//# sourceMappingURL=delete.js.map
|
||||
1
node_modules/mongodb/lib/operations/delete.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/delete.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../src/operations/delete.ts"],"names":[],"mappings":";;;AAiJA,kDAkBC;AAjKD,+DAAkE;AAClE,oCAAqE;AAErE,oCAAkG;AAElG,uCAAkG;AAClG,2CAA+D;AAkC/D,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,0BAA0B;IAK7D,YAAY,EAAoB,EAAE,UAA6B,EAAE,OAAsB;QACrF,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QALnB,iCAA4B,GAAG,2BAAe,CAAC;QAMtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,QAAi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,kBAAM,CAAC,WAAW;IAClB,kBAAM,CAAC,cAAc;IACrB,kBAAM,CAAC,iBAAiB;CACzB,CAAC,CAAC"}
|
||||
61
node_modules/mongodb/lib/operations/distinct.js
generated
vendored
Normal file
61
node_modules/mongodb/lib/operations/distinct.js
generated
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DistinctOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/**
|
||||
* Return a list of distinct values for the given key across a collection.
|
||||
* @internal
|
||||
*/
|
||||
class DistinctOperation extends command_1.CommandOperation {
|
||||
/**
|
||||
* Construct a Distinct operation.
|
||||
*
|
||||
* @param collection - Collection instance.
|
||||
* @param key - Field of the document to find distinct values for.
|
||||
* @param query - The query for filtering the set of documents to which we apply the distinct filter.
|
||||
* @param options - Optional settings. See Collection.prototype.distinct for a list of options.
|
||||
*/
|
||||
constructor(collection, key, query, options) {
|
||||
super(collection, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options ?? {};
|
||||
this.collection = collection;
|
||||
this.key = key;
|
||||
this.query = query;
|
||||
}
|
||||
get commandName() {
|
||||
return 'distinct';
|
||||
}
|
||||
buildCommandDocument(_connection) {
|
||||
const command = {
|
||||
distinct: this.collection.collectionName,
|
||||
key: this.key,
|
||||
query: this.query
|
||||
};
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (this.options.comment !== undefined) {
|
||||
command.comment = this.options.comment;
|
||||
}
|
||||
if (this.options.hint != null) {
|
||||
command.hint = this.options.hint;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
handleOk(response) {
|
||||
if (this.explain) {
|
||||
return response.toObject(this.bsonOptions);
|
||||
}
|
||||
return response.toObject(this.bsonOptions).values;
|
||||
}
|
||||
}
|
||||
exports.DistinctOperation = DistinctOperation;
|
||||
(0, operation_1.defineAspects)(DistinctOperation, [
|
||||
operation_1.Aspect.READ_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
//# sourceMappingURL=distinct.js.map
|
||||
1
node_modules/mongodb/lib/operations/distinct.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/distinct.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"distinct.js","sourceRoot":"","sources":["../../src/operations/distinct.ts"],"names":[],"mappings":";;;AAEA,+DAAkE;AAElE,uCAA2E;AAC3E,2CAAoD;AAkBpD;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,0BAAkC;IASvE;;;;;;;OAOG;IACH,YAAY,UAAsB,EAAE,GAAW,EAAE,KAAe,EAAE,OAAyB;QACzF,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAjBpB,iCAA4B,GAAG,2BAAe,CAAC;QAmBtD,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,UAAmB,CAAC;IAC7B,CAAC;IAEQ,oBAAoB,CAAC,WAAuB;QACnD,MAAM,OAAO,GAAa;YACxB,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc;YACxC,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;QACF,iEAAiE;QACjE,gDAAgD;QAChD,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACvC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACzC,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YAC9B,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QACnC,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAEQ,QAAQ,CACf,QAAgE;QAEhE,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;IACpD,CAAC;CACF;AAzDD,8CAyDC;AAED,IAAA,yBAAa,EAAC,iBAAiB,EAAE;IAC/B,kBAAM,CAAC,cAAc;IACrB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,WAAW;IAClB,kBAAM,CAAC,iBAAiB;CACzB,CAAC,CAAC"}
|
||||
93
node_modules/mongodb/lib/operations/drop.js
generated
vendored
Normal file
93
node_modules/mongodb/lib/operations/drop.js
generated
vendored
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DropDatabaseOperation = exports.DropCollectionOperation = void 0;
|
||||
exports.dropCollections = dropCollections;
|
||||
const __1 = require("..");
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const abstract_cursor_1 = require("../cursor/abstract_cursor");
|
||||
const error_1 = require("../error");
|
||||
const timeout_1 = require("../timeout");
|
||||
const command_1 = require("./command");
|
||||
const execute_operation_1 = require("./execute_operation");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class DropCollectionOperation extends command_1.CommandOperation {
|
||||
constructor(db, name, options = {}) {
|
||||
super(db, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options;
|
||||
this.name = name;
|
||||
}
|
||||
get commandName() {
|
||||
return 'drop';
|
||||
}
|
||||
buildCommandDocument(_connection, _session) {
|
||||
return { drop: this.name };
|
||||
}
|
||||
handleOk(_response) {
|
||||
return true;
|
||||
}
|
||||
handleError(error) {
|
||||
if (!(error instanceof __1.MongoServerError))
|
||||
throw error;
|
||||
if (Number(error.code) !== error_1.MONGODB_ERROR_CODES.NamespaceNotFound)
|
||||
throw error;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
exports.DropCollectionOperation = DropCollectionOperation;
|
||||
async function dropCollections(db, name, options) {
|
||||
const timeoutContext = timeout_1.TimeoutContext.create({
|
||||
session: options.session,
|
||||
serverSelectionTimeoutMS: db.client.s.options.serverSelectionTimeoutMS,
|
||||
waitQueueTimeoutMS: db.client.s.options.waitQueueTimeoutMS,
|
||||
timeoutMS: options.timeoutMS
|
||||
});
|
||||
const encryptedFieldsMap = db.client.s.options.autoEncryption?.encryptedFieldsMap;
|
||||
let encryptedFields = options.encryptedFields ?? encryptedFieldsMap?.[`${db.databaseName}.${name}`];
|
||||
if (!encryptedFields && encryptedFieldsMap) {
|
||||
// If the MongoClient was configured with an encryptedFieldsMap,
|
||||
// and no encryptedFields config was available in it or explicitly
|
||||
// passed as an argument, the spec tells us to look one up using
|
||||
// listCollections().
|
||||
const listCollectionsResult = await db
|
||||
.listCollections({ name }, {
|
||||
nameOnly: false,
|
||||
session: options.session,
|
||||
timeoutContext: new abstract_cursor_1.CursorTimeoutContext(timeoutContext, Symbol())
|
||||
})
|
||||
.toArray();
|
||||
encryptedFields = listCollectionsResult?.[0]?.options?.encryptedFields;
|
||||
}
|
||||
if (encryptedFields) {
|
||||
const escCollection = encryptedFields.escCollection || `enxcol_.${name}.esc`;
|
||||
const ecocCollection = encryptedFields.ecocCollection || `enxcol_.${name}.ecoc`;
|
||||
for (const collectionName of [escCollection, ecocCollection]) {
|
||||
// Drop auxilliary collections, ignoring potential NamespaceNotFound errors.
|
||||
const dropOp = new DropCollectionOperation(db, collectionName, options);
|
||||
await (0, execute_operation_1.executeOperation)(db.client, dropOp, timeoutContext);
|
||||
}
|
||||
}
|
||||
return await (0, execute_operation_1.executeOperation)(db.client, new DropCollectionOperation(db, name, options), timeoutContext);
|
||||
}
|
||||
/** @internal */
|
||||
class DropDatabaseOperation extends command_1.CommandOperation {
|
||||
constructor(db, options) {
|
||||
super(db, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options;
|
||||
}
|
||||
get commandName() {
|
||||
return 'dropDatabase';
|
||||
}
|
||||
buildCommandDocument(_connection, _session) {
|
||||
return { dropDatabase: 1 };
|
||||
}
|
||||
handleOk(_response) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
exports.DropDatabaseOperation = DropDatabaseOperation;
|
||||
(0, operation_1.defineAspects)(DropCollectionOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
(0, operation_1.defineAspects)(DropDatabaseOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
//# sourceMappingURL=drop.js.map
|
||||
1
node_modules/mongodb/lib/operations/drop.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/drop.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"drop.js","sourceRoot":"","sources":["../../src/operations/drop.ts"],"names":[],"mappings":";;;AAmDA,0CAkDC;AArGD,0BAAwE;AAExE,+DAAkE;AAClE,+DAAiE;AAEjE,oCAA+C;AAE/C,wCAA4C;AAC5C,uCAA2E;AAC3E,2DAAuD;AACvD,2CAAoD;AAQpD,gBAAgB;AAChB,MAAa,uBAAwB,SAAQ,0BAAyB;IAMpE,YAAY,EAAM,EAAE,IAAY,EAAE,UAAiC,EAAE;QACnE,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QANZ,iCAA4B,GAAG,2BAAe,CAAC;QAOtD,IAAI,CAAC,O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B,CAAC;IACjC,CAAC;IAEQ,oBAAoB,CAAC,WAAuB,EAAE,QAAwB;QAC7E,OAAO,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;IAC7B,CAAC;IAEQ,QAAQ,CAAC,SAAiE;QACjF,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAnBD,sDAmBC;AAED,IAAA,yBAAa,EAAC,uBAAuB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AACjE,IAAA,yBAAa,EAAC,qBAAqB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
||||
34
node_modules/mongodb/lib/operations/end_sessions.js
generated
vendored
Normal file
34
node_modules/mongodb/lib/operations/end_sessions.js
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EndSessionsOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const command_1 = require("../operations/command");
|
||||
const read_preference_1 = require("../read_preference");
|
||||
const utils_1 = require("../utils");
|
||||
const operation_1 = require("./operation");
|
||||
class EndSessionsOperation extends command_1.CommandOperation {
|
||||
constructor(sessions) {
|
||||
super();
|
||||
this.writeConcern = { w: 0 };
|
||||
this.ns = utils_1.MongoDBNamespace.fromString('admin.$cmd');
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.sessions = sessions;
|
||||
}
|
||||
buildCommandDocument(_connection, _session) {
|
||||
return {
|
||||
endSessions: this.sessions
|
||||
};
|
||||
}
|
||||
buildOptions(timeoutContext) {
|
||||
return {
|
||||
timeoutContext,
|
||||
readPreference: read_preference_1.ReadPreference.primaryPreferred
|
||||
};
|
||||
}
|
||||
get commandName() {
|
||||
return 'endSessions';
|
||||
}
|
||||
}
|
||||
exports.EndSessionsOperation = EndSessionsOperation;
|
||||
(0, operation_1.defineAspects)(EndSessionsOperation, operation_1.Aspect.WRITE_OPERATION);
|
||||
//# sourceMappingURL=end_sessions.js.map
|
||||
1
node_modules/mongodb/lib/operations/end_sessions.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/end_sessions.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"end_sessions.js","sourceRoot":"","sources":["../../src/operations/end_sessions.ts"],"names":[],"mappings":";;;AASA,+DAAkE;AAClE,mDAAyD;AACzD,wDAAoD;AACpD,oCAA4C;AAC5C,2CAAoD;AAEpD,MAAa,oBAAqB,SAAQ,0BAAsB;IAO9D,YAAY,QAAgC;QAC1C,KAAK,EAAE,CAAC;QAPD,iBAAY,GAAiB,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACtC,OAAE,GAAG,wBAAgB,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QAC/C,iCAA4B,GAAG,2BAAe,CAAC;QAMtD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEQ,oBAAoB,CAAC,WAAuB,EAAE,QAAwB;QAC7E,OAAO;YACL,WAAW,EAAE,IAAI,CAAC,QAAQ;SAC3B,CAAC;IACJ,CAAC;IACQ,YAAY,CAAC,cAA8B;QAClD,OAAO;YACL,cAAc;YACd,cAAc,EAAE,gCAAc,CAAC,gBAAgB;SAChD,CAAC;IACJ,CAAC;IACD,IAAa,WAAW;QACtB,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AA1BD,oDA0BC;AAED,IAAA,yBAAa,EAAC,oBAAoB,EAAE,kBAAM,CAAC,eAAe,CAAC,CAAC"}
|
||||
41
node_modules/mongodb/lib/operations/estimated_document_count.js
generated
vendored
Normal file
41
node_modules/mongodb/lib/operations/estimated_document_count.js
generated
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EstimatedDocumentCountOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class EstimatedDocumentCountOperation extends command_1.CommandOperation {
|
||||
constructor(collection, options = {}) {
|
||||
super(collection, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options;
|
||||
this.collectionName = collection.collectionName;
|
||||
}
|
||||
get commandName() {
|
||||
return 'count';
|
||||
}
|
||||
buildCommandDocument(_connection, _session) {
|
||||
const cmd = { count: this.collectionName };
|
||||
if (typeof this.options.maxTimeMS === 'number') {
|
||||
cmd.maxTimeMS = this.options.maxTimeMS;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (this.options.comment !== undefined) {
|
||||
cmd.comment = this.options.comment;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
handleOk(response) {
|
||||
return response.getNumber('n') ?? 0;
|
||||
}
|
||||
}
|
||||
exports.EstimatedDocumentCountOperation = EstimatedDocumentCountOperation;
|
||||
(0, operation_1.defineAspects)(EstimatedDocumentCountOperation, [
|
||||
operation_1.Aspect.READ_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.CURSOR_CREATING,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
//# sourceMappingURL=estimated_document_count.js.map
|
||||
1
node_modules/mongodb/lib/operations/estimated_document_count.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/estimated_document_count.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"estimated_document_count.js","sourceRoot":"","sources":["../../src/operations/estimated_document_count.ts"],"names":[],"mappings":";;;AAEA,+DAAkE;AAGlE,uCAA2E;AAC3E,2CAAoD;AAYpD,gBAAgB;AAChB,MAAa,+BAAgC,SAAQ,0BAAwB;IAK3E,YAAY,UAAsB,EAAE,UAAyC,EAAE;QAC7E,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QALpB,iCAA4B,GAAG,2BAAe,CAAC;QAMtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;IAClD,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,OAAgB,CAAC;IAC1B,CAAC;IAEQ,oBAAoB,CAAC,WAAuB,EAAE,QAAwB;QAC7E,MAAM,GAAG,GAAa,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;QAErD,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC/C,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;QACzC,CAAC;QAED,iEAAiE;QACjE,gDAAgD;QAChD,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACvC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrC,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAEQ,QAAQ,CAAC,QAAgE;QAChF,OAAO,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF;AAlCD,0EAkCC;AAED,IAAA,yBAAa,EAAC,+BAA+B,EAAE;IAC7C,kBAAM,CAAC,cAAc;IACrB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,eAAe;IACtB,kBAAM,CAAC,iBAAiB;CACzB,CAAC,CAAC"}
|
||||
238
node_modules/mongodb/lib/operations/execute_operation.js
generated
vendored
Normal file
238
node_modules/mongodb/lib/operations/execute_operation.js
generated
vendored
Normal file
|
|
@ -0,0 +1,238 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.executeOperation = executeOperation;
|
||||
exports.autoConnect = autoConnect;
|
||||
const constants_1 = require("../cmap/wire_protocol/constants");
|
||||
const error_1 = require("../error");
|
||||
const read_preference_1 = require("../read_preference");
|
||||
const server_selection_1 = require("../sdam/server_selection");
|
||||
const timeout_1 = require("../timeout");
|
||||
const utils_1 = require("../utils");
|
||||
const aggregate_1 = require("./aggregate");
|
||||
const operation_1 = require("./operation");
|
||||
const MMAPv1_RETRY_WRITES_ERROR_CODE = error_1.MONGODB_ERROR_CODES.IllegalOperation;
|
||||
const MMAPv1_RETRY_WRITES_ERROR_MESSAGE = 'This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.';
|
||||
/**
|
||||
* Executes the given operation with provided arguments.
|
||||
* @internal
|
||||
*
|
||||
* @remarks
|
||||
* Allows for a single point of entry to provide features such as implicit sessions, which
|
||||
* are required by the Driver Sessions specification in the event that a ClientSession is
|
||||
* not provided.
|
||||
*
|
||||
* The expectation is that this function:
|
||||
* - Connects the MongoClient if it has not already been connected, see {@link autoConnect}
|
||||
* - Creates a session if none is provided and cleans up the session it creates
|
||||
* - Tries an operation and retries under certain conditions, see {@link tryOperation}
|
||||
*
|
||||
* @typeParam T - The operation's type
|
||||
* @typeParam TResult - The type of the operation's result, calculated from T
|
||||
*
|
||||
* @param client - The MongoClient to execute this operation with
|
||||
* @param operation - The operation to execute
|
||||
*/
|
||||
async function executeOperation(client, operation, timeoutContext) {
|
||||
if (!(operation instanceof operation_1.AbstractOperation)) {
|
||||
// TODO(NODE-3483): Extend MongoRuntimeError
|
||||
throw new error_1.MongoRuntimeError('This method requires a valid operation instance');
|
||||
}
|
||||
const topology = client.topology == null
|
||||
? await (0, utils_1.abortable)(autoConnect(client), operation.options)
|
||||
: client.topology;
|
||||
// The driver sessions spec mandates that we implicitly create sessions for operations
|
||||
// that are not explicitly provided with a session.
|
||||
let session = operation.session;
|
||||
let owner;
|
||||
if (session == null) {
|
||||
owner = Symbol();
|
||||
session = client.startSession({ owner, explicit: false });
|
||||
}
|
||||
else if (session.hasEnded) {
|
||||
throw new error_1.MongoExpiredSessionError('Use of expired sessions is not permitted');
|
||||
}
|
||||
else if (session.snapshotEnabled &&
|
||||
(0, utils_1.maxWireVersion)(topology) < constants_1.MIN_SUPPORTED_SNAPSHOT_READS_WIRE_VERSION) {
|
||||
throw new error_1.MongoCompatibilityError('Snapshot reads require MongoDB 5.0 or later');
|
||||
}
|
||||
else if (session.client !== client) {
|
||||
throw new error_1.MongoInvalidArgumentError('ClientSession must be from the same MongoClient');
|
||||
}
|
||||
operation.session ??= session;
|
||||
const readPreference = operation.readPreference ?? read_preference_1.ReadPreference.primary;
|
||||
const inTransaction = !!session?.inTransaction();
|
||||
const hasReadAspect = operation.hasAspect(operation_1.Aspect.READ_OPERATION);
|
||||
if (inTransaction &&
|
||||
!readPreference.equals(read_preference_1.ReadPreference.primary) &&
|
||||
(hasReadAspect || operation.commandName === 'runCommand')) {
|
||||
throw new error_1.MongoTransactionError(`Read preference in a transaction must be primary, not: ${readPreference.mode}`);
|
||||
}
|
||||
if (session?.isPinned && session.transaction.isCommitted && !operation.bypassPinningCheck) {
|
||||
session.unpin();
|
||||
}
|
||||
timeoutContext ??= timeout_1.TimeoutContext.create({
|
||||
session,
|
||||
serverSelectionTimeoutMS: client.s.options.serverSelectionTimeoutMS,
|
||||
waitQueueTimeoutMS: client.s.options.waitQueueTimeoutMS,
|
||||
timeoutMS: operation.options.timeoutMS
|
||||
});
|
||||
try {
|
||||
return await tryOperation(operation, {
|
||||
topology,
|
||||
timeoutContext,
|
||||
session,
|
||||
readPreference
|
||||
});
|
||||
}
|
||||
finally {
|
||||
if (session?.owner != null && session.owner === owner) {
|
||||
await session.endSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Connects a client if it has not yet been connected
|
||||
* @internal
|
||||
*/
|
||||
async function autoConnect(client) {
|
||||
if (client.topology == null) {
|
||||
if (client.s.hasBeenClosed) {
|
||||
throw new error_1.MongoNotConnectedError('Client must be connected before running operations');
|
||||
}
|
||||
client.s.options.__skipPingOnConnect = true;
|
||||
try {
|
||||
await client.connect();
|
||||
if (client.topology == null) {
|
||||
throw new error_1.MongoRuntimeError('client.connect did not create a topology but also did not throw');
|
||||
}
|
||||
return client.topology;
|
||||
}
|
||||
finally {
|
||||
delete client.s.options.__skipPingOnConnect;
|
||||
}
|
||||
}
|
||||
return client.topology;
|
||||
}
|
||||
/**
|
||||
* Executes an operation and retries as appropriate
|
||||
* @internal
|
||||
*
|
||||
* @remarks
|
||||
* Implements behaviour described in [Retryable Reads](https://github.com/mongodb/specifications/blob/master/source/retryable-reads/retryable-reads.md) and [Retryable
|
||||
* Writes](https://github.com/mongodb/specifications/blob/master/source/retryable-writes/retryable-writes.md) specification
|
||||
*
|
||||
* This function:
|
||||
* - performs initial server selection
|
||||
* - attempts to execute an operation
|
||||
* - retries the operation if it meets the criteria for a retryable read or a retryable write
|
||||
*
|
||||
* @typeParam T - The operation's type
|
||||
* @typeParam TResult - The type of the operation's result, calculated from T
|
||||
*
|
||||
* @param operation - The operation to execute
|
||||
* */
|
||||
async function tryOperation(operation, { topology, timeoutContext, session, readPreference }) {
|
||||
let selector;
|
||||
if (operation.hasAspect(operation_1.Aspect.MUST_SELECT_SAME_SERVER)) {
|
||||
// GetMore and KillCursor operations must always select the same server, but run through
|
||||
// server selection to potentially force monitor checks if the server is
|
||||
// in an unknown state.
|
||||
selector = (0, server_selection_1.sameServerSelector)(operation.server?.description);
|
||||
}
|
||||
else if (operation instanceof aggregate_1.AggregateOperation && operation.hasWriteStage) {
|
||||
// If operation should try to write to secondary use the custom server selector
|
||||
// otherwise provide the read preference.
|
||||
selector = (0, server_selection_1.secondaryWritableServerSelector)(topology.commonWireVersion, readPreference);
|
||||
}
|
||||
else {
|
||||
selector = readPreference;
|
||||
}
|
||||
let server = await topology.selectServer(selector, {
|
||||
session,
|
||||
operationName: operation.commandName,
|
||||
timeoutContext,
|
||||
signal: operation.options.signal
|
||||
});
|
||||
const hasReadAspect = operation.hasAspect(operation_1.Aspect.READ_OPERATION);
|
||||
const hasWriteAspect = operation.hasAspect(operation_1.Aspect.WRITE_OPERATION);
|
||||
const inTransaction = session?.inTransaction() ?? false;
|
||||
const willRetryRead = topology.s.options.retryReads && !inTransaction && operation.canRetryRead;
|
||||
const willRetryWrite = topology.s.options.retryWrites &&
|
||||
!inTransaction &&
|
||||
(0, utils_1.supportsRetryableWrites)(server) &&
|
||||
operation.canRetryWrite;
|
||||
const willRetry = operation.hasAspect(operation_1.Aspect.RETRYABLE) &&
|
||||
session != null &&
|
||||
((hasReadAspect && willRetryRead) || (hasWriteAspect && willRetryWrite));
|
||||
if (hasWriteAspect && willRetryWrite && session != null) {
|
||||
operation.options.willRetryWrite = true;
|
||||
session.incrementTransactionNumber();
|
||||
}
|
||||
const maxTries = willRetry ? (timeoutContext.csotEnabled() ? Infinity : 2) : 1;
|
||||
let previousOperationError;
|
||||
let previousServer;
|
||||
for (let tries = 0; tries < maxTries; tries++) {
|
||||
if (previousOperationError) {
|
||||
if (hasWriteAspect && previousOperationError.code === MMAPv1_RETRY_WRITES_ERROR_CODE) {
|
||||
throw new error_1.MongoServerError({
|
||||
message: MMAPv1_RETRY_WRITES_ERROR_MESSAGE,
|
||||
errmsg: MMAPv1_RETRY_WRITES_ERROR_MESSAGE,
|
||||
originalError: previousOperationError
|
||||
});
|
||||
}
|
||||
if (operation.hasAspect(operation_1.Aspect.COMMAND_BATCHING) && !operation.canRetryWrite) {
|
||||
throw previousOperationError;
|
||||
}
|
||||
if (hasWriteAspect && !(0, error_1.isRetryableWriteError)(previousOperationError))
|
||||
throw previousOperationError;
|
||||
if (hasReadAspect && !(0, error_1.isRetryableReadError)(previousOperationError)) {
|
||||
throw previousOperationError;
|
||||
}
|
||||
if (previousOperationError instanceof error_1.MongoNetworkError &&
|
||||
operation.hasAspect(operation_1.Aspect.CURSOR_CREATING) &&
|
||||
session != null &&
|
||||
session.isPinned &&
|
||||
!session.inTransaction()) {
|
||||
session.unpin({ force: true, forceClear: true });
|
||||
}
|
||||
server = await topology.selectServer(selector, {
|
||||
session,
|
||||
operationName: operation.commandName,
|
||||
previousServer,
|
||||
signal: operation.options.signal
|
||||
});
|
||||
if (hasWriteAspect && !(0, utils_1.supportsRetryableWrites)(server)) {
|
||||
throw new error_1.MongoUnexpectedServerResponseError('Selected server does not support retryable writes');
|
||||
}
|
||||
}
|
||||
operation.server = server;
|
||||
try {
|
||||
// If tries > 0 and we are command batching we need to reset the batch.
|
||||
if (tries > 0 && operation.hasAspect(operation_1.Aspect.COMMAND_BATCHING)) {
|
||||
operation.resetBatch();
|
||||
}
|
||||
try {
|
||||
const result = await server.command(operation, timeoutContext);
|
||||
return operation.handleOk(result);
|
||||
}
|
||||
catch (error) {
|
||||
return operation.handleError(error);
|
||||
}
|
||||
}
|
||||
catch (operationError) {
|
||||
if (!(operationError instanceof error_1.MongoError))
|
||||
throw operationError;
|
||||
if (previousOperationError != null &&
|
||||
operationError.hasErrorLabel(error_1.MongoErrorLabel.NoWritesPerformed)) {
|
||||
throw previousOperationError;
|
||||
}
|
||||
previousServer = server.description;
|
||||
previousOperationError = operationError;
|
||||
// Reset timeouts
|
||||
timeoutContext.clear();
|
||||
}
|
||||
}
|
||||
throw (previousOperationError ??
|
||||
new error_1.MongoRuntimeError('Tried to propagate retryability error, but no error was found.'));
|
||||
}
|
||||
//# sourceMappingURL=execute_operation.js.map
|
||||
1
node_modules/mongodb/lib/operations/execute_operation.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/execute_operation.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
148
node_modules/mongodb/lib/operations/find.js
generated
vendored
Normal file
148
node_modules/mongodb/lib/operations/find.js
generated
vendored
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FindOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../error");
|
||||
const sort_1 = require("../sort");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class FindOperation extends command_1.CommandOperation {
|
||||
constructor(ns, filter = {}, options = {}) {
|
||||
super(undefined, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.CursorResponse;
|
||||
this.options = { ...options };
|
||||
delete this.options.writeConcern;
|
||||
this.ns = ns;
|
||||
if (typeof filter !== 'object' || Array.isArray(filter)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Query filter must be a plain object or ObjectId');
|
||||
}
|
||||
// special case passing in an ObjectId as a filter
|
||||
this.filter = filter != null && filter._bsontype === 'ObjectId' ? { _id: filter } : filter;
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = this.explain ? responses_1.ExplainedCursorResponse : responses_1.CursorResponse;
|
||||
}
|
||||
get commandName() {
|
||||
return 'find';
|
||||
}
|
||||
buildOptions(timeoutContext) {
|
||||
return {
|
||||
...this.options,
|
||||
...this.bsonOptions,
|
||||
documentsReturnedIn: 'firstBatch',
|
||||
session: this.session,
|
||||
timeoutContext
|
||||
};
|
||||
}
|
||||
handleOk(response) {
|
||||
return response;
|
||||
}
|
||||
buildCommandDocument() {
|
||||
return makeFindCommand(this.ns, this.filter, this.options);
|
||||
}
|
||||
}
|
||||
exports.FindOperation = FindOperation;
|
||||
function makeFindCommand(ns, filter, options) {
|
||||
const findCommand = {
|
||||
find: ns.collection,
|
||||
filter
|
||||
};
|
||||
if (options.sort) {
|
||||
findCommand.sort = (0, sort_1.formatSort)(options.sort);
|
||||
}
|
||||
if (options.projection) {
|
||||
let projection = options.projection;
|
||||
if (projection && Array.isArray(projection)) {
|
||||
projection = projection.length
|
||||
? projection.reduce((result, field) => {
|
||||
result[field] = 1;
|
||||
return result;
|
||||
}, {})
|
||||
: { _id: 1 };
|
||||
}
|
||||
findCommand.projection = projection;
|
||||
}
|
||||
if (options.hint) {
|
||||
findCommand.hint = (0, utils_1.normalizeHintField)(options.hint);
|
||||
}
|
||||
if (typeof options.skip === 'number') {
|
||||
findCommand.skip = options.skip;
|
||||
}
|
||||
if (typeof options.limit === 'number') {
|
||||
if (options.limit < 0) {
|
||||
findCommand.limit = -options.limit;
|
||||
findCommand.singleBatch = true;
|
||||
}
|
||||
else {
|
||||
findCommand.limit = options.limit;
|
||||
}
|
||||
}
|
||||
if (typeof options.batchSize === 'number') {
|
||||
if (options.batchSize < 0) {
|
||||
findCommand.limit = -options.batchSize;
|
||||
}
|
||||
else {
|
||||
if (options.batchSize === options.limit) {
|
||||
// Spec dictates that if these are equal the batchSize should be one more than the
|
||||
// limit to avoid leaving the cursor open.
|
||||
findCommand.batchSize = options.batchSize + 1;
|
||||
}
|
||||
else {
|
||||
findCommand.batchSize = options.batchSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof options.singleBatch === 'boolean') {
|
||||
findCommand.singleBatch = options.singleBatch;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (options.comment !== undefined) {
|
||||
findCommand.comment = options.comment;
|
||||
}
|
||||
if (options.max) {
|
||||
findCommand.max = options.max;
|
||||
}
|
||||
if (options.min) {
|
||||
findCommand.min = options.min;
|
||||
}
|
||||
if (typeof options.returnKey === 'boolean') {
|
||||
findCommand.returnKey = options.returnKey;
|
||||
}
|
||||
if (typeof options.showRecordId === 'boolean') {
|
||||
findCommand.showRecordId = options.showRecordId;
|
||||
}
|
||||
if (typeof options.tailable === 'boolean') {
|
||||
findCommand.tailable = options.tailable;
|
||||
}
|
||||
if (typeof options.oplogReplay === 'boolean') {
|
||||
findCommand.oplogReplay = options.oplogReplay;
|
||||
}
|
||||
if (typeof options.timeout === 'boolean') {
|
||||
findCommand.noCursorTimeout = !options.timeout;
|
||||
}
|
||||
else if (typeof options.noCursorTimeout === 'boolean') {
|
||||
findCommand.noCursorTimeout = options.noCursorTimeout;
|
||||
}
|
||||
if (typeof options.awaitData === 'boolean') {
|
||||
findCommand.awaitData = options.awaitData;
|
||||
}
|
||||
if (typeof options.allowPartialResults === 'boolean') {
|
||||
findCommand.allowPartialResults = options.allowPartialResults;
|
||||
}
|
||||
if (typeof options.allowDiskUse === 'boolean') {
|
||||
findCommand.allowDiskUse = options.allowDiskUse;
|
||||
}
|
||||
if (options.let) {
|
||||
findCommand.let = options.let;
|
||||
}
|
||||
return findCommand;
|
||||
}
|
||||
(0, operation_1.defineAspects)(FindOperation, [
|
||||
operation_1.Aspect.READ_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.CURSOR_CREATING,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
//# sourceMappingURL=find.js.map
|
||||
1
node_modules/mongodb/lib/operations/find.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/find.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../src/operations/find.ts"],"names":[],"mappings":";;;AACA,+DAA0F;AAE1F,oCAAqD;AAGrD,kCAAgD;AAEhD,oCAAqE;AACrE,uCAAkG;AAClG,2CAA+D;AAoE/D,gBAAgB;AAChB,MAAa,aAAc,SAAQ,0BAAgC;IAajE,YAAY,EAAoB,EAAE,SAAmB,EAAE,EAAE,UAAuB,EAAE;QAChF,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAbnB,iCAA4B,GAAG,0BAAc,CAAC;QAerD,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QACjC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QAEb,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,iCAAyB,CAAC,iDAAiD,CAAC,CAAC;QACzF,CAAC;QAED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AAC,OAAO,CAAC;IACjD,CAAC;SAAM,IAAI,OAAO,OAAO,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QACxD,WAAW,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IACxD,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC3C,WAAW,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAC5C,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,mBAAmB,KAAK,SAAS,EAAE,CAAC;QACrD,WAAW,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAChE,CAAC;IACD,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QAC9C,WAAW,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAClD,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,WAAW,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAChC,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,IAAA,yBAAa,EAAC,aAAa,EAAE;IAC3B,kBAAM,CAAC,cAAc;IACrB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,WAAW;IAClB,kBAAM,CAAC,eAAe;IACtB,kBAAM,CAAC,iBAAiB;CACzB,CAAC,CAAC"}
|
||||
158
node_modules/mongodb/lib/operations/find_and_modify.js
generated
vendored
Normal file
158
node_modules/mongodb/lib/operations/find_and_modify.js
generated
vendored
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FindOneAndUpdateOperation = exports.FindOneAndReplaceOperation = exports.FindOneAndDeleteOperation = exports.FindAndModifyOperation = exports.ReturnDocument = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../error");
|
||||
const read_preference_1 = require("../read_preference");
|
||||
const sort_1 = require("../sort");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @public */
|
||||
exports.ReturnDocument = Object.freeze({
|
||||
BEFORE: 'before',
|
||||
AFTER: 'after'
|
||||
});
|
||||
function configureFindAndModifyCmdBaseUpdateOpts(cmdBase, options) {
|
||||
cmdBase.new = options.returnDocument === exports.ReturnDocument.AFTER;
|
||||
cmdBase.upsert = options.upsert === true;
|
||||
if (options.bypassDocumentValidation === true) {
|
||||
cmdBase.bypassDocumentValidation = options.bypassDocumentValidation;
|
||||
}
|
||||
return cmdBase;
|
||||
}
|
||||
/** @internal */
|
||||
class FindAndModifyOperation extends command_1.CommandOperation {
|
||||
constructor(collection, query, options) {
|
||||
super(collection, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options;
|
||||
// force primary read preference
|
||||
this.readPreference = read_preference_1.ReadPreference.primary;
|
||||
this.collection = collection;
|
||||
this.query = query;
|
||||
}
|
||||
get commandName() {
|
||||
return 'findAndModify';
|
||||
}
|
||||
buildCommandDocument(connection, _session) {
|
||||
const options = this.options;
|
||||
const command = {
|
||||
findAndModify: this.collection.collectionName,
|
||||
query: this.query,
|
||||
remove: false,
|
||||
new: false,
|
||||
upsert: false
|
||||
};
|
||||
options.includeResultMetadata ??= false;
|
||||
const sort = (0, sort_1.formatSort)(options.sort);
|
||||
if (sort) {
|
||||
command.sort = sort;
|
||||
}
|
||||
if (options.projection) {
|
||||
command.fields = options.projection;
|
||||
}
|
||||
if (options.maxTimeMS) {
|
||||
command.maxTimeMS = options.maxTimeMS;
|
||||
}
|
||||
// Decorate the findAndModify command with the write Concern
|
||||
if (options.writeConcern) {
|
||||
command.writeConcern = options.writeConcern;
|
||||
}
|
||||
if (options.let) {
|
||||
command.let = options.let;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (options.comment !== undefined) {
|
||||
command.comment = options.comment;
|
||||
}
|
||||
(0, utils_1.decorateWithCollation)(command, options);
|
||||
if (options.hint) {
|
||||
const unacknowledgedWrite = this.writeConcern?.w === 0;
|
||||
if (unacknowledgedWrite && (0, utils_1.maxWireVersion)(connection) < 9) {
|
||||
throw new error_1.MongoCompatibilityError('hint for the findAndModify command is only supported on MongoDB 4.4+');
|
||||
}
|
||||
command.hint = options.hint;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
handleOk(response) {
|
||||
const result = super.handleOk(response);
|
||||
return this.options.includeResultMetadata ? result : (result.value ?? null);
|
||||
}
|
||||
}
|
||||
exports.FindAndModifyOperation = FindAndModifyOperation;
|
||||
/** @internal */
|
||||
class FindOneAndDeleteOperation extends FindAndModifyOperation {
|
||||
constructor(collection, filter, options) {
|
||||
// Basic validation
|
||||
if (filter == null || typeof filter !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Argument "filter" must be an object');
|
||||
}
|
||||
super(collection, filter, options);
|
||||
}
|
||||
buildCommandDocument(connection, session) {
|
||||
const document = super.buildCommandDocument(connection, session);
|
||||
document.remove = true;
|
||||
return document;
|
||||
}
|
||||
}
|
||||
exports.FindOneAndDeleteOperation = FindOneAndDeleteOperation;
|
||||
/** @internal */
|
||||
class FindOneAndReplaceOperation extends FindAndModifyOperation {
|
||||
constructor(collection, filter, replacement, options) {
|
||||
if (filter == null || typeof filter !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Argument "filter" must be an object');
|
||||
}
|
||||
if (replacement == null || typeof replacement !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Argument "replacement" must be an object');
|
||||
}
|
||||
if ((0, utils_1.hasAtomicOperators)(replacement)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Replacement document must not contain atomic operators');
|
||||
}
|
||||
super(collection, filter, options);
|
||||
this.replacement = replacement;
|
||||
}
|
||||
buildCommandDocument(connection, session) {
|
||||
const document = super.buildCommandDocument(connection, session);
|
||||
document.update = this.replacement;
|
||||
configureFindAndModifyCmdBaseUpdateOpts(document, this.options);
|
||||
return document;
|
||||
}
|
||||
}
|
||||
exports.FindOneAndReplaceOperation = FindOneAndReplaceOperation;
|
||||
/** @internal */
|
||||
class FindOneAndUpdateOperation extends FindAndModifyOperation {
|
||||
constructor(collection, filter, update, options) {
|
||||
if (filter == null || typeof filter !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Argument "filter" must be an object');
|
||||
}
|
||||
if (update == null || typeof update !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Argument "update" must be an object');
|
||||
}
|
||||
if (!(0, utils_1.hasAtomicOperators)(update, options)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Update document requires atomic operators');
|
||||
}
|
||||
super(collection, filter, options);
|
||||
this.update = update;
|
||||
this.options = options;
|
||||
}
|
||||
buildCommandDocument(connection, session) {
|
||||
const document = super.buildCommandDocument(connection, session);
|
||||
document.update = this.update;
|
||||
configureFindAndModifyCmdBaseUpdateOpts(document, this.options);
|
||||
if (this.options.arrayFilters) {
|
||||
document.arrayFilters = this.options.arrayFilters;
|
||||
}
|
||||
return document;
|
||||
}
|
||||
}
|
||||
exports.FindOneAndUpdateOperation = FindOneAndUpdateOperation;
|
||||
(0, operation_1.defineAspects)(FindAndModifyOperation, [
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
//# sourceMappingURL=find_and_modify.js.map
|
||||
1
node_modules/mongodb/lib/operations/find_and_modify.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/find_and_modify.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"find_and_modify.js","sourceRoot":"","sources":["../../src/operations/find_and_modify.ts"],"names":[],"mappings":";;;AAEA,+DAAkE;AAElE,oCAA8E;AAC9E,w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oBAAoB,CAC3B,UAAsB,EACtB,OAAuB;QAEvB,MAAM,QAAQ,GAAG,KAAK,CAAC,oBAAoB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACjE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC9B,uCAAuC,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAEhE,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;YAC9B,QAAQ,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QACpD,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAzCD,8DAyCC;AAED,IAAA,yBAAa,EAAC,sBAAsB,EAAE;IACpC,kBAAM,CAAC,eAAe;IACtB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,WAAW;IAClB,kBAAM,CAAC,iBAAiB;CACzB,CAAC,CAAC"}
|
||||
62
node_modules/mongodb/lib/operations/get_more.js
generated
vendored
Normal file
62
node_modules/mongodb/lib/operations/get_more.js
generated
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GetMoreOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../error");
|
||||
const utils_1 = require("../utils");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class GetMoreOperation extends operation_1.AbstractOperation {
|
||||
constructor(ns, cursorId, server, options) {
|
||||
super(options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.CursorResponse;
|
||||
this.options = options;
|
||||
this.ns = ns;
|
||||
this.cursorId = cursorId;
|
||||
this.server = server;
|
||||
}
|
||||
get commandName() {
|
||||
return 'getMore';
|
||||
}
|
||||
buildCommand(connection) {
|
||||
if (this.cursorId == null || this.cursorId.isZero()) {
|
||||
throw new error_1.MongoRuntimeError('Unable to iterate cursor with no id');
|
||||
}
|
||||
const collection = this.ns.collection;
|
||||
if (collection == null) {
|
||||
// Cursors should have adopted the namespace returned by MongoDB
|
||||
// which should always defined a collection name (even a pseudo one, ex. db.aggregate())
|
||||
throw new error_1.MongoRuntimeError('A collection name must be determined before getMore');
|
||||
}
|
||||
const getMoreCmd = {
|
||||
getMore: this.cursorId,
|
||||
collection
|
||||
};
|
||||
if (typeof this.options.batchSize === 'number') {
|
||||
getMoreCmd.batchSize = Math.abs(this.options.batchSize);
|
||||
}
|
||||
if (typeof this.options.maxAwaitTimeMS === 'number') {
|
||||
getMoreCmd.maxTimeMS = this.options.maxAwaitTimeMS;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (this.options.comment !== undefined && (0, utils_1.maxWireVersion)(connection) >= 9) {
|
||||
getMoreCmd.comment = this.options.comment;
|
||||
}
|
||||
return getMoreCmd;
|
||||
}
|
||||
buildOptions(timeoutContext) {
|
||||
return {
|
||||
returnFieldSelector: null,
|
||||
documentsReturnedIn: 'nextBatch',
|
||||
timeoutContext,
|
||||
...this.options
|
||||
};
|
||||
}
|
||||
handleOk(response) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
exports.GetMoreOperation = GetMoreOperation;
|
||||
(0, operation_1.defineAspects)(GetMoreOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.MUST_SELECT_SAME_SERVER]);
|
||||
//# sourceMappingURL=get_more.js.map
|
||||
1
node_modules/mongodb/lib/operations/get_more.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/get_more.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"get_more.js","sourceRoot":"","sources":["../../src/operations/get_more.ts"],"names":[],"mappings":";;;AAEA,+DAAiE;AACjE,oCAA6C;AAG7C,oCAAiE;AACjE,2CAA8F;AA+B9F,gBAAgB;AAChB,MAAa,gBAAiB,SAAQ,6BAAiC;IAKr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O,KAAK,SAAS,IAAI,IAAA,sBAAc,EAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1E,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAC5C,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAEQ,YAAY,CAAC,cAA8B;QAClD,OAAO;YACL,mBAAmB,EAAE,IAAI;YACzB,mBAAmB,EAAE,WAAW;YAChC,cAAc;YACd,GAAG,IAAI,CAAC,OAAO;SAChB,CAAC;IACJ,CAAC;IAEQ,QAAQ,CACf,QAAgE;QAEhE,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAlED,4CAkEC;AAED,IAAA,yBAAa,EAAC,gBAAgB,EAAE,CAAC,kBAAM,CAAC,cAAc,EAAE,kBAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC"}
|
||||
186
node_modules/mongodb/lib/operations/indexes.js
generated
vendored
Normal file
186
node_modules/mongodb/lib/operations/indexes.js
generated
vendored
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ListIndexesOperation = exports.DropIndexOperation = exports.CreateIndexesOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../error");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
const VALID_INDEX_OPTIONS = new Set([
|
||||
'background',
|
||||
'unique',
|
||||
'name',
|
||||
'partialFilterExpression',
|
||||
'sparse',
|
||||
'hidden',
|
||||
'expireAfterSeconds',
|
||||
'storageEngine',
|
||||
'collation',
|
||||
'version',
|
||||
// text indexes
|
||||
'weights',
|
||||
'default_language',
|
||||
'language_override',
|
||||
'textIndexVersion',
|
||||
// 2d-sphere indexes
|
||||
'2dsphereIndexVersion',
|
||||
// 2d indexes
|
||||
'bits',
|
||||
'min',
|
||||
'max',
|
||||
// geoHaystack Indexes
|
||||
'bucketSize',
|
||||
// wildcard indexes
|
||||
'wildcardProjection'
|
||||
]);
|
||||
function isIndexDirection(x) {
|
||||
return (typeof x === 'number' || x === '2d' || x === '2dsphere' || x === 'text' || x === 'geoHaystack');
|
||||
}
|
||||
function isSingleIndexTuple(t) {
|
||||
return Array.isArray(t) && t.length === 2 && isIndexDirection(t[1]);
|
||||
}
|
||||
/**
|
||||
* Converts an `IndexSpecification`, which can be specified in multiple formats, into a
|
||||
* valid `key` for the createIndexes command.
|
||||
*/
|
||||
function constructIndexDescriptionMap(indexSpec) {
|
||||
const key = new Map();
|
||||
const indexSpecs = !Array.isArray(indexSpec) || isSingleIndexTuple(indexSpec) ? [indexSpec] : indexSpec;
|
||||
// Iterate through array and handle different types
|
||||
for (const spec of indexSpecs) {
|
||||
if (typeof spec === 'string') {
|
||||
key.set(spec, 1);
|
||||
}
|
||||
else if (Array.isArray(spec)) {
|
||||
key.set(spec[0], spec[1] ?? 1);
|
||||
}
|
||||
else if (spec instanceof Map) {
|
||||
for (const [property, value] of spec) {
|
||||
key.set(property, value);
|
||||
}
|
||||
}
|
||||
else if ((0, utils_1.isObject)(spec)) {
|
||||
for (const [property, value] of Object.entries(spec)) {
|
||||
key.set(property, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return key;
|
||||
}
|
||||
/**
|
||||
* Receives an index description and returns a modified index description which has had invalid options removed
|
||||
* from the description and has mapped the `version` option to the `v` option.
|
||||
*/
|
||||
function resolveIndexDescription(description) {
|
||||
const validProvidedOptions = Object.entries(description).filter(([optionName]) => VALID_INDEX_OPTIONS.has(optionName));
|
||||
return Object.fromEntries(
|
||||
// we support the `version` option, but the `createIndexes` command expects it to be the `v`
|
||||
validProvidedOptions.map(([name, value]) => (name === 'version' ? ['v', value] : [name, value])));
|
||||
}
|
||||
/** @internal */
|
||||
class CreateIndexesOperation extends command_1.CommandOperation {
|
||||
constructor(parent, collectionName, indexes, options) {
|
||||
super(parent, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options ?? {};
|
||||
// collation is set on each index, it should not be defined at the root
|
||||
this.options.collation = undefined;
|
||||
this.collectionName = collectionName;
|
||||
this.indexes = indexes.map((userIndex) => {
|
||||
// Ensure the key is a Map to preserve index key ordering
|
||||
const key = userIndex.key instanceof Map ? userIndex.key : new Map(Object.entries(userIndex.key));
|
||||
const name = userIndex.name ?? Array.from(key).flat().join('_');
|
||||
const validIndexOptions = resolveIndexDescription(userIndex);
|
||||
return {
|
||||
...validIndexOptions,
|
||||
name,
|
||||
key
|
||||
};
|
||||
});
|
||||
this.ns = parent.s.namespace;
|
||||
}
|
||||
static fromIndexDescriptionArray(parent, collectionName, indexes, options) {
|
||||
return new CreateIndexesOperation(parent, collectionName, indexes, options);
|
||||
}
|
||||
static fromIndexSpecification(parent, collectionName, indexSpec, options = {}) {
|
||||
const key = constructIndexDescriptionMap(indexSpec);
|
||||
const description = { ...options, key };
|
||||
return new CreateIndexesOperation(parent, collectionName, [description], options);
|
||||
}
|
||||
get commandName() {
|
||||
return 'createIndexes';
|
||||
}
|
||||
buildCommandDocument(connection) {
|
||||
const options = this.options;
|
||||
const indexes = this.indexes;
|
||||
const serverWireVersion = (0, utils_1.maxWireVersion)(connection);
|
||||
const cmd = { createIndexes: this.collectionName, indexes };
|
||||
if (options.commitQuorum != null) {
|
||||
if (serverWireVersion < 9) {
|
||||
throw new error_1.MongoCompatibilityError('Option `commitQuorum` for `createIndexes` not supported on servers < 4.4');
|
||||
}
|
||||
cmd.commitQuorum = options.commitQuorum;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
handleOk(_response) {
|
||||
const indexNames = this.indexes.map(index => index.name || '');
|
||||
return indexNames;
|
||||
}
|
||||
}
|
||||
exports.CreateIndexesOperation = CreateIndexesOperation;
|
||||
/** @internal */
|
||||
class DropIndexOperation extends command_1.CommandOperation {
|
||||
constructor(collection, indexName, options) {
|
||||
super(collection, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options ?? {};
|
||||
this.collection = collection;
|
||||
this.indexName = indexName;
|
||||
this.ns = collection.fullNamespace;
|
||||
}
|
||||
get commandName() {
|
||||
return 'dropIndexes';
|
||||
}
|
||||
buildCommandDocument(_connection) {
|
||||
return { dropIndexes: this.collection.collectionName, index: this.indexName };
|
||||
}
|
||||
}
|
||||
exports.DropIndexOperation = DropIndexOperation;
|
||||
/** @internal */
|
||||
class ListIndexesOperation extends command_1.CommandOperation {
|
||||
constructor(collection, options) {
|
||||
super(collection, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.CursorResponse;
|
||||
this.options = { ...options };
|
||||
delete this.options.writeConcern;
|
||||
this.collectionNamespace = collection.s.namespace;
|
||||
}
|
||||
get commandName() {
|
||||
return 'listIndexes';
|
||||
}
|
||||
buildCommandDocument(connection) {
|
||||
const serverWireVersion = (0, utils_1.maxWireVersion)(connection);
|
||||
const cursor = this.options.batchSize ? { batchSize: this.options.batchSize } : {};
|
||||
const command = { listIndexes: this.collectionNamespace.collection, cursor };
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (serverWireVersion >= 9 && this.options.comment !== undefined) {
|
||||
command.comment = this.options.comment;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
handleOk(response) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
exports.ListIndexesOperation = ListIndexesOperation;
|
||||
(0, operation_1.defineAspects)(ListIndexesOperation, [
|
||||
operation_1.Aspect.READ_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.CURSOR_CREATING,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
(0, operation_1.defineAspects)(CreateIndexesOperation, [operation_1.Aspect.WRITE_OPERATION, operation_1.Aspect.SUPPORTS_RAW_DATA]);
|
||||
(0, operation_1.defineAspects)(DropIndexOperation, [operation_1.Aspect.WRITE_OPERATION, operation_1.Aspect.SUPPORTS_RAW_DATA]);
|
||||
//# sourceMappingURL=indexes.js.map
|
||||
1
node_modules/mongodb/lib/operations/indexes.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/indexes.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
70
node_modules/mongodb/lib/operations/insert.js
generated
vendored
Normal file
70
node_modules/mongodb/lib/operations/insert.js
generated
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.InsertOneOperation = exports.InsertOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../error");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class InsertOperation extends command_1.CommandOperation {
|
||||
constructor(ns, documents, options) {
|
||||
super(undefined, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = { ...options, checkKeys: options.checkKeys ?? false };
|
||||
this.ns = ns;
|
||||
this.documents = documents;
|
||||
}
|
||||
get commandName() {
|
||||
return 'insert';
|
||||
}
|
||||
buildCommandDocument(_connection, _session) {
|
||||
const options = this.options ?? {};
|
||||
const ordered = typeof options.ordered === 'boolean' ? options.ordered : true;
|
||||
const command = {
|
||||
insert: this.ns.collection,
|
||||
documents: this.documents,
|
||||
ordered
|
||||
};
|
||||
if (typeof options.bypassDocumentValidation === 'boolean') {
|
||||
command.bypassDocumentValidation = options.bypassDocumentValidation;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (options.comment !== undefined) {
|
||||
command.comment = options.comment;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
}
|
||||
exports.InsertOperation = InsertOperation;
|
||||
class InsertOneOperation extends InsertOperation {
|
||||
constructor(collection, doc, options) {
|
||||
super(collection.s.namespace, [(0, utils_1.maybeAddIdToDocuments)(collection, doc, options)], options);
|
||||
}
|
||||
handleOk(response) {
|
||||
const res = super.handleOk(response);
|
||||
if (res.code)
|
||||
throw new error_1.MongoServerError(res);
|
||||
if (res.writeErrors) {
|
||||
// This should be a WriteError but we can't change it now because of error hierarchy
|
||||
throw new error_1.MongoServerError(res.writeErrors[0]);
|
||||
}
|
||||
return {
|
||||
acknowledged: this.writeConcern?.w !== 0,
|
||||
insertedId: this.documents[0]._id
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.InsertOneOperation = InsertOneOperation;
|
||||
(0, operation_1.defineAspects)(InsertOperation, [
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
(0, operation_1.defineAspects)(InsertOneOperation, [
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
//# sourceMappingURL=insert.js.map
|
||||
1
node_modules/mongodb/lib/operations/insert.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/insert.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"insert.js","sourceRoot":"","sources":["../../src/operations/insert.ts"],"names":[],"mappings":";;;AAGA,+DAAkE;AAElE,oCAA4C;AAG5C,oCAAwE;AACxE,uCAA2E;AAC3E,2CAAoD;AACpD,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,0BAA0B;IAM7D,YAAY,EAAoB,EAAE,SAAqB,EAAE,OAAyB;QAChF,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QANnB,iCAA4B,GAAG,2BAAe,CAAC;QAOtD,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,IA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AC,IAAI;YAAE,MAAM,IAAI,wBAAgB,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;YACpB,oFAAoF;YACpF,MAAM,IAAI,wBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,CAAC;QAED,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC;YACxC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG;SAClC,CAAC;IACJ,CAAC;CACF;AAlBD,gDAkBC;AAYD,IAAA,yBAAa,EAAC,eAAe,EAAE;IAC7B,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,eAAe;IACtB,kBAAM,CAAC,iBAAiB;CACzB,CAAC,CAAC;AACH,IAAA,yBAAa,EAAC,kBAAkB,EAAE;IAChC,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,eAAe;IACtB,kBAAM,CAAC,iBAAiB;CACzB,CAAC,CAAC"}
|
||||
43
node_modules/mongodb/lib/operations/kill_cursors.js
generated
vendored
Normal file
43
node_modules/mongodb/lib/operations/kill_cursors.js
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.KillCursorsOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../error");
|
||||
const operation_1 = require("./operation");
|
||||
class KillCursorsOperation extends operation_1.AbstractOperation {
|
||||
constructor(cursorId, ns, server, options) {
|
||||
super(options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.ns = ns;
|
||||
this.cursorId = cursorId;
|
||||
this.server = server;
|
||||
}
|
||||
get commandName() {
|
||||
return 'killCursors';
|
||||
}
|
||||
buildCommand(_connection, _session) {
|
||||
const killCursors = this.ns.collection;
|
||||
if (killCursors == null) {
|
||||
// Cursors should have adopted the namespace returned by MongoDB
|
||||
// which should always defined a collection name (even a pseudo one, ex. db.aggregate())
|
||||
throw new error_1.MongoRuntimeError('A collection name must be determined before killCursors');
|
||||
}
|
||||
const killCursorsCommand = {
|
||||
killCursors,
|
||||
cursors: [this.cursorId]
|
||||
};
|
||||
return killCursorsCommand;
|
||||
}
|
||||
buildOptions(timeoutContext) {
|
||||
return {
|
||||
session: this.session,
|
||||
timeoutContext
|
||||
};
|
||||
}
|
||||
handleError(_error) {
|
||||
// The driver should never emit errors from killCursors, this is spec-ed behavior
|
||||
}
|
||||
}
|
||||
exports.KillCursorsOperation = KillCursorsOperation;
|
||||
(0, operation_1.defineAspects)(KillCursorsOperation, [operation_1.Aspect.MUST_SELECT_SAME_SERVER]);
|
||||
//# sourceMappingURL=kill_cursors.js.map
|
||||
1
node_modules/mongodb/lib/operations/kill_cursors.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/kill_cursors.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"kill_cursors.js","sourceRoot":"","sources":["../../src/operations/kill_cursors.ts"],"names":[],"mappings":";;;AAEA,+DAAkE;AAClE,oCAA8D;AAK9D,2CAA8F;AAY9F,MAAa,oBAAqB,SAAQ,6BAAuB;IAI/D,YAAY,QAAc,EAAE,EAAoB,EAAE,MAAc,EAAE,OAAyB;QACzF,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,iCAA4B,GAAG,2BAAe,CAAC;QAKtD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,aAAsB,CAAC;IAChC,CAAC;IAEQ,YAAY,CAAC,WAAuB,EAAE,QAAwB;QACrE,MAAM,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC;QACvC,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;YACxB,gEAAgE;YAChE,wFAAwF;YACxF,MAAM,IAAI,yBAAiB,CAAC,yDAAyD,CAAC,CAAC;QACzF,CAAC;QAED,MAAM,kBAAkB,GAAuB;YAC7C,WAAW;YACX,OAAO,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;SACzB,CAAC;QAEF,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAEQ,YAAY,CAAC,cAA8B;QAClD,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,cAAc;SACf,CAAC;IACJ,CAAC;IAEQ,WAAW,CAAC,MAAkB;QACrC,iFAAiF;IACnF,CAAC;CACF;AAzCD,oDAyCC;AAED,IAAA,yBAAa,EAAC,oBAAoB,EAAE,CAAC,kBAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC"}
|
||||
53
node_modules/mongodb/lib/operations/list_collections.js
generated
vendored
Normal file
53
node_modules/mongodb/lib/operations/list_collections.js
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ListCollectionsOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class ListCollectionsOperation extends command_1.CommandOperation {
|
||||
constructor(db, filter, options) {
|
||||
super(db, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.CursorResponse;
|
||||
this.options = { ...options };
|
||||
delete this.options.writeConcern;
|
||||
this.db = db;
|
||||
this.filter = filter;
|
||||
this.nameOnly = !!this.options.nameOnly;
|
||||
this.authorizedCollections = !!this.options.authorizedCollections;
|
||||
if (typeof this.options.batchSize === 'number') {
|
||||
this.batchSize = this.options.batchSize;
|
||||
}
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = this.explain ? responses_1.ExplainedCursorResponse : responses_1.CursorResponse;
|
||||
}
|
||||
get commandName() {
|
||||
return 'listCollections';
|
||||
}
|
||||
buildCommandDocument(connection) {
|
||||
const command = {
|
||||
listCollections: 1,
|
||||
filter: this.filter,
|
||||
cursor: this.batchSize ? { batchSize: this.batchSize } : {},
|
||||
nameOnly: this.nameOnly,
|
||||
authorizedCollections: this.authorizedCollections
|
||||
};
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if ((0, utils_1.maxWireVersion)(connection) >= 9 && this.options.comment !== undefined) {
|
||||
command.comment = this.options.comment;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
handleOk(response) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
exports.ListCollectionsOperation = ListCollectionsOperation;
|
||||
(0, operation_1.defineAspects)(ListCollectionsOperation, [
|
||||
operation_1.Aspect.READ_OPERATION,
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.CURSOR_CREATING,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
//# sourceMappingURL=list_collections.js.map
|
||||
1
node_modules/mongodb/lib/operations/list_collections.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/list_collections.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"list_collections.js","sourceRoot":"","sources":["../../src/operations/list_collections.ts"],"names":[],"mappings":";;;AAEA,+DAA0F;AAI1F,oCAA0C;AAC1C,uCAA2E;AAC3E,2CAAoD;AAmBpD,gBAAgB;AAChB,MAAa,wBAAyB,SAAQ,0BAAgC;IAgB5E,YAAY,EAAM,EAAE,MAAgB,EAAE,OAAgC;QACpE,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAhBZ,iCAA4B,GAAG,0BAAc,CAAC;QAkBrD,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAC9B,OAAO,IAAI,CAA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,CAAC;IAClB,CAAC;CACF;AA5DD,4DA4DC;AAcD,IAAA,yBAAa,EAAC,wBAAwB,EAAE;IACtC,kBAAM,CAAC,cAAc;IACrB,kBAAM,CAAC,SAAS;IAChB,kBAAM,CAAC,eAAe;IACtB,kBAAM,CAAC,iBAAiB;CACzB,CAAC,CAAC"}
|
||||
40
node_modules/mongodb/lib/operations/list_databases.js
generated
vendored
Normal file
40
node_modules/mongodb/lib/operations/list_databases.js
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ListDatabasesOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class ListDatabasesOperation extends command_1.CommandOperation {
|
||||
constructor(db, options) {
|
||||
super(db, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options ?? {};
|
||||
this.ns = new utils_1.MongoDBNamespace('admin', '$cmd');
|
||||
}
|
||||
get commandName() {
|
||||
return 'listDatabases';
|
||||
}
|
||||
buildCommandDocument(connection, _session) {
|
||||
const cmd = { listDatabases: 1 };
|
||||
if (typeof this.options.nameOnly === 'boolean') {
|
||||
cmd.nameOnly = this.options.nameOnly;
|
||||
}
|
||||
if (this.options.filter) {
|
||||
cmd.filter = this.options.filter;
|
||||
}
|
||||
if (typeof this.options.authorizedDatabases === 'boolean') {
|
||||
cmd.authorizedDatabases = this.options.authorizedDatabases;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if ((0, utils_1.maxWireVersion)(connection) >= 9 && this.options.comment !== undefined) {
|
||||
cmd.comment = this.options.comment;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
exports.ListDatabasesOperation = ListDatabasesOperation;
|
||||
(0, operation_1.defineAspects)(ListDatabasesOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.RETRYABLE]);
|
||||
//# sourceMappingURL=list_databases.js.map
|
||||
1
node_modules/mongodb/lib/operations/list_databases.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/list_databases.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"list_databases.js","sourceRoot":"","sources":["../../src/operations/list_databases.ts"],"names":[],"mappings":";;;AAEA,+DAAkE;AAGlE,oCAA4D;AAC5D,uCAA2E;AAC3E,2CAAoD;AAoBpD,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,0BAAqC;IAI/E,YAAY,EAAM,EAAE,OAA8B;QAChD,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAJZ,iCAA4B,GAAG,2BAAe,CAAC;QAKtD,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,EAAE,GAAG,IAAI,wBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,eAAwB,CAAC;IAClC,CAAC;IAEQ,oBAAoB,CAAC,UAAsB,EAAE,QAAwB;QAC5E,MAAM,GAAG,GAAa,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;QAE3C,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC/C,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QACvC,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACxB,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QACnC,CAAC;QAED,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,KAAK,SAAS,EAAE,CAAC;YAC1D,GAAG,CAAC,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;QAC7D,CAAC;QAED,iEAAiE;QACjE,gDAAgD;QAChD,IAAI,IAAA,sBAAc,EAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1E,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrC,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AArCD,wDAqCC;AAED,IAAA,yBAAa,EAAC,sBAAsB,EAAE,CAAC,kBAAM,CAAC,cAAc,EAAE,kBAAM,CAAC,SAAS,CAAC,CAAC,CAAC"}
|
||||
102
node_modules/mongodb/lib/operations/operation.js
generated
vendored
Normal file
102
node_modules/mongodb/lib/operations/operation.js
generated
vendored
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AbstractOperation = exports.Aspect = void 0;
|
||||
exports.defineAspects = defineAspects;
|
||||
const bson_1 = require("../bson");
|
||||
const read_preference_1 = require("../read_preference");
|
||||
exports.Aspect = {
|
||||
READ_OPERATION: Symbol('READ_OPERATION'),
|
||||
WRITE_OPERATION: Symbol('WRITE_OPERATION'),
|
||||
RETRYABLE: Symbol('RETRYABLE'),
|
||||
EXPLAINABLE: Symbol('EXPLAINABLE'),
|
||||
SKIP_COLLATION: Symbol('SKIP_COLLATION'),
|
||||
CURSOR_CREATING: Symbol('CURSOR_CREATING'),
|
||||
MUST_SELECT_SAME_SERVER: Symbol('MUST_SELECT_SAME_SERVER'),
|
||||
COMMAND_BATCHING: Symbol('COMMAND_BATCHING'),
|
||||
SUPPORTS_RAW_DATA: Symbol('SUPPORTS_RAW_DATA')
|
||||
};
|
||||
/**
|
||||
* This class acts as a parent class for any operation and is responsible for setting this.options,
|
||||
* as well as setting and getting a session.
|
||||
* Additionally, this class implements `hasAspect`, which determines whether an operation has
|
||||
* a specific aspect.
|
||||
* @internal
|
||||
*/
|
||||
class AbstractOperation {
|
||||
constructor(options = {}) {
|
||||
this.readPreference = this.hasAspect(exports.Aspect.WRITE_OPERATION)
|
||||
? read_preference_1.ReadPreference.primary
|
||||
: (read_preference_1.ReadPreference.fromOptions(options) ?? read_preference_1.ReadPreference.primary);
|
||||
// Pull the BSON serialize options from the already-resolved options
|
||||
this.bsonOptions = (0, bson_1.resolveBSONOptions)(options);
|
||||
this._session = options.session != null ? options.session : undefined;
|
||||
this.options = options;
|
||||
this.bypassPinningCheck = !!options.bypassPinningCheck;
|
||||
}
|
||||
hasAspect(aspect) {
|
||||
const ctor = this.constructor;
|
||||
if (ctor.aspects == null) {
|
||||
return false;
|
||||
}
|
||||
return ctor.aspects.has(aspect);
|
||||
}
|
||||
// Make sure the session is not writable from outside this class.
|
||||
get session() {
|
||||
return this._session;
|
||||
}
|
||||
set session(session) {
|
||||
this._session = session;
|
||||
}
|
||||
clearSession() {
|
||||
this._session = undefined;
|
||||
}
|
||||
resetBatch() {
|
||||
return true;
|
||||
}
|
||||
get canRetryRead() {
|
||||
return this.hasAspect(exports.Aspect.RETRYABLE) && this.hasAspect(exports.Aspect.READ_OPERATION);
|
||||
}
|
||||
get canRetryWrite() {
|
||||
return this.hasAspect(exports.Aspect.RETRYABLE) && this.hasAspect(exports.Aspect.WRITE_OPERATION);
|
||||
}
|
||||
/**
|
||||
* Given an instance of a MongoDBResponse, map the response to the correct result type. For
|
||||
* example, a `CountOperation` might map the response as follows:
|
||||
*
|
||||
* ```typescript
|
||||
* override handleOk(response: InstanceType<typeof this.SERVER_COMMAND_RESPONSE_TYPE>): TResult {
|
||||
* return response.toObject(this.bsonOptions).n ?? 0;
|
||||
* }
|
||||
*
|
||||
* // or, with type safety:
|
||||
* override handleOk(response: InstanceType<typeof this.SERVER_COMMAND_RESPONSE_TYPE>): TResult {
|
||||
* return response.getNumber('n') ?? 0;
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
handleOk(response) {
|
||||
return response.toObject(this.bsonOptions);
|
||||
}
|
||||
/**
|
||||
* Optional.
|
||||
*
|
||||
* If the operation performs error handling, such as wrapping, renaming the error, or squashing errors
|
||||
* this method can be overridden.
|
||||
*/
|
||||
handleError(error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
exports.AbstractOperation = AbstractOperation;
|
||||
function defineAspects(operation, aspects) {
|
||||
if (!Array.isArray(aspects) && !(aspects instanceof Set)) {
|
||||
aspects = [aspects];
|
||||
}
|
||||
aspects = new Set(aspects);
|
||||
Object.defineProperty(operation, 'aspects', {
|
||||
value: aspects,
|
||||
writable: false
|
||||
});
|
||||
return aspects;
|
||||
}
|
||||
//# sourceMappingURL=operation.js.map
|
||||
1
node_modules/mongodb/lib/operations/operation.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/operation.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../src/operations/operation.ts"],"names":[],"mappings":";;;AAqKA,sCAeC;AAnLD,kCAAuF;AAGvF,wDAA6E;AAMhE,QAAA,MAAM,GAAG;IACpB,cAAc,EAAE,MAAM,CAAC,gBAAgB,CAAC;IACxC,eAAe,EAAE,MAAM,CAAC,iBAAiB,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC,aAAa,CAAC;IAClC,cAAc,EAAE,MAAM,CAAC,gBAAgB,CAAC;IACxC,eAAe,EAAE,MAAM,CAAC,iBAAiB,CAAC;IAC1C,uBAAuB,EAAE,MAAM,CAAC,yBAAyB,CAAC;IAC1D,gBAAgB,EAAE,MAAM,CAAC,kBAAkB,CAAC;IAC5C,iBAAiB,EAAE,MAAM,CAAC,mBAAmB,CAAC;CACtC,CAAC;AA2BX;;;;;;GAMG;AACH,MAAsB,iBAAiB;IAkBrC,YAAY,UAAwC,EAAE;QACpD,IAAI,CAAC,cAAc,GAA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SAAS,CAAC,cAAM,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,cAAM,CAAC,eAAe,CAAC,CAAC;IACpF,CAAC;IAaD;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,QAAgE;QACvE,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAY,CAAC;IACxD,CAAC;IAED;;;;;OAKG;IACH,WAAW,CAAC,KAAiB;QAC3B,MAAM,KAAK,CAAC;IACd,CAAC;CACF;AA7GD,8CA6GC;AAED,SAAgB,aAAa,CAC3B,SAAoC,EACpC,OAAwC;IAExC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,YAAY,GAAG,CAAC,EAAE,CAAC;QACzD,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3B,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE;QAC1C,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
||||
43
node_modules/mongodb/lib/operations/profiling_level.js
generated
vendored
Normal file
43
node_modules/mongodb/lib/operations/profiling_level.js
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ProfilingLevelOperation = void 0;
|
||||
const bson_1 = require("../bson");
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../error");
|
||||
const command_1 = require("./command");
|
||||
class ProfilingLevelResponse extends responses_1.MongoDBResponse {
|
||||
get was() {
|
||||
return this.get('was', bson_1.BSONType.int, true);
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
class ProfilingLevelOperation extends command_1.CommandOperation {
|
||||
constructor(db, options) {
|
||||
super(db, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = ProfilingLevelResponse;
|
||||
this.options = options;
|
||||
}
|
||||
get commandName() {
|
||||
return 'profile';
|
||||
}
|
||||
buildCommandDocument(_connection) {
|
||||
return { profile: -1 };
|
||||
}
|
||||
handleOk(response) {
|
||||
if (response.ok === 1) {
|
||||
const was = response.was;
|
||||
if (was === 0)
|
||||
return 'off';
|
||||
if (was === 1)
|
||||
return 'slow_only';
|
||||
if (was === 2)
|
||||
return 'all';
|
||||
throw new error_1.MongoUnexpectedServerResponseError(`Illegal profiling level value ${was}`);
|
||||
}
|
||||
else {
|
||||
throw new error_1.MongoUnexpectedServerResponseError('Error with profile command');
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.ProfilingLevelOperation = ProfilingLevelOperation;
|
||||
//# sourceMappingURL=profiling_level.js.map
|
||||
1
node_modules/mongodb/lib/operations/profiling_level.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/profiling_level.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"profiling_level.js","sourceRoot":"","sources":["../../src/operations/profiling_level.ts"],"names":[],"mappings":";;;AAAA,kCAAkD;AAElD,+DAAkE;AAElE,oCAA8D;AAC9D,uCAA2E;AAK3E,MAAM,sBAAuB,SAAQ,2BAAe;IAClD,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,eAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF;AAED,gBAAgB;AAChB,MAAa,uBAAwB,SAAQ,0BAAwB;IAInE,YAAY,EAAM,EAAE,OAA8B;QAChD,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAJZ,iCAA4B,GAAG,sBAAsB,CAAC;QAK7D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,SAAkB,CAAC;IAC5B,CAAC;IAEQ,oBAAoB,CAAC,WAAuB;QACnD,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC;IACzB,CAAC;IAEQ,QAAQ,CAAC,QAAgE;QAChF,IAAI,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;YACtB,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;YACzB,IAAI,GAAG,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC5B,IAAI,GAAG,KAAK,CAAC;gBAAE,OAAO,WAAW,CAAC;YAClC,IAAI,GAAG,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC5B,MAAM,IAAI,0CAAkC,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;QACvF,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,0CAAkC,CAAC,4BAA4B,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;CACF;AA5BD,0DA4BC"}
|
||||
27
node_modules/mongodb/lib/operations/remove_user.js
generated
vendored
Normal file
27
node_modules/mongodb/lib/operations/remove_user.js
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RemoveUserOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class RemoveUserOperation extends command_1.CommandOperation {
|
||||
constructor(db, username, options) {
|
||||
super(db, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options;
|
||||
this.username = username;
|
||||
}
|
||||
get commandName() {
|
||||
return 'dropUser';
|
||||
}
|
||||
buildCommandDocument(_connection) {
|
||||
return { dropUser: this.username };
|
||||
}
|
||||
handleOk(_response) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
exports.RemoveUserOperation = RemoveUserOperation;
|
||||
(0, operation_1.defineAspects)(RemoveUserOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
//# sourceMappingURL=remove_user.js.map
|
||||
1
node_modules/mongodb/lib/operations/remove_user.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/remove_user.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"remove_user.js","sourceRoot":"","sources":["../../src/operations/remove_user.ts"],"names":[],"mappings":";;;AAEA,+DAAkE;AAElE,uCAA2E;AAC3E,2CAAoD;AAKpD,gBAAgB;AAChB,MAAa,mBAAoB,SAAQ,0BAAyB;IAKhE,YAAY,EAAM,EAAE,QAAgB,EAAE,OAA0B;QAC9D,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QALZ,iCAA4B,GAAG,2BAAe,CAAC;QAMtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,UAAmB,CAAC;IAC7B,CAAC;IAEQ,oBAAoB,CAAC,WAAuB;QACnD,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;IACrC,CAAC;IAEQ,QAAQ,CAAC,SAAiE;QACjF,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtBD,kDAsBC;AAED,IAAA,yBAAa,EAAC,mBAAmB,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
||||
38
node_modules/mongodb/lib/operations/rename.js
generated
vendored
Normal file
38
node_modules/mongodb/lib/operations/rename.js
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RenameOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const collection_1 = require("../collection");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class RenameOperation extends command_1.CommandOperation {
|
||||
constructor(collection, newName, options) {
|
||||
super(collection, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.collection = collection;
|
||||
this.newName = newName;
|
||||
this.options = options;
|
||||
this.ns = new utils_1.MongoDBNamespace('admin', '$cmd');
|
||||
}
|
||||
get commandName() {
|
||||
return 'renameCollection';
|
||||
}
|
||||
buildCommandDocument(_connection, _session) {
|
||||
const renameCollection = this.collection.namespace;
|
||||
const to = this.collection.s.namespace.withCollection(this.newName).toString();
|
||||
const dropTarget = typeof this.options.dropTarget === 'boolean' ? this.options.dropTarget : false;
|
||||
return {
|
||||
renameCollection,
|
||||
to,
|
||||
dropTarget
|
||||
};
|
||||
}
|
||||
handleOk(_response) {
|
||||
return new collection_1.Collection(this.collection.db, this.newName, this.collection.s.options);
|
||||
}
|
||||
}
|
||||
exports.RenameOperation = RenameOperation;
|
||||
(0, operation_1.defineAspects)(RenameOperation, [operation_1.Aspect.WRITE_OPERATION]);
|
||||
//# sourceMappingURL=rename.js.map
|
||||
1
node_modules/mongodb/lib/operations/rename.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/rename.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"rename.js","sourceRoot":"","sources":["../../src/operations/rename.ts"],"names":[],"mappings":";;;AAEA,+DAAkE;AAClE,8CAA2C;AAE3C,oCAA4C;AAC5C,uCAA2E;AAC3E,2CAAoD;AAUpD,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,0BAA0B;IAM7D,YAAY,UAAsB,EAAE,OAAe,EAAE,OAAsB;QACzE,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QANpB,iCAA4B,GAAG,2BAAe,CAAC;QAOtD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,IAAI,wBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,kBAA2B,CAAC;IACrC,CAAC;IAEQ,oBAAoB,CAAC,WAAuB,EAAE,QAAwB;QAC7E,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QACnD,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC/E,MAAM,UAAU,GACd,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC;QAEjF,OAAO;YACL,gBAAgB;YAChB,EAAE;YACF,UAAU;SACX,CAAC;IACJ,CAAC;IAEQ,QAAQ,CAAC,SAAiE;QACjF,OAAO,IAAI,uBAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACrF,CAAC;CACF;AAlCD,0CAkCC;AAED,IAAA,yBAAa,EAAC,eAAe,EAAE,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC,CAAC"}
|
||||
47
node_modules/mongodb/lib/operations/run_command.js
generated
vendored
Normal file
47
node_modules/mongodb/lib/operations/run_command.js
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RunCursorCommandOperation = exports.RunCommandOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const operation_1 = require("../operations/operation");
|
||||
/** @internal */
|
||||
class RunCommandOperation extends operation_1.AbstractOperation {
|
||||
constructor(namespace, command, options) {
|
||||
super(options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.command = command;
|
||||
this.options = options;
|
||||
this.ns = namespace.withCollection('$cmd');
|
||||
}
|
||||
get commandName() {
|
||||
return 'runCommand';
|
||||
}
|
||||
buildCommand(_connection, _session) {
|
||||
return this.command;
|
||||
}
|
||||
buildOptions(timeoutContext) {
|
||||
return {
|
||||
...this.options,
|
||||
session: this.session,
|
||||
timeoutContext,
|
||||
signal: this.options.signal,
|
||||
readPreference: this.options.readPreference
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.RunCommandOperation = RunCommandOperation;
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* A specialized subclass of RunCommandOperation for cursor-creating commands.
|
||||
*/
|
||||
class RunCursorCommandOperation extends RunCommandOperation {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.CursorResponse;
|
||||
}
|
||||
handleOk(response) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
exports.RunCursorCommandOperation = RunCursorCommandOperation;
|
||||
//# sourceMappingURL=run_command.js.map
|
||||
1
node_modules/mongodb/lib/operations/run_command.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/run_command.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"run_command.js","sourceRoot":"","sources":["../../src/operations/run_command.ts"],"names":[],"mappings":";;;AAGA,+DAAkF;AAClF,uDAA4D;AA6B5D,gBAAgB;AAChB,MAAa,mBAAkC,SAAQ,6BAAoB;IAKzE,YAAY,SAA2B,EAAE,OAAiB,EAAE,OAA0B;QACpF,KAAK,CAAC,OAAO,CAAC,CAAC;QALR,iCAA4B,GAAG,2BAAe,CAAC;QAMtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,YAAqB,CAAC;IAC/B,CAAC;IAEQ,YAAY,CAAC,WAAuB,EAAE,QAAwB;QACrE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEQ,YAAY,CAAC,cAA8B;QAClD,OAAO;YACL,GAAG,IAAI,CAAC,OAAO;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,cAAc;YACd,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;YAC3B,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;SAC5C,CAAC;IACJ,CAAC;CACF;AA7BD,kDA6BC;AAED;;;;GAIG;AACH,MAAa,yBAA0B,SAAQ,mBAAmB;IAAlE;;QACW,iCAA4B,GAAG,0BAAc,CAAC;IAOzD,CAAC;IALU,QAAQ,CACf,QAAgE;QAEhE,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AARD,8DAQC"}
|
||||
33
node_modules/mongodb/lib/operations/search_indexes/create.js
generated
vendored
Normal file
33
node_modules/mongodb/lib/operations/search_indexes/create.js
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CreateSearchIndexesOperation = void 0;
|
||||
const responses_1 = require("../../cmap/wire_protocol/responses");
|
||||
const operation_1 = require("../operation");
|
||||
/** @internal */
|
||||
class CreateSearchIndexesOperation extends operation_1.AbstractOperation {
|
||||
constructor(collection, descriptions) {
|
||||
super();
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.collection = collection;
|
||||
this.descriptions = descriptions;
|
||||
this.ns = collection.fullNamespace;
|
||||
}
|
||||
get commandName() {
|
||||
return 'createSearchIndexes';
|
||||
}
|
||||
buildCommand(_connection, _session) {
|
||||
const namespace = this.collection.fullNamespace;
|
||||
return {
|
||||
createSearchIndexes: namespace.collection,
|
||||
indexes: this.descriptions
|
||||
};
|
||||
}
|
||||
handleOk(response) {
|
||||
return super.handleOk(response).indexesCreated.map((val) => val.name);
|
||||
}
|
||||
buildOptions(timeoutContext) {
|
||||
return { session: this.session, timeoutContext };
|
||||
}
|
||||
}
|
||||
exports.CreateSearchIndexesOperation = CreateSearchIndexesOperation;
|
||||
//# sourceMappingURL=create.js.map
|
||||
1
node_modules/mongodb/lib/operations/search_indexes/create.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/search_indexes/create.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/operations/search_indexes/create.ts"],"names":[],"mappings":";;;AAEA,kEAAqE;AAKrE,4CAAiD;AAgBjD,gBAAgB;AAChB,MAAa,4BAA6B,SAAQ,6BAA2B;IAK3E,YAAY,UAAsB,EAAE,YAAmD;QACrF,KAAK,EAAE,CAAC;QALD,iCAA4B,GAAG,2BAAe,CAAC;QAMtD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC;IACrC,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,qBAA8B,CAAC;IACxC,CAAC;IAEQ,YAAY,CAAC,WAAuB,EAAE,QAAwB;QACrE,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;QAChD,OAAO;YACL,mBAAmB,EAAE,SAAS,CAAC,UAAU;YACzC,OAAO,EAAE,IAAI,CAAC,YAAY;SAC3B,CAAC;IACJ,CAAC;IAEQ,QAAQ,CAAC,QAAgE;QAChF,OAAO,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,GAAqB,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1F,CAAC;IAEQ,YAAY,CAAC,cAA8B;QAClD,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;IACnD,CAAC;CACF;AA/BD,oEA+BC"}
|
||||
43
node_modules/mongodb/lib/operations/search_indexes/drop.js
generated
vendored
Normal file
43
node_modules/mongodb/lib/operations/search_indexes/drop.js
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DropSearchIndexOperation = void 0;
|
||||
const responses_1 = require("../../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../../error");
|
||||
const operation_1 = require("../operation");
|
||||
/** @internal */
|
||||
class DropSearchIndexOperation extends operation_1.AbstractOperation {
|
||||
constructor(collection, name) {
|
||||
super();
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.collection = collection;
|
||||
this.name = name;
|
||||
this.ns = collection.fullNamespace;
|
||||
}
|
||||
get commandName() {
|
||||
return 'dropSearchIndex';
|
||||
}
|
||||
buildCommand(_connection, _session) {
|
||||
const namespace = this.collection.fullNamespace;
|
||||
const command = {
|
||||
dropSearchIndex: namespace.collection
|
||||
};
|
||||
if (typeof this.name === 'string') {
|
||||
command.name = this.name;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
handleOk(_response) {
|
||||
// do nothing
|
||||
}
|
||||
buildOptions(timeoutContext) {
|
||||
return { session: this.session, timeoutContext };
|
||||
}
|
||||
handleError(error) {
|
||||
const isNamespaceNotFoundError = error instanceof error_1.MongoServerError && error.code === error_1.MONGODB_ERROR_CODES.NamespaceNotFound;
|
||||
if (!isNamespaceNotFoundError) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.DropSearchIndexOperation = DropSearchIndexOperation;
|
||||
//# sourceMappingURL=drop.js.map
|
||||
1
node_modules/mongodb/lib/operations/search_indexes/drop.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/search_indexes/drop.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"drop.js","sourceRoot":"","sources":["../../../src/operations/search_indexes/drop.ts"],"names":[],"mappings":";;;AAEA,kEAAqE;AAErE,uCAAoE;AAIpE,4CAAiD;AAEjD,gBAAgB;AAChB,MAAa,wBAAyB,SAAQ,6BAAuB;IAMnE,YAAY,UAAsB,EAAE,IAAY;QAC9C,KAAK,EAAE,CAAC;QAND,iCAA4B,GAAG,2BAAe,CAAC;QAOtD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC;IACrC,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,iBAA0B,CAAC;IACpC,CAAC;IAEQ,YAAY,CAAC,WAAuB,EAAE,QAAwB;QACrE,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;QAEhD,MAAM,OAAO,GAAa;YACxB,eAAe,EAAE,SAAS,CAAC,UAAU;SACtC,CAAC;QAEF,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAEQ,QAAQ,CAAC,SAA0B;QAC1C,aAAa;IACf,CAAC;IAEQ,YAAY,CAAC,cAA8B;QAClD,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;IACnD,CAAC;IAEQ,WAAW,CAAC,KAAiB;QACpC,MAAM,wBAAwB,GAC5B,KAAK,YAAY,wBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,2BAAmB,CAAC,iBAAiB,CAAC;QAC5F,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAC9B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA9CD,4DA8CC"}
|
||||
35
node_modules/mongodb/lib/operations/search_indexes/update.js
generated
vendored
Normal file
35
node_modules/mongodb/lib/operations/search_indexes/update.js
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UpdateSearchIndexOperation = void 0;
|
||||
const responses_1 = require("../../cmap/wire_protocol/responses");
|
||||
const operation_1 = require("../operation");
|
||||
/** @internal */
|
||||
class UpdateSearchIndexOperation extends operation_1.AbstractOperation {
|
||||
constructor(collection, name, definition) {
|
||||
super();
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.collection = collection;
|
||||
this.name = name;
|
||||
this.definition = definition;
|
||||
this.ns = collection.fullNamespace;
|
||||
}
|
||||
get commandName() {
|
||||
return 'updateSearchIndex';
|
||||
}
|
||||
buildCommand(_connection, _session) {
|
||||
const namespace = this.collection.fullNamespace;
|
||||
return {
|
||||
updateSearchIndex: namespace.collection,
|
||||
name: this.name,
|
||||
definition: this.definition
|
||||
};
|
||||
}
|
||||
handleOk(_response) {
|
||||
// no response.
|
||||
}
|
||||
buildOptions(timeoutContext) {
|
||||
return { session: this.session, timeoutContext };
|
||||
}
|
||||
}
|
||||
exports.UpdateSearchIndexOperation = UpdateSearchIndexOperation;
|
||||
//# sourceMappingURL=update.js.map
|
||||
1
node_modules/mongodb/lib/operations/search_indexes/update.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/search_indexes/update.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/operations/search_indexes/update.ts"],"names":[],"mappings":";;;AAEA,kEAAqE;AAKrE,4CAAiD;AAEjD,gBAAgB;AAChB,MAAa,0BAA2B,SAAQ,6BAAuB;IAMrE,YAAY,UAAsB,EAAE,IAAY,EAAE,UAAoB;QACpE,KAAK,EAAE,CAAC;QAND,iCAA4B,GAAG,2BAAe,CAAC;QAOtD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC;IACrC,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,mBAA4B,CAAC;IACtC,CAAC;IAEQ,YAAY,CAAC,WAAuB,EAAE,QAAwB;QACrE,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;QAChD,OAAO;YACL,iBAAiB,EAAE,SAAS,CAAC,UAAU;YACvC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;IACJ,CAAC;IAEQ,QAAQ,CAAC,SAA0B;QAC1C,eAAe;IACjB,CAAC;IAEQ,YAAY,CAAC,cAA8B;QAClD,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;IACnD,CAAC;CACF;AAlCD,gEAkCC"}
|
||||
53
node_modules/mongodb/lib/operations/set_profiling_level.js
generated
vendored
Normal file
53
node_modules/mongodb/lib/operations/set_profiling_level.js
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SetProfilingLevelOperation = exports.ProfilingLevel = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../error");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const levelValues = new Set(['off', 'slow_only', 'all']);
|
||||
/** @public */
|
||||
exports.ProfilingLevel = Object.freeze({
|
||||
off: 'off',
|
||||
slowOnly: 'slow_only',
|
||||
all: 'all'
|
||||
});
|
||||
/** @internal */
|
||||
class SetProfilingLevelOperation extends command_1.CommandOperation {
|
||||
constructor(db, level, options) {
|
||||
super(db, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options;
|
||||
switch (level) {
|
||||
case exports.ProfilingLevel.off:
|
||||
this.profile = 0;
|
||||
break;
|
||||
case exports.ProfilingLevel.slowOnly:
|
||||
this.profile = 1;
|
||||
break;
|
||||
case exports.ProfilingLevel.all:
|
||||
this.profile = 2;
|
||||
break;
|
||||
default:
|
||||
this.profile = 0;
|
||||
break;
|
||||
}
|
||||
this.level = level;
|
||||
}
|
||||
get commandName() {
|
||||
return 'profile';
|
||||
}
|
||||
buildCommandDocument(_connection) {
|
||||
const level = this.level;
|
||||
if (!levelValues.has(level)) {
|
||||
// TODO(NODE-3483): Determine error to put here
|
||||
throw new error_1.MongoInvalidArgumentError(`Profiling level must be one of "${(0, utils_1.enumToString)(exports.ProfilingLevel)}"`);
|
||||
}
|
||||
return { profile: this.profile };
|
||||
}
|
||||
handleOk(_response) {
|
||||
return this.level;
|
||||
}
|
||||
}
|
||||
exports.SetProfilingLevelOperation = SetProfilingLevelOperation;
|
||||
//# sourceMappingURL=set_profiling_level.js.map
|
||||
1
node_modules/mongodb/lib/operations/set_profiling_level.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/set_profiling_level.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"set_profiling_level.js","sourceRoot":"","sources":["../../src/operations/set_profiling_level.ts"],"names":[],"mappings":";;;AAEA,+DAAkE;AAElE,oCAAqD;AACrD,oCAAwC;AACxC,uCAA2E;AAE3E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;AAEzD,cAAc;AACD,QAAA,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C,GAAG,EAAE,KAAK;IACV,QAAQ,EAAE,WAAW;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b/lib/operations/stats.js
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DbStatsOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/** @internal */
|
||||
class DbStatsOperation extends command_1.CommandOperation {
|
||||
constructor(db, options) {
|
||||
super(db, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options;
|
||||
}
|
||||
get commandName() {
|
||||
return 'dbStats';
|
||||
}
|
||||
buildCommandDocument(_connection) {
|
||||
const command = { dbStats: true };
|
||||
if (this.options.scale != null) {
|
||||
command.scale = this.options.scale;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
}
|
||||
exports.DbStatsOperation = DbStatsOperation;
|
||||
(0, operation_1.defineAspects)(DbStatsOperation, [operation_1.Aspect.READ_OPERATION]);
|
||||
//# sourceMappingURL=stats.js.map
|
||||
1
node_modules/mongodb/lib/operations/stats.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/stats.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/operations/stats.ts"],"names":[],"mappings":";;;AAEA,+DAAkE;AAElE,uCAA2E;AAC3E,2CAAoD;AAQpD,gBAAgB;AAChB,MAAa,gBAAiB,SAAQ,0BAA0B;IAI9D,YAAY,EAAM,EAAE,OAAuB;QACzC,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAJZ,iCAA4B,GAAG,2BAAe,CAAC;QAKtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,SAAkB,CAAC;IAC5B,CAAC;IAEQ,oBAAoB,CAAC,WAAuB;QACnD,MAAM,OAAO,GAAa,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YAC/B,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACrC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AApBD,4CAoBC;AAED,IAAA,yBAAa,EAAC,gBAAgB,EAAE,CAAC,kBAAM,CAAC,cAAc,CAAC,CAAC,CAAC"}
|
||||
188
node_modules/mongodb/lib/operations/update.js
generated
vendored
Normal file
188
node_modules/mongodb/lib/operations/update.js
generated
vendored
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ReplaceOneOperation = exports.UpdateManyOperation = exports.UpdateOneOperation = exports.UpdateOperation = void 0;
|
||||
exports.makeUpdateStatement = makeUpdateStatement;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../error");
|
||||
const sort_1 = require("../sort");
|
||||
const utils_1 = require("../utils");
|
||||
const command_1 = require("./command");
|
||||
const operation_1 = require("./operation");
|
||||
/**
|
||||
* @internal
|
||||
* UpdateOperation is used in bulk write, while UpdateOneOperation and UpdateManyOperation are only used in the collections API
|
||||
*/
|
||||
class UpdateOperation extends command_1.CommandOperation {
|
||||
constructor(ns, statements, options) {
|
||||
super(undefined, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options;
|
||||
this.ns = ns;
|
||||
this.statements = statements;
|
||||
}
|
||||
get commandName() {
|
||||
return 'update';
|
||||
}
|
||||
get canRetryWrite() {
|
||||
if (super.canRetryWrite === false) {
|
||||
return false;
|
||||
}
|
||||
return this.statements.every(op => op.multi == null || op.multi === false);
|
||||
}
|
||||
buildCommandDocument(_connection, _session) {
|
||||
const options = this.options;
|
||||
const command = {
|
||||
update: this.ns.collection,
|
||||
updates: this.statements,
|
||||
ordered: options.ordered ?? true
|
||||
};
|
||||
if (typeof options.bypassDocumentValidation === 'boolean') {
|
||||
command.bypassDocumentValidation = options.bypassDocumentValidation;
|
||||
}
|
||||
if (options.let) {
|
||||
command.let = options.let;
|
||||
}
|
||||
// we check for undefined specifically here to allow falsy values
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
if (options.comment !== undefined) {
|
||||
command.comment = options.comment;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
}
|
||||
exports.UpdateOperation = UpdateOperation;
|
||||
/** @internal */
|
||||
class UpdateOneOperation extends UpdateOperation {
|
||||
constructor(ns, filter, update, options) {
|
||||
super(ns, [makeUpdateStatement(filter, update, { ...options, multi: false })], options);
|
||||
if (!(0, utils_1.hasAtomicOperators)(update, options)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Update document requires atomic operators');
|
||||
}
|
||||
}
|
||||
handleOk(response) {
|
||||
const res = super.handleOk(response);
|
||||
// @ts-expect-error Explain typing is broken
|
||||
if (this.explain != null)
|
||||
return res;
|
||||
if (res.code)
|
||||
throw new error_1.MongoServerError(res);
|
||||
if (res.writeErrors)
|
||||
throw new error_1.MongoServerError(res.writeErrors[0]);
|
||||
return {
|
||||
acknowledged: this.writeConcern?.w !== 0,
|
||||
modifiedCount: res.nModified ?? res.n,
|
||||
upsertedId: Array.isArray(res.upserted) && res.upserted.length > 0 ? res.upserted[0]._id : null,
|
||||
upsertedCount: Array.isArray(res.upserted) && res.upserted.length ? res.upserted.length : 0,
|
||||
matchedCount: Array.isArray(res.upserted) && res.upserted.length > 0 ? 0 : res.n
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.UpdateOneOperation = UpdateOneOperation;
|
||||
/** @internal */
|
||||
class UpdateManyOperation extends UpdateOperation {
|
||||
constructor(ns, filter, update, options) {
|
||||
super(ns, [makeUpdateStatement(filter, update, { ...options, multi: true })], options);
|
||||
if (!(0, utils_1.hasAtomicOperators)(update, options)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Update document requires atomic operators');
|
||||
}
|
||||
}
|
||||
handleOk(response) {
|
||||
const res = super.handleOk(response);
|
||||
// @ts-expect-error Explain typing is broken
|
||||
if (this.explain != null)
|
||||
return res;
|
||||
if (res.code)
|
||||
throw new error_1.MongoServerError(res);
|
||||
if (res.writeErrors)
|
||||
throw new error_1.MongoServerError(res.writeErrors[0]);
|
||||
return {
|
||||
acknowledged: this.writeConcern?.w !== 0,
|
||||
modifiedCount: res.nModified ?? res.n,
|
||||
upsertedId: Array.isArray(res.upserted) && res.upserted.length > 0 ? res.upserted[0]._id : null,
|
||||
upsertedCount: Array.isArray(res.upserted) && res.upserted.length ? res.upserted.length : 0,
|
||||
matchedCount: Array.isArray(res.upserted) && res.upserted.length > 0 ? 0 : res.n
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.UpdateManyOperation = UpdateManyOperation;
|
||||
/** @internal */
|
||||
class ReplaceOneOperation extends UpdateOperation {
|
||||
constructor(ns, filter, replacement, options) {
|
||||
super(ns, [makeUpdateStatement(filter, replacement, { ...options, multi: false })], options);
|
||||
if ((0, utils_1.hasAtomicOperators)(replacement)) {
|
||||
throw new error_1.MongoInvalidArgumentError('Replacement document must not contain atomic operators');
|
||||
}
|
||||
}
|
||||
handleOk(response) {
|
||||
const res = super.handleOk(response);
|
||||
// @ts-expect-error Explain typing is broken
|
||||
if (this.explain != null)
|
||||
return res;
|
||||
if (res.code)
|
||||
throw new error_1.MongoServerError(res);
|
||||
if (res.writeErrors)
|
||||
throw new error_1.MongoServerError(res.writeErrors[0]);
|
||||
return {
|
||||
acknowledged: this.writeConcern?.w !== 0,
|
||||
modifiedCount: res.nModified ?? res.n,
|
||||
upsertedId: Array.isArray(res.upserted) && res.upserted.length > 0 ? res.upserted[0]._id : null,
|
||||
upsertedCount: Array.isArray(res.upserted) && res.upserted.length ? res.upserted.length : 0,
|
||||
matchedCount: Array.isArray(res.upserted) && res.upserted.length > 0 ? 0 : res.n
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.ReplaceOneOperation = ReplaceOneOperation;
|
||||
function makeUpdateStatement(filter, update, options) {
|
||||
if (filter == null || typeof filter !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Selector must be a valid JavaScript object');
|
||||
}
|
||||
if (update == null || typeof update !== 'object') {
|
||||
throw new error_1.MongoInvalidArgumentError('Document must be a valid JavaScript object');
|
||||
}
|
||||
const op = { q: filter, u: update };
|
||||
if (typeof options.upsert === 'boolean') {
|
||||
op.upsert = options.upsert;
|
||||
}
|
||||
if (options.multi) {
|
||||
op.multi = options.multi;
|
||||
}
|
||||
if (options.hint) {
|
||||
op.hint = options.hint;
|
||||
}
|
||||
if (options.arrayFilters) {
|
||||
op.arrayFilters = options.arrayFilters;
|
||||
}
|
||||
if (options.collation) {
|
||||
op.collation = options.collation;
|
||||
}
|
||||
if (!options.multi && options.sort != null) {
|
||||
op.sort = (0, sort_1.formatSort)(options.sort);
|
||||
}
|
||||
return op;
|
||||
}
|
||||
(0, operation_1.defineAspects)(UpdateOperation, [
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.SKIP_COLLATION,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
(0, operation_1.defineAspects)(UpdateOneOperation, [
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.SKIP_COLLATION,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
(0, operation_1.defineAspects)(UpdateManyOperation, [
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.EXPLAINABLE,
|
||||
operation_1.Aspect.SKIP_COLLATION,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
(0, operation_1.defineAspects)(ReplaceOneOperation, [
|
||||
operation_1.Aspect.RETRYABLE,
|
||||
operation_1.Aspect.WRITE_OPERATION,
|
||||
operation_1.Aspect.SKIP_COLLATION,
|
||||
operation_1.Aspect.SUPPORTS_RAW_DATA
|
||||
]);
|
||||
//# sourceMappingURL=update.js.map
|
||||
1
node_modules/mongodb/lib/operations/update.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/update.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
37
node_modules/mongodb/lib/operations/validate_collection.js
generated
vendored
Normal file
37
node_modules/mongodb/lib/operations/validate_collection.js
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ValidateCollectionOperation = void 0;
|
||||
const responses_1 = require("../cmap/wire_protocol/responses");
|
||||
const error_1 = require("../error");
|
||||
const command_1 = require("./command");
|
||||
/** @internal */
|
||||
class ValidateCollectionOperation extends command_1.CommandOperation {
|
||||
constructor(admin, collectionName, options) {
|
||||
super(admin.s.db, options);
|
||||
this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
|
||||
this.options = options;
|
||||
this.collectionName = collectionName;
|
||||
}
|
||||
get commandName() {
|
||||
return 'validate';
|
||||
}
|
||||
buildCommandDocument(_connection, _session) {
|
||||
// Decorate command with extra options
|
||||
return {
|
||||
validate: this.collectionName,
|
||||
...Object.fromEntries(Object.entries(this.options).filter(entry => entry[0] !== 'session'))
|
||||
};
|
||||
}
|
||||
handleOk(response) {
|
||||
const result = super.handleOk(response);
|
||||
if (result.result != null && typeof result.result !== 'string')
|
||||
throw new error_1.MongoUnexpectedServerResponseError('Error with validation data');
|
||||
if (result.result != null && result.result.match(/exception|corrupt/) != null)
|
||||
throw new error_1.MongoUnexpectedServerResponseError(`Invalid collection ${this.collectionName}`);
|
||||
if (result.valid != null && !result.valid)
|
||||
throw new error_1.MongoUnexpectedServerResponseError(`Invalid collection ${this.collectionName}`);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
exports.ValidateCollectionOperation = ValidateCollectionOperation;
|
||||
//# sourceMappingURL=validate_collection.js.map
|
||||
1
node_modules/mongodb/lib/operations/validate_collection.js.map
generated
vendored
Normal file
1
node_modules/mongodb/lib/operations/validate_collection.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"validate_collection.js","sourceRoot":"","sources":["../../src/operations/validate_collection.ts"],"names":[],"mappings":";;;AAGA,+DAAkE;AAClE,oCAA8D;AAE9D,uCAA2E;AAQ3E,gBAAgB;AAChB,MAAa,2BAA4B,SAAQ,0BAA0B;IAKzE,YAAY,KAAY,EAAE,cAAsB,EAAE,OAAkC;QAClF,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QALpB,iCAA4B,GAAG,2BAAe,CAAC;QAMtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED,IAAa,WAAW;QACtB,OAAO,UAAmB,CAAC;IAC7B,CAAC;IAEQ,oBAAoB,CAAC,WAAuB,EAAE,QAAwB;QAC7E,sCAAsC;QACtC,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,cAAc;YAC7B,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;SAC5F,CAAC;IACJ,CAAC;IAEQ,QAAQ,CAAC,QAAgE;QAChF,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,MAAM,CAAC,MAAM,IAAI,IAAI,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;YAC5D,MAAM,IAAI,0CAAkC,CAAC,4BAA4B,CAAC,CAAC;QAC7E,IAAI,MAAM,CAAC,MA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