@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.
- 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 +29 -28
- package/dist/cjs/dimensional-model/filters/filters.js +5 -0
- package/dist/cjs/dimensional-model/jaql-element.d.ts +3 -2
- package/dist/cjs/dimensional-model/jaql-element.js +2 -2
- 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 +29 -28
- package/dist/dimensional-model/filters/filters.js +5 -0
- package/dist/dimensional-model/jaql-element.d.ts +3 -2
- package/dist/dimensional-model/jaql-element.js +3 -3
- 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
|
}
|
|
@@ -7,26 +7,26 @@ import { AnyObject } from '../types.js';
|
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
9
|
export declare const TextOperators: {
|
|
10
|
-
Contains:
|
|
11
|
-
StartsWith:
|
|
12
|
-
EndsWith:
|
|
13
|
-
Equals:
|
|
14
|
-
DoesntEqual:
|
|
15
|
-
DoesntStartWith:
|
|
16
|
-
DoesntContain:
|
|
17
|
-
DoesntEndWith:
|
|
18
|
-
Like:
|
|
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:
|
|
25
|
-
DoesntEqual:
|
|
26
|
-
From:
|
|
27
|
-
FromNotEqual:
|
|
28
|
-
To:
|
|
29
|
-
ToNotEqual:
|
|
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:
|
|
60
|
-
Bottom:
|
|
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:
|
|
69
|
-
members:
|
|
70
|
-
exclude:
|
|
71
|
-
measure:
|
|
72
|
-
ranking:
|
|
73
|
-
text:
|
|
74
|
-
numeric:
|
|
75
|
-
dateRange:
|
|
76
|
-
relativeDate:
|
|
77
|
-
cascading:
|
|
78
|
-
advanced:
|
|
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
|
*/
|
|
@@ -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
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DimensionalElement } from './base.js';
|
|
2
2
|
import { SortDirection } from './interfaces.js';
|
|
3
|
-
import { MetadataItem } from './types.js';
|
|
3
|
+
import { MetadataItem, MetadataItemJaql } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* This implementation wraps metadata for a JAQL query. The metadata could be
|
|
6
6
|
* for a dimension, measure, or filter. We do little to no interpretation of
|
|
@@ -24,7 +24,8 @@ export declare class JaqlElement extends DimensionalElement {
|
|
|
24
24
|
sortType?: SortDirection;
|
|
25
25
|
constructor(item: MetadataItem, type: string);
|
|
26
26
|
get id(): string;
|
|
27
|
-
jaql():
|
|
27
|
+
jaql(nested?: true): MetadataItemJaql;
|
|
28
|
+
jaql(nested?: false | undefined): MetadataItem;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Create a JaqlElement from a MetadataItem
|
|
@@ -47,8 +47,8 @@ class JaqlElement extends base_js_1.DimensionalElement {
|
|
|
47
47
|
get id() {
|
|
48
48
|
return this.expression;
|
|
49
49
|
}
|
|
50
|
-
jaql() {
|
|
51
|
-
return this.metadataItem;
|
|
50
|
+
jaql(nested) {
|
|
51
|
+
return nested === true ? this.metadataItem.jaql : this.metadataItem;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
exports.JaqlElement = JaqlElement;
|
|
@@ -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);
|