@sisense/sdk-data 0.15.0 → 1.0.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/analytics/factory.d.ts +47 -0
- package/dist/dimensional-model/analytics/factory.js +140 -0
- package/dist/dimensional-model/data-model.js +5 -4
- package/dist/dimensional-model/factory.js +2 -2
- package/dist/dimensional-model/filters/factory.d.ts +34 -1
- package/dist/dimensional-model/filters/factory.js +56 -0
- package/dist/dimensional-model/filters/filters.d.ts +4 -0
- package/dist/dimensional-model/filters/filters.js +10 -10
- package/dist/dimensional-model/interfaces.d.ts +15 -2
- package/dist/dimensional-model/measures/factory.d.ts +547 -177
- package/dist/dimensional-model/measures/factory.js +550 -189
- package/dist/dimensional-model/measures/measures.js +6 -6
- package/dist/index.d.ts +43 -36
- package/dist/index.js +43 -36
- package/dist/interfaces.d.ts +1 -1
- package/dist/translation/initialize-i18n.d.ts +2 -0
- package/dist/translation/initialize-i18n.js +10 -0
- package/dist/translation/resources/en.d.ts +28 -0
- package/dist/translation/resources/en.js +27 -0
- package/dist/translation/resources/index.d.ts +53 -0
- package/dist/translation/resources/index.js +7 -0
- package/dist/translation/resources/uk.d.ts +5 -0
- package/dist/translation/resources/uk.js +27 -0
- package/dist/translation/translatable-error.d.ts +5 -0
- package/dist/translation/translatable-error.js +11 -0
- package/dist/utils.d.ts +16 -0
- package/dist/utils.js +63 -0
- package/package.json +14 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Attribute, Measure } from '../interfaces.js';
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare const BOX_WHISKER: {
|
|
4
|
+
BOX_MIN_VALUE_NAME: string;
|
|
5
|
+
BOX_MEDIAN_VALUE_NAME: string;
|
|
6
|
+
BOX_MAX_VALUE_NAME: string;
|
|
7
|
+
WHISKER_MIN_VALUE_NAME: string;
|
|
8
|
+
WHISKER_MAX_VALUE_NAME: string;
|
|
9
|
+
OUTLIER_COUNT_VALUE_NAME: string;
|
|
10
|
+
OUTLIER_MIN_VALUE_NAME: string;
|
|
11
|
+
OUTLIER_MAX_VALUE_NAME: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Returns an array of values for box whisker plot using interquartile range (IQR) calculations.
|
|
15
|
+
*
|
|
16
|
+
* @param {Attribute} target - The target attribute for calculations.
|
|
17
|
+
* @returns {Measure[]} An array of measures representing IQR values for box whisker plots.
|
|
18
|
+
*/
|
|
19
|
+
export declare function boxWhiskerIqrValues(target: Attribute): Measure[];
|
|
20
|
+
/**
|
|
21
|
+
* Returns an array of extremum values for box whisker plot.
|
|
22
|
+
*
|
|
23
|
+
* @param {Attribute} target - The target attribute for calculations.
|
|
24
|
+
* @returns {Measure[]} An array of measures representing extremum values for box whisker plots.
|
|
25
|
+
*/
|
|
26
|
+
export declare function boxWhiskerExtremumsValues(target: Attribute): Measure[];
|
|
27
|
+
/**
|
|
28
|
+
* Returns an array of values for box whisker plot using standard deviation calculations.
|
|
29
|
+
*
|
|
30
|
+
* @param {Attribute} target - The target attribute for calculations.
|
|
31
|
+
* @returns {Measure[]} An array of measures representing standard deviation values for box whisker plots.
|
|
32
|
+
*/
|
|
33
|
+
export declare function boxWhiskerStdDevValues(target: Attribute): Measure[];
|
|
34
|
+
/**
|
|
35
|
+
* Returns an attribute representing outlier points based on interquartile range (IQR) calculations.
|
|
36
|
+
*
|
|
37
|
+
* @param {Attribute} target - The target attribute for calculations.
|
|
38
|
+
* @returns {Attribute} An attribute representing outliers for box whisker plots using IQR.
|
|
39
|
+
*/
|
|
40
|
+
export declare const boxWhiskerIqrOutliers: (target: Attribute) => Attribute;
|
|
41
|
+
/**
|
|
42
|
+
* Returns an attribute representing outlier points based on standard deviation calculations.
|
|
43
|
+
*
|
|
44
|
+
* @param {Attribute} target - The target attribute for calculations.
|
|
45
|
+
* @returns {Attribute} An attribute representing outliers for box whisker plots using standard deviation.
|
|
46
|
+
*/
|
|
47
|
+
export declare const boxWhiskerStdDevOutliers: (target: Attribute) => Attribute;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import cloneDeep from 'lodash/cloneDeep.js';
|
|
2
|
+
import { customFormula } from '../measures/factory.js';
|
|
3
|
+
/** @internal */
|
|
4
|
+
export const BOX_WHISKER = {
|
|
5
|
+
BOX_MIN_VALUE_NAME: 'Box Min',
|
|
6
|
+
BOX_MEDIAN_VALUE_NAME: 'Box Median',
|
|
7
|
+
BOX_MAX_VALUE_NAME: 'Box Max',
|
|
8
|
+
WHISKER_MIN_VALUE_NAME: 'Whisker Min',
|
|
9
|
+
WHISKER_MAX_VALUE_NAME: 'Whisker Max',
|
|
10
|
+
OUTLIER_COUNT_VALUE_NAME: 'Outlier Count',
|
|
11
|
+
OUTLIER_MIN_VALUE_NAME: 'Outlier Min',
|
|
12
|
+
OUTLIER_MAX_VALUE_NAME: 'Outlier Max',
|
|
13
|
+
};
|
|
14
|
+
function boxWhiskerCommonValues(target) {
|
|
15
|
+
return [
|
|
16
|
+
customFormula(BOX_WHISKER.BOX_MIN_VALUE_NAME, 'QUARTILE([Attr], 1)', {
|
|
17
|
+
Attr: target,
|
|
18
|
+
}),
|
|
19
|
+
customFormula(BOX_WHISKER.BOX_MEDIAN_VALUE_NAME, 'MEDIAN([Attr])', {
|
|
20
|
+
Attr: target,
|
|
21
|
+
}),
|
|
22
|
+
customFormula(BOX_WHISKER.BOX_MAX_VALUE_NAME, 'QUARTILE([Attr], 3)', {
|
|
23
|
+
Attr: target,
|
|
24
|
+
}),
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Returns an array of values for box whisker plot using interquartile range (IQR) calculations.
|
|
29
|
+
*
|
|
30
|
+
* @param {Attribute} target - The target attribute for calculations.
|
|
31
|
+
* @returns {Measure[]} An array of measures representing IQR values for box whisker plots.
|
|
32
|
+
*/
|
|
33
|
+
export function boxWhiskerIqrValues(target) {
|
|
34
|
+
return [
|
|
35
|
+
...boxWhiskerCommonValues(target),
|
|
36
|
+
customFormula(BOX_WHISKER.WHISKER_MIN_VALUE_NAME, 'LOWERWHISKERMAX_IQR([Attr])', {
|
|
37
|
+
Attr: target,
|
|
38
|
+
}),
|
|
39
|
+
customFormula(BOX_WHISKER.WHISKER_MAX_VALUE_NAME, 'UPPERWHISKERMIN_IQR([Attr])', {
|
|
40
|
+
Attr: target,
|
|
41
|
+
}),
|
|
42
|
+
customFormula(BOX_WHISKER.OUTLIER_COUNT_VALUE_NAME, 'OUTLIERSCOUNT_IQR([Attr])', {
|
|
43
|
+
Attr: target,
|
|
44
|
+
}),
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns an array of extremum values for box whisker plot.
|
|
49
|
+
*
|
|
50
|
+
* @param {Attribute} target - The target attribute for calculations.
|
|
51
|
+
* @returns {Measure[]} An array of measures representing extremum values for box whisker plots.
|
|
52
|
+
*/
|
|
53
|
+
export function boxWhiskerExtremumsValues(target) {
|
|
54
|
+
return [
|
|
55
|
+
...boxWhiskerCommonValues(target),
|
|
56
|
+
customFormula(BOX_WHISKER.WHISKER_MIN_VALUE_NAME, 'MIN([Attr])', {
|
|
57
|
+
Attr: target,
|
|
58
|
+
}),
|
|
59
|
+
customFormula(BOX_WHISKER.WHISKER_MAX_VALUE_NAME, 'MAX([Attr])', {
|
|
60
|
+
Attr: target,
|
|
61
|
+
}),
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns an array of values for box whisker plot using standard deviation calculations.
|
|
66
|
+
*
|
|
67
|
+
* @param {Attribute} target - The target attribute for calculations.
|
|
68
|
+
* @returns {Measure[]} An array of measures representing standard deviation values for box whisker plots.
|
|
69
|
+
*/
|
|
70
|
+
export function boxWhiskerStdDevValues(target) {
|
|
71
|
+
return [
|
|
72
|
+
...boxWhiskerCommonValues(target),
|
|
73
|
+
customFormula(BOX_WHISKER.WHISKER_MIN_VALUE_NAME, 'LOWERWHISKERMAX_STDEVP([Attr])', {
|
|
74
|
+
Attr: target,
|
|
75
|
+
}),
|
|
76
|
+
customFormula(BOX_WHISKER.WHISKER_MAX_VALUE_NAME, 'UPPERWHISKERMIN_STDEVP([Attr])', {
|
|
77
|
+
Attr: target,
|
|
78
|
+
}),
|
|
79
|
+
customFormula(BOX_WHISKER.OUTLIER_COUNT_VALUE_NAME, 'OUTLIERSCOUNT_STDEVP([Attr])', {
|
|
80
|
+
Attr: target,
|
|
81
|
+
}),
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns an attribute representing outlier points based on interquartile range (IQR) calculations.
|
|
86
|
+
*
|
|
87
|
+
* @param {Attribute} target - The target attribute for calculations.
|
|
88
|
+
* @returns {Attribute} An attribute representing outliers for box whisker plots using IQR.
|
|
89
|
+
*/
|
|
90
|
+
export const boxWhiskerIqrOutliers = (target) => {
|
|
91
|
+
const outliersAttrWithInnerFilter = cloneDeep(target);
|
|
92
|
+
const outliersMax = customFormula(BOX_WHISKER.OUTLIER_MAX_VALUE_NAME, '(UPPERWHISKERMIN_IQR([Attr]), all([Attr]))', {
|
|
93
|
+
Attr: target,
|
|
94
|
+
});
|
|
95
|
+
const outliersMin = customFormula(BOX_WHISKER.OUTLIER_MIN_VALUE_NAME, '(LOWERWHISKERMAX_IQR([Attr]), all([Attr]))', {
|
|
96
|
+
Attr: target,
|
|
97
|
+
});
|
|
98
|
+
outliersAttrWithInnerFilter.name = `${outliersAttrWithInnerFilter.name} (Outliers)`;
|
|
99
|
+
outliersAttrWithInnerFilter.jaql = () => {
|
|
100
|
+
return Object.assign(Object.assign({}, target.jaql()), { filter: {
|
|
101
|
+
or: [
|
|
102
|
+
{
|
|
103
|
+
fromNotEqual: outliersMax.jaql(true),
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
toNotEqual: outliersMin.jaql(true),
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
} });
|
|
110
|
+
};
|
|
111
|
+
return outliersAttrWithInnerFilter;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Returns an attribute representing outlier points based on standard deviation calculations.
|
|
115
|
+
*
|
|
116
|
+
* @param {Attribute} target - The target attribute for calculations.
|
|
117
|
+
* @returns {Attribute} An attribute representing outliers for box whisker plots using standard deviation.
|
|
118
|
+
*/
|
|
119
|
+
export const boxWhiskerStdDevOutliers = (target) => {
|
|
120
|
+
const outliersAttrWithInnerFilter = cloneDeep(target);
|
|
121
|
+
const outliersMax = customFormula(BOX_WHISKER.OUTLIER_MAX_VALUE_NAME, '(UPPERWHISKERMIN_STDEVP([Attr]), all([Attr]))', {
|
|
122
|
+
Attr: target,
|
|
123
|
+
});
|
|
124
|
+
const outliersMin = customFormula(BOX_WHISKER.OUTLIER_MIN_VALUE_NAME, '(LOWERWHISKERMAX_STDEVP([Attr]), all([Attr]))', {
|
|
125
|
+
Attr: target,
|
|
126
|
+
});
|
|
127
|
+
outliersAttrWithInnerFilter.jaql = () => {
|
|
128
|
+
return Object.assign(Object.assign({}, target.jaql()), { filter: {
|
|
129
|
+
or: [
|
|
130
|
+
{
|
|
131
|
+
fromNotEqual: outliersMax.jaql(true),
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
toNotEqual: outliersMin.jaql(true),
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
} });
|
|
138
|
+
};
|
|
139
|
+
return outliersAttrWithInnerFilter;
|
|
140
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { create } from './factory.js';
|
|
2
|
+
import { TranslatableError } from '../translation/translatable-error.js';
|
|
2
3
|
/**
|
|
3
4
|
* @internal
|
|
4
5
|
*/
|
|
@@ -17,11 +18,11 @@ export class DimensionalDataModel {
|
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
static fromConfig(config) {
|
|
20
|
-
if (
|
|
21
|
-
throw new
|
|
21
|
+
if (config && !config.name) {
|
|
22
|
+
throw new TranslatableError('errors.dataModel.noName');
|
|
22
23
|
}
|
|
23
|
-
if (
|
|
24
|
-
throw new
|
|
24
|
+
if (config && !config.metadata) {
|
|
25
|
+
throw new TranslatableError('errors.dataModel.noMetadata');
|
|
25
26
|
}
|
|
26
27
|
const metadata = new Array();
|
|
27
28
|
for (let i = 0; i < config.metadata.length; i++) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-throw-literal */
|
|
4
3
|
import { MetadataTypes } from './types.js';
|
|
5
4
|
import { createMeasure } from './measures/measures.js';
|
|
6
5
|
import { createFilter } from './filters/filters.js';
|
|
7
6
|
import { createDimension } from './dimensions.js';
|
|
8
7
|
import { createAttribute } from './attributes.js';
|
|
8
|
+
import { TranslatableError } from '../translation/translatable-error.js';
|
|
9
9
|
/**
|
|
10
10
|
* Generate an array of dimension model instances out of the given JSON array
|
|
11
11
|
*
|
|
@@ -46,5 +46,5 @@ export function create(item) {
|
|
|
46
46
|
item.dimtype) {
|
|
47
47
|
return createDimension(item);
|
|
48
48
|
}
|
|
49
|
-
throw '
|
|
49
|
+
throw new TranslatableError('errors.unsupportedDimensionalElement');
|
|
50
50
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateDimension, LevelAttribute, Attribute, Measure, Filter, BaseMeasure } from '../interfaces.js';
|
|
1
|
+
import { DateDimension, LevelAttribute, Attribute, Measure, Filter, BaseMeasure, FilterRelationNode, FilterRelation } from '../interfaces.js';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a filter representing a union of multiple filters of the same attribute.
|
|
4
4
|
*
|
|
@@ -313,3 +313,36 @@ export declare function topRanking(attribute: Attribute, measure: Measure, count
|
|
|
313
313
|
* @returns A filter representing a bottom ranking logic on the given attribute by the given measure
|
|
314
314
|
*/
|
|
315
315
|
export declare function bottomRanking(attribute: Attribute, measure: Measure, count: number): Filter;
|
|
316
|
+
/**
|
|
317
|
+
* Set of logic operators for filter relation construction
|
|
318
|
+
*
|
|
319
|
+
* These operators are still in beta.
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
```tsx
|
|
323
|
+
import { filters } from '@sisense/sdk-data';
|
|
324
|
+
|
|
325
|
+
// define filters
|
|
326
|
+
const revenueFilter = filters.greaterThan(DM.Commerce.Revenue, 1000);
|
|
327
|
+
const countryFilter = filters.members(DM.Commerce.Country, ['USA', 'Canada']);
|
|
328
|
+
const genderFilter = filters.doesntContain(DM.Commerce.Gender, 'Unspecified');
|
|
329
|
+
const costFilter = filters.between(DM.Commerce.Cost, 1000, 2000);
|
|
330
|
+
|
|
331
|
+
// create filter relation of two filters
|
|
332
|
+
const orFilerRelations = filterFactory.logic.or(revenueFilter, countryFilter);
|
|
333
|
+
// revenueFilter OR countryFilter
|
|
334
|
+
|
|
335
|
+
// filter relations can have nested filter relations
|
|
336
|
+
const mixedFilterRelations = filterFactory.logic.and(genderFilter, orFilerRelations);
|
|
337
|
+
// genderFilter AND (revenueFilter OR countryFilter)
|
|
338
|
+
|
|
339
|
+
// array, specified in filter relations, will be converted to an intersection of filters automatically
|
|
340
|
+
const arrayFilterRelations = filterFactory.logic.or([genderFilter, costFilter], mixedFilterRelations);
|
|
341
|
+
// (genderFilter AND costFilter) OR (genderFilter AND (revenueFilter OR countryFilter))
|
|
342
|
+
```
|
|
343
|
+
* @beta
|
|
344
|
+
*/
|
|
345
|
+
export declare namespace logic {
|
|
346
|
+
const and: (left: FilterRelationNode, right: FilterRelationNode) => FilterRelation;
|
|
347
|
+
const or: (left: FilterRelationNode, right: FilterRelationNode) => FilterRelation;
|
|
348
|
+
}
|
|
@@ -402,3 +402,59 @@ export function topRanking(attribute, measure, count) {
|
|
|
402
402
|
export function bottomRanking(attribute, measure, count) {
|
|
403
403
|
return new RankingFilter(attribute, measure, RankingOperators.Bottom, count);
|
|
404
404
|
}
|
|
405
|
+
const relate = (node) => {
|
|
406
|
+
if (Array.isArray(node)) {
|
|
407
|
+
const [first, ...rest] = node;
|
|
408
|
+
return rest.length === 0
|
|
409
|
+
? relate(first)
|
|
410
|
+
: {
|
|
411
|
+
operator: 'AND',
|
|
412
|
+
left: relate(first),
|
|
413
|
+
right: relate(rest),
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
return node;
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* Set of logic operators for filter relation construction
|
|
420
|
+
*
|
|
421
|
+
* These operators are still in beta.
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
```tsx
|
|
425
|
+
import { filters } from '@sisense/sdk-data';
|
|
426
|
+
|
|
427
|
+
// define filters
|
|
428
|
+
const revenueFilter = filters.greaterThan(DM.Commerce.Revenue, 1000);
|
|
429
|
+
const countryFilter = filters.members(DM.Commerce.Country, ['USA', 'Canada']);
|
|
430
|
+
const genderFilter = filters.doesntContain(DM.Commerce.Gender, 'Unspecified');
|
|
431
|
+
const costFilter = filters.between(DM.Commerce.Cost, 1000, 2000);
|
|
432
|
+
|
|
433
|
+
// create filter relation of two filters
|
|
434
|
+
const orFilerRelations = filterFactory.logic.or(revenueFilter, countryFilter);
|
|
435
|
+
// revenueFilter OR countryFilter
|
|
436
|
+
|
|
437
|
+
// filter relations can have nested filter relations
|
|
438
|
+
const mixedFilterRelations = filterFactory.logic.and(genderFilter, orFilerRelations);
|
|
439
|
+
// genderFilter AND (revenueFilter OR countryFilter)
|
|
440
|
+
|
|
441
|
+
// array, specified in filter relations, will be converted to an intersection of filters automatically
|
|
442
|
+
const arrayFilterRelations = filterFactory.logic.or([genderFilter, costFilter], mixedFilterRelations);
|
|
443
|
+
// (genderFilter AND costFilter) OR (genderFilter AND (revenueFilter OR countryFilter))
|
|
444
|
+
```
|
|
445
|
+
* @beta
|
|
446
|
+
*/
|
|
447
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
448
|
+
export var logic;
|
|
449
|
+
(function (logic) {
|
|
450
|
+
logic.and = (left, right) => ({
|
|
451
|
+
operator: 'AND',
|
|
452
|
+
left: relate(left),
|
|
453
|
+
right: relate(right),
|
|
454
|
+
});
|
|
455
|
+
logic.or = (left, right) => ({
|
|
456
|
+
operator: 'OR',
|
|
457
|
+
left: relate(left),
|
|
458
|
+
right: relate(right),
|
|
459
|
+
});
|
|
460
|
+
})(logic = logic || (logic = {}));
|
|
@@ -88,6 +88,10 @@ declare abstract class AbstractFilter extends DimensionalElement implements Filt
|
|
|
88
88
|
* Filter type
|
|
89
89
|
*/
|
|
90
90
|
readonly filterType: string;
|
|
91
|
+
/**
|
|
92
|
+
* Global filter identifier
|
|
93
|
+
*/
|
|
94
|
+
readonly guid: string;
|
|
91
95
|
constructor(att: Attribute, filterType: string);
|
|
92
96
|
get name(): string;
|
|
93
97
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-throw-literal */
|
|
5
4
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
6
5
|
/* eslint-disable max-lines */
|
|
7
6
|
/* eslint-disable max-params */
|
|
@@ -14,6 +13,8 @@ import { DimensionalElement } from '../base.js';
|
|
|
14
13
|
import { DateLevels, MetadataTypes } from '../types.js';
|
|
15
14
|
import { create } from '../factory.js';
|
|
16
15
|
import { DimensionalBaseMeasure } from '../measures/measures.js';
|
|
16
|
+
import { TranslatableError } from '../../translation/translatable-error.js';
|
|
17
|
+
import { guidFast } from '../../utils.js';
|
|
17
18
|
/**
|
|
18
19
|
* Different text operators that can be used with text filters
|
|
19
20
|
*
|
|
@@ -100,6 +101,7 @@ class AbstractFilter extends DimensionalElement {
|
|
|
100
101
|
this.filterType = filterType;
|
|
101
102
|
AbstractFilter.checkAttributeSupport(att);
|
|
102
103
|
this.attribute = att;
|
|
104
|
+
this.guid = guidFast(13);
|
|
103
105
|
}
|
|
104
106
|
get name() {
|
|
105
107
|
return hash(this.jaql());
|
|
@@ -140,7 +142,7 @@ class AbstractFilter extends DimensionalElement {
|
|
|
140
142
|
if (granularity === DateLevels.Hours ||
|
|
141
143
|
granularity === DateLevels.MinutesRoundTo30 ||
|
|
142
144
|
granularity === DateLevels.MinutesRoundTo15) {
|
|
143
|
-
throw new
|
|
145
|
+
throw new TranslatableError('errors.filter.unsupportedDatetimeLevel');
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
}
|
|
@@ -185,7 +187,9 @@ export class MembersFilter extends AbstractFilter {
|
|
|
185
187
|
super(attribute, FilterTypes.members);
|
|
186
188
|
this.members = members !== null && members !== void 0 ? members : [];
|
|
187
189
|
if (this.members.filter((m) => m === null || m === undefined).length > 0) {
|
|
188
|
-
throw
|
|
190
|
+
throw new TranslatableError('errors.filter.membersFilterNullMember', {
|
|
191
|
+
attributeId: attribute.id,
|
|
192
|
+
});
|
|
189
193
|
}
|
|
190
194
|
}
|
|
191
195
|
/**
|
|
@@ -399,9 +403,6 @@ export class RankingFilter extends AbstractFilter {
|
|
|
399
403
|
export class NumericFilter extends DoubleOperatorFilter {
|
|
400
404
|
constructor(att, operatorA, valueA, operatorB, valueB) {
|
|
401
405
|
super(att, FilterTypes.numeric, operatorA, valueA, operatorB, valueB);
|
|
402
|
-
// if (att.dimension && !MetadataTypes.isTextDimension(att.dimension.type)) {
|
|
403
|
-
// throw 'Dimension must be of Text type to be applied with Text filter';
|
|
404
|
-
// }
|
|
405
406
|
}
|
|
406
407
|
}
|
|
407
408
|
/**
|
|
@@ -410,9 +411,6 @@ export class NumericFilter extends DoubleOperatorFilter {
|
|
|
410
411
|
export class TextFilter extends DoubleOperatorFilter {
|
|
411
412
|
constructor(att, operator, value) {
|
|
412
413
|
super(att, FilterTypes.text, operator, value);
|
|
413
|
-
// if (att.dimension && !MetadataTypes.isTextDimension(att.dimension.type)) {
|
|
414
|
-
// throw 'Dimension must be of Text type to be applied with Text filter';
|
|
415
|
-
// }
|
|
416
414
|
}
|
|
417
415
|
}
|
|
418
416
|
/**
|
|
@@ -544,5 +542,7 @@ export function createFilter(json) {
|
|
|
544
542
|
return new DateRangeFilter(create(json.attribute), json.valueA, json.valueB);
|
|
545
543
|
break;
|
|
546
544
|
}
|
|
547
|
-
throw '
|
|
545
|
+
throw new TranslatableError('errors.filter.unsupportedType', {
|
|
546
|
+
filterType: json.filterType,
|
|
547
|
+
});
|
|
548
548
|
}
|
|
@@ -62,7 +62,7 @@ export interface Element {
|
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Base interface for measure, which is typically numeric aggregation over {@link Attribute}(s).
|
|
65
|
-
* See {@link
|
|
65
|
+
* See {@link measureFactory} for how to create measures.
|
|
66
66
|
*
|
|
67
67
|
*/
|
|
68
68
|
export interface Measure extends Element {
|
|
@@ -321,9 +321,13 @@ export interface LevelAttribute extends Attribute {
|
|
|
321
321
|
};
|
|
322
322
|
}
|
|
323
323
|
/**
|
|
324
|
-
* Base interface for filter. See {@link
|
|
324
|
+
* Base interface for filter. See {@link filterFactory} for how to create filters.
|
|
325
325
|
*/
|
|
326
326
|
export interface Filter extends Element {
|
|
327
|
+
/**
|
|
328
|
+
* Global filter identifier
|
|
329
|
+
*/
|
|
330
|
+
readonly guid: string;
|
|
327
331
|
/**
|
|
328
332
|
* Attribute this filter instance is filtering
|
|
329
333
|
*/
|
|
@@ -342,3 +346,12 @@ export interface Filter extends Element {
|
|
|
342
346
|
export interface CustomFormulaContext {
|
|
343
347
|
[key: string]: Attribute | Measure;
|
|
344
348
|
}
|
|
349
|
+
export declare type FilterRelationNode = Filter | Filter[] | FilterRelation | FilterRelationJaqlNode;
|
|
350
|
+
export interface FilterRelation {
|
|
351
|
+
left: FilterRelationNode;
|
|
352
|
+
right: FilterRelationNode;
|
|
353
|
+
operator: 'AND' | 'OR';
|
|
354
|
+
}
|
|
355
|
+
export declare type FilterRelationJaqlNode = {
|
|
356
|
+
instanceid: string;
|
|
357
|
+
};
|