@mongosh/shell-api 1.2.3 → 1.4.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.
Files changed (43) hide show
  1. package/lib/abstract-cursor.d.ts +1 -1
  2. package/lib/abstract-cursor.js +14 -14
  3. package/lib/abstract-cursor.js.map +1 -1
  4. package/lib/bulk.js +31 -31
  5. package/lib/bulk.js.map +1 -1
  6. package/lib/change-stream-cursor.js +2 -2
  7. package/lib/change-stream-cursor.js.map +1 -1
  8. package/lib/collection.d.ts +3 -3
  9. package/lib/collection.js +183 -164
  10. package/lib/collection.js.map +1 -1
  11. package/lib/cursor.js +28 -28
  12. package/lib/cursor.js.map +1 -1
  13. package/lib/database.d.ts +2 -2
  14. package/lib/database.js +127 -124
  15. package/lib/database.js.map +1 -1
  16. package/lib/decorators.js +5 -5
  17. package/lib/decorators.js.map +1 -1
  18. package/lib/explainable.js +17 -17
  19. package/lib/explainable.js.map +1 -1
  20. package/lib/field-level-encryption.d.ts +11 -5
  21. package/lib/field-level-encryption.js +52 -29
  22. package/lib/field-level-encryption.js.map +1 -1
  23. package/lib/helpers.js +22 -2
  24. package/lib/helpers.js.map +1 -1
  25. package/lib/mongo.d.ts +7 -6
  26. package/lib/mongo.js +88 -58
  27. package/lib/mongo.js.map +1 -1
  28. package/lib/plan-cache.js +4 -4
  29. package/lib/plan-cache.js.map +1 -1
  30. package/lib/replica-set.js +25 -25
  31. package/lib/replica-set.js.map +1 -1
  32. package/lib/session.js +4 -4
  33. package/lib/session.js.map +1 -1
  34. package/lib/shard.js +81 -81
  35. package/lib/shard.js.map +1 -1
  36. package/lib/shell-api.js +24 -24
  37. package/lib/shell-api.js.map +1 -1
  38. package/lib/shell-bson.js +13 -13
  39. package/lib/shell-bson.js.map +1 -1
  40. package/lib/shell-instance-state.d.ts +1 -1
  41. package/lib/shell-instance-state.js +8 -8
  42. package/lib/shell-instance-state.js.map +1 -1
  43. package/package.json +8 -7
package/lib/database.js CHANGED
@@ -35,7 +35,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
35
35
  }
36
36
  if (typeof prop !== 'string' ||
37
37
  prop.startsWith('_') ||
38
- !helpers_1.isValidCollectionName(prop)) {
38
+ !(0, helpers_1.isValidCollectionName)(prop)) {
39
39
  return;
40
40
  }
41
41
  if (!collections[prop]) {
@@ -73,7 +73,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
73
73
  });
74
74
  }
75
75
  async _runCommand(cmd, options = {}) {
76
- return this._mongo._serviceProvider.runCommandWithCheck(this._name, helpers_1.adjustRunCommand(cmd, this._instanceState.shellBson), { ...this._mongo._getExplicitlyRequestedReadPref(), ...await this._baseOptions(), ...options });
76
+ return this._mongo._serviceProvider.runCommandWithCheck(this._name, (0, helpers_1.adjustRunCommand)(cmd, this._instanceState.shellBson), { ...this._mongo._getExplicitlyRequestedReadPref(), ...await this._baseOptions(), ...options });
77
77
  }
78
78
  async _runAdminCommand(cmd, options = {}) {
79
79
  return this.getSiblingDB('admin')._runCommand(cmd, { ...await this._baseOptions(), ...options });
@@ -146,7 +146,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
146
146
  return await this._listCollections(filter, options);
147
147
  }
148
148
  async runCommand(cmd) {
149
- helpers_1.assertArgsDefinedType([cmd], [['string', 'object']], 'Database.runCommand');
149
+ (0, helpers_1.assertArgsDefinedType)([cmd], [['string', 'object']], 'Database.runCommand');
150
150
  if (typeof cmd === 'string') {
151
151
  cmd = { [cmd]: 1 };
152
152
  }
@@ -157,7 +157,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
157
157
  return this._runCommand(cmd);
158
158
  }
159
159
  async adminCommand(cmd) {
160
- helpers_1.assertArgsDefinedType([cmd], [['string', 'object']], 'Database.adminCommand');
160
+ (0, helpers_1.assertArgsDefinedType)([cmd], [['string', 'object']], 'Database.adminCommand');
161
161
  if (typeof cmd === 'string') {
162
162
  cmd = { [cmd]: 1 };
163
163
  }
@@ -168,22 +168,22 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
168
168
  return await this._runAdminCommand(cmd, {});
169
169
  }
