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

@openreply/aql

Package Overview
Dependencies
Maintainers
21
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openreply/aql - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

23

lib/operators.js

@@ -151,2 +151,6 @@ 'use strict';

/**
* @deprecated since string and array are not handled everywhere the same, includesItem (for array)
* and contains (for string,number) should be used
*/
const includes = new Operator((evaluateSubexpression, collection, options, path, expectedValue) =>

@@ -157,3 +161,3 @@ collection.filter((item) => {

((_.isString(actualValue) || _.isNumber(actualValue))
&& _.toString(actualValue).includes(expectedValue))
&& _.toString(actualValue).includes(expectedValue))
|| (_.isArray(actualValue) && _.includes(actualValue, expectedValue));

@@ -163,2 +167,17 @@ return test(actualValues, condition, options);

const includesItem = new Operator((evaluateSubexpression, collection, options, path, expectedValue) =>
collection.filter((item) => {
const actualValues = queryPath(item, path, options);
const condition = (actualValue) => _.isArray(actualValue) && _.includes(actualValue, expectedValue);
return test(actualValues, condition, options);
}));
const contains = new Operator((evaluateSubexpression, collection, options, path, expectedValue) =>
collection.filter((item) => {
const actualValues = queryPath(item, path, options);
const condition = (actualValue) => (_.isString(actualValue) || _.isNumber(actualValue))
&& _.toString(actualValue).includes(expectedValue);
return test(actualValues, condition, options);
}));
const and = new Operator((evaluateSubexpression, collection, options, ...subexpressions) => {

@@ -188,2 +207,4 @@ const subexpressionResults = subexpressions.map((e) => evaluateSubexpression(collection, e, options));

includes,
includesItem,
contains,
and,

@@ -190,0 +211,0 @@ or,

4

package.json
{
"name": "@openreply/aql",
"version": "2.0.0",
"version": "2.1.0",
"description": "API Query Language - parser and filter",

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

"jsonpath": "^1.0.2",
"lodash": "^4.17.15",
"lodash": "^4.17.20",
"ohm-js": "^0.14.0"
}
}

@@ -162,3 +162,3 @@ 'use strict';

it('includes without spaces', () => {
it('DEPRECATED: includes without spaces', () => {
const conditionString = 'includes(name, e)';

@@ -170,3 +170,3 @@

it('includes with spaces', () => {
it('DEPRECATED: includes with spaces', () => {
const conditionString = 'includes(name, bc de)';

@@ -180,2 +180,19 @@ const matchingValue = { name: 'abc def' };

});
it('contains without spaces', () => {
const conditionString = 'contains(name, e)';
const filtered = filter(conditionString)(testCollection);
expect(filtered).to.deep.equal([def]);
});
it('contains with spaces', () => {
const conditionString = 'contains(name, bc de)';
const matchingValue = { name: 'abc def' };
const nonMatchingValue = { name: 'ghi' };
const customTestCollection = [matchingValue, nonMatchingValue];
const filtered = filter(conditionString)(customTestCollection);
expect(filtered).to.deep.equal([matchingValue]);
});
});

@@ -245,3 +262,3 @@

it('includes', () => {
it('DEPRECATED: includes', () => {
const conditionString = 'includes(number, 5)';

@@ -252,2 +269,9 @@

});
it('contains', () => {
const conditionString = 'contains(number, 5)';
const filtered = filter(conditionString)(testCollection);
expect(filtered).to.deep.equal([num456]);
});
});

@@ -401,3 +425,3 @@

it('includes: deep array', () => {
it('DEPRECATED: includes: deep array', () => {
const conditionString = 'includes(array.*.name, abc)';

@@ -409,3 +433,3 @@

it('includes: simple array', () => {
it('DEPRECATED: includes: simple array', () => {
const conditionString = 'includes(array, abc)';

@@ -420,2 +444,12 @@ const stringValue = { array: ['abc', 'def', 'ghi'] };

it('includesItem: simple array', () => {
const conditionString = 'includesItem(array, abc)';
const stringValue = { array: ['abc', 'def', 'ghi'] };
const numberValue = { array: [123, 456, 789] };
const customTestCollection = [stringValue, numberValue];
const filtered = filter(conditionString)(customTestCollection);
expect(filtered).to.deep.equal([stringValue]);
});
it('in', () => {

@@ -422,0 +456,0 @@ const conditionString = 'in(array.*.name, abc)';

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