@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
package/dist/index.js
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';
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import type { MeasureContext } from './dimensional-model/interfaces.js';
|
|
2
|
+
/**
|
|
3
|
+
* Data cell, which is a storage unit in a {@link Data | user-provided data set}
|
|
4
|
+
* or {@link QueryResultData | query result data set}.
|
|
5
|
+
*/
|
|
6
|
+
export interface Cell {
|
|
7
|
+
/** Cell data value */
|
|
8
|
+
data: any;
|
|
9
|
+
/** Display text */
|
|
10
|
+
text?: string;
|
|
11
|
+
/** Boolean flag whether the data value should be blurred when visualized in a chart */
|
|
12
|
+
blur?: boolean;
|
|
13
|
+
/** Color associated with the data value when visualized in a chart */
|
|
14
|
+
color?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Represents a data-cell in a query result
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export interface DataCell {
|
|
22
|
+
/**
|
|
23
|
+
* Gets the cell's data in its native type {@link (number|string|Date|boolean)}
|
|
24
|
+
*/
|
|
25
|
+
data: any;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the string representation of the cell
|
|
28
|
+
*/
|
|
29
|
+
text: string;
|
|
30
|
+
/**
|
|
31
|
+
* Used to differentiate cell data that is highlighted/blurred by a filter.
|
|
32
|
+
*
|
|
33
|
+
* Means different things depending on if it is specified in the returned dataset.
|
|
34
|
+
*
|
|
35
|
+
* The absence of `selected` across all cells means that all data is highlighted.
|
|
36
|
+
* The presence of `selected` in at least one cell means that some cells are highlighted
|
|
37
|
+
* and some are blurred.
|
|
38
|
+
*/
|
|
39
|
+
selected?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Column (or field) in a data set.
|
|
43
|
+
* When associated with a dimensional model, a column is equivalent to an {@link Attribute}.
|
|
44
|
+
*/
|
|
45
|
+
export interface Column {
|
|
46
|
+
/**
|
|
47
|
+
* Identifier. Required when associated with a model
|
|
48
|
+
*
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
id?: string;
|
|
52
|
+
/** Column name */
|
|
53
|
+
name: string;
|
|
54
|
+
/** Column type */
|
|
55
|
+
type: string;
|
|
56
|
+
/**
|
|
57
|
+
* Column description
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
description?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Aggregate function applied to a {@link Column}.
|
|
65
|
+
* When associated with a dimensional model, a Measure Column is equivalent to a {@link Measure}.
|
|
66
|
+
*/
|
|
67
|
+
export interface MeasureColumn {
|
|
68
|
+
/**
|
|
69
|
+
* Identifier. Required when associated with a model.
|
|
70
|
+
*
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
id?: string;
|
|
74
|
+
/** Column name */
|
|
75
|
+
name: string;
|
|
76
|
+
/**
|
|
77
|
+
* Aggregate function -- for example, `sum`, `count`.
|
|
78
|
+
* If not specified, default value, `sum`, will be used.
|
|
79
|
+
*/
|
|
80
|
+
aggregation?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Optional title for the column after aggregation.
|
|
83
|
+
* If not specified, the column `name` will be used.
|
|
84
|
+
*/
|
|
85
|
+
title?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Aggregate function description
|
|
88
|
+
*
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
description?: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Calculated Aggregate function applied to a {@link Column}(s).
|
|
95
|
+
* When associated with a dimensional model, a Calculated Measure Column is
|
|
96
|
+
* equivalent to a {@link CalculatedMeasure}.
|
|
97
|
+
*/
|
|
98
|
+
export interface CalculatedMeasureColumn {
|
|
99
|
+
/**
|
|
100
|
+
* Identifier. Required when associated with a model.
|
|
101
|
+
*
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
id?: string;
|
|
105
|
+
/** Column name */
|
|
106
|
+
name: string;
|
|
107
|
+
/** Measure type */
|
|
108
|
+
type: string;
|
|
109
|
+
/** Measure context */
|
|
110
|
+
context: MeasureContext;
|
|
111
|
+
/** Expression representing the element in a {@link https://sisense.dev/guides/querying/useJaql/ | JAQL query}. */
|
|
112
|
+
expression: string;
|
|
113
|
+
/**
|
|
114
|
+
* Aggregate function description
|
|
115
|
+
*
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
description?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Optional title for the column after aggregation.
|
|
121
|
+
* If not specified, the column `name` will be used.
|
|
122
|
+
*/
|
|
123
|
+
title?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Data source for queries to run against
|
|
127
|
+
*/
|
|
128
|
+
export declare type DataSource = string;
|
|
129
|
+
/**
|
|
130
|
+
* Data set, which is made up of an array of {@link Column | columns}
|
|
131
|
+
* and a two-dimensional array of data {@link Cell | cells}.
|
|
132
|
+
*
|
|
133
|
+
* This structure can be used for user-provided data in {@link @sisense/sdk-ui!ChartProps | Chart components}.
|
|
134
|
+
*/
|
|
135
|
+
export interface Data {
|
|
136
|
+
/** Array of {@link Column | columns} */
|
|
137
|
+
columns: Column[];
|
|
138
|
+
/** Two-dimensional array of data cells, each of which is either a string, number, or type {@link Cell} */
|
|
139
|
+
rows: (string | number | Cell)[][];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Query result data set, which is made of an array of {@link Column | columns}
|
|
143
|
+
* and a two-dimensional array of data {@link Cell | cells}.
|
|
144
|
+
*/
|
|
145
|
+
export interface QueryResultData {
|
|
146
|
+
/** Array of {@link Column | columns} */
|
|
147
|
+
columns: Column[];
|
|
148
|
+
/** Two-dimensional array of data {@link Cell | cells} */
|
|
149
|
+
rows: Cell[][];
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Runs type guard check for DataSource.
|
|
153
|
+
*
|
|
154
|
+
* @param arg
|
|
155
|
+
* @internal
|
|
156
|
+
*/
|
|
157
|
+
export declare function isDataSource(arg: DataSource | Data): arg is DataSource;
|
|
158
|
+
/**
|
|
159
|
+
* Trend formula options.
|
|
160
|
+
*/
|
|
161
|
+
export declare type TrendFormulaOptions = {
|
|
162
|
+
/**
|
|
163
|
+
* Trend analysis model type to be used for the operation.
|
|
164
|
+
*
|
|
165
|
+
* @defaultValue "linear"
|
|
166
|
+
*/
|
|
167
|
+
modelType?: 'linear' | 'logarithmic' | 'advancedSmoothing' | 'localEstimates';
|
|
168
|
+
/**
|
|
169
|
+
* Boolean flag that enables the function to automatically identify and ignore
|
|
170
|
+
* anomalous values in the series. This can be particularly useful when you want
|
|
171
|
+
* to maintain the integrity of your analysis by avoiding potential outliers.
|
|
172
|
+
*
|
|
173
|
+
* @defaultValue false
|
|
174
|
+
*/
|
|
175
|
+
ignoreAnomalies?: boolean;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Forecast formula options.
|
|
179
|
+
*/
|
|
180
|
+
export declare type ForecastFormulaOptions = {
|
|
181
|
+
/**
|
|
182
|
+
* Number of data points to be predicted.
|
|
183
|
+
* The accepted value range is between 1-1,000
|
|
184
|
+
*
|
|
185
|
+
* @defaultValue 3
|
|
186
|
+
*/
|
|
187
|
+
forecastHorizon: number;
|
|
188
|
+
/**
|
|
189
|
+
* Forecasting model type. The 'auto' option automatically
|
|
190
|
+
* fits the best combination of models.
|
|
191
|
+
*
|
|
192
|
+
* @defaultValue "auto"
|
|
193
|
+
*/
|
|
194
|
+
modelType?: 'auto' | 'autoArima' | 'holtWinters' | 'prophet';
|
|
195
|
+
/**
|
|
196
|
+
* Start date of the time series data that the forecasting model will
|
|
197
|
+
* be trained on. This parameter can be used to discard the beginning of
|
|
198
|
+
* the series. Specify a ISO 8601 date string or Date object.
|
|
199
|
+
*/
|
|
200
|
+
startDate?: string | Date;
|
|
201
|
+
/**
|
|
202
|
+
* End date of the time series data that the forecasting model will be
|
|
203
|
+
* trained on. This parameter can be used to discard the end of the series.
|
|
204
|
+
* Specify a ISO 8601 date string or Date object.
|
|
205
|
+
*/
|
|
206
|
+
endDate?: string | Date;
|
|
207
|
+
/**
|
|
208
|
+
* Confidence interval showing the probabilistic upper and lower limits of the
|
|
209
|
+
* forecasted series according to the uncertainty level. The valid range is (0.8 <= X < 1).
|
|
210
|
+
*
|
|
211
|
+
* @defaultValue 0.8
|
|
212
|
+
*/
|
|
213
|
+
confidenceInterval?: number;
|
|
214
|
+
/**
|
|
215
|
+
* Expected lower limit to improve the forecast accuracy when reaching
|
|
216
|
+
* the limit. Note that values in the confidence interval can exceed
|
|
217
|
+
* this limit.
|
|
218
|
+
*/
|
|
219
|
+
lowerBound?: number;
|
|
220
|
+
/**
|
|
221
|
+
* Expected upper limit to improve the forecast accuracy when reaching
|
|
222
|
+
* the limit. Note that values in the confidence interval can exceed
|
|
223
|
+
* this limit.
|
|
224
|
+
*/
|
|
225
|
+
upperBound?: number;
|
|
226
|
+
/**
|
|
227
|
+
* Boolean flag to round the predicted result to an integer if set to true.
|
|
228
|
+
* Otherwise, the predicted result is left as a float
|
|
229
|
+
*
|
|
230
|
+
* @defaultValue false
|
|
231
|
+
*/
|
|
232
|
+
roundToInt?: boolean;
|
|
233
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sisense/sdk-data",
|
|
3
|
+
"version": "0.11.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./dist/index.js",
|
|
7
|
+
"./dist/dimensional-model/filters/filters": "./dist/dimensional-model/filters/filters.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"author": "Sisense ",
|
|
13
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@sisense/sdk-rest-client": "^0.11.3",
|
|
16
|
+
"guid-typescript": "^1.0.9",
|
|
17
|
+
"numeral": "^2.0.6"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"type-check": "tsc --noEmit",
|
|
21
|
+
"build": "tsc --build tsconfig.build.json",
|
|
22
|
+
"build:prod": "tsc --project tsconfig.prod.json",
|
|
23
|
+
"build.watch": "tsc --build --watch",
|
|
24
|
+
"clean": "rm -rf dist coverage tsconfig.build.tsbuildinfo tsconfig.prod.tsbuildinfo",
|
|
25
|
+
"lint": "eslint . --fix",
|
|
26
|
+
"format": "prettier --write .",
|
|
27
|
+
"format:check": "prettier --check .",
|
|
28
|
+
"vitest": "run -T vitest",
|
|
29
|
+
"test": "run vitest run",
|
|
30
|
+
"test:watch": "run vitest watch",
|
|
31
|
+
"test:coverage": "run vitest run --coverage"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist/**/*",
|
|
35
|
+
"esm/**/*"
|
|
36
|
+
],
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@babel/preset-env": "^7.20.2",
|
|
39
|
+
"@types/numeral": "2.0.2",
|
|
40
|
+
"eslint": "^8.40.0",
|
|
41
|
+
"prettier": "2.8.4",
|
|
42
|
+
"typescript": "4.8.4"
|
|
43
|
+
},
|
|
44
|
+
"volta": {
|
|
45
|
+
"extends": "../../package.json"
|
|
46
|
+
}
|
|
47
|
+
}
|