@sisense/sdk-data 2.22.0 → 2.23.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/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/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
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FilterJaqlInternal, JaqlDataSource, JaqlDataSourceForDto, RankingFilterJaql } from './dimensional-model/filters/utils/types.js';
|
|
2
2
|
import { Attribute, BaseMeasure, CalculatedMeasure, Filter, FilterRelations, FilterRelationsJaql, LevelAttribute, SortDirection } from './dimensional-model/interfaces.js';
|
|
3
|
-
import { BaseJaql, FilterJaql, FormulaJaql, Jaql, JaqlSortDirection, MetadataItemJaql, Sort } from './dimensional-model/types.js';
|
|
3
|
+
import { AggregationType, BaseJaql, FilterJaql, FormulaJaql, Jaql, JaqlSortDirection, MetadataItemJaql, Sort } from './dimensional-model/types.js';
|
|
4
4
|
import { DataSource, DataSourceInfo } from './interfaces.js';
|
|
5
5
|
/**
|
|
6
6
|
* Generates a cryptographically secure random number between 0 and 1.
|
|
@@ -126,7 +126,7 @@ export declare function getSortType(jaqlSort: `${JaqlSortDirection}` | undefined
|
|
|
126
126
|
* @returns attribute or level attribute
|
|
127
127
|
* @internal
|
|
128
128
|
*/
|
|
129
|
-
export declare const createAttributeHelper: ({ expression, dataType, granularity, format, sort, title, panel, dataSource, }: {
|
|
129
|
+
export declare const createAttributeHelper: ({ expression, dataType, granularity, format, sort, title, panel, dataSource, indexed, merged, }: {
|
|
130
130
|
/** Dimension expression */
|
|
131
131
|
expression: string;
|
|
132
132
|
/** Data type */
|
|
@@ -143,6 +143,10 @@ export declare const createAttributeHelper: ({ expression, dataType, granularity
|
|
|
143
143
|
panel?: string | undefined;
|
|
144
144
|
/** Jaql data source */
|
|
145
145
|
dataSource?: JaqlDataSource | undefined;
|
|
146
|
+
/** Indexed */
|
|
147
|
+
indexed?: boolean | undefined;
|
|
148
|
+
/** Merged */
|
|
149
|
+
merged?: boolean | undefined;
|
|
146
150
|
}) => Attribute | LevelAttribute;
|
|
147
151
|
/**
|
|
148
152
|
* Creates a measure from the provided parameters
|
|
@@ -150,7 +154,7 @@ export declare const createAttributeHelper: ({ expression, dataType, granularity
|
|
|
150
154
|
* @returns measure
|
|
151
155
|
* @internal
|
|
152
156
|
*/
|
|
153
|
-
export declare const createMeasureHelper: ({ expression, dataType, agg, granularity, format, sort, title, dataSource, }: {
|
|
157
|
+
export declare const createMeasureHelper: ({ expression, dataType, agg, granularity, format, sort, title, dataSource, indexed, merged, }: {
|
|
154
158
|
/** Dimension expression */
|
|
155
159
|
expression: string;
|
|
156
160
|
/** Data type */
|
|
@@ -167,7 +171,16 @@ export declare const createMeasureHelper: ({ expression, dataType, agg, granular
|
|
|
167
171
|
title?: string | undefined;
|
|
168
172
|
/** Jaql data source */
|
|
169
173
|
dataSource?: JaqlDataSource | undefined;
|
|
174
|
+
/** Indexed */
|
|
175
|
+
indexed?: boolean | undefined;
|
|
176
|
+
/** Merged */
|
|
177
|
+
merged?: boolean | undefined;
|
|
170
178
|
}) => BaseMeasure;
|
|
179
|
+
/**
|
|
180
|
+
* @returns measure
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
export declare function createMeasureByAggType(agg: AggregationType, attribute: Attribute | LevelAttribute, updatedTitle?: string, format?: string): BaseMeasure;
|
|
171
184
|
/**
|
|
172
185
|
* Creates a measure from the provided parameters
|
|
173
186
|
*
|
package/dist/cjs/utils.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.translateSharedFormulas = exports.getGranularityFromJaql = exports.createDimensionalElementFromJaql = exports.createCalculatedMeasureHelper = exports.createMeasureHelper = exports.createAttributeHelper = exports.getSortType = exports.getColumnNameFromAttribute = exports.getTableNameFromAttribute = exports.parseExpression = exports.createFilterFromJaql = exports.convertSortToSortDirection = exports.convertSortDirectionToSort = exports.convertSort = exports.convertJaqlDataSourceForDto = exports.convertJaqlDataSource = exports.convertDataSource = exports.isDataSourceInfo = exports.getDataSourceName = exports.getFilterListAndRelationsJaql = exports.guidFast = exports.secureRandom = void 0;
|
|
29
|
+
exports.translateSharedFormulas = exports.getGranularityFromJaql = exports.createDimensionalElementFromJaql = exports.createCalculatedMeasureHelper = exports.createMeasureByAggType = exports.createMeasureHelper = exports.createAttributeHelper = exports.getSortType = exports.getColumnNameFromAttribute = exports.getTableNameFromAttribute = exports.parseExpression = exports.createFilterFromJaql = exports.convertSortToSortDirection = exports.convertSortDirectionToSort = exports.convertSort = exports.convertJaqlDataSourceForDto = exports.convertJaqlDataSource = exports.convertDataSource = exports.isDataSourceInfo = exports.getDataSourceName = exports.getFilterListAndRelationsJaql = exports.guidFast = exports.secureRandom = void 0;
|
|
30
30
|
const cloneDeep_js_1 = __importDefault(require("lodash-es/cloneDeep.js"));
|
|
31
31
|
const mapValues_js_1 = __importDefault(require("lodash-es/mapValues.js"));
|
|
32
32
|
const attributes_js_1 = require("./dimensional-model/attributes.js");
|
|
@@ -346,17 +346,17 @@ exports.getSortType = getSortType;
|
|
|
346
346
|
* @returns attribute or level attribute
|
|
347
347
|
* @internal
|
|
348
348
|
*/
|
|
349
|
-
const createAttributeHelper = ({ expression, dataType, granularity, format, sort, title, panel, dataSource, }) => {
|
|
349
|
+
const createAttributeHelper = ({ expression, dataType, granularity, format, sort, title, panel, dataSource, indexed, merged, }) => {
|
|
350
350
|
const column = parseExpression(expression).column;
|
|
351
351
|
const sortEnum = convertSort(sort);
|
|
352
352
|
const isDataTypeDatetime = dataType !== undefined && (0, simple_column_types_js_1.isDatetime)(dataType);
|
|
353
353
|
if (isDataTypeDatetime) {
|
|
354
354
|
const levelAttribute = new attributes_js_1.DimensionalLevelAttribute(title !== null && title !== void 0 ? title : column, expression, granularity || types_js_1.DateLevels.Years, format ||
|
|
355
|
-
attributes_js_1.DimensionalLevelAttribute.getDefaultFormatForGranularity(granularity || types_js_1.DateLevels.Years), undefined, sortEnum, dataSource, undefined, panel);
|
|
355
|
+
attributes_js_1.DimensionalLevelAttribute.getDefaultFormatForGranularity(granularity || types_js_1.DateLevels.Years), undefined, sortEnum, dataSource, undefined, panel, indexed, merged);
|
|
356
356
|
return levelAttribute;
|
|
357
357
|
}
|
|
358
358
|
const attributeType = !dataType || (0, simple_column_types_js_1.isNumber)(dataType) ? types_js_1.MetadataTypes.NumericAttribute : types_js_1.MetadataTypes.TextAttribute;
|
|
359
|
-
const attribute = new attributes_js_1.DimensionalAttribute(title !== null && title !== void 0 ? title : column, expression, attributeType, undefined, sortEnum, dataSource, undefined, panel);
|
|
359
|
+
const attribute = new attributes_js_1.DimensionalAttribute(title !== null && title !== void 0 ? title : column, expression, attributeType, undefined, sortEnum, dataSource, undefined, panel, indexed, merged);
|
|
360
360
|
return attribute;
|
|
361
361
|
};
|
|
362
362
|
exports.createAttributeHelper = createAttributeHelper;
|
|
@@ -366,7 +366,7 @@ exports.createAttributeHelper = createAttributeHelper;
|
|
|
366
366
|
* @returns measure
|
|
367
367
|
* @internal
|
|
368
368
|
*/
|
|
369
|
-
const createMeasureHelper = ({ expression, dataType, agg, granularity, format, sort, title, dataSource, }) => {
|
|
369
|
+
const createMeasureHelper = ({ expression, dataType, agg, granularity, format, sort, title, dataSource, indexed, merged, }) => {
|
|
370
370
|
const attribute = (0, exports.createAttributeHelper)({
|
|
371
371
|
expression,
|
|
372
372
|
dataType,
|
|
@@ -375,11 +375,21 @@ const createMeasureHelper = ({ expression, dataType, agg, granularity, format, s
|
|
|
375
375
|
sort,
|
|
376
376
|
title,
|
|
377
377
|
dataSource,
|
|
378
|
+
indexed,
|
|
379
|
+
merged,
|
|
378
380
|
});
|
|
379
381
|
const tranformedAgg = measures_js_1.DimensionalBaseMeasure.aggregationFromJAQL(agg);
|
|
380
382
|
const column = parseExpression(expression).column;
|
|
381
383
|
const updatedTitle = title !== null && title !== void 0 ? title : `${tranformedAgg} ${column}`;
|
|
382
|
-
|
|
384
|
+
return createMeasureByAggType(tranformedAgg, attribute, updatedTitle, format);
|
|
385
|
+
};
|
|
386
|
+
exports.createMeasureHelper = createMeasureHelper;
|
|
387
|
+
/**
|
|
388
|
+
* @returns measure
|
|
389
|
+
* @internal
|
|
390
|
+
*/
|
|
391
|
+
function createMeasureByAggType(agg, attribute, updatedTitle, format) {
|
|
392
|
+
switch (agg) {
|
|
383
393
|
case types_js_1.AggregationTypes.Sum:
|
|
384
394
|
return measureFactory.sum(attribute, updatedTitle, format);
|
|
385
395
|
case types_js_1.AggregationTypes.Average:
|
|
@@ -401,8 +411,8 @@ const createMeasureHelper = ({ expression, dataType, agg, granularity, format, s
|
|
|
401
411
|
default:
|
|
402
412
|
return measureFactory.sum(attribute, updatedTitle, format);
|
|
403
413
|
}
|
|
404
|
-
}
|
|
405
|
-
exports.
|
|
414
|
+
}
|
|
415
|
+
exports.createMeasureByAggType = createMeasureByAggType;
|
|
406
416
|
/**
|
|
407
417
|
* Creates a measure from the provided parameters
|
|
408
418
|
*
|
|
@@ -466,6 +476,8 @@ function createDimensionalElementFromJaql(jaql, datetimeFormat, panel) {
|
|
|
466
476
|
title: jaql.title,
|
|
467
477
|
panel: panel,
|
|
468
478
|
dataSource,
|
|
479
|
+
indexed: jaql.indexed,
|
|
480
|
+
merged: jaql.merged,
|
|
469
481
|
});
|
|
470
482
|
}
|
|
471
483
|
exports.createDimensionalElementFromJaql = createDimensionalElementFromJaql;
|
|
@@ -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
|
*/
|
|
@@ -17,7 +17,7 @@ export const jaqlSimpleColumnType = (datatype) => simpleColumnType(datatype).rep
|
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
19
|
export class DimensionalAttribute extends DimensionalElement {
|
|
20
|
-
constructor(name, expression, type, desc, sort, dataSource, composeCode, panel) {
|
|
20
|
+
constructor(name, expression, type, desc, sort, dataSource, composeCode, panel, indexed, merged) {
|
|
21
21
|
super(name, type || MetadataTypes.Attribute, desc, dataSource, composeCode);
|
|
22
22
|
/**
|
|
23
23
|
* @internal
|
|
@@ -36,6 +36,8 @@ export class DimensionalAttribute extends DimensionalElement {
|
|
|
36
36
|
this.panel = panel;
|
|
37
37
|
}
|
|
38
38
|
this._sort = sort || Sort.None;
|
|
39
|
+
this.merged = merged;
|
|
40
|
+
this.indexed = indexed;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
43
|
* gets the element's ID
|
|
@@ -58,7 +60,7 @@ export class DimensionalAttribute extends DimensionalElement {
|
|
|
58
60
|
* @returns An instance representing the sorted {@link Attribute} of this instance
|
|
59
61
|
*/
|
|
60
62
|
sort(sort) {
|
|
61
|
-
return new DimensionalAttribute(this.name, this.expression, this.type, this.description, sort, this.dataSource, this.composeCode, this.panel);
|
|
63
|
+
return new DimensionalAttribute(this.name, this.expression, this.type, this.description, sort, this.dataSource, this.composeCode, this.panel, this.indexed, this.merged);
|
|
62
64
|
}
|
|
63
65
|
/**
|
|
64
66
|
* Gets the JAQL representation of this instance
|
|
@@ -103,8 +105,8 @@ export const isDimensionalAttribute = (v) => {
|
|
|
103
105
|
* @internal
|
|
104
106
|
*/
|
|
105
107
|
export class DimensionalLevelAttribute extends DimensionalAttribute {
|
|
106
|
-
constructor(name, expression, granularity, format, desc, sort, dataSource, composeCode, panel) {
|
|
107
|
-
super(name, expression, MetadataTypes.DateLevel, desc, sort, dataSource, composeCode);
|
|
108
|
+
constructor(name, expression, granularity, format, desc, sort, dataSource, composeCode, panel, indexed, merged) {
|
|
109
|
+
super(name, expression, MetadataTypes.DateLevel, desc, sort, dataSource, composeCode, undefined, indexed, merged);
|
|
108
110
|
/**
|
|
109
111
|
* @internal
|
|
110
112
|
*/
|
|
@@ -150,7 +152,7 @@ export class DimensionalLevelAttribute extends DimensionalAttribute {
|
|
|
150
152
|
* @returns An instance representing the sorted {@link LevelAttribute} of this instance
|
|
151
153
|
*/
|
|
152
154
|
sort(sort) {
|
|
153
|
-
return new DimensionalLevelAttribute(this.name, this.expression, this.granularity, this._format, this.description, sort, this.dataSource, this.composeCode);
|
|
155
|
+
return new DimensionalLevelAttribute(this.name, this.expression, this.granularity, this._format, this.description, sort, this.dataSource, this.composeCode, undefined, this.indexed, this.merged);
|
|
154
156
|
}
|
|
155
157
|
/**
|
|
156
158
|
* The string formatting of this instance
|
|
@@ -167,7 +169,7 @@ export class DimensionalLevelAttribute extends DimensionalAttribute {
|
|
|
167
169
|
* @returns An instance representing the formatted {@link LevelAttribute} of this instance
|
|
168
170
|
*/
|
|
169
171
|
format(format) {
|
|
170
|
-
return new DimensionalLevelAttribute(this.name, this.expression, this.granularity, format, this.description, this._sort, this.dataSource, this.composeCode);
|
|
172
|
+
return new DimensionalLevelAttribute(this.name, this.expression, this.granularity, format, this.description, this._sort, this.dataSource, this.composeCode, undefined, this.indexed, this.merged);
|
|
171
173
|
}
|
|
172
174
|
/**
|
|
173
175
|
* Gets a {@link LevelAttribute} with the given granularity
|
|
@@ -176,7 +178,7 @@ export class DimensionalLevelAttribute extends DimensionalAttribute {
|
|
|
176
178
|
* @returns New instance representing {@link LevelAttribute} with provided granularity
|
|
177
179
|
*/
|
|
178
180
|
setGranularity(granularity) {
|
|
179
|
-
return new DimensionalLevelAttribute(this.name, this.expression, granularity, this._format, this.description, this._sort, this.dataSource, this.composeCode);
|
|
181
|
+
return new DimensionalLevelAttribute(this.name, this.expression, granularity, this._format, this.description, this._sort, this.dataSource, this.composeCode, undefined, this.indexed, this.merged);
|
|
180
182
|
}
|
|
181
183
|
/**
|
|
182
184
|
* Gets a serializable representation of the element
|
|
@@ -384,7 +386,7 @@ export function createAttribute(json) {
|
|
|
384
386
|
if (json.granularity) {
|
|
385
387
|
return createLevel(json);
|
|
386
388
|
}
|
|
387
|
-
return new DimensionalAttribute(json.name || json.title, json.attribute || json.expression || json.dim, json.type, json.desc || json.description, json.sort, json.dataSource);
|
|
389
|
+
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);
|
|
388
390
|
}
|
|
389
391
|
/**
|
|
390
392
|
* Creates a LevelAttribute instance from the given JSON object.
|
|
@@ -393,7 +395,7 @@ export function createAttribute(json) {
|
|
|
393
395
|
* @internal
|
|
394
396
|
*/
|
|
395
397
|
export function createLevel(json) {
|
|
396
|
-
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);
|
|
398
|
+
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);
|
|
397
399
|
}
|
|
398
400
|
/**
|
|
399
401
|
* Normalize attribute name
|
|
@@ -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
|
*/
|
|
@@ -172,27 +172,28 @@ export const isDimensionalDimension = (v) => {
|
|
|
172
172
|
* @internal
|
|
173
173
|
*/
|
|
174
174
|
export class DimensionalDateDimension extends DimensionalDimension {
|
|
175
|
-
constructor(name, expression, desc, sort, dataSource, composeCode) {
|
|
175
|
+
constructor(name, expression, desc, sort, dataSource, composeCode, indexed, merged) {
|
|
176
176
|
super(name, expression, [], [], MetadataTypes.DateDimension, desc, sort, dataSource, composeCode);
|
|
177
177
|
/**
|
|
178
178
|
* @internal
|
|
179
179
|
*/
|
|
180
180
|
this.__serializable = 'DimensionalDateDimension';
|
|
181
|
+
const commonProps = [desc, sort, dataSource, undefined, undefined, indexed, merged];
|
|
181
182
|
this.defaultLevel = DateLevels.Years;
|
|
182
|
-
this.Years = new DimensionalLevelAttribute(DateLevels.Years, expression, DateLevels.Years, 'yyyy',
|
|
183
|
-
this.Quarters = new DimensionalLevelAttribute(DateLevels.Quarters, expression, DateLevels.Quarters, 'Q yyyy',
|
|
184
|
-
this.Months = new DimensionalLevelAttribute(DateLevels.Months, expression, DateLevels.Months, 'yyyy-MM',
|
|
185
|
-
this.Weeks = new DimensionalLevelAttribute(DateLevels.Weeks, expression, DateLevels.Weeks, 'ww yyyy',
|
|
186
|
-
this.Days = new DimensionalLevelAttribute(DateLevels.Days, expression, DateLevels.Days, 'yyyy-MM-dd',
|
|
187
|
-
this.Hours = new DimensionalLevelAttribute(DateLevels.Hours, expression, DateLevels.Hours, 'yyyy-MM-dd HH:mm',
|
|
183
|
+
this.Years = new DimensionalLevelAttribute(DateLevels.Years, expression, DateLevels.Years, 'yyyy', ...commonProps);
|
|
184
|
+
this.Quarters = new DimensionalLevelAttribute(DateLevels.Quarters, expression, DateLevels.Quarters, 'Q yyyy', ...commonProps);
|
|
185
|
+
this.Months = new DimensionalLevelAttribute(DateLevels.Months, expression, DateLevels.Months, 'yyyy-MM', ...commonProps);
|
|
186
|
+
this.Weeks = new DimensionalLevelAttribute(DateLevels.Weeks, expression, DateLevels.Weeks, 'ww yyyy', ...commonProps);
|
|
187
|
+
this.Days = new DimensionalLevelAttribute(DateLevels.Days, expression, DateLevels.Days, 'yyyy-MM-dd', ...commonProps);
|
|
188
|
+
this.Hours = new DimensionalLevelAttribute(DateLevels.Hours, expression, DateLevels.Hours, 'yyyy-MM-dd HH:mm', ...commonProps);
|
|
188
189
|
this.MinutesRoundTo30 = new DimensionalLevelAttribute(DateLevels.MinutesRoundTo30, expression, DateLevels.MinutesRoundTo30, 'yyyy-MM-dd HH:mm', desc, sort, dataSource);
|
|
189
|
-
this.MinutesRoundTo15 = new DimensionalLevelAttribute(DateLevels.MinutesRoundTo15, expression, DateLevels.MinutesRoundTo15, 'yyyy-MM-dd HH:mm',
|
|
190
|
-
this.Minutes = new DimensionalLevelAttribute(DateLevels.Minutes, expression, DateLevels.Minutes, 'yyyy-MM-dd HH:mm',
|
|
190
|
+
this.MinutesRoundTo15 = new DimensionalLevelAttribute(DateLevels.MinutesRoundTo15, expression, DateLevels.MinutesRoundTo15, 'yyyy-MM-dd HH:mm', ...commonProps);
|
|
191
|
+
this.Minutes = new DimensionalLevelAttribute(DateLevels.Minutes, expression, DateLevels.Minutes, 'yyyy-MM-dd HH:mm', ...commonProps);
|
|
191
192
|
this.Seconds = new DimensionalLevelAttribute(DateLevels.Seconds, expression, DateLevels.Seconds, 'yyyy-MM-dd HH:mm:ss', desc, sort, dataSource);
|
|
192
|
-
this.AggHours = new DimensionalLevelAttribute(DateLevels.AggHours, expression, DateLevels.AggHours, 'HH:mm',
|
|
193
|
+
this.AggHours = new DimensionalLevelAttribute(DateLevels.AggHours, expression, DateLevels.AggHours, 'HH:mm', ...commonProps);
|
|
193
194
|
this.AggMinutesRoundTo30 = new DimensionalLevelAttribute(DateLevels.AggMinutesRoundTo30, expression, DateLevels.AggMinutesRoundTo30, 'HH:mm', desc, sort, dataSource);
|
|
194
|
-
this.AggMinutesRoundTo15 = new DimensionalLevelAttribute(DateLevels.AggMinutesRoundTo15, expression, DateLevels.AggMinutesRoundTo15, 'HH:mm',
|
|
195
|
-
this.AggMinutesRoundTo1 = new DimensionalLevelAttribute(DateLevels.AggMinutesRoundTo1, expression, DateLevels.AggMinutesRoundTo1, 'HH:mm',
|
|
195
|
+
this.AggMinutesRoundTo15 = new DimensionalLevelAttribute(DateLevels.AggMinutesRoundTo15, expression, DateLevels.AggMinutesRoundTo15, 'HH:mm', ...commonProps);
|
|
196
|
+
this.AggMinutesRoundTo1 = new DimensionalLevelAttribute(DateLevels.AggMinutesRoundTo1, expression, DateLevels.AggMinutesRoundTo1, 'HH:mm', ...commonProps);
|
|
196
197
|
this.setAttributes([
|
|
197
198
|
this.Years,
|
|
198
199
|
this.Quarters,
|
|
@@ -237,7 +238,7 @@ export class DimensionalDateDimension extends DimensionalDimension {
|
|
|
237
238
|
* @returns An instance representing the sorted {@link Dimension} of this instance
|
|
238
239
|
*/
|
|
239
240
|
sort(sort) {
|
|
240
|
-
return new DimensionalDateDimension(this.name, this.expression, this.description, sort, this.dataSource, this.composeCode);
|
|
241
|
+
return new DimensionalDateDimension(this.name, this.expression, this.description, sort, this.dataSource, this.composeCode, this.indexed, this.merged);
|
|
241
242
|
}
|
|
242
243
|
/**
|
|
243
244
|
* Gets a serializable representation of the element
|
|
@@ -280,9 +281,11 @@ export function createDimension(json) {
|
|
|
280
281
|
const type = DimensionalDimension.parseType(json.dimtype || json.type);
|
|
281
282
|
const sort = json.sort;
|
|
282
283
|
const dataSource = json.dataSource;
|
|
284
|
+
const indexed = json.indexed;
|
|
285
|
+
const merged = json.merged;
|
|
283
286
|
// date dimension
|
|
284
287
|
if (type == MetadataTypes.DateDimension) {
|
|
285
|
-
return new DimensionalDateDimension(name, expression, description, sort, dataSource);
|
|
288
|
+
return new DimensionalDateDimension(name, expression, description, sort, dataSource, undefined, indexed, merged);
|
|
286
289
|
}
|
|
287
290
|
// attributes
|
|
288
291
|
const atts = Object.getOwnPropertyNames(json)
|
|
@@ -293,12 +296,12 @@ export function createDimension(json) {
|
|
|
293
296
|
let att;
|
|
294
297
|
for (let i = 0; i < json.attributes.length; i++) {
|
|
295
298
|
att = json.attributes[i];
|
|
296
|
-
atts.push(new DimensionalAttribute(att.name, att.expression, att.type, att.description, att.sort, att.dataSource));
|
|
299
|
+
atts.push(new DimensionalAttribute(att.name, att.expression, att.type, att.description, att.sort, att.dataSource, undefined, undefined, att.indexed, att.merged));
|
|
297
300
|
}
|
|
298
301
|
}
|
|
299
302
|
// default attribute
|
|
300
303
|
else if (expression) {
|
|
301
|
-
atts.push(new DimensionalAttribute(name, expression, type, description, sort, dataSource));
|
|
304
|
+
atts.push(new DimensionalAttribute(name, expression, type, description, sort, dataSource, undefined, undefined, indexed, merged));
|
|
302
305
|
}
|
|
303
306
|
}
|
|
304
307
|
// nested dimensions
|
|
@@ -333,5 +336,5 @@ export function createDateDimension(json) {
|
|
|
333
336
|
const description = json.desc || json.description;
|
|
334
337
|
const sort = json.sort;
|
|
335
338
|
const dataSource = json.dataSource;
|
|
336
|
-
return new DimensionalDateDimension(name, expression, description, sort, dataSource);
|
|
339
|
+
return new DimensionalDateDimension(name, expression, description, sort, dataSource, undefined, json.indexed, json.merged);
|
|
337
340
|
}
|
|
@@ -33,6 +33,8 @@ const createAttributeEntry = (field, dataSource) => {
|
|
|
33
33
|
expression: attributeId,
|
|
34
34
|
dataSource: dataSourceConfig,
|
|
35
35
|
description: field.description,
|
|
36
|
+
indexed: field.indexed,
|
|
37
|
+
merged: field.merged,
|
|
36
38
|
})
|
|
37
39
|
: createAttribute({
|
|
38
40
|
name: attributeName,
|
|
@@ -40,6 +42,8 @@ const createAttributeEntry = (field, dataSource) => {
|
|
|
40
42
|
expression: attributeId,
|
|
41
43
|
dataSource: dataSourceConfig,
|
|
42
44
|
description: field.description,
|
|
45
|
+
indexed: field.indexed,
|
|
46
|
+
merged: field.merged,
|
|
43
47
|
});
|
|
44
48
|
return {
|
|
45
49
|
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
|
*
|
|
@@ -563,6 +563,29 @@ export const thisQuarter = withComposeCodeForFilter((dimension, config) => dateR
|
|
|
563
563
|
*/
|
|
564
564
|
export const today = withComposeCodeForFilter((dimension, config) => dateRelativeTo(dimension.Days, 0, 1, undefined, config), 'today');
|
|
565
565
|
// MEASURE-RELATED FILTERS
|
|
566
|
+
/**
|
|
567
|
+
* Gets the attribute from a measure, resolving through nested CalculatedMeasures.
|
|
568
|
+
* @param measure - Measure to get the attribute from
|
|
569
|
+
* @returns Attribute from the first BaseMeasure found in the measure tree
|
|
570
|
+
*/
|
|
571
|
+
function getMeasureAttribute(measure) {
|
|
572
|
+
if ('attribute' in measure) {
|
|
573
|
+
return measure.attribute;
|
|
574
|
+
}
|
|
575
|
+
for (const contextMeasure of Object.values(measure.context)) {
|
|
576
|
+
if (typeof contextMeasure !== 'object' || contextMeasure === null) {
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
if ('attribute' in contextMeasure) {
|
|
580
|
+
return contextMeasure.attribute;
|
|
581
|
+
}
|
|
582
|
+
if ('context' in contextMeasure &&
|
|
583
|
+
typeof contextMeasure.context === 'object') {
|
|
584
|
+
return getMeasureAttribute(contextMeasure);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
throw new Error('Cannot determine attribute from measure');
|
|
588
|
+
}
|
|
566
589
|
/**
|
|
567
590
|
* Creates a filter on all measure values matching the provided criteria.
|
|
568
591
|
*
|
|
@@ -595,7 +618,7 @@ export function measureBase(attribute, measure, operatorA, valueA, operatorB, va
|
|
|
595
618
|
* @param config - Optional configuration for the filter
|
|
596
619
|
* @returns A filter instance
|
|
597
620
|
*/
|
|
598
|
-
export const measureEquals = withComposeCodeForFilter((measure, value, config) => measureBase(measure
|
|
621
|
+
export const measureEquals = withComposeCodeForFilter((measure, value, config) => measureBase(getMeasureAttribute(measure), measure, NumericOperators.Equals, value, undefined, undefined, config), 'measureEquals');
|
|
599
622
|
/**
|
|
600
623
|
* Creates a filter to isolate a measure value greater than to a given number.
|
|
601
624
|
*
|
|
@@ -613,7 +636,7 @@ export const measureEquals = withComposeCodeForFilter((measure, value, config) =
|
|
|
613
636
|
* @param config - Optional configuration for the filter
|
|
614
637
|
* @returns A filter instance
|
|
615
638
|
*/
|
|
616
|
-
export const measureGreaterThan = withComposeCodeForFilter((measure, value, config) => measureBase(measure
|
|
639
|
+
export const measureGreaterThan = withComposeCodeForFilter((measure, value, config) => measureBase(getMeasureAttribute(measure), measure, NumericOperators.FromNotEqual, value, undefined, undefined, config), 'measureGreaterThan');
|
|
617
640
|
/**
|
|
618
641
|
* Creates a filter to isolate a measure value greater than or equal to a given number.
|
|
619
642
|
*
|
|
@@ -631,7 +654,7 @@ export const measureGreaterThan = withComposeCodeForFilter((measure, value, conf
|
|
|
631
654
|
* @param config - Optional configuration for the filter
|
|
632
655
|
* @returns A filter instance
|
|
633
656
|
*/
|
|
634
|
-
export const measureGreaterThanOrEqual = withComposeCodeForFilter((measure, value, config) => measureBase(measure
|
|
657
|
+
export const measureGreaterThanOrEqual = withComposeCodeForFilter((measure, value, config) => measureBase(getMeasureAttribute(measure), measure, NumericOperators.From, value, undefined, undefined, config), 'measureGreaterThanOrEqual');
|
|
635
658
|
/**
|
|
636
659
|
* Creates a filter to isolate a measure value less than or equal to a given number.
|
|
637
660
|
*
|
|
@@ -649,7 +672,7 @@ export const measureGreaterThanOrEqual = withComposeCodeForFilter((measure, valu
|
|
|
649
672
|
* @param config - Optional configuration for the filter
|
|
650
673
|
* @returns A filter instance
|
|
651
674
|
*/
|
|
652
|
-
export const measureLessThanOrEqual = withComposeCodeForFilter((measure, value, config) => measureBase(measure
|
|
675
|
+
export const measureLessThanOrEqual = withComposeCodeForFilter((measure, value, config) => measureBase(getMeasureAttribute(measure), measure, NumericOperators.To, value, undefined, undefined, config), 'measureLessThanOrEqual');
|
|
653
676
|
/**
|
|
654
677
|
* Creates a filter to isolate a measure value less than a given number.
|
|
655
678
|
*
|
|
@@ -666,7 +689,7 @@ export const measureLessThanOrEqual = withComposeCodeForFilter((measure, value,
|
|
|
666
689
|
* @param config - Optional configuration for the filter
|
|
667
690
|
* @returns A filter instance
|
|
668
691
|
*/
|
|
669
|
-
export const measureLessThan = withComposeCodeForFilter((measure, value, config) => measureBase(measure
|
|
692
|
+
export const measureLessThan = withComposeCodeForFilter((measure, value, config) => measureBase(getMeasureAttribute(measure), measure, NumericOperators.ToNotEqual, value, undefined, undefined, config), 'measureLessThan');
|
|
670
693
|
/**
|
|
671
694
|
* Creates a filter to isolate a measure value between or equal to two given numbers.
|
|
672
695
|
*
|
|
@@ -686,7 +709,7 @@ export const measureLessThan = withComposeCodeForFilter((measure, value, config)
|
|
|
686
709
|
* @param config - Optional configuration for the filter
|
|
687
710
|
* @returns A filter instance
|
|
688
711
|
*/
|
|
689
|
-
export const measureBetween = withComposeCodeForFilter((measure, valueA, valueB, config) => measureBase(measure
|
|
712
|
+
export const measureBetween = withComposeCodeForFilter((measure, valueA, valueB, config) => measureBase(getMeasureAttribute(measure), measure, NumericOperators.From, valueA, NumericOperators.To, valueB, config), 'measureBetween');
|
|
690
713
|
/**
|
|
691
714
|
* Creates a filter to isolate a measure value between but not equal to two given numbers.
|
|
692
715
|
*
|
|
@@ -706,7 +729,7 @@ export const measureBetween = withComposeCodeForFilter((measure, valueA, valueB,
|
|
|
706
729
|
* @param config - Optional configuration for the filter
|
|
707
730
|
* @returns A filter instance
|
|
708
731
|
*/
|
|
709
|
-
export const measureBetweenNotEqual = withComposeCodeForFilter((measure, valueA, valueB, config) => measureBase(measure
|
|
732
|
+
export const measureBetweenNotEqual = withComposeCodeForFilter((measure, valueA, valueB, config) => measureBase(getMeasureAttribute(measure), measure, NumericOperators.FromNotEqual, valueA, NumericOperators.ToNotEqual, valueB, config), 'measureBetweenNotEqual');
|
|
710
733
|
// RANKING FILTERS
|
|
711
734
|
/**
|
|
712
735
|
* 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
|
*
|