@sisense/sdk-data 1.28.0 → 1.30.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.
Files changed (54) hide show
  1. package/dist/cjs/dimensional-model/attributes.d.ts +2 -2
  2. package/dist/cjs/dimensional-model/attributes.js +7 -7
  3. package/dist/cjs/dimensional-model/base.d.ts +7 -1
  4. package/dist/cjs/dimensional-model/base.js +2 -1
  5. package/dist/cjs/dimensional-model/filters/filter-config-utils.d.ts +4 -0
  6. package/dist/cjs/dimensional-model/filters/filter-config-utils.js +5 -2
  7. package/dist/cjs/dimensional-model/filters/filter-relations.d.ts +187 -0
  8. package/dist/cjs/dimensional-model/filters/filter-relations.js +537 -0
  9. package/dist/cjs/dimensional-model/filters/helpers.d.ts +112 -0
  10. package/dist/cjs/dimensional-model/filters/helpers.js +178 -0
  11. package/dist/cjs/dimensional-model/filters/index.d.ts +2 -0
  12. package/dist/cjs/dimensional-model/filters/index.js +18 -0
  13. package/dist/cjs/dimensional-model/filters/utils/attribute-measure-util.d.ts +1 -35
  14. package/dist/cjs/dimensional-model/filters/utils/attribute-measure-util.js +37 -101
  15. package/dist/cjs/dimensional-model/interfaces.d.ts +9 -0
  16. package/dist/cjs/dimensional-model/interfaces.js +0 -1
  17. package/dist/cjs/dimensional-model/measures/factory.js +1 -32
  18. package/dist/cjs/dimensional-model/measures/measures.d.ts +3 -3
  19. package/dist/cjs/dimensional-model/measures/measures.js +10 -9
  20. package/dist/cjs/index.d.ts +1 -1
  21. package/dist/cjs/index.js +1 -1
  22. package/dist/cjs/interfaces.d.ts +2 -2
  23. package/dist/cjs/utils.d.ts +74 -2
  24. package/dist/cjs/utils.js +138 -3
  25. package/dist/dimensional-model/attributes.d.ts +2 -2
  26. package/dist/dimensional-model/attributes.js +7 -7
  27. package/dist/dimensional-model/base.d.ts +7 -1
  28. package/dist/dimensional-model/base.js +2 -1
  29. package/dist/dimensional-model/filters/filter-config-utils.d.ts +4 -0
  30. package/dist/dimensional-model/filters/filter-config-utils.js +5 -2
  31. package/dist/dimensional-model/filters/filter-relations.d.ts +187 -0
  32. package/dist/dimensional-model/filters/filter-relations.js +509 -0
  33. package/dist/dimensional-model/filters/helpers.d.ts +112 -0
  34. package/dist/dimensional-model/filters/helpers.js +169 -0
  35. package/dist/dimensional-model/filters/index.d.ts +2 -0
  36. package/dist/dimensional-model/filters/index.js +2 -0
  37. package/dist/dimensional-model/filters/utils/attribute-measure-util.d.ts +1 -35
  38. package/dist/dimensional-model/filters/utils/attribute-measure-util.js +36 -74
  39. package/dist/dimensional-model/interfaces.d.ts +9 -0
  40. package/dist/dimensional-model/interfaces.js +0 -1
  41. package/dist/dimensional-model/measures/factory.js +2 -30
  42. package/dist/dimensional-model/measures/measures.d.ts +3 -3
  43. package/dist/dimensional-model/measures/measures.js +10 -9
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/interfaces.d.ts +2 -2
  47. package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -1
  48. package/dist/utils.d.ts +74 -2
  49. package/dist/utils.js +133 -2
  50. package/package.json +4 -3
  51. package/dist/cjs/dimensional-model/filter-relations.d.ts +0 -9
  52. package/dist/cjs/dimensional-model/filter-relations.js +0 -18
  53. package/dist/dimensional-model/filter-relations.d.ts +0 -9
  54. package/dist/dimensional-model/filter-relations.js +0 -14
