Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mongosh/service-provider-server

Package Overview
Dependencies
Maintainers
7
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mongosh/service-provider-server - npm Package Compare versions

Comparing version 0.0.1-alpha.13 to 0.0.1-alpha.14

7

lib/compass-service-provider.d.ts
import CliServiceProvider from './cli-service-provider';
import { MongoClient } from 'mongodb';
interface DataService {
client: {
client: MongoClient;
};
}
declare class CompassServiceProvider extends CliServiceProvider {
static fromDataService(dataService: DataService): CompassServiceProvider;
}
export default CompassServiceProvider;

7

lib/compass-service-provider.js

@@ -20,3 +20,2 @@ "use strict";

var cli_service_provider_1 = __importDefault(require("./cli-service-provider"));
var mongosh_transport_server_1 = require("mongosh-transport-server");
var CompassServiceProvider = (function (_super) {

@@ -27,10 +26,6 @@ __extends(CompassServiceProvider, _super);

}
CompassServiceProvider.fromDataService = function (dataService) {
var mongoClient = dataService.client.client;
var nodeTransport = new mongosh_transport_server_1.NodeTransport(mongoClient);
return new CompassServiceProvider(nodeTransport);
};
return CompassServiceProvider;
}(cli_service_provider_1.default));
;
exports.default = CompassServiceProvider;
//# sourceMappingURL=compass-service-provider.js.map

1

lib/node/node-cursor.d.ts

@@ -49,4 +49,5 @@ import { CollationDocument } from 'mongodb';

private addFlag;
explain(verbosity: string): Promise<any>;
}
export default NodeCursor;
export { Flag };
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -214,2 +225,26 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
NodeCursor.prototype.explain = function (verbosity) {
return __awaiter(this, void 0, void 0, function () {
var fullExplain, explain;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, this.cursor.explain()];
case 1:
fullExplain = _a.sent();
explain = __assign({}, fullExplain);
if (verbosity !== 'executionStats' &&
verbosity !== 'allPlansExecution' &&
explain.executionStats) {
delete explain.executionStats;
}
if (verbosity === 'executionStats' &&
explain.executionStats &&
explain.executionStats.allPlansExecution) {
delete explain.executionStats.allPlansExecution;
}
return [2, explain];
}
});
});
};
return NodeCursor;

@@ -216,0 +251,0 @@ }());

{
"name": "@mongosh/service-provider-server",
"version": "0.0.1-alpha.13",
"version": "0.0.1-alpha.14",
"description": "MongoDB Shell Server Service Provider Package",

@@ -42,6 +42,6 @@ "main": "lib/index.js",

"dependencies": {
"@mongosh/service-provider-core": "^0.0.1-alpha.13",
"@mongosh/service-provider-core": "^0.0.1-alpha.14",
"mongodb": "3.5.3 || ^3.5.5"
},
"gitHead": "cbd3d640a1a089fd677f7136e3d80f70bce7633f"
"gitHead": "d505622df7589da25592a1abfe62cb76de702b3b"
}

@@ -494,2 +494,84 @@ import NodeCursor, { Flag } from './node-cursor';

});
describe('#explain', () => {
let nativeCursorStub;
let nodeCursor;
let mock;
beforeEach(() => {
mock = sinon.mock().resolves({
queryPlanner: { },
executionStats: {
allPlansExecution: [ ]
},
serverInfo: { },
ok: 1
});
nativeCursorStub = sinon.createStubInstance(Cursor, {
explain: mock
});
nodeCursor = new NodeCursor(nativeCursorStub);
});
it('calls explain on the native cursor', async() => {
await nodeCursor.explain();
mock.verify();
});
it('does not throw if executionStats is missing', async() => {
mock.resolves({
queryPlanner: { },
serverInfo: { },
ok: 1
});
await nodeCursor.explain();
});
context('with empty verbosity', () => {
it('filters out executionStats', async() => {
expect(await nodeCursor.explain()).to.deep.equal({
queryPlanner: { },
serverInfo: { },
ok: 1
});
});
});
context('with verbosity = queryPlanner', () => {
it('filters out executionStats', async() => {
expect(await nodeCursor.explain('queryPlanner')).to.deep.equal({
queryPlanner: { },
serverInfo: { },
ok: 1
});
});
});
context('with verbosity = executionStats', () => {
it('filters out allPlansExecution', async() => {
expect(await nodeCursor.explain('executionStats')).to.deep.equal({
queryPlanner: { },
executionStats: { },
serverInfo: { },
ok: 1
});
});
});
context('with verbosity = allPlansExecution', () => {
it('returns everything', async() => {
expect(await nodeCursor.explain('allPlansExecution')).to.deep.equal({
queryPlanner: { },
executionStats: {
allPlansExecution: [ ]
},
serverInfo: { },
ok: 1
});
});
});
});
});

@@ -380,2 +380,31 @@ import { Cursor as NativeCursor, CollationDocument } from 'mongodb';

}
// TODO: we should probably move this in the mapper
// layer
async explain(verbosity: string): Promise<any> {
// NOTE: the node driver always returns the full explain plan
// for Cursor and the queryPlanner explain for AggregationCursor.
const fullExplain = await this.cursor.explain();
const explain: any = {
...fullExplain
};
if (
verbosity !== 'executionStats' &&
verbosity !== 'allPlansExecution' &&
explain.executionStats
) {
delete explain.executionStats;
}
if (verbosity === 'executionStats' &&
explain.executionStats &&
explain.executionStats.allPlansExecution) {
delete explain.executionStats.allPlansExecution;
}
return explain;
}
}

@@ -382,0 +411,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc