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

@json-api/query-parser

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@json-api/query-parser - npm Package Compare versions

Comparing version 0.2.5 to 1.0.0

16

build/src/helpers.js

@@ -40,6 +40,14 @@ "use strict";

}
throw new SyntaxError("Field expressions must have a valid operator symbol as their first or " +
"second item, or must be a two-item list without any operators (in " +
"in which case the `eq` operator is inferred). If a binary operator is " +
"used explicitly, the expression must have exactly three items.");
if (exports.isBinaryOperator(operators, list[1])) {
throw new SyntaxError(`"${list[1].value}" is a binary operator, so the field expression ` +
"must have exactly three items.");
}
if (exports.isBinaryOperator(operators, list[0])) {
throw new SyntaxError(`"${list[0].value}" is a binary operator, so it must be infixed as ` +
"the second item in your field expression.");
}
throw new SyntaxError("Field expressions must have a valid operator symbol as their first " +
"item (for non-binary operators) or second item (for binary operators), " +
"or must be a two-item list without any operators (in which case the " +
"`eq` operator is inferred).");
});

@@ -191,6 +191,6 @@ /*

},
peg$c29 = "'",
peg$c30 = peg$literalExpectation("'", false),
peg$c31 = /^[^']/,
peg$c32 = peg$classExpectation(["'"], true, false),
peg$c29 = "!",
peg$c30 = peg$literalExpectation("!", false),
peg$c31 = /^[^!]/,
peg$c32 = peg$classExpectation(["!"], true, false),
peg$c33 = peg$otherExpectation("symbol (i.e., a field or operator name)"),

@@ -224,4 +224,4 @@ peg$c34 = /^[0-9\-.]/,

},
peg$c53 = /^[^()`,&=+[\]:@$*;]/,
peg$c54 = peg$classExpectation(["(", ")", "`", ",", "&", "=", "+", "[", "]", ":", "@", "$", "*", ";"], true, false),
peg$c53 = /^[^(),`![\]&=+#:@$*;']/,
peg$c54 = peg$classExpectation(["(", ")", ",", "`", "!", "[", "]", "&", "=", "+", "#", ":", "@", "$", "*", ";", "'"], true, false),

@@ -836,3 +836,3 @@ peg$currPos = 0,

s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 39) {
if (input.charCodeAt(peg$currPos) === 33) {
s1 = peg$c29;

@@ -864,3 +864,3 @@ peg$currPos++;

if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 39) {
if (input.charCodeAt(peg$currPos) === 33) {
s3 = peg$c29;

@@ -867,0 +867,0 @@ peg$currPos++;

@@ -93,3 +93,3 @@ "use strict";

it("should reject if the item is a binary operator", () => {
expect(() => filter_param_parser_1.default(eqOperator, "(eq)")).to.throw(/binary operator .+ exactly three items/);
expect(() => filter_param_parser_1.default(eqOperator, "(eq)")).to.throw(/"eq" .+ binary .+ infixed/);
});

@@ -114,4 +114,4 @@ it("should treat as a no-arg expression if the arg is known + n-ary", () => {

it("should not try to recognize a binary operator", () => {
const missingItemError = /binary operator .+ must have exactly three items/;
expect(() => filter_param_parser_1.default(gteOperator, "(gte,1)")).to.throw(missingItemError);
const missingItemError = /binary .+ must have exactly three items/;
expect(() => filter_param_parser_1.default(gteOperator, "(gte,1)")).to.throw(/"gte" .+ binary .+ infixed/);
expect(() => filter_param_parser_1.default(gteOperator, "(1,gte)")).to.throw(missingItemError);

@@ -155,7 +155,9 @@ expect(() => filter_param_parser_1.default(gteOperator, "(fieldName,gte)")).to.throw(missingItemError);

describe("4+-item lists", () => {
it("should reject if the first item isn't a known operator", () => {
it("should reject if the first item isn't a known nary operator", () => {
expect(() => filter_param_parser_1.default(eqOperator, "(now,test,3,14)"))
.to.throw(/must have a valid operator/);
expect(() => filter_param_parser_1.default(eqOperator, "(fieldName,eq,3,14)"))
.to.throw(/must have a valid operator/);
.to.throw(/"eq" .+ binary .+ exactly three items/);
expect(() => filter_param_parser_1.default(eqOperator, "(eq,3,14,3)"))
.to.throw(/"eq" .+ binary .+ infixed/);
});

@@ -162,0 +164,0 @@ it("should wrap up all args into an array", () => {

@@ -91,2 +91,11 @@ "use strict";

});
it("may not have a quotation mark in it", () => {
expect(() => parseSort("'test'")).to.throw(/sort fields list but "'"/i);
expect(() => parseSort("are'te")).to.throw(/end of input but "'"/i);
});
it("may have a percent sign in it", () => {
expect(parseSort("%C2%A9")).to.deep.equal([{
field: "©", direction: "ASC"
}]);
});
it("should reject leading period, minus, and number in symbol names", () => {

@@ -166,4 +175,4 @@ expect(() => { parseFilter("(-test)"); }).to.throw();

describe("String", () => {
it("should support backtick + single quote strings", () => {
expect(parseFilter("(`test`,'test2')"))
it("should support backtick + exclamation point quoted strings", () => {
expect(parseFilter("(`test`,!test2!)"))
.to.deep.equal([helpers_1.RawFieldExpression(['test', 'test2'])]);

@@ -170,0 +179,0 @@ });

{
"name": "@json-api/query-parser",
"version": "0.2.5",
"version": "1.0.0",
"description": "A query parser for the ?filter and ?sort param syntax used by @json-api/server",

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

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