@mongosh/shell-api 1.3.0 → 1.4.2

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