@sisense/sdk-data 1.30.0 → 1.32.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 (42) hide show
  1. package/dist/cjs/dimensional-model/attributes.d.ts +4 -2
  2. package/dist/cjs/dimensional-model/attributes.js +17 -3
  3. package/dist/cjs/dimensional-model/dimensions/__mocks__/sample-ecommerce-fields.d.ts +5 -0
  4. package/dist/cjs/dimensional-model/dimensions/__mocks__/sample-ecommerce-fields.js +246 -0
  5. package/dist/cjs/dimensional-model/{dimensions.d.ts → dimensions/dimensions.d.ts} +3 -3
  6. package/dist/cjs/dimensional-model/{dimensions.js → dimensions/dimensions.js} +3 -3
  7. package/dist/cjs/dimensional-model/dimensions/index.d.ts +2 -0
  8. package/dist/cjs/dimensional-model/dimensions/index.js +18 -0
  9. package/dist/cjs/dimensional-model/dimensions/utils.d.ts +11 -0
  10. package/dist/cjs/dimensional-model/dimensions/utils.js +60 -0
  11. package/dist/cjs/dimensional-model/factory.js +2 -2
  12. package/dist/cjs/dimensional-model/filters/filters.d.ts +29 -28
  13. package/dist/cjs/dimensional-model/filters/filters.js +5 -0
  14. package/dist/cjs/dimensional-model/jaql-element.d.ts +3 -2
  15. package/dist/cjs/dimensional-model/jaql-element.js +2 -2
  16. package/dist/cjs/dimensional-model/types.d.ts +2 -0
  17. package/dist/cjs/index.d.ts +1 -1
  18. package/dist/cjs/index.js +1 -1
  19. package/dist/cjs/utils.d.ts +6 -6
  20. package/dist/cjs/utils.js +7 -8
  21. package/dist/dimensional-model/attributes.d.ts +4 -2
  22. package/dist/dimensional-model/attributes.js +17 -3
  23. package/dist/dimensional-model/dimensions/__mocks__/sample-ecommerce-fields.d.ts +5 -0
  24. package/dist/dimensional-model/dimensions/__mocks__/sample-ecommerce-fields.js +243 -0
  25. package/dist/dimensional-model/{dimensions.d.ts → dimensions/dimensions.d.ts} +3 -3
  26. package/dist/dimensional-model/{dimensions.js → dimensions/dimensions.js} +3 -3
  27. package/dist/dimensional-model/dimensions/index.d.ts +2 -0
  28. package/dist/dimensional-model/dimensions/index.js +2 -0
  29. package/dist/dimensional-model/dimensions/utils.d.ts +11 -0
  30. package/dist/dimensional-model/dimensions/utils.js +56 -0
  31. package/dist/dimensional-model/factory.js +1 -1
  32. package/dist/dimensional-model/filters/filters.d.ts +29 -28
  33. package/dist/dimensional-model/filters/filters.js +5 -0
  34. package/dist/dimensional-model/jaql-element.d.ts +3 -2
  35. package/dist/dimensional-model/jaql-element.js +3 -3
  36. package/dist/dimensional-model/types.d.ts +2 -0
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -1
  40. package/dist/utils.d.ts +6 -6
  41. package/dist/utils.js +7 -8
  42. package/package.json +3 -3
@@ -82,11 +82,11 @@ export declare function getColumnNameFromAttribute(attribute: Attribute): string
82
82
  export declare function getSortType(jaqlSort: `${JaqlSortDirection}` | undefined): SortDirection;
83
83
  /**
84
84
  * Creates an attribute or level attribute from the provided parameters
85
- * @returns attribute or level attribute
86
85
  *
86
+ * @returns attribute or level attribute
87
87
  * @internal
88
88
  */
