@sisense/sdk-data 1.31.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.
- package/dist/cjs/dimensional-model/attributes.d.ts +4 -2
- package/dist/cjs/dimensional-model/attributes.js +17 -3
- package/dist/cjs/dimensional-model/dimensions/__mocks__/sample-ecommerce-fields.d.ts +5 -0
- package/dist/cjs/dimensional-model/dimensions/__mocks__/sample-ecommerce-fields.js +246 -0
- package/dist/cjs/dimensional-model/{dimensions.d.ts → dimensions/dimensions.d.ts} +3 -3
- package/dist/cjs/dimensional-model/{dimensions.js → dimensions/dimensions.js} +3 -3
- package/dist/cjs/dimensional-model/dimensions/index.d.ts +2 -0
- package/dist/cjs/dimensional-model/dimensions/index.js +18 -0
- package/dist/cjs/dimensional-model/dimensions/utils.d.ts +11 -0
- package/dist/cjs/dimensional-model/dimensions/utils.js +60 -0
- package/dist/cjs/dimensional-model/factory.js +2 -2
- package/dist/cjs/dimensional-model/filters/filters.d.ts +1 -0
- package/dist/cjs/dimensional-model/filters/filters.js +5 -0
- package/dist/cjs/dimensional-model/types.d.ts +2 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/utils.d.ts +6 -6
- package/dist/cjs/utils.js +7 -8
- package/dist/dimensional-model/attributes.d.ts +4 -2
- package/dist/dimensional-model/attributes.js +17 -3
- package/dist/dimensional-model/dimensions/__mocks__/sample-ecommerce-fields.d.ts +5 -0
- package/dist/dimensional-model/dimensions/__mocks__/sample-ecommerce-fields.js +243 -0
- package/dist/dimensional-model/{dimensions.d.ts → dimensions/dimensions.d.ts} +3 -3
- package/dist/dimensional-model/{dimensions.js → dimensions/dimensions.js} +3 -3
- package/dist/dimensional-model/dimensions/index.d.ts +2 -0
- package/dist/dimensional-model/dimensions/index.js +2 -0
- package/dist/dimensional-model/dimensions/utils.d.ts +11 -0
- package/dist/dimensional-model/dimensions/utils.js +56 -0
- package/dist/dimensional-model/factory.js +1 -1
- package/dist/dimensional-model/filters/filters.d.ts +1 -0
- package/dist/dimensional-model/filters/filters.js +5 -0
- package/dist/dimensional-model/types.d.ts +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -1
- package/dist/utils.d.ts +6 -6
- package/dist/utils.js +7 -8
- package/package.json +3 -3
|
@@ -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
|
-
|
|
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
|
*/
|
|
@@ -13,10 +13,14 @@ exports.jaqlSimpleColumnType = jaqlSimpleColumnType;
|
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
15
|
class DimensionalAttribute extends base_js_1.DimensionalElement {
|
|
16
|
-
constructor(name, expression, type, desc, sort, dataSource, composeCode) {
|
|
16
|
+
constructor(name, expression, type, desc, sort, dataSource, composeCode, panel) {
|
|
17
17
|
super(name, type || types_js_1.MetadataTypes.Attribute, desc, dataSource, composeCode);
|
|
18
18
|
this._sort = types_js_1.Sort.None;
|
|
19
19
|
this.expression = expression;
|
|
20
|
+
// panel is not needed in most cases, this is to support break by columns functionality
|
|
21
|
+
if (panel === 'columns') {
|
|
22
|
+
this.panel = panel;
|
|
23
|
+
}
|
|
20
24
|
this._sort = sort || types_js_1.Sort.None;
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
@@ -40,7 +44,7 @@ class DimensionalAttribute extends base_js_1.DimensionalElement {
|
|
|
40
44
|
* @returns An instance representing the sorted {@link Attribute} of this instance
|
|
41
45
|
*/
|
|
42
46
|
sort(sort) {
|
|
43
|
-
return new DimensionalAttribute(this.name, this.expression, this.type, this.description, sort, this.dataSource, this.composeCode);
|
|
47
|
+
return new DimensionalAttribute(this.name, this.expression, this.type, this.description, sort, this.dataSource, this.composeCode, this.panel);
|
|
44
48
|
}
|
|
45
49
|
/**
|
|
46
50
|
* Gets the JAQL representation of this instance
|
|
@@ -55,6 +59,9 @@ class DimensionalAttribute extends base_js_1.DimensionalElement {
|
|
|
55
59
|
datatype: (0, exports.jaqlSimpleColumnType)(this.type),
|
|
56
60
|
},
|
|
57
61
|
};
|
|
62
|
+
if (this.panel) {
|
|
63
|
+
result.panel = this.panel;
|
|
64
|
+
}
|
|
58
65
|
if (this._sort != types_js_1.Sort.None) {
|
|
59
66
|
result.jaql.sort = this._sort == types_js_1.Sort.Ascending ? 'asc' : 'desc';
|
|
60
67
|
}
|
|
@@ -77,10 +84,14 @@ exports.DimensionalAttribute = DimensionalAttribute;
|
|
|
77
84
|
* @internal
|
|
78
85
|
*/
|
|
79
86
|
class DimensionalLevelAttribute extends DimensionalAttribute {
|
|
80
|
-
constructor(l, expression, granularity, format, desc, sort, dataSource, composeCode) {
|
|
87
|
+
constructor(l, expression, granularity, format, desc, sort, dataSource, composeCode, panel) {
|
|
81
88
|
super(l, expression, types_js_1.MetadataTypes.DateLevel, desc, sort, dataSource, composeCode);
|
|
82
89
|
this._format = format;
|
|
83
90
|
this.granularity = granularity;
|
|
91
|
+
// panel is not needed in most cases, this is to support break by columns functionality
|
|
92
|
+
if (panel === 'columns') {
|
|
93
|
+
this.panel = panel;
|
|
94
|
+
}
|
|
84
95
|
}
|
|
85
96
|
/**
|
|
86
97
|
* gets the element's ID
|
|
@@ -148,6 +159,9 @@ class DimensionalLevelAttribute extends DimensionalAttribute {
|
|
|
148
159
|
const r = {
|
|
149
160
|
jaql: Object.assign({ title: this.name, dim: this.expression, datatype: (0, exports.jaqlSimpleColumnType)(this.type) }, this.translateGranularityToJaql()),
|
|
150
161
|
};
|
|
162
|
+
if (this.panel) {
|
|
163
|
+
r.panel = this.panel;
|
|
164
|
+
}
|
|
151
165
|
if (this._format !== undefined) {
|
|
152
166
|
const levelName = r.jaql.dateTimeLevel || r.jaql.level;
|
|
153
167
|
r.format = { mask: {} };
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sampleEcommerceFields = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Actual fields from the Sample ECommerce datasource returned by server.
|
|
6
|
+
*/
|
|
7
|
+
exports.sampleEcommerceFields = [
|
|
8
|
+
{
|
|
9
|
+
id: '[Brand.Brand]',
|
|
10
|
+
type: 'dimension',
|
|
11
|
+
dimtype: 'text',
|
|
12
|
+
title: 'Brand',
|
|
13
|
+
table: 'Brand',
|
|
14
|
+
column: 'Brand',
|
|
15
|
+
merged: false,
|
|
16
|
+
indexed: true,
|
|
17
|
+
tableDescription: null,
|
|
18
|
+
columnDescription: null,
|
|
19
|
+
tableTitle: null,
|
|
20
|
+
semanticIndex: false,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: '[Brand.Brand ID]',
|
|
24
|
+
type: 'dimension',
|
|
25
|
+
dimtype: 'numeric',
|
|
26
|
+
title: 'Brand ID',
|
|
27
|
+
table: 'Brand',
|
|
28
|
+
column: 'Brand ID',
|
|
29
|
+
merged: true,
|
|
30
|
+
indexed: false,
|
|
31
|
+
tableDescription: null,
|
|
32
|
+
columnDescription: null,
|
|
33
|
+
tableTitle: null,
|
|
34
|
+
semanticIndex: false,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: '[Category.Category]',
|
|
38
|
+
type: 'dimension',
|
|
39
|
+
dimtype: 'text',
|
|
40
|
+
title: 'Category',
|
|
41
|
+
table: 'Category',
|
|
42
|
+
column: 'Category',
|
|
43
|
+
merged: false,
|
|
44
|
+
indexed: true,
|
|
45
|
+
tableDescription: null,
|
|
46
|
+
columnDescription: null,
|
|
47
|
+
tableTitle: null,
|
|
48
|
+
semanticIndex: false,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: '[Category.Category ID]',
|
|
52
|
+
type: 'dimension',
|
|
53
|
+
dimtype: 'numeric',
|
|
54
|
+
title: 'Category ID',
|
|
55
|
+
table: 'Category',
|
|
56
|
+
column: 'Category ID',
|
|
57
|
+
merged: true,
|
|
58
|
+
indexed: false,
|
|
59
|
+
tableDescription: null,
|
|
60
|
+
columnDescription: null,
|
|
61
|
+
tableTitle: null,
|
|
62
|
+
semanticIndex: false,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: '[Commerce.Age Range]',
|
|
66
|
+
type: 'dimension',
|
|
67
|
+
dimtype: 'text',
|
|
68
|
+
title: 'Age Range',
|
|
69
|
+
table: 'Commerce',
|
|
70
|
+
column: 'Age Range',
|
|
71
|
+
merged: false,
|
|
72
|
+
indexed: true,
|
|
73
|
+
tableDescription: null,
|
|
74
|
+
columnDescription: null,
|
|
75
|
+
tableTitle: null,
|
|
76
|
+
semanticIndex: false,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: '[Commerce.Brand ID]',
|
|
80
|
+
type: 'dimension',
|
|
81
|
+
dimtype: 'numeric',
|
|
82
|
+
title: 'Brand ID',
|
|
83
|
+
table: 'Commerce',
|
|
84
|
+
column: 'Brand ID',
|
|
85
|
+
merged: true,
|
|
86
|
+
indexed: false,
|
|
87
|
+
tableDescription: null,
|
|
88
|
+
columnDescription: null,
|
|
89
|
+
tableTitle: null,
|
|
90
|
+
semanticIndex: false,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: '[Commerce.Category ID]',
|
|
94
|
+
type: 'dimension',
|
|
95
|
+
dimtype: 'numeric',
|
|
96
|
+
title: 'Category ID',
|
|
97
|
+
table: 'Commerce',
|
|
98
|
+
column: 'Category ID',
|
|
99
|
+
merged: true,
|
|
100
|
+
indexed: false,
|
|
101
|
+
tableDescription: null,
|
|
102
|
+
columnDescription: null,
|
|
103
|
+
tableTitle: null,
|
|
104
|
+
semanticIndex: false,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: '[Commerce.Condition]',
|
|
108
|
+
type: 'dimension',
|
|
109
|
+
dimtype: 'text',
|
|
110
|
+
title: 'Condition',
|
|
111
|
+
table: 'Commerce',
|
|
112
|
+
column: 'Condition',
|
|
113
|
+
merged: false,
|
|
114
|
+
indexed: true,
|
|
115
|
+
tableDescription: null,
|
|
116
|
+
columnDescription: null,
|
|
117
|
+
tableTitle: null,
|
|
118
|
+
semanticIndex: false,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: '[Commerce.Cost]',
|
|
122
|
+
type: 'dimension',
|
|
123
|
+
dimtype: 'numeric',
|
|
124
|
+
title: 'Cost',
|
|
125
|
+
table: 'Commerce',
|
|
126
|
+
column: 'Cost',
|
|
127
|
+
merged: false,
|
|
128
|
+
indexed: false,
|
|
129
|
+
tableDescription: null,
|
|
130
|
+
columnDescription: null,
|
|
131
|
+
tableTitle: null,
|
|
132
|
+
semanticIndex: false,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: '[Commerce.Country ID]',
|
|
136
|
+
type: 'dimension',
|
|
137
|
+
dimtype: 'numeric',
|
|
138
|
+
title: 'Country ID',
|
|
139
|
+
table: 'Commerce',
|
|
140
|
+
column: 'Country ID',
|
|
141
|
+
merged: true,
|
|
142
|
+
indexed: false,
|
|
143
|
+
tableDescription: null,
|
|
144
|
+
columnDescription: null,
|
|
145
|
+
tableTitle: null,
|
|
146
|
+
semanticIndex: false,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
id: '[Commerce.Date (Calendar)]',
|
|
150
|
+
type: 'dimension',
|
|
151
|
+
dimtype: 'datetime',
|
|
152
|
+
title: 'Date',
|
|
153
|
+
table: 'Commerce',
|
|
154
|
+
column: 'Date',
|
|
155
|
+
merged: false,
|
|
156
|
+
indexed: true,
|
|
157
|
+
tableDescription: null,
|
|
158
|
+
columnDescription: null,
|
|
159
|
+
tableTitle: null,
|
|
160
|
+
semanticIndex: false,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: '[Commerce.Gender]',
|
|
164
|
+
type: 'dimension',
|
|
165
|
+
dimtype: 'text',
|
|
166
|
+
title: 'Gender',
|
|
167
|
+
table: 'Commerce',
|
|
168
|
+
column: 'Gender',
|
|
169
|
+
merged: false,
|
|
170
|
+
indexed: true,
|
|
171
|
+
tableDescription: null,
|
|
172
|
+
columnDescription: null,
|
|
173
|
+
tableTitle: null,
|
|
174
|
+
semanticIndex: false,
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
id: '[Commerce.Quantity]',
|
|
178
|
+
type: 'dimension',
|
|
179
|
+
dimtype: 'numeric',
|
|
180
|
+
title: 'Quantity',
|
|
181
|
+
table: 'Commerce',
|
|
182
|
+
column: 'Quantity',
|
|
183
|
+
merged: false,
|
|
184
|
+
indexed: false,
|
|
185
|
+
tableDescription: null,
|
|
186
|
+
columnDescription: null,
|
|
187
|
+
tableTitle: null,
|
|
188
|
+
semanticIndex: false,
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
id: '[Commerce.Revenue]',
|
|
192
|
+
type: 'dimension',
|
|
193
|
+
dimtype: 'numeric',
|
|
194
|
+
title: 'Revenue',
|
|
195
|
+
table: 'Commerce',
|
|
196
|
+
column: 'Revenue',
|
|
197
|
+
merged: false,
|
|
198
|
+
indexed: false,
|
|
199
|
+
tableDescription: null,
|
|
200
|
+
columnDescription: null,
|
|
201
|
+
tableTitle: null,
|
|
202
|
+
semanticIndex: false,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
id: '[Commerce.Visit ID]',
|
|
206
|
+
type: 'dimension',
|
|
207
|
+
dimtype: 'numeric',
|
|
208
|
+
title: 'Visit ID',
|
|
209
|
+
table: 'Commerce',
|
|
210
|
+
column: 'Visit ID',
|
|
211
|
+
merged: false,
|
|
212
|
+
indexed: false,
|
|
213
|
+
tableDescription: null,
|
|
214
|
+
columnDescription: null,
|
|
215
|
+
tableTitle: null,
|
|
216
|
+
semanticIndex: false,
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
id: '[Country.Country]',
|
|
220
|
+
type: 'dimension',
|
|
221
|
+
dimtype: 'text',
|
|
222
|
+
title: 'Country',
|
|
223
|
+
table: 'Country',
|
|
224
|
+
column: 'Country',
|
|
225
|
+
merged: false,
|
|
226
|
+
indexed: true,
|
|
227
|
+
tableDescription: null,
|
|
228
|
+
columnDescription: null,
|
|
229
|
+
tableTitle: null,
|
|
230
|
+
semanticIndex: false,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
id: '[Country.Country ID]',
|
|
234
|
+
type: 'dimension',
|
|
235
|
+
dimtype: 'numeric',
|
|
236
|
+
title: 'Country ID',
|
|
237
|
+
table: 'Country',
|
|
238
|
+
column: 'Country ID',
|
|
239
|
+
merged: true,
|
|
240
|
+
indexed: false,
|
|
241
|
+
tableDescription: null,
|
|
242
|
+
columnDescription: null,
|
|
243
|
+
tableTitle: null,
|
|
244
|
+
semanticIndex: false,
|
|
245
|
+
},
|
|
246
|
+
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Attribute, LevelAttribute, Dimension, DateDimension } from '
|
|
2
|
-
import { Sort, JaqlDataSource } from '
|
|
3
|
-
import { DimensionalElement } from '
|
|
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,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createDateDimension = exports.createDimension = exports.DimensionalDateDimension = exports.DimensionalDimension = void 0;
|
|
4
|
-
const types_js_1 = require("
|
|
5
|
-
const attributes_js_1 = require("
|
|
6
|
-
const base_js_1 = require("
|
|
4
|
+
const types_js_1 = require("../types.js");
|
|
5
|
+
const attributes_js_1 = require("../attributes.js");
|
|
6
|
+
const base_js_1 = require("../base.js");
|
|
7
7
|
/**
|
|
8
8
|
* Represents a Dimension in a Dimensional Model
|
|
9
9
|
*
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./dimensions.js"), exports);
|
|
18
|
+
__exportStar(require("./utils.js"), exports);
|
|
@@ -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,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDimensionsFromDataSourceFields = void 0;
|
|
4
|
+
const attributes_js_1 = require("../attributes.js");
|
|
5
|
+
const dimensions_js_1 = require("./dimensions.js");
|
|
6
|
+
/**
|
|
7
|
+
* Function to convert data source fields to dimensions.
|
|
8
|
+
* @param fields - The data source fields to convert.
|
|
9
|
+
* @param dataSource - The data source title.
|
|
10
|
+
* @returns - The dimensions created from the data source fields.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
function getDimensionsFromDataSourceFields(fields, dataSource) {
|
|
14
|
+
const attributeEntries = fields.map((field) => createAttributeEntry(field, dataSource));
|
|
15
|
+
const groupedConfigs = groupAttributesByDimension(attributeEntries);
|
|
16
|
+
return Object.values(groupedConfigs).map((config) => (0, dimensions_js_1.createDimension)(config));
|
|
17
|
+
}
|
|
18
|
+
exports.getDimensionsFromDataSourceFields = getDimensionsFromDataSourceFields;
|
|
19
|
+
/**
|
|
20
|
+
* Given a DataSourceField and the data source title, creates an attribute entry
|
|
21
|
+
* that includes the dimension name, attribute name, and the attribute itself.
|
|
22
|
+
*/
|
|
23
|
+
const createAttributeEntry = (field, dataSource) => {
|
|
24
|
+
const dimensionId = field.table;
|
|
25
|
+
const dimensionName = field.tableTitle || dimensionId;
|
|
26
|
+
const attributeId = field.id;
|
|
27
|
+
const attributeName = field.title || attributeId;
|
|
28
|
+
const dataSourceConfig = { title: dataSource, live: false };
|
|
29
|
+
const attribute = field.dimtype === 'datetime'
|
|
30
|
+
? (0, dimensions_js_1.createDateDimension)({
|
|
31
|
+
name: attributeName,
|
|
32
|
+
expression: attributeId,
|
|
33
|
+
dataSource: dataSourceConfig,
|
|
34
|
+
})
|
|
35
|
+
: (0, attributes_js_1.createAttribute)({
|
|
36
|
+
name: attributeName,
|
|
37
|
+
type: field.dimtype === 'text' ? 'text-attribute' : 'numeric-attribute',
|
|
38
|
+
expression: attributeId,
|
|
39
|
+
dataSource: dataSourceConfig,
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
dimension: {
|
|
43
|
+
id: dimensionId,
|
|
44
|
+
name: dimensionName,
|
|
45
|
+
},
|
|
46
|
+
attribute,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Groups an array of attribute entries by their dimension name.
|
|
51
|
+
* Returns an object whose keys are dimension names and values are configuration objects
|
|
52
|
+
* that can be passed to createDimension.
|
|
53
|
+
*/
|
|
54
|
+
const groupAttributesByDimension = (entries) => entries.reduce((acc, { dimension, attribute }) => {
|
|
55
|
+
const dimensionConfig = acc[dimension.name] || {
|
|
56
|
+
name: dimension.name,
|
|
57
|
+
expression: dimension.id,
|
|
58
|
+
};
|
|
59
|
+
return Object.assign(Object.assign({}, acc), { [dimension.name]: Object.assign(Object.assign({}, dimensionConfig), { [attribute.name]: attribute }) });
|
|
60
|
+
}, {});
|
|
@@ -5,7 +5,7 @@ exports.create = exports.createAll = void 0;
|
|
|
5
5
|
const types_js_1 = require("./types.js");
|
|
6
6
|
const measures_js_1 = require("./measures/measures.js");
|
|
7
7
|
const filters_js_1 = require("./filters/filters.js");
|
|
8
|
-
const
|
|
8
|
+
const index_js_1 = require("./dimensions/index.js");
|
|
9
9
|
const attributes_js_1 = require("./attributes.js");
|
|
10
10
|
const translatable_error_js_1 = require("../translation/translatable-error.js");
|
|
11
11
|
/**
|
|
@@ -47,7 +47,7 @@ function create(item) {
|
|
|
47
47
|
item.type === 'dimension' ||
|
|
48
48
|
item.attributes ||
|
|
49
49
|
item.dimtype) {
|
|
50
|
-
return (0,
|
|
50
|
+
return (0, index_js_1.createDimension)(item);
|
|
51
51
|
}
|
|
52
52
|
throw new translatable_error_js_1.TranslatableError('errors.unsupportedDimensionalElement');
|
|
53
53
|
}
|
|
@@ -12,6 +12,7 @@ const measures_js_1 = require("../measures/measures.js");
|
|
|
12
12
|
const translatable_error_js_1 = require("../../translation/translatable-error.js");
|
|
13
13
|
const filter_config_utils_js_1 = require("./filter-config-utils.js");
|
|
14
14
|
const merge_js_1 = __importDefault(require("lodash-es/merge.js"));
|
|
15
|
+
const omit_js_1 = __importDefault(require("lodash-es/omit.js"));
|
|
15
16
|
/**
|
|
16
17
|
* Different text operators that can be used with text filters
|
|
17
18
|
*
|
|
@@ -217,6 +218,10 @@ class MembersFilter extends AbstractFilter {
|
|
|
217
218
|
get id() {
|
|
218
219
|
return `${this.attribute.id}_${this.members.map((m) => m.toString()).join()}`;
|
|
219
220
|
}
|
|
221
|
+
get name() {
|
|
222
|
+
// to hexadecimal string
|
|
223
|
+
return (0, hash_it_1.default)([this.jaql(), (0, omit_js_1.default)(this.config, ['guid', 'originalFilterJaql'])]).toString(16);
|
|
224
|
+
}
|
|
220
225
|
/**
|
|
221
226
|
* Gets a serializable representation of the element
|
|
222
227
|
*/
|
|
@@ -197,6 +197,7 @@ export declare type BaseJaql = {
|
|
|
197
197
|
};
|
|
198
198
|
};
|
|
199
199
|
merged?: boolean;
|
|
200
|
+
panel?: 'rows' | 'columns';
|
|
200
201
|
};
|
|
201
202
|
/** @internal */
|
|
202
203
|
export declare type FormulaID = string;
|
|
@@ -403,6 +404,7 @@ export declare type DataSourceField = {
|
|
|
403
404
|
indexed: boolean;
|
|
404
405
|
merged: boolean;
|
|
405
406
|
table: string;
|
|
407
|
+
tableTitle?: null | string;
|
|
406
408
|
title: string;
|
|
407
409
|
type: string;
|
|
408
410
|
};
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export * from './dimensional-model/interfaces.js';
|
|
|
12
12
|
export * from './dimensional-model/base.js';
|
|
13
13
|
export * from './dimensional-model/data-model.js';
|
|
14
14
|
export * from './dimensional-model/attributes.js';
|
|
15
|
-
export * from './dimensional-model/dimensions.js';
|
|
15
|
+
export * from './dimensional-model/dimensions/index.js';
|
|
16
16
|
export * from './dimensional-model/factory.js';
|
|
17
17
|
export * from './dimensional-model/jaql-element.js';
|
|
18
18
|
export * from './dimensional-model/filters/filters.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -41,7 +41,7 @@ __exportStar(require("./dimensional-model/interfaces.js"), exports);
|
|
|
41
41
|
__exportStar(require("./dimensional-model/base.js"), exports);
|
|
42
42
|
__exportStar(require("./dimensional-model/data-model.js"), exports);
|
|
43
43
|
__exportStar(require("./dimensional-model/attributes.js"), exports);
|
|
44
|
-
__exportStar(require("./dimensional-model/dimensions.js"), exports);
|
|
44
|
+
__exportStar(require("./dimensional-model/dimensions/index.js"), exports);
|
|
45
45
|
__exportStar(require("./dimensional-model/factory.js"), exports);
|
|
46
46
|
__exportStar(require("./dimensional-model/jaql-element.js"), exports);
|
|
47
47
|
__exportStar(require("./dimensional-model/filters/filters.js"), exports);
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -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
|
}
|