1
1
import { AndFilter , BrandAssortmentFilter , BrandDataFilter , BrandIdFilter , CartDataFilter , ContentCategoryAssortmentFilter , ContentCategoryDataFilter , ContentCategoryHasAncestorFilter , ContentCategoryHasChildFilter , ContentCategoryHasParentFilter , ContentCategoryIdFilter , ContentCategoryLevelFilter , ContentDataFilter , ContentIdFilter , Filter , FilterCollection , OrFilter , ProductAndVariantId , ProductAndVariantIdFilter , ProductAssortmentFilter , ProductCategoryAssortmentFilter , ProductCategoryDataFilter , ProductCategoryHasAncestorFilter , ProductCategoryHasChildFilter , ProductCategoryHasParentFilter , ProductCategoryIdFilter , ProductCategoryLevelFilter , ProductDataFilter , ProductDisplayNameFilter , ProductHasVariantsFilter , ProductIdFilter , ProductListPriceFilter , ProductRecentlyPurchasedByUserFilter , ProductRecentlyViewedByUserFilter , ProductSalesPriceFilter , VariantAssortmentFilter , VariantDataFilter , VariantIdFilter , VariantListPriceFilter , VariantSalesPriceFilter , VariantSpecificationFilter } from '../models/data-contracts' ;
2
+ import { FilterSettingsBuilder } from './filterSettingsBuilder' ;
2
3
import { ConditionBuilder } from './conditionBuilder' ;
3
4
5
+ export type EntityDataFilterOptions = {
6
+ objectPath ?: string [ ] ,
7
+ filterSettings ?: ( builder : FilterSettingsBuilder ) => void
8
+ } ;
9
+
4
10
export class FilterBuilder {
5
11
private filters : ( AndFilter
6
12
| BrandAssortmentFilter
@@ -463,17 +469,22 @@ export class FilterBuilder {
463
469
* @param filterOutIfKeyIsNotFound
464
470
* @param negated
465
471
*/
466
- public addProductDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false ) : this {
472
+ public addProductDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false , options ?: EntityDataFilterOptions ) : this {
467
473
const builder = new ConditionBuilder ( ) ;
468
474
conditionBuilder ( builder ) ;
469
475
476
+ const internalSettingsBuilder = new FilterSettingsBuilder ( ) ;
477
+ options ?. filterSettings ?.( internalSettingsBuilder ) ;
478
+
470
479
const filter : ProductDataFilter = {
471
480
$type : 'Relewise.Client.Requests.Filters.ProductDataFilter, Relewise.Client' ,
472
481
key : key ,
473
482
filterOutIfKeyIsNotFound : filterOutIfKeyIsNotFound ,
474
483
mustMatchAllConditions : mustMatchAllConditions ,
475
484
conditions : builder . build ( ) ,
476
485
negated : negated ,
486
+ objectPath : options ?. objectPath ,
487
+ settings : internalSettingsBuilder . build ( ) ,
477
488
} ;
478
489
this . filters . push ( filter ) ;
479
490
@@ -488,17 +499,22 @@ export class FilterBuilder {
488
499
* @param filterOutIfKeyIsNotFound
489
500
* @param negated
490
501
*/
491
- public addVariantDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false ) : this {
502
+ public addVariantDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false , options ?: EntityDataFilterOptions ) : this {
492
503
const builder = new ConditionBuilder ( ) ;
493
504
conditionBuilder ( builder ) ;
494
505
506
+ const internalSettingsBuilder = new FilterSettingsBuilder ( ) ;
507
+ options ?. filterSettings ?.( internalSettingsBuilder ) ;
508
+
495
509
const filter : VariantDataFilter = {
496
510
$type : 'Relewise.Client.Requests.Filters.VariantDataFilter, Relewise.Client' ,
497
511
key : key ,
498
512
filterOutIfKeyIsNotFound : filterOutIfKeyIsNotFound ,
499
513
mustMatchAllConditions : mustMatchAllConditions ,
500
514
conditions : builder . build ( ) ,
501
515
negated : negated ,
516
+ objectPath : options ?. objectPath ,
517
+ settings : internalSettingsBuilder . build ( ) ,
502
518
} ;
503
519
this . filters . push ( filter ) ;
504
520
@@ -513,17 +529,22 @@ export class FilterBuilder {
513
529
* @param filterOutIfKeyIsNotFound
514
530
* @param negated
515
531
*/
516
- public addBrandDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false ) : this {
532
+ public addBrandDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false , options ?: EntityDataFilterOptions ) : this {
517
533
const builder = new ConditionBuilder ( ) ;
518
534
conditionBuilder ( builder ) ;
519
535
536
+ const internalSettingsBuilder = new FilterSettingsBuilder ( ) ;
537
+ options ?. filterSettings ?.( internalSettingsBuilder ) ;
538
+
520
539
const filter : BrandDataFilter = {
521
540
$type : 'Relewise.Client.Requests.Filters.BrandDataFilter, Relewise.Client' ,
522
541
key : key ,
523
542
filterOutIfKeyIsNotFound : filterOutIfKeyIsNotFound ,
524
543
mustMatchAllConditions : mustMatchAllConditions ,
525
544
conditions : builder . build ( ) ,
526
545
negated : negated ,
546
+ objectPath : options ?. objectPath ,
547
+ settings : internalSettingsBuilder . build ( ) ,
527
548
} ;
528
549
this . filters . push ( filter ) ;
529
550
@@ -563,17 +584,22 @@ export class FilterBuilder {
563
584
* @param filterOutIfKeyIsNotFound
564
585
* @param negated
565
586
*/
566
- public addContentCategoryDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false ) : this {
587
+ public addContentCategoryDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false , options ?: EntityDataFilterOptions ) : this {
567
588
const builder = new ConditionBuilder ( ) ;
568
589
conditionBuilder ( builder ) ;
569
590
591
+ const internalSettingsBuilder = new FilterSettingsBuilder ( ) ;
592
+ options ?. filterSettings ?.( internalSettingsBuilder ) ;
593
+
570
594
const filter : ContentCategoryDataFilter = {
571
595
$type : 'Relewise.Client.Requests.Filters.ContentCategoryDataFilter, Relewise.Client' ,
572
596
key : key ,
573
597
filterOutIfKeyIsNotFound : filterOutIfKeyIsNotFound ,
574
598
mustMatchAllConditions : mustMatchAllConditions ,
575
599
conditions : builder . build ( ) ,
576
600
negated : negated ,
601
+ objectPath : options ?. objectPath ,
602
+ settings : internalSettingsBuilder . build ( ) ,
577
603
} ;
578
604
this . filters . push ( filter ) ;
579
605
@@ -588,17 +614,22 @@ export class FilterBuilder {
588
614
* @param filterOutIfKeyIsNotFound
589
615
* @param negated
590
616
*/
591
- public addContentDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false ) : this {
617
+ public addContentDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false , options ?: EntityDataFilterOptions ) : this {
592
618
const builder = new ConditionBuilder ( ) ;
593
619
conditionBuilder ( builder ) ;
594
620
621
+ const internalSettingsBuilder = new FilterSettingsBuilder ( ) ;
622
+ options ?. filterSettings ?.( internalSettingsBuilder ) ;
623
+
595
624
const filter : ContentDataFilter = {
596
625
$type : 'Relewise.Client.Requests.Filters.ContentDataFilter, Relewise.Client' ,
597
626
key : key ,
598
627
filterOutIfKeyIsNotFound : filterOutIfKeyIsNotFound ,
599
628
mustMatchAllConditions : mustMatchAllConditions ,
600
629
conditions : builder . build ( ) ,
601
630
negated : negated ,
631
+ objectPath : options ?. objectPath ,
632
+ settings : internalSettingsBuilder . build ( ) ,
602
633
} ;
603
634
this . filters . push ( filter ) ;
604
635
@@ -613,17 +644,22 @@ export class FilterBuilder {
613
644
* @param filterOutIfKeyIsNotFound
614
645
* @param negated
615
646
*/
616
- public addProductCategoryDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false ) : this {
647
+ public addProductCategoryDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false , options ?: EntityDataFilterOptions ) : this {
617
648
const builder = new ConditionBuilder ( ) ;
618
649
conditionBuilder ( builder ) ;
619
650
651
+ const internalSettingsBuilder = new FilterSettingsBuilder ( ) ;
652
+ options ?. filterSettings ?.( internalSettingsBuilder ) ;
653
+
620
654
const filter : ProductCategoryDataFilter = {
621
655
$type : 'Relewise.Client.Requests.Filters.ProductCategoryDataFilter, Relewise.Client' ,
622
656
key : key ,
623
657
filterOutIfKeyIsNotFound : filterOutIfKeyIsNotFound ,
624
658
mustMatchAllConditions : mustMatchAllConditions ,
625
659
conditions : builder . build ( ) ,
626
660
negated : negated ,
661
+ objectPath : options ?. objectPath ,
662
+ settings : internalSettingsBuilder . build ( ) ,
627
663
} ;
628
664
this . filters . push ( filter ) ;
629
665
@@ -681,7 +717,7 @@ export class FilterBuilder {
681
717
negated : negated ,
682
718
} ;
683
719
this . filters . push ( filter ) ;
684
-
720
+
685
721
return this ;
686
722
}
687
723
@@ -697,7 +733,7 @@ export class FilterBuilder {
697
733
negated : negated ,
698
734
} ;
699
735
this . filters . push ( filter ) ;
700
-
736
+
701
737
return this ;
702
738
}
703
739
@@ -713,7 +749,7 @@ export class FilterBuilder {
713
749
negated : negated ,
714
750
} ;
715
751
this . filters . push ( filter ) ;
716
-
752
+
717
753
return this ;
718
754
}
719
755
@@ -729,7 +765,7 @@ export class FilterBuilder {
729
765
negated : negated ,
730
766
} ;
731
767
this . filters . push ( filter ) ;
732
-
768
+
733
769
return this ;
734
770
}
735
771
@@ -745,7 +781,7 @@ export class FilterBuilder {
745
781
negated : negated ,
746
782
} ;
747
783
this . filters . push ( filter ) ;
748
-
784
+
749
785
return this ;
750
786
}
751
787
@@ -761,7 +797,7 @@ export class FilterBuilder {
761
797
negated : negated ,
762
798
} ;
763
799
this . filters . push ( filter ) ;
764
-
800
+
765
801
return this ;
766
802
}
767
803
@@ -777,7 +813,7 @@ export class FilterBuilder {
777
813
negated : negated ,
778
814
} ;
779
815
this . filters . push ( filter ) ;
780
-
816
+
781
817
return this ;
782
818
}
783
819
@@ -793,7 +829,7 @@ export class FilterBuilder {
793
829
negated : negated ,
794
830
} ;
795
831
this . filters . push ( filter ) ;
796
-
832
+
797
833
return this ;
798
834
}
799
835
0 commit comments