@@ -0,0 +1,169 @@
1
+ import { splitFiltersAndRelations, calculateNewRelations, combineFiltersAndRelations, getRelationsWithReplacedFilter, getFiltersArray, } from './filter-relations.js';
2
+ import { isFilterRelations } from '../../index.js';
3
+ /**
4
+ * Returns a function that adds a filter to existing filters or filter relations.
5
+ *
6
+ * @param filter - The filter to add.
7
+ * @returns A function that takes existing filters or filter relations and returns updated filters or filter relations with the new filter added.
8
+ * @group Filter Utilities
9
+ * @example
10
+ * ```ts
11
+ * // Using with an array of filters
12
+ * const originalFilters = [filterByAgeRange];
13
+ * const updatedFilters = withAddedFilter(filterByCost)(originalFilters);
14
+ * // [filterByAgeRange, filterByCost]
15
+ *
16
+ * // Using with filter relations
17
+ * const originalFilterRelations = filterFactory.logic.or(filterByAgeRange, filterByRevenue);
18
+ * const updatedFilterRelations = withAddedFilter(filterByCost)(originalFilterRelations);
19
+ * // (filterByAgeRange OR filterByRevenue) AND filterByCost
20
+ * ```
21
+ */
22
+ export function withAddedFilter(filter) {
23
+ return (filters) => {
24
+ if (isFilterRelations(filters)) {
25
+ const { filters: existingFilters, relations } = splitFiltersAndRelations(filters);
26
+ const newFilters = [...existingFilters, filter];
27
+ const newRelations = calculateNewRelations(existingFilters, relations, newFilters);
28
+ return combineFiltersAndRelations(newFilters, newRelations);
29
+ }
30
+ return [...(filters || []), filter];
31
+ };
32
+ }
33
+ /**
34
+ * Returns a function that adds multiple filters to existing filters or filter relations.
35
+ *
36
+ * @param filtersToAdd - An array of filters to add.
37
+ * @returns A function that takes existing filters or filter relations and returns updated filters or filter relations with the new filters added.
38
+ * @group Filter Utilities
39
+ * @example
40
+ * ```ts
41
+ * // Using with an array of filters
42
+ * const originalFilters = [filterByAgeRange];
43
+ * const updatedFilters = withAddedFilters([filterByCost, filterByRevenue])(originalFilters);
44
+ * // [filterByAgeRange, filterByCost, filterByRevenue]
45
+ *
46
+ * // Using with filter relations
47
+ * const originalFilterRelations = filterFactory.logic.or(filterByAgeRange, filterByRevenue);
48
+ * const updatedFilterRelations = withAddedFilters([filterByCost, filterByRevenue])(originalFilterRelations);
49
+ * // (filterByAgeRange OR filterByRevenue) AND filterByCost AND filterByRevenue
50
+ * ```
51
+ */
52
+ export function withAddedFilters(filtersToAdd) {
53
+ return (filters) => {
54
+ if (isFilterRelations(filters)) {
55
+ const { filters: existingFilters, relations } = splitFiltersAndRelations(filters);
56
+ const newFilters = [...existingFilters, ...filtersToAdd];
57
+ const newRelations = calculateNewRelations(existingFilters, relations, newFilters);
58
+ return combineFiltersAndRelations(newFilters, newRelations);
59
+ }
60
+ return [...(filters || []), ...filtersToAdd];
61
+ };
62
+ }
63
+ /**
64
+ * Returns a function that removes a filter from existing filters or filter relations.
65
+ *
66
+ * @param filterToRemove - The filter to remove.
67
+ * @returns A function that takes existing filters or filter relations and returns updated filters or filter relations without the specified filter.
68
+ * @group Filter Utilities
69
+ * @example
70
+ * ```ts
71
+ * // Using with an array of filters
72
+ * const originalFilters = [filterByAgeRange, filterByRevenue, filterByCost];
73
+ * const updatedFilters = withoutFilter(filterByCost)(originalFilters);
74
+ * // [filterByAgeRange, filterByRevenue]
75
+ *
76
+ * // Using with filter relations
77
+ * const originalFilterRelations = filterFactory.logic.or(filterByAgeRange, filterByRevenue);
78
+ * const updatedFiltersRelations = withoutFilter(filterByRevenue)(originalFilterRelations);
79
+ * // filterByAgeRange
80
+ * ```
81
+ */
82
+ export function withoutFilter(filterToRemove) {
83
+ return (filters) => {
84
+ if (isFilterRelations(filters)) {
85
+ const { filters: existingFilters, relations } = splitFiltersAndRelations(filters);
86
+ const newFilters = existingFilters.filter((filter) => filter.config.guid !== filterToRemove.config.guid);
87
+ const newRelations = calculateNewRelations(existingFilters, relations, newFilters);
88
+ return combineFiltersAndRelations(newFilters, newRelations);
89
+ }
90
+ return (filters || []).filter((filter) => filter.config.guid !== filterToRemove.config.guid);
91
+ };
92
+ }
93
+ /**
94
+ * Returns a function that removes multiple filters from existing filters or filter relations.
95
+ *
96
+ * @param filtersToRemove - An array of filters to remove.
97
+ * @returns A function that takes existing filters or filter relations and returns updated filters or filter relations without the specified filters.
98
+ * @group Filter Utilities
99
+ * @example
100
+ * ```ts
101
+ * // Using with an array of filters
102
+ * const originalFilters = [filterByAgeRange, filterByRevenue, filterByCost];
103
+ * const updatedFilters = withRemovedFilters([filterByRevenue, filterByCost])(originalFilters);
104
+ * // [filterByAgeRange]
105
+ *
106
+ * // Using with filter relations
107
+ * const originalFilterRelations = filterFactory.logic.or(filterByAgeRange, filterByRevenue);
108
+ * const updatedFiltersRelations = withRemovedFilters([filterByRevenue])(originalFilterRelations);
109
+ * // filterByAgeRange
110
+ * ```
111
+ */
112
+ export function withoutFilters(filtersToRemove) {
113
+ return (filters) => {
114
+ if (isFilterRelations(filters)) {
115
+ const { filters: existingFilters, relations } = splitFiltersAndRelations(filters);
116
+ const newFilters = existingFilters.filter((filter) => !filtersToRemove.some((filterToRemove) => filter.config.guid === filterToRemove.config.guid));
117
+ const newRelations = calculateNewRelations(existingFilters, relations, newFilters);
118
+ return combineFiltersAndRelations(newFilters, newRelations);
119
+ }
120
+ return (filters || []).filter((filter) => !filtersToRemove.some((filterToRemove) => filter.config.guid === filterToRemove.config.guid));
121
+ };
122
+ }
123
+ /**
124
+ * Returns a function that replaces a filter with a new filter in existing filters or filter relations.
125
+ *
126
+ * @param filterToReplace - The filter to replace.
127
+ * @param newFilter - The new filter to use as a replacement.
128
+ * @returns A function that takes existing filters or filter relations and returns updated filters or filter relations with the filter replaced.
129
+ * @group Filter Utilities
130
+ * @example
131
+ * ```ts
132
+ * // Using with an array of filters
133
+ * const originalFilters = [filterByAgeRange, filterByRevenue];
134
+ * const updatedFilters = withReplacedFilter(filterByRevenue, filterByCost)(originalFilters);
135
+ * // [filterByAgeRange, filterByCost]
136
+ *
137
+ * // Using with filter relations
138
+ * const originalFilterRelations = filterFactory.logic.or(filterByAgeRange, filterByRevenue);
139
+ * const updatedFilterRelations = withReplacedFilter(filterByRevenue, filterByCost)(originalFilterRelations);
140
+ * // (filterByAgeRange OR filterByCost)
141
+ * ```
142
+ */
143
+ export function withReplacedFilter(filterToReplace, newFilter) {
144
+ return (filters) => {
145
+ if (isFilterRelations(filters)) {
146
+ const { filters: existingFilters, relations } = splitFiltersAndRelations(filters);
147
+ const newFilters = existingFilters.map((filter) => filter.config.guid === filterToReplace.config.guid ? newFilter : filter);
148
+ const newRelations = getRelationsWithReplacedFilter(relations, filterToReplace, newFilter);
149
+ return combineFiltersAndRelations(newFilters, newRelations);
150
+ }
151
+ return (filters || []).map((filter) => filter.config.guid === filterToReplace.config.guid ? newFilter : filter);
152
+ };
153
+ }
154
+ /**
155
+ * Finds a filter in an array of filters or filter relations.
156
+ * Returns the first filter that satisfies the provided search function.
157
+ * @group Filter Utilities
158
+ * @param filters - An array of filters or filter relations to search.
159
+ * @param searchFn - A function that takes a filter and returns a boolean indicating whether the filter satisfies the search criteria.
160
+ * @returns The first filter that satisfies the search function, or `undefined` if no filter is found.
161
+ *
162
+ */
163
+ export function findFilter(filters, searchFn) {
164
+ if (!filters) {
165
+ return undefined;
166
+ }
167
+ const filtersArray = isFilterRelations(filters) ? getFiltersArray(filters) : filters;
168
+ return filtersArray.find(searchFn);
169
+ }
@@ -0,0 +1,2 @@
1
+ export * from './filter-relations.js';
2
+ export * from './helpers.js';
@@ -0,0 +1,2 @@
1
+ export * from './filter-relations.js';
2
+ export * from './helpers.js';
@@ -1,19 +1,6 @@
1
1
  import { Attribute, BaseMeasure, CalculatedMeasure, LevelAttribute } from '../../interfaces.js';
