@sisense/sdk-data 1.8.0 → 1.9.0
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/dist/dimensional-model/attributes.d.ts +11 -0
- package/dist/dimensional-model/attributes.js +20 -1
- package/dist/dimensional-model/base.d.ts +0 -11
- package/dist/dimensional-model/base.js +0 -17
- package/dist/dimensional-model/dimensions.js +5 -4
- package/dist/dimensional-model/factory.js +0 -1
- package/dist/dimensional-model/filters/factory.d.ts +49 -0
- package/dist/dimensional-model/filters/factory.js +56 -1
- package/dist/dimensional-model/filters/filters.js +0 -3
- package/dist/dimensional-model/filters/utils/attribute-measure-util.d.ts +47 -0
- package/dist/dimensional-model/filters/utils/attribute-measure-util.js +77 -0
- package/dist/dimensional-model/filters/utils/condition-filter-util.d.ts +19 -0
- package/dist/dimensional-model/filters/utils/condition-filter-util.js +162 -0
- package/dist/dimensional-model/filters/utils/filter-code-util.d.ts +13 -0
- package/dist/dimensional-model/filters/utils/filter-code-util.js +49 -0
- package/dist/dimensional-model/filters/utils/filter-from-jaql-util.d.ts +67 -0
- package/dist/dimensional-model/filters/utils/filter-from-jaql-util.js +149 -0
- package/dist/dimensional-model/filters/utils/filter-types-util.d.ts +15 -0
- package/dist/dimensional-model/filters/utils/filter-types-util.js +71 -0
- package/dist/dimensional-model/filters/utils/{modern-analytics-filters/types.d.ts → types.d.ts} +48 -48
- package/dist/dimensional-model/filters/utils/types.js +96 -0
- package/dist/dimensional-model/measures/factory.d.ts +13 -0
- package/dist/dimensional-model/measures/factory.js +15 -0
- package/dist/dimensional-model/measures/measures.js +1 -4
- package/dist/dimensional-model/types.d.ts +10 -1
- package/dist/dimensional-model/types.js +1 -3
- package/dist/utils.js +1 -1
- package/package.json +3 -3
- package/dist/dimensional-model/filters/utils/filter-jaql-util.d.ts +0 -25
- package/dist/dimensional-model/filters/utils/filter-jaql-util.js +0 -167
- package/dist/dimensional-model/filters/utils/modern-analytics-filters/condition-filter-util.d.ts +0 -2
- package/dist/dimensional-model/filters/utils/modern-analytics-filters/condition-filter-util.js +0 -27
- package/dist/dimensional-model/filters/utils/modern-analytics-filters/condition-types-util.d.ts +0 -24
- package/dist/dimensional-model/filters/utils/modern-analytics-filters/condition-types-util.js +0 -138
- package/dist/dimensional-model/filters/utils/modern-analytics-filters/filter-types-util.d.ts +0 -31
- package/dist/dimensional-model/filters/utils/modern-analytics-filters/filter-types-util.js +0 -114
- package/dist/dimensional-model/filters/utils/modern-analytics-filters/types.js +0 -97
- /package/dist/dimensional-model/filters/utils/{modern-analytics-filters/date-time-filter-util.d.ts → date-time-filter-util.d.ts} +0 -0
- /package/dist/dimensional-model/filters/utils/{modern-analytics-filters/date-time-filter-util.js → date-time-filter-util.js} +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ConditionFilterJaql, FilterJaqlInternal, PeriodFilterJaql, RangeFilterJaql, SpecificItemsFilterJaql } from './types.js';
|
|
2
|
+
import { Attribute, BaseMeasure, Filter, LevelAttribute } from '../../interfaces.js';
|
|
3
|
+
import { FilterJaql } from '../../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a generic filter (aka pass-through JAQL filter) if the JAQL cannot be translated to a specific filter type.
|
|
6
|
+
*
|
|
7
|
+
* @param jaql - The JAQL object.
|
|
8
|
+
* @param instanceid - The instance ID.
|
|
9
|
+
* @returns A generic Filter object.
|
|
10
|
+
*/
|
|
11
|
+
export declare const createGenericFilter: (jaql: FilterJaql | FilterJaqlInternal, instanceid?: string) => Filter;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a filter that includes all members of the attribute.
|
|
14
|
+
*
|
|
15
|
+
* @param attribute - The attribute.
|
|
16
|
+
* @returns The created Filter object.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createFilterIncludeAll: (attribute: Attribute) => Filter;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a filter from a specific items filter JAQL object.
|
|
21
|
+
*
|
|
22
|
+
* @param attribute - attribute
|
|
23
|
+
* @param specificItemsFilterJaql - Specific Items Filter Jaql
|
|
24
|
+
* @returns Filter object
|
|
25
|
+
*/
|
|
26
|
+
export declare const createFilterFromSpecificItemsFilterJaql: (attribute: Attribute, specificItemsFilterJaql: SpecificItemsFilterJaql) => Filter;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a filter from a date range filter JAQL object.
|
|
29
|
+
*
|
|
30
|
+
* @param attribute - attribute
|
|
31
|
+
* @param rangeFilterJaql - Range Filter Jaql
|
|
32
|
+
* @returns Filter object
|
|
33
|
+
*/
|
|
34
|
+
export declare const createFilterFromDateRangeFilterJaql: (attribute: LevelAttribute, rangeFilterJaql: RangeFilterJaql) => Filter;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a filter from a numeric range filter JAQL object.
|
|
37
|
+
*
|
|
38
|
+
* @param attribute - attribute
|
|
39
|
+
* @param rangeFilterJaql - Range Filter Jaql
|
|
40
|
+
* @returns Filter object
|
|
41
|
+
*/
|
|
42
|
+
export declare const createFilterFromNumericRangeJaql: (attribute: Attribute, rangeFilterJaql: RangeFilterJaql) => Filter;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a filter from a period filter JAQL object.
|
|
45
|
+
*
|
|
46
|
+
* @param attribute - attribute
|
|
47
|
+
* @param periodFilterJaql - Period Filter Jaql
|
|
48
|
+
* @returns Filter object
|
|
49
|
+
*/
|
|
50
|
+
export declare const createFilterFromPeriodFilterJaql: (attribute: LevelAttribute, periodFilterJaql: PeriodFilterJaql) => Filter;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a filter from a condition filter JAQL object.
|
|
53
|
+
*
|
|
54
|
+
* @param attribute - attribute
|
|
55
|
+
* @param conditionFilterJaql - Condition Filter Jaql
|
|
56
|
+
* @param measure - measure
|
|
57
|
+
* @returns Filter object
|
|
58
|
+
*/
|
|
59
|
+
export declare const createFilterFromConditionFilterJaql: (attribute: Attribute, conditionFilterJaql: ConditionFilterJaql, measure?: BaseMeasure) => Filter;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a filter from a filter JAQL object.
|
|
62
|
+
*
|
|
63
|
+
* @param jaql - The filter JAQL object.
|
|
64
|
+
* @param instanceid - The instance ID.
|
|
65
|
+
* @returns Filter object.
|
|
66
|
+
*/
|
|
67
|
+
export declare const createFilterFromJaqlInternal: (jaql: FilterJaqlInternal, instanceid?: string) => Filter;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { FILTER_TYPES, } from './types.js';
|
|
2
|
+
import * as filterFactory from '../factory.js';
|
|
3
|
+
import { createAttributeFilterFromConditionFilterJaql, createMeasureFilterFromConditionFilterJaql, } from './condition-filter-util.js';
|
|
4
|
+
import { extractFilterTypeFromFilterJaql } from './filter-types-util.js';
|
|
5
|
+
import { withComposeCode } from './filter-code-util.js';
|
|
6
|
+
import { createAttributeFromFilterJaql, createMeasureFromFilterJaql, } from './attribute-measure-util.js';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a generic filter (aka pass-through JAQL filter) if the JAQL cannot be translated to a specific filter type.
|
|
9
|
+
*
|
|
10
|
+
* @param jaql - The JAQL object.
|
|
11
|
+
* @param instanceid - The instance ID.
|
|
12
|
+
* @returns A generic Filter object.
|
|
13
|
+
*/
|
|
14
|
+
export const createGenericFilter = (jaql, instanceid) => {
|
|
15
|
+
return {
|
|
16
|
+
guid: instanceid,
|
|
17
|
+
jaql: (nested) => {
|
|
18
|
+
if (nested) {
|
|
19
|
+
return jaql;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
jaql,
|
|
23
|
+
panel: 'scope',
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
attribute: {
|
|
27
|
+
id: jaql.dim,
|
|
28
|
+
},
|
|
29
|
+
type: 'filter',
|
|
30
|
+
serializable() {
|
|
31
|
+
return Object.assign(Object.assign({}, this), { jaql: this.jaql() });
|
|
32
|
+
},
|
|
33
|
+
toJSON() {
|
|
34
|
+
return this.serializable();
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Creates a filter that includes all members of the attribute.
|
|
40
|
+
*
|
|
41
|
+
* @param attribute - The attribute.
|
|
42
|
+
* @returns The created Filter object.
|
|
43
|
+
*/
|
|
44
|
+
export const createFilterIncludeAll = (attribute) => {
|
|
45
|
+
return withComposeCode(filterFactory.members)(attribute, []);
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Creates a filter from a specific items filter JAQL object.
|
|
49
|
+
*
|
|
50
|
+
* @param attribute - attribute
|
|
51
|
+
* @param specificItemsFilterJaql - Specific Items Filter Jaql
|
|
52
|
+
* @returns Filter object
|
|
53
|
+
*/
|
|
54
|
+
export const createFilterFromSpecificItemsFilterJaql = (attribute, specificItemsFilterJaql) => {
|
|
55
|
+
return withComposeCode(filterFactory.members)(attribute, specificItemsFilterJaql.members);
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Creates a filter from a date range filter JAQL object.
|
|
59
|
+
*
|
|
60
|
+
* @param attribute - attribute
|
|
61
|
+
* @param rangeFilterJaql - Range Filter Jaql
|
|
62
|
+
* @returns Filter object
|
|
63
|
+
*/
|
|
64
|
+
export const createFilterFromDateRangeFilterJaql = (attribute, rangeFilterJaql) => {
|
|
65
|
+
return withComposeCode(filterFactory.dateRange)(attribute, rangeFilterJaql.from, rangeFilterJaql.to);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Creates a filter from a numeric range filter JAQL object.
|
|
69
|
+
*
|
|
70
|
+
* @param attribute - attribute
|
|
71
|
+
* @param rangeFilterJaql - Range Filter Jaql
|
|
72
|
+
* @returns Filter object
|
|
73
|
+
*/
|
|
74
|
+
export const createFilterFromNumericRangeJaql = (attribute, rangeFilterJaql) => {
|
|
75
|
+
return withComposeCode(filterFactory.between)(attribute, rangeFilterJaql.from, rangeFilterJaql.to);
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Creates a filter from a period filter JAQL object.
|
|
79
|
+
*
|
|
80
|
+
* @param attribute - attribute
|
|
81
|
+
* @param periodFilterJaql - Period Filter Jaql
|
|
82
|
+
* @returns Filter object
|
|
83
|
+
*/
|
|
84
|
+
export const createFilterFromPeriodFilterJaql = (attribute, periodFilterJaql) => {
|
|
85
|
+
if (periodFilterJaql.last) {
|
|
86
|
+
return withComposeCode(filterFactory.dateRelativeTo)(attribute, periodFilterJaql.last.offset, periodFilterJaql.last.count, periodFilterJaql.last.anchor);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return withComposeCode(filterFactory.dateRelativeFrom)(attribute, periodFilterJaql.next.offset, periodFilterJaql.next.count, periodFilterJaql.next.anchor);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Creates a filter from a condition filter JAQL object.
|
|
94
|
+
*
|
|
95
|
+
* @param attribute - attribute
|
|
96
|
+
* @param conditionFilterJaql - Condition Filter Jaql
|
|
97
|
+
* @param measure - measure
|
|
98
|
+
* @returns Filter object
|
|
99
|
+
*/
|
|
100
|
+
export const createFilterFromConditionFilterJaql = (attribute, conditionFilterJaql, measure) => {
|
|
101
|
+
if (measure) {
|
|
102
|
+
return createMeasureFilterFromConditionFilterJaql(measure, conditionFilterJaql);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return createAttributeFilterFromConditionFilterJaql(attribute, conditionFilterJaql);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Creates a filter from a filter JAQL object.
|
|
110
|
+
*
|
|
111
|
+
* @param jaql - The filter JAQL object.
|
|
112
|
+
* @param instanceid - The instance ID.
|
|
113
|
+
* @returns Filter object.
|
|
114
|
+
*/
|
|
115
|
+
export const createFilterFromJaqlInternal = (jaql, instanceid) => {
|
|
116
|
+
try {
|
|
117
|
+
if ('formula' in jaql) {
|
|
118
|
+
// generic pass-through JAQL filter will be used instead
|
|
119
|
+
throw 'Formula-based filter not supported yet: ' + JSON.stringify(jaql);
|
|
120
|
+
}
|
|
121
|
+
const filterJaqlWrapperWithType = extractFilterTypeFromFilterJaql(jaql, jaql.datatype);
|
|
122
|
+
const { filter: filterJaqlWithType } = filterJaqlWrapperWithType;
|
|
123
|
+
const { filterType } = filterJaqlWithType;
|
|
124
|
+
const attribute = createAttributeFromFilterJaql(jaql);
|
|
125
|
+
const measure = createMeasureFromFilterJaql(jaql);
|
|
126
|
+
switch (filterType) {
|
|
127
|
+
case FILTER_TYPES.INCLUDE_ALL:
|
|
128
|
+
return createFilterIncludeAll(attribute);
|
|
129
|
+
case FILTER_TYPES.SPECIFIC_ITEMS:
|
|
130
|
+
return createFilterFromSpecificItemsFilterJaql(attribute, filterJaqlWithType);
|
|
131
|
+
case FILTER_TYPES.CONDITION:
|
|
132
|
+
return createFilterFromConditionFilterJaql(attribute, filterJaqlWithType, measure);
|
|
133
|
+
case FILTER_TYPES.DATE_RANGE:
|
|
134
|
+
return createFilterFromDateRangeFilterJaql(attribute, filterJaqlWithType);
|
|
135
|
+
case FILTER_TYPES.PERIOD:
|
|
136
|
+
return createFilterFromPeriodFilterJaql(attribute, filterJaqlWithType);
|
|
137
|
+
case FILTER_TYPES.NUMERIC_RANGE:
|
|
138
|
+
return createFilterFromNumericRangeJaql(attribute, filterJaqlWithType);
|
|
139
|
+
case FILTER_TYPES.ADVANCED:
|
|
140
|
+
case FILTER_TYPES.INVALID:
|
|
141
|
+
return createGenericFilter(jaql, instanceid);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
// if a filter type is untranslatable, fall back to the generic pass-through JAQL filter
|
|
146
|
+
// console.error(e);
|
|
147
|
+
}
|
|
148
|
+
return createGenericFilter(jaql, instanceid);
|
|
149
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FilterModalType, AnyTypeFilterJaql, DatetimeLevel, FilterType, FilterJaqlInternal, FilterJaqlWrapperWithType } from './types.js';
|
|
2
|
+
export declare const isNumericRangeFilter: (filter: AnyTypeFilterJaql) => boolean;
|
|
3
|
+
export declare const getFilterType: (filter: AnyTypeFilterJaql, dataType?: FilterModalType, timeData?: {
|
|
4
|
+
level?: DatetimeLevel;
|
|
5
|
+
bucket?: string;
|
|
6
|
+
}) => FilterType;
|
|
7
|
+
/**
|
|
8
|
+
* Extracts Filter Type from Filter Jaql
|
|
9
|
+
*
|
|
10
|
+
* @param jaql - jaql
|
|
11
|
+
* @param dataType - data type
|
|
12
|
+
* @return FilterJaqlWrapperType
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare const extractFilterTypeFromFilterJaql: (jaql: FilterJaqlInternal, dataType: FilterModalType) => FilterJaqlWrapperWithType;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { getSelectedConditionOption } from './condition-filter-util.js';
|
|
2
|
+
import { FilterModalType, DatetimeLevel, FILTER_TYPES, nonSupportedMinutesBuckets, ConditionFilterType, DEFAULT_FILTER_JAQL_WRAPPER, } from './types.js';
|
|
3
|
+
import { getCorrectTimeLevel } from './date-time-filter-util.js';
|
|
4
|
+
const isIncludeAllFilter = (filter) => filter === null || filter === void 0 ? void 0 : filter.all;
|
|
5
|
+
const getInnerPeriodFilter = (filter) => (filter.last ? filter.last : filter.next);
|
|
6
|
+
const isPeriodFilter = (filter) => { var _a; return ((_a = getInnerPeriodFilter(filter)) === null || _a === void 0 ? void 0 : _a.offset) < 2; };
|
|
7
|
+
const isSpecificItemsFilter = (filter) => { var _a; return ((_a = filter === null || filter === void 0 ? void 0 : filter.members) === null || _a === void 0 ? void 0 : _a.length) > 0; };
|
|
8
|
+
const isFromOrToDefined = (fromRange, toRange) => (fromRange && typeof fromRange === 'string') || (toRange && typeof toRange === 'string');
|
|
9
|
+
const isFromAndToEmpty = (from, to) => from === '' && to === '';
|
|
10
|
+
const isDateRangeFilter = (filter, dataType) => {
|
|
11
|
+
const { from, to } = filter;
|
|
12
|
+
if (dataType !== FilterModalType.DATE_TIME)
|
|
13
|
+
return false;
|
|
14
|
+
if (isFromOrToDefined(from, to))
|
|
15
|
+
return true;
|
|
16
|
+
return isFromAndToEmpty(from, to);
|
|
17
|
+
};
|
|
18
|
+
export const isNumericRangeFilter = (filter) => {
|
|
19
|
+
const { from, to } = filter;
|
|
20
|
+
return !!(from !== undefined && to !== undefined && !filter.isBetween);
|
|
21
|
+
};
|
|
22
|
+
const isConditionFilter = (filter) => getSelectedConditionOption(filter) !== ConditionFilterType.NONE;
|
|
23
|
+
const isAdvancedFilter = (filter) => Object.keys(filter).includes('isAdvanced');
|
|
24
|
+
const isTimeLevelNotSupported = (timeData) => !!(timeData.level &&
|
|
25
|
+
timeData.bucket &&
|
|
26
|
+
timeData.level === DatetimeLevel.MINUTES &&
|
|
27
|
+
nonSupportedMinutesBuckets.includes(timeData.bucket));
|
|
28
|
+
const isInvalidFilter = (filter) => filter.filterType === FILTER_TYPES.INVALID;
|
|
29
|
+
export const getFilterType = (filter, dataType = FilterModalType.DATE_TIME, timeData) => {
|
|
30
|
+
if (timeData && isTimeLevelNotSupported(timeData))
|
|
31
|
+
return FILTER_TYPES.ADVANCED;
|
|
32
|
+
if (isIncludeAllFilter(filter))
|
|
33
|
+
return FILTER_TYPES.INCLUDE_ALL;
|
|
34
|
+
if (isPeriodFilter(filter))
|
|
35
|
+
return FILTER_TYPES.PERIOD;
|
|
36
|
+
if (isSpecificItemsFilter(filter))
|
|
37
|
+
return FILTER_TYPES.SPECIFIC_ITEMS;
|
|
38
|
+
if (isDateRangeFilter(filter, dataType))
|
|
39
|
+
return FILTER_TYPES.DATE_RANGE;
|
|
40
|
+
if (isNumericRangeFilter(filter))
|
|
41
|
+
return FILTER_TYPES.NUMERIC_RANGE;
|
|
42
|
+
if (isConditionFilter(filter))
|
|
43
|
+
return FILTER_TYPES.CONDITION;
|
|
44
|
+
if (isAdvancedFilter(filter))
|
|
45
|
+
return FILTER_TYPES.ADVANCED;
|
|
46
|
+
if (isInvalidFilter(filter))
|
|
47
|
+
return FILTER_TYPES.INVALID;
|
|
48
|
+
return FILTER_TYPES.ADVANCED;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Extracts Filter Type from Filter Jaql
|
|
52
|
+
*
|
|
53
|
+
* @param jaql - jaql
|
|
54
|
+
* @param dataType - data type
|
|
55
|
+
* @return FilterJaqlWrapperType
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export const extractFilterTypeFromFilterJaql = (jaql, dataType) => {
|
|
59
|
+
const { level: filterLevel, filter, bucket } = jaql;
|
|
60
|
+
const filterFromJaql = filter || DEFAULT_FILTER_JAQL_WRAPPER.filter;
|
|
61
|
+
const filterToReturn = {
|
|
62
|
+
filter: Object.assign(Object.assign({}, filterFromJaql), { filterType: getFilterType(filterFromJaql, dataType) }),
|
|
63
|
+
};
|
|
64
|
+
if (dataType === FilterModalType.DATE_TIME) {
|
|
65
|
+
const backgroundFilter = filterFromJaql;
|
|
66
|
+
const level = (backgroundFilter === null || backgroundFilter === void 0 ? void 0 : backgroundFilter.level) || filterLevel;
|
|
67
|
+
filterToReturn.level = getCorrectTimeLevel(level, bucket);
|
|
68
|
+
filterToReturn.filter.filterType = getFilterType(filterFromJaql, dataType, { level, bucket });
|
|
69
|
+
}
|
|
70
|
+
return filterToReturn;
|
|
71
|
+
};
|
package/dist/dimensional-model/filters/utils/{modern-analytics-filters/types.d.ts → types.d.ts}
RENAMED
|
@@ -13,50 +13,50 @@ export declare type Datasource = {
|
|
|
13
13
|
lastBuildTime?: string;
|
|
14
14
|
revisionId?: string;
|
|
15
15
|
};
|
|
16
|
-
export declare enum
|
|
16
|
+
export declare enum GeneralFilterType {
|
|
17
17
|
INCLUDE_ALL = "INCLUDE_ALL",
|
|
18
18
|
ADVANCED = "ADVANCED",
|
|
19
19
|
INVALID = "INVALID",
|
|
20
20
|
CONDITION = "CONDITION",
|
|
21
21
|
SPECIFIC_ITEMS = "SPECIFIC_ITEMS"
|
|
22
22
|
}
|
|
23
|
-
export declare enum
|
|
23
|
+
export declare enum DateTimeFilterType {
|
|
24
24
|
PERIOD = "PERIOD",
|
|
25
25
|
DATE_RANGE = "DATE_RANGE"
|
|
26
26
|
}
|
|
27
|
-
export declare enum
|
|
27
|
+
export declare enum NumericFilterType {
|
|
28
28
|
NUMERIC_RANGE = "NUMERIC_RANGE"
|
|
29
29
|
}
|
|
30
|
-
export declare type
|
|
31
|
-
export interface
|
|
32
|
-
|
|
30
|
+
export declare type FilterType = GeneralFilterType | DateTimeFilterType | NumericFilterType;
|
|
31
|
+
export interface BaseFilterJaql {
|
|
32
|
+
filterType?: FilterType;
|
|
33
33
|
custom?: boolean;
|
|
34
34
|
isAdvanced?: boolean;
|
|
35
35
|
rankingMessage?: string;
|
|
36
36
|
isBetween?: boolean;
|
|
37
37
|
isEmpty?: boolean;
|
|
38
38
|
}
|
|
39
|
-
export interface
|
|
39
|
+
export interface IncludeAllFilterJaql extends BaseFilterJaql {
|
|
40
40
|
all: boolean;
|
|
41
41
|
}
|
|
42
|
-
export declare type
|
|
42
|
+
export declare type PeriodFilterDetails = {
|
|
43
43
|
count: number;
|
|
44
44
|
offset: number;
|
|
45
45
|
anchor?: string;
|
|
46
46
|
};
|
|
47
|
-
export interface
|
|
48
|
-
last:
|
|
49
|
-
next:
|
|
47
|
+
export interface PeriodFilterJaqlOptions extends BaseFilterJaql {
|
|
48
|
+
last: PeriodFilterDetails;
|
|
49
|
+
next: PeriodFilterDetails;
|
|
50
50
|
multiSelection?: boolean;
|
|
51
51
|
isNotCurrentPeriod?: boolean;
|
|
52
52
|
}
|
|
53
|
-
export declare type
|
|
54
|
-
export interface
|
|
53
|
+
export declare type PeriodFilterJaql = RequireOnlyOne<PeriodFilterJaqlOptions, 'last' | 'next'>;
|
|
54
|
+
export interface RangeFilterJaql extends BaseFilterJaql {
|
|
55
55
|
from?: string | number;
|
|
56
56
|
to?: string | number;
|
|
57
57
|
multiSelection?: boolean;
|
|
58
58
|
}
|
|
59
|
-
export declare type
|
|
59
|
+
export declare type RankingFilterJaql = {
|
|
60
60
|
agg: string;
|
|
61
61
|
column: string;
|
|
62
62
|
datatype: string;
|
|
@@ -65,17 +65,17 @@ export declare type RankingJaql = {
|
|
|
65
65
|
merged?: boolean;
|
|
66
66
|
table: string;
|
|
67
67
|
};
|
|
68
|
-
export declare type
|
|
68
|
+
export declare type FilterMultiSelectJaql = {
|
|
69
69
|
explicit?: boolean;
|
|
70
70
|
multiSelection: boolean;
|
|
71
71
|
members: string[];
|
|
72
72
|
isCondition?: boolean;
|
|
73
73
|
};
|
|
74
|
-
export declare type
|
|
75
|
-
or:
|
|
76
|
-
and:
|
|
74
|
+
export declare type FilterMultipleConditionJaql = {
|
|
75
|
+
or: ConditionFilterJaql[];
|
|
76
|
+
and: ConditionFilterJaql[];
|
|
77
77
|
};
|
|
78
|
-
export declare type
|
|
78
|
+
export declare type ConditionFilterJaqlOptions = BaseFilterJaql & {
|
|
79
79
|
top: number;
|
|
80
80
|
bottom: number;
|
|
81
81
|
exclude: {
|
|
@@ -95,13 +95,13 @@ export declare type ConditionJaqlOptions = FilterType & {
|
|
|
95
95
|
from: number;
|
|
96
96
|
fromNotEqual: number;
|
|
97
97
|
contains: string;
|
|
98
|
-
by?:
|
|
98
|
+
by?: RankingFilterJaql;
|
|
99
99
|
rankingMessage?: string;
|
|
100
|
-
} & Partial<
|
|
101
|
-
export declare type
|
|
102
|
-
export declare type
|
|
103
|
-
export declare type
|
|
104
|
-
export declare type
|
|
100
|
+
} & Partial<FilterMultiSelectJaql> & Partial<PeriodFilterJaql> & Partial<RangeFilterJaql> & Partial<FilterMultipleConditionJaql>;
|
|
101
|
+
export declare type ConditionFilterJaql = RequireOnlyOne<ConditionFilterJaqlOptions, 'top' | 'bottom' | 'exclude' | 'last' | 'next' | 'contains' | 'equals' | 'doesntEqual' | 'to' | 'toNotEqual' | 'from' | 'fromNotEqual' | 'startsWith' | 'doesntStartWith' | 'endsWith' | 'doesntEndWith' | 'doesntContain' | 'or' | 'and'>;
|
|
102
|
+
export declare type InvalidTypeFilterJaql = BaseFilterJaql;
|
|
103
|
+
export declare type SpecificItemsFilterJaql = BaseFilterJaql & FilterMultiSelectJaql;
|
|
104
|
+
export declare type AnyTypeFilterJaql = IncludeAllFilterJaql | PeriodFilterJaql | RangeFilterJaql | ConditionFilterJaql | InvalidTypeFilterJaql | SpecificItemsFilterJaql;
|
|
105
105
|
export declare enum DatetimeLevel {
|
|
106
106
|
YEARS = "years",
|
|
107
107
|
QUARTERS = "quarters",
|
|
@@ -122,7 +122,7 @@ export declare type FilterJaqlInternal = {
|
|
|
122
122
|
firstday?: string;
|
|
123
123
|
merged?: boolean;
|
|
124
124
|
table: string;
|
|
125
|
-
filter?:
|
|
125
|
+
filter?: AnyTypeFilterJaql;
|
|
126
126
|
level?: DatetimeLevel;
|
|
127
127
|
locale?: string;
|
|
128
128
|
bucket?: string;
|
|
@@ -132,7 +132,7 @@ export declare type FilterJaqlInternal = {
|
|
|
132
132
|
context?: JaqlContext;
|
|
133
133
|
agg?: string;
|
|
134
134
|
};
|
|
135
|
-
export declare enum
|
|
135
|
+
export declare enum FilterModalType {
|
|
136
136
|
DATE_TIME = "datetime",
|
|
137
137
|
NUMERIC = "numeric",
|
|
138
138
|
TEXT = "text"
|
|
@@ -142,35 +142,35 @@ export declare type BackgroundFilterExtraProps = {
|
|
|
142
142
|
turnedOff?: boolean;
|
|
143
143
|
};
|
|
144
144
|
export declare type BackgroundFilter = {
|
|
145
|
-
filter?:
|
|
145
|
+
filter?: AnyTypeFilterJaql & BackgroundFilterExtraProps;
|
|
146
146
|
};
|
|
147
|
-
export declare type
|
|
148
|
-
filter:
|
|
147
|
+
export declare type FilterJaqlWrapperWithType = {
|
|
148
|
+
filter: AnyTypeFilterJaql & BackgroundFilter;
|
|
149
149
|
level?: DatetimeLevel;
|
|
150
150
|
agg?: string;
|
|
151
151
|
};
|
|
152
152
|
export declare const nonSupportedMinutesBuckets: string[];
|
|
153
153
|
export declare const FILTER_TYPES: {
|
|
154
|
-
NUMERIC_RANGE:
|
|
155
|
-
PERIOD:
|
|
156
|
-
DATE_RANGE:
|
|
157
|
-
INCLUDE_ALL:
|
|
158
|
-
ADVANCED:
|
|
159
|
-
INVALID:
|
|
160
|
-
CONDITION:
|
|
161
|
-
SPECIFIC_ITEMS:
|
|
154
|
+
NUMERIC_RANGE: NumericFilterType.NUMERIC_RANGE;
|
|
155
|
+
PERIOD: DateTimeFilterType.PERIOD;
|
|
156
|
+
DATE_RANGE: DateTimeFilterType.DATE_RANGE;
|
|
157
|
+
INCLUDE_ALL: GeneralFilterType.INCLUDE_ALL;
|
|
158
|
+
ADVANCED: GeneralFilterType.ADVANCED;
|
|
159
|
+
INVALID: GeneralFilterType.INVALID;
|
|
160
|
+
CONDITION: GeneralFilterType.CONDITION;
|
|
161
|
+
SPECIFIC_ITEMS: GeneralFilterType.SPECIFIC_ITEMS;
|
|
162
162
|
};
|
|
163
|
-
export declare type
|
|
164
|
-
[FILTER_TYPES.INCLUDE_ALL]:
|
|
165
|
-
[FILTER_TYPES.PERIOD]:
|
|
166
|
-
[FILTER_TYPES.DATE_RANGE]:
|
|
167
|
-
[FILTER_TYPES.NUMERIC_RANGE]:
|
|
168
|
-
[FILTER_TYPES.CONDITION]:
|
|
169
|
-
[FILTER_TYPES.SPECIFIC_ITEMS]:
|
|
163
|
+
export declare type FilterJaqlByTypeMap = {
|
|
164
|
+
[FILTER_TYPES.INCLUDE_ALL]: IncludeAllFilterJaql;
|
|
165
|
+
[FILTER_TYPES.PERIOD]: PeriodFilterJaql;
|
|
166
|
+
[FILTER_TYPES.DATE_RANGE]: RangeFilterJaql;
|
|
167
|
+
[FILTER_TYPES.NUMERIC_RANGE]: RangeFilterJaql;
|
|
168
|
+
[FILTER_TYPES.CONDITION]: ConditionFilterJaql;
|
|
169
|
+
[FILTER_TYPES.SPECIFIC_ITEMS]: SpecificItemsFilterJaql;
|
|
170
170
|
};
|
|
171
|
-
export declare const
|
|
172
|
-
export declare const
|
|
173
|
-
export declare enum
|
|
171
|
+
export declare const DEFAULT_FILTER_JAQL_BY_TYPE_MAP: FilterJaqlByTypeMap;
|
|
172
|
+
export declare const DEFAULT_FILTER_JAQL_WRAPPER: FilterJaqlWrapperWithType;
|
|
173
|
+
export declare enum ConditionFilterType {
|
|
174
174
|
IS = "members",
|
|
175
175
|
IS_NOT = "exclude",
|
|
176
176
|
IS_WITHIN = "isWithin",
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export var GeneralFilterType;
|
|
2
|
+
(function (GeneralFilterType) {
|
|
3
|
+
GeneralFilterType["INCLUDE_ALL"] = "INCLUDE_ALL";
|
|
4
|
+
GeneralFilterType["ADVANCED"] = "ADVANCED";
|
|
5
|
+
GeneralFilterType["INVALID"] = "INVALID";
|
|
6
|
+
GeneralFilterType["CONDITION"] = "CONDITION";
|
|
7
|
+
GeneralFilterType["SPECIFIC_ITEMS"] = "SPECIFIC_ITEMS";
|
|
8
|
+
})(GeneralFilterType = GeneralFilterType || (GeneralFilterType = {}));
|
|
9
|
+
export var DateTimeFilterType;
|
|
10
|
+
(function (DateTimeFilterType) {
|
|
11
|
+
DateTimeFilterType["PERIOD"] = "PERIOD";
|
|
12
|
+
DateTimeFilterType["DATE_RANGE"] = "DATE_RANGE";
|
|
13
|
+
})(DateTimeFilterType = DateTimeFilterType || (DateTimeFilterType = {}));
|
|
14
|
+
export var NumericFilterType;
|
|
15
|
+
(function (NumericFilterType) {
|
|
16
|
+
NumericFilterType["NUMERIC_RANGE"] = "NUMERIC_RANGE";
|
|
17
|
+
})(NumericFilterType = NumericFilterType || (NumericFilterType = {}));
|
|
18
|
+
export var DatetimeLevel;
|
|
19
|
+
(function (DatetimeLevel) {
|
|
20
|
+
DatetimeLevel["YEARS"] = "years";
|
|
21
|
+
DatetimeLevel["QUARTERS"] = "quarters";
|
|
22
|
+
DatetimeLevel["MONTHS"] = "months";
|
|
23
|
+
DatetimeLevel["WEEKS"] = "weeks";
|
|
24
|
+
DatetimeLevel["DAYS"] = "days";
|
|
25
|
+
DatetimeLevel["HOURS"] = "hours";
|
|
26
|
+
DatetimeLevel["MINUTES"] = "minutes";
|
|
27
|
+
})(DatetimeLevel = DatetimeLevel || (DatetimeLevel = {}));
|
|
28
|
+
export var FilterModalType;
|
|
29
|
+
(function (FilterModalType) {
|
|
30
|
+
FilterModalType["DATE_TIME"] = "datetime";
|
|
31
|
+
FilterModalType["NUMERIC"] = "numeric";
|
|
32
|
+
FilterModalType["TEXT"] = "text";
|
|
33
|
+
})(FilterModalType = FilterModalType || (FilterModalType = {}));
|
|
34
|
+
export const nonSupportedMinutesBuckets = ['1', '30'];
|
|
35
|
+
export const FILTER_TYPES = Object.assign(Object.assign(Object.assign({}, GeneralFilterType), DateTimeFilterType), NumericFilterType);
|
|
36
|
+
export const DEFAULT_FILTER_JAQL_BY_TYPE_MAP = {
|
|
37
|
+
[FILTER_TYPES.INCLUDE_ALL]: {
|
|
38
|
+
all: true,
|
|
39
|
+
filterType: FILTER_TYPES.INCLUDE_ALL,
|
|
40
|
+
},
|
|
41
|
+
[FILTER_TYPES.PERIOD]: {
|
|
42
|
+
last: { count: 1, offset: 1 },
|
|
43
|
+
isNotCurrentPeriod: true,
|
|
44
|
+
filterType: FILTER_TYPES.PERIOD,
|
|
45
|
+
},
|
|
46
|
+
[FILTER_TYPES.DATE_RANGE]: {
|
|
47
|
+
filterType: FILTER_TYPES.DATE_RANGE,
|
|
48
|
+
},
|
|
49
|
+
[FILTER_TYPES.NUMERIC_RANGE]: {
|
|
50
|
+
filterType: FILTER_TYPES.NUMERIC_RANGE,
|
|
51
|
+
},
|
|
52
|
+
[FILTER_TYPES.CONDITION]: {
|
|
53
|
+
explicit: false,
|
|
54
|
+
multiSelection: true,
|
|
55
|
+
exclude: { members: [] },
|
|
56
|
+
filterType: FILTER_TYPES.CONDITION,
|
|
57
|
+
},
|
|
58
|
+
[FILTER_TYPES.SPECIFIC_ITEMS]: {
|
|
59
|
+
explicit: true,
|
|
60
|
+
multiSelection: true,
|
|
61
|
+
members: [],
|
|
62
|
+
filterType: FILTER_TYPES.SPECIFIC_ITEMS,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
export const DEFAULT_FILTER_JAQL_WRAPPER = {
|
|
66
|
+
filter: DEFAULT_FILTER_JAQL_BY_TYPE_MAP.INCLUDE_ALL,
|
|
67
|
+
level: DatetimeLevel.YEARS,
|
|
68
|
+
};
|
|
69
|
+
export var ConditionFilterType;
|
|
70
|
+
(function (ConditionFilterType) {
|
|
71
|
+
ConditionFilterType["IS"] = "members";
|
|
72
|
+
ConditionFilterType["IS_NOT"] = "exclude";
|
|
73
|
+
ConditionFilterType["IS_WITHIN"] = "isWithin";
|
|
74
|
+
ConditionFilterType["TOP"] = "top";
|
|
75
|
+
ConditionFilterType["BOTTOM"] = "bottom";
|
|
76
|
+
ConditionFilterType["AFTER"] = "after";
|
|
77
|
+
ConditionFilterType["BEFORE"] = "before";
|
|
78
|
+
ConditionFilterType["STARTS_WITH"] = "startsWith";
|
|
79
|
+
ConditionFilterType["DOESNT_START_WITH"] = "doesntStartWith";
|
|
80
|
+
ConditionFilterType["ENDS_WITH"] = "endsWith";
|
|
81
|
+
ConditionFilterType["DOESNT_END_WITH"] = "doesntEndWith";
|
|
82
|
+
ConditionFilterType["CONTAINS"] = "contains";
|
|
83
|
+
ConditionFilterType["DOESNT_CONTAIN"] = "doesntContain";
|
|
84
|
+
ConditionFilterType["EQUALS"] = "equals";
|
|
85
|
+
ConditionFilterType["DOESNT_EQUAL"] = "doesntEqual";
|
|
86
|
+
ConditionFilterType["IS_EMPTY"] = "isEmpty";
|
|
87
|
+
ConditionFilterType["IS_NOT_EMPTY"] = "isNotEmpty";
|
|
88
|
+
ConditionFilterType["GREATER_THAN"] = "fromNotEqual";
|
|
89
|
+
ConditionFilterType["GREATER_THAN_OR_EQUAL"] = "from";
|
|
90
|
+
ConditionFilterType["LESS_THAN"] = "toNotEqual";
|
|
91
|
+
ConditionFilterType["LESS_THAN_OR_EQUAL"] = "to";
|
|
92
|
+
ConditionFilterType["BETWEEN"] = "between";
|
|
93
|
+
ConditionFilterType["IS_NOT_BETWEEN"] = "isNotBetween";
|
|
94
|
+
ConditionFilterType["MULTIPLE_CONDITION"] = "multipleCondition";
|
|
95
|
+
ConditionFilterType["NONE"] = "none";
|
|
96
|
+
})(ConditionFilterType = ConditionFilterType || (ConditionFilterType = {}));
|
|
@@ -125,6 +125,8 @@ export declare function sum(attribute: Attribute, name?: string, format?: string
|
|
|
125
125
|
/**
|
|
126
126
|
* Creates an average aggregation measure over the given attribute.
|
|
127
127
|
*
|
|
128
|
+
* Both `average()` and `avg()` can be used interchangeably.
|
|
129
|
+
*
|
|
128
130
|
* @example
|
|
129
131
|
* Calculate the average cost across all items in a category from the Sample Ecommerce data model.
|
|
130
132
|
* ```ts
|
|
@@ -137,6 +139,17 @@ export declare function sum(attribute: Attribute, name?: string, format?: string
|
|
|
137
139
|
* @group Aggregation
|
|
138
140
|
*/
|
|
139
141
|
export declare function average(attribute: Attribute, name?: string, format?: string): BaseMeasure;
|
|
142
|
+
/**
|
|
143
|
+
* {@inheritDoc average}
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* Calculate the average cost across all items in a category from the Sample Ecommerce data model.
|
|
147
|
+
* ```ts
|
|
148
|
+
* measureFactory.avg(DM.Commerce.Cost)
|
|
149
|
+
* ```
|
|
150
|
+
* @group Aggregation
|
|
151
|
+
*/
|
|
152
|
+
export declare function avg(attribute: Attribute, name?: string, format?: string): BaseMeasure;
|
|
140
153
|
/**
|
|
141
154
|
* Creates a min aggregation measure over the given attribute.
|
|
142
155
|
*
|
|
@@ -217,6 +217,8 @@ export function sum(attribute, name, format) {
|
|
|
217
217
|
/**
|
|
218
218
|
* Creates an average aggregation measure over the given attribute.
|
|
219
219
|
*
|
|
220
|
+
* Both `average()` and `avg()` can be used interchangeably.
|
|
221
|
+
*
|
|
220
222
|
* @example
|
|
221
223
|
* Calculate the average cost across all items in a category from the Sample Ecommerce data model.
|
|
222
224
|
* ```ts
|
|
@@ -231,6 +233,19 @@ export function sum(attribute, name, format) {
|
|
|
231
233
|
export function average(attribute, name, format) {
|
|
232
234
|
return aggregate(attribute, AggregationTypes.Average, name, format);
|
|
233
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* {@inheritDoc average}
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* Calculate the average cost across all items in a category from the Sample Ecommerce data model.
|
|
241
|
+
* ```ts
|
|
242
|
+
* measureFactory.avg(DM.Commerce.Cost)
|
|
243
|
+
* ```
|
|
244
|
+
* @group Aggregation
|
|
245
|
+
*/
|
|
246
|
+
export function avg(attribute, name, format) {
|
|
247
|
+
return average(attribute, name, format);
|
|
248
|
+
}
|
|
234
249
|
/**
|
|
235
250
|
* Creates a min aggregation measure over the given attribute.
|
|
236
251
|
*
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
/* eslint-disable no-underscore-dangle */
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
5
|
-
/* eslint-disable complexity */
|
|
6
|
-
/* eslint-disable max-lines */
|
|
7
5
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
8
6
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
9
|
-
/* eslint-disable sonarjs/cognitive-complexity */
|
|
10
7
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
11
8
|
import * as m from './factory.js';
|
|
12
9
|
import { Sort, AggregationTypes, MetadataTypes } from '../types.js';
|
|
@@ -352,7 +349,7 @@ export function createMeasure(json) {
|
|
|
352
349
|
// legacy
|
|
353
350
|
const exp = json.dim || json.expression;
|
|
354
351
|
if (exp) {
|
|
355
|
-
att = new DimensionalAttribute(exp, exp);
|
|
352
|
+
att = new DimensionalAttribute(exp, exp, undefined, desc);
|
|
356
353
|
}
|
|
357
354
|
// official SDK
|
|
358
355
|
if (json.attribute) {
|