@qrvey/utils 1.3.0-16 → 1.3.0-17

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/.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 {
@@ -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);
@@ -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 {
@@ -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);
@@ -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-17",
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 {
@@ -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,
@@ -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
  }));