89
- export declare const createAttributeHelper: ({ dim, table, column, dataType, level, format, sort, title, dataSource, }: {
89
+ export declare const createAttributeHelper: ({ dim, table, column, dataType, level, format, sort, title, panel, dataSource, }: {
90
90
  /** Dimension expression */
91
91
  dim: string;
92
92
  /** Table name */
@@ -103,6 +103,8 @@ export declare const createAttributeHelper: ({ dim, table, column, dataType, lev
103
103
  sort: string | undefined;
104
104
  /** Attribute title */
105
105
  title?: string | undefined;
106
+ /** Panel */
107
+ panel?: string | undefined;
106
108
  /** Jaql data source */
107
109
  dataSource?: JaqlDataSource | undefined;
108
110
  }) => Attribute | LevelAttribute;
@@ -110,7 +112,6 @@ export declare const createAttributeHelper: ({ dim, table, column, dataType, lev
110
112
  * Creates a measure from the provided parameters
111
113
  *
112
114
  * @returns measure
113
- *
114
115
  * @internal
115
116
  */
116
117
  export declare const createMeasureHelper: ({ dim, table, column, dataType, agg, level, format, sort, title, dataSource, }: {
@@ -139,16 +140,15 @@ export declare const createMeasureHelper: ({ dim, table, column, dataType, agg,
139
140
  * Creates a measure from the provided parameters
140
141
  *
141
142
  * @returns calculated measure
142
- *
143
143
  * @internal
144
144
  */
145
145
  export declare const createCalculatedMeasureHelper: (jaql: FormulaJaql) => CalculatedMeasure;
146
146
  /**
147
147
  * Creates a dimensional element from a JAQL object.
148
+ *
148
149
  * @param jaql - The JAQL object.
149
150
  * @param datetimeFormat - The datetime format.
150
151
  * @returns The created dimensional element.
151
- *
152
152
  * @internal
153
153
  */
154
- export declare function createDimensionalElementFromJaql(jaql: Jaql, datetimeFormat?: string): Attribute | BaseMeasure | CalculatedMeasure | Filter;
154
+ export declare function createDimensionalElementFromJaql(jaql: Jaql, datetimeFormat?: string, panel?: string): Attribute | BaseMeasure | CalculatedMeasure | Filter;
package/dist/cjs/utils.js CHANGED
@@ -240,11 +240,11 @@ exports.getSortType = getSortType;
240
240
  const DATA_MODEL_MODULE_NAME = 'DM';
241
241
  /**
242
242
  * Creates an attribute or level attribute from the provided parameters
243
- * @returns attribute or level attribute
244
243
  *
244
+ * @returns attribute or level attribute
245
245
  * @internal
246
246
  */
247
- const createAttributeHelper = ({ dim, table, column, dataType, level, format, sort, title, dataSource, }) => {
247
+ const createAttributeHelper = ({ dim, table, column, dataType, level, format, sort, title, panel, dataSource, }) => {
248
248
  // if table is undefined, extract it from dim
249
249
  const dimTable = table !== null && table !== void 0 ? table : parseExpression(dim).table;
250
250
  // if column is undefined, extract it from dim
@@ -254,12 +254,12 @@ const createAttributeHelper = ({ dim, table, column, dataType, level, format, so
254
254
  if (isDataTypeDatetime) {
255
255
  const dateLevel = attributes_js_1.DimensionalLevelAttribute.translateJaqlToGranularity({ level });
256
256
  const composeCode = (0, attributes_js_1.normalizeAttributeName)(dimTable, dimColumn, level, DATA_MODEL_MODULE_NAME);
257
- const levelAttribute = new attributes_js_1.DimensionalLevelAttribute(title !== null && title !== void 0 ? title : dimColumn, dim, dateLevel, format || attributes_js_1.DimensionalLevelAttribute.getDefaultFormatForGranularity(dateLevel), undefined, sortEnum, dataSource, composeCode);
257
+ const levelAttribute = new attributes_js_1.DimensionalLevelAttribute(title !== null && title !== void 0 ? title : dimColumn, dim, dateLevel, format || attributes_js_1.DimensionalLevelAttribute.getDefaultFormatForGranularity(dateLevel), undefined, sortEnum, dataSource, composeCode, panel);
258
258
  return levelAttribute;
259
259
  }
260
260
  const attributeType = !dataType || (0, simple_column_types_js_1.isNumber)(dataType) ? types_js_1.MetadataTypes.NumericAttribute : types_js_1.MetadataTypes.TextAttribute;
261
261
  const composeCode = (0, attributes_js_1.normalizeAttributeName)(dimTable, dimColumn, undefined, DATA_MODEL_MODULE_NAME);
262
- const attribute = new attributes_js_1.DimensionalAttribute(title !== null && title !== void 0 ? title : dimColumn, dim, attributeType, undefined, sortEnum, dataSource, composeCode);
262
+ const attribute = new attributes_js_1.DimensionalAttribute(title !== null && title !== void 0 ? title : dimColumn, dim, attributeType, undefined, sortEnum, dataSource, composeCode, panel);
263
263
  return attribute;
264
264
  };
265
265
  exports.createAttributeHelper = createAttributeHelper;
@@ -267,7 +267,6 @@ exports.createAttributeHelper = createAttributeHelper;
267
267
  * Creates a measure from the provided parameters
268
268
  *
269
269
  * @returns measure
270
- *
271
270
  * @internal
272
271
  */
273
272
  const createMeasureHelper = ({ dim, table, column, dataType, agg, level, format, sort, title, dataSource, }) => {
@@ -305,7 +304,6 @@ const getContextComposeCode = (context) => {
305
304
  * Creates a measure from the provided parameters
306
305
  *
307
306
  * @returns calculated measure
308
- *
309
307
  * @internal
310
308
  */
311
309
  const createCalculatedMeasureHelper = (jaql) => {
@@ -323,13 +321,13 @@ const createCalculatedMeasureHelper = (jaql) => {
323
321
  exports.createCalculatedMeasureHelper = createCalculatedMeasureHelper;
324
322
  /**
325
323
  * Creates a dimensional element from a JAQL object.
324
+ *
326
325
  * @param jaql - The JAQL object.
327
326
  * @param datetimeFormat - The datetime format.
328
327
  * @returns The created dimensional element.
329
- *
330
328
  * @internal
331
329
  */
332
- function createDimensionalElementFromJaql(jaql, datetimeFormat) {
330
+ function createDimensionalElementFromJaql(jaql, datetimeFormat, panel) {
333
331
  const isFilterJaql = 'filter' in jaql;
334
332
  if (isFilterJaql) {
335
333
  return (0, exports.createFilterFromJaql)(jaql);
@@ -363,6 +361,7 @@ function createDimensionalElementFromJaql(jaql, datetimeFormat) {
363
361
  format: datetimeFormat,
364
362
  sort: jaql.sort,
365
363
  title: jaql.title,
364
+ panel: panel,
366
365
  dataSource,
367
366
  });
368
367
  }
@@ -10,8 +10,9 @@ export declare const jaqlSimpleColumnType: (datatype: string) => string;
10
10
  */
11
11
  export declare class DimensionalAttribute extends DimensionalElement implements Attribute {
12
12
  readonly expression: string;
13
+ readonly panel: string;
13
14
  protected _sort: Sort;
14
- constructor(name: string, expression: string, type?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string);
15
+ constructor(name: string, expression: string, type?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string, panel?: string);
15
16
  /**
16
17
  * gets the element's ID
17
18
  */
@@ -46,7 +47,8 @@ export declare class DimensionalAttribute extends DimensionalElement implements
46
47
  export declare class DimensionalLevelAttribute extends DimensionalAttribute implements LevelAttribute {
47
48
  private _format;
48
49
  readonly granularity: string;
49
- constructor(l: string, expression: string, granularity: string, format?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string);
50
+ readonly panel: string;
51
+ constructor(l: string, expression: string, granularity: string, format?: string, desc?: string, sort?: Sort, dataSource?: JaqlDataSource, composeCode?: string, panel?: string);
50
52
  /**
51
53
  * gets the element's ID
52
54
  */
@@ -9,10 +9,14 @@ export const jaqlSimpleColumnType = (datatype) => simpleColumnType(datatype).rep
9
9
  * @internal
10
10
  */
11
11
  export class DimensionalAttribute extends DimensionalElement {
12
- constructor(name, expression, type, desc, sort, dataSource, composeCode) {
12
+ constructor(name, expression, type, desc, sort, dataSource, composeCode, panel) {
13
13
  super(name, type || MetadataTypes.Attribute, desc, dataSource, composeCode);
14
14
  this._sort = Sort.None;
15
15
  this.expression = expression;
16
+ // panel is not needed in most cases, this is to support break by columns functionality
17
+ if (panel === 'columns') {
18
+ this.panel = panel;
19
+ }
16
20
  this._sort = sort || Sort.None;
17
21
  }
18
22
  /**
@@ -36,7 +40,7 @@ export class DimensionalAttribute extends DimensionalElement {
36
40
  * @returns An instance representing the sorted {@link Attribute} of this instance
37
41
  */
38
42
  sort(sort) {
39
- return new DimensionalAttribute(this.name, this.expression, this.type, this.description, sort, this.dataSource, this.composeCode);
43
+ return new DimensionalAttribute(this.name, this.expression, this.type, this.description, sort, this.dataSource, this.composeCode, this.panel);
40
44
  }
41
45
  /**
42
46
  * Gets the JAQL representation of this instance
@@ -51,6 +55,9 @@ export class DimensionalAttribute extends DimensionalElement {
51
55
  datatype: jaqlSimpleColumnType(this.type),
52
56
  },
53
57
  };
58
+ if (this.panel) {
59
+ result.panel = this.panel;
60
+ }
54
61
  if (this._sort != Sort.None) {
55
62
  result.jaql.sort = this._sort == Sort.Ascending ? 'asc' : 'desc';
56
63
  }
@@ -72,10 +79,14 @@ export class DimensionalAttribute extends DimensionalElement {
72
79
  * @internal
73
80
  */
74
81
  export class DimensionalLevelAttribute extends DimensionalAttribute {
75
- constructor(l, expression, granularity, format, desc, sort, dataSource, composeCode) {
82
+ constructor(l, expression, granularity, format, desc, sort, dataSource, composeCode, panel) {
76
83
  super(l, expression, MetadataTypes.DateLevel, desc, sort, dataSource, composeCode);
77
84
  this._format = format;
78
85
  this.granularity = granularity;
86
+ // panel is not needed in most cases, this is to support break by columns functionality
87
+ if (panel === 'columns') {
88
+ this.panel = panel;
89
+ }
79
90
  }
80
91
  /**
81
92
  * gets the element's ID
@@ -143,6 +154,9 @@ export class DimensionalLevelAttribute extends DimensionalAttribute {
143
154
  const r = {
144
155
  jaql: Object.assign({ title: this.name, dim: this.expression, datatype: jaqlSimpleColumnType(this.type) }, this.translateGranularityToJaql()),
145
156
  };
157
+ if (this.panel) {
158
+ r.panel = this.panel;
159
+ }
146
160
  if (this._format !== undefined) {
147
161
  const levelName = r.jaql.dateTimeLevel || r.jaql.level;
148
162
  r.format = { mask: {} };
@@ -0,0 +1,5 @@
1
+ import { AnyObject, DataSourceField } from '../../types.js';
2
+ /**
3
+ * Actual fields from the Sample ECommerce datasource returned by server.
4
+ */
5
+ export declare const sampleEcommerceFields: (DataSourceField & AnyObject)[];
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Actual fields from the Sample ECommerce datasource returned by server.
3
+ */
4
+ export const sampleEcommerceFields = [
5
+ {
6
+ id: '[Brand.Brand]',
7
+ type: 'dimension',
8
+ dimtype: 'text',
9
+ title: 'Brand',
10
+ table: 'Brand',
11
+ column: 'Brand',
12
+ merged: false,
13
+ indexed: true,
14
+ tableDescription: null,
15
+ columnDescription: null,
16
+ tableTitle: null,
17
+ semanticIndex: false,
18
+ },
19
+ {
20
+ id: '[Brand.Brand ID]',
21
+ type: 'dimension',
22
+ dimtype: 'numeric',
23
+ title: 'Brand ID',
24
+ table: 'Brand',
25
+ column: 'Brand ID',
26
+ merged: true,
27
+ indexed: false,
28
+ tableDescription: null,
29
+ columnDescription: null,
30
+ tableTitle: null,
31
+ semanticIndex: false,
32
+ },
33
+ {
34
+ id: '[Category.Category]',
35
+ type: 'dimension',
36
+ dimtype: 'text',
37
+ title: 'Category',
38
+ table: 'Category',
39
+ column: 'Category',
40
+ merged: false,
41
+ indexed: true,
42
+ tableDescription: null,
43
+ columnDescription: null,
44
+ tableTitle: null,
45
+ semanticIndex: false,
46
+ },
47
+ {
48
+ id: '[Category.Category ID]',
49
+ type: 'dimension',
50
+ dimtype: 'numeric',
51
+ title: 'Category ID',
52
+ table: 'Category',
53
+ column: 'Category ID',
54
+ merged: true,
55
+ indexed: false,
56
+ tableDescription: null,
57
+ columnDescription: null,
58
+ tableTitle: null,
59
+ semanticIndex: false,
60
+ },
61
+ {
62
+ id: '[Commerce.Age Range]',
63
+ type: 'dimension',
64
+ dimtype: 'text',
65
+ title: 'Age Range',
66
+ table: 'Commerce',
67
+ column: 'Age Range',
68
+ merged: false,
69
+ indexed: true,
70
+ tableDescription: null,
71
+ columnDescription: null,
72
+ tableTitle: null,
73
+ semanticIndex: false,
74
+ },
75
+ {
76
+ id: '[Commerce.Brand ID]',
77
+ type: 'dimension',
78
+ dimtype: 'numeric',
79
+ title: 'Brand ID',
80
+ table: 'Commerce',
81
+ column: 'Brand ID',
82
+ merged: true,
83
+ indexed: false,
84
+ tableDescription: null,
85
+ columnDescription: null,
86
+ tableTitle: null,
87
+ semanticIndex: false,
88
+ },
89
+ {
90
+ id: '[Commerce.Category ID]',
91
+ type: 'dimension',
92
+ dimtype: 'numeric',
93
+ title: 'Category ID',
94
+ table: 'Commerce',
95
+ column: 'Category ID',
96
+ merged: true,
97
+ indexed: false,
98
+ tableDescription: null,
99
+ columnDescription: null,
100
+ tableTitle: null,
101
+ semanticIndex: false,
102
+ },
103
+ {
104
+ id: '[Commerce.Condition]',
105
+ type: 'dimension',
106
+ dimtype: 'text',
107
+ title: 'Condition',
108
+ table: 'Commerce',
109
+ column: 'Condition',
110
+ merged: false,
111
+ indexed: true,
112
+ tableDescription: null,
113
+ columnDescription: null,
114
+ tableTitle: null,
115
+ semanticIndex: false,
116
+ },
117
+ {
118
+ id: '[Commerce.Cost]',
119
+ type: 'dimension',
120
+ dimtype: 'numeric',
121
+ title: 'Cost',
122
+ table: 'Commerce',
123
+ column: 'Cost',
124
+ merged: false,
125
+ indexed: false,
126
+ tableDescription: null,
127
+ columnDescription: null,
128
+ tableTitle: null,
129
+ semanticIndex: false,
130
+ },
131
+ {
132
+ id: '[Commerce.Country ID]',
133
+ type: 'dimension',
134
+ dimtype: 'numeric',
135
+ title: 'Country ID',
136
+ table: 'Commerce',
137
+ column: 'Country ID',
138
+ merged: true,
139
+ indexed: false,
140
+ tableDescription: null,
141
+ columnDescription: null,
142
+ tableTitle: null,
143
+ semanticIndex: false,
144
+ },
145
+ {
146
+ id: '[Commerce.Date (Calendar)]',
147
+ type: 'dimension',
148
+ dimtype: 'datetime',
149
+ title: 'Date',
150
+ table: 'Commerce',
151
+ column: 'Date',
152
+ merged: false,
153
+ indexed: true,
154
+ tableDescription: null,
155
+ columnDescription: null,
156
+ tableTitle: null,
157
+ semanticIndex: false,
158
+ },
159
+ {
160
+ id: '[Commerce.Gender]',
161
+ type: 'dimension',
162
+ dimtype: 'text',
163
+ title: 'Gender',
164
+ table: 'Commerce',
165
+ column: 'Gender',
166
+ merged: false,
167
+ indexed: true,
168
+ tableDescription: null,
169
+ columnDescription: null,
170
+ tableTitle: null,
171
+ semanticIndex: false,
172
+ },
173
+ {
174
+ id: '[Commerce.Quantity]',
175
+ type: 'dimension',
176
+ dimtype: 'numeric',
177
+ title: 'Quantity',
178
+ table: 'Commerce',
179
+ column: 'Quantity',
180
+ merged: false,
181
+ indexed: false,
182
+ tableDescription: null,
183
+ columnDescription: null,
184
+ tableTitle: null,
185
+ semanticIndex: false,
186
+ },
187
+ {
188
+ id: '[Commerce.Revenue]',
189
+ type: 'dimension',
190
+ dimtype: 'numeric',
191
+ title: 'Revenue',
192
+ table: 'Commerce',
193
+ column: 'Revenue',
194
+ merged: false,
195
+ indexed: false,
196
+ tableDescription: null,
197
+ columnDescription: null,
198
+ tableTitle: null,
199
+ semanticIndex: false,
200
+ },
201
+ {
202
+ id: '[Commerce.Visit ID]',
203
+ type: 'dimension',
204
+ dimtype: 'numeric',
205
+ title: 'Visit ID',
206
+ table: 'Commerce',
207
+ column: 'Visit ID',
208
+ merged: false,
209
+ indexed: false,
210
+ tableDescription: null,
211
+ columnDescription: null,
212
+ tableTitle: null,
213
+ semanticIndex: false,
214
+ },
215
+ {
216
+ id: '[Country.Country]',
217
+ type: 'dimension',
218
+ dimtype: 'text',
219
+ title: 'Country',
220
+ table: 'Country',
221
+ column: 'Country',
222
+ merged: false,
223
+ indexed: true,
224
+ tableDescription: null,
225
+ columnDescription: null,
226
+ tableTitle: null,
227
+ semanticIndex: false,
228
+ },
229
+ {
230
+ id: '[Country.Country ID]',
231
+ type: 'dimension',
232
+ dimtype: 'numeric',
233
+ title: 'Country ID',
234
+ table: 'Country',
235
+ column: 'Country ID',
236
+ merged: true,
237
+ indexed: false,
238
+ tableDescription: null,
239
+ columnDescription: null,
240
+ tableTitle: null,
241
+ semanticIndex: false,
242
+ },
243
+ ];
@@ -1,6 +1,6 @@
1
- import { Attribute, LevelAttribute, Dimension, DateDimension } from './interfaces.js';
2
- import { Sort, JaqlDataSource } from './types.js';
3
- import { DimensionalElement } from './base.js';
1
+ import { Attribute, LevelAttribute, Dimension, DateDimension } from '../interfaces.js';
2
+ import { Sort, JaqlDataSource } from '../types.js';
3
+ import { DimensionalElement } from '../base.js';
4
4
  /**
5
5
  * Represents a Dimension in a Dimensional Model
6
6
  *
@@ -1,6 +1,6 @@
1
- import { Sort, DateLevels, MetadataTypes } from './types.js';
2
- import { DimensionalAttribute, DimensionalLevelAttribute, jaqlSimpleColumnType, } from './attributes.js';
3
- import { DimensionalElement, normalizeName } from './base.js';
1
+ import { Sort, DateLevels, MetadataTypes } from '../types.js';
2
+ import { DimensionalAttribute, DimensionalLevelAttribute, jaqlSimpleColumnType, } from '../attributes.js';
3
+ import { DimensionalElement, normalizeName } from '../base.js';
4
4
  /**
5
5
  * Represents a Dimension in a Dimensional Model
6
6
  *
@@ -0,0 +1,2 @@
1
+ export * from './dimensions.js';
2
+ export * from './utils.js';
@@ -0,0 +1,2 @@
1
+ export * from './dimensions.js';
2
+ export * from './utils.js';
@@ -0,0 +1,11 @@
1
+ import { DataSource } from '../../interfaces.js';
2
+ import { Dimension } from '../interfaces.js';
3
+ import { DataSourceField } from '../types.js';
4
+ /**
5
+ * Function to convert data source fields to dimensions.
6
+ * @param fields - The data source fields to convert.
7
+ * @param dataSource - The data source title.
8
+ * @returns - The dimensions created from the data source fields.
9
+ * @internal
10
+ */
11
+ export declare function getDimensionsFromDataSourceFields(fields: DataSourceField[], dataSource: DataSource): Dimension[];
@@ -0,0 +1,56 @@
1
+ import { createAttribute } from '../attributes.js';
2
+ import { createDimension, createDateDimension } from './dimensions.js';
3
+ /**
4
+ * Function to convert data source fields to dimensions.
5
+ * @param fields - The data source fields to convert.
6
+ * @param dataSource - The data source title.
7
+ * @returns - The dimensions created from the data source fields.
8
+ * @internal
9
+ */
10
+ export function getDimensionsFromDataSourceFields(fields, dataSource) {
11
+ const attributeEntries = fields.map((field) => createAttributeEntry(field, dataSource));
12
+ const groupedConfigs = groupAttributesByDimension(attributeEntries);
13
+ return Object.values(groupedConfigs).map((config) => createDimension(config));
14
+ }
15
+ /**
16
+ * Given a DataSourceField and the data source title, creates an attribute entry
17
+ * that includes the dimension name, attribute name, and the attribute itself.
18
+ */
19
+ const createAttributeEntry = (field, dataSource) => {
20
+ const dimensionId = field.table;
21
+ const dimensionName = field.tableTitle || dimensionId;
22
+ const attributeId = field.id;
23
+ const attributeName = field.title || attributeId;
24
+ const dataSourceConfig = { title: dataSource, live: false };
25
+ const attribute = field.dimtype === 'datetime'
26
+ ? createDateDimension({
27
+ name: attributeName,
28
+ expression: attributeId,
29
+ dataSource: dataSourceConfig,
30
+ })
31
+ : createAttribute({
32
+ name: attributeName,
33
+ type: field.dimtype === 'text' ? 'text-attribute' : 'numeric-attribute',
34
+ expression: attributeId,
35
+ dataSource: dataSourceConfig,
36
+ });
37
+ return {
38
+ dimension: {
39
+ id: dimensionId,
40
+ name: dimensionName,
41
+ },
42
+ attribute,
43
+ };
44
+ };
45
+ /**
46
+ * Groups an array of attribute entries by their dimension name.
47
+ * Returns an object whose keys are dimension names and values are configuration objects
48
+ * that can be passed to createDimension.
49
+ */
50
+ const groupAttributesByDimension = (entries) => entries.reduce((acc, { dimension, attribute }) => {
51
+ const dimensionConfig = acc[dimension.name] || {
52
+ name: dimension.name,
53
+ expression: dimension.id,
54
+ };
55
+ return Object.assign(Object.assign({}, acc), { [dimension.name]: Object.assign(Object.assign({}, dimensionConfig), { [attribute.name]: attribute }) });
56
+ }, {});
@@ -2,7 +2,7 @@
2
2
  import { MetadataTypes } from './types.js';
3
3
  import { createMeasure } from './measures/measures.js';
4
4
  import { createFilter } from './filters/filters.js';
5
- import { createDimension } from './dimensions.js';
5
+ import { createDimension } from './dimensions/index.js';
6
6
  import { createAttribute } from './attributes.js';
7
7
  import { TranslatableError } from '../translation/translatable-error.js';
8
8
  /**
@@ -7,26 +7,26 @@ import { AnyObject } from '../types.js';
7
7
  * @internal
8
8
  */
9
9
  export declare const TextOperators: {
10
- Contains: string;
11
- StartsWith: string;
12
- EndsWith: string;
13
- Equals: string;
14
- DoesntEqual: string;
15
- DoesntStartWith: string;
16
- DoesntContain: string;
17
- DoesntEndWith: string;
18
- Like: string;
10
+ readonly Contains: "contains";
11
+ readonly StartsWith: "startsWith";
12
+ readonly EndsWith: "endsWith";
13
+ readonly Equals: "equals";
14
+ readonly DoesntEqual: "doesntEqual";
15
+ readonly DoesntStartWith: "doesntStartWith";
16
+ readonly DoesntContain: "doesntContain";
17
+ readonly DoesntEndWith: "doesntEndWith";
18
+ readonly Like: "like";
19
19
  };
20
20
  /**
21
21
  * Different numeric operators that can be used with numeric filters
22
22
  */
23
23
  export declare const NumericOperators: {
24
- Equals: string;
25
- DoesntEqual: string;
26
- From: string;
27
- FromNotEqual: string;
28
- To: string;
29
- ToNotEqual: string;
24
+ readonly Equals: "equals";
25
+ readonly DoesntEqual: "doesntEqual";
26
+ readonly From: "from";
27
+ readonly FromNotEqual: "fromNotEqual";
28
+ readonly To: "to";
29
+ readonly ToNotEqual: "toNotEqual";
30
30
  };
31
31
  /**
32
32
  * Different date operators that can be used with date filters
@@ -56,8 +56,8 @@ export declare const LogicalOperators: {
56
56
  * @internal
57
57
  */
58
58
  export declare const RankingOperators: {
59
- Top: string;
60
- Bottom: string;
59
+ readonly Top: "top";
60
+ readonly Bottom: "bottom";
61
61
  };
62
62
  /**
63
63
  * Different filter types
@@ -65,17 +65,17 @@ export declare const RankingOperators: {
65
65
  * @internal
66
66
  */
67
67
  export declare const FilterTypes: {
68
- logicalAttribute: string;
69
- members: string;
70
- exclude: string;
71
- measure: string;
72
- ranking: string;
73
- text: string;
74
- numeric: string;
75
- dateRange: string;
76
- relativeDate: string;
77
- cascading: string;
78
- advanced: string;
68
+ readonly logicalAttribute: "logicalAttribute";
69
+ readonly members: "members";
70
+ readonly exclude: "exclude";
71
+ readonly measure: "measure";
72
+ readonly ranking: "ranking";
73
+ readonly text: "text";
74
+ readonly numeric: "numeric";
75
+ readonly dateRange: "dateRange";
76
+ readonly relativeDate: "relativeDate";
77
+ readonly cascading: "cascading";
78
+ readonly advanced: "advanced";
79
79
  };
80
80
  /**
81
81
  * base implementation for filter classes
@@ -153,6 +153,7 @@ export declare class MembersFilter extends AbstractFilter {
153
153
  * gets the element's ID
154
154
  */
155
155
  get id(): string;
156
+ get name(): string;
156
157
  /**
157
158
  * Gets a serializable representation of the element
158
159
  */
@@ -6,6 +6,7 @@ import { DimensionalBaseMeasure } from '../measures/measures.js';
6
6
  import { TranslatableError } from '../../translation/translatable-error.js';
7
7
  import { getDefaultBaseFilterConfig, getDefaultMembersFilterConfig, } from './filter-config-utils.js';
8
8
  import merge from 'lodash-es/merge.js';
9
+ import omit from 'lodash-es/omit.js';
9
10
  /**
10
11
  * Different text operators that can be used with text filters
11
12
  *
@@ -210,6 +211,10 @@ export class MembersFilter extends AbstractFilter {
210
211
  get id() {
211
212
  return `${this.attribute.id}_${this.members.map((m) => m.toString()).join()}`;
212
213
  }
214
+ get name() {
215
+ // to hexadecimal string
216
+ return hash([this.jaql(), omit(this.config, ['guid', 'originalFilterJaql'])]).toString(16);
217
+ }
213
218
  /**
214
219
  * Gets a serializable representation of the element
215
220
  */