@sisense/sdk-data 0.14.0 → 0.16.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/dimensional-model/data-model.js +5 -4
- package/dist/dimensional-model/factory.js +2 -2
- package/dist/dimensional-model/filters/filters.js +8 -10
- package/dist/dimensional-model/interfaces.d.ts +3 -0
- package/dist/dimensional-model/measures/factory.d.ts +61 -1
- package/dist/dimensional-model/measures/factory.js +96 -12
- package/dist/dimensional-model/measures/measures.js +6 -6
- package/dist/dimensional-model/types.d.ts +52 -0
- package/dist/dimensional-model/types.js +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces.d.ts +1 -1
- package/dist/translation/initialize-i18n.d.ts +2 -0
- package/dist/translation/initialize-i18n.js +10 -0
- package/dist/translation/resources/en.d.ts +28 -0
- package/dist/translation/resources/en.js +27 -0
- package/dist/translation/resources/index.d.ts +53 -0
- package/dist/translation/resources/index.js +7 -0
- package/dist/translation/resources/uk.d.ts +5 -0
- package/dist/translation/resources/uk.js +27 -0
- package/dist/translation/translatable-error.d.ts +5 -0
- package/dist/translation/translatable-error.js +11 -0
- package/package.json +5 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { create } from './factory.js';
|
|
2
|
+
import { TranslatableError } from '../translation/translatable-error.js';
|
|
2
3
|
/**
|
|
3
4
|
* @internal
|
|
4
5
|
*/
|
|
@@ -17,11 +18,11 @@ export class DimensionalDataModel {
|
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
static fromConfig(config) {
|
|
20
|
-
if (
|
|
21
|
-
throw new
|
|
21
|
+
if (config && !config.name) {
|
|
22
|
+
throw new TranslatableError('errors.dataModel.noName');
|
|
22
23
|
}
|
|
23
|
-
if (
|
|
24
|
-
throw new
|
|
24
|
+
if (config && !config.metadata) {
|
|
25
|
+
throw new TranslatableError('errors.dataModel.noMetadata');
|
|
25
26
|
}
|
|
26
27
|
const metadata = new Array();
|
|
27
28
|
for (let i = 0; i < config.metadata.length; i++) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-throw-literal */
|
|
4
3
|
import { MetadataTypes } from './types.js';
|
|
5
4
|
import { createMeasure } from './measures/measures.js';
|
|
6
5
|
import { createFilter } from './filters/filters.js';
|
|
7
6
|
import { createDimension } from './dimensions.js';
|
|
8
7
|
import { createAttribute } from './attributes.js';
|
|
8
|
+
import { TranslatableError } from '../translation/translatable-error.js';
|
|
9
9
|
/**
|
|
10
10
|
* Generate an array of dimension model instances out of the given JSON array
|
|
11
11
|
*
|
|
@@ -46,5 +46,5 @@ export function create(item) {
|
|
|
46
46
|
item.dimtype) {
|
|
47
47
|
return createDimension(item);
|
|
48
48
|
}
|
|
49
|
-
throw '
|
|
49
|
+
throw new TranslatableError('errors.unsupportedDimesionalElement');
|
|
50
50
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-throw-literal */
|
|
5
4
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
6
5
|
/* eslint-disable max-lines */
|
|
7
6
|
/* eslint-disable max-params */
|
|
@@ -14,6 +13,7 @@ import { DimensionalElement } from '../base.js';
|
|
|
14
13
|
import { DateLevels, MetadataTypes } from '../types.js';
|
|
15
14
|
import { create } from '../factory.js';
|
|
16
15
|
import { DimensionalBaseMeasure } from '../measures/measures.js';
|
|
16
|
+
import { TranslatableError } from '../../translation/translatable-error.js';
|
|
17
17
|
/**
|
|
18
18
|
* Different text operators that can be used with text filters
|
|
19
19
|
*
|
|
@@ -140,7 +140,7 @@ class AbstractFilter extends DimensionalElement {
|
|
|
140
140
|
if (granularity === DateLevels.Hours ||
|
|
141
141
|
granularity === DateLevels.MinutesRoundTo30 ||
|
|
142
142
|
granularity === DateLevels.MinutesRoundTo15) {
|
|
143
|
-
throw new
|
|
143
|
+
throw new TranslatableError('errors.filter.unsupportedDatetimeLevel');
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -185,7 +185,9 @@ export class MembersFilter extends AbstractFilter {
|
|
|
185
185
|
super(attribute, FilterTypes.members);
|
|
186
186
|
this.members = members !== null && members !== void 0 ? members : [];
|
|
187
187
|
if (this.members.filter((m) => m === null || m === undefined).length > 0) {
|
|
188
|
-
throw
|
|
188
|
+
throw new TranslatableError('errors.filter.membersFilterNullMember', {
|
|
189
|
+
attributeId: attribute.id,
|
|
190
|
+
});
|
|
189
191
|
}
|
|
190
192
|
}
|
|
191
193
|
/**
|
|
@@ -399,9 +401,6 @@ export class RankingFilter extends AbstractFilter {
|
|
|
399
401
|
export class NumericFilter extends DoubleOperatorFilter {
|
|
400
402
|
constructor(att, operatorA, valueA, operatorB, valueB) {
|
|
401
403
|
super(att, FilterTypes.numeric, operatorA, valueA, operatorB, valueB);
|
|
402
|
-
// if (att.dimension && !MetadataTypes.isTextDimension(att.dimension.type)) {
|
|
403
|
-
// throw 'Dimension must be of Text type to be applied with Text filter';
|
|
404
|
-
// }
|
|
405
404
|
}
|
|
406
405
|
}
|
|
407
406
|
/**
|
|
@@ -410,9 +409,6 @@ export class NumericFilter extends DoubleOperatorFilter {
|
|
|
410
409
|
export class TextFilter extends DoubleOperatorFilter {
|
|
411
410
|
constructor(att, operator, value) {
|
|
412
411
|
super(att, FilterTypes.text, operator, value);
|
|
413
|
-
// if (att.dimension && !MetadataTypes.isTextDimension(att.dimension.type)) {
|
|
414
|
-
// throw 'Dimension must be of Text type to be applied with Text filter';
|
|
415
|
-
// }
|
|
416
412
|
}
|
|
417
413
|
}
|
|
418
414
|
/**
|
|
@@ -544,5 +540,7 @@ export function createFilter(json) {
|
|
|
544
540
|
return new DateRangeFilter(create(json.attribute), json.valueA, json.valueB);
|
|
545
541
|
break;
|
|
546
542
|
}
|
|
547
|
-
throw '
|
|
543
|
+
throw new TranslatableError('errors.filter.unsupportedType', {
|
|
544
|
+
filterType: json.filterType,
|
|
545
|
+
});
|
|
548
546
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Attribute, Measure, Filter, CalculatedMeasure, BaseMeasure } from '../interfaces.js';
|
|
1
|
+
import { Attribute, Measure, Filter, CalculatedMeasure, BaseMeasure, CustomFormulaContext } from '../interfaces.js';
|
|
2
2
|
import { ForecastFormulaOptions, TrendFormulaOptions } from '../../interfaces.js';
|
|
3
3
|
/**
|
|
4
4
|
* Defines the different numeric operators that can be used with numeric filters
|
|
@@ -32,6 +32,66 @@ export declare const RankingSortTypes: {
|
|
|
32
32
|
Ascending: string;
|
|
33
33
|
Descending: string;
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Creates a calculated measure for a [valid custom formula](https://docs.sisense.com/main/SisenseLinux/dashboard-functions-reference.htm).
|
|
37
|
+
*
|
|
38
|
+
* Use square brackets within the `formula` to include dimensions or measures.
|
|
39
|
+
* Each unique dimension or measure included in the `formula` must be defined using a property:value pair in the `context` parameter.
|
|
40
|
+
*
|
|
41
|
+
* You can nest custom formulas by placing one inside the `formula` parameter of another
|
|
42
|
+
*
|
|
43
|
+
*
|
|
44
|
+
* Note: Shared formula must be fetched prior to use (see {@link @sisense/sdk-ui!useGetSharedFormula | useGetSharedFormula}).
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* An example of constructing a `customFormula` using dimensions, measures, and nested custom formulas:
|
|
48
|
+
* ```tsx
|
|
49
|
+
* const profitabilityRatio = measures.customFormula(
|
|
50
|
+
* 'Profitability Ratio',
|
|
51
|
+
* '([totalRevenue] - SUM([cost])) / [totalRevenue]',
|
|
52
|
+
* {
|
|
53
|
+
* totalRevenue: measures.sum(DM.Commerce.Revenue),
|
|
54
|
+
* cost: DM.Commerce.Cost,
|
|
55
|
+
* },
|
|
56
|
+
* );
|
|
57
|
+
*
|
|
58
|
+
* const profitabilityRatioRank = measures.customFormula(
|
|
59
|
+
* 'Profitability Ratio Rank',
|
|
60
|
+
* 'RANK([profRatio], "ASC", "1224")',
|
|
61
|
+
* {
|
|
62
|
+
* profRatio: profitabilityRatio,
|
|
63
|
+
* },
|
|
64
|
+
* );
|
|
65
|
+
*
|
|
66
|
+
* return (
|
|
67
|
+
* <Chart
|
|
68
|
+
* dataSet={DM.DataSource}
|
|
69
|
+
* chartType="line"
|
|
70
|
+
* dataOptions={{
|
|
71
|
+
* category: [DM.Commerce.AgeRange],
|
|
72
|
+
* value: [
|
|
73
|
+
* profitabilityRatioRank,
|
|
74
|
+
* {
|
|
75
|
+
* column: measures.sum(DM.Commerce.Revenue, 'Total Revenue'),
|
|
76
|
+
* showOnRightAxis: true,
|
|
77
|
+
* chartType: 'column',
|
|
78
|
+
* },
|
|
79
|
+
* {
|
|
80
|
+
* column: measures.sum(DM.Commerce.Cost, 'Total Cost'),
|
|
81
|
+
* showOnRightAxis: true,
|
|
82
|
+
* chartType: 'column',
|
|
83
|
+
* },
|
|
84
|
+
* ],
|
|
85
|
+
* }}
|
|
86
|
+
* />
|
|
87
|
+
* );
|
|
88
|
+
* ```
|
|
89
|
+
* @param title - Title of the measure to be displayed in legend
|
|
90
|
+
* @param formula - Formula to be used for the measure
|
|
91
|
+
* @param context - Formula context as a map of strings to measures or attributes
|
|
92
|
+
* @returns A calculated measure object that may be used in a chart or a query
|
|
93
|
+
*/
|
|
94
|
+
export declare function customFormula(title: string, formula: string, context: CustomFormulaContext): Attribute | Measure;
|
|
35
95
|
/**
|
|
36
96
|
* Creates a basic aggregated measure.
|
|
37
97
|
* This is a base function to build other aggregation functions (e.g., `sum`, `average`, etc)
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { DimensionalBaseMeasure, DimensionalCalculatedMeasure } from './measures.js';
|
|
2
|
-
import { AggregationTypes, MetadataTypes } from '../types.js';
|
|
2
|
+
import { AggregationTypes, MetadataTypes, Sort } from '../types.js';
|
|
3
3
|
import { normalizeName } from '../base.js';
|
|
4
|
+
import mapValues from 'lodash/mapValues.js';
|
|
5
|
+
import { DimensionalAttribute, DimensionalLevelAttribute } from '../attributes.js';
|
|
6
|
+
import { isDatetime, isNumber } from './../simple-column-types.js';
|
|
4
7
|
/**
|
|
5
8
|
* Defines the different numeric operators that can be used with numeric filters
|
|
6
9
|
*
|
|
@@ -70,6 +73,96 @@ function measureFunction(measure, name, func, options) {
|
|
|
70
73
|
builder.push(')');
|
|
71
74
|
return new DimensionalCalculatedMeasure(name, builder.join(''), context);
|
|
72
75
|
}
|
|
76
|
+
function transformCustomFormulaJaql(jaql) {
|
|
77
|
+
var _a;
|
|
78
|
+
const isFormulaJaql = 'formula' in jaql;
|
|
79
|
+
let sort;
|
|
80
|
+
if (jaql.sort) {
|
|
81
|
+
sort = jaql.sort === 'asc' ? Sort.Ascending : Sort.Descending;
|
|
82
|
+
}
|
|
83
|
+
if (isFormulaJaql) {
|
|
84
|
+
const context = mapValues((_a = jaql.context) !== null && _a !== void 0 ? _a : {}, (jaqlContextValue) => jaqlContextValue ? transformCustomFormulaJaql(jaqlContextValue) : {});
|
|
85
|
+
return new DimensionalCalculatedMeasure(jaql.title, jaql.formula, context, undefined, undefined, sort);
|
|
86
|
+
}
|
|
87
|
+
const hasAggregation = !!jaql.agg;
|
|
88
|
+
const isDatatypeDatetime = isDatetime(jaql.datatype);
|
|
89
|
+
const attributeType = isNumber(jaql.datatype)
|
|
90
|
+
? MetadataTypes.NumericAttribute
|
|
91
|
+
: MetadataTypes.TextAttribute;
|
|
92
|
+
const attribute = isDatatypeDatetime
|
|
93
|
+
? new DimensionalLevelAttribute(jaql.title, jaql.dim, DimensionalLevelAttribute.translateJaqlToGranularity(jaql), undefined, undefined, sort)
|
|
94
|
+
: new DimensionalAttribute(jaql.title, jaql.dim, attributeType, undefined, sort);
|
|
95
|
+
if (hasAggregation) {
|
|
96
|
+
return new DimensionalBaseMeasure(jaql.title, attribute, DimensionalBaseMeasure.aggregationFromJAQL(jaql.agg || ''), undefined, undefined, sort);
|
|
97
|
+
}
|
|
98
|
+
return attribute;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Creates a calculated measure for a [valid custom formula](https://docs.sisense.com/main/SisenseLinux/dashboard-functions-reference.htm).
|
|
102
|
+
*
|
|
103
|
+
* Use square brackets within the `formula` to include dimensions or measures.
|
|
104
|
+
* Each unique dimension or measure included in the `formula` must be defined using a property:value pair in the `context` parameter.
|
|
105
|
+
*
|
|
106
|
+
* You can nest custom formulas by placing one inside the `formula` parameter of another
|
|
107
|
+
*
|
|
108
|
+
*
|
|
109
|
+
* Note: Shared formula must be fetched prior to use (see {@link @sisense/sdk-ui!useGetSharedFormula | useGetSharedFormula}).
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* An example of constructing a `customFormula` using dimensions, measures, and nested custom formulas:
|
|
113
|
+
* ```tsx
|
|
114
|
+
* const profitabilityRatio = measures.customFormula(
|
|
115
|
+
* 'Profitability Ratio',
|
|
116
|
+
* '([totalRevenue] - SUM([cost])) / [totalRevenue]',
|
|
117
|
+
* {
|
|
118
|
+
* totalRevenue: measures.sum(DM.Commerce.Revenue),
|
|
119
|
+
* cost: DM.Commerce.Cost,
|
|
120
|
+
* },
|
|
121
|
+
* );
|
|
122
|
+
*
|
|
123
|
+
* const profitabilityRatioRank = measures.customFormula(
|
|
124
|
+
* 'Profitability Ratio Rank',
|
|
125
|
+
* 'RANK([profRatio], "ASC", "1224")',
|
|
126
|
+
* {
|
|
127
|
+
* profRatio: profitabilityRatio,
|
|
128
|
+
* },
|
|
129
|
+
* );
|
|
130
|
+
*
|
|
131
|
+
* return (
|
|
132
|
+
* <Chart
|
|
133
|
+
* dataSet={DM.DataSource}
|
|
134
|
+
* chartType="line"
|
|
135
|
+
* dataOptions={{
|
|
136
|
+
* category: [DM.Commerce.AgeRange],
|
|
137
|
+
* value: [
|
|
138
|
+
* profitabilityRatioRank,
|
|
139
|
+
* {
|
|
140
|
+
* column: measures.sum(DM.Commerce.Revenue, 'Total Revenue'),
|
|
141
|
+
* showOnRightAxis: true,
|
|
142
|
+
* chartType: 'column',
|
|
143
|
+
* },
|
|
144
|
+
* {
|
|
145
|
+
* column: measures.sum(DM.Commerce.Cost, 'Total Cost'),
|
|
146
|
+
* showOnRightAxis: true,
|
|
147
|
+
* chartType: 'column',
|
|
148
|
+
* },
|
|
149
|
+
* ],
|
|
150
|
+
* }}
|
|
151
|
+
* />
|
|
152
|
+
* );
|
|
153
|
+
* ```
|
|
154
|
+
* @param title - Title of the measure to be displayed in legend
|
|
155
|
+
* @param formula - Formula to be used for the measure
|
|
156
|
+
* @param context - Formula context as a map of strings to measures or attributes
|
|
157
|
+
* @returns A calculated measure object that may be used in a chart or a query
|
|
158
|
+
*/
|
|
159
|
+
export function customFormula(title, formula, context) {
|
|
160
|
+
const newContext = Object.entries(context).reduce((acc, [key, val]) => {
|
|
161
|
+
acc[`[${key}]`] = val.jaql().jaql;
|
|
162
|
+
return acc;
|
|
163
|
+
}, {});
|
|
164
|
+
return transformCustomFormulaJaql({ title, formula, context: newContext });
|
|
165
|
+
}
|
|
73
166
|
function arithmetic(operand1, operator, operand2, name, withParentheses) {
|
|
74
167
|
const builder = [];
|
|
75
168
|
const context = {};
|
|
@@ -97,13 +190,6 @@ function arithmetic(operand1, operator, operand2, name, withParentheses) {
|
|
|
97
190
|
* @returns A Measure instance
|
|
98
191
|
*/
|
|
99
192
|
export function aggregate(attribute, aggregationType, name, format) {
|
|
100
|
-
// if (aggregationType == AggregationTypes.Average || aggregationType == AggregationTypes.Max ||
|
|
101
|
-
// aggregationType == AggregationTypes.Min || aggregationType == AggregationTypes.Median ||
|
|
102
|
-
// aggregationType == AggregationTypes.Sum) {
|
|
103
|
-
// if (!MetadataTypes.isNumericDimension(attribute.type)) {
|
|
104
|
-
// throw `${aggregationType} is supported for numeric attributes only, where ${attribute.name} is ${attribute.type}`;
|
|
105
|
-
// }
|
|
106
|
-
// }
|
|
107
193
|
return new DimensionalBaseMeasure(name !== null && name !== void 0 ? name : `${aggregationType.toString()} ${attribute.name}`, attribute, aggregationType, format);
|
|
108
194
|
}
|
|
109
195
|
/**
|
|
@@ -541,9 +627,7 @@ export function contribution(measure, name) {
|
|
|
541
627
|
*/
|
|
542
628
|
export function trend(measure, name, options) {
|
|
543
629
|
let params;
|
|
544
|
-
const adjustValues = (value) => value
|
|
545
|
-
.replace('advancedSmoothing', 'Advanced Smoothing')
|
|
546
|
-
.replace('localEstimates', 'Local Estimates');
|
|
630
|
+
const adjustValues = (value) => value.replace('advancedSmoothing', 'smooth').replace('localEstimates', 'local');
|
|
547
631
|
if (options) {
|
|
548
632
|
// make a comma separated name=value string based on options
|
|
549
633
|
params = Object.entries(options)
|
|
@@ -577,7 +661,7 @@ export function forecast(measure, name, options) {
|
|
|
577
661
|
let params;
|
|
578
662
|
if (options) {
|
|
579
663
|
// create ISO string values for any Date objects
|
|
580
|
-
const adjustedOptions = Object.assign({}, options);
|
|
664
|
+
const adjustedOptions = Object.assign({ forecastHorizon: 3 }, options);
|
|
581
665
|
if (adjustedOptions.startDate) {
|
|
582
666
|
const startDate = new Date(adjustedOptions.startDate);
|
|
583
667
|
adjustedOptions.startDate = startDate.toISOString().replace(/.\d+Z$/g, '');
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
9
9
|
/* eslint-disable sonarjs/cognitive-complexity */
|
|
10
10
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
11
|
-
/* eslint-disable @typescript-eslint/no-throw-literal */
|
|
12
11
|
import * as m from './factory.js';
|
|
13
12
|
import { Sort, AggregationTypes, MetadataTypes } from '../types.js';
|
|
14
13
|
import { DimensionalElement } from '../base.js';
|
|
15
14
|
import { DimensionalAttribute, createAttribute } from '../attributes.js';
|
|
16
15
|
import { create } from '../factory.js';
|
|
16
|
+
import { TranslatableError } from '../../translation/translatable-error.js';
|
|
17
17
|
/**
|
|
18
18
|
* @internal
|
|
19
19
|
*/
|
|
@@ -360,7 +360,7 @@ export function createMeasure(json) {
|
|
|
360
360
|
}
|
|
361
361
|
if (MetadataTypes.isCalculatedMeasure(json)) {
|
|
362
362
|
if (json.context === undefined) {
|
|
363
|
-
throw new
|
|
363
|
+
throw new TranslatableError('errors.measure.dimensionalCalculatedMeasure.noContext');
|
|
364
364
|
}
|
|
365
365
|
const context = {};
|
|
366
366
|
Object.getOwnPropertyNames(json.context).forEach((pname) => {
|
|
@@ -370,19 +370,19 @@ export function createMeasure(json) {
|
|
|
370
370
|
}
|
|
371
371
|
else if (MetadataTypes.isMeasureTemplate(json)) {
|
|
372
372
|
if (att === undefined) {
|
|
373
|
-
throw new
|
|
373
|
+
throw new TranslatableError('errors.measure.dimensionalBaseMeasure.noAttributeDimExpression');
|
|
374
374
|
}
|
|
375
375
|
return new DimensionalMeasureTemplate(name, att, format, desc);
|
|
376
376
|
}
|
|
377
377
|
else if (MetadataTypes.isBaseMeasure(json)) {
|
|
378
378
|
if (att === undefined) {
|
|
379
|
-
throw new
|
|
379
|
+
throw new TranslatableError('errors.measure.dimensionalBaseMeasure.noAttributeDimExpression');
|
|
380
380
|
}
|
|
381
381
|
const agg = json.agg || json.aggregation;
|
|
382
382
|
if (!agg) {
|
|
383
|
-
throw
|
|
383
|
+
throw new TranslatableError('errors.measure.dimensionalBaseMeasure.noAggAggregation');
|
|
384
384
|
}
|
|
385
385
|
return new DimensionalBaseMeasure(name, att, agg, format, desc);
|
|
386
386
|
}
|
|
387
|
-
throw '
|
|
387
|
+
throw new TranslatableError('errors.measure.unsupportedType');
|
|
388
388
|
}
|
|
@@ -150,3 +150,55 @@ export declare const DateLevels: {
|
|
|
150
150
|
/** @internal */
|
|
151
151
|
readonly all: string[];
|
|
152
152
|
};
|
|
153
|
+
export declare enum DataType {
|
|
154
|
+
TEXT = "text",
|
|
155
|
+
NUMERIC = "numeric",
|
|
156
|
+
DATETIME = "datetime"
|
|
157
|
+
}
|
|
158
|
+
export declare enum SortDirection {
|
|
159
|
+
ASC = "asc",
|
|
160
|
+
DESC = "desc"
|
|
161
|
+
}
|
|
162
|
+
export declare type Jaql = BaseJaql | FormulaJaql | FilterJaql;
|
|
163
|
+
export declare type BaseJaql = {
|
|
164
|
+
agg?: string;
|
|
165
|
+
datatype: DataType;
|
|
166
|
+
dim: string;
|
|
167
|
+
table: string;
|
|
168
|
+
column: string;
|
|
169
|
+
title: string;
|
|
170
|
+
level?: 'years' | 'quarters' | 'months' | 'weeks' | 'minutes' | 'days';
|
|
171
|
+
sort?: SortDirection;
|
|
172
|
+
};
|
|
173
|
+
export declare type FormulaID = string;
|
|
174
|
+
export declare type FormulaContext = BaseJaql | FormulaJaql | FilterJaql;
|
|
175
|
+
export declare type FormulaJaql = {
|
|
176
|
+
type?: 'measure';
|
|
177
|
+
sort?: SortDirection;
|
|
178
|
+
title: string;
|
|
179
|
+
formula: string;
|
|
180
|
+
context?: Record<FormulaID, FormulaContext>;
|
|
181
|
+
};
|
|
182
|
+
export declare type BaseFilter = IncludeAllFilter | IncludeMembersFilter | ExcludeMembersFilter;
|
|
183
|
+
export declare type BackgroundFilter = BaseFilter & {
|
|
184
|
+
level?: 'string';
|
|
185
|
+
};
|
|
186
|
+
export declare type IncludeAllFilter = {
|
|
187
|
+
all: true;
|
|
188
|
+
};
|
|
189
|
+
export declare type IncludeMembersFilter = {
|
|
190
|
+
members: string[];
|
|
191
|
+
};
|
|
192
|
+
export declare type ExcludeMembersFilter = {
|
|
193
|
+
exclude: {
|
|
194
|
+
members: string[];
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
export declare type TurnOffMembersFilter = ExcludeMembersFilter & {
|
|
198
|
+
turnedOff: boolean;
|
|
199
|
+
};
|
|
200
|
+
export declare type FilterJaql = BaseJaql & {
|
|
201
|
+
filter: BaseFilter & {
|
|
202
|
+
filter?: BackgroundFilter | TurnOffMembersFilter;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
@@ -282,3 +282,14 @@ export const DateLevels = {
|
|
|
282
282
|
];
|
|
283
283
|
},
|
|
284
284
|
};
|
|
285
|
+
export var DataType;
|
|
286
|
+
(function (DataType) {
|
|
287
|
+
DataType["TEXT"] = "text";
|
|
288
|
+
DataType["NUMERIC"] = "numeric";
|
|
289
|
+
DataType["DATETIME"] = "datetime";
|
|
290
|
+
})(DataType = DataType || (DataType = {}));
|
|
291
|
+
export var SortDirection;
|
|
292
|
+
(function (SortDirection) {
|
|
293
|
+
SortDirection["ASC"] = "asc";
|
|
294
|
+
SortDirection["DESC"] = "desc";
|
|
295
|
+
})(SortDirection = SortDirection || (SortDirection = {}));
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/interfaces.d.ts
CHANGED
|
@@ -184,7 +184,7 @@ export declare type ForecastFormulaOptions = {
|
|
|
184
184
|
*
|
|
185
185
|
* @defaultValue 3
|
|
186
186
|
*/
|
|
187
|
-
forecastHorizon
|
|
187
|
+
forecastHorizon?: number;
|
|
188
188
|
/**
|
|
189
189
|
* Forecasting model type. The 'auto' option automatically
|
|
190
190
|
* fits the best combination of models.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { initI18next } from '@sisense/sdk-common';
|
|
2
|
+
import { resources, PACKAGE_NAMESPACE } from './resources/index.js';
|
|
3
|
+
export function initializeI18n() {
|
|
4
|
+
return initI18next({
|
|
5
|
+
resource: resources,
|
|
6
|
+
language: 'en',
|
|
7
|
+
namespace: PACKAGE_NAMESPACE,
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export const { i18nextInstance } = initializeI18n();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translation dictionary for English language.
|
|
3
|
+
*/
|
|
4
|
+
export declare const translation: {
|
|
5
|
+
errors: {
|
|
6
|
+
measure: {
|
|
7
|
+
unsupportedType: string;
|
|
8
|
+
dimensionalCalculatedMeasure: {
|
|
9
|
+
noContext: string;
|
|
10
|
+
};
|
|
11
|
+
dimensionalBaseMeasure: {
|
|
12
|
+
noAttributeDimExpression: string;
|
|
13
|
+
noAggAggregation: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
dataModelConfig: {
|
|
17
|
+
noName: string;
|
|
18
|
+
noMetadata: string;
|
|
19
|
+
};
|
|
20
|
+
filter: {
|
|
21
|
+
unsupportedType: string;
|
|
22
|
+
unsupportedDatetimeLevel: string;
|
|
23
|
+
membersFilterNullMember: string;
|
|
24
|
+
};
|
|
25
|
+
unsupportedDimesionalElement: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare type TranslationDictionary = typeof translation;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translation dictionary for English language.
|
|
3
|
+
*/
|
|
4
|
+
export const translation = {
|
|
5
|
+
errors: {
|
|
6
|
+
measure: {
|
|
7
|
+
unsupportedType: 'Unsupported measure type',
|
|
8
|
+
dimensionalCalculatedMeasure: {
|
|
9
|
+
noContext: "DimensionalCalculatedMeasure must have 'context' property",
|
|
10
|
+
},
|
|
11
|
+
dimensionalBaseMeasure: {
|
|
12
|
+
noAttributeDimExpression: "DimensionalBaseMeasure must have 'attribute'/'dim'/'expression' property",
|
|
13
|
+
noAggAggregation: "DimensionalBaseMeasure must have 'agg' or 'aggregation' property",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
dataModelConfig: {
|
|
17
|
+
noName: "'name' must be specified in config for DataModel",
|
|
18
|
+
noMetadata: "'metadata' must be specified in config for DataModel",
|
|
19
|
+
},
|
|
20
|
+
filter: {
|
|
21
|
+
unsupportedType: 'Unsupported filter type: {{filterType}}',
|
|
22
|
+
unsupportedDatetimeLevel: 'Filters do not support the next "datetime" levels: Hours, MinutesRoundTo30, MinutesRoundTo15',
|
|
23
|
+
membersFilterNullMember: 'MembersFilter of {{attributeId}} - member cannot be null',
|
|
24
|
+
},
|
|
25
|
+
unsupportedDimesionalElement: 'Unsupported dimensional element type',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { TranslationDictionary } from './en.js';
|
|
2
|
+
export type { TranslationDictionary };
|
|
3
|
+
export declare const PACKAGE_NAMESPACE: "sdkData";
|
|
4
|
+
export declare const resources: {
|
|
5
|
+
en: {
|
|
6
|
+
errors: {
|
|
7
|
+
measure: {
|
|
8
|
+
unsupportedType: string;
|
|
9
|
+
dimensionalCalculatedMeasure: {
|
|
10
|
+
noContext: string;
|
|
11
|
+
};
|
|
12
|
+
dimensionalBaseMeasure: {
|
|
13
|
+
noAttributeDimExpression: string;
|
|
14
|
+
noAggAggregation: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
dataModelConfig: {
|
|
18
|
+
noName: string;
|
|
19
|
+
noMetadata: string;
|
|
20
|
+
};
|
|
21
|
+
filter: {
|
|
22
|
+
unsupportedType: string;
|
|
23
|
+
unsupportedDatetimeLevel: string;
|
|
24
|
+
membersFilterNullMember: string;
|
|
25
|
+
};
|
|
26
|
+
unsupportedDimesionalElement: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
uk: {
|
|
30
|
+
errors: {
|
|
31
|
+
measure: {
|
|
32
|
+
unsupportedType: string;
|
|
33
|
+
dimensionalCalculatedMeasure: {
|
|
34
|
+
noContext: string;
|
|
35
|
+
};
|
|
36
|
+
dimensionalBaseMeasure: {
|
|
37
|
+
noAttributeDimExpression: string;
|
|
38
|
+
noAggAggregation: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
dataModelConfig: {
|
|
42
|
+
noName: string;
|
|
43
|
+
noMetadata: string;
|
|
44
|
+
};
|
|
45
|
+
filter: {
|
|
46
|
+
unsupportedType: string;
|
|
47
|
+
unsupportedDatetimeLevel: string;
|
|
48
|
+
membersFilterNullMember: string;
|
|
49
|
+
};
|
|
50
|
+
unsupportedDimesionalElement: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translation dictionary for Ukrainian language.
|
|
3
|
+
*/
|
|
4
|
+
export const translation = {
|
|
5
|
+
errors: {
|
|
6
|
+
measure: {
|
|
7
|
+
unsupportedType: 'Непідтримуваний тип measure',
|
|
8
|
+
dimensionalCalculatedMeasure: {
|
|
9
|
+
noContext: "DimensionalCalculatedMeasure має мати властивість 'context'",
|
|
10
|
+
},
|
|
11
|
+
dimensionalBaseMeasure: {
|
|
12
|
+
noAttributeDimExpression: "DimensionalBaseMeasure має мати властивість 'attribute'/'dim'/'expression'",
|
|
13
|
+
noAggAggregation: "DimensionalBaseMeasure має мати властивість 'agg' або 'aggregation'",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
dataModelConfig: {
|
|
17
|
+
noName: "'name' має бути вказано в конфігурації для DataModel",
|
|
18
|
+
noMetadata: "'metadata' має бути вказано в конфігурації для DataModel",
|
|
19
|
+
},
|
|
20
|
+
filter: {
|
|
21
|
+
unsupportedType: 'Непідтримуваний тип фільтра: {{filterType}}',
|
|
22
|
+
unsupportedDatetimeLevel: 'Фільтри не підтримують наступні рівні "datetime": Hours, MinutesRoundTo30, MinutesRoundTo15',
|
|
23
|
+
membersFilterNullMember: 'MembersFilter у {{attributeId}} - member не може бути нульовим',
|
|
24
|
+
},
|
|
25
|
+
unsupportedDimesionalElement: 'Непідтримуваний тип елемента',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AbstractTranslatableError } from '@sisense/sdk-common';
|
|
2
|
+
import { PACKAGE_NAMESPACE } from './resources/index.js';
|
|
3
|
+
export declare class TranslatableError extends AbstractTranslatableError<typeof PACKAGE_NAMESPACE> {
|
|
4
|
+
constructor(translationKey: string, interpolationOptions?: Record<string, string>);
|
|
5
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AbstractTranslatableError } from '@sisense/sdk-common';
|
|
2
|
+
import { i18nextInstance } from './initialize-i18n.js';
|
|
3
|
+
import { PACKAGE_NAMESPACE } from './resources/index.js';
|
|
4
|
+
export class TranslatableError extends AbstractTranslatableError {
|
|
5
|
+
constructor(translationKey, interpolationOptions) {
|
|
6
|
+
super(PACKAGE_NAMESPACE, {
|
|
7
|
+
key: translationKey,
|
|
8
|
+
interpolationOptions: interpolationOptions,
|
|
9
|
+
}, i18nextInstance.t);
|
|
10
|
+
}
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sisense/sdk-data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
"author": "Sisense ",
|
|
13
13
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@sisense/sdk-
|
|
15
|
+
"@sisense/sdk-common": "^0.16.0",
|
|
16
|
+
"@sisense/sdk-rest-client": "^0.16.0",
|
|
16
17
|
"guid-typescript": "^1.0.9",
|
|
18
|
+
"lodash": "^4.17.21",
|
|
17
19
|
"numeral": "^2.0.6",
|
|
18
20
|
"object-hash": "^3.0.0"
|
|
19
21
|
},
|
|
@@ -37,6 +39,7 @@
|
|
|
37
39
|
],
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@babel/preset-env": "^7.20.2",
|
|
42
|
+
"@types/lodash": "^4.14.201",
|
|
40
43
|
"@types/numeral": "2.0.2",
|
|
41
44
|
"@types/object-hash": "^3.0.5",
|
|
42
45
|
"eslint": "^8.40.0",
|