@sisense/sdk-data 1.7.2 → 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/README.md +1 -1
- package/dist/dimensional-model/analytics/factory.js +2 -2
- package/dist/dimensional-model/attributes.d.ts +11 -0
- package/dist/dimensional-model/attributes.js +20 -1
- package/dist/dimensional-model/dimensions.js +5 -4
- package/dist/dimensional-model/factory.js +0 -1
- package/dist/dimensional-model/filters/factory.d.ts +58 -0
- package/dist/dimensional-model/filters/factory.js +68 -0
- 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/date-time-filter-util.d.ts +2 -0
- package/dist/dimensional-model/filters/utils/date-time-filter-util.js +8 -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/types.d.ts +200 -0
- package/dist/dimensional-model/filters/utils/types.js +96 -0
- package/dist/dimensional-model/interfaces.d.ts +58 -8
- package/dist/dimensional-model/measures/factory.d.ts +15 -2
- package/dist/dimensional-model/measures/factory.js +17 -2
- package/dist/dimensional-model/measures/measures.js +1 -4
- package/dist/dimensional-model/types.d.ts +37 -5
- package/dist/dimensional-model/types.js +6 -8
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/utils.d.ts +12 -1
- package/dist/utils.js +17 -0
- package/package.json +3 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stringifies the argument
|
|
3
|
+
*
|
|
4
|
+
* @param arg - argument to stringify
|
|
5
|
+
* @returns stringified argument
|
|
6
|
+
*/
|
|
7
|
+
export function stringifyHelper(arg) {
|
|
8
|
+
try {
|
|
9
|
+
if (arg === null || arg === undefined) {
|
|
10
|
+
return JSON.stringify(arg);
|
|
11
|
+
}
|
|
12
|
+
if (arg === Object(arg) && 'composeCode' in arg) {
|
|
13
|
+
return arg.composeCode;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(arg)) {
|
|
16
|
+
return ('[' +
|
|
17
|
+
arg
|
|
18
|
+
.map((e) => {
|
|
19
|
+
return stringifyHelper(e);
|
|
20
|
+
})
|
|
21
|
+
.join(', ') +
|
|
22
|
+
']');
|
|
23
|
+
}
|
|
24
|
+
if (typeof arg === 'string') {
|
|
25
|
+
return `'${arg}'`;
|
|
26
|
+
}
|
|
27
|
+
if (typeof arg === 'number' || !isNaN(arg)) {
|
|
28
|
+
return arg;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
console.error(e);
|
|
33
|
+
}
|
|
34
|
+
return JSON.stringify(arg);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* High order function to construct compose code for filter factory functions
|
|
38
|
+
*
|
|
39
|
+
* @param func - filter factory function
|
|
40
|
+
*/
|
|
41
|
+
export function withComposeCode(func) {
|
|
42
|
+
return function (...args) {
|
|
43
|
+
const argValues = args.map(stringifyHelper).join(', ');
|
|
44
|
+
const signature = `filterFactory.${func.name}(${argValues})`;
|
|
45
|
+
const filter = func(...args);
|
|
46
|
+
filter.composeCode = signature;
|
|
47
|
+
return filter;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
declare type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
|
2
|
+
[K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
|
|
3
|
+
}[Keys];
|
|
4
|
+
export declare type JaqlContext = Record<string, Partial<FilterJaqlInternal>>;
|
|
5
|
+
export declare type Id = string;
|
|
6
|
+
export declare type Datasource = {
|
|
7
|
+
address: Id;
|
|
8
|
+
database: string;
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
live?: boolean;
|
|
12
|
+
fullname: string;
|
|
13
|
+
lastBuildTime?: string;
|
|
14
|
+
revisionId?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare enum GeneralFilterType {
|
|
17
|
+
INCLUDE_ALL = "INCLUDE_ALL",
|
|
18
|
+
ADVANCED = "ADVANCED",
|
|
19
|
+
INVALID = "INVALID",
|
|
20
|
+
CONDITION = "CONDITION",
|
|
21
|
+
SPECIFIC_ITEMS = "SPECIFIC_ITEMS"
|
|
22
|
+
}
|
|
23
|
+
export declare enum DateTimeFilterType {
|
|
24
|
+
PERIOD = "PERIOD",
|
|
25
|
+
DATE_RANGE = "DATE_RANGE"
|
|
26
|
+
}
|
|
27
|
+
export declare enum NumericFilterType {
|
|
28
|
+
NUMERIC_RANGE = "NUMERIC_RANGE"
|
|
29
|
+
}
|
|
30
|
+
export declare type FilterType = GeneralFilterType | DateTimeFilterType | NumericFilterType;
|
|
31
|
+
export interface BaseFilterJaql {
|
|
32
|
+
filterType?: FilterType;
|
|
33
|
+
custom?: boolean;
|
|
34
|
+
isAdvanced?: boolean;
|
|
35
|
+
rankingMessage?: string;
|
|
36
|
+
isBetween?: boolean;
|
|
37
|
+
isEmpty?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface IncludeAllFilterJaql extends BaseFilterJaql {
|
|
40
|
+
all: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare type PeriodFilterDetails = {
|
|
43
|
+
count: number;
|
|
44
|
+
offset: number;
|
|
45
|
+
anchor?: string;
|
|
46
|
+
};
|
|
47
|
+
export interface PeriodFilterJaqlOptions extends BaseFilterJaql {
|
|
48
|
+
last: PeriodFilterDetails;
|
|
49
|
+
next: PeriodFilterDetails;
|
|
50
|
+
multiSelection?: boolean;
|
|
51
|
+
isNotCurrentPeriod?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare type PeriodFilterJaql = RequireOnlyOne<PeriodFilterJaqlOptions, 'last' | 'next'>;
|
|
54
|
+
export interface RangeFilterJaql extends BaseFilterJaql {
|
|
55
|
+
from?: string | number;
|
|
56
|
+
to?: string | number;
|
|
57
|
+
multiSelection?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export declare type RankingFilterJaql = {
|
|
60
|
+
agg: string;
|
|
61
|
+
column: string;
|
|
62
|
+
datatype: string;
|
|
63
|
+
dim: string;
|
|
64
|
+
level?: string;
|
|
65
|
+
merged?: boolean;
|
|
66
|
+
table: string;
|
|
67
|
+
};
|
|
68
|
+
export declare type FilterMultiSelectJaql = {
|
|
69
|
+
explicit?: boolean;
|
|
70
|
+
multiSelection: boolean;
|
|
71
|
+
members: string[];
|
|
72
|
+
isCondition?: boolean;
|
|
73
|
+
};
|
|
74
|
+
export declare type FilterMultipleConditionJaql = {
|
|
75
|
+
or: ConditionFilterJaql[];
|
|
76
|
+
and: ConditionFilterJaql[];
|
|
77
|
+
};
|
|
78
|
+
export declare type ConditionFilterJaqlOptions = BaseFilterJaql & {
|
|
79
|
+
top: number;
|
|
80
|
+
bottom: number;
|
|
81
|
+
exclude: {
|
|
82
|
+
members?: string[];
|
|
83
|
+
from?: number;
|
|
84
|
+
to?: number;
|
|
85
|
+
};
|
|
86
|
+
startsWith: string;
|
|
87
|
+
doesntStartWith: string;
|
|
88
|
+
endsWith: string;
|
|
89
|
+
doesntEndWith: string;
|
|
90
|
+
doesntContain: string;
|
|
91
|
+
equals: number | string;
|
|
92
|
+
doesntEqual: number | string;
|
|
93
|
+
to: number;
|
|
94
|
+
toNotEqual: number;
|
|
95
|
+
from: number;
|
|
96
|
+
fromNotEqual: number;
|
|
97
|
+
contains: string;
|
|
98
|
+
by?: RankingFilterJaql;
|
|
99
|
+
rankingMessage?: string;
|
|
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
|
+
export declare enum DatetimeLevel {
|
|
106
|
+
YEARS = "years",
|
|
107
|
+
QUARTERS = "quarters",
|
|
108
|
+
MONTHS = "months",
|
|
109
|
+
WEEKS = "weeks",
|
|
110
|
+
DAYS = "days",
|
|
111
|
+
HOURS = "hours",
|
|
112
|
+
MINUTES = "minutes"
|
|
113
|
+
}
|
|
114
|
+
export declare type FilterJaqlInternal = {
|
|
115
|
+
title: string;
|
|
116
|
+
column: string;
|
|
117
|
+
datasource?: Datasource;
|
|
118
|
+
datatype: string;
|
|
119
|
+
dim: string;
|
|
120
|
+
dimension?: string;
|
|
121
|
+
fiscal?: string;
|
|
122
|
+
firstday?: string;
|
|
123
|
+
merged?: boolean;
|
|
124
|
+
table: string;
|
|
125
|
+
filter?: AnyTypeFilterJaql;
|
|
126
|
+
level?: DatetimeLevel;
|
|
127
|
+
locale?: string;
|
|
128
|
+
bucket?: string;
|
|
129
|
+
collapsed?: boolean;
|
|
130
|
+
isDashboardFilter?: boolean;
|
|
131
|
+
formula?: string;
|
|
132
|
+
context?: JaqlContext;
|
|
133
|
+
agg?: string;
|
|
134
|
+
};
|
|
135
|
+
export declare enum FilterModalType {
|
|
136
|
+
DATE_TIME = "datetime",
|
|
137
|
+
NUMERIC = "numeric",
|
|
138
|
+
TEXT = "text"
|
|
139
|
+
}
|
|
140
|
+
export declare type BackgroundFilterExtraProps = {
|
|
141
|
+
level?: DatetimeLevel;
|
|
142
|
+
turnedOff?: boolean;
|
|
143
|
+
};
|
|
144
|
+
export declare type BackgroundFilter = {
|
|
145
|
+
filter?: AnyTypeFilterJaql & BackgroundFilterExtraProps;
|
|
146
|
+
};
|
|
147
|
+
export declare type FilterJaqlWrapperWithType = {
|
|
148
|
+
filter: AnyTypeFilterJaql & BackgroundFilter;
|
|
149
|
+
level?: DatetimeLevel;
|
|
150
|
+
agg?: string;
|
|
151
|
+
};
|
|
152
|
+
export declare const nonSupportedMinutesBuckets: string[];
|
|
153
|
+
export declare const FILTER_TYPES: {
|
|
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
|
+
};
|
|
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
|
+
};
|
|
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
|
+
IS = "members",
|
|
175
|
+
IS_NOT = "exclude",
|
|
176
|
+
IS_WITHIN = "isWithin",
|
|
177
|
+
TOP = "top",
|
|
178
|
+
BOTTOM = "bottom",
|
|
179
|
+
AFTER = "after",
|
|
180
|
+
BEFORE = "before",
|
|
181
|
+
STARTS_WITH = "startsWith",
|
|
182
|
+
DOESNT_START_WITH = "doesntStartWith",
|
|
183
|
+
ENDS_WITH = "endsWith",
|
|
184
|
+
DOESNT_END_WITH = "doesntEndWith",
|
|
185
|
+
CONTAINS = "contains",
|
|
186
|
+
DOESNT_CONTAIN = "doesntContain",
|
|
187
|
+
EQUALS = "equals",
|
|
188
|
+
DOESNT_EQUAL = "doesntEqual",
|
|
189
|
+
IS_EMPTY = "isEmpty",
|
|
190
|
+
IS_NOT_EMPTY = "isNotEmpty",
|
|
191
|
+
GREATER_THAN = "fromNotEqual",
|
|
192
|
+
GREATER_THAN_OR_EQUAL = "from",
|
|
193
|
+
LESS_THAN = "toNotEqual",
|
|
194
|
+
LESS_THAN_OR_EQUAL = "to",
|
|
195
|
+
BETWEEN = "between",
|
|
196
|
+
IS_NOT_BETWEEN = "isNotBetween",
|
|
197
|
+
MULTIPLE_CONDITION = "multipleCondition",
|
|
198
|
+
NONE = "none"
|
|
199
|
+
}
|
|
200
|
+
export {};
|
|
@@ -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 = {}));
|