@qrvey/utils 1.8.0-5 → 1.8.0-7

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-5*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.8.0-7*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -56,7 +56,7 @@ const isComparison = (data) => Boolean(data === null || data === void 0 ? void 0
56
56
  export const metricMakeTimeData = (dateColumn, timeData, range) => {
57
57
  const relativObject = getConfigRelativeObjectBytimeLabel(timeData.label, range);
58
58
  if (!isEmpty(relativObject))
59
- return Object.assign(Object.assign({}, relativObject), { questionid: dateColumn.id });
59
+ return Object.assign(Object.assign({}, relativObject), { questionid: dateColumn.id, type: dateColumn === null || dateColumn === void 0 ? void 0 : dateColumn.type });
60
60
  };
61
61
  /**
62
62
  * Given a time label and a custom range, return a relative date config or a metric custom range.
@@ -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";
@@ -1,4 +1,4 @@
1
- import { IBColumn } from "../../columns";
1
+ import { IBColumn, IColumnType } from "../../columns";
2
2
  import { IDateGroupingProperty, RelativeCursor } from "../../dates";
3
3
  import { IFBLogic } from "../../filters";
4
4
  import { TimePeriod, TP_CUSTOM_RANGE } from "../../interfaces";
@@ -43,6 +43,7 @@ export declare type RelativeDateConfig = {
43
43
  unit: IDateGroupingProperty;
44
44
  includeCurrent?: boolean;
45
45
  isCalendarDate?: boolean;
46
+ type?: IColumnType;
46
47
  };
47
48
  /**
48
49
  * `MetricCustomRange` is a type that has a property called `customRange` that is of type
@@ -51,6 +52,7 @@ export declare type RelativeDateConfig = {
51
52
  */
52
53
  export declare type MetricCustomRange = {
53
54
  customRange: CustomRange;
55
+ type?: IColumnType;
54
56
  };
55
57
  /**
56
58
  * `CustomRangeConfig` is an object with optional properties `startingDate`, `endDate`, and `label`.
@@ -60,7 +60,7 @@ const isComparison = (data) => Boolean(data === null || data === void 0 ? void 0
60
60
  const metricMakeTimeData = (dateColumn, timeData, range) => {
61
61
  const relativObject = getConfigRelativeObjectBytimeLabel(timeData.label, range);
62
62
  if (!(0, general_1.isEmpty)(relativObject))
63
- return Object.assign(Object.assign({}, relativObject), { questionid: dateColumn.id });
63
+ return Object.assign(Object.assign({}, relativObject), { questionid: dateColumn.id, type: dateColumn === null || dateColumn === void 0 ? void 0 : dateColumn.type });
64
64
  };
65
65
  exports.metricMakeTimeData = metricMakeTimeData;
66
66
  /**
@@ -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);
@@ -1,4 +1,4 @@
1
- import { IBColumn } from "../../columns";
1
+ import { IBColumn, IColumnType } from "../../columns";
2
2
  import { IDateGroupingProperty, RelativeCursor } from "../../dates";
3
3
  import { IFBLogic } from "../../filters";
4
4
  import { TimePeriod, TP_CUSTOM_RANGE } from "../../interfaces";
@@ -43,6 +43,7 @@ export declare type RelativeDateConfig = {
43
43
  unit: IDateGroupingProperty;
44
44
  includeCurrent?: boolean;
45
45
  isCalendarDate?: boolean;
46
+ type?: IColumnType;
46
47
  };
47
48
  /**
48
49
  * `MetricCustomRange` is a type that has a property called `customRange` that is of type
@@ -51,6 +52,7 @@ export declare type RelativeDateConfig = {
51
52
  */
52
53
  export declare type MetricCustomRange = {
53
54
  customRange: CustomRange;
55
+ type?: IColumnType;
54
56
  };
55
57
  /**
56
58
  * `CustomRangeConfig` is an object with optional properties `startingDate`, `endDate`, and `label`.
@@ -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;
@@ -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";
@@ -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
  }
@@ -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-5",
3
+ "version": "1.8.0-7",
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",