@mongosh/shell-api 1.2.2 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/collection.js CHANGED
@@ -32,7 +32,7 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
32
32
  }
33
33
  if (typeof prop !== 'string' ||
34
34
  prop.startsWith('_') ||
35
- !helpers_1.isValidCollectionName(prop)) {
35
+ !(0, helpers_1.isValidCollectionName)(prop)) {
36
36
  return;
37
37
  }
38
38
  return database.getCollection(`${name}.${prop}`);
@@ -67,13 +67,13 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
67
67
  pipeline = args || [];
68
68
  }
69
69
  this._emitCollectionApiCall('aggregate', { options, pipeline });
70
- const { aggOptions, dbOptions, explain } = helpers_1.adaptAggregateOptions(options);
70
+ const { aggOptions, dbOptions, explain } = (0, helpers_1.adaptAggregateOptions)(options);
71
71
  const providerCursor = this._mongo._serviceProvider.aggregate(this._database._name, this._name, pipeline, { ...await this._database._baseOptions(), ...aggOptions }, dbOptions);
72
72
  const cursor = new index_1.AggregationCursor(this._mongo, providerCursor);
73
73
  if (explain) {
74
74
  return await cursor.explain(explain);
75
75
  }
76
- else if (helpers_1.shouldRunAggregationImmediately(pipeline)) {
76
+ else if ((0, helpers_1.shouldRunAggregationImmediately)(pipeline)) {
77
77
  await cursor.hasNext();
78
78
  }
79
79
  this._mongo._instanceState.currentCursor = cursor;
@@ -94,26 +94,26 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
94
94
  return this._mongo._serviceProvider.countDocuments(this._database._name, this._name, query, { ...await this._database._baseOptions(), ...options });
95
95
  }