2
2
  import { FilterJaql } from '../../types.js';
3
- import { CustomFormulaJaql, FilterJaqlInternal, JaqlDataSource, RankingFilterJaql } from './types.js';
4
- /**
5
- * Creates an attribute or level attribute from the provided parameters
6
- *
7
- * @param dim - Dimension expression
8
- * @param table - Table name
9
- * @param column - Column name
10
- * @param level - Date level
11
- * @param dataType - Data type
12
- * @param title - Attribute title
13
- * @param dataSource - Jaql data source
14
- * @returns attribute or level attribute
15
- */
16
- export declare const createAttributeHelper: (dim: string, table: string | undefined, column: string | undefined, level: string | undefined, dataType: string, title?: string, dataSource?: JaqlDataSource) => Attribute | LevelAttribute;
3
+ import { CustomFormulaJaql, FilterJaqlInternal, RankingFilterJaql } from './types.js';
17
4
  /**
18
5
  * Creates an attribute or level attribute from the provided filter JAQL object
19
6
  *
@@ -21,27 +8,6 @@ export declare const createAttributeHelper: (dim: string, table: string | undefi
21
8
  * @returns attribute or level attribute
22
9
  */
23
10
  export declare const createAttributeFromFilterJaql: (jaql: FilterJaql | FilterJaqlInternal) => Attribute | LevelAttribute;
