Socket
Socket
Sign inDemoInstall

@oridune/epic-odm

Package Overview
Dependencies
3
Maintainers
2
Versions
81
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.6 to 1.1.7

2

package.json
{
"name": "@oridune/epic-odm",
"version": "1.1.6",
"version": "1.1.7",
"description": "Install 1 ODM and code once with any database driver.",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -8,4 +8,4 @@ import * as mongodb from "mongodb";

Config: mongodb.MongoClientOptions;
Logs: boolean;
constructor(models: (typeof BaseModel | Promise<typeof BaseModel>)[], uri: string, Config?: mongodb.MongoClientOptions, Logs?: boolean);
Logs: boolean | ((logs: any) => void);
constructor(models: (typeof BaseModel | Promise<typeof BaseModel>)[], uri: string, Config?: mongodb.MongoClientOptions, Logs?: boolean | ((logs: any) => void));
createConnection(config: DatabaseConfiguration): Promise<mongodb.MongoClient>;

@@ -12,0 +12,0 @@ closeConnection(connectionObject: C): Promise<void>;

@@ -285,7 +285,12 @@ "use strict";

// Create New Connection
const Connection = await new mongodb.MongoClient(config.uri, Object.assign(Object.assign({}, this.Config), { monitorCommands: this.Logs })).connect();
const Connection = await new mongodb.MongoClient(config.uri, Object.assign(Object.assign({}, this.Config), { monitorCommands: !!this.Logs })).connect();
// MongoDB Logs
if (this.Logs) {
require("mongodb").Logger.setLevel("debug");
Connection.on("commandStarted", (event) => console.log(JSON.stringify(event.command, undefined, 2)));
Connection.on("commandStarted", (logs) => {
if (typeof this.Logs === "function")
this.Logs(logs);
else
console.log(JSON.stringify(logs.command, undefined, 2));
});
}

@@ -292,0 +297,0 @@ return Connection;

@@ -14,3 +14,3 @@ import { GraphQLObjectType, GraphQLList } from "graphql";

/** List of String choices */
choices?: Array<string>;
choices?: Array<string> | (() => Array<string>);
/** Set if the value is immutable? */

@@ -17,0 +17,0 @@ immutable?: boolean;

@@ -49,6 +49,9 @@ "use strict";

!(value instanceof operators_1.Operator)) {
const Choices = typeof options.choices === "function"
? options.choices()
: options.choices;
// Enum Validation
if (options.choices instanceof Array)
if (!options.choices.includes(value))
throw new Error(`Invalid value '${value}' has been provided for field '${name}'! Allowed values are (${options.choices.join(", ")}).`);
if (Choices instanceof Array)
if (!Choices.includes(value))
throw new Error(`Invalid value '${value}' has been provided for field '${name}'! Allowed values are (${Choices.join(", ")}).`);
// Match Regex

@@ -95,3 +98,3 @@ if (options.match instanceof RegExp && !options.match.test(value))

options.type =
options.choices instanceof Array
options.choices instanceof Array || typeof options.choices === "function"
? String

@@ -107,5 +110,8 @@ : options.type ||

else if (options.type === String &&
options.choices instanceof Array &&
options.length === undefined)
options.length = Math.max(...options.choices.map((c) => c.toString().length));
(options.choices instanceof Array ||
typeof options.choices === "function") &&
options.length === undefined) {
const Choices = options.choices instanceof Array ? options.choices : options.choices();
options.length = Math.max(...Choices.map((c) => c.toString().length));
}
else if (options.type === Object && options.length === undefined)

@@ -112,0 +118,0 @@ options.length = null;

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc