@qrvey/utils 1.3.0-16 → 1.3.0-19

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.
Files changed (54) hide show
  1. package/.eslintrc.json +2 -0
  2. package/dist/cjs/columns/helpers/getDatasetColumnByDatasets.js +1 -1
  3. package/dist/cjs/filters/adapters/FDToLogic.js +3 -3
  4. package/dist/cjs/filters/helpers/backend/getLogicByDatasets.d.ts +11 -0
  5. package/dist/cjs/filters/helpers/backend/getLogicByDatasets.js +34 -0
  6. package/dist/cjs/filters/helpers/backend/getLogicByDatasetsColumns.d.ts +12 -0
  7. package/dist/cjs/filters/helpers/backend/getLogicByDatasetsColumns.js +47 -0
  8. package/dist/cjs/filters/helpers/backend/index.d.ts +2 -0
  9. package/dist/cjs/filters/helpers/backend/index.js +2 -0
  10. package/dist/cjs/filters/helpers/common/getFiltersByDatasetsColumns.js +1 -1
  11. package/dist/cjs/filters/interfaces/backend/IFBExpression.d.ts +1 -0
  12. package/dist/cjs/filters/interfaces/functions/IFFGetLogicByDatasets.d.ts +6 -0
  13. package/dist/cjs/filters/interfaces/functions/IFFGetLogicByDatasets.js +2 -0
  14. package/dist/cjs/filters/interfaces/functions/IFFGetLogicByDatasetsColumns.d.ts +7 -0
  15. package/dist/cjs/filters/interfaces/functions/IFFGetLogicByDatasetsColumns.js +2 -0
  16. package/dist/cjs/filters/interfaces/functions/index.d.ts +2 -0
  17. package/dist/cjs/filters/interfaces/functions/index.js +2 -0
  18. package/dist/cjs/filters/services/Filters.api.js +4 -2
  19. package/dist/cjs/globalization/helpers/getI18nDateGroupLabel.js +1 -1
  20. package/dist/cjs/services/adapters/BBranchesMapToUIBranchesMap.adapter.js +3 -3
  21. package/dist/columns/helpers/getDatasetColumnByDatasets.js +1 -1
  22. package/dist/filters/adapters/FDToLogic.js +3 -3
  23. package/dist/filters/helpers/backend/getLogicByDatasets.d.ts +11 -0
  24. package/dist/filters/helpers/backend/getLogicByDatasets.js +30 -0
  25. package/dist/filters/helpers/backend/getLogicByDatasetsColumns.d.ts +12 -0
  26. package/dist/filters/helpers/backend/getLogicByDatasetsColumns.js +43 -0
  27. package/dist/filters/helpers/backend/index.d.ts +2 -0
  28. package/dist/filters/helpers/backend/index.js +2 -0
  29. package/dist/filters/helpers/common/getFiltersByDatasetsColumns.js +1 -1
  30. package/dist/filters/interfaces/backend/IFBExpression.d.ts +1 -0
  31. package/dist/filters/interfaces/functions/IFFGetLogicByDatasets.d.ts +6 -0
  32. package/dist/filters/interfaces/functions/IFFGetLogicByDatasets.js +1 -0
  33. package/dist/filters/interfaces/functions/IFFGetLogicByDatasetsColumns.d.ts +7 -0
  34. package/dist/filters/interfaces/functions/IFFGetLogicByDatasetsColumns.js +1 -0
  35. package/dist/filters/interfaces/functions/index.d.ts +2 -0
  36. package/dist/filters/interfaces/functions/index.js +2 -0
  37. package/dist/filters/services/Filters.api.js +4 -2
  38. package/dist/globalization/helpers/getI18nDateGroupLabel.js +1 -1
  39. package/dist/services/adapters/BBranchesMapToUIBranchesMap.adapter.js +3 -3
  40. package/package.json +1 -1
  41. package/src/columns/helpers/getDatasetColumnByDatasets.ts +1 -1
  42. package/src/filters/adapters/FDToLogic.ts +5 -5
  43. package/src/filters/helpers/backend/getLogicByDatasets.ts +37 -0
  44. package/src/filters/helpers/backend/getLogicByDatasetsColumns.ts +52 -0
  45. package/src/filters/helpers/backend/index.ts +2 -0
  46. package/src/filters/helpers/common/getFiltersByDatasetsColumns.ts +1 -1
  47. package/src/filters/interfaces/backend/IFBExpression.ts +1 -0
  48. package/src/filters/interfaces/functions/IFFGetLogicByDatasets.ts +6 -0
  49. package/src/filters/interfaces/functions/IFFGetLogicByDatasetsColumns.ts +7 -0
  50. package/src/filters/interfaces/functions/index.ts +2 -0
  51. package/src/filters/services/Filters.api.ts +4 -2
  52. package/src/globalization/helpers/getI18nDateGroupLabel.ts +1 -1
  53. package/src/services/adapters/BBranchesMapToUIBranchesMap.adapter.ts +3 -3
  54. package/test/filters/backend/getLogicByDatasetsColumns.test.js +312 -0
package/.eslintrc.json CHANGED
@@ -20,7 +20,9 @@
20
20
  "comma-spacing": "off",
21
21
  "semi": "off",
22
22
  "no-unused-vars": "off",
23
+ "no-shadow": "off",
23
24
 
25
+ "@typescript-eslint/no-shadow": ["error"],
24
26
  "@typescript-eslint/no-inferrable-types": "warn",
25
27
  "@typescript-eslint/object-curly-spacing": ["warn", "always"],
26
28
  "@typescript-eslint/no-extra-semi": ["warn"],
@@ -13,7 +13,7 @@ const getDatasetColumn_1 = require("./getDatasetColumn");
13
13
  function getDatasetColumnByDatasets(column, datasets) {
14
14
  if ((0, isEmpty_1.isEmpty)(column) || (0, isEmpty_1.isEmpty)(datasets))
15
15
  return;
16
- const dataset = datasets.find(dataset => dataset.qrveyid === column.qrveyid);
16
+ const dataset = datasets.find(_dataset => _dataset.qrveyid === column.qrveyid);
17
17
  return (0, getDatasetColumn_1.getDatasetColumn)(column, dataset);
18
18
  }
19
19
  exports.getDatasetColumnByDatasets = getDatasetColumnByDatasets;
@@ -29,8 +29,9 @@ exports.FDToLogic = FDToLogic;
29
29
  * @returns a filter logic array
30
30
  */
31
31
  function getLogicBodyFromFD21(filterData) {
32
- let logics = [];
33
- logics = filterData.scopes.reduce((logics, scope) => {
32
+ if ((0, isEmpty_1.isEmpty)(filterData))
33
+ return [];
34
+ return filterData.scopes.reduce((logics, scope) => {
34
35
  const logic = buildLogic(scope);
35
36
  let filters = [];
36
37
  if (scope.datasets.length > 0) {
@@ -42,7 +43,6 @@ function getLogicBodyFromFD21(filterData) {
42
43
  logics.push(Object.assign(Object.assign({}, logic), { filters }));
43
44
  return logics;
44
45
  }, []);
45
- return logics;
46
46
  }
47
47
  function buildLogic(scopeSection) {
48
48
  return {
@@ -0,0 +1,11 @@
1
+ import { IFBLogic } from "../../interfaces/backend/IFBLogic";
2
+ import { IFFGetLogicByDatasets } from "../../interfaces/functions/IFFGetLogicByDatasets";
3
+ /**
4
+ * [TODO: Add filterEmptyArrays to the filterNestedTree filter condition. Firstly, that function should accept this argument]
5
+ * Filters the logic by a qrveyids array
6
+ * If an qrveyid is not provided in the expression the filter passes normally
7
+ * @param logic The logic of the filter
8
+ * @param datasets The collection of qrveyids
9
+ * @returns a new filtered logic
10
+ */
11
+ export declare function getLogicByDatasets(logic: IFBLogic[], datasets?: string[], settings?: IFFGetLogicByDatasets): IFBLogic[];
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLogicByDatasets = void 0;
4
+ const general_1 = require("../../../general");
5
+ const isEmpty_1 = require("../../../general/mix/isEmpty");
6
+ /**
7
+ * [TODO: Add filterEmptyArrays to the filterNestedTree filter condition. Firstly, that function should accept this argument]
8
+ * Filters the logic by a qrveyids array
9
+ * If an qrveyid is not provided in the expression the filter passes normally
10
+ * @param logic The logic of the filter
11
+ * @param datasets The collection of qrveyids
12
+ * @returns a new filtered logic
13
+ */
14
+ function getLogicByDatasets(logic, datasets = [], settings) {
15
+ if ((0, isEmpty_1.isEmpty)(logic))
16
+ return;
17
+ if ((0, isEmpty_1.isEmpty)(datasets))
18
+ return logic;
19
+ settings = getGetLogicByDatasetsSettings(settings);
20
+ return logic.map(_l => (Object.assign(Object.assign({}, _l), { filters: (0, general_1.filterNestedTree)(_l.filters, 'expressions', (expression) => {
21
+ const dataset = datasets.find(_data => _data === expression.qrveyid);
22
+ return (settings.letPassUndefinedProperties.qrveyid && !(0, general_1._hasProperty)(expression, 'qrveyid')) || !(0, isEmpty_1.isEmpty)(dataset);
23
+ }) })));
24
+ }
25
+ exports.getLogicByDatasets = getLogicByDatasets;
26
+ function getGetLogicByDatasetsSettings(settings) {
27
+ var _a, _b, _c;
28
+ return {
29
+ filterEmptyArrays: (_a = settings === null || settings === void 0 ? void 0 : settings.filterEmptyArrays) !== null && _a !== void 0 ? _a : true,
30
+ letPassUndefinedProperties: {
31
+ qrveyid: (_c = (_b = settings === null || settings === void 0 ? void 0 : settings.letPassUndefinedProperties) === null || _b === void 0 ? void 0 : _b.qrveyid) !== null && _c !== void 0 ? _c : true
32
+ }
33
+ };
34
+ }
@@ -0,0 +1,12 @@
1
+ import { IDataset } from "../../../qrvey/interfaces/IDataset";
2
+ import { IFBLogic } from "../../interfaces/backend/IFBLogic";
3
+ import { IFFGetLogicByDatasetsColumns } from "../../interfaces/functions/IFFGetLogicByDatasetsColumns";
4
+ /**
5
+ * @todo MODULE NO READY
6
+ * Filters the logic by a datasets array
7
+ * If an qrveyid is not provided in the expression a the filter passes normally
8
+ * @param logic The logic of the filter
9
+ * @param datasets The collection of datasets
10
+ * @returns a new filtered logic
11
+ */
12
+ export declare function getLogicByDatasetsColumns(logic: IFBLogic[], datasets?: IDataset[], settings?: IFFGetLogicByDatasetsColumns): IFBLogic[];
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLogicByDatasetsColumns = void 0;
4
+ const filterNestedTree_1 = require("../../../general/array/filterNestedTree");
5
+ const isEmpty_1 = require("../../../general/mix/isEmpty");
6
+ const hasProperty_1 = require("../../../general/object/hasProperty");
7
+ /**
8
+ * @todo MODULE NO READY
9
+ * Filters the logic by a datasets array
10
+ * If an qrveyid is not provided in the expression a the filter passes normally
11
+ * @param logic The logic of the filter
12
+ * @param datasets The collection of datasets
13
+ * @returns a new filtered logic
14
+ */
15
+ function getLogicByDatasetsColumns(logic, datasets = [], settings) {
16
+ if ((0, isEmpty_1.isEmpty)(logic))
17
+ return;
18
+ if ((0, isEmpty_1.isEmpty)(datasets))
19
+ return logic;
20
+ settings = getGetLogicByDatasetsSettings(settings);
21
+ return logic.map(_l => (Object.assign(Object.assign({}, _l), { filters: (0, filterNestedTree_1.filterNestedTree)(_l.filters, 'expressions', (expression) => {
22
+ const letQrveyidPass = settings.letPassUndefinedProperties.qrveyid || (0, hasProperty_1._hasProperty)(expression, 'qrveyid');
23
+ let letQuestionidPass = settings.letPassUndefinedProperties.questionid || (0, hasProperty_1._hasProperty)(expression, 'questionid');
24
+ const dataset = letQrveyidPass ? datasets.find(_data => _data.qrveyid === expression.qrveyid) : undefined;
25
+ if (!(0, isEmpty_1.isEmpty)(dataset)) {
26
+ const column = letQuestionidPass ? (dataset.options || []).find(option => option.id === expression.questionid) : undefined;
27
+ letQuestionidPass = letQuestionidPass || !(0, isEmpty_1.isEmpty)(column);
28
+ }
29
+ return (letQrveyidPass && !(0, isEmpty_1.isEmpty)(dataset)) && letQuestionidPass;
30
+ }) })));
31
+ }
32
+ exports.getLogicByDatasetsColumns = getLogicByDatasetsColumns;
33
+ /**
34
+ * Gets the default settings for the getLogicByDatasetsColumn function
35
+ * @param settings the settings given by the implementer
36
+ * @returns an object with all properties set
37
+ */
38
+ function getGetLogicByDatasetsSettings(settings) {
39
+ var _a, _b, _c, _d, _e;
40
+ return {
41
+ filterEmptyArrays: (_a = settings === null || settings === void 0 ? void 0 : settings.filterEmptyArrays) !== null && _a !== void 0 ? _a : true,
42
+ letPassUndefinedProperties: {
43
+ qrveyid: (_c = (_b = settings === null || settings === void 0 ? void 0 : settings.letPassUndefinedProperties) === null || _b === void 0 ? void 0 : _b.qrveyid) !== null && _c !== void 0 ? _c : true,
44
+ questionid: (_e = (_d = settings === null || settings === void 0 ? void 0 : settings.letPassUndefinedProperties) === null || _d === void 0 ? void 0 : _d.questionid) !== null && _e !== void 0 ? _e : true
45
+ }
46
+ };
47
+ }
@@ -6,5 +6,7 @@ export * from './getBackendGroupValue';
6
6
  export * from './getBackendProperty';
7
7
  export * from './getBackendValidator';
8
8
  export * from './getBackendValues';
9
+ export * from './getLogicByDatasets';
10
+ export * from './getLogicByDatasetsColumns';
9
11
  export * from './getLogicByScopes';
10
12
  export * from './getLogicByScopesHierarchy';
@@ -22,6 +22,8 @@ __exportStar(require("./getBackendGroupValue"), exports);
22
22
  __exportStar(require("./getBackendProperty"), exports);
23
23
  __exportStar(require("./getBackendValidator"), exports);
24
24
  __exportStar(require("./getBackendValues"), exports);
25
+ __exportStar(require("./getLogicByDatasets"), exports);
26
+ __exportStar(require("./getLogicByDatasetsColumns"), exports);
25
27
  __exportStar(require("./getLogicByScopes"), exports);
26
28
  __exportStar(require("./getLogicByScopesHierarchy"), exports);
27
29
  // export * from './hasDatasetRelatedFilters';
@@ -15,7 +15,7 @@ function getFiltersByDatasetsColumns(data, datasets = []) {
15
15
  if ((0, isEmpty_1.isEmpty)(datasets))
16
16
  return data;
17
17
  const newData = Object.assign(Object.assign({}, data), { scopes: data.scopes.map(scope => (Object.assign(Object.assign({}, scope), { datasets: scope.datasets.map(filterDataset => {
18
- const dataset = datasets.find(data => data.qrveyid === filterDataset.qrveyid);
18
+ const dataset = datasets.find(_data => _data.qrveyid === filterDataset.qrveyid);
19
19
  if (!(0, isEmpty_1.isEmpty)(dataset)) {
20
20
  return Object.assign(Object.assign({}, filterDataset), { filters: filterDataset.filters.map(filter => {
21
21
  const column = (dataset.options || []).find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid);
@@ -7,6 +7,7 @@ import { IFProperty } from "../IFProperty";
7
7
  export interface IFBExpression {
8
8
  enabled?: boolean;
9
9
  groupValue?: IFProperty;
10
+ qrveyid?: string;
10
11
  questionid?: string;
11
12
  questionType?: string;
12
13
  property?: IFProperty;
@@ -0,0 +1,6 @@
1
+ export interface IFFGetLogicByDatasets {
2
+ letPassUndefinedProperties?: {
3
+ qrveyid?: boolean;
4
+ };
5
+ filterEmptyArrays?: boolean;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export interface IFFGetLogicByDatasetsColumns {
2
+ letPassUndefinedProperties?: {
3
+ qrveyid?: boolean;
4
+ questionid?: boolean;
5
+ };
6
+ filterEmptyArrays?: boolean;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,5 @@
1
+ export * from './IFFGetLogicByDatasets';
2
+ export * from './IFFGetLogicByDatasetsColumns';
1
3
  export * from './IFFiltersGetData';
2
4
  export * from './IFFiltersGetValuesFromDataset';
3
5
  export * from './IFFiltersGetValuesFromModel';
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./IFFGetLogicByDatasets"), exports);
18
+ __exportStar(require("./IFFGetLogicByDatasetsColumns"), exports);
17
19
  __exportStar(require("./IFFiltersGetData"), exports);
18
20
  __exportStar(require("./IFFiltersGetValuesFromDataset"), exports);
19
21
  __exportStar(require("./IFFiltersGetValuesFromModel"), exports);
@@ -32,6 +32,7 @@ const areStaticColumnValues_1 = require("../../qrvey/helpers/areStaticColumnValu
32
32
  const getValuesFromDataset_1 = require("../helpers/common/getValuesFromDataset");
33
33
  const getFiltersByDatasetsColumns_1 = require("../helpers/common/getFiltersByDatasetsColumns");
34
34
  const getDatasetByColumn_1 = require("../../qrvey/helpers/getDatasetByColumn");
35
+ const getLogicByDatasets_1 = require("../helpers/backend/getLogicByDatasets");
35
36
  class FiltersApi {
36
37
  constructor(cfg) {
37
38
  this.setConfig(cfg);
@@ -100,13 +101,14 @@ class FiltersApi {
100
101
  var _a;
101
102
  const scopes = this.getAvailableScopeIds(config);
102
103
  let filterData = (0, getFiltersByVisibility_1.getFiltersByVisibility)(config.filterData, scopes);
103
- filterData = (0, getFiltersByDatasetsColumns_1.getFiltersByDatasetsColumns)(filterData, config.datasets);
104
+ const dataset = config.datasets.find(d => { var _a; return d.qrveyid === ((_a = config.filter) === null || _a === void 0 ? void 0 : _a.column.qrveyid); });
105
+ filterData = (0, getFiltersByDatasetsColumns_1.getFiltersByDatasetsColumns)(filterData, (0, isEmpty_1.isEmpty)(dataset) ? [] : [dataset]);
104
106
  filterData = (0, excludeFiltersByAggregateColumn_1.excludeFiltersByAggregateColumn)(filterData);
105
107
  const logics = (0, FDToLogic_1.FDToLogic)(filterData);
106
108
  const hierarchyLogic = (0, getLogicByScopesHierarchy_1.getLogicByScopesHierarchy)(logics, scopes, (_a = config.filter) === null || _a === void 0 ? void 0 : _a.extras.scope);
107
109
  return [
108
110
  ...hierarchyLogic,
109
- ...(0, buildUserFilters_1.buildUserFilters)(config.userFilters) || [],
111
+ ...(0, getLogicByDatasets_1.getLogicByDatasets)((0, buildUserFilters_1.buildUserFilters)(config.userFilters), (0, isEmpty_1.isEmpty)(dataset) ? [] : [dataset.qrveyid]) || [],
110
112
  ];
111
113
  }
112
114
  getFilter(config) {
@@ -29,7 +29,7 @@ function getI18nMonthLabel(label, translate) {
29
29
  }
30
30
  function getI18nYearMonthLabel(label, translate) {
31
31
  if (!(0, isTokenLabel_1.isTokenLabel)(label) && !(0, isEmpty_1.isEmpty)(translate)) {
32
- const month = getI18nMonthPropertyByIndex(DATE_YEAR_MONTHS_1.DATE_YEAR_MONTHS.findIndex(month => month === label));
32
+ const month = getI18nMonthPropertyByIndex(DATE_YEAR_MONTHS_1.DATE_YEAR_MONTHS.findIndex(_month => _month === label));
33
33
  if (!(0, isEmpty_1.isEmpty)(month))
34
34
  label = translate('common.date_grouping.' + month + '_mmm');
35
35
  }
@@ -11,9 +11,9 @@ const BColumnsToUIColumns_adapter_1 = require("./BColumnsToUIColumns.adapter");
11
11
  function BBranchesMapToUIBranchesMap(branchesMap) {
12
12
  if ((0, isEmpty_1.isEmpty)(branchesMap))
13
13
  return [];
14
- return branchesMap.map(branchesMap => ({
15
- questionid: branchesMap.questionid,
16
- branches: branchesMap.branches.map(branch => ({
14
+ return branchesMap.map(branchMap => ({
15
+ questionid: branchMap.questionid,
16
+ branches: branchMap.branches.map(branch => ({
17
17
  columns: (0, BColumnsToUIColumns_adapter_1.BColumnsToUIColumns)(branch.questions.data)
18
18
  }))
19
19
  }));
@@ -10,6 +10,6 @@ import { getDatasetColumn } from "./getDatasetColumn";
10
10
  export function getDatasetColumnByDatasets(column, datasets) {
11
11
  if (isEmpty(column) || isEmpty(datasets))
12
12
  return;
13
- const dataset = datasets.find(dataset => dataset.qrveyid === column.qrveyid);
13
+ const dataset = datasets.find(_dataset => _dataset.qrveyid === column.qrveyid);
14
14
  return getDatasetColumn(column, dataset);
15
15
  }
@@ -25,8 +25,9 @@ export function FDToLogic(filterData) {
25
25
  * @returns a filter logic array
26
26
  */
27
27
  function getLogicBodyFromFD21(filterData) {
28
- let logics = [];
29
- logics = filterData.scopes.reduce((logics, scope) => {
28
+ if (isEmpty(filterData))
29
+ return [];
30
+ return filterData.scopes.reduce((logics, scope) => {
30
31
  const logic = buildLogic(scope);
31
32
  let filters = [];
32
33
  if (scope.datasets.length > 0) {
@@ -38,7 +39,6 @@ function getLogicBodyFromFD21(filterData) {
38
39
  logics.push(Object.assign(Object.assign({}, logic), { filters }));
39
40
  return logics;
40
41
  }, []);
41
- return logics;
42
42
  }
43
43
  function buildLogic(scopeSection) {
44
44
  return {
@@ -0,0 +1,11 @@
1
+ import { IFBLogic } from "../../interfaces/backend/IFBLogic";
2
+ import { IFFGetLogicByDatasets } from "../../interfaces/functions/IFFGetLogicByDatasets";
3
+ /**
4
+ * [TODO: Add filterEmptyArrays to the filterNestedTree filter condition. Firstly, that function should accept this argument]
5
+ * Filters the logic by a qrveyids array
6
+ * If an qrveyid is not provided in the expression the filter passes normally
7
+ * @param logic The logic of the filter
8
+ * @param datasets The collection of qrveyids
9
+ * @returns a new filtered logic
10
+ */
11
+ export declare function getLogicByDatasets(logic: IFBLogic[], datasets?: string[], settings?: IFFGetLogicByDatasets): IFBLogic[];
@@ -0,0 +1,30 @@
1
+ import { filterNestedTree, _hasProperty } from "../../../general";
2
+ import { isEmpty } from "../../../general/mix/isEmpty";
3
+ /**
4
+ * [TODO: Add filterEmptyArrays to the filterNestedTree filter condition. Firstly, that function should accept this argument]
5
+ * Filters the logic by a qrveyids array
6
+ * If an qrveyid is not provided in the expression the filter passes normally
7
+ * @param logic The logic of the filter
8
+ * @param datasets The collection of qrveyids
9
+ * @returns a new filtered logic
10
+ */
11
+ export function getLogicByDatasets(logic, datasets = [], settings) {
12
+ if (isEmpty(logic))
13
+ return;
14
+ if (isEmpty(datasets))
15
+ return logic;
16
+ settings = getGetLogicByDatasetsSettings(settings);
17
+ return logic.map(_l => (Object.assign(Object.assign({}, _l), { filters: filterNestedTree(_l.filters, 'expressions', (expression) => {
18
+ const dataset = datasets.find(_data => _data === expression.qrveyid);
19
+ return (settings.letPassUndefinedProperties.qrveyid && !_hasProperty(expression, 'qrveyid')) || !isEmpty(dataset);
20
+ }) })));
21
+ }
22
+ function getGetLogicByDatasetsSettings(settings) {
23
+ var _a, _b, _c;
24
+ return {
25
+ filterEmptyArrays: (_a = settings === null || settings === void 0 ? void 0 : settings.filterEmptyArrays) !== null && _a !== void 0 ? _a : true,
26
+ letPassUndefinedProperties: {
27
+ qrveyid: (_c = (_b = settings === null || settings === void 0 ? void 0 : settings.letPassUndefinedProperties) === null || _b === void 0 ? void 0 : _b.qrveyid) !== null && _c !== void 0 ? _c : true
28
+ }
29
+ };
30
+ }
@@ -0,0 +1,12 @@
1
+ import { IDataset } from "../../../qrvey/interfaces/IDataset";
2
+ import { IFBLogic } from "../../interfaces/backend/IFBLogic";
3
+ import { IFFGetLogicByDatasetsColumns } from "../../interfaces/functions/IFFGetLogicByDatasetsColumns";
4
+ /**
5
+ * @todo MODULE NO READY
6
+ * Filters the logic by a datasets array
7
+ * If an qrveyid is not provided in the expression a the filter passes normally
8
+ * @param logic The logic of the filter
9
+ * @param datasets The collection of datasets
10
+ * @returns a new filtered logic
11
+ */
12
+ export declare function getLogicByDatasetsColumns(logic: IFBLogic[], datasets?: IDataset[], settings?: IFFGetLogicByDatasetsColumns): IFBLogic[];
@@ -0,0 +1,43 @@
1
+ import { filterNestedTree } from "../../../general/array/filterNestedTree";
2
+ import { isEmpty } from "../../../general/mix/isEmpty";
3
+ import { _hasProperty } from "../../../general/object/hasProperty";
4
+ /**
5
+ * @todo MODULE NO READY
6
+ * Filters the logic by a datasets array
7
+ * If an qrveyid is not provided in the expression a the filter passes normally
8
+ * @param logic The logic of the filter
9
+ * @param datasets The collection of datasets
10
+ * @returns a new filtered logic
11
+ */
12
+ export function getLogicByDatasetsColumns(logic, datasets = [], settings) {
13
+ if (isEmpty(logic))
14
+ return;
15
+ if (isEmpty(datasets))
16
+ return logic;
17
+ settings = getGetLogicByDatasetsSettings(settings);
18
+ return logic.map(_l => (Object.assign(Object.assign({}, _l), { filters: filterNestedTree(_l.filters, 'expressions', (expression) => {
19
+ const letQrveyidPass = settings.letPassUndefinedProperties.qrveyid || _hasProperty(expression, 'qrveyid');
20
+ let letQuestionidPass = settings.letPassUndefinedProperties.questionid || _hasProperty(expression, 'questionid');
21
+ const dataset = letQrveyidPass ? datasets.find(_data => _data.qrveyid === expression.qrveyid) : undefined;
22
+ if (!isEmpty(dataset)) {
23
+ const column = letQuestionidPass ? (dataset.options || []).find(option => option.id === expression.questionid) : undefined;
24
+ letQuestionidPass = letQuestionidPass || !isEmpty(column);
25
+ }
26
+ return (letQrveyidPass && !isEmpty(dataset)) && letQuestionidPass;
27
+ }) })));
28
+ }
29
+ /**
30
+ * Gets the default settings for the getLogicByDatasetsColumn function
31
+ * @param settings the settings given by the implementer
32
+ * @returns an object with all properties set
33
+ */
34
+ function getGetLogicByDatasetsSettings(settings) {
35
+ var _a, _b, _c, _d, _e;
36
+ return {
37
+ filterEmptyArrays: (_a = settings === null || settings === void 0 ? void 0 : settings.filterEmptyArrays) !== null && _a !== void 0 ? _a : true,
38
+ letPassUndefinedProperties: {
39
+ qrveyid: (_c = (_b = settings === null || settings === void 0 ? void 0 : settings.letPassUndefinedProperties) === null || _b === void 0 ? void 0 : _b.qrveyid) !== null && _c !== void 0 ? _c : true,
40
+ questionid: (_e = (_d = settings === null || settings === void 0 ? void 0 : settings.letPassUndefinedProperties) === null || _d === void 0 ? void 0 : _d.questionid) !== null && _e !== void 0 ? _e : true
41
+ }
42
+ };
43
+ }
@@ -6,5 +6,7 @@ export * from './getBackendGroupValue';
6
6
  export * from './getBackendProperty';
7
7
  export * from './getBackendValidator';
8
8
  export * from './getBackendValues';
9
+ export * from './getLogicByDatasets';
10
+ export * from './getLogicByDatasetsColumns';
9
11
  export * from './getLogicByScopes';
10
12
  export * from './getLogicByScopesHierarchy';
@@ -6,6 +6,8 @@ export * from './getBackendGroupValue';
6
6
  export * from './getBackendProperty';
7
7
  export * from './getBackendValidator';
8
8
  export * from './getBackendValues';
9
+ export * from './getLogicByDatasets';
10
+ export * from './getLogicByDatasetsColumns';
9
11
  export * from './getLogicByScopes';
10
12
  export * from './getLogicByScopesHierarchy';
11
13
  // export * from './hasDatasetRelatedFilters';
@@ -12,7 +12,7 @@ export function getFiltersByDatasetsColumns(data, datasets = []) {
12
12
  if (isEmpty(datasets))
13
13
  return data;
14
14
  const newData = Object.assign(Object.assign({}, data), { scopes: data.scopes.map(scope => (Object.assign(Object.assign({}, scope), { datasets: scope.datasets.map(filterDataset => {
15
- const dataset = datasets.find(data => data.qrveyid === filterDataset.qrveyid);
15
+ const dataset = datasets.find(_data => _data.qrveyid === filterDataset.qrveyid);
16
16
  if (!isEmpty(dataset)) {
17
17
  return Object.assign(Object.assign({}, filterDataset), { filters: filterDataset.filters.map(filter => {
18
18
  const column = (dataset.options || []).find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid);
@@ -7,6 +7,7 @@ import { IFProperty } from "../IFProperty";
7
7
  export interface IFBExpression {
8
8
  enabled?: boolean;
9
9
  groupValue?: IFProperty;
10
+ qrveyid?: string;
10
11
  questionid?: string;
11
12
  questionType?: string;
12
13
  property?: IFProperty;
@@ -0,0 +1,6 @@
1
+ export interface IFFGetLogicByDatasets {
2
+ letPassUndefinedProperties?: {
3
+ qrveyid?: boolean;
4
+ };
5
+ filterEmptyArrays?: boolean;
6
+ }
@@ -0,0 +1,7 @@
1
+ export interface IFFGetLogicByDatasetsColumns {
2
+ letPassUndefinedProperties?: {
3
+ qrveyid?: boolean;
4
+ questionid?: boolean;
5
+ };
6
+ filterEmptyArrays?: boolean;
7
+ }
@@ -1,3 +1,5 @@
1
+ export * from './IFFGetLogicByDatasets';
2
+ export * from './IFFGetLogicByDatasetsColumns';
1
3
  export * from './IFFiltersGetData';
2
4
  export * from './IFFiltersGetValuesFromDataset';
3
5
  export * from './IFFiltersGetValuesFromModel';
@@ -1,3 +1,5 @@
1
+ export * from './IFFGetLogicByDatasets';
2
+ export * from './IFFGetLogicByDatasetsColumns';
1
3
  export * from './IFFiltersGetData';
2
4
  export * from './IFFiltersGetValuesFromDataset';
3
5
  export * from './IFFiltersGetValuesFromModel';
@@ -26,6 +26,7 @@ import { areStaticColumnValues } from '../../qrvey/helpers/areStaticColumnValues
26
26
  import { getValuesFromDataset } from '../helpers/common/getValuesFromDataset';
27
27
  import { getFiltersByDatasetsColumns } from '../helpers/common/getFiltersByDatasetsColumns';
28
28
  import { getDatasetByColumn } from '../../qrvey/helpers/getDatasetByColumn';
29
+ import { getLogicByDatasets } from '../helpers/backend/getLogicByDatasets';
29
30
  export class FiltersApi {
30
31
  constructor(cfg) {
31
32
  this.setConfig(cfg);
@@ -94,13 +95,14 @@ export class FiltersApi {
94
95
  var _a;
95
96
  const scopes = this.getAvailableScopeIds(config);
96
97
  let filterData = getFiltersByVisibility(config.filterData, scopes);
97
- filterData = getFiltersByDatasetsColumns(filterData, config.datasets);
98
+ const dataset = config.datasets.find(d => { var _a; return d.qrveyid === ((_a = config.filter) === null || _a === void 0 ? void 0 : _a.column.qrveyid); });
99
+ filterData = getFiltersByDatasetsColumns(filterData, isEmpty(dataset) ? [] : [dataset]);
98
100
  filterData = excludeFiltersByAggregateColumn(filterData);
99
101
  const logics = FDToLogic(filterData);
100
102
  const hierarchyLogic = getLogicByScopesHierarchy(logics, scopes, (_a = config.filter) === null || _a === void 0 ? void 0 : _a.extras.scope);
101
103
  return [
102
104
  ...hierarchyLogic,
103
- ...buildUserFilters(config.userFilters) || [],
105
+ ...getLogicByDatasets(buildUserFilters(config.userFilters), isEmpty(dataset) ? [] : [dataset.qrveyid]) || [],
104
106
  ];
105
107
  }
106
108
  getFilter(config) {
@@ -25,7 +25,7 @@ function getI18nMonthLabel(label, translate) {
25
25
  }
26
26
  function getI18nYearMonthLabel(label, translate) {
27
27
  if (!isTokenLabel(label) && !isEmpty(translate)) {
28
- const month = getI18nMonthPropertyByIndex(DATE_YEAR_MONTHS.findIndex(month => month === label));
28
+ const month = getI18nMonthPropertyByIndex(DATE_YEAR_MONTHS.findIndex(_month => _month === label));
29
29
  if (!isEmpty(month))
30
30
  label = translate('common.date_grouping.' + month + '_mmm');
31
31
  }
@@ -8,9 +8,9 @@ import { BColumnsToUIColumns } from "./BColumnsToUIColumns.adapter";
8
8
  export function BBranchesMapToUIBranchesMap(branchesMap) {
9
9
  if (isEmpty(branchesMap))
10
10
  return [];
11
- return branchesMap.map(branchesMap => ({
12
- questionid: branchesMap.questionid,
13
- branches: branchesMap.branches.map(branch => ({
11
+ return branchesMap.map(branchMap => ({
12
+ questionid: branchMap.questionid,
13
+ branches: branchMap.branches.map(branch => ({
14
14
  columns: BColumnsToUIColumns(branch.questions.data)
15
15
  }))
16
16
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.3.0-16",
3
+ "version": "1.3.0-19",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",
@@ -14,6 +14,6 @@ import { getDatasetColumn } from "./getDatasetColumn";
14
14
  export function getDatasetColumnByDatasets(column: Partial<IColumn>, datasets: IDataset[]): IColumn {
15
15
  if (isEmpty(column) || isEmpty(datasets)) return;
16
16
 
17
- const dataset = datasets.find(dataset => dataset.qrveyid === column.qrveyid);
17
+ const dataset = datasets.find(_dataset => _dataset.qrveyid === column.qrveyid);
18
18
  return getDatasetColumn(column, dataset);
19
19
  }
@@ -33,8 +33,9 @@ export function FDToLogic(filterData: IFSData): IFBLogic[] {
33
33
  * @returns a filter logic array
34
34
  */
35
35
  function getLogicBodyFromFD21(filterData: IFSData): IFBLogic[] {
36
- let logics = [];
37
- logics = filterData.scopes.reduce((logics: IFBLogic[], scope: IFSScope) => {
36
+ if (isEmpty(filterData)) return [];
37
+
38
+ return filterData.scopes.reduce((logics: IFBLogic[], scope: IFSScope) => {
38
39
  const logic: IFBLogic = buildLogic(scope);
39
40
  let filters: IFBFilter[] = [];
40
41
  if (scope.datasets.length > 0) {
@@ -45,9 +46,8 @@ function getLogicBodyFromFD21(filterData: IFSData): IFBLogic[] {
45
46
  }
46
47
  logics.push({ ...logic, filters });
47
48
  return logics;
48
- }, [] as IFBLogic[]);
49
- return logics;
50
- }
49
+ }, [] as IFBLogic[]);
50
+ }
51
51
 
52
52
  function buildLogic(scopeSection: IFSScope): IFBLogic {
53
53
  return {
@@ -0,0 +1,37 @@
1
+ import { filterNestedTree, _hasProperty } from "../../../general";
2
+ import { isEmpty } from "../../../general/mix/isEmpty";
3
+ import { IFBExpression } from "../../interfaces/backend/IFBExpression";
4
+ import { IFBLogic } from "../../interfaces/backend/IFBLogic";
5
+ import { IFFGetLogicByDatasets } from "../../interfaces/functions/IFFGetLogicByDatasets";
6
+
7
+ /**
8
+ * [TODO: Add filterEmptyArrays to the filterNestedTree filter condition. Firstly, that function should accept this argument]
9
+ * Filters the logic by a qrveyids array
10
+ * If an qrveyid is not provided in the expression the filter passes normally
11
+ * @param logic The logic of the filter
12
+ * @param datasets The collection of qrveyids
13
+ * @returns a new filtered logic
14
+ */
15
+ export function getLogicByDatasets(logic: IFBLogic[], datasets: string[] = [], settings?: IFFGetLogicByDatasets): IFBLogic[] {
16
+ if (isEmpty(logic)) return;
17
+ if (isEmpty(datasets)) return logic;
18
+
19
+ settings = getGetLogicByDatasetsSettings(settings);
20
+
21
+ return logic.map(_l => ({
22
+ ..._l,
23
+ filters: filterNestedTree(_l.filters, 'expressions', (expression: IFBExpression) => {
24
+ const dataset = datasets.find(_data => _data === expression.qrveyid);
25
+ return (settings.letPassUndefinedProperties.qrveyid && !_hasProperty(expression, 'qrveyid')) || !isEmpty(dataset);
26
+ })
27
+ }));
28
+ }
29
+
30
+ function getGetLogicByDatasetsSettings(settings?: IFFGetLogicByDatasets): IFFGetLogicByDatasets {
31
+ return {
32
+ filterEmptyArrays: settings?.filterEmptyArrays ?? true,
33
+ letPassUndefinedProperties: {
34
+ qrveyid: settings?.letPassUndefinedProperties?.qrveyid ?? true
35
+ }
36
+ };
37
+ }
@@ -0,0 +1,52 @@
1
+ import { filterNestedTree } from "../../../general/array/filterNestedTree";
2
+ import { isEmpty } from "../../../general/mix/isEmpty";
3
+ import { _hasProperty } from "../../../general/object/hasProperty";
4
+ import { IDataset } from "../../../qrvey/interfaces/IDataset";
5
+ import { IFBExpression } from "../../interfaces/backend/IFBExpression";
6
+ import { IFBLogic } from "../../interfaces/backend/IFBLogic";
7
+ import { IFFGetLogicByDatasetsColumns } from "../../interfaces/functions/IFFGetLogicByDatasetsColumns";
8
+
9
+ /**
10
+ * @todo MODULE NO READY
11
+ * Filters the logic by a datasets array
12
+ * If an qrveyid is not provided in the expression a the filter passes normally
13
+ * @param logic The logic of the filter
14
+ * @param datasets The collection of datasets
15
+ * @returns a new filtered logic
16
+ */
17
+ export function getLogicByDatasetsColumns(logic: IFBLogic[], datasets: IDataset[] = [], settings?: IFFGetLogicByDatasetsColumns): IFBLogic[] {
18
+ if (isEmpty(logic)) return;
19
+ if (isEmpty(datasets)) return logic;
20
+
21
+ settings = getGetLogicByDatasetsSettings(settings);
22
+
23
+ return logic.map(_l => ({
24
+ ..._l,
25
+ filters: filterNestedTree(_l.filters, 'expressions', (expression: IFBExpression) => {
26
+ const letQrveyidPass = settings.letPassUndefinedProperties.qrveyid || _hasProperty(expression, 'qrveyid');
27
+ let letQuestionidPass = settings.letPassUndefinedProperties.questionid || _hasProperty(expression, 'questionid');
28
+ const dataset = letQrveyidPass ? datasets.find(_data => _data.qrveyid === expression.qrveyid) : undefined;
29
+ if (!isEmpty(dataset)) {
30
+ const column = letQuestionidPass ? (dataset.options || []).find(option => option.id === expression.questionid) : undefined;
31
+ letQuestionidPass = letQuestionidPass || !isEmpty(column);
32
+ }
33
+
34
+ return (letQrveyidPass && !isEmpty(dataset)) && letQuestionidPass;
35
+ })
36
+ }));
37
+ }
38
+
39
+ /**
40
+ * Gets the default settings for the getLogicByDatasetsColumn function
41
+ * @param settings the settings given by the implementer
42
+ * @returns an object with all properties set
43
+ */
44
+ function getGetLogicByDatasetsSettings(settings?: IFFGetLogicByDatasetsColumns): IFFGetLogicByDatasetsColumns {
45
+ return {
46
+ filterEmptyArrays: settings?.filterEmptyArrays ?? true,
47
+ letPassUndefinedProperties: {
48
+ qrveyid: settings?.letPassUndefinedProperties?.qrveyid ?? true,
49
+ questionid: settings?.letPassUndefinedProperties?.questionid ?? true
50
+ }
51
+ };
52
+ }
@@ -6,6 +6,8 @@ export * from './getBackendGroupValue';
6
6
  export * from './getBackendProperty';
7
7
  export * from './getBackendValidator';
8
8
  export * from './getBackendValues';
9
+ export * from './getLogicByDatasets';
10
+ export * from './getLogicByDatasetsColumns';
9
11
  export * from './getLogicByScopes';
10
12
  export * from './getLogicByScopesHierarchy';
11
13
  // export * from './hasDatasetRelatedFilters';
@@ -18,7 +18,7 @@ export function getFiltersByDatasetsColumns(data: IFUData, datasets: IDataset[]
18
18
  scopes: data.scopes.map(scope => ({
19
19
  ...scope,
20
20
  datasets: scope.datasets.map(filterDataset => {
21
- const dataset = datasets.find(data => data.qrveyid === filterDataset.qrveyid);
21
+ const dataset = datasets.find(_data => _data.qrveyid === filterDataset.qrveyid);
22
22
  if (!isEmpty(dataset)) {
23
23
  return {
24
24
  ...filterDataset,
@@ -8,6 +8,7 @@ import { IFProperty } from "../IFProperty";
8
8
  export interface IFBExpression {
9
9
  enabled?: boolean; // True: The filter expression is applied; False: The filter expression is not applied.
10
10
  groupValue?: IFProperty; // Date grouping for Date column filters
11
+ qrveyid?: string; // The Qrvey ID used in the expression
11
12
  questionid?: string; // The Question/Column ID
12
13
  questionType?: string; // The type of the Question/Column. Require if it is FORMULA OR BUCKET, otherwise is optional.
13
14
  property?: IFProperty; // Properties for Complex Data types
@@ -0,0 +1,6 @@
1
+ export interface IFFGetLogicByDatasets {
2
+ letPassUndefinedProperties?: {
3
+ qrveyid?: boolean;
4
+ }
5
+ filterEmptyArrays?: boolean;
6
+ }
@@ -0,0 +1,7 @@
1
+ export interface IFFGetLogicByDatasetsColumns {
2
+ letPassUndefinedProperties?: {
3
+ qrveyid?: boolean;
4
+ questionid?: boolean;
5
+ }
6
+ filterEmptyArrays?: boolean;
7
+ }
@@ -1,3 +1,5 @@
1
+ export * from './IFFGetLogicByDatasets';
2
+ export * from './IFFGetLogicByDatasetsColumns';
1
3
  export * from './IFFiltersGetData';
2
4
  export * from './IFFiltersGetValuesFromDataset';
3
5
  export * from './IFFiltersGetValuesFromModel';
@@ -28,6 +28,7 @@ import { IFFiltersGetData } from '../interfaces/functions/IFFiltersGetData';
28
28
  import { getFiltersByDatasetsColumns } from '../helpers/common/getFiltersByDatasetsColumns';
29
29
  import { IFUData } from '../interfaces/ui/IFUData';
30
30
  import { getDatasetByColumn } from '../../qrvey/helpers/getDatasetByColumn';
31
+ import { getLogicByDatasets } from '../helpers/backend/getLogicByDatasets';
31
32
 
32
33
 
33
34
  interface IFilterApiConfig extends IFilterConfig {
@@ -109,14 +110,15 @@ export class FiltersApi {
109
110
  private getLogic(config: IFSGetDataValues) {
110
111
  const scopes = this.getAvailableScopeIds(config);
111
112
  let filterData = getFiltersByVisibility(config.filterData, scopes);
112
- filterData = getFiltersByDatasetsColumns(filterData as IFUData, config.datasets);
113
+ const dataset = config.datasets.find(d => d.qrveyid === config.filter?.column.qrveyid);
114
+ filterData = getFiltersByDatasetsColumns(filterData as IFUData, isEmpty(dataset) ? [] : [dataset]);
113
115
  filterData = excludeFiltersByAggregateColumn(filterData);
114
116
  const logics = FDToLogic(filterData);
115
117
  const hierarchyLogic = getLogicByScopesHierarchy(logics, scopes, config.filter?.extras.scope);
116
118
 
117
119
  return [
118
120
  ...hierarchyLogic,
119
- ...buildUserFilters(config.userFilters) || [],
121
+ ...getLogicByDatasets(buildUserFilters(config.userFilters), isEmpty(dataset) ? [] : [dataset.qrveyid]) || [],
120
122
  ];
121
123
  }
122
124
 
@@ -30,7 +30,7 @@ function getI18nMonthLabel(label: string, translate?: II18nServiceTranslate): st
30
30
 
31
31
  function getI18nYearMonthLabel(label: string, translate?: II18nServiceTranslate): string {
32
32
  if (!isTokenLabel(label) && !isEmpty(translate)) {
33
- const month = getI18nMonthPropertyByIndex(DATE_YEAR_MONTHS.findIndex(month => month === label));
33
+ const month = getI18nMonthPropertyByIndex(DATE_YEAR_MONTHS.findIndex(_month => _month === label));
34
34
  if (!isEmpty(month)) label = translate('common.date_grouping.' + month + '_mmm');
35
35
  }
36
36
  return label;
@@ -11,9 +11,9 @@ import { BColumnsToUIColumns } from "./BColumnsToUIColumns.adapter";
11
11
  export function BBranchesMapToUIBranchesMap(branchesMap: IBModelBranchesMap[]): IModelBranchesMap[] {
12
12
  if (isEmpty(branchesMap)) return [];
13
13
 
14
- return branchesMap.map(branchesMap => ({
15
- questionid: branchesMap.questionid,
16
- branches: branchesMap.branches.map(branch => ({
14
+ return branchesMap.map(branchMap => ({
15
+ questionid: branchMap.questionid,
16
+ branches: branchMap.branches.map(branch => ({
17
17
  columns: BColumnsToUIColumns(branch.questions.data)
18
18
  }))
19
19
  }));
@@ -0,0 +1,312 @@
1
+ // const { buildUserFilters, getLogicByDatasetsColumns } = require('../../../dist/cjs');
2
+
3
+ // // 1- Buen questionid y qrveyid
4
+ // const userFilters = {
5
+ // filters: [
6
+ // {
7
+ // operator: "AND",
8
+ // expressions: [
9
+ // {
10
+ // questionid: "OTCK9KZe2",
11
+ // qrveyid: "mSdv9Qjm5",
12
+ // validationType: "BETWEEN",
13
+ // value: [
14
+ // {
15
+ // lte: "15",
16
+ // gte: "10"
17
+ // },
18
+ // {
19
+ // lte: "30",
20
+ // gte: "20"
21
+ // }
22
+ // ]
23
+ // }
24
+ // ]
25
+ // }
26
+ // ]
27
+ // };
28
+
29
+ // // 2 - Buen questionid sin qrveyid
30
+ // const userFilters2 = {
31
+ // filters: [
32
+ // {
33
+ // operator: "AND",
34
+ // expressions: [
35
+ // {
36
+ // questionid: "OTCK9KZe2",
37
+ // validationType: "BETWEEN",
38
+ // value: [
39
+ // {
40
+ // lte: "15",
41
+ // gte: "10"
42
+ // },
43
+ // {
44
+ // lte: "30",
45
+ // gte: "20"
46
+ // }
47
+ // ]
48
+ // }
49
+ // ]
50
+ // }
51
+ // ]
52
+ // };
53
+
54
+ // // 3 - Buen questionid con mal qrveyid
55
+ // const userFilters3 = {
56
+ // filters: [
57
+ // {
58
+ // operator: "AND",
59
+ // expressions: [
60
+ // {
61
+ // questionid: "OTCK9KZe2",
62
+ // qrveyid: "mSdv9Qjm55",
63
+ // validationType: "BETWEEN",
64
+ // value: [
65
+ // {
66
+ // lte: "15",
67
+ // gte: "10"
68
+ // },
69
+ // {
70
+ // lte: "30",
71
+ // gte: "20"
72
+ // }
73
+ // ]
74
+ // }
75
+ // ]
76
+ // }
77
+ // ]
78
+ // };
79
+
80
+ // // 4 - Mal questionid con buen qrveyid
81
+ // const userFilters4 = {
82
+ // filters: [
83
+ // {
84
+ // operator: "AND",
85
+ // expressions: [
86
+ // {
87
+ // questionid: "OTCK9KZe22",
88
+ // qrveyid: "mSdv9Qjm5",
89
+ // validationType: "BETWEEN",
90
+ // value: [
91
+ // {
92
+ // lte: "15",
93
+ // gte: "10"
94
+ // },
95
+ // {
96
+ // lte: "30",
97
+ // gte: "20"
98
+ // }
99
+ // ]
100
+ // }
101
+ // ]
102
+ // }
103
+ // ]
104
+ // };
105
+
106
+ // // 5 - Mal questionid sin qrveyid
107
+ // const userFilters5 = {
108
+ // filters: [
109
+ // {
110
+ // operator: "AND",
111
+ // expressions: [
112
+ // {
113
+ // questionid: "OTCK9KZe22",
114
+ // validationType: "BETWEEN",
115
+ // value: [
116
+ // {
117
+ // lte: "15",
118
+ // gte: "10"
119
+ // },
120
+ // {
121
+ // lte: "30",
122
+ // gte: "20"
123
+ // }
124
+ // ]
125
+ // }
126
+ // ]
127
+ // }
128
+ // ]
129
+ // };
130
+
131
+ // // 6 - Mal questionid con mal qrveyid
132
+ // const userFilters6 = {
133
+ // filters: [
134
+ // {
135
+ // operator: "AND",
136
+ // expressions: [
137
+ // {
138
+ // questionid: "OTCK9KZe22",
139
+ // qrveyid: "mSdv9Qjm55",
140
+ // validationType: "BETWEEN",
141
+ // value: [
142
+ // {
143
+ // lte: "15",
144
+ // gte: "10"
145
+ // },
146
+ // {
147
+ // lte: "30",
148
+ // gte: "20"
149
+ // }
150
+ // ]
151
+ // }
152
+ // ]
153
+ // }
154
+ // ]
155
+ // };
156
+
157
+ // // 7 - Sin questionid con buen qrveyid
158
+ // const userFilters7 = {
159
+ // filters: [
160
+ // {
161
+ // operator: "AND",
162
+ // expressions: [
163
+ // {
164
+ // qrveyid: "mSdv9Qjm5",
165
+ // validationType: "BETWEEN",
166
+ // value: [
167
+ // {
168
+ // lte: "15",
169
+ // gte: "10"
170
+ // },
171
+ // {
172
+ // lte: "30",
173
+ // gte: "20"
174
+ // }
175
+ // ]
176
+ // }
177
+ // ]
178
+ // }
179
+ // ]
180
+ // };
181
+
182
+ // // 8 - Sin questionid y sin qrveyid
183
+ // const userFilters8 = {
184
+ // filters: [
185
+ // {
186
+ // operator: "AND",
187
+ // expressions: [
188
+ // {
189
+ // validationType: "BETWEEN",
190
+ // value: [
191
+ // {
192
+ // lte: "15",
193
+ // gte: "10"
194
+ // },
195
+ // {
196
+ // lte: "30",
197
+ // gte: "20"
198
+ // }
199
+ // ]
200
+ // }
201
+ // ]
202
+ // }
203
+ // ]
204
+ // };
205
+
206
+ // // 9 - Sin questionid con mal qrveyid
207
+ // const userFilters9 = {
208
+ // filters: [
209
+ // {
210
+ // operator: "AND",
211
+ // expressions: [
212
+ // {
213
+ // qrveyid: "mSdv9Qjm55",
214
+ // validationType: "BETWEEN",
215
+ // value: [
216
+ // {
217
+ // lte: "15",
218
+ // gte: "10"
219
+ // },
220
+ // {
221
+ // lte: "30",
222
+ // gte: "20"
223
+ // }
224
+ // ]
225
+ // }
226
+ // ]
227
+ // }
228
+ // ]
229
+ // };
230
+
231
+ // const datasets = [
232
+ // {
233
+ // "qrveyid": "mSdv9Qjm5",
234
+ // "label": "SQL SELECT ALL - NewView SELECT ALL",
235
+ // "options": [
236
+ // {
237
+ // "id": "OTCK9KZe2",
238
+ // "label": "id",
239
+ // "outputFormat": {
240
+ // "format": "Numeric",
241
+ // "numericType": "INTEGER",
242
+ // "type": "NUMERIC",
243
+ // "decimals": "0"
244
+ // },
245
+ // "qrveyid": "mSdv9Qjm5",
246
+ // "type": "NUMERIC"
247
+ // },
248
+ // {
249
+ // "id": "pL4N25I67",
250
+ // "label": "date_1",
251
+ // "outputFormat": {
252
+ // "type": "DATE",
253
+ // "format": "MM/DD/YYYY"
254
+ // },
255
+ // "qrveyid": "mSdv9Qjm5",
256
+ // "type": "DATE"
257
+ // },
258
+ // {
259
+ // "id": "VvHNwFfjQ",
260
+ // "label": "date_2_dt",
261
+ // "outputFormat": {
262
+ // "type": "DATE",
263
+ // "format": "MM/DD/YYYY"
264
+ // },
265
+ // "qrveyid": "mSdv9Qjm5",
266
+ // "type": "DATE"
267
+ // },
268
+ // {
269
+ // "id": "Em6zxp2Ch",
270
+ // "label": "country",
271
+ // "qrveyid": "mSdv9Qjm5",
272
+ // "type": "TEXT_LABEL"
273
+ // },
274
+ // {
275
+ // "id": "J6Oq48t8F",
276
+ // "label": "epoch",
277
+ // "outputFormat": {
278
+ // "type": "DATE",
279
+ // "format": "MM/DD/YYYY"
280
+ // },
281
+ // "qrveyid": "mSdv9Qjm5",
282
+ // "type": "DATE"
283
+ // }
284
+ // ]
285
+ // }
286
+ // ];
287
+
288
+ // console.log('1 - Buen questionid y buen qrveyid');
289
+ // getLogicByDatasetsColumns(buildUserFilters(userFilters), datasets);
290
+ // console.log('2 - Buen questionid sin qrveyid');
291
+ // getLogicByDatasetsColumns(buildUserFilters(userFilters2), datasets);
292
+ // console.log('3 - Buen questionid con mal qrveyid');
293
+ // getLogicByDatasetsColumns(buildUserFilters(userFilters3), datasets);
294
+ // console.log('4 - Mal questionid con buen qrveyid');
295
+ // getLogicByDatasetsColumns(buildUserFilters(userFilters4), datasets);
296
+ // console.log('5 - Mal questionid sin qrveyid');
297
+ // getLogicByDatasetsColumns(buildUserFilters(userFilters5), datasets);
298
+ // console.log('6 - Mal questionid y mal qrveyid');
299
+ // getLogicByDatasetsColumns(buildUserFilters(userFilters6), datasets);
300
+ // console.log('7 - Sin questionid con buen qrveyid');
301
+ // getLogicByDatasetsColumns(buildUserFilters(userFilters7), datasets);
302
+ // console.log('8 - Sin questionid y sin qrveyid');
303
+ // getLogicByDatasetsColumns(buildUserFilters(userFilters8), datasets);
304
+ // console.log('9 - Sin questionid con mal qrveyid');
305
+ // getLogicByDatasetsColumns(buildUserFilters(userFilters9), datasets);
306
+
307
+
308
+ describe('Dummy test', function () {
309
+ test('Dummy test #1', function () {
310
+ expect([]).toEqual([]);
311
+ });
312
+ });