@sisense/sdk-data 2.22.0 → 2.24.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 +10 -2
- package/dist/cjs/dimensional-model/attributes.js +11 -9
- package/dist/cjs/dimensional-model/dimensions/dimensions.d.ts +1 -1
- package/dist/cjs/dimensional-model/dimensions/dimensions.js +20 -17
- package/dist/cjs/dimensional-model/dimensions/utils.js +4 -0
- package/dist/cjs/dimensional-model/filters/factory.d.ts +8 -8
- package/dist/cjs/dimensional-model/filters/factory.js +30 -7
- package/dist/cjs/dimensional-model/filters/filter-relations.d.ts +16 -1
- package/dist/cjs/dimensional-model/filters/filter-relations.js +50 -13
- package/dist/cjs/dimensional-model/filters/filters.js +2 -2
- package/dist/cjs/dimensional-model/interfaces.d.ts +12 -0
- package/dist/cjs/dimensional-model/measures/factory.d.ts +2 -2
- package/dist/cjs/dimensional-model/measures/factory.js +5 -2
- package/dist/cjs/dimensional-model/measures/measures.d.ts +2 -2
- package/dist/cjs/dimensional-model/measures/measures.js +4 -1
- package/dist/cjs/dimensional-model/types.d.ts +15 -9
- package/dist/cjs/dimensional-model/types.js +1 -0
- package/dist/cjs/utils.d.ts +16 -3
- package/dist/cjs/utils.js +20 -8
- package/dist/dimensional-model/attributes.d.ts +10 -2
- package/dist/dimensional-model/attributes.js +11 -9
- package/dist/dimensional-model/dimensions/dimensions.d.ts +1 -1
- package/dist/dimensional-model/dimensions/dimensions.js +20 -17
- package/dist/dimensional-model/dimensions/utils.js +4 -0
- package/dist/dimensional-model/filters/factory.d.ts +8 -8
- package/dist/dimensional-model/filters/factory.js +30 -7
- package/dist/dimensional-model/filters/filter-relations.d.ts +16 -1
- package/dist/dimensional-model/filters/filter-relations.js +50 -13
- package/dist/dimensional-model/filters/filters.js +3 -3
- package/dist/dimensional-model/interfaces.d.ts +12 -0
- package/dist/dimensional-model/measures/factory.d.ts +2 -2
- package/dist/dimensional-model/measures/factory.js +5 -2
- package/dist/dimensional-model/measures/measures.d.ts +2 -2
- package/dist/dimensional-model/measures/measures.js +4 -1
- package/dist/dimensional-model/types.d.ts +15 -9
- package/dist/dimensional-model/types.js +1 -0
- package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -1
- package/dist/utils.d.ts +16 -3
- package/dist/utils.js +17 -6
- package/package.json +2 -2
|
@@ -16,7 +16,15 @@ export declare class DimensionalAttribute extends DimensionalElement implements
|
|
|
16
16
|
readonly expression: string;
|
|
17
17
|
readonly panel: string;
|
|
18
18
|
protected _sort: Sort;
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
readonly merged?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
readonly indexed?: boolean;
|
|
27
|
+
constructor(name: string, expression: string, type?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string, panel?: string, indexed?: boolean, merged?: boolean);
|
|
20
28
|
/**
|
|
21
29
|
* gets the element's ID
|
|
22
30
|
*/
|
|
@@ -60,7 +68,7 @@ export declare class DimensionalLevelAttribute extends DimensionalAttribute impl
|
|
|
60
68
|
private _format;
|
|
61
69
|
readonly granularity: string;
|
|
62
70
|
readonly panel: string;
|
|
63
|
-
constructor(name: string, expression: string, granularity: string, format?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string, panel?: string);
|
|
71
|
+
constructor(name: string, expression: string, granularity: string, format?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string, panel?: string, indexed?: boolean, merged?: boolean);
|
|
64
72
|
/**
|
|
65
73
|
* gets the element's ID
|
|
66
74
|
*/
|
|
@@ -21,7 +21,7 @@ exports.jaqlSimpleColumnType = jaqlSimpleColumnType;
|
|
|
21
21
|
* @internal
|
|
22
22
|
*/
|
|
23
23
|
class DimensionalAttribute extends base_js_1.DimensionalElement {
|
|
24
|
-
constructor(name, expression, type, desc, sort, dataSource, composeCode, panel) {
|
|
24
|
+
constructor(name, expression, type, desc, sort, dataSource, composeCode, panel, indexed, merged) {
|
|
25
25
|
super(name, type || types_js_1.MetadataTypes.Attribute, desc, dataSource, composeCode);
|
|
26
26
|
/**
|
|
27
27
|
* @internal
|
|
@@ -40,6 +40,8 @@ class DimensionalAttribute extends base_js_1.DimensionalElement {
|
|
|
40
40
|
this.panel = panel;
|
|
41
41
|
}
|
|
42
42
|
this._sort = sort || types_js_1.Sort.None;
|
|
43
|
+
this.merged = merged;
|
|
44
|
+
this.indexed = indexed;
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
47
|
* gets the element's ID
|
|
@@ -62,7 +64,7 @@ class DimensionalAttribute extends base_js_1.DimensionalElement {
|
|
|
62
64
|
* @returns An instance representing the sorted {@link Attribute} of this instance
|
|
63
65
|
*/
|
|
64
66
|
sort(sort) {
|
|
65
|
-
return new DimensionalAttribute(this.name, this.expression, this.type, this.description, sort, this.dataSource, this.composeCode, this.panel);
|
|
67
|
+
return new DimensionalAttribute(this.name, this.expression, this.type, this.description, sort, this.dataSource, this.composeCode, this.panel, this.indexed, this.merged);
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
70
|
* Gets the JAQL representation of this instance
|
|
@@ -109,8 +111,8 @@ exports.isDimensionalAttribute = isDimensionalAttribute;
|
|
|
109
111
|
* @internal
|
|
110
112
|
*/
|
|
111
113
|
class DimensionalLevelAttribute extends DimensionalAttribute {
|
|
112
|
-
constructor(name, expression, granularity, format, desc, sort, dataSource, composeCode, panel) {
|
|
113
|
-
super(name, expression, types_js_1.MetadataTypes.DateLevel, desc, sort, dataSource, composeCode);
|
|
114
|
+
constructor(name, expression, granularity, format, desc, sort, dataSource, composeCode, panel, indexed, merged) {
|
|
115
|
+
super(name, expression, types_js_1.MetadataTypes.DateLevel, desc, sort, dataSource, composeCode, undefined, indexed, merged);
|
|
114
116
|
/**
|
|
115
117
|
* @internal
|
|
116
118
|
*/
|
|
@@ -156,7 +158,7 @@ class DimensionalLevelAttribute extends DimensionalAttribute {
|
|
|
156
158
|
* @returns An instance representing the sorted {@link LevelAttribute} of this instance
|
|
157
159
|
*/
|
|
158
160
|
sort(sort) {
|
|
159
|
-
return new DimensionalLevelAttribute(this.name, this.expression, this.granularity, this._format, this.description, sort, this.dataSource, this.composeCode);
|
|
161
|
+
return new DimensionalLevelAttribute(this.name, this.expression, this.granularity, this._format, this.description, sort, this.dataSource, this.composeCode, undefined, this.indexed, this.merged);
|
|
160
162
|
}
|
|
161
163
|
/**
|
|
162
164
|
* The string formatting of this instance
|
|
@@ -173,7 +175,7 @@ class DimensionalLevelAttribute extends DimensionalAttribute {
|
|
|
173
175
|
* @returns An instance representing the formatted {@link LevelAttribute} of this instance
|
|
174
176
|
*/
|
|
175
177
|
format(format) {
|
|
176
|
-
return new DimensionalLevelAttribute(this.name, this.expression, this.granularity, format, this.description, this._sort, this.dataSource, this.composeCode);
|
|
178
|
+
return new DimensionalLevelAttribute(this.name, this.expression, this.granularity, format, this.description, this._sort, this.dataSource, this.composeCode, undefined, this.indexed, this.merged);
|
|
177
179
|
}
|
|
178
180
|
/**
|
|
179
181
|
* Gets a {@link LevelAttribute} with the given granularity
|
|
@@ -182,7 +184,7 @@ class DimensionalLevelAttribute extends DimensionalAttribute {
|
|
|
182
184
|
* @returns New instance representing {@link LevelAttribute} with provided granularity
|
|
183
185
|
*/
|
|
184
186
|
setGranularity(granularity) {
|
|
185
|
-
return new DimensionalLevelAttribute(this.name, this.expression, granularity, this._format, this.description, this._sort, this.dataSource, this.composeCode);
|
|
187
|
+
return new DimensionalLevelAttribute(this.name, this.expression, granularity, this._format, this.description, this._sort, this.dataSource, this.composeCode, undefined, this.indexed, this.merged);
|
|
186
188
|
}
|
|
187
189
|
/**
|
|
188
190
|
* Gets a serializable representation of the element
|
|
@@ -392,7 +394,7 @@ function createAttribute(json) {
|
|
|
392
394
|
if (json.granularity) {
|
|
393
395
|
return createLevel(json);
|
|
394
396
|
}
|
|
395
|
-
return new DimensionalAttribute(json.name || json.title, json.attribute || json.expression || json.dim, json.type, json.desc || json.description, json.sort, json.dataSource);
|
|
397
|
+
return new DimensionalAttribute(json.name || json.title, json.attribute || json.expression || json.dim, json.type, json.desc || json.description, json.sort, json.dataSource, undefined, undefined, json.indexed, json.merged);
|
|
396
398
|
}
|
|
397
399
|
exports.createAttribute = createAttribute;
|
|
398
400
|
/**
|
|
@@ -402,7 +404,7 @@ exports.createAttribute = createAttribute;
|
|
|
402
404
|
* @internal
|
|
403
405
|
*/
|
|
404
406
|
function createLevel(json) {
|
|
405
|
-
return new DimensionalLevelAttribute(json.name || json.title, json.attribute || json.expression || json.dim, json.granularity, json.format, json.desc || json.description, json.sort, json.dataSource);
|
|
407
|
+
return new DimensionalLevelAttribute(json.name || json.title, json.attribute || json.expression || json.dim, json.granularity, json.format, json.desc || json.description, json.sort, json.dataSource, undefined, undefined, json.indexed, json.merged);
|
|
406
408
|
}
|
|
407
409
|
exports.createLevel = createLevel;
|
|
408
410
|
/**
|
|
@@ -73,7 +73,7 @@ export declare class DimensionalDateDimension extends DimensionalDimension imple
|
|
|
73
73
|
* @internal
|
|
74
74
|
*/
|
|
75
75
|
readonly __serializable: string;
|
|
76
|
-
constructor(name: string, expression: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string);
|
|
76
|
+
constructor(name: string, expression: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string, indexed?: boolean, merged?: boolean);
|
|
77
77
|
/**
|
|
78
78
|
* Years level
|
|
79
79
|
*/
|
|
@@ -177,27 +177,28 @@ exports.isDimensionalDimension = isDimensionalDimension;
|
|
|
177
177
|
* @internal
|
|
178
178
|
*/
|
|
179
179
|
class DimensionalDateDimension extends DimensionalDimension {
|
|
180
|
-
constructor(name, expression, desc, sort, dataSource, composeCode) {
|
|
180
|
+
constructor(name, expression, desc, sort, dataSource, composeCode, indexed, merged) {
|
|
181
181
|
super(name, expression, [], [], types_js_1.MetadataTypes.DateDimension, desc, sort, dataSource, composeCode);
|
|
182
182
|
/**
|
|
183
183
|
* @internal
|
|
184
184
|
*/
|
|
185
185
|
this.__serializable = 'DimensionalDateDimension';
|
|
186
|
+
const commonProps = [desc, sort, dataSource, undefined, undefined, indexed, merged];
|
|
186
187
|
this.defaultLevel = types_js_1.DateLevels.Years;
|
|
187
|
-
this.Years = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Years, expression, types_js_1.DateLevels.Years, 'yyyy',
|
|
188
|
-
this.Quarters = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Quarters, expression, types_js_1.DateLevels.Quarters, 'Q yyyy',
|
|
189
|
-
this.Months = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Months, expression, types_js_1.DateLevels.Months, 'yyyy-MM',
|
|
190
|
-
this.Weeks = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Weeks, expression, types_js_1.DateLevels.Weeks, 'ww yyyy',
|
|
191
|
-
this.Days = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Days, expression, types_js_1.DateLevels.Days, 'yyyy-MM-dd',
|
|
192
|
-
this.Hours = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Hours, expression, types_js_1.DateLevels.Hours, 'yyyy-MM-dd HH:mm',
|
|
188
|
+
this.Years = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Years, expression, types_js_1.DateLevels.Years, 'yyyy', ...commonProps);
|
|
189
|
+
this.Quarters = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Quarters, expression, types_js_1.DateLevels.Quarters, 'Q yyyy', ...commonProps);
|
|
190
|
+
this.Months = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Months, expression, types_js_1.DateLevels.Months, 'yyyy-MM', ...commonProps);
|
|
191
|
+
this.Weeks = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Weeks, expression, types_js_1.DateLevels.Weeks, 'ww yyyy', ...commonProps);
|
|
192
|
+
this.Days = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Days, expression, types_js_1.DateLevels.Days, 'yyyy-MM-dd', ...commonProps);
|
|
193
|
+
this.Hours = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Hours, expression, types_js_1.DateLevels.Hours, 'yyyy-MM-dd HH:mm', ...commonProps);
|
|
193
194
|
this.MinutesRoundTo30 = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.MinutesRoundTo30, expression, types_js_1.DateLevels.MinutesRoundTo30, 'yyyy-MM-dd HH:mm', desc, sort, dataSource);
|
|
194
|
-
this.MinutesRoundTo15 = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.MinutesRoundTo15, expression, types_js_1.DateLevels.MinutesRoundTo15, 'yyyy-MM-dd HH:mm',
|
|
195
|
-
this.Minutes = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Minutes, expression, types_js_1.DateLevels.Minutes, 'yyyy-MM-dd HH:mm',
|
|
195
|
+
this.MinutesRoundTo15 = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.MinutesRoundTo15, expression, types_js_1.DateLevels.MinutesRoundTo15, 'yyyy-MM-dd HH:mm', ...commonProps);
|
|
196
|
+
this.Minutes = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Minutes, expression, types_js_1.DateLevels.Minutes, 'yyyy-MM-dd HH:mm', ...commonProps);
|
|
196
197
|
this.Seconds = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.Seconds, expression, types_js_1.DateLevels.Seconds, 'yyyy-MM-dd HH:mm:ss', desc, sort, dataSource);
|
|
197
|
-
this.AggHours = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.AggHours, expression, types_js_1.DateLevels.AggHours, 'HH:mm',
|
|
198
|
+
this.AggHours = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.AggHours, expression, types_js_1.DateLevels.AggHours, 'HH:mm', ...commonProps);
|
|
198
199
|
this.AggMinutesRoundTo30 = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.AggMinutesRoundTo30, expression, types_js_1.DateLevels.AggMinutesRoundTo30, 'HH:mm', desc, sort, dataSource);
|
|
199
|
-
this.AggMinutesRoundTo15 = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.AggMinutesRoundTo15, expression, types_js_1.DateLevels.AggMinutesRoundTo15, 'HH:mm',
|
|
200
|
-
this.AggMinutesRoundTo1 = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.AggMinutesRoundTo1, expression, types_js_1.DateLevels.AggMinutesRoundTo1, 'HH:mm',
|
|
200
|
+
this.AggMinutesRoundTo15 = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.AggMinutesRoundTo15, expression, types_js_1.DateLevels.AggMinutesRoundTo15, 'HH:mm', ...commonProps);
|
|
201
|
+
this.AggMinutesRoundTo1 = new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.AggMinutesRoundTo1, expression, types_js_1.DateLevels.AggMinutesRoundTo1, 'HH:mm', ...commonProps);
|
|
201
202
|
this.setAttributes([
|
|
202
203
|
this.Years,
|
|
203
204
|
this.Quarters,
|
|
@@ -242,7 +243,7 @@ class DimensionalDateDimension extends DimensionalDimension {
|
|
|
242
243
|
* @returns An instance representing the sorted {@link Dimension} of this instance
|
|
243
244
|
*/
|
|
244
245
|
sort(sort) {
|
|
245
|
-
return new DimensionalDateDimension(this.name, this.expression, this.description, sort, this.dataSource, this.composeCode);
|
|
246
|
+
return new DimensionalDateDimension(this.name, this.expression, this.description, sort, this.dataSource, this.composeCode, this.indexed, this.merged);
|
|
246
247
|
}
|
|
247
248
|
/**
|
|
248
249
|
* Gets a serializable representation of the element
|
|
@@ -287,9 +288,11 @@ function createDimension(json) {
|
|
|
287
288
|
const type = DimensionalDimension.parseType(json.dimtype || json.type);
|
|
288
289
|
const sort = json.sort;
|
|
289
290
|
const dataSource = json.dataSource;
|
|
291
|
+
const indexed = json.indexed;
|
|
292
|
+
const merged = json.merged;
|
|
290
293
|
// date dimension
|
|
291
294
|
if (type == types_js_1.MetadataTypes.DateDimension) {
|
|
292
|
-
return new DimensionalDateDimension(name, expression, description, sort, dataSource);
|
|
295
|
+
return new DimensionalDateDimension(name, expression, description, sort, dataSource, undefined, indexed, merged);
|
|
293
296
|
}
|
|
294
297
|
// attributes
|
|
295
298
|
const atts = Object.getOwnPropertyNames(json)
|
|
@@ -300,12 +303,12 @@ function createDimension(json) {
|
|
|
300
303
|
let att;
|
|
301
304
|
for (let i = 0; i < json.attributes.length; i++) {
|
|
302
305
|
att = json.attributes[i];
|
|
303
|
-
atts.push(new attributes_js_1.DimensionalAttribute(att.name, att.expression, att.type, att.description, att.sort, att.dataSource));
|
|
306
|
+
atts.push(new attributes_js_1.DimensionalAttribute(att.name, att.expression, att.type, att.description, att.sort, att.dataSource, undefined, undefined, att.indexed, att.merged));
|
|
304
307
|
}
|
|
305
308
|
}
|
|
306
309
|
// default attribute
|
|
307
310
|
else if (expression) {
|
|
308
|
-
atts.push(new attributes_js_1.DimensionalAttribute(name, expression, type, description, sort, dataSource));
|
|
311
|
+
atts.push(new attributes_js_1.DimensionalAttribute(name, expression, type, description, sort, dataSource, undefined, undefined, indexed, merged));
|
|
309
312
|
}
|
|
310
313
|
}
|
|
311
314
|
// nested dimensions
|
|
@@ -341,6 +344,6 @@ function createDateDimension(json) {
|
|
|
341
344
|
const description = json.desc || json.description;
|
|
342
345
|
const sort = json.sort;
|
|
343
346
|
const dataSource = json.dataSource;
|
|
344
|
-
return new DimensionalDateDimension(name, expression, description, sort, dataSource);
|
|
347
|
+
return new DimensionalDateDimension(name, expression, description, sort, dataSource, undefined, json.indexed, json.merged);
|
|
345
348
|
}
|
|
346
349
|
exports.createDateDimension = createDateDimension;
|
|
@@ -37,6 +37,8 @@ const createAttributeEntry = (field, dataSource) => {
|
|
|
37
37
|
expression: attributeId,
|
|
38
38
|
dataSource: dataSourceConfig,
|
|
39
39
|
description: field.description,
|
|
40
|
+
indexed: field.indexed,
|
|
41
|
+
merged: field.merged,
|
|
40
42
|
})
|
|
41
43
|
: (0, attributes_js_1.createAttribute)({
|
|
42
44
|
name: attributeName,
|
|
@@ -44,6 +46,8 @@ const createAttributeEntry = (field, dataSource) => {
|
|
|
44
46
|
expression: attributeId,
|
|
45
47
|
dataSource: dataSourceConfig,
|
|
46
48
|
description: field.description,
|
|
49
|
+
indexed: field.indexed,
|
|
50
|
+
merged: field.merged,
|
|
47
51
|
});
|
|
48
52
|
return {
|
|
49
53
|
dimension: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Attribute, BaseFilterConfig, BaseMeasure, DateDimension, Filter, FilterRelations, FilterRelationsNode, LevelAttribute, Measure, MembersFilterConfig } from '../interfaces.js';
|
|
1
|
+
import { Attribute, BaseFilterConfig, BaseMeasure, CalculatedMeasure, DateDimension, Filter, FilterRelations, FilterRelationsNode, LevelAttribute, Measure, MembersFilterConfig } from '../interfaces.js';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a filter representing the union of multiple filters on the same attribute. The resulting
|
|
4
4
|
* union filter filters on items that match any of the given filters.
|
|
@@ -571,7 +571,7 @@ export declare function measureBase(attribute: Attribute, measure: Measure, oper
|
|
|
571
571
|
* @param config - Optional configuration for the filter
|
|
572
572
|
* @returns A filter instance
|
|
573
573
|
*/
|
|
574
|
-
export declare const measureEquals: (measure: BaseMeasure, value: number, config?: BaseFilterConfig) => Filter;
|
|
574
|
+
export declare const measureEquals: (measure: BaseMeasure | CalculatedMeasure, value: number, config?: BaseFilterConfig) => Filter;
|
|
575
575
|
/**
|
|
576
576
|
* Creates a filter to isolate a measure value greater than to a given number.
|
|
577
577
|
*
|
|
@@ -589,7 +589,7 @@ export declare const measureEquals: (measure: BaseMeasure, value: number, config
|
|
|
589
589
|
* @param config - Optional configuration for the filter
|
|
590
590
|
* @returns A filter instance
|
|
591
591
|
*/
|
|
592
|
-
export declare const measureGreaterThan: (measure: BaseMeasure, value: number, config?: BaseFilterConfig) => Filter;
|
|
592
|
+
export declare const measureGreaterThan: (measure: BaseMeasure | CalculatedMeasure, value: number, config?: BaseFilterConfig) => Filter;
|
|
593
593
|
/**
|
|
594
594
|
* Creates a filter to isolate a measure value greater than or equal to a given number.
|
|
595
595
|
*
|
|
@@ -607,7 +607,7 @@ export declare const measureGreaterThan: (measure: BaseMeasure, value: number, c
|
|
|
607
607
|
* @param config - Optional configuration for the filter
|
|
608
608
|
* @returns A filter instance
|
|
609
609
|
*/
|
|
610
|
-
export declare const measureGreaterThanOrEqual: (measure: BaseMeasure, value: number, config?: BaseFilterConfig) => Filter;
|
|
610
|
+
export declare const measureGreaterThanOrEqual: (measure: BaseMeasure | CalculatedMeasure, value: number, config?: BaseFilterConfig) => Filter;
|
|
611
611
|
/**
|
|
612
612
|
* Creates a filter to isolate a measure value less than or equal to a given number.
|
|
613
613
|
*
|
|
@@ -625,7 +625,7 @@ export declare const measureGreaterThanOrEqual: (measure: BaseMeasure, value: nu
|
|
|
625
625
|
* @param config - Optional configuration for the filter
|
|
626
626
|
* @returns A filter instance
|
|
627
627
|
*/
|
|
628
|
-
export declare const measureLessThanOrEqual: (measure: BaseMeasure, value: number, config?: BaseFilterConfig) => Filter;
|
|
628
|
+
export declare const measureLessThanOrEqual: (measure: BaseMeasure | CalculatedMeasure, value: number, config?: BaseFilterConfig) => Filter;
|
|
629
629
|
/**
|
|
630
630
|
* Creates a filter to isolate a measure value less than a given number.
|
|
631
631
|
*
|
|
@@ -642,7 +642,7 @@ export declare const measureLessThanOrEqual: (measure: BaseMeasure, value: numbe
|
|
|
642
642
|
* @param config - Optional configuration for the filter
|
|
643
643
|
* @returns A filter instance
|
|
644
644
|
*/
|
|
645
|
-
export declare const measureLessThan: (measure: BaseMeasure, value: number, config?: BaseFilterConfig) => Filter;
|
|
645
|
+
export declare const measureLessThan: (measure: BaseMeasure | CalculatedMeasure, value: number, config?: BaseFilterConfig) => Filter;
|
|
646
646
|
/**
|
|
647
647
|
* Creates a filter to isolate a measure value between or equal to two given numbers.
|
|
648
648
|
*
|
|
@@ -662,7 +662,7 @@ export declare const measureLessThan: (measure: BaseMeasure, value: number, conf
|
|
|
662
662
|
* @param config - Optional configuration for the filter
|
|
663
663
|
* @returns A filter instance
|
|
664
664
|
*/
|
|
665
|
-
export declare const measureBetween: (measure: BaseMeasure, valueA: number, valueB: number, config?: BaseFilterConfig) => Filter;
|
|
665
|
+
export declare const measureBetween: (measure: BaseMeasure | CalculatedMeasure, valueA: number, valueB: number, config?: BaseFilterConfig) => Filter;
|
|
666
666
|
/**
|
|
667
667
|
* Creates a filter to isolate a measure value between but not equal to two given numbers.
|
|
668
668
|
*
|
|
@@ -682,7 +682,7 @@ export declare const measureBetween: (measure: BaseMeasure, valueA: number, valu
|
|
|
682
682
|
* @param config - Optional configuration for the filter
|
|
683
683
|
* @returns A filter instance
|
|
684
684
|
*/
|
|
685
|
-
export declare const measureBetweenNotEqual: (measure: BaseMeasure, valueA: number, valueB: number, config?: BaseFilterConfig) => Filter;
|
|
685
|
+
export declare const measureBetweenNotEqual: (measure: BaseMeasure | CalculatedMeasure, valueA: number, valueB: number, config?: BaseFilterConfig) => Filter;
|
|
686
686
|
/**
|
|
687
687
|
* Creates a filter to isolate items that rank towards the top for a given measure.
|
|
688
688
|
*
|
|
@@ -566,6 +566,29 @@ exports.thisQuarter = (0, compose_code_utils_js_1.withComposeCodeForFilter)((dim
|
|
|
566
566
|
*/
|
|
567
567
|
exports.today = (0, compose_code_utils_js_1.withComposeCodeForFilter)((dimension, config) => (0, exports.dateRelativeTo)(dimension.Days, 0, 1, undefined, config), 'today');
|
|
568
568
|
// MEASURE-RELATED FILTERS
|
|
569
|
+
/**
|
|
570
|
+
* Gets the attribute from a measure, resolving through nested CalculatedMeasures.
|
|
571
|
+
* @param measure - Measure to get the attribute from
|
|
572
|
+
* @returns Attribute from the first BaseMeasure found in the measure tree
|
|
573
|
+
*/
|
|
574
|
+
function getMeasureAttribute(measure) {
|
|
575
|
+
if ('attribute' in measure) {
|
|
576
|
+
return measure.attribute;
|
|
577
|
+
}
|
|
578
|
+
for (const contextMeasure of Object.values(measure.context)) {
|
|
579
|
+
if (typeof contextMeasure !== 'object' || contextMeasure === null) {
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
if ('attribute' in contextMeasure) {
|
|
583
|
+
return contextMeasure.attribute;
|
|
584
|
+
}
|
|
585
|
+
if ('context' in contextMeasure &&
|
|
586
|
+
typeof contextMeasure.context === 'object') {
|
|
587
|
+
return getMeasureAttribute(contextMeasure);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
throw new Error('Cannot determine attribute from measure');
|
|
591
|
+
}
|
|
569
592
|
/**
|
|
570
593
|
* Creates a filter on all measure values matching the provided criteria.
|
|
571
594
|
*
|
|
@@ -599,7 +622,7 @@ exports.measureBase = measureBase;
|
|
|
599
622
|
* @param config - Optional configuration for the filter
|
|
600
623
|
* @returns A filter instance
|
|
601
624
|
*/
|
|
602
|
-
exports.measureEquals = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, value, config) => measureBase(measure
|
|
625
|
+
exports.measureEquals = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, value, config) => measureBase(getMeasureAttribute(measure), measure, filters_js_1.NumericOperators.Equals, value, undefined, undefined, config), 'measureEquals');
|
|
603
626
|
/**
|
|
604
627
|
* Creates a filter to isolate a measure value greater than to a given number.
|
|
605
628
|
*
|
|
@@ -617,7 +640,7 @@ exports.measureEquals = (0, compose_code_utils_js_1.withComposeCodeForFilter)((m
|
|
|
617
640
|
* @param config - Optional configuration for the filter
|
|
618
641
|
* @returns A filter instance
|
|
619
642
|
*/
|
|
620
|
-
exports.measureGreaterThan = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, value, config) => measureBase(measure
|
|
643
|
+
exports.measureGreaterThan = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, value, config) => measureBase(getMeasureAttribute(measure), measure, filters_js_1.NumericOperators.FromNotEqual, value, undefined, undefined, config), 'measureGreaterThan');
|
|
621
644
|
/**
|
|
622
645
|
* Creates a filter to isolate a measure value greater than or equal to a given number.
|
|
623
646
|
*
|
|
@@ -635,7 +658,7 @@ exports.measureGreaterThan = (0, compose_code_utils_js_1.withComposeCodeForFilte
|
|
|
635
658
|
* @param config - Optional configuration for the filter
|
|
636
659
|
* @returns A filter instance
|
|
637
660
|
*/
|
|
638
|
-
exports.measureGreaterThanOrEqual = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, value, config) => measureBase(measure
|
|
661
|
+
exports.measureGreaterThanOrEqual = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, value, config) => measureBase(getMeasureAttribute(measure), measure, filters_js_1.NumericOperators.From, value, undefined, undefined, config), 'measureGreaterThanOrEqual');
|
|
639
662
|
/**
|
|
640
663
|
* Creates a filter to isolate a measure value less than or equal to a given number.
|
|
641
664
|
*
|
|
@@ -653,7 +676,7 @@ exports.measureGreaterThanOrEqual = (0, compose_code_utils_js_1.withComposeCodeF
|
|
|
653
676
|
* @param config - Optional configuration for the filter
|
|
654
677
|
* @returns A filter instance
|
|
655
678
|
*/
|
|
656
|
-
exports.measureLessThanOrEqual = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, value, config) => measureBase(measure
|
|
679
|
+
exports.measureLessThanOrEqual = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, value, config) => measureBase(getMeasureAttribute(measure), measure, filters_js_1.NumericOperators.To, value, undefined, undefined, config), 'measureLessThanOrEqual');
|
|
657
680
|
/**
|
|
658
681
|
* Creates a filter to isolate a measure value less than a given number.
|
|
659
682
|
*
|
|
@@ -670,7 +693,7 @@ exports.measureLessThanOrEqual = (0, compose_code_utils_js_1.withComposeCodeForF
|
|
|
670
693
|
* @param config - Optional configuration for the filter
|
|
671
694
|
* @returns A filter instance
|
|
672
695
|
*/
|
|
673
|
-
exports.measureLessThan = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, value, config) => measureBase(measure
|
|
696
|
+
exports.measureLessThan = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, value, config) => measureBase(getMeasureAttribute(measure), measure, filters_js_1.NumericOperators.ToNotEqual, value, undefined, undefined, config), 'measureLessThan');
|
|
674
697
|
/**
|
|
675
698
|
* Creates a filter to isolate a measure value between or equal to two given numbers.
|
|
676
699
|
*
|
|
@@ -690,7 +713,7 @@ exports.measureLessThan = (0, compose_code_utils_js_1.withComposeCodeForFilter)(
|
|
|
690
713
|
* @param config - Optional configuration for the filter
|
|
691
714
|
* @returns A filter instance
|
|
692
715
|
*/
|
|
693
|
-
exports.measureBetween = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, valueA, valueB, config) => measureBase(measure
|
|
716
|
+
exports.measureBetween = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, valueA, valueB, config) => measureBase(getMeasureAttribute(measure), measure, filters_js_1.NumericOperators.From, valueA, filters_js_1.NumericOperators.To, valueB, config), 'measureBetween');
|
|
694
717
|
/**
|
|
695
718
|
* Creates a filter to isolate a measure value between but not equal to two given numbers.
|
|
696
719
|
*
|
|
@@ -710,7 +733,7 @@ exports.measureBetween = (0, compose_code_utils_js_1.withComposeCodeForFilter)((
|
|
|
710
733
|
* @param config - Optional configuration for the filter
|
|
711
734
|
* @returns A filter instance
|
|
712
735
|
*/
|
|
713
|
-
exports.measureBetweenNotEqual = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, valueA, valueB, config) => measureBase(measure
|
|
736
|
+
exports.measureBetweenNotEqual = (0, compose_code_utils_js_1.withComposeCodeForFilter)((measure, valueA, valueB, config) => measureBase(getMeasureAttribute(measure), measure, filters_js_1.NumericOperators.FromNotEqual, valueA, filters_js_1.NumericOperators.ToNotEqual, valueB, config), 'measureBetweenNotEqual');
|
|
714
737
|
// RANKING FILTERS
|
|
715
738
|
/**
|
|
716
739
|
* Creates a filter to isolate items that rank towards the top for a given measure.
|
|
@@ -36,6 +36,12 @@ export declare type FilterAction = {
|
|
|
36
36
|
} | {
|
|
37
37
|
type: 'remove';
|
|
38
38
|
payload: Filter;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'replace';
|
|
41
|
+
payload: {
|
|
42
|
+
prevFilter: Filter;
|
|
43
|
+
newFilter: Filter;
|
|
44
|
+
};
|
|
39
45
|
};
|
|
40
46
|
/**
|
|
41
47
|
* Merges source filters with target filters and recalculates relations.
|
|
@@ -77,9 +83,18 @@ export declare function isTrivialSingleNodeRelations(relations: FilterRelationsR
|
|
|
77
83
|
/**
|
|
78
84
|
* Calculates new relations based on the changes in filters.
|
|
79
85
|
*
|
|
86
|
+
* @param prevFilters - The previous array of filters that the relations were built for.
|
|
87
|
+
* @param prevRelations - The previous relation rules.
|
|
88
|
+
* @param newFilters - The updated array of filters to build new relations for.
|
|
89
|
+
* @param options - Optional flags controlling how the diff is computed:
|
|
90
|
+
* - `shouldReplaceSameAttributeFilters`: when `true`, a new filter on the same attribute as
|
|
91
|
+
* an existing one (but with a different GUID) is treated as an in-place replacement rather
|
|
92
|
+
* than a remove + add pair, preserving the original relation tree structure.
|
|
80
93
|
* @internal
|
|
81
94
|
*/
|
|
82
|
-
export declare function calculateNewRelations(prevFilters: Filter[], prevRelations: FilterRelationsRules, newFilters: Filter[]
|
|
95
|
+
export declare function calculateNewRelations(prevFilters: Filter[], prevRelations: FilterRelationsRules, newFilters: Filter[], options?: {
|
|
96
|
+
shouldReplaceSameAttributeFilters?: boolean;
|
|
97
|
+
}): FilterRelationsRules;
|
|
83
98
|
/**
|
|
84
99
|
* Replaces a filter in the relations tree with a new filter.
|
|
85
100
|
*
|
|
@@ -148,14 +148,21 @@ exports.isTrivialSingleNodeRelations = isTrivialSingleNodeRelations;
|
|
|
148
148
|
/**
|
|
149
149
|
* Calculates new relations based on the changes in filters.
|
|
150
150
|
*
|
|
151
|
+
* @param prevFilters - The previous array of filters that the relations were built for.
|
|
152
|
+
* @param prevRelations - The previous relation rules.
|
|
153
|
+
* @param newFilters - The updated array of filters to build new relations for.
|
|
154
|
+
* @param options - Optional flags controlling how the diff is computed:
|
|
155
|
+
* - `shouldReplaceSameAttributeFilters`: when `true`, a new filter on the same attribute as
|
|
156
|
+
* an existing one (but with a different GUID) is treated as an in-place replacement rather
|
|
157
|
+
* than a remove + add pair, preserving the original relation tree structure.
|
|
151
158
|
* @internal
|
|
152
159
|
*/
|
|
153
|
-
function calculateNewRelations(prevFilters, prevRelations, newFilters) {
|
|
160
|
+
function calculateNewRelations(prevFilters, prevRelations, newFilters, options = {}) {
|
|
154
161
|
// If there are no previous relations - no need to recalculate them
|
|
155
162
|
if (prevRelations === null) {
|
|
156
163
|
return null;
|
|
157
164
|
}
|
|
158
|
-
const performedActions = diffFilters(prevFilters, newFilters);
|
|
165
|
+
const performedActions = diffFilters(prevFilters, newFilters, options.shouldReplaceSameAttributeFilters);
|
|
159
166
|
if (performedActions.length === 0) {
|
|
160
167
|
return prevRelations;
|
|
161
168
|
}
|
|
@@ -165,6 +172,8 @@ function calculateNewRelations(prevFilters, prevRelations, newFilters) {
|
|
|
165
172
|
return addFilterToRelations(action.payload, relations);
|
|
166
173
|
case 'remove':
|
|
167
174
|
return removeFilterFromRelations(action.payload, relations);
|
|
175
|
+
case 'replace':
|
|
176
|
+
return getRelationsWithReplacedFilter(relations, action.payload.prevFilter, action.payload.newFilter);
|
|
168
177
|
}
|
|
169
178
|
}, prevRelations);
|
|
170
179
|
}
|
|
@@ -207,26 +216,54 @@ exports.getRelationsWithReplacedFilter = getRelationsWithReplacedFilter;
|
|
|
207
216
|
* Compares two arrays of Filter objects and determines the actions needed
|
|
208
217
|
* to transform prevFilters into newFilters.
|
|
209
218
|
*
|
|
219
|
+
* When `shouldReplaceSameAttributeFilters` is enabled, a new filter whose attribute matches
|
|
220
|
+
* an existing one (same `getFilterCompareId`) but has a different GUID is emitted as a single
|
|
221
|
+
* `replace` action instead of a `remove` + `add` pair. This preserves the relation tree node
|
|
222
|
+
* at the original position rather than appending the new filter with AND at the root.
|
|
223
|
+
* The disabled existing filters are excluded from the same-attribute replacement check
|
|
224
|
+
* and will therefore never be replaced in-place.
|
|
225
|
+
*
|
|
210
226
|
* @param prevFilters - The original array of filters.
|
|
211
227
|
* @param newFilters - The updated array of filters.
|
|
212
|
-
* @param
|
|
228
|
+
* @param shouldReplaceSameAttributeFilters - Optional flag to enable same-attribute filter replacement.
|
|
213
229
|
* @returns An array of FilterAction objects representing the changes.
|
|
214
230
|
*/
|
|
215
|
-
function diffFilters(prevFilters, newFilters) {
|
|
231
|
+
function diffFilters(prevFilters, newFilters, shouldReplaceSameAttributeFilters = false) {
|
|
216
232
|
const actions = [];
|
|
217
|
-
//
|
|
218
|
-
const
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
233
|
+
// Track which filters from each side have already been matched to avoid double-counting.
|
|
234
|
+
const matchedPrevFilters = new Set();
|
|
235
|
+
const matchedNewFilters = new Set();
|
|
236
|
+
if (shouldReplaceSameAttributeFilters) {
|
|
237
|
+
prevFilters.forEach((prevFilter, prevIdx) => {
|
|
238
|
+
// Disabled filters are never eligible for in-place replacement.
|
|
239
|
+
if (prevFilter.config.disabled) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
// Look for a new filter on the same attribute with a different GUID.
|
|
243
|
+
const newIdx = newFilters.findIndex((newFilter, idx) => !matchedNewFilters.has(idx) &&
|
|
244
|
+
!areFiltersEqualForRelations(prevFilter, newFilter) &&
|
|
245
|
+
getFilterCompareId(prevFilter) === getFilterCompareId(newFilter));
|
|
246
|
+
if (newIdx !== -1) {
|
|
247
|
+
actions.push({ type: 'replace', payload: { prevFilter, newFilter: newFilters[newIdx] } });
|
|
248
|
+
matchedPrevFilters.add(prevIdx);
|
|
249
|
+
matchedNewFilters.add(newIdx);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
// Removals: prev filters not matched by GUID in new filters (and not already handled as replace).
|
|
254
|
+
prevFilters.forEach((prevFilter, prevIdx) => {
|
|
255
|
+
if (matchedPrevFilters.has(prevIdx))
|
|
256
|
+
return;
|
|
257
|
+
const existsInNew = newFilters.some((newFilter) => areFiltersEqualForRelations(prevFilter, newFilter));
|
|
223
258
|
if (!existsInNew) {
|
|
224
259
|
actions.push({ type: 'remove', payload: prevFilter });
|
|
225
260
|
}
|
|
226
261
|
});
|
|
227
|
-
//
|
|
228
|
-
|
|
229
|
-
|
|
262
|
+
// Additions: new filters not matched by GUID in prev filters (and not already handled as replace).
|
|
263
|
+
newFilters.forEach((newFilter, newIdx) => {
|
|
264
|
+
if (matchedNewFilters.has(newIdx))
|
|
265
|
+
return;
|
|
266
|
+
const existsInPrev = prevFilters.some((prevFilter) => areFiltersEqualForRelations(newFilter, prevFilter));
|
|
230
267
|
if (!existsInPrev) {
|
|
231
268
|
actions.push({ type: 'add', payload: newFilter });
|
|
232
269
|
}
|
|
@@ -481,7 +481,7 @@ class MeasureFilter extends DoubleOperatorFilter {
|
|
|
481
481
|
return AbstractFilter.disabledJaql(nested);
|
|
482
482
|
}
|
|
483
483
|
const result = super.jaql(nested);
|
|
484
|
-
if ((0, measures_js_1.isDimensionalBaseMeasure)(this.measure)) {
|
|
484
|
+
if ((0, measures_js_1.isDimensionalBaseMeasure)(this.measure) || (0, measures_js_1.isDimensionalCalculatedMeasure)(this.measure)) {
|
|
485
485
|
Object.entries(this.measure.jaql().jaql).forEach(([key, value]) => {
|
|
486
486
|
result.jaql[key] = value;
|
|
487
487
|
});
|
|
@@ -574,7 +574,7 @@ class MeasureRankingFilter extends AbstractFilter {
|
|
|
574
574
|
return AbstractFilter.disabledJaql(nested);
|
|
575
575
|
}
|
|
576
576
|
const result = super.jaql(nested);
|
|
577
|
-
if ((0, measures_js_1.isDimensionalBaseMeasure)(this.measure)) {
|
|
577
|
+
if ((0, measures_js_1.isDimensionalBaseMeasure)(this.measure) || (0, measures_js_1.isDimensionalCalculatedMeasure)(this.measure)) {
|
|
578
578
|
Object.entries(this.measure.jaql().jaql).forEach(([key, value]) => {
|
|
579
579
|
result.jaql[key] = value;
|
|
580
580
|
});
|
|
@@ -82,6 +82,18 @@ export interface Element {
|
|
|
82
82
|
* @internal
|
|
83
83
|
*/
|
|
84
84
|
composeCode?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Merged from DataSourceField. It is used for the aggregation filtering
|
|
87
|
+
*
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
readonly merged?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Indexed from DataSourceField. It is used for the aggregation filtering
|
|
93
|
+
*
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
readonly indexed?: boolean;
|
|
85
97
|
}
|
|
86
98
|
/**
|
|
87
99
|
* Base interface for measure, which is typically numeric aggregation over {@link Attribute}(s).
|
|
@@ -80,13 +80,13 @@ export declare const RankingSortTypes: {
|
|
|
80
80
|
* ```
|
|
81
81
|
* @param title - Title of the measure to be displayed in legend
|
|
82
82
|
* @param formula - Formula to be used for the measure
|
|
83
|
-
* @param context -
|
|
83
|
+
* @param context - Optional formula context as a map of strings to attributes, measures, or filters
|
|
84
84
|
* @param format - Optional format string for the measure
|
|
85
85
|
* @param description - Optional description of the measure
|
|
86
86
|
* @returns A calculated measure instance
|
|
87
87
|
* @group Advanced Analytics
|
|
88
88
|
*/
|
|
89
|
-
export declare const customFormula: (title: string, formula: string, context
|
|
89
|
+
export declare const customFormula: (title: string, formula: string, context?: CustomFormulaContext, format?: string, description?: string) => CalculatedMeasure;
|
|
90
90
|
/**
|
|
91
91
|
* Creates an aggregated measure.
|
|
92
92
|
*
|
|
@@ -123,7 +123,7 @@ function measureFunction(measure, name, func, options) {
|
|
|
123
123
|
* ```
|
|
124
124
|
* @param title - Title of the measure to be displayed in legend
|
|
125
125
|
* @param formula - Formula to be used for the measure
|
|
126
|
-
* @param context -
|
|
126
|
+
* @param context - Optional formula context as a map of strings to attributes, measures, or filters
|
|
127
127
|
* @param format - Optional format string for the measure
|
|
128
128
|
* @param description - Optional description of the measure
|
|
129
129
|
* @returns A calculated measure instance
|
|
@@ -131,7 +131,10 @@ function measureFunction(measure, name, func, options) {
|
|
|
131
131
|
*/
|
|
132
132
|
exports.customFormula = (0, compose_code_utils_js_1.withComposeCodeForMeasure)((title, formula, context, format, description) => {
|
|
133
133
|
// context keys must be in brackets
|
|
134
|
-
const newContext = Object.fromEntries(Object.entries(context).map(([key, val]) => [
|
|
134
|
+
const newContext = Object.fromEntries(Object.entries(context !== null && context !== void 0 ? context : {}).map(([key, val]) => [
|
|
135
|
+
key.startsWith('[') ? key : `[${key}]`,
|
|
136
|
+
val,
|
|
137
|
+
]));
|
|
135
138
|
return new measures_js_1.DimensionalCalculatedMeasure(title, formula, newContext, format, description);
|
|
136
139
|
}, 'customFormula');
|
|
137
140
|
function arithmetic(operand1, operator, operand2, name, withParentheses) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DimensionalElement } from '../base.js';
|
|
2
2
|
import { Attribute, BaseMeasure, CalculatedMeasure, Measure, MeasureContext, MeasureTemplate } from '../interfaces.js';
|
|
3
|
-
import { AnyObject, JaqlDataSource, JSONObject, Sort } from '../types.js';
|
|
3
|
+
import { AggregationType, AnyObject, JaqlDataSource, JSONObject, Sort } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
@@ -57,7 +57,7 @@ export declare class DimensionalBaseMeasure extends AbstractMeasure implements B
|
|
|
57
57
|
* @internal
|
|
58
58
|
*/
|
|
59
59
|
readonly __serializable: string;
|
|
60
|
-
static aggregationFromJAQL(agg: string):
|
|
60
|
+
static aggregationFromJAQL(agg: string): AggregationType;
|
|
61
61
|
static aggregationToJAQL(agg: string): string;
|
|
62
62
|
constructor(name: string, attribute: Attribute, agg: string, format?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string);
|
|
63
63
|
/**
|
|
@@ -264,7 +264,10 @@ class DimensionalCalculatedMeasure extends AbstractMeasure {
|
|
|
264
264
|
};
|
|
265
265
|
const context = {};
|
|
266
266
|
const keys = Object.getOwnPropertyNames(this.context);
|
|
267
|
-
keys.forEach((k) =>
|
|
267
|
+
keys.forEach((k) => {
|
|
268
|
+
const v = this.context[k];
|
|
269
|
+
context[k] = v && typeof v.jaql === 'function' ? v.jaql(true) : v;
|
|
270
|
+
});
|
|
268
271
|
r.jaql.context = context;
|
|
269
272
|
if (this._format) {
|
|
270
273
|
r.format = { number: this._format };
|