@splitsoftware/splitio-commons 1.13.2-rc.5 → 1.13.2-rc.7
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/CHANGES.txt +2 -0
- package/cjs/evaluator/Engine.js +5 -6
- package/cjs/evaluator/combiners/ifelseif.js +2 -3
- package/cjs/evaluator/condition/index.js +2 -3
- package/cjs/evaluator/index.js +4 -5
- package/cjs/evaluator/matchers/all.js +1 -3
- package/cjs/evaluator/matchers/between.js +1 -3
- package/cjs/evaluator/matchers/boolean.js +1 -3
- package/cjs/evaluator/matchers/cont_all.js +1 -3
- package/cjs/evaluator/matchers/cont_any.js +1 -3
- package/cjs/evaluator/matchers/cont_str.js +1 -3
- package/cjs/evaluator/matchers/dependency.js +1 -1
- package/cjs/evaluator/matchers/eq.js +1 -3
- package/cjs/evaluator/matchers/eq_set.js +1 -3
- package/cjs/evaluator/matchers/ew.js +1 -3
- package/cjs/evaluator/matchers/gte.js +1 -3
- package/cjs/evaluator/matchers/index.js +1 -1
- package/cjs/evaluator/matchers/lte.js +1 -3
- package/cjs/evaluator/matchers/part_of.js +1 -3
- package/cjs/evaluator/matchers/segment.js +1 -6
- package/cjs/evaluator/matchers/semver_between.js +1 -3
- package/cjs/evaluator/matchers/semver_eq.js +1 -3
- package/cjs/evaluator/matchers/semver_gte.js +1 -3
- package/cjs/evaluator/matchers/semver_inlist.js +4 -6
- package/cjs/evaluator/matchers/semver_lte.js +1 -3
- package/cjs/evaluator/matchers/string.js +1 -3
- package/cjs/evaluator/matchers/sw.js +1 -3
- package/cjs/evaluator/matchers/whitelist.js +3 -4
- package/cjs/evaluator/matchersTransform/index.js +6 -8
- package/cjs/evaluator/matchersTransform/whitelist.js +2 -3
- package/cjs/evaluator/parser/index.js +13 -14
- package/cjs/logger/constants.js +4 -24
- package/cjs/logger/index.js +8 -1
- package/cjs/logger/messages/debug.js +5 -25
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/services/splitApi.js +5 -5
- package/cjs/storages/KeyBuilder.js +3 -2
- package/cjs/utils/constants/index.js +2 -1
- package/esm/evaluator/Engine.js +5 -5
- package/esm/evaluator/combiners/ifelseif.js +2 -2
- package/esm/evaluator/condition/index.js +2 -2
- package/esm/evaluator/index.js +4 -4
- package/esm/evaluator/matchers/all.js +1 -3
- package/esm/evaluator/matchers/between.js +1 -3
- package/esm/evaluator/matchers/boolean.js +1 -3
- package/esm/evaluator/matchers/cont_all.js +1 -3
- package/esm/evaluator/matchers/cont_any.js +1 -3
- package/esm/evaluator/matchers/cont_str.js +1 -3
- package/esm/evaluator/matchers/dependency.js +1 -1
- package/esm/evaluator/matchers/eq.js +1 -3
- package/esm/evaluator/matchers/eq_set.js +1 -3
- package/esm/evaluator/matchers/ew.js +1 -3
- package/esm/evaluator/matchers/gte.js +1 -3
- package/esm/evaluator/matchers/index.js +1 -1
- package/esm/evaluator/matchers/lte.js +1 -3
- package/esm/evaluator/matchers/part_of.js +1 -3
- package/esm/evaluator/matchers/segment.js +1 -6
- package/esm/evaluator/matchers/semver_between.js +1 -3
- package/esm/evaluator/matchers/semver_eq.js +1 -3
- package/esm/evaluator/matchers/semver_gte.js +1 -3
- package/esm/evaluator/matchers/semver_inlist.js +5 -7
- package/esm/evaluator/matchers/semver_lte.js +1 -3
- package/esm/evaluator/matchers/string.js +1 -3
- package/esm/evaluator/matchers/sw.js +1 -3
- package/esm/evaluator/matchers/whitelist.js +4 -5
- package/esm/evaluator/matchersTransform/index.js +6 -8
- package/esm/evaluator/matchersTransform/whitelist.js +2 -3
- package/esm/evaluator/parser/index.js +14 -15
- package/esm/logger/constants.js +1 -21
- package/esm/logger/index.js +9 -2
- package/esm/logger/messages/debug.js +5 -25
- package/esm/logger/messages/warn.js +1 -1
- package/esm/services/splitApi.js +6 -6
- package/esm/storages/KeyBuilder.js +3 -2
- package/esm/utils/constants/index.js +1 -0
- package/package.json +1 -1
- package/src/evaluator/Engine.ts +5 -6
- package/src/evaluator/combiners/ifelseif.ts +2 -2
- package/src/evaluator/condition/index.ts +2 -2
- package/src/evaluator/index.ts +4 -4
- package/src/evaluator/matchers/all.ts +1 -5
- package/src/evaluator/matchers/between.ts +3 -7
- package/src/evaluator/matchers/boolean.ts +2 -6
- package/src/evaluator/matchers/cont_all.ts +1 -5
- package/src/evaluator/matchers/cont_any.ts +1 -5
- package/src/evaluator/matchers/cont_str.ts +2 -6
- package/src/evaluator/matchers/dependency.ts +1 -1
- package/src/evaluator/matchers/eq.ts +2 -6
- package/src/evaluator/matchers/eq_set.ts +1 -5
- package/src/evaluator/matchers/ew.ts +2 -6
- package/src/evaluator/matchers/gte.ts +2 -6
- package/src/evaluator/matchers/index.ts +1 -1
- package/src/evaluator/matchers/lte.ts +2 -6
- package/src/evaluator/matchers/part_of.ts +1 -5
- package/src/evaluator/matchers/segment.ts +1 -8
- package/src/evaluator/matchers/semver_between.ts +1 -5
- package/src/evaluator/matchers/semver_eq.ts +1 -5
- package/src/evaluator/matchers/semver_gte.ts +1 -5
- package/src/evaluator/matchers/semver_inlist.ts +5 -9
- package/src/evaluator/matchers/semver_lte.ts +1 -5
- package/src/evaluator/matchers/string.ts +1 -6
- package/src/evaluator/matchers/sw.ts +2 -6
- package/src/evaluator/matchers/whitelist.ts +5 -7
- package/src/evaluator/matchersTransform/index.ts +5 -8
- package/src/evaluator/matchersTransform/whitelist.ts +2 -3
- package/src/evaluator/parser/index.ts +12 -8
- package/src/evaluator/types.ts +2 -2
- package/src/logger/constants.ts +1 -21
- package/src/logger/index.ts +8 -2
- package/src/logger/messages/debug.ts +5 -25
- package/src/logger/messages/warn.ts +1 -1
- package/src/services/splitApi.ts +5 -6
- package/src/storages/KeyBuilder.ts +3 -2
- package/src/utils/constants/index.ts +2 -0
- package/types/evaluator/matchers/all.d.ts +1 -2
- package/types/evaluator/matchers/between.d.ts +1 -2
- package/types/evaluator/matchers/boolean.d.ts +1 -2
- package/types/evaluator/matchers/cont_all.d.ts +1 -2
- package/types/evaluator/matchers/cont_any.d.ts +1 -2
- package/types/evaluator/matchers/cont_str.d.ts +1 -2
- package/types/evaluator/matchers/dependency.d.ts +1 -1
- package/types/evaluator/matchers/eq.d.ts +1 -2
- package/types/evaluator/matchers/eq_set.d.ts +1 -2
- package/types/evaluator/matchers/ew.d.ts +1 -2
- package/types/evaluator/matchers/gte.d.ts +1 -2
- package/types/evaluator/matchers/lte.d.ts +1 -2
- package/types/evaluator/matchers/part_of.d.ts +1 -2
- package/types/evaluator/matchers/segment.d.ts +1 -2
- package/types/evaluator/matchers/semver_between.d.ts +1 -2
- package/types/evaluator/matchers/semver_eq.d.ts +1 -2
- package/types/evaluator/matchers/semver_gte.d.ts +1 -2
- package/types/evaluator/matchers/semver_inlist.d.ts +1 -3
- package/types/evaluator/matchers/semver_lte.d.ts +1 -2
- package/types/evaluator/matchers/string.d.ts +1 -2
- package/types/evaluator/matchers/sw.d.ts +1 -2
- package/types/evaluator/matchers/whitelist.d.ts +1 -3
- package/types/evaluator/matchersTransform/whitelist.d.ts +2 -2
- package/types/evaluator/types.d.ts +2 -2
- package/types/logger/constants.d.ts +1 -21
- package/types/storages/KeyBuilder.d.ts +1 -1
- package/types/utils/constants/index.d.ts +1 -0
- package/cjs/evaluator/matchersTransform/set.js +0 -10
- package/esm/evaluator/matchersTransform/set.js +0 -6
- package/src/evaluator/matchersTransform/set.ts +0 -8
|
@@ -2,7 +2,6 @@ import { findIndex } from '../../utils/lang';
|
|
|
2
2
|
import { matcherTypes, matcherTypesMapper, matcherDataTypes } from '../matchers/matcherTypes';
|
|
3
3
|
import { segmentTransform } from './segment';
|
|
4
4
|
import { whitelistTransform } from './whitelist';
|
|
5
|
-
import { setTransform } from './set';
|
|
6
5
|
import { numericTransform } from './unaryNumeric';
|
|
7
6
|
import { zeroSinceHH, zeroSinceSS } from '../convertions';
|
|
8
7
|
/**
|
|
@@ -19,10 +18,6 @@ export function matchersTransform(matchers) {
|
|
|
19
18
|
if (type === matcherTypes.IN_SEGMENT) {
|
|
20
19
|
value = segmentTransform(userDefinedSegmentMatcherData);
|
|
21
20
|
}
|
|
22
|
-
else if (type === matcherTypes.WHITELIST ||
|
|
23
|
-
type === matcherTypes.IN_LIST_SEMVER) {
|
|
24
|
-
value = whitelistTransform(whitelistMatcherData);
|
|
25
|
-
}
|
|
26
21
|
else if (type === matcherTypes.EQUAL_TO) {
|
|
27
22
|
value = numericTransform(unaryNumericMatcherData);
|
|
28
23
|
dataType = matcherDataTypes.NUMBER;
|
|
@@ -56,13 +51,15 @@ export function matchersTransform(matchers) {
|
|
|
56
51
|
type === matcherTypes.CONTAINS_ANY_OF_SET ||
|
|
57
52
|
type === matcherTypes.CONTAINS_ALL_OF_SET ||
|
|
58
53
|
type === matcherTypes.PART_OF_SET) {
|
|
59
|
-
value =
|
|
54
|
+
value = whitelistTransform(whitelistMatcherData);
|
|
60
55
|
dataType = matcherDataTypes.SET;
|
|
61
56
|
}
|
|
62
|
-
else if (type === matcherTypes.
|
|
57
|
+
else if (type === matcherTypes.WHITELIST ||
|
|
58
|
+
type === matcherTypes.IN_LIST_SEMVER ||
|
|
59
|
+
type === matcherTypes.STARTS_WITH ||
|
|
63
60
|
type === matcherTypes.ENDS_WITH ||
|
|
64
61
|
type === matcherTypes.CONTAINS_STRING) {
|
|
65
|
-
value =
|
|
62
|
+
value = whitelistTransform(whitelistMatcherData);
|
|
66
63
|
}
|
|
67
64
|
else if (type === matcherTypes.IN_SPLIT_TREATMENT) {
|
|
68
65
|
value = dependencyMatcherData;
|
|
@@ -82,6 +79,7 @@ export function matchersTransform(matchers) {
|
|
|
82
79
|
attribute: attribute,
|
|
83
80
|
negate: negate,
|
|
84
81
|
type: type,
|
|
82
|
+
name: matcherType,
|
|
85
83
|
value: value,
|
|
86
84
|
dataType: dataType // runtime input data type
|
|
87
85
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { _Set } from '../../utils/lang/sets';
|
|
2
1
|
/**
|
|
3
|
-
* Extract whitelist
|
|
2
|
+
* Extract whitelist array.
|
|
4
3
|
*/
|
|
5
4
|
export function whitelistTransform(whitelistObject) {
|
|
6
|
-
return
|
|
5
|
+
return whitelistObject && whitelistObject.whitelist;
|
|
7
6
|
}
|
|
@@ -6,21 +6,21 @@ import { conditionContext } from '../condition';
|
|
|
6
6
|
import { ifElseIfCombinerContext } from '../combiners/ifelseif';
|
|
7
7
|
import { andCombinerContext } from '../combiners/and';
|
|
8
8
|
import { thenable } from '../../utils/promise/thenable';
|
|
9
|
-
import { ENGINE_MATCHER_ERROR } from '../../logger/constants';
|
|
9
|
+
import { ENGINE_MATCHER_ERROR, ENGINE_MATCHER_RESULT } from '../../logger/constants';
|
|
10
10
|
export function parser(log, conditions, storage) {
|
|
11
11
|
var predicates = [];
|
|
12
|
-
var
|
|
12
|
+
for (var i = 0; i < conditions.length; i++) {
|
|
13
13
|
var _a = conditions[i], matcherGroup = _a.matcherGroup, partitions = _a.partitions, label = _a.label, conditionType = _a.conditionType;
|
|
14
14
|
// transform data structure
|
|
15
15
|
var matchers = matchersTransform(matcherGroup.matchers);
|
|
16
16
|
// create a set of pure functions from the matcher's dto
|
|
17
|
-
var expressions = matchers.map(function (matcherDto
|
|
17
|
+
var expressions = matchers.map(function (matcherDto) {
|
|
18
18
|
var matcher;
|
|
19
19
|
try {
|
|
20
20
|
matcher = matcherFactory(log, matcherDto, storage);
|
|
21
21
|
}
|
|
22
22
|
catch (error) {
|
|
23
|
-
log.error(ENGINE_MATCHER_ERROR, [
|
|
23
|
+
log.error(ENGINE_MATCHER_ERROR, [matcherDto.name, error]);
|
|
24
24
|
}
|
|
25
25
|
// Evaluator function.
|
|
26
26
|
return function (key, attributes, splitEvaluator) {
|
|
@@ -31,27 +31,26 @@ export function parser(log, conditions, storage) {
|
|
|
31
31
|
result = matcher(value, splitEvaluator);
|
|
32
32
|
}
|
|
33
33
|
catch (error) {
|
|
34
|
-
log.error(ENGINE_MATCHER_ERROR, [
|
|
34
|
+
log.error(ENGINE_MATCHER_ERROR, [matcherDto.name, error]);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
function handleResult(result) {
|
|
38
|
+
log.debug(ENGINE_MATCHER_RESULT, [matcherDto.name, result, matcherDto.value, value]); // @ts-ignore
|
|
39
|
+
return Boolean(result ^ matcherDto.negate);
|
|
40
|
+
}
|
|
41
|
+
return thenable(result) ?
|
|
42
|
+
result.then(handleResult) :
|
|
43
|
+
handleResult(result);
|
|
41
44
|
};
|
|
42
45
|
});
|
|
43
46
|
// if matcher's factory can't instantiate the matchers, the expressions array will be empty
|
|
44
47
|
if (expressions.length === 0) {
|
|
45
48
|
// reset any data collected during parsing
|
|
46
49
|
predicates = [];
|
|
47
|
-
|
|
50
|
+
// and break the loop
|
|
51
|
+
break;
|
|
48
52
|
}
|
|
49
53
|
predicates.push(conditionContext(log, andCombinerContext(log, expressions), Treatments.parse(partitions), label, conditionType));
|
|
50
|
-
};
|
|
51
|
-
for (var i = 0; i < conditions.length; i++) {
|
|
52
|
-
var state_1 = _loop_1(i);
|
|
53
|
-
if (state_1 === "break")
|
|
54
|
-
break;
|
|
55
54
|
}
|
|
56
55
|
// Instanciate evaluator given the set of conditions using if else if logic
|
|
57
56
|
return ifElseIfCombinerContext(log, predicates);
|
package/esm/logger/constants.js
CHANGED
|
@@ -9,24 +9,8 @@ export var ENGINE_COMBINER_AND = 0;
|
|
|
9
9
|
export var ENGINE_COMBINER_IFELSEIF = 1;
|
|
10
10
|
export var ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = 2;
|
|
11
11
|
export var ENGINE_BUCKET = 3;
|
|
12
|
-
export var ENGINE_MATCHER_ALL = 4;
|
|
13
|
-
export var ENGINE_MATCHER_BETWEEN = 5;
|
|
14
|
-
export var ENGINE_MATCHER_BOOLEAN = 6;
|
|
15
|
-
export var ENGINE_MATCHER_CONTAINS_ALL = 7;
|
|
16
|
-
export var ENGINE_MATCHER_CONTAINS_ANY = 8;
|
|
17
|
-
export var ENGINE_MATCHER_CONTAINS_STRING = 9;
|
|
18
12
|
export var ENGINE_MATCHER_DEPENDENCY = 10;
|
|
19
13
|
export var ENGINE_MATCHER_DEPENDENCY_PRE = 11;
|
|
20
|
-
export var ENGINE_MATCHER_EQUAL = 12;
|
|
21
|
-
export var ENGINE_MATCHER_EQUAL_TO_SET = 13;
|
|
22
|
-
export var ENGINE_MATCHER_ENDS_WITH = 14;
|
|
23
|
-
export var ENGINE_MATCHER_GREATER = 15;
|
|
24
|
-
export var ENGINE_MATCHER_LESS = 16;
|
|
25
|
-
export var ENGINE_MATCHER_PART_OF = 17;
|
|
26
|
-
export var ENGINE_MATCHER_SEGMENT = 18;
|
|
27
|
-
export var ENGINE_MATCHER_STRING = 19;
|
|
28
|
-
export var ENGINE_MATCHER_STARTS_WITH = 21;
|
|
29
|
-
export var ENGINE_MATCHER_WHITELIST = 22;
|
|
30
14
|
export var ENGINE_VALUE = 23;
|
|
31
15
|
export var ENGINE_SANITIZE = 24;
|
|
32
16
|
export var CLEANUP_REGISTERING = 25;
|
|
@@ -44,11 +28,7 @@ export var SYNC_TASK_START = 36;
|
|
|
44
28
|
export var SYNC_TASK_EXECUTE = 37;
|
|
45
29
|
export var SYNC_TASK_STOP = 38;
|
|
46
30
|
export var SETTINGS_SPLITS_FILTER = 39;
|
|
47
|
-
export var
|
|
48
|
-
export var ENGINE_MATCHER_GREATER_SEMVER = 41;
|
|
49
|
-
export var ENGINE_MATCHER_LESS_SEMVER = 42;
|
|
50
|
-
export var ENGINE_MATCHER_BETWEEN_SEMVER = 43;
|
|
51
|
-
export var ENGINE_MATCHER_IN_LIST_SEMVER = 44;
|
|
31
|
+
export var ENGINE_MATCHER_RESULT = 40;
|
|
52
32
|
export var CLIENT_READY_FROM_CACHE = 100;
|
|
53
33
|
export var CLIENT_READY = 101;
|
|
54
34
|
export var IMPRESSION = 102;
|
package/esm/logger/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
|
-
import { find } from '../utils/lang';
|
|
2
|
+
import { find, isObject } from '../utils/lang';
|
|
3
3
|
import { _Map } from '../utils/lang/maps';
|
|
4
4
|
export var LogLevels = {
|
|
5
5
|
DEBUG: 'DEBUG',
|
|
@@ -24,7 +24,14 @@ export function _sprintf(format, args) {
|
|
|
24
24
|
if (args === void 0) { args = []; }
|
|
25
25
|
var i = 0;
|
|
26
26
|
return format.replace(/%s/g, function () {
|
|
27
|
-
|
|
27
|
+
var arg = args[i++];
|
|
28
|
+
if (isObject(arg) || Array.isArray(arg)) {
|
|
29
|
+
try {
|
|
30
|
+
arg = JSON.stringify(arg);
|
|
31
|
+
}
|
|
32
|
+
catch (e) { /* empty */ }
|
|
33
|
+
}
|
|
34
|
+
return arg;
|
|
28
35
|
});
|
|
29
36
|
}
|
|
30
37
|
var defaultOptions = {
|
|
@@ -6,31 +6,11 @@ export var codesDebug = codesInfo.concat([
|
|
|
6
6
|
[c.ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Treatment found: %s'],
|
|
7
7
|
[c.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT, c.LOG_PREFIX_ENGINE_COMBINER + 'All predicates evaluated, no treatment found.'],
|
|
8
8
|
[c.ENGINE_BUCKET, c.LOG_PREFIX_ENGINE + ': using algo "murmur" bucket %s for key %s using seed %s - treatment %s'],
|
|
9
|
-
[c.
|
|
10
|
-
[c.
|
|
11
|
-
[c.
|
|
12
|
-
[c.
|
|
13
|
-
[c.
|
|
14
|
-
[c.ENGINE_MATCHER_CONTAINS_STRING, c.LOG_PREFIX_ENGINE_MATCHER + '[containsStringMatcher] %s contains %s? %s'],
|
|
15
|
-
[c.ENGINE_MATCHER_DEPENDENCY, c.LOG_PREFIX_ENGINE_MATCHER + '[dependencyMatcher] parent feature flag "%s" evaluated to "%s" with label "%s". %s evaluated treatment is part of [%s] ? %s.'],
|
|
16
|
-
[c.ENGINE_MATCHER_DEPENDENCY_PRE, c.LOG_PREFIX_ENGINE_MATCHER + '[dependencyMatcher] will evaluate parent feature flag: "%s" with key: %s %s'],
|
|
17
|
-
[c.ENGINE_MATCHER_EQUAL, c.LOG_PREFIX_ENGINE_MATCHER + '[equalToMatcher] is %s equal to %s? %s'],
|
|
18
|
-
[c.ENGINE_MATCHER_EQUAL_TO_SET, c.LOG_PREFIX_ENGINE_MATCHER + '[equalToSetMatcher] is %s equal to set %s? %s'],
|
|
19
|
-
[c.ENGINE_MATCHER_ENDS_WITH, c.LOG_PREFIX_ENGINE_MATCHER + '[endsWithMatcher] %s ends with %s? %s'],
|
|
20
|
-
[c.ENGINE_MATCHER_GREATER, c.LOG_PREFIX_ENGINE_MATCHER + '[greaterThanEqualMatcher] is %s greater than %s? %s'],
|
|
21
|
-
[c.ENGINE_MATCHER_LESS, c.LOG_PREFIX_ENGINE_MATCHER + '[lessThanEqualMatcher] is %s less than %s? %s'],
|
|
22
|
-
[c.ENGINE_MATCHER_PART_OF, c.LOG_PREFIX_ENGINE_MATCHER + '[partOfMatcher] %s is part of %s? %s'],
|
|
23
|
-
[c.ENGINE_MATCHER_SEGMENT, c.LOG_PREFIX_ENGINE_MATCHER + '[segmentMatcher] evaluated %s / %s => %s'],
|
|
24
|
-
[c.ENGINE_MATCHER_STRING, c.LOG_PREFIX_ENGINE_MATCHER + '[stringMatcher] does %s matches with %s? %s'],
|
|
25
|
-
[c.ENGINE_MATCHER_STARTS_WITH, c.LOG_PREFIX_ENGINE_MATCHER + '[startsWithMatcher] %s starts with %s? %s'],
|
|
26
|
-
[c.ENGINE_MATCHER_WHITELIST, c.LOG_PREFIX_ENGINE_MATCHER + '[whitelistMatcher] evaluated %s in [%s] => %s'],
|
|
27
|
-
[c.ENGINE_VALUE, c.LOG_PREFIX_ENGINE_VALUE + 'Extracted attribute [%s], [%s] will be used for matching.'],
|
|
28
|
-
[c.ENGINE_SANITIZE, c.LOG_PREFIX_ENGINE + ':sanitize: Attempted to sanitize [%s] which should be of type [%s]. Sanitized and processed value => [%s]'],
|
|
29
|
-
[c.ENGINE_MATCHER_EQUAL_SEMVER, c.LOG_PREFIX_ENGINE_MATCHER + '[equalToSemverMatcher] is %s equal to %s? %s'],
|
|
30
|
-
[c.ENGINE_MATCHER_GREATER_SEMVER, c.LOG_PREFIX_ENGINE_MATCHER + '[greaterThanEqualSemverMatcher] is %s greater than %s? %s'],
|
|
31
|
-
[c.ENGINE_MATCHER_LESS_SEMVER, c.LOG_PREFIX_ENGINE_MATCHER + '[lessThanEqualSemverMatcher] is %s less than %s? %s'],
|
|
32
|
-
[c.ENGINE_MATCHER_BETWEEN_SEMVER, c.LOG_PREFIX_ENGINE_MATCHER + '[betweenSemverMatcher] is %s between %s and %s? %s'],
|
|
33
|
-
[c.ENGINE_MATCHER_IN_LIST_SEMVER, c.LOG_PREFIX_ENGINE_MATCHER + '[inListSemverMatcher] is %s in list [%s]? %s'],
|
|
9
|
+
[c.ENGINE_MATCHER_DEPENDENCY, c.LOG_PREFIX_ENGINE_MATCHER + '[IN_SPLIT_TREATMENT] parent feature flag "%s" evaluated to "%s" with label "%s". %s evaluated treatment is part of %s ? %s.'],
|
|
10
|
+
[c.ENGINE_MATCHER_DEPENDENCY_PRE, c.LOG_PREFIX_ENGINE_MATCHER + '[IN_SPLIT_TREATMENT] will evaluate parent feature flag: "%s" with key: %s %s'],
|
|
11
|
+
[c.ENGINE_VALUE, c.LOG_PREFIX_ENGINE_VALUE + 'Extracted attribute `%s`. %s will be used for matching.'],
|
|
12
|
+
[c.ENGINE_SANITIZE, c.LOG_PREFIX_ENGINE + ':sanitize: Attempted to sanitize %s which should be of type %s. Sanitized and processed value => %s'],
|
|
13
|
+
[c.ENGINE_MATCHER_RESULT, c.LOG_PREFIX_ENGINE_MATCHER + '[%s] Result: %s. Rule value: %s. Evaluation value: %s'],
|
|
34
14
|
// SDK
|
|
35
15
|
[c.CLEANUP_REGISTERING, c.LOG_PREFIX_CLEANUP + 'Registering cleanup handler %s'],
|
|
36
16
|
[c.CLEANUP_DEREGISTERING, c.LOG_PREFIX_CLEANUP + 'Deregistering cleanup handler %s'],
|
|
@@ -3,7 +3,7 @@ import { codesError } from './error';
|
|
|
3
3
|
export var codesWarn = codesError.concat([
|
|
4
4
|
// evaluator
|
|
5
5
|
[c.ENGINE_VALUE_INVALID, c.LOG_PREFIX_ENGINE_VALUE + 'Value %s doesn\'t match with expected type.'],
|
|
6
|
-
[c.ENGINE_VALUE_NO_ATTRIBUTES, c.LOG_PREFIX_ENGINE_VALUE + 'Defined attribute
|
|
6
|
+
[c.ENGINE_VALUE_NO_ATTRIBUTES, c.LOG_PREFIX_ENGINE_VALUE + 'Defined attribute `%s`. No attributes received.'],
|
|
7
7
|
// synchronizer
|
|
8
8
|
[c.SYNC_MYSEGMENTS_FETCH_RETRY, c.LOG_PREFIX_SYNC_MYSEGMENTS + 'Retrying download of segments #%s. Reason: %s'],
|
|
9
9
|
[c.SYNC_SPLITS_FETCH_FAILS, c.LOG_PREFIX_SYNC_SPLITS + 'Error while doing fetch of feature flags. %s'],
|
package/esm/services/splitApi.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { splitHttpClientFactory } from './splitHttpClient';
|
|
2
2
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
3
|
-
import { SPLITS, IMPRESSIONS, IMPRESSIONS_COUNT, EVENTS, TELEMETRY, TOKEN, SEGMENT, MY_SEGMENT } from '../utils/constants';
|
|
3
|
+
import { SPLITS, IMPRESSIONS, IMPRESSIONS_COUNT, EVENTS, TELEMETRY, TOKEN, SEGMENT, MY_SEGMENT, FLAGS_SPEC } from '../utils/constants';
|
|
4
4
|
import { ERROR_TOO_MANY_SETS } from '../logger/constants';
|
|
5
5
|
var noCacheHeaderOptions = { headers: { 'Cache-Control': 'no-cache' } };
|
|
6
6
|
function userKeyToQueryParam(userKey) {
|
|
@@ -29,16 +29,16 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
29
29
|
return splitHttpClient(url).then(function () { return true; }).catch(function () { return false; });
|
|
30
30
|
},
|
|
31
31
|
fetchAuth: function (userMatchingKeys) {
|
|
32
|
-
var url = urls.auth + "/v2/auth";
|
|
33
|
-
if (userMatchingKeys) { //
|
|
32
|
+
var url = urls.auth + "/v2/auth?s=" + FLAGS_SPEC;
|
|
33
|
+
if (userMatchingKeys) { // `userMatchingKeys` is undefined in server-side
|
|
34
34
|
var queryParams = userMatchingKeys.map(userKeyToQueryParam).join('&');
|
|
35
|
-
if (queryParams)
|
|
36
|
-
url += '
|
|
35
|
+
if (queryParams)
|
|
36
|
+
url += '&' + queryParams;
|
|
37
37
|
}
|
|
38
38
|
return splitHttpClient(url, undefined, telemetryTracker.trackHttp(TOKEN));
|
|
39
39
|
},
|
|
40
40
|
fetchSplitChanges: function (since, noCache, till) {
|
|
41
|
-
var url = urls.sdk + "/splitChanges?since=" + since + (till ? '&till=' + till : '') + (filterQueryString || '');
|
|
41
|
+
var url = urls.sdk + "/splitChanges?s=" + FLAGS_SPEC + "&since=" + since + (till ? '&till=' + till : '') + (filterQueryString || '');
|
|
42
42
|
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(SPLITS))
|
|
43
43
|
.catch(function (err) {
|
|
44
44
|
if (err.statusCode === 414)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FLAGS_SPEC } from '../utils/constants';
|
|
1
2
|
import { startsWith } from '../utils/lang';
|
|
2
3
|
import { hash } from '../utils/murmur3/murmur3';
|
|
3
4
|
var everythingAtTheEnd = /[^.]+$/;
|
|
@@ -62,9 +63,9 @@ var KeyBuilder = /** @class */ (function () {
|
|
|
62
63
|
}());
|
|
63
64
|
export { KeyBuilder };
|
|
64
65
|
/**
|
|
65
|
-
* Generates a murmur32 hash based on the authorization key
|
|
66
|
+
* Generates a murmur32 hash based on the authorization key, the feature flags filter query, and version of SplitChanges API.
|
|
66
67
|
* The hash is in hexadecimal format (8 characters max, 32 bits).
|
|
67
68
|
*/
|
|
68
69
|
export function getStorageHash(settings) {
|
|
69
|
-
return hash(settings.core.authorizationKey + "::" + settings.sync.__splitFiltersValidation.queryString).toString(16);
|
|
70
|
+
return hash(settings.core.authorizationKey + "::" + settings.sync.__splitFiltersValidation.queryString + "::" + FLAGS_SPEC).toString(16);
|
|
70
71
|
}
|
package/package.json
CHANGED
package/src/evaluator/Engine.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { get } from '../utils/lang';
|
|
|
2
2
|
import { parser } from './parser';
|
|
3
3
|
import { keyParser } from '../utils/key';
|
|
4
4
|
import { thenable } from '../utils/promise/thenable';
|
|
5
|
-
import
|
|
5
|
+
import { EXCEPTION, NO_CONDITION_MATCH, SPLIT_ARCHIVED, SPLIT_KILLED } from '../utils/labels';
|
|
6
6
|
import { CONTROL } from '../utils/constants';
|
|
7
7
|
import { ISplit, MaybeThenable } from '../dtos/types';
|
|
8
8
|
import { SplitIO } from '../types';
|
|
@@ -13,7 +13,7 @@ import { ILogger } from '../logger/types';
|
|
|
13
13
|
function evaluationResult(result: IEvaluation | undefined, defaultTreatment: string): IEvaluationResult {
|
|
14
14
|
return {
|
|
15
15
|
treatment: get(result, 'treatment', defaultTreatment),
|
|
16
|
-
label: get(result, 'label',
|
|
16
|
+
label: get(result, 'label', NO_CONDITION_MATCH)
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -55,16 +55,16 @@ export class Engine {
|
|
|
55
55
|
} catch (err) {
|
|
56
56
|
return {
|
|
57
57
|
treatment: CONTROL,
|
|
58
|
-
label:
|
|
58
|
+
label: EXCEPTION
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
if (this.isGarbage()) {
|
|
63
63
|
treatment = CONTROL;
|
|
64
|
-
label =
|
|
64
|
+
label = SPLIT_ARCHIVED;
|
|
65
65
|
} else if (killed) {
|
|
66
66
|
treatment = defaultTreatment;
|
|
67
|
-
label =
|
|
67
|
+
label = SPLIT_KILLED;
|
|
68
68
|
} else {
|
|
69
69
|
const evaluation = this.evaluator(
|
|
70
70
|
parsedKey,
|
|
@@ -98,4 +98,3 @@ export class Engine {
|
|
|
98
98
|
return this.baseInfo.changeNumber;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { findIndex } from '../../utils/lang';
|
|
2
2
|
import { ILogger } from '../../logger/types';
|
|
3
3
|
import { thenable } from '../../utils/promise/thenable';
|
|
4
|
-
import
|
|
4
|
+
import { UNSUPPORTED_MATCHER_TYPE } from '../../utils/labels';
|
|
5
5
|
import { CONTROL } from '../../utils/constants';
|
|
6
6
|
import { SplitIO } from '../../types';
|
|
7
7
|
import { IEvaluation, IEvaluator, ISplitEvaluator } from '../types';
|
|
@@ -14,7 +14,7 @@ export function ifElseIfCombinerContext(log: ILogger, predicates: IEvaluator[]):
|
|
|
14
14
|
|
|
15
15
|
return {
|
|
16
16
|
treatment: CONTROL,
|
|
17
|
-
label:
|
|
17
|
+
label: UNSUPPORTED_MATCHER_TYPE
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getTreatment, shouldApplyRollout } from './engineUtils';
|
|
2
2
|
import { thenable } from '../../utils/promise/thenable';
|
|
3
|
-
import
|
|
3
|
+
import { NOT_IN_SPLIT } from '../../utils/labels';
|
|
4
4
|
import { MaybeThenable } from '../../dtos/types';
|
|
5
5
|
import { IEvaluation, IEvaluator, ISplitEvaluator } from '../types';
|
|
6
6
|
import { SplitIO } from '../../types';
|
|
@@ -30,7 +30,7 @@ export function conditionContext(log: ILogger, matcherEvaluator: (...args: any)
|
|
|
30
30
|
if (conditionType === 'ROLLOUT' && !shouldApplyRollout(trafficAllocation as number, (key as SplitIO.SplitKeyObject).bucketingKey as string, trafficAllocationSeed as number)) {
|
|
31
31
|
return {
|
|
32
32
|
treatment: undefined, // treatment value is assigned later
|
|
33
|
-
label:
|
|
33
|
+
label: NOT_IN_SPLIT
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
package/src/evaluator/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Engine } from './Engine';
|
|
2
2
|
import { thenable } from '../utils/promise/thenable';
|
|
3
|
-
import
|
|
3
|
+
import { EXCEPTION, SPLIT_NOT_FOUND } from '../utils/labels';
|
|
4
4
|
import { CONTROL } from '../utils/constants';
|
|
5
5
|
import { ISplit, MaybeThenable } from '../dtos/types';
|
|
6
6
|
import { IStorageAsync, IStorageSync } from '../storages/types';
|
|
@@ -12,7 +12,7 @@ import { WARN_FLAGSET_WITHOUT_FLAGS } from '../logger/constants';
|
|
|
12
12
|
|
|
13
13
|
const treatmentException = {
|
|
14
14
|
treatment: CONTROL,
|
|
15
|
-
label:
|
|
15
|
+
label: EXCEPTION,
|
|
16
16
|
config: null
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -143,7 +143,7 @@ function getEvaluation(
|
|
|
143
143
|
): MaybeThenable<IEvaluationResult> {
|
|
144
144
|
let evaluation: MaybeThenable<IEvaluationResult> = {
|
|
145
145
|
treatment: CONTROL,
|
|
146
|
-
label:
|
|
146
|
+
label: SPLIT_NOT_FOUND,
|
|
147
147
|
config: null
|
|
148
148
|
};
|
|
149
149
|
|
|
@@ -151,7 +151,7 @@ function getEvaluation(
|
|
|
151
151
|
const split = Engine.parse(log, splitJSON, storage);
|
|
152
152
|
evaluation = split.getTreatment(key, attributes, evaluateFeature);
|
|
153
153
|
|
|
154
|
-
// If the storage is async and the evaluated
|
|
154
|
+
// If the storage is async and the evaluated flag uses segments or dependencies, evaluation is thenable
|
|
155
155
|
if (thenable(evaluation)) {
|
|
156
156
|
return evaluation.then(result => {
|
|
157
157
|
result.changeNumber = split.getChangeNumber();
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
1
|
+
export function allMatcherContext() {
|
|
3
2
|
|
|
4
|
-
export function allMatcherContext(log: ILogger) {
|
|
5
3
|
return function allMatcher(runtimeAttr: string): boolean {
|
|
6
|
-
log.debug(ENGINE_MATCHER_ALL);
|
|
7
|
-
|
|
8
4
|
return runtimeAttr != null;
|
|
9
5
|
};
|
|
10
6
|
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { IBetweenMatcherData } from '../../dtos/types';
|
|
2
|
-
import { ENGINE_MATCHER_BETWEEN } from '../../logger/constants';
|
|
3
|
-
import { ILogger } from '../../logger/types';
|
|
4
2
|
|
|
5
|
-
export function betweenMatcherContext(
|
|
6
|
-
return function betweenMatcher(runtimeAttr: number): boolean {
|
|
7
|
-
|
|
8
|
-
let isBetween = runtimeAttr >= ruleVO.start && runtimeAttr <= ruleVO.end;
|
|
3
|
+
export function betweenMatcherContext(ruleVO: IBetweenMatcherData) {
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
return function betweenMatcher(runtimeAttr: number): boolean {
|
|
6
|
+
const isBetween = runtimeAttr >= ruleVO.start && runtimeAttr <= ruleVO.end;
|
|
11
7
|
|
|
12
8
|
return isBetween;
|
|
13
9
|
};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
1
|
+
export function booleanMatcherContext(ruleAttr: boolean) {
|
|
3
2
|
|
|
4
|
-
export function booleanMatcherContext(log: ILogger, ruleAttr: boolean) {
|
|
5
3
|
return function booleanMatcher(runtimeAttr: boolean): boolean {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
log.debug(ENGINE_MATCHER_BOOLEAN, [ruleAttr, runtimeAttr]);
|
|
4
|
+
const booleanMatches = ruleAttr === runtimeAttr;
|
|
9
5
|
|
|
10
6
|
return booleanMatches;
|
|
11
7
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ENGINE_MATCHER_CONTAINS_ALL } from '../../logger/constants';
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
1
|
import { findIndex } from '../../utils/lang';
|
|
4
2
|
|
|
5
|
-
export function containsAllSetMatcherContext(
|
|
3
|
+
export function containsAllSetMatcherContext(ruleAttr: string[]) {
|
|
6
4
|
return function containsAllMatcher(runtimeAttr: string[]): boolean {
|
|
7
5
|
let containsAll = true;
|
|
8
6
|
|
|
@@ -15,8 +13,6 @@ export function containsAllSetMatcherContext(log: ILogger, ruleAttr: string[]) {
|
|
|
15
13
|
}
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
log.debug(ENGINE_MATCHER_CONTAINS_ALL, [runtimeAttr, ruleAttr, containsAll]);
|
|
19
|
-
|
|
20
16
|
return containsAll;
|
|
21
17
|
};
|
|
22
18
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ENGINE_MATCHER_CONTAINS_ANY } from '../../logger/constants';
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
1
|
import { findIndex } from '../../utils/lang';
|
|
4
2
|
|
|
5
|
-
export function containsAnySetMatcherContext(
|
|
3
|
+
export function containsAnySetMatcherContext(ruleAttr: string[]) {
|
|
6
4
|
return function containsAnyMatcher(runtimeAttr: string[]): boolean {
|
|
7
5
|
let containsAny = false;
|
|
8
6
|
|
|
@@ -10,8 +8,6 @@ export function containsAnySetMatcherContext(log: ILogger, ruleAttr: string[]) {
|
|
|
10
8
|
if (findIndex(runtimeAttr, e => e === ruleAttr[i]) >= 0) containsAny = true;
|
|
11
9
|
}
|
|
12
10
|
|
|
13
|
-
log.debug(ENGINE_MATCHER_CONTAINS_ANY, [runtimeAttr, ruleAttr, containsAny]);
|
|
14
|
-
|
|
15
11
|
return containsAny;
|
|
16
12
|
};
|
|
17
13
|
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { isString } from '../../utils/lang';
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
|
-
import { ENGINE_MATCHER_CONTAINS_STRING } from '../../logger/constants';
|
|
4
2
|
|
|
5
|
-
export function containsStringMatcherContext(
|
|
3
|
+
export function containsStringMatcherContext(ruleAttr: string[]) {
|
|
6
4
|
return function containsStringMatcher(runtimeAttr: string): boolean {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
log.debug(ENGINE_MATCHER_CONTAINS_STRING, [runtimeAttr, ruleAttr, contains]);
|
|
5
|
+
const contains = ruleAttr.some(e => isString(runtimeAttr) && runtimeAttr.indexOf(e) > -1);
|
|
10
6
|
|
|
11
7
|
return contains;
|
|
12
8
|
};
|
|
@@ -5,7 +5,7 @@ import { thenable } from '../../utils/promise/thenable';
|
|
|
5
5
|
import { IDependencyMatcherValue, IEvaluation, ISplitEvaluator } from '../types';
|
|
6
6
|
import { ENGINE_MATCHER_DEPENDENCY, ENGINE_MATCHER_DEPENDENCY_PRE } from '../../logger/constants';
|
|
7
7
|
|
|
8
|
-
export function dependencyMatcherContext(
|
|
8
|
+
export function dependencyMatcherContext({ split, treatments }: IDependencyMatcherData, storage: IStorageSync | IStorageAsync, log: ILogger) {
|
|
9
9
|
|
|
10
10
|
function checkTreatment(evaluation: IEvaluation, acceptableTreatments: string[], parentName: string) {
|
|
11
11
|
let matches = false;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
1
|
+
export function equalToMatcherContext(ruleAttr: number) {
|
|
3
2
|
|
|
4
|
-
export function equalToMatcherContext(log: ILogger, ruleAttr: number) {
|
|
5
3
|
return function equalToMatcher(runtimeAttr: number): boolean {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
log.debug(ENGINE_MATCHER_EQUAL, [runtimeAttr, ruleAttr, isEqual]);
|
|
4
|
+
const isEqual = runtimeAttr === ruleAttr;
|
|
9
5
|
|
|
10
6
|
return isEqual;
|
|
11
7
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ENGINE_MATCHER_EQUAL_TO_SET } from '../../logger/constants';
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
1
|
import { findIndex } from '../../utils/lang';
|
|
4
2
|
|
|
5
|
-
export function equalToSetMatcherContext(
|
|
3
|
+
export function equalToSetMatcherContext(ruleAttr: string[]) {
|
|
6
4
|
return function equalToSetMatcher(runtimeAttr: string[]): boolean {
|
|
7
5
|
// Length being the same is the first condition.
|
|
8
6
|
let isEqual = runtimeAttr.length === ruleAttr.length;
|
|
@@ -12,8 +10,6 @@ export function equalToSetMatcherContext(log: ILogger, ruleAttr: string[]) {
|
|
|
12
10
|
if (findIndex(ruleAttr, e => e === runtimeAttr[i]) < 0) isEqual = false;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
log.debug(ENGINE_MATCHER_EQUAL_TO_SET, [runtimeAttr, ruleAttr, isEqual]);
|
|
16
|
-
|
|
17
13
|
return isEqual;
|
|
18
14
|
};
|
|
19
15
|
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { ENGINE_MATCHER_ENDS_WITH } from '../../logger/constants';
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
1
|
import { endsWith } from '../../utils/lang';
|
|
4
2
|
|
|
5
|
-
export function endsWithMatcherContext(
|
|
3
|
+
export function endsWithMatcherContext(ruleAttr: string[]) {
|
|
6
4
|
return function endsWithMatcher(runtimeAttr: string): boolean {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
log.debug(ENGINE_MATCHER_ENDS_WITH, [runtimeAttr, ruleAttr, strEndsWith]);
|
|
5
|
+
const strEndsWith = ruleAttr.some(e => endsWith(runtimeAttr, e));
|
|
10
6
|
|
|
11
7
|
return strEndsWith;
|
|
12
8
|
};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
1
|
+
export function greaterThanEqualMatcherContext(ruleAttr: number) {
|
|
3
2
|
|
|
4
|
-
export function greaterThanEqualMatcherContext(log: ILogger, ruleAttr: number) {
|
|
5
3
|
return function greaterThanEqualMatcher(runtimeAttr: number): boolean {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
log.debug(ENGINE_MATCHER_GREATER, [runtimeAttr, ruleAttr, isGreaterThanEqual]);
|
|
4
|
+
const isGreaterThanEqual = runtimeAttr >= ruleAttr;
|
|
9
5
|
|
|
10
6
|
return isGreaterThanEqual;
|
|
11
7
|
};
|
|
@@ -61,6 +61,6 @@ export function matcherFactory(log: ILogger, matcherDto: IMatcherDto, storage?:
|
|
|
61
61
|
|
|
62
62
|
let matcherFn;
|
|
63
63
|
// @ts-ignore
|
|
64
|
-
if (matchers[type]) matcherFn = matchers[type](
|
|
64
|
+
if (matchers[type]) matcherFn = matchers[type](value, storage, log); // There is no index-out-of-bound exception in JavaScript
|
|
65
65
|
return matcherFn;
|
|
66
66
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
1
|
+
export function lessThanEqualMatcherContext(ruleAttr: number) {
|
|
3
2
|
|
|
4
|
-
export function lessThanEqualMatcherContext(log: ILogger, ruleAttr: number) {
|
|
5
3
|
return function lessThanEqualMatcher(runtimeAttr: number): boolean {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
log.debug(ENGINE_MATCHER_LESS, [runtimeAttr, ruleAttr, isLessThanEqual]);
|
|
4
|
+
const isLessThanEqual = runtimeAttr <= ruleAttr;
|
|
9
5
|
|
|
10
6
|
return isLessThanEqual;
|
|
11
7
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { findIndex } from '../../utils/lang';
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
|
-
import { ENGINE_MATCHER_PART_OF } from '../../logger/constants';
|
|
4
2
|
|
|
5
|
-
export function partOfSetMatcherContext(
|
|
3
|
+
export function partOfSetMatcherContext(ruleAttr: string[]) {
|
|
6
4
|
return function partOfMatcher(runtimeAttr: string[]): boolean {
|
|
7
5
|
// To be part of the length should be minor or equal.
|
|
8
6
|
let isPartOf = runtimeAttr.length <= ruleAttr.length;
|
|
@@ -12,8 +10,6 @@ export function partOfSetMatcherContext(log: ILogger, ruleAttr: string[]) {
|
|
|
12
10
|
if (findIndex(ruleAttr, e => e === runtimeAttr[i]) < 0) isPartOf = false;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
log.debug(ENGINE_MATCHER_PART_OF, [runtimeAttr, ruleAttr, isPartOf]);
|
|
16
|
-
|
|
17
13
|
return isPartOf;
|
|
18
14
|
};
|
|
19
15
|
}
|