@sisense/sdk-data 1.33.0 → 2.0.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 (97) 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 +13 -6
  4. package/dist/cjs/dimensional-model/attributes.js +39 -12
  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/data-model.d.ts +1 -1
  12. package/dist/cjs/dimensional-model/data-model.js +1 -1
  13. package/dist/cjs/dimensional-model/dimensions/dimensions.d.ts +6 -6
  14. package/dist/cjs/dimensional-model/dimensions/dimensions.js +34 -17
  15. package/dist/cjs/dimensional-model/dimensions/utils.d.ts +1 -0
  16. package/dist/cjs/dimensional-model/dimensions/utils.js +2 -1
  17. package/dist/cjs/dimensional-model/factory.js +5 -5
  18. package/dist/cjs/dimensional-model/filters/factory.d.ts +42 -42
  19. package/dist/cjs/dimensional-model/filters/factory.js +53 -168
  20. package/dist/cjs/dimensional-model/filters/filter-relations.d.ts +11 -2
  21. package/dist/cjs/dimensional-model/filters/filter-relations.js +14 -7
  22. package/dist/cjs/dimensional-model/filters/filters.d.ts +40 -24
  23. package/dist/cjs/dimensional-model/filters/filters.js +106 -56
  24. package/dist/cjs/dimensional-model/filters/helpers.d.ts +1 -1
  25. package/dist/cjs/dimensional-model/filters/helpers.js +2 -2
  26. package/dist/cjs/dimensional-model/filters/utils/attribute-measure-util.js +9 -17
  27. package/dist/cjs/dimensional-model/filters/utils/condition-filter-util.d.ts +1 -1
  28. package/dist/cjs/dimensional-model/filters/utils/condition-filter-util.js +31 -29
  29. package/dist/cjs/dimensional-model/filters/utils/filter-from-jaql-util.d.ts +1 -1
  30. package/dist/cjs/dimensional-model/filters/utils/filter-from-jaql-util.js +13 -19
  31. package/dist/cjs/dimensional-model/filters/utils/filter-types-util.d.ts +1 -1
  32. package/dist/cjs/dimensional-model/filters/utils/filter-types-util.js +1 -1
  33. package/dist/cjs/dimensional-model/filters/utils/types.d.ts +10 -0
  34. package/dist/cjs/dimensional-model/interfaces.d.ts +17 -7
  35. package/dist/cjs/dimensional-model/jaql-element.d.ts +13 -1
  36. package/dist/cjs/dimensional-model/jaql-element.js +54 -2
  37. package/dist/cjs/dimensional-model/measures/factory.d.ts +46 -53
  38. package/dist/cjs/dimensional-model/measures/factory.js +57 -186
  39. package/dist/cjs/dimensional-model/measures/measures.d.ts +10 -10
  40. package/dist/cjs/dimensional-model/measures/measures.js +35 -33
  41. package/dist/cjs/dimensional-model/types.d.ts +41 -16
  42. package/dist/cjs/index.d.ts +7 -7
  43. package/dist/cjs/index.js +7 -7
  44. package/dist/cjs/utils.d.ts +45 -22
  45. package/dist/cjs/utils.js +119 -47
  46. package/dist/dimensional-model/analytics/factory.d.ts +10 -10
  47. package/dist/dimensional-model/analytics/factory.js +15 -14
  48. package/dist/dimensional-model/attributes.d.ts +13 -6
  49. package/dist/dimensional-model/attributes.js +39 -12
  50. package/dist/dimensional-model/base.d.ts +3 -3
  51. package/dist/dimensional-model/base.js +7 -4
  52. package/dist/dimensional-model/compose-code-utils.d.ts +41 -0
  53. package/dist/dimensional-model/compose-code-utils.js +119 -0
  54. package/dist/dimensional-model/consts.d.ts +1 -0
  55. package/dist/dimensional-model/consts.js +1 -0
  56. package/dist/dimensional-model/data-model.d.ts +1 -1
  57. package/dist/dimensional-model/data-model.js +1 -1
  58. package/dist/dimensional-model/dimensions/dimensions.d.ts +6 -6
  59. package/dist/dimensional-model/dimensions/dimensions.js +35 -18
  60. package/dist/dimensional-model/dimensions/utils.d.ts +1 -0
  61. package/dist/dimensional-model/dimensions/utils.js +3 -2
  62. package/dist/dimensional-model/factory.js +5 -5
  63. package/dist/dimensional-model/filters/factory.d.ts +42 -42
  64. package/dist/dimensional-model/filters/factory.js +52 -126
  65. package/dist/dimensional-model/filters/filter-relations.d.ts +11 -2
  66. package/dist/dimensional-model/filters/filter-relations.js +14 -7
  67. package/dist/dimensional-model/filters/filters.d.ts +40 -24
  68. package/dist/dimensional-model/filters/filters.js +106 -56
  69. package/dist/dimensional-model/filters/helpers.d.ts +1 -1
  70. package/dist/dimensional-model/filters/helpers.js +2 -2
  71. package/dist/dimensional-model/filters/utils/attribute-measure-util.js +10 -18
  72. package/dist/dimensional-model/filters/utils/condition-filter-util.d.ts +1 -1
  73. package/dist/dimensional-model/filters/utils/condition-filter-util.js +31 -29
  74. package/dist/dimensional-model/filters/utils/filter-from-jaql-util.d.ts +1 -1
  75. package/dist/dimensional-model/filters/utils/filter-from-jaql-util.js +13 -19
  76. package/dist/dimensional-model/filters/utils/filter-types-util.d.ts +1 -1
  77. package/dist/dimensional-model/filters/utils/filter-types-util.js +1 -1
  78. package/dist/dimensional-model/filters/utils/types.d.ts +10 -0
  79. package/dist/dimensional-model/interfaces.d.ts +17 -7
  80. package/dist/dimensional-model/jaql-element.d.ts +13 -1
  81. package/dist/dimensional-model/jaql-element.js +52 -1
  82. package/dist/dimensional-model/measures/factory.d.ts +46 -53
  83. package/dist/dimensional-model/measures/factory.js +56 -143
  84. package/dist/dimensional-model/measures/measures.d.ts +10 -10
  85. package/dist/dimensional-model/measures/measures.js +35 -33
  86. package/dist/dimensional-model/types.d.ts +41 -16
  87. package/dist/index.d.ts +7 -7
  88. package/dist/index.js +7 -7
  89. package/dist/translation/initialize-i18n.js +1 -1
  90. package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -1
  91. package/dist/utils.d.ts +45 -22
  92. package/dist/utils.js +94 -49
  93. package/package.json +5 -4
  94. package/dist/cjs/dimensional-model/filters/utils/filter-code-util.d.ts +0 -17
  95. package/dist/cjs/dimensional-model/filters/utils/filter-code-util.js +0 -82
  96. package/dist/dimensional-model/filters/utils/filter-code-util.d.ts +0 -17
  97. package/dist/dimensional-model/filters/utils/filter-code-util.js +0 -77