170
170
  async aggregate(pipeline, options) {
171
- helpers_1.assertArgsDefinedType([pipeline], [true], 'Database.aggregate');
171
+ (0, helpers_1.assertArgsDefinedType)([pipeline], [true], 'Database.aggregate');
172
172
  this._emitDatabaseApiCall('aggregate', { options, pipeline });
173
- const { aggOptions, dbOptions, explain } = helpers_1.adaptAggregateOptions(options);
173
+ const { aggOptions, dbOptions, explain } = (0, helpers_1.adaptAggregateOptions)(options);
174
174
  const providerCursor = this._mongo._serviceProvider.aggregateDb(this._name, pipeline, { ...await this._baseOptions(), ...aggOptions }, dbOptions);
175
175
  const cursor = new index_1.AggregationCursor(this._mongo, providerCursor);
176
176
  if (explain) {
177
177
  return await cursor.explain(explain);
178
178
  }
179
- else if (helpers_1.shouldRunAggregationImmediately(pipeline)) {
179
+ else if ((0, helpers_1.shouldRunAggregationImmediately)(pipeline)) {
180
180
  await cursor.hasNext();
181
181
  }
182
182
  this._mongo._instanceState.currentCursor = cursor;
183
183
  return cursor;
184
184
  }
185
185
  getSiblingDB(db) {
186
- helpers_1.assertArgsDefinedType([db], ['string'], 'Database.getSiblingDB');
186
+ (0, helpers_1.assertArgsDefinedType)([db], ['string'], 'Database.getSiblingDB');
187
187
  this._emitDatabaseApiCall('getSiblingDB', { db });
188
188
  if (this._session) {
189
189
  return this._session.getDatabase(db);
@@ -191,9 +191,9 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
191
191
  return this._mongo._getDb(db);
192
192
  }
193
193
  getCollection(coll) {
194
- helpers_1.assertArgsDefinedType([coll], ['string'], 'Database.getColl');
194
+ (0, helpers_1.assertArgsDefinedType)([coll], ['string'], 'Database.getColl');
195
195
  this._emitDatabaseApiCall('getCollection', { coll });
196
- if (!helpers_1.isValidCollectionName(coll)) {
196
+ if (!(0, helpers_1.isValidCollectionName)(coll)) {
197
197
  throw new errors_1.MongoshInvalidInputError(`Invalid collection name: ${coll}`, errors_1.CommonErrors.InvalidArgument);
198
198
  }
199
199
  const collections = this._collections;
@@ -206,48 +206,48 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
206
206
  return await this._mongo._serviceProvider.dropDatabase(this._name, { ...await this._baseOptions(), writeConcern });
207
207
  }
208
208
  async createUser(user, writeConcern) {
209
- helpers_1.assertArgsDefinedType([user], ['object'], 'Database.createUser');
210
- helpers_1.assertKeysDefined(user, ['user', 'roles']);
209
+ (0, helpers_1.assertArgsDefinedType)([user], ['object'], 'Database.createUser');
210
+ (0, helpers_1.assertKeysDefined)(user, ['user', 'roles']);
211
211
  if (this._name === '$external') {
212
212
  if ('pwd' in user) {
213
213
  throw new errors_1.MongoshInvalidInputError('Cannot set password for users on the $external database', errors_1.CommonErrors.InvalidArgument);
214
214
  }
215
215
  }
216
216
  else {
217
- helpers_1.assertKeysDefined(user, ['pwd']);
217
+ (0, helpers_1.assertKeysDefined)(user, ['pwd']);
218
218
  }
219
219
  this._emitDatabaseApiCall('createUser', {});
220
220
  if (user.createUser) {
221
221
  throw new errors_1.MongoshInvalidInputError('Cannot set createUser field in helper method', errors_1.CommonErrors.InvalidArgument);
222
222
  }
223
- const command = helpers_1.adaptOptions({ user: 'createUser', passwordDigestor: null }, {}, user);
223
+ const command = (0, helpers_1.adaptOptions)({ user: 'createUser', passwordDigestor: null }, {}, user);
224
224
  if (writeConcern) {
225
225
  command.writeConcern = writeConcern;
226
226
  }
227
- const digestPwd = helpers_1.processDigestPassword(user.user, user.passwordDigestor, command);
227
+ const digestPwd = (0, helpers_1.processDigestPassword)(user.user, user.passwordDigestor, command);
228
228
  const orderedCmd = { createUser: command.createUser, ...command, ...digestPwd };
229
229
  return await this._runCommand(orderedCmd);
230
230
  }
231
231
  async updateUser(username, userDoc, writeConcern) {
232
- helpers_1.assertArgsDefinedType([username, userDoc], ['string', 'object'], 'Database.updateUser');
232
+ (0, helpers_1.assertArgsDefinedType)([username, userDoc], ['string', 'object'], 'Database.updateUser');
233
233
  this._emitDatabaseApiCall('updateUser', {});
234
234
  if (userDoc.passwordDigestor && userDoc.passwordDigestor !== 'server' && userDoc.passwordDigestor !== 'client') {
235
235
  throw new errors_1.MongoshInvalidInputError(`Invalid field: passwordDigestor must be 'client' or 'server', got ${userDoc.passwordDigestor}`, errors_1.CommonErrors.InvalidArgument);
236
236
  }
237
- const command = helpers_1.adaptOptions({ passwordDigestor: null }, {
237
+ const command = (0, helpers_1.adaptOptions)({ passwordDigestor: null }, {
238
238
  updateUser: username
239
239
  }, userDoc);
240
240
  if (writeConcern) {
241
241
  command.writeConcern = writeConcern;
242
242
  }
243
- const digestPwd = helpers_1.processDigestPassword(username, userDoc.passwordDigestor, command);
243
+ const digestPwd = (0, helpers_1.processDigestPassword)(username, userDoc.passwordDigestor, command);
244
244
  const orderedCmd = { updateUser: command.updateUser, ...command, ...digestPwd };
245
245
  return await this._runCommand(orderedCmd);
246
246
  }
247
247
  async changeUserPassword(username, password, writeConcern) {
248
- helpers_1.assertArgsDefinedType([username, password], ['string', 'string'], 'Database.changeUserPassword');
248
+ (0, helpers_1.assertArgsDefinedType)([username, password], ['string', 'string'], 'Database.changeUserPassword');
249
249
  this._emitDatabaseApiCall('changeUserPassword', {});
250
- const command = helpers_1.adaptOptions({}, {
250
+ const command = (0, helpers_1.adaptOptions)({}, {
251
251
  updateUser: username,
252
252
  pwd: password
253
253
  }, {});
@@ -263,7 +263,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
263
263
  return await this._runCommand({ logout: 1 });
264
264
  }
265
265
  async dropUser(username, writeConcern) {
266
- helpers_1.assertArgsDefinedType([username], ['string'], 'Database.dropUser');
266
+ (0, helpers_1.assertArgsDefinedType)([username], ['string'], 'Database.dropUser');
267
267
  this._emitDatabaseApiCall('dropUser', {});
268
268
  const cmd = { dropUser: username };
269
269
  if (writeConcern) {
@@ -314,7 +314,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
314
314
  return await this._mongo._serviceProvider.authenticate(authDoc);
315
315
  }
316
316
  async grantRolesToUser(username, roles, writeConcern) {
317
- helpers_1.assertArgsDefinedType([username, roles], ['string', true], 'Database.grantRolesToUser');
317
+ (0, helpers_1.assertArgsDefinedType)([username, roles], ['string', true], 'Database.grantRolesToUser');
318
318
  this._emitDatabaseApiCall('grantRolesToUser', {});
319
319
  const cmd = { grantRolesToUser: username, roles: roles };
320
320
  if (writeConcern) {
@@ -323,7 +323,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
323
323
  return await this._runCommand(cmd);
324
324
  }
325
325
  async revokeRolesFromUser(username, roles, writeConcern) {
326
- helpers_1.assertArgsDefinedType([username, roles], ['string', true], 'Database.revokeRolesFromUser');
326
+ (0, helpers_1.assertArgsDefinedType)([username, roles], ['string', true], 'Database.revokeRolesFromUser');
327
327
  this._emitDatabaseApiCall('revokeRolesFromUser', {});
328
328
  const cmd = { revokeRolesFromUser: username, roles: roles };
329
329
  if (writeConcern) {
@@ -332,9 +332,9 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
332
332
  return await this._runCommand(cmd);
333
333
  }
334
334
  async getUser(username, options = {}) {
335
- helpers_1.assertArgsDefinedType([username], ['string'], 'Database.getUser');
335
+ (0, helpers_1.assertArgsDefinedType)([username], ['string'], 'Database.getUser');
336
336
  this._emitDatabaseApiCall('getUser', { username: username });
337
- const command = helpers_1.adaptOptions({}, { usersInfo: { user: username, db: this._name } }, options);
337
+ const command = (0, helpers_1.adaptOptions)({}, { usersInfo: { user: username, db: this._name } }, options);
338
338
  const result = await this._runCommand(command);
339
339
  if (result.users === undefined) {
340
340
  throw new errors_1.MongoshInternalError('No users were returned from the userInfo command');
@@ -348,16 +348,16 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
348
348
  }
349
349
  async getUsers(options = {}) {
350
350
  this._emitDatabaseApiCall('getUsers', { options: options });
351
- const command = helpers_1.adaptOptions({}, { usersInfo: 1 }, options);
351
+ const command = (0, helpers_1.adaptOptions)({}, { usersInfo: 1 }, options);
352
352
  return await this._runCommand(command);
353
353
  }
354
354
  async createCollection(name, options = {}) {
355
- helpers_1.assertArgsDefinedType([name], ['string'], 'Database.createCollection');
355
+ (0, helpers_1.assertArgsDefinedType)([name], ['string'], 'Database.createCollection');
356
356
  this._emitDatabaseApiCall('createCollection', { name: name, options: options });
357
357
  return await this._mongo._serviceProvider.createCollection(this._name, name, { ...await this._baseOptions(), ...options });
358
358
  }
359
359
  async createView(name, source, pipeline, options = {}) {
360
- helpers_1.assertArgsDefinedType([name, source, pipeline], ['string', 'string', true], 'Database.createView');
360
+ (0, helpers_1.assertArgsDefinedType)([name, source, pipeline], ['string', 'string', true], 'Database.createView');
361
361
  this._emitDatabaseApiCall('createView', { name, source, pipeline, options });
362
362
  const ccOpts = {
363
363
  ...await this._baseOptions(),
@@ -370,13 +370,13 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
370
370
  return await this._mongo._serviceProvider.createCollection(this._name, name, ccOpts);
371
371
  }
372
372
  async createRole(role, writeConcern) {
373
- helpers_1.assertArgsDefinedType([role], ['object'], 'Database.createRole');
374
- helpers_1.assertKeysDefined(role, ['role', 'privileges', 'roles']);
373
+ (0, helpers_1.assertArgsDefinedType)([role], ['object'], 'Database.createRole');
374
+ (0, helpers_1.assertKeysDefined)(role, ['role', 'privileges', 'roles']);
375
375
  this._emitDatabaseApiCall('createRole', {});
376
376
  if (role.createRole) {
377
377
  throw new errors_1.MongoshInvalidInputError('Cannot set createRole field in helper method', errors_1.CommonErrors.InvalidArgument);
378
378
  }
379
- const command = helpers_1.adaptOptions({ role: 'createRole' }, {}, role);
379
+ const command = (0, helpers_1.adaptOptions)({ role: 'createRole' }, {}, role);
380
380
  if (writeConcern) {
381
381
  command.writeConcern = writeConcern;
382
382
  }
@@ -384,9 +384,9 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
384
384
  return await this._runCommand(orderedCmd);
385
385
  }
386
386
  async updateRole(rolename, roleDoc, writeConcern) {
387
- helpers_1.assertArgsDefinedType([rolename, roleDoc], ['string', 'object'], 'Database.updateRole');
387
+ (0, helpers_1.assertArgsDefinedType)([rolename, roleDoc], ['string', 'object'], 'Database.updateRole');
388
388
  this._emitDatabaseApiCall('updateRole', {});
389
- const command = helpers_1.adaptOptions({}, {
389
+ const command = (0, helpers_1.adaptOptions)({}, {
390
390
  updateRole: rolename
391
391
  }, roleDoc);
392
392
  if (writeConcern) {
@@ -396,7 +396,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
396
396
  return await this._runCommand(orderedCmd);
397
397
  }
398
398
  async dropRole(rolename, writeConcern) {
399
- helpers_1.assertArgsDefinedType([rolename], ['string'], 'Database.dropRole');
399
+ (0, helpers_1.assertArgsDefinedType)([rolename], ['string'], 'Database.dropRole');
400
400
  this._emitDatabaseApiCall('dropRole', {});
401
401
  const cmd = { dropRole: rolename };
402
402
  if (writeConcern) {
@@ -413,7 +413,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
413
413
  return await this._runCommand(cmd);
414
414
  }
415
415
  async grantRolesToRole(rolename, roles, writeConcern) {
416
- helpers_1.assertArgsDefinedType([rolename, roles], ['string', true], 'Database.grantRolesToRole');
416
+ (0, helpers_1.assertArgsDefinedType)([rolename, roles], ['string', true], 'Database.grantRolesToRole');
417
417
  this._emitDatabaseApiCall('grantRolesToRole', {});
418
418
  const cmd = { grantRolesToRole: rolename, roles: roles };
419
419
  if (writeConcern) {
@@ -422,7 +422,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
422
422
  return await this._runCommand(cmd);
423
423
  }
424
424
  async revokeRolesFromRole(rolename, roles, writeConcern) {
425
- helpers_1.assertArgsDefinedType([rolename, roles], ['string', true], 'Database.revokeRolesFromRole');
425
+ (0, helpers_1.assertArgsDefinedType)([rolename, roles], ['string', true], 'Database.revokeRolesFromRole');
426
426
  this._emitDatabaseApiCall('revokeRolesFromRole', {});
427
427
  const cmd = { revokeRolesFromRole: rolename, roles: roles };
428
428
  if (writeConcern) {
@@ -431,7 +431,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
431
431
  return await this._runCommand(cmd);
432
432
  }
433
433
  async grantPrivilegesToRole(rolename, privileges, writeConcern) {
434
- helpers_1.assertArgsDefinedType([rolename, privileges], ['string', true], 'Database.grantPrivilegesToRole');
434
+ (0, helpers_1.assertArgsDefinedType)([rolename, privileges], ['string', true], 'Database.grantPrivilegesToRole');
435
435
  this._emitDatabaseApiCall('grantPrivilegesToRole', {});
436
436
  const cmd = { grantPrivilegesToRole: rolename, privileges: privileges };
437
437
  if (writeConcern) {
@@ -440,7 +440,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
440
440
  return await this._runCommand(cmd);
441
441
  }
442
442
  async revokePrivilegesFromRole(rolename, privileges, writeConcern) {
443
- helpers_1.assertArgsDefinedType([rolename, privileges], ['string', true], 'Database.revokePrivilegesFromRole');
443
+ (0, helpers_1.assertArgsDefinedType)([rolename, privileges], ['string', true], 'Database.revokePrivilegesFromRole');
444
444
  this._emitDatabaseApiCall('revokePrivilegesFromRole', {});
445
445
  const cmd = { revokePrivilegesFromRole: rolename, privileges: privileges };
446
446
  if (writeConcern) {
@@ -449,9 +449,9 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
449
449
  return await this._runCommand(cmd);
450
450
  }
451
451
  async getRole(rolename, options = {}) {
452
- helpers_1.assertArgsDefinedType([rolename], ['string'], 'Database.getRole');
452
+ (0, helpers_1.assertArgsDefinedType)([rolename], ['string'], 'Database.getRole');
453
453
  this._emitDatabaseApiCall('getRole', { rolename: rolename });
454
- const command = helpers_1.adaptOptions({}, { rolesInfo: { role: rolename, db: this._name } }, options);
454
+ const command = (0, helpers_1.adaptOptions)({}, { rolesInfo: { role: rolename, db: this._name } }, options);
455
455
  const result = await this._runCommand(command);
456
456
  if (result.roles === undefined) {
457
457
  throw new errors_1.MongoshInternalError('No roles returned from rolesInfo command');
@@ -465,18 +465,21 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
465
465
  }
466
466
  async getRoles(options = {}) {
467
467
  this._emitDatabaseApiCall('getRoles', { options: options });
468
- const command = helpers_1.adaptOptions({}, { rolesInfo: 1 }, options);
468
+ const command = (0, helpers_1.adaptOptions)({}, { rolesInfo: 1 }, options);
469
469
  return await this._runCommand(command);
470
470
  }
471
471
  async currentOp(opts = {}) {
472
472
  this._emitDatabaseApiCall('currentOp', { opts: opts });
473
+ if (typeof opts === 'boolean') {
474
+ opts = { $all: opts };
475
+ }
473
476
  return await this._runAdminCommand({
474
477
  currentOp: 1,
475
478
  ...opts
476
479
  });
477
480
  }
478
481
  async killOp(opId) {
479
- helpers_1.assertArgsDefinedType([opId], ['number'], 'Database.killOp');
482
+ (0, helpers_1.assertArgsDefinedType)([opId], ['number'], 'Database.killOp');
480
483
  this._emitDatabaseApiCall('killOp', { opId });
481
484
  return await this._runAdminCommand({
482
485
  killOp: 1,
@@ -540,7 +543,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
540
543
  return this._cachedHello;
541
544
  }
542
545
  catch (err) {
543
- if (err.codeName === 'CommandNotFound') {
546
+ if ((err === null || err === void 0 ? void 0 : err.codeName) === 'CommandNotFound') {
544
547
  const result = await this.isMaster();
545
548
  delete result.ismaster;
546
549
  this._cachedHello = result;
@@ -562,7 +565,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
562
565
  });
563
566
  }
564
567
  async stats(scaleOrOptions = 1) {
565
- helpers_1.assertArgsDefinedType([scaleOrOptions], [['number', 'object']], 'Database.stats');
568
+ (0, helpers_1.assertArgsDefinedType)([scaleOrOptions], [['number', 'object']], 'Database.stats');
566
569
  if (typeof scaleOrOptions === 'number') {
567
570
  scaleOrOptions = { scale: scaleOrOptions };
568
571
  }
@@ -603,7 +606,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
603
606
  result[c] = await this.getCollection(c).stats({ scale });
604
607
  }
605
608
  catch (error) {
606
- result[c] = { ok: 0, errmsg: error.message };
609
+ result[c] = { ok: 0, errmsg: error === null || error === void 0 ? void 0 : error.message };
607
610
  }
608
611
  }
609
612
  return new index_1.CommandResult('StatsResult', result);
@@ -661,7 +664,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
661
664
  });
662
665
  }
663
666
  async setProfilingLevel(level, opts = {}) {
664
- helpers_1.assertArgsDefinedType([level], ['number'], 'Database.setProfilingLevel');
667
+ (0, helpers_1.assertArgsDefinedType)([level], ['number'], 'Database.setProfilingLevel');
665
668
  if (level < 0 || level > 2) {
666
669
  throw new errors_1.MongoshInvalidInputError(`Input level ${level} is out of range [0..2]`, errors_1.CommonErrors.InvalidArgument);
667
670
  }
@@ -675,7 +678,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
675
678
  });
676
679
  }
677
680
  async setLogLevel(logLevel, component) {
678
- helpers_1.assertArgsDefinedType([logLevel], ['number'], 'Database.setLogLevel');
681
+ (0, helpers_1.assertArgsDefinedType)([logLevel], ['number'], 'Database.setLogLevel');
679
682
  this._emitDatabaseApiCall('setLogLevel', { logLevel: logLevel, component: component });
680
683
  let componentNames = [];
681
684
  if (typeof component === 'string') {
@@ -711,7 +714,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
711
714
  throw new errors_1.MongoshDeprecatedError('`copyDatabase()` was removed because it was deprecated in MongoDB 4.0');
712
715
  }
713
716
  async commandHelp(name) {
714
- helpers_1.assertArgsDefinedType([name], ['string'], 'Database.commandHelp');
717
+ (0, helpers_1.assertArgsDefinedType)([name], ['string'], 'Database.commandHelp');
715
718
  this._emitDatabaseApiCall('commandHelp', { name: name });
716
719
  const command = {};
717
720
  command[name] = 1;
@@ -755,7 +758,7 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
755
758
  }
756
759
  async printShardingStatus(verbose = false) {
757
760
  this._emitDatabaseApiCall('printShardingStatus', { verbose });
758
- const result = await helpers_1.getPrintableShardStatus(await helpers_1.getConfigDB(this), verbose);
761
+ const result = await (0, helpers_1.getPrintableShardStatus)(await (0, helpers_1.getConfigDB)(this), verbose);
759
762
  return new index_1.CommandResult('StatsResult', result);
760
763
  }
761
764
  async printSecondaryReplicationInfo() {
@@ -844,8 +847,8 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
844
847
  let tfirst = first.ts;
845
848
  let tlast = last.ts;
846
849
  if (tfirst && tlast) {
847
- tfirst = helpers_1.tsToSeconds(tfirst);
848
- tlast = helpers_1.tsToSeconds(tlast);
850
+ tfirst = (0, helpers_1.tsToSeconds)(tfirst);
851
+ tlast = (0, helpers_1.tsToSeconds)(tlast);
849
852
  result.timeDiff = tlast - tfirst;
850
853
  result.timeDiffHours = Math.round(result.timeDiff / 36) / 100;
851
854
  result.tFirst = (new Date(tfirst * 1000)).toString();
@@ -932,222 +935,222 @@ let Database = class Database extends decorators_1.ShellApiWithMongoClass {
932
935
  }
933
936
  };
934
937
  __decorate([
935
- decorators_1.returnType('Mongo')
938
+ (0, decorators_1.returnType)('Mongo')
936
939
  ], Database.prototype, "getMongo", null);
937
940
  __decorate([
938
941
  decorators_1.returnsPromise,
939
- decorators_1.apiVersions([1])
942
+ (0, decorators_1.apiVersions)([1])
940
943
  ], Database.prototype, "getCollectionNames", null);
941
944
  __decorate([
942
945
  decorators_1.returnsPromise,
943
- decorators_1.serverVersions(['3.0.0', enums_1.ServerVersions.latest]),
944
- decorators_1.apiVersions([1])
946
+ (0, decorators_1.serverVersions)(['3.0.0', enums_1.ServerVersions.latest]),
947
+ (0, decorators_1.apiVersions)([1])
945
948
  ], Database.prototype, "getCollectionInfos", null);
946
949
  __decorate([
947
950
  decorators_1.returnsPromise,
948
- decorators_1.apiVersions([1])
951
+ (0, decorators_1.apiVersions)([1])
949
952
  ], Database.prototype, "runCommand", null);
950
953
  __decorate([
951
954
  decorators_1.returnsPromise,
952
- decorators_1.serverVersions(['3.4.0', enums_1.ServerVersions.latest]),
953
- decorators_1.apiVersions([1])
955
+ (0, decorators_1.serverVersions)(['3.4.0', enums_1.ServerVersions.latest]),
956
+ (0, decorators_1.apiVersions)([1])
954
957
  ], Database.prototype, "adminCommand", null);
955
958
  __decorate([
956
959
  decorators_1.returnsPromise,
957
- decorators_1.returnType('AggregationCursor'),
958
- decorators_1.apiVersions([1])
960
+ (0, decorators_1.returnType)('AggregationCursor'),
961
+ (0, decorators_1.apiVersions)([1])
959
962
  ], Database.prototype, "aggregate", null);
960
963
  __decorate([
961
- decorators_1.returnType('Database')
964
+ (0, decorators_1.returnType)('Database')
962
965
  ], Database.prototype, "getSiblingDB", null);
963
966
  __decorate([
964
- decorators_1.returnType('Collection')
967
+ (0, decorators_1.returnType)('Collection')
965
968
  ], Database.prototype, "getCollection", null);
966
969
  __decorate([
967
970
  decorators_1.returnsPromise,
968
- decorators_1.apiVersions([1])
971
+ (0, decorators_1.apiVersions)([1])
969
972
  ], Database.prototype, "dropDatabase", null);
970
973
  __decorate([
971
974
  decorators_1.returnsPromise,
972
- decorators_1.apiVersions([])
975
+ (0, decorators_1.apiVersions)([])
973
976
  ], Database.prototype, "createUser", null);
974
977
  __decorate([
975
978
  decorators_1.returnsPromise
976
979
  ], Database.prototype, "updateUser", null);
977
980
  __decorate([
978
981
  decorators_1.returnsPromise,
979
- decorators_1.apiVersions([])
982
+ (0, decorators_1.apiVersions)([])
980
983
  ], Database.prototype, "changeUserPassword", null);
981
984
  __decorate([
982
985
  decorators_1.returnsPromise,
983
- decorators_1.apiVersions([])
986
+ (0, decorators_1.apiVersions)([])
984
987
  ], Database.prototype, "logout", null);
985
988
  __decorate([
986
989
  decorators_1.returnsPromise,
987
- decorators_1.apiVersions([])
990
+ (0, decorators_1.apiVersions)([])
988
991
  ], Database.prototype, "dropUser", null);
989
992
  __decorate([
990
993
  decorators_1.returnsPromise,
991
- decorators_1.apiVersions([])
994
+ (0, decorators_1.apiVersions)([])
992
995
  ], Database.prototype, "dropAllUsers", null);
993
996
  __decorate([
994
997
  decorators_1.returnsPromise
995
998
  ], Database.prototype, "auth", null);
996
999
  __decorate([
997
1000
  decorators_1.returnsPromise,
998
- decorators_1.apiVersions([])
1001
+ (0, decorators_1.apiVersions)([])
999
1002
  ], Database.prototype, "grantRolesToUser", null);
1000
1003
  __decorate([
1001
1004
  decorators_1.returnsPromise,
1002
- decorators_1.apiVersions([])
1005
+ (0, decorators_1.apiVersions)([])
1003
1006
  ], Database.prototype, "revokeRolesFromUser", null);
1004
1007
  __decorate([
1005
1008
  decorators_1.returnsPromise,
1006
- decorators_1.apiVersions([])
1009
+ (0, decorators_1.apiVersions)([])
1007
1010
  ], Database.prototype, "getUser", null);
1008
1011
  __decorate([
1009
1012
  decorators_1.returnsPromise,
1010
- decorators_1.apiVersions([])
1013
+ (0, decorators_1.apiVersions)([])
1011
1014
  ], Database.prototype, "getUsers", null);
1012
1015
  __decorate([
1013
1016
  decorators_1.returnsPromise,
1014
- decorators_1.apiVersions([1])
1017
+ (0, decorators_1.apiVersions)([1])
1015
1018
  ], Database.prototype, "createCollection", null);
1016
1019
  __decorate([
1017
1020
  decorators_1.returnsPromise,
1018
- decorators_1.apiVersions([1])
1021
+ (0, decorators_1.apiVersions)([1])
1019
1022
  ], Database.prototype, "createView", null);
1020
1023
  __decorate([
1021
1024
  decorators_1.returnsPromise,
1022
- decorators_1.apiVersions([])
1025
+ (0, decorators_1.apiVersions)([])
1023
1026
  ], Database.prototype, "createRole", null);
1024
1027
  __decorate([
1025
1028
  decorators_1.returnsPromise,
1026
- decorators_1.apiVersions([])
1029
+ (0, decorators_1.apiVersions)([])
1027
1030
  ], Database.prototype, "updateRole", null);
1028
1031
  __decorate([
1029
1032
  decorators_1.returnsPromise,
1030
- decorators_1.apiVersions([])
1033
+ (0, decorators_1.apiVersions)([])
1031
1034
  ], Database.prototype, "dropRole", null);
1032
1035
  __decorate([
1033
1036
  decorators_1.returnsPromise
1034
1037
  ], Database.prototype, "dropAllRoles", null);
1035
1038
  __decorate([
1036
1039
  decorators_1.returnsPromise,
1037
- decorators_1.apiVersions([])
1040
+ (0, decorators_1.apiVersions)([])
1038
1041
  ], Database.prototype, "grantRolesToRole", null);
1039
1042
  __decorate([
1040
1043
  decorators_1.returnsPromise,
1041
- decorators_1.apiVersions([])
1044
+ (0, decorators_1.apiVersions)([])
1042
1045
  ], Database.prototype, "revokeRolesFromRole", null);
1043
1046
  __decorate([
1044
1047
  decorators_1.returnsPromise
1045
1048
  ], Database.prototype, "grantPrivilegesToRole", null);
1046
1049
  __decorate([
1047
1050
  decorators_1.returnsPromise,
1048
- decorators_1.apiVersions([])
1051
+ (0, decorators_1.apiVersions)([])
1049
1052
  ], Database.prototype, "revokePrivilegesFromRole", null);
1050
1053
  __decorate([
1051
1054
  decorators_1.returnsPromise,
1052
- decorators_1.apiVersions([])
1055
+ (0, decorators_1.apiVersions)([])
1053
1056
  ], Database.prototype, "getRole", null);
1054
1057
  __decorate([
1055
1058
  decorators_1.returnsPromise,
1056
- decorators_1.apiVersions([])
1059
+ (0, decorators_1.apiVersions)([])
1057
1060
  ], Database.prototype, "getRoles", null);
1058
1061
  __decorate([
1059
1062
  decorators_1.returnsPromise,
1060
- decorators_1.apiVersions([])
1063
+ (0, decorators_1.apiVersions)([])
1061
1064
  ], Database.prototype, "currentOp", null);
1062
1065
  __decorate([
1063
1066
  decorators_1.returnsPromise,
1064
- decorators_1.apiVersions([])
1067
+ (0, decorators_1.apiVersions)([])
1065
1068
  ], Database.prototype, "killOp", null);
1066
1069
  __decorate([
1067
1070
  decorators_1.returnsPromise,
1068
- decorators_1.apiVersions([])
1071
+ (0, decorators_1.apiVersions)([])
1069
1072
  ], Database.prototype, "shutdownServer", null);
1070
1073
  __decorate([
1071
1074
  decorators_1.returnsPromise,
1072
- decorators_1.apiVersions([])
1075
+ (0, decorators_1.apiVersions)([])
1073
1076
  ], Database.prototype, "fsyncLock", null);
1074
1077
  __decorate([
1075
1078
  decorators_1.returnsPromise,
1076
- decorators_1.apiVersions([])
1079
+ (0, decorators_1.apiVersions)([])
1077
1080
  ], Database.prototype, "fsyncUnlock", null);
1078
1081
  __decorate([
1079
1082
  decorators_1.returnsPromise,
1080
- decorators_1.apiVersions([])
1083
+ (0, decorators_1.apiVersions)([])
1081
1084
  ], Database.prototype, "version", null);
1082
1085
  __decorate([
1083
1086
  decorators_1.returnsPromise,
1084
- decorators_1.apiVersions([])
1087
+ (0, decorators_1.apiVersions)([])
1085
1088
  ], Database.prototype, "serverBits", null);
1086
1089
  __decorate([
1087
1090
  decorators_1.returnsPromise,
1088
- decorators_1.apiVersions([])
1091
+ (0, decorators_1.apiVersions)([])
1089
1092
  ], Database.prototype, "isMaster", null);
1090
1093
  __decorate([
1091
1094
  decorators_1.returnsPromise,
1092
- decorators_1.apiVersions([1]),
1093
- decorators_1.serverVersions(['5.0.0', enums_1.ServerVersions.latest])
1095
+ (0, decorators_1.apiVersions)([1]),
1096
+ (0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest])
1094
1097
  ], Database.prototype, "hello", null);
1095
1098
  __decorate([
1096
1099
  decorators_1.returnsPromise,
1097
- decorators_1.apiVersions([])
1100
+ (0, decorators_1.apiVersions)([])
1098
1101
  ], Database.prototype, "serverBuildInfo", null);
1099
1102
  __decorate([
1100
1103
  decorators_1.returnsPromise,
1101
- decorators_1.apiVersions([])
1104
+ (0, decorators_1.apiVersions)([])
1102
1105
  ], Database.prototype, "serverStatus", null);
1103
1106
  __decorate([
1104
1107
  decorators_1.returnsPromise,
1105
- decorators_1.apiVersions([])
1108
+ (0, decorators_1.apiVersions)([])
1106
1109
  ], Database.prototype, "stats", null);
1107
1110
  __decorate([
1108
1111
  decorators_1.returnsPromise,
1109
- decorators_1.apiVersions([])
1112
+ (0, decorators_1.apiVersions)([])
1110
1113
  ], Database.prototype, "hostInfo", null);
1111
1114
  __decorate([
1112
1115
  decorators_1.returnsPromise,
1113
- decorators_1.apiVersions([])
1116
+ (0, decorators_1.apiVersions)([])
1114
1117
  ], Database.prototype, "serverCmdLineOpts", null);
1115
1118
  __decorate([
1116
1119
  decorators_1.returnsPromise,
1117
- decorators_1.serverVersions(['5.0.0', enums_1.ServerVersions.latest]),
1118
- decorators_1.apiVersions([])
1120
+ (0, decorators_1.serverVersions)(['5.0.0', enums_1.ServerVersions.latest]),
1121
+ (0, decorators_1.apiVersions)([])
1119
1122
  ], Database.prototype, "rotateCertificates", null);
1120
1123
  __decorate([
1121
1124
  decorators_1.returnsPromise,
1122
- decorators_1.apiVersions([])
1125
+ (0, decorators_1.apiVersions)([])
1123
1126
  ], Database.prototype, "printCollectionStats", null);
1124
1127
  __decorate([
1125
1128
  decorators_1.returnsPromise,
1126
- decorators_1.apiVersions([])
1129
+ (0, decorators_1.apiVersions)([])
1127
1130
  ], Database.prototype, "getFreeMonitoringStatus", null);
1128
1131
  __decorate([
1129
1132
  decorators_1.returnsPromise,
1130
- decorators_1.apiVersions([])
1133
+ (0, decorators_1.apiVersions)([])
1131
1134
  ], Database.prototype, "disableFreeMonitoring", null);
1132
1135
  __decorate([
1133
1136
  decorators_1.returnsPromise,
1134
- decorators_1.apiVersions([])
1137
+ (0, decorators_1.apiVersions)([])
1135
1138
  ], Database.prototype, "enableFreeMonitoring", null);
1136
1139
  __decorate([
1137
1140
  decorators_1.returnsPromise,
1138
- decorators_1.apiVersions([])
1141
+ (0, decorators_1.apiVersions)([])
1139
1142
  ], Database.prototype, "getProfilingStatus", null);
1140
1143
  __decorate([
1141
1144
  decorators_1.returnsPromise,
1142
- decorators_1.apiVersions([])
1145
+ (0, decorators_1.apiVersions)([])
1143
1146
  ], Database.prototype, "setProfilingLevel", null);
1144
1147
  __decorate([
1145
1148
  decorators_1.returnsPromise,
1146
- decorators_1.apiVersions([])
1149
+ (0, decorators_1.apiVersions)([])
1147
1150
  ], Database.prototype, "setLogLevel", null);
1148
1151
  __decorate([
1149
1152
  decorators_1.returnsPromise,
1150
- decorators_1.apiVersions([])
1153
+ (0, decorators_1.apiVersions)([])
1151
1154
  ], Database.prototype, "getLogComponents", null);
1152
1155
  __decorate([
1153
1156
  decorators_1.deprecated
@@ -1160,41 +1163,41 @@ __decorate([
1160
1163
  ], Database.prototype, "copyDatabase", null);
1161
1164
  __decorate([
1162
1165
  decorators_1.returnsPromise,
1163
- decorators_1.apiVersions([1])
1166
+ (0, decorators_1.apiVersions)([1])
1164
1167
  ], Database.prototype, "commandHelp", null);
1165
1168
  __decorate([
1166
1169
  decorators_1.returnsPromise,
1167
- decorators_1.apiVersions([])
1170
+ (0, decorators_1.apiVersions)([])
1168
1171
  ], Database.prototype, "listCommands", null);
1169
1172
  __decorate([
1170
1173
  decorators_1.deprecated,
1171
1174
  decorators_1.returnsPromise,
1172
- decorators_1.apiVersions([])
1175
+ (0, decorators_1.apiVersions)([])
1173
1176
  ], Database.prototype, "getLastErrorObj", null);
1174
1177
  __decorate([
1175
1178
  decorators_1.deprecated,
1176
1179
  decorators_1.returnsPromise,
1177
- decorators_1.apiVersions([])
1180
+ (0, decorators_1.apiVersions)([])
1178
1181
  ], Database.prototype, "getLastError", null);
1179
1182
  __decorate([
1180
1183
  decorators_1.returnsPromise,
1181
- decorators_1.topologies([enums_1.Topologies.Sharded]),
1182
- decorators_1.apiVersions([1])
1184
+ (0, decorators_1.topologies)([enums_1.Topologies.Sharded]),
1185
+ (0, decorators_1.apiVersions)([1])
1183
1186
  ], Database.prototype, "printShardingStatus", null);
1184
1187
  __decorate([
1185
1188
  decorators_1.returnsPromise,
1186
- decorators_1.topologies([enums_1.Topologies.ReplSet]),
1187
- decorators_1.apiVersions([])
1189
+ (0, decorators_1.topologies)([enums_1.Topologies.ReplSet]),
1190
+ (0, decorators_1.apiVersions)([])
1188
1191
  ], Database.prototype, "printSecondaryReplicationInfo", null);
1189
1192
  __decorate([
1190
1193
  decorators_1.returnsPromise,
1191
- decorators_1.topologies([enums_1.Topologies.ReplSet]),
1192
- decorators_1.apiVersions([])
1194
+ (0, decorators_1.topologies)([enums_1.Topologies.ReplSet]),
1195
+ (0, decorators_1.apiVersions)([])
1193
1196
  ], Database.prototype, "getReplicationInfo", null);
1194
1197
  __decorate([
1195
1198
  decorators_1.returnsPromise,
1196
- decorators_1.apiVersions([]),
1197
- decorators_1.topologies([enums_1.Topologies.ReplSet])
1199
+ (0, decorators_1.apiVersions)([]),
1200
+ (0, decorators_1.topologies)([enums_1.Topologies.ReplSet])
1198
1201
  ], Database.prototype, "printReplicationInfo", null);
1199
1202
  __decorate([
1200
1203
  decorators_1.deprecated
@@ -1204,15 +1207,15 @@ __decorate([
1204
1207
  decorators_1.returnsPromise
1205
1208
  ], Database.prototype, "setSecondaryOk", null);
1206
1209
  __decorate([
1207
- decorators_1.serverVersions(['3.1.0', enums_1.ServerVersions.latest]),
1208
- decorators_1.topologies([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]),
1209
- decorators_1.apiVersions([1]),
1210
+ (0, decorators_1.serverVersions)(['3.1.0', enums_1.ServerVersions.latest]),
1211
+ (0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]),
1212
+ (0, decorators_1.apiVersions)([1]),
1210
1213
  decorators_1.returnsPromise
1211
1214
  ], Database.prototype, "watch", null);
1212
1215
  __decorate([
1213
- decorators_1.serverVersions(['4.4.0', enums_1.ServerVersions.latest]),
1216
+ (0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]),
1214
1217
  decorators_1.returnsPromise,
1215
- decorators_1.returnType('AggregationCursor')
1218
+ (0, decorators_1.returnType)('AggregationCursor')
1216
1219
  ], Database.prototype, "sql", null);
1217
1220
  Database = __decorate([
1218
1221
  decorators_1.shellApiClassDefault