@qrvey/utils 1.8.0-6 → 1.8.0-8

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.8.0-6*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.8.0-8*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -0,0 +1,4 @@
1
+ export declare function getChartComparison(comparisonItem: any): {
2
+ comparison: import("..").RelativeDateConfig | import("..").MetricCustomRange;
3
+ period: import("..").RelativeDateConfig | import("..").MetricCustomRange;
4
+ };
@@ -0,0 +1,20 @@
1
+ import { isEmpty } from "../../general/mix/isEmpty";
2
+ import { metricMakeTimeData } from "../adapters/RequestAdapterMetric";
3
+ export function getChartComparison(comparisonItem) {
4
+ var _a, _b, _c, _d;
5
+ if (isEmpty(comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.comparison))
6
+ return undefined;
7
+ const { comparison, id, qrveyid, text, type } = comparisonItem;
8
+ const dateColumn = { id, qrveyid, text, type };
9
+ const makeComparison = metricMakeTimeData(dateColumn, { key: "", label: comparison.time_comparison.value, text: "" }, {
10
+ startingDate: (_a = comparison.time_comparison) === null || _a === void 0 ? void 0 : _a.start,
11
+ endDate: (_b = comparison.time_comparison) === null || _b === void 0 ? void 0 : _b.end,
12
+ label: comparison.time_comparison.range,
13
+ });
14
+ const makePeriod = metricMakeTimeData(dateColumn, { key: "", label: comparison.time_period.value, text: "" }, {
15
+ startingDate: (_c = comparison.time_period) === null || _c === void 0 ? void 0 : _c.start,
16
+ endDate: (_d = comparison.time_period) === null || _d === void 0 ? void 0 : _d.end,
17
+ label: comparison.time_period.range,
18
+ });
19
+ return { comparison: makeComparison, period: makePeriod };
20
+ }
@@ -1,3 +1,4 @@
1
1
  export * from "./isExpandableTableChart";
2
2
  export * from "./isSimpleTableChart";
3
3
  export * from "./isTableChart";
4
+ export * from "./getChartComparison";
@@ -1,3 +1,4 @@
1
1
  export * from "./isExpandableTableChart";
2
2
  export * from "./isSimpleTableChart";
3
3
  export * from "./isTableChart";
4
+ export * from "./getChartComparison";
@@ -1,3 +1,4 @@
1
1
  export * from "./constants/index";
2
2
  export * from "./interfaces/index";
3
3
  export * from "./adapters/index";
4
+ export * from "./helpers/index";
@@ -1,3 +1,4 @@
1
1
  export * from "./constants/index";
2
2
  export * from "./interfaces/index";
3
3
  export * from "./adapters/index";
