@sisense/sdk-data 1.19.0 → 1.21.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/cjs/dimensional-model/attributes.d.ts +3 -3
- package/dist/cjs/dimensional-model/attributes.js +4 -4
- package/dist/cjs/dimensional-model/base.d.ts +10 -1
- package/dist/cjs/dimensional-model/base.js +11 -1
- package/dist/cjs/dimensional-model/filters/filters.js +4 -0
- package/dist/cjs/dimensional-model/filters/utils/attribute-measure-util.d.ts +15 -5
- package/dist/cjs/dimensional-model/filters/utils/attribute-measure-util.js +30 -9
- package/dist/cjs/dimensional-model/filters/utils/condition-filter-util.js +3 -1
- package/dist/cjs/dimensional-model/filters/utils/filter-from-jaql-util.js +1 -1
- package/dist/cjs/dimensional-model/filters/utils/types.d.ts +15 -6
- package/dist/cjs/dimensional-model/interfaces.d.ts +17 -3
- package/dist/cjs/dimensional-model/measures/factory.d.ts +11 -1
- package/dist/cjs/dimensional-model/measures/factory.js +3 -2
- package/dist/cjs/dimensional-model/types.d.ts +8 -3
- package/dist/cjs/utils.d.ts +27 -2
- package/dist/cjs/utils.js +61 -2
- package/dist/dimensional-model/attributes.d.ts +3 -3
- package/dist/dimensional-model/attributes.js +4 -4
- package/dist/dimensional-model/base.d.ts +10 -1
- package/dist/dimensional-model/base.js +11 -1
- package/dist/dimensional-model/filters/filters.js +4 -0
- package/dist/dimensional-model/filters/utils/attribute-measure-util.d.ts +15 -5
- package/dist/dimensional-model/filters/utils/attribute-measure-util.js +28 -8
- package/dist/dimensional-model/filters/utils/condition-filter-util.js +3 -1
- package/dist/dimensional-model/filters/utils/filter-from-jaql-util.js +1 -1
- package/dist/dimensional-model/filters/utils/types.d.ts +15 -6
- package/dist/dimensional-model/interfaces.d.ts +17 -3
- package/dist/dimensional-model/measures/factory.d.ts +11 -1
- package/dist/dimensional-model/measures/factory.js +2 -2
- package/dist/dimensional-model/types.d.ts +8 -3
- package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -1
- package/dist/utils.d.ts +27 -2
- package/dist/utils.js +56 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Attribute, LevelAttribute } from './interfaces.js';
|
|
2
|
-
import { Sort } from './types.js';
|
|
2
|
+
import { Sort, JaqlDataSource } from './types.js';
|
|
3
3
|
import { DimensionalElement } from './base.js';
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
@@ -11,7 +11,7 @@ export declare const jaqlSimpleColumnType: (datatype: string) => string;
|
|
|
11
11
|
export declare class DimensionalAttribute extends DimensionalElement implements Attribute {
|
|
12
12
|
readonly expression: string;
|
|
13
13
|
protected _sort: Sort;
|
|
14
|
-
constructor(name: string, expression: string, type?: string, desc?: string, sort?: Sort);
|
|
14
|
+
constructor(name: string, expression: string, type?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource);
|
|
15
15
|
/**
|
|
16
16
|
* gets the element's ID
|
|
17
17
|
*/
|
|
@@ -46,7 +46,7 @@ export declare class DimensionalAttribute extends DimensionalElement implements
|
|
|
46
46
|
export declare class DimensionalLevelAttribute extends DimensionalAttribute implements LevelAttribute {
|
|
47
47
|
private _format;
|
|
48
48
|
readonly granularity: string;
|
|
49
|
-
constructor(l: string, expression: string, granularity: string, format?: string, desc?: string, sort?: Sort);
|
|
49
|
+
constructor(l: string, expression: string, granularity: string, format?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource);
|
|
50
50
|
/**
|
|
51
51
|
* gets the element's ID
|
|
52
52
|
*/
|
|
@@ -13,8 +13,8 @@ exports.jaqlSimpleColumnType = jaqlSimpleColumnType;
|
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
15
|
class DimensionalAttribute extends base_js_1.DimensionalElement {
|
|
16
|
-
constructor(name, expression, type, desc, sort) {
|
|
17
|
-
super(name, type || types_js_1.MetadataTypes.Attribute, desc);
|
|
16
|
+
constructor(name, expression, type, desc, sort, dataSource) {
|
|
17
|
+
super(name, type || types_js_1.MetadataTypes.Attribute, desc, dataSource);
|
|
18
18
|
this._sort = types_js_1.Sort.None;
|
|
19
19
|
this.expression = expression;
|
|
20
20
|
this._sort = sort || types_js_1.Sort.None;
|
|
@@ -77,8 +77,8 @@ exports.DimensionalAttribute = DimensionalAttribute;
|
|
|
77
77
|
* @internal
|
|
78
78
|
*/
|
|
79
79
|
class DimensionalLevelAttribute extends DimensionalAttribute {
|
|
80
|
-
constructor(l, expression, granularity, format, desc, sort) {
|
|
81
|
-
super(l, expression, types_js_1.MetadataTypes.DateLevel, desc, sort);
|
|
80
|
+
constructor(l, expression, granularity, format, desc, sort, dataSource) {
|
|
81
|
+
super(l, expression, types_js_1.MetadataTypes.DateLevel, desc, sort, dataSource);
|
|
82
82
|
this._format = format;
|
|
83
83
|
this.granularity = granularity;
|
|
84
84
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Element } from './interfaces.js';
|
|
2
|
+
import { JaqlDataSource } from './types.js';
|
|
2
3
|
/**
|
|
3
4
|
* @internal
|
|
4
5
|
*/
|
|
@@ -7,12 +8,20 @@ export declare abstract class DimensionalElement implements Element {
|
|
|
7
8
|
* @internal
|
|
8
9
|
*/
|
|
9
10
|
private _name;
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
private readonly _dataSource;
|
|
10
15
|
/**
|
|
11
16
|
* Defines the element's name
|
|
12
17
|
*/
|
|
13
18
|
get name(): string;
|
|
14
19
|
set name(value: string);
|
|
15
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Defines the element's data source
|
|
22
|
+
*/
|
|
23
|
+
get dataSource(): JaqlDataSource;
|
|
24
|
+
constructor(name: string, type: string, desc?: string, dataSource?: JaqlDataSource);
|
|
16
25
|
/**
|
|
17
26
|
* gets the element's description
|
|
18
27
|
*/
|
|
@@ -5,10 +5,13 @@ exports.normalizeName = exports.DimensionalElement = void 0;
|
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
7
|
class DimensionalElement {
|
|
8
|
-
constructor(name, type, desc) {
|
|
8
|
+
constructor(name, type, desc, dataSource) {
|
|
9
9
|
this._name = name;
|
|
10
10
|
this.type = type;
|
|
11
11
|
this.description = desc || '';
|
|
12
|
+
if (dataSource) {
|
|
13
|
+
this._dataSource = dataSource;
|
|
14
|
+
}
|
|
12
15
|
}
|
|
13
16
|
/**
|
|
14
17
|
* Defines the element's name
|
|
@@ -19,6 +22,12 @@ class DimensionalElement {
|
|
|
19
22
|
set name(value) {
|
|
20
23
|
this._name = value;
|
|
21
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Defines the element's data source
|
|
27
|
+
*/
|
|
28
|
+
get dataSource() {
|
|
29
|
+
return this._dataSource;
|
|
30
|
+
}
|
|
22
31
|
/**
|
|
23
32
|
* Gets a serializable representation of the element
|
|
24
33
|
*/
|
|
@@ -27,6 +36,7 @@ class DimensionalElement {
|
|
|
27
36
|
name: this.name,
|
|
28
37
|
type: this.type,
|
|
29
38
|
desc: this.description,
|
|
39
|
+
dataSource: this.dataSource,
|
|
30
40
|
__serializable: 'DimensionalElement',
|
|
31
41
|
};
|
|
32
42
|
}
|
|
@@ -166,6 +166,10 @@ class AbstractFilter extends base_js_1.DimensionalElement {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
result.jaql.filter = this.filterJaql();
|
|
169
|
+
// prioritize attribute dataSource for the use case of multi-source dashboard
|
|
170
|
+
if (this.attribute.dataSource) {
|
|
171
|
+
result.jaql.datasource = this.attribute.dataSource;
|
|
172
|
+
}
|
|
169
173
|
if (this.isScope) {
|
|
170
174
|
result.panel = 'scope';
|
|
171
175
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Attribute, BaseMeasure, LevelAttribute } from '../../interfaces.js';
|
|
1
|
+
import { Attribute, BaseMeasure, CalculatedMeasure, LevelAttribute } from '../../interfaces.js';
|
|
2
2
|
import { FilterJaql } from '../../types.js';
|
|
3
|
-
import { FilterJaqlInternal, RankingFilterJaql } from './types.js';
|
|
3
|
+
import { CustomFormulaJaql, FilterJaqlInternal, JaqlDataSource, RankingFilterJaql } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Creates an attribute or level attribute from the provided parameters
|
|
6
6
|
*
|
|
@@ -10,9 +10,10 @@ import { FilterJaqlInternal, RankingFilterJaql } from './types.js';
|
|
|
10
10
|
* @param level - Date level
|
|
11
11
|
* @param dataType - Data type
|
|
12
12
|
* @param title - Attribute title
|
|
13
|
+
* @param dataSource - Jaql data source
|
|
13
14
|
* @returns attribute or level attribute
|
|
14
15
|
*/
|
|
15
|
-
export declare const createAttributeHelper: (dim: string, table: string | undefined, column: string, level: string | undefined, dataType: string, title?: string) => Attribute | LevelAttribute;
|
|
16
|
+
export declare const createAttributeHelper: (dim: string, table: string | undefined, column: string, level: string | undefined, dataType: string, title?: string, dataSource?: JaqlDataSource) => Attribute | LevelAttribute;
|
|
16
17
|
/**
|
|
17
18
|
* Creates an attribute or level attribute from the provided filter JAQL object
|
|
18
19
|
*
|
|
@@ -29,9 +30,18 @@ export declare const createAttributeFromFilterJaql: (jaql: FilterJaql | FilterJa
|
|
|
29
30
|
* @param level - Date level
|
|
30
31
|
* @param dataType - Data type
|
|
31
32
|
* @param agg - Aggregation function
|
|
33
|
+
* @param title - Measure title
|
|
34
|
+
* @param dataSource - data source provided in JAQL
|
|
32
35
|
* @returns measure
|
|
33
36
|
*/
|
|
34
|
-
export declare const createMeasureHelper: (dim: string, table: string | undefined, column: string, level: string | undefined, dataType: string, agg: string, title?: string) => BaseMeasure;
|
|
37
|
+
export declare const createMeasureHelper: (dim: string, table: string | undefined, column: string, level: string | undefined, dataType: string, agg: string, title?: string, dataSource?: JaqlDataSource) => BaseMeasure;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a calculated measure from the provided filter JAQL object
|
|
40
|
+
*
|
|
41
|
+
* @param jaql - custom formula jaql
|
|
42
|
+
* @returns calculated measure
|
|
43
|
+
*/
|
|
44
|
+
export declare const createCalculatedMeasureFromJaql: (jaql: CustomFormulaJaql) => CalculatedMeasure;
|
|
35
45
|
/**
|
|
36
46
|
* Creates a measure from the provided filter JAQL object
|
|
37
47
|
*
|
|
@@ -45,4 +55,4 @@ export declare const createMeasureFromFilterJaql: (jaql: FilterJaqlInternal) =>
|
|
|
45
55
|
* @param jaql - Ranking filter Jaql object
|
|
46
56
|
* @returns Measure
|
|
47
57
|
*/
|
|
48
|
-
export declare const createMeasureFromRankingFilterJaql: (jaql: RankingFilterJaql) => BaseMeasure;
|
|
58
|
+
export declare const createMeasureFromRankingFilterJaql: (jaql: RankingFilterJaql | CustomFormulaJaql) => BaseMeasure | CalculatedMeasure;
|
|
@@ -23,11 +23,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createMeasureFromRankingFilterJaql = exports.createMeasureFromFilterJaql = exports.createMeasureHelper = exports.createAttributeFromFilterJaql = exports.createAttributeHelper = void 0;
|
|
26
|
+
exports.createMeasureFromRankingFilterJaql = exports.createMeasureFromFilterJaql = exports.createCalculatedMeasureFromJaql = exports.createMeasureHelper = exports.createAttributeFromFilterJaql = exports.createAttributeHelper = void 0;
|
|
27
27
|
const attributes_js_1 = require("../../attributes.js");
|
|
28
28
|
const simple_column_types_js_1 = require("../../simple-column-types.js");
|
|
29
29
|
const types_js_1 = require("../../types.js");
|
|
30
30
|
const measureFactory = __importStar(require("../../measures/factory.js"));
|
|
31
|
+
const factory_js_1 = require("../../measures/factory.js");
|
|
31
32
|
const DATA_MODEL_MODULE_NAME = 'DM';
|
|
32
33
|
/**
|
|
33
34
|
* Creates an attribute or level attribute from the provided parameters
|
|
@@ -38,22 +39,23 @@ const DATA_MODEL_MODULE_NAME = 'DM';
|
|
|
38
39
|
* @param level - Date level
|
|
39
40
|
* @param dataType - Data type
|
|
40
41
|
* @param title - Attribute title
|
|
42
|
+
* @param dataSource - Jaql data source
|
|
41
43
|
* @returns attribute or level attribute
|
|
42
44
|
*/
|
|
43
|
-
const createAttributeHelper = (dim, table, column, level, dataType, title) => {
|
|
45
|
+
const createAttributeHelper = (dim, table, column, level, dataType, title, dataSource) => {
|
|
44
46
|
// if table is undefined, extract it from dim
|
|
45
47
|
const dimTable = table !== null && table !== void 0 ? table : dim.slice(1, -1).split('.')[0];
|
|
46
48
|
if (level) {
|
|
47
49
|
const dateLevel = attributes_js_1.DimensionalLevelAttribute.translateJaqlToGranularity({ level });
|
|
48
50
|
const format = attributes_js_1.DimensionalLevelAttribute.getDefaultFormatForGranularity(dateLevel);
|
|
49
|
-
const levelAttribute = new attributes_js_1.DimensionalLevelAttribute(title !== null && title !== void 0 ? title : column, dim, dateLevel, format);
|
|
51
|
+
const levelAttribute = new attributes_js_1.DimensionalLevelAttribute(title !== null && title !== void 0 ? title : column, dim, dateLevel, format, undefined, undefined, dataSource);
|
|
50
52
|
levelAttribute.composeCode = (0, attributes_js_1.normalizeAttributeName)(dimTable, column, level, DATA_MODEL_MODULE_NAME);
|
|
51
53
|
return levelAttribute;
|
|
52
54
|
}
|
|
53
55
|
const attributeType = (0, simple_column_types_js_1.isNumber)(dataType)
|
|
54
56
|
? types_js_1.MetadataTypes.NumericAttribute
|
|
55
57
|
: types_js_1.MetadataTypes.TextAttribute;
|
|
56
|
-
const attribute = new attributes_js_1.DimensionalAttribute(title !== null && title !== void 0 ? title : column, dim, attributeType);
|
|
58
|
+
const attribute = new attributes_js_1.DimensionalAttribute(title !== null && title !== void 0 ? title : column, dim, attributeType, undefined, undefined, dataSource);
|
|
57
59
|
attribute.composeCode = (0, attributes_js_1.normalizeAttributeName)(dimTable, column, undefined, DATA_MODEL_MODULE_NAME);
|
|
58
60
|
return attribute;
|
|
59
61
|
};
|
|
@@ -65,7 +67,8 @@ exports.createAttributeHelper = createAttributeHelper;
|
|
|
65
67
|
* @returns attribute or level attribute
|
|
66
68
|
*/
|
|
67
69
|
const createAttributeFromFilterJaql = (jaql) => {
|
|
68
|
-
|
|
70
|
+
const { dim, table, column, level, datatype, title, datasource: dataSource } = jaql;
|
|
71
|
+
return (0, exports.createAttributeHelper)(dim, table, column, level, datatype, title, dataSource);
|
|
69
72
|
};
|
|
70
73
|
exports.createAttributeFromFilterJaql = createAttributeFromFilterJaql;
|
|
71
74
|
/**
|
|
@@ -77,15 +80,31 @@ exports.createAttributeFromFilterJaql = createAttributeFromFilterJaql;
|
|
|
77
80
|
* @param level - Date level
|
|
78
81
|
* @param dataType - Data type
|
|
79
82
|
* @param agg - Aggregation function
|
|
83
|
+
* @param title - Measure title
|
|
84
|
+
* @param dataSource - data source provided in JAQL
|
|
80
85
|
* @returns measure
|
|
81
86
|
*/
|
|
82
|
-
const createMeasureHelper = (dim, table, column, level, dataType, agg, title) => {
|
|
83
|
-
const attribute = (0, exports.createAttributeHelper)(dim, table, column, level, dataType, title);
|
|
87
|
+
const createMeasureHelper = (dim, table, column, level, dataType, agg, title, dataSource) => {
|
|
88
|
+
const attribute = (0, exports.createAttributeHelper)(dim, table, column, level, dataType, title, dataSource);
|
|
84
89
|
const measure = measureFactory.aggregate(attribute, agg);
|
|
85
90
|
measure.composeCode = `measureFactory.${agg}(${attribute.composeCode})`;
|
|
86
91
|
return measure;
|
|
87
92
|
};
|
|
88
93
|
exports.createMeasureHelper = createMeasureHelper;
|
|
94
|
+
/**
|
|
95
|
+
* Creates a calculated measure from the provided filter JAQL object
|
|
96
|
+
*
|
|
97
|
+
* @param jaql - custom formula jaql
|
|
98
|
+
* @returns calculated measure
|
|
99
|
+
*/
|
|
100
|
+
const createCalculatedMeasureFromJaql = (jaql) => {
|
|
101
|
+
const measure = (0, factory_js_1.transformCustomFormulaJaql)(jaql);
|
|
102
|
+
// TBD (SNS-108945)
|
|
103
|
+
// Handle preparation of 'composeCode' for formula
|
|
104
|
+
measure.composeCode = `'Formula code to be implemented'`;
|
|
105
|
+
return measure;
|
|
106
|
+
};
|
|
107
|
+
exports.createCalculatedMeasureFromJaql = createCalculatedMeasureFromJaql;
|
|
89
108
|
/**
|
|
90
109
|
* Creates a measure from the provided filter JAQL object
|
|
91
110
|
*
|
|
@@ -93,10 +112,10 @@ exports.createMeasureHelper = createMeasureHelper;
|
|
|
93
112
|
* @returns Measure
|
|
94
113
|
*/
|
|
95
114
|
const createMeasureFromFilterJaql = (jaql) => {
|
|
96
|
-
const { dim, table, column, title, level, datatype: dataType, agg } = jaql;
|
|
115
|
+
const { dim, table, column, title, level, datatype: dataType, agg, datasource: dataSource, } = jaql;
|
|
97
116
|
if (!agg)
|
|
98
117
|
return undefined;
|
|
99
|
-
return (0, exports.createMeasureHelper)(dim, table, column, level, dataType, agg, title);
|
|
118
|
+
return (0, exports.createMeasureHelper)(dim, table, column, level, dataType, agg, title, dataSource);
|
|
100
119
|
};
|
|
101
120
|
exports.createMeasureFromFilterJaql = createMeasureFromFilterJaql;
|
|
102
121
|
/**
|
|
@@ -106,6 +125,8 @@ exports.createMeasureFromFilterJaql = createMeasureFromFilterJaql;
|
|
|
106
125
|
* @returns Measure
|
|
107
126
|
*/
|
|
108
127
|
const createMeasureFromRankingFilterJaql = (jaql) => {
|
|
128
|
+
if ('formula' in jaql)
|
|
129
|
+
return (0, exports.createCalculatedMeasureFromJaql)(jaql);
|
|
109
130
|
const { dim, table, column, level, datatype: dataType, agg } = jaql;
|
|
110
131
|
return (0, exports.createMeasureHelper)(dim, table, column, level, dataType, agg);
|
|
111
132
|
};
|
|
@@ -112,12 +112,14 @@ const createAttributeFilterFromConditionFilterJaql = (attribute, conditionFilter
|
|
|
112
112
|
const conditionType = (0, exports.getSelectedConditionOption)(conditionFilterJaql);
|
|
113
113
|
switch (conditionType) {
|
|
114
114
|
case types_js_1.ConditionFilterType.BOTTOM:
|
|
115
|
-
if (conditionFilterJaql.by
|
|
115
|
+
if (conditionFilterJaql.by) {
|
|
116
116
|
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.bottomRanking)(attribute, (0, attribute_measure_util_js_1.createMeasureFromRankingFilterJaql)(conditionFilterJaql.by), conditionFilterJaql[types_js_1.ConditionFilterType.BOTTOM], guid);
|
|
117
117
|
}
|
|
118
118
|
break;
|
|
119
119
|
case types_js_1.ConditionFilterType.EQUALS:
|
|
120
120
|
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.equals)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.EQUALS], guid);
|
|
121
|
+
case types_js_1.ConditionFilterType.DOESNT_EQUAL:
|
|
122
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.doesntEqual)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.DOESNT_EQUAL], guid);
|
|
121
123
|
case types_js_1.ConditionFilterType.GREATER_THAN:
|
|
122
124
|
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.greaterThan)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.GREATER_THAN], guid);
|
|
123
125
|
case types_js_1.ConditionFilterType.GREATER_THAN_OR_EQUAL:
|
|
@@ -211,7 +211,7 @@ const createFilterFromJaqlInternal = (jaql, guid) => {
|
|
|
211
211
|
}
|
|
212
212
|
catch (e) {
|
|
213
213
|
// if a filter type is untranslatable, fall back to the generic pass-through JAQL filter
|
|
214
|
-
|
|
214
|
+
console.debug('Fall back to generic pass-through JAQL filter due to filter translation error:', e);
|
|
215
215
|
}
|
|
216
216
|
return (0, exports.createGenericFilter)(jaql, guid);
|
|
217
217
|
};
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
import { FormulaContext, FormulaJaql } from '../../types.js';
|
|
1
2
|
declare type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
|
2
3
|
[K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
|
|
3
4
|
}[Keys];
|
|
4
5
|
export declare type JaqlContext = Record<string, Partial<FilterJaqlInternal>>;
|
|
5
6
|
export declare type Id = string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Data source as specified in the jaql
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare type JaqlDataSource = {
|
|
13
|
+
address?: Id;
|
|
14
|
+
database?: string;
|
|
15
|
+
id?: string;
|
|
10
16
|
title: string;
|
|
11
17
|
live?: boolean;
|
|
12
|
-
fullname
|
|
18
|
+
fullname?: string;
|
|
13
19
|
lastBuildTime?: string;
|
|
14
20
|
revisionId?: string;
|
|
15
21
|
};
|
|
@@ -56,6 +62,9 @@ export interface RangeFilterJaql extends BaseFilterJaql {
|
|
|
56
62
|
to?: string | number;
|
|
57
63
|
multiSelection?: boolean;
|
|
58
64
|
}
|
|
65
|
+
export declare type CustomFormulaJaql = (FormulaJaql & {
|
|
66
|
+
context?: FormulaJaql | FormulaContext;
|
|
67
|
+
}) | FormulaContext;
|
|
59
68
|
export declare type RankingFilterJaql = {
|
|
60
69
|
agg: string;
|
|
61
70
|
column: string;
|
|
@@ -120,7 +129,7 @@ export declare enum DatetimeLevel {
|
|
|
120
129
|
export declare type FilterJaqlInternal = {
|
|
121
130
|
title: string;
|
|
122
131
|
column: string;
|
|
123
|
-
datasource?:
|
|
132
|
+
datasource?: JaqlDataSource;
|
|
124
133
|
datatype: string;
|
|
125
134
|
dim: string;
|
|
126
135
|
dimension?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataSource } from '../interfaces.js';
|
|
2
|
-
import { Sort } from './types.js';
|
|
2
|
+
import { JaqlDataSource, Sort } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
@@ -35,6 +35,12 @@ export interface Element {
|
|
|
35
35
|
* @internal
|
|
36
36
|
*/
|
|
37
37
|
readonly id: string;
|
|
38
|
+
/**
|
|
39
|
+
* Data Source
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
readonly dataSource?: JaqlDataSource;
|
|
38
44
|
/**
|
|
39
45
|
* Gets a serializable representation of the element.
|
|
40
46
|
*
|
|
@@ -440,6 +446,7 @@ export declare type FilterRelationsJaqlNode = FilterRelationsJaqlIdNode | Filter
|
|
|
440
446
|
/**
|
|
441
447
|
* Representation of filter logical relations (AND/OR)
|
|
442
448
|
*
|
|
449
|
+
* @privateRemarks
|
|
443
450
|
* Unlike {@link FilterRelationsModel} or {@link FilterRelationsJaql},
|
|
444
451
|
* this interface contains filter objects, not just id nodes
|
|
445
452
|
*/
|
|
@@ -468,11 +475,18 @@ export interface FilterRelationsJaql {
|
|
|
468
475
|
right: FilterRelationsJaqlNode;
|
|
469
476
|
operator: 'AND' | 'OR';
|
|
470
477
|
}
|
|
471
|
-
/**
|
|
478
|
+
/**
|
|
479
|
+
* A node of a {@link FilterRelationsJaql} tree that represents a filter
|
|
480
|
+
*
|
|
481
|
+
* @internal
|
|
482
|
+
*/
|
|
472
483
|
export declare type FilterRelationsJaqlIdNode = {
|
|
473
484
|
instanceid: string;
|
|
474
485
|
};
|
|
475
|
-
/**
|
|
486
|
+
/**
|
|
487
|
+
* A node of a {@link FilterRelationsModel} tree that represents a filter
|
|
488
|
+
* @internal
|
|
489
|
+
*/
|
|
476
490
|
export declare type FilterRelationsModelIdNode = {
|
|
477
491
|
instanceId: string;
|
|
478
492
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Attribute, Measure, Filter, CalculatedMeasure, BaseMeasure, CustomFormulaContext } from '../interfaces.js';
|
|
2
2
|
import { ForecastFormulaOptions, TrendFormulaOptions } from '../../interfaces.js';
|
|
3
|
+
import { CustomFormulaJaql } from '../filters/utils/types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Defines the different numeric operators that can be used with numeric filters
|
|
5
6
|
*
|
|
@@ -32,6 +33,16 @@ export declare const RankingSortTypes: {
|
|
|
32
33
|
Ascending: string;
|
|
33
34
|
Descending: string;
|
|
34
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Transforms a custom formula jaql into a calculated measure instance.
|
|
38
|
+
*
|
|
39
|
+
* As custom formulas can be nested, the function performs a recursive transformation via a helper function.
|
|
40
|
+
*
|
|
41
|
+
* @param jaql - Custom formula jaql
|
|
42
|
+
* @returns Calculated measure instance
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export declare function transformCustomFormulaJaql(jaql: CustomFormulaJaql): CalculatedMeasure;
|
|
35
46
|
/**
|
|
36
47
|
* Creates a calculated measure for a valid custom formula built from [base functions](/guides/sdk/reference/functions.html#measured-value-functions).
|
|
37
48
|
*
|
|
@@ -78,7 +89,6 @@ export declare const RankingSortTypes: {
|
|
|
78
89
|
* },
|
|
79
90
|
* );
|
|
80
91
|
* ```
|
|
81
|
-
*
|
|
82
92
|
* @param title - Title of the measure to be displayed in legend
|
|
83
93
|
* @param formula - Formula to be used for the measure
|
|
84
94
|
* @param context - Formula context as a map of strings to attributes, measures, or filters
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.rank = exports.forecast = exports.trend = exports.contribution = exports.pastYear = exports.pastQuarter = exports.pastMonth = exports.pastWeek = exports.pastDay = exports.diffPastYear = exports.diffPastQuarter = exports.diffPastMonth = exports.diffPastWeek = exports.difference = exports.growthPastYear = exports.growthPastQuarter = exports.growthPastMonth = exports.growthPastWeek = exports.growthRate = exports.growth = exports.runningSum = exports.weekToDateSum = exports.monthToDateSum = exports.quarterToDateSum = exports.yearToDateSum = exports.divide = exports.multiply = exports.subtract = exports.add = exports.measuredValue = exports.countDistinct = exports.count = exports.median = exports.max = exports.min = exports.avg = exports.average = exports.sum = exports.constant = exports.aggregate = exports.customFormula = exports.RankingSortTypes = exports.RankingTypes = void 0;
|
|
6
|
+
exports.rank = exports.forecast = exports.trend = exports.contribution = exports.pastYear = exports.pastQuarter = exports.pastMonth = exports.pastWeek = exports.pastDay = exports.diffPastYear = exports.diffPastQuarter = exports.diffPastMonth = exports.diffPastWeek = exports.difference = exports.growthPastYear = exports.growthPastQuarter = exports.growthPastMonth = exports.growthPastWeek = exports.growthRate = exports.growth = exports.runningSum = exports.weekToDateSum = exports.monthToDateSum = exports.quarterToDateSum = exports.yearToDateSum = exports.divide = exports.multiply = exports.subtract = exports.add = exports.measuredValue = exports.countDistinct = exports.count = exports.median = exports.max = exports.min = exports.avg = exports.average = exports.sum = exports.constant = exports.aggregate = exports.customFormula = exports.transformCustomFormulaJaql = exports.RankingSortTypes = exports.RankingTypes = void 0;
|
|
7
7
|
const measures_js_1 = require("./measures.js");
|
|
8
8
|
const types_js_1 = require("../types.js");
|
|
9
9
|
const base_js_1 = require("../base.js");
|
|
@@ -109,6 +109,7 @@ function transformFormulaJaqlHelper(jaql) {
|
|
|
109
109
|
*
|
|
110
110
|
* @param jaql - Custom formula jaql
|
|
111
111
|
* @returns Calculated measure instance
|
|
112
|
+
* @internal
|
|
112
113
|
*/
|
|
113
114
|
function transformCustomFormulaJaql(jaql) {
|
|
114
115
|
var _a;
|
|
@@ -120,6 +121,7 @@ function transformCustomFormulaJaql(jaql) {
|
|
|
120
121
|
const context = (0, mapValues_js_1.default)((_a = jaql.context) !== null && _a !== void 0 ? _a : {}, (jaqlContextValue) => jaqlContextValue ? transformFormulaJaqlHelper(jaqlContextValue) : {});
|
|
121
122
|
return new measures_js_1.DimensionalCalculatedMeasure(jaql.title, jaql.formula, context, undefined, undefined, sort);
|
|
122
123
|
}
|
|
124
|
+
exports.transformCustomFormulaJaql = transformCustomFormulaJaql;
|
|
123
125
|
/**
|
|
124
126
|
* Creates a calculated measure for a valid custom formula built from [base functions](/guides/sdk/reference/functions.html#measured-value-functions).
|
|
125
127
|
*
|
|
@@ -166,7 +168,6 @@ function transformCustomFormulaJaql(jaql) {
|
|
|
166
168
|
* },
|
|
167
169
|
* );
|
|
168
170
|
* ```
|
|
169
|
-
*
|
|
170
171
|
* @param title - Title of the measure to be displayed in legend
|
|
171
172
|
* @param formula - Formula to be used for the measure
|
|
172
173
|
* @param context - Formula context as a map of strings to attributes, measures, or filters
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { type ConditionFilterJaql } from './filters/utils/types.js';
|
|
1
|
+
import { JaqlDataSource, type ConditionFilterJaql } from './filters/utils/types.js';
|
|
2
|
+
import { Attribute } from './interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export type { JaqlDataSource };
|
|
2
7
|
/**
|
|
3
8
|
* Different aggregation types
|
|
4
9
|
*/
|
|
@@ -123,7 +128,7 @@ export declare const MetadataTypes: {
|
|
|
123
128
|
* @param o - object to check
|
|
124
129
|
* @returns true if the object or type is an attribute - of any type
|
|
125
130
|
*/
|
|
126
|
-
isAttribute(o: any):
|
|
131
|
+
isAttribute(o: any): o is Attribute;
|
|
127
132
|
/**
|
|
128
133
|
* Checks whether the given object or type is a filter
|
|
129
134
|
*
|
|
@@ -182,6 +187,7 @@ export declare type BaseJaql = {
|
|
|
182
187
|
dim: string;
|
|
183
188
|
table: string;
|
|
184
189
|
column: string;
|
|
190
|
+
datasource?: JaqlDataSource;
|
|
185
191
|
title: string;
|
|
186
192
|
level?: 'years' | 'quarters' | 'months' | 'weeks' | 'minutes' | 'days';
|
|
187
193
|
sort?: `${JaqlSortDirection}`;
|
|
@@ -260,4 +266,3 @@ export declare type OrFilter<FilterItem> = {
|
|
|
260
266
|
* Abstract object with any unknown values
|
|
261
267
|
*/
|
|
262
268
|
export declare type AnyObject = Record<string, any>;
|
|
263
|
-
export {};
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Filter, FilterRelations, FilterRelationsJaql, DataSource, DataSourceInfo, FilterJaql, Sort } from './index.js';
|
|
1
|
+
import { Filter, FilterRelations, FilterRelationsJaql, DataSource, DataSourceInfo, FilterJaql, Sort, Attribute } from './index.js';
|
|
2
|
+
import { JaqlDataSource } from './dimensional-model/filters/utils/types.js';
|
|
2
3
|
/**
|
|
3
4
|
* A more performant, but slightly bulkier, RFC4122v4 implementation. Performance is improved by minimizing calls to random()
|
|
4
5
|
*
|
|
@@ -26,11 +27,23 @@ export declare function getDataSourceName(dataSource: DataSource): string;
|
|
|
26
27
|
* @internal
|
|
27
28
|
*/
|
|
28
29
|
export declare function isDataSourceInfo(dataSource: DataSource): dataSource is DataSourceInfo;
|
|
30
|
+
/**
|
|
31
|
+
* Converts a JaqlDataSource to DataSource.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export declare function convertDataSource(jaqlDataSource: JaqlDataSource): DataSource;
|
|
36
|
+
/**
|
|
37
|
+
* Converts a DataSource to a description of data source used in JAQL.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare function convertJaqlDataSource(dataSource: DataSource): JaqlDataSource;
|
|
29
42
|
/**
|
|
30
43
|
* Converts a string to a Sort enum
|
|
44
|
+
*
|
|
31
45
|
* @param sort - The string to convert
|
|
32
46
|
* @returns The converted Sort enum
|
|
33
|
-
*
|
|
34
47
|
* @internal
|
|
35
48
|
*/
|
|
36
49
|
export declare function convertSort(sort?: string): Sort;
|
|
@@ -43,3 +56,15 @@ export declare function convertSort(sort?: string): Sort;
|
|
|
43
56
|
* @internal
|
|
44
57
|
*/
|
|
45
58
|
export declare const createFilterFromJaql: (jaql: FilterJaql, instanceid?: string) => Filter;
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves the table value from the attribute.
|
|
61
|
+
*
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export declare function getTableNameFromAttribute(attribute: Attribute): string;
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves the column value from the attribute.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export declare function getColumnNameFromAttribute(attribute: Attribute): string;
|
package/dist/cjs/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createFilterFromJaql = exports.convertSort = exports.isDataSourceInfo = exports.getDataSourceName = exports.getFilterListAndRelations = exports.guidFast = void 0;
|
|
6
|
+
exports.getColumnNameFromAttribute = exports.getTableNameFromAttribute = exports.createFilterFromJaql = exports.convertSort = exports.convertJaqlDataSource = exports.convertDataSource = exports.isDataSourceInfo = exports.getDataSourceName = exports.getFilterListAndRelations = exports.guidFast = void 0;
|
|
7
7
|
const cloneDeep_js_1 = __importDefault(require("lodash-es/cloneDeep.js"));
|
|
8
8
|
const index_js_1 = require("./index.js");
|
|
9
9
|
const filter_from_jaql_util_js_1 = require("./dimensional-model/filters/utils/filter-from-jaql-util.js");
|
|
@@ -89,11 +89,40 @@ function isDataSourceInfo(dataSource) {
|
|
|
89
89
|
return typeof dataSource === 'object' && 'type' in dataSource && 'title' in dataSource;
|
|
90
90
|
}
|
|
91
91
|
exports.isDataSourceInfo = isDataSourceInfo;
|
|
92
|
+
/**
|
|
93
|
+
* Converts a JaqlDataSource to DataSource.
|
|
94
|
+
*
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
function convertDataSource(jaqlDataSource) {
|
|
98
|
+
return {
|
|
99
|
+
title: jaqlDataSource.title,
|
|
100
|
+
type: jaqlDataSource.live ? 'live' : 'elasticube',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
exports.convertDataSource = convertDataSource;
|
|
104
|
+
/**
|
|
105
|
+
* Converts a DataSource to a description of data source used in JAQL.
|
|
106
|
+
*
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
function convertJaqlDataSource(dataSource) {
|
|
110
|
+
return isDataSourceInfo(dataSource)
|
|
111
|
+
? {
|
|
112
|
+
title: dataSource.title,
|
|
113
|
+
live: dataSource.type === 'live',
|
|
114
|
+
}
|
|
115
|
+
: {
|
|
116
|
+
title: dataSource,
|
|
117
|
+
live: false,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
exports.convertJaqlDataSource = convertJaqlDataSource;
|
|
92
121
|
/**
|
|
93
122
|
* Converts a string to a Sort enum
|
|
123
|
+
*
|
|
94
124
|
* @param sort - The string to convert
|
|
95
125
|
* @returns The converted Sort enum
|
|
96
|
-
*
|
|
97
126
|
* @internal
|
|
98
127
|
*/
|
|
99
128
|
function convertSort(sort) {
|
|
@@ -124,3 +153,33 @@ const createFilterFromJaql = (jaql, instanceid) => {
|
|
|
124
153
|
return filter;
|
|
125
154
|
};
|
|
126
155
|
exports.createFilterFromJaql = createFilterFromJaql;
|
|
156
|
+
/**
|
|
157
|
+
* Extracts the table and column names from the given expression string.
|
|
158
|
+
*
|
|
159
|
+
* @internal
|
|
160
|
+
*/
|
|
161
|
+
function parseExpression(expression) {
|
|
162
|
+
const [table, column] = expression.slice(1, -1).split('.');
|
|
163
|
+
return {
|
|
164
|
+
table,
|
|
165
|
+
column,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Retrieves the table value from the attribute.
|
|
170
|
+
*
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
function getTableNameFromAttribute(attribute) {
|
|
174
|
+
return parseExpression(attribute.expression).table;
|
|
175
|
+
}
|
|
176
|
+
exports.getTableNameFromAttribute = getTableNameFromAttribute;
|
|
177
|
+
/**
|
|
178
|
+
* Retrieves the column value from the attribute.
|
|
179
|
+
*
|
|
180
|
+
* @internal
|
|
181
|
+
*/
|
|
182
|
+
function getColumnNameFromAttribute(attribute) {
|
|
183
|
+
return parseExpression(attribute.expression).column;
|
|
184
|
+
}
|
|
185
|
+
exports.getColumnNameFromAttribute = getColumnNameFromAttribute;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Attribute, LevelAttribute } from './interfaces.js';
|
|
2
|
-
import { Sort } from './types.js';
|
|
2
|
+
import { Sort, JaqlDataSource } from './types.js';
|
|
3
3
|
import { DimensionalElement } from './base.js';
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
@@ -11,7 +11,7 @@ export declare const jaqlSimpleColumnType: (datatype: string) => string;
|
|
|
11
11
|
export declare class DimensionalAttribute extends DimensionalElement implements Attribute {
|
|
12
12
|
readonly expression: string;
|
|
13
13
|
protected _sort: Sort;
|
|
14
|
-
constructor(name: string, expression: string, type?: string, desc?: string, sort?: Sort);
|
|
14
|
+
constructor(name: string, expression: string, type?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource);
|
|
15
15
|
/**
|
|
16
16
|
* gets the element's ID
|
|
17
17
|
*/
|
|
@@ -46,7 +46,7 @@ export declare class DimensionalAttribute extends DimensionalElement implements
|
|
|
46
46
|
export declare class DimensionalLevelAttribute extends DimensionalAttribute implements LevelAttribute {
|
|
47
47
|
private _format;
|
|
48
48
|
readonly granularity: string;
|
|
49
|
-
constructor(l: string, expression: string, granularity: string, format?: string, desc?: string, sort?: Sort);
|
|
49
|
+
constructor(l: string, expression: string, granularity: string, format?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource);
|
|
50
50
|
/**
|
|
51
51
|
* gets the element's ID
|
|
52
52
|
*/
|