@qrvey/cd-package-registry 1.0.9-1097 → 1.0.11-1109

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/cjs/index.js CHANGED
@@ -4738,25 +4738,41 @@ var _DatasetDependencyValidator = class _DatasetDependencyValidator {
4738
4738
  }
4739
4739
  getDependencyKeys(input) {
4740
4740
  var _a3, _b;
4741
+ const keys = (_b = (_a3 = input.datasources) == null ? void 0 : _a3.map((ds) => ({
4742
+ connectionId: ds.connectionId
4743
+ }))) != null ? _b : [];
4744
+ if (input.datasetParentId) {
4745
+ keys.push({
4746
+ parentDatasetId: input.datasetParentId
4747
+ });
4748
+ }
4741
4749
  return {
4742
- keys: (_b = (_a3 = input.datasources) == null ? void 0 : _a3.map((ds) => ({
4743
- connectionId: ds.connectionId
4744
- }))) != null ? _b : []
4750
+ keys
4745
4751
  };
4746
4752
  }
4747
4753
  async fetchDependencies(keys) {
4748
- const args = uniqueBy(keys != null ? keys : [], "connectionId");
4749
- const connections = await this.fetchConnectionsByIds(args);
4750
- const connectionMap = new Map(connections.map((c) => [
4751
- c.connectorid,
4752
- c
4753
- ]));
4754
+ const connectionKeys = uniqueBy(keys.filter((k) => k.connectionId), "connectionId");
4755
+ const parentKeys = uniqueBy(keys.filter((k) => k.parentDatasetId), "parentDatasetId");
4756
+ const [connections, parentDatasets] = await Promise.all([
4757
+ this.fetchConnectionsByIds(connectionKeys),
4758
+ this.fetchDatasetsByIds(parentKeys)
4759
+ ]);
4754
4760
  return {
4755
- connections: connectionMap
4761
+ connections: new Map(connections.map((c) => [
4762
+ c.connectorid,
4763
+ c
4764
+ ])),
4765
+ parentDatasets: new Map(parentDatasets.map((d) => {
4766
+ var _a3;
4767
+ return [
4768
+ (_a3 = d.datasetId) != null ? _a3 : d.qrveyid,
4769
+ d
4770
+ ];
4771
+ }))
4756
4772
  };
4757
4773
  }
4758
4774
  validateWithContext(input, context) {
4759
- var _a3;
4775
+ var _a3, _b;
4760
4776
  const errors = [];
4761
4777
  (_a3 = input.datasources) == null ? void 0 : _a3.forEach((ds) => {
4762
4778
  const connections = context.connections.get(ds.connectionId);
@@ -4770,6 +4786,18 @@ Connection ID: ${ds.connectionId}`
4770
4786
  });
4771
4787
  }
4772
4788
  });
4789
+ if (input.datasetParentId) {
4790
+ const parent = (_b = context.parentDatasets) == null ? void 0 : _b.get(input.datasetParentId);
4791
+ if (!parent) {
4792
+ errors.push({
4793
+ field: "datasetParentId",
4794
+ message: `The custom dataset '${input.name}' references a parent dataset that does not exist or is inaccessible.`,
4795
+ value: input,
4796
+ textDetails: `Dataset ID: ${input.datasetId}
4797
+ Parent Dataset ID: ${input.datasetParentId}`
4798
+ });
4799
+ }
4800
+ }
4773
4801
  return errors;
4774
4802
  }
4775
4803
  //#region Private methods
@@ -4781,6 +4809,14 @@ Connection ID: ${ds.connectionId}`
4781
4809
  }, this.options)));
4782
4810
  return result.filter((res) => res.status === "fulfilled").map((res) => res.value);
4783
4811
  }
4812
+ async fetchDatasetsByIds(args) {
4813
+ const result = await Promise.allSettled(args.map(({ parentDatasetId }) => QrveyFetchClient.get({
4814
+ userId: this.params.userId,
4815
+ appId: this.params.appId,
4816
+ qrveyId: parentDatasetId
4817
+ }, this.options)));
4818
+ return result.filter((res) => res.status === "fulfilled").map((res) => res.value);
4819
+ }
4784
4820
  };
4785
4821
  __name(_DatasetDependencyValidator, "DatasetDependencyValidator");
4786
4822
  var DatasetDependencyValidator = _DatasetDependencyValidator;
@@ -4839,7 +4875,7 @@ var _DashboardContentElementDependencyValidatorService = class _DashboardContent
4839
4875
  if ((_g = input.itemData) == null ? void 0 : _g.chartId) {
4840
4876
  errors.push({
4841
4877
  field: "chartId",
4842
- message: `A dashboard content element of the dashbaord '${dashboardInfo == null ? void 0 : dashboardInfo.name}' references a chart that does not exist or is inaccessible. Chart ID: ${(_h = input.itemData) == null ? void 0 : _h.chartId}`,
4878
+ message: `A dashboard content element of the dashboard '${dashboardInfo == null ? void 0 : dashboardInfo.name}' references a chart that does not exist or is inaccessible. Chart ID: ${(_h = input.itemData) == null ? void 0 : _h.chartId}`,
4843
4879
  value: input,
4844
4880
  textDetails: `Dashboard content element ID: ${input.elementId}
4845
4881
  Dashboard content ID: ${input.contentId}
@@ -4849,7 +4885,7 @@ Chart ID: ${(_i = input.itemData) == null ? void 0 : _i.chartId}`
4849
4885
  } else if ((_j = input.itemData) == null ? void 0 : _j.metricId) {
4850
4886
  errors.push({
4851
4887
  field: "metricId",
4852
- message: `A dashboard content element of the dashbaord '${dashboardInfo == null ? void 0 : dashboardInfo.name}' references a metric that does not exist or is inaccessible. Metric ID: ${(_k = input.itemData) == null ? void 0 : _k.metricId}`,
4888
+ message: `A dashboard content element of the dashboard '${dashboardInfo == null ? void 0 : dashboardInfo.name}' references a metric that does not exist or is inaccessible. Metric ID: ${(_k = input.itemData) == null ? void 0 : _k.metricId}`,
4853
4889
  value: input,
4854
4890
  textDetails: `Dashboard content element ID: ${input.elementId}
4855
4891
  Dashboard content ID: ${input.contentId}