@sisense/sdk-data 1.18.1 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dimensional-model/attributes.d.ts +3 -3
- package/dist/cjs/dimensional-model/attributes.js +4 -4
- package/dist/cjs/dimensional-model/base.d.ts +10 -1
- package/dist/cjs/dimensional-model/base.js +11 -1
- package/dist/cjs/dimensional-model/dimensions.js +9 -8
- package/dist/cjs/dimensional-model/filters/factory.d.ts +9 -9
- package/dist/cjs/dimensional-model/filters/factory.js +9 -9
- package/dist/cjs/dimensional-model/filters/filters.d.ts +79 -1
- package/dist/cjs/dimensional-model/filters/filters.js +119 -4
- package/dist/cjs/dimensional-model/filters/utils/attribute-measure-util.d.ts +16 -5
- package/dist/cjs/dimensional-model/filters/utils/attribute-measure-util.js +31 -9
- package/dist/cjs/dimensional-model/filters/utils/condition-filter-util.js +3 -1
- package/dist/cjs/dimensional-model/filters/utils/filter-from-jaql-util.js +1 -1
- package/dist/cjs/dimensional-model/filters/utils/types.d.ts +15 -6
- package/dist/cjs/dimensional-model/interfaces.d.ts +11 -1
- package/dist/cjs/dimensional-model/measures/factory.d.ts +12 -2
- package/dist/cjs/dimensional-model/measures/factory.js +4 -3
- package/dist/cjs/dimensional-model/types.d.ts +13 -3
- package/dist/cjs/utils.d.ts +27 -2
- package/dist/cjs/utils.js +61 -2
- package/dist/dimensional-model/attributes.d.ts +3 -3
- package/dist/dimensional-model/attributes.js +4 -4
- package/dist/dimensional-model/base.d.ts +10 -1
- package/dist/dimensional-model/base.js +11 -1
- package/dist/dimensional-model/dimensions.js +9 -8
- package/dist/dimensional-model/filters/factory.d.ts +9 -9
- package/dist/dimensional-model/filters/factory.js +9 -9
- package/dist/dimensional-model/filters/filters.d.ts +79 -1
- package/dist/dimensional-model/filters/filters.js +107 -3
- package/dist/dimensional-model/filters/utils/attribute-measure-util.d.ts +16 -5
- package/dist/dimensional-model/filters/utils/attribute-measure-util.js +29 -8
- package/dist/dimensional-model/filters/utils/condition-filter-util.js +3 -1
- package/dist/dimensional-model/filters/utils/filter-from-jaql-util.js +1 -1
- package/dist/dimensional-model/filters/utils/types.d.ts +15 -6
- package/dist/dimensional-model/interfaces.d.ts +11 -1
- package/dist/dimensional-model/measures/factory.d.ts +12 -2
- package/dist/dimensional-model/measures/factory.js +3 -3
- package/dist/dimensional-model/types.d.ts +13 -3
- package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -1
- package/dist/utils.d.ts +27 -2
- package/dist/utils.js +56 -1
- package/package.json +3 -3
|
@@ -562,7 +562,7 @@ export declare function measureBase(attribute: Attribute, measure: Measure, oper
|
|
|
562
562
|
* Filter for categories that have an average revenue equal 50 in the Sample ECommerce data model.
|
|
563
563
|
* ```ts
|
|
564
564
|
* filterFactory.measureEquals(
|
|
565
|
-
*
|
|
565
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
566
566
|
* 50
|
|
567
567
|
* )
|
|
568
568
|
* ```
|
|
@@ -580,7 +580,7 @@ export declare function measureEquals(measure: BaseMeasure, value: number, guid?
|
|
|
580
580
|
* to 50 in the Sample ECommerce data model.
|
|
581
581
|
* ```ts
|
|
582
582
|
* filterFactory.measureGreaterThan(
|
|
583
|
-
*
|
|
583
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
584
584
|
* 50
|
|
585
585
|
* )
|
|
586
586
|
* ```
|
|
@@ -598,7 +598,7 @@ export declare function measureGreaterThan(measure: BaseMeasure, value: number,
|
|
|
598
598
|
* or equal to 50 in the Sample ECommerce data model.
|
|
599
599
|
* ```ts
|
|
600
600
|
* filterFactory.measureGreaterThanOrEqual(
|
|
601
|
-
*
|
|
601
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
602
602
|
* 50
|
|
603
603
|
* )
|
|
604
604
|
* ```
|
|
@@ -616,7 +616,7 @@ export declare function measureGreaterThanOrEqual(measure: BaseMeasure, value: n
|
|
|
616
616
|
* or equal to 100 in the Sample ECommerce data model.
|
|
617
617
|
* ```ts
|
|
618
618
|
* filterFactory.measureLessThanOrEqual(
|
|
619
|
-
*
|
|
619
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
620
620
|
* 100
|
|
621
621
|
* )
|
|
622
622
|
* ```
|
|
@@ -633,7 +633,7 @@ export declare function measureLessThanOrEqual(measure: BaseMeasure, value: numb
|
|
|
633
633
|
* Filter for categories that have an average revenue less than 100 in the Sample ECommerce data model.
|
|
634
634
|
* ```ts
|
|
635
635
|
* filterFactory.measureLessThan(
|
|
636
|
-
*
|
|
636
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
637
637
|
* 100
|
|
638
638
|
* )
|
|
639
639
|
* ```
|
|
@@ -651,7 +651,7 @@ export declare function measureLessThan(measure: BaseMeasure, value: number, gui
|
|
|
651
651
|
* or equal to 100 in the Sample ECommerce data model.
|
|
652
652
|
* ```ts
|
|
653
653
|
* filterFactory.measureBetween(
|
|
654
|
-
*
|
|
654
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
655
655
|
* 50,
|
|
656
656
|
* 100
|
|
657
657
|
* )
|
|
@@ -671,7 +671,7 @@ export declare function measureBetween(measure: BaseMeasure, valueA: number, val
|
|
|
671
671
|
* 100 in the Sample ECommerce data model.
|
|
672
672
|
* ```ts
|
|
673
673
|
* filterFactory.measureBetweenNotEqual(
|
|
674
|
-
*
|
|
674
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
675
675
|
* 50,
|
|
676
676
|
* 100
|
|
677
677
|
* )
|
|
@@ -691,7 +691,7 @@ export declare function measureBetweenNotEqual(measure: BaseMeasure, valueA: num
|
|
|
691
691
|
* ```ts
|
|
692
692
|
* filterFactory.topRanking(
|
|
693
693
|
* DM.Commerce.AgeRange,
|
|
694
|
-
*
|
|
694
|
+
* measureFactory.sum(DM.Commerce.Revenue),
|
|
695
695
|
* 3
|
|
696
696
|
* )
|
|
697
697
|
* ```
|
|
@@ -710,7 +710,7 @@ export declare function topRanking(attribute: Attribute, measure: Measure, count
|
|
|
710
710
|
* ```ts
|
|
711
711
|
* filterFactory.bottomRanking(
|
|
712
712
|
* DM.Commerce.AgeRange,
|
|
713
|
-
*
|
|
713
|
+
* measureFactory.sum(DM.Commerce.Revenue),
|
|
714
714
|
* 3
|
|
715
715
|
* )
|
|
716
716
|
* ```
|
|
@@ -638,7 +638,7 @@ export function measureBase(attribute, measure, operatorA, valueA, operatorB, va
|
|
|
638
638
|
* Filter for categories that have an average revenue equal 50 in the Sample ECommerce data model.
|
|
639
639
|
* ```ts
|
|
640
640
|
* filterFactory.measureEquals(
|
|
641
|
-
*
|
|
641
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
642
642
|
* 50
|
|
643
643
|
* )
|
|
644
644
|
* ```
|
|
@@ -658,7 +658,7 @@ export function measureEquals(measure, value, guid) {
|
|
|
658
658
|
* to 50 in the Sample ECommerce data model.
|
|
659
659
|
* ```ts
|
|
660
660
|
* filterFactory.measureGreaterThan(
|
|
661
|
-
*
|
|
661
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
662
662
|
* 50
|
|
663
663
|
* )
|
|
664
664
|
* ```
|
|
@@ -678,7 +678,7 @@ export function measureGreaterThan(measure, value, guid) {
|
|
|
678
678
|
* or equal to 50 in the Sample ECommerce data model.
|
|
679
679
|
* ```ts
|
|
680
680
|
* filterFactory.measureGreaterThanOrEqual(
|
|
681
|
-
*
|
|
681
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
682
682
|
* 50
|
|
683
683
|
* )
|
|
684
684
|
* ```
|
|
@@ -698,7 +698,7 @@ export function measureGreaterThanOrEqual(measure, value, guid) {
|
|
|
698
698
|
* or equal to 100 in the Sample ECommerce data model.
|
|
699
699
|
* ```ts
|
|
700
700
|
* filterFactory.measureLessThanOrEqual(
|
|
701
|
-
*
|
|
701
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
702
702
|
* 100
|
|
703
703
|
* )
|
|
704
704
|
* ```
|
|
@@ -717,7 +717,7 @@ export function measureLessThanOrEqual(measure, value, guid) {
|
|
|
717
717
|
* Filter for categories that have an average revenue less than 100 in the Sample ECommerce data model.
|
|
718
718
|
* ```ts
|
|
719
719
|
* filterFactory.measureLessThan(
|
|
720
|
-
*
|
|
720
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
721
721
|
* 100
|
|
722
722
|
* )
|
|
723
723
|
* ```
|
|
@@ -737,7 +737,7 @@ export function measureLessThan(measure, value, guid) {
|
|
|
737
737
|
* or equal to 100 in the Sample ECommerce data model.
|
|
738
738
|
* ```ts
|
|
739
739
|
* filterFactory.measureBetween(
|
|
740
|
-
*
|
|
740
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
741
741
|
* 50,
|
|
742
742
|
* 100
|
|
743
743
|
* )
|
|
@@ -759,7 +759,7 @@ export function measureBetween(measure, valueA, valueB, guid) {
|
|
|
759
759
|
* 100 in the Sample ECommerce data model.
|
|
760
760
|
* ```ts
|
|
761
761
|
* filterFactory.measureBetweenNotEqual(
|
|
762
|
-
*
|
|
762
|
+
* measureFactory.average(DM.Commerce.Revenue),
|
|
763
763
|
* 50,
|
|
764
764
|
* 100
|
|
765
765
|
* )
|
|
@@ -782,7 +782,7 @@ export function measureBetweenNotEqual(measure, valueA, valueB, guid) {
|
|
|
782
782
|
* ```ts
|
|
783
783
|
* filterFactory.topRanking(
|
|
784
784
|
* DM.Commerce.AgeRange,
|
|
785
|
-
*
|
|
785
|
+
* measureFactory.sum(DM.Commerce.Revenue),
|
|
786
786
|
* 3
|
|
787
787
|
* )
|
|
788
788
|
* ```
|
|
@@ -803,7 +803,7 @@ export function topRanking(attribute, measure, count, guid) {
|
|
|
803
803
|
* ```ts
|
|
804
804
|
* filterFactory.bottomRanking(
|
|
805
805
|
* DM.Commerce.AgeRange,
|
|
806
|
-
*
|
|
806
|
+
* measureFactory.sum(DM.Commerce.Revenue),
|
|
807
807
|
* 3
|
|
808
808
|
* )
|
|
809
809
|
* ```
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LevelAttribute, Attribute, Measure, Filter } from '../interfaces.js';
|
|
2
2
|
import { DimensionalElement } from '../base.js';
|
|
3
|
+
import { AnyObject } from '../types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Different text operators that can be used with text filters
|
|
5
6
|
*
|
|
@@ -71,7 +72,7 @@ export declare const FilterTypes: {
|
|
|
71
72
|
ranking: string;
|
|
72
73
|
text: string;
|
|
73
74
|
numeric: string;
|
|
74
|
-
|
|
75
|
+
dateRange: string;
|
|
75
76
|
relativeDate: string;
|
|
76
77
|
cascading: string;
|
|
77
78
|
advanced: string;
|
|
@@ -350,6 +351,83 @@ export declare class CustomFilter extends AbstractFilter {
|
|
|
350
351
|
*/
|
|
351
352
|
filterJaql(): any;
|
|
352
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Checks if a filter is a CustomFilter.
|
|
356
|
+
*
|
|
357
|
+
* @param filter - The filter to check.
|
|
358
|
+
* @internal
|
|
359
|
+
*/
|
|
360
|
+
export declare function isCustomFilter(filter: Filter & AnyObject): filter is CustomFilter;
|
|
361
|
+
/**
|
|
362
|
+
* Checks if a filter is a MembersFilter.
|
|
363
|
+
*
|
|
364
|
+
* @param filter - The filter to check.
|
|
365
|
+
* @internal
|
|
366
|
+
*/
|
|
367
|
+
export declare function isMembersFilter(filter: Filter & AnyObject): filter is MembersFilter;
|
|
368
|
+
/**
|
|
369
|
+
* Checks if a filter is a NumericFilter.
|
|
370
|
+
*
|
|
371
|
+
* @param filter - The filter to check.
|
|
372
|
+
* @internal
|
|
373
|
+
*/
|
|
374
|
+
export declare function isNumericFilter(filter: Filter & AnyObject): filter is NumericFilter;
|
|
375
|
+
/**
|
|
376
|
+
* Checks if a filter is a TextFilter.
|
|
377
|
+
*
|
|
378
|
+
* @param filter - The filter to check.
|
|
379
|
+
* @internal
|
|
380
|
+
*/
|
|
381
|
+
export declare function isRankingFilter(filter: Filter & AnyObject): filter is RankingFilter;
|
|
382
|
+
/**
|
|
383
|
+
* Checks if a filter is a MeasureFilter.
|
|
384
|
+
*
|
|
385
|
+
* @param filter - The filter to check.
|
|
386
|
+
* @internal
|
|
387
|
+
*/
|
|
388
|
+
export declare function isMeasureFilter(filter: Filter & AnyObject): filter is MeasureFilter;
|
|
389
|
+
/**
|
|
390
|
+
* Checks if a filter is a ExcludeFilter.
|
|
391
|
+
*
|
|
392
|
+
* @param filter - The filter to check.
|
|
393
|
+
* @internal
|
|
394
|
+
*/
|
|
395
|
+
export declare function isExcludeFilter(filter: Filter & AnyObject): filter is ExcludeFilter;
|
|
396
|
+
/**
|
|
397
|
+
* Checks if a filter is a LogicalAttributeFilter.
|
|
398
|
+
*
|
|
399
|
+
* @param filter - The filter to check.
|
|
400
|
+
* @internal
|
|
401
|
+
*/
|
|
402
|
+
export declare function isLogicalAttributeFilter(filter: Filter & AnyObject): filter is LogicalAttributeFilter;
|
|
403
|
+
/**
|
|
404
|
+
* Checks if a filter is a CascadingFilter.
|
|
405
|
+
*
|
|
406
|
+
* @param filter - The filter to check.
|
|
407
|
+
* @internal
|
|
408
|
+
*/
|
|
409
|
+
export declare function isCascadingFilter(filter: Filter & AnyObject): filter is CascadingFilter;
|
|
410
|
+
/**
|
|
411
|
+
* Checks if a filter is a RelativeDateFilter.
|
|
412
|
+
*
|
|
413
|
+
* @param filter - The filter to check.
|
|
414
|
+
* @internal
|
|
415
|
+
*/
|
|
416
|
+
export declare function isRelativeDateFilter(filter: Filter & AnyObject): filter is RelativeDateFilter;
|
|
417
|
+
/**
|
|
418
|
+
* Checks if a filter is a TextFilter.
|
|
419
|
+
*
|
|
420
|
+
* @param filter - The filter to check.
|
|
421
|
+
* @internal
|
|
422
|
+
*/
|
|
423
|
+
export declare function isTextFilter(filter: Filter & AnyObject): filter is TextFilter;
|
|
424
|
+
/**
|
|
425
|
+
* Checks if a filter is a DateRangeFilter.
|
|
426
|
+
*
|
|
427
|
+
* @param filter - The filter to check.
|
|
428
|
+
* @internal
|
|
429
|
+
*/
|
|
430
|
+
export declare function isDateRangeFilter(filter: Filter & AnyObject): filter is DateRangeFilter;
|
|
353
431
|
/**
|
|
354
432
|
* @param json - Filter JSON representation
|
|
355
433
|
* @internal
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
1
2
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
3
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
4
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
@@ -83,7 +84,7 @@ export const FilterTypes = {
|
|
|
83
84
|
ranking: 'ranking',
|
|
84
85
|
text: 'text',
|
|
85
86
|
numeric: 'numeric',
|
|
86
|
-
|
|
87
|
+
dateRange: 'dateRange',
|
|
87
88
|
relativeDate: 'relativeDate',
|
|
88
89
|
cascading: 'cascading',
|
|
89
90
|
advanced: 'advanced',
|
|
@@ -159,6 +160,10 @@ class AbstractFilter extends DimensionalElement {
|
|
|
159
160
|
};
|
|
160
161
|
}
|
|
161
162
|
result.jaql.filter = this.filterJaql();
|
|
163
|
+
// prioritize attribute dataSource for the use case of multi-source dashboard
|
|
164
|
+
if (this.attribute.dataSource) {
|
|
165
|
+
result.jaql.datasource = this.attribute.dataSource;
|
|
166
|
+
}
|
|
162
167
|
if (this.isScope) {
|
|
163
168
|
result.panel = 'scope';
|
|
164
169
|
}
|
|
@@ -531,7 +536,7 @@ export class TextFilter extends DoubleOperatorFilter {
|
|
|
531
536
|
*/
|
|
532
537
|
export class DateRangeFilter extends DoubleOperatorFilter {
|
|
533
538
|
constructor(l, valueFrom, valueTo, guid) {
|
|
534
|
-
super(l, FilterTypes.
|
|
539
|
+
super(l, FilterTypes.dateRange, DateOperators.From, valueFrom, DateOperators.To, valueTo, guid);
|
|
535
540
|
if (typeof valueFrom === 'object') {
|
|
536
541
|
this.valueA = valueFrom.toISOString();
|
|
537
542
|
}
|
|
@@ -645,6 +650,105 @@ export class CustomFilter extends AbstractFilter {
|
|
|
645
650
|
return this.jaqlExpression;
|
|
646
651
|
}
|
|
647
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* Checks if a filter is a CustomFilter.
|
|
655
|
+
*
|
|
656
|
+
* @param filter - The filter to check.
|
|
657
|
+
* @internal
|
|
658
|
+
*/
|
|
659
|
+
export function isCustomFilter(filter) {
|
|
660
|
+
return 'filterType' in filter && filter.filterType === FilterTypes.advanced;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Checks if a filter is a MembersFilter.
|
|
664
|
+
*
|
|
665
|
+
* @param filter - The filter to check.
|
|
666
|
+
* @internal
|
|
667
|
+
*/
|
|
668
|
+
export function isMembersFilter(filter) {
|
|
669
|
+
return 'filterType' in filter && filter.filterType === FilterTypes.members;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Checks if a filter is a NumericFilter.
|
|
673
|
+
*
|
|
674
|
+
* @param filter - The filter to check.
|
|
675
|
+
* @internal
|
|
676
|
+
*/
|
|
677
|
+
export function isNumericFilter(filter) {
|
|
678
|
+
return 'filterType' in filter && filter.filterType === FilterTypes.numeric;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Checks if a filter is a TextFilter.
|
|
682
|
+
*
|
|
683
|
+
* @param filter - The filter to check.
|
|
684
|
+
* @internal
|
|
685
|
+
*/
|
|
686
|
+
export function isRankingFilter(filter) {
|
|
687
|
+
return 'filterType' in filter && filter.filterType === FilterTypes.ranking;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Checks if a filter is a MeasureFilter.
|
|
691
|
+
*
|
|
692
|
+
* @param filter - The filter to check.
|
|
693
|
+
* @internal
|
|
694
|
+
*/
|
|
695
|
+
export function isMeasureFilter(filter) {
|
|
696
|
+
return 'filterType' in filter && filter.filterType === FilterTypes.measure;
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Checks if a filter is a ExcludeFilter.
|
|
700
|
+
*
|
|
701
|
+
* @param filter - The filter to check.
|
|
702
|
+
* @internal
|
|
703
|
+
*/
|
|
704
|
+
export function isExcludeFilter(filter) {
|
|
705
|
+
return 'filterType' in filter && filter.filterType === FilterTypes.exclude;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Checks if a filter is a LogicalAttributeFilter.
|
|
709
|
+
*
|
|
710
|
+
* @param filter - The filter to check.
|
|
711
|
+
* @internal
|
|
712
|
+
*/
|
|
713
|
+
export function isLogicalAttributeFilter(filter) {
|
|
714
|
+
return 'filterType' in filter && filter.filterType === FilterTypes.logicalAttribute;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Checks if a filter is a CascadingFilter.
|
|
718
|
+
*
|
|
719
|
+
* @param filter - The filter to check.
|
|
720
|
+
* @internal
|
|
721
|
+
*/
|
|
722
|
+
export function isCascadingFilter(filter) {
|
|
723
|
+
return 'filterType' in filter && filter.filterType === FilterTypes.cascading;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Checks if a filter is a RelativeDateFilter.
|
|
727
|
+
*
|
|
728
|
+
* @param filter - The filter to check.
|
|
729
|
+
* @internal
|
|
730
|
+
*/
|
|
731
|
+
export function isRelativeDateFilter(filter) {
|
|
732
|
+
return 'filterType' in filter && filter.filterType === FilterTypes.relativeDate;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Checks if a filter is a TextFilter.
|
|
736
|
+
*
|
|
737
|
+
* @param filter - The filter to check.
|
|
738
|
+
* @internal
|
|
739
|
+
*/
|
|
740
|
+
export function isTextFilter(filter) {
|
|
741
|
+
return 'filterType' in filter && filter.filterType === FilterTypes.text;
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Checks if a filter is a DateRangeFilter.
|
|
745
|
+
*
|
|
746
|
+
* @param filter - The filter to check.
|
|
747
|
+
* @internal
|
|
748
|
+
*/
|
|
749
|
+
export function isDateRangeFilter(filter) {
|
|
750
|
+
return 'filterType' in filter && filter.filterType === FilterTypes.dateRange;
|
|
751
|
+
}
|
|
648
752
|
/**
|
|
649
753
|
* @param json - Filter JSON representation
|
|
650
754
|
* @internal
|
|
@@ -675,7 +779,7 @@ export function createFilter(json) {
|
|
|
675
779
|
case FilterTypes.relativeDate:
|
|
676
780
|
return new RelativeDateFilter(create(json.attribute), json.offset, json.count, json.operator, json.anchor);
|
|
677
781
|
break;
|
|
678
|
-
case FilterTypes.
|
|
782
|
+
case FilterTypes.dateRange:
|
|
679
783
|
return new DateRangeFilter(create(json.attribute), json.valueA, json.valueB);
|
|
680
784
|
break;
|
|
681
785
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Attribute, BaseMeasure, LevelAttribute } from '../../interfaces.js';
|
|
1
|
+
import { Attribute, BaseMeasure, CalculatedMeasure, LevelAttribute } from '../../interfaces.js';
|
|
2
2
|
import { FilterJaql } from '../../types.js';
|
|
3
|
-
import { FilterJaqlInternal, RankingFilterJaql } from './types.js';
|
|
3
|
+
import { CustomFormulaJaql, FilterJaqlInternal, JaqlDataSource, RankingFilterJaql } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Creates an attribute or level attribute from the provided parameters
|
|
6
6
|
*
|
|
@@ -9,9 +9,11 @@ import { FilterJaqlInternal, RankingFilterJaql } from './types.js';
|
|
|
9
9
|
* @param column - Column name
|
|
10
10
|
* @param level - Date level
|
|
11
11
|
* @param dataType - Data type
|
|
12
|
+
* @param title - Attribute title
|
|
13
|
+
* @param dataSource - Jaql data source
|
|
12
14
|
* @returns attribute or level attribute
|
|
13
15
|
*/
|
|
14
|
-
export declare const createAttributeHelper: (dim: string, table: string | undefined, column: string, level: string | undefined, dataType: string) => Attribute | LevelAttribute;
|
|
16
|
+
export declare const createAttributeHelper: (dim: string, table: string | undefined, column: string, level: string | undefined, dataType: string, title?: string, dataSource?: JaqlDataSource) => Attribute | LevelAttribute;
|
|
15
17
|
/**
|
|
16
18
|
* Creates an attribute or level attribute from the provided filter JAQL object
|
|
17
19
|
*
|
|
@@ -28,9 +30,18 @@ export declare const createAttributeFromFilterJaql: (jaql: FilterJaql | FilterJa
|
|
|
28
30
|
* @param level - Date level
|
|
29
31
|
* @param dataType - Data type
|
|
30
32
|
* @param agg - Aggregation function
|
|
33
|
+
* @param title - Measure title
|
|
34
|
+
* @param dataSource - data source provided in JAQL
|
|
31
35
|
* @returns measure
|
|
32
36
|
*/
|
|
33
|
-
export declare const createMeasureHelper: (dim: string, table: string | undefined, column: string, level: string | undefined, dataType: string, agg: string) => BaseMeasure;
|
|
37
|
+
export declare const createMeasureHelper: (dim: string, table: string | undefined, column: string, level: string | undefined, dataType: string, agg: string, title?: string, dataSource?: JaqlDataSource) => BaseMeasure;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a calculated measure from the provided filter JAQL object
|
|
40
|
+
*
|
|
41
|
+
* @param jaql - custom formula jaql
|
|
42
|
+
* @returns calculated measure
|
|
43
|
+
*/
|
|
44
|
+
export declare const createCalculatedMeasureFromJaql: (jaql: CustomFormulaJaql) => CalculatedMeasure;
|
|
34
45
|
/**
|
|
35
46
|
* Creates a measure from the provided filter JAQL object
|
|
36
47
|
*
|
|
@@ -44,4 +55,4 @@ export declare const createMeasureFromFilterJaql: (jaql: FilterJaqlInternal) =>
|
|
|
44
55
|
* @param jaql - Ranking filter Jaql object
|
|
45
56
|
* @returns Measure
|
|
46
57
|
*/
|
|
47
|
-
export declare const createMeasureFromRankingFilterJaql: (jaql: RankingFilterJaql) => BaseMeasure;
|
|
58
|
+
export declare const createMeasureFromRankingFilterJaql: (jaql: RankingFilterJaql | CustomFormulaJaql) => BaseMeasure | CalculatedMeasure;
|
|
@@ -2,6 +2,7 @@ import { DimensionalAttribute, DimensionalLevelAttribute, normalizeAttributeName
|
|
|
2
2
|
import { isNumber } from '../../simple-column-types.js';
|
|
3
3
|
import { MetadataTypes } from '../../types.js';
|
|
4
4
|
import * as measureFactory from '../../measures/factory.js';
|
|
5
|
+
import { transformCustomFormulaJaql } from '../../measures/factory.js';
|
|
5
6
|
const DATA_MODEL_MODULE_NAME = 'DM';
|
|
6
7
|
/**
|
|
7
8
|
* Creates an attribute or level attribute from the provided parameters
|
|
@@ -11,22 +12,24 @@ const DATA_MODEL_MODULE_NAME = 'DM';
|
|
|
11
12
|
* @param column - Column name
|
|
12
13
|
* @param level - Date level
|
|
13
14
|
* @param dataType - Data type
|
|
15
|
+
* @param title - Attribute title
|
|
16
|
+
* @param dataSource - Jaql data source
|
|
14
17
|
* @returns attribute or level attribute
|
|
15
18
|
*/
|
|
16
|
-
export const createAttributeHelper = (dim, table, column, level, dataType) => {
|
|
19
|
+
export const createAttributeHelper = (dim, table, column, level, dataType, title, dataSource) => {
|
|
17
20
|
// if table is undefined, extract it from dim
|
|
18
21
|
const dimTable = table !== null && table !== void 0 ? table : dim.slice(1, -1).split('.')[0];
|
|
19
22
|
if (level) {
|
|
20
23
|
const dateLevel = DimensionalLevelAttribute.translateJaqlToGranularity({ level });
|
|
21
24
|
const format = DimensionalLevelAttribute.getDefaultFormatForGranularity(dateLevel);
|
|
22
|
-
const levelAttribute = new DimensionalLevelAttribute(column, dim, dateLevel, format);
|
|
25
|
+
const levelAttribute = new DimensionalLevelAttribute(title !== null && title !== void 0 ? title : column, dim, dateLevel, format, undefined, undefined, dataSource);
|
|
23
26
|
levelAttribute.composeCode = normalizeAttributeName(dimTable, column, level, DATA_MODEL_MODULE_NAME);
|
|
24
27
|
return levelAttribute;
|
|
25
28
|
}
|
|
26
29
|
const attributeType = isNumber(dataType)
|
|
27
30
|
? MetadataTypes.NumericAttribute
|
|
28
31
|
: MetadataTypes.TextAttribute;
|
|
29
|
-
const attribute = new DimensionalAttribute(column, dim, attributeType);
|
|
32
|
+
const attribute = new DimensionalAttribute(title !== null && title !== void 0 ? title : column, dim, attributeType, undefined, undefined, dataSource);
|
|
30
33
|
attribute.composeCode = normalizeAttributeName(dimTable, column, undefined, DATA_MODEL_MODULE_NAME);
|
|
31
34
|
return attribute;
|
|
32
35
|
};
|
|
@@ -37,7 +40,8 @@ export const createAttributeHelper = (dim, table, column, level, dataType) => {
|
|
|
37
40
|
* @returns attribute or level attribute
|
|
38
41
|
*/
|
|
39
42
|
export const createAttributeFromFilterJaql = (jaql) => {
|
|
40
|
-
|
|
43
|
+
const { dim, table, column, level, datatype, title, datasource: dataSource } = jaql;
|
|
44
|
+
return createAttributeHelper(dim, table, column, level, datatype, title, dataSource);
|
|
41
45
|
};
|
|
42
46
|
/**
|
|
43
47
|
* Creates a measure from the provided parameters
|
|
@@ -48,14 +52,29 @@ export const createAttributeFromFilterJaql = (jaql) => {
|
|
|
48
52
|
* @param level - Date level
|
|
49
53
|
* @param dataType - Data type
|
|
50
54
|
* @param agg - Aggregation function
|
|
55
|
+
* @param title - Measure title
|
|
56
|
+
* @param dataSource - data source provided in JAQL
|
|
51
57
|
* @returns measure
|
|
52
58
|
*/
|
|
53
|
-
export const createMeasureHelper = (dim, table, column, level, dataType, agg) => {
|
|
54
|
-
const attribute = createAttributeHelper(dim, table, column, level, dataType);
|
|
59
|
+
export const createMeasureHelper = (dim, table, column, level, dataType, agg, title, dataSource) => {
|
|
60
|
+
const attribute = createAttributeHelper(dim, table, column, level, dataType, title, dataSource);
|
|
55
61
|
const measure = measureFactory.aggregate(attribute, agg);
|
|
56
62
|
measure.composeCode = `measureFactory.${agg}(${attribute.composeCode})`;
|
|
57
63
|
return measure;
|
|
58
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Creates a calculated measure from the provided filter JAQL object
|
|
67
|
+
*
|
|
68
|
+
* @param jaql - custom formula jaql
|
|
69
|
+
* @returns calculated measure
|
|
70
|
+
*/
|
|
71
|
+
export const createCalculatedMeasureFromJaql = (jaql) => {
|
|
72
|
+
const measure = transformCustomFormulaJaql(jaql);
|
|
73
|
+
// TBD (SNS-108945)
|
|
74
|
+
// Handle preparation of 'composeCode' for formula
|
|
75
|
+
measure.composeCode = `'Formula code to be implemented'`;
|
|
76
|
+
return measure;
|
|
77
|
+
};
|
|
59
78
|
/**
|
|
60
79
|
* Creates a measure from the provided filter JAQL object
|
|
61
80
|
*
|
|
@@ -63,10 +82,10 @@ export const createMeasureHelper = (dim, table, column, level, dataType, agg) =>
|
|
|
63
82
|
* @returns Measure
|
|
64
83
|
*/
|
|
65
84
|
export const createMeasureFromFilterJaql = (jaql) => {
|
|
66
|
-
const { dim, table, column, level, datatype: dataType, agg } = jaql;
|
|
85
|
+
const { dim, table, column, title, level, datatype: dataType, agg, datasource: dataSource, } = jaql;
|
|
67
86
|
if (!agg)
|
|
68
87
|
return undefined;
|
|
69
|
-
return createMeasureHelper(dim, table, column, level, dataType, agg);
|
|
88
|
+
return createMeasureHelper(dim, table, column, level, dataType, agg, title, dataSource);
|
|
70
89
|
};
|
|
71
90
|
/**
|
|
72
91
|
* Creates a measure from the provided ranking filter JAQL object
|
|
@@ -75,6 +94,8 @@ export const createMeasureFromFilterJaql = (jaql) => {
|
|
|
75
94
|
* @returns Measure
|
|
76
95
|
*/
|
|
77
96
|
export const createMeasureFromRankingFilterJaql = (jaql) => {
|
|
97
|
+
if ('formula' in jaql)
|
|
98
|
+
return createCalculatedMeasureFromJaql(jaql);
|
|
78
99
|
const { dim, table, column, level, datatype: dataType, agg } = jaql;
|
|
79
100
|
return createMeasureHelper(dim, table, column, level, dataType, agg);
|
|
80
101
|
};
|
|
@@ -85,12 +85,14 @@ export const createAttributeFilterFromConditionFilterJaql = (attribute, conditio
|
|
|
85
85
|
const conditionType = getSelectedConditionOption(conditionFilterJaql);
|
|
86
86
|
switch (conditionType) {
|
|
87
87
|
case ConditionFilterType.BOTTOM:
|
|
88
|
-
if (conditionFilterJaql.by
|
|
88
|
+
if (conditionFilterJaql.by) {
|
|
89
89
|
return withComposeCode(filterFactory.bottomRanking)(attribute, createMeasureFromRankingFilterJaql(conditionFilterJaql.by), conditionFilterJaql[ConditionFilterType.BOTTOM], guid);
|
|
90
90
|
}
|
|
91
91
|
break;
|
|
92
92
|
case ConditionFilterType.EQUALS:
|
|
93
93
|
return withComposeCode(filterFactory.equals)(attribute, conditionFilterJaql[ConditionFilterType.EQUALS], guid);
|
|
94
|
+
case ConditionFilterType.DOESNT_EQUAL:
|
|
95
|
+
return withComposeCode(filterFactory.doesntEqual)(attribute, conditionFilterJaql[ConditionFilterType.DOESNT_EQUAL], guid);
|
|
94
96
|
case ConditionFilterType.GREATER_THAN:
|
|
95
97
|
return withComposeCode(filterFactory.greaterThan)(attribute, conditionFilterJaql[ConditionFilterType.GREATER_THAN], guid);
|
|
96
98
|
case ConditionFilterType.GREATER_THAN_OR_EQUAL:
|
|
@@ -177,7 +177,7 @@ export const createFilterFromJaqlInternal = (jaql, guid) => {
|
|
|
177
177
|
}
|
|
178
178
|
catch (e) {
|
|
179
179
|
// if a filter type is untranslatable, fall back to the generic pass-through JAQL filter
|
|
180
|
-
|
|
180
|
+
console.debug('Fall back to generic pass-through JAQL filter due to filter translation error:', e);
|
|
181
181
|
}
|
|
182
182
|
return createGenericFilter(jaql, guid);
|
|
183
183
|
};
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
import { FormulaContext, FormulaJaql } from '../../types.js';
|
|
1
2
|
declare type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
|
2
3
|
[K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
|
|
3
4
|
}[Keys];
|
|
4
5
|
export declare type JaqlContext = Record<string, Partial<FilterJaqlInternal>>;
|
|
5
6
|
export declare type Id = string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Data source as specified in the jaql
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare type JaqlDataSource = {
|
|
13
|
+
address?: Id;
|
|
14
|
+
database?: string;
|
|
15
|
+
id?: string;
|
|
10
16
|
title: string;
|
|
11
17
|
live?: boolean;
|
|
12
|
-
fullname
|
|
18
|
+
fullname?: string;
|
|
13
19
|
lastBuildTime?: string;
|
|
14
20
|
revisionId?: string;
|
|
15
21
|
};
|
|
@@ -56,6 +62,9 @@ export interface RangeFilterJaql extends BaseFilterJaql {
|
|
|
56
62
|
to?: string | number;
|
|
57
63
|
multiSelection?: boolean;
|
|
58
64
|
}
|
|
65
|
+
export declare type CustomFormulaJaql = (FormulaJaql & {
|
|
66
|
+
context?: FormulaJaql | FormulaContext;
|
|
67
|
+
}) | FormulaContext;
|
|
59
68
|
export declare type RankingFilterJaql = {
|
|
60
69
|
agg: string;
|
|
61
70
|
column: string;
|
|
@@ -120,7 +129,7 @@ export declare enum DatetimeLevel {
|
|
|
120
129
|
export declare type FilterJaqlInternal = {
|
|
121
130
|
title: string;
|
|
122
131
|
column: string;
|
|
123
|
-
datasource?:
|
|
132
|
+
datasource?: JaqlDataSource;
|
|
124
133
|
datatype: string;
|
|
125
134
|
dim: string;
|
|
126
135
|
dimension?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataSource } from '../interfaces.js';
|
|
2
|
-
import { Sort } from './types.js';
|
|
2
|
+
import { JaqlDataSource, Sort } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
@@ -35,6 +35,12 @@ export interface Element {
|
|
|
35
35
|
* @internal
|
|
36
36
|
*/
|
|
37
37
|
readonly id: string;
|
|
38
|
+
/**
|
|
39
|
+
* Data Source
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
readonly dataSource?: JaqlDataSource;
|
|
38
44
|
/**
|
|
39
45
|
* Gets a serializable representation of the element.
|
|
40
46
|
*
|
|
@@ -344,6 +350,10 @@ export interface Filter extends Element {
|
|
|
344
350
|
* Attribute this filter instance is filtering
|
|
345
351
|
*/
|
|
346
352
|
readonly attribute: Attribute;
|
|
353
|
+
/**
|
|
354
|
+
* Filter type
|
|
355
|
+
*/
|
|
356
|
+
readonly filterType: string;
|
|
347
357
|
/**
|
|
348
358
|
* Boolean flag whether the filter is a scope filter
|
|
349
359
|
*/
|