mongodb-data-service 22.5.1 → 22.7.0
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/connect-mongo-client.d.ts +7 -3
- package/lib/connect-mongo-client.d.ts.map +1 -1
- package/lib/connect-mongo-client.js +82 -20
- package/lib/connect-mongo-client.js.map +1 -1
- package/lib/connect.d.ts +3 -1
- package/lib/connect.d.ts.map +1 -1
- package/lib/connect.js +3 -3
- package/lib/connect.js.map +1 -1
- package/lib/connection-options.d.ts +5 -0
- package/lib/connection-options.d.ts.map +1 -1
- package/lib/csfle-collection-tracker.d.ts +8 -8
- package/lib/csfle-collection-tracker.d.ts.map +1 -1
- package/lib/csfle-collection-tracker.js +17 -19
- package/lib/csfle-collection-tracker.js.map +1 -1
- package/lib/data-service.d.ts +112 -127
- package/lib/data-service.d.ts.map +1 -1
- package/lib/data-service.js +1087 -1040
- package/lib/data-service.js.map +1 -1
- package/lib/index-detail-helper.d.ts +36 -0
- package/lib/index-detail-helper.d.ts.map +1 -0
- package/lib/index-detail-helper.js +92 -0
- package/lib/index-detail-helper.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/instance-detail-helper.d.ts +10 -8
- package/lib/instance-detail-helper.d.ts.map +1 -1
- package/lib/instance-detail-helper.js +12 -4
- package/lib/instance-detail-helper.js.map +1 -1
- package/lib/legacy/legacy-connection-model.d.ts +1 -1
- package/lib/legacy/legacy-connection-model.d.ts.map +1 -1
- package/lib/logger.d.ts +19 -0
- package/lib/logger.d.ts.map +1 -0
- package/lib/logger.js +10 -0
- package/lib/logger.js.map +1 -0
- package/lib/run-command.d.ts +56 -19
- package/lib/run-command.d.ts.map +1 -1
- package/lib/run-command.js.map +1 -1
- package/lib/ssh-tunnel.d.ts +4 -3
- package/lib/ssh-tunnel.d.ts.map +1 -1
- package/lib/ssh-tunnel.js +7 -9
- package/lib/ssh-tunnel.js.map +1 -1
- package/lib/types.d.ts +1 -17
- package/lib/types.d.ts.map +1 -1
- package/package.json +27 -34
package/lib/data-service.js
CHANGED
|
@@ -15,6 +15,40 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
19
|
+
var useValue = arguments.length > 2;
|
|
20
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
21
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
22
|
+
}
|
|
23
|
+
return useValue ? value : void 0;
|
|
24
|
+
};
|
|
25
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
26
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
27
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
28
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
29
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
30
|
+
var _, done = false;
|
|
31
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
32
|
+
var context = {};
|
|
33
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
34
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
35
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
36
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
37
|
+
if (kind === "accessor") {
|
|
38
|
+
if (result === void 0) continue;
|
|
39
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
40
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
41
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
42
|
+
if (_ = accept(result.init)) initializers.push(_);
|
|
43
|
+
}
|
|
44
|
+
else if (_ = accept(result)) {
|
|
45
|
+
if (kind === "field") initializers.push(_);
|
|
46
|
+
else descriptor[key] = _;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
50
|
+
done = true;
|
|
51
|
+
};
|
|
18
52
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
53
|
if (mod && mod.__esModule) return mod;
|
|
20
54
|
var result = {};
|
|
@@ -27,19 +61,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
61
|
};
|
|
28
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
63
|
exports.DataServiceImpl = void 0;
|
|
30
|
-
const util_1 = require("util");
|
|
31
|
-
const async_1 = __importDefault(require("async"));
|
|
32
|
-
const compass_logging_1 = __importDefault(require("@mongodb-js/compass-logging"));
|
|
33
64
|
const events_1 = require("events");
|
|
34
65
|
const mongodb_connection_string_url_1 = __importDefault(require("mongodb-connection-string-url"));
|
|
35
66
|
const mongodb_ns_1 = __importDefault(require("mongodb-ns"));
|
|
36
67
|
const instance_detail_helper_1 = require("./instance-detail-helper");
|
|
68
|
+
const instance_detail_helper_2 = require("./instance-detail-helper");
|
|
37
69
|
const redact_1 = require("./redact");
|
|
38
|
-
const connect_mongo_client_1 =
|
|
70
|
+
const connect_mongo_client_1 = require("./connect-mongo-client");
|
|
39
71
|
const run_command_1 = require("./run-command");
|
|
40
72
|
const csfle_collection_tracker_1 = require("./csfle-collection-tracker");
|
|
41
73
|
const mongodb = __importStar(require("mongodb"));
|
|
42
74
|
const compass_utils_1 = require("@mongodb-js/compass-utils");
|
|
75
|
+
const index_detail_helper_1 = require("./index-detail-helper");
|
|
76
|
+
const logger_1 = require("./logger");
|
|
77
|
+
const lodash_1 = require("lodash");
|
|
43
78
|
let ClientEncryption;
|
|
44
79
|
try {
|
|
45
80
|
const { extension } = require('mongodb-client-encryption');
|
|
@@ -48,8 +83,6 @@ try {
|
|
|
48
83
|
catch (e) {
|
|
49
84
|
console.warn(e);
|
|
50
85
|
}
|
|
51
|
-
const { fetch: getIndexes } = require('mongodb-index-model');
|
|
52
|
-
const { log, mongoLogId, debug } = (0, compass_logging_1.default)('COMPASS-DATA-SERVICE');
|
|
53
86
|
function uniqueBy(values, key) {
|
|
54
87
|
return Array.from(new Map(values.map((val) => [val[key], val])).values());
|
|
55
88
|
}
|
|
@@ -58,1078 +91,1092 @@ function isEmptyObject(obj) {
|
|
|
58
91
|
}
|
|
59
92
|
let id = 0;
|
|
60
93
|
const kSessionClientType = Symbol('kSessionClientType');
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
class DataServiceImpl extends events_1.EventEmitter {
|
|
65
|
-
constructor(connectionOptions) {
|
|
66
|
-
super();
|
|
67
|
-
this._isConnecting = false;
|
|
68
|
-
this._useCRUDClient = true;
|
|
69
|
-
this._lastSeenTopology = null;
|
|
70
|
-
this._isWritable = false;
|
|
71
|
-
this._topologyType = 'Unknown';
|
|
72
|
-
this._id = id++;
|
|
73
|
-
this._connectionOptions = connectionOptions;
|
|
74
|
-
}
|
|
75
|
-
getMongoClientConnectionOptions() {
|
|
76
|
-
return this._mongoClientConnectionOptions;
|
|
77
|
-
}
|
|
78
|
-
_logCtx() {
|
|
79
|
-
return `Connection ${this._id}`;
|
|
80
|
-
}
|
|
81
|
-
getConnectionOptions() {
|
|
82
|
-
return this._connectionOptions;
|
|
83
|
-
}
|
|
84
|
-
getConnectionString() {
|
|
85
|
-
return new mongodb_connection_string_url_1.default(this._connectionOptions.connectionString);
|
|
94
|
+
const maybePickNs = ([ns]) => {
|
|
95
|
+
if (typeof ns === 'string') {
|
|
96
|
+
return { ns };
|
|
86
97
|
}
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
};
|
|
99
|
+
const isPromiseLike = (val) => {
|
|
100
|
+
return 'then' in val && typeof val.then === 'function';
|
|
101
|
+
};
|
|
102
|
+
const translateErrorMessage = (error) => {
|
|
103
|
+
if (typeof error === 'string') {
|
|
104
|
+
error = { message: error };
|
|
89
105
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
enabled,
|
|
93
|
-
});
|
|
94
|
-
this._useCRUDClient = enabled;
|
|
106
|
+
else if (!error.message) {
|
|
107
|
+
error.message = error.err || error.errmsg;
|
|
95
108
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
109
|
+
return error;
|
|
110
|
+
};
|
|
111
|
+
function op(logId, pickLogAttrs = maybePickNs) {
|
|
112
|
+
return function (target, context) {
|
|
113
|
+
const opName = String(context.name);
|
|
114
|
+
return function (...args) {
|
|
115
|
+
const handleResult = (result) => {
|
|
116
|
+
this._logger.info(logId, `Running ${opName}`, pickLogAttrs(args, result));
|
|
117
|
+
return result;
|
|
118
|
+
};
|
|
119
|
+
const handleError = (error) => {
|
|
120
|
+
var _a;
|
|
121
|
+
const err = translateErrorMessage(error);
|
|
122
|
+
this._logger.error((0, logger_1.mongoLogId)(1001000058), 'Failed to perform data service operation', {
|
|
123
|
+
op: opName,
|
|
124
|
+
message: err,
|
|
125
|
+
...((_a = pickLogAttrs(args)) !== null && _a !== void 0 ? _a : {}),
|
|
126
|
+
});
|
|
127
|
+
throw err;
|
|
128
|
+
};
|
|
129
|
+
try {
|
|
130
|
+
const result = target.call(this, ...args);
|
|
131
|
+
if (isPromiseLike(result)) {
|
|
132
|
+
return result.then(handleResult, handleError);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
return handleResult(result);
|
|
136
|
+
}
|
|
103
137
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return 'unavailable';
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
collection(ns, options, callback) {
|
|
110
|
-
async_1.default.parallel({
|
|
111
|
-
stats: this.collectionStats.bind(this, this._databaseName(ns), this._collectionName(ns)),
|
|
112
|
-
indexes: this.indexes.bind(this, ns, options),
|
|
113
|
-
}, (error, coll) => {
|
|
114
|
-
if (error) {
|
|
115
|
-
return callback(this._translateMessage(error));
|
|
116
|
-
}
|
|
117
|
-
callback(null, this._buildCollectionDetail(ns, coll));
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
collections(databaseName, callback) {
|
|
121
|
-
if (databaseName === 'system') {
|
|
122
|
-
return callback(null, []);
|
|
123
|
-
}
|
|
124
|
-
this._collectionNames(databaseName, (error, names) => {
|
|
125
|
-
if (error) {
|
|
126
|
-
return callback(this._translateMessage(error));
|
|
138
|
+
catch (error) {
|
|
139
|
+
return handleError(error);
|
|
127
140
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
let DataServiceImpl = (() => {
|
|
145
|
+
var _a;
|
|
146
|
+
let _instanceExtraInitializers = [];
|
|
147
|
+
let _collectionStats_decorators;
|
|
148
|
+
let _collectionInfo_decorators;
|
|
149
|
+
let _killOp_decorators;
|
|
150
|
+
let __connectionStatus_decorators;
|
|
151
|
+
let _listCollections_decorators;
|
|
152
|
+
let _listDatabases_decorators;
|
|
153
|
+
let _estimatedCount_decorators;
|
|
154
|
+
let _count_decorators;
|
|
155
|
+
let _createCollection_decorators;
|
|
156
|
+
let _createIndex_decorators;
|
|
157
|
+
let _deleteOne_decorators;
|
|
158
|
+
let _deleteMany_decorators;
|
|
159
|
+
let _dropCollection_decorators;
|
|
160
|
+
let _dropDatabase_decorators;
|
|
161
|
+
let _dropIndex_decorators;
|
|
162
|
+
let _aggregateCursor_decorators;
|
|
163
|
+
let _aggregate_decorators;
|
|
164
|
+
let _find_decorators;
|
|
165
|
+
let _findCursor_decorators;
|
|
166
|
+
let _findOneAndReplace_decorators;
|
|
167
|
+
let _findOneAndUpdate_decorators;
|
|
168
|
+
let _updateOne_decorators;
|
|
169
|
+
let _replaceOne_decorators;
|
|
170
|
+
let _explainFind_decorators;
|
|
171
|
+
let _explainAggregate_decorators;
|
|
172
|
+
let _indexes_decorators;
|
|
173
|
+
let _instance_decorators;
|
|
174
|
+
let _insertOne_decorators;
|
|
175
|
+
let _insertMany_decorators;
|
|
176
|
+
let _updateCollection_decorators;
|
|
177
|
+
let _currentOp_decorators;
|
|
178
|
+
let _serverStatus_decorators;
|
|
179
|
+
let _top_decorators;
|
|
180
|
+
let _createView_decorators;
|
|
181
|
+
let _databaseStats_decorators;
|
|
182
|
+
let _createDataKey_decorators;
|
|
183
|
+
return _a = class DataServiceImpl extends logger_1.WithLogContext {
|
|
184
|
+
constructor(connectionOptions, logger) {
|
|
185
|
+
super();
|
|
186
|
+
this._connectionOptions = (__runInitializers(this, _instanceExtraInitializers), void 0);
|
|
187
|
+
this._isConnecting = false;
|
|
188
|
+
this._useCRUDClient = true;
|
|
189
|
+
this._lastSeenTopology = null;
|
|
190
|
+
this._isWritable = false;
|
|
191
|
+
this._emitter = new events_1.EventEmitter();
|
|
192
|
+
this._id = id++;
|
|
193
|
+
this._connectionOptions = connectionOptions;
|
|
194
|
+
const logComponent = 'COMPASS-DATA-SERVICE';
|
|
195
|
+
const logCtx = `Connection ${this._id}`;
|
|
196
|
+
this._logger = {
|
|
197
|
+
debug: (logId, ...args) => {
|
|
198
|
+
return logger === null || logger === void 0 ? void 0 : logger.debug(logComponent, logId, logCtx, ...args);
|
|
199
|
+
},
|
|
200
|
+
info: (logId, ...args) => {
|
|
201
|
+
return logger === null || logger === void 0 ? void 0 : logger.info(logComponent, logId, logCtx, ...args);
|
|
202
|
+
},
|
|
203
|
+
warn: (logId, ...args) => {
|
|
204
|
+
return logger === null || logger === void 0 ? void 0 : logger.warn(logComponent, logId, logCtx, ...args);
|
|
205
|
+
},
|
|
206
|
+
error: (logId, ...args) => {
|
|
207
|
+
return logger === null || logger === void 0 ? void 0 : logger.error(logComponent, logId, logCtx, ...args);
|
|
208
|
+
},
|
|
209
|
+
fatal: (logId, ...args) => {
|
|
210
|
+
return logger === null || logger === void 0 ? void 0 : logger.fatal(logComponent, logId, logCtx, ...args);
|
|
211
|
+
},
|
|
131
212
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
collectionStats(databaseName, collectionName, callback) {
|
|
136
|
-
const logop = this._startLogOp(mongoLogId(1001000031), 'Fetching collection info', { ns: `${databaseName}.${collectionName}` });
|
|
137
|
-
const db = this._initializedClient('META').db(databaseName);
|
|
138
|
-
(0, util_1.callbackify)(db.command.bind(db))({ collStats: collectionName, verbose: true }, (error, data) => {
|
|
139
|
-
logop(error);
|
|
140
|
-
if (error && !error.message.includes('is a view, not a collection')) {
|
|
141
|
-
return callback(this._translateMessage(error));
|
|
142
|
-
}
|
|
143
|
-
callback(null, this._buildCollectionStats(databaseName, collectionName, data || {}));
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
async collectionInfo(dbName, collName) {
|
|
147
|
-
try {
|
|
148
|
-
const [collInfo] = await this.listCollections(dbName, { name: collName });
|
|
149
|
-
return collInfo !== null && collInfo !== void 0 ? collInfo : null;
|
|
150
|
-
}
|
|
151
|
-
catch (err) {
|
|
152
|
-
throw this._translateMessage(err);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
command(databaseName, comm, callback) {
|
|
156
|
-
const db = this._initializedClient('META').db(databaseName);
|
|
157
|
-
(0, util_1.callbackify)(db.command.bind(db))(comm, (error, result) => {
|
|
158
|
-
if (error) {
|
|
159
|
-
return callback(this._translateMessage(error));
|
|
160
|
-
}
|
|
161
|
-
callback(null, result);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
isWritable() {
|
|
165
|
-
return this._isWritable;
|
|
166
|
-
}
|
|
167
|
-
isMongos() {
|
|
168
|
-
return this._topologyType === 'Sharded';
|
|
169
|
-
}
|
|
170
|
-
currentTopologyType() {
|
|
171
|
-
return this._topologyType;
|
|
172
|
-
}
|
|
173
|
-
async connectionStatus() {
|
|
174
|
-
const logop = this._startLogOp(mongoLogId(1001000100), 'Running connectionStatus');
|
|
175
|
-
try {
|
|
176
|
-
const adminDb = this._initializedClient('META').db('admin');
|
|
177
|
-
const result = await (0, run_command_1.runCommand)(adminDb, {
|
|
178
|
-
connectionStatus: 1,
|
|
179
|
-
showPrivileges: true,
|
|
180
|
-
});
|
|
181
|
-
logop(null);
|
|
182
|
-
return result;
|
|
183
|
-
}
|
|
184
|
-
catch (e) {
|
|
185
|
-
logop(e);
|
|
186
|
-
throw e;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
async _getPrivilegesOrFallback(privileges = null) {
|
|
190
|
-
if (privileges) {
|
|
191
|
-
return privileges;
|
|
192
|
-
}
|
|
193
|
-
const { authInfo: { authenticatedUserPrivileges }, } = await this.connectionStatus();
|
|
194
|
-
return authenticatedUserPrivileges;
|
|
195
|
-
}
|
|
196
|
-
async _getRolesOrFallback(roles = null) {
|
|
197
|
-
if (roles) {
|
|
198
|
-
return roles;
|
|
199
|
-
}
|
|
200
|
-
const { authInfo: { authenticatedUserRoles }, } = await this.connectionStatus();
|
|
201
|
-
return authenticatedUserRoles;
|
|
202
|
-
}
|
|
203
|
-
async listCollections(databaseName, filter = {}, { nameOnly, privileges = null, } = {}) {
|
|
204
|
-
const logop = this._startLogOp(mongoLogId(1001000032), 'Running listCollections', { db: databaseName, nameOnly: nameOnly !== null && nameOnly !== void 0 ? nameOnly : false });
|
|
205
|
-
const db = this._initializedClient('CRUD').db(databaseName);
|
|
206
|
-
const listCollections = async () => {
|
|
207
|
-
try {
|
|
208
|
-
const cursor = db.listCollections(filter, { nameOnly });
|
|
209
|
-
const results = [];
|
|
210
|
-
for await (const result of cursor) {
|
|
211
|
-
this.emit('collectionInfoFetched', { databaseName, nameOnly }, result);
|
|
212
|
-
results.push(result);
|
|
213
|
+
if (logger) {
|
|
214
|
+
this._unboundLogger = Object.assign(logger, { mongoLogId: logger_1.mongoLogId });
|
|
213
215
|
}
|
|
214
|
-
return results;
|
|
215
216
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return
|
|
217
|
+
on(...args) {
|
|
218
|
+
this._emitter.on(...args);
|
|
219
|
+
return this;
|
|
219
220
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
catch (err) {
|
|
237
|
-
logop(err);
|
|
238
|
-
throw err;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
async listDatabases({ nameOnly, privileges = null, roles = null, } = {}) {
|
|
242
|
-
const logop = this._startLogOp(mongoLogId(1001000033), 'Running listDatabases', { nameOnly: nameOnly !== null && nameOnly !== void 0 ? nameOnly : false });
|
|
243
|
-
const adminDb = this._initializedClient('CRUD').db('admin');
|
|
244
|
-
const listDatabases = async () => {
|
|
245
|
-
try {
|
|
246
|
-
const { databases } = await (0, run_command_1.runCommand)(adminDb, {
|
|
247
|
-
listDatabases: 1,
|
|
248
|
-
nameOnly,
|
|
221
|
+
once(...args) {
|
|
222
|
+
this._emitter.on(...args);
|
|
223
|
+
return this;
|
|
224
|
+
}
|
|
225
|
+
getMongoClientConnectionOptions() {
|
|
226
|
+
return (0, lodash_1.omit)(this._mongoClientConnectionOptions, 'options.oidc.notifyDeviceFlow', 'options.oidc.signal');
|
|
227
|
+
}
|
|
228
|
+
getConnectionOptions() {
|
|
229
|
+
return this._connectionOptions;
|
|
230
|
+
}
|
|
231
|
+
getConnectionString() {
|
|
232
|
+
return new mongodb_connection_string_url_1.default(this._connectionOptions.connectionString);
|
|
233
|
+
}
|
|
234
|
+
setCSFLEEnabled(enabled) {
|
|
235
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000117), 'Setting CSFLE mode', {
|
|
236
|
+
enabled,
|
|
249
237
|
});
|
|
250
|
-
|
|
238
|
+
this._useCRUDClient = enabled;
|
|
251
239
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
240
|
+
getCSFLEMode() {
|
|
241
|
+
if (this._crudClient && (0, instance_detail_helper_2.checkIsCSFLEConnection)(this._crudClient)) {
|
|
242
|
+
if (this._useCRUDClient) {
|
|
243
|
+
return 'enabled';
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
return 'disabled';
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
return 'unavailable';
|
|
251
|
+
}
|
|
255
252
|
}
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
this._tunnel = tunnel;
|
|
310
|
-
this._mongoClientConnectionOptions = connectionOptions;
|
|
311
|
-
this._csfleCollectionTracker = new csfle_collection_tracker_1.CSFLECollectionTrackerImpl(this, this._crudClient);
|
|
312
|
-
}
|
|
313
|
-
finally {
|
|
314
|
-
this._isConnecting = false;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
estimatedCount(ns, options = {}, executionOptions) {
|
|
318
|
-
log.info(mongoLogId(1001000034), this._logCtx(), 'Running estimatedCount', { ns });
|
|
319
|
-
let _session;
|
|
320
|
-
return this.cancellableOperation(async (session) => {
|
|
321
|
-
_session = session;
|
|
322
|
-
return this._collection(ns, 'CRUD').estimatedDocumentCount({
|
|
323
|
-
...options,
|
|
324
|
-
session,
|
|
325
|
-
});
|
|
326
|
-
}, () => _session.endSession(), executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.abortSignal);
|
|
327
|
-
}
|
|
328
|
-
count(ns, filter, options = {}, executionOptions) {
|
|
329
|
-
log.info(mongoLogId(1001000035), this._logCtx(), 'Running countDocuments', { ns });
|
|
330
|
-
let _session;
|
|
331
|
-
return this.cancellableOperation(async (session) => {
|
|
332
|
-
_session = session;
|
|
333
|
-
return this._collection(ns, 'CRUD').countDocuments(filter, {
|
|
334
|
-
...options,
|
|
335
|
-
session,
|
|
336
|
-
});
|
|
337
|
-
}, () => _session.endSession(), executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.abortSignal);
|
|
338
|
-
}
|
|
339
|
-
createCollection(ns, options, callback) {
|
|
340
|
-
const collectionName = this._collectionName(ns);
|
|
341
|
-
const db = this._initializedClient('CRUD').db(this._databaseName(ns));
|
|
342
|
-
const logop = this._startLogOp(mongoLogId(1001000036), 'Running createCollection', { ns, options });
|
|
343
|
-
(0, util_1.callbackify)(allArgumentsMandatory(db.createCollection.bind(db)))(collectionName, options, (error, result) => {
|
|
344
|
-
logop(error);
|
|
345
|
-
if (error) {
|
|
346
|
-
return callback(this._translateMessage(error));
|
|
347
|
-
}
|
|
348
|
-
callback(null, result);
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
createIndex(ns, spec, options, callback) {
|
|
352
|
-
const logop = this._startLogOp(mongoLogId(1001000037), 'Running createIndex', { ns, spec, options });
|
|
353
|
-
const coll = this._collection(ns, 'CRUD');
|
|
354
|
-
(0, util_1.callbackify)(allArgumentsMandatory(coll.createIndex.bind(coll)))(spec, options, (error, result) => {
|
|
355
|
-
logop(error);
|
|
356
|
-
if (error) {
|
|
357
|
-
return callback(this._translateMessage(error));
|
|
358
|
-
}
|
|
359
|
-
callback(null, result);
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
database(name, options, callback) {
|
|
363
|
-
const asyncColls = (0, util_1.promisify)(this.collections.bind(this));
|
|
364
|
-
void Promise.all([this.databaseStats(name), asyncColls(name)]).then(([stats, collections]) => {
|
|
365
|
-
callback(null, this._buildDatabaseDetail(name, { stats, collections }));
|
|
366
|
-
}, (err) => {
|
|
367
|
-
callback(this._translateMessage(err));
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
deleteOne(ns, filter, options, callback) {
|
|
371
|
-
const logop = this._startLogOp(mongoLogId(1001000038), 'Running deleteOne', { ns });
|
|
372
|
-
const coll = this._collection(ns, 'CRUD');
|
|
373
|
-
(0, util_1.callbackify)(allArgumentsMandatory(coll.deleteOne.bind(coll)))(filter, options, (error, result) => {
|
|
374
|
-
logop(error, result);
|
|
375
|
-
if (error) {
|
|
376
|
-
return callback(this._translateMessage(error));
|
|
377
|
-
}
|
|
378
|
-
callback(null, result);
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
deleteMany(ns, filter, options, callback) {
|
|
382
|
-
const logop = this._startLogOp(mongoLogId(1001000039), 'Running deleteMany', { ns });
|
|
383
|
-
const coll = this._collection(ns, 'CRUD');
|
|
384
|
-
(0, util_1.callbackify)(allArgumentsMandatory(coll.deleteMany.bind(coll)))(filter, options, (error, result) => {
|
|
385
|
-
logop(error, result);
|
|
386
|
-
if (error) {
|
|
387
|
-
return callback(this._translateMessage(error));
|
|
388
|
-
}
|
|
389
|
-
callback(null, result);
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
async disconnect() {
|
|
393
|
-
var _a, _b, _c;
|
|
394
|
-
log.info(mongoLogId(1001000016), this._logCtx(), 'Disconnecting');
|
|
395
|
-
try {
|
|
396
|
-
await Promise.all([
|
|
397
|
-
(_a = this._metadataClient) === null || _a === void 0 ? void 0 : _a.close(true).catch((err) => debug('failed to close MongoClient', err)),
|
|
398
|
-
this._crudClient !== this._metadataClient &&
|
|
399
|
-
((_b = this._crudClient) === null || _b === void 0 ? void 0 : _b.close(true).catch((err) => debug('failed to close MongoClient', err))),
|
|
400
|
-
(_c = this._tunnel) === null || _c === void 0 ? void 0 : _c.close().catch((err) => debug('failed to close tunnel', err)),
|
|
401
|
-
]);
|
|
402
|
-
}
|
|
403
|
-
finally {
|
|
404
|
-
this._cleanup();
|
|
405
|
-
log.info(mongoLogId(1001000017), this._logCtx(), 'Fully closed');
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
dropCollection(ns, callback) {
|
|
409
|
-
const logop = this._startLogOp(mongoLogId(1001000059), 'Running dropCollection', { ns });
|
|
410
|
-
const client = this._initializedClient('CRUD');
|
|
411
|
-
const db = client.db(this._databaseName(ns));
|
|
412
|
-
const collName = this._collectionName(ns);
|
|
413
|
-
const coll = db.collection(collName);
|
|
414
|
-
const cursor = db.listCollections({ name: collName }, { nameOnly: false });
|
|
415
|
-
(0, util_1.callbackify)(cursor.toArray.bind(cursor))((_errIgnore, result) => {
|
|
416
|
-
var _a, _b;
|
|
417
|
-
const options = {};
|
|
418
|
-
const encryptedFieldsInfo = (_b = (_a = result === null || result === void 0 ? void 0 : result[0]) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.encryptedFields;
|
|
419
|
-
if (encryptedFieldsInfo) {
|
|
420
|
-
options.encryptedFields = encryptedFieldsInfo;
|
|
421
|
-
}
|
|
422
|
-
(0, util_1.callbackify)(allArgumentsMandatory(coll.drop.bind(coll)))(options, (error, result) => {
|
|
423
|
-
logop(error, result);
|
|
424
|
-
if (error) {
|
|
425
|
-
return callback(this._translateMessage(error));
|
|
253
|
+
async collectionStats(databaseName, collectionName) {
|
|
254
|
+
const ns = `${databaseName}.${collectionName}`;
|
|
255
|
+
try {
|
|
256
|
+
const coll = this._collection(ns, 'CRUD');
|
|
257
|
+
const collStats = await coll
|
|
258
|
+
.aggregate([
|
|
259
|
+
{ $collStats: { storageStats: {} } },
|
|
260
|
+
{
|
|
261
|
+
$group: {
|
|
262
|
+
_id: null,
|
|
263
|
+
capped: { $first: '$storageStats.capped' },
|
|
264
|
+
count: { $sum: '$storageStats.count' },
|
|
265
|
+
size: { $sum: { $toDouble: '$storageStats.size' } },
|
|
266
|
+
storageSize: {
|
|
267
|
+
$sum: { $toDouble: '$storageStats.storageSize' },
|
|
268
|
+
},
|
|
269
|
+
totalIndexSize: {
|
|
270
|
+
$sum: { $toDouble: '$storageStats.totalIndexSize' },
|
|
271
|
+
},
|
|
272
|
+
freeStorageSize: {
|
|
273
|
+
$sum: { $toDouble: '$storageStats.freeStorageSize' },
|
|
274
|
+
},
|
|
275
|
+
unscaledCollSize: {
|
|
276
|
+
$sum: {
|
|
277
|
+
$multiply: [
|
|
278
|
+
{ $toDouble: '$storageStats.avgObjSize' },
|
|
279
|
+
{ $toDouble: '$storageStats.count' },
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
nindexes: { $max: '$storageStats.nindexes' },
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
$addFields: {
|
|
288
|
+
avgObjSize: {
|
|
289
|
+
$cond: {
|
|
290
|
+
if: { $ne: ['$count', 0] },
|
|
291
|
+
then: {
|
|
292
|
+
$divide: ['$unscaledCollSize', { $toDouble: '$count' }],
|
|
293
|
+
},
|
|
294
|
+
else: 0,
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
])
|
|
300
|
+
.toArray();
|
|
301
|
+
if (!collStats || collStats[0] === undefined) {
|
|
302
|
+
throw new Error(`Error running $collStats aggregation stage on ${ns}`);
|
|
303
|
+
}
|
|
304
|
+
collStats[0].ns = ns;
|
|
305
|
+
return this._buildCollectionStats(databaseName, collectionName, collStats[0]);
|
|
426
306
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
dropDatabase(name, callback) {
|
|
432
|
-
const logop = this._startLogOp(mongoLogId(1001000040), 'Running dropDatabase', { db: name });
|
|
433
|
-
const db = this._initializedClient('CRUD').db(this._databaseName(name));
|
|
434
|
-
(0, util_1.callbackify)(db.dropDatabase.bind(db))((error, result) => {
|
|
435
|
-
logop(error, result);
|
|
436
|
-
if (error) {
|
|
437
|
-
return callback(this._translateMessage(error));
|
|
438
|
-
}
|
|
439
|
-
callback(null, result);
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
dropIndex(ns, name, callback) {
|
|
443
|
-
const logop = this._startLogOp(mongoLogId(1001000060), 'Running dropIndex', { ns, name });
|
|
444
|
-
const coll = this._collection(ns, 'CRUD');
|
|
445
|
-
(0, util_1.callbackify)(coll.dropIndex.bind(coll))(name, (error, result) => {
|
|
446
|
-
logop(error, result);
|
|
447
|
-
if (error) {
|
|
448
|
-
return callback(this._translateMessage(error));
|
|
449
|
-
}
|
|
450
|
-
callback(null, result);
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
aggregateCursor(ns, pipeline, options = {}) {
|
|
454
|
-
log.info(mongoLogId(1001000041), this._logCtx(), 'Running aggregation', {
|
|
455
|
-
ns,
|
|
456
|
-
stages: pipeline.map((stage) => Object.keys(stage)[0]),
|
|
457
|
-
});
|
|
458
|
-
return this._collection(ns, 'CRUD').aggregate(pipeline, options);
|
|
459
|
-
}
|
|
460
|
-
aggregate(ns, pipeline, options = {}, executionOptions) {
|
|
461
|
-
let cursor;
|
|
462
|
-
return this.cancellableOperation(async (session) => {
|
|
463
|
-
cursor = this.aggregateCursor(ns, pipeline, { ...options, session });
|
|
464
|
-
const results = await cursor.toArray();
|
|
465
|
-
void cursor.close();
|
|
466
|
-
return results;
|
|
467
|
-
}, () => cursor === null || cursor === void 0 ? void 0 : cursor.close(), executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.abortSignal);
|
|
468
|
-
}
|
|
469
|
-
find(ns, filter, options = {}, executionOptions) {
|
|
470
|
-
let cursor;
|
|
471
|
-
return this.cancellableOperation(async (session) => {
|
|
472
|
-
cursor = this.findCursor(ns, filter, { ...options, session });
|
|
473
|
-
const results = await cursor.toArray();
|
|
474
|
-
void cursor.close();
|
|
475
|
-
return results;
|
|
476
|
-
}, () => cursor === null || cursor === void 0 ? void 0 : cursor.close(), executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.abortSignal);
|
|
477
|
-
}
|
|
478
|
-
findCursor(ns, filter, options = {}) {
|
|
479
|
-
log.info(mongoLogId(1001000043), this._logCtx(), 'Running find', { ns });
|
|
480
|
-
return this._collection(ns, 'CRUD').find(filter, options);
|
|
481
|
-
}
|
|
482
|
-
findOneAndReplace(ns, filter, replacement, options, callback) {
|
|
483
|
-
const logop = this._startLogOp(mongoLogId(1001000044), 'Running findOneAndReplace', { ns });
|
|
484
|
-
const coll = this._collection(ns, 'CRUD');
|
|
485
|
-
(0, util_1.callbackify)(allArgumentsMandatory(coll.findOneAndReplace.bind(coll)))(filter, replacement, options, (error, result) => {
|
|
486
|
-
logop(error);
|
|
487
|
-
if (error) {
|
|
488
|
-
return callback(this._translateMessage(error));
|
|
489
|
-
}
|
|
490
|
-
callback(null, result.value);
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
findOneAndUpdate(ns, filter, update, options, callback) {
|
|
494
|
-
const logop = this._startLogOp(mongoLogId(1001000045), 'Running findOneAndUpdate', { ns });
|
|
495
|
-
const coll = this._collection(ns, 'CRUD');
|
|
496
|
-
(0, util_1.callbackify)(allArgumentsMandatory(coll.findOneAndUpdate.bind(coll)))(filter, update, options, (error, result) => {
|
|
497
|
-
logop(error);
|
|
498
|
-
if (error) {
|
|
499
|
-
return callback(this._translateMessage(error));
|
|
500
|
-
}
|
|
501
|
-
callback(null, result.value);
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
explainFind(ns, filter, options = {}, executionOptions) {
|
|
505
|
-
const verbosity = (executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.explainVerbosity) ||
|
|
506
|
-
mongodb.ExplainVerbosity.allPlansExecution;
|
|
507
|
-
log.info(mongoLogId(1001000046), this._logCtx(), 'Running find explain', { ns, verbosity });
|
|
508
|
-
let cursor;
|
|
509
|
-
return this.cancellableOperation(async (session) => {
|
|
510
|
-
cursor = this.findCursor(ns, filter, { ...options, session });
|
|
511
|
-
const results = await cursor.explain(verbosity);
|
|
512
|
-
void cursor.close();
|
|
513
|
-
return results;
|
|
514
|
-
}, () => cursor === null || cursor === void 0 ? void 0 : cursor.close(), executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.abortSignal);
|
|
515
|
-
}
|
|
516
|
-
explainAggregate(ns, pipeline, options, executionOptions) {
|
|
517
|
-
const verbosity = (executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.explainVerbosity) ||
|
|
518
|
-
mongodb.ExplainVerbosity.queryPlanner;
|
|
519
|
-
log.info(mongoLogId(1001000177), this._logCtx(), 'Running aggregate explain', { ns, verbosity });
|
|
520
|
-
let cursor;
|
|
521
|
-
return this.cancellableOperation(async (session) => {
|
|
522
|
-
cursor = this.aggregateCursor(ns, pipeline, { ...options, session });
|
|
523
|
-
const results = await cursor.explain(verbosity);
|
|
524
|
-
void cursor.close();
|
|
525
|
-
return results;
|
|
526
|
-
}, () => cursor === null || cursor === void 0 ? void 0 : cursor.close(), executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.abortSignal);
|
|
527
|
-
}
|
|
528
|
-
indexes(ns, options, callback) {
|
|
529
|
-
const logop = this._startLogOp(mongoLogId(1001000047), 'Listing indexes', { ns });
|
|
530
|
-
getIndexes(this._initializedClient('META'), ns, (error, data) => {
|
|
531
|
-
logop(error);
|
|
532
|
-
if (error) {
|
|
533
|
-
return callback(this._translateMessage(error));
|
|
534
|
-
}
|
|
535
|
-
callback(null, data);
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
async instance() {
|
|
539
|
-
try {
|
|
540
|
-
const instanceData = {
|
|
541
|
-
...(await (0, instance_detail_helper_1.getInstance)(this._initializedClient('META'))),
|
|
542
|
-
csfleMode: this.getCSFLEMode(),
|
|
543
|
-
};
|
|
544
|
-
log.info(mongoLogId(1001000024), this._logCtx(), 'Fetched instance information', {
|
|
545
|
-
serverVersion: instanceData.build.version,
|
|
546
|
-
genuineMongoDB: instanceData.genuineMongoDB,
|
|
547
|
-
dataLake: instanceData.dataLake,
|
|
548
|
-
featureCompatibilityVersion: instanceData.featureCompatibilityVersion,
|
|
549
|
-
});
|
|
550
|
-
return instanceData;
|
|
551
|
-
}
|
|
552
|
-
catch (err) {
|
|
553
|
-
throw this._translateMessage(err);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
insertOne(ns, doc, options, callback) {
|
|
557
|
-
const logop = this._startLogOp(mongoLogId(1001000048), 'Running insertOne', { ns });
|
|
558
|
-
const coll = this._collection(ns, 'CRUD');
|
|
559
|
-
(0, util_1.callbackify)(allArgumentsMandatory(coll.insertOne.bind(coll)))(doc, options, (error, result) => {
|
|
560
|
-
logop(error, { acknowledged: result === null || result === void 0 ? void 0 : result.acknowledged });
|
|
561
|
-
if (error) {
|
|
562
|
-
return callback(this._translateMessage(error));
|
|
563
|
-
}
|
|
564
|
-
callback(null, result);
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
insertMany(ns, docs, options, callback) {
|
|
568
|
-
const logop = this._startLogOp(mongoLogId(1001000049), 'Running insertMany', { ns });
|
|
569
|
-
const coll = this._collection(ns, 'CRUD');
|
|
570
|
-
(0, util_1.callbackify)(allArgumentsMandatory(coll.insertMany.bind(coll)))(docs, options, (error, result) => {
|
|
571
|
-
logop(error, {
|
|
572
|
-
acknowledged: result === null || result === void 0 ? void 0 : result.acknowledged,
|
|
573
|
-
insertedCount: result === null || result === void 0 ? void 0 : result.insertedCount,
|
|
574
|
-
});
|
|
575
|
-
if (error) {
|
|
576
|
-
return callback(this._translateMessage(error));
|
|
577
|
-
}
|
|
578
|
-
callback(null, result);
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
putMany(ns, docs, options) {
|
|
582
|
-
return this._collection(ns, 'CRUD').insertMany(docs, options);
|
|
583
|
-
}
|
|
584
|
-
updateCollection(ns, flags, callback) {
|
|
585
|
-
const logop = this._startLogOp(mongoLogId(1001000050), 'Running updateCollection', { ns });
|
|
586
|
-
const collectionName = this._collectionName(ns);
|
|
587
|
-
const db = this._initializedClient('CRUD').db(this._databaseName(ns));
|
|
588
|
-
const command = {
|
|
589
|
-
collMod: collectionName,
|
|
590
|
-
...flags,
|
|
591
|
-
};
|
|
592
|
-
(0, util_1.callbackify)(db.command.bind(db))(command, (error, result) => {
|
|
593
|
-
logop(error, result);
|
|
594
|
-
if (error) {
|
|
595
|
-
return callback(this._translateMessage(error));
|
|
596
|
-
}
|
|
597
|
-
this._resetCRUDClient().then(() => {
|
|
598
|
-
callback(null, result);
|
|
599
|
-
}, (error) => {
|
|
600
|
-
callback(this._translateMessage(error));
|
|
601
|
-
});
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
updateOne(ns, filter, update, options, callback) {
|
|
605
|
-
const logop = this._startLogOp(mongoLogId(1001000051), 'Running updateOne', { ns });
|
|
606
|
-
const coll = this._collection(ns, 'CRUD');
|
|
607
|
-
(0, util_1.callbackify)(allArgumentsMandatory(coll.updateOne.bind(coll)))(filter, update, options, (error, result) => {
|
|
608
|
-
logop(error, result);
|
|
609
|
-
if (error) {
|
|
610
|
-
return callback(this._translateMessage(error));
|
|
611
|
-
}
|
|
612
|
-
callback(null, result);
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
updateMany(ns, filter, update, options, callback) {
|
|
616
|
-
const logop = this._startLogOp(mongoLogId(1001000052), 'Running updateMany', { ns });
|
|
617
|
-
const coll = this._collection(ns, 'CRUD');
|
|
618
|
-
(0, util_1.callbackify)(allArgumentsMandatory(coll.updateMany.bind(coll)))(filter, update, options, (error, result) => {
|
|
619
|
-
logop(error, result);
|
|
620
|
-
if (error) {
|
|
621
|
-
return callback(this._translateMessage(error));
|
|
622
|
-
}
|
|
623
|
-
callback(null, result);
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
bulkWrite(ns, operations, options) {
|
|
627
|
-
return this._collection(ns, 'CRUD').bulkWrite(operations, options);
|
|
628
|
-
}
|
|
629
|
-
currentOp(includeAll, callback) {
|
|
630
|
-
const logop = this._startLogOp(mongoLogId(1001000053), 'Running currentOp');
|
|
631
|
-
const db = this._initializedClient('META').db('admin');
|
|
632
|
-
(0, util_1.callbackify)(db.command.bind(db))({ currentOp: 1, $all: includeAll }, (error, result) => {
|
|
633
|
-
logop(error);
|
|
634
|
-
if (error) {
|
|
635
|
-
const logop = this._startLogOp(mongoLogId(1001000054), 'Searching $cmd.sys.inprog manually');
|
|
636
|
-
const coll = db.collection('$cmd.sys.inprog');
|
|
637
|
-
(0, util_1.callbackify)(coll.findOne.bind(coll))({ $all: includeAll }, (error2, result2) => {
|
|
638
|
-
logop(error2);
|
|
639
|
-
if (error2) {
|
|
640
|
-
return callback(this._translateMessage(error2));
|
|
307
|
+
catch (error) {
|
|
308
|
+
if (!error.message.includes('is a view, not a collection')) {
|
|
309
|
+
throw error;
|
|
641
310
|
}
|
|
642
|
-
|
|
311
|
+
return this._buildCollectionStats(databaseName, collectionName, {});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
async collectionInfo(dbName, collName) {
|
|
315
|
+
var _a;
|
|
316
|
+
const [collInfo] = await this._listCollections(dbName, { name: collName });
|
|
317
|
+
return (_a = (0, instance_detail_helper_2.adaptCollectionInfo)({ db: dbName, ...collInfo })) !== null && _a !== void 0 ? _a : null;
|
|
318
|
+
}
|
|
319
|
+
async killOp(id, comment) {
|
|
320
|
+
const db = this._database('admin', 'META');
|
|
321
|
+
return (0, run_command_1.runCommand)(db, { killOp: 1, id, comment });
|
|
322
|
+
}
|
|
323
|
+
isWritable() {
|
|
324
|
+
return this._isWritable;
|
|
325
|
+
}
|
|
326
|
+
isMongos() {
|
|
327
|
+
return this.getCurrentTopologyType() === 'Sharded';
|
|
328
|
+
}
|
|
329
|
+
getCurrentTopologyType() {
|
|
330
|
+
var _a, _b;
|
|
331
|
+
return (_b = (_a = this.getLastSeenTopology()) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : 'Unknown';
|
|
332
|
+
}
|
|
333
|
+
async _connectionStatus() {
|
|
334
|
+
const adminDb = this._database('admin', 'META');
|
|
335
|
+
return await (0, run_command_1.runCommand)(adminDb, {
|
|
336
|
+
connectionStatus: 1,
|
|
337
|
+
showPrivileges: true,
|
|
643
338
|
});
|
|
644
|
-
return;
|
|
645
339
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
return
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
}
|
|
663
|
-
top(callback) {
|
|
664
|
-
const logop = this._startLogOp(mongoLogId(1001000062), 'Running top');
|
|
665
|
-
const admin = this._initializedClient('META').db().admin();
|
|
666
|
-
(0, util_1.callbackify)(admin.command.bind(admin))({ top: 1 }, (error, result) => {
|
|
667
|
-
logop(error);
|
|
668
|
-
if (error) {
|
|
669
|
-
return callback(this._translateMessage(error));
|
|
670
|
-
}
|
|
671
|
-
callback(null, result);
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
|
-
createView(name, sourceNs, pipeline, options, callback) {
|
|
675
|
-
options.viewOn = this._collectionName(sourceNs);
|
|
676
|
-
options.pipeline = pipeline;
|
|
677
|
-
const logop = this._startLogOp(mongoLogId(1001000055), 'Running createView', {
|
|
678
|
-
name,
|
|
679
|
-
sourceNs,
|
|
680
|
-
stages: pipeline.map((stage) => Object.keys(stage)[0]),
|
|
681
|
-
options,
|
|
682
|
-
});
|
|
683
|
-
const db = this._initializedClient('CRUD').db(this._databaseName(sourceNs));
|
|
684
|
-
(0, util_1.callbackify)(allArgumentsMandatory(db.createCollection.bind(db)))(name, options, (error, result) => {
|
|
685
|
-
logop(error, result);
|
|
686
|
-
if (error) {
|
|
687
|
-
return callback(this._translateMessage(error));
|
|
688
|
-
}
|
|
689
|
-
callback(null, result);
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
updateView(name, sourceNs, pipeline, options, callback) {
|
|
693
|
-
options.viewOn = this._collectionName(sourceNs);
|
|
694
|
-
options.pipeline = pipeline;
|
|
695
|
-
const command = {
|
|
696
|
-
collMod: name,
|
|
697
|
-
...options,
|
|
698
|
-
};
|
|
699
|
-
const db = this._initializedClient('META').db(this._databaseName(sourceNs));
|
|
700
|
-
const logop = this._startLogOp(mongoLogId(1001000056), 'Running updateView', {
|
|
701
|
-
name,
|
|
702
|
-
sourceNs,
|
|
703
|
-
stages: pipeline.map((stage) => Object.keys(stage)[0]),
|
|
704
|
-
options,
|
|
705
|
-
});
|
|
706
|
-
(0, util_1.callbackify)(db.command.bind(db))(command, (error, result) => {
|
|
707
|
-
logop(error, result);
|
|
708
|
-
if (error) {
|
|
709
|
-
return callback(this._translateMessage(error));
|
|
710
|
-
}
|
|
711
|
-
callback(null, result);
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
dropView(ns, callback) {
|
|
715
|
-
this.dropCollection(ns, callback);
|
|
716
|
-
}
|
|
717
|
-
sample(ns, { query, size, fields, } = {}, options = {}, executionOptions) {
|
|
718
|
-
const pipeline = [];
|
|
719
|
-
if (query && Object.keys(query).length > 0) {
|
|
720
|
-
pipeline.push({
|
|
721
|
-
$match: query,
|
|
722
|
-
});
|
|
723
|
-
}
|
|
724
|
-
pipeline.push({
|
|
725
|
-
$sample: {
|
|
726
|
-
size: size === 0 ? 0 : size || 1000,
|
|
727
|
-
},
|
|
728
|
-
});
|
|
729
|
-
if (fields && Object.keys(fields).length > 0) {
|
|
730
|
-
pipeline.push({
|
|
731
|
-
$project: fields,
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
return this.aggregate(ns, pipeline, {
|
|
735
|
-
allowDiskUse: true,
|
|
736
|
-
...options,
|
|
737
|
-
}, executionOptions);
|
|
738
|
-
}
|
|
739
|
-
startSession(clientType) {
|
|
740
|
-
const session = this._initializedClient(clientType).startSession();
|
|
741
|
-
session[kSessionClientType] = clientType;
|
|
742
|
-
return session;
|
|
743
|
-
}
|
|
744
|
-
killSessions(sessions) {
|
|
745
|
-
const sessionsArray = Array.isArray(sessions) ? sessions : [sessions];
|
|
746
|
-
const clientTypes = new Set(sessionsArray.map((s) => s[kSessionClientType]));
|
|
747
|
-
if (clientTypes.size !== 1) {
|
|
748
|
-
throw new Error(`Cannot kill sessions without a specific client type: [${[
|
|
749
|
-
...clientTypes,
|
|
750
|
-
].join(', ')}]`);
|
|
751
|
-
}
|
|
752
|
-
const [clientType] = clientTypes;
|
|
753
|
-
return this._initializedClient(clientType)
|
|
754
|
-
.db('admin')
|
|
755
|
-
.command({
|
|
756
|
-
killSessions: sessionsArray.map((s) => s.id),
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
isConnected() {
|
|
760
|
-
return !!this._metadataClient;
|
|
761
|
-
}
|
|
762
|
-
async cancellableOperation(start, stop = () => Promise.resolve(), abortSignal) {
|
|
763
|
-
var _a;
|
|
764
|
-
if (!abortSignal) {
|
|
765
|
-
return await start();
|
|
766
|
-
}
|
|
767
|
-
if (abortSignal.aborted) {
|
|
768
|
-
throw (_a = abortSignal.reason) !== null && _a !== void 0 ? _a : (0, compass_utils_1.createCancelError)();
|
|
769
|
-
}
|
|
770
|
-
const session = this.startSession('CRUD');
|
|
771
|
-
let result;
|
|
772
|
-
const abort = async () => {
|
|
773
|
-
const logAbortError = (error) => {
|
|
340
|
+
async _getPrivilegesOrFallback(privileges = null) {
|
|
341
|
+
if (privileges) {
|
|
342
|
+
return privileges;
|
|
343
|
+
}
|
|
344
|
+
const { authInfo: { authenticatedUserPrivileges }, } = await this._connectionStatus();
|
|
345
|
+
return authenticatedUserPrivileges;
|
|
346
|
+
}
|
|
347
|
+
async _getRolesOrFallback(roles = null) {
|
|
348
|
+
if (roles) {
|
|
349
|
+
return roles;
|
|
350
|
+
}
|
|
351
|
+
const { authInfo: { authenticatedUserRoles }, } = await this._connectionStatus();
|
|
352
|
+
return authenticatedUserRoles;
|
|
353
|
+
}
|
|
354
|
+
async _listCollections(databaseName, filter = {}, { nameOnly } = {}) {
|
|
355
|
+
var _a;
|
|
774
356
|
try {
|
|
775
|
-
|
|
357
|
+
const cursor = this._database(databaseName, 'CRUD').listCollections(filter, { nameOnly });
|
|
358
|
+
const results = [];
|
|
359
|
+
for await (const result of cursor) {
|
|
360
|
+
if (!nameOnly) {
|
|
361
|
+
(_a = this._csfleCollectionTracker) === null || _a === void 0 ? void 0 : _a.updateCollectionInfo(`${databaseName}.${result.name}`, result);
|
|
362
|
+
}
|
|
363
|
+
results.push(result);
|
|
364
|
+
}
|
|
365
|
+
return results;
|
|
776
366
|
}
|
|
777
|
-
catch (
|
|
367
|
+
catch (err) {
|
|
368
|
+
this._logger.warn((0, logger_1.mongoLogId)(1001000099), 'Failed to run listCollections', { message: err.message });
|
|
369
|
+
return [];
|
|
778
370
|
}
|
|
779
|
-
};
|
|
780
|
-
await stop().catch(logAbortError);
|
|
781
|
-
await this.killSessions(session).catch(logAbortError);
|
|
782
|
-
};
|
|
783
|
-
const logop = this._startLogOp(mongoLogId(1001000179), 'Running cancellable operation');
|
|
784
|
-
try {
|
|
785
|
-
result = await (0, compass_utils_1.raceWithAbort)(start(session), abortSignal);
|
|
786
|
-
logop(null);
|
|
787
|
-
}
|
|
788
|
-
catch (err) {
|
|
789
|
-
logop(err);
|
|
790
|
-
if ((0, compass_utils_1.isCancelError)(err)) {
|
|
791
|
-
void abort();
|
|
792
371
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
372
|
+
async listCollections(databaseName, filter = {}, { nameOnly, privileges = null, } = {}) {
|
|
373
|
+
const getCollectionsFromPrivileges = async () => {
|
|
374
|
+
const databases = (0, instance_detail_helper_2.getPrivilegesByDatabaseAndCollection)(await this._getPrivilegesOrFallback(privileges), ['find']);
|
|
375
|
+
return Object.keys(databases[databaseName] || {})
|
|
376
|
+
.filter(Boolean)
|
|
377
|
+
.map((name) => ({ name }));
|
|
378
|
+
};
|
|
379
|
+
const [listedCollections, collectionsFromPrivileges] = await Promise.all([
|
|
380
|
+
this._listCollections(databaseName, filter, { nameOnly }),
|
|
381
|
+
isEmptyObject(filter) ? getCollectionsFromPrivileges() : [],
|
|
382
|
+
]);
|
|
383
|
+
const collections = uniqueBy([...collectionsFromPrivileges, ...listedCollections], 'name').map((coll) => (0, instance_detail_helper_2.adaptCollectionInfo)({ db: databaseName, ...coll }));
|
|
384
|
+
return collections;
|
|
385
|
+
}
|
|
386
|
+
async listDatabases({ nameOnly, privileges = null, roles = null, } = {}) {
|
|
387
|
+
const adminDb = this._database('admin', 'CRUD');
|
|
388
|
+
const listDatabases = async () => {
|
|
389
|
+
try {
|
|
390
|
+
const { databases } = await (0, run_command_1.runCommand)(adminDb, {
|
|
391
|
+
listDatabases: 1,
|
|
392
|
+
nameOnly,
|
|
393
|
+
});
|
|
394
|
+
return databases;
|
|
395
|
+
}
|
|
396
|
+
catch (err) {
|
|
397
|
+
this._logger.warn((0, logger_1.mongoLogId)(1001000098), 'Failed to run listDatabases', { message: err.message });
|
|
398
|
+
return [];
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
const getDatabasesFromPrivileges = async () => {
|
|
402
|
+
const databases = (0, instance_detail_helper_2.getPrivilegesByDatabaseAndCollection)(await this._getPrivilegesOrFallback(privileges), ['find']);
|
|
403
|
+
return Object.keys(databases)
|
|
404
|
+
.filter(Boolean)
|
|
405
|
+
.map((name) => ({ name }));
|
|
406
|
+
};
|
|
407
|
+
const getDatabasesFromRoles = async () => {
|
|
408
|
+
const databases = (0, instance_detail_helper_2.getDatabasesByRoles)(await this._getRolesOrFallback(roles), ['read', 'readWrite', 'dbAdmin', 'dbOwner']);
|
|
409
|
+
return databases.map((name) => ({ name }));
|
|
410
|
+
};
|
|
411
|
+
const [listedDatabases, databasesFromPrivileges, databasesFromRoles] = await Promise.all([
|
|
412
|
+
listDatabases(),
|
|
413
|
+
getDatabasesFromPrivileges(),
|
|
414
|
+
getDatabasesFromRoles(),
|
|
415
|
+
]);
|
|
416
|
+
const databases = uniqueBy([...databasesFromRoles, ...databasesFromPrivileges, ...listedDatabases], 'name').map((db) => {
|
|
417
|
+
return { _id: db.name, name: db.name, ...(0, instance_detail_helper_2.adaptDatabaseInfo)(db) };
|
|
815
418
|
});
|
|
816
|
-
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
419
|
+
return databases;
|
|
420
|
+
}
|
|
421
|
+
async connect(signal) {
|
|
422
|
+
if (this._metadataClient) {
|
|
423
|
+
(0, logger_1.debug)('already connected');
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (this._isConnecting) {
|
|
427
|
+
(0, logger_1.debug)('connect method called more than once');
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
(0, logger_1.debug)('connecting...');
|
|
431
|
+
this._isConnecting = true;
|
|
432
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000014), 'Connecting', {
|
|
433
|
+
url: (0, redact_1.redactConnectionString)(this._connectionOptions.connectionString),
|
|
434
|
+
csfle: this._csfleLogInformation(this._connectionOptions.fleOptions),
|
|
821
435
|
});
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
after = Math.max(after, 200);
|
|
847
|
-
return Math.abs(Math.log2(before / after)) >= 1;
|
|
848
|
-
};
|
|
849
|
-
client.on('serverHeartbeatSucceeded', (evt) => {
|
|
850
|
-
const previousStatus = heartbeatStatusMap.get(evt.connectionId);
|
|
851
|
-
if (!previousStatus ||
|
|
852
|
-
previousStatus.failure ||
|
|
853
|
-
isSignificantDurationChange(previousStatus.duration, evt.duration)) {
|
|
854
|
-
heartbeatStatusMap.set(evt.connectionId, {
|
|
855
|
-
failure: null,
|
|
856
|
-
duration: evt.duration,
|
|
436
|
+
try {
|
|
437
|
+
const [metadataClient, crudClient, tunnel, state, connectionOptions] = await (0, connect_mongo_client_1.connectMongoClientCompass)(this._connectionOptions, this._setupListeners.bind(this), signal, this._unboundLogger);
|
|
438
|
+
const attr = {
|
|
439
|
+
isWritable: this.isWritable(),
|
|
440
|
+
isMongos: this.isMongos(),
|
|
441
|
+
};
|
|
442
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000015), 'Connected', attr);
|
|
443
|
+
(0, logger_1.debug)('connected!', attr);
|
|
444
|
+
this._metadataClient = metadataClient;
|
|
445
|
+
this._crudClient = crudClient;
|
|
446
|
+
this._tunnel = tunnel;
|
|
447
|
+
this._state = state;
|
|
448
|
+
this._mongoClientConnectionOptions = connectionOptions;
|
|
449
|
+
this._csfleCollectionTracker = new csfle_collection_tracker_1.CSFLECollectionTrackerImpl(this, this._crudClient);
|
|
450
|
+
}
|
|
451
|
+
finally {
|
|
452
|
+
this._isConnecting = false;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
estimatedCount(ns, options = {}, executionOptions) {
|
|
456
|
+
return this._cancellableOperation(async (session) => {
|
|
457
|
+
return this._collection(ns, 'CRUD').estimatedDocumentCount({
|
|
458
|
+
...options,
|
|
459
|
+
session,
|
|
857
460
|
});
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
duration: evt.duration,
|
|
866
|
-
},
|
|
461
|
+
}, (session) => session.endSession(), executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.abortSignal);
|
|
462
|
+
}
|
|
463
|
+
count(ns, filter, options = {}, executionOptions) {
|
|
464
|
+
return this._cancellableOperation(async (session) => {
|
|
465
|
+
return this._collection(ns, 'CRUD').countDocuments(filter, {
|
|
466
|
+
...options,
|
|
467
|
+
session,
|
|
867
468
|
});
|
|
469
|
+
}, (session) => session.endSession(), executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.abortSignal);
|
|
470
|
+
}
|
|
471
|
+
async createCollection(ns, options) {
|
|
472
|
+
const collectionName = this._collectionName(ns);
|
|
473
|
+
const db = this._database(ns, 'CRUD');
|
|
474
|
+
return await db.createCollection(collectionName, options);
|
|
475
|
+
}
|
|
476
|
+
async createIndex(ns, spec, options) {
|
|
477
|
+
const coll = this._collection(ns, 'CRUD');
|
|
478
|
+
return await coll.createIndex(spec, options);
|
|
479
|
+
}
|
|
480
|
+
async deleteOne(ns, filter, options) {
|
|
481
|
+
const coll = this._collection(ns, 'CRUD');
|
|
482
|
+
return await coll.deleteOne(filter, options);
|
|
483
|
+
}
|
|
484
|
+
async deleteMany(ns, filter, options) {
|
|
485
|
+
const coll = this._collection(ns, 'CRUD');
|
|
486
|
+
return await coll.deleteMany(filter, options);
|
|
487
|
+
}
|
|
488
|
+
async disconnect() {
|
|
489
|
+
var _a, _b, _c, _d;
|
|
490
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000016), 'Disconnecting');
|
|
491
|
+
try {
|
|
492
|
+
await Promise.all([
|
|
493
|
+
(_a = this._metadataClient) === null || _a === void 0 ? void 0 : _a.close(true).catch((err) => (0, logger_1.debug)('failed to close MongoClient', err)),
|
|
494
|
+
this._crudClient !== this._metadataClient &&
|
|
495
|
+
((_b = this._crudClient) === null || _b === void 0 ? void 0 : _b.close(true).catch((err) => (0, logger_1.debug)('failed to close MongoClient', err))),
|
|
496
|
+
(_c = this._tunnel) === null || _c === void 0 ? void 0 : _c.close().catch((err) => (0, logger_1.debug)('failed to close tunnel', err)),
|
|
497
|
+
(_d = this._state) === null || _d === void 0 ? void 0 : _d.destroy().catch((err) => (0, logger_1.debug)('failed to destroy DevtoolsConnectionState', err)),
|
|
498
|
+
]);
|
|
499
|
+
}
|
|
500
|
+
finally {
|
|
501
|
+
this._cleanup();
|
|
502
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000017), 'Fully closed');
|
|
868
503
|
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
504
|
+
}
|
|
505
|
+
async dropCollection(ns) {
|
|
506
|
+
var _a;
|
|
507
|
+
const db = this._database(ns, 'CRUD');
|
|
508
|
+
const collName = this._collectionName(ns);
|
|
509
|
+
const coll = db.collection(collName);
|
|
510
|
+
let result = null;
|
|
511
|
+
try {
|
|
512
|
+
[result] = await db
|
|
513
|
+
.listCollections({ name: collName }, { nameOnly: false })
|
|
514
|
+
.toArray();
|
|
515
|
+
}
|
|
516
|
+
catch (_b) {
|
|
517
|
+
}
|
|
518
|
+
const options = {};
|
|
519
|
+
const encryptedFieldsInfo = (_a = result === null || result === void 0 ? void 0 : result.options) === null || _a === void 0 ? void 0 : _a.encryptedFields;
|
|
520
|
+
if (encryptedFieldsInfo) {
|
|
521
|
+
options.encryptedFields = encryptedFieldsInfo;
|
|
522
|
+
}
|
|
523
|
+
return await coll.drop(options);
|
|
524
|
+
}
|
|
525
|
+
async dropDatabase(name) {
|
|
526
|
+
const db = this._database(name, 'CRUD');
|
|
527
|
+
return await db.dropDatabase();
|
|
528
|
+
}
|
|
529
|
+
async dropIndex(ns, name) {
|
|
530
|
+
const coll = this._collection(ns, 'CRUD');
|
|
531
|
+
return await coll.dropIndex(name);
|
|
532
|
+
}
|
|
533
|
+
aggregateCursor(ns, pipeline, options = {}) {
|
|
534
|
+
return this._collection(ns, 'CRUD').aggregate(pipeline, options);
|
|
535
|
+
}
|
|
536
|
+
aggregate(ns, pipeline, options = {}, executionOptions) {
|
|
537
|
+
let cursor;
|
|
538
|
+
return this._cancellableOperation(async (session) => {
|
|
539
|
+
cursor = this._collection(ns, 'CRUD').aggregate(pipeline, {
|
|
540
|
+
...options,
|
|
541
|
+
session,
|
|
542
|
+
});
|
|
543
|
+
const results = await cursor.toArray();
|
|
544
|
+
void cursor.close();
|
|
545
|
+
return results;
|
|
546
|
+
}, () => cursor === null || cursor === void 0 ? void 0 : cursor.close(), executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.abortSignal);
|
|
547
|
+
}
|
|
548
|
+
find(ns, filter, options = {}, executionOptions) {
|
|
549
|
+
let cursor;
|
|
550
|
+
return this._cancellableOperation(async (session) => {
|
|
551
|
+
cursor = this._collection(ns, 'CRUD').find(filter, {
|
|
552
|
+
...options,
|
|
553
|
+
session,
|
|
554
|
+
});
|
|
555
|
+
const results = await cursor.toArray();
|
|
556
|
+
void cursor.close();
|
|
557
|
+
return results;
|
|
558
|
+
}, () => cursor === null || cursor === void 0 ? void 0 : cursor.close(), executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.abortSignal);
|
|
559
|
+
}
|
|
560
|
+
findCursor(ns, filter, options = {}) {
|
|
561
|
+
return this._collection(ns, 'CRUD').find(filter, options);
|
|
562
|
+
}
|
|
563
|
+
async findOneAndReplace(ns, filter, replacement, options) {
|
|
564
|
+
const coll = this._collection(ns, 'CRUD');
|
|
565
|
+
return (await coll.findOneAndReplace(filter, replacement, options)).value;
|
|
566
|
+
}
|
|
567
|
+
async findOneAndUpdate(ns, filter, update, options) {
|
|
568
|
+
const coll = this._collection(ns, 'CRUD');
|
|
569
|
+
return (await coll.findOneAndUpdate(filter, update, options)).value;
|
|
570
|
+
}
|
|
571
|
+
async updateOne(ns, filter, update, options) {
|
|
572
|
+
const coll = this._collection(ns, 'CRUD');
|
|
573
|
+
return await coll.updateOne(filter, update, options);
|
|
574
|
+
}
|
|
575
|
+
async replaceOne(ns, filter, replacement, options) {
|
|
576
|
+
const coll = this._collection(ns, 'CRUD');
|
|
577
|
+
return await coll.replaceOne(filter, replacement, options);
|
|
578
|
+
}
|
|
579
|
+
explainFind(ns, filter, options = {}, executionOptions) {
|
|
580
|
+
const verbosity = (executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.explainVerbosity) ||
|
|
581
|
+
mongodb.ExplainVerbosity.allPlansExecution;
|
|
582
|
+
let cursor;
|
|
583
|
+
return this._cancellableOperation(async (session) => {
|
|
584
|
+
cursor = this._collection(ns, 'CRUD').find(filter, {
|
|
585
|
+
...options,
|
|
586
|
+
session,
|
|
879
587
|
});
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
588
|
+
const results = await cursor.explain(verbosity);
|
|
589
|
+
void cursor.close();
|
|
590
|
+
return results;
|
|
591
|
+
}, () => cursor === null || cursor === void 0 ? void 0 : cursor.close(), executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.abortSignal);
|
|
592
|
+
}
|
|
593
|
+
explainAggregate(ns, pipeline, options, executionOptions) {
|
|
594
|
+
const verbosity = (executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.explainVerbosity) ||
|
|
595
|
+
mongodb.ExplainVerbosity.queryPlanner;
|
|
596
|
+
let cursor;
|
|
597
|
+
return this._cancellableOperation(async (session) => {
|
|
598
|
+
cursor = this._collection(ns, 'CRUD').aggregate(pipeline, {
|
|
599
|
+
...options,
|
|
600
|
+
session,
|
|
884
601
|
});
|
|
602
|
+
const results = await cursor.explain(verbosity);
|
|
603
|
+
void cursor.close();
|
|
604
|
+
return results;
|
|
605
|
+
}, () => cursor === null || cursor === void 0 ? void 0 : cursor.close(), executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.abortSignal);
|
|
606
|
+
}
|
|
607
|
+
async _indexStats(ns) {
|
|
608
|
+
try {
|
|
609
|
+
const stats = await this.aggregate(ns, [
|
|
610
|
+
{ $indexStats: {} },
|
|
611
|
+
{
|
|
612
|
+
$project: {
|
|
613
|
+
name: 1,
|
|
614
|
+
usageHost: '$host',
|
|
615
|
+
usageCount: '$accesses.ops',
|
|
616
|
+
usageSince: '$accesses.since',
|
|
617
|
+
},
|
|
618
|
+
},
|
|
619
|
+
]);
|
|
620
|
+
return Object.fromEntries(stats.map((index) => {
|
|
621
|
+
return [index.name, index];
|
|
622
|
+
}));
|
|
885
623
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
}
|
|
624
|
+
catch (err) {
|
|
625
|
+
if ((0, instance_detail_helper_1.isNotAuthorized)(err) || (0, instance_detail_helper_1.isNotSupportedPipelineStage)(err)) {
|
|
626
|
+
return {};
|
|
627
|
+
}
|
|
628
|
+
throw err;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
async _indexSizes(ns) {
|
|
632
|
+
try {
|
|
633
|
+
return (await this._collection(ns, 'META').stats()).indexSizes;
|
|
634
|
+
}
|
|
635
|
+
catch (err) {
|
|
636
|
+
if ((0, instance_detail_helper_1.isNotAuthorized)(err) || (0, instance_detail_helper_1.isNotSupportedPipelineStage)(err)) {
|
|
637
|
+
return {};
|
|
638
|
+
}
|
|
639
|
+
throw err;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
async indexes(ns, options) {
|
|
643
|
+
const [indexes, indexStats, indexSizes] = await Promise.all([
|
|
644
|
+
this._collection(ns, 'CRUD').indexes(options),
|
|
645
|
+
this._indexStats(ns),
|
|
646
|
+
this._indexSizes(ns),
|
|
647
|
+
]);
|
|
648
|
+
const maxSize = Math.max(...Object.values(indexSizes));
|
|
649
|
+
return indexes.map((index) => {
|
|
650
|
+
const name = index.name;
|
|
651
|
+
return (0, index_detail_helper_1.createIndexDefinition)(ns, index, indexStats[name], indexSizes[name], maxSize);
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
async instance() {
|
|
655
|
+
return {
|
|
656
|
+
...(await (0, instance_detail_helper_2.getInstance)(this._initializedClient('META'))),
|
|
657
|
+
csfleMode: this.getCSFLEMode(),
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
async insertOne(ns, doc, options) {
|
|
661
|
+
const coll = this._collection(ns, 'CRUD');
|
|
662
|
+
return await coll.insertOne(doc, options);
|
|
663
|
+
}
|
|
664
|
+
async insertMany(ns, docs, options) {
|
|
665
|
+
const coll = this._collection(ns, 'CRUD');
|
|
666
|
+
return await coll.insertMany(docs, options);
|
|
667
|
+
}
|
|
668
|
+
async updateCollection(ns, flags = {}) {
|
|
669
|
+
const collectionName = this._collectionName(ns);
|
|
670
|
+
const db = this._database(ns, 'CRUD');
|
|
671
|
+
const result = await (0, run_command_1.runCommand)(db, {
|
|
672
|
+
collMod: collectionName,
|
|
673
|
+
...flags,
|
|
901
674
|
});
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
675
|
+
await this._resetCRUDClient();
|
|
676
|
+
return result;
|
|
677
|
+
}
|
|
678
|
+
bulkWrite(ns, operations, options) {
|
|
679
|
+
return this._collection(ns, 'CRUD').bulkWrite(operations, options);
|
|
680
|
+
}
|
|
681
|
+
async currentOp() {
|
|
682
|
+
const db = this._database('admin', 'META');
|
|
683
|
+
const pipelineWithTruncateOps = [
|
|
684
|
+
{
|
|
685
|
+
$currentOp: {
|
|
686
|
+
allUsers: true,
|
|
687
|
+
idleConnections: false,
|
|
688
|
+
truncateOps: false,
|
|
689
|
+
},
|
|
690
|
+
},
|
|
691
|
+
];
|
|
692
|
+
const currentOp = await db.aggregate(pipelineWithTruncateOps).toArray();
|
|
693
|
+
return { inprog: currentOp };
|
|
694
|
+
}
|
|
695
|
+
getLastSeenTopology() {
|
|
696
|
+
return this._lastSeenTopology;
|
|
697
|
+
}
|
|
698
|
+
async serverStatus() {
|
|
699
|
+
const admin = this._database('admin', 'META');
|
|
700
|
+
return await (0, run_command_1.runCommand)(admin, { serverStatus: 1 });
|
|
701
|
+
}
|
|
702
|
+
async top() {
|
|
703
|
+
const adminDb = this._database('admin', 'META');
|
|
704
|
+
return await (0, run_command_1.runCommand)(adminDb, { top: 1 });
|
|
705
|
+
}
|
|
706
|
+
async createView(name, sourceNs, pipeline, options = {}) {
|
|
707
|
+
const createCollectionOptions = {
|
|
708
|
+
...options,
|
|
709
|
+
viewOn: this._collectionName(sourceNs),
|
|
710
|
+
pipeline,
|
|
711
|
+
};
|
|
712
|
+
const db = this._database(sourceNs, 'CRUD');
|
|
713
|
+
return await db.createCollection(name, createCollectionOptions);
|
|
714
|
+
}
|
|
715
|
+
sample(ns, { query, size, fields, } = {}, options = {}, executionOptions) {
|
|
716
|
+
const pipeline = [];
|
|
717
|
+
if (query && Object.keys(query).length > 0) {
|
|
718
|
+
pipeline.push({
|
|
719
|
+
$match: query,
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
pipeline.push({
|
|
723
|
+
$sample: {
|
|
724
|
+
size: size === 0 ? 0 : size || 1000,
|
|
916
725
|
},
|
|
917
726
|
});
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
const normalized = (0, instance_detail_helper_1.adaptDatabaseInfo)(stats);
|
|
945
|
-
return { name, ...normalized };
|
|
946
|
-
}
|
|
947
|
-
catch (err) {
|
|
948
|
-
logop(err);
|
|
949
|
-
throw this._translateMessage(err);
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
_buildCollectionDetail(ns, data) {
|
|
953
|
-
return {
|
|
954
|
-
...data.stats,
|
|
955
|
-
_id: ns,
|
|
956
|
-
name: this._collectionName(ns),
|
|
957
|
-
database: this._databaseName(ns),
|
|
958
|
-
indexes: data.indexes,
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
_buildCollectionStats(databaseName, collectionName, data) {
|
|
962
|
-
var _a, _b, _c, _d, _e, _f;
|
|
963
|
-
return {
|
|
964
|
-
ns: databaseName + '.' + collectionName,
|
|
965
|
-
name: collectionName,
|
|
966
|
-
database: databaseName,
|
|
967
|
-
is_capped: data.capped,
|
|
968
|
-
max: data.max,
|
|
969
|
-
is_power_of_two: data.userFlags === 1,
|
|
970
|
-
index_sizes: data.indexSizes,
|
|
971
|
-
document_count: (_a = data.count) !== null && _a !== void 0 ? _a : 0,
|
|
972
|
-
document_size: data.size,
|
|
973
|
-
avg_document_size: (_b = data.avgObjSize) !== null && _b !== void 0 ? _b : 0,
|
|
974
|
-
storage_size: (_c = data.storageSize) !== null && _c !== void 0 ? _c : 0,
|
|
975
|
-
free_storage_size: (_d = data.freeStorageSize) !== null && _d !== void 0 ? _d : 0,
|
|
976
|
-
index_count: (_e = data.nindexes) !== null && _e !== void 0 ? _e : 0,
|
|
977
|
-
index_size: (_f = data.totalIndexSize) !== null && _f !== void 0 ? _f : 0,
|
|
978
|
-
padding_factor: data.paddingFactor,
|
|
979
|
-
extent_count: data.numExtents,
|
|
980
|
-
extent_last_size: data.lastExtentSize,
|
|
981
|
-
flags_user: data.userFlags,
|
|
982
|
-
max_document_size: data.maxSize,
|
|
983
|
-
size: data.size,
|
|
984
|
-
index_details: data.indexDetails || {},
|
|
985
|
-
wired_tiger: data.wiredTiger || {},
|
|
986
|
-
};
|
|
987
|
-
}
|
|
988
|
-
_buildDatabaseDetail(name, db) {
|
|
989
|
-
return {
|
|
990
|
-
_id: name,
|
|
991
|
-
name: name,
|
|
992
|
-
stats: db.stats,
|
|
993
|
-
collections: db.collections,
|
|
994
|
-
};
|
|
995
|
-
}
|
|
996
|
-
_collection(ns, type) {
|
|
997
|
-
return this._initializedClient(type)
|
|
998
|
-
.db(this._databaseName(ns))
|
|
999
|
-
.collection(this._collectionName(ns));
|
|
1000
|
-
}
|
|
1001
|
-
_collectionNames(databaseName, callback) {
|
|
1002
|
-
this.listCollections(databaseName, {}, { nameOnly: true }).then((collections) => {
|
|
1003
|
-
const names = collections === null || collections === void 0 ? void 0 : collections.map((c) => c.name);
|
|
1004
|
-
callback(null, names);
|
|
1005
|
-
}, (error) => {
|
|
1006
|
-
callback(this._translateMessage(error));
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
_collectionName(ns) {
|
|
1010
|
-
return (0, mongodb_ns_1.default)(ns).collection;
|
|
1011
|
-
}
|
|
1012
|
-
_databaseName(ns) {
|
|
1013
|
-
return (0, mongodb_ns_1.default)(ns).database;
|
|
1014
|
-
}
|
|
1015
|
-
_checkIsWritable(evt) {
|
|
1016
|
-
return [...evt.newDescription.servers.values()].some((server) => server.isWritable);
|
|
1017
|
-
}
|
|
1018
|
-
_translateMessage(error) {
|
|
1019
|
-
if (typeof error === 'string') {
|
|
1020
|
-
error = { message: error };
|
|
1021
|
-
}
|
|
1022
|
-
else if (!error.message) {
|
|
1023
|
-
error.message = error.err || error.errmsg;
|
|
1024
|
-
}
|
|
1025
|
-
return error;
|
|
1026
|
-
}
|
|
1027
|
-
_cleanup() {
|
|
1028
|
-
var _a, _b, _c, _d;
|
|
1029
|
-
(_b = (_a = this._metadataClient) === null || _a === void 0 ? void 0 : _a.removeAllListeners) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1030
|
-
(_d = (_c = this._crudClient) === null || _c === void 0 ? void 0 : _c.removeAllListeners) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
1031
|
-
this._metadataClient = undefined;
|
|
1032
|
-
this._crudClient = undefined;
|
|
1033
|
-
this._tunnel = undefined;
|
|
1034
|
-
this._mongoClientConnectionOptions = undefined;
|
|
1035
|
-
this._isWritable = false;
|
|
1036
|
-
this._topologyType = 'Unknown';
|
|
1037
|
-
this._isConnecting = false;
|
|
1038
|
-
}
|
|
1039
|
-
async _resetCRUDClient() {
|
|
1040
|
-
if (this.getCSFLEMode() === 'unavailable') {
|
|
1041
|
-
return;
|
|
1042
|
-
}
|
|
1043
|
-
const crudClient = this._crudClient;
|
|
1044
|
-
if (!crudClient) {
|
|
1045
|
-
return;
|
|
1046
|
-
}
|
|
1047
|
-
const newClient = await crudClient[connect_mongo_client_1.createClonedClient]();
|
|
1048
|
-
if (this._crudClient === crudClient) {
|
|
1049
|
-
this._crudClient = newClient;
|
|
1050
|
-
await crudClient.close();
|
|
1051
|
-
}
|
|
1052
|
-
else {
|
|
1053
|
-
await newClient.close();
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
_startLogOp(logId, op, attr = {}) {
|
|
1057
|
-
return (error, result) => {
|
|
1058
|
-
if (error) {
|
|
1059
|
-
const { message } = this._translateMessage(error);
|
|
1060
|
-
log.error(mongoLogId(1001000058), this._logCtx(), 'Failed to perform data service operation', {
|
|
1061
|
-
op,
|
|
1062
|
-
message,
|
|
1063
|
-
...attr,
|
|
727
|
+
if (fields && Object.keys(fields).length > 0) {
|
|
728
|
+
pipeline.push({
|
|
729
|
+
$project: fields,
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
return this.aggregate(ns, pipeline, {
|
|
733
|
+
allowDiskUse: true,
|
|
734
|
+
...options,
|
|
735
|
+
}, executionOptions);
|
|
736
|
+
}
|
|
737
|
+
_startSession(clientType) {
|
|
738
|
+
const session = this._initializedClient(clientType).startSession();
|
|
739
|
+
session[kSessionClientType] = clientType;
|
|
740
|
+
return session;
|
|
741
|
+
}
|
|
742
|
+
_killSessions(sessions) {
|
|
743
|
+
const sessionsArray = Array.isArray(sessions) ? sessions : [sessions];
|
|
744
|
+
const clientTypes = new Set(sessionsArray.map((s) => s[kSessionClientType]));
|
|
745
|
+
if (clientTypes.size !== 1) {
|
|
746
|
+
throw new Error(`Cannot kill sessions without a specific client type: [${[
|
|
747
|
+
...clientTypes,
|
|
748
|
+
].join(', ')}]`);
|
|
749
|
+
}
|
|
750
|
+
const [clientType] = clientTypes;
|
|
751
|
+
return (0, run_command_1.runCommand)(this._database('admin', clientType), {
|
|
752
|
+
killSessions: sessionsArray.map((s) => s.id),
|
|
1064
753
|
});
|
|
1065
754
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
755
|
+
isConnected() {
|
|
756
|
+
return !!this._metadataClient;
|
|
757
|
+
}
|
|
758
|
+
async _cancellableOperation(start, stop = () => Promise.resolve(), abortSignal) {
|
|
759
|
+
var _a;
|
|
760
|
+
if (!abortSignal) {
|
|
761
|
+
return await start();
|
|
762
|
+
}
|
|
763
|
+
if (abortSignal.aborted) {
|
|
764
|
+
throw (_a = abortSignal.reason) !== null && _a !== void 0 ? _a : (0, compass_utils_1.createCancelError)();
|
|
765
|
+
}
|
|
766
|
+
const session = this._startSession('CRUD');
|
|
767
|
+
let result;
|
|
768
|
+
const abort = async () => {
|
|
769
|
+
const logAbortError = (error) => {
|
|
770
|
+
this._logger.warn((0, logger_1.mongoLogId)(1001000140), 'Attempting to kill the operation failed', { error: error.message });
|
|
771
|
+
};
|
|
772
|
+
await stop(session).catch(logAbortError);
|
|
773
|
+
await this._killSessions(session).catch(logAbortError);
|
|
774
|
+
};
|
|
775
|
+
try {
|
|
776
|
+
result = await (0, compass_utils_1.raceWithAbort)(start(session), abortSignal);
|
|
777
|
+
}
|
|
778
|
+
catch (err) {
|
|
779
|
+
if ((0, compass_utils_1.isCancelError)(err)) {
|
|
780
|
+
void abort();
|
|
781
|
+
}
|
|
782
|
+
throw err;
|
|
783
|
+
}
|
|
784
|
+
return result;
|
|
785
|
+
}
|
|
786
|
+
isCancelError(error) {
|
|
787
|
+
return (0, compass_utils_1.isCancelError)(error);
|
|
788
|
+
}
|
|
789
|
+
_setupListeners(client) {
|
|
790
|
+
if (client) {
|
|
791
|
+
client.on('serverDescriptionChanged', (evt) => {
|
|
792
|
+
var _a, _b;
|
|
793
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000018), 'Server description changed', {
|
|
794
|
+
address: evt.address,
|
|
795
|
+
error: (_b = (_a = evt.newDescription.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : null,
|
|
796
|
+
previousType: evt.previousDescription.type,
|
|
797
|
+
newType: evt.newDescription.type,
|
|
798
|
+
});
|
|
799
|
+
});
|
|
800
|
+
client.on('serverOpening', (evt) => {
|
|
801
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000019), 'Server opening', {
|
|
802
|
+
address: evt.address,
|
|
803
|
+
});
|
|
804
|
+
});
|
|
805
|
+
client.on('serverClosed', (evt) => {
|
|
806
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000020), 'Server closed', {
|
|
807
|
+
address: evt.address,
|
|
808
|
+
});
|
|
809
|
+
});
|
|
810
|
+
client.on('topologyDescriptionChanged', (evt) => {
|
|
811
|
+
this._isWritable = this._checkIsWritable(evt);
|
|
812
|
+
const attr = {
|
|
813
|
+
isWritable: this.isWritable(),
|
|
814
|
+
isMongos: this.isMongos(),
|
|
815
|
+
previousType: evt.previousDescription.type,
|
|
816
|
+
newType: evt.newDescription.type,
|
|
817
|
+
};
|
|
818
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000021), 'Topology description changed', attr);
|
|
819
|
+
this._lastSeenTopology = evt.newDescription;
|
|
820
|
+
this._emitter.emit('topologyDescriptionChanged', evt);
|
|
821
|
+
});
|
|
822
|
+
const heartbeatStatusMap = new Map();
|
|
823
|
+
const isSignificantDurationChange = (before, after) => {
|
|
824
|
+
before = Math.max(before, 200);
|
|
825
|
+
after = Math.max(after, 200);
|
|
826
|
+
return Math.abs(Math.log2(before / after)) >= 1;
|
|
827
|
+
};
|
|
828
|
+
client.on('serverHeartbeatSucceeded', (evt) => {
|
|
829
|
+
const previousStatus = heartbeatStatusMap.get(evt.connectionId);
|
|
830
|
+
if (!previousStatus ||
|
|
831
|
+
previousStatus.failure ||
|
|
832
|
+
isSignificantDurationChange(previousStatus.duration, evt.duration)) {
|
|
833
|
+
heartbeatStatusMap.set(evt.connectionId, {
|
|
834
|
+
failure: null,
|
|
835
|
+
duration: evt.duration,
|
|
836
|
+
});
|
|
837
|
+
this._logger.debug((0, logger_1.mongoLogId)(1001000022), 'Server heartbeat succeeded', {
|
|
838
|
+
connectionId: evt.connectionId,
|
|
839
|
+
duration: evt.duration,
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
client.on('serverHeartbeatFailed', (evt) => {
|
|
844
|
+
const previousStatus = heartbeatStatusMap.get(evt.connectionId);
|
|
845
|
+
if (!previousStatus ||
|
|
846
|
+
!previousStatus.failure ||
|
|
847
|
+
isSignificantDurationChange(previousStatus.duration, evt.duration)) {
|
|
848
|
+
heartbeatStatusMap.set(evt.connectionId, {
|
|
849
|
+
failure: evt.failure.message,
|
|
850
|
+
duration: evt.duration,
|
|
851
|
+
});
|
|
852
|
+
this._logger.warn((0, logger_1.mongoLogId)(1001000023), 'Server heartbeat failed', {
|
|
853
|
+
connectionId: evt.connectionId,
|
|
854
|
+
duration: evt.duration,
|
|
855
|
+
failure: evt.failure.message,
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
client.on('commandSucceeded', (evt) => {
|
|
860
|
+
const { address, connectionId, duration, commandName } = evt;
|
|
861
|
+
this._logger.debug((0, logger_1.mongoLogId)(1001000029), 'Driver command succeeded', {
|
|
862
|
+
address,
|
|
863
|
+
serverConnectionId: connectionId,
|
|
864
|
+
duration,
|
|
865
|
+
commandName,
|
|
866
|
+
});
|
|
867
|
+
});
|
|
868
|
+
client.on('commandFailed', (evt) => {
|
|
869
|
+
const { address, connectionId, duration, commandName, failure } = evt;
|
|
870
|
+
this._logger.debug((0, logger_1.mongoLogId)(1001000030), 'Driver command failed', {
|
|
871
|
+
address,
|
|
872
|
+
serverConnectionId: connectionId,
|
|
873
|
+
duration,
|
|
874
|
+
commandName,
|
|
875
|
+
failure: failure.message,
|
|
876
|
+
});
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
_initializedClient(type) {
|
|
881
|
+
if (type !== 'CRUD' && type !== 'META') {
|
|
882
|
+
throw new Error(`Invalid client type: ${type}`);
|
|
883
|
+
}
|
|
884
|
+
const client = type === 'CRUD' && this._useCRUDClient
|
|
885
|
+
? this._crudClient
|
|
886
|
+
: this._metadataClient;
|
|
887
|
+
if (!client) {
|
|
888
|
+
throw new Error('Client not yet initialized');
|
|
889
|
+
}
|
|
890
|
+
return client;
|
|
891
|
+
}
|
|
892
|
+
_getCSFLECollectionTracker() {
|
|
893
|
+
if (!this._csfleCollectionTracker) {
|
|
894
|
+
throw new Error('Client not yet initialized');
|
|
895
|
+
}
|
|
896
|
+
return this._csfleCollectionTracker;
|
|
897
|
+
}
|
|
898
|
+
isUpdateAllowed(ns, originalDocument) {
|
|
899
|
+
return this._getCSFLECollectionTracker().isUpdateAllowed(ns, originalDocument);
|
|
900
|
+
}
|
|
901
|
+
knownSchemaForCollection(ns) {
|
|
902
|
+
return this._getCSFLECollectionTracker().knownSchemaForCollection(ns);
|
|
903
|
+
}
|
|
904
|
+
async databaseStats(name) {
|
|
905
|
+
const db = this._database(name, 'META');
|
|
906
|
+
const stats = await (0, run_command_1.runCommand)(db, { dbStats: 1 });
|
|
907
|
+
const normalized = (0, instance_detail_helper_2.adaptDatabaseInfo)(stats);
|
|
908
|
+
return { name, ...normalized };
|
|
909
|
+
}
|
|
910
|
+
_buildCollectionStats(databaseName, collectionName, data) {
|
|
911
|
+
var _a, _b, _c, _d, _e, _f;
|
|
912
|
+
return {
|
|
913
|
+
ns: databaseName + '.' + collectionName,
|
|
914
|
+
name: collectionName,
|
|
915
|
+
database: databaseName,
|
|
916
|
+
is_capped: data.capped,
|
|
917
|
+
document_count: (_a = data.count) !== null && _a !== void 0 ? _a : 0,
|
|
918
|
+
document_size: data.size,
|
|
919
|
+
avg_document_size: (_b = data.avgObjSize) !== null && _b !== void 0 ? _b : 0,
|
|
920
|
+
storage_size: (_c = data.storageSize) !== null && _c !== void 0 ? _c : 0,
|
|
921
|
+
free_storage_size: (_d = data.freeStorageSize) !== null && _d !== void 0 ? _d : 0,
|
|
922
|
+
index_count: (_e = data.nindexes) !== null && _e !== void 0 ? _e : 0,
|
|
923
|
+
index_size: (_f = data.totalIndexSize) !== null && _f !== void 0 ? _f : 0,
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
_collection(ns, type) {
|
|
927
|
+
return this._initializedClient(type)
|
|
928
|
+
.db(this._databaseName(ns))
|
|
929
|
+
.collection(this._collectionName(ns));
|
|
930
|
+
}
|
|
931
|
+
_database(ns, type) {
|
|
932
|
+
return this._initializedClient(type).db(this._databaseName(ns));
|
|
933
|
+
}
|
|
934
|
+
_collectionName(ns) {
|
|
935
|
+
return (0, mongodb_ns_1.default)(ns).collection;
|
|
936
|
+
}
|
|
937
|
+
_databaseName(ns) {
|
|
938
|
+
return (0, mongodb_ns_1.default)(ns).database;
|
|
939
|
+
}
|
|
940
|
+
_checkIsWritable(evt) {
|
|
941
|
+
return [...evt.newDescription.servers.values()].some((server) => server.isWritable);
|
|
942
|
+
}
|
|
943
|
+
_cleanup() {
|
|
944
|
+
var _a, _b, _c, _d;
|
|
945
|
+
this._emitter.removeAllListeners();
|
|
946
|
+
(_b = (_a = this._metadataClient) === null || _a === void 0 ? void 0 : _a.removeAllListeners) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
947
|
+
(_d = (_c = this._crudClient) === null || _c === void 0 ? void 0 : _c.removeAllListeners) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
948
|
+
this._metadataClient = undefined;
|
|
949
|
+
this._crudClient = undefined;
|
|
950
|
+
this._tunnel = undefined;
|
|
951
|
+
this._state = undefined;
|
|
952
|
+
this._mongoClientConnectionOptions = undefined;
|
|
953
|
+
this._isWritable = false;
|
|
954
|
+
this._isConnecting = false;
|
|
955
|
+
}
|
|
956
|
+
async _resetCRUDClient() {
|
|
957
|
+
if (this.getCSFLEMode() === 'unavailable') {
|
|
958
|
+
return;
|
|
1069
959
|
}
|
|
1070
|
-
|
|
1071
|
-
|
|
960
|
+
const crudClient = this._crudClient;
|
|
961
|
+
if (!crudClient) {
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
const newClient = await crudClient[connect_mongo_client_1.createClonedClient]();
|
|
965
|
+
if (this._crudClient === crudClient) {
|
|
966
|
+
this._crudClient = newClient;
|
|
967
|
+
await crudClient.close();
|
|
1072
968
|
}
|
|
1073
969
|
else {
|
|
1074
|
-
|
|
970
|
+
await newClient.close();
|
|
1075
971
|
}
|
|
1076
972
|
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
result = await clientEncryption.createDataKey(provider, options !== null && options !== void 0 ? options : {});
|
|
1104
|
-
}
|
|
1105
|
-
catch (err) {
|
|
1106
|
-
logop(err);
|
|
1107
|
-
throw err;
|
|
1108
|
-
}
|
|
1109
|
-
logop(null);
|
|
1110
|
-
return result;
|
|
1111
|
-
}
|
|
1112
|
-
_getClientEncryption() {
|
|
1113
|
-
if (!ClientEncryption) {
|
|
1114
|
-
throw new Error('Cannot get client encryption, because the optional mongodb-client-encryption dependency is not installed');
|
|
1115
|
-
}
|
|
1116
|
-
const crudClient = this._initializedClient('CRUD');
|
|
1117
|
-
const autoEncryptionOptions = crudClient.options.autoEncryption;
|
|
1118
|
-
const { proxyHost, proxyPort, proxyUsername, proxyPassword } = crudClient.options;
|
|
1119
|
-
return new ClientEncryption(crudClient, {
|
|
1120
|
-
keyVaultNamespace: autoEncryptionOptions.keyVaultNamespace,
|
|
1121
|
-
kmsProviders: autoEncryptionOptions.kmsProviders,
|
|
1122
|
-
tlsOptions: autoEncryptionOptions.tlsOptions,
|
|
1123
|
-
proxyOptions: proxyHost
|
|
1124
|
-
? {
|
|
1125
|
-
proxyHost,
|
|
1126
|
-
proxyPort,
|
|
1127
|
-
proxyUsername,
|
|
1128
|
-
proxyPassword,
|
|
973
|
+
configuredKMSProviders() {
|
|
974
|
+
var _a;
|
|
975
|
+
return (0, instance_detail_helper_2.configuredKMSProviders)((_a = this._connectionOptions.fleOptions) === null || _a === void 0 ? void 0 : _a.autoEncryption);
|
|
976
|
+
}
|
|
977
|
+
_csfleLogInformation(fleOptions) {
|
|
978
|
+
var _a, _b, _c;
|
|
979
|
+
const kmsProviders = (0, instance_detail_helper_2.configuredKMSProviders)(fleOptions === null || fleOptions === void 0 ? void 0 : fleOptions.autoEncryption);
|
|
980
|
+
if (kmsProviders.length === 0)
|
|
981
|
+
return null;
|
|
982
|
+
return {
|
|
983
|
+
storeCredentials: fleOptions === null || fleOptions === void 0 ? void 0 : fleOptions.storeCredentials,
|
|
984
|
+
encryptedFieldsMapNamespaces: Object.keys({
|
|
985
|
+
...(_a = fleOptions === null || fleOptions === void 0 ? void 0 : fleOptions.autoEncryption) === null || _a === void 0 ? void 0 : _a.encryptedFieldsMap,
|
|
986
|
+
...(_b = fleOptions === null || fleOptions === void 0 ? void 0 : fleOptions.autoEncryption) === null || _b === void 0 ? void 0 : _b.schemaMap,
|
|
987
|
+
}),
|
|
988
|
+
keyVaultNamespace: (_c = fleOptions === null || fleOptions === void 0 ? void 0 : fleOptions.autoEncryption) === null || _c === void 0 ? void 0 : _c.keyVaultNamespace,
|
|
989
|
+
kmsProviders,
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
async createDataKey(provider, options) {
|
|
993
|
+
const clientEncryption = this._getClientEncryption();
|
|
994
|
+
return await clientEncryption.createDataKey(provider, options !== null && options !== void 0 ? options : {});
|
|
995
|
+
}
|
|
996
|
+
_getClientEncryption() {
|
|
997
|
+
if (!ClientEncryption) {
|
|
998
|
+
throw new Error('Cannot get client encryption, because the optional mongodb-client-encryption dependency is not installed');
|
|
1129
999
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1000
|
+
const crudClient = this._initializedClient('CRUD');
|
|
1001
|
+
const autoEncryptionOptions = crudClient.options.autoEncryption;
|
|
1002
|
+
const { proxyHost, proxyPort, proxyUsername, proxyPassword } = crudClient.options;
|
|
1003
|
+
return new ClientEncryption(crudClient, {
|
|
1004
|
+
keyVaultNamespace: autoEncryptionOptions.keyVaultNamespace,
|
|
1005
|
+
kmsProviders: autoEncryptionOptions.kmsProviders,
|
|
1006
|
+
tlsOptions: autoEncryptionOptions.tlsOptions,
|
|
1007
|
+
proxyOptions: proxyHost
|
|
1008
|
+
? {
|
|
1009
|
+
proxyHost,
|
|
1010
|
+
proxyPort,
|
|
1011
|
+
proxyUsername,
|
|
1012
|
+
proxyPassword,
|
|
1013
|
+
}
|
|
1014
|
+
: undefined,
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
},
|
|
1018
|
+
(() => {
|
|
1019
|
+
_collectionStats_decorators = [op((0, logger_1.mongoLogId)(1001000178), ([dbName, collName], result) => {
|
|
1020
|
+
return { ns: `${dbName}.${collName}`, ...(result && { result }) };
|
|
1021
|
+
})];
|
|
1022
|
+
_collectionInfo_decorators = [op((0, logger_1.mongoLogId)(1001000179))];
|
|
1023
|
+
_killOp_decorators = [op((0, logger_1.mongoLogId)(1001000031))];
|
|
1024
|
+
__connectionStatus_decorators = [op((0, logger_1.mongoLogId)(1001000100))];
|
|
1025
|
+
_listCollections_decorators = [op((0, logger_1.mongoLogId)(1001000032), ([databaseName, , options], colls) => {
|
|
1026
|
+
var _a;
|
|
1027
|
+
return {
|
|
1028
|
+
db: databaseName,
|
|
1029
|
+
nameOnly: (_a = options === null || options === void 0 ? void 0 : options.nameOnly) !== null && _a !== void 0 ? _a : false,
|
|
1030
|
+
...(colls && { collectionsCount: colls.length }),
|
|
1031
|
+
};
|
|
1032
|
+
})];
|
|
1033
|
+
_listDatabases_decorators = [op((0, logger_1.mongoLogId)(1001000033), ([options], dbs) => {
|
|
1034
|
+
var _a;
|
|
1035
|
+
return {
|
|
1036
|
+
nameOnly: (_a = options === null || options === void 0 ? void 0 : options.nameOnly) !== null && _a !== void 0 ? _a : false,
|
|
1037
|
+
...(dbs && { databasesCount: dbs.length }),
|
|
1038
|
+
};
|
|
1039
|
+
})];
|
|
1040
|
+
_estimatedCount_decorators = [op((0, logger_1.mongoLogId)(1001000034))];
|
|
1041
|
+
_count_decorators = [op((0, logger_1.mongoLogId)(1001000035))];
|
|
1042
|
+
_createCollection_decorators = [op((0, logger_1.mongoLogId)(1001000036), ([ns, options], result) => {
|
|
1043
|
+
return { ns, options, ...(result && { result }) };
|
|
1044
|
+
})];
|
|
1045
|
+
_createIndex_decorators = [op((0, logger_1.mongoLogId)(1001000037), ([ns, spec, options], result) => {
|
|
1046
|
+
return { ns, spec, options, ...(result && { result }) };
|
|
1047
|
+
})];
|
|
1048
|
+
_deleteOne_decorators = [op((0, logger_1.mongoLogId)(1001000038), ([ns], result) => {
|
|
1049
|
+
return { ns, ...(result && { result }) };
|
|
1050
|
+
})];
|
|
1051
|
+
_deleteMany_decorators = [op((0, logger_1.mongoLogId)(1001000039), ([ns], result) => {
|
|
1052
|
+
return { ns, ...(result && { result }) };
|
|
1053
|
+
})];
|
|
1054
|
+
_dropCollection_decorators = [op((0, logger_1.mongoLogId)(1001000059), ([ns], result) => {
|
|
1055
|
+
return { ns, ...(result && { result }) };
|
|
1056
|
+
})];
|
|
1057
|
+
_dropDatabase_decorators = [op((0, logger_1.mongoLogId)(1001000040), ([db], result) => {
|
|
1058
|
+
return { db, ...(result && { result }) };
|
|
1059
|
+
})];
|
|
1060
|
+
_dropIndex_decorators = [op((0, logger_1.mongoLogId)(1001000182), ([ns, name], result) => {
|
|
1061
|
+
return { ns, name, ...(result && { result }) };
|
|
1062
|
+
})];
|
|
1063
|
+
_aggregateCursor_decorators = [op((0, logger_1.mongoLogId)(1001000041), ([ns, pipeline]) => {
|
|
1064
|
+
return { ns, stages: pipeline.map((stage) => Object.keys(stage)[0]) };
|
|
1065
|
+
})];
|
|
1066
|
+
_aggregate_decorators = [op((0, logger_1.mongoLogId)(1001000181), ([ns, pipeline]) => {
|
|
1067
|
+
return { ns, stages: pipeline.map((stage) => Object.keys(stage)[0]) };
|
|
1068
|
+
})];
|
|
1069
|
+
_find_decorators = [op((0, logger_1.mongoLogId)(1001000060))];
|
|
1070
|
+
_findCursor_decorators = [op((0, logger_1.mongoLogId)(1001000043))];
|
|
1071
|
+
_findOneAndReplace_decorators = [op((0, logger_1.mongoLogId)(1001000044))];
|
|
1072
|
+
_findOneAndUpdate_decorators = [op((0, logger_1.mongoLogId)(1001000045))];
|
|
1073
|
+
_updateOne_decorators = [op((0, logger_1.mongoLogId)(1001000183))];
|
|
1074
|
+
_replaceOne_decorators = [op((0, logger_1.mongoLogId)(1001000191))];
|
|
1075
|
+
_explainFind_decorators = [op((0, logger_1.mongoLogId)(1001000046), ([ns, , , executionOptions]) => {
|
|
1076
|
+
return {
|
|
1077
|
+
ns,
|
|
1078
|
+
verbosity: (executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.explainVerbosity) ||
|
|
1079
|
+
mongodb.ExplainVerbosity.allPlansExecution,
|
|
1080
|
+
};
|
|
1081
|
+
})];
|
|
1082
|
+
_explainAggregate_decorators = [op((0, logger_1.mongoLogId)(1001000177), ([ns, , , executionOptions]) => {
|
|
1083
|
+
return {
|
|
1084
|
+
ns,
|
|
1085
|
+
verbosity: (executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.explainVerbosity) ||
|
|
1086
|
+
mongodb.ExplainVerbosity.allPlansExecution,
|
|
1087
|
+
};
|
|
1088
|
+
})];
|
|
1089
|
+
_indexes_decorators = [op((0, logger_1.mongoLogId)(1001000047))];
|
|
1090
|
+
_instance_decorators = [op((0, logger_1.mongoLogId)(1001000024), (_, instanceData) => {
|
|
1091
|
+
if (instanceData) {
|
|
1092
|
+
return {
|
|
1093
|
+
serverVersion: instanceData.build.version,
|
|
1094
|
+
genuineMongoDB: instanceData.genuineMongoDB,
|
|
1095
|
+
dataLake: instanceData.dataLake,
|
|
1096
|
+
featureCompatibilityVersion: instanceData.featureCompatibilityVersion,
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
})];
|
|
1100
|
+
_insertOne_decorators = [op((0, logger_1.mongoLogId)(1001000048), ([ns], result) => {
|
|
1101
|
+
return { ns, ...(result && { acknowledged: result.acknowledged }) };
|
|
1102
|
+
})];
|
|
1103
|
+
_insertMany_decorators = [op((0, logger_1.mongoLogId)(1001000049), ([ns], result) => {
|
|
1104
|
+
return {
|
|
1105
|
+
ns,
|
|
1106
|
+
...(result && {
|
|
1107
|
+
acknowledged: result.acknowledged,
|
|
1108
|
+
insertedCount: result.insertedCount,
|
|
1109
|
+
}),
|
|
1110
|
+
};
|
|
1111
|
+
})];
|
|
1112
|
+
_updateCollection_decorators = [op((0, logger_1.mongoLogId)(1001000050), ([ns], result) => {
|
|
1113
|
+
return { ns, ...(result && { result }) };
|
|
1114
|
+
})];
|
|
1115
|
+
_currentOp_decorators = [op((0, logger_1.mongoLogId)(1001000053), (_, result) => {
|
|
1116
|
+
return result ? { result } : undefined;
|
|
1117
|
+
})];
|
|
1118
|
+
_serverStatus_decorators = [op((0, logger_1.mongoLogId)(1001000061), (_, result) => {
|
|
1119
|
+
return result ? { result } : undefined;
|
|
1120
|
+
})];
|
|
1121
|
+
_top_decorators = [op((0, logger_1.mongoLogId)(1001000062), (_, result) => {
|
|
1122
|
+
return result ? { result } : undefined;
|
|
1123
|
+
})];
|
|
1124
|
+
_createView_decorators = [op((0, logger_1.mongoLogId)(1001000055), ([name, sourceNs, pipeline, options], result) => {
|
|
1125
|
+
return {
|
|
1126
|
+
name,
|
|
1127
|
+
sourceNs,
|
|
1128
|
+
stages: pipeline.map((stage) => Object.keys(stage)[0]),
|
|
1129
|
+
options,
|
|
1130
|
+
...(result && { result }),
|
|
1131
|
+
};
|
|
1132
|
+
})];
|
|
1133
|
+
_databaseStats_decorators = [op((0, logger_1.mongoLogId)(1001000057))];
|
|
1134
|
+
_createDataKey_decorators = [op((0, logger_1.mongoLogId)(1001000123), ([provider]) => {
|
|
1135
|
+
return { provider };
|
|
1136
|
+
})];
|
|
1137
|
+
__esDecorate(_a, null, _collectionStats_decorators, { kind: "method", name: "collectionStats", static: false, private: false, access: { has: obj => "collectionStats" in obj, get: obj => obj.collectionStats } }, null, _instanceExtraInitializers);
|
|
1138
|
+
__esDecorate(_a, null, _collectionInfo_decorators, { kind: "method", name: "collectionInfo", static: false, private: false, access: { has: obj => "collectionInfo" in obj, get: obj => obj.collectionInfo } }, null, _instanceExtraInitializers);
|
|
1139
|
+
__esDecorate(_a, null, _killOp_decorators, { kind: "method", name: "killOp", static: false, private: false, access: { has: obj => "killOp" in obj, get: obj => obj.killOp } }, null, _instanceExtraInitializers);
|
|
1140
|
+
__esDecorate(_a, null, __connectionStatus_decorators, { kind: "method", name: "_connectionStatus", static: false, private: false, access: { has: obj => "_connectionStatus" in obj, get: obj => obj._connectionStatus } }, null, _instanceExtraInitializers);
|
|
1141
|
+
__esDecorate(_a, null, _listCollections_decorators, { kind: "method", name: "listCollections", static: false, private: false, access: { has: obj => "listCollections" in obj, get: obj => obj.listCollections } }, null, _instanceExtraInitializers);
|
|
1142
|
+
__esDecorate(_a, null, _listDatabases_decorators, { kind: "method", name: "listDatabases", static: false, private: false, access: { has: obj => "listDatabases" in obj, get: obj => obj.listDatabases } }, null, _instanceExtraInitializers);
|
|
1143
|
+
__esDecorate(_a, null, _estimatedCount_decorators, { kind: "method", name: "estimatedCount", static: false, private: false, access: { has: obj => "estimatedCount" in obj, get: obj => obj.estimatedCount } }, null, _instanceExtraInitializers);
|
|
1144
|
+
__esDecorate(_a, null, _count_decorators, { kind: "method", name: "count", static: false, private: false, access: { has: obj => "count" in obj, get: obj => obj.count } }, null, _instanceExtraInitializers);
|
|
1145
|
+
__esDecorate(_a, null, _createCollection_decorators, { kind: "method", name: "createCollection", static: false, private: false, access: { has: obj => "createCollection" in obj, get: obj => obj.createCollection } }, null, _instanceExtraInitializers);
|
|
1146
|
+
__esDecorate(_a, null, _createIndex_decorators, { kind: "method", name: "createIndex", static: false, private: false, access: { has: obj => "createIndex" in obj, get: obj => obj.createIndex } }, null, _instanceExtraInitializers);
|
|
1147
|
+
__esDecorate(_a, null, _deleteOne_decorators, { kind: "method", name: "deleteOne", static: false, private: false, access: { has: obj => "deleteOne" in obj, get: obj => obj.deleteOne } }, null, _instanceExtraInitializers);
|
|
1148
|
+
__esDecorate(_a, null, _deleteMany_decorators, { kind: "method", name: "deleteMany", static: false, private: false, access: { has: obj => "deleteMany" in obj, get: obj => obj.deleteMany } }, null, _instanceExtraInitializers);
|
|
1149
|
+
__esDecorate(_a, null, _dropCollection_decorators, { kind: "method", name: "dropCollection", static: false, private: false, access: { has: obj => "dropCollection" in obj, get: obj => obj.dropCollection } }, null, _instanceExtraInitializers);
|
|
1150
|
+
__esDecorate(_a, null, _dropDatabase_decorators, { kind: "method", name: "dropDatabase", static: false, private: false, access: { has: obj => "dropDatabase" in obj, get: obj => obj.dropDatabase } }, null, _instanceExtraInitializers);
|
|
1151
|
+
__esDecorate(_a, null, _dropIndex_decorators, { kind: "method", name: "dropIndex", static: false, private: false, access: { has: obj => "dropIndex" in obj, get: obj => obj.dropIndex } }, null, _instanceExtraInitializers);
|
|
1152
|
+
__esDecorate(_a, null, _aggregateCursor_decorators, { kind: "method", name: "aggregateCursor", static: false, private: false, access: { has: obj => "aggregateCursor" in obj, get: obj => obj.aggregateCursor } }, null, _instanceExtraInitializers);
|
|
1153
|
+
__esDecorate(_a, null, _aggregate_decorators, { kind: "method", name: "aggregate", static: false, private: false, access: { has: obj => "aggregate" in obj, get: obj => obj.aggregate } }, null, _instanceExtraInitializers);
|
|
1154
|
+
__esDecorate(_a, null, _find_decorators, { kind: "method", name: "find", static: false, private: false, access: { has: obj => "find" in obj, get: obj => obj.find } }, null, _instanceExtraInitializers);
|
|
1155
|
+
__esDecorate(_a, null, _findCursor_decorators, { kind: "method", name: "findCursor", static: false, private: false, access: { has: obj => "findCursor" in obj, get: obj => obj.findCursor } }, null, _instanceExtraInitializers);
|
|
1156
|
+
__esDecorate(_a, null, _findOneAndReplace_decorators, { kind: "method", name: "findOneAndReplace", static: false, private: false, access: { has: obj => "findOneAndReplace" in obj, get: obj => obj.findOneAndReplace } }, null, _instanceExtraInitializers);
|
|
1157
|
+
__esDecorate(_a, null, _findOneAndUpdate_decorators, { kind: "method", name: "findOneAndUpdate", static: false, private: false, access: { has: obj => "findOneAndUpdate" in obj, get: obj => obj.findOneAndUpdate } }, null, _instanceExtraInitializers);
|
|
1158
|
+
__esDecorate(_a, null, _updateOne_decorators, { kind: "method", name: "updateOne", static: false, private: false, access: { has: obj => "updateOne" in obj, get: obj => obj.updateOne } }, null, _instanceExtraInitializers);
|
|
1159
|
+
__esDecorate(_a, null, _replaceOne_decorators, { kind: "method", name: "replaceOne", static: false, private: false, access: { has: obj => "replaceOne" in obj, get: obj => obj.replaceOne } }, null, _instanceExtraInitializers);
|
|
1160
|
+
__esDecorate(_a, null, _explainFind_decorators, { kind: "method", name: "explainFind", static: false, private: false, access: { has: obj => "explainFind" in obj, get: obj => obj.explainFind } }, null, _instanceExtraInitializers);
|
|
1161
|
+
__esDecorate(_a, null, _explainAggregate_decorators, { kind: "method", name: "explainAggregate", static: false, private: false, access: { has: obj => "explainAggregate" in obj, get: obj => obj.explainAggregate } }, null, _instanceExtraInitializers);
|
|
1162
|
+
__esDecorate(_a, null, _indexes_decorators, { kind: "method", name: "indexes", static: false, private: false, access: { has: obj => "indexes" in obj, get: obj => obj.indexes } }, null, _instanceExtraInitializers);
|
|
1163
|
+
__esDecorate(_a, null, _instance_decorators, { kind: "method", name: "instance", static: false, private: false, access: { has: obj => "instance" in obj, get: obj => obj.instance } }, null, _instanceExtraInitializers);
|
|
1164
|
+
__esDecorate(_a, null, _insertOne_decorators, { kind: "method", name: "insertOne", static: false, private: false, access: { has: obj => "insertOne" in obj, get: obj => obj.insertOne } }, null, _instanceExtraInitializers);
|
|
1165
|
+
__esDecorate(_a, null, _insertMany_decorators, { kind: "method", name: "insertMany", static: false, private: false, access: { has: obj => "insertMany" in obj, get: obj => obj.insertMany } }, null, _instanceExtraInitializers);
|
|
1166
|
+
__esDecorate(_a, null, _updateCollection_decorators, { kind: "method", name: "updateCollection", static: false, private: false, access: { has: obj => "updateCollection" in obj, get: obj => obj.updateCollection } }, null, _instanceExtraInitializers);
|
|
1167
|
+
__esDecorate(_a, null, _currentOp_decorators, { kind: "method", name: "currentOp", static: false, private: false, access: { has: obj => "currentOp" in obj, get: obj => obj.currentOp } }, null, _instanceExtraInitializers);
|
|
1168
|
+
__esDecorate(_a, null, _serverStatus_decorators, { kind: "method", name: "serverStatus", static: false, private: false, access: { has: obj => "serverStatus" in obj, get: obj => obj.serverStatus } }, null, _instanceExtraInitializers);
|
|
1169
|
+
__esDecorate(_a, null, _top_decorators, { kind: "method", name: "top", static: false, private: false, access: { has: obj => "top" in obj, get: obj => obj.top } }, null, _instanceExtraInitializers);
|
|
1170
|
+
__esDecorate(_a, null, _createView_decorators, { kind: "method", name: "createView", static: false, private: false, access: { has: obj => "createView" in obj, get: obj => obj.createView } }, null, _instanceExtraInitializers);
|
|
1171
|
+
__esDecorate(_a, null, _databaseStats_decorators, { kind: "method", name: "databaseStats", static: false, private: false, access: { has: obj => "databaseStats" in obj, get: obj => obj.databaseStats } }, null, _instanceExtraInitializers);
|
|
1172
|
+
__esDecorate(_a, null, _createDataKey_decorators, { kind: "method", name: "createDataKey", static: false, private: false, access: { has: obj => "createDataKey" in obj, get: obj => obj.createDataKey } }, null, _instanceExtraInitializers);
|
|
1173
|
+
})(),
|
|
1174
|
+
(() => {
|
|
1175
|
+
const assertNoExtraProps = (_cls) => {
|
|
1176
|
+
};
|
|
1177
|
+
assertNoExtraProps(_a);
|
|
1178
|
+
})(),
|
|
1179
|
+
_a;
|
|
1180
|
+
})();
|
|
1134
1181
|
exports.DataServiceImpl = DataServiceImpl;
|
|
1135
1182
|
//# sourceMappingURL=data-service.js.map
|