@sisense/sdk-data 0.15.0 → 1.0.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/analytics/factory.d.ts +47 -0
- package/dist/dimensional-model/analytics/factory.js +140 -0
- package/dist/dimensional-model/data-model.js +5 -4
- package/dist/dimensional-model/factory.js +2 -2
- package/dist/dimensional-model/filters/factory.d.ts +34 -1
- package/dist/dimensional-model/filters/factory.js +56 -0
- package/dist/dimensional-model/filters/filters.d.ts +4 -0
- package/dist/dimensional-model/filters/filters.js +10 -10
- package/dist/dimensional-model/interfaces.d.ts +15 -2
- package/dist/dimensional-model/measures/factory.d.ts +547 -177
- package/dist/dimensional-model/measures/factory.js +550 -189
- package/dist/dimensional-model/measures/measures.js +6 -6
- package/dist/index.d.ts +43 -36
- package/dist/index.js +43 -36
- 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/dist/utils.d.ts +16 -0
- package/dist/utils.js +63 -0
- package/package.json +14 -2
|
@@ -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
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import './translation/initialize-i18n.js';
|
|
1
2
|
/**
|
|
2
3
|
* @packageDocumentation
|
|
3
|
-
* @beta
|
|
4
4
|
*/
|
|
5
5
|
export * from './interfaces.js';
|
|
6
6
|
export * from './dimensional-model/types.js';
|
|
@@ -21,31 +21,32 @@ export * from './dimensional-model/filters/filters.js';
|
|
|
21
21
|
* and {@link @sisense/sdk-ui!ExecuteQueryProps | ExecuteQuery}.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
-
* Example of using
|
|
25
|
-
*
|
|
24
|
+
* Example of using React hook `useExecuteQuery` to query the `Sample ECommerce` data source.
|
|
25
|
+
* Factory function `filterFactory.greaterThan()` is used to create a filter on `Revenue` to get values
|
|
26
26
|
* greater than 1000.
|
|
27
27
|
* ```tsx
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* {
|
|
35
|
-
*
|
|
36
|
-
* if (data) {
|
|
37
|
-
* console.log(data);
|
|
38
|
-
* return <div>{`Total Rows: ${data.rows.length}`}</div>;
|
|
39
|
-
* }
|
|
28
|
+
* const { data, isLoading, isError } = useExecuteQuery({
|
|
29
|
+
* dataSource: DM.DataSource,
|
|
30
|
+
* dimensions: [DM.Commerce.AgeRange],
|
|
31
|
+
* measures: [measureFactory.sum(DM.Commerce.Revenue)],
|
|
32
|
+
* filters: [filterFactory.greaterThan(DM.Commerce.Revenue, 1000)],
|
|
33
|
+
* });
|
|
34
|
+
* if (isLoading) {
|
|
35
|
+
* return <div>Loading...</div>;
|
|
40
36
|
* }
|
|
41
|
-
*
|
|
42
|
-
* </
|
|
37
|
+
* if (isError) {
|
|
38
|
+
* return <div>Error</div>;
|
|
39
|
+
* }
|
|
40
|
+
* if (data) {
|
|
41
|
+
* return <div>{`Total Rows: ${data.rows.length}`}</div>;
|
|
42
|
+
* }
|
|
43
|
+
* return null;
|
|
43
44
|
* ```
|
|
44
45
|
*/
|
|
45
|
-
export * as
|
|
46
|
+
export * as filterFactory from './dimensional-model/filters/factory.js';
|
|
46
47
|
export * from './dimensional-model/measures/measures.js';
|
|
47
48
|
/**
|
|
48
|
-
* Functions to
|
|
49
|
+
* Functions to create measures that aggregate, summarize, and accumulate data,
|
|
49
50
|
* plus show changes in data over time.
|
|
50
51
|
*
|
|
51
52
|
* They are similar to [Formulas](https://docs.sisense.com/main/SisenseLinux/build-formulas.htm) in Sisense.
|
|
@@ -55,25 +56,31 @@ export * from './dimensional-model/measures/measures.js';
|
|
|
55
56
|
* and {@link @sisense/sdk-ui!ExecuteQueryProps | ExecuteQuery}.
|
|
56
57
|
*
|
|
57
58
|
* @example
|
|
58
|
-
* Example of using
|
|
59
|
-
*
|
|
59
|
+
* Example of using React hook useExecuteQuery to query the `Sample ECommerce` data source.
|
|
60
|
+
* Factory function `measureFactory.sum()` is used to create a measure that sums the `Revenue` column.
|
|
60
61
|
* ```tsx
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* {
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* }
|
|
62
|
+
* const { data, isLoading, isError } = useExecuteQuery({
|
|
63
|
+
* dataSource: DM.DataSource,
|
|
64
|
+
* dimensions: [DM.Commerce.AgeRange],
|
|
65
|
+
* measures: [measureFactory.sum(DM.Commerce.Revenue)],
|
|
66
|
+
* filters: [filterFactory.greaterThan(DM.Commerce.Revenue, 1000)],
|
|
67
|
+
* });
|
|
68
|
+
* if (isLoading) {
|
|
69
|
+
* return <div>Loading...</div>;
|
|
70
|
+
* }
|
|
71
|
+
* if (isError) {
|
|
72
|
+
* return <div>Error</div>;
|
|
73
73
|
* }
|
|
74
|
-
*
|
|
75
|
-
* </
|
|
74
|
+
* if (data) {
|
|
75
|
+
* return <div>{`Total Rows: ${data.rows.length}`}</div>;
|
|
76
|
+
* }
|
|
77
|
+
* return null;
|
|
76
78
|
* ```
|
|
77
79
|
*/
|
|
78
|
-
export * as
|
|
80
|
+
export * as measureFactory from './dimensional-model/measures/factory.js';
|
|
79
81
|
export * from './dimensional-model/simple-column-types.js';
|
|
82
|
+
/**
|
|
83
|
+
* Functions to create elements for advanced analytics – for example, attributes and measures for constructing a custom Boxplot chart
|
|
84
|
+
*/
|
|
85
|
+
export * as analyticsFactory from './dimensional-model/analytics/factory.js';
|
|
86
|
+
export * from './utils.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import './translation/initialize-i18n.js';
|
|
1
2
|
/**
|
|
2
3
|
* @packageDocumentation
|
|
3
|
-
* @beta
|
|
4
4
|
*/
|
|
5
5
|
export * from './interfaces.js';
|
|
6
6
|
export * from './dimensional-model/types.js';
|
|
@@ -21,31 +21,32 @@ export * from './dimensional-model/filters/filters.js';
|
|
|
21
21
|
* and {@link @sisense/sdk-ui!ExecuteQueryProps | ExecuteQuery}.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
-
* Example of using
|
|
25
|
-
*
|
|
24
|
+
* Example of using React hook `useExecuteQuery` to query the `Sample ECommerce` data source.
|
|
25
|
+
* Factory function `filterFactory.greaterThan()` is used to create a filter on `Revenue` to get values
|
|
26
26
|
* greater than 1000.
|
|
27
27
|
* ```tsx
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* {
|
|
35
|
-
*
|
|
36
|
-
* if (data) {
|
|
37
|
-
* console.log(data);
|
|
38
|
-
* return <div>{`Total Rows: ${data.rows.length}`}</div>;
|
|
39
|
-
* }
|
|
28
|
+
* const { data, isLoading, isError } = useExecuteQuery({
|
|
29
|
+
* dataSource: DM.DataSource,
|
|
30
|
+
* dimensions: [DM.Commerce.AgeRange],
|
|
31
|
+
* measures: [measureFactory.sum(DM.Commerce.Revenue)],
|
|
32
|
+
* filters: [filterFactory.greaterThan(DM.Commerce.Revenue, 1000)],
|
|
33
|
+
* });
|
|
34
|
+
* if (isLoading) {
|
|
35
|
+
* return <div>Loading...</div>;
|
|
40
36
|
* }
|
|
41
|
-
*
|
|
42
|
-
* </
|
|
37
|
+
* if (isError) {
|
|
38
|
+
* return <div>Error</div>;
|
|
39
|
+
* }
|
|
40
|
+
* if (data) {
|
|
41
|
+
* return <div>{`Total Rows: ${data.rows.length}`}</div>;
|
|
42
|
+
* }
|
|
43
|
+
* return null;
|
|
43
44
|
* ```
|
|
44
45
|
*/
|
|
45
|
-
export * as
|
|
46
|
+
export * as filterFactory from './dimensional-model/filters/factory.js';
|
|
46
47
|
export * from './dimensional-model/measures/measures.js';
|
|
47
48
|
/**
|
|
48
|
-
* Functions to
|
|
49
|
+
* Functions to create measures that aggregate, summarize, and accumulate data,
|
|
49
50
|
* plus show changes in data over time.
|
|
50
51
|
*
|
|
51
52
|
* They are similar to [Formulas](https://docs.sisense.com/main/SisenseLinux/build-formulas.htm) in Sisense.
|
|
@@ -55,25 +56,31 @@ export * from './dimensional-model/measures/measures.js';
|
|
|
55
56
|
* and {@link @sisense/sdk-ui!ExecuteQueryProps | ExecuteQuery}.
|
|
56
57
|
*
|
|
57
58
|
* @example
|
|
58
|
-
* Example of using
|
|
59
|
-
*
|
|
59
|
+
* Example of using React hook useExecuteQuery to query the `Sample ECommerce` data source.
|
|
60
|
+
* Factory function `measureFactory.sum()` is used to create a measure that sums the `Revenue` column.
|
|
60
61
|
* ```tsx
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* {
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* }
|
|
62
|
+
* const { data, isLoading, isError } = useExecuteQuery({
|
|
63
|
+
* dataSource: DM.DataSource,
|
|
64
|
+
* dimensions: [DM.Commerce.AgeRange],
|
|
65
|
+
* measures: [measureFactory.sum(DM.Commerce.Revenue)],
|
|
66
|
+
* filters: [filterFactory.greaterThan(DM.Commerce.Revenue, 1000)],
|
|
67
|
+
* });
|
|
68
|
+
* if (isLoading) {
|
|
69
|
+
* return <div>Loading...</div>;
|
|
70
|
+
* }
|
|
71
|
+
* if (isError) {
|
|
72
|
+
* return <div>Error</div>;
|
|
73
73
|
* }
|
|
74
|
-
*
|
|
75
|
-
* </
|
|
74
|
+
* if (data) {
|
|
75
|
+
* return <div>{`Total Rows: ${data.rows.length}`}</div>;
|
|
76
|
+
* }
|
|
77
|
+
* return null;
|
|
76
78
|
* ```
|
|
77
79
|
*/
|
|
78
|
-
export * as
|
|
80
|
+
export * as measureFactory from './dimensional-model/measures/factory.js';
|
|
79
81
|
export * from './dimensional-model/simple-column-types.js';
|
|
82
|
+
/**
|
|
83
|
+
* Functions to create elements for advanced analytics – for example, attributes and measures for constructing a custom Boxplot chart
|
|
84
|
+
*/
|
|
85
|
+
export * as analyticsFactory from './dimensional-model/analytics/factory.js';
|
|
86
|
+
export * from './utils.js';
|
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
|
+
unsupportedDimensionalElement: 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
|
+
unsupportedDimensionalElement: '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
|
+
unsupportedDimensionalElement: 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
|
+
unsupportedDimensionalElement: 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
|
+
unsupportedDimensionalElement: 'Непідтримуваний тип елемента',
|
|
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/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Filter, FilterRelation } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* A more performant, but slightly bulkier, RFC4122v4 implementation. Performance is improved by minimizing calls to random()
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare const guidFast: (len?: number) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Function to separate list of filters from the provided relation and get logical relations for jaql
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const getFilterListAndRelations: (filterRelations: FilterRelation | Filter[] | undefined) => {
|
|
14
|
+
filters: Filter[] | undefined;
|
|
15
|
+
relations: FilterRelation | undefined;
|
|
16
|
+
};
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import cloneDeep from 'lodash/cloneDeep.js';
|
|
2
|
+
/**
|
|
3
|
+
* A more performant, but slightly bulkier, RFC4122v4 implementation. Performance is improved by minimizing calls to random()
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export const guidFast = function (len) {
|
|
8
|
+
if (!len) {
|
|
9
|
+
len = 20;
|
|
10
|
+
}
|
|
11
|
+
const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
|
12
|
+
const uuid = new Array(len);
|
|
13
|
+
let rnd = 0;
|
|
14
|
+
let r;
|
|
15
|
+
for (let i = 0; i < len; i += 1) {
|
|
16
|
+
if (i > 0 && i % 5 == 0) {
|
|
17
|
+
uuid[i] = '-';
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (rnd <= 0x02) {
|
|
21
|
+
rnd = (0x2000000 + Math.random() * 0x1000000) | 0;
|
|
22
|
+
}
|
|
23
|
+
r = rnd & 0xf;
|
|
24
|
+
rnd = rnd >> 4;
|
|
25
|
+
uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r];
|
|
26
|
+
}
|
|
27
|
+
return uuid.join('');
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Function to separate list of filters from the provided relation and get logical relations for jaql
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export const getFilterListAndRelations = (filterRelations) => {
|
|
35
|
+
if (!filterRelations) {
|
|
36
|
+
return { filters: undefined, relations: undefined };
|
|
37
|
+
}
|
|
38
|
+
if (Array.isArray(filterRelations)) {
|
|
39
|
+
return { filters: filterRelations, relations: undefined };
|
|
40
|
+
}
|
|
41
|
+
const filters = new Set();
|
|
42
|
+
function traverse(node) {
|
|
43
|
+
if (!node)
|
|
44
|
+
return node;
|
|
45
|
+
if ('guid' in node) {
|
|
46
|
+
filters.add(node);
|
|
47
|
+
return { instanceid: node.guid };
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
if ('left' in node) {
|
|
51
|
+
node.left = traverse(node.left);
|
|
52
|
+
}
|
|
53
|
+
if ('right' in node) {
|
|
54
|
+
node.right = traverse(node.right);
|
|
55
|
+
}
|
|
56
|
+
return node;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Create a deep copy of filterRelations to avoid mutation
|
|
60
|
+
const copiedFilterRelations = cloneDeep(filterRelations);
|
|
61
|
+
const relations = traverse(copiedFilterRelations);
|
|
62
|
+
return { filters: Array.from(filters), relations };
|
|
63
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sisense/sdk-data",
|
|
3
|
-
"
|
|
3
|
+
"homepage": "https://sisense.dev/guides/sdk/",
|
|
4
|
+
"description": "Compose SDK package for implementing the elements of dimensional modeling",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/sisense/compose-sdk-monorepo",
|
|
8
|
+
"directory": "packages/sdk-data"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"Sisense",
|
|
12
|
+
"Compose SDK"
|
|
13
|
+
],
|
|
14
|
+
"version": "1.0.0",
|
|
4
15
|
"type": "module",
|
|
5
16
|
"exports": {
|
|
6
17
|
".": "./dist/index.js",
|
|
@@ -12,7 +23,8 @@
|
|
|
12
23
|
"author": "Sisense ",
|
|
13
24
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
14
25
|
"dependencies": {
|
|
15
|
-
"@sisense/sdk-
|
|
26
|
+
"@sisense/sdk-common": "^1.0.0",
|
|
27
|
+
"@sisense/sdk-rest-client": "^1.0.0",
|
|
16
28
|
"guid-typescript": "^1.0.9",
|
|
17
29
|
"lodash": "^4.17.21",
|
|
18
30
|
"numeral": "^2.0.6",
|