@splitsoftware/splitio-commons 1.13.2-rc.3 → 1.13.2-rc.4
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/matchers/semver_eq.js +2 -1
- package/cjs/evaluator/matchers/semver_gte.js +2 -1
- package/cjs/evaluator/matchers/semver_lte.js +2 -1
- package/cjs/evaluator/matchers/string.js +2 -9
- package/cjs/evaluator/parser/index.js +27 -10
- package/cjs/logger/constants.js +4 -4
- package/cjs/logger/messages/debug.js +0 -1
- package/cjs/logger/messages/error.js +1 -0
- package/cjs/utils/Semver.js +3 -0
- package/esm/evaluator/matchers/semver_eq.js +2 -1
- package/esm/evaluator/matchers/semver_gte.js +2 -1
- package/esm/evaluator/matchers/semver_lte.js +2 -1
- package/esm/evaluator/matchers/string.js +3 -10
- package/esm/evaluator/parser/index.js +27 -10
- package/esm/logger/constants.js +1 -1
- package/esm/logger/messages/debug.js +0 -1
- package/esm/logger/messages/error.js +1 -0
- package/esm/utils/Semver.js +3 -0
- package/package.json +1 -1
- package/src/evaluator/matchers/semver_between.ts +1 -3
- package/src/evaluator/matchers/semver_eq.ts +3 -2
- package/src/evaluator/matchers/semver_gte.ts +3 -2
- package/src/evaluator/matchers/semver_lte.ts +3 -2
- package/src/evaluator/matchers/string.ts +4 -12
- package/src/evaluator/parser/index.ts +20 -8
- package/src/logger/constants.ts +1 -1
- package/src/logger/messages/debug.ts +0 -1
- package/src/logger/messages/error.ts +1 -0
- package/src/utils/Semver.ts +4 -0
- package/types/evaluator/matchersTransform/string.d.ts +7 -0
- package/types/logger/constants.d.ts +1 -1
|
@@ -5,7 +5,8 @@ var Semver_1 = require("../../utils/Semver");
|
|
|
5
5
|
function equalToSemverMatcherContext(log, ruleAttr) {
|
|
6
6
|
var ruleSemver = new Semver_1.Semver(ruleAttr);
|
|
7
7
|
return function equalToSemverMatcher(runtimeAttr) {
|
|
8
|
-
var
|
|
8
|
+
var runtimeSemver = new Semver_1.Semver(runtimeAttr);
|
|
9
|
+
var isEqual = ruleSemver.version === runtimeSemver.version;
|
|
9
10
|
return isEqual;
|
|
10
11
|
};
|
|
11
12
|
}
|
|
@@ -5,7 +5,8 @@ var Semver_1 = require("../../utils/Semver");
|
|
|
5
5
|
function greaterThanEqualToSemverMatcherContext(log, ruleAttr) {
|
|
6
6
|
var ruleSemver = new Semver_1.Semver(ruleAttr);
|
|
7
7
|
return function greaterThanEqualToSemverMatcher(runtimeAttr) {
|
|
8
|
-
var
|
|
8
|
+
var runtimeSemver = new Semver_1.Semver(runtimeAttr);
|
|
9
|
+
var isGreaterThanEqual = runtimeSemver.compare(ruleSemver) >= 0;
|
|
9
10
|
return isGreaterThanEqual;
|
|
10
11
|
};
|
|
11
12
|
}
|
|
@@ -5,7 +5,8 @@ var Semver_1 = require("../../utils/Semver");
|
|
|
5
5
|
function lessThanEqualToSemverMatcherContext(log, ruleAttr) {
|
|
6
6
|
var ruleSemver = new Semver_1.Semver(ruleAttr);
|
|
7
7
|
return function lessThanEqualToSemverMatcher(runtimeAttr) {
|
|
8
|
-
var
|
|
8
|
+
var runtimeSemver = new Semver_1.Semver(runtimeAttr);
|
|
9
|
+
var isLessThenEqual = runtimeSemver.compare(ruleSemver) <= 0;
|
|
9
10
|
return isLessThenEqual;
|
|
10
11
|
};
|
|
11
12
|
}
|
|
@@ -3,16 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.stringMatcherContext = void 0;
|
|
4
4
|
var constants_1 = require("../../logger/constants");
|
|
5
5
|
function stringMatcherContext(log, ruleAttr) {
|
|
6
|
+
var regex = new RegExp(ruleAttr);
|
|
6
7
|
return function stringMatcher(runtimeAttr) {
|
|
7
|
-
var
|
|
8
|
-
try {
|
|
9
|
-
re = new RegExp(ruleAttr);
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
12
|
-
log.debug(constants_1.ENGINE_MATCHER_STRING_INVALID, [ruleAttr]);
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
var regexMatches = re.test(runtimeAttr);
|
|
8
|
+
var regexMatches = regex.test(runtimeAttr);
|
|
16
9
|
log.debug(constants_1.ENGINE_MATCHER_STRING, [runtimeAttr, ruleAttr, regexMatches ? 'yes' : 'no']);
|
|
17
10
|
return regexMatches;
|
|
18
11
|
};
|
|
@@ -9,24 +9,37 @@ var condition_1 = require("../condition");
|
|
|
9
9
|
var ifelseif_1 = require("../combiners/ifelseif");
|
|
10
10
|
var and_1 = require("../combiners/and");
|
|
11
11
|
var thenable_1 = require("../../utils/promise/thenable");
|
|
12
|
+
var constants_1 = require("../../logger/constants");
|
|
12
13
|
function parser(log, conditions, storage) {
|
|
13
14
|
var predicates = [];
|
|
14
|
-
|
|
15
|
+
var _loop_1 = function (i) {
|
|
15
16
|
var _a = conditions[i], matcherGroup = _a.matcherGroup, partitions = _a.partitions, label = _a.label, conditionType = _a.conditionType;
|
|
16
17
|
// transform data structure
|
|
17
18
|
var matchers = (0, matchersTransform_1.matchersTransform)(matcherGroup.matchers);
|
|
18
19
|
// create a set of pure functions from the matcher's dto
|
|
19
|
-
var expressions = matchers.map(function (matcherDto) {
|
|
20
|
-
var matcher
|
|
20
|
+
var expressions = matchers.map(function (matcherDto, index) {
|
|
21
|
+
var matcher;
|
|
22
|
+
try {
|
|
23
|
+
matcher = (0, matchers_1.matcherFactory)(log, matcherDto, storage);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
log.error(constants_1.ENGINE_MATCHER_ERROR, [matcherGroup.matchers[index].matcherType, error]);
|
|
27
|
+
}
|
|
21
28
|
// Evaluator function.
|
|
22
29
|
return function (key, attributes, splitEvaluator) {
|
|
23
30
|
var value = (0, value_1.sanitizeValue)(log, key, matcherDto, attributes);
|
|
24
|
-
var result =
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
var result = false;
|
|
32
|
+
if (value !== undefined && matcher) {
|
|
33
|
+
try {
|
|
34
|
+
result = matcher(value, splitEvaluator);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
log.error(constants_1.ENGINE_MATCHER_ERROR, [matcherGroup.matchers[index].matcherType, error]);
|
|
38
|
+
}
|
|
28
39
|
}
|
|
29
|
-
// @ts-ignore
|
|
40
|
+
if ((0, thenable_1.thenable)(result)) { // @ts-ignore
|
|
41
|
+
return result.then(function (res) { return Boolean(res ^ matcherDto.negate); });
|
|
42
|
+
} // @ts-ignore
|
|
30
43
|
return Boolean(result ^ matcherDto.negate);
|
|
31
44
|
};
|
|
32
45
|
});
|
|
@@ -34,10 +47,14 @@ function parser(log, conditions, storage) {
|
|
|
34
47
|
if (expressions.length === 0) {
|
|
35
48
|
// reset any data collected during parsing
|
|
36
49
|
predicates = [];
|
|
37
|
-
|
|
38
|
-
break;
|
|
50
|
+
return "break";
|
|
39
51
|
}
|
|
40
52
|
predicates.push((0, condition_1.conditionContext)(log, (0, and_1.andCombinerContext)(log, expressions), treatments_1.Treatments.parse(partitions), label, conditionType));
|
|
53
|
+
};
|
|
54
|
+
for (var i = 0; i < conditions.length; i++) {
|
|
55
|
+
var state_1 = _loop_1(i);
|
|
56
|
+
if (state_1 === "break")
|
|
57
|
+
break;
|
|
41
58
|
}
|
|
42
59
|
// Instanciate evaluator given the set of conditions using if else if logic
|
|
43
60
|
return (0, ifelseif_1.ifElseIfCombinerContext)(log, predicates);
|
package/cjs/logger/constants.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SYNC_SPLITS_FETCH_RETRY = exports.POLLING_STOP = exports.POLLING_START = exports.POLLING_SMART_PAUSING = exports.NEW_FACTORY = exports.NEW_SHARED_CLIENT = exports.IMPRESSION_QUEUEING = exports.IMPRESSION = exports.CLIENT_READY = exports.CLIENT_READY_FROM_CACHE = exports.SETTINGS_SPLITS_FILTER = exports.SYNC_TASK_STOP = exports.SYNC_TASK_EXECUTE = exports.SYNC_TASK_START = exports.STREAMING_NEW_MESSAGE = exports.SYNC_SPLITS_SEGMENTS = exports.SYNC_SPLITS_REMOVED = exports.SYNC_SPLITS_NEW = exports.SYNC_SPLITS_FETCH = exports.SYNC_OFFLINE_DATA = exports.RETRIEVE_MANAGER = exports.RETRIEVE_CLIENT_EXISTING = exports.RETRIEVE_CLIENT_DEFAULT = exports.CLEANUP_DEREGISTERING = exports.CLEANUP_REGISTERING = exports.ENGINE_SANITIZE = exports.ENGINE_VALUE = exports.ENGINE_MATCHER_WHITELIST = exports.ENGINE_MATCHER_STARTS_WITH = exports.
|
|
4
|
-
exports.ERROR_STREAMING_SSE = exports.ERROR_SYNC_OFFLINE_LOADING = exports.ERROR_CLIENT_CANNOT_GET_READY = exports.ERROR_CLIENT_LISTENER = exports.ERROR_LOGLEVEL_INVALID = exports.ERROR_ENGINE_COMBINER_IFELSEIF = exports.WARN_FLAGSET_WITHOUT_FLAGS = exports.WARN_FLAGSET_NOT_CONFIGURED = exports.WARN_LOWERCASE_FLAGSET = exports.WARN_INVALID_FLAGSET = exports.STREAMING_PARSING_SPLIT_UPDATE = exports.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = exports.WARN_SDK_KEY = exports.WARN_SPLITS_FILTER_EMPTY = exports.WARN_SPLITS_FILTER_INVALID = exports.WARN_SPLITS_FILTER_IGNORED = exports.WARN_INTEGRATION_INVALID = exports.WARN_NOT_EXISTENT_TT = exports.WARN_LOWERCASE_TRAFFIC_TYPE = exports.WARN_NOT_EXISTENT_SPLIT = exports.WARN_TRIMMING = exports.WARN_CONVERTING = exports.WARN_TRIMMING_PROPERTIES = exports.WARN_SETTING_NULL = exports.SUBMITTERS_PUSH_RETRY = exports.SUBMITTERS_PUSH_FAILS = exports.STREAMING_FALLBACK = exports.STREAMING_PARSING_MESSAGE_FAILS = exports.STREAMING_PARSING_ERROR_FAILS = exports.SYNC_SPLITS_FETCH_FAILS = exports.SYNC_MYSEGMENTS_FETCH_RETRY = exports.CLIENT_NOT_READY = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = exports.ENGINE_VALUE_INVALID = exports.USER_CONSENT_INITIAL = exports.USER_CONSENT_NOT_UPDATED = exports.USER_CONSENT_UPDATED = exports.IMPRESSIONS_TRACKER_SUCCESS = exports.EVENTS_TRACKER_SUCCESS = exports.SYNC_STOP_POLLING = exports.SYNC_CONTINUE_POLLING = exports.SYNC_START_POLLING = exports.SUBMITTERS_PUSH = exports.SUBMITTERS_PUSH_FULL_QUEUE = exports.STREAMING_DISCONNECTING = exports.STREAMING_DISABLED = exports.STREAMING_CONNECTING = exports.STREAMING_RECONNECT =
|
|
5
|
-
exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ERROR_SETS_FILTER_EXCLUSIVE = exports.ERROR_TOO_MANY_SETS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN = exports.ERROR_STORAGE_INVALID = exports.ERROR_LOCALHOST_MODULE_REQUIRED = exports.ERROR_HTTP = exports.ERROR_INVALID_CONFIG_PARAM = exports.ERROR_EMPTY_ARRAY = exports.ERROR_EMPTY = exports.ERROR_INVALID = exports.ERROR_INVALID_KEY_OBJECT = exports.ERROR_TOO_LONG = exports.ERROR_NULL = exports.ERROR_CLIENT_DESTROYED = exports.ERROR_NOT_FINITE = exports.ERROR_SIZE_EXCEEDED = exports.ERROR_NOT_PLAIN_OBJECT = exports.ERROR_EVENT_TYPE_FORMAT = exports.ERROR_EVENTS_TRACKER = exports.ERROR_IMPRESSIONS_LISTENER = exports.ERROR_IMPRESSIONS_TRACKER =
|
|
3
|
+
exports.STREAMING_REFRESH_TOKEN = exports.SYNC_SPLITS_FETCH_RETRY = exports.POLLING_STOP = exports.POLLING_START = exports.POLLING_SMART_PAUSING = exports.NEW_FACTORY = exports.NEW_SHARED_CLIENT = exports.IMPRESSION_QUEUEING = exports.IMPRESSION = exports.CLIENT_READY = exports.CLIENT_READY_FROM_CACHE = exports.SETTINGS_SPLITS_FILTER = exports.SYNC_TASK_STOP = exports.SYNC_TASK_EXECUTE = exports.SYNC_TASK_START = exports.STREAMING_NEW_MESSAGE = exports.SYNC_SPLITS_SEGMENTS = exports.SYNC_SPLITS_REMOVED = exports.SYNC_SPLITS_NEW = exports.SYNC_SPLITS_FETCH = exports.SYNC_OFFLINE_DATA = exports.RETRIEVE_MANAGER = exports.RETRIEVE_CLIENT_EXISTING = exports.RETRIEVE_CLIENT_DEFAULT = exports.CLEANUP_DEREGISTERING = exports.CLEANUP_REGISTERING = exports.ENGINE_SANITIZE = exports.ENGINE_VALUE = exports.ENGINE_MATCHER_WHITELIST = exports.ENGINE_MATCHER_STARTS_WITH = exports.ENGINE_MATCHER_STRING = exports.ENGINE_MATCHER_SEGMENT = exports.ENGINE_MATCHER_PART_OF = exports.ENGINE_MATCHER_LESS = exports.ENGINE_MATCHER_GREATER = exports.ENGINE_MATCHER_ENDS_WITH = exports.ENGINE_MATCHER_EQUAL_TO_SET = exports.ENGINE_MATCHER_EQUAL = exports.ENGINE_MATCHER_DEPENDENCY_PRE = exports.ENGINE_MATCHER_DEPENDENCY = exports.ENGINE_MATCHER_CONTAINS_STRING = exports.ENGINE_MATCHER_CONTAINS_ANY = exports.ENGINE_MATCHER_CONTAINS_ALL = exports.ENGINE_MATCHER_BOOLEAN = exports.ENGINE_MATCHER_BETWEEN = exports.ENGINE_MATCHER_ALL = exports.ENGINE_BUCKET = exports.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = exports.ENGINE_COMBINER_IFELSEIF = exports.ENGINE_COMBINER_AND = void 0;
|
|
4
|
+
exports.ERROR_STREAMING_AUTH = exports.ERROR_STREAMING_SSE = exports.ERROR_SYNC_OFFLINE_LOADING = exports.ERROR_CLIENT_CANNOT_GET_READY = exports.ERROR_CLIENT_LISTENER = exports.ERROR_LOGLEVEL_INVALID = exports.ERROR_ENGINE_COMBINER_IFELSEIF = exports.WARN_FLAGSET_WITHOUT_FLAGS = exports.WARN_FLAGSET_NOT_CONFIGURED = exports.WARN_LOWERCASE_FLAGSET = exports.WARN_INVALID_FLAGSET = exports.STREAMING_PARSING_SPLIT_UPDATE = exports.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = exports.WARN_SDK_KEY = exports.WARN_SPLITS_FILTER_EMPTY = exports.WARN_SPLITS_FILTER_INVALID = exports.WARN_SPLITS_FILTER_IGNORED = exports.WARN_INTEGRATION_INVALID = exports.WARN_NOT_EXISTENT_TT = exports.WARN_LOWERCASE_TRAFFIC_TYPE = exports.WARN_NOT_EXISTENT_SPLIT = exports.WARN_TRIMMING = exports.WARN_CONVERTING = exports.WARN_TRIMMING_PROPERTIES = exports.WARN_SETTING_NULL = exports.SUBMITTERS_PUSH_RETRY = exports.SUBMITTERS_PUSH_FAILS = exports.STREAMING_FALLBACK = exports.STREAMING_PARSING_MESSAGE_FAILS = exports.STREAMING_PARSING_ERROR_FAILS = exports.SYNC_SPLITS_FETCH_FAILS = exports.SYNC_MYSEGMENTS_FETCH_RETRY = exports.CLIENT_NOT_READY = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = exports.ENGINE_VALUE_INVALID = exports.USER_CONSENT_INITIAL = exports.USER_CONSENT_NOT_UPDATED = exports.USER_CONSENT_UPDATED = exports.IMPRESSIONS_TRACKER_SUCCESS = exports.EVENTS_TRACKER_SUCCESS = exports.SYNC_STOP_POLLING = exports.SYNC_CONTINUE_POLLING = exports.SYNC_START_POLLING = exports.SUBMITTERS_PUSH = exports.SUBMITTERS_PUSH_FULL_QUEUE = exports.STREAMING_DISCONNECTING = exports.STREAMING_DISABLED = exports.STREAMING_CONNECTING = exports.STREAMING_RECONNECT = void 0;
|
|
5
|
+
exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ENGINE_MATCHER_ERROR = exports.ERROR_SETS_FILTER_EXCLUSIVE = exports.ERROR_TOO_MANY_SETS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN = exports.ERROR_STORAGE_INVALID = exports.ERROR_LOCALHOST_MODULE_REQUIRED = exports.ERROR_HTTP = exports.ERROR_INVALID_CONFIG_PARAM = exports.ERROR_EMPTY_ARRAY = exports.ERROR_EMPTY = exports.ERROR_INVALID = exports.ERROR_INVALID_KEY_OBJECT = exports.ERROR_TOO_LONG = exports.ERROR_NULL = exports.ERROR_CLIENT_DESTROYED = exports.ERROR_NOT_FINITE = exports.ERROR_SIZE_EXCEEDED = exports.ERROR_NOT_PLAIN_OBJECT = exports.ERROR_EVENT_TYPE_FORMAT = exports.ERROR_EVENTS_TRACKER = exports.ERROR_IMPRESSIONS_LISTENER = exports.ERROR_IMPRESSIONS_TRACKER = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* Message codes used to trim string log messages from commons and client-side API modules,
|
|
8
8
|
* in order to reduce the minimal SDK size for Browser and eventually other client-side environments.
|
|
@@ -30,7 +30,6 @@ exports.ENGINE_MATCHER_LESS = 16;
|
|
|
30
30
|
exports.ENGINE_MATCHER_PART_OF = 17;
|
|
31
31
|
exports.ENGINE_MATCHER_SEGMENT = 18;
|
|
32
32
|
exports.ENGINE_MATCHER_STRING = 19;
|
|
33
|
-
exports.ENGINE_MATCHER_STRING_INVALID = 20;
|
|
34
33
|
exports.ENGINE_MATCHER_STARTS_WITH = 21;
|
|
35
34
|
exports.ENGINE_MATCHER_WHITELIST = 22;
|
|
36
35
|
exports.ENGINE_VALUE = 23;
|
|
@@ -133,6 +132,7 @@ exports.ERROR_NOT_BOOLEAN = 325;
|
|
|
133
132
|
exports.ERROR_MIN_CONFIG_PARAM = 326;
|
|
134
133
|
exports.ERROR_TOO_MANY_SETS = 327;
|
|
135
134
|
exports.ERROR_SETS_FILTER_EXCLUSIVE = 328;
|
|
135
|
+
exports.ENGINE_MATCHER_ERROR = 329;
|
|
136
136
|
// Log prefixes (a.k.a. tags or categories)
|
|
137
137
|
exports.LOG_PREFIX_SETTINGS = 'settings';
|
|
138
138
|
exports.LOG_PREFIX_INSTANTIATION = 'Factory instantiation';
|
|
@@ -26,7 +26,6 @@ exports.codesDebug = info_1.codesInfo.concat([
|
|
|
26
26
|
[c.ENGINE_MATCHER_PART_OF, c.LOG_PREFIX_ENGINE_MATCHER + '[partOfMatcher] %s is part of %s? %s'],
|
|
27
27
|
[c.ENGINE_MATCHER_SEGMENT, c.LOG_PREFIX_ENGINE_MATCHER + '[segmentMatcher] evaluated %s / %s => %s'],
|
|
28
28
|
[c.ENGINE_MATCHER_STRING, c.LOG_PREFIX_ENGINE_MATCHER + '[stringMatcher] does %s matches with %s? %s'],
|
|
29
|
-
[c.ENGINE_MATCHER_STRING_INVALID, c.LOG_PREFIX_ENGINE_MATCHER + '[stringMatcher] %s is an invalid regex'],
|
|
30
29
|
[c.ENGINE_MATCHER_STARTS_WITH, c.LOG_PREFIX_ENGINE_MATCHER + '[startsWithMatcher] %s starts with %s? %s'],
|
|
31
30
|
[c.ENGINE_MATCHER_WHITELIST, c.LOG_PREFIX_ENGINE_MATCHER + '[whitelistMatcher] evaluated %s in [%s] => %s'],
|
|
32
31
|
[c.ENGINE_VALUE, c.LOG_PREFIX_ENGINE_VALUE + 'Extracted attribute [%s], [%s] will be used for matching.'],
|
|
@@ -6,6 +6,7 @@ var c = (0, tslib_1.__importStar)(require("../constants"));
|
|
|
6
6
|
exports.codesError = [
|
|
7
7
|
// evaluator
|
|
8
8
|
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules or unsupported matcher type found'],
|
|
9
|
+
[c.ENGINE_MATCHER_ERROR, c.LOG_PREFIX_ENGINE_MATCHER + '[%s] %s'],
|
|
9
10
|
// SDK
|
|
10
11
|
[c.ERROR_LOGLEVEL_INVALID, 'logger: Invalid Log Level - No changes to the logs will be applied.'],
|
|
11
12
|
[c.ERROR_CLIENT_CANNOT_GET_READY, 'The SDK will not get ready. Reason: %s'],
|
package/cjs/utils/Semver.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Semver = void 0;
|
|
4
|
+
var lang_1 = require("../utils/lang");
|
|
4
5
|
var NUMERIC_IDENTIFIER_REGEX = /^[0-9]+$/;
|
|
5
6
|
var METADATA_DELIMITER = '+';
|
|
6
7
|
var PRERELEASE_DELIMITER = '-';
|
|
@@ -27,6 +28,8 @@ function throwError(version) {
|
|
|
27
28
|
}
|
|
28
29
|
var Semver = /** @class */ (function () {
|
|
29
30
|
function Semver(version) {
|
|
31
|
+
if (!(0, lang_1.isString)(version))
|
|
32
|
+
throwError(version);
|
|
30
33
|
// Separate metadata if exists
|
|
31
34
|
var index = version.indexOf(METADATA_DELIMITER);
|
|
32
35
|
var _a = index === -1 ? [version] : [version.slice(0, index), version.slice(index + 1)], vWithoutMetadata = _a[0], metadata = _a[1];
|
|
@@ -2,7 +2,8 @@ import { Semver } from '../../utils/Semver';
|
|
|
2
2
|
export function equalToSemverMatcherContext(log, ruleAttr) {
|
|
3
3
|
var ruleSemver = new Semver(ruleAttr);
|
|
4
4
|
return function equalToSemverMatcher(runtimeAttr) {
|
|
5
|
-
var
|
|
5
|
+
var runtimeSemver = new Semver(runtimeAttr);
|
|
6
|
+
var isEqual = ruleSemver.version === runtimeSemver.version;
|
|
6
7
|
return isEqual;
|
|
7
8
|
};
|
|
8
9
|
}
|
|
@@ -2,7 +2,8 @@ import { Semver } from '../../utils/Semver';
|
|
|
2
2
|
export function greaterThanEqualToSemverMatcherContext(log, ruleAttr) {
|
|
3
3
|
var ruleSemver = new Semver(ruleAttr);
|
|
4
4
|
return function greaterThanEqualToSemverMatcher(runtimeAttr) {
|
|
5
|
-
var
|
|
5
|
+
var runtimeSemver = new Semver(runtimeAttr);
|
|
6
|
+
var isGreaterThanEqual = runtimeSemver.compare(ruleSemver) >= 0;
|
|
6
7
|
return isGreaterThanEqual;
|
|
7
8
|
};
|
|
8
9
|
}
|
|
@@ -2,7 +2,8 @@ import { Semver } from '../../utils/Semver';
|
|
|
2
2
|
export function lessThanEqualToSemverMatcherContext(log, ruleAttr) {
|
|
3
3
|
var ruleSemver = new Semver(ruleAttr);
|
|
4
4
|
return function lessThanEqualToSemverMatcher(runtimeAttr) {
|
|
5
|
-
var
|
|
5
|
+
var runtimeSemver = new Semver(runtimeAttr);
|
|
6
|
+
var isLessThenEqual = runtimeSemver.compare(ruleSemver) <= 0;
|
|
6
7
|
return isLessThenEqual;
|
|
7
8
|
};
|
|
8
9
|
}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ENGINE_MATCHER_STRING } from '../../logger/constants';
|
|
2
2
|
export function stringMatcherContext(log, ruleAttr) {
|
|
3
|
+
var regex = new RegExp(ruleAttr);
|
|
3
4
|
return function stringMatcher(runtimeAttr) {
|
|
4
|
-
var
|
|
5
|
-
try {
|
|
6
|
-
re = new RegExp(ruleAttr);
|
|
7
|
-
}
|
|
8
|
-
catch (e) {
|
|
9
|
-
log.debug(ENGINE_MATCHER_STRING_INVALID, [ruleAttr]);
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
var regexMatches = re.test(runtimeAttr);
|
|
5
|
+
var regexMatches = regex.test(runtimeAttr);
|
|
13
6
|
log.debug(ENGINE_MATCHER_STRING, [runtimeAttr, ruleAttr, regexMatches ? 'yes' : 'no']);
|
|
14
7
|
return regexMatches;
|
|
15
8
|
};
|
|
@@ -6,24 +6,37 @@ 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
10
|
export function parser(log, conditions, storage) {
|
|
10
11
|
var predicates = [];
|
|
11
|
-
|
|
12
|
+
var _loop_1 = function (i) {
|
|
12
13
|
var _a = conditions[i], matcherGroup = _a.matcherGroup, partitions = _a.partitions, label = _a.label, conditionType = _a.conditionType;
|
|
13
14
|
// transform data structure
|
|
14
15
|
var matchers = matchersTransform(matcherGroup.matchers);
|
|
15
16
|
// create a set of pure functions from the matcher's dto
|
|
16
|
-
var expressions = matchers.map(function (matcherDto) {
|
|
17
|
-
var matcher
|
|
17
|
+
var expressions = matchers.map(function (matcherDto, index) {
|
|
18
|
+
var matcher;
|
|
19
|
+
try {
|
|
20
|
+
matcher = matcherFactory(log, matcherDto, storage);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
log.error(ENGINE_MATCHER_ERROR, [matcherGroup.matchers[index].matcherType, error]);
|
|
24
|
+
}
|
|
18
25
|
// Evaluator function.
|
|
19
26
|
return function (key, attributes, splitEvaluator) {
|
|
20
27
|
var value = sanitizeValue(log, key, matcherDto, attributes);
|
|
21
|
-
var result =
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
var result = false;
|
|
29
|
+
if (value !== undefined && matcher) {
|
|
30
|
+
try {
|
|
31
|
+
result = matcher(value, splitEvaluator);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
log.error(ENGINE_MATCHER_ERROR, [matcherGroup.matchers[index].matcherType, error]);
|
|
35
|
+
}
|
|
25
36
|
}
|
|
26
|
-
// @ts-ignore
|
|
37
|
+
if (thenable(result)) { // @ts-ignore
|
|
38
|
+
return result.then(function (res) { return Boolean(res ^ matcherDto.negate); });
|
|
39
|
+
} // @ts-ignore
|
|
27
40
|
return Boolean(result ^ matcherDto.negate);
|
|
28
41
|
};
|
|
29
42
|
});
|
|
@@ -31,10 +44,14 @@ export function parser(log, conditions, storage) {
|
|
|
31
44
|
if (expressions.length === 0) {
|
|
32
45
|
// reset any data collected during parsing
|
|
33
46
|
predicates = [];
|
|
34
|
-
|
|
35
|
-
break;
|
|
47
|
+
return "break";
|
|
36
48
|
}
|
|
37
49
|
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;
|
|
38
55
|
}
|
|
39
56
|
// Instanciate evaluator given the set of conditions using if else if logic
|
|
40
57
|
return ifElseIfCombinerContext(log, predicates);
|
package/esm/logger/constants.js
CHANGED
|
@@ -25,7 +25,6 @@ export var ENGINE_MATCHER_LESS = 16;
|
|
|
25
25
|
export var ENGINE_MATCHER_PART_OF = 17;
|
|
26
26
|
export var ENGINE_MATCHER_SEGMENT = 18;
|
|
27
27
|
export var ENGINE_MATCHER_STRING = 19;
|
|
28
|
-
export var ENGINE_MATCHER_STRING_INVALID = 20;
|
|
29
28
|
export var ENGINE_MATCHER_STARTS_WITH = 21;
|
|
30
29
|
export var ENGINE_MATCHER_WHITELIST = 22;
|
|
31
30
|
export var ENGINE_VALUE = 23;
|
|
@@ -128,6 +127,7 @@ export var ERROR_NOT_BOOLEAN = 325;
|
|
|
128
127
|
export var ERROR_MIN_CONFIG_PARAM = 326;
|
|
129
128
|
export var ERROR_TOO_MANY_SETS = 327;
|
|
130
129
|
export var ERROR_SETS_FILTER_EXCLUSIVE = 328;
|
|
130
|
+
export var ENGINE_MATCHER_ERROR = 329;
|
|
131
131
|
// Log prefixes (a.k.a. tags or categories)
|
|
132
132
|
export var LOG_PREFIX_SETTINGS = 'settings';
|
|
133
133
|
export var LOG_PREFIX_INSTANTIATION = 'Factory instantiation';
|
|
@@ -22,7 +22,6 @@ export var codesDebug = codesInfo.concat([
|
|
|
22
22
|
[c.ENGINE_MATCHER_PART_OF, c.LOG_PREFIX_ENGINE_MATCHER + '[partOfMatcher] %s is part of %s? %s'],
|
|
23
23
|
[c.ENGINE_MATCHER_SEGMENT, c.LOG_PREFIX_ENGINE_MATCHER + '[segmentMatcher] evaluated %s / %s => %s'],
|
|
24
24
|
[c.ENGINE_MATCHER_STRING, c.LOG_PREFIX_ENGINE_MATCHER + '[stringMatcher] does %s matches with %s? %s'],
|
|
25
|
-
[c.ENGINE_MATCHER_STRING_INVALID, c.LOG_PREFIX_ENGINE_MATCHER + '[stringMatcher] %s is an invalid regex'],
|
|
26
25
|
[c.ENGINE_MATCHER_STARTS_WITH, c.LOG_PREFIX_ENGINE_MATCHER + '[startsWithMatcher] %s starts with %s? %s'],
|
|
27
26
|
[c.ENGINE_MATCHER_WHITELIST, c.LOG_PREFIX_ENGINE_MATCHER + '[whitelistMatcher] evaluated %s in [%s] => %s'],
|
|
28
27
|
[c.ENGINE_VALUE, c.LOG_PREFIX_ENGINE_VALUE + 'Extracted attribute [%s], [%s] will be used for matching.'],
|
|
@@ -2,6 +2,7 @@ import * as c from '../constants';
|
|
|
2
2
|
export var codesError = [
|
|
3
3
|
// evaluator
|
|
4
4
|
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules or unsupported matcher type found'],
|
|
5
|
+
[c.ENGINE_MATCHER_ERROR, c.LOG_PREFIX_ENGINE_MATCHER + '[%s] %s'],
|
|
5
6
|
// SDK
|
|
6
7
|
[c.ERROR_LOGLEVEL_INVALID, 'logger: Invalid Log Level - No changes to the logs will be applied.'],
|
|
7
8
|
[c.ERROR_CLIENT_CANNOT_GET_READY, 'The SDK will not get ready. Reason: %s'],
|
package/esm/utils/Semver.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isString } from '../utils/lang';
|
|
1
2
|
var NUMERIC_IDENTIFIER_REGEX = /^[0-9]+$/;
|
|
2
3
|
var METADATA_DELIMITER = '+';
|
|
3
4
|
var PRERELEASE_DELIMITER = '-';
|
|
@@ -24,6 +25,8 @@ function throwError(version) {
|
|
|
24
25
|
}
|
|
25
26
|
var Semver = /** @class */ (function () {
|
|
26
27
|
function Semver(version) {
|
|
28
|
+
if (!isString(version))
|
|
29
|
+
throwError(version);
|
|
27
30
|
// Separate metadata if exists
|
|
28
31
|
var index = version.indexOf(METADATA_DELIMITER);
|
|
29
32
|
var _a = index === -1 ? [version] : [version.slice(0, index), version.slice(index + 1)], vWithoutMetadata = _a[0], metadata = _a[1];
|
package/package.json
CHANGED
|
@@ -3,15 +3,13 @@ import { ILogger } from '../../logger/types';
|
|
|
3
3
|
import { Semver } from '../../utils/Semver';
|
|
4
4
|
|
|
5
5
|
export function betweenSemverMatcherContext(log: ILogger, ruleAttr: IBetweenStringMatcherData) {
|
|
6
|
-
|
|
7
6
|
const startSemver = new Semver(ruleAttr.start);
|
|
8
7
|
const endSemver = new Semver(ruleAttr.end);
|
|
9
8
|
|
|
10
9
|
return function betweenSemverMatcher(key: string): boolean {
|
|
11
|
-
|
|
12
10
|
const runtimeSemver = new Semver(key);
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
const isBetween = startSemver.compare(runtimeSemver) <= 0 && endSemver.compare(runtimeSemver) >= 0;
|
|
15
13
|
|
|
16
14
|
return isBetween;
|
|
17
15
|
};
|
|
@@ -2,11 +2,12 @@ import { ILogger } from '../../logger/types';
|
|
|
2
2
|
import { Semver } from '../../utils/Semver';
|
|
3
3
|
|
|
4
4
|
export function equalToSemverMatcherContext(log: ILogger, ruleAttr: string) {
|
|
5
|
-
|
|
6
5
|
const ruleSemver = new Semver(ruleAttr);
|
|
7
6
|
|
|
8
7
|
return function equalToSemverMatcher(runtimeAttr: string): boolean {
|
|
9
|
-
const
|
|
8
|
+
const runtimeSemver = new Semver(runtimeAttr);
|
|
9
|
+
|
|
10
|
+
const isEqual = ruleSemver.version === runtimeSemver.version;
|
|
10
11
|
|
|
11
12
|
return isEqual;
|
|
12
13
|
};
|
|
@@ -2,11 +2,12 @@ import { ILogger } from '../../logger/types';
|
|
|
2
2
|
import { Semver } from '../../utils/Semver';
|
|
3
3
|
|
|
4
4
|
export function greaterThanEqualToSemverMatcherContext(log: ILogger, ruleAttr: string) {
|
|
5
|
-
|
|
6
5
|
const ruleSemver = new Semver(ruleAttr);
|
|
7
6
|
|
|
8
7
|
return function greaterThanEqualToSemverMatcher(runtimeAttr: string): boolean {
|
|
9
|
-
|
|
8
|
+
const runtimeSemver = new Semver(runtimeAttr);
|
|
9
|
+
|
|
10
|
+
const isGreaterThanEqual = runtimeSemver.compare(ruleSemver) >= 0;
|
|
10
11
|
|
|
11
12
|
return isGreaterThanEqual;
|
|
12
13
|
};
|
|
@@ -2,11 +2,12 @@ import { ILogger } from '../../logger/types';
|
|
|
2
2
|
import { Semver } from '../../utils/Semver';
|
|
3
3
|
|
|
4
4
|
export function lessThanEqualToSemverMatcherContext(log: ILogger, ruleAttr: string) {
|
|
5
|
-
|
|
6
5
|
const ruleSemver = new Semver(ruleAttr);
|
|
7
6
|
|
|
8
7
|
return function lessThanEqualToSemverMatcher(runtimeAttr: string): boolean {
|
|
9
|
-
|
|
8
|
+
const runtimeSemver = new Semver(runtimeAttr);
|
|
9
|
+
|
|
10
|
+
const isLessThenEqual = runtimeSemver.compare(ruleSemver) <= 0;
|
|
10
11
|
|
|
11
12
|
return isLessThenEqual;
|
|
12
13
|
};
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ENGINE_MATCHER_STRING } from '../../logger/constants';
|
|
2
2
|
import { ILogger } from '../../logger/types';
|
|
3
3
|
|
|
4
4
|
export function stringMatcherContext(log: ILogger, ruleAttr: string) {
|
|
5
|
-
|
|
6
|
-
let re;
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
re = new RegExp(ruleAttr);
|
|
10
|
-
} catch (e) {
|
|
11
|
-
log.debug(ENGINE_MATCHER_STRING_INVALID, [ruleAttr]);
|
|
5
|
+
const regex = new RegExp(ruleAttr);
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
let regexMatches = re.test(runtimeAttr);
|
|
7
|
+
return function stringMatcher(runtimeAttr: string): boolean {
|
|
8
|
+
const regexMatches = regex.test(runtimeAttr);
|
|
17
9
|
|
|
18
10
|
log.debug(ENGINE_MATCHER_STRING, [runtimeAttr, ruleAttr, regexMatches ? 'yes' : 'no']);
|
|
19
11
|
|
|
@@ -7,10 +7,11 @@ import { ifElseIfCombinerContext } from '../combiners/ifelseif';
|
|
|
7
7
|
import { andCombinerContext } from '../combiners/and';
|
|
8
8
|
import { thenable } from '../../utils/promise/thenable';
|
|
9
9
|
import { IEvaluator, IMatcherDto, ISplitEvaluator } from '../types';
|
|
10
|
-
import { ISplitCondition } from '../../dtos/types';
|
|
10
|
+
import { ISplitCondition, MaybeThenable } from '../../dtos/types';
|
|
11
11
|
import { IStorageAsync, IStorageSync } from '../../storages/types';
|
|
12
12
|
import { SplitIO } from '../../types';
|
|
13
13
|
import { ILogger } from '../../logger/types';
|
|
14
|
+
import { ENGINE_MATCHER_ERROR } from '../../logger/constants';
|
|
14
15
|
|
|
15
16
|
export function parser(log: ILogger, conditions: ISplitCondition[], storage: IStorageSync | IStorageAsync): IEvaluator {
|
|
16
17
|
let predicates = [];
|
|
@@ -27,19 +28,30 @@ export function parser(log: ILogger, conditions: ISplitCondition[], storage: ISt
|
|
|
27
28
|
const matchers = matchersTransform(matcherGroup.matchers);
|
|
28
29
|
|
|
29
30
|
// create a set of pure functions from the matcher's dto
|
|
30
|
-
const expressions = matchers.map((matcherDto: IMatcherDto) => {
|
|
31
|
-
|
|
31
|
+
const expressions = matchers.map((matcherDto: IMatcherDto, index: number) => {
|
|
32
|
+
let matcher: ReturnType<typeof matcherFactory>;
|
|
33
|
+
try {
|
|
34
|
+
matcher = matcherFactory(log, matcherDto, storage);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
log.error(ENGINE_MATCHER_ERROR, [matcherGroup.matchers[index].matcherType, error]);
|
|
37
|
+
}
|
|
32
38
|
|
|
33
39
|
// Evaluator function.
|
|
34
40
|
return (key: string, attributes: SplitIO.Attributes | undefined, splitEvaluator: ISplitEvaluator) => {
|
|
35
41
|
const value = sanitizeValue(log, key, matcherDto, attributes);
|
|
36
|
-
|
|
42
|
+
let result: MaybeThenable<boolean> = false;
|
|
37
43
|
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
if (value !== undefined && matcher) {
|
|
45
|
+
try {
|
|
46
|
+
result = matcher(value, splitEvaluator);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
log.error(ENGINE_MATCHER_ERROR, [matcherGroup.matchers[index].matcherType, error]);
|
|
49
|
+
}
|
|
41
50
|
}
|
|
42
|
-
|
|
51
|
+
|
|
52
|
+
if (thenable(result)) { // @ts-ignore
|
|
53
|
+
return result.then(res => Boolean(res ^ matcherDto.negate));
|
|
54
|
+
} // @ts-ignore
|
|
43
55
|
return Boolean(result ^ matcherDto.negate);
|
|
44
56
|
};
|
|
45
57
|
});
|
package/src/logger/constants.ts
CHANGED
|
@@ -25,7 +25,6 @@ export const ENGINE_MATCHER_LESS = 16;
|
|
|
25
25
|
export const ENGINE_MATCHER_PART_OF = 17;
|
|
26
26
|
export const ENGINE_MATCHER_SEGMENT = 18;
|
|
27
27
|
export const ENGINE_MATCHER_STRING = 19;
|
|
28
|
-
export const ENGINE_MATCHER_STRING_INVALID = 20;
|
|
29
28
|
export const ENGINE_MATCHER_STARTS_WITH = 21;
|
|
30
29
|
export const ENGINE_MATCHER_WHITELIST = 22;
|
|
31
30
|
export const ENGINE_VALUE = 23;
|
|
@@ -131,6 +130,7 @@ export const ERROR_NOT_BOOLEAN = 325;
|
|
|
131
130
|
export const ERROR_MIN_CONFIG_PARAM = 326;
|
|
132
131
|
export const ERROR_TOO_MANY_SETS = 327;
|
|
133
132
|
export const ERROR_SETS_FILTER_EXCLUSIVE = 328;
|
|
133
|
+
export const ENGINE_MATCHER_ERROR = 329;
|
|
134
134
|
|
|
135
135
|
// Log prefixes (a.k.a. tags or categories)
|
|
136
136
|
export const LOG_PREFIX_SETTINGS = 'settings';
|
|
@@ -23,7 +23,6 @@ export const codesDebug: [number, string][] = codesInfo.concat([
|
|
|
23
23
|
[c.ENGINE_MATCHER_PART_OF, c.LOG_PREFIX_ENGINE_MATCHER + '[partOfMatcher] %s is part of %s? %s'],
|
|
24
24
|
[c.ENGINE_MATCHER_SEGMENT, c.LOG_PREFIX_ENGINE_MATCHER + '[segmentMatcher] evaluated %s / %s => %s'],
|
|
25
25
|
[c.ENGINE_MATCHER_STRING, c.LOG_PREFIX_ENGINE_MATCHER + '[stringMatcher] does %s matches with %s? %s'],
|
|
26
|
-
[c.ENGINE_MATCHER_STRING_INVALID, c.LOG_PREFIX_ENGINE_MATCHER + '[stringMatcher] %s is an invalid regex'],
|
|
27
26
|
[c.ENGINE_MATCHER_STARTS_WITH, c.LOG_PREFIX_ENGINE_MATCHER + '[startsWithMatcher] %s starts with %s? %s'],
|
|
28
27
|
[c.ENGINE_MATCHER_WHITELIST, c.LOG_PREFIX_ENGINE_MATCHER + '[whitelistMatcher] evaluated %s in [%s] => %s'],
|
|
29
28
|
[c.ENGINE_VALUE, c.LOG_PREFIX_ENGINE_VALUE + 'Extracted attribute [%s], [%s] will be used for matching.'],
|
|
@@ -3,6 +3,7 @@ import * as c from '../constants';
|
|
|
3
3
|
export const codesError: [number, string][] = [
|
|
4
4
|
// evaluator
|
|
5
5
|
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules or unsupported matcher type found'],
|
|
6
|
+
[c.ENGINE_MATCHER_ERROR, c.LOG_PREFIX_ENGINE_MATCHER + '[%s] %s'],
|
|
6
7
|
// SDK
|
|
7
8
|
[c.ERROR_LOGLEVEL_INVALID, 'logger: Invalid Log Level - No changes to the logs will be applied.'],
|
|
8
9
|
[c.ERROR_CLIENT_CANNOT_GET_READY, 'The SDK will not get ready. Reason: %s'],
|
package/src/utils/Semver.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isString } from '../utils/lang';
|
|
2
|
+
|
|
1
3
|
const NUMERIC_IDENTIFIER_REGEX = /^[0-9]+$/;
|
|
2
4
|
|
|
3
5
|
const METADATA_DELIMITER = '+';
|
|
@@ -39,6 +41,8 @@ export class Semver {
|
|
|
39
41
|
public readonly version: string;
|
|
40
42
|
|
|
41
43
|
public constructor(version: string) {
|
|
44
|
+
if (!isString(version)) throwError(version);
|
|
45
|
+
|
|
42
46
|
// Separate metadata if exists
|
|
43
47
|
let index = version.indexOf(METADATA_DELIMITER);
|
|
44
48
|
let [vWithoutMetadata, metadata] = index === -1 ? [version] : [version.slice(0, index), version.slice(index + 1)];
|
|
@@ -25,7 +25,6 @@ export declare const ENGINE_MATCHER_LESS = 16;
|
|
|
25
25
|
export declare const ENGINE_MATCHER_PART_OF = 17;
|
|
26
26
|
export declare const ENGINE_MATCHER_SEGMENT = 18;
|
|
27
27
|
export declare const ENGINE_MATCHER_STRING = 19;
|
|
28
|
-
export declare const ENGINE_MATCHER_STRING_INVALID = 20;
|
|
29
28
|
export declare const ENGINE_MATCHER_STARTS_WITH = 21;
|
|
30
29
|
export declare const ENGINE_MATCHER_WHITELIST = 22;
|
|
31
30
|
export declare const ENGINE_VALUE = 23;
|
|
@@ -128,6 +127,7 @@ export declare const ERROR_NOT_BOOLEAN = 325;
|
|
|
128
127
|
export declare const ERROR_MIN_CONFIG_PARAM = 326;
|
|
129
128
|
export declare const ERROR_TOO_MANY_SETS = 327;
|
|
130
129
|
export declare const ERROR_SETS_FILTER_EXCLUSIVE = 328;
|
|
130
|
+
export declare const ENGINE_MATCHER_ERROR = 329;
|
|
131
131
|
export declare const LOG_PREFIX_SETTINGS = "settings";
|
|
132
132
|
export declare const LOG_PREFIX_INSTANTIATION = "Factory instantiation";
|
|
133
133
|
export declare const LOG_PREFIX_ENGINE = "engine";
|