@embeddable.com/sdk-react 3.3.0 → 3.3.1

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/lib/index.esm.js CHANGED
@@ -659,7 +659,6 @@ const componentMetaSchema = z
659
659
  }
660
660
  });
661
661
 
662
- const getObjectProperty = (value) => value.object.name + "." + value.property.name;
663
662
  // @ts-ignore
664
663
  const babelTraverse = traverse.default;
665
664
  const parseAndTraverse = (code, visitor) => {
@@ -687,14 +686,13 @@ const validateComponentProps = (metaInfo) => {
687
686
  const errors = [];
688
687
  parseAndTraverse(metaInfo.moduleInfo.code, {
689
688
  ExportDefaultDeclaration: (path) => {
690
- var _a, _b, _c, _d;
689
+ var _a;
691
690
  const componentConfig = path.node.declaration
692
691
  .arguments[2];
693
692
  const propsNode = (_a = componentConfig.properties) === null || _a === void 0 ? void 0 : _a.find((x) => { var _a; return ((_a = x.key) === null || _a === void 0 ? void 0 : _a.name) === "props"; });
694
693
  // There is no props defined
695
694
  if (!propsNode)
696
695
  return;
697
- let functionBody;
698
696
  // if propsNode is a function defined elsewhere
699
697
  if (propsNode.value.type === "Identifier") {
700
698
  const functionName = propsNode.value.name;
@@ -705,38 +703,15 @@ const validateComponentProps = (metaInfo) => {
705
703
  if (path.node.id.name === functionName &&
706
704
  (path.node.init.type === "FunctionExpression" ||
707
705
  path.node.init.type === "ArrowFunctionExpression")) {
708
- functionBody = path.node.init.body.body;
706
+ path.node.init.body.body;
709
707
  }
710
708
  },
711
709
  });
712
710
  }
713
711
  else {
714
712
  // assume that propsNode is anonymous function
715
- functionBody = propsNode.value.body.body;
716
- }
717
- const propsReturnStatement = functionBody === null || functionBody === void 0 ? void 0 : functionBody.find((x) => x.type === "ReturnStatement");
718
- const results = (_c = (_b = propsReturnStatement === null || propsReturnStatement === void 0 ? void 0 : propsReturnStatement.argument) === null || _b === void 0 ? void 0 : _b.properties) === null || _c === void 0 ? void 0 : _c.find((x) => { var _a; return ((_a = x === null || x === void 0 ? void 0 : x.key) === null || _a === void 0 ? void 0 : _a.name) === "results"; });
719
- // There is no results defined inside props
720
- if (results === undefined) {
721
- return;
713
+ propsNode.value.body.body;
722
714
  }
723
- const loadDataProperties = (_d = results === null || results === void 0 ? void 0 : results.value) === null || _d === void 0 ? void 0 : _d.arguments[0].properties;
724
- const dimensions = loadDataProperties === null || loadDataProperties === void 0 ? void 0 : loadDataProperties.find((prop) => prop.key.name === "dimensions");
725
- const timeDimensions = loadDataProperties === null || loadDataProperties === void 0 ? void 0 : loadDataProperties.find((prop) => prop.key.name === "timeDimensions");
726
- // There is no missuse of dimensions and timeDimensions
727
- if (!dimensions || !timeDimensions)
728
- return;
729
- const usedDimensions = dimensions.value.elements.map((x) => getObjectProperty(x));
730
- const usedTimeDimensions = timeDimensions.value.elements
731
- .map((x) => x.properties)
732
- .flatMap((group) => group
733
- .filter((property) => property.key.name === "dimension")
734
- .map((property) => getObjectProperty(property.value.object)));
735
- usedDimensions.forEach((dimension) => {
736
- if (usedTimeDimensions.includes(dimension)) {
737
- errors.push(`Dimension ${dimension} should not be requested as both a dimension and a timeDimension.`);
738
- }
739
- });
740
715
  },
741
716
  });
742
717
  return errors;