Socket
Socket
Sign inDemoInstall

@mongosh/types

Package Overview
Dependencies
Maintainers
11
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mongosh/types - npm Package Compare versions

Comparing version 0.13.2 to 0.14.0

2

lib/index.d.ts

@@ -71,3 +71,2 @@ export interface ApiEventArguments {

'mongosh:error': (error: Error) => void;
'mongosh:help': () => void;
'mongosh:evaluate-input': (ev: EvaluateInputEvent) => void;

@@ -112,2 +111,3 @@ 'mongosh:evaluate-finished': () => void;

disableGreetingMessage: boolean;
inspectCompact: number | boolean;
inspectDepth: number;

@@ -114,0 +114,0 @@ historyLength: number;

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

this.disableGreetingMessage = false;
this.inspectCompact = 3;
this.inspectDepth = 6;

@@ -48,2 +49,7 @@ this.historyLength = 1000;

return null;
case 'inspectCompact':
if (typeof value !== 'boolean' && (typeof value !== 'number' || value < 0)) {
return `${key} must be a boolean or a positive integer`;
}
return null;
case 'inspectDepth':

@@ -50,0 +56,0 @@ case 'historyLength':

{
"name": "@mongosh/types",
"version": "0.13.2",
"version": "0.14.0",
"description": "Types for mongosh internals",

@@ -31,3 +31,3 @@ "author": "Anna Henningsen <anna.henningsen@mongodb.com>",

},
"gitHead": "7517f44ef756760060666c20f0de964564fb3aa2"
"gitHead": "39df2de64c8448b4afaee905a038d615345a1e44"
}

@@ -1,2 +0,2 @@

import { CliUserConfigValidator } from './';
import { CliUserConfig, CliUserConfigValidator } from './';
import { expect } from 'chai';

@@ -32,3 +32,15 @@

expect(await validate('enableTelemetry', true)).to.equal(null);
expect(await validate('inspectCompact', 'foo')).to.equal('inspectCompact must be a boolean or a positive integer');
expect(await validate('inspectCompact', -1)).to.equal('inspectCompact must be a boolean or a positive integer');
expect(await validate('inspectCompact', false)).to.equal(null);
expect(await validate('inspectCompact', true)).to.equal(null);
expect(await validate('inspectCompact', 32)).to.equal(null);
});
it('allows default CliUserConfig values', async() => {
const userConfig = new CliUserConfig();
for (const key of Object.keys(userConfig) as (keyof CliUserConfig)[]) {
expect(await CliUserConfigValidator.validate(key, userConfig[key])).to.equal(null);
}
});
});

@@ -80,31 +80,127 @@ /* eslint camelcase: 0 */