@@ -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;
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.boxWhiskerStdDevOutliers = exports.boxWhiskerIqrOutliers = exports.boxWhiskerStdDevValues = exports.boxWhiskerExtremumsValues = exports.boxWhiskerIqrValues = exports.BOX_WHISKER = void 0;
7
7
  const cloneDeep_js_1 = __importDefault(require("lodash-es/cloneDeep.js"));
8
+ const compose_code_utils_js_1 = require("../compose-code-utils.js");
8
9
  const factory_js_1 = require("../measures/factory.js");
9
10
  /** @internal */
10
11
  exports.BOX_WHISKER = {
@@ -33,8 +34,8 @@ function boxWhiskerCommonValues(target) {
33
34
  /**
34
35
  * Returns an array of values for box whisker plot using interquartile range (IQR) calculations.
35
36
  *
36
- * @param {Attribute} target - The target attribute for calculations.
37
- * @returns {Measure[]} An array of measures representing IQR values for box whisker plots.
37
+ * @param target - The target attribute for calculations.
38
+ * @returns An array of measures representing IQR values for box whisker plots.
38
39
  */
39
40
  function boxWhiskerIqrValues(target) {
40
41
  return [
@@ -54,8 +55,8 @@ exports.boxWhiskerIqrValues = boxWhiskerIqrValues;
54
55
  /**
55
56
  * Returns an array of extremum values for box whisker plot.
56
57
  *
57
- * @param {Attribute} target - The target attribute for calculations.
58
- * @returns {Measure[]} An array of measures representing extremum values for box whisker plots.
58
+ * @param target - The target attribute for calculations.
59
+ * @returns An array of measures representing extremum values for box whisker plots.
59
60
  */
60
61
  function boxWhiskerExtremumsValues(target) {
61
62
  return [
@@ -72,8 +73,8 @@ exports.boxWhiskerExtremumsValues = boxWhiskerExtremumsValues;
72
73
  /**
73
74
  * Returns an array of values for box whisker plot using standard deviation calculations.
74
75
  *
75
- * @param {Attribute} target - The target attribute for calculations.
76
- * @returns {Measure[]} An array of measures representing standard deviation values for box whisker plots.
76
+ * @param target - The target attribute for calculations.
77
+ * @returns An array of measures representing standard deviation values for box whisker plots.
77
78
  */
78
79
  function boxWhiskerStdDevValues(target) {
79
80
  return [
@@ -93,10 +94,10 @@ exports.boxWhiskerStdDevValues = boxWhiskerStdDevValues;
93
94
  /**
94
95
  * Returns an attribute representing outlier points based on interquartile range (IQR) calculations.
95
96
  *
96
- * @param {Attribute} target - The target attribute for calculations.
97
- * @returns {Attribute} An attribute representing outliers for box whisker plots using IQR.
97
+ * @param target - The target attribute for calculations.
98
+ * @returns An attribute representing outliers for box whisker plots using IQR.
98
99
  */
99
- const boxWhiskerIqrOutliers = (target) => {
100
+ exports.boxWhiskerIqrOutliers = (0, compose_code_utils_js_1.withComposeCodeForAnalytics)((target) => {
100
101
  const outliersAttrWithInnerFilter = (0, cloneDeep_js_1.default)(target);
101
102
  const outliersMax = (0, factory_js_1.customFormula)(exports.BOX_WHISKER.OUTLIER_MAX_VALUE_NAME, '(UPPERWHISKERMIN_IQR([Attr]), all([Attr]))', {
102
103
  Attr: target,
@@ -119,15 +120,14 @@ const boxWhiskerIqrOutliers = (target) => {
119
120
  return nested ? jaql : { jaql };
120
121
  };
121
122
  return outliersAttrWithInnerFilter;
122
- };
123
- exports.boxWhiskerIqrOutliers = boxWhiskerIqrOutliers;
123
+ }, 'boxWhiskerIqrOutliers');
124
124
  /**
125
125
  * Returns an attribute representing outlier points based on standard deviation calculations.
126
126
  *
127
- * @param {Attribute} target - The target attribute for calculations.
128
- * @returns {Attribute} An attribute representing outliers for box whisker plots using standard deviation.
127
+ * @param target - The target attribute for calculations.
128
+ * @returns An attribute representing outliers for box whisker plots using standard deviation.
129
129
  */
130
- const boxWhiskerStdDevOutliers = (target) => {
130
+ exports.boxWhiskerStdDevOutliers = (0, compose_code_utils_js_1.withComposeCodeForAnalytics)((target) => {
131
131
  const outliersAttrWithInnerFilter = (0, cloneDeep_js_1.default)(target);
132
132
  const outliersMax = (0, factory_js_1.customFormula)(exports.BOX_WHISKER.OUTLIER_MAX_VALUE_NAME, '(UPPERWHISKERMIN_STDEVP([Attr]), all([Attr]))', {
133
133
  Attr: target,
@@ -149,5 +149,4 @@ const boxWhiskerStdDevOutliers = (target) => {
149
149
  return nested ? jaql : { jaql };
150
150
  };
151
151
  return outliersAttrWithInnerFilter;
152
- };
153
- exports.boxWhiskerStdDevOutliers = boxWhiskerStdDevOutliers;
152
+ }, 'boxWhiskerStdDevOutliers');
@@ -1,6 +1,6 @@
1
- import { Attribute, LevelAttribute } from './interfaces.js';
2
- import { Sort, JaqlDataSource } from './types.js';
3
1
  import { DimensionalElement } from './base.js';
2
+ import { Attribute, LevelAttribute } from './interfaces.js';
3
+ import { DateLevel, JaqlDataSource, JSONObject, Sort } from './types.js';
4
4
  /**
5
5
  * @internal
6
6
  */
@@ -39,7 +39,7 @@ export declare class DimensionalAttribute extends DimensionalElement implements
39
39
  /**
40
40
  * Gets a serializable representation of the element
41
41
  */
42
- serializable(): any;
42
+ serialize(): JSONObject;
43
43
  }
44
44
  /**
45
45
  * @internal
@@ -48,7 +48,7 @@ export declare class DimensionalLevelAttribute extends DimensionalAttribute impl
48
48
  private _format;
49
49
  readonly granularity: string;
50
50
  readonly panel: string;
51
- constructor(l: string, expression: string, granularity: string, format?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string, panel?: string);
51
+ constructor(name: string, expression: string, granularity: string, format?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string, panel?: string);
52
52
  /**
53
53
  * gets the element's ID
54
54
  */
@@ -79,10 +79,17 @@ export declare class DimensionalLevelAttribute extends DimensionalAttribute impl
79
79
  * @returns An instance representing the formatted {@link LevelAttribute} of this instance
80
80
  */
81
81
  format(format: string): LevelAttribute;
82
+ /**
83
+ * Gets a {@link LevelAttribute} with the given granularity
84
+ *
85
+ * @param granularity - Date granularity
86
+ * @returns New instance representing {@link LevelAttribute} with provided granularity
87
+ */
88
+ setGranularity(granularity: DateLevel): LevelAttribute;
82
89
  /**
83
90
  * Gets a serializable representation of the element
84
91
  */
85
- serializable(): any;
92
+ serialize(): JSONObject;
86
93
  /**
87
94
  * Gets the JAQL representation of this instance
88
95
  *
@@ -138,4 +145,4 @@ export declare function createLevel(json: any): LevelAttribute;
138
145
  * @return full normalized attribute name (e.g., DM.CommerceSales.OrderDate.Years)
139
146
  * @internal
140
147
  */
141
- export declare function normalizeAttributeName(tableName: string, columnName: string, dateLevel?: string, modelName?: string): string;
148
+ export declare function normalizeAttributeName(tableName: string, columnName: string, granularity?: string, modelName?: string): string;
@@ -1,9 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeAttributeName = exports.createLevel = exports.createAttribute = exports.DimensionalLevelAttribute = exports.DimensionalAttribute = exports.jaqlSimpleColumnType = void 0;
4
- const types_js_1 = require("./types.js");
4
+ /* eslint-disable max-params */
5
+ /* eslint-disable no-underscore-dangle */
6
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
7
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
8
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
9
+ /* eslint-disable sonarjs/no-nested-switch */
10
+ const utils_js_1 = require("../utils.js");
5
11
  const base_js_1 = require("./base.js");
12
+ const consts_js_1 = require("./consts.js");
6
13
  const simple_column_types_js_1 = require("./simple-column-types.js");
14
+ const types_js_1 = require("./types.js");
7
15
  /**
8
16
  * @internal
9
17
  */
@@ -17,6 +25,11 @@ class DimensionalAttribute extends base_js_1.DimensionalElement {
17
25
  super(name, type || types_js_1.MetadataTypes.Attribute, desc, dataSource, composeCode);
18
26
  this._sort = types_js_1.Sort.None;
19
27
  this.expression = expression;
28
+ // if composeCode is not explicitly set by the caller, extract it from expression
29
+ if (!composeCode && expression) {
30
+ const { table, column } = (0, utils_js_1.parseExpression)(expression);
31
+ this.composeCode = normalizeAttributeName(table, column, '', consts_js_1.DATA_MODEL_MODULE_NAME);
32
+ }
20
33
  // panel is not needed in most cases, this is to support break by columns functionality
21
34
  if (panel === 'columns') {
22
35
  this.panel = panel;
@@ -70,11 +83,12 @@ class DimensionalAttribute extends base_js_1.DimensionalElement {
70
83
  /**
71
84
  * Gets a serializable representation of the element
72
85
  */
73
- serializable() {
74
- const result = super.serializable();
86
+ serialize() {
87
+ const result = super.serialize();
88
+ result.__serializable = 'DimensionalAttribute';
75
89
  result.expression = this.expression;
76
90
  if (this.getSort() !== types_js_1.Sort.None) {
77
- result.sort = this.getSort().toString();
91
+ result.sort = this.getSort();
78
92
  }
79
93
  return result;
80
94
  }
@@ -84,10 +98,15 @@ exports.DimensionalAttribute = DimensionalAttribute;
84
98
  * @internal
85
99
  */
86
100
  class DimensionalLevelAttribute extends DimensionalAttribute {
87
- constructor(l, expression, granularity, format, desc, sort, dataSource, composeCode, panel) {
88
- super(l, expression, types_js_1.MetadataTypes.DateLevel, desc, sort, dataSource, composeCode);
101
+ constructor(name, expression, granularity, format, desc, sort, dataSource, composeCode, panel) {
102
+ super(name, expression, types_js_1.MetadataTypes.DateLevel, desc, sort, dataSource, composeCode);
89
103
  this._format = format;
90
104
  this.granularity = granularity;
105
+ // if composeCode is not explicitly set by the caller, extract it from expression and granularity
106
+ if (!composeCode && expression) {
107
+ const { table, column } = (0, utils_js_1.parseExpression)(expression);
108
+ this.composeCode = normalizeAttributeName(table, column, granularity, consts_js_1.DATA_MODEL_MODULE_NAME);
109
+ }
91
110
  // panel is not needed in most cases, this is to support break by columns functionality
92
111
  if (panel === 'columns') {
93
112
  this.panel = panel;
@@ -139,11 +158,21 @@ class DimensionalLevelAttribute extends DimensionalAttribute {
139
158
  format(format) {
140
159
  return new DimensionalLevelAttribute(this.name, this.expression, this.granularity, format, this.description, this._sort, this.dataSource, this.composeCode);
141
160
  }
161
+ /**
162
+ * Gets a {@link LevelAttribute} with the given granularity
163
+ *
164
+ * @param granularity - Date granularity
165
+ * @returns New instance representing {@link LevelAttribute} with provided granularity
166
+ */
167
+ setGranularity(granularity) {
168
+ return new DimensionalLevelAttribute(this.name, this.expression, granularity, this._format, this.description, this._sort, this.dataSource, this.composeCode);
169
+ }
142
170
  /**
143
171
  * Gets a serializable representation of the element
144
172
  */
145
- serializable() {
146
- const result = super.serializable();
173
+ serialize() {
174
+ const result = super.serialize();
175
+ result.__serializable = 'DimensionalLevelAttribute';
147
176
  result.granularity = this.granularity;
148
177
  if (this.getFormat() !== undefined) {
149
178
  result.format = this.getFormat();
@@ -363,13 +392,11 @@ exports.createLevel = createLevel;
363
392
  * @return full normalized attribute name (e.g., DM.CommerceSales.OrderDate.Years)
364
393
  * @internal
365
394
  */
366
- function normalizeAttributeName(tableName, columnName, dateLevel, modelName) {
395
+ function normalizeAttributeName(tableName, columnName, granularity, modelName) {
367
396
  return ((modelName && modelName.length > 0 ? modelName + '.' : '') +
368
397
  (0, base_js_1.normalizeName)(tableName) +
369
398
  '.' +
370
399
  (0, base_js_1.normalizeName)(columnName) +
371
- (dateLevel && dateLevel.length > 0
372
- ? '.' + DimensionalLevelAttribute.translateJaqlToGranularity({ level: dateLevel })
373
- : ''));
400
+ (granularity && granularity.length > 0 ? '.' + granularity : ''));
374
401
  }
375
402
  exports.normalizeAttributeName = normalizeAttributeName;
@@ -1,5 +1,5 @@
1
1
  import { Element } from './interfaces.js';
2
- import { JaqlDataSource } from './types.js';
2
+ import { JaqlDataSource, JSONObject } from './types.js';
3
3
  /**
4
4
  * @internal
5
5
  */
@@ -43,8 +43,8 @@ export declare abstract class DimensionalElement implements Element {
43
43
  /**
44
44
  * Gets a serializable representation of the element
45
45
  */
46
- serializable(): any;
47
- toJSON(): any;
46
+ serialize(): JSONObject;
47
+ toJSON(): JSONObject;
48
48
  abstract jaql(nested?: boolean): any;
49
49
  /**
50
50
  * Gets a string representation of the element
@@ -12,7 +12,9 @@ class DimensionalElement {
12
12
  if (dataSource) {
13
13
  this._dataSource = dataSource;
14
14
  }
15
- this.composeCode = composeCode;
15
+ if (composeCode) {
16
+ this.composeCode = composeCode;
17
+ }
16
18
  }
17
19
  /**
18
20
  * Defines the element's name
@@ -32,17 +34,18 @@ class DimensionalElement {
32
34
  /**
33
35
  * Gets a serializable representation of the element
34
36
  */
35
- serializable() {
37
+ serialize() {
36
38
  return {
37
39
  name: this.name,
38
40
  type: this.type,
39
- desc: this.description,
41
+ description: this.description,
40
42
  dataSource: this.dataSource,
43
+ composeCode: this.composeCode,
41
44
  __serializable: 'DimensionalElement',
42
45
  };
43
46
  }
44
47
  toJSON() {
45
- return this.serializable();
48
+ return this.serialize();
46
49
  }
47
50
  /**
48
51
  * Gets a string representation of the element
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Stringifies the argument, with an option to exclude specific properties from objects without a 'composeCode'.
3
+ * Keys with spaces in objects will be enclosed in single quotes.
4
+ *
5
+ * @param arg - The argument to stringify.
6
+ * @param excludeProps - Optional array of property names to exclude when stringifying objects (that don't have 'composeCode').
7
+ * @returns The stringified representation of the argument.
8
+ */
9
+ export declare function stringifyHelper(arg: any, excludeProps?: string[]): string;
10
+ /**
11
+ * High order function to construct compose code for filter factory functions
12
+ *
13
+ * @param func - filter factory function
14
+ * @param funcName - name of the filter factory function. Needed if the function name is minified.
15
+ * @returns filter factory function with composeCode property added to the filter
16
+ */
17
+ export declare function withComposeCodeForFilter<T extends (...args: any[]) => any>(func: T, funcName?: string): T;
18
+ /**
19
+ * High order function to construct compose code for filter relations factory functions
20
+ *
21
+ * @param func - filter factory function
22
+ * @param funcName - name of the filter factory function. Needed if the function name is minified.
23
+ * @returns filter factory function with composeCode property added to the filter
24
+ */
25
+ export declare function withComposeCodeForFilterRelations<T extends (...args: any[]) => any>(func: T, funcName?: string): T;
26
+ /**
27
+ * High order function to construct compose code for analytics factory functions
28
+ *
29
+ * @param func - analytics factory function
30
+ * @param funcName - name of the analytics factory function. Needed if the function name is minified.
31
+ * @returns analytics factory function with composeCode property added to the analytics
32
+ */
33
+ export declare function withComposeCodeForAnalytics<T extends (...args: any[]) => any>(func: T, funcName?: string): T;
34
+ /**
35
+ * High order function to construct compose code for measure factory functions
36
+ *
37
+ * @param func - measure factory function
38
+ * @param funcName - name of the measure factory function. Needed if the function name is minified.
39
+ * @returns measure factory function with composeCode property added to the measure
40
+ */
41
+ export declare function withComposeCodeForMeasure<T extends (...args: any[]) => any>(func: T, funcName?: string): T;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withComposeCodeForMeasure = exports.withComposeCodeForAnalytics = exports.withComposeCodeForFilterRelations = exports.withComposeCodeForFilter = exports.stringifyHelper = void 0;
4
+ const sdk_common_1 = require("@sisense/sdk-common");
5
+ /**
6
+ * Stringifies the argument, with an option to exclude specific properties from objects without a 'composeCode'.
7
+ * Keys with spaces in objects will be enclosed in single quotes.
8
+ *
9
+ * @param arg - The argument to stringify.
10
+ * @param excludeProps - Optional array of property names to exclude when stringifying objects (that don't have 'composeCode').
11
+ * @returns The stringified representation of the argument.
12
+ */
13
+ function stringifyHelper(arg, excludeProps = []) {
14
+ try {
15
+ if (arg === null || arg === undefined) {
16
+ return String(arg);
17
+ }
18
+ if (typeof arg === 'string') {
19
+ return `'${(0, sdk_common_1.escapeSingleQuotes)(arg)}'`;
20
+ }
21
+ if (typeof arg === 'number' || typeof arg === 'boolean') {
22
+ return String(arg);
23
+ }
24
+ if (arg instanceof Date) {
25
+ return `new Date('${arg.toISOString()}')`;
26
+ }
27
+ if (Array.isArray(arg)) {
28
+ return `[${arg.map((item) => stringifyHelper(item, excludeProps)).join(', ')}]`;
29
+ }
30
+ if (typeof arg === 'object' && arg !== null) {
31
+ if ('composeCode' in arg) {
32
+ return arg.composeCode;
33
+ }
34
+ const entries = Object.entries(arg)
35
+ .filter(([key]) => !excludeProps.includes(key))
36
+ .map(([key, value]) => {
37
+ const formattedKey = /[^a-zA-Z0-9_$]/.test(key) ? `'${key}'` : key;
38
+ return `${formattedKey}: ${stringifyHelper(value, excludeProps)}`;
39
+ });
40
+ return `{ ${entries.join(', ')} }`;
41
+ }
42
+ // Fallback for anything else
43
+ return JSON.stringify(arg);
44
+ }
45
+ catch (e) {
46
+ console.error(e, JSON.stringify(arg, null, 2));
47
+ return JSON.stringify(arg);
48
+ }
49
+ }
50
+ exports.stringifyHelper = stringifyHelper;
51
+ function trimTrailingUndefined(args) {
52
+ let i = args.length;
53
+ while (i > 0 && args[i - 1] === undefined) {
54
+ i--;
55
+ }
56
+ return args.slice(0, i);
57
+ }
58
+ /**
59
+ * Generic high order function to construct compose code for factory functions
60
+ *
61
+ * @param func - factory function
62
+ * @param factoryName - name of the factory (e.g. 'filterFactory', 'measureFactory')
63
+ * @param funcName - name of the factory function. Needed if the function name is minified.
64
+ * @returns factory function with composeCode property added
65
+ */
66
+ function withComposeCode(factoryName, funcName) {
67
+ return function (func) {
68
+ return function (...args) {
69
+ const trimmedArgs = trimTrailingUndefined(args);
70
+ const length = trimmedArgs.length;
71
+ const argValues = trimmedArgs
72
+ .map((arg) => stringifyHelper(arg, ['guid']))
73
+ // Remove trivial arg values from the end of the array
74
+ .filter((str, index) => !(['', '{ }', '[]', 'undefined', 'null'].includes(str) && index === length - 1))
75
+ .join(', ');
76
+ const signature = `${factoryName}.${funcName !== null && funcName !== void 0 ? funcName : func.name}(${argValues})`;
77
+ // Call the original function and get the result
78
+ const result = func(...args);
79
+ result.composeCode = signature; // Type assertion needed here
80
+ return result;
81
+ };
82
+ };
83
+ }
84
+ /**
85
+ * High order function to construct compose code for filter factory functions
86
+ *
87
+ * @param func - filter factory function
88
+ * @param funcName - name of the filter factory function. Needed if the function name is minified.
89
+ * @returns filter factory function with composeCode property added to the filter
90
+ */
91
+ function withComposeCodeForFilter(func, funcName) {
92
+ return withComposeCode('filterFactory', funcName)(func);
93
+ }
94
+ exports.withComposeCodeForFilter = withComposeCodeForFilter;
95
+ /**
96
+ * High order function to construct compose code for filter relations factory functions
97
+ *
98
+ * @param func - filter factory function
99
+ * @param funcName - name of the filter factory function. Needed if the function name is minified.
100
+ * @returns filter factory function with composeCode property added to the filter
101
+ */
102
+ function withComposeCodeForFilterRelations(func, funcName) {
103
+ return withComposeCode('filterFactory.logic', funcName)(func);
104
+ }
105
+ exports.withComposeCodeForFilterRelations = withComposeCodeForFilterRelations;
106
+ /**
107
+ * High order function to construct compose code for analytics factory functions
108
+ *
109
+ * @param func - analytics factory function
110
+ * @param funcName - name of the analytics factory function. Needed if the function name is minified.
111
+ * @returns analytics factory function with composeCode property added to the analytics
112
+ */
113
+ function withComposeCodeForAnalytics(func, funcName) {
114
+ return withComposeCode('analyticsFactory', funcName)(func);
115
+ }
116
+ exports.withComposeCodeForAnalytics = withComposeCodeForAnalytics;
117
+ /**
118
+ * High order function to construct compose code for measure factory functions
119
+ *
120
+ * @param func - measure factory function
121
+ * @param funcName - name of the measure factory function. Needed if the function name is minified.
122
+ * @returns measure factory function with composeCode property added to the measure
123
+ */
124
+ function withComposeCodeForMeasure(func, funcName) {
125
+ return withComposeCode('measureFactory', funcName)(func);
126
+ }
127
+ exports.withComposeCodeForMeasure = withComposeCodeForMeasure;
@@ -0,0 +1 @@
1
+ export declare const DATA_MODEL_MODULE_NAME = "DM";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DATA_MODEL_MODULE_NAME = void 0;
4
+ exports.DATA_MODEL_MODULE_NAME = 'DM';
@@ -1,5 +1,5 @@
1
- import { DataModel, Element } from './interfaces.js';
2
1
  import { DataSource, DataSourceInfo } from '../interfaces.js';
2
+ import { DataModel, Element } from './interfaces.js';
3
3
  /**
4
4
  * @internal
5
5
  */
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DimensionalDataModel = void 0;
4
- const factory_js_1 = require("./factory.js");
5
4
  const translatable_error_js_1 = require("../translation/translatable-error.js");
5
+ const factory_js_1 = require("./factory.js");
6
6
  /**
7
7
  * @internal
8
8
  */
@@ -1,6 +1,6 @@
1
- import { Attribute, LevelAttribute, Dimension, DateDimension } from '../interfaces.js';
2
- import { Sort, JaqlDataSource } from '../types.js';
3
1
  import { DimensionalElement } from '../base.js';
2
+ import { Attribute, DateDimension, Dimension, LevelAttribute } from '../interfaces.js';
3
+ import { JaqlDataSource, JSONObject, Sort } from '../types.js';
4
4
  /**
5
5
  * Represents a Dimension in a Dimensional Model
6
6
  *
@@ -14,7 +14,7 @@ export declare class DimensionalDimension extends DimensionalElement implements
14
14
  protected _attributes: Attribute[];
15
15
  private _expression;
16
16
  protected _sort: Sort;
17
- constructor(name: string, expression: string, attributes: Attribute[], dimensions?: Dimension[], type?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource);
17
+ constructor(name: string, expression: string, attributes: Attribute[], dimensions?: Dimension[], type?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string, defaultAttribute?: Attribute);
18
18
  private getAttachedName;
19
19
  protected setDimensions(dimensions: Dimension[]): void;
20
20
  protected setAttributes(attributes: Attribute[]): void;
@@ -47,7 +47,7 @@ export declare class DimensionalDimension extends DimensionalElement implements
47
47
  /**
48
48
  * Gets a serializable representation of the element
49
49
  */
50
- serializable(): any;
50
+ serialize(): JSONObject;
51
51
  /**
52
52
  * Gets the JAQL representation of this instance
53
53
  *
@@ -61,7 +61,7 @@ export declare class DimensionalDimension extends DimensionalElement implements
61
61
  * @internal
62
62
  */
63
63
  export declare class DimensionalDateDimension extends DimensionalDimension implements DateDimension {
64
- constructor(name: string, expression: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource);
64
+ constructor(name: string, expression: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string);
65
65
  /**
66
66
  * Years level
67
67
  */
@@ -141,7 +141,7 @@ export declare class DimensionalDateDimension extends DimensionalDimension imple
141
141
  /**
142
142
  * Gets a serializable representation of the element
143
143
  */
144
- serializable(): any;
144
+ serialize(): JSONObject;
145
145
  /**
146
146
  * Gets the JAQL representation of this instance
147
147
  *