@mongosh/shell-api 2.1.1 → 2.1.4

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 (59) hide show
  1. package/AUTHORS +1 -0
  2. package/lib/abstract-cursor.js +176 -132
  3. package/lib/abstract-cursor.js.map +1 -1
  4. package/lib/aggregate-or-find-cursor.js +102 -51
  5. package/lib/aggregate-or-find-cursor.js.map +1 -1
  6. package/lib/aggregation-cursor.js +59 -13
  7. package/lib/aggregation-cursor.js.map +1 -1
  8. package/lib/bulk.js +248 -197
  9. package/lib/bulk.js.map +1 -1
  10. package/lib/change-stream-cursor.js +145 -101
  11. package/lib/change-stream-cursor.js.map +1 -1
  12. package/lib/collection.d.ts +2 -1
  13. package/lib/collection.js +1185 -1245
  14. package/lib/collection.js.map +1 -1
  15. package/lib/cursor.js +238 -203
  16. package/lib/cursor.js.map +1 -1
  17. package/lib/database.js +1189 -1206
  18. package/lib/database.js.map +1 -1
  19. package/lib/dbquery.js +68 -22
  20. package/lib/dbquery.js.map +1 -1
  21. package/lib/decorators.d.ts +39 -13
  22. package/lib/decorators.js +34 -34
  23. package/lib/decorators.js.map +1 -1
  24. package/lib/explainable-cursor.js +66 -20
  25. package/lib/explainable-cursor.js.map +1 -1
  26. package/lib/explainable.js +214 -179
  27. package/lib/explainable.js.map +1 -1
  28. package/lib/field-level-encryption.js +286 -235
  29. package/lib/field-level-encryption.js.map +1 -1
  30. package/lib/helpers.d.ts +9 -1
  31. package/lib/helpers.js +24 -17
  32. package/lib/helpers.js.map +1 -1
  33. package/lib/interruptor.js.map +1 -1
  34. package/lib/log-entry.js.map +1 -1
  35. package/lib/mongo-errors.js +3 -1
  36. package/lib/mongo-errors.js.map +1 -1
  37. package/lib/mongo.js +581 -547
  38. package/lib/mongo.js.map +1 -1
  39. package/lib/plan-cache.js +108 -64
  40. package/lib/plan-cache.js.map +1 -1
  41. package/lib/replica-set.js +290 -277
  42. package/lib/replica-set.js.map +1 -1
  43. package/lib/result.js +228 -91
  44. package/lib/result.js.map +1 -1
  45. package/lib/run-command-cursor.js +59 -13
  46. package/lib/run-command-cursor.js.map +1 -1
  47. package/lib/session.js +123 -76
  48. package/lib/session.js.map +1 -1
  49. package/lib/shard.js +507 -514
  50. package/lib/shard.js.map +1 -1
  51. package/lib/shell-api.js +313 -268
  52. package/lib/shell-api.js.map +1 -1
  53. package/lib/shell-bson.js.map +1 -1
  54. package/lib/shell-instance-state.js.map +1 -1
  55. package/lib/stream-processor.js +139 -92
  56. package/lib/stream-processor.js.map +1 -1
  57. package/lib/streams.js +158 -110
  58. package/lib/streams.js.map +1 -1
  59. package/package.json +10 -10
@@ -1,9 +1,41 @@
1
1
  "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
3
+ var useValue = arguments.length > 2;
4
+ for (var i = 0; i < initializers.length; i++) {
5
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
6
+ }
7
+ return useValue ? value : void 0;
8
+ };
9
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
10
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
11
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
12
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
13
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
14
+ var _, done = false;
15
+ for (var i = decorators.length - 1; i >= 0; i--) {
16
+ var context = {};
17
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
18
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
19
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
20
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
21
+ if (kind === "accessor") {
22
+ if (result === void 0) continue;
23
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
24
+ if (_ = accept(result.get)) descriptor.get = _;
25
+ if (_ = accept(result.set)) descriptor.set = _;
26
+ if (_ = accept(result.init)) initializers.unshift(_);
27
+ }
28
+ else if (_ = accept(result)) {
29
+ if (kind === "field") initializers.unshift(_);
30
+ else descriptor[key] = _;
31
+ }
32
+ }
33
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
34
+ done = true;
35
+ };
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
7
39
  };
8
40
  Object.defineProperty(exports, "__esModule", { value: true });
9
41
  const errors_1 = require("@mongosh/errors");
@@ -11,297 +43,278 @@ const history_1 = require("@mongosh/history");
11
43
  const decorators_1 = require("./decorators");
12
44
  const enums_1 = require("./enums");
13
45
  const helpers_1 = require("./helpers");
14
- let ReplicaSet = class ReplicaSet extends decorators_1.ShellApiWithMongoClass {
15
- constructor(database) {
16
- super();
17
- this._database = database;
18
- }
19
- get _mongo() {
20
- return this._database._mongo;
21
- }
22
- async initiate(config = {}) {
23
- this._emitReplicaSetApiCall('initiate', { config });
24
- return this._database._runAdminCommand({ replSetInitiate: config });
25
- }
26
- async _getConfig() {
27
- try {
28
- const result = await this._database._runAdminCommand({
29
- replSetGetConfig: 1,
30
- });
31
- if (result.config === undefined) {
32
- throw new errors_1.MongoshRuntimeError("Documented returned from command replSetGetConfig does not contain 'config'", errors_1.CommonErrors.CommandFailed);
33
- }
34
- return result.config;
46
+ let ReplicaSet = (() => {
47
+ let _classDecorators = [decorators_1.shellApiClassDefault];
48
+ let _classDescriptor;
49
+ let _classExtraInitializers = [];
50
+ let _classThis;
51
+ let _classSuper = decorators_1.ShellApiWithMongoClass;
52
+ let _instanceExtraInitializers = [];
53
+ let _initiate_decorators;
54
+ let _config_decorators;
55
+ let _conf_decorators;
56
+ let _reconfig_decorators;
57
+ let _reconfigForPSASet_decorators;
58
+ let _status_decorators;
59
+ let _isMaster_decorators;
60
+ let _hello_decorators;
61
+ let _printSecondaryReplicationInfo_decorators;
62
+ let _printSlaveReplicationInfo_decorators;
63
+ let _printReplicationInfo_decorators;
64
+ let _add_decorators;
65
+ let _addArb_decorators;
66
+ let _remove_decorators;
67
+ let _freeze_decorators;
68
+ let _stepDown_decorators;
69
+ let _syncFrom_decorators;
70
+ let _secondaryOk_decorators;
71
+ var ReplicaSet = _classThis = class extends _classSuper {
72
+ constructor(database) {
73
+ super();
74
+ this._database = (__runInitializers(this, _instanceExtraInitializers), void 0);
75
+ this._database = database;
76
+ }
77
+ get _mongo() {
78
+ return this._database._mongo;
79
+ }
80
+ async initiate(config = {}) {
81
+ this._emitReplicaSetApiCall('initiate', { config });
82
+ return this._database._runAdminCommand({ replSetInitiate: config });
35
83
  }
36
- catch (error) {
37
- if ((error === null || error === void 0 ? void 0 : error.codeName) === 'CommandNotFound' ||
38
- (error === null || error === void 0 ? void 0 : error.codeName) === 'APIStrictError') {
39
- const doc = (await this._database
40
- .getSiblingDB('local')
41
- .getCollection('system.replset')
42
- .findOne());
43
- if (doc === null) {
44
- throw new errors_1.MongoshRuntimeError('No documents in local.system.replset', errors_1.CommonErrors.CommandFailed);
84
+ async _getConfig() {
85
+ try {
86
+ const result = await this._database._runAdminCommand({
87
+ replSetGetConfig: 1,
88
+ });
89
+ if (result.config === undefined) {
90
+ throw new errors_1.MongoshRuntimeError("Documented returned from command replSetGetConfig does not contain 'config'", errors_1.CommonErrors.CommandFailed);
91
+ }
92
+ return result.config;
93
+ }
94
+ catch (error) {
95
+ if ((error === null || error === void 0 ? void 0 : error.codeName) === 'CommandNotFound' ||
96
+ (error === null || error === void 0 ? void 0 : error.codeName) === 'APIStrictError') {
97
+ const doc = (await this._database
98
+ .getSiblingDB('local')
99
+ .getCollection('system.replset')
100
+ .findOne());
101
+ if (doc === null) {
102
+ throw new errors_1.MongoshRuntimeError('No documents in local.system.replset', errors_1.CommonErrors.CommandFailed);
103
+ }
104
+ return doc;
45
105
  }
46
- return doc;
106
+ throw error;
47
107
  }
48
- throw error;
49
108
  }
50
- }
51
- async config() {
52
- this._emitReplicaSetApiCall('config', {});
53
- return this._getConfig();
54
- }
55
- async conf() {
56
- this._emitReplicaSetApiCall('conf', {});
57
- return this._getConfig();
58
- }
59
- async reconfig(config, options = {}) {
60
- var _a;
61
- (0, helpers_1.assertArgsDefinedType)([config, options], ['object', [undefined, 'object']], 'ReplicaSet.reconfig');
62
- this._emitReplicaSetApiCall('reconfig', { config, options });
63
- const conf = await this._getConfig();
64
- config.version = conf.version ? conf.version + 1 : 1;
65
- (_a = config.protocolVersion) !== null && _a !== void 0 ? _a : (config.protocolVersion = conf.protocolVersion);
66
- const cmd = { replSetReconfig: config, ...options };
67
- return await this._database._runAdminCommand(cmd);
68
- }
69
- async reconfigForPSASet(newMemberIndex, config, options = {}) {
70
- var _a;
71
- (0, helpers_1.assertArgsDefinedType)([newMemberIndex, config, options], ['number', 'object', [undefined, 'object']], 'ReplicaSet.reconfigForPSASet');
72
- this._emitReplicaSetApiCall('reconfigForPSASet', {
73
- newMemberIndex,
74
- config,
75
- options,
76
- });
77
- const print = (msg) => this._instanceState.shellApi.print(msg);
78
- const newMemberConfig = (_a = config.members) === null || _a === void 0 ? void 0 : _a[newMemberIndex];
79
- if (!newMemberConfig) {
80
- throw new errors_1.MongoshInvalidInputError(`Node at index ${newMemberIndex} does not exist in the new config`, errors_1.CommonErrors.InvalidArgument);
109
+ async config() {
110
+ this._emitReplicaSetApiCall('config', {});
111
+ return this._getConfig();
112
+ }
113
+ async conf() {
114
+ this._emitReplicaSetApiCall('conf', {});
115
+ return this._getConfig();
81
116
  }
82
- if (newMemberConfig.votes !== 1) {
83
- throw new errors_1.MongoshInvalidInputError(`Node at index ${newMemberIndex} must have { votes: 1 } in the new config (actual: { votes: ${newMemberConfig.votes} })`, errors_1.CommonErrors.InvalidArgument);
117
+ async reconfig(config, options = {}) {
118
+ var _a;
119
+ (0, helpers_1.assertArgsDefinedType)([config, options], ['object', [undefined, 'object']], 'ReplicaSet.reconfig');
120
+ this._emitReplicaSetApiCall('reconfig', { config, options });
121
+ const conf = await this._getConfig();
122
+ config.version = conf.version ? conf.version + 1 : 1;
123
+ (_a = config.protocolVersion) !== null && _a !== void 0 ? _a : (config.protocolVersion = conf.protocolVersion);
124
+ const cmd = { replSetReconfig: config, ...options };
125
+ return await this._database._runAdminCommand(cmd);
84
126
  }
85
- const oldConfig = await this._getConfig();
86
- const oldMemberConfig = oldConfig.members.find((member) => member._id === newMemberConfig._id);
87
- if (!oldMemberConfig) {
88
- if (oldConfig.members.find((member) => member.host === newMemberConfig.host)) {
89
- await print(`Warning: Node at index ${newMemberIndex} has { host: "${newMemberConfig.host}" }, ` +
90
- 'which is also present in the old config, but with a different _id field.');
127
+ async reconfigForPSASet(newMemberIndex, config, options = {}) {
128
+ var _a;
129
+ (0, helpers_1.assertArgsDefinedType)([newMemberIndex, config, options], ['number', 'object', [undefined, 'object']], 'ReplicaSet.reconfigForPSASet');
130
+ this._emitReplicaSetApiCall('reconfigForPSASet', {
131
+ newMemberIndex,
132
+ config,
133
+ options,
134
+ });
135
+ const print = (msg) => this._instanceState.shellApi.print(msg);
136
+ const newMemberConfig = (_a = config.members) === null || _a === void 0 ? void 0 : _a[newMemberIndex];
137
+ if (!newMemberConfig) {
138
+ throw new errors_1.MongoshInvalidInputError(`Node at index ${newMemberIndex} does not exist in the new config`, errors_1.CommonErrors.InvalidArgument);
139
+ }
140
+ if (newMemberConfig.votes !== 1) {
141
+ throw new errors_1.MongoshInvalidInputError(`Node at index ${newMemberIndex} must have { votes: 1 } in the new config (actual: { votes: ${newMemberConfig.votes} })`, errors_1.CommonErrors.InvalidArgument);
142
+ }
143
+ const oldConfig = await this._getConfig();
144
+ const oldMemberConfig = oldConfig.members.find((member) => member._id === newMemberConfig._id);
145
+ if (!oldMemberConfig) {
146
+ if (oldConfig.members.find((member) => member.host === newMemberConfig.host)) {
147
+ await print(`Warning: Node at index ${newMemberIndex} has { host: "${newMemberConfig.host}" }, ` +
148
+ 'which is also present in the old config, but with a different _id field.');
149
+ }
150
+ }
151
+ else if (oldMemberConfig.votes) {
152
+ throw new errors_1.MongoshInvalidInputError(`Node at index ${newMemberIndex} must have { votes: 0 } in the old config (actual: { votes: ${oldMemberConfig.votes} })`, errors_1.CommonErrors.InvalidArgument);
153
+ }
154
+ const newMemberPriority = newMemberConfig.priority;
155
+ await print(`Running first reconfig to give member at index ${newMemberIndex} { votes: 1, priority: 0 }`);
156
+ newMemberConfig.votes = 1;
157
+ newMemberConfig.priority = 0;
158
+ const firstResult = await this.reconfig(config, options);
159
+ if (newMemberPriority === 0) {
160
+ await print('No second reconfig necessary because .priority = 0');
161
+ return firstResult;
162
+ }
163
+ await print(`Running second reconfig to give member at index ${newMemberIndex} { priority: ${newMemberPriority} }`);
164
+ newMemberConfig.priority = newMemberPriority;
165
+ try {
166
+ return await this.reconfig(config, options);
167
+ }
168
+ catch (e) {
169
+ await print('Second reconfig did not succeed, giving up');
170
+ await print(`Attempted command: rs.reconfig(${JSON.stringify(config, null, ' ')}, ${JSON.stringify(options)})`);
171
+ throw e;
91
172
  }
92
173
  }
93
- else if (oldMemberConfig.votes) {
94
- throw new errors_1.MongoshInvalidInputError(`Node at index ${newMemberIndex} must have { votes: 0 } in the old config (actual: { votes: ${oldMemberConfig.votes} })`, errors_1.CommonErrors.InvalidArgument);
174
+ async status() {
175
+ this._emitReplicaSetApiCall('status', {});
176
+ return this._database._runAdminCommand({
177
+ replSetGetStatus: 1,
178
+ });
95
179
  }
96
- const newMemberPriority = newMemberConfig.priority;
97
- await print(`Running first reconfig to give member at index ${newMemberIndex} { votes: 1, priority: 0 }`);
98
- newMemberConfig.votes = 1;
99
- newMemberConfig.priority = 0;
100
- const firstResult = await this.reconfig(config, options);
101
- if (newMemberPriority === 0) {
102
- await print('No second reconfig necessary because .priority = 0');
103
- return firstResult;
180
+ async isMaster() {
181
+ this._emitReplicaSetApiCall('isMaster', {});
182
+ return this._database.getSiblingDB('admin').isMaster();
104
183
  }
105
- await print(`Running second reconfig to give member at index ${newMemberIndex} { priority: ${newMemberPriority} }`);
106
- newMemberConfig.priority = newMemberPriority;
107
- try {
108
- return await this.reconfig(config, options);
184
+ async hello() {
185
+ this._emitReplicaSetApiCall('hello', {});
186
+ return this._database.getSiblingDB('admin').hello();
109
187
  }
110
- catch (e) {
111
- await print('Second reconfig did not succeed, giving up');
112
- await print(`Attempted command: rs.reconfig(${JSON.stringify(config, null, ' ')}, ${JSON.stringify(options)})`);
113
- throw e;
188
+ async printSecondaryReplicationInfo() {
189
+ this._emitReplicaSetApiCall('printSecondaryReplicationInfo', {});
190
+ return this._database.printSecondaryReplicationInfo();
114
191
  }
115
- }
116
- async status() {
117
- this._emitReplicaSetApiCall('status', {});
118
- return this._database._runAdminCommand({
119
- replSetGetStatus: 1,
120
- });
121
- }
122
- async isMaster() {
123
- this._emitReplicaSetApiCall('isMaster', {});
124
- return this._database.getSiblingDB('admin').isMaster();
125
- }
126
- async hello() {
127
- this._emitReplicaSetApiCall('hello', {});
128
- return this._database.getSiblingDB('admin').hello();
129
- }
130
- async printSecondaryReplicationInfo() {
131
- this._emitReplicaSetApiCall('printSecondaryReplicationInfo', {});
132
- return this._database.printSecondaryReplicationInfo();
133
- }
134
- printSlaveReplicationInfo() {
135
- throw new errors_1.MongoshDeprecatedError('printSlaveReplicationInfo has been deprecated. Use printSecondaryReplicationInfo instead');
136
- }
137
- async printReplicationInfo() {
138
- this._emitReplicaSetApiCall('printReplicationInfo', {});
139
- return this._database.printReplicationInfo();
140
- }
141
- async add(hostport, arb) {
142
- (0, helpers_1.assertArgsDefinedType)([hostport, arb], [
143
- ['string', 'object'],
144
- [undefined, 'boolean'],
145
- ], 'ReplicaSet.add');
146
- this._emitReplicaSetApiCall('add', { hostport, arb });
147
- const configDoc = await this._getConfig();
148
- configDoc.version++;
149
- const max = Math.max(...configDoc.members.map((m) => m._id));
150
- let cfg;
151
- if (typeof hostport === 'string') {
152
- cfg = { _id: max + 1, host: hostport };
153
- if (arb) {
154
- cfg.arbiterOnly = true;
192
+ printSlaveReplicationInfo() {
193
+ throw new errors_1.MongoshDeprecatedError('printSlaveReplicationInfo has been deprecated. Use printSecondaryReplicationInfo instead');
194
+ }
195
+ async printReplicationInfo() {
196
+ this._emitReplicaSetApiCall('printReplicationInfo', {});
197
+ return this._database.printReplicationInfo();
198
+ }
199
+ async add(hostport, arb) {
200
+ (0, helpers_1.assertArgsDefinedType)([hostport, arb], [
201
+ ['string', 'object'],
202
+ [undefined, 'boolean'],
203
+ ], 'ReplicaSet.add');
204
+ this._emitReplicaSetApiCall('add', { hostport, arb });
205
+ const configDoc = await this._getConfig();
206
+ configDoc.version++;
207
+ const max = Math.max(...configDoc.members.map((m) => m._id));
208
+ let cfg;
209
+ if (typeof hostport === 'string') {
210
+ cfg = { _id: max + 1, host: hostport };
211
+ if (arb) {
212
+ cfg.arbiterOnly = true;
213
+ }
155
214
  }
215
+ else if (arb === true) {
216
+ throw new errors_1.MongoshInvalidInputError(`Expected first parameter to be a host-and-port string of arbiter, but got ${JSON.stringify(hostport)}`, errors_1.CommonErrors.InvalidArgument);
217
+ }
218
+ else {
219
+ cfg = hostport;
220
+ if (cfg._id === null || cfg._id === undefined) {
221
+ cfg._id = max + 1;
222
+ }
223
+ }
224
+ configDoc.members.push(cfg);
225
+ return this._database._runAdminCommand({
226
+ replSetReconfig: configDoc,
227
+ });
156
228
  }
157
- else if (arb === true) {
158
- throw new errors_1.MongoshInvalidInputError(`Expected first parameter to be a host-and-port string of arbiter, but got ${JSON.stringify(hostport)}`, errors_1.CommonErrors.InvalidArgument);
229
+ async addArb(hostname) {
230
+ this._emitReplicaSetApiCall('addArb', { hostname });
231
+ return this.add(hostname, true);
159
232
  }
160
- else {
161
- cfg = hostport;
162
- if (cfg._id === null || cfg._id === undefined) {
163
- cfg._id = max + 1;
233
+ async remove(hostname) {
234
+ (0, helpers_1.assertArgsDefinedType)([hostname], ['string'], 'ReplicaSet.remove');
235
+ this._emitReplicaSetApiCall('remove', { hostname });
236
+ const configDoc = await this._getConfig();
237
+ configDoc.version++;
238
+ for (let i = 0; i < configDoc.members.length; i++) {
239
+ if (configDoc.members[i].host === hostname) {
240
+ configDoc.members.splice(i, 1);
241
+ return this._database._runAdminCommand({
242
+ replSetReconfig: configDoc,
243
+ });
244
+ }
164
245
  }
246
+ throw new errors_1.MongoshInvalidInputError(`Couldn't find ${hostname} in ${JSON.stringify(configDoc.members)}. Is ${hostname} a member of this replset?`, errors_1.CommonErrors.InvalidArgument);
165
247
  }
166
- configDoc.members.push(cfg);
167
- return this._database._runAdminCommand({
168
- replSetReconfig: configDoc,
169
- });
170
- }
171
- async addArb(hostname) {
172
- this._emitReplicaSetApiCall('addArb', { hostname });
173
- return this.add(hostname, true);
174
- }
175
- async remove(hostname) {
176
- (0, helpers_1.assertArgsDefinedType)([hostname], ['string'], 'ReplicaSet.remove');
177
- this._emitReplicaSetApiCall('remove', { hostname });
178
- const configDoc = await this._getConfig();
179
- configDoc.version++;
180
- for (let i = 0; i < configDoc.members.length; i++) {
181
- if (configDoc.members[i].host === hostname) {
182
- configDoc.members.splice(i, 1);
183
- return this._database._runAdminCommand({
184
- replSetReconfig: configDoc,
185
- });
248
+ async freeze(secs) {
249
+ (0, helpers_1.assertArgsDefinedType)([secs], ['number'], 'ReplicaSet.freeze');
250
+ this._emitReplicaSetApiCall('freeze', { secs });
251
+ return this._database._runAdminCommand({
252
+ replSetFreeze: secs,
253
+ });
254
+ }
255
+ async stepDown(stepdownSecs, catchUpSecs) {
256
+ (0, helpers_1.assertArgsDefinedType)([stepdownSecs, catchUpSecs], [
257
+ [undefined, 'number'],
258
+ [undefined, 'number'],
259
+ ], 'ReplicaSet.stepDown');
260
+ this._emitReplicaSetApiCall('stepDown', { stepdownSecs, catchUpSecs });
261
+ const cmd = {
262
+ replSetStepDown: stepdownSecs === undefined ? 60 : stepdownSecs,
263
+ };
264
+ if (catchUpSecs !== undefined) {
265
+ cmd.secondaryCatchUpPeriodSecs = catchUpSecs;
186
266
  }
267
+ return this._database._runAdminCommand(cmd);
187
268
  }
188
- throw new errors_1.MongoshInvalidInputError(`Couldn't find ${hostname} in ${JSON.stringify(configDoc.members)}. Is ${hostname} a member of this replset?`, errors_1.CommonErrors.InvalidArgument);
189
- }
190
- async freeze(secs) {
191
- (0, helpers_1.assertArgsDefinedType)([secs], ['number'], 'ReplicaSet.freeze');
192
- this._emitReplicaSetApiCall('freeze', { secs });
193
- return this._database._runAdminCommand({
194
- replSetFreeze: secs,
195
- });
196
- }
197
- async stepDown(stepdownSecs, catchUpSecs) {
198
- (0, helpers_1.assertArgsDefinedType)([stepdownSecs, catchUpSecs], [
199
- [undefined, 'number'],
200
- [undefined, 'number'],
201
- ], 'ReplicaSet.stepDown');
202
- this._emitReplicaSetApiCall('stepDown', { stepdownSecs, catchUpSecs });
203
- const cmd = {
204
- replSetStepDown: stepdownSecs === undefined ? 60 : stepdownSecs,
205
- };
206
- if (catchUpSecs !== undefined) {
207
- cmd.secondaryCatchUpPeriodSecs = catchUpSecs;
269
+ async syncFrom(host) {
270
+ (0, helpers_1.assertArgsDefinedType)([host], ['string'], 'ReplicaSet.syncFrom');
271
+ this._emitReplicaSetApiCall('syncFrom', { host });
272
+ return this._database._runAdminCommand({
273
+ replSetSyncFrom: host,
274
+ });
208
275
  }
209
- return this._database._runAdminCommand(cmd);
210
- }
211
- async syncFrom(host) {
212
- (0, helpers_1.assertArgsDefinedType)([host], ['string'], 'ReplicaSet.syncFrom');
213
- this._emitReplicaSetApiCall('syncFrom', { host });
214
- return this._database._runAdminCommand({
215
- replSetSyncFrom: host,
216
- });
217
- }
218
- async secondaryOk() {
219
- await this._mongo.setSecondaryOk();
220
- }
221
- [enums_1.asPrintable]() {
222
- return `ReplicaSet class connected to ${(0, history_1.redactURICredentials)(this._database._mongo._uri)} via db ${this._database._name}`;
223
- }
224
- _emitReplicaSetApiCall(methodName, methodArguments = {}) {
225
- this._database._mongo._instanceState.emitApiCallWithArgs({
226
- method: methodName,
227
- class: 'ReplicaSet',
228
- arguments: methodArguments,
229
- });
230
- }
231
- };
232
- __decorate([
233
- decorators_1.returnsPromise
234
- ], ReplicaSet.prototype, "initiate", null);
235
- __decorate([
236
- decorators_1.returnsPromise,
237
- (0, decorators_1.apiVersions)([1])
238
- ], ReplicaSet.prototype, "config", null);
239
- __decorate([
240
- decorators_1.returnsPromise,
241
- (0, decorators_1.apiVersions)([1])
242
- ], ReplicaSet.prototype, "conf", null);
243
- __decorate([
244
- decorators_1.returnsPromise,
245
- (0, decorators_1.apiVersions)([])
246
- ], ReplicaSet.prototype, "reconfig", null);
247
- __decorate([
248
- decorators_1.returnsPromise,
249
- (0, decorators_1.apiVersions)([])
250
- ], ReplicaSet.prototype, "reconfigForPSASet", null);
251
- __decorate([
252
- decorators_1.returnsPromise,
253
- (0, decorators_1.apiVersions)([])
254
- ], ReplicaSet.prototype, "status", null);
255
- __decorate([
256
- decorators_1.returnsPromise,
257
- (0, decorators_1.apiVersions)([])
258
- ], ReplicaSet.prototype, "isMaster", null);
259
- __decorate([
260
- decorators_1.returnsPromise,
261
- (0, decorators_1.apiVersions)([1])
262
- ], ReplicaSet.prototype, "hello", null);
263
- __decorate([
264
- decorators_1.returnsPromise,
265
- (0, decorators_1.apiVersions)([])
266
- ], ReplicaSet.prototype, "printSecondaryReplicationInfo", null);
267
- __decorate([
268
- decorators_1.deprecated,
269
- (0, decorators_1.apiVersions)([])
270
- ], ReplicaSet.prototype, "printSlaveReplicationInfo", null);
271
- __decorate([
272
- decorators_1.returnsPromise,
273
- (0, decorators_1.apiVersions)([])
274
- ], ReplicaSet.prototype, "printReplicationInfo", null);
275
- __decorate([
276
- decorators_1.returnsPromise,
277
- (0, decorators_1.apiVersions)([])
278
- ], ReplicaSet.prototype, "add", null);
279
- __decorate([
280
- decorators_1.returnsPromise,
281
- (0, decorators_1.apiVersions)([])
282
- ], ReplicaSet.prototype, "addArb", null);
283
- __decorate([
284
- decorators_1.returnsPromise,
285
- (0, decorators_1.apiVersions)([])
286
- ], ReplicaSet.prototype, "remove", null);
287
- __decorate([
288
- decorators_1.returnsPromise,
289
- (0, decorators_1.apiVersions)([])
290
- ], ReplicaSet.prototype, "freeze", null);
291
- __decorate([
292
- decorators_1.returnsPromise,
293
- (0, decorators_1.apiVersions)([])
294
- ], ReplicaSet.prototype, "stepDown", null);
295
- __decorate([
296
- decorators_1.returnsPromise,
297
- (0, decorators_1.apiVersions)([])
298
- ], ReplicaSet.prototype, "syncFrom", null);
299
- __decorate([
300
- decorators_1.deprecated,
301
- decorators_1.returnsPromise
302
- ], ReplicaSet.prototype, "secondaryOk", null);
303
- ReplicaSet = __decorate([
304
- decorators_1.shellApiClassDefault
305
- ], ReplicaSet);
276
+ async secondaryOk() {
277
+ await this._mongo.setSecondaryOk();
278
+ }
279
+ [(_initiate_decorators = [decorators_1.returnsPromise], _config_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])], _conf_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])], _reconfig_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])], _reconfigForPSASet_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])], _status_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])], _isMaster_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])], _hello_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])], _printSecondaryReplicationInfo_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])], _printSlaveReplicationInfo_decorators = [decorators_1.deprecated, (0, decorators_1.apiVersions)([])], _printReplicationInfo_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])], _add_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])], _addArb_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])], _remove_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])], _freeze_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])], _stepDown_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])], _syncFrom_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])], _secondaryOk_decorators = [decorators_1.deprecated, decorators_1.returnsPromise], enums_1.asPrintable)]() {
280
+ return `ReplicaSet class connected to ${(0, history_1.redactURICredentials)(this._database._mongo._uri)} via db ${this._database._name}`;
281
+ }
282
+ _emitReplicaSetApiCall(methodName, methodArguments = {}) {
283
+ this._database._mongo._instanceState.emitApiCallWithArgs({
284
+ method: methodName,
285
+ class: 'ReplicaSet',
286
+ arguments: methodArguments,
287
+ });
288
+ }
289
+ };
290
+ __setFunctionName(_classThis, "ReplicaSet");
291
+ (() => {
292
+ var _a;
293
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
294
+ __esDecorate(_classThis, null, _initiate_decorators, { kind: "method", name: "initiate", static: false, private: false, access: { has: obj => "initiate" in obj, get: obj => obj.initiate }, metadata: _metadata }, null, _instanceExtraInitializers);
295
+ __esDecorate(_classThis, null, _config_decorators, { kind: "method", name: "config", static: false, private: false, access: { has: obj => "config" in obj, get: obj => obj.config }, metadata: _metadata }, null, _instanceExtraInitializers);
296
+ __esDecorate(_classThis, null, _conf_decorators, { kind: "method", name: "conf", static: false, private: false, access: { has: obj => "conf" in obj, get: obj => obj.conf }, metadata: _metadata }, null, _instanceExtraInitializers);
297
+ __esDecorate(_classThis, null, _reconfig_decorators, { kind: "method", name: "reconfig", static: false, private: false, access: { has: obj => "reconfig" in obj, get: obj => obj.reconfig }, metadata: _metadata }, null, _instanceExtraInitializers);
298
+ __esDecorate(_classThis, null, _reconfigForPSASet_decorators, { kind: "method", name: "reconfigForPSASet", static: false, private: false, access: { has: obj => "reconfigForPSASet" in obj, get: obj => obj.reconfigForPSASet }, metadata: _metadata }, null, _instanceExtraInitializers);
299
+ __esDecorate(_classThis, null, _status_decorators, { kind: "method", name: "status", static: false, private: false, access: { has: obj => "status" in obj, get: obj => obj.status }, metadata: _metadata }, null, _instanceExtraInitializers);
300
+ __esDecorate(_classThis, null, _isMaster_decorators, { kind: "method", name: "isMaster", static: false, private: false, access: { has: obj => "isMaster" in obj, get: obj => obj.isMaster }, metadata: _metadata }, null, _instanceExtraInitializers);
301
+ __esDecorate(_classThis, null, _hello_decorators, { kind: "method", name: "hello", static: false, private: false, access: { has: obj => "hello" in obj, get: obj => obj.hello }, metadata: _metadata }, null, _instanceExtraInitializers);
302
+ __esDecorate(_classThis, null, _printSecondaryReplicationInfo_decorators, { kind: "method", name: "printSecondaryReplicationInfo", static: false, private: false, access: { has: obj => "printSecondaryReplicationInfo" in obj, get: obj => obj.printSecondaryReplicationInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
303
+ __esDecorate(_classThis, null, _printSlaveReplicationInfo_decorators, { kind: "method", name: "printSlaveReplicationInfo", static: false, private: false, access: { has: obj => "printSlaveReplicationInfo" in obj, get: obj => obj.printSlaveReplicationInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
304
+ __esDecorate(_classThis, null, _printReplicationInfo_decorators, { kind: "method", name: "printReplicationInfo", static: false, private: false, access: { has: obj => "printReplicationInfo" in obj, get: obj => obj.printReplicationInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
305
+ __esDecorate(_classThis, null, _add_decorators, { kind: "method", name: "add", static: false, private: false, access: { has: obj => "add" in obj, get: obj => obj.add }, metadata: _metadata }, null, _instanceExtraInitializers);
306
+ __esDecorate(_classThis, null, _addArb_decorators, { kind: "method", name: "addArb", static: false, private: false, access: { has: obj => "addArb" in obj, get: obj => obj.addArb }, metadata: _metadata }, null, _instanceExtraInitializers);
307
+ __esDecorate(_classThis, null, _remove_decorators, { kind: "method", name: "remove", static: false, private: false, access: { has: obj => "remove" in obj, get: obj => obj.remove }, metadata: _metadata }, null, _instanceExtraInitializers);
308
+ __esDecorate(_classThis, null, _freeze_decorators, { kind: "method", name: "freeze", static: false, private: false, access: { has: obj => "freeze" in obj, get: obj => obj.freeze }, metadata: _metadata }, null, _instanceExtraInitializers);
309
+ __esDecorate(_classThis, null, _stepDown_decorators, { kind: "method", name: "stepDown", static: false, private: false, access: { has: obj => "stepDown" in obj, get: obj => obj.stepDown }, metadata: _metadata }, null, _instanceExtraInitializers);
310
+ __esDecorate(_classThis, null, _syncFrom_decorators, { kind: "method", name: "syncFrom", static: false, private: false, access: { has: obj => "syncFrom" in obj, get: obj => obj.syncFrom }, metadata: _metadata }, null, _instanceExtraInitializers);
311
+ __esDecorate(_classThis, null, _secondaryOk_decorators, { kind: "method", name: "secondaryOk", static: false, private: false, access: { has: obj => "secondaryOk" in obj, get: obj => obj.secondaryOk }, metadata: _metadata }, null, _instanceExtraInitializers);
312
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
313
+ ReplicaSet = _classThis = _classDescriptor.value;
314
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
315
+ __runInitializers(_classThis, _classExtraInitializers);
316
+ })();
317
+ return ReplicaSet = _classThis;
318
+ })();
306
319
  exports.default = ReplicaSet;
307
320
  //# sourceMappingURL=replica-set.js.map