@sisense/sdk-data 1.11.0 → 1.12.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/analytics/factory.d.ts +47 -0
- package/dist/cjs/dimensional-model/analytics/factory.js +151 -0
- package/dist/cjs/dimensional-model/analytics/factory.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/analytics/factory.test.js +99 -0
- package/dist/cjs/dimensional-model/attributes.d.ts +139 -0
- package/dist/cjs/dimensional-model/attributes.js +342 -0
- package/dist/cjs/dimensional-model/attributes.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/attributes.test.js +154 -0
- package/dist/cjs/dimensional-model/base.d.ts +43 -0
- package/dist/cjs/dimensional-model/base.js +58 -0
- package/dist/cjs/dimensional-model/base.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/base.test.js +17 -0
- package/dist/cjs/dimensional-model/data-model.d.ts +13 -0
- package/dist/cjs/dimensional-model/data-model.js +37 -0
- package/dist/cjs/dimensional-model/dimensions.d.ts +167 -0
- package/dist/cjs/dimensional-model/dimensions.js +307 -0
- package/dist/cjs/dimensional-model/dimensions.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/dimensions.test.js +54 -0
- package/dist/cjs/dimensional-model/factory.d.ts +17 -0
- package/dist/cjs/dimensional-model/factory.js +54 -0
- package/dist/cjs/dimensional-model/filters/factory.d.ts +796 -0
- package/dist/cjs/dimensional-model/filters/factory.js +962 -0
- package/dist/cjs/dimensional-model/filters/factory.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/filters/factory.test.js +366 -0
- package/dist/cjs/dimensional-model/filters/filters.d.ts +321 -0
- package/dist/cjs/dimensional-model/filters/filters.js +614 -0
- package/dist/cjs/dimensional-model/filters/filters.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/filters/filters.test.js +225 -0
- package/dist/cjs/dimensional-model/filters/utils/attribute-measure-util.d.ts +47 -0
- package/dist/cjs/dimensional-model/filters/utils/attribute-measure-util.js +111 -0
- package/dist/cjs/dimensional-model/filters/utils/condition-filter-util.d.ts +21 -0
- package/dist/cjs/dimensional-model/filters/utils/condition-filter-util.js +194 -0
- package/dist/cjs/dimensional-model/filters/utils/date-time-filter-util.d.ts +2 -0
- package/dist/cjs/dimensional-model/filters/utils/date-time-filter-util.js +12 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-code-util.d.ts +13 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-code-util.js +54 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-code-util.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-code-util.test.js +32 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-from-jaql-util.d.ts +73 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-from-jaql-util.js +190 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-from-jaql-util.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-from-jaql-util.test.js +558 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-matcher-utils.d.ts +5 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-matcher-utils.js +174 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-matcher-utils.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-matcher-utils.test.js +236 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-types-util.d.ts +17 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-types-util.js +79 -0
- package/dist/cjs/dimensional-model/filters/utils/types.d.ts +200 -0
- package/dist/cjs/dimensional-model/filters/utils/types.js +99 -0
- package/dist/cjs/dimensional-model/interfaces.d.ts +512 -0
- package/dist/cjs/dimensional-model/interfaces.js +31 -0
- package/dist/cjs/dimensional-model/measures/factory.d.ts +920 -0
- package/dist/cjs/dimensional-model/measures/factory.js +1188 -0
- package/dist/cjs/dimensional-model/measures/factory.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/measures/factory.test.js +481 -0
- package/dist/cjs/dimensional-model/measures/measures.d.ts +217 -0
- package/dist/cjs/dimensional-model/measures/measures.js +416 -0
- package/dist/cjs/dimensional-model/measures/measures.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/measures/measures.test.js +79 -0
- package/dist/cjs/dimensional-model/simple-column-types.d.ts +39 -0
- package/dist/cjs/dimensional-model/simple-column-types.js +134 -0
- package/dist/cjs/dimensional-model/simple-column-types.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/simple-column-types.test.js +85 -0
- package/dist/cjs/dimensional-model/types.d.ts +256 -0
- package/dist/cjs/dimensional-model/types.js +298 -0
- package/dist/cjs/dimensional-model/types.test.d.ts +1 -0
- package/dist/cjs/dimensional-model/types.test.js +33 -0
- package/dist/cjs/index.d.ts +93 -0
- package/dist/cjs/index.js +123 -0
- package/dist/cjs/interfaces.d.ts +367 -0
- package/dist/cjs/interfaces.js +21 -0
- package/dist/cjs/translation/initialize-i18n.d.ts +2 -0
- package/dist/cjs/translation/initialize-i18n.js +14 -0
- package/dist/cjs/translation/resources/en.d.ts +28 -0
- package/dist/cjs/translation/resources/en.js +30 -0
- package/dist/cjs/translation/resources/index.d.ts +53 -0
- package/dist/cjs/translation/resources/index.js +10 -0
- package/dist/cjs/translation/resources/uk.d.ts +5 -0
- package/dist/cjs/translation/resources/uk.js +30 -0
- package/dist/cjs/translation/translatable-error.d.ts +5 -0
- package/dist/cjs/translation/translatable-error.js +15 -0
- package/dist/cjs/utils.d.ts +37 -0
- package/dist/cjs/utils.js +105 -0
- package/dist/cjs/utils.test.d.ts +1 -0
- package/dist/cjs/utils.test.js +158 -0
- package/dist/dimensional-model/filters/factory.d.ts +80 -42
- package/dist/dimensional-model/filters/factory.js +123 -85
- package/dist/dimensional-model/filters/filters.d.ts +34 -12
- package/dist/dimensional-model/filters/filters.js +69 -27
- package/dist/dimensional-model/filters/utils/condition-filter-util.d.ts +4 -2
- package/dist/dimensional-model/filters/utils/condition-filter-util.js +27 -25
- package/dist/dimensional-model/filters/utils/filter-code-util.js +1 -1
- package/dist/dimensional-model/filters/utils/filter-from-jaql-util.d.ts +16 -10
- package/dist/dimensional-model/filters/utils/filter-from-jaql-util.js +34 -27
- package/package.json +18 -9
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
27
|
+
/* eslint-disable vitest/expect-expect */
|
|
28
|
+
const vitest_1 = require("vitest");
|
|
29
|
+
const filter_from_jaql_util_js_1 = require("./filter-from-jaql-util.js");
|
|
30
|
+
const filterFactory = __importStar(require("../factory.js"));
|
|
31
|
+
const types_js_1 = require("./types.js");
|
|
32
|
+
const attribute_measure_util_js_1 = require("./attribute-measure-util.js");
|
|
33
|
+
const condition_filter_util_js_1 = require("./condition-filter-util.js");
|
|
34
|
+
(0, vitest_1.describe)('filter-from-jaql-util', () => {
|
|
35
|
+
(0, vitest_1.describe)('createFilterFromJaqlInternal', () => {
|
|
36
|
+
const guid = 'instanceid';
|
|
37
|
+
const expectEqualFilters = (actual, expected) => {
|
|
38
|
+
// delete compose code
|
|
39
|
+
delete actual.composeCode;
|
|
40
|
+
expect(Object.assign({}, actual)).toEqual(Object.assign({}, expected));
|
|
41
|
+
expect(actual.serializable()).toBeDefined();
|
|
42
|
+
};
|
|
43
|
+
(0, vitest_1.describe)('MembersFilter', () => {
|
|
44
|
+
it('should handle include all', () => {
|
|
45
|
+
const jaql = {
|
|
46
|
+
table: 'Category',
|
|
47
|
+
column: 'Category',
|
|
48
|
+
dim: '[Category.Category]',
|
|
49
|
+
datatype: 'text',
|
|
50
|
+
filter: {
|
|
51
|
+
explicit: true,
|
|
52
|
+
multiSelection: true,
|
|
53
|
+
all: true,
|
|
54
|
+
},
|
|
55
|
+
title: 'Category',
|
|
56
|
+
};
|
|
57
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
58
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
59
|
+
const expectedFilter = filterFactory.members(attribute, [], guid);
|
|
60
|
+
expectEqualFilters(filter, expectedFilter);
|
|
61
|
+
});
|
|
62
|
+
it('should handle members text', () => {
|
|
63
|
+
const jaql = {
|
|
64
|
+
table: 'Category',
|
|
65
|
+
column: 'Category',
|
|
66
|
+
dim: '[Category.Category]',
|
|
67
|
+
datatype: 'text',
|
|
68
|
+
filter: {
|
|
69
|
+
explicit: true,
|
|
70
|
+
multiSelection: true,
|
|
71
|
+
members: ['Cell Phones', 'GPS Devices'],
|
|
72
|
+
},
|
|
73
|
+
title: 'Category',
|
|
74
|
+
};
|
|
75
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
76
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
77
|
+
const expectedFilter = filterFactory.members(attribute, jaql.filter.members, guid);
|
|
78
|
+
expectEqualFilters(filter, expectedFilter);
|
|
79
|
+
});
|
|
80
|
+
test('should handle members datetime', () => {
|
|
81
|
+
[
|
|
82
|
+
{
|
|
83
|
+
title: 'Years',
|
|
84
|
+
table: 'Commerce',
|
|
85
|
+
column: 'Date',
|
|
86
|
+
dim: '[Commerce.Date (Calendar)]',
|
|
87
|
+
datatype: 'datetime',
|
|
88
|
+
level: 'years',
|
|
89
|
+
filter: {
|
|
90
|
+
explicit: true,
|
|
91
|
+
multiSelection: true,
|
|
92
|
+
members: ['2013-01-01T00:00:00', '2011-01-01T00:00:00'],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
datasource: {
|
|
97
|
+
title: 'Sample ECommerce',
|
|
98
|
+
fullname: 'LocalHost/Sample ECommerce',
|
|
99
|
+
id: 'localhost_aSampleIAAaECommerce',
|
|
100
|
+
address: 'LocalHost',
|
|
101
|
+
database: 'aSampleIAAaECommerce',
|
|
102
|
+
},
|
|
103
|
+
column: 'Date',
|
|
104
|
+
dim: '[Commerce.Date (Calendar)]',
|
|
105
|
+
datatype: 'datetime',
|
|
106
|
+
level: 'years',
|
|
107
|
+
title: 'YEARS',
|
|
108
|
+
collapsed: true,
|
|
109
|
+
isDashboardFilter: true,
|
|
110
|
+
filter: {
|
|
111
|
+
explicit: true,
|
|
112
|
+
multiSelection: true,
|
|
113
|
+
members: ['2013-01-01T00:00:00'],
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
].forEach((jaql) => {
|
|
117
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
118
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
119
|
+
const expectedFilter = filterFactory.members(attribute, jaql.filter.members, guid);
|
|
120
|
+
expectEqualFilters(filter, expectedFilter);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
test('should handle JAQL without table name', () => {
|
|
124
|
+
const jaql = {
|
|
125
|
+
column: 'Category',
|
|
126
|
+
dim: '[Category.Category]',
|
|
127
|
+
datatype: 'text',
|
|
128
|
+
filter: {
|
|
129
|
+
explicit: true,
|
|
130
|
+
multiSelection: true,
|
|
131
|
+
members: ['Cell Phones', 'GPS Devices'],
|
|
132
|
+
},
|
|
133
|
+
title: 'Category',
|
|
134
|
+
};
|
|
135
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
136
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
137
|
+
const expectedFilter = filterFactory.members(attribute, jaql.filter.members, guid);
|
|
138
|
+
expectEqualFilters(filter, expectedFilter);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
(0, vitest_1.describe)('NumericFilter', () => {
|
|
142
|
+
test('should handle unary operator for number', () => {
|
|
143
|
+
[
|
|
144
|
+
{ operator: types_js_1.ConditionFilterType.GREATER_THAN, factoryFunc: filterFactory.greaterThan },
|
|
145
|
+
{
|
|
146
|
+
operator: types_js_1.ConditionFilterType.GREATER_THAN_OR_EQUAL,
|
|
147
|
+
factoryFunc: filterFactory.greaterThanOrEqual,
|
|
148
|
+
},
|
|
149
|
+
{ operator: types_js_1.ConditionFilterType.EQUALS, factoryFunc: filterFactory.equals },
|
|
150
|
+
{ operator: types_js_1.ConditionFilterType.LESS_THAN, factoryFunc: filterFactory.lessThan },
|
|
151
|
+
{
|
|
152
|
+
operator: types_js_1.ConditionFilterType.LESS_THAN_OR_EQUAL,
|
|
153
|
+
factoryFunc: filterFactory.lessThanOrEqual,
|
|
154
|
+
},
|
|
155
|
+
].forEach((test) => {
|
|
156
|
+
const jaql = {
|
|
157
|
+
table: 'Commerce',
|
|
158
|
+
column: 'Revenue',
|
|
159
|
+
datatype: 'numeric',
|
|
160
|
+
dim: '[Commerce.Revenue]',
|
|
161
|
+
title: 'Revenue',
|
|
162
|
+
filter: {
|
|
163
|
+
[test.operator]: 1000,
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
167
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
168
|
+
const expectedFilter = test.factoryFunc(attribute, jaql.filter[test.operator], guid);
|
|
169
|
+
expectEqualFilters(filter, expectedFilter);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
test('should handle unary operator for string', () => {
|
|
173
|
+
[
|
|
174
|
+
{ operator: types_js_1.ConditionFilterType.EQUALS, factoryFunc: filterFactory.equals },
|
|
175
|
+
{ operator: types_js_1.ConditionFilterType.STARTS_WITH, factoryFunc: filterFactory.startsWith },
|
|
176
|
+
{
|
|
177
|
+
operator: types_js_1.ConditionFilterType.DOESNT_START_WITH,
|
|
178
|
+
factoryFunc: filterFactory.doesntStartWith,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
operator: types_js_1.ConditionFilterType.ENDS_WITH,
|
|
182
|
+
factoryFunc: filterFactory.endsWith,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
operator: types_js_1.ConditionFilterType.DOESNT_END_WITH,
|
|
186
|
+
factoryFunc: filterFactory.doesntEndWith,
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
operator: types_js_1.ConditionFilterType.CONTAINS,
|
|
190
|
+
factoryFunc: filterFactory.contains,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
operator: types_js_1.ConditionFilterType.DOESNT_CONTAIN,
|
|
194
|
+
factoryFunc: filterFactory.doesntContain,
|
|
195
|
+
},
|
|
196
|
+
].forEach((test) => {
|
|
197
|
+
const jaql = {
|
|
198
|
+
table: 'Country',
|
|
199
|
+
column: 'Country',
|
|
200
|
+
datatype: 'text',
|
|
201
|
+
dim: '[Country.Country]',
|
|
202
|
+
title: 'Country',
|
|
203
|
+
filter: {
|
|
204
|
+
[test.operator]: 'ABC',
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
208
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
209
|
+
const expectedFilter = test.factoryFunc(attribute, jaql.filter[test.operator], guid);
|
|
210
|
+
expectEqualFilters(filter, expectedFilter);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
test('should handle binary operator', () => {
|
|
214
|
+
[{ operator: types_js_1.ConditionFilterType.BETWEEN, factoryFunc: filterFactory.between }].forEach((test) => {
|
|
215
|
+
const jaql = {
|
|
216
|
+
table: 'Commerce',
|
|
217
|
+
column: 'Revenue',
|
|
218
|
+
datatype: 'numeric',
|
|
219
|
+
dim: '[Commerce.Revenue]',
|
|
220
|
+
title: 'Revenue',
|
|
221
|
+
filter: {
|
|
222
|
+
from: 1000,
|
|
223
|
+
to: 2000,
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
227
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
228
|
+
const expectedFilter = test.factoryFunc(attribute, jaql.filter.from, jaql.filter.to, guid);
|
|
229
|
+
expectEqualFilters(filter, expectedFilter);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
test('should handle not between operator', () => {
|
|
233
|
+
const jaql = {
|
|
234
|
+
table: 'Commerce',
|
|
235
|
+
column: 'Revenue',
|
|
236
|
+
datatype: 'numeric',
|
|
237
|
+
dim: '[Commerce.Revenue]',
|
|
238
|
+
title: 'Revenue',
|
|
239
|
+
filter: {
|
|
240
|
+
exclude: {
|
|
241
|
+
from: 1000,
|
|
242
|
+
to: 2000,
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
247
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
248
|
+
const expectedFilter = filterFactory.exclude(filterFactory.between(attribute, jaql.filter.exclude.from, jaql.filter.exclude.to, guid), undefined, guid);
|
|
249
|
+
expectEqualFilters(filter.filter, expectedFilter.filter);
|
|
250
|
+
expect(filter.serializable()).toBeDefined();
|
|
251
|
+
expect(filter.id).toEqual(expectedFilter.id);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
(0, vitest_1.describe)('RelativeDateFilter', () => {
|
|
255
|
+
test('should handle dateRelativeFrom', () => {
|
|
256
|
+
[
|
|
257
|
+
{
|
|
258
|
+
jaql: {
|
|
259
|
+
title: 'Years',
|
|
260
|
+
table: 'Commerce',
|
|
261
|
+
column: 'Date',
|
|
262
|
+
dim: '[Commerce.Date (Calendar)]',
|
|
263
|
+
datatype: 'datetime',
|
|
264
|
+
level: 'months',
|
|
265
|
+
filter: {
|
|
266
|
+
next: {
|
|
267
|
+
count: 18,
|
|
268
|
+
offset: 0,
|
|
269
|
+
anchor: '2011-01',
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
factoryFunc: filterFactory.dateRelativeFrom,
|
|
274
|
+
},
|
|
275
|
+
].forEach(({ jaql, factoryFunc }) => {
|
|
276
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
277
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
278
|
+
const expectedFilter = factoryFunc(attribute, jaql.filter.next.offset, jaql.filter.next.count, jaql.filter.next.anchor, guid);
|
|
279
|
+
expectEqualFilters(filter, expectedFilter);
|
|
280
|
+
expect(filter.serializable()).toBeDefined();
|
|
281
|
+
expect(filter.jaql().jaql).toEqual(expectedFilter.jaql().jaql);
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
test('should handle dateRelativeTo', () => {
|
|
285
|
+
[
|
|
286
|
+
{
|
|
287
|
+
jaql: {
|
|
288
|
+
title: 'Years',
|
|
289
|
+
table: 'Commerce',
|
|
290
|
+
column: 'Date',
|
|
291
|
+
dim: '[Commerce.Date (Calendar)]',
|
|
292
|
+
datatype: 'datetime',
|
|
293
|
+
level: 'months',
|
|
294
|
+
filter: {
|
|
295
|
+
last: {
|
|
296
|
+
count: 18,
|
|
297
|
+
offset: 0,
|
|
298
|
+
anchor: '2011-01',
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
factoryFunc: filterFactory.dateRelativeTo,
|
|
303
|
+
},
|
|
304
|
+
].forEach(({ jaql, factoryFunc }) => {
|
|
305
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
306
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
307
|
+
const expectedFilter = factoryFunc(attribute, jaql.filter.last.offset, jaql.filter.last.count, jaql.filter.last.anchor, guid);
|
|
308
|
+
expectEqualFilters(filter, expectedFilter);
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
(0, vitest_1.describe)('DateRangeFilter', () => {
|
|
313
|
+
test('should handle', () => {
|
|
314
|
+
const jaql = {
|
|
315
|
+
title: 'Years',
|
|
316
|
+
table: 'Commerce',
|
|
317
|
+
column: 'Date',
|
|
318
|
+
dim: '[Commerce.Date (Calendar)]',
|
|
319
|
+
datatype: 'datetime',
|
|
320
|
+
level: 'years',
|
|
321
|
+
filter: {
|
|
322
|
+
from: '2010-01-01',
|
|
323
|
+
to: '2012-01-01',
|
|
324
|
+
},
|
|
325
|
+
};
|
|
326
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
327
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
328
|
+
const expectedFilter = filterFactory.dateRange(attribute, '2010-01-01', '2012-01-01', guid);
|
|
329
|
+
expectEqualFilters(filter, expectedFilter);
|
|
330
|
+
expect(filter.from).toBeDefined();
|
|
331
|
+
expect(filter.to).toBeDefined();
|
|
332
|
+
expect(filter.level).toBeDefined();
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
(0, vitest_1.describe)('RankingFilter', () => {
|
|
336
|
+
it('should handle top', () => {
|
|
337
|
+
const jaql = {
|
|
338
|
+
table: 'Brand',
|
|
339
|
+
column: 'Brand',
|
|
340
|
+
datatype: 'text',
|
|
341
|
+
title: 'Top 10 Brand by Total Revenue',
|
|
342
|
+
dim: '[Brand.Brand]',
|
|
343
|
+
filter: {
|
|
344
|
+
top: 10,
|
|
345
|
+
by: {
|
|
346
|
+
table: 'Commerce',
|
|
347
|
+
column: 'Revenue',
|
|
348
|
+
datatype: 'numeric',
|
|
349
|
+
title: 'sum Revenue',
|
|
350
|
+
dim: '[Commerce.Revenue]',
|
|
351
|
+
agg: 'sum',
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
};
|
|
355
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
356
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
357
|
+
const measure = (0, attribute_measure_util_js_1.createMeasureFromRankingFilterJaql)(jaql.filter.by);
|
|
358
|
+
const expectedFilter = filterFactory.topRanking(attribute, measure, jaql.filter.top, guid);
|
|
359
|
+
expectEqualFilters(filter, expectedFilter);
|
|
360
|
+
});
|
|
361
|
+
it('should handle bottom', () => {
|
|
362
|
+
const jaql = {
|
|
363
|
+
table: 'Brand',
|
|
364
|
+
column: 'Brand',
|
|
365
|
+
datatype: 'text',
|
|
366
|
+
title: 'Bottom 10 Brand by Total Revenue',
|
|
367
|
+
dim: '[Brand.Brand]',
|
|
368
|
+
filter: {
|
|
369
|
+
bottom: 10,
|
|
370
|
+
by: {
|
|
371
|
+
table: 'Commerce',
|
|
372
|
+
column: 'Revenue',
|
|
373
|
+
datatype: 'numeric',
|
|
374
|
+
title: 'sum Revenue',
|
|
375
|
+
dim: '[Commerce.Revenue]',
|
|
376
|
+
agg: 'sum',
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
};
|
|
380
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
381
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
382
|
+
const measure = (0, attribute_measure_util_js_1.createMeasureFromRankingFilterJaql)(jaql.filter.by);
|
|
383
|
+
const expectedFilter = filterFactory.bottomRanking(attribute, measure, jaql.filter.bottom, guid);
|
|
384
|
+
expectEqualFilters(filter, expectedFilter);
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
(0, vitest_1.describe)('LogicalAttributeFilter', () => {
|
|
388
|
+
it('should handle or', () => {
|
|
389
|
+
const jaql = {
|
|
390
|
+
table: 'Brand',
|
|
391
|
+
column: 'Brand',
|
|
392
|
+
datatype: 'text',
|
|
393
|
+
title: 'Brand',
|
|
394
|
+
dim: '[Brand.Brand]',
|
|
395
|
+
filter: {
|
|
396
|
+
or: [
|
|
397
|
+
{
|
|
398
|
+
startsWith: 'A',
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
endsWith: 's',
|
|
402
|
+
},
|
|
403
|
+
],
|
|
404
|
+
},
|
|
405
|
+
};
|
|
406
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
407
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
408
|
+
const expectedFilter = filterFactory.union(jaql.filter.or.map((c) => (0, condition_filter_util_js_1.createAttributeFilterFromConditionFilterJaql)(attribute, c, guid)), guid);
|
|
409
|
+
expect(filter.type).toEqual(expectedFilter.type);
|
|
410
|
+
expect(filter.id).toEqual(expectedFilter.id);
|
|
411
|
+
expect(filter.serializable()).toBeDefined();
|
|
412
|
+
});
|
|
413
|
+
it('should handle and', () => {
|
|
414
|
+
const jaql = {
|
|
415
|
+
table: 'Brand',
|
|
416
|
+
column: 'Brand',
|
|
417
|
+
datatype: 'text',
|
|
418
|
+
title: 'Brand',
|
|
419
|
+
dim: '[Brand.Brand]',
|
|
420
|
+
filter: {
|
|
421
|
+
and: [
|
|
422
|
+
{
|
|
423
|
+
startsWith: 'A',
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
endsWith: 's',
|
|
427
|
+
},
|
|
428
|
+
],
|
|
429
|
+
},
|
|
430
|
+
};
|
|
431
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
432
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
433
|
+
const expectedFilter = filterFactory.intersection(jaql.filter.and.map((c) => (0, condition_filter_util_js_1.createAttributeFilterFromConditionFilterJaql)(attribute, c, guid)), guid);
|
|
434
|
+
expect(filter.type).toEqual(expectedFilter.type);
|
|
435
|
+
expect(filter.id).toEqual(expectedFilter.id);
|
|
436
|
+
expect(filter.serializable()).toBeDefined();
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
(0, vitest_1.describe)('MeasureFilter', () => {
|
|
440
|
+
it('should handle unary operation', () => {
|
|
441
|
+
[
|
|
442
|
+
{
|
|
443
|
+
operator: types_js_1.ConditionFilterType.GREATER_THAN,
|
|
444
|
+
factoryFunc: filterFactory.measureGreaterThan,
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
operator: types_js_1.ConditionFilterType.GREATER_THAN_OR_EQUAL,
|
|
448
|
+
factoryFunc: filterFactory.measureGreaterThanOrEqual,
|
|
449
|
+
},
|
|
450
|
+
{ operator: types_js_1.ConditionFilterType.EQUALS, factoryFunc: filterFactory.measureEquals },
|
|
451
|
+
{ operator: types_js_1.ConditionFilterType.LESS_THAN, factoryFunc: filterFactory.measureLessThan },
|
|
452
|
+
{
|
|
453
|
+
operator: types_js_1.ConditionFilterType.LESS_THAN_OR_EQUAL,
|
|
454
|
+
factoryFunc: filterFactory.measureLessThanOrEqual,
|
|
455
|
+
},
|
|
456
|
+
].forEach((test) => {
|
|
457
|
+
const jaql = {
|
|
458
|
+
table: 'Commerce',
|
|
459
|
+
column: 'Revenue',
|
|
460
|
+
datatype: 'numeric',
|
|
461
|
+
title: 'sum Revenue',
|
|
462
|
+
dim: '[Commerce.Revenue]',
|
|
463
|
+
agg: 'sum',
|
|
464
|
+
filter: {
|
|
465
|
+
[test.operator]: 2000,
|
|
466
|
+
},
|
|
467
|
+
};
|
|
468
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
469
|
+
const measure = (0, attribute_measure_util_js_1.createMeasureFromFilterJaql)(jaql);
|
|
470
|
+
expect(measure).toBeDefined();
|
|
471
|
+
if (!measure)
|
|
472
|
+
return;
|
|
473
|
+
const expectedFilter = test.factoryFunc(measure, jaql.filter[test.operator], guid);
|
|
474
|
+
expectEqualFilters(filter, expectedFilter);
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
(0, vitest_1.describe)('Generic filter (pass-through JAQL)', () => {
|
|
479
|
+
test('should fall back to generic filter (pass-through JAQL)', () => {
|
|
480
|
+
[
|
|
481
|
+
// ADVANCED FILTER TYPE
|
|
482
|
+
{
|
|
483
|
+
table: 'Commerce',
|
|
484
|
+
column: 'Revenue',
|
|
485
|
+
datatype: 'numeric',
|
|
486
|
+
title: 'sum Revenue',
|
|
487
|
+
filter: {
|
|
488
|
+
isAdvanced: true,
|
|
489
|
+
},
|
|
490
|
+
},
|
|
491
|
+
// SIMULATE INVALID FILTER TYPE
|
|
492
|
+
{
|
|
493
|
+
table: 'Commerce',
|
|
494
|
+
column: 'Revenue',
|
|
495
|
+
datatype: 'numeric',
|
|
496
|
+
title: 'sum Revenue',
|
|
497
|
+
filter: {
|
|
498
|
+
filterType: 'INVALID',
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
type: 'measure',
|
|
503
|
+
formula: 'QUARTILE([042C4-365], 2)',
|
|
504
|
+
context: {
|
|
505
|
+
'[042C4-365]': {
|
|
506
|
+
table: 'Commerce',
|
|
507
|
+
column: 'Revenue',
|
|
508
|
+
dim: '[Commerce.Revenue]',
|
|
509
|
+
datatype: 'numeric',
|
|
510
|
+
title: 'Revenue',
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
title: 'QUARTILE([Revenue], 2)',
|
|
514
|
+
datatype: 'numeric',
|
|
515
|
+
filter: {
|
|
516
|
+
fromNotEqual: '500',
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
table: 'Brand',
|
|
521
|
+
column: 'Brand',
|
|
522
|
+
dim: '[Brand.Brand]',
|
|
523
|
+
datatype: 'text',
|
|
524
|
+
merged: true,
|
|
525
|
+
title: 'Brand',
|
|
526
|
+
filter: {
|
|
527
|
+
top: 10,
|
|
528
|
+
by: {
|
|
529
|
+
type: 'measure',
|
|
530
|
+
formula: 'QUARTILE([042C4-365], 2)',
|
|
531
|
+
context: {
|
|
532
|
+
'[042C4-365]': {
|
|
533
|
+
table: 'Commerce',
|
|
534
|
+
column: 'Revenue',
|
|
535
|
+
dim: '[Commerce.Revenue]',
|
|
536
|
+
datatype: 'numeric',
|
|
537
|
+
title: 'Revenue',
|
|
538
|
+
},
|
|
539
|
+
},
|
|
540
|
+
title: 'QUARTILE([Revenue], 2)',
|
|
541
|
+
datatype: 'numeric',
|
|
542
|
+
},
|
|
543
|
+
rankingMessage: 'QUARTILE([Revenue], 2)',
|
|
544
|
+
},
|
|
545
|
+
},
|
|
546
|
+
].forEach((item) => {
|
|
547
|
+
const jaql = item;
|
|
548
|
+
const filter = (0, filter_from_jaql_util_js_1.createFilterFromJaqlInternal)(jaql, guid);
|
|
549
|
+
const expectedFilter = filterFactory.customFilter(jaql, guid);
|
|
550
|
+
expect(filter.jaql()).toEqual(expectedFilter.jaql());
|
|
551
|
+
expect(filter.jaql(true)).toEqual(expectedFilter.jaql(true));
|
|
552
|
+
expect(filter.serializable()).toBeDefined();
|
|
553
|
+
expect(filter.toJSON()).toBeDefined();
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
});
|