@labdigital/commercetools-mock 2.53.0 → 2.53.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4600,6 +4600,7 @@ const resolveSymbol = (val, vars) => {
4600
4600
  };
4601
4601
  const resolveValue = (obj, val) => {
4602
4602
  if (val.type !== "identifier") throw new PredicateError("Internal error");
4603
+ if (val.value === "variants" && obj.masterVariant && obj.variants !== void 0) return [obj.masterVariant, ...obj.variants ?? []];
4603
4604
  if (!(val.value in obj)) {
4604
4605
  if (Array.isArray(obj)) return Object.values(obj).filter((v) => val.value in v).map((v) => v[val.value]);
4605
4606
  return void 0;
@@ -4645,7 +4646,7 @@ const generateMatchFunc = (predicate) => {
4645
4646
  return (obj) => !expr(obj);
4646
4647
  }).nud("EMPTY", 10, ({ bp }) => "empty").nud("DEFINED", 10, ({ bp }) => "defined").led("AND", 5, ({ left, bp }) => {
4647
4648
  const expr = parser.parse({ terminals: [bp - 1] });
4648
- return (obj) => left(obj) && expr(obj);
4649
+ return (obj, vars) => left(obj, vars) && expr(obj, vars);
4649
4650
  }).led("OR", 5, ({ left, token, bp }) => {
4650
4651
  const expr = parser.parse({ terminals: [bp - 1] });
4651
4652
  return (obj, vars) => left(obj, vars) || expr(obj, vars);
@@ -4740,6 +4741,7 @@ const generateMatchFunc = (predicate) => {
4740
4741
  }
4741
4742
  }).led("IN", 20, ({ left, bp }) => {
4742
4743
  const expr = parser.parse({ terminals: [bp - 1] });
4744
+ lexer.expect(")");
4743
4745
  return (obj, vars) => {
4744
4746
  let symbols = expr;
4745
4747
  if (!Array.isArray(symbols)) symbols = [expr];
@@ -4761,6 +4763,7 @@ const generateMatchFunc = (predicate) => {
4761
4763
  if (type.match !== "circle") throw new PredicateError(`Invalid input '${type.match}', expected circle`);
4762
4764
  lexer.expect("(");
4763
4765
  const expr = parser.parse({ terminals: [")"] });
4766
+ lexer.expect(")");
4764
4767
  return (obj, vars) => {
4765
4768
  const value = resolveValue(obj, left);
4766
4769
  if (!value) return false;