@embeddable.com/sdk-react 3.2.3 → 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.js CHANGED
@@ -685,7 +685,6 @@ const componentMetaSchema = zod.z
685
685
  }
686
686
  });
687
687
 
688
- const getObjectProperty = (value) => value.object.name + "." + value.property.name;
689
688
  // @ts-ignore
690
689
  const babelTraverse = traverse.default;
691
690
  const parseAndTraverse = (code, visitor) => {
@@ -713,14 +712,13 @@ const validateComponentProps = (metaInfo) => {
713
712
  const errors = [];
714
713
  parseAndTraverse(metaInfo.moduleInfo.code, {
715
714
  ExportDefaultDeclaration: (path) => {
716
- var _a, _b, _c, _d;
715
+ var _a;
717
716
  const componentConfig = path.node.declaration
718
717
  .arguments[2];
719
718
  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"; });
720
719
  // There is no props defined
721
720
  if (!propsNode)
722
721
  return;
723
- let functionBody;
724
722
  // if propsNode is a function defined elsewhere
725
723
  if (propsNode.value.type === "Identifier") {
726
724
  const functionName = propsNode.value.name;
@@ -731,38 +729,15 @@ const validateComponentProps = (metaInfo) => {
731
729
  if (path.node.id.name === functionName &&
732
730
  (path.node.init.type === "FunctionExpression" ||
733
731
  path.node.init.type === "ArrowFunctionExpression")) {
734
- functionBody = path.node.init.body.body;
732
+ path.node.init.body.body;
735
733
  }
736
734
  },
737
735
  });
738
736
  }
739
737
  else {
740
738
  // assume that propsNode is anonymous function
741
- functionBody = propsNode.value.body.body;
742
- }
743
- const propsReturnStatement = functionBody === null || functionBody === void 0 ? void 0 : functionBody.find((x) => x.type === "ReturnStatement");
744
- 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"; });
745
- // There is no results defined inside props
746
- if (results === undefined) {
747
- return;
739
+ propsNode.value.body.body;
748
740
  }
749
- const loadDataProperties = (_d = results === null || results === void 0 ? void 0 : results.value) === null || _d === void 0 ? void 0 : _d.arguments[0].properties;
750
- const dimensions = loadDataProperties === null || loadDataProperties === void 0 ? void 0 : loadDataProperties.find((prop) => prop.key.name === "dimensions");
751
- const timeDimensions = loadDataProperties === null || loadDataProperties === void 0 ? void 0 : loadDataProperties.find((prop) => prop.key.name === "timeDimensions");
752
- // There is no missuse of dimensions and timeDimensions
753
- if (!dimensions || !timeDimensions)
754
- return;
755
- const usedDimensions = dimensions.value.elements.map((x) => getObjectProperty(x));
756
- const usedTimeDimensions = timeDimensions.value.elements
757
- .map((x) => x.properties)
758
- .flatMap((group) => group
759
- .filter((property) => property.key.name === "dimension")
760
- .map((property) => getObjectProperty(property.value.object)));
761
- usedDimensions.forEach((dimension) => {
762
- if (usedTimeDimensions.includes(dimension)) {
763
- errors.push(`Dimension ${dimension} should not be requested as both a dimension and a timeDimension.`);
764
- }
765
- });
766
741
  },
767
742
  });
768
743
  return errors;
@@ -1138,7 +1113,7 @@ async function runViteBuild(ctx, watch = null) {
1138
1113
  }
1139
1114
  : undefined,
1140
1115
  lib: {
1141
- entry: path__namespace.resolve(ctx.client.rootDir, ctx["sdk-react"].outputOptions.componentsEntryPointFilename),
1116
+ entry: path__namespace.resolve(ctx.client.buildDir, ctx["sdk-react"].outputOptions.componentsEntryPointFilename),
1142
1117
  formats: ["es"],
1143
1118
  fileName: ctx["sdk-react"].outputOptions.fileName,
1144
1119
  },
@@ -1165,7 +1140,7 @@ const ADDITIONAL_CONTENT_IMPORT_TOKEN = "{{ADDITIONAL_CONTENT_IMPORT}}";
1165
1140
  const ADDITIONAL_CONTENT_BEGIN_TOKEN = "{{ADDITIONAL_CONTENT_BEGIN}}";
1166
1141
  const ADDITIONAL_CONTENT_END_TOKEN = "{{ADDITIONAL_CONTENT_END}}";
1167
1142
  function getRelativeFileNameForImport(ctx, fileName) {
1168
- return `./${path__namespace
1143
+ return `../${path__namespace
1169
1144
  .relative(ctx.client.rootDir, fileName)
1170
1145
  // it is a bit of a hack. On windows the path will look like '.src\something\something'
1171
1146
  // but for imports it must be '.src/something/something'
@@ -1192,7 +1167,7 @@ async function prepareEntrypoint(ctx, filesList) {
1192
1167
  }
1193
1168
  }
1194
1169
  const content = await fs__namespace$2.readFile(path__namespace.resolve(ctx["sdk-react"].templatesDir, `${ctx["sdk-react"].outputOptions.componentsEntryPointFilename}.template`), "utf8");
1195
- await fs__namespace$2.writeFile(path__namespace.resolve(ctx.client.rootDir, ctx["sdk-react"].outputOptions.componentsEntryPointFilename), content
1170
+ await fs__namespace$2.writeFile(path__namespace.resolve(ctx.client.buildDir, ctx["sdk-react"].outputOptions.componentsEntryPointFilename), content
1196
1171
  .replace(IMPORT_REPLACE_TOKEN, imports)
1197
1172
  .replace(ERROR_FALLBACK_COMPONENT_IMPORT_TOKEN, errorBoundaryImport)
1198
1173
  .replace(ERROR_FALLBACK_COMPONENT_TOKEN, errorFallbackComponent)
@@ -1207,7 +1182,7 @@ var build = async (ctx) => {
1207
1182
  };
1208
1183
 
1209
1184
  var cleanup = async (ctx) => {
1210
- await fs.rm(path.resolve(ctx.client.rootDir, ctx["sdk-react"].outputOptions.componentsEntryPointFilename));
1185
+ await fs.rm(path.resolve(ctx.client.buildDir, ctx["sdk-react"].outputOptions.componentsEntryPointFilename));
1211
1186
  };
1212
1187
 
1213
1188
  var index = () => {