@splitsoftware/splitio-commons 1.13.2-rc.5 → 1.13.2-rc.6
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/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 +3 -5
- 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 +5 -8
- package/cjs/evaluator/matchersTransform/whitelist.js +1 -2
- package/cjs/evaluator/parser/index.js +8 -4
- package/cjs/logger/constants.js +4 -24
- package/cjs/logger/index.js +8 -1
- package/cjs/logger/messages/debug.js +4 -24
- package/cjs/logger/messages/warn.js +1 -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 +4 -6
- 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 +5 -8
- package/esm/evaluator/matchersTransform/whitelist.js +1 -2
- package/esm/evaluator/parser/index.js +9 -5
- package/esm/logger/constants.js +1 -21
- package/esm/logger/index.js +9 -2
- package/esm/logger/messages/debug.js +4 -24
- package/esm/logger/messages/warn.js +1 -1
- 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 +4 -8
- 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 -9
- package/src/evaluator/matchersTransform/whitelist.ts +1 -2
- package/src/evaluator/parser/index.ts +10 -5
- package/src/evaluator/types.ts +1 -2
- package/src/logger/constants.ts +1 -21
- package/src/logger/index.ts +8 -2
- package/src/logger/messages/debug.ts +4 -24
- package/src/logger/messages/warn.ts +1 -1
- 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 +1 -1
- package/types/evaluator/types.d.ts +1 -2
- package/types/logger/constants.d.ts +1 -21
- package/cjs/evaluator/matchersTransform/set.js +0 -10
- package/esm/evaluator/matchersTransform/set.js +0 -6
- package/src/evaluator/matchersTransform/set.ts +0 -8
|
@@ -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.ENGINE_MATCHER_BETWEEN, c.LOG_PREFIX_ENGINE_MATCHER + '[betweenMatcher] is %s between %s and %s? %s'],
|
|
11
|
-
[c.ENGINE_MATCHER_BOOLEAN, c.LOG_PREFIX_ENGINE_MATCHER + '[booleanMatcher] %s === %s'],
|
|
12
|
-
[c.ENGINE_MATCHER_CONTAINS_ALL, c.LOG_PREFIX_ENGINE_MATCHER + '[containsAllMatcher] %s contains all elements of %s? %s'],
|
|
13
|
-
[c.ENGINE_MATCHER_CONTAINS_ANY, c.LOG_PREFIX_ENGINE_MATCHER + '[containsAnyMatcher] %s contains at least an element of %s? %s'],
|
|
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.'],
|
|
9
|
+
[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
10
|
[c.ENGINE_MATCHER_DEPENDENCY_PRE, c.LOG_PREFIX_ENGINE_MATCHER + '[dependencyMatcher] will evaluate parent feature flag: "%s" with key: %s %s'],
|
|
17
|
-
[c.
|
|
18
|
-
[c.
|
|
19
|
-
[c.
|
|
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'],
|
|
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/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 feature flag is type IN_SPLIT_TREATMENT or IN_SEGMENT, 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
|
}
|
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
import { MaybeThenable } from '../../dtos/types';
|
|
2
2
|
import { ISegmentsCacheBase } from '../../storages/types';
|
|
3
|
-
import { ILogger } from '../../logger/types';
|
|
4
3
|
import { thenable } from '../../utils/promise/thenable';
|
|
5
|
-
import { ENGINE_MATCHER_SEGMENT } from '../../logger/constants';
|
|
6
4
|
|
|
7
|
-
export function segmentMatcherContext(
|
|
5
|
+
export function segmentMatcherContext(segmentName: string, storage: { segments: ISegmentsCacheBase }) {
|
|
8
6
|
|
|
9
7
|
return function segmentMatcher(key: string): MaybeThenable<boolean> {
|
|
10
8
|
const isInSegment = storage.segments.isInSegment(segmentName, key);
|
|
11
9
|
|
|
12
10
|
if (thenable(isInSegment)) {
|
|
13
11
|
isInSegment.then(result => {
|
|
14
|
-
log.debug(ENGINE_MATCHER_SEGMENT, [segmentName, key, isInSegment]);
|
|
15
|
-
|
|
16
12
|
return result;
|
|
17
13
|
});
|
|
18
|
-
} else {
|
|
19
|
-
log.debug(ENGINE_MATCHER_SEGMENT, [segmentName, key, isInSegment]);
|
|
20
14
|
}
|
|
21
15
|
|
|
22
16
|
return isInSegment;
|
|
23
17
|
};
|
|
24
|
-
|
|
25
18
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { IBetweenStringMatcherData } from '../../dtos/types';
|
|
2
|
-
import { ENGINE_MATCHER_BETWEEN_SEMVER } from '../../logger/constants';
|
|
3
|
-
import { ILogger } from '../../logger/types';
|
|
4
2
|
import { Semver } from '../../utils/Semver';
|
|
5
3
|
|
|
6
|
-
export function betweenSemverMatcherContext(
|
|
4
|
+
export function betweenSemverMatcherContext(ruleAttr: IBetweenStringMatcherData) {
|
|
7
5
|
const startSemver = new Semver(ruleAttr.start);
|
|
8
6
|
const endSemver = new Semver(ruleAttr.end);
|
|
9
7
|
|
|
@@ -12,8 +10,6 @@ export function betweenSemverMatcherContext(log: ILogger, ruleAttr: IBetweenStri
|
|
|
12
10
|
|
|
13
11
|
const isBetween = startSemver.compare(runtimeSemver) <= 0 && endSemver.compare(runtimeSemver) >= 0;
|
|
14
12
|
|
|
15
|
-
log.debug(ENGINE_MATCHER_BETWEEN_SEMVER, [runtimeAttr, ruleAttr.start, ruleAttr.end, isBetween]);
|
|
16
|
-
|
|
17
13
|
return isBetween;
|
|
18
14
|
};
|
|
19
15
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ENGINE_MATCHER_EQUAL_SEMVER } from '../../logger/constants';
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
1
|
import { Semver } from '../../utils/Semver';
|
|
4
2
|
|
|
5
|
-
export function equalToSemverMatcherContext(
|
|
3
|
+
export function equalToSemverMatcherContext(ruleAttr: string) {
|
|
6
4
|
const ruleSemver = new Semver(ruleAttr);
|
|
7
5
|
|
|
8
6
|
return function equalToSemverMatcher(runtimeAttr: string): boolean {
|
|
@@ -10,8 +8,6 @@ export function equalToSemverMatcherContext(log: ILogger, ruleAttr: string) {
|
|
|
10
8
|
|
|
11
9
|
const isEqual = ruleSemver.version === runtimeSemver.version;
|
|
12
10
|
|
|
13
|
-
log.debug(ENGINE_MATCHER_EQUAL_SEMVER, [runtimeAttr, ruleAttr, isEqual]);
|
|
14
|
-
|
|
15
11
|
return isEqual;
|
|
16
12
|
};
|
|
17
13
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ENGINE_MATCHER_GREATER_SEMVER } from '../../logger/constants';
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
1
|
import { Semver } from '../../utils/Semver';
|
|
4
2
|
|
|
5
|
-
export function greaterThanEqualToSemverMatcherContext(
|
|
3
|
+
export function greaterThanEqualToSemverMatcherContext(ruleAttr: string) {
|
|
6
4
|
const ruleSemver = new Semver(ruleAttr);
|
|
7
5
|
|
|
8
6
|
return function greaterThanEqualToSemverMatcher(runtimeAttr: string): boolean {
|
|
@@ -10,8 +8,6 @@ export function greaterThanEqualToSemverMatcherContext(log: ILogger, ruleAttr: s
|
|
|
10
8
|
|
|
11
9
|
const isGreaterThanEqual = runtimeSemver.compare(ruleSemver) >= 0;
|
|
12
10
|
|
|
13
|
-
log.debug(ENGINE_MATCHER_GREATER_SEMVER, [runtimeAttr, ruleAttr, isGreaterThanEqual]);
|
|
14
|
-
|
|
15
11
|
return isGreaterThanEqual;
|
|
16
12
|
};
|
|
17
13
|
}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
1
|
+
import { _Set } from '../../utils/lang/sets';
|
|
3
2
|
import { Semver } from '../../utils/Semver';
|
|
4
|
-
import { ENGINE_MATCHER_IN_LIST_SEMVER } from '../../logger/constants';
|
|
5
3
|
|
|
6
|
-
export function inListSemverMatcherContext(
|
|
4
|
+
export function inListSemverMatcherContext(ruleAttr: string[]) {
|
|
7
5
|
// @TODO move eventually to `matchersTransform` and validate for all matchers
|
|
8
|
-
if (!ruleAttr || ruleAttr.
|
|
6
|
+
if (!ruleAttr || ruleAttr.length === 0) throw new Error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type');
|
|
9
7
|
|
|
10
|
-
const listOfSemvers = new _Set(
|
|
8
|
+
const listOfSemvers = new _Set(ruleAttr.map((version) => new Semver(version).version));
|
|
11
9
|
|
|
12
10
|
return function inListSemverMatcher(runtimeAttr: string): boolean {
|
|
13
11
|
const runtimeSemver = new Semver(runtimeAttr).version;
|
|
14
12
|
|
|
15
13
|
const isInList = listOfSemvers.has(runtimeSemver);
|
|
16
14
|
|
|
17
|
-
log.debug(ENGINE_MATCHER_IN_LIST_SEMVER, [runtimeAttr, setToArray(ruleAttr).join(','), isInList]);
|
|
18
|
-
|
|
19
15
|
return isInList;
|
|
20
16
|
};
|
|
21
17
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ENGINE_MATCHER_LESS_SEMVER } from '../../logger/constants';
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
1
|
import { Semver } from '../../utils/Semver';
|
|
4
2
|
|
|
5
|
-
export function lessThanEqualToSemverMatcherContext(
|
|
3
|
+
export function lessThanEqualToSemverMatcherContext(ruleAttr: string) {
|
|
6
4
|
const ruleSemver = new Semver(ruleAttr);
|
|
7
5
|
|
|
8
6
|
return function lessThanEqualToSemverMatcher(runtimeAttr: string): boolean {
|
|
@@ -10,8 +8,6 @@ export function lessThanEqualToSemverMatcherContext(log: ILogger, ruleAttr: stri
|
|
|
10
8
|
|
|
11
9
|
const isLessThanEqual = runtimeSemver.compare(ruleSemver) <= 0;
|
|
12
10
|
|
|
13
|
-
log.debug(ENGINE_MATCHER_LESS_SEMVER, [runtimeAttr, ruleAttr, isLessThanEqual]);
|
|
14
|
-
|
|
15
11
|
return isLessThanEqual;
|
|
16
12
|
};
|
|
17
13
|
}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
|
-
|
|
4
|
-
export function stringMatcherContext(log: ILogger, ruleAttr: string) {
|
|
1
|
+
export function stringMatcherContext(ruleAttr: string) {
|
|
5
2
|
const regex = new RegExp(ruleAttr);
|
|
6
3
|
|
|
7
4
|
return function stringMatcher(runtimeAttr: string): boolean {
|
|
8
5
|
const regexMatches = regex.test(runtimeAttr);
|
|
9
6
|
|
|
10
|
-
log.debug(ENGINE_MATCHER_STRING, [runtimeAttr, ruleAttr, regexMatches ? 'yes' : 'no']);
|
|
11
|
-
|
|
12
7
|
return regexMatches;
|
|
13
8
|
};
|
|
14
9
|
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { ENGINE_MATCHER_STARTS_WITH } from '../../logger/constants';
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
1
|
import { startsWith } from '../../utils/lang';
|
|
4
2
|
|
|
5
|
-
export function startsWithMatcherContext(
|
|
3
|
+
export function startsWithMatcherContext(ruleAttr: string[]) {
|
|
6
4
|
return function startsWithMatcher(runtimeAttr: string): boolean {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
log.debug(ENGINE_MATCHER_STARTS_WITH, [runtimeAttr, ruleAttr, matches]);
|
|
5
|
+
const matches = ruleAttr.some(e => startsWith(runtimeAttr, e));
|
|
10
6
|
|
|
11
7
|
return matches;
|
|
12
8
|
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
3
|
-
import { ENGINE_MATCHER_WHITELIST } from '../../logger/constants';
|
|
1
|
+
import { _Set } from '../../utils/lang/sets';
|
|
4
2
|
|
|
5
|
-
export function whitelistMatcherContext(
|
|
6
|
-
|
|
7
|
-
let isInWhitelist = ruleAttr.has(runtimeAttr);
|
|
3
|
+
export function whitelistMatcherContext(ruleAttr: string[]) {
|
|
4
|
+
const whitelistSet = new _Set(ruleAttr);
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
return function whitelistMatcher(runtimeAttr: string): boolean {
|
|
7
|
+
const isInWhitelist = whitelistSet.has(runtimeAttr);
|
|
10
8
|
|
|
11
9
|
return isInWhitelist;
|
|
12
10
|
};
|
|
@@ -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
|
import { IBetweenMatcherData, IInSegmentMatcherData, ISplitMatcher, IUnaryNumericMatcherData } from '../../dtos/types';
|
|
@@ -32,15 +31,10 @@ export function matchersTransform(matchers: ISplitMatcher[]): IMatcherDto[] {
|
|
|
32
31
|
let type = matcherTypesMapper(matcherType);
|
|
33
32
|
// As default input data type we use string (even for ALL_KEYS)
|
|
34
33
|
let dataType = matcherDataTypes.STRING;
|
|
35
|
-
let value = undefined;
|
|
34
|
+
let value: IMatcherDto['value'] = undefined;
|
|
36
35
|
|
|
37
36
|
if (type === matcherTypes.IN_SEGMENT) {
|
|
38
37
|
value = segmentTransform(userDefinedSegmentMatcherData as IInSegmentMatcherData);
|
|
39
|
-
} else if (
|
|
40
|
-
type === matcherTypes.WHITELIST ||
|
|
41
|
-
type === matcherTypes.IN_LIST_SEMVER
|
|
42
|
-
) {
|
|
43
|
-
value = whitelistTransform(whitelistMatcherData);
|
|
44
38
|
} else if (type === matcherTypes.EQUAL_TO) {
|
|
45
39
|
value = numericTransform(unaryNumericMatcherData as IUnaryNumericMatcherData);
|
|
46
40
|
dataType = matcherDataTypes.NUMBER;
|
|
@@ -75,14 +69,16 @@ export function matchersTransform(matchers: ISplitMatcher[]): IMatcherDto[] {
|
|
|
75
69
|
type === matcherTypes.CONTAINS_ALL_OF_SET ||
|
|
76
70
|
type === matcherTypes.PART_OF_SET
|
|
77
71
|
) {
|
|
78
|
-
value =
|
|
72
|
+
value = whitelistTransform(whitelistMatcherData);
|
|
79
73
|
dataType = matcherDataTypes.SET;
|
|
80
74
|
} else if (
|
|
75
|
+
type === matcherTypes.WHITELIST ||
|
|
76
|
+
type === matcherTypes.IN_LIST_SEMVER ||
|
|
81
77
|
type === matcherTypes.STARTS_WITH ||
|
|
82
78
|
type === matcherTypes.ENDS_WITH ||
|
|
83
79
|
type === matcherTypes.CONTAINS_STRING
|
|
84
80
|
) {
|
|
85
|
-
value =
|
|
81
|
+
value = whitelistTransform(whitelistMatcherData);
|
|
86
82
|
} else if (type === matcherTypes.IN_SPLIT_TREATMENT) {
|
|
87
83
|
value = dependencyMatcherData;
|
|
88
84
|
dataType = matcherDataTypes.NOT_SPECIFIED;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ISplitMatcher } from '../../dtos/types';
|
|
2
|
-
import { _Set } from '../../utils/lang/sets';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Extract whitelist as a set. Used by 'WHITELIST' matcher.
|
|
6
5
|
*/
|
|
7
6
|
export function whitelistTransform(whitelistObject: ISplitMatcher['whitelistMatcherData']) {
|
|
8
|
-
return
|
|
7
|
+
return whitelistObject && whitelistObject.whitelist;
|
|
9
8
|
}
|