mongodb-data-service 22.6.0 → 22.8.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 +13 -2
- package/lib/connect-mongo-client.d.ts.map +1 -1
- package/lib/connect-mongo-client.js +75 -19
- package/lib/connect-mongo-client.js.map +1 -1
- package/lib/connect.d.ts +9 -1
- package/lib/connect.d.ts.map +1 -1
- package/lib/connect.js +7 -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 +5 -3
- package/lib/csfle-collection-tracker.d.ts.map +1 -1
- package/lib/csfle-collection-tracker.js +16 -13
- package/lib/csfle-collection-tracker.js.map +1 -1
- package/lib/data-service.d.ts +26 -12
- package/lib/data-service.d.ts.map +1 -1
- package/lib/data-service.js +188 -121
- package/lib/data-service.js.map +1 -1
- package/lib/instance-detail-helper.d.ts.map +1 -1
- package/lib/instance-detail-helper.js +2 -3
- package/lib/instance-detail-helper.js.map +1 -1
- package/lib/legacy/legacy-connection-model.d.ts +1 -3
- package/lib/legacy/legacy-connection-model.d.ts.map +1 -1
- package/lib/legacy/legacy-connection-model.js.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/ssh-tunnel.d.ts +3 -2
- 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 +0 -11
- package/lib/types.d.ts.map +1 -1
- package/package.json +23 -27
package/lib/data-service.js
CHANGED
|
@@ -61,19 +61,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
61
61
|
};
|
|
62
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
63
|
exports.DataServiceImpl = void 0;
|
|
64
|
-
const compass_logging_1 = __importDefault(require("@mongodb-js/compass-logging"));
|
|
65
64
|
const events_1 = require("events");
|
|
66
65
|
const mongodb_connection_string_url_1 = __importDefault(require("mongodb-connection-string-url"));
|
|
67
66
|
const mongodb_ns_1 = __importDefault(require("mongodb-ns"));
|
|
68
67
|
const instance_detail_helper_1 = require("./instance-detail-helper");
|
|
69
68
|
const instance_detail_helper_2 = require("./instance-detail-helper");
|
|
70
69
|
const redact_1 = require("./redact");
|
|
71
|
-
const connect_mongo_client_1 =
|
|
70
|
+
const connect_mongo_client_1 = require("./connect-mongo-client");
|
|
72
71
|
const run_command_1 = require("./run-command");
|
|
73
72
|
const csfle_collection_tracker_1 = require("./csfle-collection-tracker");
|
|
74
73
|
const mongodb = __importStar(require("mongodb"));
|
|
75
74
|
const compass_utils_1 = require("@mongodb-js/compass-utils");
|
|
76
75
|
const index_detail_helper_1 = require("./index-detail-helper");
|
|
76
|
+
const logger_1 = require("./logger");
|
|
77
|
+
const lodash_1 = require("lodash");
|
|
77
78
|
let ClientEncryption;
|
|
78
79
|
try {
|
|
79
80
|
const { extension } = require('mongodb-client-encryption');
|
|
@@ -82,7 +83,6 @@ try {
|
|
|
82
83
|
catch (e) {
|
|
83
84
|
console.warn(e);
|
|
84
85
|
}
|
|
85
|
-
const { log, mongoLogId, debug } = (0, compass_logging_1.default)('COMPASS-DATA-SERVICE');
|
|
86
86
|
function uniqueBy(values, key) {
|
|
87
87
|
return Array.from(new Map(values.map((val) => [val[key], val])).values());
|
|
88
88
|
}
|
|
@@ -108,20 +108,18 @@ const translateErrorMessage = (error) => {
|
|
|
108
108
|
}
|
|
109
109
|
return error;
|
|
110
110
|
};
|
|
111
|
-
class WithLogContext {
|
|
112
|
-
}
|
|
113
111
|
function op(logId, pickLogAttrs = maybePickNs) {
|
|
114
112
|
return function (target, context) {
|
|
115
113
|
const opName = String(context.name);
|
|
116
114
|
return function (...args) {
|
|
117
115
|
const handleResult = (result) => {
|
|
118
|
-
|
|
116
|
+
this._logger.info(logId, `Running ${opName}`, pickLogAttrs(args, result));
|
|
119
117
|
return result;
|
|
120
118
|
};
|
|
121
119
|
const handleError = (error) => {
|
|
122
120
|
var _a;
|
|
123
121
|
const err = translateErrorMessage(error);
|
|
124
|
-
|
|
122
|
+
this._logger.error((0, logger_1.mongoLogId)(1001000058), 'Failed to perform data service operation', {
|
|
125
123
|
op: opName,
|
|
126
124
|
message: err,
|
|
127
125
|
...((_a = pickLogAttrs(args)) !== null && _a !== void 0 ? _a : {}),
|
|
@@ -167,6 +165,8 @@ let DataServiceImpl = (() => {
|
|
|
167
165
|
let _findCursor_decorators;
|
|
168
166
|
let _findOneAndReplace_decorators;
|
|
169
167
|
let _findOneAndUpdate_decorators;
|
|
168
|
+
let _updateOne_decorators;
|
|
169
|
+
let _replaceOne_decorators;
|
|
170
170
|
let _explainFind_decorators;
|
|
171
171
|
let _explainAggregate_decorators;
|
|
172
172
|
let _indexes_decorators;
|
|
@@ -180,8 +180,8 @@ let DataServiceImpl = (() => {
|
|
|
180
180
|
let _createView_decorators;
|
|
181
181
|
let _databaseStats_decorators;
|
|
182
182
|
let _createDataKey_decorators;
|
|
183
|
-
return _a = class DataServiceImpl extends WithLogContext {
|
|
184
|
-
constructor(connectionOptions) {
|
|
183
|
+
return _a = class DataServiceImpl extends logger_1.WithLogContext {
|
|
184
|
+
constructor(connectionOptions, logger) {
|
|
185
185
|
super();
|
|
186
186
|
this._connectionOptions = (__runInitializers(this, _instanceExtraInitializers), void 0);
|
|
187
187
|
this._isConnecting = false;
|
|
@@ -191,6 +191,28 @@ let DataServiceImpl = (() => {
|
|
|
191
191
|
this._emitter = new events_1.EventEmitter();
|
|
192
192
|
this._id = id++;
|
|
193
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
|
+
},
|
|
212
|
+
};
|
|
213
|
+
if (logger) {
|
|
214
|
+
this._unboundLogger = Object.assign(logger, { mongoLogId: logger_1.mongoLogId });
|
|
215
|
+
}
|
|
194
216
|
}
|
|
195
217
|
on(...args) {
|
|
196
218
|
this._emitter.on(...args);
|
|
@@ -201,10 +223,7 @@ let DataServiceImpl = (() => {
|
|
|
201
223
|
return this;
|
|
202
224
|
}
|
|
203
225
|
getMongoClientConnectionOptions() {
|
|
204
|
-
return this._mongoClientConnectionOptions;
|
|
205
|
-
}
|
|
206
|
-
_logCtx() {
|
|
207
|
-
return `Connection ${this._id}`;
|
|
226
|
+
return (0, lodash_1.omit)(this._mongoClientConnectionOptions, 'options.oidc.notifyDeviceFlow', 'options.oidc.signal');
|
|
208
227
|
}
|
|
209
228
|
getConnectionOptions() {
|
|
210
229
|
return this._connectionOptions;
|
|
@@ -213,7 +232,7 @@ let DataServiceImpl = (() => {
|
|
|
213
232
|
return new mongodb_connection_string_url_1.default(this._connectionOptions.connectionString);
|
|
214
233
|
}
|
|
215
234
|
setCSFLEEnabled(enabled) {
|
|
216
|
-
|
|
235
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000117), 'Setting CSFLE mode', {
|
|
217
236
|
enabled,
|
|
218
237
|
});
|
|
219
238
|
this._useCRUDClient = enabled;
|
|
@@ -232,10 +251,58 @@ let DataServiceImpl = (() => {
|
|
|
232
251
|
}
|
|
233
252
|
}
|
|
234
253
|
async collectionStats(databaseName, collectionName) {
|
|
235
|
-
const
|
|
254
|
+
const ns = `${databaseName}.${collectionName}`;
|
|
236
255
|
try {
|
|
237
|
-
const
|
|
238
|
-
|
|
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]);
|
|
239
306
|
}
|
|
240
307
|
catch (error) {
|
|
241
308
|
if (!error.message.includes('is a view, not a collection')) {
|
|
@@ -298,7 +365,7 @@ let DataServiceImpl = (() => {
|
|
|
298
365
|
return results;
|
|
299
366
|
}
|
|
300
367
|
catch (err) {
|
|
301
|
-
|
|
368
|
+
this._logger.warn((0, logger_1.mongoLogId)(1001000099), 'Failed to run listCollections', { message: err.message });
|
|
302
369
|
return [];
|
|
303
370
|
}
|
|
304
371
|
}
|
|
@@ -327,7 +394,7 @@ let DataServiceImpl = (() => {
|
|
|
327
394
|
return databases;
|
|
328
395
|
}
|
|
329
396
|
catch (err) {
|
|
330
|
-
|
|
397
|
+
this._logger.warn((0, logger_1.mongoLogId)(1001000098), 'Failed to run listDatabases', { message: err.message });
|
|
331
398
|
return [];
|
|
332
399
|
}
|
|
333
400
|
};
|
|
@@ -351,32 +418,40 @@ let DataServiceImpl = (() => {
|
|
|
351
418
|
});
|
|
352
419
|
return databases;
|
|
353
420
|
}
|
|
354
|
-
async connect() {
|
|
421
|
+
async connect({ signal, productName, productDocsLink, } = {}) {
|
|
355
422
|
if (this._metadataClient) {
|
|
356
|
-
debug('already connected');
|
|
423
|
+
(0, logger_1.debug)('already connected');
|
|
357
424
|
return;
|
|
358
425
|
}
|
|
359
426
|
if (this._isConnecting) {
|
|
360
|
-
debug('connect method called more than once');
|
|
427
|
+
(0, logger_1.debug)('connect method called more than once');
|
|
361
428
|
return;
|
|
362
429
|
}
|
|
363
|
-
debug('connecting...');
|
|
430
|
+
(0, logger_1.debug)('connecting...');
|
|
364
431
|
this._isConnecting = true;
|
|
365
|
-
|
|
432
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000014), 'Connecting', {
|
|
366
433
|
url: (0, redact_1.redactConnectionString)(this._connectionOptions.connectionString),
|
|
367
434
|
csfle: this._csfleLogInformation(this._connectionOptions.fleOptions),
|
|
368
435
|
});
|
|
369
436
|
try {
|
|
370
|
-
const [metadataClient, crudClient, tunnel, connectionOptions] = await (0, connect_mongo_client_1.
|
|
437
|
+
const [metadataClient, crudClient, tunnel, state, connectionOptions] = await (0, connect_mongo_client_1.connectMongoClientDataService)({
|
|
438
|
+
connectionOptions: this._connectionOptions,
|
|
439
|
+
setupListeners: this._setupListeners.bind(this),
|
|
440
|
+
signal,
|
|
441
|
+
logger: this._unboundLogger,
|
|
442
|
+
productName,
|
|
443
|
+
productDocsLink,
|
|
444
|
+
});
|
|
371
445
|
const attr = {
|
|
372
446
|
isWritable: this.isWritable(),
|
|
373
447
|
isMongos: this.isMongos(),
|
|
374
448
|
};
|
|
375
|
-
|
|
376
|
-
debug('connected!', attr);
|
|
449
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000015), 'Connected', attr);
|
|
450
|
+
(0, logger_1.debug)('connected!', attr);
|
|
377
451
|
this._metadataClient = metadataClient;
|
|
378
452
|
this._crudClient = crudClient;
|
|
379
453
|
this._tunnel = tunnel;
|
|
454
|
+
this._state = state;
|
|
380
455
|
this._mongoClientConnectionOptions = connectionOptions;
|
|
381
456
|
this._csfleCollectionTracker = new csfle_collection_tracker_1.CSFLECollectionTrackerImpl(this, this._crudClient);
|
|
382
457
|
}
|
|
@@ -418,19 +493,20 @@ let DataServiceImpl = (() => {
|
|
|
418
493
|
return await coll.deleteMany(filter, options);
|
|
419
494
|
}
|
|
420
495
|
async disconnect() {
|
|
421
|
-
var _a, _b, _c;
|
|
422
|
-
|
|
496
|
+
var _a, _b, _c, _d;
|
|
497
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000016), 'Disconnecting');
|
|
423
498
|
try {
|
|
424
499
|
await Promise.all([
|
|
425
|
-
(_a = this._metadataClient) === null || _a === void 0 ? void 0 : _a.close(true).catch((err) => debug('failed to close MongoClient', err)),
|
|
500
|
+
(_a = this._metadataClient) === null || _a === void 0 ? void 0 : _a.close(true).catch((err) => (0, logger_1.debug)('failed to close MongoClient', err)),
|
|
426
501
|
this._crudClient !== this._metadataClient &&
|
|
427
|
-
((_b = this._crudClient) === null || _b === void 0 ? void 0 : _b.close(true).catch((err) => debug('failed to close MongoClient', err))),
|
|
428
|
-
(_c = this._tunnel) === null || _c === void 0 ? void 0 : _c.close().catch((err) => debug('failed to close tunnel', err)),
|
|
502
|
+
((_b = this._crudClient) === null || _b === void 0 ? void 0 : _b.close(true).catch((err) => (0, logger_1.debug)('failed to close MongoClient', err))),
|
|
503
|
+
(_c = this._tunnel) === null || _c === void 0 ? void 0 : _c.close().catch((err) => (0, logger_1.debug)('failed to close tunnel', err)),
|
|
504
|
+
(_d = this._state) === null || _d === void 0 ? void 0 : _d.destroy().catch((err) => (0, logger_1.debug)('failed to destroy DevtoolsConnectionState', err)),
|
|
429
505
|
]);
|
|
430
506
|
}
|
|
431
507
|
finally {
|
|
432
508
|
this._cleanup();
|
|
433
|
-
|
|
509
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000017), 'Fully closed');
|
|
434
510
|
}
|
|
435
511
|
}
|
|
436
512
|
async dropCollection(ns) {
|
|
@@ -499,6 +575,14 @@ let DataServiceImpl = (() => {
|
|
|
499
575
|
const coll = this._collection(ns, 'CRUD');
|
|
500
576
|
return (await coll.findOneAndUpdate(filter, update, options)).value;
|
|
501
577
|
}
|
|
578
|
+
async updateOne(ns, filter, update, options) {
|
|
579
|
+
const coll = this._collection(ns, 'CRUD');
|
|
580
|
+
return await coll.updateOne(filter, update, options);
|
|
581
|
+
}
|
|
582
|
+
async replaceOne(ns, filter, replacement, options) {
|
|
583
|
+
const coll = this._collection(ns, 'CRUD');
|
|
584
|
+
return await coll.replaceOne(filter, replacement, options);
|
|
585
|
+
}
|
|
502
586
|
explainFind(ns, filter, options = {}, executionOptions) {
|
|
503
587
|
const verbosity = (executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.explainVerbosity) ||
|
|
504
588
|
mongodb.ExplainVerbosity.allPlansExecution;
|
|
@@ -601,12 +685,19 @@ let DataServiceImpl = (() => {
|
|
|
601
685
|
bulkWrite(ns, operations, options) {
|
|
602
686
|
return this._collection(ns, 'CRUD').bulkWrite(operations, options);
|
|
603
687
|
}
|
|
604
|
-
async currentOp(
|
|
688
|
+
async currentOp() {
|
|
605
689
|
const db = this._database('admin', 'META');
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
690
|
+
const pipelineWithTruncateOps = [
|
|
691
|
+
{
|
|
692
|
+
$currentOp: {
|
|
693
|
+
allUsers: true,
|
|
694
|
+
idleConnections: false,
|
|
695
|
+
truncateOps: false,
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
];
|
|
699
|
+
const currentOp = await db.aggregate(pipelineWithTruncateOps).toArray();
|
|
700
|
+
return { inprog: currentOp };
|
|
610
701
|
}
|
|
611
702
|
getLastSeenTopology() {
|
|
612
703
|
return this._lastSeenTopology;
|
|
@@ -683,7 +774,7 @@ let DataServiceImpl = (() => {
|
|
|
683
774
|
let result;
|
|
684
775
|
const abort = async () => {
|
|
685
776
|
const logAbortError = (error) => {
|
|
686
|
-
|
|
777
|
+
this._logger.warn((0, logger_1.mongoLogId)(1001000140), 'Attempting to kill the operation failed', { error: error.message });
|
|
687
778
|
};
|
|
688
779
|
await stop(session).catch(logAbortError);
|
|
689
780
|
await this._killSessions(session).catch(logAbortError);
|
|
@@ -706,7 +797,7 @@ let DataServiceImpl = (() => {
|
|
|
706
797
|
if (client) {
|
|
707
798
|
client.on('serverDescriptionChanged', (evt) => {
|
|
708
799
|
var _a, _b;
|
|
709
|
-
|
|
800
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000018), 'Server description changed', {
|
|
710
801
|
address: evt.address,
|
|
711
802
|
error: (_b = (_a = evt.newDescription.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : null,
|
|
712
803
|
previousType: evt.previousDescription.type,
|
|
@@ -714,12 +805,12 @@ let DataServiceImpl = (() => {
|
|
|
714
805
|
});
|
|
715
806
|
});
|
|
716
807
|
client.on('serverOpening', (evt) => {
|
|
717
|
-
|
|
808
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000019), 'Server opening', {
|
|
718
809
|
address: evt.address,
|
|
719
810
|
});
|
|
720
811
|
});
|
|
721
812
|
client.on('serverClosed', (evt) => {
|
|
722
|
-
|
|
813
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000020), 'Server closed', {
|
|
723
814
|
address: evt.address,
|
|
724
815
|
});
|
|
725
816
|
});
|
|
@@ -731,7 +822,7 @@ let DataServiceImpl = (() => {
|
|
|
731
822
|
previousType: evt.previousDescription.type,
|
|
732
823
|
newType: evt.newDescription.type,
|
|
733
824
|
};
|
|
734
|
-
|
|
825
|
+
this._logger.info((0, logger_1.mongoLogId)(1001000021), 'Topology description changed', attr);
|
|
735
826
|
this._lastSeenTopology = evt.newDescription;
|
|
736
827
|
this._emitter.emit('topologyDescriptionChanged', evt);
|
|
737
828
|
});
|
|
@@ -750,15 +841,9 @@ let DataServiceImpl = (() => {
|
|
|
750
841
|
failure: null,
|
|
751
842
|
duration: evt.duration,
|
|
752
843
|
});
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
ctx: this._logCtx(),
|
|
757
|
-
msg: 'Server heartbeat succeeded',
|
|
758
|
-
attr: {
|
|
759
|
-
connectionId: evt.connectionId,
|
|
760
|
-
duration: evt.duration,
|
|
761
|
-
},
|
|
844
|
+
this._logger.debug((0, logger_1.mongoLogId)(1001000022), 'Server heartbeat succeeded', {
|
|
845
|
+
connectionId: evt.connectionId,
|
|
846
|
+
duration: evt.duration,
|
|
762
847
|
});
|
|
763
848
|
}
|
|
764
849
|
});
|
|
@@ -771,7 +856,7 @@ let DataServiceImpl = (() => {
|
|
|
771
856
|
failure: evt.failure.message,
|
|
772
857
|
duration: evt.duration,
|
|
773
858
|
});
|
|
774
|
-
|
|
859
|
+
this._logger.warn((0, logger_1.mongoLogId)(1001000023), 'Server heartbeat failed', {
|
|
775
860
|
connectionId: evt.connectionId,
|
|
776
861
|
duration: evt.duration,
|
|
777
862
|
failure: evt.failure.message,
|
|
@@ -780,33 +865,21 @@ let DataServiceImpl = (() => {
|
|
|
780
865
|
});
|
|
781
866
|
client.on('commandSucceeded', (evt) => {
|
|
782
867
|
const { address, connectionId, duration, commandName } = evt;
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
attr: {
|
|
789
|
-
address,
|
|
790
|
-
serverConnectionId: connectionId,
|
|
791
|
-
duration,
|
|
792
|
-
commandName,
|
|
793
|
-
},
|
|
868
|
+
this._logger.debug((0, logger_1.mongoLogId)(1001000029), 'Driver command succeeded', {
|
|
869
|
+
address,
|
|
870
|
+
serverConnectionId: connectionId,
|
|
871
|
+
duration,
|
|
872
|
+
commandName,
|
|
794
873
|
});
|
|
795
874
|
});
|
|
796
875
|
client.on('commandFailed', (evt) => {
|
|
797
876
|
const { address, connectionId, duration, commandName, failure } = evt;
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
address,
|
|
805
|
-
serverConnectionId: connectionId,
|
|
806
|
-
duration,
|
|
807
|
-
commandName,
|
|
808
|
-
failure: failure.message,
|
|
809
|
-
},
|
|
877
|
+
this._logger.debug((0, logger_1.mongoLogId)(1001000030), 'Driver command failed', {
|
|
878
|
+
address,
|
|
879
|
+
serverConnectionId: connectionId,
|
|
880
|
+
duration,
|
|
881
|
+
commandName,
|
|
882
|
+
failure: failure.message,
|
|
810
883
|
});
|
|
811
884
|
});
|
|
812
885
|
}
|
|
@@ -848,9 +921,6 @@ let DataServiceImpl = (() => {
|
|
|
848
921
|
name: collectionName,
|
|
849
922
|
database: databaseName,
|
|
850
923
|
is_capped: data.capped,
|
|
851
|
-
max: data.max,
|
|
852
|
-
is_power_of_two: data.userFlags === 1,
|
|
853
|
-
index_sizes: data.indexSizes,
|
|
854
924
|
document_count: (_a = data.count) !== null && _a !== void 0 ? _a : 0,
|
|
855
925
|
document_size: data.size,
|
|
856
926
|
avg_document_size: (_b = data.avgObjSize) !== null && _b !== void 0 ? _b : 0,
|
|
@@ -858,14 +928,6 @@ let DataServiceImpl = (() => {
|
|
|
858
928
|
free_storage_size: (_d = data.freeStorageSize) !== null && _d !== void 0 ? _d : 0,
|
|
859
929
|
index_count: (_e = data.nindexes) !== null && _e !== void 0 ? _e : 0,
|
|
860
930
|
index_size: (_f = data.totalIndexSize) !== null && _f !== void 0 ? _f : 0,
|
|
861
|
-
padding_factor: data.paddingFactor,
|
|
862
|
-
extent_count: data.numExtents,
|
|
863
|
-
extent_last_size: data.lastExtentSize,
|
|
864
|
-
flags_user: data.userFlags,
|
|
865
|
-
max_document_size: data.maxSize,
|
|
866
|
-
size: data.size,
|
|
867
|
-
index_details: data.indexDetails || {},
|
|
868
|
-
wired_tiger: data.wiredTiger || {},
|
|
869
931
|
};
|
|
870
932
|
}
|
|
871
933
|
_collection(ns, type) {
|
|
@@ -893,6 +955,7 @@ let DataServiceImpl = (() => {
|
|
|
893
955
|
this._metadataClient = undefined;
|
|
894
956
|
this._crudClient = undefined;
|
|
895
957
|
this._tunnel = undefined;
|
|
958
|
+
this._state = undefined;
|
|
896
959
|
this._mongoClientConnectionOptions = undefined;
|
|
897
960
|
this._isWritable = false;
|
|
898
961
|
this._isConnecting = false;
|
|
@@ -960,13 +1023,13 @@ let DataServiceImpl = (() => {
|
|
|
960
1023
|
}
|
|
961
1024
|
},
|
|
962
1025
|
(() => {
|
|
963
|
-
_collectionStats_decorators = [op(mongoLogId(1001000178), ([dbName, collName], result) => {
|
|
1026
|
+
_collectionStats_decorators = [op((0, logger_1.mongoLogId)(1001000178), ([dbName, collName], result) => {
|
|
964
1027
|
return { ns: `${dbName}.${collName}`, ...(result && { result }) };
|
|
965
1028
|
})];
|
|
966
|
-
_collectionInfo_decorators = [op(mongoLogId(1001000179))];
|
|
967
|
-
_killOp_decorators = [op(mongoLogId(1001000031))];
|
|
968
|
-
__connectionStatus_decorators = [op(mongoLogId(1001000100))];
|
|
969
|
-
_listCollections_decorators = [op(mongoLogId(1001000032), ([databaseName, , options], colls) => {
|
|
1029
|
+
_collectionInfo_decorators = [op((0, logger_1.mongoLogId)(1001000179))];
|
|
1030
|
+
_killOp_decorators = [op((0, logger_1.mongoLogId)(1001000031))];
|
|
1031
|
+
__connectionStatus_decorators = [op((0, logger_1.mongoLogId)(1001000100))];
|
|
1032
|
+
_listCollections_decorators = [op((0, logger_1.mongoLogId)(1001000032), ([databaseName, , options], colls) => {
|
|
970
1033
|
var _a;
|
|
971
1034
|
return {
|
|
972
1035
|
db: databaseName,
|
|
@@ -974,62 +1037,64 @@ let DataServiceImpl = (() => {
|
|
|
974
1037
|
...(colls && { collectionsCount: colls.length }),
|
|
975
1038
|
};
|
|
976
1039
|
})];
|
|
977
|
-
_listDatabases_decorators = [op(mongoLogId(1001000033), ([options], dbs) => {
|
|
1040
|
+
_listDatabases_decorators = [op((0, logger_1.mongoLogId)(1001000033), ([options], dbs) => {
|
|
978
1041
|
var _a;
|
|
979
1042
|
return {
|
|
980
1043
|
nameOnly: (_a = options === null || options === void 0 ? void 0 : options.nameOnly) !== null && _a !== void 0 ? _a : false,
|
|
981
1044
|
...(dbs && { databasesCount: dbs.length }),
|
|
982
1045
|
};
|
|
983
1046
|
})];
|
|
984
|
-
_estimatedCount_decorators = [op(mongoLogId(1001000034))];
|
|
985
|
-
_count_decorators = [op(mongoLogId(1001000035))];
|
|
986
|
-
_createCollection_decorators = [op(mongoLogId(1001000036), ([ns, options], result) => {
|
|
1047
|
+
_estimatedCount_decorators = [op((0, logger_1.mongoLogId)(1001000034))];
|
|
1048
|
+
_count_decorators = [op((0, logger_1.mongoLogId)(1001000035))];
|
|
1049
|
+
_createCollection_decorators = [op((0, logger_1.mongoLogId)(1001000036), ([ns, options], result) => {
|
|
987
1050
|
return { ns, options, ...(result && { result }) };
|
|
988
1051
|
})];
|
|
989
|
-
_createIndex_decorators = [op(mongoLogId(1001000037), ([ns, spec, options], result) => {
|
|
1052
|
+
_createIndex_decorators = [op((0, logger_1.mongoLogId)(1001000037), ([ns, spec, options], result) => {
|
|
990
1053
|
return { ns, spec, options, ...(result && { result }) };
|
|
991
1054
|
})];
|
|
992
|
-
_deleteOne_decorators = [op(mongoLogId(1001000038), ([ns], result) => {
|
|
1055
|
+
_deleteOne_decorators = [op((0, logger_1.mongoLogId)(1001000038), ([ns], result) => {
|
|
993
1056
|
return { ns, ...(result && { result }) };
|
|
994
1057
|
})];
|
|
995
|
-
_deleteMany_decorators = [op(mongoLogId(1001000039), ([ns], result) => {
|
|
1058
|
+
_deleteMany_decorators = [op((0, logger_1.mongoLogId)(1001000039), ([ns], result) => {
|
|
996
1059
|
return { ns, ...(result && { result }) };
|
|
997
1060
|
})];
|
|
998
|
-
_dropCollection_decorators = [op(mongoLogId(1001000059), ([ns], result) => {
|
|
1061
|
+
_dropCollection_decorators = [op((0, logger_1.mongoLogId)(1001000059), ([ns], result) => {
|
|
999
1062
|
return { ns, ...(result && { result }) };
|
|
1000
1063
|
})];
|
|
1001
|
-
_dropDatabase_decorators = [op(mongoLogId(1001000040), ([db], result) => {
|
|
1064
|
+
_dropDatabase_decorators = [op((0, logger_1.mongoLogId)(1001000040), ([db], result) => {
|
|
1002
1065
|
return { db, ...(result && { result }) };
|
|
1003
1066
|
})];
|
|
1004
|
-
_dropIndex_decorators = [op(mongoLogId(1001000182), ([ns, name], result) => {
|
|
1067
|
+
_dropIndex_decorators = [op((0, logger_1.mongoLogId)(1001000182), ([ns, name], result) => {
|
|
1005
1068
|
return { ns, name, ...(result && { result }) };
|
|
1006
1069
|
})];
|
|
1007
|
-
_aggregateCursor_decorators = [op(mongoLogId(1001000041), ([ns, pipeline]) => {
|
|
1070
|
+
_aggregateCursor_decorators = [op((0, logger_1.mongoLogId)(1001000041), ([ns, pipeline]) => {
|
|
1008
1071
|
return { ns, stages: pipeline.map((stage) => Object.keys(stage)[0]) };
|
|
1009
1072
|
})];
|
|
1010
|
-
_aggregate_decorators = [op(mongoLogId(1001000181), ([ns, pipeline]) => {
|
|
1073
|
+
_aggregate_decorators = [op((0, logger_1.mongoLogId)(1001000181), ([ns, pipeline]) => {
|
|
1011
1074
|
return { ns, stages: pipeline.map((stage) => Object.keys(stage)[0]) };
|
|
1012
1075
|
})];
|
|
1013
|
-
_find_decorators = [op(mongoLogId(1001000060))];
|
|
1014
|
-
_findCursor_decorators = [op(mongoLogId(1001000043))];
|
|
1015
|
-
_findOneAndReplace_decorators = [op(mongoLogId(1001000044))];
|
|
1016
|
-
_findOneAndUpdate_decorators = [op(mongoLogId(1001000045))];
|
|
1017
|
-
|
|
1076
|
+
_find_decorators = [op((0, logger_1.mongoLogId)(1001000060))];
|
|
1077
|
+
_findCursor_decorators = [op((0, logger_1.mongoLogId)(1001000043))];
|
|
1078
|
+
_findOneAndReplace_decorators = [op((0, logger_1.mongoLogId)(1001000044))];
|
|
1079
|
+
_findOneAndUpdate_decorators = [op((0, logger_1.mongoLogId)(1001000045))];
|
|
1080
|
+
_updateOne_decorators = [op((0, logger_1.mongoLogId)(1001000183))];
|
|
1081
|
+
_replaceOne_decorators = [op((0, logger_1.mongoLogId)(1001000191))];
|
|
1082
|
+
_explainFind_decorators = [op((0, logger_1.mongoLogId)(1001000046), ([ns, , , executionOptions]) => {
|
|
1018
1083
|
return {
|
|
1019
1084
|
ns,
|
|
1020
1085
|
verbosity: (executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.explainVerbosity) ||
|
|
1021
1086
|
mongodb.ExplainVerbosity.allPlansExecution,
|
|
1022
1087
|
};
|
|
1023
1088
|
})];
|
|
1024
|
-
_explainAggregate_decorators = [op(mongoLogId(1001000177), ([ns, , , executionOptions]) => {
|
|
1089
|
+
_explainAggregate_decorators = [op((0, logger_1.mongoLogId)(1001000177), ([ns, , , executionOptions]) => {
|
|
1025
1090
|
return {
|
|
1026
1091
|
ns,
|
|
1027
1092
|
verbosity: (executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.explainVerbosity) ||
|
|
1028
1093
|
mongodb.ExplainVerbosity.allPlansExecution,
|
|
1029
1094
|
};
|
|
1030
1095
|
})];
|
|
1031
|
-
_indexes_decorators = [op(mongoLogId(1001000047))];
|
|
1032
|
-
_instance_decorators = [op(mongoLogId(1001000024), (_, instanceData) => {
|
|
1096
|
+
_indexes_decorators = [op((0, logger_1.mongoLogId)(1001000047))];
|
|
1097
|
+
_instance_decorators = [op((0, logger_1.mongoLogId)(1001000024), (_, instanceData) => {
|
|
1033
1098
|
if (instanceData) {
|
|
1034
1099
|
return {
|
|
1035
1100
|
serverVersion: instanceData.build.version,
|
|
@@ -1039,10 +1104,10 @@ let DataServiceImpl = (() => {
|
|
|
1039
1104
|
};
|
|
1040
1105
|
}
|
|
1041
1106
|
})];
|
|
1042
|
-
_insertOne_decorators = [op(mongoLogId(1001000048), ([ns], result) => {
|
|
1107
|
+
_insertOne_decorators = [op((0, logger_1.mongoLogId)(1001000048), ([ns], result) => {
|
|
1043
1108
|
return { ns, ...(result && { acknowledged: result.acknowledged }) };
|
|
1044
1109
|
})];
|
|
1045
|
-
_insertMany_decorators = [op(mongoLogId(1001000049), ([ns], result) => {
|
|
1110
|
+
_insertMany_decorators = [op((0, logger_1.mongoLogId)(1001000049), ([ns], result) => {
|
|
1046
1111
|
return {
|
|
1047
1112
|
ns,
|
|
1048
1113
|
...(result && {
|
|
@@ -1051,19 +1116,19 @@ let DataServiceImpl = (() => {
|
|
|
1051
1116
|
}),
|
|
1052
1117
|
};
|
|
1053
1118
|
})];
|
|
1054
|
-
_updateCollection_decorators = [op(mongoLogId(1001000050), ([ns], result) => {
|
|
1119
|
+
_updateCollection_decorators = [op((0, logger_1.mongoLogId)(1001000050), ([ns], result) => {
|
|
1055
1120
|
return { ns, ...(result && { result }) };
|
|
1056
1121
|
})];
|
|
1057
|
-
_currentOp_decorators = [op(mongoLogId(1001000053), (_, result) => {
|
|
1122
|
+
_currentOp_decorators = [op((0, logger_1.mongoLogId)(1001000053), (_, result) => {
|
|
1058
1123
|
return result ? { result } : undefined;
|
|
1059
1124
|
})];
|
|
1060
|
-
_serverStatus_decorators = [op(mongoLogId(1001000061), (_, result) => {
|
|
1125
|
+
_serverStatus_decorators = [op((0, logger_1.mongoLogId)(1001000061), (_, result) => {
|
|
1061
1126
|
return result ? { result } : undefined;
|
|
1062
1127
|
})];
|
|
1063
|
-
_top_decorators = [op(mongoLogId(1001000062), (_, result) => {
|
|
1128
|
+
_top_decorators = [op((0, logger_1.mongoLogId)(1001000062), (_, result) => {
|
|
1064
1129
|
return result ? { result } : undefined;
|
|
1065
1130
|
})];
|
|
1066
|
-
_createView_decorators = [op(mongoLogId(1001000055), ([name, sourceNs, pipeline, options], result) => {
|
|
1131
|
+
_createView_decorators = [op((0, logger_1.mongoLogId)(1001000055), ([name, sourceNs, pipeline, options], result) => {
|
|
1067
1132
|
return {
|
|
1068
1133
|
name,
|
|
1069
1134
|
sourceNs,
|
|
@@ -1072,8 +1137,8 @@ let DataServiceImpl = (() => {
|
|
|
1072
1137
|
...(result && { result }),
|
|
1073
1138
|
};
|
|
1074
1139
|
})];
|
|
1075
|
-
_databaseStats_decorators = [op(mongoLogId(1001000057))];
|
|
1076
|
-
_createDataKey_decorators = [op(mongoLogId(1001000123), ([provider]) => {
|
|
1140
|
+
_databaseStats_decorators = [op((0, logger_1.mongoLogId)(1001000057))];
|
|
1141
|
+
_createDataKey_decorators = [op((0, logger_1.mongoLogId)(1001000123), ([provider]) => {
|
|
1077
1142
|
return { provider };
|
|
1078
1143
|
})];
|
|
1079
1144
|
__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);
|
|
@@ -1097,6 +1162,8 @@ let DataServiceImpl = (() => {
|
|
|
1097
1162
|
__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);
|
|
1098
1163
|
__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);
|
|
1099
1164
|
__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);
|
|
1165
|
+
__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);
|
|
1166
|
+
__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);
|
|
1100
1167
|
__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);
|
|
1101
1168
|
__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);
|
|
1102
1169
|
__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);
|