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

@mongosh/service-provider-core

Package Overview
Dependencies
Maintainers
8
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.2.2 to 0.3.0

8

lib/admin.d.ts

@@ -6,2 +6,6 @@ import Result from './result';

import DatabaseOptions from './database-options';
import ReadPreference from './read-preference';
import ReadConcern from './read-concern';
import WriteConcern from './write-concern';
import Document from './document';
export default interface Admin {

@@ -18,2 +22,6 @@ platform: ReplPlatform;

createCollection(dbName: string, collName: string, opts: CollectionOptions, dbOptions?: DatabaseOptions): Promise<any>;
getReadPreference(): ReadPreference;
getReadConcern(): ReadConcern | undefined;
getWriteConcern(): WriteConcern | undefined;
resetConnectionOptions(options: Document): Promise<void>;
}

2

lib/cursor.d.ts

@@ -54,2 +54,4 @@ import Document from './document';

explain(verbosity: string): Promise<any>;
showRecordId(recordId: boolean): ServiceProviderCursor;
bufferedCount(): number;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CURSOR_FLAGS = void 0;
exports.CURSOR_FLAGS = {

@@ -4,0 +5,0 @@ 2: "tailable",

3

lib/index.d.ts

@@ -8,2 +8,3 @@ import ServiceProvider, { ServiceProviderCore } from './service-provider';

import ReadConcern from './read-concern';
import ReadPreference, { ReadPreferenceMode } from './read-preference';
import CommandOptions from './command-options';

@@ -20,2 +21,2 @@ import BaseOptions from './base-options';

import ServiceProviderBulkOp, { ServiceProviderBulkFindOp, BulkBatch } from './bulk';
export { ServiceProvider, BulkWriteResult, Document, Cursor, CursorFlag, CURSOR_FLAGS, Result, ReadConcern, WriteConcern, CommandOptions, BaseOptions, AuthOptions, DatabaseOptions, getConnectInfo, ReplPlatform, CliOptions, generateUri, Scheme, DEFAULT_DB, ServiceProviderCore, bson, ServiceProviderBulkFindOp, ServiceProviderBulkOp, BulkBatch };
export { ServiceProvider, BulkWriteResult, Document, Cursor, CursorFlag, CURSOR_FLAGS, Result, ReadConcern, WriteConcern, ReadPreference, ReadPreferenceMode, CommandOptions, BaseOptions, AuthOptions, DatabaseOptions, getConnectInfo, ReplPlatform, CliOptions, generateUri, Scheme, DEFAULT_DB, ServiceProviderCore, bson, ServiceProviderBulkFindOp, ServiceProviderBulkOp, BulkBatch };
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.bson = exports.ServiceProviderCore = exports.DEFAULT_DB = exports.Scheme = exports.generateUri = exports.ReplPlatform = exports.getConnectInfo = exports.ReadPreferenceMode = exports.CURSOR_FLAGS = void 0;
var service_provider_1 = require("./service-provider");
exports.ServiceProviderCore = service_provider_1.ServiceProviderCore;
Object.defineProperty(exports, "ServiceProviderCore", { enumerable: true, get: function () { return service_provider_1.ServiceProviderCore; } });
var cursor_1 = require("./cursor");
exports.CURSOR_FLAGS = cursor_1.CURSOR_FLAGS;
Object.defineProperty(exports, "CURSOR_FLAGS", { enumerable: true, get: function () { return cursor_1.CURSOR_FLAGS; } });
var read_preference_1 = require("./read-preference");
Object.defineProperty(exports, "ReadPreferenceMode", { enumerable: true, get: function () { return read_preference_1.ReadPreferenceMode; } });
var connect_info_1 = __importDefault(require("./connect-info"));
exports.getConnectInfo = connect_info_1.default;
var platform_1 = require("./platform");
exports.ReplPlatform = platform_1.ReplPlatform;
Object.defineProperty(exports, "ReplPlatform", { enumerable: true, get: function () { return platform_1.ReplPlatform; } });
var uri_generator_1 = __importStar(require("./uri-generator"));
exports.generateUri = uri_generator_1.default;
exports.Scheme = uri_generator_1.Scheme;
Object.defineProperty(exports, "Scheme", { enumerable: true, get: function () { return uri_generator_1.Scheme; } });
var DEFAULT_DB = 'test';

@@ -25,0 +40,0 @@ exports.DEFAULT_DB = DEFAULT_DB;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReplPlatform = void 0;
var ReplPlatform;

@@ -4,0 +5,0 @@ (function (ReplPlatform) {

@@ -56,7 +56,20 @@ "use strict";

bson.Long.prototype[toString] = function () {
return "NumberLong(" + this.toNumber() + ")";
return "NumberLong(\"" + this.toString() + "\")";
};
bson.Long.prototype.asPrintable = bson.Long.prototype[toString];
bson.Binary.prototype[toString] = function () {
return "BinData(" + this.sub_type + ", \"" + this.value() + "\")";
var asBuffer = this.value(true);
switch (this.sub_type) {
case bson.Binary.SUBTYPE_MD5:
return "MD5(\"" + asBuffer.toString('hex') + "\")";
case bson.Binary.SUBTYPE_UUID:
if (asBuffer.length === 16) {
var hex = asBuffer.toString('hex');
var asUUID = hex.match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/)
.slice(1, 6).join('-');
return "UUID(\"" + asUUID + "\")";
}
default:
return "BinData(" + this.sub_type + ", \"" + asBuffer.toString('base64') + "\")";
}
};

@@ -63,0 +76,0 @@ bson.Binary.prototype.asPrintable = bson.Binary.prototype[toString];

@@ -0,3 +1,10 @@

export declare enum ReadConcernLevel {
local = "local",
majority = "majority",
linearizable = "linearizable",
available = "available",
snapshot = "snapshot"
}
export default interface ReadConcern {
level: string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReadConcernLevel = void 0;
var ReadConcernLevel;
(function (ReadConcernLevel) {
ReadConcernLevel["local"] = "local";
ReadConcernLevel["majority"] = "majority";
ReadConcernLevel["linearizable"] = "linearizable";
ReadConcernLevel["available"] = "available";
ReadConcernLevel["snapshot"] = "snapshot";
})(ReadConcernLevel = exports.ReadConcernLevel || (exports.ReadConcernLevel = {}));
//# sourceMappingURL=read-concern.js.map

@@ -0,4 +1,11 @@

export declare enum ReadPreferenceMode {
primary = "primary",
primaryPreferred = "primaryPreferred",
secondary = "secondary",
secondaryPreferred = "secondaryPreferred",
nearest = "nearest"
}
export default interface ReadPreference {
mode: string;
mode: ReadPreferenceMode;
tags?: Record<string, string>[];
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReadPreferenceMode = void 0;
var ReadPreferenceMode;
(function (ReadPreferenceMode) {
ReadPreferenceMode["primary"] = "primary";
ReadPreferenceMode["primaryPreferred"] = "primaryPreferred";
ReadPreferenceMode["secondary"] = "secondary";
ReadPreferenceMode["secondaryPreferred"] = "secondaryPreferred";
ReadPreferenceMode["nearest"] = "nearest";
})(ReadPreferenceMode = exports.ReadPreferenceMode || (exports.ReadPreferenceMode = {}));
//# sourceMappingURL=read-preference.js.map

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.ServiceProviderCore = void 0;
var printable_bson_1 = __importDefault(require("./printable-bson"));

@@ -8,0 +9,0 @@ var errors_1 = require("@mongosh/errors");

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.Scheme = void 0;
var i18n_1 = __importDefault(require("@mongosh/i18n"));

@@ -54,2 +55,5 @@ var index_1 = require("./index");

var parts = uriMatch.exec(uri);
if (parts === null) {
throw new errors_1.MongoshInvalidInputError("Invalid URI: " + uri);
}
var host = parts[1];

@@ -56,0 +60,0 @@ var port = parts[2];

@@ -9,2 +9,3 @@ import Document from './document';

runCommand(db: string, spec: Document, options?: CommandOptions, dbOptions?: DatabaseOptions): Promise<Result>;
runCommandWithCheck(db: string, spec: Document, options?: CommandOptions, dbOptions?: DatabaseOptions): Promise<Result>;
dropDatabase(database: string, writeConcern?: WriteConcern, dbOptions?: DatabaseOptions): Promise<Result>;

@@ -11,0 +12,0 @@ bulkWrite(database: string, collection: string, requests: Document, options?: Document, dbOptions?: DatabaseOptions): Promise<BulkWriteResult>;

{
"name": "@mongosh/service-provider-core",
"version": "0.2.2",
"version": "0.3.0",
"description": "MongoDB Shell Core Service Provider Package",

@@ -30,4 +30,4 @@ "main": "lib/index.js",

"dependencies": {
"@mongosh/errors": "^0.2.2",
"@mongosh/i18n": "^0.2.2",
"@mongosh/errors": "^0.3.0",
"@mongosh/i18n": "^0.3.0",
"bson": "4.0.4",

@@ -48,3 +48,3 @@ "mongodb-build-info": "^1.0.0"

},
"gitHead": "4e188a4336bb5f57bc2431811e54b90bf83b1cdf"
"gitHead": "decab9f8f132403125d7084922a0b7a84afc8098"
}

@@ -6,2 +6,6 @@ import Result from './result';

import DatabaseOptions from './database-options';
import ReadPreference from './read-preference';
import ReadConcern from './read-concern';
import WriteConcern from './write-concern';
import Document from './document';

@@ -69,2 +73,24 @@ export default interface Admin {

createCollection(dbName: string, collName: string, opts: CollectionOptions, dbOptions?: DatabaseOptions): Promise<any>;
/**
* Return read preference for connection.
*/
getReadPreference(): ReadPreference;
/**
* Return read concern for connection.
*/
getReadConcern(): ReadConcern | undefined;
/**
* Return write concern for connection.
*/
getWriteConcern(): WriteConcern | undefined;
/**
* Reset the connection to have the option specified.
*
* @param options
*/
resetConnectionOptions(options: Document): Promise<void>;
}

@@ -265,3 +265,13 @@ import Document from './document';

explain(verbosity: string): Promise<any>;
/**
* Set the showRecordId flag to true.
*/
showRecordId(recordId: boolean): ServiceProviderCursor;
/**
* Current buffered documents length.
*/
bufferedCount(): number;
}

@@ -8,2 +8,3 @@ import ServiceProvider, { ServiceProviderCore } from './service-provider';

import ReadConcern from './read-concern';
import ReadPreference, { ReadPreferenceMode } from './read-preference';
import CommandOptions from './command-options';

@@ -31,2 +32,4 @@ import BaseOptions from './base-options';

WriteConcern,
ReadPreference,
ReadPreferenceMode,
CommandOptions,

@@ -33,0 +36,0 @@ BaseOptions,

@@ -68,3 +68,3 @@ import BSON from 'bson';

bson.Long.prototype[toString] = function(): string {
return `NumberLong(${this.toNumber()})`;
return `NumberLong("${this.toString()}")`;
};

@@ -74,5 +74,23 @@ bson.Long.prototype.asPrintable = bson.Long.prototype[toString];

bson.Binary.prototype[toString] = function(): string {
return `BinData(${this.sub_type}, "${this.value()}")`;
const asBuffer = this.value(true);
switch (this.sub_type) {
case bson.Binary.SUBTYPE_MD5:
return `MD5("${asBuffer.toString('hex')}")`;
case bson.Binary.SUBTYPE_UUID:
if (asBuffer.length === 16) {
// Format '0123456789abcdef0123456789abcdef' into
// '01234567-89ab-cdef-0123-456789abcdef'.
const hex = asBuffer.toString('hex');
const asUUID = hex.match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/)
.slice(1, 6).join('-');
return `UUID("${asUUID}")`;
}
// Fall through in case somebody did something weird and used an UUID
// with a non-standard length.
// eslint-disable-next-line no-fallthrough
default:
return `BinData(${this.sub_type}, "${asBuffer.toString('base64')}")`;
}
};
bson.Binary.prototype.asPrintable = bson.Binary.prototype[toString];
}

@@ -0,3 +1,11 @@

export enum ReadConcernLevel {
local = 'local',
majority = 'majority',
linearizable = 'linearizable',
available = 'available',
snapshot = 'snapshot'
}
export default interface ReadConcern {
level: string;
}

@@ -0,4 +1,12 @@

export enum ReadPreferenceMode {
primary = 'primary',
primaryPreferred = 'primaryPreferred',
secondary = 'secondary',
secondaryPreferred = 'secondaryPreferred',
nearest = 'nearest'
}
export default interface ReadPreference {
mode: string;
mode: ReadPreferenceMode;
tags?: Record<string, string>[];
}

@@ -149,2 +149,12 @@ import generateUri from './uri-generator';

});
context('when an invalid URI is provided', () => {
const uri = '/x';
const options = { _: [ uri ] };
it('returns the uri', () => {
expect(() => generateUri(options)).to.throw('Invalid URI: /x');
});
});
});

@@ -124,2 +124,6 @@ /* eslint complexity: 0*/

if (parts === null) {
throw new MongoshInvalidInputError(`Invalid URI: ${uri}`);
}
let host = parts[1];

@@ -126,0 +130,0 @@ const port = parts[2];

@@ -28,2 +28,16 @@ import Document from './document';

/**
* @param {String} db - the db name
* @param spec
* @param options
* @param {DatabaseOptions} dbOptions - The database options
* @return {Promise<Result>}
*/
runCommandWithCheck(
db: string,
spec: Document,
options?: CommandOptions,
dbOptions?: DatabaseOptions
): Promise<Result>;
/**
* Drop a database

@@ -30,0 +44,0 @@ *

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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