@mongosh/shell-api 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/abstract-cursor.js +176 -132
- package/lib/abstract-cursor.js.map +1 -1
- package/lib/aggregate-or-find-cursor.js +102 -51
- package/lib/aggregate-or-find-cursor.js.map +1 -1
- package/lib/aggregation-cursor.js +59 -13
- package/lib/aggregation-cursor.js.map +1 -1
- package/lib/bulk.js +248 -197
- package/lib/bulk.js.map +1 -1
- package/lib/change-stream-cursor.js +145 -101
- package/lib/change-stream-cursor.js.map +1 -1
- package/lib/collection.d.ts +2 -1
- package/lib/collection.js +1185 -1245
- package/lib/collection.js.map +1 -1
- package/lib/cursor.js +238 -203
- package/lib/cursor.js.map +1 -1
- package/lib/database.js +1180 -1206
- package/lib/database.js.map +1 -1
- package/lib/dbquery.js +68 -22
- package/lib/dbquery.js.map +1 -1
- package/lib/decorators.d.ts +39 -13
- package/lib/decorators.js +34 -34
- package/lib/decorators.js.map +1 -1
- package/lib/explainable-cursor.js +66 -20
- package/lib/explainable-cursor.js.map +1 -1
- package/lib/explainable.js +214 -179
- package/lib/explainable.js.map +1 -1
- package/lib/field-level-encryption.js +286 -235
- package/lib/field-level-encryption.js.map +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/interruptor.js.map +1 -1
- package/lib/log-entry.js.map +1 -1
- package/lib/mongo-errors.js.map +1 -1
- package/lib/mongo.js +581 -547
- package/lib/mongo.js.map +1 -1
- package/lib/plan-cache.js +108 -64
- package/lib/plan-cache.js.map +1 -1
- package/lib/replica-set.js +290 -277
- package/lib/replica-set.js.map +1 -1
- package/lib/result.js +228 -91
- package/lib/result.js.map +1 -1
- package/lib/run-command-cursor.js +59 -13
- package/lib/run-command-cursor.js.map +1 -1
- package/lib/session.js +123 -76
- package/lib/session.js.map +1 -1
- package/lib/shard.js +507 -514
- package/lib/shard.js.map +1 -1
- package/lib/shell-api.js +313 -268
- package/lib/shell-api.js.map +1 -1
- package/lib/shell-bson.js.map +1 -1
- package/lib/shell-instance-state.js.map +1 -1
- package/lib/stream-processor.js +139 -92
- package/lib/stream-processor.js.map +1 -1
- package/lib/streams.js +158 -110
- package/lib/streams.js.map +1 -1
- package/package.json +8 -8
package/lib/shell-api.js
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -23,66 +55,79 @@ const types_1 = require("@mongosh/types");
|
|
|
23
55
|
const i18n_1 = __importDefault(require("@mongosh/i18n"));
|
|
24
56
|
const instanceStateSymbol = Symbol.for('@@mongosh.instanceState');
|
|
25
57
|
const loadCallNestingLevelSymbol = Symbol.for('@@mongosh.loadCallNestingLevel');
|
|
26
|
-
let ShellConfig =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
58
|
+
let ShellConfig = (() => {
|
|
59
|
+
let _classDecorators = [decorators_1.shellApiClassDefault];
|
|
60
|
+
let _classDescriptor;
|
|
61
|
+
let _classExtraInitializers = [];
|
|
62
|
+
let _classThis;
|
|
63
|
+
let _classSuper = decorators_1.ShellApiClass;
|
|
64
|
+
let _instanceExtraInitializers = [];
|
|
65
|
+
let _set_decorators;
|
|
66
|
+
let _get_decorators;
|
|
67
|
+
let _reset_decorators;
|
|
68
|
+
var ShellConfig = _classThis = class extends _classSuper {
|
|
69
|
+
constructor(instanceState) {
|
|
70
|
+
super();
|
|
71
|
+
this._instanceState = (__runInitializers(this, _instanceExtraInitializers), void 0);
|
|
72
|
+
this._instanceState = instanceState;
|
|
73
|
+
this.defaults = Object.freeze(new types_1.ShellUserConfig());
|
|
74
|
+
}
|
|
75
|
+
async set(key, value) {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
(0, helpers_1.assertArgsDefinedType)([key], ['string'], 'config.set');
|
|
78
|
+
const { evaluationListener } = this._instanceState;
|
|
79
|
+
const isValidKey = (await this._allKeys()).includes(key);
|
|
80
|
+
if (isValidKey) {
|
|
81
|
+
const validationResult = await ((_a = evaluationListener.validateConfig) === null || _a === void 0 ? void 0 : _a.call(evaluationListener, key, value));
|
|
82
|
+
if (validationResult) {
|
|
83
|
+
return `Cannot set option "${key}": ${validationResult}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const result = isValidKey && (await ((_b = evaluationListener.setConfig) === null || _b === void 0 ? void 0 : _b.call(evaluationListener, key, value)));
|
|
87
|
+
if (result !== 'success') {
|
|
88
|
+
return `Option "${key}" is not available in this environment`;
|
|
41
89
|
}
|
|
90
|
+
return `Setting "${key}" has been changed`;
|
|
42
91
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
92
|
+
async get(key) {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
(0, helpers_1.assertArgsDefinedType)([key], ['string'], 'config.get');
|
|
95
|
+
const { evaluationListener } = this._instanceState;
|
|
96
|
+
return (_b = (await ((_a = evaluationListener.getConfig) === null || _a === void 0 ? void 0 : _a.call(evaluationListener, key)))) !== null && _b !== void 0 ? _b : this.defaults[key];
|
|
46
97
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var _a;
|
|
57
|
-
(0, helpers_1.assertArgsDefinedType)([key], ['string'], 'config.reset');
|
|
58
|
-
const { evaluationListener } = this._instanceState;
|
|
59
|
-
const result = await ((_a = evaluationListener.resetConfig) === null || _a === void 0 ? void 0 : _a.call(evaluationListener, key));
|
|
60
|
-
if (result !== 'success') {
|
|
61
|
-
return `Option "${key}" cannot be changed in this environment`;
|
|
98
|
+
async reset(key) {
|
|
99
|
+
var _a;
|
|
100
|
+
(0, helpers_1.assertArgsDefinedType)([key], ['string'], 'config.reset');
|
|
101
|
+
const { evaluationListener } = this._instanceState;
|
|
102
|
+
const result = await ((_a = evaluationListener.resetConfig) === null || _a === void 0 ? void 0 : _a.call(evaluationListener, key));
|
|
103
|
+
if (result !== 'success') {
|
|
104
|
+
return `Option "${key}" cannot be changed in this environment`;
|
|
105
|
+
}
|
|
106
|
+
return `Setting "${key}" has been reset to its default value`;
|
|
62
107
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
108
|
+
async _allKeys() {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
const { evaluationListener } = this._instanceState;
|
|
111
|
+
return ((_b = (await ((_a = evaluationListener.listConfigOptions) === null || _a === void 0 ? void 0 : _a.call(evaluationListener)))) !== null && _b !== void 0 ? _b : Object.keys(this.defaults));
|
|
112
|
+
}
|
|
113
|
+
async [(_set_decorators = [decorators_1.returnsPromise], _get_decorators = [decorators_1.returnsPromise], _reset_decorators = [decorators_1.returnsPromise], enums_1.asPrintable)]() {
|
|
114
|
+
return new Map(await Promise.all((await this._allKeys()).map(async (key) => [key, await this.get(key)])));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
__setFunctionName(_classThis, "ShellConfig");
|
|
118
|
+
(() => {
|
|
119
|
+
var _a;
|
|
120
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
121
|
+
__esDecorate(_classThis, null, _set_decorators, { kind: "method", name: "set", static: false, private: false, access: { has: obj => "set" in obj, get: obj => obj.set }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
122
|
+
__esDecorate(_classThis, null, _get_decorators, { kind: "method", name: "get", static: false, private: false, access: { has: obj => "get" in obj, get: obj => obj.get }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
123
|
+
__esDecorate(_classThis, null, _reset_decorators, { kind: "method", name: "reset", static: false, private: false, access: { has: obj => "reset" in obj, get: obj => obj.reset }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
124
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
125
|
+
ShellConfig = _classThis = _classDescriptor.value;
|
|
126
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
127
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
128
|
+
})();
|
|
129
|
+
return ShellConfig = _classThis;
|
|
130
|
+
})();
|
|
86
131
|
async function useCompleter(params, args) {
|
|
87
132
|
var _a;
|
|
88
133
|
if (args.length > 2)
|
|
@@ -111,219 +156,219 @@ async function showCompleter(params, args) {
|
|
|
111
156
|
];
|
|
112
157
|
return candidates.filter((str) => { var _a; return str.startsWith((_a = args[1]) !== null && _a !== void 0 ? _a : ''); });
|
|
113
158
|
}
|
|
114
|
-
let ShellApi =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
async quit(exitCode) {
|
|
149
|
-
return await this.exit(exitCode);
|
|
150
|
-
}
|
|
151
|
-
async Mongo(uri, fleOptions, otherOptions) {
|
|
152
|
-
(0, helpers_1.assertCLI)(this._instanceState.initialServiceProvider.platform, 'new Mongo connections');
|
|
153
|
-
const mongo = new mongo_1.default(this._instanceState, uri, fleOptions, otherOptions);
|
|
154
|
-
await mongo.connect();
|
|
155
|
-
this._instanceState.mongos.push(mongo);
|
|
156
|
-
return mongo;
|
|
157
|
-
}
|
|
158
|
-
async connect(uri, user, pwd) {
|
|
159
|
-
(0, helpers_1.assertArgsDefinedType)([uri, user, pwd], ['string', [undefined, 'string'], [undefined, 'string']], 'connect');
|
|
160
|
-
(0, helpers_1.assertCLI)(this._instanceState.initialServiceProvider.platform, 'new Mongo connections');
|
|
161
|
-
const mongo = new mongo_1.default(this._instanceState, uri);
|
|
162
|
-
await mongo.connect(user, pwd);
|
|
163
|
-
this._instanceState.mongos.push(mongo);
|
|
164
|
-
const db = mongo._serviceProvider.initialDb || service_provider_core_1.DEFAULT_DB;
|
|
165
|
-
return mongo.getDB(db);
|
|
166
|
-
}
|
|
167
|
-
async it() {
|
|
168
|
-
if (!this._instanceState.currentCursor) {
|
|
169
|
-
return new result_1.CursorIterationResult();
|
|
159
|
+
let ShellApi = (() => {
|
|
160
|
+
var _a;
|
|
161
|
+
let _classDecorators = [decorators_1.shellApiClassDefault];
|
|
162
|
+
let _classDescriptor;
|
|
163
|
+
let _classExtraInitializers = [];
|
|
164
|
+
let _classThis;
|
|
165
|
+
let _classSuper = decorators_1.ShellApiClass;
|
|
166
|
+
let _instanceExtraInitializers = [];
|
|
167
|
+
let _use_decorators;
|
|
168
|
+
let _show_decorators;
|
|
169
|
+
let __untrackedShow_decorators;
|
|
170
|
+
let _exit_decorators;
|
|
171
|
+
let _quit_decorators;
|
|
172
|
+
let _Mongo_decorators;
|
|
173
|
+
let _connect_decorators;
|
|
174
|
+
let _it_decorators;
|
|
175
|
+
let _load_decorators;
|
|
176
|
+
let _enableTelemetry_decorators;
|
|
177
|
+
let _disableTelemetry_decorators;
|
|
178
|
+
let _passwordPrompt_decorators;
|
|
179
|
+
let _sleep_decorators;
|
|
180
|
+
let _print_decorators;
|
|
181
|
+
let _printjson_decorators;
|
|
182
|
+
let _convertShardKeyToHashed_decorators;
|
|
183
|
+
let _cls_decorators;
|
|
184
|
+
var ShellApi = _classThis = class extends _classSuper {
|
|
185
|
+
constructor(instanceState) {
|
|
186
|
+
super();
|
|
187
|
+
this[_a] = (__runInitializers(this, _instanceExtraInitializers), void 0);
|
|
188
|
+
this[instanceStateSymbol] = instanceState;
|
|
189
|
+
this[loadCallNestingLevelSymbol] = 0;
|
|
190
|
+
this.DBQuery = new dbquery_1.DBQuery(instanceState);
|
|
191
|
+
this.config = new ShellConfig(instanceState);
|
|
170
192
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
await
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
193
|
+
get _instanceState() {
|
|
194
|
+
return this[instanceStateSymbol];
|
|
195
|
+
}
|
|
196
|
+
get loadCallNestingLevel() {
|
|
197
|
+
return this[loadCallNestingLevelSymbol];
|
|
198
|
+
}
|
|
199
|
+
set loadCallNestingLevel(value) {
|
|
200
|
+
this[loadCallNestingLevelSymbol] = value;
|
|
201
|
+
}
|
|
202
|
+
use(db) {
|
|
203
|
+
return this._instanceState.currentDb._mongo.use(db);
|
|
204
|
+
}
|
|
205
|
+
async show(cmd, arg) {
|
|
206
|
+
return await this._instanceState.currentDb._mongo.show(cmd, arg);
|
|
207
|
+
}
|
|
208
|
+
async _untrackedShow(cmd, arg) {
|
|
209
|
+
return await this._instanceState.currentDb._mongo.show(cmd, arg, false);
|
|
210
|
+
}
|
|
211
|
+
async exit(exitCode) {
|
|
212
|
+
var _b, _c;
|
|
213
|
+
(0, helpers_1.assertArgsDefinedType)([exitCode], [[undefined, 'number']], 'exit');
|
|
214
|
+
(0, helpers_1.assertCLI)(this._instanceState.initialServiceProvider.platform, 'the exit/quit commands');
|
|
215
|
+
await this._instanceState.close(true);
|
|
216
|
+
await ((_c = (_b = this._instanceState.evaluationListener).onExit) === null || _c === void 0 ? void 0 : _c.call(_b, exitCode));
|
|
217
|
+
throw new errors_1.MongoshInternalError('.onExit listener returned');
|
|
218
|
+
}
|
|
219
|
+
async quit(exitCode) {
|
|
220
|
+
return await this.exit(exitCode);
|
|
221
|
+
}
|
|
222
|
+
async Mongo(uri, fleOptions, otherOptions) {
|
|
223
|
+
(0, helpers_1.assertCLI)(this._instanceState.initialServiceProvider.platform, 'new Mongo connections');
|
|
224
|
+
const mongo = new mongo_1.default(this._instanceState, uri, fleOptions, otherOptions);
|
|
225
|
+
await mongo.connect();
|
|
226
|
+
this._instanceState.mongos.push(mongo);
|
|
227
|
+
return mongo;
|
|
228
|
+
}
|
|
229
|
+
async connect(uri, user, pwd) {
|
|
230
|
+
(0, helpers_1.assertArgsDefinedType)([uri, user, pwd], ['string', [undefined, 'string'], [undefined, 'string']], 'connect');
|
|
231
|
+
(0, helpers_1.assertCLI)(this._instanceState.initialServiceProvider.platform, 'new Mongo connections');
|
|
232
|
+
const mongo = new mongo_1.default(this._instanceState, uri);
|
|
233
|
+
await mongo.connect(user, pwd);
|
|
234
|
+
this._instanceState.mongos.push(mongo);
|
|
235
|
+
const db = mongo._serviceProvider.initialDb || service_provider_core_1.DEFAULT_DB;
|
|
236
|
+
return mongo.getDB(db);
|
|
237
|
+
}
|
|
238
|
+
async it() {
|
|
239
|
+
if (!this._instanceState.currentCursor) {
|
|
240
|
+
return new result_1.CursorIterationResult();
|
|
241
|
+
}
|
|
242
|
+
return await this._instanceState.currentCursor._it();
|
|
243
|
+
}
|
|
244
|
+
version() {
|
|
245
|
+
const version = require('../package.json').version;
|
|
246
|
+
return version;
|
|
247
|
+
}
|
|
248
|
+
async load(filename) {
|
|
249
|
+
(0, helpers_1.assertArgsDefinedType)([filename], ['string'], 'load');
|
|
250
|
+
if (!this._instanceState.evaluationListener.onLoad) {
|
|
251
|
+
throw new errors_1.MongoshUnimplementedError('load is not currently implemented for this platform', errors_1.CommonErrors.NotImplemented);
|
|
252
|
+
}
|
|
253
|
+
this._instanceState.messageBus.emit('mongosh:api-load-file', {
|
|
254
|
+
nested: this.loadCallNestingLevel > 0,
|
|
255
|
+
filename,
|
|
256
|
+
});
|
|
257
|
+
const { resolvedFilename, evaluate } = await this._instanceState.evaluationListener.onLoad(filename);
|
|
258
|
+
const context = this._instanceState.context;
|
|
259
|
+
const previousFilename = context.__filename;
|
|
260
|
+
context.__filename = resolvedFilename;
|
|
261
|
+
context.__dirname = (0, path_1.dirname)(resolvedFilename);
|
|
262
|
+
this.loadCallNestingLevel++;
|
|
263
|
+
try {
|
|
264
|
+
await evaluate();
|
|
200
265
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
266
|
+
finally {
|
|
267
|
+
this.loadCallNestingLevel--;
|
|
268
|
+
if (previousFilename) {
|
|
269
|
+
context.__filename = previousFilename;
|
|
270
|
+
context.__dirname = (0, path_1.dirname)(previousFilename);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
delete context.__filename;
|
|
274
|
+
delete context.__dirname;
|
|
275
|
+
}
|
|
204
276
|
}
|
|
277
|
+
return true;
|
|
205
278
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return i18n_1.default.__('cli-repl.cli-repl.enabledTelemetry');
|
|
279
|
+
async enableTelemetry() {
|
|
280
|
+
var _b, _c;
|
|
281
|
+
const result = await ((_c = (_b = this._instanceState.evaluationListener).setConfig) === null || _c === void 0 ? void 0 : _c.call(_b, 'enableTelemetry', true));
|
|
282
|
+
if (result === 'success') {
|
|
283
|
+
return i18n_1.default.__('cli-repl.cli-repl.enabledTelemetry');
|
|
284
|
+
}
|
|
213
285
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
286
|
+
async disableTelemetry() {
|
|
287
|
+
var _b, _c;
|
|
288
|
+
const result = await ((_c = (_b = this._instanceState.evaluationListener).setConfig) === null || _c === void 0 ? void 0 : _c.call(_b, 'enableTelemetry', false));
|
|
289
|
+
if (result === 'success') {
|
|
290
|
+
return i18n_1.default.__('cli-repl.cli-repl.disabledTelemetry');
|
|
291
|
+
}
|
|
220
292
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
293
|
+
async passwordPrompt() {
|
|
294
|
+
const { evaluationListener } = this._instanceState;
|
|
295
|
+
if (!evaluationListener.onPrompt) {
|
|
296
|
+
throw new errors_1.MongoshUnimplementedError('passwordPrompt() is not available in this shell', errors_1.CommonErrors.NotImplemented);
|
|
297
|
+
}
|
|
298
|
+
return await evaluationListener.onPrompt('Enter password', 'password');
|
|
226
299
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
], ShellApi.prototype, "enableTelemetry", null);
|
|
301
|
-
__decorate([
|
|
302
|
-
decorators_1.returnsPromise,
|
|
303
|
-
(0, decorators_1.platforms)(['CLI'])
|
|
304
|
-
], ShellApi.prototype, "disableTelemetry", null);
|
|
305
|
-
__decorate([
|
|
306
|
-
decorators_1.returnsPromise,
|
|
307
|
-
(0, decorators_1.platforms)(['CLI'])
|
|
308
|
-
], ShellApi.prototype, "passwordPrompt", null);
|
|
309
|
-
__decorate([
|
|
310
|
-
decorators_1.returnsPromise
|
|
311
|
-
], ShellApi.prototype, "sleep", null);
|
|
312
|
-
__decorate([
|
|
313
|
-
decorators_1.returnsPromise
|
|
314
|
-
], ShellApi.prototype, "print", null);
|
|
315
|
-
__decorate([
|
|
316
|
-
decorators_1.returnsPromise
|
|
317
|
-
], ShellApi.prototype, "printjson", null);
|
|
318
|
-
__decorate([
|
|
319
|
-
decorators_1.returnsPromise
|
|
320
|
-
], ShellApi.prototype, "convertShardKeyToHashed", null);
|
|
321
|
-
__decorate([
|
|
322
|
-
decorators_1.directShellCommand,
|
|
323
|
-
decorators_1.returnsPromise
|
|
324
|
-
], ShellApi.prototype, "cls", null);
|
|
325
|
-
ShellApi = __decorate([
|
|
326
|
-
decorators_1.shellApiClassDefault
|
|
327
|
-
], ShellApi);
|
|
300
|
+
async sleep(ms) {
|
|
301
|
+
return await (0, util_1.promisify)(setTimeout)(ms);
|
|
302
|
+
}
|
|
303
|
+
async _print(origArgs, type) {
|
|
304
|
+
var _b;
|
|
305
|
+
const { evaluationListener } = this._instanceState;
|
|
306
|
+
const args = await Promise.all(origArgs.map((arg) => (0, decorators_1.toShellResult)(arg)));
|
|
307
|
+
await ((_b = evaluationListener.onPrint) === null || _b === void 0 ? void 0 : _b.call(evaluationListener, args, type));
|
|
308
|
+
}
|
|
309
|
+
async print(...origArgs) {
|
|
310
|
+
await this._print(origArgs, 'print');
|
|
311
|
+
}
|
|
312
|
+
async printjson(...origArgs) {
|
|
313
|
+
await this._print(origArgs, 'printjson');
|
|
314
|
+
}
|
|
315
|
+
async convertShardKeyToHashed(value) {
|
|
316
|
+
return this._instanceState.currentDb._mongo.convertShardKeyToHashed(value);
|
|
317
|
+
}
|
|
318
|
+
async cls() {
|
|
319
|
+
var _b;
|
|
320
|
+
const { evaluationListener } = this._instanceState;
|
|
321
|
+
await ((_b = evaluationListener.onClearCommand) === null || _b === void 0 ? void 0 : _b.call(evaluationListener));
|
|
322
|
+
}
|
|
323
|
+
isInteractive() {
|
|
324
|
+
return this._instanceState.isInteractive;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
_a = instanceStateSymbol;
|
|
328
|
+
__setFunctionName(_classThis, "ShellApi");
|
|
329
|
+
(() => {
|
|
330
|
+
var _b;
|
|
331
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
|
|
332
|
+
_use_decorators = [decorators_1.directShellCommand, (0, decorators_1.shellCommandCompleter)(useCompleter)];
|
|
333
|
+
_show_decorators = [decorators_1.directShellCommand, decorators_1.returnsPromise, (0, decorators_1.shellCommandCompleter)(showCompleter)];
|
|
334
|
+
__untrackedShow_decorators = [decorators_1.directShellCommand, decorators_1.returnsPromise, (0, decorators_1.shellCommandCompleter)(showCompleter)];
|
|
335
|
+
_exit_decorators = [decorators_1.directShellCommand, decorators_1.returnsPromise, (0, decorators_1.platforms)(['CLI'])];
|
|
336
|
+
_quit_decorators = [decorators_1.directShellCommand, decorators_1.returnsPromise, (0, decorators_1.platforms)(['CLI'])];
|
|
337
|
+
_Mongo_decorators = [decorators_1.returnsPromise, (0, decorators_1.returnType)('Mongo'), (0, decorators_1.platforms)(['CLI'])];
|
|
338
|
+
_connect_decorators = [decorators_1.returnsPromise, (0, decorators_1.returnType)('Database'), (0, decorators_1.platforms)(['CLI'])];
|
|
339
|
+
_it_decorators = [decorators_1.directShellCommand, decorators_1.returnsPromise];
|
|
340
|
+
_load_decorators = [decorators_1.returnsPromise];
|
|
341
|
+
_enableTelemetry_decorators = [decorators_1.returnsPromise, (0, decorators_1.platforms)(['CLI'])];
|
|
342
|
+
_disableTelemetry_decorators = [decorators_1.returnsPromise, (0, decorators_1.platforms)(['CLI'])];
|
|
343
|
+
_passwordPrompt_decorators = [decorators_1.returnsPromise, (0, decorators_1.platforms)(['CLI'])];
|
|
344
|
+
_sleep_decorators = [decorators_1.returnsPromise];
|
|
345
|
+
_print_decorators = [decorators_1.returnsPromise];
|
|
346
|
+
_printjson_decorators = [decorators_1.returnsPromise];
|
|
347
|
+
_convertShardKeyToHashed_decorators = [decorators_1.returnsPromise];
|
|
348
|
+
_cls_decorators = [decorators_1.directShellCommand, decorators_1.returnsPromise];
|
|
349
|
+
__esDecorate(_classThis, null, _use_decorators, { kind: "method", name: "use", static: false, private: false, access: { has: obj => "use" in obj, get: obj => obj.use }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
350
|
+
__esDecorate(_classThis, null, _show_decorators, { kind: "method", name: "show", static: false, private: false, access: { has: obj => "show" in obj, get: obj => obj.show }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
351
|
+
__esDecorate(_classThis, null, __untrackedShow_decorators, { kind: "method", name: "_untrackedShow", static: false, private: false, access: { has: obj => "_untrackedShow" in obj, get: obj => obj._untrackedShow }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
352
|
+
__esDecorate(_classThis, null, _exit_decorators, { kind: "method", name: "exit", static: false, private: false, access: { has: obj => "exit" in obj, get: obj => obj.exit }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
353
|
+
__esDecorate(_classThis, null, _quit_decorators, { kind: "method", name: "quit", static: false, private: false, access: { has: obj => "quit" in obj, get: obj => obj.quit }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
354
|
+
__esDecorate(_classThis, null, _Mongo_decorators, { kind: "method", name: "Mongo", static: false, private: false, access: { has: obj => "Mongo" in obj, get: obj => obj.Mongo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
355
|
+
__esDecorate(_classThis, null, _connect_decorators, { kind: "method", name: "connect", static: false, private: false, access: { has: obj => "connect" in obj, get: obj => obj.connect }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
356
|
+
__esDecorate(_classThis, null, _it_decorators, { kind: "method", name: "it", static: false, private: false, access: { has: obj => "it" in obj, get: obj => obj.it }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
357
|
+
__esDecorate(_classThis, null, _load_decorators, { kind: "method", name: "load", static: false, private: false, access: { has: obj => "load" in obj, get: obj => obj.load }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
358
|
+
__esDecorate(_classThis, null, _enableTelemetry_decorators, { kind: "method", name: "enableTelemetry", static: false, private: false, access: { has: obj => "enableTelemetry" in obj, get: obj => obj.enableTelemetry }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
359
|
+
__esDecorate(_classThis, null, _disableTelemetry_decorators, { kind: "method", name: "disableTelemetry", static: false, private: false, access: { has: obj => "disableTelemetry" in obj, get: obj => obj.disableTelemetry }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
360
|
+
__esDecorate(_classThis, null, _passwordPrompt_decorators, { kind: "method", name: "passwordPrompt", static: false, private: false, access: { has: obj => "passwordPrompt" in obj, get: obj => obj.passwordPrompt }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
361
|
+
__esDecorate(_classThis, null, _sleep_decorators, { kind: "method", name: "sleep", static: false, private: false, access: { has: obj => "sleep" in obj, get: obj => obj.sleep }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
362
|
+
__esDecorate(_classThis, null, _print_decorators, { kind: "method", name: "print", static: false, private: false, access: { has: obj => "print" in obj, get: obj => obj.print }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
363
|
+
__esDecorate(_classThis, null, _printjson_decorators, { kind: "method", name: "printjson", static: false, private: false, access: { has: obj => "printjson" in obj, get: obj => obj.printjson }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
364
|
+
__esDecorate(_classThis, null, _convertShardKeyToHashed_decorators, { kind: "method", name: "convertShardKeyToHashed", static: false, private: false, access: { has: obj => "convertShardKeyToHashed" in obj, get: obj => obj.convertShardKeyToHashed }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
365
|
+
__esDecorate(_classThis, null, _cls_decorators, { kind: "method", name: "cls", static: false, private: false, access: { has: obj => "cls" in obj, get: obj => obj.cls }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
366
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
367
|
+
ShellApi = _classThis = _classDescriptor.value;
|
|
368
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
369
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
370
|
+
})();
|
|
371
|
+
return ShellApi = _classThis;
|
|
372
|
+
})();
|
|
328
373
|
exports.default = ShellApi;
|
|
329
374
|
//# sourceMappingURL=shell-api.js.map
|