@sisense/sdk-data 1.10.1 → 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/attributes.d.ts +1 -0
- package/dist/dimensional-model/attributes.js +31 -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 +40 -12
- package/dist/dimensional-model/filters/filters.js +75 -24
- package/dist/dimensional-model/filters/utils/attribute-measure-util.d.ts +2 -2
- package/dist/dimensional-model/filters/utils/attribute-measure-util.js +6 -3
- package/dist/dimensional-model/filters/utils/condition-filter-util.d.ts +4 -2
- package/dist/dimensional-model/filters/utils/condition-filter-util.js +34 -31
- 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/dist/dimensional-model/filters/utils/filter-matcher-utils.d.ts +5 -0
- package/dist/dimensional-model/filters/utils/filter-matcher-utils.js +170 -0
- package/dist/dimensional-model/filters/utils/filter-types-util.d.ts +3 -1
- package/dist/dimensional-model/filters/utils/filter-types-util.js +2 -2
- package/dist/dimensional-model/filters/utils/types.d.ts +1 -1
- package/dist/dimensional-model/interfaces.d.ts +6 -0
- package/dist/dimensional-model/types.d.ts +9 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +18 -9
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withComposeCode = exports.stringifyHelper = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Stringifies the argument
|
|
6
|
+
*
|
|
7
|
+
* @param arg - argument to stringify
|
|
8
|
+
* @returns stringified argument
|
|
9
|
+
*/
|
|
10
|
+
function stringifyHelper(arg) {
|
|
11
|
+
try {
|
|
12
|
+
if (arg === null || arg === undefined) {
|
|
13
|
+
return JSON.stringify(arg);
|
|
14
|
+
}
|
|
15
|
+
if (arg === Object(arg) && 'composeCode' in arg) {
|
|
16
|
+
return arg.composeCode;
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(arg)) {
|
|
19
|
+
return ('[' +
|
|
20
|
+
arg
|
|
21
|
+
.map((e) => {
|
|
22
|
+
return stringifyHelper(e);
|
|
23
|
+
})
|
|
24
|
+
.join(', ') +
|
|
25
|
+
']');
|
|
26
|
+
}
|
|
27
|
+
if (typeof arg === 'string') {
|
|
28
|
+
return `'${arg}'`;
|
|
29
|
+
}
|
|
30
|
+
if (typeof arg === 'number' || !isNaN(arg)) {
|
|
31
|
+
return arg;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.error(e);
|
|
36
|
+
}
|
|
37
|
+
return JSON.stringify(arg);
|
|
38
|
+
}
|
|
39
|
+
exports.stringifyHelper = stringifyHelper;
|
|
40
|
+
/**
|
|
41
|
+
* High order function to construct compose code for filter factory functions
|
|
42
|
+
*
|
|
43
|
+
* @param func - filter factory function
|
|
44
|
+
*/
|
|
45
|
+
function withComposeCode(func) {
|
|
46
|
+
return function (...args) {
|
|
47
|
+
const argValues = args.map(stringifyHelper).join(', ').replace(/, $/, '');
|
|
48
|
+
const signature = `filterFactory.${func.name}(${argValues})`;
|
|
49
|
+
const filter = func(...args);
|
|
50
|
+
filter.composeCode = signature;
|
|
51
|
+
return filter;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.withComposeCode = withComposeCode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const attributes_js_1 = require("../../attributes.js");
|
|
4
|
+
const filter_code_util_js_1 = require("./filter-code-util.js");
|
|
5
|
+
describe('stringifyHelper', () => {
|
|
6
|
+
it('should stringify random argument', () => {
|
|
7
|
+
const arg = { foo: 'bar' };
|
|
8
|
+
const result = (0, filter_code_util_js_1.stringifyHelper)(arg);
|
|
9
|
+
expect(result).toBe('{"foo":"bar"}');
|
|
10
|
+
});
|
|
11
|
+
it('should stringify common argument', () => {
|
|
12
|
+
const arg = (0, attributes_js_1.createAttribute)({
|
|
13
|
+
name: 'AgeRange',
|
|
14
|
+
type: 'text-attribute',
|
|
15
|
+
expression: '[Commerce.Age Range]',
|
|
16
|
+
});
|
|
17
|
+
arg.composeCode = 'some code';
|
|
18
|
+
const result = (0, filter_code_util_js_1.stringifyHelper)(arg);
|
|
19
|
+
expect(result).toBe('some code');
|
|
20
|
+
});
|
|
21
|
+
it('should stringify null', () => {
|
|
22
|
+
const arg = null;
|
|
23
|
+
const result = (0, filter_code_util_js_1.stringifyHelper)(arg);
|
|
24
|
+
expect(result).toBe('null');
|
|
25
|
+
});
|
|
26
|
+
it('should stringify undefined', () => {
|
|
27
|
+
const arg = undefined;
|
|
28
|
+
const result = (0, filter_code_util_js_1.stringifyHelper)(arg);
|
|
29
|
+
expect(result).toBeUndefined();
|
|
30
|
+
});
|
|
31
|
+
// Add more test cases as needed
|
|
32
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ConditionFilterJaql, FilterJaqlInternal, PeriodFilterJaql, RangeFilterJaql, SpecificItemsFilterJaql } from './types.js';
|
|
2
|
+
import { Attribute, BaseMeasure, Filter, LevelAttribute } from '../../interfaces.js';
|
|
3
|
+
import { FilterJaql } from '../../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a generic filter (aka pass-through JAQL filter) if the JAQL cannot be translated to a specific filter type.
|
|
6
|
+
*
|
|
7
|
+
* @param jaql - The JAQL object.
|
|
8
|
+
* @param guid - Optional GUID for the filter
|
|
9
|
+
* @returns A generic Filter object.
|
|
10
|
+
*/
|
|
11
|
+
export declare const createGenericFilter: (jaql: FilterJaql | FilterJaqlInternal, guid?: string) => Filter;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a filter that includes all members of the attribute.
|
|
14
|
+
*
|
|
15
|
+
* @param attribute - The attribute.
|
|
16
|
+
* @param guid - Optional GUID for the filter
|
|
17
|
+
* @returns The created Filter object.
|
|
18
|
+
*/
|
|
19
|
+
export declare const createFilterIncludeAll: (attribute: Attribute, guid?: string) => Filter;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a filter from a specific items filter JAQL object.
|
|
22
|
+
*
|
|
23
|
+
* @param attribute - attribute
|
|
24
|
+
* @param specificItemsFilterJaql - Specific Items Filter Jaql
|
|
25
|
+
* @param guid - Optional GUID for the filter
|
|
26
|
+
* @returns Filter object
|
|
27
|
+
*/
|
|
28
|
+
export declare const createFilterFromSpecificItemsFilterJaql: (attribute: Attribute, specificItemsFilterJaql: SpecificItemsFilterJaql, guid?: string) => Filter;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a filter from a date range filter JAQL object.
|
|
31
|
+
*
|
|
32
|
+
* @param attribute - attribute
|
|
33
|
+
* @param rangeFilterJaql - Range Filter Jaql
|
|
34
|
+
* @param guid - Optional GUID for the filter
|
|
35
|
+
* @returns Filter object
|
|
36
|
+
*/
|
|
37
|
+
export declare const createFilterFromDateRangeFilterJaql: (attribute: LevelAttribute, rangeFilterJaql: RangeFilterJaql, guid?: string) => Filter;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a filter from a numeric range filter JAQL object.
|
|
40
|
+
*
|
|
41
|
+
* @param attribute - attribute
|
|
42
|
+
* @param rangeFilterJaql - Range Filter Jaql
|
|
43
|
+
* @param guid - Optional GUID for the filter
|
|
44
|
+
* @returns Filter object
|
|
45
|
+
*/
|
|
46
|
+
export declare const createFilterFromNumericRangeJaql: (attribute: Attribute, rangeFilterJaql: RangeFilterJaql, guid?: string) => Filter;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a filter from a period filter JAQL object.
|
|
49
|
+
*
|
|
50
|
+
* @param attribute - attribute
|
|
51
|
+
* @param periodFilterJaql - Period Filter Jaql
|
|
52
|
+
* @param guid - Optional GUID for the filter
|
|
53
|
+
* @returns Filter object
|
|
54
|
+
*/
|
|
55
|
+
export declare const createFilterFromPeriodFilterJaql: (attribute: LevelAttribute, periodFilterJaql: PeriodFilterJaql, guid?: string) => Filter;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a filter from a condition filter JAQL object.
|
|
58
|
+
*
|
|
59
|
+
* @param attribute - attribute
|
|
60
|
+
* @param conditionFilterJaql - Condition Filter Jaql
|
|
61
|
+
* @param measure - measure
|
|
62
|
+
* @param guid - Optional GUID for the filter
|
|
63
|
+
* @returns Filter object
|
|
64
|
+
*/
|
|
65
|
+
export declare const createFilterFromConditionFilterJaql: (attribute: Attribute, conditionFilterJaql: ConditionFilterJaql, measure?: BaseMeasure, guid?: string) => Filter;
|
|
66
|
+
/**
|
|
67
|
+
* Creates a filter from a filter JAQL object.
|
|
68
|
+
*
|
|
69
|
+
* @param jaql - The filter JAQL object.
|
|
70
|
+
* @param guid - Optional GUID for the filter
|
|
71
|
+
* @returns Filter object.
|
|
72
|
+
*/
|
|
73
|
+
export declare const createFilterFromJaqlInternal: (jaql: FilterJaqlInternal, guid?: string) => Filter;
|
|
@@ -0,0 +1,190 @@
|
|
|
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.createFilterFromJaqlInternal = exports.createFilterFromConditionFilterJaql = exports.createFilterFromPeriodFilterJaql = exports.createFilterFromNumericRangeJaql = exports.createFilterFromDateRangeFilterJaql = exports.createFilterFromSpecificItemsFilterJaql = exports.createFilterIncludeAll = exports.createGenericFilter = void 0;
|
|
27
|
+
const types_js_1 = require("./types.js");
|
|
28
|
+
const filterFactory = __importStar(require("../factory.js"));
|
|
29
|
+
const condition_filter_util_js_1 = require("./condition-filter-util.js");
|
|
30
|
+
const filter_types_util_js_1 = require("./filter-types-util.js");
|
|
31
|
+
const filter_code_util_js_1 = require("./filter-code-util.js");
|
|
32
|
+
const attribute_measure_util_js_1 = require("./attribute-measure-util.js");
|
|
33
|
+
const utils_js_1 = require("../../../utils.js");
|
|
34
|
+
/**
|
|
35
|
+
* Creates a generic filter (aka pass-through JAQL filter) if the JAQL cannot be translated to a specific filter type.
|
|
36
|
+
*
|
|
37
|
+
* @param jaql - The JAQL object.
|
|
38
|
+
* @param guid - Optional GUID for the filter
|
|
39
|
+
* @returns A generic Filter object.
|
|
40
|
+
*/
|
|
41
|
+
const createGenericFilter = (jaql, guid) => {
|
|
42
|
+
return {
|
|
43
|
+
guid: guid || (0, utils_js_1.guidFast)(13),
|
|
44
|
+
jaql: (nested) => {
|
|
45
|
+
if (nested) {
|
|
46
|
+
return jaql;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
jaql,
|
|
50
|
+
panel: 'scope',
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
attribute: {
|
|
54
|
+
id: jaql.dim,
|
|
55
|
+
},
|
|
56
|
+
type: 'filter',
|
|
57
|
+
serializable() {
|
|
58
|
+
return Object.assign(Object.assign({}, this), { jaql: this.jaql() });
|
|
59
|
+
},
|
|
60
|
+
toJSON() {
|
|
61
|
+
return this.serializable();
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
exports.createGenericFilter = createGenericFilter;
|
|
66
|
+
/**
|
|
67
|
+
* Creates a filter that includes all members of the attribute.
|
|
68
|
+
*
|
|
69
|
+
* @param attribute - The attribute.
|
|
70
|
+
* @param guid - Optional GUID for the filter
|
|
71
|
+
* @returns The created Filter object.
|
|
72
|
+
*/
|
|
73
|
+
const createFilterIncludeAll = (attribute, guid) => {
|
|
74
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.members)(attribute, [], guid);
|
|
75
|
+
};
|
|
76
|
+
exports.createFilterIncludeAll = createFilterIncludeAll;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a filter from a specific items filter JAQL object.
|
|
79
|
+
*
|
|
80
|
+
* @param attribute - attribute
|
|
81
|
+
* @param specificItemsFilterJaql - Specific Items Filter Jaql
|
|
82
|
+
* @param guid - Optional GUID for the filter
|
|
83
|
+
* @returns Filter object
|
|
84
|
+
*/
|
|
85
|
+
const createFilterFromSpecificItemsFilterJaql = (attribute, specificItemsFilterJaql, guid) => {
|
|
86
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.members)(attribute, specificItemsFilterJaql.members, guid);
|
|
87
|
+
};
|
|
88
|
+
exports.createFilterFromSpecificItemsFilterJaql = createFilterFromSpecificItemsFilterJaql;
|
|
89
|
+
/**
|
|
90
|
+
* Creates a filter from a date range filter JAQL object.
|
|
91
|
+
*
|
|
92
|
+
* @param attribute - attribute
|
|
93
|
+
* @param rangeFilterJaql - Range Filter Jaql
|
|
94
|
+
* @param guid - Optional GUID for the filter
|
|
95
|
+
* @returns Filter object
|
|
96
|
+
*/
|
|
97
|
+
const createFilterFromDateRangeFilterJaql = (attribute, rangeFilterJaql, guid) => {
|
|
98
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.dateRange)(attribute, rangeFilterJaql.from, rangeFilterJaql.to, guid);
|
|
99
|
+
};
|
|
100
|
+
exports.createFilterFromDateRangeFilterJaql = createFilterFromDateRangeFilterJaql;
|
|
101
|
+
/**
|
|
102
|
+
* Creates a filter from a numeric range filter JAQL object.
|
|
103
|
+
*
|
|
104
|
+
* @param attribute - attribute
|
|
105
|
+
* @param rangeFilterJaql - Range Filter Jaql
|
|
106
|
+
* @param guid - Optional GUID for the filter
|
|
107
|
+
* @returns Filter object
|
|
108
|
+
*/
|
|
109
|
+
const createFilterFromNumericRangeJaql = (attribute, rangeFilterJaql, guid) => {
|
|
110
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.between)(attribute, rangeFilterJaql.from, rangeFilterJaql.to, guid);
|
|
111
|
+
};
|
|
112
|
+
exports.createFilterFromNumericRangeJaql = createFilterFromNumericRangeJaql;
|
|
113
|
+
/**
|
|
114
|
+
* Creates a filter from a period filter JAQL object.
|
|
115
|
+
*
|
|
116
|
+
* @param attribute - attribute
|
|
117
|
+
* @param periodFilterJaql - Period Filter Jaql
|
|
118
|
+
* @param guid - Optional GUID for the filter
|
|
119
|
+
* @returns Filter object
|
|
120
|
+
*/
|
|
121
|
+
const createFilterFromPeriodFilterJaql = (attribute, periodFilterJaql, guid) => {
|
|
122
|
+
if (periodFilterJaql.last) {
|
|
123
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.dateRelativeTo)(attribute, periodFilterJaql.last.offset, periodFilterJaql.last.count, periodFilterJaql.last.anchor, guid);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
return (0, filter_code_util_js_1.withComposeCode)(filterFactory.dateRelativeFrom)(attribute, periodFilterJaql.next.offset, periodFilterJaql.next.count, periodFilterJaql.next.anchor, guid);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
exports.createFilterFromPeriodFilterJaql = createFilterFromPeriodFilterJaql;
|
|
130
|
+
/**
|
|
131
|
+
* Creates a filter from a condition filter JAQL object.
|
|
132
|
+
*
|
|
133
|
+
* @param attribute - attribute
|
|
134
|
+
* @param conditionFilterJaql - Condition Filter Jaql
|
|
135
|
+
* @param measure - measure
|
|
136
|
+
* @param guid - Optional GUID for the filter
|
|
137
|
+
* @returns Filter object
|
|
138
|
+
*/
|
|
139
|
+
const createFilterFromConditionFilterJaql = (attribute, conditionFilterJaql, measure, guid) => {
|
|
140
|
+
if (measure) {
|
|
141
|
+
return (0, condition_filter_util_js_1.createMeasureFilterFromConditionFilterJaql)(measure, conditionFilterJaql, guid);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
return (0, condition_filter_util_js_1.createAttributeFilterFromConditionFilterJaql)(attribute, conditionFilterJaql, guid);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
exports.createFilterFromConditionFilterJaql = createFilterFromConditionFilterJaql;
|
|
148
|
+
/**
|
|
149
|
+
* Creates a filter from a filter JAQL object.
|
|
150
|
+
*
|
|
151
|
+
* @param jaql - The filter JAQL object.
|
|
152
|
+
* @param guid - Optional GUID for the filter
|
|
153
|
+
* @returns Filter object.
|
|
154
|
+
*/
|
|
155
|
+
const createFilterFromJaqlInternal = (jaql, guid) => {
|
|
156
|
+
try {
|
|
157
|
+
if ('formula' in jaql) {
|
|
158
|
+
// generic pass-through JAQL filter will be used instead
|
|
159
|
+
throw 'Formula-based filter not supported yet: ' + JSON.stringify(jaql);
|
|
160
|
+
}
|
|
161
|
+
const filterJaqlWrapperWithType = (0, filter_types_util_js_1.extractFilterTypeFromFilterJaql)(jaql, jaql.datatype);
|
|
162
|
+
const { filter: filterJaqlWithType } = filterJaqlWrapperWithType;
|
|
163
|
+
const { filterType } = filterJaqlWithType;
|
|
164
|
+
const attribute = (0, attribute_measure_util_js_1.createAttributeFromFilterJaql)(jaql);
|
|
165
|
+
const measure = (0, attribute_measure_util_js_1.createMeasureFromFilterJaql)(jaql);
|
|
166
|
+
switch (filterType) {
|
|
167
|
+
case types_js_1.FILTER_TYPES.INCLUDE_ALL:
|
|
168
|
+
return (0, exports.createFilterIncludeAll)(attribute, guid);
|
|
169
|
+
case types_js_1.FILTER_TYPES.SPECIFIC_ITEMS:
|
|
170
|
+
return (0, exports.createFilterFromSpecificItemsFilterJaql)(attribute, filterJaqlWithType, guid);
|
|
171
|
+
case types_js_1.FILTER_TYPES.CONDITION:
|
|
172
|
+
return (0, exports.createFilterFromConditionFilterJaql)(attribute, filterJaqlWithType, measure, guid);
|
|
173
|
+
case types_js_1.FILTER_TYPES.DATE_RANGE:
|
|
174
|
+
return (0, exports.createFilterFromDateRangeFilterJaql)(attribute, filterJaqlWithType, guid);
|
|
175
|
+
case types_js_1.FILTER_TYPES.PERIOD:
|
|
176
|
+
return (0, exports.createFilterFromPeriodFilterJaql)(attribute, filterJaqlWithType, guid);
|
|
177
|
+
case types_js_1.FILTER_TYPES.NUMERIC_RANGE:
|
|
178
|
+
return (0, exports.createFilterFromNumericRangeJaql)(attribute, filterJaqlWithType, guid);
|
|
179
|
+
case types_js_1.FILTER_TYPES.ADVANCED:
|
|
180
|
+
case types_js_1.FILTER_TYPES.INVALID:
|
|
181
|
+
return (0, exports.createGenericFilter)(jaql, guid);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (e) {
|
|
185
|
+
// if a filter type is untranslatable, fall back to the generic pass-through JAQL filter
|
|
186
|
+
// console.error(e);
|
|
187
|
+
}
|
|
188
|
+
return (0, exports.createGenericFilter)(jaql, guid);
|
|
189
|
+
};
|
|
190
|
+
exports.createFilterFromJaqlInternal = createFilterFromJaqlInternal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|