@splitsoftware/splitio-commons 1.13.2-rc.0 → 1.13.2-rc.10
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 +4 -3
- package/cjs/evaluator/Engine.js +5 -6
- package/cjs/evaluator/combiners/ifelseif.js +3 -4
- 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 +3 -5
- package/cjs/evaluator/matchers/index.js +12 -2
- package/cjs/evaluator/matchers/lte.js +3 -5
- package/cjs/evaluator/matchers/matcherTypes.js +6 -1
- package/cjs/evaluator/matchers/part_of.js +1 -3
- package/cjs/evaluator/matchers/segment.js +1 -6
- package/cjs/evaluator/matchers/semver_between.js +14 -0
- package/cjs/evaluator/matchers/semver_eq.js +13 -0
- package/cjs/evaluator/matchers/semver_gte.js +13 -0
- package/cjs/evaluator/matchers/semver_inlist.js +17 -0
- package/cjs/evaluator/matchers/semver_lte.js +13 -0
- package/cjs/evaluator/matchers/string.js +3 -12
- package/cjs/evaluator/matchers/sw.js +1 -3
- package/cjs/evaluator/matchers/whitelist.js +3 -4
- package/cjs/evaluator/matchersTransform/index.js +21 -16
- package/cjs/evaluator/matchersTransform/whitelist.js +2 -3
- package/cjs/evaluator/parser/index.js +24 -9
- package/cjs/logger/constants.js +5 -20
- package/cjs/logger/index.js +8 -1
- package/cjs/logger/messages/debug.js +5 -21
- package/cjs/logger/messages/error.js +2 -1
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/sdkClient/sdkClient.js +1 -6
- package/cjs/services/splitApi.js +5 -5
- package/cjs/storages/KeyBuilder.js +2 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +1 -1
- package/cjs/storages/pluggable/index.js +1 -1
- package/cjs/utils/Semver.js +103 -0
- package/cjs/utils/constants/index.js +2 -1
- package/cjs/utils/labels/index.js +1 -1
- package/cjs/utils/settingsValidation/index.js +1 -1
- package/cjs/utils/settingsValidation/logger/pluggableLogger.js +1 -1
- package/esm/evaluator/Engine.js +5 -5
- package/esm/evaluator/combiners/ifelseif.js +3 -3
- 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 +3 -5
- package/esm/evaluator/matchers/index.js +12 -2
- package/esm/evaluator/matchers/lte.js +3 -5
- package/esm/evaluator/matchers/matcherTypes.js +6 -1
- package/esm/evaluator/matchers/part_of.js +1 -3
- package/esm/evaluator/matchers/segment.js +1 -6
- package/esm/evaluator/matchers/semver_between.js +10 -0
- package/esm/evaluator/matchers/semver_eq.js +9 -0
- package/esm/evaluator/matchers/semver_gte.js +9 -0
- package/esm/evaluator/matchers/semver_inlist.js +13 -0
- package/esm/evaluator/matchers/semver_lte.js +9 -0
- package/esm/evaluator/matchers/string.js +3 -12
- package/esm/evaluator/matchers/sw.js +1 -3
- package/esm/evaluator/matchers/whitelist.js +4 -5
- package/esm/evaluator/matchersTransform/index.js +21 -16
- package/esm/evaluator/matchersTransform/whitelist.js +2 -3
- package/esm/evaluator/parser/index.js +24 -9
- package/esm/logger/constants.js +2 -17
- package/esm/logger/index.js +9 -2
- package/esm/logger/messages/debug.js +5 -21
- package/esm/logger/messages/error.js +2 -1
- package/esm/logger/messages/warn.js +1 -1
- package/esm/sdkClient/sdkClient.js +1 -6
- package/esm/services/splitApi.js +6 -6
- package/esm/storages/KeyBuilder.js +2 -1
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +1 -1
- package/esm/storages/pluggable/index.js +1 -1
- package/esm/utils/Semver.js +100 -0
- package/esm/utils/constants/index.js +1 -0
- package/esm/utils/labels/index.js +1 -1
- package/esm/utils/settingsValidation/index.js +1 -1
- package/esm/utils/settingsValidation/logger/pluggableLogger.js +1 -1
- package/package.json +1 -2
- package/src/dtos/types.ts +34 -1
- package/src/evaluator/Engine.ts +5 -6
- package/src/evaluator/combiners/ifelseif.ts +3 -3
- 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 +3 -7
- package/src/evaluator/matchers/index.ts +29 -19
- package/src/evaluator/matchers/lte.ts +3 -7
- package/src/evaluator/matchers/matcherTypes.ts +6 -1
- package/src/evaluator/matchers/part_of.ts +1 -5
- package/src/evaluator/matchers/segment.ts +1 -8
- package/src/evaluator/matchers/semver_between.ts +15 -0
- package/src/evaluator/matchers/semver_eq.ts +13 -0
- package/src/evaluator/matchers/semver_gte.ts +13 -0
- package/src/evaluator/matchers/semver_inlist.ts +17 -0
- package/src/evaluator/matchers/semver_lte.ts +13 -0
- package/src/evaluator/matchers/string.ts +3 -16
- package/src/evaluator/matchers/sw.ts +2 -6
- package/src/evaluator/matchers/whitelist.ts +5 -7
- package/src/evaluator/matchersTransform/index.ts +31 -23
- package/src/evaluator/matchersTransform/whitelist.ts +4 -5
- package/src/evaluator/parser/index.ts +25 -10
- package/src/evaluator/types.ts +3 -3
- package/src/logger/constants.ts +2 -17
- package/src/logger/index.ts +8 -2
- package/src/logger/messages/debug.ts +5 -21
- package/src/logger/messages/error.ts +2 -1
- package/src/logger/messages/warn.ts +1 -1
- package/src/sdkClient/sdkClient.ts +1 -8
- package/src/services/splitApi.ts +5 -6
- package/src/storages/KeyBuilder.ts +2 -1
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +1 -1
- package/src/storages/pluggable/index.ts +1 -1
- package/src/types.ts +3 -3
- package/src/utils/Semver.ts +111 -0
- package/src/utils/constants/index.ts +2 -0
- package/src/utils/labels/index.ts +1 -1
- package/src/utils/settingsValidation/index.ts +1 -1
- package/src/utils/settingsValidation/logger/pluggableLogger.ts +1 -1
- package/types/dtos/types.d.ts +26 -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/sember_inlist.d.ts +3 -0
- package/types/evaluator/matchers/semver_between.d.ts +2 -0
- package/types/evaluator/matchers/semver_eq.d.ts +1 -0
- package/types/evaluator/matchers/semver_gte.d.ts +1 -0
- package/types/evaluator/matchers/semver_inlist.d.ts +1 -0
- package/types/evaluator/matchers/semver_lte.d.ts +1 -0
- 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/set.d.ts +2 -2
- package/types/evaluator/matchersTransform/string.d.ts +7 -0
- package/types/evaluator/matchersTransform/whitelist.d.ts +3 -3
- package/types/evaluator/types.d.ts +3 -3
- package/types/logger/constants.d.ts +2 -17
- package/types/types.d.ts +3 -3
- package/types/utils/constants/index.d.ts +1 -0
- package/types/utils/labels/index.d.ts +1 -1
- package/types/utils/semVer.d.ts +15 -0
- package/types/utils/settingsValidation/logger/globalLogLevel.d.ts +8 -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
|
@@ -6,27 +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_STRING_INVALID, c.LOG_PREFIX_ENGINE_MATCHER + '[stringMatcher] %s is an invalid regex'],
|
|
26
|
-
[c.ENGINE_MATCHER_STARTS_WITH, c.LOG_PREFIX_ENGINE_MATCHER + '[startsWithMatcher] %s starts with %s? %s'],
|
|
27
|
-
[c.ENGINE_MATCHER_WHITELIST, c.LOG_PREFIX_ENGINE_MATCHER + '[whitelistMatcher] evaluated %s in [%s] => %s'],
|
|
28
|
-
[c.ENGINE_VALUE, c.LOG_PREFIX_ENGINE_VALUE + 'Extracted attribute [%s], [%s] will be used for matching.'],
|
|
29
|
-
[c.ENGINE_SANITIZE, c.LOG_PREFIX_ENGINE + ':sanitize: Attempted to sanitize [%s] which should be of type [%s]. Sanitized and processed value => [%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'],
|
|
30
14
|
// SDK
|
|
31
15
|
[c.CLEANUP_REGISTERING, c.LOG_PREFIX_CLEANUP + 'Registering cleanup handler %s'],
|
|
32
16
|
[c.CLEANUP_DEREGISTERING, c.LOG_PREFIX_CLEANUP + 'Deregistering cleanup handler %s'],
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as c from '../constants';
|
|
2
2
|
export var codesError = [
|
|
3
3
|
// evaluator
|
|
4
|
-
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules found'],
|
|
4
|
+
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules or unsupported targeting rule 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'],
|
|
@@ -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'],
|
|
@@ -28,8 +28,6 @@ export function sdkClientFactory(params, isSharedClient) {
|
|
|
28
28
|
function __flush() {
|
|
29
29
|
return syncManager ? syncManager.flush() : Promise.resolve();
|
|
30
30
|
}
|
|
31
|
-
// Same promise if `destroy` is called multiple times
|
|
32
|
-
var destroyPromise;
|
|
33
31
|
return objectAssign(
|
|
34
32
|
// Proto-linkage of the readiness Event Emitter
|
|
35
33
|
Object.create(sdkReadinessManager.sdkStatus),
|
|
@@ -42,8 +40,6 @@ export function sdkClientFactory(params, isSharedClient) {
|
|
|
42
40
|
return __cooldown(__flush, COOLDOWN_TIME_IN_MILLIS);
|
|
43
41
|
},
|
|
44
42
|
destroy: function () {
|
|
45
|
-
if (destroyPromise)
|
|
46
|
-
return destroyPromise;
|
|
47
43
|
// Mark the SDK as destroyed immediately
|
|
48
44
|
sdkReadinessManager.readinessManager.destroy();
|
|
49
45
|
// For main client, release the SDK Key and record stat before flushing data
|
|
@@ -53,7 +49,7 @@ export function sdkClientFactory(params, isSharedClient) {
|
|
|
53
49
|
}
|
|
54
50
|
// Stop background jobs
|
|
55
51
|
syncManager && syncManager.stop();
|
|
56
|
-
|
|
52
|
+
return __flush().then(function () {
|
|
57
53
|
// Cleanup event listeners
|
|
58
54
|
signalListener && signalListener.stop();
|
|
59
55
|
// @TODO stop only if last client is destroyed
|
|
@@ -62,7 +58,6 @@ export function sdkClientFactory(params, isSharedClient) {
|
|
|
62
58
|
// Cleanup storage
|
|
63
59
|
return storage.destroy();
|
|
64
60
|
});
|
|
65
|
-
return destroyPromise;
|
|
66
61
|
}
|
|
67
62
|
});
|
|
68
63
|
}
|
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?
|
|
41
|
+
var url = urls.sdk + "/splitChanges?s=" + FLAGS_SPEC + "&since=" + since + (filterQueryString || '') + (till ? '&till=' + till : '');
|
|
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 = /[^.]+$/;
|
|
@@ -66,5 +67,5 @@ export { KeyBuilder };
|
|
|
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 + "::
|
|
70
|
+
return hash(settings.core.authorizationKey + "::" + settings.sync.__splitFiltersValidation.queryString + "::" + FLAGS_SPEC).toString(16);
|
|
70
71
|
}
|
|
@@ -123,7 +123,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
123
123
|
SplitsCacheInLocal.prototype.setChangeNumber = function (changeNumber) {
|
|
124
124
|
// when using a new split query, we must update it at the store
|
|
125
125
|
if (this.updateNewFilter) {
|
|
126
|
-
this.log.info(LOG_PREFIX + 'SDK key or
|
|
126
|
+
this.log.info(LOG_PREFIX + 'SDK key, flags filter criteria or flags spec version was modified. Updating cache');
|
|
127
127
|
var storageHashKey = this.keys.buildHashKey();
|
|
128
128
|
try {
|
|
129
129
|
localStorage.setItem(storageHashKey, this.storageHash);
|
|
@@ -79,7 +79,7 @@ export function PluggableStorage(options) {
|
|
|
79
79
|
return wrapper.get(keys.buildHashKey()).then(function (hash) {
|
|
80
80
|
var currentHash = getStorageHash(settings);
|
|
81
81
|
if (hash !== currentHash) {
|
|
82
|
-
log.info(LOG_PREFIX + 'Storage HASH has changed (SDK key or
|
|
82
|
+
log.info(LOG_PREFIX + 'Storage HASH has changed (SDK key, flags filter criteria or flags spec version was modified). Clearing cache');
|
|
83
83
|
return wrapper.getKeysByPrefix(keys.prefix + ".").then(function (storageKeys) {
|
|
84
84
|
return Promise.all(storageKeys.map(function (storageKey) { return wrapper.del(storageKey); }));
|
|
85
85
|
}).then(function () { return wrapper.set(keys.buildHashKey(), currentHash); });
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { isString } from '../utils/lang';
|
|
2
|
+
var NUMERIC_IDENTIFIER_REGEX = /^[0-9]+$/;
|
|
3
|
+
var METADATA_DELIMITER = '+';
|
|
4
|
+
var PRERELEASE_DELIMITER = '-';
|
|
5
|
+
var VALUE_DELIMITER = '.';
|
|
6
|
+
/**
|
|
7
|
+
* Compares two strings. If both strings are numeric identifiers, they are compared numerically. Otherwise, they are compared lexicographically.
|
|
8
|
+
* This could be implemented using `a.localeCompare(b, undefined, { numeric: true })` but locale options are not broadly supported.
|
|
9
|
+
*/
|
|
10
|
+
function compareStrings(a, b) {
|
|
11
|
+
if (NUMERIC_IDENTIFIER_REGEX.test(a) && NUMERIC_IDENTIFIER_REGEX.test(b)) {
|
|
12
|
+
var result = a.length - b.length;
|
|
13
|
+
if (result !== 0) {
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
18
|
+
}
|
|
19
|
+
// Sanitizes a numeric identifier by removing leading zeros
|
|
20
|
+
function sanitizeNumericIdentifier(value) {
|
|
21
|
+
return value.replace(/^0+(?=\d)/, '');
|
|
22
|
+
}
|
|
23
|
+
function throwError(version) {
|
|
24
|
+
throw new Error('Unable to convert to Semver, incorrect format: ' + version);
|
|
25
|
+
}
|
|
26
|
+
var Semver = /** @class */ (function () {
|
|
27
|
+
function Semver(version) {
|
|
28
|
+
if (!isString(version))
|
|
29
|
+
throwError(version);
|
|
30
|
+
// Separate metadata if exists
|
|
31
|
+
var index = version.indexOf(METADATA_DELIMITER);
|
|
32
|
+
var _a = index === -1 ? [version] : [version.slice(0, index), version.slice(index + 1)], vWithoutMetadata = _a[0], metadata = _a[1];
|
|
33
|
+
if (metadata === '')
|
|
34
|
+
throwError(version);
|
|
35
|
+
// Set pre-release versions if exists
|
|
36
|
+
index = vWithoutMetadata.indexOf(PRERELEASE_DELIMITER);
|
|
37
|
+
if (index === -1) {
|
|
38
|
+
this._isStable = true;
|
|
39
|
+
this._preRelease = [];
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this._isStable = false;
|
|
43
|
+
this._preRelease = vWithoutMetadata.slice(index + 1).split(VALUE_DELIMITER).map(function (value) {
|
|
44
|
+
if (!value)
|
|
45
|
+
throwError(version);
|
|
46
|
+
return NUMERIC_IDENTIFIER_REGEX.test(value) ?
|
|
47
|
+
sanitizeNumericIdentifier(value) :
|
|
48
|
+
value;
|
|
49
|
+
});
|
|
50
|
+
vWithoutMetadata = vWithoutMetadata.slice(0, index);
|
|
51
|
+
}
|
|
52
|
+
// Set major, minor, and patch versions
|
|
53
|
+
var vParts = vWithoutMetadata.split(VALUE_DELIMITER).map(function (value) {
|
|
54
|
+
if (!value || !NUMERIC_IDENTIFIER_REGEX.test(value))
|
|
55
|
+
throwError(version);
|
|
56
|
+
return sanitizeNumericIdentifier(value);
|
|
57
|
+
});
|
|
58
|
+
if (vParts.length !== 3)
|
|
59
|
+
throwError(version);
|
|
60
|
+
this._major = vParts[0];
|
|
61
|
+
this._minor = vParts[1];
|
|
62
|
+
this._patch = vParts[2];
|
|
63
|
+
// Set version string
|
|
64
|
+
this.version = vParts.join(VALUE_DELIMITER);
|
|
65
|
+
if (this._preRelease.length)
|
|
66
|
+
this.version += PRERELEASE_DELIMITER + this._preRelease.join(VALUE_DELIMITER);
|
|
67
|
+
if (metadata)
|
|
68
|
+
this.version += METADATA_DELIMITER + metadata;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Precedence comparision between 2 Semver objects.
|
|
72
|
+
*
|
|
73
|
+
* @return `0` if `this === toCompare`, `-1` if `this < toCompare`, and `1` if `this > toCompare`
|
|
74
|
+
*/
|
|
75
|
+
Semver.prototype.compare = function (toCompare) {
|
|
76
|
+
if (this.version === toCompare.version)
|
|
77
|
+
return 0;
|
|
78
|
+
var result = compareStrings(this._major, toCompare._major);
|
|
79
|
+
if (result !== 0)
|
|
80
|
+
return result;
|
|
81
|
+
result = compareStrings(this._minor, toCompare._minor);
|
|
82
|
+
if (result !== 0)
|
|
83
|
+
return result;
|
|
84
|
+
result = compareStrings(this._patch, toCompare._patch);
|
|
85
|
+
if (result !== 0)
|
|
86
|
+
return result;
|
|
87
|
+
if (!this._isStable && toCompare._isStable)
|
|
88
|
+
return -1;
|
|
89
|
+
if (this._isStable && !toCompare._isStable)
|
|
90
|
+
return 1;
|
|
91
|
+
for (var i = 0, length_1 = Math.min(this._preRelease.length, toCompare._preRelease.length); i < length_1; i++) {
|
|
92
|
+
var result_1 = compareStrings(this._preRelease[i], toCompare._preRelease[i]);
|
|
93
|
+
if (result_1 !== 0)
|
|
94
|
+
return result_1;
|
|
95
|
+
}
|
|
96
|
+
return this._preRelease.length - toCompare._preRelease.length;
|
|
97
|
+
};
|
|
98
|
+
return Semver;
|
|
99
|
+
}());
|
|
100
|
+
export { Semver };
|
|
@@ -5,4 +5,4 @@ export var SDK_NOT_READY = 'not ready';
|
|
|
5
5
|
export var EXCEPTION = 'exception';
|
|
6
6
|
export var SPLIT_ARCHIVED = 'archived';
|
|
7
7
|
export var NOT_IN_SPLIT = 'not in split';
|
|
8
|
-
export var UNSUPPORTED_MATCHER_TYPE = 'unsupported
|
|
8
|
+
export var UNSUPPORTED_MATCHER_TYPE = 'targeting rule type unsupported by sdk';
|
|
@@ -54,7 +54,7 @@ export var base = {
|
|
|
54
54
|
// Telemetry Server
|
|
55
55
|
telemetry: 'https://telemetry.split.io/api',
|
|
56
56
|
},
|
|
57
|
-
// Defines which kind of storage we should
|
|
57
|
+
// Defines which kind of storage we should instantiate.
|
|
58
58
|
storage: undefined,
|
|
59
59
|
// Defines if the logs are enabled, SDK wide.
|
|
60
60
|
debug: undefined,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Logger, LogLevels } from '../../../logger';
|
|
2
2
|
import { getLogLevel } from './commons';
|
|
3
3
|
function isLogger(log) {
|
|
4
|
-
return log && typeof log.debug === 'function' && typeof log.info === 'function' && typeof log.warn === 'function' && typeof log.error === 'function' && typeof log.setLogLevel === 'function';
|
|
4
|
+
return log !== null && typeof log === 'object' && typeof log.debug === 'function' && typeof log.info === 'function' && typeof log.warn === 'function' && typeof log.error === 'function' && typeof log.setLogLevel === 'function';
|
|
5
5
|
}
|
|
6
6
|
// By default it starts disabled.
|
|
7
7
|
var initialLogLevel = LogLevels.NONE;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splitsoftware/splitio-commons",
|
|
3
|
-
"version": "1.13.2-rc.
|
|
3
|
+
"version": "1.13.2-rc.10",
|
|
4
4
|
"description": "Split JavaScript SDK common components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"@typescript-eslint/eslint-plugin": "^6.6.0",
|
|
64
64
|
"@typescript-eslint/parser": "^6.6.0",
|
|
65
65
|
"cross-env": "^7.0.2",
|
|
66
|
-
"csv-streamify": "^4.0.0",
|
|
67
66
|
"eslint": "^8.48.0",
|
|
68
67
|
"eslint-plugin-compat": "^4.2.0",
|
|
69
68
|
"eslint-plugin-import": "^2.25.3",
|
package/src/dtos/types.ts
CHANGED
|
@@ -17,6 +17,11 @@ export interface IBetweenMatcherData {
|
|
|
17
17
|
end: number
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export interface IBetweenStringMatcherData {
|
|
21
|
+
start: string
|
|
22
|
+
end: string
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
export interface IWhitelistMatcherData {
|
|
21
26
|
whitelist: string[]
|
|
22
27
|
}
|
|
@@ -44,6 +49,7 @@ interface ISplitMatcherBase {
|
|
|
44
49
|
dependencyMatcherData?: null | IDependencyMatcherData
|
|
45
50
|
booleanMatcherData?: null | boolean
|
|
46
51
|
stringMatcherData?: null | string
|
|
52
|
+
betweenStringMatcherData?: null | IBetweenStringMatcherData
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
interface IAllKeysMatcher extends ISplitMatcherBase {
|
|
@@ -130,9 +136,36 @@ interface IMatchesStringMatcher extends ISplitMatcherBase {
|
|
|
130
136
|
stringMatcherData: string
|
|
131
137
|
}
|
|
132
138
|
|
|
139
|
+
interface IEqualToSemverMatcher extends ISplitMatcherBase {
|
|
140
|
+
matcherType: 'EQUAL_TO_SEMVER',
|
|
141
|
+
stringMatcherData: string
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
interface IGreaterThanOrEqualToSemverMatcher extends ISplitMatcherBase {
|
|
145
|
+
matcherType: 'GREATER_THAN_OR_EQUAL_TO_SEMVER',
|
|
146
|
+
stringMatcherData: string
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
interface ILessThanOrEqualToSemverMatcher extends ISplitMatcherBase {
|
|
151
|
+
matcherType: 'LESS_THAN_OR_EQUAL_TO_SEMVER',
|
|
152
|
+
stringMatcherData: string
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
interface IBetweenSemverMatcher extends ISplitMatcherBase {
|
|
156
|
+
matcherType: 'BETWEEN_SEMVER'
|
|
157
|
+
betweenStringMatcherData: IBetweenStringMatcherData
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
interface IInListSemverMatcher extends ISplitMatcherBase {
|
|
161
|
+
matcherType: 'IN_LIST_SEMVER',
|
|
162
|
+
whitelistMatcherData: IWhitelistMatcherData
|
|
163
|
+
}
|
|
164
|
+
|
|
133
165
|
export type ISplitMatcher = IAllKeysMatcher | IInSegmentMatcher | IWhitelistMatcher | IEqualToMatcher | IGreaterThanOrEqualToMatcher |
|
|
134
166
|
ILessThanOrEqualToMatcher | IBetweenMatcher | IEqualToSetMatcher | IContainsAnyOfSetMatcher | IContainsAllOfSetMatcher | IPartOfSetMatcher |
|
|
135
|
-
IStartsWithMatcher | IEndsWithMatcher | IContainsStringMatcher | IInSplitTreatmentMatcher | IEqualToBooleanMatcher | IMatchesStringMatcher
|
|
167
|
+
IStartsWithMatcher | IEndsWithMatcher | IContainsStringMatcher | IInSplitTreatmentMatcher | IEqualToBooleanMatcher | IMatchesStringMatcher |
|
|
168
|
+
IEqualToSemverMatcher | IGreaterThanOrEqualToSemverMatcher | ILessThanOrEqualToSemverMatcher | IBetweenSemverMatcher | IInListSemverMatcher
|
|
136
169
|
|
|
137
170
|
/** Split object */
|
|
138
171
|
export interface ISplitPartition {
|
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
|
|
|
@@ -50,7 +50,7 @@ export function ifElseIfCombinerContext(log: ILogger, predicates: IEvaluator[]):
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// if there is none predicates, then there was an error in parsing phase
|
|
53
|
-
if (!Array.isArray(predicates) ||
|
|
53
|
+
if (!Array.isArray(predicates) || predicates.length === 0) {
|
|
54
54
|
return unexpectedInputHandler;
|
|
55
55
|
} else {
|
|
56
56
|
return ifElseIfCombiner;
|
|
@@ -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) /*: Function */ {
|
|
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) /*: Function */ {
|
|
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[]) /*: F
|
|
|
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
|
}
|