export interface MongoshBusEventsMap {
/**
* Signals a connection to a MongoDB instance has been established
* or the used database changed.
*/
'mongosh:connect': (ev: ConnectEvent) => void;
/**
* Signals the creation of a new Mongo client with metadata provided
* by the underlying driver implementation.
*/
'mongosh:driver-initialized': (driverMetadata: any) => void;
/**
* Signals that the shell is started by a new user.
*/
'mongosh:new-user': (id: string, enableTelemetry: boolean) => void;
/**
* Signals a change of the user telemetry settings.
*/
'mongosh:update-user': (id: string, enableTelemetry: boolean) => void;
/**
* Signals an error that should be logged or potentially tracked by analytics.
*/
'mongosh:error': (error: Error) => void;
'mongosh:help': () => void;
'mongosh:evaluate-input': (ev: EvaluateInputEvent) => void; // fired before user code is evaluated in ShellEvaluator
'mongosh:evaluate-finished': () => void; // fired when the code evaluation is completed (regardless of success / error / interrupt) in AsyncRepl
/**
* Signals the start of the evaluation of user code inside Shellevaluator.
*/
'mongosh:evaluate-input': (ev: EvaluateInputEvent) => void;
/**
* Signals the completion of the evaluation of user code in AsyncRepl (final step of the evaluation)
* regardless of success, error, or being interrupted.
*/
'mongosh:evaluate-finished': () => void;
/**
* Signals a user used the `use` command.
*/
'mongosh:use': (ev: UseEvent) => void;
/**
* Signals a user used the `Mongo.getDB` method.
*/
'mongosh:getDB': (ev: UseEvent) => void;
/**
* Signals a user used the `show` command.
*/
'mongosh:show': (ev: ShowEvent) => void;
/**
* Signals the global context for the shell evaluation has been initialized.
*/
'mongosh:setCtx': (ev: ApiEvent) => void;
/**
* Signals usage of a shell API method.
*/
'mongosh:api-call': (ev: ApiEvent) => void;
/**
* Signals usage of a deprecated shell API method.
*/
'mongosh:deprecated-api-call': (ev: ApiEvent) => void;
/**
* Signals an error for an operation that we can silently ignore but still warn about.
*/
'mongosh:warn': (ev: ApiWarning) => void;
/**
* Signals the use of the `load` feature to load a file for evaluation.
*/
'mongosh:api-load-file': (ev: ScriptLoadFileEvent) => void;
/**
* Signals the start of loading external files upon startup.
*/
'mongosh:start-loading-cli-scripts': (event: StartLoadingCliScriptsEvent) => void;
/**
* Signals the successful startup of the mongosh REPL after initial files and configuration
* have been loaded.
*/
'mongosh:start-mongosh-repl': (ev: StartMongoshReplEvent) => void;
/**
* Signals the start of loading a mongosh configuration file.
*/
'mongosh:mongoshrc-load': () => void;
/**
* Signals the detection of a legacy `mongo` configuration file or a misnamed mongosh configuration file.
*/
'mongosh:mongoshrc-mongorc-warn': () => void;
/**
* Signals the start of the evaluation of a script provided by the --eval CLI option.
*/
'mongosh:eval-cli-script': () => void;
/**
* Signals the completion of asynchronous user code execution due to the internal interrupt exception
* caused by CTRL-C.
* Not fired for interrupts of _synchronous_ code.
*/
'mongosh:eval-interrupted': () => void;
/**
* Signals the start of trying to spawn a `mongocryptd` process.
*/
'mongosh:mongocryptd-tryspawn': (ev: MongocryptdTrySpawnEvent) => void;
/**
* Signals an error while interfacing with a `mongocryptd` process.
*/
'mongosh:mongocryptd-error': (ev: MongocryptdErrorEvent) => void;
/**
* Signals an event to be logged for a `mongocryptd` process.
*/
'mongosh:mongocryptd-log': (ev: MongocryptdLogEvent) => void;
'mongosh:closed': () => void; // For testing.
'mongosh:eval-complete': () => void; // For testing - fired when the code evaluation in MongoshRepl finishes
'mongosh:autocompletion-complete': () => void; // For testing.
'mongosh:interrupt-complete': () => void; // For testing - fired when the interrupt code in MongoshRepl finishes
/**
* Signals that the CLI REPL's `close` method has completed.
* _ONLY AVAILABLE FOR TESTING._
*/
'mongosh:closed': () => void;
/**
* Signals the completion of executing user code in MongoshRepl. Not fired for nested `load` evaluations.
*
* Note: When the evaluation of user code returns an error, the `mongosh:error` event is fired _after_ this event.
*
* _ONLY AVAILABLE FOR TESTING._
*/
'mongosh:eval-complete': () => void;
/**
* Signals the completion of the autocomplete suggestion providers.
* _ONLY AVAILABLE FOR TESTING._
*/
'mongosh:autocompletion-complete': () => void;
/**
* Signals the completion of the asynchronous interrupt handler in MongoshRepl. Not fired for interrupts of _synchronous_ code.
* _ONLY AVAILABLE FOR TESTING._
*/
'mongosh:interrupt-complete': () => void;
}

@@ -146,2 +242,3 @@

disableGreetingMessage = false;
inspectCompact: number | boolean = 3;
inspectDepth = 6;

@@ -153,2 +250,3 @@ historyLength = 1000;

export class CliUserConfigValidator extends ShellUserConfigValidator {
// eslint-disable-next-line complexity
static async validate<K extends keyof CliUserConfig>(key: K, value: CliUserConfig[K]): Promise<string | null> {

@@ -159,2 +257,7 @@ switch (key) {

return null; // Not modifiable by the user anyway.
case 'inspectCompact':
if (typeof value !== 'boolean' && (typeof value !== 'number' || value < 0)) {
return `${key} must be a boolean or a positive integer`;
}
return null;
case 'inspectDepth':

@@ -161,0 +264,0 @@ case 'historyLength':

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