@sisense/sdk-data 1.34.0 → 2.1.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 (68) hide show
  1. package/dist/cjs/dimensional-model/analytics/factory.d.ts +10 -10
  2. package/dist/cjs/dimensional-model/analytics/factory.js +15 -16
  3. package/dist/cjs/dimensional-model/attributes.d.ts +4 -4
  4. package/dist/cjs/dimensional-model/attributes.js +21 -7
  5. package/dist/cjs/dimensional-model/base.d.ts +3 -3
  6. package/dist/cjs/dimensional-model/base.js +7 -4
  7. package/dist/cjs/dimensional-model/compose-code-utils.d.ts +41 -0
  8. package/dist/cjs/dimensional-model/compose-code-utils.js +127 -0
  9. package/dist/cjs/dimensional-model/consts.d.ts +1 -0
  10. package/dist/cjs/dimensional-model/consts.js +4 -0
  11. package/dist/cjs/dimensional-model/dimensions/dimensions.d.ts +5 -5
  12. package/dist/cjs/dimensional-model/dimensions/dimensions.js +25 -16
  13. package/dist/cjs/dimensional-model/filters/factory.d.ts +41 -41
  14. package/dist/cjs/dimensional-model/filters/factory.js +53 -168
  15. package/dist/cjs/dimensional-model/filters/filter-relations.js +2 -5
  16. package/dist/cjs/dimensional-model/filters/filters.d.ts +39 -23
  17. package/dist/cjs/dimensional-model/filters/filters.js +102 -52
  18. package/dist/cjs/dimensional-model/filters/utils/attribute-measure-util.js +6 -14
  19. package/dist/cjs/dimensional-model/filters/utils/condition-filter-util.js +28 -26
  20. package/dist/cjs/dimensional-model/filters/utils/filter-from-jaql-util.js +9 -15
  21. package/dist/cjs/dimensional-model/filters/utils/types.d.ts +10 -0
  22. package/dist/cjs/dimensional-model/interfaces.d.ts +9 -7
  23. package/dist/cjs/dimensional-model/jaql-element.d.ts +13 -1
  24. package/dist/cjs/dimensional-model/jaql-element.js +53 -1
  25. package/dist/cjs/dimensional-model/measures/factory.d.ts +45 -52
  26. package/dist/cjs/dimensional-model/measures/factory.js +55 -184
  27. package/dist/cjs/dimensional-model/measures/measures.d.ts +9 -9
  28. package/dist/cjs/dimensional-model/measures/measures.js +31 -29
  29. package/dist/cjs/dimensional-model/types.d.ts +25 -2
  30. package/dist/cjs/utils.d.ts +26 -19
  31. package/dist/cjs/utils.js +85 -41
  32. package/dist/dimensional-model/analytics/factory.d.ts +10 -10
  33. package/dist/dimensional-model/analytics/factory.js +15 -14
  34. package/dist/dimensional-model/attributes.d.ts +4 -4
  35. package/dist/dimensional-model/attributes.js +21 -7
  36. package/dist/dimensional-model/base.d.ts +3 -3
  37. package/dist/dimensional-model/base.js +7 -4
  38. package/dist/dimensional-model/compose-code-utils.d.ts +41 -0
  39. package/dist/dimensional-model/compose-code-utils.js +119 -0
  40. package/dist/dimensional-model/consts.d.ts +1 -0
  41. package/dist/dimensional-model/consts.js +1 -0
  42. package/dist/dimensional-model/dimensions/dimensions.d.ts +5 -5
  43. package/dist/dimensional-model/dimensions/dimensions.js +26 -17
  44. package/dist/dimensional-model/filters/factory.d.ts +41 -41
  45. package/dist/dimensional-model/filters/factory.js +51 -125
  46. package/dist/dimensional-model/filters/filter-relations.js +3 -6
  47. package/dist/dimensional-model/filters/filters.d.ts +39 -23
  48. package/dist/dimensional-model/filters/filters.js +102 -52
  49. package/dist/dimensional-model/filters/utils/attribute-measure-util.js +6 -14
  50. package/dist/dimensional-model/filters/utils/condition-filter-util.js +28 -26
  51. package/dist/dimensional-model/filters/utils/filter-from-jaql-util.js +9 -15
  52. package/dist/dimensional-model/filters/utils/types.d.ts +10 -0
  53. package/dist/dimensional-model/interfaces.d.ts +9 -7
  54. package/dist/dimensional-model/jaql-element.d.ts +13 -1
  55. package/dist/dimensional-model/jaql-element.js +52 -1
  56. package/dist/dimensional-model/measures/factory.d.ts +45 -52
  57. package/dist/dimensional-model/measures/factory.js +54 -141
  58. package/dist/dimensional-model/measures/measures.d.ts +9 -9
  59. package/dist/dimensional-model/measures/measures.js +31 -29
  60. package/dist/dimensional-model/types.d.ts +25 -2
  61. package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -1
  62. package/dist/utils.d.ts +26 -19
  63. package/dist/utils.js +63 -44
  64. package/package.json +3 -3
  65. package/dist/cjs/dimensional-model/filters/utils/filter-code-util.d.ts +0 -17
  66. package/dist/cjs/dimensional-model/filters/utils/filter-code-util.js +0 -82
  67. package/dist/dimensional-model/filters/utils/filter-code-util.d.ts +0 -17
  68. package/dist/dimensional-model/filters/utils/filter-code-util.js +0 -77
