@qrvey/utils 1.8.0-2 → 1.8.0-4

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 (24) hide show
  1. package/README.md +1 -1
  2. package/dist/charts/adapters/RequestAdapterMetric.d.ts +14 -1
  3. package/dist/charts/adapters/RequestAdapterMetric.js +2 -2
  4. package/dist/cjs/charts/adapters/RequestAdapterMetric.d.ts +14 -1
  5. package/dist/cjs/charts/adapters/RequestAdapterMetric.js +5 -4
  6. package/dist/cjs/columns/helpers/isDateColumn.js +2 -1
  7. package/dist/cjs/columns/helpers/isNumericalColumn.js +2 -1
  8. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilder.d.ts +2 -0
  9. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderMessagesCombined.d.ts +3 -0
  10. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderMessagesCombined.js +2 -0
  11. package/dist/cjs/globalization/interfaces/chart_builder/index.d.ts +1 -0
  12. package/dist/cjs/globalization/interfaces/chart_builder/index.js +1 -0
  13. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.d.ts +1 -1
  14. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +3 -0
  15. package/dist/columns/helpers/isDateColumn.js +2 -1
  16. package/dist/columns/helpers/isNumericalColumn.js +2 -1
  17. package/dist/globalization/interfaces/chart_builder/II18nChartBuilder.d.ts +2 -0
  18. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderMessagesCombined.d.ts +3 -0
  19. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderMessagesCombined.js +1 -0
  20. package/dist/globalization/interfaces/chart_builder/index.d.ts +1 -0
  21. package/dist/globalization/interfaces/chart_builder/index.js +1 -0
  22. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.d.ts +1 -1
  23. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +3 -0
  24. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.8.0-2*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.8.0-4*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -1,7 +1,20 @@
1
- import { MetricConfig, MetricRequestPayload } from "../interfaces/IRequestAdapterMetric";
1
+ import { IBColumn } from "../../columns";
2
+ import { CustomRangeConfig, MetricConfig, MetricCustomRange, MetricPeriod, MetricRequestPayload, MetricTimeInfo } from "../interfaces/IRequestAdapterMetric";
2
3
  /**
3
4
  * It takes a metric object and returns a metric request object
4
5
  * @param {MetricConfig} metricObj - MetricConfigData
5
6
  * @returns A function that takes in a metricObj and returns a partial metricRequest
6
7
  */
7
8
  export declare const makeBodyRequestMetrics: (metricObj: MetricConfig) => Partial<MetricRequestPayload>;
