@splitsoftware/splitio-commons 2.2.0 → 2.2.1-rc.0
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 -0
- package/README.md +1 -0
- package/cjs/evaluator/Engine.js +40 -61
- package/cjs/evaluator/combiners/and.js +2 -6
- package/cjs/evaluator/combiners/ifelseif.js +6 -6
- package/cjs/evaluator/condition/index.js +6 -5
- package/cjs/evaluator/index.js +11 -11
- package/cjs/evaluator/matchers/index.js +3 -1
- package/cjs/evaluator/matchers/matcherTypes.js +1 -0
- package/cjs/evaluator/matchers/prerequisites.js +22 -0
- package/cjs/evaluator/matchers/rbsegment.js +44 -0
- package/cjs/evaluator/matchersTransform/index.js +4 -0
- package/cjs/evaluator/parser/index.js +2 -2
- package/cjs/evaluator/value/sanitize.js +1 -0
- package/cjs/logger/constants.js +5 -3
- package/cjs/logger/messages/debug.js +4 -2
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/sdkManager/index.js +2 -1
- package/cjs/services/splitApi.js +3 -4
- package/cjs/storages/AbstractSplitsCacheSync.js +5 -2
- package/cjs/storages/KeyBuilder.js +9 -0
- package/cjs/storages/KeyBuilderCS.js +3 -0
- package/cjs/storages/KeyBuilderSS.js +3 -0
- package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +117 -0
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +9 -14
- package/cjs/storages/inLocalStorage/index.js +5 -1
- package/cjs/storages/inLocalStorage/validateCache.js +2 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +3 -0
- package/cjs/storages/inMemory/InMemoryStorageCS.js +4 -0
- package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +61 -0
- package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +64 -0
- package/cjs/storages/inRedis/index.js +2 -0
- package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +64 -0
- package/cjs/storages/pluggable/index.js +2 -0
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +51 -4
- package/cjs/sync/polling/pollingManagerCS.js +7 -7
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +51 -33
- package/cjs/sync/streaming/SSEHandler/index.js +1 -0
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +106 -77
- package/cjs/sync/streaming/constants.js +2 -1
- package/cjs/sync/streaming/pushManager.js +3 -16
- package/cjs/sync/syncManagerOnline.js +2 -2
- package/cjs/utils/constants/index.js +3 -2
- package/cjs/utils/labels/index.js +2 -1
- package/esm/evaluator/Engine.js +40 -62
- package/esm/evaluator/combiners/and.js +2 -6
- package/esm/evaluator/combiners/ifelseif.js +7 -7
- package/esm/evaluator/condition/index.js +6 -5
- package/esm/evaluator/index.js +12 -12
- package/esm/evaluator/matchers/index.js +3 -1
- package/esm/evaluator/matchers/matcherTypes.js +1 -0
- package/esm/evaluator/matchers/prerequisites.js +18 -0
- package/esm/evaluator/matchers/rbsegment.js +40 -0
- package/esm/evaluator/matchersTransform/index.js +4 -0
- package/esm/evaluator/parser/index.js +2 -2
- package/esm/evaluator/value/sanitize.js +1 -0
- package/esm/logger/constants.js +2 -0
- package/esm/logger/messages/debug.js +4 -2
- package/esm/logger/messages/warn.js +1 -1
- package/esm/sdkManager/index.js +2 -1
- package/esm/services/splitApi.js +3 -4
- package/esm/storages/AbstractSplitsCacheSync.js +5 -2
- package/esm/storages/KeyBuilder.js +9 -0
- package/esm/storages/KeyBuilderCS.js +3 -0
- package/esm/storages/KeyBuilderSS.js +3 -0
- package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +114 -0
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +9 -14
- package/esm/storages/inLocalStorage/index.js +5 -1
- package/esm/storages/inLocalStorage/validateCache.js +2 -1
- package/esm/storages/inMemory/InMemoryStorage.js +3 -0
- package/esm/storages/inMemory/InMemoryStorageCS.js +4 -0
- package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +58 -0
- package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +61 -0
- package/esm/storages/inRedis/index.js +2 -0
- package/esm/storages/pluggable/RBSegmentsCachePluggable.js +61 -0
- package/esm/storages/pluggable/index.js +2 -0
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +51 -4
- package/esm/sync/polling/pollingManagerCS.js +7 -7
- package/esm/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/esm/sync/polling/updaters/splitChangesUpdater.js +51 -33
- package/esm/sync/streaming/SSEHandler/index.js +2 -1
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +102 -73
- package/esm/sync/streaming/constants.js +1 -0
- package/esm/sync/streaming/pushManager.js +6 -19
- package/esm/sync/syncManagerOnline.js +2 -2
- package/esm/utils/constants/index.js +2 -1
- package/esm/utils/labels/index.js +1 -0
- package/package.json +1 -1
- package/src/dtos/types.ts +36 -8
- package/src/evaluator/Engine.ts +42 -69
- package/src/evaluator/combiners/and.ts +5 -4
- package/src/evaluator/combiners/ifelseif.ts +7 -9
- package/src/evaluator/condition/engineUtils.ts +1 -1
- package/src/evaluator/condition/index.ts +12 -12
- package/src/evaluator/index.ts +12 -14
- package/src/evaluator/matchers/index.ts +3 -1
- package/src/evaluator/matchers/matcherTypes.ts +1 -0
- package/src/evaluator/matchers/prerequisites.ts +24 -0
- package/src/evaluator/matchers/rbsegment.ts +62 -0
- package/src/evaluator/matchersTransform/index.ts +3 -0
- package/src/evaluator/parser/index.ts +3 -3
- package/src/evaluator/types.ts +2 -2
- package/src/evaluator/value/index.ts +2 -2
- package/src/evaluator/value/sanitize.ts +5 -4
- package/src/logger/constants.ts +2 -0
- package/src/logger/messages/debug.ts +4 -2
- package/src/logger/messages/warn.ts +1 -1
- package/src/sdkManager/index.ts +3 -2
- package/src/services/splitApi.ts +3 -4
- package/src/services/types.ts +1 -1
- package/src/storages/AbstractSplitsCacheSync.ts +6 -3
- package/src/storages/KeyBuilder.ts +12 -0
- package/src/storages/KeyBuilderCS.ts +4 -0
- package/src/storages/KeyBuilderSS.ts +4 -0
- package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +136 -0
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +10 -14
- package/src/storages/inLocalStorage/index.ts +5 -1
- package/src/storages/inLocalStorage/validateCache.ts +3 -1
- package/src/storages/inMemory/InMemoryStorage.ts +3 -0
- package/src/storages/inMemory/InMemoryStorageCS.ts +4 -0
- package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +68 -0
- package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +79 -0
- package/src/storages/inRedis/index.ts +2 -0
- package/src/storages/pluggable/RBSegmentsCachePluggable.ts +76 -0
- package/src/storages/pluggable/index.ts +2 -0
- package/src/storages/types.ts +33 -1
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +62 -4
- package/src/sync/polling/fetchers/types.ts +1 -0
- package/src/sync/polling/pollingManagerCS.ts +7 -7
- package/src/sync/polling/syncTasks/splitsSyncTask.ts +1 -1
- package/src/sync/polling/types.ts +2 -2
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -2
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
- package/src/sync/polling/updaters/splitChangesUpdater.ts +61 -42
- package/src/sync/streaming/SSEHandler/index.ts +2 -1
- package/src/sync/streaming/SSEHandler/types.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +98 -68
- package/src/sync/streaming/constants.ts +1 -0
- package/src/sync/streaming/parseUtils.ts +2 -2
- package/src/sync/streaming/pushManager.ts +6 -18
- package/src/sync/streaming/types.ts +3 -2
- package/src/sync/syncManagerOnline.ts +2 -2
- package/src/utils/constants/index.ts +2 -1
- package/src/utils/labels/index.ts +1 -0
- package/src/utils/lang/index.ts +1 -1
- package/types/splitio.d.ts +5 -1
package/CHANGES.txt
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
2.3.0 (April XXX, 2025)
|
|
2
|
+
- Added support for targeting rules based on rule-based segments.
|
|
3
|
+
- Added support for feature flag prerequisites.
|
|
4
|
+
|
|
1
5
|
2.2.0 (March 28, 2025)
|
|
2
6
|
- Added a new optional argument to the client `getTreatment` methods to allow passing additional evaluation options, such as a map of properties to append to the generated impressions sent to Split backend. Read more in our docs.
|
|
3
7
|
- Added two new configuration options for the SDK storage in browsers when using storage type `LOCALSTORAGE`:
|
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ Split has built and maintains SDKs for:
|
|
|
27
27
|
* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
|
|
28
28
|
* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
|
|
29
29
|
* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
|
|
30
|
+
* Elixir thin-client [Github](https://github.com/splitio/elixir-thin-client) [Docs](https://help.split.io/hc/en-us/articles/26988707417869-Elixir-Thin-Client-SDK)
|
|
30
31
|
* Flutter [Github](https://github.com/splitio/flutter-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/8096158017165-Flutter-plugin)
|
|
31
32
|
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
|
|
32
33
|
* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
|
package/cjs/evaluator/Engine.js
CHANGED
|
@@ -1,79 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.engineParser = void 0;
|
|
4
4
|
var lang_1 = require("../utils/lang");
|
|
5
5
|
var parser_1 = require("./parser");
|
|
6
6
|
var key_1 = require("../utils/key");
|
|
7
7
|
var thenable_1 = require("../utils/promise/thenable");
|
|
8
8
|
var labels_1 = require("../utils/labels");
|
|
9
9
|
var constants_1 = require("../utils/constants");
|
|
10
|
+
var constants_2 = require("../logger/constants");
|
|
11
|
+
var prerequisites_1 = require("./matchers/prerequisites");
|
|
10
12
|
function evaluationResult(result, defaultTreatment) {
|
|
11
13
|
return {
|
|
12
14
|
treatment: (0, lang_1.get)(result, 'treatment', defaultTreatment),
|
|
13
15
|
label: (0, lang_1.get)(result, 'label', labels_1.NO_CONDITION_MATCH)
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var treatment;
|
|
37
|
-
var label;
|
|
38
|
-
try {
|
|
39
|
-
parsedKey = (0, key_1.keyParser)(key);
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
return {
|
|
43
|
-
treatment: constants_1.CONTROL,
|
|
44
|
-
label: labels_1.EXCEPTION
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
if (this.isGarbage()) {
|
|
48
|
-
treatment = constants_1.CONTROL;
|
|
49
|
-
label = labels_1.SPLIT_ARCHIVED;
|
|
50
|
-
}
|
|
51
|
-
else if (killed) {
|
|
52
|
-
treatment = defaultTreatment;
|
|
53
|
-
label = labels_1.SPLIT_KILLED;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
var evaluation = this.evaluator(parsedKey, seed, trafficAllocation, trafficAllocationSeed, attributes, splitEvaluator);
|
|
57
|
-
// Evaluation could be async, so we should handle that case checking for a
|
|
58
|
-
// thenable object
|
|
59
|
-
if ((0, thenable_1.thenable)(evaluation)) {
|
|
60
|
-
return evaluation.then(function (result) { return evaluationResult(result, defaultTreatment); });
|
|
18
|
+
function engineParser(log, split, storage) {
|
|
19
|
+
var killed = split.killed, seed = split.seed, trafficAllocation = split.trafficAllocation, trafficAllocationSeed = split.trafficAllocationSeed, status = split.status, conditions = split.conditions, prerequisites = split.prerequisites;
|
|
20
|
+
var defaultTreatment = (0, lang_1.isString)(split.defaultTreatment) ? split.defaultTreatment : constants_1.CONTROL;
|
|
21
|
+
var evaluator = (0, parser_1.parser)(log, conditions, storage);
|
|
22
|
+
var prerequisiteMatcher = (0, prerequisites_1.prerequisitesMatcherContext)(prerequisites, storage, log);
|
|
23
|
+
return {
|
|
24
|
+
getTreatment: function (key, attributes, splitEvaluator) {
|
|
25
|
+
var parsedKey = (0, key_1.keyParser)(key);
|
|
26
|
+
function evaluate(prerequisitesMet) {
|
|
27
|
+
if (!prerequisitesMet) {
|
|
28
|
+
log.debug(constants_2.ENGINE_DEFAULT, ['Prerequisite not met']);
|
|
29
|
+
return {
|
|
30
|
+
treatment: defaultTreatment,
|
|
31
|
+
label: labels_1.PREREQUISITES_NOT_MET
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
var evaluation = evaluator(parsedKey, seed, trafficAllocation, trafficAllocationSeed, attributes, splitEvaluator);
|
|
35
|
+
return (0, thenable_1.thenable)(evaluation) ?
|
|
36
|
+
evaluation.then(function (result) { return evaluationResult(result, defaultTreatment); }) :
|
|
37
|
+
evaluationResult(evaluation, defaultTreatment);
|
|
61
38
|
}
|
|
62
|
-
|
|
63
|
-
return
|
|
39
|
+
if (status === 'ARCHIVED')
|
|
40
|
+
return {
|
|
41
|
+
treatment: constants_1.CONTROL,
|
|
42
|
+
label: labels_1.SPLIT_ARCHIVED
|
|
43
|
+
};
|
|
44
|
+
if (killed) {
|
|
45
|
+
log.debug(constants_2.ENGINE_DEFAULT, ['Flag is killed']);
|
|
46
|
+
return {
|
|
47
|
+
treatment: defaultTreatment,
|
|
48
|
+
label: labels_1.SPLIT_KILLED
|
|
49
|
+
};
|
|
64
50
|
}
|
|
51
|
+
var prerequisitesMet = prerequisiteMatcher({ key: key, attributes: attributes }, splitEvaluator);
|
|
52
|
+
return (0, thenable_1.thenable)(prerequisitesMet) ?
|
|
53
|
+
prerequisitesMet.then(evaluate) :
|
|
54
|
+
evaluate(prerequisitesMet);
|
|
65
55
|
}
|
|
66
|
-
return {
|
|
67
|
-
treatment: treatment,
|
|
68
|
-
label: label
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
Engine.prototype.isGarbage = function () {
|
|
72
|
-
return this.baseInfo.status === 'ARCHIVED';
|
|
73
56
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
77
|
-
return Engine;
|
|
78
|
-
}());
|
|
79
|
-
exports.Engine = Engine;
|
|
57
|
+
}
|
|
58
|
+
exports.engineParser = engineParser;
|
|
@@ -11,12 +11,8 @@ function andCombinerContext(log, matchers) {
|
|
|
11
11
|
log.debug(constants_1.ENGINE_COMBINER_AND, [hasMatchedAll]);
|
|
12
12
|
return hasMatchedAll;
|
|
13
13
|
}
|
|
14
|
-
return function andCombiner() {
|
|
15
|
-
var
|
|
16
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
17
|
-
params[_i] = arguments[_i];
|
|
18
|
-
}
|
|
19
|
-
var matcherResults = matchers.map(function (matcher) { return matcher.apply(void 0, params); });
|
|
14
|
+
return function andCombiner(key, attributes, splitEvaluator) {
|
|
15
|
+
var matcherResults = matchers.map(function (matcher) { return matcher(key, attributes, splitEvaluator); });
|
|
20
16
|
// If any matching result is a thenable we should use Promise.all
|
|
21
17
|
if ((0, lang_1.findIndex)(matcherResults, thenable_1.thenable) !== -1) {
|
|
22
18
|
return Promise.all(matcherResults).then(andResults);
|
|
@@ -14,12 +14,12 @@ function ifElseIfCombinerContext(log, predicates) {
|
|
|
14
14
|
label: labels_1.UNSUPPORTED_MATCHER_TYPE
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
var len = predicateResults.length;
|
|
19
|
-
for (var i = 0; i < len; i++) {
|
|
17
|
+
function computeEvaluation(predicateResults) {
|
|
18
|
+
for (var i = 0, len = predicateResults.length; i < len; i++) {
|
|
20
19
|
var evaluation = predicateResults[i];
|
|
21
20
|
if (evaluation !== undefined) {
|
|
22
|
-
|
|
21
|
+
if (!(0, lang_1.isBoolean)(evaluation))
|
|
22
|
+
log.debug(constants_2.ENGINE_COMBINER_IFELSEIF, [evaluation.treatment]);
|
|
23
23
|
return evaluation;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -33,9 +33,9 @@ function ifElseIfCombinerContext(log, predicates) {
|
|
|
33
33
|
var predicateResults = predicates.map(function (evaluator) { return evaluator(key, seed, trafficAllocation, trafficAllocationSeed, attributes, splitEvaluator); });
|
|
34
34
|
// if we find a thenable
|
|
35
35
|
if ((0, lang_1.findIndex)(predicateResults, thenable_1.thenable) !== -1) {
|
|
36
|
-
return Promise.all(predicateResults).then(function (results) { return
|
|
36
|
+
return Promise.all(predicateResults).then(function (results) { return computeEvaluation(results); });
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return computeEvaluation(predicateResults);
|
|
39
39
|
}
|
|
40
40
|
// if there is none predicates, then there was an error in parsing phase
|
|
41
41
|
if (!Array.isArray(predicates) || predicates.length === 0) {
|
|
@@ -7,11 +7,12 @@ var labels_1 = require("../../utils/labels");
|
|
|
7
7
|
// Build Evaluation object if and only if matchingResult is true
|
|
8
8
|
function match(log, matchingResult, bucketingKey, seed, treatments, label) {
|
|
9
9
|
if (matchingResult) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
return treatments ? // Feature flag
|
|
11
|
+
{
|
|
12
|
+
treatment: (0, engineUtils_1.getTreatment)(log, bucketingKey, seed, treatments),
|
|
13
|
+
label: label
|
|
14
|
+
} : // Rule-based segment
|
|
15
|
+
true;
|
|
15
16
|
}
|
|
16
17
|
// else we should notify the engine to continue evaluating
|
|
17
18
|
return undefined;
|
package/cjs/evaluator/index.js
CHANGED
|
@@ -29,12 +29,12 @@ function evaluateFeature(log, key, splitName, attributes, storage) {
|
|
|
29
29
|
return treatmentException;
|
|
30
30
|
}
|
|
31
31
|
if ((0, thenable_1.thenable)(parsedSplit)) {
|
|
32
|
-
return parsedSplit.then(function (split) { return getEvaluation(log,
|
|
32
|
+
return parsedSplit.then(function (split) { return getEvaluation(log, key, split, attributes, storage); }).catch(
|
|
33
33
|
// Exception on async `getSplit` storage. For example, when the storage is redis or
|
|
34
34
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
35
35
|
function () { return treatmentException; });
|
|
36
36
|
}
|
|
37
|
-
return getEvaluation(log,
|
|
37
|
+
return getEvaluation(log, key, parsedSplit, attributes, storage);
|
|
38
38
|
}
|
|
39
39
|
exports.evaluateFeature = evaluateFeature;
|
|
40
40
|
function evaluateFeatures(log, key, splitNames, attributes, storage) {
|
|
@@ -47,13 +47,13 @@ function evaluateFeatures(log, key, splitNames, attributes, storage) {
|
|
|
47
47
|
return treatmentsException(splitNames);
|
|
48
48
|
}
|
|
49
49
|
return (0, thenable_1.thenable)(parsedSplits) ?
|
|
50
|
-
parsedSplits.then(function (splits) { return getEvaluations(log, splitNames, splits,
|
|
50
|
+
parsedSplits.then(function (splits) { return getEvaluations(log, key, splitNames, splits, attributes, storage); })
|
|
51
51
|
.catch(function () {
|
|
52
52
|
// Exception on async `getSplits` storage. For example, when the storage is redis or
|
|
53
53
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
54
54
|
return treatmentsException(splitNames);
|
|
55
55
|
}) :
|
|
56
|
-
getEvaluations(log, splitNames, parsedSplits,
|
|
56
|
+
getEvaluations(log, key, splitNames, parsedSplits, attributes, storage);
|
|
57
57
|
}
|
|
58
58
|
exports.evaluateFeatures = evaluateFeatures;
|
|
59
59
|
function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method) {
|
|
@@ -90,37 +90,37 @@ function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, met
|
|
|
90
90
|
evaluate(storedFlagNames);
|
|
91
91
|
}
|
|
92
92
|
exports.evaluateFeaturesByFlagSets = evaluateFeaturesByFlagSets;
|
|
93
|
-
function getEvaluation(log,
|
|
93
|
+
function getEvaluation(log, key, splitJSON, attributes, storage) {
|
|
94
94
|
var evaluation = {
|
|
95
95
|
treatment: constants_1.CONTROL,
|
|
96
96
|
label: labels_1.SPLIT_NOT_FOUND,
|
|
97
97
|
config: null
|
|
98
98
|
};
|
|
99
99
|
if (splitJSON) {
|
|
100
|
-
var
|
|
101
|
-
evaluation =
|
|
100
|
+
var split = (0, Engine_1.engineParser)(log, splitJSON, storage);
|
|
101
|
+
evaluation = split.getTreatment(key, attributes, evaluateFeature);
|
|
102
102
|
// If the storage is async and the evaluated flag uses segments or dependencies, evaluation is thenable
|
|
103
103
|
if ((0, thenable_1.thenable)(evaluation)) {
|
|
104
104
|
return evaluation.then(function (result) {
|
|
105
|
-
result.changeNumber =
|
|
105
|
+
result.changeNumber = splitJSON.changeNumber;
|
|
106
106
|
result.config = splitJSON.configurations && splitJSON.configurations[result.treatment] || null;
|
|
107
107
|
result.impressionsDisabled = splitJSON.impressionsDisabled;
|
|
108
108
|
return result;
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
else {
|
|
112
|
-
evaluation.changeNumber =
|
|
112
|
+
evaluation.changeNumber = splitJSON.changeNumber;
|
|
113
113
|
evaluation.config = splitJSON.configurations && splitJSON.configurations[evaluation.treatment] || null;
|
|
114
114
|
evaluation.impressionsDisabled = splitJSON.impressionsDisabled;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
return evaluation;
|
|
118
118
|
}
|
|
119
|
-
function getEvaluations(log, splitNames, splits,
|
|
119
|
+
function getEvaluations(log, key, splitNames, splits, attributes, storage) {
|
|
120
120
|
var result = {};
|
|
121
121
|
var thenables = [];
|
|
122
122
|
splitNames.forEach(function (splitName) {
|
|
123
|
-
var evaluation = getEvaluation(log, splits[splitName],
|
|
123
|
+
var evaluation = getEvaluation(log, key, splits[splitName], attributes, storage);
|
|
124
124
|
if ((0, thenable_1.thenable)(evaluation)) {
|
|
125
125
|
thenables.push(evaluation.then(function (res) {
|
|
126
126
|
result[splitName] = res;
|
|
@@ -24,6 +24,7 @@ var semver_gte_1 = require("./semver_gte");
|
|
|
24
24
|
var semver_lte_1 = require("./semver_lte");
|
|
25
25
|
var semver_between_1 = require("./semver_between");
|
|
26
26
|
var semver_inlist_1 = require("./semver_inlist");
|
|
27
|
+
var rbsegment_1 = require("./rbsegment");
|
|
27
28
|
var matchers = [
|
|
28
29
|
undefined,
|
|
29
30
|
all_1.allMatcherContext,
|
|
@@ -48,7 +49,8 @@ var matchers = [
|
|
|
48
49
|
semver_lte_1.lessThanEqualToSemverMatcherContext,
|
|
49
50
|
semver_between_1.betweenSemverMatcherContext,
|
|
50
51
|
semver_inlist_1.inListSemverMatcherContext,
|
|
51
|
-
large_segment_1.largeSegmentMatcherContext,
|
|
52
|
+
large_segment_1.largeSegmentMatcherContext,
|
|
53
|
+
rbsegment_1.ruleBasedSegmentMatcherContext // IN_RULE_BASED_SEGMENT: 24
|
|
52
54
|
];
|
|
53
55
|
/**
|
|
54
56
|
* Matcher factory.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prerequisitesMatcherContext = void 0;
|
|
4
|
+
var thenable_1 = require("../../utils/promise/thenable");
|
|
5
|
+
function prerequisitesMatcherContext(prerequisites, storage, log) {
|
|
6
|
+
if (prerequisites === void 0) { prerequisites = []; }
|
|
7
|
+
return function prerequisitesMatcher(_a, splitEvaluator) {
|
|
8
|
+
var key = _a.key, attributes = _a.attributes;
|
|
9
|
+
function evaluatePrerequisite(prerequisite) {
|
|
10
|
+
var evaluation = splitEvaluator(log, key, prerequisite.n, attributes, storage);
|
|
11
|
+
return (0, thenable_1.thenable)(evaluation) ?
|
|
12
|
+
evaluation.then(function (evaluation) { return prerequisite.ts.indexOf(evaluation.treatment) !== -1; }) :
|
|
13
|
+
prerequisite.ts.indexOf(evaluation.treatment) !== -1;
|
|
14
|
+
}
|
|
15
|
+
return prerequisites.reduce(function (prerequisitesMet, prerequisite) {
|
|
16
|
+
return (0, thenable_1.thenable)(prerequisitesMet) ?
|
|
17
|
+
prerequisitesMet.then(function (prerequisitesMet) { return prerequisitesMet ? evaluatePrerequisite(prerequisite) : false; }) :
|
|
18
|
+
prerequisitesMet ? evaluatePrerequisite(prerequisite) : false;
|
|
19
|
+
}, true);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.prerequisitesMatcherContext = prerequisitesMatcherContext;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ruleBasedSegmentMatcherContext = void 0;
|
|
4
|
+
var thenable_1 = require("../../utils/promise/thenable");
|
|
5
|
+
var key_1 = require("../../utils/key");
|
|
6
|
+
var parser_1 = require("../parser");
|
|
7
|
+
function ruleBasedSegmentMatcherContext(segmentName, storage, log) {
|
|
8
|
+
return function ruleBasedSegmentMatcher(_a, splitEvaluator) {
|
|
9
|
+
var key = _a.key, attributes = _a.attributes;
|
|
10
|
+
function matchConditions(rbsegment) {
|
|
11
|
+
var conditions = rbsegment.conditions || [];
|
|
12
|
+
var evaluator = (0, parser_1.parser)(log, conditions, storage);
|
|
13
|
+
var evaluation = evaluator((0, key_1.keyParser)(key), undefined, undefined, undefined, attributes, splitEvaluator);
|
|
14
|
+
return (0, thenable_1.thenable)(evaluation) ?
|
|
15
|
+
evaluation.then(function (evaluation) { return evaluation ? true : false; }) :
|
|
16
|
+
evaluation ? true : false;
|
|
17
|
+
}
|
|
18
|
+
function isExcluded(rbSegment) {
|
|
19
|
+
var matchingKey = (0, key_1.getMatching)(key);
|
|
20
|
+
var excluded = rbSegment.excluded || {};
|
|
21
|
+
if (excluded.keys && excluded.keys.indexOf(matchingKey) !== -1)
|
|
22
|
+
return true;
|
|
23
|
+
var isInSegment = (excluded.segments || []).map(function (segmentName) {
|
|
24
|
+
return storage.segments.isInSegment(segmentName, matchingKey);
|
|
25
|
+
});
|
|
26
|
+
return isInSegment.length && (0, thenable_1.thenable)(isInSegment[0]) ?
|
|
27
|
+
Promise.all(isInSegment).then(function (results) { return results.some(function (result) { return result; }); }) :
|
|
28
|
+
isInSegment.some(function (result) { return result; });
|
|
29
|
+
}
|
|
30
|
+
function isInSegment(rbSegment) {
|
|
31
|
+
if (!rbSegment)
|
|
32
|
+
return false;
|
|
33
|
+
var excluded = isExcluded(rbSegment);
|
|
34
|
+
return (0, thenable_1.thenable)(excluded) ?
|
|
35
|
+
excluded.then(function (excluded) { return excluded ? false : matchConditions(rbSegment); }) :
|
|
36
|
+
excluded ? false : matchConditions(rbSegment);
|
|
37
|
+
}
|
|
38
|
+
var rbSegment = storage.rbSegments.get(segmentName);
|
|
39
|
+
return (0, thenable_1.thenable)(rbSegment) ?
|
|
40
|
+
rbSegment.then(isInSegment) :
|
|
41
|
+
isInSegment(rbSegment);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.ruleBasedSegmentMatcherContext = ruleBasedSegmentMatcherContext;
|
|
@@ -81,6 +81,10 @@ function matchersTransform(matchers) {
|
|
|
81
81
|
type === matcherTypes_1.matcherTypes.LESS_THAN_OR_EQUAL_TO_SEMVER) {
|
|
82
82
|
value = stringMatcherData;
|
|
83
83
|
}
|
|
84
|
+
else if (type === matcherTypes_1.matcherTypes.IN_RULE_BASED_SEGMENT) {
|
|
85
|
+
value = (0, segment_1.segmentTransform)(userDefinedSegmentMatcherData);
|
|
86
|
+
dataType = matcherTypes_1.matcherDataTypes.NOT_SPECIFIED;
|
|
87
|
+
}
|
|
84
88
|
return {
|
|
85
89
|
attribute: attribute,
|
|
86
90
|
negate: negate,
|
|
@@ -53,9 +53,9 @@ function parser(log, conditions, storage) {
|
|
|
53
53
|
// and break the loop
|
|
54
54
|
break;
|
|
55
55
|
}
|
|
56
|
-
predicates.push((0, condition_1.conditionContext)(log, (0, and_1.andCombinerContext)(log, expressions), treatments_1.Treatments.parse(partitions), label, conditionType));
|
|
56
|
+
predicates.push((0, condition_1.conditionContext)(log, (0, and_1.andCombinerContext)(log, expressions), partitions && treatments_1.Treatments.parse(partitions), label, conditionType));
|
|
57
57
|
}
|
|
58
|
-
//
|
|
58
|
+
// Instantiate evaluator given the set of conditions using if else if logic
|
|
59
59
|
return (0, ifelseif_1.ifElseIfCombinerContext)(log, predicates);
|
|
60
60
|
}
|
|
61
61
|
exports.parser = parser;
|
|
@@ -52,6 +52,7 @@ function getProcessingFunction(matcherTypeID, dataType) {
|
|
|
52
52
|
case matcherTypes_1.matcherTypes.BETWEEN:
|
|
53
53
|
return dataType === 'DATETIME' ? convertions_1.zeroSinceSS : undefined;
|
|
54
54
|
case matcherTypes_1.matcherTypes.IN_SPLIT_TREATMENT:
|
|
55
|
+
case matcherTypes_1.matcherTypes.IN_RULE_BASED_SEGMENT:
|
|
55
56
|
return dependencyProcessor;
|
|
56
57
|
default:
|
|
57
58
|
return undefined;
|
package/cjs/logger/constants.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
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_CLIENT_INSTANTIATION = 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 = void 0;
|
|
3
|
+
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 = 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.ENGINE_DEFAULT = exports.ENGINE_MATCHER_RESULT = exports.SETTINGS_SPLITS_FILTER = exports.SYNC_TASK_STOP = exports.SYNC_TASK_EXECUTE = exports.SYNC_TASK_START = exports.STREAMING_NEW_MESSAGE = exports.SYNC_RBS_UPDATE = exports.SYNC_SPLITS_UPDATE = 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_DEPENDENCY_PRE = exports.ENGINE_MATCHER_DEPENDENCY = exports.ENGINE_BUCKET = exports.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = exports.ENGINE_COMBINER_IFELSEIF = exports.ENGINE_COMBINER_AND = void 0;
|
|
4
|
+
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 = 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_MEMBERSHIPS_UPDATE = 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 = 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_CLIENT_INSTANTIATION = 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_HTTP = 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.
|
|
@@ -26,12 +26,14 @@ exports.RETRIEVE_MANAGER = 29;
|
|
|
26
26
|
exports.SYNC_OFFLINE_DATA = 30;
|
|
27
27
|
exports.SYNC_SPLITS_FETCH = 31;
|
|
28
28
|
exports.SYNC_SPLITS_UPDATE = 32;
|
|
29
|
+
exports.SYNC_RBS_UPDATE = 33;
|
|
29
30
|
exports.STREAMING_NEW_MESSAGE = 35;
|
|
30
31
|
exports.SYNC_TASK_START = 36;
|
|
31
32
|
exports.SYNC_TASK_EXECUTE = 37;
|
|
32
33
|
exports.SYNC_TASK_STOP = 38;
|
|
33
34
|
exports.SETTINGS_SPLITS_FILTER = 39;
|
|
34
35
|
exports.ENGINE_MATCHER_RESULT = 40;
|
|
36
|
+
exports.ENGINE_DEFAULT = 41;
|
|
35
37
|
exports.CLIENT_READY_FROM_CACHE = 100;
|
|
36
38
|
exports.CLIENT_READY = 101;
|
|
37
39
|
exports.IMPRESSION = 102;
|
|
@@ -15,6 +15,7 @@ exports.codesDebug = info_1.codesInfo.concat([
|
|
|
15
15
|
[c.ENGINE_VALUE, c.LOG_PREFIX_ENGINE_VALUE + 'Extracted attribute `%s`. %s will be used for matching.'],
|
|
16
16
|
[c.ENGINE_SANITIZE, c.LOG_PREFIX_ENGINE + ':sanitize: Attempted to sanitize %s which should be of type %s. Sanitized and processed value => %s'],
|
|
17
17
|
[c.ENGINE_MATCHER_RESULT, c.LOG_PREFIX_ENGINE_MATCHER + '[%s] Result: %s. Rule value: %s. Evaluation value: %s'],
|
|
18
|
+
[c.ENGINE_DEFAULT, c.LOG_PREFIX_ENGINE + 'Evaluates to default treatment. %s'],
|
|
18
19
|
// SDK
|
|
19
20
|
[c.CLEANUP_REGISTERING, c.LOG_PREFIX_CLEANUP + 'Registering cleanup handler %s'],
|
|
20
21
|
[c.CLEANUP_DEREGISTERING, c.LOG_PREFIX_CLEANUP + 'Deregistering cleanup handler %s'],
|
|
@@ -23,8 +24,9 @@ exports.codesDebug = info_1.codesInfo.concat([
|
|
|
23
24
|
[c.RETRIEVE_MANAGER, 'Retrieving manager instance.'],
|
|
24
25
|
// synchronizer
|
|
25
26
|
[c.SYNC_OFFLINE_DATA, c.LOG_PREFIX_SYNC_OFFLINE + 'Feature flags data: \n%s'],
|
|
26
|
-
[c.SYNC_SPLITS_FETCH, c.LOG_PREFIX_SYNC_SPLITS + 'Spin up feature flags update using since = %s'],
|
|
27
|
-
[c.SYNC_SPLITS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New feature flags %s. Removed feature flags %s.
|
|
27
|
+
[c.SYNC_SPLITS_FETCH, c.LOG_PREFIX_SYNC_SPLITS + 'Spin up feature flags update using since = %s and rbSince = %s.'],
|
|
28
|
+
[c.SYNC_SPLITS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New feature flags %s. Removed feature flags %s.'],
|
|
29
|
+
[c.SYNC_RBS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New rule-based segments %s. Removed rule-based segments %s.'],
|
|
28
30
|
[c.STREAMING_NEW_MESSAGE, c.LOG_PREFIX_SYNC_STREAMING + 'New SSE message received, with data: %s.'],
|
|
29
31
|
[c.SYNC_TASK_START, c.LOG_PREFIX_SYNC + ': Starting %s. Running each %s millis'],
|
|
30
32
|
[c.SYNC_TASK_EXECUTE, c.LOG_PREFIX_SYNC + ': Running %s'],
|
|
@@ -35,7 +35,7 @@ exports.codesWarn = error_1.codesError.concat([
|
|
|
35
35
|
[c.WARN_SPLITS_FILTER_EMPTY, c.LOG_PREFIX_SETTINGS + ': feature flag filter configuration must be a non-empty array of filter objects.'],
|
|
36
36
|
[c.WARN_SDK_KEY, c.LOG_PREFIX_SETTINGS + ': You already have %s. We recommend keeping only one instance of the factory at all times (Singleton pattern) and reusing it throughout your application'],
|
|
37
37
|
[c.STREAMING_PARSING_MEMBERSHIPS_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching Memberships due to an error processing %s notification: %s'],
|
|
38
|
-
[c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing
|
|
38
|
+
[c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing %s notification: %s'],
|
|
39
39
|
[c.WARN_INVALID_FLAGSET, '%s: you passed %s, flag set must adhere to the regular expressions %s. This means a flag set must start with a letter or number, be in lowercase, alphanumeric and have a max length of 50 characters. %s was discarded.'],
|
|
40
40
|
[c.WARN_LOWERCASE_FLAGSET, '%s: flag set %s should be all lowercase - converting string to lowercase.'],
|
|
41
41
|
[c.WARN_FLAGSET_WITHOUT_FLAGS, '%s: you passed %s flag set that does not contain cached feature flag names. Please double check what flag sets are in use in the Split user interface.'],
|
package/cjs/sdkManager/index.js
CHANGED
|
@@ -29,7 +29,8 @@ function objectToView(splitObject) {
|
|
|
29
29
|
configs: splitObject.configurations || {},
|
|
30
30
|
sets: splitObject.sets || [],
|
|
31
31
|
defaultTreatment: splitObject.defaultTreatment,
|
|
32
|
-
impressionsDisabled: splitObject.impressionsDisabled === true
|
|
32
|
+
impressionsDisabled: splitObject.impressionsDisabled === true,
|
|
33
|
+
prerequisites: (splitObject.prerequisites || []).map(function (p) { return ({ flagName: p.n, treatments: p.ts }); }),
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
function objectsToViews(splitObjects) {
|
package/cjs/services/splitApi.js
CHANGED
|
@@ -20,7 +20,6 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
20
20
|
var urls = settings.urls;
|
|
21
21
|
var filterQueryString = settings.sync.__splitFiltersValidation && settings.sync.__splitFiltersValidation.queryString;
|
|
22
22
|
var SplitSDKImpressionsMode = settings.sync.impressionsMode;
|
|
23
|
-
var flagSpecVersion = settings.sync.flagSpecVersion;
|
|
24
23
|
var splitHttpClient = (0, splitHttpClient_1.splitHttpClientFactory)(settings, platform);
|
|
25
24
|
return {
|
|
26
25
|
// @TODO throw errors if health check requests fail, to log them in the Synchronizer
|
|
@@ -33,7 +32,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
33
32
|
return splitHttpClient(url).then(function () { return true; }).catch(function () { return false; });
|
|
34
33
|
},
|
|
35
34
|
fetchAuth: function (userMatchingKeys) {
|
|
36
|
-
var url = urls.auth + "/v2/auth?s=" + flagSpecVersion;
|
|
35
|
+
var url = urls.auth + "/v2/auth?s=" + settings.sync.flagSpecVersion;
|
|
37
36
|
if (userMatchingKeys) { // `userMatchingKeys` is undefined in server-side
|
|
38
37
|
var queryParams = userMatchingKeys.map(userKeyToQueryParam).join('&');
|
|
39
38
|
if (queryParams)
|
|
@@ -41,8 +40,8 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
41
40
|
}
|
|
42
41
|
return splitHttpClient(url, undefined, telemetryTracker.trackHttp(constants_1.TOKEN));
|
|
43
42
|
},
|
|
44
|
-
fetchSplitChanges: function (since, noCache, till) {
|
|
45
|
-
var url = urls.sdk + "/splitChanges?s=" + flagSpecVersion + "&since=" + since + (filterQueryString || '') + (till ? '&till=' + till : '');
|
|
43
|
+
fetchSplitChanges: function (since, noCache, till, rbSince) {
|
|
44
|
+
var url = urls.sdk + "/splitChanges?s=" + settings.sync.flagSpecVersion + "&since=" + since + (rbSince ? '&rbSince=' + rbSince : '') + (filterQueryString || '') + (till ? '&till=' + till : '');
|
|
46
45
|
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(constants_1.SPLITS))
|
|
47
46
|
.catch(function (err) {
|
|
48
47
|
if (err.statusCode === 414)
|
|
@@ -53,8 +53,8 @@ exports.AbstractSplitsCacheSync = AbstractSplitsCacheSync;
|
|
|
53
53
|
* Given a parsed split, it returns a boolean flagging if its conditions use segments matchers (rules & whitelists).
|
|
54
54
|
* This util is intended to simplify the implementation of `splitsCache::usesSegments` method
|
|
55
55
|
*/
|
|
56
|
-
function usesSegments(
|
|
57
|
-
var conditions =
|
|
56
|
+
function usesSegments(ruleEntity) {
|
|
57
|
+
var conditions = ruleEntity.conditions || [];
|
|
58
58
|
for (var i = 0; i < conditions.length; i++) {
|
|
59
59
|
var matchers = conditions[i].matcherGroup.matchers;
|
|
60
60
|
for (var j = 0; j < matchers.length; j++) {
|
|
@@ -63,6 +63,9 @@ function usesSegments(split) {
|
|
|
63
63
|
return true;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
var excluded = ruleEntity.excluded;
|
|
67
|
+
if (excluded && excluded.segments && excluded.segments.length > 0)
|
|
68
|
+
return true;
|
|
66
69
|
return false;
|
|
67
70
|
}
|
|
68
71
|
exports.usesSegments = usesSegments;
|
|
@@ -28,6 +28,15 @@ var KeyBuilder = /** @class */ (function () {
|
|
|
28
28
|
KeyBuilder.prototype.buildSplitKeyPrefix = function () {
|
|
29
29
|
return this.prefix + ".split.";
|
|
30
30
|
};
|
|
31
|
+
KeyBuilder.prototype.buildRBSegmentKey = function (rbsegmentName) {
|
|
32
|
+
return this.prefix + ".rbsegment." + rbsegmentName;
|
|
33
|
+
};
|
|
34
|
+
KeyBuilder.prototype.buildRBSegmentsTillKey = function () {
|
|
35
|
+
return this.prefix + ".rbsegments.till";
|
|
36
|
+
};
|
|
37
|
+
KeyBuilder.prototype.buildRBSegmentKeyPrefix = function () {
|
|
38
|
+
return this.prefix + ".rbsegment.";
|
|
39
|
+
};
|
|
31
40
|
KeyBuilder.prototype.buildSegmentNameKey = function (segmentName) {
|
|
32
41
|
return this.prefix + ".segment." + segmentName;
|
|
33
42
|
};
|
|
@@ -35,6 +35,9 @@ var KeyBuilderCS = /** @class */ (function (_super) {
|
|
|
35
35
|
KeyBuilderCS.prototype.isSplitKey = function (key) {
|
|
36
36
|
return (0, lang_1.startsWith)(key, this.prefix + ".split.");
|
|
37
37
|
};
|
|
38
|
+
KeyBuilderCS.prototype.isRBSegmentKey = function (key) {
|
|
39
|
+
return (0, lang_1.startsWith)(key, this.prefix + ".rbsegment.");
|
|
40
|
+
};
|
|
38
41
|
KeyBuilderCS.prototype.buildSplitsWithSegmentCountKey = function () {
|
|
39
42
|
return this.prefix + ".splits.usingSegments";
|
|
40
43
|
};
|
|
@@ -42,6 +42,9 @@ var KeyBuilderSS = /** @class */ (function (_super) {
|
|
|
42
42
|
KeyBuilderSS.prototype.searchPatternForSplitKeys = function () {
|
|
43
43
|
return this.buildSplitKeyPrefix() + "*";
|
|
44
44
|
};
|
|
45
|
+
KeyBuilderSS.prototype.searchPatternForRBSegmentKeys = function () {
|
|
46
|
+
return this.buildRBSegmentKeyPrefix() + "*";
|
|
47
|
+
};
|
|
45
48
|
/* Telemetry keys */
|
|
46
49
|
KeyBuilderSS.prototype.buildLatencyKey = function (method, bucket) {
|
|
47
50
|
return this.latencyPrefix + "::" + this.versionablePrefix + "/" + exports.METHOD_NAMES[method] + "/" + bucket;
|