@@ -41,13 +41,12 @@ const m = __importStar(require("./factory.js"));
41
41
  * @internal
42
42
  */
43
43
  class AbstractMeasure extends base_js_1.DimensionalElement {
44
- constructor(name, type, format, desc, sort, composeCode) {
45
- super(name, type, desc);
44
+ constructor(name, type, format, desc, sort, dataSource, composeCode) {
45
+ super(name, type, desc, dataSource, composeCode);
46
46
  this._sort = types_js_1.Sort.None;
47
47
  this._format = '#,#.00';
48
48
  this._format = format;
49
49
  this._sort = sort || types_js_1.Sort.None;
50
- this.composeCode = composeCode;
51
50
  }
52
51
  /**
53
52
  * Gets the sort definition of this instance
@@ -68,8 +67,8 @@ class AbstractMeasure extends base_js_1.DimensionalElement {
68
67
  /**
69
68
  * Gets a serializable representation of the element
70
69
  */
71
- serializable() {
72
- const result = super.serializable();
70
+ serialize() {
71
+ const result = super.serialize();
73
72
  if (this.getFormat() !== undefined) {
74
73
  result.format = this.getFormat();
75
74
  }
@@ -86,8 +85,8 @@ exports.AbstractMeasure = AbstractMeasure;
86
85
  * @internal
87
86
  */
88
87
  class DimensionalBaseMeasure extends AbstractMeasure {
89
- constructor(name, attribute, agg, format, desc, sort, composeCode) {
90
- super(name, types_js_1.MetadataTypes.BaseMeasure, format, desc, sort, composeCode);
88
+ constructor(name, attribute, agg, format, desc, sort, dataSource, composeCode) {
89
+ super(name, types_js_1.MetadataTypes.BaseMeasure, format, desc, sort, dataSource, composeCode);
91
90
  this.attribute = attribute;
92
91
  this.aggregation = agg;
93
92
  }
@@ -144,7 +143,7 @@ class DimensionalBaseMeasure extends AbstractMeasure {
144
143
  * @returns An instance representing the sorted {@link Measure} of this instance
145
144
  */
146
145
  sort(sort) {
147
- return new DimensionalBaseMeasure(this.name, this.attribute, this.aggregation, this._format, this.description, sort, this.composeCode);
146
+ return new DimensionalBaseMeasure(this.name, this.attribute, this.aggregation, this._format, this.description, sort, this.dataSource, this.composeCode);
148
147
  }
149
148
  /**
150
149
  * Gets a formatted {@link Measure} with the given definition
@@ -155,7 +154,7 @@ class DimensionalBaseMeasure extends AbstractMeasure {
155
154
  * @returns An instance representing the formatted {@link Measure} of this instance
156
155
  */
157
156
  format(format) {
158
- return new DimensionalBaseMeasure(this.name, this.attribute, this.aggregation, format, this.description, this._sort, this.composeCode);
157
+ return new DimensionalBaseMeasure(this.name, this.attribute, this.aggregation, format, this.description, this._sort, this.dataSource, this.composeCode);
159
158
  }
160
159
  /**
161
160
  * gets the element's ID
@@ -166,10 +165,11 @@ class DimensionalBaseMeasure extends AbstractMeasure {
166
165
  /**
167
166
  * Gets a serializable representation of the element
168
167
  */
169
- serializable() {
170
- const result = super.serializable();
168
+ serialize() {
169
+ const result = super.serialize();
170
+ result.__serializable = 'DimensionalBaseMeasure';
171
171
  result.aggregation = this.aggregation;
172
- result.attribute = this.attribute.serializable();
172
+ result.attribute = this.attribute.serialize();
173
173
  return result;
174
174
  }
175
175
  jaql(nested) {
@@ -194,8 +194,8 @@ exports.DimensionalBaseMeasure = DimensionalBaseMeasure;
194
194
  * @internal
195
195
  */
196
196
  class DimensionalCalculatedMeasure extends AbstractMeasure {
197
- constructor(name, expression, context, format, desc, sort, composeCode) {
198
- super(name, types_js_1.MetadataTypes.CalculatedMeasure, format, desc, sort, composeCode);
197
+ constructor(name, expression, context, format, desc, sort, dataSource, composeCode) {
198
+ super(name, types_js_1.MetadataTypes.CalculatedMeasure, format, desc, sort, dataSource, composeCode);
199
199
  this.expression = expression;
200
200
  this.context = context;
201
201
  }
@@ -206,7 +206,7 @@ class DimensionalCalculatedMeasure extends AbstractMeasure {
206
206
  * @returns An instance representing the sorted {@link Measure} of this instance
207
207
  */
208
208
  sort(sort) {
209
- return new DimensionalCalculatedMeasure(this.name, this.expression, this.context, this._format, this.description, sort, this.composeCode);
209
+ return new DimensionalCalculatedMeasure(this.name, this.expression, this.context, this._format, this.description, sort, this.dataSource, this.composeCode);
210
210
  }
211
211
  /**
212
212
  * Gets a formatted {@link Measure} with the given definition
@@ -217,7 +217,7 @@ class DimensionalCalculatedMeasure extends AbstractMeasure {
217
217
  * @returns An instance representing the formatted {@link Measure} of this instance
218
218
  */
219
219
  format(format) {
220
- return new DimensionalCalculatedMeasure(this.name, this.expression, this.context, format, this.description, this._sort, this.composeCode);
220
+ return new DimensionalCalculatedMeasure(this.name, this.expression, this.context, format, this.description, this._sort, this.dataSource, this.composeCode);
221
221
  }
222
222
  /**
223
223
  * gets the element's ID
@@ -228,13 +228,14 @@ class DimensionalCalculatedMeasure extends AbstractMeasure {
228
228
  /**
229
229
  * Gets a serializable representation of the element
230
230
  */
231
- serializable() {
232
- const result = super.serializable();
231
+ serialize() {
232
+ const result = super.serialize();
233
+ result.__serializable = 'DimensionalCalculatedMeasure';
233
234
  result.expression = this.expression;
234
- result.context = {};
235
- Object.getOwnPropertyNames(this.context).forEach((p) => {
236
- result.context[p] = this.context[p].serializable();
237
- });
235
+ result.context = Object.fromEntries(Object.entries(this.context).map(([key, value]) => [
236
+ key,
237
+ value.serialize ? value.serialize(value) : value,
238
+ ]));
238
239
  return result;
239
240
  }
240
241
  jaql(nested) {
@@ -264,8 +265,8 @@ exports.DimensionalCalculatedMeasure = DimensionalCalculatedMeasure;
264
265
  * @internal
265
266
  */
266
267
  class DimensionalMeasureTemplate extends AbstractMeasure {
267
- constructor(name, attribute, format, desc, sort) {
268
- super(name, types_js_1.MetadataTypes.MeasureTemplate, format, desc, sort);
268
+ constructor(name, attribute, format, desc, sort, dataSource, composeCode) {
269
+ super(name, types_js_1.MetadataTypes.MeasureTemplate, format, desc, sort, dataSource, composeCode);
269
270
  this.attribute = attribute;
270
271
  }
271
272
  /**
@@ -277,9 +278,10 @@ class DimensionalMeasureTemplate extends AbstractMeasure {
277
278
  /**
278
279
  * Gets a serializable representation of the element
279
280
  */
280
- serializable() {
281
- const result = super.serializable();
282
- result.attribute = this.attribute.serializable();
281
+ serialize() {
282
+ const result = super.serialize();
283
+ result.__serializable = 'DimensionalMeasureTemplate';
284
+ result.attribute = this.attribute.serialize();
283
285
  return result;
284
286
  }
285
287
  /**
@@ -289,7 +291,7 @@ class DimensionalMeasureTemplate extends AbstractMeasure {
289
291
  * @returns An instance representing the sorted {@link MeasureTemplate} of this instance
290
292
  */
291
293
  sort(sort) {
292
- return new DimensionalMeasureTemplate(this.name, this.attribute, this._format, this.description, sort);
294
+ return new DimensionalMeasureTemplate(this.name, this.attribute, this._format, this.description, sort, this.dataSource, this.composeCode);
293
295
  }
294
296
  /**
295
297
  * Gets a formatted {@link Measure} with the given definition
@@ -298,7 +300,7 @@ class DimensionalMeasureTemplate extends AbstractMeasure {
298
300
  * @returns An instance representing the formatted {@link Measure} of this instance
299
301
  */
300
302
  format(format) {
301
- return new DimensionalMeasureTemplate(this.name, this.attribute, format, this.description, this._sort);
303
+ return new DimensionalMeasureTemplate(this.name, this.attribute, format, this.description, this._sort, this.dataSource, this.composeCode);
302
304
  }
303
305
  /**
304
306
  * Gets the JAQL representation of this instance
@@ -1,9 +1,9 @@
1
- import { type ConditionFilterJaql, JaqlDataSource } from './filters/utils/types.js';
1
+ import type { ConditionFilterJaql, JaqlDataSource, JaqlDataSourceForDto } from './filters/utils/types.js';
2
2
  import { Attribute } from './interfaces.js';
3
3
  /**
4
4
  * @internal
5
5
  */
6
- export type { JaqlDataSource };
6
+ export type { JaqlDataSource, JaqlDataSourceForDto };
7
7
  /**
8
8
  * Different aggregation types
9
9
  */
@@ -212,6 +212,7 @@ export declare type FormulaJaql = {
212
212
  title: string;
213
213
  formula: string;
214
214
  context?: Record<FormulaID, FormulaContext>;
215
+ datasource?: JaqlDataSource;
215
216
  };
216
217
  /** @internal */
217
218
  export declare type BaseFilterJaql = IncludeAllFilterJaql | IncludeMembersFilterJaql | ExcludeMembersFilterJaql | NumericFilterJaql | ConditionFilterJaql | AndFilterJaql<NumericFilterJaql | ConditionFilterJaql> | OrFilterJaql<NumericFilterJaql | ConditionFilterJaql>;
@@ -271,6 +272,27 @@ export declare type OrFilterJaql<FilterItem> = {
271
272
  * Abstract object with any unknown values
272
273
  */
273
274
  export declare type AnyObject = Record<string, any>;
275
+ /**
276
+ * JSON Value
277
+ *
278
+ * @internal
279
+ */
280
+ export declare type JSONValue = string | number | boolean | undefined | null | JSONArray | JSONObject;
281
+ /**
282
+ * JSON Array
283
+ *
284
+ * @internal
285
+ */
286
+ export interface JSONArray extends Array<JSONValue> {
287
+ }
288
+ /**
289
+ * JSON Object
290
+ *
291
+ * @internal
292
+ */
293
+ export interface JSONObject {
294
+ [key: string]: JSONValue;
295
+ }
274
296
  /**
275
297
  * @internal
276
298
  */
@@ -395,6 +417,7 @@ export declare type MetadataItemJaql = {
395
417
  sortingLastDimension?: boolean;
396
418
  initialized?: boolean;
397
419
  };
420
+ datasource?: JaqlDataSource;
398
421
  };
399
422
  /**
400
423
  * @internal
@@ -1,4 +1,4 @@
1
- import { FilterJaqlInternal, JaqlDataSource, RankingFilterJaql } from './dimensional-model/filters/utils/types.js';
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
3
  import { BaseJaql, FilterJaql, FormulaJaql, Jaql, JaqlSortDirection, Sort } from './dimensional-model/types.js';
4
4
  import { DataSource, DataSourceInfo } from './interfaces.js';
@@ -41,6 +41,12 @@ export declare function convertDataSource(jaqlDataSource: JaqlDataSource): DataS
41
41
  * @internal
42
42
  */
43
43
  export declare function convertJaqlDataSource(dataSource: DataSource): JaqlDataSource;
44
+ /**
45
+ * Converts a DataSource to JaqlDataSourceForDto.
46
+ *
47
+ * @internal
48
+ */
49
+ export declare function convertJaqlDataSourceForDto(dataSource: DataSource): JaqlDataSourceForDto;
44
50
  /**
45
51
  * Converts a string to a Sort enum
46
52
  *
@@ -68,6 +74,15 @@ export declare function convertSortDirectionToSort(sortDirection: SortDirection)
68
74
  * @internal
69
75
  */
70
76
  export declare const createFilterFromJaql: (jaql: FilterJaql, instanceid?: string, disabled?: boolean, locked?: boolean) => Filter;
77
+ /**
78
+ * Extracts the table and column names from the given expression string.
79
+ *
80
+ * @internal
81
+ */
82
+ export declare function parseExpression(expression: string): {
83
+ table: string;
84
+ column: string;
85
+ };
71
86
  /**
72
87
  * Retrieves the table value from the attribute.
73
88
  *
@@ -94,21 +109,17 @@ export declare function getSortType(jaqlSort: `${JaqlSortDirection}` | undefined
94
109
  * @returns attribute or level attribute
95
110
  * @internal
96
111
  */
97
- export declare const createAttributeHelper: ({ dim, table, column, dataType, granularity, format, sort, title, panel, dataSource, }: {
112
+ export declare const createAttributeHelper: ({ expression, dataType, granularity, format, sort, title, panel, dataSource, }: {
98
113
  /** Dimension expression */
99
- dim: string;
100
- /** Table name */
101
- table: string | undefined;
102
- /** Column name */
103
- column: string | undefined;
114
+ expression: string;
104
115
  /** Data type */
105
116
  dataType: string;
106
117
  /** Date granularity */
107
- granularity: string | undefined;
118
+ granularity?: string | undefined;
108
119
  /** Format */
109
- format: string | undefined;
120
+ format?: string | undefined;
110
121
  /** Sort */
111
- sort: string | undefined;
122
+ sort?: string | undefined;
112
123
  /** Attribute title */
113
124
  title?: string | undefined;
114
125
  /** Panel */
@@ -122,23 +133,19 @@ export declare const createAttributeHelper: ({ dim, table, column, dataType, gra
122
133
  * @returns measure
123
134
  * @internal
124
135
  */
125
- export declare const createMeasureHelper: ({ dim, table, column, dataType, agg, granularity, format, sort, title, dataSource, }: {
136
+ export declare const createMeasureHelper: ({ expression, dataType, agg, granularity, format, sort, title, dataSource, }: {
126
137
  /** Dimension expression */
127
- dim: string;
128
- /** Table name */
129
- table: string | undefined;
130
- /** Column name */
131
- column: string;
138
+ expression: string;
132
139
  /** Data type */
133
140
  dataType: string;
134
141
  /** Aggregation function */
135
142
  agg: string;
136
143
  /** Date granularity */
137
- granularity: string | undefined;
144
+ granularity?: string | undefined;
138
145
  /** Format */
139
- format: string | undefined;
146
+ format?: string | undefined;
140
147
  /** Sort */
141
- sort: string | undefined;
148
+ sort?: string | undefined;
142
149
  /** Measure title */
143
150
  title?: string | undefined;
144
151
  /** Jaql data source */
package/dist/cjs/utils.js CHANGED
@@ -1,15 +1,38 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getGranularityFromJaql = exports.createDimensionalElementFromJaql = exports.createCalculatedMeasureHelper = exports.createMeasureHelper = exports.createAttributeHelper = exports.getSortType = exports.getColumnNameFromAttribute = exports.getTableNameFromAttribute = exports.createFilterFromJaql = exports.convertSortDirectionToSort = exports.convertSort = exports.convertJaqlDataSource = exports.convertDataSource = exports.isDataSourceInfo = exports.getDataSourceName = exports.getFilterListAndRelationsJaql = exports.guidFast = void 0;
7
- const sdk_common_1 = require("@sisense/sdk-common");
29
+ exports.getGranularityFromJaql = exports.createDimensionalElementFromJaql = exports.createCalculatedMeasureHelper = exports.createMeasureHelper = exports.createAttributeHelper = exports.getSortType = exports.getColumnNameFromAttribute = exports.getTableNameFromAttribute = exports.parseExpression = exports.createFilterFromJaql = exports.convertSortDirectionToSort = exports.convertSort = exports.convertJaqlDataSourceForDto = exports.convertJaqlDataSource = exports.convertDataSource = exports.isDataSourceInfo = exports.getDataSourceName = exports.getFilterListAndRelationsJaql = exports.guidFast = void 0;
8
30
  const cloneDeep_js_1 = __importDefault(require("lodash-es/cloneDeep.js"));
9
31
  const mapValues_js_1 = __importDefault(require("lodash-es/mapValues.js"));
10
32
  const attributes_js_1 = require("./dimensional-model/attributes.js");
11
33
  const filters_js_1 = require("./dimensional-model/filters/filters.js");
12
34
  const filter_from_jaql_util_js_1 = require("./dimensional-model/filters/utils/filter-from-jaql-util.js");
35
+ const measureFactory = __importStar(require("./dimensional-model/measures/factory.js"));
13
36
  const measures_js_1 = require("./dimensional-model/measures/measures.js");
14
37
  const simple_column_types_js_1 = require("./dimensional-model/simple-column-types.js");
15
38
  const types_js_1 = require("./dimensional-model/types.js");
@@ -81,6 +104,9 @@ const getFilterListAndRelationsJaql = (filterRelations) => {
81
104
  if ('right' in node) {
82
105
  node.right = traverse(node.right);
83
106
  }
107
+ if ('composeCode' in node) {
108
+ delete node.composeCode;
109
+ }
84
110
  return node;
85
111
  }
86
112
  }
@@ -142,6 +168,29 @@ function convertJaqlDataSource(dataSource) {
142
168
  };
143
169
  }
144
170
  exports.convertJaqlDataSource = convertJaqlDataSource;
171
+ /**
172
+ * Converts a DataSource to JaqlDataSourceForDto.
173
+ *
174
+ * @internal
175
+ */
176
+ function convertJaqlDataSourceForDto(dataSource) {
177
+ var _a;
178
+ if (isDataSourceInfo(dataSource)) {
179
+ return {
180
+ title: dataSource.title,
181
+ live: dataSource.type === 'live',
182
+ id: (_a = dataSource.id) !== null && _a !== void 0 ? _a : '',
183
+ address: dataSource.address,
184
+ };
185
+ }
186
+ else {
187
+ return {
188
+ title: dataSource,
189
+ id: '',
190
+ };
191
+ }
192
+ }
193
+ exports.convertJaqlDataSourceForDto = convertJaqlDataSourceForDto;
145
194
  /**
146
195
  * Converts a string to a Sort enum
147
196
  *
@@ -219,6 +268,7 @@ function parseExpression(expression) {
219
268
  : '',
220
269
  };
221
270
  }
271
+ exports.parseExpression = parseExpression;
222
272
  /**
223
273
  * Retrieves the table value from the attribute.
224
274
  *
@@ -255,29 +305,23 @@ function getSortType(jaqlSort) {
255
305
  }
256
306
  }
257
307
  exports.getSortType = getSortType;
258
- const DATA_MODEL_MODULE_NAME = 'DM';
259
308
  /**
260
309
  * Creates an attribute or level attribute from the provided parameters
261
310
  *
262
311
  * @returns attribute or level attribute
263
312
  * @internal
264
313
  */
265
- const createAttributeHelper = ({ dim, table, column, dataType, granularity, format, sort, title, panel, dataSource, }) => {
266
- // if table is undefined, extract it from dim
267
- const dimTable = table !== null && table !== void 0 ? table : parseExpression(dim).table;
268
- // if column is undefined, extract it from dim
269
- const dimColumn = column !== null && column !== void 0 ? column : parseExpression(dim).column;
314
+ const createAttributeHelper = ({ expression, dataType, granularity, format, sort, title, panel, dataSource, }) => {
315
+ const column = parseExpression(expression).column;
270
316
  const sortEnum = convertSort(sort);
271
317
  const isDataTypeDatetime = dataType === types_js_1.DataType.DATETIME;
272
318
  if (isDataTypeDatetime) {
273
- const composeCode = (0, attributes_js_1.normalizeAttributeName)(dimTable, dimColumn, granularity, DATA_MODEL_MODULE_NAME);
274
- const levelAttribute = new attributes_js_1.DimensionalLevelAttribute(title !== null && title !== void 0 ? title : dimColumn, dim, granularity || types_js_1.DateLevels.Years, format ||
275
- attributes_js_1.DimensionalLevelAttribute.getDefaultFormatForGranularity(granularity || types_js_1.DateLevels.Years), undefined, sortEnum, dataSource, composeCode, panel);
319
+ const levelAttribute = new attributes_js_1.DimensionalLevelAttribute(title !== null && title !== void 0 ? title : column, expression, granularity || types_js_1.DateLevels.Years, format ||
320
+ attributes_js_1.DimensionalLevelAttribute.getDefaultFormatForGranularity(granularity || types_js_1.DateLevels.Years), undefined, sortEnum, dataSource, undefined, panel);
276
321
  return levelAttribute;
277
322
  }
278
323
  const attributeType = !dataType || (0, simple_column_types_js_1.isNumber)(dataType) ? types_js_1.MetadataTypes.NumericAttribute : types_js_1.MetadataTypes.TextAttribute;
279
- const composeCode = (0, attributes_js_1.normalizeAttributeName)(dimTable, dimColumn, undefined, DATA_MODEL_MODULE_NAME);
280
- const attribute = new attributes_js_1.DimensionalAttribute(title !== null && title !== void 0 ? title : dimColumn, dim, attributeType, undefined, sortEnum, dataSource, composeCode, panel);
324
+ const attribute = new attributes_js_1.DimensionalAttribute(title !== null && title !== void 0 ? title : column, expression, attributeType, undefined, sortEnum, dataSource, undefined, panel);
281
325
  return attribute;
282
326
  };
283
327
  exports.createAttributeHelper = createAttributeHelper;
@@ -287,12 +331,9 @@ exports.createAttributeHelper = createAttributeHelper;
287
331
  * @returns measure
288
332
  * @internal
289
333
  */
290
- const createMeasureHelper = ({ dim, table, column, dataType, agg, granularity, format, sort, title, dataSource, }) => {
291
- const sortEnum = convertSort(sort);
334
+ const createMeasureHelper = ({ expression, dataType, agg, granularity, format, sort, title, dataSource, }) => {
292
335
  const attribute = (0, exports.createAttributeHelper)({
293
- dim,
294
- table,
295
- column,
336
+ expression,
296
337
  dataType,
297
338
  granularity,
298
339
  format,
@@ -301,23 +342,32 @@ const createMeasureHelper = ({ dim, table, column, dataType, agg, granularity, f
301
342
  dataSource,
302
343
  });
303
344
  const tranformedAgg = measures_js_1.DimensionalBaseMeasure.aggregationFromJAQL(agg);
345
+ const column = parseExpression(expression).column;
304
346
  const updatedTitle = title !== null && title !== void 0 ? title : `${tranformedAgg} ${column}`;
305
- // currently, sort and format applied to attribute but not to measure
306
- const composeCode = `measureFactory.${tranformedAgg}(${attribute.composeCode}, '${(0, sdk_common_1.escapeSingleQuotes)(updatedTitle)}')`;
307
- const measure = new measures_js_1.DimensionalBaseMeasure(updatedTitle, attribute, tranformedAgg, undefined, undefined, sortEnum, composeCode);
308
- return measure;
347
+ switch (tranformedAgg) {
348
+ case types_js_1.AggregationTypes.Sum:
349
+ return measureFactory.sum(attribute, updatedTitle, format);
350
+ case types_js_1.AggregationTypes.Average:
351
+ return measureFactory.avg(attribute, updatedTitle, format);
352
+ case types_js_1.AggregationTypes.Min:
353
+ return measureFactory.min(attribute, updatedTitle, format);
354
+ case types_js_1.AggregationTypes.Max:
355
+ return measureFactory.max(attribute, updatedTitle, format);
356
+ case types_js_1.AggregationTypes.Count:
357
+ return measureFactory.count(attribute, updatedTitle, format);
358
+ case types_js_1.AggregationTypes.CountDistinct:
359
+ return measureFactory.countDistinct(attribute, updatedTitle, format);
360
+ case types_js_1.AggregationTypes.Median:
361
+ return measureFactory.median(attribute, updatedTitle, format);
362
+ case types_js_1.AggregationTypes.Variance:
363
+ return measureFactory.aggregate(attribute, types_js_1.AggregationTypes.Variance, updatedTitle, format);
364
+ case types_js_1.AggregationTypes.StandardDeviation:
365
+ return measureFactory.aggregate(attribute, types_js_1.AggregationTypes.StandardDeviation, updatedTitle, format);
366
+ default:
367
+ return measureFactory.sum(attribute, updatedTitle, format);
368
+ }
309
369
  };
310
370
  exports.createMeasureHelper = createMeasureHelper;
311
- const getContextComposeCode = (context) => {
312
- return ('{' +
313
- Object.entries(context).reduce((acc, [key, value]) => {
314
- acc =
315
- acc +
316
- `'${key.slice(1, -1)}': ${value && 'composeCode' in value ? value.composeCode : JSON.stringify(value)},`;
317
- return acc;
318
- }, '') +
319
- '}');
320
- };
321
371
  /**
322
372
  * Creates a measure from the provided parameters
323
373
  *
@@ -326,15 +376,13 @@ const getContextComposeCode = (context) => {
326
376
  */
327
377
  const createCalculatedMeasureHelper = (jaql) => {
328
378
  var _a;
329
- const sortEnum = convertSort(jaql.sort);
330
379
  const context = (0, mapValues_js_1.default)((_a = jaql.context) !== null && _a !== void 0 ? _a : {}, (jaqlContextValue) => {
331
380
  if (typeof jaqlContextValue === 'string') {
332
381
  return jaqlContextValue;
333
382
  }
334
383
  return jaqlContextValue && createDimensionalElementFromJaql(jaqlContextValue);
335
384
  });
336
- const composeCode = `measureFactory.customFormula('${(0, sdk_common_1.escapeSingleQuotes)(jaql.title)}', '${jaql.formula}', ${getContextComposeCode(context)})`;
337
- return new measures_js_1.DimensionalCalculatedMeasure(jaql.title, jaql.formula, context, undefined, undefined, sortEnum, composeCode);
385
+ return measureFactory.customFormula(jaql.title, jaql.formula, context);
338
386
  };
339
387
  exports.createCalculatedMeasureHelper = createCalculatedMeasureHelper;
340
388
  /**
@@ -358,9 +406,7 @@ function createDimensionalElementFromJaql(jaql, datetimeFormat, panel) {
358
406
  const hasAggregation = !!jaql.agg;
359
407
  if (hasAggregation) {
360
408
  return (0, exports.createMeasureHelper)({
361
- dim: jaql.dim,
362
- table: jaql.table,
363
- column: jaql.column,
409
+ expression: jaql.dim,
364
410
  dataType: jaql.datatype,
365
411
  agg: jaql.agg || '',
366
412
  granularity: getGranularityFromJaql(jaql),
@@ -371,9 +417,7 @@ function createDimensionalElementFromJaql(jaql, datetimeFormat, panel) {
371
417
  });
372
418
  }
373
419
  return (0, exports.createAttributeHelper)({
374
- dim: jaql.dim,
375
- table: jaql.table,
376
- column: jaql.column,
420
+ expression: jaql.dim,
377
421
  dataType: jaql.datatype,
378
422
  granularity: getGranularityFromJaql(jaql),
379
423
  format: datetimeFormat,
@@ -13,35 +13,35 @@ export declare const BOX_WHISKER: {
13
13
  /**
14
14
  * Returns an array of values for box whisker plot using interquartile range (IQR) calculations.
15
15
  *
16
- * @param {Attribute} target - The target attribute for calculations.
17
- * @returns {Measure[]} An array of measures representing IQR values for box whisker plots.
16
+ * @param target - The target attribute for calculations.
17
+ * @returns An array of measures representing IQR values for box whisker plots.
18
18
  */
19
19
  export declare function boxWhiskerIqrValues(target: Attribute): Measure[];
20
20
  /**
21
21
  * Returns an array of extremum values for box whisker plot.
22
22
  *
23
- * @param {Attribute} target - The target attribute for calculations.
24
- * @returns {Measure[]} An array of measures representing extremum values for box whisker plots.
23
+ * @param target - The target attribute for calculations.
24
+ * @returns An array of measures representing extremum values for box whisker plots.
25
25
  */
26
26
  export declare function boxWhiskerExtremumsValues(target: Attribute): Measure[];
27
27
  /**
28
28
  * Returns an array of values for box whisker plot using standard deviation calculations.
29
29
  *
30
- * @param {Attribute} target - The target attribute for calculations.
31
- * @returns {Measure[]} An array of measures representing standard deviation values for box whisker plots.
30
+ * @param target - The target attribute for calculations.
31
+ * @returns An array of measures representing standard deviation values for box whisker plots.
32
32
  */
33
33
  export declare function boxWhiskerStdDevValues(target: Attribute): Measure[];
34
34
  /**
35
35
  * Returns an attribute representing outlier points based on interquartile range (IQR) calculations.
36
36
  *
37
- * @param {Attribute} target - The target attribute for calculations.
38
- * @returns {Attribute} An attribute representing outliers for box whisker plots using IQR.
37
+ * @param target - The target attribute for calculations.
38
+ * @returns An attribute representing outliers for box whisker plots using IQR.
39
39
  */
40
40
  export declare const boxWhiskerIqrOutliers: (target: Attribute) => Attribute;
41
41
  /**
42
42
  * Returns an attribute representing outlier points based on standard deviation calculations.
43
43
  *
44
- * @param {Attribute} target - The target attribute for calculations.
45
- * @returns {Attribute} An attribute representing outliers for box whisker plots using standard deviation.
44
+ * @param target - The target attribute for calculations.
45
+ * @returns An attribute representing outliers for box whisker plots using standard deviation.
46
46
  */
47
47
  export declare const boxWhiskerStdDevOutliers: (target: Attribute) => Attribute;
@@ -1,4 +1,5 @@
1
1
  import cloneDeep from 'lodash-es/cloneDeep.js';
2
+ import { withComposeCodeForAnalytics } from '../compose-code-utils.js';
2
3
  import { customFormula } from '../measures/factory.js';
3
4
  /** @internal */
4
5
  export const BOX_WHISKER = {
@@ -27,8 +28,8 @@ function boxWhiskerCommonValues(target) {
27
28
  /**
28
29
  * Returns an array of values for box whisker plot using interquartile range (IQR) calculations.
29
30
  *
30
- * @param {Attribute} target - The target attribute for calculations.
31
- * @returns {Measure[]} An array of measures representing IQR values for box whisker plots.
31
+ * @param target - The target attribute for calculations.
32
+ * @returns An array of measures representing IQR values for box whisker plots.
32
33
  */
33
34
  export function boxWhiskerIqrValues(target) {
34
35
  return [
@@ -47,8 +48,8 @@ export function boxWhiskerIqrValues(target) {
47
48
  /**
48
49
  * Returns an array of extremum values for box whisker plot.
49
50
  *
50
- * @param {Attribute} target - The target attribute for calculations.
51
- * @returns {Measure[]} An array of measures representing extremum values for box whisker plots.
51
+ * @param target - The target attribute for calculations.
52
+ * @returns An array of measures representing extremum values for box whisker plots.
52
53
  */
53
54
  export function boxWhiskerExtremumsValues(target) {
54
55
  return [
@@ -64,8 +65,8 @@ export function boxWhiskerExtremumsValues(target) {
64
65
  /**
65
66
  * Returns an array of values for box whisker plot using standard deviation calculations.
66
67
  *
67
- * @param {Attribute} target - The target attribute for calculations.
68
- * @returns {Measure[]} An array of measures representing standard deviation values for box whisker plots.
68
+ * @param target - The target attribute for calculations.
69
+ * @returns An array of measures representing standard deviation values for box whisker plots.
69
70
  */
70
71
  export function boxWhiskerStdDevValues(target) {
71
72
  return [
@@ -84,10 +85,10 @@ export function boxWhiskerStdDevValues(target) {
84
85
  /**
85
86
  * Returns an attribute representing outlier points based on interquartile range (IQR) calculations.
86
87
  *
87
- * @param {Attribute} target - The target attribute for calculations.
88
- * @returns {Attribute} An attribute representing outliers for box whisker plots using IQR.
88
+ * @param target - The target attribute for calculations.
89
+ * @returns An attribute representing outliers for box whisker plots using IQR.
89
90
  */
90
- export const boxWhiskerIqrOutliers = (target) => {
91
+ export const boxWhiskerIqrOutliers = withComposeCodeForAnalytics((target) => {
91
92
  const outliersAttrWithInnerFilter = cloneDeep(target);
92
93
  const outliersMax = customFormula(BOX_WHISKER.OUTLIER_MAX_VALUE_NAME, '(UPPERWHISKERMIN_IQR([Attr]), all([Attr]))', {
93
94
  Attr: target,
@@ -110,14 +111,14 @@ export const boxWhiskerIqrOutliers = (target) => {
110
111
  return nested ? jaql : { jaql };
111
112
  };
112
113
  return outliersAttrWithInnerFilter;
113
- };
114
+ }, 'boxWhiskerIqrOutliers');
114
115
  /**
115
116
  * Returns an attribute representing outlier points based on standard deviation calculations.
116
117
  *
117
- * @param {Attribute} target - The target attribute for calculations.
118
- * @returns {Attribute} An attribute representing outliers for box whisker plots using standard deviation.
118
+ * @param target - The target attribute for calculations.
119
+ * @returns An attribute representing outliers for box whisker plots using standard deviation.
119
120
  */
120
- export const boxWhiskerStdDevOutliers = (target) => {
121
+ export const boxWhiskerStdDevOutliers = withComposeCodeForAnalytics((target) => {
121
122
  const outliersAttrWithInnerFilter = cloneDeep(target);
122
123
  const outliersMax = customFormula(BOX_WHISKER.OUTLIER_MAX_VALUE_NAME, '(UPPERWHISKERMIN_STDEVP([Attr]), all([Attr]))', {
123
124
  Attr: target,
@@ -139,4 +140,4 @@ export const boxWhiskerStdDevOutliers = (target) => {
139
140
  return nested ? jaql : { jaql };
140
141
  };
141
142
  return outliersAttrWithInnerFilter;
142
- };
143
+ }, 'boxWhiskerStdDevOutliers');