24
- /**
25
- * Creates a measure from the provided parameters
26
- *
27
- * @param dim - Dimension expression
28
- * @param table - Table name
29
- * @param column - Column name
30
- * @param level - Date level
31
- * @param dataType - Data type
32
- * @param agg - Aggregation function
33
- * @param title - Measure title
34
- * @param dataSource - data source provided in JAQL
35
- * @returns measure
36
- */
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;
45
11
  /**
46
12
  * Creates a measure from the provided filter JAQL object
47
13
  *
@@ -1,41 +1,4 @@
1
- import { DimensionalAttribute, DimensionalLevelAttribute, normalizeAttributeName, } from '../../attributes.js';
2
- import { isNumber } from '../../simple-column-types.js';
3
- import { MetadataTypes } from '../../types.js';
4
- import * as measureFactory from '../../measures/factory.js';
5
- import { transformCustomFormulaJaql } from '../../measures/factory.js';
6
- import { DimensionalBaseMeasure } from '../../measures/measures.js';
7
- const DATA_MODEL_MODULE_NAME = 'DM';
8
- /**
9
- * Creates an attribute or level attribute from the provided parameters
10
- *
11
- * @param dim - Dimension expression
12
- * @param table - Table name
13
- * @param column - Column name
14
- * @param level - Date level
15
- * @param dataType - Data type
16
- * @param title - Attribute title
17
- * @param dataSource - Jaql data source
18
- * @returns attribute or level attribute
19
- */
20
- export const createAttributeHelper = (dim, table, column, level, dataType, title, dataSource) => {
21
- // if table is undefined, extract it from dim
22
- const dimTable = table !== null && table !== void 0 ? table : dim.slice(1, -1).split('.')[0];
23
- // if column is undefined, extract it from dim
24
- const dimColumn = column !== null && column !== void 0 ? column : dim.slice(1, -1).split('.')[1];
25
- if (level) {
26
- const dateLevel = DimensionalLevelAttribute.translateJaqlToGranularity({ level });
27
- const format = DimensionalLevelAttribute.getDefaultFormatForGranularity(dateLevel);
28
- const levelAttribute = new DimensionalLevelAttribute(title !== null && title !== void 0 ? title : dimColumn, dim, dateLevel, format, undefined, undefined, dataSource);
29
- levelAttribute.composeCode = normalizeAttributeName(dimTable, dimColumn, level, DATA_MODEL_MODULE_NAME);
30
- return levelAttribute;
31
- }
32
- const attributeType = isNumber(dataType)
33
- ? MetadataTypes.NumericAttribute
34
- : MetadataTypes.TextAttribute;
35
- const attribute = new DimensionalAttribute(title !== null && title !== void 0 ? title : dimColumn, dim, attributeType, undefined, undefined, dataSource);
36
- attribute.composeCode = normalizeAttributeName(dimTable, dimColumn, undefined, DATA_MODEL_MODULE_NAME);
37
- return attribute;
38
- };
1
+ import { createAttributeHelper, createCalculatedMeasureHelper, createMeasureHelper, } from '../../../utils.js';
39
2
  /**
40
3
  * Creates an attribute or level attribute from the provided filter JAQL object
41
4
  *
@@ -44,39 +7,17 @@ export const createAttributeHelper = (dim, table, column, level, dataType, title
44
7
  */