96
96
  async deleteMany(filter, options = {}) {
97
- helpers_1.assertArgsDefinedType([filter], [true], 'Collection.deleteMany');
97
+ (0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.deleteMany');
98
98
  this._emitCollectionApiCall('deleteMany', { filter, options });
99
99
  const result = await this._mongo._serviceProvider.deleteMany(this._database._name, this._name, filter, { ...await this._database._baseOptions(), ...options });
100
100
  if (options.explain) {
101
- return helpers_1.markAsExplainOutput(result);
101
+ return (0, helpers_1.markAsExplainOutput)(result);
102
102
  }
103
103
  return new index_1.DeleteResult(!!result.acknowledged, result.deletedCount);
104
104
  }
105
105
  async deleteOne(filter, options = {}) {
106
- helpers_1.assertArgsDefinedType([filter], [true], 'Collection.deleteOne');
106
+ (0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.deleteOne');
107
107
  this._emitCollectionApiCall('deleteOne', { filter, options });
108
108
  const result = await this._mongo._serviceProvider.deleteOne(this._database._name, this._name, filter, { ...await this._database._baseOptions(), ...options });
109
109
  if (options.explain) {
110
- return helpers_1.markAsExplainOutput(result);
110
+ return (0, helpers_1.markAsExplainOutput)(result);
111
111
  }
112
112
  return new index_1.DeleteResult(!!result.acknowledged, result.deletedCount);
113
113
  }
114
114
  async distinct(field, query, options = {}) {
115
115
  this._emitCollectionApiCall('distinct', { field, query, options });
116
- return helpers_1.maybeMarkAsExplainOutput(await this._mongo._serviceProvider.distinct(this._database._name, this._name, field, query, { ...await this._database._baseOptions(), ...options }), options);
116
+ return (0, helpers_1.maybeMarkAsExplainOutput)(await this._mongo._serviceProvider.distinct(this._database._name, this._name, field, query, { ...await this._database._baseOptions(), ...options }), options);
117
117
  }
118
118
  async estimatedDocumentCount(options = {}) {
119
119
  this._emitCollectionApiCall('estimatedDocumentCount', { options });
@@ -129,8 +129,8 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
129
129
  return cursor;
130
130
  }
131
131
  async findAndModify(options) {
132
- helpers_1.assertArgsDefinedType([options], [true], 'Collection.findAndModify');
133
- helpers_1.assertKeysDefined(options, ['query']);
132
+ (0, helpers_1.assertArgsDefinedType)([options], [true], 'Collection.findAndModify');
133
+ (0, helpers_1.assertKeysDefined)(options, ['query']);
134
134
  this._emitCollectionApiCall('findAndModify', { options: { ...options, update: !!options.update } });
135
135
  const reducedOptions = { ...options };
136
136
  delete reducedOptions.query;
@@ -155,7 +155,7 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
155
155
  return new index_1.Cursor(this._mongo, this._mongo._serviceProvider.find(this._database._name, this._name, query, { ...await this._database._baseOptions(), ...options })).limit(1).tryNext();
156
156
  }
157
157
  async renameCollection(newName, dropTarget) {
158
- helpers_1.assertArgsDefinedType([newName], ['string'], 'Collection.renameCollection');
158
+ (0, helpers_1.assertArgsDefinedType)([newName], ['string'], 'Collection.renameCollection');
159
159
  this._emitCollectionApiCall('renameCollection', { newName, dropTarget });
160
160
  try {
161
161
  await this._mongo._serviceProvider.renameCollection(this._database._name, this._name, newName, { ...await this._database._baseOptions(), dropTarget: !!dropTarget });
@@ -164,7 +164,7 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
164
164
  };
165
165
  }
166
166
  catch (e) {
167
- if (e.name === 'MongoError') {
167
+ if ((e === null || e === void 0 ? void 0 : e.name) === 'MongoError') {
168
168
  return {
169
169
  ok: 0,
170
170
  errmsg: e.errmsg,
@@ -176,57 +176,57 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
176
176
  }
177
177
  }
178
178
  async findOneAndDelete(filter, options = {}) {
179
- helpers_1.assertArgsDefinedType([filter], [true], 'Collection.findOneAndDelete');
179
+ (0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.findOneAndDelete');
180
180
  this._emitCollectionApiCall('findOneAndDelete', { filter, options });
181
181
  const result = await this._mongo._serviceProvider.findOneAndDelete(this._database._name, this._name, filter, { ...await this._database._baseOptions(), ...options });
182
182
  if (options.explain) {
183
- return helpers_1.markAsExplainOutput(result);
183
+ return (0, helpers_1.markAsExplainOutput)(result);
184
184
  }
185
185
  return result.value;
186
186
  }
187
187
  async findOneAndReplace(filter, replacement, options = {}) {
188
- helpers_1.assertArgsDefinedType([filter], [true], 'Collection.findOneAndReplace');
189
- const findOneAndReplaceOptions = helpers_1.processFindAndModifyOptions({
188
+ (0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.findOneAndReplace');
189
+ const findOneAndReplaceOptions = (0, helpers_1.processFindAndModifyOptions)({
190
190
  ...await this._database._baseOptions(),
191
191
  ...options
192
192
  });
193
193
  this._emitCollectionApiCall('findOneAndReplace', { filter, findOneAndReplaceOptions });
194
194
  const result = await this._mongo._serviceProvider.findOneAndReplace(this._database._name, this._name, filter, replacement, findOneAndReplaceOptions);
195
195
  if (options.explain) {
196
- return helpers_1.markAsExplainOutput(result);
196
+ return (0, helpers_1.markAsExplainOutput)(result);
197
197
  }
198
198
  return result.value;
199
199
  }
200
200
  async findOneAndUpdate(filter, update, options = {}) {
201
- helpers_1.assertArgsDefinedType([filter], [true], 'Collection.findOneAndUpdate');
202
- const findOneAndUpdateOptions = helpers_1.processFindAndModifyOptions({
201
+ (0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.findOneAndUpdate');
202
+ const findOneAndUpdateOptions = (0, helpers_1.processFindAndModifyOptions)({
203
203
  ...await this._database._baseOptions(),
204
204
  ...options
205
205
  });
206
206
  this._emitCollectionApiCall('findOneAndUpdate', { filter, findOneAndUpdateOptions });
207
207
  const result = await this._mongo._serviceProvider.findOneAndUpdate(this._database._name, this._name, filter, update, findOneAndUpdateOptions);
208
208
  if (options.explain) {
209
- return helpers_1.markAsExplainOutput(result);
209
+ return (0, helpers_1.markAsExplainOutput)(result);
210
210
  }
211
211
  return result.value;
212
212
  }
213
213
  async insert(docs, options = {}) {
214
214
  await this._instanceState.printDeprecationWarning('Collection.insert() is deprecated. Use insertOne, insertMany, or bulkWrite.');
215
- helpers_1.assertArgsDefinedType([docs], [true], 'Collection.insert');
215
+ (0, helpers_1.assertArgsDefinedType)([docs], [true], 'Collection.insert');
216
216
  const docsToInsert = Array.isArray(docs) ? docs.map((doc) => ({ ...doc })) : [{ ...docs }];
217
217
  this._emitCollectionApiCall('insert', { options });
218
218
  const result = await this._mongo._serviceProvider.insertMany(this._database._name, this._name, docsToInsert, { ...await this._database._baseOptions(), ...options });
219
219
  return new index_1.InsertManyResult(!!result.acknowledged, result.insertedIds);
220
220
  }
221
221
  async insertMany(docs, options = {}) {
222
- helpers_1.assertArgsDefinedType([docs], [true], 'Collection.insertMany');
222
+ (0, helpers_1.assertArgsDefinedType)([docs], [true], 'Collection.insertMany');
223
223
  const docsToInsert = Array.isArray(docs) ? docs.map((doc) => ({ ...doc })) : docs;
224
224
  this._emitCollectionApiCall('insertMany', { options });
225
225
  const result = await this._mongo._serviceProvider.insertMany(this._database._name, this._name, docsToInsert, { ...await this._database._baseOptions(), ...options });
226
226
  return new index_1.InsertManyResult(!!result.acknowledged, result.insertedIds);
227
227
  }
228
228
  async insertOne(doc, options = {}) {
229
- helpers_1.assertArgsDefinedType([doc], [true], 'Collection.insertOne');
229
+ (0, helpers_1.assertArgsDefinedType)([doc], [true], 'Collection.insertOne');
230
230
  this._emitCollectionApiCall('insertOne', { options });
231
231
  const result = await this._mongo._serviceProvider.insertOne(this._database._name, this._name, { ...doc }, { ...await this._database._baseOptions(), ...options });
232
232
  return new index_1.InsertOneResult(!!result.acknowledged, result.insertedId);
@@ -237,14 +237,14 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
237
237
  }
238
238
  async remove(query, options = {}) {
239
239
  await this._instanceState.printDeprecationWarning('Collection.remove() is deprecated. Use deleteOne, deleteMany, findOneAndDelete, or bulkWrite.');
240
- helpers_1.assertArgsDefinedType([query], [true], 'Collection.remove');
241
- const removeOptions = helpers_1.processRemoveOptions(options);
240
+ (0, helpers_1.assertArgsDefinedType)([query], [true], 'Collection.remove');
241
+ const removeOptions = (0, helpers_1.processRemoveOptions)(options);
242
242
  const method = removeOptions.justOne ? 'deleteOne' : 'deleteMany';
243
243
  delete removeOptions.justOne;
244
244
  this._emitCollectionApiCall('remove', { query, removeOptions });
245
245
  const result = await this._mongo._serviceProvider[method](this._database._name, this._name, query, { ...await this._database._baseOptions(), ...removeOptions });
246
246
  if (removeOptions.explain) {
247
- return helpers_1.markAsExplainOutput(result);
247
+ return (0, helpers_1.markAsExplainOutput)(result);
248
248
  }
249
249
  return new index_1.DeleteResult(!!result.acknowledged, result.deletedCount);
250
250
  }
@@ -252,14 +252,14 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
252
252
  throw new errors_1.MongoshInvalidInputError('Collection.save() is deprecated. Use insertOne, insertMany, updateOne, or updateMany.');
253
253
  }
254
254
  async replaceOne(filter, replacement, options = {}) {
255
- helpers_1.assertArgsDefinedType([filter], [true], 'Collection.replaceOne');
255
+ (0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.replaceOne');
256
256
  this._emitCollectionApiCall('replaceOne', { filter, options });
257
257
  const result = await this._mongo._serviceProvider.replaceOne(this._database._name, this._name, filter, replacement, { ...await this._database._baseOptions(), ...options });
258
258
  return new index_1.UpdateResult(!!result.acknowledged, result.matchedCount, result.modifiedCount, result.upsertedCount, result.upsertedId);
259
259
  }
260
260
  async update(filter, update, options = {}) {
261
261
  await this._instanceState.printDeprecationWarning('Collection.update() is deprecated. Use updateOne, updateMany, or bulkWrite.');
262
- helpers_1.assertArgsDefinedType([filter, update], [true, true], 'Collection.update');
262
+ (0, helpers_1.assertArgsDefinedType)([filter, update], [true, true], 'Collection.update');
263
263
  this._emitCollectionApiCall('update', { filter, options });
264
264
  let result;
265
265
  if (options.multi) {
@@ -269,25 +269,25 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
269
269
  result = await this._mongo._serviceProvider.updateOne(this._database._name, this._name, filter, update, { ...await this._database._baseOptions(), ...options });
270
270
  }
271
271
  if (options.explain) {
272
- return helpers_1.markAsExplainOutput(result);
272
+ return (0, helpers_1.markAsExplainOutput)(result);
273
273
  }
274
274
  return new index_1.UpdateResult(!!result.acknowledged, result.matchedCount, result.modifiedCount, result.upsertedCount, result.upsertedId);
275
275
  }
276
276
  async updateMany(filter, update, options = {}) {
277
- helpers_1.assertArgsDefinedType([filter], [true], 'Collection.updateMany');
277
+ (0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.updateMany');
278
278
  this._emitCollectionApiCall('updateMany', { filter, options });
279
279
  const result = await this._mongo._serviceProvider.updateMany(this._database._name, this._name, filter, update, { ...await this._database._baseOptions(), ...options });
280
280
  if (options.explain) {
281
- return helpers_1.markAsExplainOutput(result);
281
+ return (0, helpers_1.markAsExplainOutput)(result);
282
282
  }
283
283
  return new index_1.UpdateResult(!!result.acknowledged, result.matchedCount, result.modifiedCount, result.upsertedCount, result.upsertedId);
284
284
  }
285
285
  async updateOne(filter, update, options = {}) {
286
- helpers_1.assertArgsDefinedType([filter], [true], 'Collection.updateOne');
286
+ (0, helpers_1.assertArgsDefinedType)([filter], [true], 'Collection.updateOne');
287
287
  this._emitCollectionApiCall('updateOne', { filter, options });
288
288
  const result = await this._mongo._serviceProvider.updateOne(this._database._name, this._name, filter, update, { ...await this._database._baseOptions(), ...options });
289
289
  if (options.explain) {
290
- return helpers_1.markAsExplainOutput(result);
290
+ return (0, helpers_1.markAsExplainOutput)(result);
291
291
  }
292
292
  return new index_1.UpdateResult(!!result.acknowledged, result.matchedCount, result.modifiedCount, result.upsertedCount, result.upsertedId);
293
293
  }
@@ -298,38 +298,42 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
298
298
  size
299
299
  });
300
300
  }
301
- async createIndexes(keyPatterns, options = {}) {
302
- helpers_1.assertArgsDefinedType([keyPatterns], [true], 'Collection.createIndexes');
301
+ async _createIndexes(keyPatterns, options = {}, commitQuorum) {
302
+ (0, helpers_1.assertArgsDefinedType)([keyPatterns], [true], 'Collection.createIndexes');
303
303
  if (typeof options !== 'object' || Array.isArray(options)) {
304
304
  throw new errors_1.MongoshInvalidInputError('The "options" argument must be an object.', errors_1.CommonErrors.InvalidArgument);
305
305
  }
306
+ const specs = keyPatterns.map((pattern) => ({
307
+ ...options, key: pattern
308
+ }));
309
+ const createIndexesOptions = { ...await this._database._baseOptions(), ...options };
310
+ if (undefined !== commitQuorum) {
311
+ createIndexesOptions.commitQuorum = commitQuorum;
312
+ }
313
+ return await this._mongo._serviceProvider.createIndexes(this._database._name, this._name, specs, createIndexesOptions);
314
+ }
315
+ async createIndexes(keyPatterns, options = {}, commitQuorum) {
306
316
  const specs = keyPatterns.map((pattern) => ({
307
317
  ...options, key: pattern
308
318
  }));
309
319
  this._emitCollectionApiCall('createIndexes', { specs });
310
- return await this._mongo._serviceProvider.createIndexes(this._database._name, this._name, specs, { ...await this._database._baseOptions(), ...options });
320
+ return this._createIndexes(keyPatterns, options, commitQuorum);
311
321
  }
312
- async createIndex(keys, options = {}) {
313
- helpers_1.assertArgsDefinedType([keys], [true], 'Collection.createIndex');
322
+ async createIndex(keys, options = {}, commitQuorum) {
323
+ (0, helpers_1.assertArgsDefinedType)([keys], [true], 'Collection.createIndex');
314
324
  if (typeof options !== 'object' || Array.isArray(options)) {
315
325
  throw new errors_1.MongoshInvalidInputError('The "options" argument must be an object.', errors_1.CommonErrors.InvalidArgument);
316
326
  }
317
327
  this._emitCollectionApiCall('createIndex', { keys, options });
318
- const spec = { key: keys, ...options };
319
- const names = await this._mongo._serviceProvider.createIndexes(this._database._name, this._name, [spec], { ...await this._database._baseOptions(), ...options });
328
+ const names = await this._createIndexes([keys], options, commitQuorum);
320
329
  if (!Array.isArray(names) || names.length !== 1) {
321
330
  throw new errors_1.MongoshInternalError(`Expected createIndexes() to return array of length 1, saw ${names}`);
322
331
  }
323
332
  return names[0];
324
333
  }
325
- async ensureIndex(keys, options = {}) {
326
- helpers_1.assertArgsDefinedType([keys], [true], 'Collection.ensureIndex');
327
- if (typeof options !== 'object' || Array.isArray(options)) {
328
- throw new errors_1.MongoshInvalidInputError('The "options" argument must be an object.', errors_1.CommonErrors.InvalidArgument);
329
- }
334
+ async ensureIndex(keys, options = {}, commitQuorum) {
330
335
  this._emitCollectionApiCall('ensureIndex', { keys, options });
331
- const spec = { key: keys, ...options };
332
- return await this._mongo._serviceProvider.createIndexes(this._database._name, this._name, [spec], { ...await this._database._baseOptions(), ...options });
336
+ return await this._createIndexes([keys], options, commitQuorum);
333
337
  }
334
338
  async getIndexes() {
335
339
  this._emitCollectionApiCall('getIndexes');
@@ -357,8 +361,8 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
357
361
  });
358
362
  }
359
363
  catch (error) {
360
- if ((error.codeName === 'IndexNotFound' || error.codeName === undefined) &&
361
- (error.errmsg === 'invalid index name spec' || error.errmsg === undefined) &&
364
+ if (((error === null || error === void 0 ? void 0 : error.codeName) === 'IndexNotFound' || (error === null || error === void 0 ? void 0 : error.codeName) === undefined) &&
365
+ ((error === null || error === void 0 ? void 0 : error.errmsg) === 'invalid index name spec' || (error === null || error === void 0 ? void 0 : error.errmsg) === undefined) &&
362
366
  Array.isArray(indexes) &&
363
367
  indexes.length > 0 &&
364
368
  (await this._database.version()).match(/^4\.0\./)) {
@@ -368,7 +372,7 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
368
372
  return errored;
369
373
  return all.sort((a, b) => b.nIndexesWas - a.nIndexesWas)[0];
370
374
  }
371
- if (error.codeName === 'IndexNotFound') {
375
+ if ((error === null || error === void 0 ? void 0 : error.codeName) === 'IndexNotFound') {
372
376
  return {
373
377
  ok: error.ok,
374
378
  errmsg: error.errmsg,
@@ -380,7 +384,7 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
380
384
  }
381
385
  }
382
386
  async dropIndex(index) {
383
- helpers_1.assertArgsDefinedType([index], [true], 'Collection.dropIndex');
387
+ (0, helpers_1.assertArgsDefinedType)([index], [true], 'Collection.dropIndex');
384
388
  this._emitCollectionApiCall('dropIndex', { index });
385
389
  if (index === '*') {
386
390
  throw new errors_1.MongoshInvalidInputError('To drop indexes in the collection using \'*\', use db.collection.dropIndexes().', errors_1.CommonErrors.InvalidArgument);
@@ -433,7 +437,7 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
433
437
  return await this._mongo._serviceProvider.dropCollection(this._database._name, this._name, await this._database._baseOptions());
434
438
  }
435
439
  catch (error) {
436
- if (error.codeName === 'NamespaceNotFound') {
440
+ if ((error === null || error === void 0 ? void 0 : error.codeName) === 'NamespaceNotFound') {
437
441
  this._mongo._instanceState.messageBus.emit('mongosh:warn', {
438
442
  method: 'drop',
439
443
  class: 'Collection',
@@ -460,7 +464,7 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
460
464
  return `${this._name}`;
461
465
  }
462
466
  async runCommand(commandName, options) {
463
- helpers_1.assertArgsDefinedType([commandName], [['string', 'object']], 'Collection.runCommand');
467
+ (0, helpers_1.assertArgsDefinedType)([commandName], [['string', 'object']], 'Collection.runCommand');
464
468
  if (options) {
465
469
  if (typeof commandName !== 'string') {
466
470
  throw new errors_1.MongoshInvalidInputError('Collection.runCommand takes a command string as its first arugment', errors_1.CommonErrors.InvalidArgument);
@@ -480,7 +484,7 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
480
484
  return await this._database._runCommand(cmd);
481
485
  }
482
486
  explain(verbosity = 'queryPlanner') {
483
- verbosity = helpers_1.validateExplainableVerbosity(verbosity);
487
+ verbosity = (0, helpers_1.validateExplainableVerbosity)(verbosity);
484
488
  this._emitCollectionApiCall('explain', { verbosity });
485
489
  return new index_1.Explainable(this._mongo, this, verbosity);
486
490
  }
@@ -560,13 +564,13 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
560
564
  }
561
565
  async mapReduce(map, reduce, optionsOrOutString) {
562
566
  await this._instanceState.printDeprecationWarning('Collection.mapReduce() is deprecated. Use an aggregation instead.\nSee https://docs.mongodb.com/manual/core/map-reduce for details.');
563
- helpers_1.assertArgsDefinedType([map, reduce, optionsOrOutString], [true, true, true], 'Collection.mapReduce');
567
+ (0, helpers_1.assertArgsDefinedType)([map, reduce, optionsOrOutString], [true, true, true], 'Collection.mapReduce');
564
568
  this._emitCollectionApiCall('mapReduce', { map, reduce, out: optionsOrOutString });
565
569
  let cmd = {
566
570
  mapReduce: this._name,
567
571
  map: map,
568
572
  reduce: reduce,
569
- ...helpers_1.processMapReduceOptions(optionsOrOutString)
573
+ ...(0, helpers_1.processMapReduceOptions)(optionsOrOutString)
570
574
  };
571
575
  if (cmd.explain) {
572
576
  const verbosity = cmd.explain;
@@ -630,10 +634,10 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
630
634
  const estChunkData = (shardStats.numChunks === 0) ? 0 : (shardStats.size / shardStats.numChunks);
631
635
  const estChunkCount = (shardStats.numChunks === 0) ? 0 : Math.floor(shardStats.count / shardStats.numChunks);
632
636
  result[key] = {
633
- data: helpers_1.dataFormat(shardStats.size),
637
+ data: (0, helpers_1.dataFormat)(shardStats.size),
634
638
  docs: shardStats.count,
635
639
  chunks: shardStats.numChunks,
636
- 'estimated data per chunk': helpers_1.dataFormat(estChunkData),
640
+ 'estimated data per chunk': (0, helpers_1.dataFormat)(estChunkData),
637
641
  'estimated docs per chunk': estChunkCount
638
642
  };
639
643
  totals.size += shardStats.size;
@@ -642,7 +646,7 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
642
646
  conciseShardsStats.push(shardStats);
643
647
  })())));
644
648
  const totalValue = {
645
- data: helpers_1.dataFormat(totals.size),
649
+ data: (0, helpers_1.dataFormat)(totals.size),
646
650
  docs: totals.count,
647
651
  chunks: totals.numChunks
648
652
  };
@@ -652,7 +656,7 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
652
656
  totalValue[`Shard ${shardStats.shardId}`] = [
653
657
  `${estDataPercent} % data`,
654
658
  `${estDocPercent} % docs in cluster`,
655
- `${helpers_1.dataFormat(shardStats.avgObjSize)} avg obj size on shard`
659
+ `${(0, helpers_1.dataFormat)(shardStats.avgObjSize)} avg obj size on shard`
656
660
  ];
657
661
  }
658
662
  result.Totals = totalValue;
@@ -676,282 +680,282 @@ let Collection = class Collection extends decorators_1.ShellApiWithMongoClass {
676
680
  }
677
681
  async hideIndex(index) {
678
682
  this._emitCollectionApiCall('hideIndex');
679
- return helpers_1.setHideIndex(this, index, true);
683
+ return (0, helpers_1.setHideIndex)(this, index, true);
680
684
  }
681
685
  async unhideIndex(index) {
682
686
  this._emitCollectionApiCall('unhideIndex');
683
- return helpers_1.setHideIndex(this, index, false);
687
+ return (0, helpers_1.setHideIndex)(this, index, false);
684
688
  }
685
689
  };
686
690
  __decorate([
687
691
  decorators_1.returnsPromise,
688
- decorators_1.returnType('AggregationCursor'),
689
- decorators_1.apiVersions([1])
692
+ (0, decorators_1.returnType)('AggregationCursor'),
693
+ (0, decorators_1.apiVersions)([1])
690
694
  ], Collection.prototype, "aggregate", null);
691
695
  __decorate([
692
696
  decorators_1.returnsPromise,
693
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
694
- decorators_1.apiVersions([1])
697
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
698
+ (0, decorators_1.apiVersions)([1])
695
699
  ], Collection.prototype, "bulkWrite", null);
696
700
  __decorate([
697
701
  decorators_1.returnsPromise,
698
702
  decorators_1.deprecated,
699
- decorators_1.serverVersions([enums_1.ServerVersions.earliest, '4.0.0']),
700
- decorators_1.apiVersions([])
703
+ (0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '4.0.0']),
704
+ (0, decorators_1.apiVersions)([])
701
705
  ], Collection.prototype, "count", null);
702
706
  __decorate([
703
707
  decorators_1.returnsPromise,
704
- decorators_1.serverVersions(['4.0.3', enums_1.ServerVersions.latest]),
705
- decorators_1.apiVersions([1])
708
+ (0, decorators_1.serverVersions)(['4.0.3', enums_1.ServerVersions.latest]),
709
+ (0, decorators_1.apiVersions)([1])
706
710
  ], Collection.prototype, "countDocuments", null);
707
711
  __decorate([
708
712
  decorators_1.returnsPromise,
709
- decorators_1.apiVersions([1])
713
+ (0, decorators_1.apiVersions)([1])
710
714
  ], Collection.prototype, "deleteMany", null);
711
715
  __decorate([
712
716
  decorators_1.returnsPromise,
713
- decorators_1.apiVersions([1])
717
+ (0, decorators_1.apiVersions)([1])
714
718
  ], Collection.prototype, "deleteOne", null);
715
719
  __decorate([
716
720
  decorators_1.returnsPromise,
717
- decorators_1.apiVersions([])
721
+ (0, decorators_1.apiVersions)([])
718
722
  ], Collection.prototype, "distinct", null);
719
723
  __decorate([
720
724
  decorators_1.returnsPromise,
721
- decorators_1.serverVersions(['4.0.3', enums_1.ServerVersions.latest]),
722
- decorators_1.apiVersions([1])
725
+ (0, decorators_1.serverVersions)(['4.0.3', enums_1.ServerVersions.latest]),
726
+ (0, decorators_1.apiVersions)([1])
723
727
  ], Collection.prototype, "estimatedDocumentCount", null);
724
728
  __decorate([
725
- decorators_1.returnType('Cursor'),
726
- decorators_1.apiVersions([1]),
729
+ (0, decorators_1.returnType)('Cursor'),
730
+ (0, decorators_1.apiVersions)([1]),
727
731
  decorators_1.returnsPromise
728
732
  ], Collection.prototype, "find", null);
729
733
  __decorate([
730
734
  decorators_1.returnsPromise,
731
735
  decorators_1.deprecated,
732
- decorators_1.apiVersions([1])
736
+ (0, decorators_1.apiVersions)([1])
733
737
  ], Collection.prototype, "findAndModify", null);
734
738
  __decorate([
735
739
  decorators_1.returnsPromise,
736
- decorators_1.returnType('Document'),
737
- decorators_1.apiVersions([1])
740
+ (0, decorators_1.returnType)('Document'),
741
+ (0, decorators_1.apiVersions)([1])
738
742
  ], Collection.prototype, "findOne", null);
739
743
  __decorate([
740
744
  decorators_1.returnsPromise,
741
- decorators_1.apiVersions([])
745
+ (0, decorators_1.apiVersions)([])
742
746
  ], Collection.prototype, "renameCollection", null);
743
747
  __decorate([
744
748
  decorators_1.returnsPromise,
745
- decorators_1.returnType('Document'),
746
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
747
- decorators_1.apiVersions([1])
749
+ (0, decorators_1.returnType)('Document'),
750
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
751
+ (0, decorators_1.apiVersions)([1])
748
752
  ], Collection.prototype, "findOneAndDelete", null);
749
753
  __decorate([
750
754
  decorators_1.returnsPromise,
751
- decorators_1.returnType('Document'),
752
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
753
- decorators_1.apiVersions([1])
755
+ (0, decorators_1.returnType)('Document'),
756
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
757
+ (0, decorators_1.apiVersions)([1])
754
758
  ], Collection.prototype, "findOneAndReplace", null);
755
759
  __decorate([
756
760
  decorators_1.returnsPromise,
757
- decorators_1.returnType('Document'),
758
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
759
- decorators_1.apiVersions([1])
761
+ (0, decorators_1.returnType)('Document'),
762
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
763
+ (0, decorators_1.apiVersions)([1])
760
764
  ], Collection.prototype, "findOneAndUpdate", null);
761
765
  __decorate([
762
766
  decorators_1.returnsPromise,
763
767
  decorators_1.deprecated,
764
- decorators_1.serverVersions([enums_1.ServerVersions.earliest, '3.6.0']),
765
- decorators_1.apiVersions([1])
768
+ (0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '3.6.0']),
769
+ (0, decorators_1.apiVersions)([1])
766
770
  ], Collection.prototype, "insert", null);
767
771
  __decorate([
768
772
  decorators_1.returnsPromise,
769
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
770
- decorators_1.apiVersions([1])
773
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
774
+ (0, decorators_1.apiVersions)([1])
771
775
  ], Collection.prototype, "insertMany", null);
772
776
  __decorate([
773
777
  decorators_1.returnsPromise,
774
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
775
- decorators_1.apiVersions([1])
778
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
779
+ (0, decorators_1.apiVersions)([1])
776
780
  ], Collection.prototype, "insertOne", null);
777
781
  __decorate([
778
782
  decorators_1.returnsPromise,
779
- decorators_1.apiVersions([1])
783
+ (0, decorators_1.apiVersions)([1])
780
784
  ], Collection.prototype, "isCapped", null);
781
785
  __decorate([
782
786
  decorators_1.returnsPromise,
783
787
  decorators_1.deprecated,
784
- decorators_1.serverVersions([enums_1.ServerVersions.earliest, '3.2.0']),
785
- decorators_1.apiVersions([1])
788
+ (0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '3.2.0']),
789
+ (0, decorators_1.apiVersions)([1])
786
790
  ], Collection.prototype, "remove", null);
787
791
  __decorate([
788
792
  decorators_1.deprecated
789
793
  ], Collection.prototype, "save", null);
790
794
  __decorate([
791
795
  decorators_1.returnsPromise,
792
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
793
- decorators_1.apiVersions([1])
796
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
797
+ (0, decorators_1.apiVersions)([1])
794
798
  ], Collection.prototype, "replaceOne", null);
795
799
  __decorate([
796
800
  decorators_1.returnsPromise,
797
801
  decorators_1.deprecated,
798
- decorators_1.serverVersions([enums_1.ServerVersions.earliest, '3.2.0']),
799
- decorators_1.apiVersions([1])
802
+ (0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '3.2.0']),
803
+ (0, decorators_1.apiVersions)([1])
800
804
  ], Collection.prototype, "update", null);
801
805
  __decorate([
802
806
  decorators_1.returnsPromise,
803
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
804
- decorators_1.apiVersions([1])
807
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
808
+ (0, decorators_1.apiVersions)([1])
805
809
  ], Collection.prototype, "updateMany", null);
806
810
  __decorate([
807
811
  decorators_1.returnsPromise,
808
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
809
- decorators_1.apiVersions([1])
812
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
813
+ (0, decorators_1.apiVersions)([1])
810
814
  ], Collection.prototype, "updateOne", null);
811
815
  __decorate([
812
816
  decorators_1.returnsPromise,
813
- decorators_1.apiVersions([])
817
+ (0, decorators_1.apiVersions)([])
814
818
  ], Collection.prototype, "convertToCapped", null);
815
819
  __decorate([
816
820
  decorators_1.returnsPromise,
817
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
818
- decorators_1.apiVersions([1])
821
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
822
+ (0, decorators_1.apiVersions)([1])
819
823
  ], Collection.prototype, "createIndexes", null);
820
824
  __decorate([
821
825
  decorators_1.returnsPromise,
822
- decorators_1.apiVersions([1])
826
+ (0, decorators_1.apiVersions)([1])
823
827
  ], Collection.prototype, "createIndex", null);
824
828
  __decorate([
825
829
  decorators_1.returnsPromise,
826
- decorators_1.apiVersions([1])
830
+ (0, decorators_1.apiVersions)([1])
827
831
  ], Collection.prototype, "ensureIndex", null);
828
832
  __decorate([
829
833
  decorators_1.returnsPromise,
830
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
831
- decorators_1.apiVersions([1])
834
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
835
+ (0, decorators_1.apiVersions)([1])
832
836
  ], Collection.prototype, "getIndexes", null);
833
837
  __decorate([
834
838
  decorators_1.returnsPromise,
835
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
836
- decorators_1.apiVersions([1])
839
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
840
+ (0, decorators_1.apiVersions)([1])
837
841
  ], Collection.prototype, "getIndexSpecs", null);
838
842
  __decorate([
839
843
  decorators_1.returnsPromise,
840
- decorators_1.apiVersions([1])
844
+ (0, decorators_1.apiVersions)([1])
841
845
  ], Collection.prototype, "getIndices", null);
842
846
  __decorate([
843
847
  decorators_1.returnsPromise,
844
- decorators_1.serverVersions(['3.2.0', enums_1.ServerVersions.latest]),
845
- decorators_1.apiVersions([1])
848
+ (0, decorators_1.serverVersions)(['3.2.0', enums_1.ServerVersions.latest]),
849
+ (0, decorators_1.apiVersions)([1])
846
850
  ], Collection.prototype, "getIndexKeys", null);
847
851
  __decorate([
848
852
  decorators_1.returnsPromise,
849
- decorators_1.apiVersions([1])
853
+ (0, decorators_1.apiVersions)([1])
850
854
  ], Collection.prototype, "dropIndexes", null);
851
855
  __decorate([
852
856
  decorators_1.returnsPromise,
853
- decorators_1.apiVersions([1])
857
+ (0, decorators_1.apiVersions)([1])
854
858
  ], Collection.prototype, "dropIndex", null);
855
859
  __decorate([
856
860
  decorators_1.returnsPromise,
857
- decorators_1.apiVersions([])
861
+ (0, decorators_1.apiVersions)([])
858
862
  ], Collection.prototype, "totalIndexSize", null);
859
863
  __decorate([
860
864
  decorators_1.returnsPromise,
861
- decorators_1.topologies([enums_1.Topologies.Standalone]),
862
- decorators_1.apiVersions([])
865
+ (0, decorators_1.topologies)([enums_1.Topologies.Standalone]),
866
+ (0, decorators_1.apiVersions)([])
863
867
  ], Collection.prototype, "reIndex", null);
864
868
  __decorate([
865
- decorators_1.returnType('Database')
869
+ (0, decorators_1.returnType)('Database')
866
870
  ], Collection.prototype, "getDB", null);
867
871
  __decorate([
868
- decorators_1.returnType('Mongo')
872
+ (0, decorators_1.returnType)('Mongo')
869
873
  ], Collection.prototype, "getMongo", null);
870
874
  __decorate([
871
875
  decorators_1.returnsPromise,
872
- decorators_1.apiVersions([])
876
+ (0, decorators_1.apiVersions)([])
873
877
  ], Collection.prototype, "dataSize", null);
874
878
  __decorate([
875
879
  decorators_1.returnsPromise,
876
- decorators_1.apiVersions([])
880
+ (0, decorators_1.apiVersions)([])
877
881
  ], Collection.prototype, "storageSize", null);
878
882
  __decorate([
879
883
  decorators_1.returnsPromise,
880
- decorators_1.apiVersions([])
884
+ (0, decorators_1.apiVersions)([])
881
885
  ], Collection.prototype, "totalSize", null);
882
886
  __decorate([
883
887
  decorators_1.returnsPromise,
884
- decorators_1.apiVersions([1])
888
+ (0, decorators_1.apiVersions)([1])
885
889
  ], Collection.prototype, "drop", null);
886
890
  __decorate([
887
891
  decorators_1.returnsPromise,
888
- decorators_1.apiVersions([1])
892
+ (0, decorators_1.apiVersions)([1])
889
893
  ], Collection.prototype, "exists", null);
890
894
  __decorate([
891
895
  decorators_1.returnsPromise,
892
- decorators_1.apiVersions([1])
896
+ (0, decorators_1.apiVersions)([1])
893
897
  ], Collection.prototype, "runCommand", null);
894
898
  __decorate([
895
- decorators_1.returnType('Explainable'),
896
- decorators_1.apiVersions([1])
899
+ (0, decorators_1.returnType)('Explainable'),
900
+ (0, decorators_1.apiVersions)([1])
897
901
  ], Collection.prototype, "explain", null);
898
902
  __decorate([
899
903
  decorators_1.returnsPromise,
900
- decorators_1.apiVersions([])
904
+ (0, decorators_1.apiVersions)([])
901
905
  ], Collection.prototype, "stats", null);
902
906
  __decorate([
903
907
  decorators_1.returnsPromise,
904
- decorators_1.apiVersions([])
908
+ (0, decorators_1.apiVersions)([])
905
909
  ], Collection.prototype, "latencyStats", null);
906
910
  __decorate([
907
911
  decorators_1.returnsPromise,
908
- decorators_1.returnType('Bulk'),
909
- decorators_1.apiVersions([1])
912
+ (0, decorators_1.returnType)('Bulk'),
913
+ (0, decorators_1.apiVersions)([1])
910
914
  ], Collection.prototype, "initializeOrderedBulkOp", null);
911
915
  __decorate([
912
916
  decorators_1.returnsPromise,
913
- decorators_1.returnType('Bulk'),
914
- decorators_1.apiVersions([1])
917
+ (0, decorators_1.returnType)('Bulk'),
918
+ (0, decorators_1.apiVersions)([1])
915
919
  ], Collection.prototype, "initializeUnorderedBulkOp", null);
916
920
  __decorate([
917
- decorators_1.returnType('PlanCache'),
918
- decorators_1.apiVersions([])
921
+ (0, decorators_1.returnType)('PlanCache'),
922
+ (0, decorators_1.apiVersions)([])
919
923
  ], Collection.prototype, "getPlanCache", null);
920
924
  __decorate([
921
925
  decorators_1.returnsPromise,
922
926
  decorators_1.deprecated,
923
- decorators_1.serverVersions([enums_1.ServerVersions.earliest, '4.9.0']),
924
- decorators_1.apiVersions([])
927
+ (0, decorators_1.serverVersions)([enums_1.ServerVersions.earliest, '4.9.0']),
928
+ (0, decorators_1.apiVersions)([])
925
929
  ], Collection.prototype, "mapReduce", null);
926
930
  __decorate([
927
931
  decorators_1.returnsPromise,
928
- decorators_1.apiVersions([])
932
+ (0, decorators_1.apiVersions)([])
929
933
  ], Collection.prototype, "validate", null);
930
934
  __decorate([
931
935
  decorators_1.returnsPromise,
932
- decorators_1.topologies([enums_1.Topologies.Sharded]),
933
- decorators_1.apiVersions([])
936
+ (0, decorators_1.topologies)([enums_1.Topologies.Sharded]),
937
+ (0, decorators_1.apiVersions)([])
934
938
  ], Collection.prototype, "getShardVersion", null);
935
939
  __decorate([
936
940
  decorators_1.returnsPromise,
937
- decorators_1.topologies([enums_1.Topologies.Sharded]),
938
- decorators_1.apiVersions([])
941
+ (0, decorators_1.topologies)([enums_1.Topologies.Sharded]),
942
+ (0, decorators_1.apiVersions)([])
939
943
  ], Collection.prototype, "getShardDistribution", null);
940
944
  __decorate([
941
- decorators_1.serverVersions(['3.1.0', enums_1.ServerVersions.latest]),
942
- decorators_1.topologies([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]),
943
- decorators_1.apiVersions([1]),
945
+ (0, decorators_1.serverVersions)(['3.1.0', enums_1.ServerVersions.latest]),
946
+ (0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]),
947
+ (0, decorators_1.apiVersions)([1]),
944
948
  decorators_1.returnsPromise
945
949
  ], Collection.prototype, "watch", null);
946
950
  __decorate([
947
- decorators_1.serverVersions(['4.4.0', enums_1.ServerVersions.latest]),
951
+ (0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]),
948
952
  decorators_1.returnsPromise,
949
- decorators_1.apiVersions([1])
953
+ (0, decorators_1.apiVersions)([1])
950
954
  ], Collection.prototype, "hideIndex", null);
951
955
  __decorate([
952
- decorators_1.serverVersions(['4.4.0', enums_1.ServerVersions.latest]),
956
+ (0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]),
953
957
  decorators_1.returnsPromise,
954
- decorators_1.apiVersions([1])
958
+ (0, decorators_1.apiVersions)([1])
955
959
  ], Collection.prototype, "unhideIndex", null);
956
960
  Collection = __decorate([
957
961
  decorators_1.shellApiClassDefault,