@qrvey/cd-package-registry 1.0.8-1068.beta → 1.0.10-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
@@ -4581,7 +4581,7 @@ Dataset ID: ${input.qrveyId}`
4581
4581
  let columns = [];
4582
4582
  if (input.formula) columns = [
4583
4583
  ...input.formula.matchAll(/\[(.*?)\]/g)
4584
- ].map((m) => m[1]);
4584
+ ].map((m) => m[1].replace("/formula", ""));
4585
4585
  if (columns.length > 0 && qrvey) {
4586
4586
  if (!qrvey.questions.data.some((q) => columns.includes(q.id))) errors.push({
4587
4587
  field: "formula",
@@ -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;