45
8
  export const createAttributeFromFilterJaql = (jaql) => {
46
9
  const { dim, table, column, level, datatype, title, datasource: dataSource } = jaql;
47
- return createAttributeHelper(dim, table, column, level, datatype, title, dataSource);
48
- };
49
- /**
50
- * Creates a measure from the provided parameters
51
- *
52
- * @param dim - Dimension expression
53
- * @param table - Table name
54
- * @param column - Column name
55
- * @param level - Date level
56
- * @param dataType - Data type
57
- * @param agg - Aggregation function
58
- * @param title - Measure title
59
- * @param dataSource - data source provided in JAQL
60
- * @returns measure
61
- */
62
- export const createMeasureHelper = (dim, table, column, level, dataType, agg, title, dataSource) => {
63
- const attribute = createAttributeHelper(dim, table, column, level, dataType, title, dataSource);
64
- const measure = measureFactory.aggregate(attribute, agg, title);
65
- measure.composeCode = `measureFactory.${agg}(${attribute.composeCode})`;
66
- return measure;
67
- };
68
- /**
69
- * Creates a calculated measure from the provided filter JAQL object
70
- *
71
- * @param jaql - custom formula jaql
72
- * @returns calculated measure
73
- */
74
- export const createCalculatedMeasureFromJaql = (jaql) => {
75
- const measure = transformCustomFormulaJaql(jaql);
76
- // TBD (SNS-108945)
77
- // Handle preparation of 'composeCode' for formula
78
- measure.composeCode = `'Formula code to be implemented'`;
79
- return measure;
10
+ return createAttributeHelper({
11
+ dim,
12
+ table,
13
+ column,
14
+ dataType: datatype,
15
+ level,
16
+ format: undefined,
17
+ sort: undefined,
18
+ title,
19
+ dataSource,
20
+ });
80
21
  };
81
22
  /**
82
23
  * Creates a measure from the provided filter JAQL object
@@ -88,7 +29,18 @@ export const createMeasureFromFilterJaql = (jaql) => {
88
29
  const { dim, table, column, title, level, datatype: dataType, agg, datasource: dataSource, } = jaql;
89
30
  if (!agg)
90
31
  return undefined;
91
- return createMeasureHelper(dim, table, column, level, dataType, DimensionalBaseMeasure.aggregationFromJAQL(agg), title, dataSource);
32
+ return createMeasureHelper({
33
+ dim,
34
+ table,
35
+ column,
36
+ dataType,
37
+ agg,
38
+ level,
39
+ format: undefined,
40
+ sort: undefined,
41
+ title,
42
+ dataSource,
43
+ });
92
44
  };
93
45
  /**
94
46
  * Creates a measure from the provided ranking filter JAQL object
@@ -98,7 +50,17 @@ export const createMeasureFromFilterJaql = (jaql) => {
98
50
  */
99
51
  export const createMeasureFromRankingFilterJaql = (jaql, rankingMessage) => {
100
52
  if ('formula' in jaql)
101
- return createCalculatedMeasureFromJaql(jaql);
53
+ return createCalculatedMeasureHelper(jaql);
102
54
  const { dim, table, column, level, datatype: dataType, agg } = jaql;
103
- return createMeasureHelper(dim, table, column, level, dataType, DimensionalBaseMeasure.aggregationFromJAQL(agg), rankingMessage);
55
+ return createMeasureHelper({
56
+ dim,
57
+ table,
58
+ column,
59
+ level,
60
+ dataType,
61
+ agg,
62
+ format: undefined,
63
+ sort: undefined,
64
+ title: rankingMessage,
65
+ });
104
66
  };
@@ -438,6 +438,7 @@ export declare type FilterConfig = CompleteBaseFilterConfig | CompleteMembersFil
438
438
  export interface Filter extends Element {
439
439
  /**
440
440
  * Attribute this filter instance is filtering
441
+ *
441
442
  * @internal
442
443
  */
443
444
  readonly attribute: Attribute;
@@ -448,6 +449,7 @@ export interface Filter extends Element {
448
449
  /**
449
450
  * Boolean flag whether the filter is a scope filter
450
451
  * which is on a dimension that isn’t used in the query
452
+ *
451
453
  * @internal
452
454
  */
453
455
  isScope: boolean;
@@ -496,6 +498,10 @@ export interface PivotMeasure {
496
498
  * @internal
497
499
  */
498
500
  dataBars?: boolean;
501
+ /**
502
+ * @internal
503
+ */
504
+ shouldRequestMinMax?: boolean;
499
505
  }
500
506
  /**
501
507
  * Runs type guard check for PivotMeasure.
@@ -508,6 +514,9 @@ export declare function isPivotMeasure(arg: Measure | PivotMeasure): arg is Pivo
508
514
  * Data options for grand totals of a pivot table
509
515
  */
510
516
  export declare type PivotGrandTotals = {
517
+ /**
518
+ * @deprecated
519
+ */
511
520
  title?: string;
512
521
  rows?: boolean;
513
522
  columns?: boolean;
@@ -20,7 +20,6 @@ export function isPivotMeasure(arg) {
20
20
  * @internal
21
21
  */
22
22
  export const DEFAULT_PIVOT_GRAND_TOTALS = {
23
- title: 'Grand Total',
24
23
  rows: false,
25
24
  columns: false,
26
25
  };
@@ -1,10 +1,7 @@
1
1
  import { DimensionalBaseMeasure, DimensionalCalculatedMeasure } from './measures.js';
2
2
  import { AggregationTypes, MetadataTypes } from '../types.js';
3
3
  import { normalizeName } from '../base.js';
4
- import mapValues from 'lodash-es/mapValues.js';
5
- import { DimensionalAttribute, DimensionalLevelAttribute } from '../attributes.js';
6
- import { isDatetime, isNumber } from './../simple-column-types.js';
7
- import { convertSort, createFilterFromJaql } from '../../utils.js';
4
+ import { createCalculatedMeasureHelper } from '../../utils.js';
8
5
  import { TranslatableError } from '../../translation/translatable-error.js';
9
6
  /**
10
7
  * Defines the different numeric operators that can be used with numeric filters
@@ -75,28 +72,6 @@ function measureFunction(measure, name, func, options) {
75
72
  builder.push(')');
76
73
  return new DimensionalCalculatedMeasure(name, builder.join(''), context);
77
74
  }
78
- function transformFormulaJaqlHelper(jaql) {
79
- const isFormulaJaql = 'formula' in jaql;
80
- if (isFormulaJaql) {
81
- return transformCustomFormulaJaql(jaql);
82
- }
83
- const sort = convertSort(jaql.sort);
84
- const hasAggregation = !!jaql.agg;
85
- const isDatatypeDatetime = isDatetime(jaql.datatype);
86
- const attributeType = isNumber(jaql.datatype)
87
- ? MetadataTypes.NumericAttribute
88
- : MetadataTypes.TextAttribute;
89
- const attribute = isDatatypeDatetime
90
- ? new DimensionalLevelAttribute(jaql.title, jaql.dim, DimensionalLevelAttribute.translateJaqlToGranularity(jaql), undefined, undefined, sort)
91
- : new DimensionalAttribute(jaql.title, jaql.dim, attributeType, undefined, sort);
92
- if (hasAggregation) {
93
- return new DimensionalBaseMeasure(jaql.title, attribute, DimensionalBaseMeasure.aggregationFromJAQL(jaql.agg || ''), undefined, undefined, sort);
94
- }
95
- if ('filter' in jaql) {
96
- return createFilterFromJaql(jaql);
97
- }
98
- return attribute;
99
- }
100
75
  /**
101
76
  * Transforms a custom formula jaql into a calculated measure instance.
102
77
  *
@@ -107,14 +82,11 @@ function transformFormulaJaqlHelper(jaql) {
107
82
  * @internal
108
83
  */
109
84
  export function transformCustomFormulaJaql(jaql) {
110
- var _a;
111
85
  const isFormulaJaql = 'formula' in jaql;
112
86
  if (!isFormulaJaql) {
113
87
  throw new TranslatableError('errors.measure.notAFormula');
114
88
  }
115
- const sort = convertSort(jaql.sort);
116
- const context = mapValues((_a = jaql.context) !== null && _a !== void 0 ? _a : {}, (jaqlContextValue) => jaqlContextValue ? transformFormulaJaqlHelper(jaqlContextValue) : {});
117
- return new DimensionalCalculatedMeasure(jaql.title, jaql.formula, context, undefined, undefined, sort);
89
+ return createCalculatedMeasureHelper(jaql);
118
90
  }
119
91
  /**
120
92
  * Creates a calculated measure for a valid custom formula built from [base functions](/guides/sdk/reference/functions.html#measured-value-functions).
@@ -7,7 +7,7 @@ import { DimensionalElement } from '../base.js';
7
7
  export declare abstract class AbstractMeasure extends DimensionalElement {
8
8
  protected _sort: Sort;
9
9
  protected _format: string | undefined;
10
- constructor(name: string, type: string, format?: string, desc?: string, sort?: Sort);
10
+ constructor(name: string, type: string, format?: string, desc?: string, sort?: Sort, composeCode?: string);
11
11
  /**
12
12
  * gets the element's ID
13
13
  */
@@ -51,7 +51,7 @@ export declare abstract class AbstractMeasure extends DimensionalElement {
51
51
  export declare class DimensionalBaseMeasure extends AbstractMeasure implements BaseMeasure {
52
52
  static aggregationFromJAQL(agg: string): string;
53
53
  static aggregationToJAQL(agg: string): string;
54
- constructor(name: string, attribute: Attribute, agg: string, format?: string, desc?: string, sort?: Sort);
54
+ constructor(name: string, attribute: Attribute, agg: string, format?: string, desc?: string, sort?: Sort, composeCode?: string);
55
55
  /**
56
56
  * Aggregating attribute
57
57
  */
@@ -93,7 +93,7 @@ export declare class DimensionalBaseMeasure extends AbstractMeasure implements B
93
93
  * @internal
94
94
  */
95
95
  export declare class DimensionalCalculatedMeasure extends AbstractMeasure implements CalculatedMeasure {
96
- constructor(name: string, expression: string, context: MeasureContext, format?: string, desc?: string, sort?: Sort);
96
+ constructor(name: string, expression: string, context: MeasureContext, format?: string, desc?: string, sort?: Sort, composeCode?: string);
97
97
  /**
98
98
  * Defines the Calculated measure's expression
99
99
  */
@@ -15,12 +15,13 @@ import { TranslatableError } from '../../translation/translatable-error.js';
15
15
  * @internal
16
16
  */
17
17
  export class AbstractMeasure extends DimensionalElement {
18
- constructor(name, type, format, desc, sort) {
18
+ constructor(name, type, format, desc, sort, composeCode) {
19
19
  super(name, type, desc);
20
20
  this._sort = Sort.None;
21
21
  this._format = '#,#.00';
22
22
  this._format = format;
23
23
  this._sort = sort || Sort.None;
24
+ this.composeCode = composeCode;
24
25
  }
25
26
  /**
26
27
  * Gets the sort definition of this instance
@@ -58,8 +59,8 @@ export class AbstractMeasure extends DimensionalElement {
58
59
  * @internal
59
60
  */
60
61
  export class DimensionalBaseMeasure extends AbstractMeasure {
61
- constructor(name, attribute, agg, format, desc, sort) {
62
- super(name, MetadataTypes.BaseMeasure, format, desc, sort);
62
+ constructor(name, attribute, agg, format, desc, sort, composeCode) {
63
+ super(name, MetadataTypes.BaseMeasure, format, desc, sort, composeCode);
63
64
  this.attribute = attribute;
64
65
  this.aggregation = agg;
65
66
  }
@@ -116,7 +117,7 @@ export class DimensionalBaseMeasure extends AbstractMeasure {
116
117
  * @returns An instance representing the sorted {@link Measure} of this instance
117
118
  */
118
119
  sort(sort) {
119
- return new DimensionalBaseMeasure(this.name, this.attribute, this.aggregation, this._format, this.description, sort);
120
+ return new DimensionalBaseMeasure(this.name, this.attribute, this.aggregation, this._format, this.description, sort, this.composeCode);
120
121
  }
121
122
  /**
122
123
  * Gets a formatted {@link Measure} with the given definition
@@ -127,7 +128,7 @@ export class DimensionalBaseMeasure extends AbstractMeasure {
127
128
  * @returns An instance representing the formatted {@link Measure} of this instance
128
129
  */
129
130
  format(format) {
130
- return new DimensionalBaseMeasure(this.name, this.attribute, this.aggregation, format, this.description, this._sort);
131
+ return new DimensionalBaseMeasure(this.name, this.attribute, this.aggregation, format, this.description, this._sort, this.composeCode);
131
132
  }
132
133
  /**
133
134
  * gets the element's ID
@@ -165,8 +166,8 @@ export class DimensionalBaseMeasure extends AbstractMeasure {
165
166
  * @internal
166
167
  */
167
168
  export class DimensionalCalculatedMeasure extends AbstractMeasure {
168
- constructor(name, expression, context, format, desc, sort) {
169
- super(name, MetadataTypes.CalculatedMeasure, format, desc, sort);
169
+ constructor(name, expression, context, format, desc, sort, composeCode) {
170
+ super(name, MetadataTypes.CalculatedMeasure, format, desc, sort, composeCode);
170
171
  this.expression = expression;
171
172
  this.context = context;
172
173
  }
@@ -177,7 +178,7 @@ export class DimensionalCalculatedMeasure extends AbstractMeasure {
177
178
  * @returns An instance representing the sorted {@link Measure} of this instance
178
179
  */
179
180
  sort(sort) {
180
- return new DimensionalCalculatedMeasure(this.name, this.expression, this.context, this._format, this.description, sort);
181
+ return new DimensionalCalculatedMeasure(this.name, this.expression, this.context, this._format, this.description, sort, this.composeCode);
181
182
  }
182
183
  /**
183
184
  * Gets a formatted {@link Measure} with the given definition
@@ -188,7 +189,7 @@ export class DimensionalCalculatedMeasure extends AbstractMeasure {
188
189
  * @returns An instance representing the formatted {@link Measure} of this instance
189
190
  */
190
191
  format(format) {
191
- return new DimensionalCalculatedMeasure(this.name, this.expression, this.context, format, this.description, this._sort);
192
+ return new DimensionalCalculatedMeasure(this.name, this.expression, this.context, format, this.description, this._sort, this.composeCode);
192
193
  }
193
194
  /**
194
195
  * gets the element's ID
package/dist/index.d.ts CHANGED
@@ -86,7 +86,6 @@ export * from './dimensional-model/measures/measures.js';
86
86
  */
87
87
  export * as measureFactory from './dimensional-model/measures/factory.js';
88
88
  export * from './dimensional-model/simple-column-types.js';
89
- export * from './dimensional-model/filter-relations.js';
90
89
  /**
91
90
  * Functions to create elements for advanced analytics – for example, attributes and measures for constructing a custom Boxplot chart
92
91
  *
@@ -94,4 +93,5 @@ export * from './dimensional-model/filter-relations.js';
94
93
  */
95
94
  export * as analyticsFactory from './dimensional-model/analytics/factory.js';
96
95
  export * from './utils.js';
96
+ export * from './dimensional-model/filters/index.js';
97
97
  export { type TranslationDictionary, PACKAGE_NAMESPACE as translationNamespace, } from './translation/resources/index.js';
package/dist/index.js CHANGED
@@ -86,7 +86,6 @@ export * from './dimensional-model/measures/measures.js';
86
86
  */
87
87
  export * as measureFactory from './dimensional-model/measures/factory.js';
88
88
  export * from './dimensional-model/simple-column-types.js';
89
- export * from './dimensional-model/filter-relations.js';
90
89
  /**
91
90
  * Functions to create elements for advanced analytics – for example, attributes and measures for constructing a custom Boxplot chart
92
91
  *
@@ -94,4 +93,5 @@ export * from './dimensional-model/filter-relations.js';
94
93
  */
95
94
  export * as analyticsFactory from './dimensional-model/analytics/factory.js';
96
95
  export * from './utils.js';
96
+ export * from './dimensional-model/filters/index.js';
97
97
  export { PACKAGE_NAMESPACE as translationNamespace, } from './translation/resources/index.js';
@@ -134,11 +134,11 @@ export interface CalculatedMeasureColumn {
134
134
  export declare type DataSourceInfo = {
135
135
  /**
136
136
  * @internal
137
- **/
137
+ */
138
138
  id?: string;
139
139
  /**
140
140
  * @internal
141
- **/
141
+ */
142
142
  address?: string;
143
143
  title: string;
144
144
  type: 'live' | 'elasticube';