@usertour/helpers 0.0.24 → 0.0.25
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/__tests__/condition.test.cjs +81 -54
- package/dist/__tests__/condition.test.js +66 -43
- package/dist/{chunk-WDSNF52D.js → chunk-4UMEUZN5.js} +16 -12
- package/dist/conditions/condition.cjs +16 -12
- package/dist/conditions/condition.d.cts +2 -2
- package/dist/conditions/condition.d.ts +2 -2
- package/dist/conditions/condition.js +1 -1
- package/dist/conditions/index.cjs +16 -12
- package/dist/conditions/index.js +1 -1
- package/dist/index.cjs +16 -12
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -351,7 +351,7 @@ var filterConditionsByType = (conditions, allowedTypes) => {
|
|
|
351
351
|
return condition;
|
|
352
352
|
});
|
|
353
353
|
};
|
|
354
|
-
var evaluateRule = (rule, options) => {
|
|
354
|
+
var evaluateRule = async (rule, options) => {
|
|
355
355
|
var _a;
|
|
356
356
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
357
357
|
const ruleId = rule.id;
|
|
@@ -361,7 +361,8 @@ var evaluateRule = (rule, options) => {
|
|
|
361
361
|
return false;
|
|
362
362
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[rule.type];
|
|
363
363
|
if (customEvaluator) {
|
|
364
|
-
|
|
364
|
+
const result = customEvaluator(rule, options);
|
|
365
|
+
return typeof result === "object" && result !== null && "then" in result ? await result : result;
|
|
365
366
|
}
|
|
366
367
|
if (typeControl[rule.type] !== true) {
|
|
367
368
|
return rule.actived || false;
|
|
@@ -382,19 +383,22 @@ var evaluateRule = (rule, options) => {
|
|
|
382
383
|
return rule.actived || false;
|
|
383
384
|
}
|
|
384
385
|
};
|
|
385
|
-
var activedRulesConditions = (conditions, options = {}) => {
|
|
386
|
-
|
|
386
|
+
var activedRulesConditions = async (conditions, options = {}) => {
|
|
387
|
+
const results = [];
|
|
388
|
+
for (const rule of conditions) {
|
|
387
389
|
if (rule.type === "group" && rule.conditions) {
|
|
388
|
-
|
|
390
|
+
results.push({
|
|
389
391
|
...rule,
|
|
390
|
-
conditions: activedRulesConditions(rule.conditions, options)
|
|
391
|
-
};
|
|
392
|
+
conditions: await activedRulesConditions(rule.conditions, options)
|
|
393
|
+
});
|
|
394
|
+
} else {
|
|
395
|
+
results.push({
|
|
396
|
+
...rule,
|
|
397
|
+
actived: await evaluateRule(rule, options)
|
|
398
|
+
});
|
|
392
399
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
actived: evaluateRule(rule, options)
|
|
396
|
-
};
|
|
397
|
-
});
|
|
400
|
+
}
|
|
401
|
+
return results;
|
|
398
402
|
};
|
|
399
403
|
|
|
400
404
|
// src/__tests__/condition.test.ts
|
|
@@ -654,7 +658,7 @@ describe("activedRulesConditions", () => {
|
|
|
654
658
|
email: "test@example.com"
|
|
655
659
|
}
|
|
656
660
|
};
|
|
657
|
-
test("should return conditions with default actived state when no options provided", () => {
|
|
661
|
+
test("should return conditions with default actived state when no options provided", async () => {
|
|
658
662
|
const conditions = [
|
|
659
663
|
{
|
|
660
664
|
id: "rule-1",
|
|
@@ -671,13 +675,13 @@ describe("activedRulesConditions", () => {
|
|
|
671
675
|
data: {}
|
|
672
676
|
}
|
|
673
677
|
];
|
|
674
|
-
const result = activedRulesConditions(conditions);
|
|
678
|
+
const result = await activedRulesConditions(conditions);
|
|
675
679
|
expect(result).toHaveLength(2);
|
|
676
680
|
expect(result[0].actived).toBe(true);
|
|
677
681
|
expect(result[1].actived).toBe(false);
|
|
678
682
|
});
|
|
679
|
-
test("should disable all rule types by default when typeControl is empty", () => {
|
|
680
|
-
const result = activedRulesConditions(mockConditions, {
|
|
683
|
+
test("should disable all rule types by default when typeControl is empty", async () => {
|
|
684
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
681
685
|
...mockOptions,
|
|
682
686
|
typeControl: {}
|
|
683
687
|
});
|
|
@@ -686,8 +690,8 @@ describe("activedRulesConditions", () => {
|
|
|
686
690
|
expect(result[2].actived).toBe(false);
|
|
687
691
|
expect(result[3].actived).toBe(true);
|
|
688
692
|
});
|
|
689
|
-
test("should force activate rules by ID", () => {
|
|
690
|
-
const result = activedRulesConditions(mockConditions, {
|
|
693
|
+
test("should force activate rules by ID", async () => {
|
|
694
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
691
695
|
...mockOptions,
|
|
692
696
|
activatedIds: ["rule-1", "rule-2"]
|
|
693
697
|
});
|
|
@@ -696,8 +700,8 @@ describe("activedRulesConditions", () => {
|
|
|
696
700
|
expect(result[2].actived).toBe(false);
|
|
697
701
|
expect(result[3].actived).toBe(true);
|
|
698
702
|
});
|
|
699
|
-
test("should force deactivate rules by ID", () => {
|
|
700
|
-
const result = activedRulesConditions(mockConditions, {
|
|
703
|
+
test("should force deactivate rules by ID", async () => {
|
|
704
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
701
705
|
...mockOptions,
|
|
702
706
|
deactivatedIds: ["rule-1", "rule-4"]
|
|
703
707
|
});
|
|
@@ -706,16 +710,16 @@ describe("activedRulesConditions", () => {
|
|
|
706
710
|
expect(result[2].actived).toBe(false);
|
|
707
711
|
expect(result[3].actived).toBe(false);
|
|
708
712
|
});
|
|
709
|
-
test("should prioritize activatedIds over deactivatedIds", () => {
|
|
710
|
-
const result = activedRulesConditions(mockConditions, {
|
|
713
|
+
test("should prioritize activatedIds over deactivatedIds", async () => {
|
|
714
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
711
715
|
...mockOptions,
|
|
712
716
|
activatedIds: ["rule-1"],
|
|
713
717
|
deactivatedIds: ["rule-1"]
|
|
714
718
|
});
|
|
715
719
|
expect(result[0].actived).toBe(true);
|
|
716
720
|
});
|
|
717
|
-
test("should disable evaluation for specific rule types by default", () => {
|
|
718
|
-
const result = activedRulesConditions(mockConditions, {
|
|
721
|
+
test("should disable evaluation for specific rule types by default", async () => {
|
|
722
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
719
723
|
...mockOptions,
|
|
720
724
|
typeControl: {
|
|
721
725
|
[import_types3.RulesType.CURRENT_PAGE]: false,
|
|
@@ -727,8 +731,8 @@ describe("activedRulesConditions", () => {
|
|
|
727
731
|
expect(result[2].actived).toBe(false);
|
|
728
732
|
expect(result[3].actived).toBe(true);
|
|
729
733
|
});
|
|
730
|
-
test("should evaluate URL conditions correctly when enabled", () => {
|
|
731
|
-
const result = activedRulesConditions(mockConditions, {
|
|
734
|
+
test("should evaluate URL conditions correctly when enabled", async () => {
|
|
735
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
732
736
|
...mockOptions,
|
|
733
737
|
typeControl: {
|
|
734
738
|
[import_types3.RulesType.CURRENT_PAGE]: true
|
|
@@ -736,8 +740,8 @@ describe("activedRulesConditions", () => {
|
|
|
736
740
|
});
|
|
737
741
|
expect(result[0].actived).toBe(false);
|
|
738
742
|
});
|
|
739
|
-
test("should evaluate time conditions correctly when enabled", () => {
|
|
740
|
-
const result = activedRulesConditions(mockConditions, {
|
|
743
|
+
test("should evaluate time conditions correctly when enabled", async () => {
|
|
744
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
741
745
|
...mockOptions,
|
|
742
746
|
typeControl: {
|
|
743
747
|
[import_types3.RulesType.TIME]: true
|
|
@@ -745,8 +749,8 @@ describe("activedRulesConditions", () => {
|
|
|
745
749
|
});
|
|
746
750
|
expect(typeof result[1].actived).toBe("boolean");
|
|
747
751
|
});
|
|
748
|
-
test("should evaluate attribute conditions correctly when enabled", () => {
|
|
749
|
-
const result = activedRulesConditions(mockConditions, {
|
|
752
|
+
test("should evaluate attribute conditions correctly when enabled", async () => {
|
|
753
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
750
754
|
...mockOptions,
|
|
751
755
|
typeControl: {
|
|
752
756
|
[import_types3.RulesType.USER_ATTR]: true
|
|
@@ -754,7 +758,7 @@ describe("activedRulesConditions", () => {
|
|
|
754
758
|
});
|
|
755
759
|
expect(result[2].actived).toBe(true);
|
|
756
760
|
});
|
|
757
|
-
test("should handle rules without ID", () => {
|
|
761
|
+
test("should handle rules without ID", async () => {
|
|
758
762
|
const conditions = [
|
|
759
763
|
{
|
|
760
764
|
id: "rule-without-id",
|
|
@@ -764,13 +768,13 @@ describe("activedRulesConditions", () => {
|
|
|
764
768
|
data: {}
|
|
765
769
|
}
|
|
766
770
|
];
|
|
767
|
-
const result = activedRulesConditions(conditions, {
|
|
771
|
+
const result = await activedRulesConditions(conditions, {
|
|
768
772
|
activatedIds: ["non-existent"],
|
|
769
773
|
deactivatedIds: ["non-existent"]
|
|
770
774
|
});
|
|
771
775
|
expect(result[0].actived).toBe(true);
|
|
772
776
|
});
|
|
773
|
-
test("should handle nested group conditions", () => {
|
|
777
|
+
test("should handle nested group conditions", async () => {
|
|
774
778
|
const nestedConditions = [
|
|
775
779
|
{
|
|
776
780
|
id: "group-1",
|
|
@@ -799,7 +803,7 @@ describe("activedRulesConditions", () => {
|
|
|
799
803
|
]
|
|
800
804
|
}
|
|
801
805
|
];
|
|
802
|
-
const result = activedRulesConditions(nestedConditions, {
|
|
806
|
+
const result = await activedRulesConditions(nestedConditions, {
|
|
803
807
|
...mockOptions,
|
|
804
808
|
activatedIds: ["rule-1"]
|
|
805
809
|
});
|
|
@@ -808,7 +812,7 @@ describe("activedRulesConditions", () => {
|
|
|
808
812
|
expect(result[0].conditions[0].actived).toBe(true);
|
|
809
813
|
expect(result[0].conditions[1].actived).toBe(true);
|
|
810
814
|
});
|
|
811
|
-
test("should handle deep nested group conditions", () => {
|
|
815
|
+
test("should handle deep nested group conditions", async () => {
|
|
812
816
|
const deepNestedConditions = [
|
|
813
817
|
{
|
|
814
818
|
id: "group-1",
|
|
@@ -839,17 +843,17 @@ describe("activedRulesConditions", () => {
|
|
|
839
843
|
]
|
|
840
844
|
}
|
|
841
845
|
];
|
|
842
|
-
const result = activedRulesConditions(deepNestedConditions, {
|
|
846
|
+
const result = await activedRulesConditions(deepNestedConditions, {
|
|
843
847
|
...mockOptions,
|
|
844
848
|
activatedIds: ["rule-1"]
|
|
845
849
|
});
|
|
846
850
|
expect(result[0].conditions[0].conditions[0].actived).toBe(true);
|
|
847
851
|
});
|
|
848
|
-
test("should handle empty conditions array", () => {
|
|
849
|
-
const result = activedRulesConditions([]);
|
|
852
|
+
test("should handle empty conditions array", async () => {
|
|
853
|
+
const result = await activedRulesConditions([]);
|
|
850
854
|
expect(result).toEqual([]);
|
|
851
855
|
});
|
|
852
|
-
test("should handle conditions with missing data", () => {
|
|
856
|
+
test("should handle conditions with missing data", async () => {
|
|
853
857
|
const conditions = [
|
|
854
858
|
{
|
|
855
859
|
id: "rule-1",
|
|
@@ -859,10 +863,10 @@ describe("activedRulesConditions", () => {
|
|
|
859
863
|
data: void 0
|
|
860
864
|
}
|
|
861
865
|
];
|
|
862
|
-
const result = activedRulesConditions(conditions, mockOptions);
|
|
866
|
+
const result = await activedRulesConditions(conditions, mockOptions);
|
|
863
867
|
expect(result[0].actived).toBe(false);
|
|
864
868
|
});
|
|
865
|
-
test("should handle mixed rule types with different evaluation results when enabled", () => {
|
|
869
|
+
test("should handle mixed rule types with different evaluation results when enabled", async () => {
|
|
866
870
|
const mixedConditions = [
|
|
867
871
|
{
|
|
868
872
|
id: "url-rule",
|
|
@@ -893,7 +897,7 @@ describe("activedRulesConditions", () => {
|
|
|
893
897
|
data: {}
|
|
894
898
|
}
|
|
895
899
|
];
|
|
896
|
-
const result = activedRulesConditions(mixedConditions, {
|
|
900
|
+
const result = await activedRulesConditions(mixedConditions, {
|
|
897
901
|
...mockOptions,
|
|
898
902
|
typeControl: {
|
|
899
903
|
[import_types3.RulesType.CURRENT_PAGE]: true,
|
|
@@ -904,8 +908,8 @@ describe("activedRulesConditions", () => {
|
|
|
904
908
|
expect(result[1].actived).toBe(true);
|
|
905
909
|
expect(result[2].actived).toBe(false);
|
|
906
910
|
});
|
|
907
|
-
test("should handle type control with partial configuration", () => {
|
|
908
|
-
const result = activedRulesConditions(mockConditions, {
|
|
911
|
+
test("should handle type control with partial configuration", async () => {
|
|
912
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
909
913
|
...mockOptions,
|
|
910
914
|
typeControl: {
|
|
911
915
|
[import_types3.RulesType.CURRENT_PAGE]: false
|
|
@@ -917,8 +921,8 @@ describe("activedRulesConditions", () => {
|
|
|
917
921
|
expect(result[2].actived).toBe(false);
|
|
918
922
|
expect(result[3].actived).toBe(true);
|
|
919
923
|
});
|
|
920
|
-
test("should enable evaluation for explicitly enabled rule types", () => {
|
|
921
|
-
const result = activedRulesConditions(mockConditions, {
|
|
924
|
+
test("should enable evaluation for explicitly enabled rule types", async () => {
|
|
925
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
922
926
|
...mockOptions,
|
|
923
927
|
typeControl: {
|
|
924
928
|
[import_types3.RulesType.CURRENT_PAGE]: true,
|
|
@@ -931,8 +935,31 @@ describe("activedRulesConditions", () => {
|
|
|
931
935
|
expect(result[2].actived).toBe(true);
|
|
932
936
|
expect(result[3].actived).toBe(true);
|
|
933
937
|
});
|
|
934
|
-
test("should
|
|
935
|
-
const
|
|
938
|
+
test("should support custom evaluators with async functions", async () => {
|
|
939
|
+
const customEvaluators = {
|
|
940
|
+
[import_types3.RulesType.CURRENT_PAGE]: async (_rule, _options) => {
|
|
941
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
942
|
+
return true;
|
|
943
|
+
},
|
|
944
|
+
[import_types3.RulesType.USER_ATTR]: (_rule, _options) => {
|
|
945
|
+
return false;
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
949
|
+
...mockOptions,
|
|
950
|
+
typeControl: {
|
|
951
|
+
[import_types3.RulesType.CURRENT_PAGE]: true,
|
|
952
|
+
[import_types3.RulesType.USER_ATTR]: true
|
|
953
|
+
},
|
|
954
|
+
customEvaluators
|
|
955
|
+
});
|
|
956
|
+
expect(result[0].actived).toBe(true);
|
|
957
|
+
expect(result[2].actived).toBe(false);
|
|
958
|
+
expect(result[1].actived).toBe(false);
|
|
959
|
+
expect(result[3].actived).toBe(true);
|
|
960
|
+
});
|
|
961
|
+
test("should handle missing clientContext gracefully when enabled", async () => {
|
|
962
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
936
963
|
attributes: mockOptions.attributes,
|
|
937
964
|
userAttributes: mockOptions.userAttributes,
|
|
938
965
|
typeControl: {
|
|
@@ -944,8 +971,8 @@ describe("activedRulesConditions", () => {
|
|
|
944
971
|
expect(result).toHaveLength(4);
|
|
945
972
|
expect(typeof result[0].actived).toBe("boolean");
|
|
946
973
|
});
|
|
947
|
-
test("should handle missing attributes gracefully when enabled", () => {
|
|
948
|
-
const result = activedRulesConditions(mockConditions, {
|
|
974
|
+
test("should handle missing attributes gracefully when enabled", async () => {
|
|
975
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
949
976
|
clientContext: mockOptions.clientContext,
|
|
950
977
|
userAttributes: mockOptions.userAttributes,
|
|
951
978
|
typeControl: {
|
|
@@ -954,8 +981,8 @@ describe("activedRulesConditions", () => {
|
|
|
954
981
|
});
|
|
955
982
|
expect(result[2].actived).toBe(false);
|
|
956
983
|
});
|
|
957
|
-
test("should handle missing userAttributes gracefully when enabled", () => {
|
|
958
|
-
const result = activedRulesConditions(mockConditions, {
|
|
984
|
+
test("should handle missing userAttributes gracefully when enabled", async () => {
|
|
985
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
959
986
|
clientContext: mockOptions.clientContext,
|
|
960
987
|
attributes: mockOptions.attributes,
|
|
961
988
|
typeControl: {
|
|
@@ -964,7 +991,7 @@ describe("activedRulesConditions", () => {
|
|
|
964
991
|
});
|
|
965
992
|
expect(result[2].actived).toBe(false);
|
|
966
993
|
});
|
|
967
|
-
test("debug: should test URL evaluation directly when enabled", () => {
|
|
994
|
+
test("debug: should test URL evaluation directly when enabled", async () => {
|
|
968
995
|
const urlCondition = {
|
|
969
996
|
id: "debug-rule",
|
|
970
997
|
type: "current-page",
|
|
@@ -985,7 +1012,7 @@ describe("activedRulesConditions", () => {
|
|
|
985
1012
|
[import_types3.RulesType.CURRENT_PAGE]: true
|
|
986
1013
|
}
|
|
987
1014
|
};
|
|
988
|
-
const result = activedRulesConditions([urlCondition], options);
|
|
1015
|
+
const result = await activedRulesConditions([urlCondition], options);
|
|
989
1016
|
expect(result[0].actived).toBe(false);
|
|
990
1017
|
});
|
|
991
1018
|
});
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
activedRulesConditions,
|
|
3
3
|
filterConditionsByType,
|
|
4
4
|
isConditionsActived
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-4UMEUZN5.js";
|
|
6
6
|
import "../chunk-YYIGUZNZ.js";
|
|
7
7
|
import "../chunk-PAESAL23.js";
|
|
8
8
|
import "../chunk-PBZSPV5R.js";
|
|
@@ -267,7 +267,7 @@ describe("activedRulesConditions", () => {
|
|
|
267
267
|
email: "test@example.com"
|
|
268
268
|
}
|
|
269
269
|
};
|
|
270
|
-
test("should return conditions with default actived state when no options provided", () => {
|
|
270
|
+
test("should return conditions with default actived state when no options provided", async () => {
|
|
271
271
|
const conditions = [
|
|
272
272
|
{
|
|
273
273
|
id: "rule-1",
|
|
@@ -284,13 +284,13 @@ describe("activedRulesConditions", () => {
|
|
|
284
284
|
data: {}
|
|
285
285
|
}
|
|
286
286
|
];
|
|
287
|
-
const result = activedRulesConditions(conditions);
|
|
287
|
+
const result = await activedRulesConditions(conditions);
|
|
288
288
|
expect(result).toHaveLength(2);
|
|
289
289
|
expect(result[0].actived).toBe(true);
|
|
290
290
|
expect(result[1].actived).toBe(false);
|
|
291
291
|
});
|
|
292
|
-
test("should disable all rule types by default when typeControl is empty", () => {
|
|
293
|
-
const result = activedRulesConditions(mockConditions, {
|
|
292
|
+
test("should disable all rule types by default when typeControl is empty", async () => {
|
|
293
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
294
294
|
...mockOptions,
|
|
295
295
|
typeControl: {}
|
|
296
296
|
});
|
|
@@ -299,8 +299,8 @@ describe("activedRulesConditions", () => {
|
|
|
299
299
|
expect(result[2].actived).toBe(false);
|
|
300
300
|
expect(result[3].actived).toBe(true);
|
|
301
301
|
});
|
|
302
|
-
test("should force activate rules by ID", () => {
|
|
303
|
-
const result = activedRulesConditions(mockConditions, {
|
|
302
|
+
test("should force activate rules by ID", async () => {
|
|
303
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
304
304
|
...mockOptions,
|
|
305
305
|
activatedIds: ["rule-1", "rule-2"]
|
|
306
306
|
});
|
|
@@ -309,8 +309,8 @@ describe("activedRulesConditions", () => {
|
|
|
309
309
|
expect(result[2].actived).toBe(false);
|
|
310
310
|
expect(result[3].actived).toBe(true);
|
|
311
311
|
});
|
|
312
|
-
test("should force deactivate rules by ID", () => {
|
|
313
|
-
const result = activedRulesConditions(mockConditions, {
|
|
312
|
+
test("should force deactivate rules by ID", async () => {
|
|
313
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
314
314
|
...mockOptions,
|
|
315
315
|
deactivatedIds: ["rule-1", "rule-4"]
|
|
316
316
|
});
|
|
@@ -319,16 +319,16 @@ describe("activedRulesConditions", () => {
|
|
|
319
319
|
expect(result[2].actived).toBe(false);
|
|
320
320
|
expect(result[3].actived).toBe(false);
|
|
321
321
|
});
|
|
322
|
-
test("should prioritize activatedIds over deactivatedIds", () => {
|
|
323
|
-
const result = activedRulesConditions(mockConditions, {
|
|
322
|
+
test("should prioritize activatedIds over deactivatedIds", async () => {
|
|
323
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
324
324
|
...mockOptions,
|
|
325
325
|
activatedIds: ["rule-1"],
|
|
326
326
|
deactivatedIds: ["rule-1"]
|
|
327
327
|
});
|
|
328
328
|
expect(result[0].actived).toBe(true);
|
|
329
329
|
});
|
|
330
|
-
test("should disable evaluation for specific rule types by default", () => {
|
|
331
|
-
const result = activedRulesConditions(mockConditions, {
|
|
330
|
+
test("should disable evaluation for specific rule types by default", async () => {
|
|
331
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
332
332
|
...mockOptions,
|
|
333
333
|
typeControl: {
|
|
334
334
|
[RulesType.CURRENT_PAGE]: false,
|
|
@@ -340,8 +340,8 @@ describe("activedRulesConditions", () => {
|
|
|
340
340
|
expect(result[2].actived).toBe(false);
|
|
341
341
|
expect(result[3].actived).toBe(true);
|
|
342
342
|
});
|
|
343
|
-
test("should evaluate URL conditions correctly when enabled", () => {
|
|
344
|
-
const result = activedRulesConditions(mockConditions, {
|
|
343
|
+
test("should evaluate URL conditions correctly when enabled", async () => {
|
|
344
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
345
345
|
...mockOptions,
|
|
346
346
|
typeControl: {
|
|
347
347
|
[RulesType.CURRENT_PAGE]: true
|
|
@@ -349,8 +349,8 @@ describe("activedRulesConditions", () => {
|
|
|
349
349
|
});
|
|
350
350
|
expect(result[0].actived).toBe(false);
|
|
351
351
|
});
|
|
352
|
-
test("should evaluate time conditions correctly when enabled", () => {
|
|
353
|
-
const result = activedRulesConditions(mockConditions, {
|
|
352
|
+
test("should evaluate time conditions correctly when enabled", async () => {
|
|
353
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
354
354
|
...mockOptions,
|
|
355
355
|
typeControl: {
|
|
356
356
|
[RulesType.TIME]: true
|
|
@@ -358,8 +358,8 @@ describe("activedRulesConditions", () => {
|
|
|
358
358
|
});
|
|
359
359
|
expect(typeof result[1].actived).toBe("boolean");
|
|
360
360
|
});
|
|
361
|
-
test("should evaluate attribute conditions correctly when enabled", () => {
|
|
362
|
-
const result = activedRulesConditions(mockConditions, {
|
|
361
|
+
test("should evaluate attribute conditions correctly when enabled", async () => {
|
|
362
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
363
363
|
...mockOptions,
|
|
364
364
|
typeControl: {
|
|
365
365
|
[RulesType.USER_ATTR]: true
|
|
@@ -367,7 +367,7 @@ describe("activedRulesConditions", () => {
|
|
|
367
367
|
});
|
|
368
368
|
expect(result[2].actived).toBe(true);
|
|
369
369
|
});
|
|
370
|
-
test("should handle rules without ID", () => {
|
|
370
|
+
test("should handle rules without ID", async () => {
|
|
371
371
|
const conditions = [
|
|
372
372
|
{
|
|
373
373
|
id: "rule-without-id",
|
|
@@ -377,13 +377,13 @@ describe("activedRulesConditions", () => {
|
|
|
377
377
|
data: {}
|
|
378
378
|
}
|
|
379
379
|
];
|
|
380
|
-
const result = activedRulesConditions(conditions, {
|
|
380
|
+
const result = await activedRulesConditions(conditions, {
|
|
381
381
|
activatedIds: ["non-existent"],
|
|
382
382
|
deactivatedIds: ["non-existent"]
|
|
383
383
|
});
|
|
384
384
|
expect(result[0].actived).toBe(true);
|
|
385
385
|
});
|
|
386
|
-
test("should handle nested group conditions", () => {
|
|
386
|
+
test("should handle nested group conditions", async () => {
|
|
387
387
|
const nestedConditions = [
|
|
388
388
|
{
|
|
389
389
|
id: "group-1",
|
|
@@ -412,7 +412,7 @@ describe("activedRulesConditions", () => {
|
|
|
412
412
|
]
|
|
413
413
|
}
|
|
414
414
|
];
|
|
415
|
-
const result = activedRulesConditions(nestedConditions, {
|
|
415
|
+
const result = await activedRulesConditions(nestedConditions, {
|
|
416
416
|
...mockOptions,
|
|
417
417
|
activatedIds: ["rule-1"]
|
|
418
418
|
});
|
|
@@ -421,7 +421,7 @@ describe("activedRulesConditions", () => {
|
|
|
421
421
|
expect(result[0].conditions[0].actived).toBe(true);
|
|
422
422
|
expect(result[0].conditions[1].actived).toBe(true);
|
|
423
423
|
});
|
|
424
|
-
test("should handle deep nested group conditions", () => {
|
|
424
|
+
test("should handle deep nested group conditions", async () => {
|
|
425
425
|
const deepNestedConditions = [
|
|
426
426
|
{
|
|
427
427
|
id: "group-1",
|
|
@@ -452,17 +452,17 @@ describe("activedRulesConditions", () => {
|
|
|
452
452
|
]
|
|
453
453
|
}
|
|
454
454
|
];
|
|
455
|
-
const result = activedRulesConditions(deepNestedConditions, {
|
|
455
|
+
const result = await activedRulesConditions(deepNestedConditions, {
|
|
456
456
|
...mockOptions,
|
|
457
457
|
activatedIds: ["rule-1"]
|
|
458
458
|
});
|
|
459
459
|
expect(result[0].conditions[0].conditions[0].actived).toBe(true);
|
|
460
460
|
});
|
|
461
|
-
test("should handle empty conditions array", () => {
|
|
462
|
-
const result = activedRulesConditions([]);
|
|
461
|
+
test("should handle empty conditions array", async () => {
|
|
462
|
+
const result = await activedRulesConditions([]);
|
|
463
463
|
expect(result).toEqual([]);
|
|
464
464
|
});
|
|
465
|
-
test("should handle conditions with missing data", () => {
|
|
465
|
+
test("should handle conditions with missing data", async () => {
|
|
466
466
|
const conditions = [
|
|
467
467
|
{
|
|
468
468
|
id: "rule-1",
|
|
@@ -472,10 +472,10 @@ describe("activedRulesConditions", () => {
|
|
|
472
472
|
data: void 0
|
|
473
473
|
}
|
|
474
474
|
];
|
|
475
|
-
const result = activedRulesConditions(conditions, mockOptions);
|
|
475
|
+
const result = await activedRulesConditions(conditions, mockOptions);
|
|
476
476
|
expect(result[0].actived).toBe(false);
|
|
477
477
|
});
|
|
478
|
-
test("should handle mixed rule types with different evaluation results when enabled", () => {
|
|
478
|
+
test("should handle mixed rule types with different evaluation results when enabled", async () => {
|
|
479
479
|
const mixedConditions = [
|
|
480
480
|
{
|
|
481
481
|
id: "url-rule",
|
|
@@ -506,7 +506,7 @@ describe("activedRulesConditions", () => {
|
|
|
506
506
|
data: {}
|
|
507
507
|
}
|
|
508
508
|
];
|
|
509
|
-
const result = activedRulesConditions(mixedConditions, {
|
|
509
|
+
const result = await activedRulesConditions(mixedConditions, {
|
|
510
510
|
...mockOptions,
|
|
511
511
|
typeControl: {
|
|
512
512
|
[RulesType.CURRENT_PAGE]: true,
|
|
@@ -517,8 +517,8 @@ describe("activedRulesConditions", () => {
|
|
|
517
517
|
expect(result[1].actived).toBe(true);
|
|
518
518
|
expect(result[2].actived).toBe(false);
|
|
519
519
|
});
|
|
520
|
-
test("should handle type control with partial configuration", () => {
|
|
521
|
-
const result = activedRulesConditions(mockConditions, {
|
|
520
|
+
test("should handle type control with partial configuration", async () => {
|
|
521
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
522
522
|
...mockOptions,
|
|
523
523
|
typeControl: {
|
|
524
524
|
[RulesType.CURRENT_PAGE]: false
|
|
@@ -530,8 +530,8 @@ describe("activedRulesConditions", () => {
|
|
|
530
530
|
expect(result[2].actived).toBe(false);
|
|
531
531
|
expect(result[3].actived).toBe(true);
|
|
532
532
|
});
|
|
533
|
-
test("should enable evaluation for explicitly enabled rule types", () => {
|
|
534
|
-
const result = activedRulesConditions(mockConditions, {
|
|
533
|
+
test("should enable evaluation for explicitly enabled rule types", async () => {
|
|
534
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
535
535
|
...mockOptions,
|
|
536
536
|
typeControl: {
|
|
537
537
|
[RulesType.CURRENT_PAGE]: true,
|
|
@@ -544,8 +544,31 @@ describe("activedRulesConditions", () => {
|
|
|
544
544
|
expect(result[2].actived).toBe(true);
|
|
545
545
|
expect(result[3].actived).toBe(true);
|
|
546
546
|
});
|
|
547
|
-
test("should
|
|
548
|
-
const
|
|
547
|
+
test("should support custom evaluators with async functions", async () => {
|
|
548
|
+
const customEvaluators = {
|
|
549
|
+
[RulesType.CURRENT_PAGE]: async (_rule, _options) => {
|
|
550
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
551
|
+
return true;
|
|
552
|
+
},
|
|
553
|
+
[RulesType.USER_ATTR]: (_rule, _options) => {
|
|
554
|
+
return false;
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
558
|
+
...mockOptions,
|
|
559
|
+
typeControl: {
|
|
560
|
+
[RulesType.CURRENT_PAGE]: true,
|
|
561
|
+
[RulesType.USER_ATTR]: true
|
|
562
|
+
},
|
|
563
|
+
customEvaluators
|
|
564
|
+
});
|
|
565
|
+
expect(result[0].actived).toBe(true);
|
|
566
|
+
expect(result[2].actived).toBe(false);
|
|
567
|
+
expect(result[1].actived).toBe(false);
|
|
568
|
+
expect(result[3].actived).toBe(true);
|
|
569
|
+
});
|
|
570
|
+
test("should handle missing clientContext gracefully when enabled", async () => {
|
|
571
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
549
572
|
attributes: mockOptions.attributes,
|
|
550
573
|
userAttributes: mockOptions.userAttributes,
|
|
551
574
|
typeControl: {
|
|
@@ -557,8 +580,8 @@ describe("activedRulesConditions", () => {
|
|
|
557
580
|
expect(result).toHaveLength(4);
|
|
558
581
|
expect(typeof result[0].actived).toBe("boolean");
|
|
559
582
|
});
|
|
560
|
-
test("should handle missing attributes gracefully when enabled", () => {
|
|
561
|
-
const result = activedRulesConditions(mockConditions, {
|
|
583
|
+
test("should handle missing attributes gracefully when enabled", async () => {
|
|
584
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
562
585
|
clientContext: mockOptions.clientContext,
|
|
563
586
|
userAttributes: mockOptions.userAttributes,
|
|
564
587
|
typeControl: {
|
|
@@ -567,8 +590,8 @@ describe("activedRulesConditions", () => {
|
|
|
567
590
|
});
|
|
568
591
|
expect(result[2].actived).toBe(false);
|
|
569
592
|
});
|
|
570
|
-
test("should handle missing userAttributes gracefully when enabled", () => {
|
|
571
|
-
const result = activedRulesConditions(mockConditions, {
|
|
593
|
+
test("should handle missing userAttributes gracefully when enabled", async () => {
|
|
594
|
+
const result = await activedRulesConditions(mockConditions, {
|
|
572
595
|
clientContext: mockOptions.clientContext,
|
|
573
596
|
attributes: mockOptions.attributes,
|
|
574
597
|
typeControl: {
|
|
@@ -577,7 +600,7 @@ describe("activedRulesConditions", () => {
|
|
|
577
600
|
});
|
|
578
601
|
expect(result[2].actived).toBe(false);
|
|
579
602
|
});
|
|
580
|
-
test("debug: should test URL evaluation directly when enabled", () => {
|
|
603
|
+
test("debug: should test URL evaluation directly when enabled", async () => {
|
|
581
604
|
const urlCondition = {
|
|
582
605
|
id: "debug-rule",
|
|
583
606
|
type: "current-page",
|
|
@@ -598,7 +621,7 @@ describe("activedRulesConditions", () => {
|
|
|
598
621
|
[RulesType.CURRENT_PAGE]: true
|
|
599
622
|
}
|
|
600
623
|
};
|
|
601
|
-
const result = activedRulesConditions([urlCondition], options);
|
|
624
|
+
const result = await activedRulesConditions([urlCondition], options);
|
|
602
625
|
expect(result[0].actived).toBe(false);
|
|
603
626
|
});
|
|
604
627
|
});
|
|
@@ -44,7 +44,7 @@ var filterConditionsByType = (conditions, allowedTypes) => {
|
|
|
44
44
|
return condition;
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
|
-
var evaluateRule = (rule, options) => {
|
|
47
|
+
var evaluateRule = async (rule, options) => {
|
|
48
48
|
var _a;
|
|
49
49
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
50
50
|
const ruleId = rule.id;
|
|
@@ -54,7 +54,8 @@ var evaluateRule = (rule, options) => {
|
|
|
54
54
|
return false;
|
|
55
55
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[rule.type];
|
|
56
56
|
if (customEvaluator) {
|
|
57
|
-
|
|
57
|
+
const result = customEvaluator(rule, options);
|
|
58
|
+
return typeof result === "object" && result !== null && "then" in result ? await result : result;
|
|
58
59
|
}
|
|
59
60
|
if (typeControl[rule.type] !== true) {
|
|
60
61
|
return rule.actived || false;
|
|
@@ -75,19 +76,22 @@ var evaluateRule = (rule, options) => {
|
|
|
75
76
|
return rule.actived || false;
|
|
76
77
|
}
|
|
77
78
|
};
|
|
78
|
-
var activedRulesConditions = (conditions, options = {}) => {
|
|
79
|
-
|
|
79
|
+
var activedRulesConditions = async (conditions, options = {}) => {
|
|
80
|
+
const results = [];
|
|
81
|
+
for (const rule of conditions) {
|
|
80
82
|
if (rule.type === "group" && rule.conditions) {
|
|
81
|
-
|
|
83
|
+
results.push({
|
|
82
84
|
...rule,
|
|
83
|
-
conditions: activedRulesConditions(rule.conditions, options)
|
|
84
|
-
};
|
|
85
|
+
conditions: await activedRulesConditions(rule.conditions, options)
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
results.push({
|
|
89
|
+
...rule,
|
|
90
|
+
actived: await evaluateRule(rule, options)
|
|
91
|
+
});
|
|
85
92
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
actived: evaluateRule(rule, options)
|
|
89
|
-
};
|
|
90
|
-
});
|
|
93
|
+
}
|
|
94
|
+
return results;
|
|
91
95
|
};
|
|
92
96
|
|
|
93
97
|
export {
|
|
@@ -366,7 +366,7 @@ var filterConditionsByType = (conditions, allowedTypes) => {
|
|
|
366
366
|
return condition;
|
|
367
367
|
});
|
|
368
368
|
};
|
|
369
|
-
var evaluateRule = (rule, options) => {
|
|
369
|
+
var evaluateRule = async (rule, options) => {
|
|
370
370
|
var _a;
|
|
371
371
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
372
372
|
const ruleId = rule.id;
|
|
@@ -376,7 +376,8 @@ var evaluateRule = (rule, options) => {
|
|
|
376
376
|
return false;
|
|
377
377
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[rule.type];
|
|
378
378
|
if (customEvaluator) {
|
|
379
|
-
|
|
379
|
+
const result = customEvaluator(rule, options);
|
|
380
|
+
return typeof result === "object" && result !== null && "then" in result ? await result : result;
|
|
380
381
|
}
|
|
381
382
|
if (typeControl[rule.type] !== true) {
|
|
382
383
|
return rule.actived || false;
|
|
@@ -397,19 +398,22 @@ var evaluateRule = (rule, options) => {
|
|
|
397
398
|
return rule.actived || false;
|
|
398
399
|
}
|
|
399
400
|
};
|
|
400
|
-
var activedRulesConditions = (conditions, options = {}) => {
|
|
401
|
-
|
|
401
|
+
var activedRulesConditions = async (conditions, options = {}) => {
|
|
402
|
+
const results = [];
|
|
403
|
+
for (const rule of conditions) {
|
|
402
404
|
if (rule.type === "group" && rule.conditions) {
|
|
403
|
-
|
|
405
|
+
results.push({
|
|
404
406
|
...rule,
|
|
405
|
-
conditions: activedRulesConditions(rule.conditions, options)
|
|
406
|
-
};
|
|
407
|
+
conditions: await activedRulesConditions(rule.conditions, options)
|
|
408
|
+
});
|
|
409
|
+
} else {
|
|
410
|
+
results.push({
|
|
411
|
+
...rule,
|
|
412
|
+
actived: await evaluateRule(rule, options)
|
|
413
|
+
});
|
|
407
414
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
actived: evaluateRule(rule, options)
|
|
411
|
-
};
|
|
412
|
-
});
|
|
415
|
+
}
|
|
416
|
+
return results;
|
|
413
417
|
};
|
|
414
418
|
// Annotate the CommonJS export names for ESM import in node:
|
|
415
419
|
0 && (module.exports = {
|
|
@@ -34,7 +34,7 @@ declare const filterConditionsByType: (conditions: RulesCondition[], allowedType
|
|
|
34
34
|
* deactivatedIds: ['rule-3']
|
|
35
35
|
* });
|
|
36
36
|
*/
|
|
37
|
-
declare const evaluateRule: (rule: RulesCondition, options: RulesEvaluationOptions) => boolean
|
|
38
|
-
declare const activedRulesConditions: (conditions: RulesCondition[], options?: RulesEvaluationOptions) => RulesCondition[]
|
|
37
|
+
declare const evaluateRule: (rule: RulesCondition, options: RulesEvaluationOptions) => Promise<boolean>;
|
|
38
|
+
declare const activedRulesConditions: (conditions: RulesCondition[], options?: RulesEvaluationOptions) => Promise<RulesCondition[]>;
|
|
39
39
|
|
|
40
40
|
export { activedRulesConditions, conditionsIsSame, evaluateRule, filterConditionsByType, isConditionsActived };
|
|
@@ -34,7 +34,7 @@ declare const filterConditionsByType: (conditions: RulesCondition[], allowedType
|
|
|
34
34
|
* deactivatedIds: ['rule-3']
|
|
35
35
|
* });
|
|
36
36
|
*/
|
|
37
|
-
declare const evaluateRule: (rule: RulesCondition, options: RulesEvaluationOptions) => boolean
|
|
38
|
-
declare const activedRulesConditions: (conditions: RulesCondition[], options?: RulesEvaluationOptions) => RulesCondition[]
|
|
37
|
+
declare const evaluateRule: (rule: RulesCondition, options: RulesEvaluationOptions) => Promise<boolean>;
|
|
38
|
+
declare const activedRulesConditions: (conditions: RulesCondition[], options?: RulesEvaluationOptions) => Promise<RulesCondition[]>;
|
|
39
39
|
|
|
40
40
|
export { activedRulesConditions, conditionsIsSame, evaluateRule, filterConditionsByType, isConditionsActived };
|
|
@@ -372,7 +372,7 @@ var filterConditionsByType = (conditions, allowedTypes) => {
|
|
|
372
372
|
return condition;
|
|
373
373
|
});
|
|
374
374
|
};
|
|
375
|
-
var evaluateRule = (rule, options) => {
|
|
375
|
+
var evaluateRule = async (rule, options) => {
|
|
376
376
|
var _a;
|
|
377
377
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
378
378
|
const ruleId = rule.id;
|
|
@@ -382,7 +382,8 @@ var evaluateRule = (rule, options) => {
|
|
|
382
382
|
return false;
|
|
383
383
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[rule.type];
|
|
384
384
|
if (customEvaluator) {
|
|
385
|
-
|
|
385
|
+
const result = customEvaluator(rule, options);
|
|
386
|
+
return typeof result === "object" && result !== null && "then" in result ? await result : result;
|
|
386
387
|
}
|
|
387
388
|
if (typeControl[rule.type] !== true) {
|
|
388
389
|
return rule.actived || false;
|
|
@@ -403,19 +404,22 @@ var evaluateRule = (rule, options) => {
|
|
|
403
404
|
return rule.actived || false;
|
|
404
405
|
}
|
|
405
406
|
};
|
|
406
|
-
var activedRulesConditions = (conditions, options = {}) => {
|
|
407
|
-
|
|
407
|
+
var activedRulesConditions = async (conditions, options = {}) => {
|
|
408
|
+
const results = [];
|
|
409
|
+
for (const rule of conditions) {
|
|
408
410
|
if (rule.type === "group" && rule.conditions) {
|
|
409
|
-
|
|
411
|
+
results.push({
|
|
410
412
|
...rule,
|
|
411
|
-
conditions: activedRulesConditions(rule.conditions, options)
|
|
412
|
-
};
|
|
413
|
+
conditions: await activedRulesConditions(rule.conditions, options)
|
|
414
|
+
});
|
|
415
|
+
} else {
|
|
416
|
+
results.push({
|
|
417
|
+
...rule,
|
|
418
|
+
actived: await evaluateRule(rule, options)
|
|
419
|
+
});
|
|
413
420
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
actived: evaluateRule(rule, options)
|
|
417
|
-
};
|
|
418
|
-
});
|
|
421
|
+
}
|
|
422
|
+
return results;
|
|
419
423
|
};
|
|
420
424
|
// Annotate the CommonJS export names for ESM import in node:
|
|
421
425
|
0 && (module.exports = {
|
package/dist/conditions/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1293,7 +1293,7 @@ var filterConditionsByType = (conditions, allowedTypes) => {
|
|
|
1293
1293
|
return condition;
|
|
1294
1294
|
});
|
|
1295
1295
|
};
|
|
1296
|
-
var evaluateRule = (rule, options) => {
|
|
1296
|
+
var evaluateRule = async (rule, options) => {
|
|
1297
1297
|
var _a;
|
|
1298
1298
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
1299
1299
|
const ruleId = rule.id;
|
|
@@ -1303,7 +1303,8 @@ var evaluateRule = (rule, options) => {
|
|
|
1303
1303
|
return false;
|
|
1304
1304
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[rule.type];
|
|
1305
1305
|
if (customEvaluator) {
|
|
1306
|
-
|
|
1306
|
+
const result = customEvaluator(rule, options);
|
|
1307
|
+
return typeof result === "object" && result !== null && "then" in result ? await result : result;
|
|
1307
1308
|
}
|
|
1308
1309
|
if (typeControl[rule.type] !== true) {
|
|
1309
1310
|
return rule.actived || false;
|
|
@@ -1324,19 +1325,22 @@ var evaluateRule = (rule, options) => {
|
|
|
1324
1325
|
return rule.actived || false;
|
|
1325
1326
|
}
|
|
1326
1327
|
};
|
|
1327
|
-
var activedRulesConditions = (conditions, options = {}) => {
|
|
1328
|
-
|
|
1328
|
+
var activedRulesConditions = async (conditions, options = {}) => {
|
|
1329
|
+
const results = [];
|
|
1330
|
+
for (const rule of conditions) {
|
|
1329
1331
|
if (rule.type === "group" && rule.conditions) {
|
|
1330
|
-
|
|
1332
|
+
results.push({
|
|
1331
1333
|
...rule,
|
|
1332
|
-
conditions: activedRulesConditions(rule.conditions, options)
|
|
1333
|
-
};
|
|
1334
|
+
conditions: await activedRulesConditions(rule.conditions, options)
|
|
1335
|
+
});
|
|
1336
|
+
} else {
|
|
1337
|
+
results.push({
|
|
1338
|
+
...rule,
|
|
1339
|
+
actived: await evaluateRule(rule, options)
|
|
1340
|
+
});
|
|
1334
1341
|
}
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
actived: evaluateRule(rule, options)
|
|
1338
|
-
};
|
|
1339
|
-
});
|
|
1342
|
+
}
|
|
1343
|
+
return results;
|
|
1340
1344
|
};
|
|
1341
1345
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1342
1346
|
0 && (module.exports = {
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usertour/helpers",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Utility functions and helpers shared across the UserTour project",
|
|
6
6
|
"homepage": "https://www.usertour.io",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
32
|
-
"@usertour/types": "^0.0.
|
|
32
|
+
"@usertour/types": "^0.0.14",
|
|
33
33
|
"chroma-js": "^3.1.2",
|
|
34
34
|
"class-variance-authority": "^0.4.0",
|
|
35
35
|
"clsx": "^1.2.1",
|