@sisense/sdk-data 1.11.0 → 1.13.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 +153 -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 +797 -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 +344 -0
- package/dist/cjs/dimensional-model/filters/filters.js +663 -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 +196 -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 +58 -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 +82 -0
- package/dist/cjs/dimensional-model/filters/utils/filter-from-jaql-util.js +215 -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 +623 -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 +206 -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/analytics/factory.js +6 -4
- package/dist/dimensional-model/filters/factory.d.ts +81 -42
- package/dist/dimensional-model/filters/factory.js +125 -87
- package/dist/dimensional-model/filters/filters.d.ts +58 -13
- package/dist/dimensional-model/filters/filters.js +117 -27
- package/dist/dimensional-model/filters/utils/condition-filter-util.d.ts +4 -2
- package/dist/dimensional-model/filters/utils/condition-filter-util.js +30 -26
- package/dist/dimensional-model/filters/utils/filter-code-util.js +5 -1
- package/dist/dimensional-model/filters/utils/filter-from-jaql-util.d.ts +26 -11
- package/dist/dimensional-model/filters/utils/filter-from-jaql-util.js +58 -27
- package/dist/dimensional-model/filters/utils/filter-types-util.js +3 -3
- package/dist/dimensional-model/filters/utils/types.d.ts +6 -0
- package/package.json +18 -9
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
6
|
+
const filters_js_1 = require("./filters.js");
|
|
7
|
+
const attributes_js_1 = require("../attributes.js");
|
|
8
|
+
const measures_js_1 = require("../measures/measures.js");
|
|
9
|
+
const types_js_1 = require("../types.js");
|
|
10
|
+
describe('Filters jaql preparations', () => {
|
|
11
|
+
it('must prepare members filter jaql', () => {
|
|
12
|
+
const result = {
|
|
13
|
+
jaql: {
|
|
14
|
+
title: 'CommerceGender',
|
|
15
|
+
dim: '[Commerce.Gender]',
|
|
16
|
+
datatype: 'text',
|
|
17
|
+
filter: { members: ['Female'] },
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const filter = new filters_js_1.MembersFilter(new attributes_js_1.DimensionalAttribute('[Commerce.Gender]', '[Commerce.Gender]'), ['Female']);
|
|
21
|
+
const jaql = filter.jaql();
|
|
22
|
+
expect(jaql).toStrictEqual(result);
|
|
23
|
+
});
|
|
24
|
+
it('must prepare exclude filter jaql', () => {
|
|
25
|
+
const result = {
|
|
26
|
+
jaql: {
|
|
27
|
+
title: 'CommerceGender',
|
|
28
|
+
dim: '[Commerce.Gender]',
|
|
29
|
+
datatype: 'text',
|
|
30
|
+
filter: { exclude: { members: ['Female'] } },
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
const filter = new filters_js_1.ExcludeFilter(new filters_js_1.MembersFilter(new attributes_js_1.DimensionalAttribute('[Commerce.Gender]', '[Commerce.Gender]'), [
|
|
34
|
+
'Female',
|
|
35
|
+
]));
|
|
36
|
+
const jaql = filter.jaql();
|
|
37
|
+
expect(jaql).toStrictEqual(result);
|
|
38
|
+
});
|
|
39
|
+
it('must prepare date range filter jaql', () => {
|
|
40
|
+
const result = {
|
|
41
|
+
jaql: {
|
|
42
|
+
title: 'Years',
|
|
43
|
+
dim: '[Commerce.Date (Calendar)]',
|
|
44
|
+
level: 'years',
|
|
45
|
+
datatype: 'datetime',
|
|
46
|
+
filter: {
|
|
47
|
+
from: '2010-01-01T00:00:00.000Z',
|
|
48
|
+
to: '2012-01-01T00:00:00.000Z',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
const filter = new filters_js_1.DateRangeFilter(new attributes_js_1.DimensionalLevelAttribute('Years', '[Commerce.Date (Calendar)]', 'Years'), new Date('2010-01-01'), new Date('2012-01-01'));
|
|
53
|
+
const jaql = filter.jaql();
|
|
54
|
+
expect(jaql).toStrictEqual(result);
|
|
55
|
+
});
|
|
56
|
+
it('must prepare partial date range filters jaql', () => {
|
|
57
|
+
var _a, _b, _c, _d;
|
|
58
|
+
const filterFrom = new filters_js_1.DateRangeFilter(new attributes_js_1.DimensionalLevelAttribute('Years', '[Commerce.Date (Calendar)]', 'Years'), new Date('2010-01-01'));
|
|
59
|
+
const filterTo = new filters_js_1.DateRangeFilter(new attributes_js_1.DimensionalLevelAttribute('Years', '[Commerce.Date (Calendar)]', 'Years'), undefined, new Date('2012-01-01'));
|
|
60
|
+
const jaqlFrom = filterFrom.jaql();
|
|
61
|
+
const jaqlTo = filterTo.jaql();
|
|
62
|
+
expect((_a = jaqlFrom.jaql.filter) === null || _a === void 0 ? void 0 : _a.from).toBe('2010-01-01T00:00:00.000Z');
|
|
63
|
+
expect((_b = jaqlFrom.jaql.filter) === null || _b === void 0 ? void 0 : _b.to).toBeUndefined();
|
|
64
|
+
expect((_c = jaqlTo.jaql.filter) === null || _c === void 0 ? void 0 : _c.from).toBeUndefined();
|
|
65
|
+
expect((_d = jaqlTo.jaql.filter) === null || _d === void 0 ? void 0 : _d.to).toBe('2012-01-01T00:00:00.000Z');
|
|
66
|
+
});
|
|
67
|
+
it('must prepare logical attribute filter jaql', () => {
|
|
68
|
+
const result = {
|
|
69
|
+
jaql: {
|
|
70
|
+
title: 'CommerceGender',
|
|
71
|
+
dim: '[Commerce.Gender]',
|
|
72
|
+
datatype: 'text',
|
|
73
|
+
filter: {
|
|
74
|
+
or: [{ members: ['Female'] }, { exclude: { members: ['Male'] } }],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
const filter = new filters_js_1.LogicalAttributeFilter([
|
|
79
|
+
new filters_js_1.MembersFilter(new attributes_js_1.DimensionalAttribute('[Commerce.Gender]', '[Commerce.Gender]'), [
|
|
80
|
+
'Female',
|
|
81
|
+
]),
|
|
82
|
+
new filters_js_1.ExcludeFilter(new filters_js_1.MembersFilter(new attributes_js_1.DimensionalAttribute('[Commerce.Gender]', '[Commerce.Gender]'), [
|
|
83
|
+
'Male',
|
|
84
|
+
])),
|
|
85
|
+
], 'or');
|
|
86
|
+
const jaql = filter.jaql();
|
|
87
|
+
expect(jaql).toStrictEqual(result);
|
|
88
|
+
});
|
|
89
|
+
it('must prepare measure filter jaql', () => {
|
|
90
|
+
const result = {
|
|
91
|
+
jaql: {
|
|
92
|
+
title: 'Cost',
|
|
93
|
+
dim: '[Commerce.Cost]',
|
|
94
|
+
datatype: 'numeric',
|
|
95
|
+
agg: 'sum',
|
|
96
|
+
filter: {},
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
const filter = new filters_js_1.MeasureFilter(new attributes_js_1.DimensionalAttribute('[Commerce.Gender]', '[Commerce.Gender]'), new measures_js_1.DimensionalBaseMeasure('Cost', new attributes_js_1.DimensionalAttribute('[Commerce.Cost]', '[Commerce.Cost]', 'numeric-attribute'), 'sum'));
|
|
100
|
+
const jaql = filter.jaql();
|
|
101
|
+
expect(jaql).toStrictEqual(result);
|
|
102
|
+
});
|
|
103
|
+
it('must prepare relative date (years level) filter jaql', () => {
|
|
104
|
+
const result = {
|
|
105
|
+
jaql: {
|
|
106
|
+
title: 'Years',
|
|
107
|
+
dim: '[Commerce.Date (Calendar)]',
|
|
108
|
+
level: 'years',
|
|
109
|
+
datatype: 'datetime',
|
|
110
|
+
filter: {
|
|
111
|
+
last: { offset: 0, count: 2, anchor: '2012-01-01T00:00:00.000Z' },
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
const filter = new filters_js_1.RelativeDateFilter(new attributes_js_1.DimensionalLevelAttribute('Years', '[Commerce.Date (Calendar)]', 'Years'), 0, 2, filters_js_1.DateOperators.Last, new Date('2012-01-01'));
|
|
116
|
+
const jaql = filter.jaql();
|
|
117
|
+
expect(jaql).toStrictEqual(result);
|
|
118
|
+
});
|
|
119
|
+
it('must prepare relative date (minutes level) filter jaql', () => {
|
|
120
|
+
const result = {
|
|
121
|
+
jaql: {
|
|
122
|
+
title: types_js_1.DateLevels.AggMinutesRoundTo15,
|
|
123
|
+
dim: '[Commerce.Date (Calendar)]',
|
|
124
|
+
level: 'minutes',
|
|
125
|
+
bucket: '15',
|
|
126
|
+
datatype: 'datetime',
|
|
127
|
+
filter: {
|
|
128
|
+
last: { offset: 0, count: 2, anchor: '2012-01-01T00:00:00.000Z' },
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
const filter = new filters_js_1.RelativeDateFilter(new attributes_js_1.DimensionalLevelAttribute(types_js_1.DateLevels.AggMinutesRoundTo15, '[Commerce.Date (Calendar)]', types_js_1.DateLevels.AggMinutesRoundTo15), 0, 2, filters_js_1.DateOperators.Last, new Date('2012-01-01'));
|
|
133
|
+
const jaql = filter.jaql();
|
|
134
|
+
expect(jaql).toStrictEqual(result);
|
|
135
|
+
});
|
|
136
|
+
it('must prepare text filter jaql', () => {
|
|
137
|
+
const result = {
|
|
138
|
+
jaql: {
|
|
139
|
+
title: 'CommerceGender',
|
|
140
|
+
dim: '[Commerce.Gender]',
|
|
141
|
+
datatype: 'text',
|
|
142
|
+
filter: { contains: 'Male' },
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
const filter = new filters_js_1.TextFilter(new attributes_js_1.DimensionalAttribute('[Commerce.Gender]', '[Commerce.Gender]'), filters_js_1.TextOperators.Contains, 'Male');
|
|
146
|
+
const jaql = filter.jaql();
|
|
147
|
+
expect(jaql).toStrictEqual(result);
|
|
148
|
+
});
|
|
149
|
+
it('must prepare numeric filter jaql', () => {
|
|
150
|
+
const result = {
|
|
151
|
+
jaql: {
|
|
152
|
+
title: 'CommerceCost',
|
|
153
|
+
dim: '[Commerce.Cost]',
|
|
154
|
+
datatype: 'numeric',
|
|
155
|
+
filter: { from: 1, to: 3 },
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
const filter = new filters_js_1.NumericFilter(new attributes_js_1.DimensionalAttribute('[Commerce.Cost]', '[Commerce.Cost]', 'numeric-attribute'), filters_js_1.NumericOperators.From, 1, filters_js_1.NumericOperators.To, 3);
|
|
159
|
+
const jaql = filter.jaql();
|
|
160
|
+
expect(jaql).toStrictEqual(result);
|
|
161
|
+
});
|
|
162
|
+
it('must prepare ranking filter jaql', () => {
|
|
163
|
+
const result = {
|
|
164
|
+
jaql: {
|
|
165
|
+
title: 'CommerceCost',
|
|
166
|
+
dim: '[Commerce.Cost]',
|
|
167
|
+
datatype: 'numeric',
|
|
168
|
+
filter: {
|
|
169
|
+
top: 2,
|
|
170
|
+
by: { title: 'Cost', agg: 'sum', dim: '[Commerce.Cost]', datatype: 'numeric' },
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
const filter = new filters_js_1.RankingFilter(new attributes_js_1.DimensionalAttribute('[Commerce.Cost]', '[Commerce.Cost]', 'numeric-attribute'), new measures_js_1.DimensionalBaseMeasure('Cost', new attributes_js_1.DimensionalAttribute('[Commerce.Cost]', '[Commerce.Cost]', 'numeric-attribute'), 'sum'), filters_js_1.RankingOperators.Top, 2);
|
|
175
|
+
const jaql = filter.jaql();
|
|
176
|
+
expect(jaql).toStrictEqual(result);
|
|
177
|
+
});
|
|
178
|
+
it('must prepare cascading filter jaql', () => {
|
|
179
|
+
const result = [
|
|
180
|
+
{
|
|
181
|
+
jaql: {
|
|
182
|
+
title: 'CategoryCategory',
|
|
183
|
+
dim: '[Category.Category]',
|
|
184
|
+
datatype: 'text',
|
|
185
|
+
filter: {
|
|
186
|
+
members: ['Apple Mac Desktops', 'Apple Mac Laptops', 'Calculators'],
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
panel: 'scope',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
jaql: {
|
|
193
|
+
title: 'CommerceGender',
|
|
194
|
+
dim: '[Commerce.Gender]',
|
|
195
|
+
datatype: 'text',
|
|
196
|
+
filter: {
|
|
197
|
+
members: ['Female'],
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
panel: 'scope',
|
|
201
|
+
},
|
|
202
|
+
];
|
|
203
|
+
const levelFilter1 = new filters_js_1.MembersFilter(new attributes_js_1.DimensionalAttribute('[Category.Category]', '[Category.Category]'), ['Apple Mac Desktops', 'Apple Mac Laptops', 'Calculators']);
|
|
204
|
+
const levelFilter2 = new filters_js_1.MembersFilter(new attributes_js_1.DimensionalAttribute('[Commerce.Gender]', '[Commerce.Gender]'), ['Female']);
|
|
205
|
+
const filter = new filters_js_1.CascadingFilter([levelFilter1, levelFilter2]);
|
|
206
|
+
const jaql = filter.jaql();
|
|
207
|
+
expect(jaql).toStrictEqual(result);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
describe('Disabled Filter', () => {
|
|
211
|
+
it('must prepare empty jaql for attribute filter', () => {
|
|
212
|
+
const filter = new filters_js_1.MembersFilter(new attributes_js_1.DimensionalAttribute('[Commerce.Gender]', '[Commerce.Gender]'), ['Female']);
|
|
213
|
+
expect(filter.disabled).toBe(false);
|
|
214
|
+
filter.disabled = true;
|
|
215
|
+
expect(filter.jaql(true)).toStrictEqual({ filter: {} });
|
|
216
|
+
expect(filter.jaql()).toStrictEqual({ jaql: { filter: {} } });
|
|
217
|
+
});
|
|
218
|
+
it('must prepare empty jaql for measure filter', () => {
|
|
219
|
+
const filter = new filters_js_1.MeasureFilter(new attributes_js_1.DimensionalAttribute('[Commerce.Gender]', '[Commerce.Gender]'), new measures_js_1.DimensionalBaseMeasure('Cost', new attributes_js_1.DimensionalAttribute('[Commerce.Cost]', '[Commerce.Cost]', 'numeric-attribute'), 'sum'));
|
|
220
|
+
expect(filter.disabled).toBe(false);
|
|
221
|
+
filter.disabled = true;
|
|
222
|
+
expect(filter.jaql(true)).toStrictEqual({ filter: {} });
|
|
223
|
+
expect(filter.jaql()).toStrictEqual({ jaql: { filter: {} } });
|
|
224
|
+
});
|
|
225
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Attribute, BaseMeasure, LevelAttribute } from '../../interfaces.js';
|
|
2
|
+
import { FilterJaql } from '../../types.js';
|
|
3
|
+
import { FilterJaqlInternal, RankingFilterJaql } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates an attribute or level attribute from the provided parameters
|
|
6
|
+
*
|
|
7
|
+
* @param dim - Dimension expression
|
|
8
|
+
* @param table - Table name
|
|
9
|
+
* @param column - Column name
|
|
10
|
+
* @param level - Date level
|
|
11
|
+
* @param dataType - Data type
|
|
12
|
+
* @returns attribute or level attribute
|
|
13
|
+
*/
|
|
14
|
+
export declare const createAttributeHelper: (dim: string, table: string | undefined, column: string, level: string | undefined, dataType: string) => Attribute | LevelAttribute;
|
|
15
|
+
/**
|
|
16
|
+
* Creates an attribute or level attribute from the provided filter JAQL object
|
|
17
|
+
*
|
|
18
|
+
* @param jaql - Filter JAQL object
|
|
19
|
+
* @returns attribute or level attribute
|
|
20
|
+
*/
|
|
21
|
+
export declare const createAttributeFromFilterJaql: (jaql: FilterJaql | FilterJaqlInternal) => Attribute | LevelAttribute;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a measure from the provided parameters
|
|
24
|
+
*
|
|
25
|
+
* @param dim - Dimension expression
|
|
26
|
+
* @param table - Table name
|
|
27
|
+
* @param column - Column name
|
|
28
|
+
* @param level - Date level
|
|
29
|
+
* @param dataType - Data type
|
|
30
|
+
* @param agg - Aggregation function
|
|
31
|
+
* @returns measure
|
|
32
|
+
*/
|
|
33
|
+
export declare const createMeasureHelper: (dim: string, table: string | undefined, column: string, level: string | undefined, dataType: string, agg: string) => BaseMeasure;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a measure from the provided filter JAQL object
|
|
36
|
+
*
|
|
37
|
+
* @param jaql - Filter JAQL object
|
|
38
|
+
* @returns Measure
|
|
39
|
+
*/
|
|
40
|
+
export declare const createMeasureFromFilterJaql: (jaql: FilterJaqlInternal) => BaseMeasure | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a measure from the provided ranking filter JAQL object
|
|
43
|
+
*
|
|
44
|
+
* @param jaql - Ranking filter Jaql object
|
|
45
|
+
* @returns Measure
|
|
46
|
+
*/
|
|
47
|
+
export declare const createMeasureFromRankingFilterJaql: (jaql: RankingFilterJaql) => BaseMeasure;
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
exports.createMeasureFromRankingFilterJaql = exports.createMeasureFromFilterJaql = exports.createMeasureHelper = exports.createAttributeFromFilterJaql = exports.createAttributeHelper = void 0;
|
|
27
|
+
const attributes_js_1 = require("../../attributes.js");
|
|
28
|
+
const simple_column_types_js_1 = require("../../simple-column-types.js");
|
|
29
|
+
const types_js_1 = require("../../types.js");
|
|
30
|
+
const measureFactory = __importStar(require("../../measures/factory.js"));
|
|
31
|
+
const DATA_MODEL_MODULE_NAME = 'DM';
|
|
32
|
+
/**
|
|
33
|
+
* Creates an attribute or level attribute from the provided parameters
|
|
34
|
+
*
|
|
35
|
+
* @param dim - Dimension expression
|
|
36
|
+
* @param table - Table name
|
|
37
|
+
* @param column - Column name
|
|
38
|
+
* @param level - Date level
|
|
39
|
+
* @param dataType - Data type
|
|
40
|
+
* @returns attribute or level attribute
|
|
41
|
+
*/
|
|
42
|
+
const createAttributeHelper = (dim, table, column, level, dataType) => {
|
|
43
|
+
// if table is undefined, extract it from dim
|
|
44
|
+
const dimTable = table !== null && table !== void 0 ? table : dim.slice(1, -1).split('.')[0];
|
|
45
|
+
if (level) {
|
|
46
|
+
const dateLevel = attributes_js_1.DimensionalLevelAttribute.translateJaqlToGranularity({ level });
|
|
47
|
+
const format = attributes_js_1.DimensionalLevelAttribute.getDefaultFormatForGranularity(dateLevel);
|
|
48
|
+
const levelAttribute = new attributes_js_1.DimensionalLevelAttribute(column, dim, dateLevel, format);
|
|
49
|
+
levelAttribute.composeCode = (0, attributes_js_1.normalizeAttributeName)(dimTable, column, level, DATA_MODEL_MODULE_NAME);
|
|
50
|
+
return levelAttribute;
|
|
51
|
+
}
|
|
52
|
+
const attributeType = (0, simple_column_types_js_1.isNumber)(dataType)
|
|
53
|
+
? types_js_1.MetadataTypes.NumericAttribute
|
|
54
|
+
: types_js_1.MetadataTypes.TextAttribute;
|
|
55
|
+
const attribute = new attributes_js_1.DimensionalAttribute(column, dim, attributeType);
|
|
56
|
+
attribute.composeCode = (0, attributes_js_1.normalizeAttributeName)(dimTable, column, undefined, DATA_MODEL_MODULE_NAME);
|
|
57
|
+
return attribute;
|
|
58
|
+
};
|
|
59
|
+
exports.createAttributeHelper = createAttributeHelper;
|
|
60
|
+
/**
|
|
61
|
+
* Creates an attribute or level attribute from the provided filter JAQL object
|
|
62
|
+
*
|
|
63
|
+
* @param jaql - Filter JAQL object
|
|
64
|
+
* @returns attribute or level attribute
|
|
65
|
+
*/
|
|
66
|
+
const createAttributeFromFilterJaql = (jaql) => {
|
|
67
|
+
return (0, exports.createAttributeHelper)(jaql.dim, jaql.table, jaql.column, jaql.level, jaql.datatype);
|
|
68
|
+
};
|
|
69
|
+
exports.createAttributeFromFilterJaql = createAttributeFromFilterJaql;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a measure from the provided parameters
|
|
72
|
+
*
|
|
73
|
+
* @param dim - Dimension expression
|
|
74
|
+
* @param table - Table name
|
|
75
|
+
* @param column - Column name
|
|
76
|
+
* @param level - Date level
|
|
77
|
+
* @param dataType - Data type
|
|
78
|
+
* @param agg - Aggregation function
|
|
79
|
+
* @returns measure
|
|
80
|
+
*/
|
|
81
|
+
const createMeasureHelper = (dim, table, column, level, dataType, agg) => {
|
|
82
|
+
const attribute = (0, exports.createAttributeHelper)(dim, table, column, level, dataType);
|
|
83
|
+
const measure = measureFactory.aggregate(attribute, agg);
|
|
84
|
+
measure.composeCode = `measureFactory.${agg}(${attribute.composeCode})`;
|
|
85
|
+
return measure;
|
|
86
|
+
};
|
|
87
|
+
exports.createMeasureHelper = createMeasureHelper;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a measure from the provided filter JAQL object
|
|
90
|
+
*
|
|
91
|
+
* @param jaql - Filter JAQL object
|
|
92
|
+
* @returns Measure
|
|
93
|
+
*/
|
|
94
|
+
const createMeasureFromFilterJaql = (jaql) => {
|
|
95
|
+
const { dim, table, column, level, datatype: dataType, agg } = jaql;
|
|
96
|
+
if (!agg)
|
|
97
|
+
return undefined;
|
|
98
|
+
return (0, exports.createMeasureHelper)(dim, table, column, level, dataType, agg);
|
|
99
|
+
};
|
|
100
|
+
exports.createMeasureFromFilterJaql = createMeasureFromFilterJaql;
|
|
101
|
+
/**
|
|
102
|
+
* Creates a measure from the provided ranking filter JAQL object
|
|
103
|
+
*
|
|
104
|
+
* @param jaql - Ranking filter Jaql object
|
|
105
|
+
* @returns Measure
|
|
106
|
+
*/
|
|
107
|
+
const createMeasureFromRankingFilterJaql = (jaql) => {
|
|
108
|
+
const { dim, table, column, level, datatype: dataType, agg } = jaql;
|
|
109
|
+
return (0, exports.createMeasureHelper)(dim, table, column, level, dataType, agg);
|
|
110
|
+
};
|
|
111
|
+
exports.createMeasureFromRankingFilterJaql = createMeasureFromRankingFilterJaql;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ConditionFilterJaql, ConditionFilterType } from './types.js';
|
|
2
|
+
import { Attribute, BaseMeasure, Filter } from '../../interfaces.js';
|
|
3
|
+
export declare const getSelectedConditionOption: (filter: ConditionFilterJaql) => ConditionFilterType;
|
|
4
|
+
/**
|
|
5
|
+
* Creates an attribute filter from the provided attribute and condition filter JAQL object
|
|
6
|
+
*
|
|
7
|
+
* @param attribute - Provided attribute
|
|
8
|
+
* @param conditionFilterJaql - Condition filter JAQL object
|
|
9
|
+
* @param guid - Optional GUID for the filter
|
|
10
|
+
* @returns attribute filter
|
|
11
|
+
*/
|
|
12
|
+
export declare const createAttributeFilterFromConditionFilterJaql: (attribute: Attribute, conditionFilterJaql: ConditionFilterJaql, guid?: string) => Filter;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a measure filter from the provided measure and condition filter JAQL object
|
|
15
|
+
*
|
|
16
|
+
* @param measure - Provided measure
|
|
17
|
+
* @param conditionFilterJaql - Condition filter JAQL object
|
|
18
|
+
* @param guid - Optional GUID for the filter
|
|
19
|
+
* @returns measure filter
|
|
20
|
+
*/
|
|
21
|
+
export declare const createMeasureFilterFromConditionFilterJaql: (measure: BaseMeasure, conditionFilterJaql: ConditionFilterJaql, guid?: string) => Filter;
|
|
@@ -0,0 +1,196 @@
|
|
|
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
|
+
exports.createMeasureFilterFromConditionFilterJaql = exports.createAttributeFilterFromConditionFilterJaql = exports.getSelectedConditionOption = void 0;
|
|
27
|
+
const types_js_1 = require("./types.js");
|
|
28
|
+
const filter_code_util_js_1 = require("./filter-code-util.js");
|
|
29
|
+
const filterFactory = __importStar(require("../factory.js"));
|
|
30
|
+
const attribute_measure_util_js_1 = require("./attribute-measure-util.js");
|
|
31
|
+
const isTopCondition = (filter) => filter.top !== undefined;
|
|
32
|
+
const isBottomCondition = (filter) => filter.bottom !== undefined;
|
|
33
|
+
const isExcludeCondition = (filter) => { var _a; return !!((_a = filter.exclude) === null || _a === void 0 ? void 0 : _a.members); };
|
|
34
|
+
const isMembersCondition = (filter) => !!filter.members && !!filter.isCondition;
|
|
35
|
+
const isWithinCondition = (filter) => { var _a, _b; return ((_a = filter.last) === null || _a === void 0 ? void 0 : _a.anchor) !== undefined || ((_b = filter.next) === null || _b === void 0 ? void 0 : _b.anchor) !== undefined; };
|
|
36
|
+
const isGreaterThanCondition = (filter) => filter.fromNotEqual !== undefined;
|
|
37
|
+
const isGreaterThanOrEqualCondition = (filter) => filter.from !== undefined && !filter.isBetween;
|
|
38
|
+
const isLessThanCondition = (filter) => filter.toNotEqual !== undefined;
|
|
39
|
+
const isLessThanOrEqualCondition = (filter) => filter.to !== undefined && !filter.isBetween;
|
|
40
|
+
const isEqualsCondition = (filter) => filter.equals !== undefined;
|
|
41
|
+
const isNotEqualCondition = (filter) => filter.doesntEqual !== undefined;
|
|
42
|
+
const isEmptyCondition = (filter) => !!(filter.equals === '' && filter.isEmpty);
|
|
43
|
+
const isNotEmptyCondition = (filter) => !!(filter.doesntEqual === '' && filter.isEmpty);
|
|
44
|
+
const isContainsCondition = (filter) => filter.contains !== undefined;
|
|
45
|
+
const isDoesntContainCondition = (filter) => filter.doesntContain !== undefined;
|
|
46
|
+
const isStartsWithCondition = (filter) => filter.startsWith !== undefined;
|
|
47
|
+
const isDoesntStartsWithCondition = (filter) => filter.doesntStartWith !== undefined;
|
|
48
|
+
const isEndsWithCondition = (filter) => filter.endsWith !== undefined;
|
|
49
|
+
const isDoesntEndWithCondition = (filter) => filter.doesntEndWith !== undefined;
|
|
50
|
+
const isBetweenCondition = (filter) => filter.from !== undefined && filter.to !== undefined;
|
|
51
|
+
const isNotBetweenCondition = (filter) => { var _a, _b; return ((_a = filter.exclude) === null || _a === void 0 ? void 0 : _a.from) !== undefined && ((_b = filter.exclude) === null || _b === void 0 ? void 0 : _b.to) !== undefined; };
|
|
52
|
+
const isMultipleCondition = (filter) => !!(filter.or || filter.and);
|
|
53
|
+
const getSelectedConditionOption = (filter) => {
|
|
54
|
+
if (isBottomCondition(filter))
|
|
55
|
+
return types_js_1.ConditionFilterType.BOTTOM;
|
|
56
|
+
if (isTopCondition(filter))
|
|
57
|
+
return types_js_1.ConditionFilterType.TOP;
|
|
58
|
+
if (isExcludeCondition(filter))
|
|
59
|
+
return types_js_1.ConditionFilterType.IS_NOT;
|
|
60
|
+
if (isWithinCondition(filter))
|
|
61
|
+
return types_js_1.ConditionFilterType.IS_WITHIN;
|
|
62
|
+
if (isGreaterThanCondition(filter))
|
|
63
|
+
return types_js_1.ConditionFilterType.GREATER_THAN;
|
|
64
|
+
if (isLessThanCondition(filter))
|
|
65
|
+
return types_js_1.ConditionFilterType.LESS_THAN;
|
|
66
|
+
if (isEqualsCondition(filter))
|
|
67
|
+
return types_js_1.ConditionFilterType.EQUALS;
|
|
68
|
+
if (isNotEqualCondition(filter))
|
|
69
|
+
return types_js_1.ConditionFilterType.DOESNT_EQUAL;
|
|
70
|
+
if (isEmptyCondition(filter))
|
|
71
|
+
return types_js_1.ConditionFilterType.IS_EMPTY;
|
|
72
|
+
if (isNotEmptyCondition(filter))
|
|
73
|
+
return types_js_1.ConditionFilterType.IS_NOT_EMPTY;
|
|
74
|
+
if (isContainsCondition(filter))
|
|
75
|
+
return types_js_1.ConditionFilterType.CONTAINS;
|
|
76
|
+
if (isDoesntContainCondition(filter))
|
|
77
|
+
return types_js_1.ConditionFilterType.DOESNT_CONTAIN;
|
|
78
|
+
if (isDoesntEndWithCondition(filter))
|
|
79
|
+
return types_js_1.ConditionFilterType.DOESNT_END_WITH;
|
|
80
|
+
if (isDoesntStartsWithCondition(filter))
|
|
81
|
+
return types_js_1.ConditionFilterType.DOESNT_START_WITH;
|
|
82
|
+
if (isEndsWithCondition(filter))
|
|
83
|
+
return types_js_1.ConditionFilterType.ENDS_WITH;
|
|
84
|
+
if (isStartsWithCondition(filter))
|
|
85
|
+
return types_js_1.ConditionFilterType.STARTS_WITH;
|
|
86
|
+
if (isNotBetweenCondition(filter))
|
|
87
|
+
return types_js_1.ConditionFilterType.IS_NOT_BETWEEN;
|
|
88
|
+
if (isMembersCondition(filter))
|
|
89
|
+
return types_js_1.ConditionFilterType.IS;
|
|
90
|
+
if (isMultipleCondition(filter))
|
|
91
|
+
return types_js_1.ConditionFilterType.MULTIPLE_CONDITION;
|
|
92
|
+
// Need to verify BETWEEN case before the GREATER_THAN_OR_EQUAL and LESS_THAN_OR_EQUAL due to missing `filter.isBetween` property in some cases
|
|
93
|
+
if (isBetweenCondition(filter))
|
|
94
|
+
return types_js_1.ConditionFilterType.BETWEEN;
|
|
95
|
+
if (isGreaterThanOrEqualCondition(filter))
|
|
96
|
+
return types_js_1.ConditionFilterType.GREATER_THAN_OR_EQUAL;
|
|
97
|
+
if (isLessThanOrEqualCondition(filter))
|
|
98
|
+
return types_js_1.ConditionFilterType.LESS_THAN_OR_EQUAL;
|
|
99
|
+
return types_js_1.ConditionFilterType.NONE;
|
|
100
|
+
};
|
|
101
|
+
exports.getSelectedConditionOption = getSelectedConditionOption;
|
|
102
|
+
/**
|
|
103
|
+
* Creates an attribute filter from the provided attribute and condition filter JAQL object
|
|
104
|
+
*
|
|
105
|
+
* @param attribute - Provided attribute
|
|
106
|
+
* @param conditionFilterJaql - Condition filter JAQL object
|
|
107
|
+
* @param guid - Optional GUID for the filter
|
|
108
|
+
* @returns attribute filter
|
|
109
|
+
*/
|
|
110
|
+
const createAttributeFilterFromConditionFilterJaql = (attribute, conditionFilterJaql, guid) => {
|
|
111
|
+
var _a, _b, _c;
|
|
112
|
+
const conditionType = (0, exports.getSelectedConditionOption)(conditionFilterJaql);
|
|
113
|
+
switch (conditionType) {
|
|
114
|
+
case types_js_1.ConditionFilterType.BOTTOM:
|
|
115
|
+
if (conditionFilterJaql.by && 'agg' in conditionFilterJaql.by) {
|
|
116
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.bottomRanking)(attribute, (0, attribute_measure_util_js_1.createMeasureFromRankingFilterJaql)(conditionFilterJaql.by), conditionFilterJaql[types_js_1.ConditionFilterType.BOTTOM], guid);
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
case types_js_1.ConditionFilterType.EQUALS:
|
|
120
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.equals)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.EQUALS], guid);
|
|
121
|
+
case types_js_1.ConditionFilterType.GREATER_THAN:
|
|
122
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.greaterThan)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.GREATER_THAN], guid);
|
|
123
|
+
case types_js_1.ConditionFilterType.GREATER_THAN_OR_EQUAL:
|
|
124
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.greaterThanOrEqual)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.GREATER_THAN_OR_EQUAL], guid);
|
|
125
|
+
case types_js_1.ConditionFilterType.TOP:
|
|
126
|
+
if (conditionFilterJaql.by) {
|
|
127
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.topRanking)(attribute, (0, attribute_measure_util_js_1.createMeasureFromRankingFilterJaql)(conditionFilterJaql.by), conditionFilterJaql[types_js_1.ConditionFilterType.TOP], guid);
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case types_js_1.ConditionFilterType.STARTS_WITH:
|
|
131
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.startsWith)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.STARTS_WITH], guid);
|
|
132
|
+
case types_js_1.ConditionFilterType.DOESNT_START_WITH:
|
|
133
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.doesntStartWith)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.DOESNT_START_WITH], guid);
|
|
134
|
+
case types_js_1.ConditionFilterType.ENDS_WITH:
|
|
135
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.endsWith)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.ENDS_WITH], guid);
|
|
136
|
+
case types_js_1.ConditionFilterType.DOESNT_END_WITH:
|
|
137
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.doesntEndWith)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.DOESNT_END_WITH], guid);
|
|
138
|
+
case types_js_1.ConditionFilterType.CONTAINS:
|
|
139
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.contains)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.CONTAINS], guid);
|
|
140
|
+
case types_js_1.ConditionFilterType.DOESNT_CONTAIN:
|
|
141
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.doesntContain)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.DOESNT_CONTAIN], guid);
|
|
142
|
+
case types_js_1.ConditionFilterType.LESS_THAN:
|
|
143
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.lessThan)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.LESS_THAN], guid);
|
|
144
|
+
case types_js_1.ConditionFilterType.LESS_THAN_OR_EQUAL:
|
|
145
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.lessThanOrEqual)(attribute, conditionFilterJaql[types_js_1.ConditionFilterType.LESS_THAN_OR_EQUAL], guid);
|
|
146
|
+
case types_js_1.ConditionFilterType.BETWEEN:
|
|
147
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.between)(attribute, conditionFilterJaql.from, conditionFilterJaql.to, guid);
|
|
148
|
+
case types_js_1.ConditionFilterType.IS_NOT_BETWEEN:
|
|
149
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.exclude)((0, filter_code_util_js_1.withComposeCode)(filterFactory.between)(attribute, (_a = conditionFilterJaql.exclude) === null || _a === void 0 ? void 0 : _a.from, (_b = conditionFilterJaql.exclude) === null || _b === void 0 ? void 0 : _b.to, guid), undefined, guid);
|
|
150
|
+
case types_js_1.ConditionFilterType.MULTIPLE_CONDITION:
|
|
151
|
+
if (conditionFilterJaql.and) {
|
|
152
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.intersection)(conditionFilterJaql.and.map((c) => (0, exports.createAttributeFilterFromConditionFilterJaql)(attribute, c, guid)), guid);
|
|
153
|
+
}
|
|
154
|
+
if (conditionFilterJaql.or) {
|
|
155
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.union)(conditionFilterJaql.or.map((c) => (0, exports.createAttributeFilterFromConditionFilterJaql)(attribute, c, guid)), guid);
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case types_js_1.ConditionFilterType.IS_NOT:
|
|
159
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.exclude)((0, filter_code_util_js_1.withComposeCode)(filterFactory.members)(attribute, ((_c = conditionFilterJaql.exclude) === null || _c === void 0 ? void 0 : _c.members) || [], undefined, guid), undefined, guid);
|
|
160
|
+
case types_js_1.ConditionFilterType.AFTER:
|
|
161
|
+
case types_js_1.ConditionFilterType.BEFORE:
|
|
162
|
+
case types_js_1.ConditionFilterType.IS_EMPTY:
|
|
163
|
+
case types_js_1.ConditionFilterType.IS_NOT_EMPTY:
|
|
164
|
+
// TODO Handle these cases later; may need filterFactory function added first
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
throw 'Jaql contains unsupported condition filter: ' + JSON.stringify(conditionFilterJaql);
|
|
168
|
+
};
|
|
169
|
+
exports.createAttributeFilterFromConditionFilterJaql = createAttributeFilterFromConditionFilterJaql;
|
|
170
|
+
/**
|
|
171
|
+
* Creates a measure filter from the provided measure and condition filter JAQL object
|
|
172
|
+
*
|
|
173
|
+
* @param measure - Provided measure
|
|
174
|
+
* @param conditionFilterJaql - Condition filter JAQL object
|
|
175
|
+
* @param guid - Optional GUID for the filter
|
|
176
|
+
* @returns measure filter
|
|
177
|
+
*/
|
|
178
|
+
const createMeasureFilterFromConditionFilterJaql = (measure, conditionFilterJaql, guid) => {
|
|
179
|
+
const conditionType = (0, exports.getSelectedConditionOption)(conditionFilterJaql);
|
|
180
|
+
switch (conditionType) {
|
|
181
|
+
case types_js_1.ConditionFilterType.EQUALS:
|
|
182
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.measureEquals)(measure, conditionFilterJaql[types_js_1.ConditionFilterType.EQUALS], guid);
|
|
183
|
+
case types_js_1.ConditionFilterType.GREATER_THAN:
|
|
184
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.measureGreaterThan)(measure, conditionFilterJaql[types_js_1.ConditionFilterType.GREATER_THAN], guid);
|
|
185
|
+
case types_js_1.ConditionFilterType.GREATER_THAN_OR_EQUAL:
|
|
186
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.measureGreaterThanOrEqual)(measure, conditionFilterJaql[types_js_1.ConditionFilterType.GREATER_THAN_OR_EQUAL], guid);
|
|
187
|
+
case types_js_1.ConditionFilterType.LESS_THAN:
|
|
188
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.measureLessThan)(measure, conditionFilterJaql[types_js_1.ConditionFilterType.LESS_THAN], guid);
|
|
189
|
+
case types_js_1.ConditionFilterType.LESS_THAN_OR_EQUAL:
|
|
190
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.measureLessThanOrEqual)(measure, conditionFilterJaql[types_js_1.ConditionFilterType.LESS_THAN_OR_EQUAL], guid);
|
|
191
|
+
case types_js_1.ConditionFilterType.BETWEEN:
|
|
192
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.measureBetween)(measure, conditionFilterJaql.from, conditionFilterJaql.to, guid);
|
|
193
|
+
}
|
|
194
|
+
throw 'Jaql contains unsupported condition filter: ' + JSON.stringify(conditionFilterJaql);
|
|
195
|
+
};
|
|
196
|
+
exports.createMeasureFilterFromConditionFilterJaql = createMeasureFilterFromConditionFilterJaql;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCorrectTimeLevel = void 0;
|
|
4
|
+
const types_js_1 = require("./types.js");
|
|
5
|
+
const getCorrectTimeLevel = (level, bucket) => {
|
|
6
|
+
let newLevel = level ? level.toLocaleLowerCase() : types_js_1.DatetimeLevel.YEARS;
|
|
7
|
+
if (newLevel === types_js_1.DatetimeLevel.MINUTES && bucket === '60') {
|
|
8
|
+
newLevel = types_js_1.DatetimeLevel.HOURS;
|
|
9
|
+
}
|
|
10
|
+
return newLevel;
|
|
11
|
+
};
|
|
12
|
+
exports.getCorrectTimeLevel = getCorrectTimeLevel;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stringifies the argument
|
|
3
|
+
*
|
|
4
|
+
* @param arg - argument to stringify
|
|
5
|
+
* @returns stringified argument
|
|
6
|
+
*/
|
|
7
|
+
export declare function stringifyHelper(arg: any): string;
|
|
8
|
+
/**
|
|
9
|
+
* High order function to construct compose code for filter factory functions
|
|
10
|
+
*
|
|
11
|
+
* @param func - filter factory function
|
|
12
|
+
*/
|
|
13
|
+
export declare function withComposeCode(func: (...args: any[]) => any): (...args: any[]) => any;
|