@sisense/sdk-data 0.11.3
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/LICENSE.md +35 -0
- package/README.md +3 -0
- package/dist/dimensional-model/attributes.d.ts +124 -0
- package/dist/dimensional-model/attributes.js +280 -0
- package/dist/dimensional-model/base.d.ts +38 -0
- package/dist/dimensional-model/base.js +37 -0
- package/dist/dimensional-model/data-model.d.ts +13 -0
- package/dist/dimensional-model/data-model.js +32 -0
- package/dist/dimensional-model/dimensions.d.ts +165 -0
- package/dist/dimensional-model/dimensions.js +297 -0
- package/dist/dimensional-model/factory.d.ts +17 -0
- package/dist/dimensional-model/factory.js +50 -0
- package/dist/dimensional-model/filters/factory.d.ts +315 -0
- package/dist/dimensional-model/filters/factory.js +404 -0
- package/dist/dimensional-model/filters/filters.d.ts +288 -0
- package/dist/dimensional-model/filters/filters.js +534 -0
- package/dist/dimensional-model/interfaces.d.ts +341 -0
- package/dist/dimensional-model/interfaces.js +1 -0
- package/dist/dimensional-model/measures/factory.d.ts +437 -0
- package/dist/dimensional-model/measures/factory.js +632 -0
- package/dist/dimensional-model/measures/measures.d.ts +217 -0
- package/dist/dimensional-model/measures/measures.js +388 -0
- package/dist/dimensional-model/simple-column-types.d.ts +39 -0
- package/dist/dimensional-model/simple-column-types.js +124 -0
- package/dist/dimensional-model/types.d.ts +152 -0
- package/dist/dimensional-model/types.js +284 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +79 -0
- package/dist/interfaces.d.ts +233 -0
- package/dist/interfaces.js +9 -0
- package/package.json +47 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param type
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export const isInteger = (type) => {
|
|
6
|
+
return [
|
|
7
|
+
'__int4',
|
|
8
|
+
'__int8',
|
|
9
|
+
'int',
|
|
10
|
+
'tinyint',
|
|
11
|
+
'bigint',
|
|
12
|
+
'int2',
|
|
13
|
+
'int4',
|
|
14
|
+
'int8',
|
|
15
|
+
'smallint',
|
|
16
|
+
'mediumint',
|
|
17
|
+
'serial',
|
|
18
|
+
'integer',
|
|
19
|
+
'byteint',
|
|
20
|
+
'int64',
|
|
21
|
+
].includes(type.toLowerCase());
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* @param type
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export const isDecimal = (type) => {
|
|
28
|
+
return [
|
|
29
|
+
'basemeasure',
|
|
30
|
+
'calculatedmeasure',
|
|
31
|
+
'float',
|
|
32
|
+
'float4',
|
|
33
|
+
'float8',
|
|
34
|
+
'double precision',
|
|
35
|
+
'double',
|
|
36
|
+
'numeric',
|
|
37
|
+
'decimal',
|
|
38
|
+
'real',
|
|
39
|
+
'number',
|
|
40
|
+
'float64',
|
|
41
|
+
].includes(type.toLowerCase());
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* @param type
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
export const isNumber = (type) => {
|
|
48
|
+
return isInteger(type) || isDecimal(type) || type === 'numeric-attribute';
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @param type
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export const isText = (type) => {
|
|
55
|
+
return [
|
|
56
|
+
'textdimension',
|
|
57
|
+
'string',
|
|
58
|
+
'varchar',
|
|
59
|
+
'text',
|
|
60
|
+
'ntext',
|
|
61
|
+
'char',
|
|
62
|
+
'character',
|
|
63
|
+
'character varying',
|
|
64
|
+
'smalltext',
|
|
65
|
+
'nchar',
|
|
66
|
+
'nvarchar',
|
|
67
|
+
'json',
|
|
68
|
+
'jsonb',
|
|
69
|
+
'object',
|
|
70
|
+
'text-attribute',
|
|
71
|
+
].includes(type.toLowerCase());
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* @param type
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
export const isDatetime = (type) => {
|
|
78
|
+
return [
|
|
79
|
+
'datelevel',
|
|
80
|
+
'date',
|
|
81
|
+
'time',
|
|
82
|
+
'datetime',
|
|
83
|
+
'timestamp without time zone',
|
|
84
|
+
'timestamp',
|
|
85
|
+
'timestamp with time zone',
|
|
86
|
+
'timestamp(6)',
|
|
87
|
+
'timestamp_tz',
|
|
88
|
+
'timestamp_ntz',
|
|
89
|
+
'timestamp_ltz',
|
|
90
|
+
'timestampltz',
|
|
91
|
+
'timestampntz',
|
|
92
|
+
'timestamptz',
|
|
93
|
+
'datetime64[ns]',
|
|
94
|
+
'timewithtimezone',
|
|
95
|
+
'timestampwithtimezone',
|
|
96
|
+
'timestamp_with_timezone',
|
|
97
|
+
].includes(type.toLowerCase());
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* @param type
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
export const isBoolean = (type) => {
|
|
104
|
+
return ['bool', 'boolean', 'bit', 'logical'].includes(type.toLowerCase());
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* @param type
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
110
|
+
export const simpleColumnType = (type) => {
|
|
111
|
+
if (isNumber(type)) {
|
|
112
|
+
return 'number';
|
|
113
|
+
}
|
|
114
|
+
if (isDatetime(type)) {
|
|
115
|
+
return 'datetime';
|
|
116
|
+
}
|
|
117
|
+
if (isText(type)) {
|
|
118
|
+
return 'text';
|
|
119
|
+
}
|
|
120
|
+
if (isBoolean(type)) {
|
|
121
|
+
return 'boolean';
|
|
122
|
+
}
|
|
123
|
+
return 'text';
|
|
124
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Different aggregation types
|
|
3
|
+
*/
|
|
4
|
+
export declare const AggregationTypes: {
|
|
5
|
+
/** Sum aggregation type */
|
|
6
|
+
Sum: string;
|
|
7
|
+
/** Average aggregation type */
|
|
8
|
+
Average: string;
|
|
9
|
+
/** Min aggregation type */
|
|
10
|
+
Min: string;
|
|
11
|
+
/** Max aggregation type */
|
|
12
|
+
Max: string;
|
|
13
|
+
/** Count aggregation type */
|
|
14
|
+
Count: string;
|
|
15
|
+
/** Count distinct aggregation type */
|
|
16
|
+
CountDistinct: string;
|
|
17
|
+
/** Median aggregation type */
|
|
18
|
+
Median: string;
|
|
19
|
+
/** Variance aggregation type */
|
|
20
|
+
Variance: string;
|
|
21
|
+
/** Standard deviation aggregation type */
|
|
22
|
+
StandardDeviation: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Different sort types.
|
|
26
|
+
*/
|
|
27
|
+
export declare enum Sort {
|
|
28
|
+
/** No sort definition */
|
|
29
|
+
None = 0,
|
|
30
|
+
/** Sort Ascending */
|
|
31
|
+
Ascending = 1,
|
|
32
|
+
/** Sort Descending */
|
|
33
|
+
Descending = 2
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Different metadata types
|
|
37
|
+
*
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export declare const MetadataTypes: {
|
|
41
|
+
Measure: string;
|
|
42
|
+
MeasureTemplate: string;
|
|
43
|
+
BaseMeasure: string;
|
|
44
|
+
CalculatedMeasure: string;
|
|
45
|
+
Dimension: string;
|
|
46
|
+
DateDimension: string;
|
|
47
|
+
TextDimension: string;
|
|
48
|
+
NumericDimension: string;
|
|
49
|
+
DateLevel: string;
|
|
50
|
+
Attribute: string;
|
|
51
|
+
TextAttribute: string;
|
|
52
|
+
NumericAttribute: string;
|
|
53
|
+
Filter: string;
|
|
54
|
+
DimensionFilter: string;
|
|
55
|
+
MeasureFilter: string;
|
|
56
|
+
/**
|
|
57
|
+
* Checks whether the given object or type is a metadata element
|
|
58
|
+
*
|
|
59
|
+
* @param o - object to check
|
|
60
|
+
* @returns true if the object or type is a metadata element
|
|
61
|
+
*/
|
|
62
|
+
isMetadata(o: any): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Checks whether the given object or type is a measure template
|
|
65
|
+
*
|
|
66
|
+
* @param o - object to check
|
|
67
|
+
* @returns true if the object or type is a measure template
|
|
68
|
+
*/
|
|
69
|
+
isMeasureTemplate(o: any): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Checks whether the given object or type is a base measure
|
|
72
|
+
*
|
|
73
|
+
* @param o - object to check
|
|
74
|
+
* @returns true if the object or type is a base measure
|
|
75
|
+
*/
|
|
76
|
+
isBaseMeasure(o: any): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Checks whether the given object or type is a measure - of any type
|
|
79
|
+
*
|
|
80
|
+
* @param o - object to check
|
|
81
|
+
* @returns true if the object or type is a measure - of any type
|
|
82
|
+
*/
|
|
83
|
+
isMeasure(o: any): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Checks whether the given object or type is a calculated measure
|
|
86
|
+
*
|
|
87
|
+
* @param o - object to check
|
|
88
|
+
* @returns true if the object or type is a calculated measure
|
|
89
|
+
*/
|
|
90
|
+
isCalculatedMeasure(o: any): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Checks whether the given object or type is a date dimension
|
|
93
|
+
*
|
|
94
|
+
* @param o - object to check
|
|
95
|
+
* @returns true if the object or type is a date dimension
|
|
96
|
+
*/
|
|
97
|
+
isDateDimension(o: any): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Checks whether the given object or type is a text dimension
|
|
100
|
+
*
|
|
101
|
+
* @param o - object to check
|
|
102
|
+
* @returns true if the object or type is a text dimension
|
|
103
|
+
*/
|
|
104
|
+
isTextDimension(o: any): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Checks whether the given object or type is a numeric dimension
|
|
107
|
+
*
|
|
108
|
+
* @param o - object to check
|
|
109
|
+
* @returns true if the object or type is a numeric dimension
|
|
110
|
+
*/
|
|
111
|
+
isNumericDimension(o: any): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Checks whether the given object or type is a dimension - of any type
|
|
114
|
+
*
|
|
115
|
+
* @param o - object to check
|
|
116
|
+
* @returns true if the object or type is a dimension - of any type
|
|
117
|
+
*/
|
|
118
|
+
isDimension(o: any): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Checks whether the given object or type is an attribute - of any type
|
|
121
|
+
*
|
|
122
|
+
* @param o - object to check
|
|
123
|
+
* @returns true if the object or type is an attribute - of any type
|
|
124
|
+
*/
|
|
125
|
+
isAttribute(o: any): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Checks whether the given object or type is a filter
|
|
128
|
+
*
|
|
129
|
+
* @param o - object to check
|
|
130
|
+
* @returns true if the object or type is a filter
|
|
131
|
+
*/
|
|
132
|
+
isFilter(o: any): boolean;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Levels for {@link DateDimension}
|
|
136
|
+
*/
|
|
137
|
+
export declare const DateLevels: {
|
|
138
|
+
Years: string;
|
|
139
|
+
Quarters: string;
|
|
140
|
+
Months: string;
|
|
141
|
+
Weeks: string;
|
|
142
|
+
Days: string;
|
|
143
|
+
Hours: string;
|
|
144
|
+
MinutesRoundTo30: string;
|
|
145
|
+
MinutesRoundTo15: string;
|
|
146
|
+
AggHours: string;
|
|
147
|
+
AggMinutesRoundTo30: string;
|
|
148
|
+
AggMinutesRoundTo15: string;
|
|
149
|
+
AggMinutesRoundTo1: string;
|
|
150
|
+
/** @internal */
|
|
151
|
+
readonly all: string[];
|
|
152
|
+
};
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
|
+
/* eslint-disable complexity */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
5
|
+
/* eslint-disable max-lines */
|
|
6
|
+
/*
|
|
7
|
+
* Types
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Different aggregation types
|
|
11
|
+
*/
|
|
12
|
+
export const AggregationTypes = {
|
|
13
|
+
/** Sum aggregation type */
|
|
14
|
+
Sum: 'sum',
|
|
15
|
+
/** Average aggregation type */
|
|
16
|
+
Average: 'avg',
|
|
17
|
+
/** Min aggregation type */
|
|
18
|
+
Min: 'min',
|
|
19
|
+
/** Max aggregation type */
|
|
20
|
+
Max: 'max',
|
|
21
|
+
/** Count aggregation type */
|
|
22
|
+
Count: 'count',
|
|
23
|
+
/** Count distinct aggregation type */
|
|
24
|
+
CountDistinct: 'countdistinct',
|
|
25
|
+
/** Median aggregation type */
|
|
26
|
+
Median: 'median',
|
|
27
|
+
/** Variance aggregation type */
|
|
28
|
+
Variance: 'var',
|
|
29
|
+
/** Standard deviation aggregation type */
|
|
30
|
+
StandardDeviation: 'stdev',
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Different sort types.
|
|
34
|
+
*/
|
|
35
|
+
export var Sort;
|
|
36
|
+
(function (Sort) {
|
|
37
|
+
/** No sort definition */
|
|
38
|
+
Sort[Sort["None"] = 0] = "None";
|
|
39
|
+
/** Sort Ascending */
|
|
40
|
+
Sort[Sort["Ascending"] = 1] = "Ascending";
|
|
41
|
+
/** Sort Descending */
|
|
42
|
+
Sort[Sort["Descending"] = 2] = "Descending";
|
|
43
|
+
})(Sort = Sort || (Sort = {}));
|
|
44
|
+
/**
|
|
45
|
+
* Different metadata types
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export const MetadataTypes = {
|
|
50
|
+
Measure: 'measure',
|
|
51
|
+
MeasureTemplate: 'measuretemplate',
|
|
52
|
+
BaseMeasure: 'basemeasure',
|
|
53
|
+
CalculatedMeasure: 'calculatedmeasure',
|
|
54
|
+
Dimension: 'dimension',
|
|
55
|
+
DateDimension: 'datedimension',
|
|
56
|
+
TextDimension: 'textdimension',
|
|
57
|
+
NumericDimension: 'numericdimension',
|
|
58
|
+
DateLevel: 'datelevel',
|
|
59
|
+
Attribute: 'attribute',
|
|
60
|
+
TextAttribute: 'text-attribute',
|
|
61
|
+
NumericAttribute: 'numeric-attribute',
|
|
62
|
+
Filter: 'filter',
|
|
63
|
+
DimensionFilter: 'dimensionfilter',
|
|
64
|
+
MeasureFilter: 'measurefilter',
|
|
65
|
+
/**
|
|
66
|
+
* Checks whether the given object or type is a metadata element
|
|
67
|
+
*
|
|
68
|
+
* @param o - object to check
|
|
69
|
+
* @returns true if the object or type is a metadata element
|
|
70
|
+
*/
|
|
71
|
+
isMetadata(o) {
|
|
72
|
+
return (MetadataTypes.isMeasure(o) ||
|
|
73
|
+
MetadataTypes.isDimension(o) ||
|
|
74
|
+
MetadataTypes.isAttribute(o) ||
|
|
75
|
+
MetadataTypes.isFilter(o));
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Checks whether the given object or type is a measure template
|
|
79
|
+
*
|
|
80
|
+
* @param o - object to check
|
|
81
|
+
* @returns true if the object or type is a measure template
|
|
82
|
+
*/
|
|
83
|
+
isMeasureTemplate(o) {
|
|
84
|
+
if (!o) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (typeof o === 'string') {
|
|
88
|
+
const type = o;
|
|
89
|
+
return type.toLowerCase() === MetadataTypes.MeasureTemplate;
|
|
90
|
+
}
|
|
91
|
+
return (o.agg === '*' ||
|
|
92
|
+
o.aggregation === '*' ||
|
|
93
|
+
(o.type && o.type.toLowerCase() === MetadataTypes.MeasureTemplate));
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* Checks whether the given object or type is a base measure
|
|
97
|
+
*
|
|
98
|
+
* @param o - object to check
|
|
99
|
+
* @returns true if the object or type is a base measure
|
|
100
|
+
*/
|
|
101
|
+
isBaseMeasure(o) {
|
|
102
|
+
if (!o) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (typeof o === 'string') {
|
|
106
|
+
const type = o;
|
|
107
|
+
return type.toLowerCase() === MetadataTypes.BaseMeasure;
|
|
108
|
+
}
|
|
109
|
+
return (o.agg || o.aggregation) && o.attribute && !this.isMeasureTemplate(o);
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* Checks whether the given object or type is a measure - of any type
|
|
113
|
+
*
|
|
114
|
+
* @param o - object to check
|
|
115
|
+
* @returns true if the object or type is a measure - of any type
|
|
116
|
+
*/
|
|
117
|
+
isMeasure(o) {
|
|
118
|
+
if (!o) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if (typeof o === 'string') {
|
|
122
|
+
const type = o;
|
|
123
|
+
return (type.toLowerCase() === MetadataTypes.Measure ||
|
|
124
|
+
type.toLowerCase() === MetadataTypes.BaseMeasure ||
|
|
125
|
+
type.toLowerCase() === MetadataTypes.MeasureTemplate ||
|
|
126
|
+
type.toLowerCase() === MetadataTypes.CalculatedMeasure);
|
|
127
|
+
}
|
|
128
|
+
return this.isBaseMeasure(o) || this.isCalculatedMeasure(o) || this.isMeasureTemplate(o);
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* Checks whether the given object or type is a calculated measure
|
|
132
|
+
*
|
|
133
|
+
* @param o - object to check
|
|
134
|
+
* @returns true if the object or type is a calculated measure
|
|
135
|
+
*/
|
|
136
|
+
isCalculatedMeasure(o) {
|
|
137
|
+
if (!o) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
if (typeof o === 'string') {
|
|
141
|
+
const type = o;
|
|
142
|
+
return type.toLowerCase() === MetadataTypes.CalculatedMeasure;
|
|
143
|
+
}
|
|
144
|
+
return (o.expression || o.formula) && o.context;
|
|
145
|
+
},
|
|
146
|
+
/**
|
|
147
|
+
* Checks whether the given object or type is a date dimension
|
|
148
|
+
*
|
|
149
|
+
* @param o - object to check
|
|
150
|
+
* @returns true if the object or type is a date dimension
|
|
151
|
+
*/
|
|
152
|
+
isDateDimension(o) {
|
|
153
|
+
if (!o) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
if (typeof o === 'string') {
|
|
157
|
+
const type = o;
|
|
158
|
+
return type.toLowerCase() === MetadataTypes.DateDimension;
|
|
159
|
+
}
|
|
160
|
+
return (o.dim || o.expression) && o.level;
|
|
161
|
+
},
|
|
162
|
+
/**
|
|
163
|
+
* Checks whether the given object or type is a text dimension
|
|
164
|
+
*
|
|
165
|
+
* @param o - object to check
|
|
166
|
+
* @returns true if the object or type is a text dimension
|
|
167
|
+
*/
|
|
168
|
+
isTextDimension(o) {
|
|
169
|
+
if (!o) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
if (typeof o === 'string') {
|
|
173
|
+
const type = o;
|
|
174
|
+
return type.toLowerCase() === MetadataTypes.TextDimension;
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
},
|
|
178
|
+
/**
|
|
179
|
+
* Checks whether the given object or type is a numeric dimension
|
|
180
|
+
*
|
|
181
|
+
* @param o - object to check
|
|
182
|
+
* @returns true if the object or type is a numeric dimension
|
|
183
|
+
*/
|
|
184
|
+
isNumericDimension(o) {
|
|
185
|
+
if (!o) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
if (typeof o === 'string') {
|
|
189
|
+
const type = o;
|
|
190
|
+
return type.toLowerCase() === MetadataTypes.NumericDimension;
|
|
191
|
+
}
|
|
192
|
+
return false;
|
|
193
|
+
},
|
|
194
|
+
/**
|
|
195
|
+
* Checks whether the given object or type is a dimension - of any type
|
|
196
|
+
*
|
|
197
|
+
* @param o - object to check
|
|
198
|
+
* @returns true if the object or type is a dimension - of any type
|
|
199
|
+
*/
|
|
200
|
+
isDimension(o) {
|
|
201
|
+
if (typeof o === 'object') {
|
|
202
|
+
o = o.type;
|
|
203
|
+
}
|
|
204
|
+
if (typeof o === 'string') {
|
|
205
|
+
const type = o;
|
|
206
|
+
return (type.toLowerCase() === MetadataTypes.DateDimension ||
|
|
207
|
+
type.toLowerCase() === MetadataTypes.Dimension ||
|
|
208
|
+
type.toLowerCase() === MetadataTypes.TextDimension ||
|
|
209
|
+
type.toLowerCase() === MetadataTypes.NumericDimension);
|
|
210
|
+
}
|
|
211
|
+
return false;
|
|
212
|
+
},
|
|
213
|
+
/**
|
|
214
|
+
* Checks whether the given object or type is an attribute - of any type
|
|
215
|
+
*
|
|
216
|
+
* @param o - object to check
|
|
217
|
+
* @returns true if the object or type is an attribute - of any type
|
|
218
|
+
*/
|
|
219
|
+
isAttribute(o) {
|
|
220
|
+
if (typeof o === 'string') {
|
|
221
|
+
const type = o;
|
|
222
|
+
return (type.toLowerCase() === MetadataTypes.Attribute ||
|
|
223
|
+
type.toLowerCase() === MetadataTypes.TextAttribute ||
|
|
224
|
+
type.toLowerCase() === MetadataTypes.NumericAttribute ||
|
|
225
|
+
type.toLowerCase() === MetadataTypes.DateLevel);
|
|
226
|
+
}
|
|
227
|
+
if (o && o.type) {
|
|
228
|
+
return this.isAttribute(o.type);
|
|
229
|
+
}
|
|
230
|
+
return false;
|
|
231
|
+
},
|
|
232
|
+
/**
|
|
233
|
+
* Checks whether the given object or type is a filter
|
|
234
|
+
*
|
|
235
|
+
* @param o - object to check
|
|
236
|
+
* @returns true if the object or type is a filter
|
|
237
|
+
*/
|
|
238
|
+
isFilter(o) {
|
|
239
|
+
if (typeof o === 'object') {
|
|
240
|
+
o = o.type;
|
|
241
|
+
}
|
|
242
|
+
if (typeof o === 'string') {
|
|
243
|
+
const type = o;
|
|
244
|
+
return (type.toLowerCase() === MetadataTypes.Filter ||
|
|
245
|
+
type.toLowerCase() === MetadataTypes.DimensionFilter ||
|
|
246
|
+
type.toLowerCase() === MetadataTypes.MeasureFilter);
|
|
247
|
+
}
|
|
248
|
+
return false;
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* Levels for {@link DateDimension}
|
|
253
|
+
*/
|
|
254
|
+
export const DateLevels = {
|
|
255
|
+
Years: 'Years',
|
|
256
|
+
Quarters: 'Quarters',
|
|
257
|
+
Months: 'Months',
|
|
258
|
+
Weeks: 'Weeks',
|
|
259
|
+
Days: 'Days',
|
|
260
|
+
Hours: 'Hours',
|
|
261
|
+
MinutesRoundTo30: 'MinutesRoundTo30',
|
|
262
|
+
MinutesRoundTo15: 'MinutesRoundTo15',
|
|
263
|
+
AggHours: 'AggHours',
|
|
264
|
+
AggMinutesRoundTo30: 'AggMinutesRoundTo30',
|
|
265
|
+
AggMinutesRoundTo15: 'AggMinutesRoundTo15',
|
|
266
|
+
AggMinutesRoundTo1: 'AggMinutesRoundTo1',
|
|
267
|
+
/** @internal */
|
|
268
|
+
get all() {
|
|
269
|
+
return [
|
|
270
|
+
DateLevels.Years,
|
|
271
|
+
DateLevels.Quarters,
|
|
272
|
+
DateLevels.Months,
|
|
273
|
+
DateLevels.Weeks,
|
|
274
|
+
DateLevels.Days,
|
|
275
|
+
DateLevels.Hours,
|
|
276
|
+
DateLevels.MinutesRoundTo30,
|
|
277
|
+
DateLevels.MinutesRoundTo15,
|
|
278
|
+
DateLevels.AggHours,
|
|
279
|
+
DateLevels.AggMinutesRoundTo30,
|
|
280
|
+
DateLevels.AggMinutesRoundTo15,
|
|
281
|
+
DateLevels.AggMinutesRoundTo1,
|
|
282
|
+
];
|
|
283
|
+
},
|
|
284
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @beta
|
|
4
|
+
*/
|
|
5
|
+
export * from './interfaces.js';
|
|
6
|
+
export * from './dimensional-model/types.js';
|
|
7
|
+
export * from './dimensional-model/interfaces.js';
|
|
8
|
+
export * from './dimensional-model/base.js';
|
|
9
|
+
export * from './dimensional-model/data-model.js';
|
|
10
|
+
export * from './dimensional-model/attributes.js';
|
|
11
|
+
export * from './dimensional-model/dimensions.js';
|
|
12
|
+
export * from './dimensional-model/factory.js';
|
|
13
|
+
export * from './dimensional-model/filters/filters.js';
|
|
14
|
+
/**
|
|
15
|
+
* Functions to create date, text, or numeric filters on certain data columns
|
|
16
|
+
*
|
|
17
|
+
* They are similar to [Dashboard and Widget Filters](https://docs.sisense.com/main/SisenseLinux/build-formulas.htm) in Sisense.
|
|
18
|
+
*
|
|
19
|
+
* Filters created with these functions can be used in the data options of UI components such as
|
|
20
|
+
* {@link @sisense/sdk-ui!ChartProps | Chart}, {@link @sisense/sdk-ui!ChartWidgetProps | ChartWidget},
|
|
21
|
+
* and {@link @sisense/sdk-ui!ExecuteQueryProps | ExecuteQuery}.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* Example of using the component to query the `Sample ECommerce` data source.
|
|
25
|
+
* Function `filters.greaterThan` is used to create a filter on `Revenue` to get values
|
|
26
|
+
* greater than 1000.
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <ExecuteQuery
|
|
29
|
+
* dataSource={DM.DataSource}
|
|
30
|
+
* dimensions={[DM.Commerce.AgeRange]}
|
|
31
|
+
* measures={[measures.sum(DM.Commerce.Revenue)]}
|
|
32
|
+
* filters={[filters.greaterThan(DM.Commerce.Revenue, 1000)]}
|
|
33
|
+
* >
|
|
34
|
+
* {
|
|
35
|
+
* (data) => {
|
|
36
|
+
* if (data) {
|
|
37
|
+
* console.log(data);
|
|
38
|
+
* return <div>{`Total Rows: ${data.rows.length}`}</div>;
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* </ExecuteQuery>
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export * as filters from './dimensional-model/filters/factory.js';
|
|
46
|
+
export * from './dimensional-model/measures/measures.js';
|
|
47
|
+
/**
|
|
48
|
+
* Functions to build formulas that aggregate, summarize, and accumulate data,
|
|
49
|
+
* plus show changes in data over time.
|
|
50
|
+
*
|
|
51
|
+
* They are similar to [Formulas](https://docs.sisense.com/main/SisenseLinux/build-formulas.htm) in Sisense.
|
|
52
|
+
*
|
|
53
|
+
* Measures created with these functions can be used in the data options of UI components such as
|
|
54
|
+
* {@link @sisense/sdk-ui!ChartProps | Chart}, {@link @sisense/sdk-ui!ChartWidgetProps | ChartWidget},
|
|
55
|
+
* and {@link @sisense/sdk-ui!ExecuteQueryProps | ExecuteQuery}.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* Example of using the component to query the `Sample ECommerce` data source.
|
|
59
|
+
* Function `measures.sum` is used to create a measure that sums the `Revenue` column.
|
|
60
|
+
* ```tsx
|
|
61
|
+
* <ExecuteQuery
|
|
62
|
+
* dataSource={DM.DataSource}
|
|
63
|
+
* dimensions={[DM.Commerce.AgeRange]}
|
|
64
|
+
* measures={[measures.sum(DM.Commerce.Revenue)]}
|
|
65
|
+
* filters={[filters.greaterThan(DM.Commerce.Revenue, 1000)]}
|
|
66
|
+
* >
|
|
67
|
+
* {
|
|
68
|
+
* (data) => {
|
|
69
|
+
* if (data) {
|
|
70
|
+
* console.log(data);
|
|
71
|
+
* return <div>{`Total Rows: ${data.rows.length}`}</div>;
|
|
72
|
+
* }
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
* </ExecuteQuery>
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export * as measures from './dimensional-model/measures/factory.js';
|
|
79
|
+
export * from './dimensional-model/simple-column-types.js';
|