4
+ export * from "./helpers/index";
@@ -0,0 +1,4 @@
1
+ export declare function getChartComparison(comparisonItem: any): {
2
+ comparison: import("..").RelativeDateConfig | import("..").MetricCustomRange;
3
+ period: import("..").RelativeDateConfig | import("..").MetricCustomRange;
4
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getChartComparison = void 0;
4
+ const isEmpty_1 = require("../../general/mix/isEmpty");
5
+ const RequestAdapterMetric_1 = require("../adapters/RequestAdapterMetric");
6
+ function getChartComparison(comparisonItem) {
7
+ var _a, _b, _c, _d;
8
+ if ((0, isEmpty_1.isEmpty)(comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.comparison))
9
+ return undefined;
10
+ const { comparison, id, qrveyid, text, type } = comparisonItem;
11
+ const dateColumn = { id, qrveyid, text, type };
12
+ const makeComparison = (0, RequestAdapterMetric_1.metricMakeTimeData)(dateColumn, { key: "", label: comparison.time_comparison.value, text: "" }, {
13
+ startingDate: (_a = comparison.time_comparison) === null || _a === void 0 ? void 0 : _a.start,
14
+ endDate: (_b = comparison.time_comparison) === null || _b === void 0 ? void 0 : _b.end,
15
+ label: comparison.time_comparison.range,
16
+ });
17
+ const makePeriod = (0, RequestAdapterMetric_1.metricMakeTimeData)(dateColumn, { key: "", label: comparison.time_period.value, text: "" }, {
18
+ startingDate: (_c = comparison.time_period) === null || _c === void 0 ? void 0 : _c.start,
19
+ endDate: (_d = comparison.time_period) === null || _d === void 0 ? void 0 : _d.end,
20
+ label: comparison.time_period.range,
21
+ });
22
+ return { comparison: makeComparison, period: makePeriod };
23
+ }
24
+ exports.getChartComparison = getChartComparison;
@@ -1,3 +1,4 @@
1
1
  export * from "./isExpandableTableChart";
2
2
  export * from "./isSimpleTableChart";
3
3
  export * from "./isTableChart";
4
+ export * from "./getChartComparison";
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./isExpandableTableChart"), exports);
18
18
  __exportStar(require("./isSimpleTableChart"), exports);
19
19
  __exportStar(require("./isTableChart"), exports);
20
+ __exportStar(require("./getChartComparison"), exports);
@@ -1,3 +1,4 @@
1
1
  export * from "./constants/index";
2
2
  export * from "./interfaces/index";
3
3
  export * from "./adapters/index";
4
+ export * from "./helpers/index";
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./constants/index"), exports);
18
18
  __exportStar(require("./interfaces/index"), exports);
19
19
  __exportStar(require("./adapters/index"), exports);
20
+ __exportStar(require("./helpers/index"), exports);
@@ -34,7 +34,7 @@ function getTokensFromFilters(filters, options) {
34
34
  continue;
35
35
  if (options.showScope) {
36
36
  tokens.push({
37
- token: i18nService.translate(`filter.scope_title.${scope.scope.toLowerCase()}`) + ":",
37
+ token: `${i18nService.translate(`filter.scope_title.${scope.scope.toLowerCase()}`)}:`,
38
38
  type: FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.SCOPE,
39
39
  });
40
40
  }
@@ -44,7 +44,7 @@ function getTokensFromFilters(filters, options) {
44
44
  continue;
45
45
  if (options.showDatabaseName) {
46
46
  tokens.push({
47
- token: database.label + ":",
47
+ token: `${database.label}:`,
48
48
  type: FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.DATABASE_NAME,
49
49
  });
50
50
  }
@@ -60,27 +60,26 @@ function getTokensFromFilters(filters, options) {
60
60
  if (!thereIsFiltersWithValues)
61
61
  thereIsFiltersWithValues = true;
62
62
  if (options.showChartName && scope.scope === constants_1.FILTER_SCOPE.CHART) {
63
- const searchToken = tokens.find((token) => token.token === filter.extras.filterLabel + ":");
63
+ const searchToken = tokens.find((token) => token.token === `${filter.extras.filterLabel}:` &&
64
+ token.id === filter.extras.panelid);
64
65
  if (!searchToken) {
65
66
  if (((_b = tokens[tokens.length - 1]) === null || _b === void 0 ? void 0 : _b.type) ===
66
67
  FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.LOGICAL_OPERATOR) {
67
68
  tokens.pop();
68
69
  }
69
70
  tokens.push({
70
- token: filter.extras.filterLabel + ":",
71
+ token: `${filter.extras.filterLabel}:`,
71
72
  type: FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.CHART_NAME,
73
+ id: filter.extras.panelid,
72
74
  });
73
75
  }
74
76
  }
75
77
  let columnLabel = filter.column.label;
76
78
  if ((_c = filter === null || filter === void 0 ? void 0 : filter.column) === null || _c === void 0 ? void 0 : _c.aggregate) {
77
- columnLabel +=
78
- " (" +
79
- i18nService.translate(`common.aggregate_labels.${(_d = filter === null || filter === void 0 ? void 0 : filter.column) === null || _d === void 0 ? void 0 : _d.aggregate.toLowerCase()}`) +
80
- ")";
79
+ columnLabel += ` (${i18nService.translate(`common.aggregate_labels.${(_d = filter === null || filter === void 0 ? void 0 : filter.column) === null || _d === void 0 ? void 0 : _d.aggregate.toLowerCase()}`)})`;
81
80
  }
82
81
  tokens.push({
83
- token: columnLabel + ":",
82
+ token: `${columnLabel}:`,
84
83
  type: FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.COLUMN_NAME,
85
84
  });
86
85
  const property = (0, getFilterPropertyLabel_1.getFilterPropertyLabel)(filter, settings.translate);
@@ -3,20 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformFilterValues = void 0;
4
4
  const isEmpty_1 = require("../../../general/mix/isEmpty");
5
5
  const transformValue_1 = require("../../../qrvey/helpers/transformValue");
6
- const common_1 = require("../common");
6
+ const isInValidator_1 = require("../common/isInValidator");
7
7
  const isRangeValidator_1 = require("../common/isRangeValidator");
8
+ const isRankingFilter_1 = require("../common/isRankingFilter");
8
9
  const isRegularValidator_1 = require("../common/isRegularValidator");
9
10
  function transformFilterValues(filter, settings) {
10
11
  const transformValueSettings = Object.assign(Object.assign({}, settings), { column: filter.column, property: filter.property });
11
12
  if ((0, isEmpty_1.isEmpty)(filter))
12
13
  return [];
13
14
  const values = filter.values || [];
14
- if ((0, isRegularValidator_1.isRegularValidator)(filter.validator) && !(0, common_1.isRankingFilter)(filter)) {
15
+ if ((0, isRegularValidator_1.isRegularValidator)(filter.validator) && !(0, isRankingFilter_1.isRankingFilter)(filter)) {
15
16
  return values.map((value) => (Object.assign(Object.assign({}, value), { value: (0, transformValue_1.transformValue)(value.value, transformValueSettings) })));
16
17
  }
17
18
  else if ((0, isRangeValidator_1.isRangeValidator)(filter.validator)) {
18
19
  return values.map((value) => (Object.assign(Object.assign({}, value), { min: (0, transformValue_1.transformValue)(value.min, transformValueSettings), max: (0, transformValue_1.transformValue)(value.max, transformValueSettings) })));
19
20
  }
21
+ else if ((0, isInValidator_1.isInValidator)(filter.validator)) {
22
+ return values.map((value) => (Object.assign(Object.assign({}, value), { anchor: typeof value.anchor === "string"
23
+ ? (0, transformValue_1.transformValue)(value.anchor, transformValueSettings)
24
+ : value.anchor })));
25
+ }
20
26
  return values;
21
27
  }
22
28
  exports.transformFilterValues = transformFilterValues;
@@ -2,4 +2,5 @@ import { FILTER_TOKENS_STRUCTURE_TYPE } from "../constants/common/FILTER_TOKENS_
2
2
  export interface IFFilterTokens {
3
3
  token: string;
4
4
  type: FILTER_TOKENS_STRUCTURE_TYPE;
5
+ id?: string;
5
6
  }
@@ -38,8 +38,9 @@ function getOutputFormat(settings) {
38
38
  DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.HOUR,
39
39
  DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.MINUTE,
40
40
  DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.SECOND,
41
+ undefined,
41
42
  ].includes(settings.property);
42
- const isDate = [DATE_GROUPING_PROPERTY_1.DATE_GROUPING_PROPERTY.DAY].includes(settings.property);
43
+ const isDate = [DATE_GROUPING_PROPERTY_1.DATE_GROUPING_PROPERTY.DAY, undefined].includes(settings.property);
43
44
  if ((0, isDateColumn_1.isDateColumn)(settings.column) && (isDate || isDateTime)) {
44
45
  type = "DATE";
45
46
  format = "Default";
@@ -31,7 +31,7 @@ export function getTokensFromFilters(filters, options) {
31
31
  continue;
32
32
  if (options.showScope) {
33
33
  tokens.push({
34
- token: i18nService.translate(`filter.scope_title.${scope.scope.toLowerCase()}`) + ":",
34
+ token: `${i18nService.translate(`filter.scope_title.${scope.scope.toLowerCase()}`)}:`,
35
35
  type: FILTER_TOKENS_STRUCTURE_TYPE.SCOPE,
36
36
  });
37
37
  }
@@ -41,7 +41,7 @@ export function getTokensFromFilters(filters, options) {
41
41
  continue;
42
42
  if (options.showDatabaseName) {
43
43
  tokens.push({
44
- token: database.label + ":",
44
+ token: `${database.label}:`,
45
45
  type: FILTER_TOKENS_STRUCTURE_TYPE.DATABASE_NAME,
46
46
  });
47
47
  }
@@ -57,27 +57,26 @@ export function getTokensFromFilters(filters, options) {
57
57
  if (!thereIsFiltersWithValues)
58
58
  thereIsFiltersWithValues = true;
59
59
  if (options.showChartName && scope.scope === FILTER_SCOPE.CHART) {
60
- const searchToken = tokens.find((token) => token.token === filter.extras.filterLabel + ":");
60
+ const searchToken = tokens.find((token) => token.token === `${filter.extras.filterLabel}:` &&
61
+ token.id === filter.extras.panelid);
61
62
  if (!searchToken) {
62
63
  if (((_b = tokens[tokens.length - 1]) === null || _b === void 0 ? void 0 : _b.type) ===
63
64
  FILTER_TOKENS_STRUCTURE_TYPE.LOGICAL_OPERATOR) {
64
65
  tokens.pop();
65
66
  }
66
67
  tokens.push({
67
- token: filter.extras.filterLabel + ":",
68
+ token: `${filter.extras.filterLabel}:`,
68
69
  type: FILTER_TOKENS_STRUCTURE_TYPE.CHART_NAME,
70
+ id: filter.extras.panelid,
69
71
  });
70
72
  }
71
73
  }
72
74
  let columnLabel = filter.column.label;
73
75
  if ((_c = filter === null || filter === void 0 ? void 0 : filter.column) === null || _c === void 0 ? void 0 : _c.aggregate) {
74
- columnLabel +=
75
- " (" +
76
- i18nService.translate(`common.aggregate_labels.${(_d = filter === null || filter === void 0 ? void 0 : filter.column) === null || _d === void 0 ? void 0 : _d.aggregate.toLowerCase()}`) +
77
- ")";
76
+ columnLabel += ` (${i18nService.translate(`common.aggregate_labels.${(_d = filter === null || filter === void 0 ? void 0 : filter.column) === null || _d === void 0 ? void 0 : _d.aggregate.toLowerCase()}`)})`;
78
77
  }
79
78
  tokens.push({
80
- token: columnLabel + ":",
79
+ token: `${columnLabel}:`,
81
80
  type: FILTER_TOKENS_STRUCTURE_TYPE.COLUMN_NAME,
82
81
  });
83
82
  const property = getFilterPropertyLabel(filter, settings.translate);
@@ -1,7 +1,8 @@
1
1
  import { isEmpty } from "../../../general/mix/isEmpty";
2
2
  import { transformValue } from "../../../qrvey/helpers/transformValue";
3
- import { isRankingFilter } from "../common";
3
+ import { isInValidator } from "../common/isInValidator";
4
4
  import { isRangeValidator } from "../common/isRangeValidator";
5
+ import { isRankingFilter } from "../common/isRankingFilter";
5
6
  import { isRegularValidator } from "../common/isRegularValidator";
6
7
  export function transformFilterValues(filter, settings) {
7
8
  const transformValueSettings = Object.assign(Object.assign({}, settings), { column: filter.column, property: filter.property });
@@ -14,5 +15,10 @@ export function transformFilterValues(filter, settings) {
14
15
  else if (isRangeValidator(filter.validator)) {
15
16
  return values.map((value) => (Object.assign(Object.assign({}, value), { min: transformValue(value.min, transformValueSettings), max: transformValue(value.max, transformValueSettings) })));
16
17
  }
18
+ else if (isInValidator(filter.validator)) {
19
+ return values.map((value) => (Object.assign(Object.assign({}, value), { anchor: typeof value.anchor === "string"
20
+ ? transformValue(value.anchor, transformValueSettings)
21
+ : value.anchor })));
22
+ }
17
23
  return values;
18
24
  }
@@ -2,4 +2,5 @@ import { FILTER_TOKENS_STRUCTURE_TYPE } from "../constants/common/FILTER_TOKENS_
2
2
  export interface IFFilterTokens {
3
3
  token: string;
4
4
  type: FILTER_TOKENS_STRUCTURE_TYPE;
5
+ id?: string;
5
6
  }
@@ -34,8 +34,9 @@ function getOutputFormat(settings) {
34
34
  DATE_GROUPING_TIME_PROPERTY.HOUR,
35
35
  DATE_GROUPING_TIME_PROPERTY.MINUTE,
36
36
  DATE_GROUPING_TIME_PROPERTY.SECOND,
37
+ undefined,
37
38
  ].includes(settings.property);
38
- const isDate = [DATE_GROUPING_PROPERTY.DAY].includes(settings.property);
39
+ const isDate = [DATE_GROUPING_PROPERTY.DAY, undefined].includes(settings.property);
39
40
  if (isDateColumn(settings.column) && (isDate || isDateTime)) {
40
41
  type = "DATE";
41
42
  format = "Default";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.8.0-6",
3
+ "version": "1.8.0-8",
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",