@sisense/sdk-data 1.21.0 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dimensional-model/attributes.js +5 -5
- package/dist/cjs/dimensional-model/base.js +1 -1
- package/dist/cjs/dimensional-model/dimensions.d.ts +3 -3
- package/dist/cjs/dimensional-model/dimensions.js +29 -25
- package/dist/cjs/dimensional-model/filters/factory.d.ts +3 -1
- package/dist/cjs/dimensional-model/filters/factory.js +4 -2
- package/dist/cjs/dimensional-model/filters/filters.d.ts +3 -1
- package/dist/cjs/dimensional-model/filters/filters.js +3 -5
- package/dist/cjs/dimensional-model/filters/utils/attribute-measure-util.d.ts +1 -1
- package/dist/cjs/dimensional-model/filters/utils/attribute-measure-util.js +5 -4
- package/dist/cjs/dimensional-model/filters/utils/condition-filter-util.js +16 -7
- package/dist/cjs/dimensional-model/filters/utils/filter-from-jaql-util.d.ts +1 -1
- package/dist/cjs/dimensional-model/filters/utils/filter-from-jaql-util.js +7 -4
- package/dist/cjs/dimensional-model/interfaces.d.ts +1 -0
- package/dist/cjs/dimensional-model/jaql-element.d.ts +36 -0
- package/dist/cjs/dimensional-model/jaql-element.js +73 -0
- package/dist/cjs/dimensional-model/measures/factory.js +2 -1
- package/dist/cjs/dimensional-model/types.d.ts +148 -0
- package/dist/cjs/dimensional-model/types.js +11 -2
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/translation/resources/en.d.ts +17 -0
- package/dist/cjs/translation/resources/en.js +3 -0
- package/dist/cjs/translation/resources/index.d.ts +12 -0
- package/dist/cjs/translation/resources/index.js +6 -0
- package/dist/cjs/translation/resources/uk.js +3 -0
- package/dist/cjs/utils.d.ts +11 -1
- package/dist/cjs/utils.js +28 -5
- package/dist/dimensional-model/attributes.js +5 -5
- package/dist/dimensional-model/base.js +1 -1
- package/dist/dimensional-model/dimensions.d.ts +3 -3
- package/dist/dimensional-model/dimensions.js +29 -25
- package/dist/dimensional-model/filters/factory.d.ts +3 -1
- package/dist/dimensional-model/filters/factory.js +4 -2
- package/dist/dimensional-model/filters/filters.d.ts +3 -1
- package/dist/dimensional-model/filters/filters.js +3 -5
- package/dist/dimensional-model/filters/utils/attribute-measure-util.d.ts +1 -1
- package/dist/dimensional-model/filters/utils/attribute-measure-util.js +5 -4
- package/dist/dimensional-model/filters/utils/condition-filter-util.js +16 -7
- package/dist/dimensional-model/filters/utils/filter-from-jaql-util.d.ts +1 -1
- package/dist/dimensional-model/filters/utils/filter-from-jaql-util.js +7 -4
- package/dist/dimensional-model/interfaces.d.ts +1 -0
- package/dist/dimensional-model/jaql-element.d.ts +36 -0
- package/dist/dimensional-model/jaql-element.js +68 -0
- package/dist/dimensional-model/measures/factory.js +2 -1
- package/dist/dimensional-model/types.d.ts +148 -0
- package/dist/dimensional-model/types.js +10 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/translation/resources/en.d.ts +17 -0
- package/dist/translation/resources/en.js +3 -0
- package/dist/translation/resources/index.d.ts +12 -0
- package/dist/translation/resources/index.js +6 -0
- package/dist/translation/resources/uk.js +3 -0
- package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -1
- package/dist/utils.d.ts +11 -1
- package/dist/utils.js +24 -2
- package/package.json +3 -3
|
@@ -427,10 +427,12 @@ export function numeric(attribute, operatorA, valueA, operatorB, valueB, guid) {
|
|
|
427
427
|
* @param guid - Optional GUID for the filter
|
|
428
428
|
* @param deactivatedMembers - Array of deactivated member values
|
|
429
429
|
* @param backgroundFilter - Optional background filter
|
|
430
|
+
* @param multiSelection - Optional flag to disable multi-selection
|
|
430
431
|
* @returns A filter instance
|
|
432
|
+
* @shortDescription Creates filter on attribute to match certain string values
|
|
431
433
|
*/
|
|
432
|
-
export function members(attribute, members, excludeMembers, guid, deactivatedMembers, backgroundFilter) {
|
|
433
|
-
return new MembersFilter(attribute, members, excludeMembers, guid, deactivatedMembers, backgroundFilter);
|
|
434
|
+
export function members(attribute, members, excludeMembers, guid, deactivatedMembers, backgroundFilter, multiSelection) {
|
|
435
|
+
return new MembersFilter(attribute, members, excludeMembers, guid, deactivatedMembers, backgroundFilter, multiSelection);
|
|
434
436
|
}
|
|
435
437
|
// DATE FILTERS
|
|
436
438
|
/**
|
|
@@ -166,10 +166,12 @@ export declare class MembersFilter extends AbstractFilter {
|
|
|
166
166
|
/** @internal */
|
|
167
167
|
excludeMembers: boolean;
|
|
168
168
|
/** @internal */
|
|
169
|
+
multiSelection: boolean;
|
|
170
|
+
/** @internal */
|
|
169
171
|
deactivatedMembers: any[];
|
|
170
172
|
/** @internal */
|
|
171
173
|
backgroundFilter?: Filter;
|
|
172
|
-
constructor(attribute: Attribute, members?: any[], excludeMembers?: boolean, guid?: string, deactivatedMembers?: any[], backgroundFilter?: Filter);
|
|
174
|
+
constructor(attribute: Attribute, members?: any[], excludeMembers?: boolean, guid?: string, deactivatedMembers?: any[], backgroundFilter?: Filter, multiSelection?: boolean);
|
|
173
175
|
/**
|
|
174
176
|
* gets the element's ID
|
|
175
177
|
*/
|
|
@@ -220,10 +220,11 @@ export class LogicalAttributeFilter extends AbstractFilter {
|
|
|
220
220
|
* @internal
|
|
221
221
|
*/
|
|
222
222
|
export class MembersFilter extends AbstractFilter {
|
|
223
|
-
constructor(attribute, members, excludeMembers, guid, deactivatedMembers, backgroundFilter) {
|
|
223
|
+
constructor(attribute, members, excludeMembers, guid, deactivatedMembers, backgroundFilter, multiSelection = true) {
|
|
224
224
|
super(attribute, FilterTypes.members, guid);
|
|
225
225
|
this.members = members !== null && members !== void 0 ? members : [];
|
|
226
226
|
this.excludeMembers = excludeMembers !== null && excludeMembers !== void 0 ? excludeMembers : false;
|
|
227
|
+
this.multiSelection = multiSelection;
|
|
227
228
|
this.deactivatedMembers = deactivatedMembers !== null && deactivatedMembers !== void 0 ? deactivatedMembers : [];
|
|
228
229
|
this.backgroundFilter = backgroundFilter;
|
|
229
230
|
if (this.members.filter((m) => m === null || m === undefined).length > 0) {
|
|
@@ -256,10 +257,7 @@ export class MembersFilter extends AbstractFilter {
|
|
|
256
257
|
const membersFilterJaql = {
|
|
257
258
|
members: this.members.map((m) => m.toString()),
|
|
258
259
|
};
|
|
259
|
-
|
|
260
|
-
const filterJaql = this.excludeMembers && this.members.length
|
|
261
|
-
? { exclude: membersFilterJaql }
|
|
262
|
-
: membersFilterJaql;
|
|
260
|
+
const filterJaql = this.excludeMembers ? { exclude: membersFilterJaql } : membersFilterJaql;
|
|
263
261
|
if (this.backgroundFilter) {
|
|
264
262
|
return {
|
|
265
263
|
and: [filterJaql, this.backgroundFilter.filterJaql()],
|
|
@@ -55,4 +55,4 @@ export declare const createMeasureFromFilterJaql: (jaql: FilterJaqlInternal) =>
|
|
|
55
55
|
* @param jaql - Ranking filter Jaql object
|
|
56
56
|
* @returns Measure
|
|
57
57
|
*/
|
|
58
|
-
export declare const createMeasureFromRankingFilterJaql: (jaql: RankingFilterJaql | CustomFormulaJaql) => BaseMeasure | CalculatedMeasure;
|
|
58
|
+
export declare const createMeasureFromRankingFilterJaql: (jaql: RankingFilterJaql | CustomFormulaJaql, rankingMessage?: string) => BaseMeasure | CalculatedMeasure;
|
|
@@ -3,6 +3,7 @@ import { isNumber } from '../../simple-column-types.js';
|
|
|
3
3
|
import { MetadataTypes } from '../../types.js';
|
|
4
4
|
import * as measureFactory from '../../measures/factory.js';
|
|
5
5
|
import { transformCustomFormulaJaql } from '../../measures/factory.js';
|
|
6
|
+
import { DimensionalBaseMeasure } from '../../measures/measures.js';
|
|
6
7
|
const DATA_MODEL_MODULE_NAME = 'DM';
|
|
7
8
|
/**
|
|
8
9
|
* Creates an attribute or level attribute from the provided parameters
|
|
@@ -58,7 +59,7 @@ export const createAttributeFromFilterJaql = (jaql) => {
|
|
|
58
59
|
*/
|
|
59
60
|
export const createMeasureHelper = (dim, table, column, level, dataType, agg, title, dataSource) => {
|
|
60
61
|
const attribute = createAttributeHelper(dim, table, column, level, dataType, title, dataSource);
|
|
61
|
-
const measure = measureFactory.aggregate(attribute, agg);
|
|
62
|
+
const measure = measureFactory.aggregate(attribute, agg, title);
|
|
62
63
|
measure.composeCode = `measureFactory.${agg}(${attribute.composeCode})`;
|
|
63
64
|
return measure;
|
|
64
65
|
};
|
|
@@ -85,7 +86,7 @@ export const createMeasureFromFilterJaql = (jaql) => {
|
|
|
85
86
|
const { dim, table, column, title, level, datatype: dataType, agg, datasource: dataSource, } = jaql;
|
|
86
87
|
if (!agg)
|
|
87
88
|
return undefined;
|
|
88
|
-
return createMeasureHelper(dim, table, column, level, dataType, agg, title, dataSource);
|
|
89
|
+
return createMeasureHelper(dim, table, column, level, dataType, DimensionalBaseMeasure.aggregationFromJAQL(agg), title, dataSource);
|
|
89
90
|
};
|
|
90
91
|
/**
|
|
91
92
|
* Creates a measure from the provided ranking filter JAQL object
|
|
@@ -93,9 +94,9 @@ export const createMeasureFromFilterJaql = (jaql) => {
|
|
|
93
94
|
* @param jaql - Ranking filter Jaql object
|
|
94
95
|
* @returns Measure
|
|
95
96
|
*/
|
|
96
|
-
export const createMeasureFromRankingFilterJaql = (jaql) => {
|
|
97
|
+
export const createMeasureFromRankingFilterJaql = (jaql, rankingMessage) => {
|
|
97
98
|
if ('formula' in jaql)
|
|
98
99
|
return createCalculatedMeasureFromJaql(jaql);
|
|
99
100
|
const { dim, table, column, level, datatype: dataType, agg } = jaql;
|
|
100
|
-
return createMeasureHelper(dim, table, column, level, dataType, agg);
|
|
101
|
+
return createMeasureHelper(dim, table, column, level, dataType, DimensionalBaseMeasure.aggregationFromJAQL(agg), rankingMessage);
|
|
101
102
|
};
|
|
@@ -2,6 +2,7 @@ import { ConditionFilterType } from './types.js';
|
|
|
2
2
|
import { withComposeCode } from './filter-code-util.js';
|
|
3
3
|
import * as filterFactory from '../factory.js';
|
|
4
4
|
import { createMeasureFromRankingFilterJaql } from './attribute-measure-util.js';
|
|
5
|
+
import { TranslatableError } from '../../../translation/translatable-error.js';
|
|
5
6
|
const isTopCondition = (filter) => filter.top !== undefined;
|
|
6
7
|
const isBottomCondition = (filter) => filter.bottom !== undefined;
|
|
7
8
|
const isExcludeCondition = (filter) => { var _a; return !!((_a = filter.exclude) === null || _a === void 0 ? void 0 : _a.members); };
|
|
@@ -81,12 +82,12 @@ export const getSelectedConditionOption = (filter) => {
|
|
|
81
82
|
* @returns attribute filter
|
|
82
83
|
*/
|
|
83
84
|
export const createAttributeFilterFromConditionFilterJaql = (attribute, conditionFilterJaql, guid) => {
|
|
84
|
-
var _a, _b, _c;
|
|
85
|
+
var _a, _b, _c, _d, _e, _f;
|
|
85
86
|
const conditionType = getSelectedConditionOption(conditionFilterJaql);
|
|
86
87
|
switch (conditionType) {
|
|
87
88
|
case ConditionFilterType.BOTTOM:
|
|
88
89
|
if (conditionFilterJaql.by) {
|
|
89
|
-
return withComposeCode(filterFactory.bottomRanking)(attribute, createMeasureFromRankingFilterJaql(conditionFilterJaql.by), conditionFilterJaql[ConditionFilterType.BOTTOM], guid);
|
|
90
|
+
return withComposeCode(filterFactory.bottomRanking)(attribute, createMeasureFromRankingFilterJaql(conditionFilterJaql.by, conditionFilterJaql.rankingMessage), conditionFilterJaql[ConditionFilterType.BOTTOM], guid);
|
|
90
91
|
}
|
|
91
92
|
break;
|
|
92
93
|
case ConditionFilterType.EQUALS:
|
|
@@ -99,7 +100,7 @@ export const createAttributeFilterFromConditionFilterJaql = (attribute, conditio
|
|
|
99
100
|
return withComposeCode(filterFactory.greaterThanOrEqual)(attribute, conditionFilterJaql[ConditionFilterType.GREATER_THAN_OR_EQUAL], guid);
|
|
100
101
|
case ConditionFilterType.TOP:
|
|
101
102
|
if (conditionFilterJaql.by) {
|
|
102
|
-
return withComposeCode(filterFactory.topRanking)(attribute, createMeasureFromRankingFilterJaql(conditionFilterJaql.by), conditionFilterJaql[ConditionFilterType.TOP], guid);
|
|
103
|
+
return withComposeCode(filterFactory.topRanking)(attribute, createMeasureFromRankingFilterJaql(conditionFilterJaql.by, conditionFilterJaql.rankingMessage), conditionFilterJaql[ConditionFilterType.TOP], guid);
|
|
103
104
|
}
|
|
104
105
|
break;
|
|
105
106
|
case ConditionFilterType.STARTS_WITH:
|
|
@@ -130,9 +131,13 @@ export const createAttributeFilterFromConditionFilterJaql = (attribute, conditio
|
|
|
130
131
|
return withComposeCode(filterFactory.union)(conditionFilterJaql.or.map((c) => createAttributeFilterFromConditionFilterJaql(attribute, c, guid)), guid);
|
|
131
132
|
}
|
|
132
133
|
break;
|
|
133
|
-
case ConditionFilterType.IS_NOT:
|
|
134
|
+
case ConditionFilterType.IS_NOT: {
|
|
135
|
+
const deactivatedMembers = (((_c = conditionFilterJaql.filter) === null || _c === void 0 ? void 0 : _c.turnedOff) && ((_d = conditionFilterJaql.filter.exclude) === null || _d === void 0 ? void 0 : _d.members)) ||
|
|
136
|
+
[];
|
|
137
|
+
const selectedMembers = ((_f = (_e = conditionFilterJaql.exclude) === null || _e === void 0 ? void 0 : _e.members) === null || _f === void 0 ? void 0 : _f.filter((member) => !deactivatedMembers.includes(member))) || [];
|
|
134
138
|
// use members filter with exclude instead of exclude filter
|
|
135
|
-
return withComposeCode(filterFactory.members)(attribute,
|
|
139
|
+
return withComposeCode(filterFactory.members)(attribute, selectedMembers, true, guid, deactivatedMembers, undefined, conditionFilterJaql.multiSelection);
|
|
140
|
+
}
|
|
136
141
|
case ConditionFilterType.AFTER:
|
|
137
142
|
case ConditionFilterType.BEFORE:
|
|
138
143
|
case ConditionFilterType.IS_EMPTY:
|
|
@@ -140,7 +145,9 @@ export const createAttributeFilterFromConditionFilterJaql = (attribute, conditio
|
|
|
140
145
|
// TODO Handle these cases later; may need filterFactory function added first
|
|
141
146
|
break;
|
|
142
147
|
}
|
|
143
|
-
throw '
|
|
148
|
+
throw new TranslatableError('errors.filter.unsupportedConditionFilter', {
|
|
149
|
+
filter: JSON.stringify(conditionFilterJaql),
|
|
150
|
+
});
|
|
144
151
|
};
|
|
145
152
|
/**
|
|
146
153
|
* Creates a measure filter from the provided measure and condition filter JAQL object
|
|
@@ -166,5 +173,7 @@ export const createMeasureFilterFromConditionFilterJaql = (measure, conditionFil
|
|
|
166
173
|
case ConditionFilterType.BETWEEN:
|
|
167
174
|
return withComposeCode(filterFactory.measureBetween)(measure, conditionFilterJaql.from, conditionFilterJaql.to, guid);
|
|
168
175
|
}
|
|
169
|
-
throw '
|
|
176
|
+
throw new TranslatableError('errors.filter.unsupportedConditionFilter', {
|
|
177
|
+
filter: JSON.stringify(conditionFilterJaql),
|
|
178
|
+
});
|
|
170
179
|
};
|
|
@@ -25,7 +25,7 @@ export declare const createFilterIncludeAll: (attribute: Attribute, guid?: strin
|
|
|
25
25
|
* @param guid - Optional GUID for the filter
|
|
26
26
|
* @returns Filter object
|
|
27
27
|
*/
|
|
28
|
-
export declare const createFilterFromSpecificItemsFilterJaql: (attribute: Attribute, specificItemsFilterJaql: SpecificItemsFilterJaql, guid?: string) => Filter;
|
|
28
|
+
export declare const createFilterFromSpecificItemsFilterJaql: (attribute: Attribute, specificItemsFilterJaql: SpecificItemsFilterJaql, guid?: string, multiSelection?: boolean) => Filter;
|
|
29
29
|
/**
|
|
30
30
|
* Creates a filter from a date range filter JAQL object.
|
|
31
31
|
*
|
|
@@ -5,6 +5,7 @@ import { extractFilterTypeFromFilterJaql } from './filter-types-util.js';
|
|
|
5
5
|
import { withComposeCode } from './filter-code-util.js';
|
|
6
6
|
import { createAttributeFromFilterJaql, createMeasureFromFilterJaql, } from './attribute-measure-util.js';
|
|
7
7
|
import { guidFast } from '../../../utils.js';
|
|
8
|
+
import { TranslatableError } from '../../../translation/translatable-error.js';
|
|
8
9
|
/**
|
|
9
10
|
* Creates a generic filter (aka pass-through JAQL filter) if the JAQL cannot be translated to a specific filter type.
|
|
10
11
|
*
|
|
@@ -56,11 +57,11 @@ export const createFilterIncludeAll = (attribute, guid) => {
|
|
|
56
57
|
* @param guid - Optional GUID for the filter
|
|
57
58
|
* @returns Filter object
|
|
58
59
|
*/
|
|
59
|
-
export const createFilterFromSpecificItemsFilterJaql = (attribute, specificItemsFilterJaql, guid) => {
|
|
60
|
+
export const createFilterFromSpecificItemsFilterJaql = (attribute, specificItemsFilterJaql, guid, multiSelection) => {
|
|
60
61
|
const deactivatedMembers = getDeactivatedMembersFromFilterJaql(specificItemsFilterJaql);
|
|
61
62
|
const activeMembers = getActiveMembersFromFilterJaql(specificItemsFilterJaql, deactivatedMembers);
|
|
62
63
|
return withComposeCode(filterFactory.members)(attribute, activeMembers, undefined, // use undefined instead of false to avoid including the property in composeCode
|
|
63
|
-
guid, deactivatedMembers);
|
|
64
|
+
guid, deactivatedMembers, undefined, multiSelection);
|
|
64
65
|
};
|
|
65
66
|
function getDeactivatedMembersFromFilterJaql(filterJaql) {
|
|
66
67
|
var _a, _b, _c;
|
|
@@ -149,7 +150,9 @@ export const createFilterFromJaqlInternal = (jaql, guid) => {
|
|
|
149
150
|
try {
|
|
150
151
|
if ('formula' in jaql) {
|
|
151
152
|
// generic pass-through JAQL filter will be used instead
|
|
152
|
-
throw '
|
|
153
|
+
throw new TranslatableError('errors.filter.formulaFiltersNotSupported', {
|
|
154
|
+
filter: JSON.stringify(jaql),
|
|
155
|
+
});
|
|
153
156
|
}
|
|
154
157
|
const filterJaqlWrapperWithType = extractFilterTypeFromFilterJaql(jaql, jaql.datatype);
|
|
155
158
|
const { filter: filterJaqlWithType } = filterJaqlWrapperWithType;
|
|
@@ -160,7 +163,7 @@ export const createFilterFromJaqlInternal = (jaql, guid) => {
|
|
|
160
163
|
case FILTER_TYPES.INCLUDE_ALL:
|
|
161
164
|
return createFilterIncludeAll(attribute, guid);
|
|
162
165
|
case FILTER_TYPES.SPECIFIC_ITEMS:
|
|
163
|
-
return createFilterFromSpecificItemsFilterJaql(attribute, filterJaqlWithType, guid);
|
|
166
|
+
return createFilterFromSpecificItemsFilterJaql(attribute, filterJaqlWithType, guid, filterJaqlWithType.multiSelection);
|
|
164
167
|
case FILTER_TYPES.CONDITION:
|
|
165
168
|
return createFilterFromConditionFilterJaql(attribute, filterJaqlWithType, measure, guid);
|
|
166
169
|
case FILTER_TYPES.DATE_RANGE:
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DimensionalElement } from './base.js';
|
|
2
|
+
import { SortDirection } from './interfaces.js';
|
|
3
|
+
import { MetadataItem } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* This implementation wraps metadata for a JAQL query. The metadata could be
|
|
6
|
+
* for a dimension, measure, or filter. We do little to no interpretation of
|
|
7
|
+
* the JAQL as it is designed to be "passed through" to the query execution
|
|
8
|
+
* step.
|
|
9
|
+
*
|
|
10
|
+
* This will typically be used for JAQL metadata that is coming from a Sisense
|
|
11
|
+
* instance and is assumed to be correct (e.g. dashboard widget, NLQ
|
|
12
|
+
* suggestion).
|
|
13
|
+
*
|
|
14
|
+
* @param item - the metadata item in a JAQL query
|
|
15
|
+
* @param type - the data type of the dimension
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare class JaqlElement extends DimensionalElement {
|
|
19
|
+
private readonly metadataItem;
|
|
20
|
+
expression: string;
|
|
21
|
+
skipValidation: boolean;
|
|
22
|
+
aggregation?: string;
|
|
23
|
+
formula?: string;
|
|
24
|
+
sortType?: SortDirection;
|
|
25
|
+
constructor(item: MetadataItem, type: string);
|
|
26
|
+
get id(): string;
|
|
27
|
+
jaql(): MetadataItem;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a JaqlElement from a MetadataItem
|
|
31
|
+
*
|
|
32
|
+
* @param item - the metadata item in a JAQL query
|
|
33
|
+
* @returns a JaqlElement
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare function createJaqlElement(item: MetadataItem): JaqlElement;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { DimensionalElement } from './base.js';
|
|
2
|
+
import { getSortType } from '../utils.js';
|
|
3
|
+
import { MetadataTypes } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* This implementation wraps metadata for a JAQL query. The metadata could be
|
|
6
|
+
* for a dimension, measure, or filter. We do little to no interpretation of
|
|
7
|
+
* the JAQL as it is designed to be "passed through" to the query execution
|
|
8
|
+
* step.
|
|
9
|
+
*
|
|
10
|
+
* This will typically be used for JAQL metadata that is coming from a Sisense
|
|
11
|
+
* instance and is assumed to be correct (e.g. dashboard widget, NLQ
|
|
12
|
+
* suggestion).
|
|
13
|
+
*
|
|
14
|
+
* @param item - the metadata item in a JAQL query
|
|
15
|
+
* @param type - the data type of the dimension
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export class JaqlElement extends DimensionalElement {
|
|
19
|
+
constructor(item, type) {
|
|
20
|
+
var _a;
|
|
21
|
+
super((_a = item.jaql.title) !== null && _a !== void 0 ? _a : '', type);
|
|
22
|
+
this.expression = (item.jaql.dim || item.jaql.formula);
|
|
23
|
+
this.metadataItem = item;
|
|
24
|
+
if (item.jaql.agg) {
|
|
25
|
+
this.aggregation = item.jaql.agg;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
delete this.aggregation;
|
|
29
|
+
}
|
|
30
|
+
if (item.jaql.formula) {
|
|
31
|
+
this.formula = item.jaql.formula;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
delete this.formula;
|
|
35
|
+
}
|
|
36
|
+
if (item.jaql.sort) {
|
|
37
|
+
this.sortType = getSortType(item.jaql.sort);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
delete this.sortType;
|
|
41
|
+
}
|
|
42
|
+
this.skipValidation = true;
|
|
43
|
+
}
|
|
44
|
+
get id() {
|
|
45
|
+
return this.expression;
|
|
46
|
+
}
|
|
47
|
+
jaql() {
|
|
48
|
+
return this.metadataItem;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const toMetadataType = {
|
|
52
|
+
text: MetadataTypes.TextAttribute,
|
|
53
|
+
numeric: MetadataTypes.NumericAttribute,
|
|
54
|
+
datetime: MetadataTypes.DateLevel,
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Create a JaqlElement from a MetadataItem
|
|
58
|
+
*
|
|
59
|
+
* @param item - the metadata item in a JAQL query
|
|
60
|
+
* @returns a JaqlElement
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export function createJaqlElement(item) {
|
|
64
|
+
var _a;
|
|
65
|
+
// TODO: measures with a "formula" may not have a datatype. force this to be numeric because aggregations
|
|
66
|
+
// will always be of type number. check if there is a more correct way to do this
|
|
67
|
+
return new JaqlElement(item, (_a = toMetadataType[item.jaql.datatype]) !== null && _a !== void 0 ? _a : 'numeric');
|
|
68
|
+
}
|
|
@@ -5,6 +5,7 @@ import mapValues from 'lodash-es/mapValues.js';
|
|
|
5
5
|
import { DimensionalAttribute, DimensionalLevelAttribute } from '../attributes.js';
|
|
6
6
|
import { isDatetime, isNumber } from './../simple-column-types.js';
|
|
7
7
|
import { convertSort, createFilterFromJaql } from '../../utils.js';
|
|
8
|
+
import { TranslatableError } from '../../translation/translatable-error.js';
|
|
8
9
|
/**
|
|
9
10
|
* Defines the different numeric operators that can be used with numeric filters
|
|
10
11
|
*
|
|
@@ -109,7 +110,7 @@ export function transformCustomFormulaJaql(jaql) {
|
|
|
109
110
|
var _a;
|
|
110
111
|
const isFormulaJaql = 'formula' in jaql;
|
|
111
112
|
if (!isFormulaJaql) {
|
|
112
|
-
throw new
|
|
113
|
+
throw new TranslatableError('errors.measure.notAFormula');
|
|
113
114
|
}
|
|
114
115
|
const sort = convertSort(jaql.sort);
|
|
115
116
|
const context = mapValues((_a = jaql.context) !== null && _a !== void 0 ? _a : {}, (jaqlContextValue) => jaqlContextValue ? transformFormulaJaqlHelper(jaqlContextValue) : {});
|
|
@@ -223,12 +223,14 @@ export declare type IncludeAllFilter = {
|
|
|
223
223
|
/** @internal */
|
|
224
224
|
export declare type IncludeMembersFilter = {
|
|
225
225
|
members: string[];
|
|
226
|
+
multiSelection?: boolean;
|
|
226
227
|
};
|
|
227
228
|
/** @internal */
|
|
228
229
|
export declare type ExcludeMembersFilter = {
|
|
229
230
|
exclude: {
|
|
230
231
|
members: string[];
|
|
231
232
|
};
|
|
233
|
+
multiSelection?: boolean;
|
|
232
234
|
};
|
|
233
235
|
/** @internal */
|
|
234
236
|
export declare type TurnOffMembersFilter = ExcludeMembersFilter & {
|
|
@@ -266,3 +268,149 @@ export declare type OrFilter<FilterItem> = {
|
|
|
266
268
|
* Abstract object with any unknown values
|
|
267
269
|
*/
|
|
268
270
|
export declare type AnyObject = Record<string, any>;
|
|
271
|
+
/**
|
|
272
|
+
* @internal
|
|
273
|
+
*/
|
|
274
|
+
interface DecimalAbbreviations {
|
|
275
|
+
k: boolean;
|
|
276
|
+
m: boolean;
|
|
277
|
+
b: boolean;
|
|
278
|
+
t: boolean;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* @internal
|
|
282
|
+
*/
|
|
283
|
+
export declare enum CurrencyPosition {
|
|
284
|
+
PRE = "pre",
|
|
285
|
+
POST = "post"
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* @internal
|
|
289
|
+
*/
|
|
290
|
+
export declare type NumericMask = {
|
|
291
|
+
isdefault?: boolean;
|
|
292
|
+
abbreviations?: DecimalAbbreviations;
|
|
293
|
+
decimals?: 'auto' | number | string;
|
|
294
|
+
currency?: {
|
|
295
|
+
symbol: string;
|
|
296
|
+
position: CurrencyPosition;
|
|
297
|
+
};
|
|
298
|
+
percent?: boolean;
|
|
299
|
+
number?: {
|
|
300
|
+
separated: boolean;
|
|
301
|
+
};
|
|
302
|
+
separated?: boolean;
|
|
303
|
+
type?: string;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* @internal
|
|
307
|
+
*/
|
|
308
|
+
export declare type DatetimeMask = {
|
|
309
|
+
isdefault?: boolean;
|
|
310
|
+
years: string;
|
|
311
|
+
quarters: string;
|
|
312
|
+
months: string;
|
|
313
|
+
weeks: string;
|
|
314
|
+
minutes: string;
|
|
315
|
+
days: string;
|
|
316
|
+
type: string;
|
|
317
|
+
dateAndTime?: string;
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* @internal
|
|
321
|
+
*/
|
|
322
|
+
export declare type MetadataItem = {
|
|
323
|
+
instanceid?: string;
|
|
324
|
+
measure?: MetadataItemJaql;
|
|
325
|
+
jaql: MetadataItemJaql;
|
|
326
|
+
panel?: string;
|
|
327
|
+
isScope?: boolean;
|
|
328
|
+
format?: {
|
|
329
|
+
mask?: Partial<DatetimeMask> | Partial<NumericMask>;
|
|
330
|
+
number?: string;
|
|
331
|
+
subtotal?: boolean;
|
|
332
|
+
width?: number;
|
|
333
|
+
databars?: boolean;
|
|
334
|
+
color?: {
|
|
335
|
+
type: string;
|
|
336
|
+
color?: string;
|
|
337
|
+
conditions?: Array<{
|
|
338
|
+
color: string;
|
|
339
|
+
operator: string;
|
|
340
|
+
expression: string | Record<string, any>;
|
|
341
|
+
}>;
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
field?: {
|
|
345
|
+
id?: string;
|
|
346
|
+
index?: number;
|
|
347
|
+
};
|
|
348
|
+
filter?: MetadataItem;
|
|
349
|
+
exclude?: MetadataItem;
|
|
350
|
+
by?: MetadataItemJaql;
|
|
351
|
+
level?: string;
|
|
352
|
+
anchor?: string;
|
|
353
|
+
from?: string;
|
|
354
|
+
to?: string;
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* @internal
|
|
358
|
+
*/
|
|
359
|
+
export declare type MetadataItemJaql = {
|
|
360
|
+
dim?: string;
|
|
361
|
+
agg?: string;
|
|
362
|
+
datatype?: string;
|
|
363
|
+
table?: string;
|
|
364
|
+
column?: string;
|
|
365
|
+
level?: string;
|
|
366
|
+
dateTimeLevel?: string;
|
|
367
|
+
bucket?: string;
|
|
368
|
+
sort?: string;
|
|
369
|
+
in?: {
|
|
370
|
+
selected: {
|
|
371
|
+
jaql: MetadataItemJaql;
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
title?: string;
|
|
375
|
+
type?: string;
|
|
376
|
+
formula?: string;
|
|
377
|
+
context?: {
|
|
378
|
+
[itemId: string]: MetadataItemJaql;
|
|
379
|
+
};
|
|
380
|
+
filter?: MetadataItem;
|
|
381
|
+
sortDetails?: {
|
|
382
|
+
dir: string;
|
|
383
|
+
field?: number;
|
|
384
|
+
measurePath?: Record<number, string | number>;
|
|
385
|
+
sortingLastDimension?: boolean;
|
|
386
|
+
initialized?: boolean;
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
/**
|
|
390
|
+
* @internal
|
|
391
|
+
*/
|
|
392
|
+
export declare type DataSourceField = {
|
|
393
|
+
column: string;
|
|
394
|
+
dimtype: string;
|
|
395
|
+
id: string;
|
|
396
|
+
indexed: boolean;
|
|
397
|
+
merged: boolean;
|
|
398
|
+
table: string;
|
|
399
|
+
title: string;
|
|
400
|
+
type: string;
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* @internal
|
|
404
|
+
*/
|
|
405
|
+
export declare type DataSourceSchema = {
|
|
406
|
+
title: string;
|
|
407
|
+
type: 'extract' | 'live';
|
|
408
|
+
} & AnyObject;
|
|
409
|
+
/**
|
|
410
|
+
* @internal
|
|
411
|
+
*/
|
|
412
|
+
export declare type DataSourceMetadata = {
|
|
413
|
+
title: string;
|
|
414
|
+
fullname: string;
|
|
415
|
+
live: boolean;
|
|
416
|
+
};
|
|
@@ -104,7 +104,8 @@ export const MetadataTypes = {
|
|
|
104
104
|
const type = o;
|
|
105
105
|
return type.toLowerCase() === MetadataTypes.BaseMeasure;
|
|
106
106
|
}
|
|
107
|
-
|
|
107
|
+
// JaqlElement doesn't have property attribute. Check for jaql instead
|
|
108
|
+
return (o.agg || o.aggregation) && (o.attribute || o.jaql) && !this.isMeasureTemplate(o);
|
|
108
109
|
},
|
|
109
110
|
/**
|
|
110
111
|
* Checks whether the given object or type is a measure - of any type
|
|
@@ -297,3 +298,11 @@ export var JaqlSortDirection;
|
|
|
297
298
|
JaqlSortDirection["ASC"] = "asc";
|
|
298
299
|
JaqlSortDirection["DESC"] = "desc";
|
|
299
300
|
})(JaqlSortDirection = JaqlSortDirection || (JaqlSortDirection = {}));
|
|
301
|
+
/**
|
|
302
|
+
* @internal
|
|
303
|
+
*/
|
|
304
|
+
export var CurrencyPosition;
|
|
305
|
+
(function (CurrencyPosition) {
|
|
306
|
+
CurrencyPosition["PRE"] = "pre";
|
|
307
|
+
CurrencyPosition["POST"] = "post";
|
|
308
|
+
})(CurrencyPosition = CurrencyPosition || (CurrencyPosition = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './dimensional-model/data-model.js';
|
|
|
14
14
|
export * from './dimensional-model/attributes.js';
|
|
15
15
|
export * from './dimensional-model/dimensions.js';
|
|
16
16
|
export * from './dimensional-model/factory.js';
|
|
17
|
+
export * from './dimensional-model/jaql-element.js';
|
|
17
18
|
export * from './dimensional-model/filters/filters.js';
|
|
18
19
|
export { createFilterMatcher } from './dimensional-model/filters/utils/filter-matcher-utils.js';
|
|
19
20
|
/**
|
|
@@ -91,3 +92,4 @@ export * from './dimensional-model/simple-column-types.js';
|
|
|
91
92
|
*/
|
|
92
93
|
export * as analyticsFactory from './dimensional-model/analytics/factory.js';
|
|
93
94
|
export * from './utils.js';
|
|
95
|
+
export { type TranslationDictionary, PACKAGE_NAMESPACE as translationNamespace, } from './translation/resources/index.js';
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from './dimensional-model/data-model.js';
|
|
|
14
14
|
export * from './dimensional-model/attributes.js';
|
|
15
15
|
export * from './dimensional-model/dimensions.js';
|
|
16
16
|
export * from './dimensional-model/factory.js';
|
|
17
|
+
export * from './dimensional-model/jaql-element.js';
|
|
17
18
|
export * from './dimensional-model/filters/filters.js';
|
|
18
19
|
export { createFilterMatcher } from './dimensional-model/filters/utils/filter-matcher-utils.js';
|
|
19
20
|
/**
|
|
@@ -91,3 +92,4 @@ export * from './dimensional-model/simple-column-types.js';
|
|
|
91
92
|
*/
|
|
92
93
|
export * as analyticsFactory from './dimensional-model/analytics/factory.js';
|
|
93
94
|
export * from './utils.js';
|
|
95
|
+
export { PACKAGE_NAMESPACE as translationNamespace, } from './translation/resources/index.js';
|
|
@@ -12,6 +12,7 @@ export declare const translation: {
|
|
|
12
12
|
noAttributeDimExpression: string;
|
|
13
13
|
noAggAggregation: string;
|
|
14
14
|
};
|
|
15
|
+
notAFormula: string;
|
|
15
16
|
};
|
|
16
17
|
dataModelConfig: {
|
|
17
18
|
noName: string;
|
|
@@ -21,8 +22,24 @@ export declare const translation: {
|
|
|
21
22
|
unsupportedType: string;
|
|
22
23
|
unsupportedDatetimeLevel: string;
|
|
23
24
|
membersFilterNullMember: string;
|
|
25
|
+
unsupportedConditionFilter: string;
|
|
26
|
+
formulaFiltersNotSupported: string;
|
|
24
27
|
};
|
|
25
28
|
unsupportedDimensionalElement: string;
|
|
26
29
|
};
|
|
27
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* A reference type containing all currently used translation keys.
|
|
33
|
+
* This type serves as a complete resource for creating custom translations,
|
|
34
|
+
* ensuring that all required keys are present and included.
|
|
35
|
+
* It can also be used as Partial to make sure custom translation does not contain any typos.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { TranslationDictionary } from '@sisense/sdk-data';
|
|
40
|
+
*
|
|
41
|
+
* const customTranslationResources: Partial<TranslationDictionary> = {
|
|
42
|
+
* ```
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
28
45
|
export declare type TranslationDictionary = typeof translation;
|
|
@@ -12,6 +12,7 @@ export const translation = {
|
|
|
12
12
|
noAttributeDimExpression: "DimensionalBaseMeasure must have 'attribute'/'dim'/'expression' property",
|
|
13
13
|
noAggAggregation: "DimensionalBaseMeasure must have 'agg' or 'aggregation' property",
|
|
14
14
|
},
|
|
15
|
+
notAFormula: 'Jaql is not a formula',
|
|
15
16
|
},
|
|
16
17
|
dataModelConfig: {
|
|
17
18
|
noName: "'name' must be specified in config for DataModel",
|
|
@@ -21,6 +22,8 @@ export const translation = {
|
|
|
21
22
|
unsupportedType: 'Unsupported filter type: {{filterType}}',
|
|
22
23
|
unsupportedDatetimeLevel: 'Filters do not support the next "datetime" levels: Hours, MinutesRoundTo30, MinutesRoundTo15, Minutes, Seconds',
|
|
23
24
|
membersFilterNullMember: 'MembersFilter of {{attributeId}} - member cannot be null',
|
|
25
|
+
unsupportedConditionFilter: 'Jaql contains unsupported condition filter: {{filter}}',
|
|
26
|
+
formulaFiltersNotSupported: 'Formula-based filter not supported yet: {{filter}}',
|
|
24
27
|
},
|
|
25
28
|
unsupportedDimensionalElement: 'Unsupported dimensional element type',
|
|
26
29
|
},
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { TranslationDictionary } from './en.js';
|
|
2
2
|
export type { TranslationDictionary };
|
|
3
|
+
/**
|
|
4
|
+
* A reference to the namespace of the translation resources.
|
|
5
|
+
* This namespace is used to access the translation resources in the i18next instance.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
3
9
|
export declare const PACKAGE_NAMESPACE: "sdkData";
|
|
4
10
|
export declare const resources: {
|
|
5
11
|
en: {
|
|
@@ -13,6 +19,7 @@ export declare const resources: {
|
|
|
13
19
|
noAttributeDimExpression: string;
|
|
14
20
|
noAggAggregation: string;
|
|
15
21
|
};
|
|
22
|
+
notAFormula: string;
|
|
16
23
|
};
|
|
17
24
|
dataModelConfig: {
|
|
18
25
|
noName: string;
|
|
@@ -22,6 +29,8 @@ export declare const resources: {
|
|
|
22
29
|
unsupportedType: string;
|
|
23
30
|
unsupportedDatetimeLevel: string;
|
|
24
31
|
membersFilterNullMember: string;
|
|
32
|
+
unsupportedConditionFilter: string;
|
|
33
|
+
formulaFiltersNotSupported: string;
|
|
25
34
|
};
|
|
26
35
|
unsupportedDimensionalElement: string;
|
|
27
36
|
};
|
|
@@ -37,6 +46,7 @@ export declare const resources: {
|
|
|
37
46
|
noAttributeDimExpression: string;
|
|
38
47
|
noAggAggregation: string;
|
|
39
48
|
};
|
|
49
|
+
notAFormula: string;
|
|
40
50
|
};
|
|
41
51
|
dataModelConfig: {
|
|
42
52
|
noName: string;
|
|
@@ -46,6 +56,8 @@ export declare const resources: {
|
|
|
46
56
|
unsupportedType: string;
|
|
47
57
|
unsupportedDatetimeLevel: string;
|
|
48
58
|
membersFilterNullMember: string;
|
|
59
|
+
unsupportedConditionFilter: string;
|
|
60
|
+
formulaFiltersNotSupported: string;
|
|
49
61
|
};
|
|
50
62
|
unsupportedDimensionalElement: string;
|
|
51
63
|
};
|