@qrvey/utils 1.16.0-7 → 1.16.0-7-AN-25240

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.
@@ -1,3 +1,4 @@
1
+ import { FORMULA_SCOPE } from "../../formulas";
1
2
  import { isEmpty } from "../../general";
2
3
  import { TIME_PERIOD, TP_CUSTOM_RANGE } from "../../interfaces";
3
4
  import { RELATIVE_OBJECT_BY_TIME_LABEL } from "../constants/REQUEST_ADAPTER";
@@ -30,12 +31,15 @@ const getFilterLogic = (filters) => (filters === null || filters === void 0 ? vo
30
31
  * @returns A metric value object
31
32
  */
32
33
  const metricMakeValue = (data) => {
33
- var _a, _b, _c;
34
- return {
35
- questionid: (_a = data === null || data === void 0 ? void 0 : data.value) === null || _a === void 0 ? void 0 : _a.id,
36
- aggregate: (_b = data === null || data === void 0 ? void 0 : data.valueAggregate) === null || _b === void 0 ? void 0 : _b.label,
34
+ var _a, _b, _c, _d;
35
+ const isAggregateFormula = ((_a = data === null || data === void 0 ? void 0 : data.value) === null || _a === void 0 ? void 0 : _a.formulaInputType) === FORMULA_SCOPE.AGGREGATE;
36
+ const metricValue = {
37
+ questionid: (_b = data === null || data === void 0 ? void 0 : data.value) === null || _b === void 0 ? void 0 : _b.id,
37
38
  property: ((_c = data === null || data === void 0 ? void 0 : data.value) === null || _c === void 0 ? void 0 : _c.property) || null,
38
39
  };
40
+ if (!isAggregateFormula)
41
+ metricValue.aggregate = (_d = data === null || data === void 0 ? void 0 : data.valueAggregate) === null || _d === void 0 ? void 0 : _d.label;
42
+ return metricValue;
39
43
  };
40
44
  /**
41
45
  * If data is truthy and data.dateColumn is truthy, return true, otherwise return false.
@@ -1,6 +1,7 @@
1
1
  import { IBColumn, IColumnType } from "../../columns";
2
2
  import { IDateGroupingProperty, RelativeCursor } from "../../dates";
3
3
  import { IFBLogic } from "../../filters";
4
+ import { IFormulaScope } from "../../formulas";
4
5
  import { TimePeriod, TP_CUSTOM_RANGE } from "../../interfaces";
5
6
  import { AGGREGATE_LABEL } from "../constants";
6
7
  export interface MetricRequestPayload {
@@ -18,7 +19,7 @@ export interface MetricRequestPayload {
18
19
  * property "answered".
19
20
  */
20
21
  export type MetricValue = {
21
- aggregate: AGGREGATE_LABEL;
22
+ aggregate?: AGGREGATE_LABEL;
22
23
  questionid: string;
23
24
  property?: string | null;
24
25
  };
@@ -109,6 +110,7 @@ export type MetricConfigData = {
109
110
  value: {
110
111
  id: string;
111
112
  property: string;
113
+ formulaInputType?: IFormulaScope;
112
114
  };
113
115
  valueAggregate: {
114
116
  label: AGGREGATE_LABEL;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.metricMakeTimeData = exports.makeBodyRequestMetrics = void 0;
4
+ const formulas_1 = require("../../formulas");
4
5
  const general_1 = require("../../general");
5
6
  const interfaces_1 = require("../../interfaces");
6
7
  const REQUEST_ADAPTER_1 = require("../constants/REQUEST_ADAPTER");
@@ -34,12 +35,15 @@ const getFilterLogic = (filters) => (filters === null || filters === void 0 ? vo
34
35
  * @returns A metric value object
35
36
  */
36
37
  const metricMakeValue = (data) => {
37
- var _a, _b, _c;
38
- return {
39
- questionid: (_a = data === null || data === void 0 ? void 0 : data.value) === null || _a === void 0 ? void 0 : _a.id,
40
- aggregate: (_b = data === null || data === void 0 ? void 0 : data.valueAggregate) === null || _b === void 0 ? void 0 : _b.label,
38
+ var _a, _b, _c, _d;
39
+ const isAggregateFormula = ((_a = data === null || data === void 0 ? void 0 : data.value) === null || _a === void 0 ? void 0 : _a.formulaInputType) === formulas_1.FORMULA_SCOPE.AGGREGATE;
40
+ const metricValue = {
41
+ questionid: (_b = data === null || data === void 0 ? void 0 : data.value) === null || _b === void 0 ? void 0 : _b.id,
41
42
  property: ((_c = data === null || data === void 0 ? void 0 : data.value) === null || _c === void 0 ? void 0 : _c.property) || null,
42
43
  };
44
+ if (!isAggregateFormula)
45
+ metricValue.aggregate = (_d = data === null || data === void 0 ? void 0 : data.valueAggregate) === null || _d === void 0 ? void 0 : _d.label;
46
+ return metricValue;
43
47
  };
44
48
  /**
45
49
  * If data is truthy and data.dateColumn is truthy, return true, otherwise return false.
@@ -1,6 +1,7 @@
1
1
  import { IBColumn, IColumnType } from "../../columns";
2
2
  import { IDateGroupingProperty, RelativeCursor } from "../../dates";
3
3
  import { IFBLogic } from "../../filters";
4
+ import { IFormulaScope } from "../../formulas";
4
5
  import { TimePeriod, TP_CUSTOM_RANGE } from "../../interfaces";
5
6
  import { AGGREGATE_LABEL } from "../constants";
6
7
  export interface MetricRequestPayload {
@@ -18,7 +19,7 @@ export interface MetricRequestPayload {
18
19
  * property "answered".
19
20
  */
20
21
  export type MetricValue = {
21
- aggregate: AGGREGATE_LABEL;
22
+ aggregate?: AGGREGATE_LABEL;
22
23
  questionid: string;
23
24
  property?: string | null;
24
25
  };
@@ -109,6 +110,7 @@ export type MetricConfigData = {
109
110
  value: {
110
111
  id: string;
111
112
  property: string;
113
+ formulaInputType?: IFormulaScope;
112
114
  };
113
115
  valueAggregate: {
114
116
  label: AGGREGATE_LABEL;
@@ -9,3 +9,8 @@ export declare enum FORMULA {
9
9
  export declare const COLUMN_BY_FORMULA: {
10
10
  [key in IFormulaType]: IColumnType;
11
11
  };
12
+ export declare enum FORMULA_SCOPE {
13
+ RAW = "RAW",
14
+ AGGREGATE = "AGGREGATE"
15
+ }
16
+ export type IFormulaScope = FORMULA_SCOPE;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.COLUMN_BY_FORMULA = exports.FORMULA = void 0;
3
+ exports.FORMULA_SCOPE = exports.COLUMN_BY_FORMULA = exports.FORMULA = void 0;
4
4
  const COLUMN_1 = require("../../columns/constants/COLUMN");
5
5
  var FORMULA;
6
6
  (function (FORMULA) {
@@ -15,3 +15,8 @@ exports.COLUMN_BY_FORMULA = {
15
15
  [FORMULA.TEXT]: COLUMN_1.COLUMN.TEXT_FORMULA,
16
16
  [FORMULA.BOOLEAN]: COLUMN_1.COLUMN.TEXT_FORMULA,
17
17
  };
18
+ var FORMULA_SCOPE;
19
+ (function (FORMULA_SCOPE) {
20
+ FORMULA_SCOPE["RAW"] = "RAW";
21
+ FORMULA_SCOPE["AGGREGATE"] = "AGGREGATE";
22
+ })(FORMULA_SCOPE || (exports.FORMULA_SCOPE = FORMULA_SCOPE = {}));
@@ -9,3 +9,8 @@ export declare enum FORMULA {
9
9
  export declare const COLUMN_BY_FORMULA: {
10
10
  [key in IFormulaType]: IColumnType;
11
11
  };
12
+ export declare enum FORMULA_SCOPE {
13
+ RAW = "RAW",
14
+ AGGREGATE = "AGGREGATE"
15
+ }
16
+ export type IFormulaScope = FORMULA_SCOPE;
@@ -12,3 +12,8 @@ export const COLUMN_BY_FORMULA = {
12
12
  [FORMULA.TEXT]: COLUMN.TEXT_FORMULA,
13
13
  [FORMULA.BOOLEAN]: COLUMN.TEXT_FORMULA,
14
14
  };
15
+ export var FORMULA_SCOPE;
16
+ (function (FORMULA_SCOPE) {
17
+ FORMULA_SCOPE["RAW"] = "RAW";
18
+ FORMULA_SCOPE["AGGREGATE"] = "AGGREGATE";
19
+ })(FORMULA_SCOPE || (FORMULA_SCOPE = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.16.0-7",
3
+ "version": "1.16.0-7-AN-25240",
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",