9
+ /**
10
+ * It takes a date column, time data, and a custom range config and returns a metric period or metric
11
+ * custom range
12
+ * @param dateColumn - The column that contains the date data.
13
+ * @param timeData - {
14
+ * @param {CustomRangeConfig} range - CustomRangeConfig
15
+ * @returns An object with the following properties:
16
+ * - label
17
+ * - value
18
+ * - questionid
19
+ */
20
+ export declare const metricMakeTimeData: (dateColumn: IBColumn, timeData: MetricTimeInfo, range: CustomRangeConfig) => MetricPeriod | MetricCustomRange;
@@ -53,7 +53,7 @@ const isComparison = (data) => Boolean(data === null || data === void 0 ? void 0
53
53
  * - value
54
54
  * - questionid
55
55
  */
56
- const metricMakeTimeData = (dateColumn, timeData, range) => {
56
+ export const metricMakeTimeData = (dateColumn, timeData, range) => {
57
57
  const relativObject = getConfigRelativeObjectBytimeLabel(timeData.label, range);
58
58
  if (!isEmpty(relativObject))
59
59
  return Object.assign(Object.assign({}, relativObject), { questionid: dateColumn.id });
@@ -83,7 +83,7 @@ const makeCustomRangeConfig = (customRangeData) => {
83
83
  return { gte: startingDate };
84
84
  if (label === TP_CUSTOM_RANGE.BEFORE && !isEmpty(startingDate))
85
85
  return { lte: startingDate };
86
- if (!isEmpty(startingDate) && !isEmpty(endDate))
86
+ if (!isEmpty(startingDate) || !isEmpty(endDate))
87
87
  return { gte: startingDate, lte: endDate };
88
88
  };
89
89
  /**
@@ -1,7 +1,20 @@
1
- import { MetricConfig, MetricRequestPayload } from "../interfaces/IRequestAdapterMetric";
1
+ import { IBColumn } from "../../columns";
2
+ import { CustomRangeConfig, MetricConfig, MetricCustomRange, MetricPeriod, MetricRequestPayload, MetricTimeInfo } from "../interfaces/IRequestAdapterMetric";
2
3
  /**
3
4
  * It takes a metric object and returns a metric request object
4
5
  * @param {MetricConfig} metricObj - MetricConfigData
5
6
  * @returns A function that takes in a metricObj and returns a partial metricRequest
6
7
  */
7
8
  export declare const makeBodyRequestMetrics: (metricObj: MetricConfig) => Partial<MetricRequestPayload>;
9
+ /**
10
+ * It takes a date column, time data, and a custom range config and returns a metric period or metric
11
+ * custom range
12
+ * @param dateColumn - The column that contains the date data.
13
+ * @param timeData - {
14
+ * @param {CustomRangeConfig} range - CustomRangeConfig
15
+ * @returns An object with the following properties:
16
+ * - label
17
+ * - value
18
+ * - questionid
19
+ */
20
+ export declare const metricMakeTimeData: (dateColumn: IBColumn, timeData: MetricTimeInfo, range: CustomRangeConfig) => MetricPeriod | MetricCustomRange;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeBodyRequestMetrics = void 0;
3
+ exports.metricMakeTimeData = exports.makeBodyRequestMetrics = void 0;
4
4
  const general_1 = require("../../general");
5
5
  const interfaces_1 = require("../../interfaces");
6
6
  const REQUEST_ADAPTER_1 = require("../constants/REQUEST_ADAPTER");
@@ -17,8 +17,8 @@ const makeBodyRequestMetrics = (metricObj) => {
17
17
  /* Checking if the data object has a dateColumn property. If it does, it will add a period and
18
18
  comparison property to the body object. */
19
19
  if (isComparison(data)) {
20
- body.period = metricMakeTimeData(data.dateColumn, data.timePeriod, getRangeDataPeriod(data));
21
- body.comparison = metricMakeTimeData(data.dateColumn, data.comparison, getRangeDataComparison(data));
20
+ body.period = (0, exports.metricMakeTimeData)(data.dateColumn, data.timePeriod, getRangeDataPeriod(data));
21
+ body.comparison = (0, exports.metricMakeTimeData)(data.dateColumn, data.comparison, getRangeDataComparison(data));
22
22
  }
23
23
  return body;
24
24
  };
@@ -62,6 +62,7 @@ const metricMakeTimeData = (dateColumn, timeData, range) => {
62
62
  if (!(0, general_1.isEmpty)(relativObject))
63
63
  return Object.assign(Object.assign({}, relativObject), { questionid: dateColumn.id });
64
64
  };
65
+ exports.metricMakeTimeData = metricMakeTimeData;
65
66
  /**
66
67
  * Given a time label and a custom range, return a relative date config or a metric custom range.
67
68
  * @param {TIME_PERIOD} timeLabel - TIME_PERIOD.CUSTOM_RANGE
@@ -87,7 +88,7 @@ const makeCustomRangeConfig = (customRangeData) => {
87
88
  return { gte: startingDate };
88
89
  if (label === interfaces_1.TP_CUSTOM_RANGE.BEFORE && !(0, general_1.isEmpty)(startingDate))
89
90
  return { lte: startingDate };
90
- if (!(0, general_1.isEmpty)(startingDate) && !(0, general_1.isEmpty)(endDate))
91
+ if (!(0, general_1.isEmpty)(startingDate) || !(0, general_1.isEmpty)(endDate))
91
92
  return { gte: startingDate, lte: endDate };
92
93
  };
93
94
  /**
@@ -12,5 +12,6 @@ const FORMULA_1 = require("../../formulas/constants/FORMULA");
12
12
  */
13
13
  const isDateColumn = (column) => !(0, isEmpty_1.isEmpty)(column) &&
14
14
  (0, isObject_1.isObject)(column) &&
15
- (column.type === COLUMN_1.COLUMN.DATE || column.formulaType === FORMULA_1.FORMULA.DATE);
15
+ (column.type === COLUMN_1.COLUMN.DATE ||
16
+ (column.type === COLUMN_1.COLUMN.FORMULA && column.formulaType === FORMULA_1.FORMULA.DATE));
16
17
  exports.isDateColumn = isDateColumn;
@@ -4,6 +4,7 @@ exports.isNumericalColumn = void 0;
4
4
  const FORMULA_1 = require("../../formulas/constants/FORMULA");
5
5
  const isEmpty_1 = require("../../general/mix/isEmpty");
6
6
  const isObject_1 = require("../../general/object/isObject");
7
+ const COLUMN_1 = require("../constants/COLUMN");
7
8
  const NUMERICAL_COLUMNS_1 = require("../constants/NUMERICAL_COLUMNS");
8
9
  /**
9
10
  * Validates if the given column is numerical type
@@ -13,5 +14,5 @@ const NUMERICAL_COLUMNS_1 = require("../constants/NUMERICAL_COLUMNS");
13
14
  const isNumericalColumn = (column) => !(0, isEmpty_1.isEmpty)(column) &&
14
15
  (0, isObject_1.isObject)(column) &&
15
16
  (NUMERICAL_COLUMNS_1.NUMERICAL_COLUMNS.includes(column.type) ||
16
- column.formulaType === FORMULA_1.FORMULA.NUMBER);
17
+ (column.type === COLUMN_1.COLUMN.FORMULA && column.formulaType === FORMULA_1.FORMULA.NUMBER));
17
18
  exports.isNumericalColumn = isNumericalColumn;
@@ -57,6 +57,7 @@ import { II18nChartBuilderMessagesBoxWhiskers } from "./II18nChartBuilderMessage
57
57
  import { II18nChartBuilderMessagesDefault } from "./II18nChartBuilderMessagesDefault";
58
58
  import { II18nChartBuilderMessagesCrosstab } from "./II18nChartBuilderMessagesCrosstab";
59
59
  import { II18nChartBuilderMessagesTableChart } from "./II18nChartBuilderMessagesTableChart";
60
+ import { II18nChartBuilderMessagesCombined } from "./II18nChartBuilderMessagesCombined";
60
61
  import { II18nChartBuilderTrendsLine } from "./II18nChartBuilderTrendsLine";
61
62
  import { II18nChartBuilderReferenceLine } from "./II18nChartBuilderRefernceLine";
62
63
  import { II18nChartBuilderSmallMultiples } from "./II18nChartBuilderSmallMultiple";
@@ -117,6 +118,7 @@ export interface II18nChartBuilder {
117
118
  messages_ms: II18nChartBuilderMessagesMs;
118
119
  messages_pie: II18nChartBuilderMessagesPie;
119
120
  messages_table_chart: II18nChartBuilderMessagesTableChart;
121
+ messages_combined: II18nChartBuilderMessagesCombined;
120
122
  nav_panel: II18nChartBuilderNavPanel;
121
123
  operators: II18nChartBuilderOperators;
122
124
  references_line: II18nChartBuilderReferenceLine;
@@ -0,0 +1,3 @@
1
+ export interface II18nChartBuilderMessagesCombined {
2
+ column_missing: string;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -71,3 +71,4 @@ export * from "./II18nChartBuilderTimePeriodCustomRange";
71
71
  export * from "./II18nChartBuilderWordCloud";
72
72
  export * from "./II18nChartBuilderBoxWhisker";
73
73
  export * from "./II18nChartBuilderDurationParts";
74
+ export * from "./II18nChartBuilderMessagesCombined";
@@ -87,3 +87,4 @@ __exportStar(require("./II18nChartBuilderTimePeriodCustomRange"), exports);
87
87
  __exportStar(require("./II18nChartBuilderWordCloud"), exports);
88
88
  __exportStar(require("./II18nChartBuilderBoxWhisker"), exports);
89
89
  __exportStar(require("./II18nChartBuilderDurationParts"), exports);
90
+ __exportStar(require("./II18nChartBuilderMessagesCombined"), exports);
@@ -1,4 +1,4 @@
1
1
  import { II18nChartBuilder } from "../../interfaces/chart_builder/II18nChartBuilder";
2
- declare type General = "nav_panel" | "save_dialog" | "save_incomplete_dialog" | "leave_dialog" | "custom_format_dialog" | "data_panel" | "dimensions" | "shelf_menu" | "scale_types" | "trend_chart" | "chart_info" | "dnd_zone" | "chart_labels" | "action_panel" | "messages_general" | "messages_default" | "messages_crosstab" | "messages_table_chart" | "messages_missing_default" | "messages_ms" | "messages_pie" | "messages_min_max" | "messages_metric" | "messages_heatmap" | "messages_geo" | "messages_geo_bubble" | "messages_box_whiskers";
2
+ declare type General = "nav_panel" | "save_dialog" | "save_incomplete_dialog" | "leave_dialog" | "custom_format_dialog" | "data_panel" | "dimensions" | "shelf_menu" | "scale_types" | "trend_chart" | "chart_info" | "dnd_zone" | "chart_labels" | "action_panel" | "messages_general" | "messages_default" | "messages_crosstab" | "messages_table_chart" | "messages_missing_default" | "messages_ms" | "messages_pie" | "messages_min_max" | "messages_metric" | "messages_heatmap" | "messages_geo" | "messages_geo_bubble" | "messages_box_whiskers" | "messages_combined";
3
3
  export declare const I18N_CHART_BUILDER_GENERAL: Pick<II18nChartBuilder, General>;
4
4
  export {};
@@ -258,4 +258,7 @@ exports.I18N_CHART_BUILDER_GENERAL = {
258
258
  value_missing: "A <i>Value</i> column is needed for this chart.",
259
259
  distribution_missing: "A <i>Distribution</i> column is needed for this chart when the <i>Value</i> column is of non-numeric datatype.",
260
260
  },
261
+ messages_combined: {
262
+ column_missing: "A <i>Category</i>, a <i>Series</i> and at least two <i>Value</i> are needed for this chart.",
263
+ },
261
264
  };
@@ -9,4 +9,5 @@ import { FORMULA } from "../../formulas/constants/FORMULA";
9
9
  */
10
10
  export const isDateColumn = (column) => !isEmpty(column) &&
11
11
  isObject(column) &&
12
- (column.type === COLUMN.DATE || column.formulaType === FORMULA.DATE);
12
+ (column.type === COLUMN.DATE ||
13
+ (column.type === COLUMN.FORMULA && column.formulaType === FORMULA.DATE));
@@ -1,6 +1,7 @@
1
1
  import { FORMULA } from "../../formulas/constants/FORMULA";
2
2
  import { isEmpty } from "../../general/mix/isEmpty";
3
3
  import { isObject } from "../../general/object/isObject";
4
+ import { COLUMN } from "../constants/COLUMN";
4
5
  import { NUMERICAL_COLUMNS } from "../constants/NUMERICAL_COLUMNS";
5
6
  /**
6
7
  * Validates if the given column is numerical type
@@ -10,4 +11,4 @@ import { NUMERICAL_COLUMNS } from "../constants/NUMERICAL_COLUMNS";
10
11
  export const isNumericalColumn = (column) => !isEmpty(column) &&
11
12
  isObject(column) &&
12
13
  (NUMERICAL_COLUMNS.includes(column.type) ||
13
- column.formulaType === FORMULA.NUMBER);
14
+ (column.type === COLUMN.FORMULA && column.formulaType === FORMULA.NUMBER));
@@ -57,6 +57,7 @@ import { II18nChartBuilderMessagesBoxWhiskers } from "./II18nChartBuilderMessage
57
57
  import { II18nChartBuilderMessagesDefault } from "./II18nChartBuilderMessagesDefault";
58
58
  import { II18nChartBuilderMessagesCrosstab } from "./II18nChartBuilderMessagesCrosstab";
59
59
  import { II18nChartBuilderMessagesTableChart } from "./II18nChartBuilderMessagesTableChart";
60
+ import { II18nChartBuilderMessagesCombined } from "./II18nChartBuilderMessagesCombined";
60
61
  import { II18nChartBuilderTrendsLine } from "./II18nChartBuilderTrendsLine";
61
62
  import { II18nChartBuilderReferenceLine } from "./II18nChartBuilderRefernceLine";
62
63
  import { II18nChartBuilderSmallMultiples } from "./II18nChartBuilderSmallMultiple";
@@ -117,6 +118,7 @@ export interface II18nChartBuilder {
117
118
  messages_ms: II18nChartBuilderMessagesMs;
118
119
  messages_pie: II18nChartBuilderMessagesPie;
119
120
  messages_table_chart: II18nChartBuilderMessagesTableChart;
121
+ messages_combined: II18nChartBuilderMessagesCombined;
120
122
  nav_panel: II18nChartBuilderNavPanel;
121
123
  operators: II18nChartBuilderOperators;
122
124
  references_line: II18nChartBuilderReferenceLine;
@@ -0,0 +1,3 @@
1
+ export interface II18nChartBuilderMessagesCombined {
2
+ column_missing: string;
3
+ }
@@ -71,3 +71,4 @@ export * from "./II18nChartBuilderTimePeriodCustomRange";
71
71
  export * from "./II18nChartBuilderWordCloud";
72
72
  export * from "./II18nChartBuilderBoxWhisker";
73
73
  export * from "./II18nChartBuilderDurationParts";
74
+ export * from "./II18nChartBuilderMessagesCombined";
@@ -71,3 +71,4 @@ export * from "./II18nChartBuilderTimePeriodCustomRange";
71
71
  export * from "./II18nChartBuilderWordCloud";
72
72
  export * from "./II18nChartBuilderBoxWhisker";
73
73
  export * from "./II18nChartBuilderDurationParts";
74
+ export * from "./II18nChartBuilderMessagesCombined";
@@ -1,4 +1,4 @@
1
1
  import { II18nChartBuilder } from "../../interfaces/chart_builder/II18nChartBuilder";
2
- declare type General = "nav_panel" | "save_dialog" | "save_incomplete_dialog" | "leave_dialog" | "custom_format_dialog" | "data_panel" | "dimensions" | "shelf_menu" | "scale_types" | "trend_chart" | "chart_info" | "dnd_zone" | "chart_labels" | "action_panel" | "messages_general" | "messages_default" | "messages_crosstab" | "messages_table_chart" | "messages_missing_default" | "messages_ms" | "messages_pie" | "messages_min_max" | "messages_metric" | "messages_heatmap" | "messages_geo" | "messages_geo_bubble" | "messages_box_whiskers";
2
+ declare type General = "nav_panel" | "save_dialog" | "save_incomplete_dialog" | "leave_dialog" | "custom_format_dialog" | "data_panel" | "dimensions" | "shelf_menu" | "scale_types" | "trend_chart" | "chart_info" | "dnd_zone" | "chart_labels" | "action_panel" | "messages_general" | "messages_default" | "messages_crosstab" | "messages_table_chart" | "messages_missing_default" | "messages_ms" | "messages_pie" | "messages_min_max" | "messages_metric" | "messages_heatmap" | "messages_geo" | "messages_geo_bubble" | "messages_box_whiskers" | "messages_combined";
3
3
  export declare const I18N_CHART_BUILDER_GENERAL: Pick<II18nChartBuilder, General>;
4
4
  export {};
@@ -255,4 +255,7 @@ export const I18N_CHART_BUILDER_GENERAL = {
255
255
  value_missing: "A <i>Value</i> column is needed for this chart.",
256
256
  distribution_missing: "A <i>Distribution</i> column is needed for this chart when the <i>Value</i> column is of non-numeric datatype.",
257
257
  },
258
+ messages_combined: {
259
+ column_missing: "A <i>Category</i>, a <i>Series</i> and at least two <i>Value</i> are needed for this chart.",
260
+ },
258
261
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.8.0-2",
3
+ "version": "1.8.0-4",
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",