New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@synatic/noql

Package Overview
Dependencies
Maintainers
0
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@synatic/noql - npm Package Compare versions

Comparing version

to
4.1.10

72

lib/make/optimize-join-and-where.js

@@ -596,8 +596,22 @@ const {snakeCase} = require('lodash');

function getMatches(matches, sourceName, destinationName, parentMatchType) {
const sourceMatches = matches.filter((m) =>
Object.keys(m)[0].startsWith(`${sourceName}.`)
);
const destinationMatches = matches.filter((m) =>
Object.keys(m)[0].startsWith(`${destinationName}.`)
);
const sourceMatches = matches.filter((m) => {
if (m.$expr) {
return checkExpressionForString(
m.$expr,
`${sourceName}.`,
`${destinationName}.`
);
}
return Object.keys(m)[0].startsWith(`${sourceName}.`);
});
const destinationMatches = matches.filter((m) => {
if (m.$expr) {
return checkExpressionForString(
m.$expr,
`${destinationName}.`,
`${sourceName}.`
);
}
return Object.keys(m)[0].startsWith(`${destinationName}.`);
});
const miscMatches = matches.filter((m) => {

@@ -628,2 +642,48 @@ const key = Object.keys(m)[0];

*
* @param expression
* @param mustContain
* @param mustNotContain
*/
function checkExpressionForString(expression, mustContain, mustNotContain) {
let expressionArray;
if (expression.$and) {
expressionArray = expression.$and;
} else if (expression.$or) {
expressionArray = expression.$or;
} else {
return false;
}
const containsRequired = expressionContains(expressionArray, mustContain);
const containsNotAllowed = expressionContains(
expressionArray,
mustNotContain
);
if (containsNotAllowed) {
return false;
}
return containsRequired;
}
/**
*
* @param {Record<string,unknown>[]} expression
* @param {string} searchString
* @returns {boolean}
*/
function expressionContains(expression, searchString) {
return expression.some((e) => {
if (typeof e === 'string') {
return (
e.startsWith(searchString) || e.startsWith(`$${searchString}`)
);
}
if ($check.object(e)) {
const values = Object.values(e).flat();
return expressionContains(values, searchString);
}
});
}
/**
*
* @param match

@@ -630,0 +690,0 @@ * @param {string} sourceName

2

package.json
{
"name": "@synatic/noql",
"version": "4.1.9",
"version": "4.1.10",
"description": "Convert SQL statements to mongo queries or aggregates",

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