@splitsoftware/splitio-commons 1.2.1-rc.1 → 1.2.1-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/evaluator/Engine.js +6 -6
- package/cjs/evaluator/combiners/and.js +1 -1
- package/cjs/evaluator/combiners/ifelseif.js +2 -2
- package/cjs/evaluator/condition/engineUtils.js +2 -2
- package/cjs/evaluator/condition/index.js +4 -4
- package/cjs/evaluator/index.js +5 -5
- package/cjs/evaluator/matchers/cont_all.js +1 -1
- package/cjs/evaluator/matchers/cont_any.js +1 -1
- package/cjs/evaluator/matchers/cont_str.js +1 -1
- package/cjs/evaluator/matchers/dependency.js +1 -1
- package/cjs/evaluator/matchers/eq_set.js +1 -1
- package/cjs/evaluator/matchers/ew.js +1 -1
- package/cjs/evaluator/matchers/part_of.js +1 -1
- package/cjs/evaluator/matchers/segment.js +1 -1
- package/cjs/evaluator/matchers/sw.js +1 -1
- package/cjs/evaluator/matchers/whitelist.js +1 -1
- package/cjs/evaluator/matchersTransform/index.js +12 -12
- package/cjs/evaluator/parser/index.js +6 -6
- package/cjs/evaluator/treatments/index.js +1 -1
- package/cjs/evaluator/value/index.js +1 -1
- package/cjs/evaluator/value/sanitize.js +4 -4
- package/cjs/integrations/browser.js +3 -3
- package/cjs/integrations/ga/GaToSplit.js +14 -14
- package/cjs/integrations/ga/GoogleAnalyticsToSplit.js +1 -1
- package/cjs/integrations/ga/SplitToGa.js +1 -1
- package/cjs/listeners/browser.js +1 -1
- package/cjs/listeners/node.js +1 -1
- package/cjs/logger/constants.js +3 -1
- package/cjs/logger/index.js +2 -2
- package/cjs/logger/messages/debug.js +1 -1
- package/cjs/logger/messages/error.js +1 -1
- package/cjs/logger/messages/info.js +1 -1
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/logger/sdkLogger.js +1 -1
- package/cjs/readiness/readinessManager.js +2 -2
- package/cjs/readiness/sdkReadinessManager.js +4 -4
- package/cjs/sdkClient/client.js +9 -9
- package/cjs/sdkClient/clientAttributesDecoration.js +4 -4
- package/cjs/sdkClient/clientCS.js +2 -2
- package/cjs/sdkClient/clientInputValidation.js +14 -14
- package/cjs/sdkClient/sdkClient.js +3 -3
- package/cjs/sdkClient/sdkClientMethod.js +1 -1
- package/cjs/sdkClient/sdkClientMethodCS.js +6 -6
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +8 -8
- package/cjs/sdkFactory/index.js +8 -8
- package/cjs/sdkManager/index.js +11 -11
- package/cjs/services/splitApi.js +3 -2
- package/cjs/services/splitHttpClient.js +2 -2
- package/cjs/storages/KeyBuilder.js +2 -2
- package/cjs/storages/KeyBuilderCS.js +2 -2
- package/cjs/storages/KeyBuilderSS.js +1 -1
- package/cjs/storages/findLatencyIndex.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +12 -12
- package/cjs/storages/inLocalStorage/index.js +3 -3
- package/cjs/storages/inMemory/AttributesCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/LatenciesCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +2 -2
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +5 -5
- package/cjs/storages/inRedis/LatenciesCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RedisAdapter.js +16 -10
- package/cjs/storages/inRedis/SegmentsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +3 -3
- package/cjs/storages/inRedis/index.js +1 -1
- package/cjs/storages/pluggable/SegmentsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SplitsCachePluggable.js +3 -3
- package/cjs/storages/pluggable/inMemoryWrapper.js +4 -4
- package/cjs/storages/pluggable/index.js +4 -4
- package/cjs/sync/offline/LocalhostFromFile.js +1 -1
- package/cjs/sync/offline/LocalhostFromObject.js +1 -1
- package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
- package/cjs/sync/offline/splitsParser/splitsParserFromFile.js +13 -13
- package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +3 -3
- package/cjs/sync/offline/syncManagerOffline.js +1 -1
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +2 -2
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/pollingManagerCS.js +6 -6
- package/cjs/sync/polling/pollingManagerSS.js +3 -3
- package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
- package/cjs/sync/polling/syncTasks/segmentsSyncTask.js +1 -1
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +1 -1
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +2 -2
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +2 -2
- package/cjs/sync/streaming/AuthClient/index.js +3 -3
- package/cjs/sync/streaming/SSEHandler/NotificationParser.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +3 -3
- package/cjs/sync/streaming/mySegmentsV2utils.js +1 -1
- package/cjs/sync/streaming/pushManager.js +15 -15
- package/cjs/sync/submitters/eventsSyncTask.js +1 -1
- package/cjs/sync/submitters/impressionCountsSyncTask.js +1 -1
- package/cjs/sync/submitters/impressionsSyncTask.js +3 -3
- package/cjs/sync/submitters/metricsSyncTask.js +3 -3
- package/cjs/sync/submitters/submitterManager.js +4 -4
- package/cjs/sync/submitters/submitterSyncTask.js +1 -1
- package/cjs/sync/syncManagerOnline.js +1 -1
- package/cjs/trackers/eventTracker.js +3 -3
- package/cjs/trackers/impressionObserver/impressionObserverCS.js +1 -1
- package/cjs/trackers/impressionObserver/impressionObserverSS.js +1 -1
- package/cjs/trackers/impressionsTracker.js +3 -3
- package/cjs/utils/MinEvents.js +2 -1
- package/cjs/utils/inputValidation/apiKey.js +1 -1
- package/cjs/utils/inputValidation/attribute.js +4 -4
- package/cjs/utils/inputValidation/attributes.js +2 -2
- package/cjs/utils/inputValidation/event.js +1 -1
- package/cjs/utils/inputValidation/eventProperties.js +5 -5
- package/cjs/utils/inputValidation/eventValue.js +1 -1
- package/cjs/utils/inputValidation/key.js +6 -5
- package/cjs/utils/inputValidation/preloadedData.js +8 -8
- package/cjs/utils/inputValidation/split.js +1 -1
- package/cjs/utils/inputValidation/splits.js +2 -2
- package/cjs/utils/inputValidation/trafficType.js +1 -1
- package/cjs/utils/inputValidation/trafficTypeExistance.js +1 -1
- package/cjs/utils/jwt/index.js +1 -1
- package/cjs/utils/key/index.js +3 -3
- package/cjs/utils/lang/index.js +1 -1
- package/cjs/utils/murmur3/common.js +1 -1
- package/cjs/utils/murmur3/murmur3.js +10 -10
- package/cjs/utils/murmur3/murmur3_128.js +1 -1
- package/cjs/utils/murmur3/murmur3_128_x86.js +37 -37
- package/cjs/utils/murmur3/murmur3_64.js +1 -1
- package/cjs/utils/settingsValidation/index.js +5 -10
- package/cjs/utils/settingsValidation/integrations/configurable.js +1 -1
- package/cjs/utils/settingsValidation/integrations/pluggable.js +1 -1
- package/cjs/utils/settingsValidation/localhost/builtin.js +2 -2
- package/cjs/utils/settingsValidation/logger/builtinLogger.js +3 -3
- package/cjs/utils/settingsValidation/logger/commons.js +1 -1
- package/cjs/utils/settingsValidation/logger/pluggableLogger.js +1 -1
- package/cjs/utils/settingsValidation/runtime/browser.js +10 -0
- package/cjs/utils/settingsValidation/runtime/node.js +22 -0
- package/cjs/utils/settingsValidation/splitFilters.js +1 -1
- package/cjs/utils/settingsValidation/storage/storageCS.js +1 -1
- package/cjs/utils/timeTracker/index.js +3 -3
- package/esm/services/splitApi.js +2 -1
- package/esm/storages/inRedis/RedisAdapter.js +7 -1
- package/esm/sync/offline/splitsParser/splitsParserFromFile.js +1 -1
- package/esm/sync/polling/fetchers/segmentChangesFetcher.js +2 -2
- package/esm/utils/inputValidation/key.js +2 -1
- package/esm/utils/lang/index.js +2 -2
- package/esm/utils/settingsValidation/index.js +1 -6
- package/esm/utils/settingsValidation/runtime/browser.js +6 -0
- package/esm/utils/settingsValidation/runtime/node.js +17 -0
- package/package.json +9 -8
- package/src/logger/types.ts +4 -0
- package/src/sync/offline/splitsParser/splitsParserFromFile.ts +1 -1
- package/src/utils/settingsValidation/index.ts +1 -6
- package/src/utils/settingsValidation/runtime/browser.ts +6 -0
- package/src/utils/settingsValidation/runtime/node.ts +22 -0
- package/src/utils/settingsValidation/types.ts +6 -6
- package/types/logger/types.d.ts +4 -0
- package/types/sdkClient/clientAttributesDecoration.d.ts +1 -1
- package/types/utils/settingsValidation/runtime/browser.d.ts +4 -0
- package/types/utils/settingsValidation/runtime/node.d.ts +5 -0
- package/types/utils/settingsValidation/types.d.ts +6 -6
|
@@ -9,7 +9,7 @@ var constants_1 = require("./constants");
|
|
|
9
9
|
* ISplitsCacheSync implementation that stores split definitions in browser LocalStorage.
|
|
10
10
|
*/
|
|
11
11
|
var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
12
|
-
tslib_1.__extends(SplitsCacheInLocal, _super);
|
|
12
|
+
(0, tslib_1.__extends)(SplitsCacheInLocal, _super);
|
|
13
13
|
/**
|
|
14
14
|
* @param {KeyBuilderCS} keys
|
|
15
15
|
* @param {number | undefined} expirationTimestamp
|
|
@@ -27,7 +27,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
27
27
|
return _this;
|
|
28
28
|
}
|
|
29
29
|
SplitsCacheInLocal.prototype._decrementCount = function (key) {
|
|
30
|
-
var count = lang_1.toNumber(localStorage.getItem(key)) - 1;
|
|
30
|
+
var count = (0, lang_1.toNumber)(localStorage.getItem(key)) - 1;
|
|
31
31
|
// @ts-expect-error
|
|
32
32
|
if (count > 0)
|
|
33
33
|
localStorage.setItem(key, count);
|
|
@@ -41,7 +41,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
41
41
|
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
42
42
|
this._decrementCount(ttKey);
|
|
43
43
|
}
|
|
44
|
-
if (AbstractSplitsCacheSync_1.usesSegments(split)) {
|
|
44
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(split)) {
|
|
45
45
|
var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
|
|
46
46
|
this._decrementCount(segmentsCountKey);
|
|
47
47
|
}
|
|
@@ -57,12 +57,12 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
57
57
|
if (split.trafficTypeName) {
|
|
58
58
|
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
59
59
|
// @ts-expect-error
|
|
60
|
-
localStorage.setItem(ttKey, lang_1.toNumber(localStorage.getItem(ttKey)) + 1);
|
|
60
|
+
localStorage.setItem(ttKey, (0, lang_1.toNumber)(localStorage.getItem(ttKey)) + 1);
|
|
61
61
|
}
|
|
62
|
-
if (AbstractSplitsCacheSync_1.usesSegments(split)) {
|
|
62
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(split)) {
|
|
63
63
|
var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
|
|
64
64
|
// @ts-expect-error
|
|
65
|
-
localStorage.setItem(segmentsCountKey, lang_1.toNumber(localStorage.getItem(segmentsCountKey)) + 1);
|
|
65
|
+
localStorage.setItem(segmentsCountKey, (0, lang_1.toNumber)(localStorage.getItem(segmentsCountKey)) + 1);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -161,7 +161,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
161
161
|
var value = localStorage.getItem(this.keys.buildSplitsTillKey());
|
|
162
162
|
if (value !== null) {
|
|
163
163
|
value = parseInt(value, 10);
|
|
164
|
-
return lang_1.isNaNNumber(value) ? n : value;
|
|
164
|
+
return (0, lang_1.isNaNNumber)(value) ? n : value;
|
|
165
165
|
}
|
|
166
166
|
return n;
|
|
167
167
|
};
|
|
@@ -178,16 +178,16 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
178
178
|
return accum;
|
|
179
179
|
};
|
|
180
180
|
SplitsCacheInLocal.prototype.trafficTypeExists = function (trafficType) {
|
|
181
|
-
var ttCount = lang_1.toNumber(localStorage.getItem(this.keys.buildTrafficTypeKey(trafficType)));
|
|
182
|
-
return lang_1.isFiniteNumber(ttCount) && ttCount > 0;
|
|
181
|
+
var ttCount = (0, lang_1.toNumber)(localStorage.getItem(this.keys.buildTrafficTypeKey(trafficType)));
|
|
182
|
+
return (0, lang_1.isFiniteNumber)(ttCount) && ttCount > 0;
|
|
183
183
|
};
|
|
184
184
|
SplitsCacheInLocal.prototype.usesSegments = function () {
|
|
185
185
|
// If cache hasn't been synchronized with the cloud, assume we need them.
|
|
186
186
|
if (!this.hasSync)
|
|
187
187
|
return true;
|
|
188
188
|
var storedCount = localStorage.getItem(this.keys.buildSplitsWithSegmentCountKey());
|
|
189
|
-
var splitsWithSegmentsCount = storedCount === null ? 0 : lang_1.toNumber(storedCount);
|
|
190
|
-
if (lang_1.isFiniteNumber(splitsWithSegmentsCount)) {
|
|
189
|
+
var splitsWithSegmentsCount = storedCount === null ? 0 : (0, lang_1.toNumber)(storedCount);
|
|
190
|
+
if ((0, lang_1.isFiniteNumber)(splitsWithSegmentsCount)) {
|
|
191
191
|
return splitsWithSegmentsCount > 0;
|
|
192
192
|
}
|
|
193
193
|
else {
|
|
@@ -212,7 +212,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
212
212
|
var value = localStorage.getItem(this.keys.buildLastUpdatedKey());
|
|
213
213
|
if (value !== null) {
|
|
214
214
|
value = parseInt(value, 10);
|
|
215
|
-
if (!lang_1.isNaNNumber(value) && expirationTimestamp && value < expirationTimestamp)
|
|
215
|
+
if (!(0, lang_1.isNaNNumber)(value) && expirationTimestamp && value < expirationTimestamp)
|
|
216
216
|
this.clear();
|
|
217
217
|
}
|
|
218
218
|
};
|
|
@@ -20,12 +20,12 @@ var constants_2 = require("../../utils/constants");
|
|
|
20
20
|
*/
|
|
21
21
|
function InLocalStorage(options) {
|
|
22
22
|
if (options === void 0) { options = {}; }
|
|
23
|
-
var prefix = KeyBuilder_1.validatePrefix(options.prefix);
|
|
23
|
+
var prefix = (0, KeyBuilder_1.validatePrefix)(options.prefix);
|
|
24
24
|
function InLocalStorageCSFactory(params) {
|
|
25
25
|
// Fallback to InMemoryStorage if LocalStorage API is not available
|
|
26
|
-
if (!isLocalStorageAvailable_1.isLocalStorageAvailable()) {
|
|
26
|
+
if (!(0, isLocalStorageAvailable_1.isLocalStorageAvailable)()) {
|
|
27
27
|
params.log.warn(constants_1.LOG_PREFIX + 'LocalStorage API is unavailable. Fallbacking into default MEMORY storage');
|
|
28
|
-
return InMemoryStorageCS_1.InMemoryStorageCSFactory(params);
|
|
28
|
+
return (0, InMemoryStorageCS_1.InMemoryStorageCSFactory)(params);
|
|
29
29
|
}
|
|
30
30
|
var log = params.log;
|
|
31
31
|
var keys = new KeyBuilderCS_1.KeyBuilderCS(prefix, params.matchingKey);
|
|
@@ -33,7 +33,7 @@ var AttributesCacheInMemory = /** @class */ (function () {
|
|
|
33
33
|
* @returns {boolean} attributes were stored
|
|
34
34
|
*/
|
|
35
35
|
AttributesCacheInMemory.prototype.setAttributes = function (attributes) {
|
|
36
|
-
this.attributesCache = objectAssign_1.objectAssign(this.attributesCache, attributes);
|
|
36
|
+
this.attributesCache = (0, objectAssign_1.objectAssign)(this.attributesCache, attributes);
|
|
37
37
|
return true;
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
@@ -10,7 +10,7 @@ var ImpressionCountsCacheInMemory = /** @class */ (function () {
|
|
|
10
10
|
* Builds key to be stored in the cache with the featureName and the timeFrame truncated.
|
|
11
11
|
*/
|
|
12
12
|
ImpressionCountsCacheInMemory.prototype._makeKey = function (featureName, timeFrame) {
|
|
13
|
-
return featureName + "::" + time_1.truncateTimeFrame(timeFrame);
|
|
13
|
+
return featureName + "::" + (0, time_1.truncateTimeFrame)(timeFrame);
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* Increments the quantity of impressions with the passed featureName and timeFrame.
|
|
@@ -17,7 +17,7 @@ var LatenciesCacheInMemory = /** @class */ (function () {
|
|
|
17
17
|
];
|
|
18
18
|
}
|
|
19
19
|
// +1 based on the latency number
|
|
20
|
-
this.counters[metricName][findLatencyIndex_1.findLatencyIndex(latency)]++;
|
|
20
|
+
this.counters[metricName][(0, findLatencyIndex_1.findLatencyIndex)(latency)]++;
|
|
21
21
|
return true;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
@@ -8,7 +8,7 @@ var AbstractSegmentsCacheSync_1 = require("../AbstractSegmentsCacheSync");
|
|
|
8
8
|
* Supported by all JS runtimes.
|
|
9
9
|
*/
|
|
10
10
|
var MySegmentsCacheInMemory = /** @class */ (function (_super) {
|
|
11
|
-
tslib_1.__extends(MySegmentsCacheInMemory, _super);
|
|
11
|
+
(0, tslib_1.__extends)(MySegmentsCacheInMemory, _super);
|
|
12
12
|
function MySegmentsCacheInMemory() {
|
|
13
13
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
14
14
|
_this.segmentCache = {};
|
|
@@ -10,7 +10,7 @@ var lang_1 = require("../../utils/lang");
|
|
|
10
10
|
* Supported by all JS runtimes.
|
|
11
11
|
*/
|
|
12
12
|
var SegmentsCacheInMemory = /** @class */ (function (_super) {
|
|
13
|
-
tslib_1.__extends(SegmentsCacheInMemory, _super);
|
|
13
|
+
(0, tslib_1.__extends)(SegmentsCacheInMemory, _super);
|
|
14
14
|
function SegmentsCacheInMemory() {
|
|
15
15
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
16
16
|
_this.segmentCache = {};
|
|
@@ -63,7 +63,7 @@ var SegmentsCacheInMemory = /** @class */ (function (_super) {
|
|
|
63
63
|
};
|
|
64
64
|
SegmentsCacheInMemory.prototype.getChangeNumber = function (name) {
|
|
65
65
|
var value = this.segmentChangeNumber[name];
|
|
66
|
-
return lang_1.isIntegerNumber(value) ? value : -1;
|
|
66
|
+
return (0, lang_1.isIntegerNumber)(value) ? value : -1;
|
|
67
67
|
};
|
|
68
68
|
return SegmentsCacheInMemory;
|
|
69
69
|
}(AbstractSegmentsCacheSync_1.AbstractSegmentsCacheSync));
|
|
@@ -9,7 +9,7 @@ var lang_1 = require("../../utils/lang");
|
|
|
9
9
|
* Supported by all JS runtimes.
|
|
10
10
|
*/
|
|
11
11
|
var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
12
|
-
tslib_1.__extends(SplitsCacheInMemory, _super);
|
|
12
|
+
(0, tslib_1.__extends)(SplitsCacheInMemory, _super);
|
|
13
13
|
function SplitsCacheInMemory() {
|
|
14
14
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
15
15
|
_this.splitsCache = {};
|
|
@@ -34,7 +34,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
34
34
|
if (!this.ttCache[previousTtName])
|
|
35
35
|
delete this.ttCache[previousTtName];
|
|
36
36
|
}
|
|
37
|
-
if (AbstractSplitsCacheSync_1.usesSegments(previousSplit)) { // Substract from segments count for the previous version of this Split.
|
|
37
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(previousSplit)) { // Substract from segments count for the previous version of this Split.
|
|
38
38
|
this.splitsWithSegmentsCount--;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -50,7 +50,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
50
50
|
this.ttCache[ttName]++;
|
|
51
51
|
}
|
|
52
52
|
// Add to segments count for the new version of the Split
|
|
53
|
-
if (AbstractSplitsCacheSync_1.usesSegments(parsedSplit))
|
|
53
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(parsedSplit))
|
|
54
54
|
this.splitsWithSegmentsCount++;
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
@@ -71,7 +71,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
71
71
|
delete this.ttCache[ttName];
|
|
72
72
|
}
|
|
73
73
|
// Update the segments count.
|
|
74
|
-
if (AbstractSplitsCacheSync_1.usesSegments(parsedSplit))
|
|
74
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(parsedSplit))
|
|
75
75
|
this.splitsWithSegmentsCount--;
|
|
76
76
|
return true;
|
|
77
77
|
}
|
|
@@ -93,7 +93,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
93
93
|
return Object.keys(this.splitsCache);
|
|
94
94
|
};
|
|
95
95
|
SplitsCacheInMemory.prototype.trafficTypeExists = function (trafficType) {
|
|
96
|
-
return lang_1.isFiniteNumber(this.ttCache[trafficType]) && this.ttCache[trafficType] > 0;
|
|
96
|
+
return (0, lang_1.isFiniteNumber)(this.ttCache[trafficType]) && this.ttCache[trafficType] > 0;
|
|
97
97
|
};
|
|
98
98
|
SplitsCacheInMemory.prototype.usesSegments = function () {
|
|
99
99
|
return this.getChangeNumber() === -1 || this.splitsWithSegmentsCount > 0;
|
|
@@ -8,7 +8,7 @@ var LatenciesCacheInRedis = /** @class */ (function () {
|
|
|
8
8
|
this.redis = redis;
|
|
9
9
|
}
|
|
10
10
|
LatenciesCacheInRedis.prototype.track = function (metricName, latency) {
|
|
11
|
-
var bucketNumber = findLatencyIndex_1.findLatencyIndex(latency);
|
|
11
|
+
var bucketNumber = (0, findLatencyIndex_1.findLatencyIndex)(latency);
|
|
12
12
|
return this.redis.incr(this.keys.buildLatencyKey(metricName, bucketNumber)).catch(function () {
|
|
13
13
|
// noop, for telemetry metrics there's no need to throw.
|
|
14
14
|
}).then(function () { return true; });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RedisAdapter = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var ioredis_1 = tslib_1.__importDefault(require("ioredis"));
|
|
5
|
+
var ioredis_1 = (0, tslib_1.__importDefault)(require("ioredis"));
|
|
6
6
|
var lang_1 = require("../../utils/lang");
|
|
7
7
|
var sets_1 = require("../../utils/lang/sets");
|
|
8
8
|
var thenable_1 = require("../../utils/promise/thenable");
|
|
@@ -25,7 +25,7 @@ var DEFAULT_LIBRARY_OPTIONS = {
|
|
|
25
25
|
* Redis adapter on top of the library of choice (written with ioredis) for some extra control.
|
|
26
26
|
*/
|
|
27
27
|
var RedisAdapter = /** @class */ (function (_super) {
|
|
28
|
-
tslib_1.__extends(RedisAdapter, _super);
|
|
28
|
+
(0, tslib_1.__extends)(RedisAdapter, _super);
|
|
29
29
|
function RedisAdapter(log, storageSettings) {
|
|
30
30
|
var _this = this;
|
|
31
31
|
var options = RedisAdapter._defineOptions(storageSettings);
|
|
@@ -66,7 +66,7 @@ var RedisAdapter = /** @class */ (function (_super) {
|
|
|
66
66
|
instance.log.debug(LOG_PREFIX + ("Executing " + method + "."));
|
|
67
67
|
// Return original method
|
|
68
68
|
var result = originalMethod.apply(instance, params);
|
|
69
|
-
if (thenable_1.thenable(result)) {
|
|
69
|
+
if ((0, thenable_1.thenable)(result)) {
|
|
70
70
|
// For handling pending commands on disconnect, add to the set and remove once finished.
|
|
71
71
|
// On sync commands there's no need, only thenables.
|
|
72
72
|
instance._runningCommands.add(result);
|
|
@@ -75,7 +75,7 @@ var RedisAdapter = /** @class */ (function (_super) {
|
|
|
75
75
|
};
|
|
76
76
|
// Both success and error remove from queue.
|
|
77
77
|
result.then(cleanUpRunningCommandsCb, cleanUpRunningCommandsCb);
|
|
78
|
-
return timeout_1.timeout(instance._options.operationTimeout, result).catch(function (err) {
|
|
78
|
+
return (0, timeout_1.timeout)(instance._options.operationTimeout, result).catch(function (err) {
|
|
79
79
|
instance.log.error(LOG_PREFIX + (method + " operation threw an error or exceeded configured timeout of " + instance._options.operationTimeout + "ms. Message: " + err));
|
|
80
80
|
// Handling is not the adapter responsibility.
|
|
81
81
|
throw err;
|
|
@@ -110,7 +110,7 @@ var RedisAdapter = /** @class */ (function (_super) {
|
|
|
110
110
|
setTimeout(function deferedDisconnect() {
|
|
111
111
|
if (instance._runningCommands.size > 0) {
|
|
112
112
|
instance.log.info(LOG_PREFIX + ("Attempting to disconnect but there are " + instance._runningCommands.size + " commands still waiting for resolution. Defering disconnection until those finish."));
|
|
113
|
-
Promise.all(sets_1.setToArray(instance._runningCommands))
|
|
113
|
+
Promise.all((0, sets_1.setToArray)(instance._runningCommands))
|
|
114
114
|
.then(function () {
|
|
115
115
|
instance.log.debug(LOG_PREFIX + 'Pending commands finished successfully, disconnecting.');
|
|
116
116
|
originalMethod.apply(instance, params);
|
|
@@ -133,10 +133,10 @@ var RedisAdapter = /** @class */ (function (_super) {
|
|
|
133
133
|
* Keeping both redis setup options for backwards compatibility.
|
|
134
134
|
*/
|
|
135
135
|
RedisAdapter._defineLibrarySettings = function (options) {
|
|
136
|
-
var opts = lang_1.merge({}, DEFAULT_LIBRARY_OPTIONS);
|
|
136
|
+
var opts = (0, lang_1.merge)({}, DEFAULT_LIBRARY_OPTIONS);
|
|
137
137
|
var result = [opts];
|
|
138
|
-
if (!lang_1.isString(options.url)) {
|
|
139
|
-
lang_1.merge(opts, {
|
|
138
|
+
if (!(0, lang_1.isString)(options.url)) {
|
|
139
|
+
(0, lang_1.merge)(opts, {
|
|
140
140
|
host: options.host,
|
|
141
141
|
port: options.port,
|
|
142
142
|
db: options.db,
|
|
@@ -154,9 +154,15 @@ var RedisAdapter = /** @class */ (function (_super) {
|
|
|
154
154
|
RedisAdapter._defineOptions = function (_a) {
|
|
155
155
|
var connectionTimeout = _a.connectionTimeout, operationTimeout = _a.operationTimeout, url = _a.url, host = _a.host, port = _a.port, db = _a.db, pass = _a.pass;
|
|
156
156
|
var parsedOptions = {
|
|
157
|
-
connectionTimeout: connectionTimeout,
|
|
157
|
+
connectionTimeout: connectionTimeout,
|
|
158
|
+
operationTimeout: operationTimeout,
|
|
159
|
+
url: url,
|
|
160
|
+
host: host,
|
|
161
|
+
port: port,
|
|
162
|
+
db: db,
|
|
163
|
+
pass: pass
|
|
158
164
|
};
|
|
159
|
-
return lang_1.merge({}, DEFAULT_OPTIONS, parsedOptions);
|
|
165
|
+
return (0, lang_1.merge)({}, DEFAULT_OPTIONS, parsedOptions);
|
|
160
166
|
};
|
|
161
167
|
return RedisAdapter;
|
|
162
168
|
}(ioredis_1.default));
|
|
@@ -37,7 +37,7 @@ var SegmentsCacheInRedis = /** @class */ (function () {
|
|
|
37
37
|
var _this = this;
|
|
38
38
|
return this.redis.get(this.keys.buildSegmentTillKey(name)).then(function (value) {
|
|
39
39
|
var i = parseInt(value, 10);
|
|
40
|
-
return lang_1.isNaNNumber(i) ? -1 : i;
|
|
40
|
+
return (0, lang_1.isNaNNumber)(i) ? -1 : i;
|
|
41
41
|
}).catch(function (e) {
|
|
42
42
|
_this.log.error(constants_1.LOG_PREFIX + 'Could not retrieve changeNumber from segments storage. Error: ' + e);
|
|
43
43
|
return -1;
|
|
@@ -20,7 +20,7 @@ function processPipelineAnswer(results) {
|
|
|
20
20
|
* Supported by Node.
|
|
21
21
|
*/
|
|
22
22
|
var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
23
|
-
tslib_1.__extends(SplitsCacheInRedis, _super);
|
|
23
|
+
(0, tslib_1.__extends)(SplitsCacheInRedis, _super);
|
|
24
24
|
function SplitsCacheInRedis(log, keys, redis) {
|
|
25
25
|
var _this = _super.call(this) || this;
|
|
26
26
|
_this.log = log;
|
|
@@ -142,7 +142,7 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
142
142
|
var _this = this;
|
|
143
143
|
return this.redis.get(this.keys.buildSplitsTillKey()).then(function (value) {
|
|
144
144
|
var i = parseInt(value, 10);
|
|
145
|
-
return lang_1.isNaNNumber(i) ? -1 : i;
|
|
145
|
+
return (0, lang_1.isNaNNumber)(i) ? -1 : i;
|
|
146
146
|
}).catch(function (e) {
|
|
147
147
|
_this.log.error(constants_1.LOG_PREFIX + 'Could not retrieve changeNumber from storage. Error: ' + e);
|
|
148
148
|
return -1;
|
|
@@ -183,7 +183,7 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
183
183
|
if (ttCount === null)
|
|
184
184
|
return false; // if entry doesn't exist, means that TT doesn't exist
|
|
185
185
|
ttCount = parseInt(ttCount, 10);
|
|
186
|
-
if (!lang_1.isFiniteNumber(ttCount) || ttCount < 0) {
|
|
186
|
+
if (!(0, lang_1.isFiniteNumber)(ttCount) || ttCount < 0) {
|
|
187
187
|
_this.log.info(constants_1.LOG_PREFIX + ("Could not validate traffic type existance of " + trafficType + " due to data corruption of some sorts."));
|
|
188
188
|
return false;
|
|
189
189
|
}
|
|
@@ -17,7 +17,7 @@ var constants_1 = require("../../utils/constants");
|
|
|
17
17
|
*/
|
|
18
18
|
function InRedisStorage(options) {
|
|
19
19
|
if (options === void 0) { options = {}; }
|
|
20
|
-
var prefix = KeyBuilder_1.validatePrefix(options.prefix);
|
|
20
|
+
var prefix = (0, KeyBuilder_1.validatePrefix)(options.prefix);
|
|
21
21
|
function InRedisStorageFactory(_a) {
|
|
22
22
|
var log = _a.log, metadata = _a.metadata, onReadyCb = _a.onReadyCb;
|
|
23
23
|
var keys = new KeyBuilderSS_1.KeyBuilderSS(prefix, metadata);
|
|
@@ -66,7 +66,7 @@ var SegmentsCachePluggable = /** @class */ (function () {
|
|
|
66
66
|
var _this = this;
|
|
67
67
|
return this.wrapper.get(this.keys.buildSegmentTillKey(name)).then(function (value) {
|
|
68
68
|
var i = parseInt(value, 10);
|
|
69
|
-
return lang_1.isNaNNumber(i) ? -1 : i;
|
|
69
|
+
return (0, lang_1.isNaNNumber)(i) ? -1 : i;
|
|
70
70
|
}).catch(function (e) {
|
|
71
71
|
_this.log.error(constants_1.LOG_PREFIX + 'Could not retrieve changeNumber from segments storage. Error: ' + e);
|
|
72
72
|
return -1;
|
|
@@ -9,7 +9,7 @@ var AbstractSplitsCacheAsync_1 = require("../AbstractSplitsCacheAsync");
|
|
|
9
9
|
* ISplitsCacheAsync implementation for pluggable storages.
|
|
10
10
|
*/
|
|
11
11
|
var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
12
|
-
tslib_1.__extends(SplitsCachePluggable, _super);
|
|
12
|
+
(0, tslib_1.__extends)(SplitsCachePluggable, _super);
|
|
13
13
|
/**
|
|
14
14
|
* Create a SplitsCache that uses a storage wrapper.
|
|
15
15
|
* @param log Logger instance.
|
|
@@ -154,7 +154,7 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
154
154
|
if (ttCount === null)
|
|
155
155
|
return false; // if entry doesn't exist, means that TT doesn't exist
|
|
156
156
|
ttCount = parseInt(ttCount, 10);
|
|
157
|
-
if (!lang_1.isFiniteNumber(ttCount) || ttCount < 0) {
|
|
157
|
+
if (!(0, lang_1.isFiniteNumber)(ttCount) || ttCount < 0) {
|
|
158
158
|
_this.log.info(constants_1.LOG_PREFIX + ("Could not validate traffic type existence of " + trafficType + " due to data corruption of some sorts."));
|
|
159
159
|
return false;
|
|
160
160
|
}
|
|
@@ -182,7 +182,7 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
182
182
|
var _this = this;
|
|
183
183
|
return this.wrapper.get(this.keys.buildSplitsTillKey()).then(function (value) {
|
|
184
184
|
var i = parseInt(value, 10);
|
|
185
|
-
return lang_1.isNaNNumber(i) ? -1 : i;
|
|
185
|
+
return (0, lang_1.isNaNNumber)(i) ? -1 : i;
|
|
186
186
|
}).catch(function (e) {
|
|
187
187
|
_this.log.error(constants_1.LOG_PREFIX + 'Could not retrieve changeNumber from storage. Error: ' + e);
|
|
188
188
|
return -1;
|
|
@@ -35,11 +35,11 @@ function inMemoryWrapperFactory(connDelay) {
|
|
|
35
35
|
return Promise.resolve(result);
|
|
36
36
|
},
|
|
37
37
|
getKeysByPrefix: function (prefix) {
|
|
38
|
-
return Promise.resolve(Object.keys(_cache).filter(function (key) { return lang_1.startsWith(key, prefix); }));
|
|
38
|
+
return Promise.resolve(Object.keys(_cache).filter(function (key) { return (0, lang_1.startsWith)(key, prefix); }));
|
|
39
39
|
},
|
|
40
40
|
incr: function (key) {
|
|
41
41
|
if (key in _cache) {
|
|
42
|
-
var count = lang_1.toNumber(_cache[key]) + 1;
|
|
42
|
+
var count = (0, lang_1.toNumber)(_cache[key]) + 1;
|
|
43
43
|
if (isNaN(count))
|
|
44
44
|
return Promise.reject('Given key is not a number');
|
|
45
45
|
_cache[key] = count + '';
|
|
@@ -52,7 +52,7 @@ function inMemoryWrapperFactory(connDelay) {
|
|
|
52
52
|
},
|
|
53
53
|
decr: function (key) {
|
|
54
54
|
if (key in _cache) {
|
|
55
|
-
var count = lang_1.toNumber(_cache[key]) - 1;
|
|
55
|
+
var count = (0, lang_1.toNumber)(_cache[key]) - 1;
|
|
56
56
|
if (isNaN(count))
|
|
57
57
|
return Promise.reject('Given key is not a number');
|
|
58
58
|
_cache[key] = count + '';
|
|
@@ -117,7 +117,7 @@ function inMemoryWrapperFactory(connDelay) {
|
|
|
117
117
|
if (!set)
|
|
118
118
|
return Promise.resolve([]);
|
|
119
119
|
if (set instanceof sets_1._Set)
|
|
120
|
-
return Promise.resolve(sets_1.setToArray(set));
|
|
120
|
+
return Promise.resolve((0, sets_1.setToArray)(set));
|
|
121
121
|
return Promise.reject('key is not a set');
|
|
122
122
|
},
|
|
123
123
|
// always connects and disconnects
|
|
@@ -23,7 +23,7 @@ var NO_VALID_WRAPPER_INTERFACE = 'The provided wrapper instance doesn’t follow
|
|
|
23
23
|
* @throws Will throw an error if the options are invalid. Example: wrapper is not provided or doesn't have some methods.
|
|
24
24
|
*/
|
|
25
25
|
function validatePluggableStorageOptions(options) {
|
|
26
|
-
if (!lang_1.isObject(options) || !lang_1.isObject(options.wrapper))
|
|
26
|
+
if (!(0, lang_1.isObject)(options) || !(0, lang_1.isObject)(options.wrapper))
|
|
27
27
|
throw new Error(NO_VALID_WRAPPER);
|
|
28
28
|
var wrapper = options.wrapper;
|
|
29
29
|
var missingMethods = wrapperAdapter_1.METHODS_TO_PROMISE_WRAP.filter(function (method) { return typeof wrapper[method] !== 'function'; });
|
|
@@ -52,11 +52,11 @@ function promisifyEventsTrack(events) {
|
|
|
52
52
|
*/
|
|
53
53
|
function PluggableStorage(options) {
|
|
54
54
|
validatePluggableStorageOptions(options);
|
|
55
|
-
var prefix = KeyBuilder_1.validatePrefix(options.prefix);
|
|
55
|
+
var prefix = (0, KeyBuilder_1.validatePrefix)(options.prefix);
|
|
56
56
|
function PluggableStorageFactory(_a) {
|
|
57
57
|
var log = _a.log, metadata = _a.metadata, onReadyCb = _a.onReadyCb, mode = _a.mode, eventsQueueSize = _a.eventsQueueSize, optimize = _a.optimize;
|
|
58
58
|
var keys = new KeyBuilderSS_1.KeyBuilderSS(prefix, metadata);
|
|
59
|
-
var wrapper = wrapperAdapter_1.wrapperAdapter(log, options.wrapper);
|
|
59
|
+
var wrapper = (0, wrapperAdapter_1.wrapperAdapter)(log, options.wrapper);
|
|
60
60
|
var isPartialConsumer = mode === constants_1.CONSUMER_PARTIAL_MODE;
|
|
61
61
|
// Connects to wrapper and emits SDK_READY event on main client
|
|
62
62
|
wrapperConnect(wrapper, onReadyCb);
|
|
@@ -74,7 +74,7 @@ function PluggableStorage(options) {
|
|
|
74
74
|
// emits SDK_READY event on shared clients and returns a reference to the storage
|
|
75
75
|
shared: function (_, onReadyCb) {
|
|
76
76
|
wrapperConnect(wrapper, onReadyCb);
|
|
77
|
-
return tslib_1.__assign(tslib_1.__assign({}, this), {
|
|
77
|
+
return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, this), {
|
|
78
78
|
// no-op destroy, to disconnect the wrapper only when the main client is destroyed
|
|
79
79
|
destroy: function () { } });
|
|
80
80
|
}
|
|
@@ -5,7 +5,7 @@ var splitsParserFromFile_1 = require("./splitsParser/splitsParserFromFile");
|
|
|
5
5
|
var syncManagerOffline_1 = require("./syncManagerOffline");
|
|
6
6
|
// Singleton instance of the factory function for offline SyncManager from YAML file (a.k.a. localhostFromFile)
|
|
7
7
|
// Requires Node 'fs' and 'path' APIs.
|
|
8
|
-
var localhostFromFile = syncManagerOffline_1.syncManagerOfflineFactory(splitsParserFromFile_1.splitsParserFromFileFactory);
|
|
8
|
+
var localhostFromFile = (0, syncManagerOffline_1.syncManagerOfflineFactory)(splitsParserFromFile_1.splitsParserFromFileFactory);
|
|
9
9
|
localhostFromFile.type = 'LocalhostFromFile';
|
|
10
10
|
function LocalhostFromFile() {
|
|
11
11
|
return localhostFromFile;
|
|
@@ -5,7 +5,7 @@ var splitsParserFromSettings_1 = require("./splitsParser/splitsParserFromSetting
|
|
|
5
5
|
var syncManagerOffline_1 = require("./syncManagerOffline");
|
|
6
6
|
// Singleton instance of the factory function for offline SyncManager from object (a.k.a. localhostFromObject)
|
|
7
7
|
// SDK instances instantiate their SyncManagers with the same factory
|
|
8
|
-
var localhostFromObject = syncManagerOffline_1.syncManagerOfflineFactory(splitsParserFromSettings_1.splitsParserFromSettingsFactory);
|
|
8
|
+
var localhostFromObject = (0, syncManagerOffline_1.syncManagerOfflineFactory)(splitsParserFromSettings_1.splitsParserFromSettingsFactory);
|
|
9
9
|
localhostFromObject.type = 'LocalhostFromObject';
|
|
10
10
|
function LocalhostFromObject() {
|
|
11
11
|
return localhostFromObject;
|
|
@@ -4,16 +4,16 @@ exports.splitsParserFromFileFactory = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
/* eslint-disable no-undef */
|
|
6
6
|
// @TODO consider moving it to Node-SDK and remove js-yaml dependency from Js-commons
|
|
7
|
-
var fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
|
-
var path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
var fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
8
|
+
var path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
9
9
|
// @ts-ignore
|
|
10
|
-
var js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
10
|
+
var js_yaml_1 = (0, tslib_1.__importDefault)(require("js-yaml"));
|
|
11
11
|
var lang_1 = require("../../../utils/lang");
|
|
12
12
|
var parseCondition_1 = require("./parseCondition");
|
|
13
13
|
var logPrefix = 'sync:offline:splits-fetcher: ';
|
|
14
14
|
var DEFAULT_FILENAME = '.split';
|
|
15
15
|
function configFilesPath(configFilePath) {
|
|
16
|
-
if (configFilePath === DEFAULT_FILENAME || !lang_1.isString(configFilePath)) {
|
|
16
|
+
if (configFilePath === DEFAULT_FILENAME || !(0, lang_1.isString)(configFilePath)) {
|
|
17
17
|
var root = process.env.HOME;
|
|
18
18
|
if (process.env.SPLIT_CONFIG_ROOT)
|
|
19
19
|
root = process.env.SPLIT_CONFIG_ROOT;
|
|
@@ -22,7 +22,7 @@ function configFilesPath(configFilePath) {
|
|
|
22
22
|
configFilePath = path_1.default.join(root, DEFAULT_FILENAME);
|
|
23
23
|
}
|
|
24
24
|
// Validate the extensions
|
|
25
|
-
if (!(lang_1.endsWith(configFilePath, '.yaml', true) || lang_1.endsWith(configFilePath, '.yml', true) || lang_1.endsWith(configFilePath, '.split', true)))
|
|
25
|
+
if (!((0, lang_1.endsWith)(configFilePath, '.yaml', true) || (0, lang_1.endsWith)(configFilePath, '.yml', true) || (0, lang_1.endsWith)(configFilePath, '.split', true)))
|
|
26
26
|
throw new Error("Invalid extension specified for Splits mock file. Accepted extensions are \".yml\" and \".yaml\". Your specified file is " + configFilePath);
|
|
27
27
|
if (!fs_1.default.existsSync(configFilePath))
|
|
28
28
|
throw new Error("Split configuration not found in " + configFilePath + " - Please review your Split file location.");
|
|
@@ -32,13 +32,13 @@ function configFilesPath(configFilePath) {
|
|
|
32
32
|
// for behaviour that's ensured by the BE.
|
|
33
33
|
function arrangeConditions(mocksData) {
|
|
34
34
|
// Iterate through each Split data
|
|
35
|
-
lang_1.forOwn(mocksData, function (data) {
|
|
35
|
+
(0, lang_1.forOwn)(mocksData, function (data) {
|
|
36
36
|
var conditions = data.conditions;
|
|
37
37
|
// On the manager, as the split jsons come with all treatments on the partitions prop,
|
|
38
38
|
// we'll add all the treatments to the first condition.
|
|
39
|
-
var firstRolloutCondition = lang_1.find(conditions, function (cond) { return cond.conditionType === 'ROLLOUT'; });
|
|
39
|
+
var firstRolloutCondition = (0, lang_1.find)(conditions, function (cond) { return cond.conditionType === 'ROLLOUT'; });
|
|
40
40
|
// Malformed mocks may have
|
|
41
|
-
var treatments = lang_1.uniq(data.treatments);
|
|
41
|
+
var treatments = (0, lang_1.uniq)(data.treatments);
|
|
42
42
|
// If they're only specifying a whitelist we add the treatments there.
|
|
43
43
|
var allTreatmentsCondition = firstRolloutCondition ? firstRolloutCondition : conditions[0];
|
|
44
44
|
var fullyAllocatedTreatment = allTreatmentsCondition.partitions[0].treatment;
|
|
@@ -66,7 +66,7 @@ function splitsParserFromFileFactory() {
|
|
|
66
66
|
data = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
67
67
|
}
|
|
68
68
|
catch (e) {
|
|
69
|
-
log.error(e.message);
|
|
69
|
+
log.error(e && e.message);
|
|
70
70
|
return {};
|
|
71
71
|
}
|
|
72
72
|
if (data === previousMock)
|
|
@@ -84,7 +84,7 @@ function splitsParserFromFileFactory() {
|
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
86
|
var splitName = tuple[SPLIT_POSITION];
|
|
87
|
-
var condition = parseCondition_1.parseCondition({ treatment: tuple[TREATMENT_POSITION] });
|
|
87
|
+
var condition = (0, parseCondition_1.parseCondition)({ treatment: tuple[TREATMENT_POSITION] });
|
|
88
88
|
accum[splitName] = { conditions: [condition], configurations: {}, trafficTypeName: 'localhost' };
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -110,7 +110,7 @@ function splitsParserFromFileFactory() {
|
|
|
110
110
|
// Each entry will be mapped to a condition, but we'll also keep the configurations map.
|
|
111
111
|
var mocksData = yamldoc.reduce(function (accum, splitEntry) {
|
|
112
112
|
var splitName = Object.keys(splitEntry)[0];
|
|
113
|
-
if (!splitName || !lang_1.isString(splitEntry[splitName].treatment))
|
|
113
|
+
if (!splitName || !(0, lang_1.isString)(splitEntry[splitName].treatment))
|
|
114
114
|
log.error(logPrefix + 'Ignoring entry on YAML since the format is incorrect.');
|
|
115
115
|
var mockData = splitEntry[splitName];
|
|
116
116
|
// "Template" for each split accumulated data
|
|
@@ -123,7 +123,7 @@ function splitsParserFromFileFactory() {
|
|
|
123
123
|
if (mockData.config)
|
|
124
124
|
accum[splitName].configurations[mockData.treatment] = mockData.config;
|
|
125
125
|
// Parse the condition from the entry.
|
|
126
|
-
var condition = parseCondition_1.parseCondition(mockData);
|
|
126
|
+
var condition = (0, parseCondition_1.parseCondition)(mockData);
|
|
127
127
|
accum[splitName].conditions[condition.conditionType === 'ROLLOUT' ? 'push' : 'unshift'](condition);
|
|
128
128
|
// Also keep track of the treatments, will be useful for manager functionality.
|
|
129
129
|
accum[splitName].treatments.push(mockData.treatment);
|
|
@@ -138,7 +138,7 @@ function splitsParserFromFileFactory() {
|
|
|
138
138
|
var filePath = configFilesPath(features);
|
|
139
139
|
var mockData;
|
|
140
140
|
// If we have a filePath, it means the extension is correct, choose the parser.
|
|
141
|
-
if (lang_1.endsWith(filePath, '.split')) {
|
|
141
|
+
if ((0, lang_1.endsWith)(filePath, '.split')) {
|
|
142
142
|
log.warn(logPrefix + '.split mocks will be deprecated soon in favor of YAML files, which provide more targeting power. Take a look in our documentation.');
|
|
143
143
|
mockData = readSplitConfigFile(log, filePath);
|
|
144
144
|
}
|
|
@@ -40,10 +40,10 @@ function splitsParserFromSettingsFactory() {
|
|
|
40
40
|
if (!mockUpdated(features))
|
|
41
41
|
return false;
|
|
42
42
|
var splitObjects = {};
|
|
43
|
-
lang_1.forOwn(features, function (data, splitName) {
|
|
43
|
+
(0, lang_1.forOwn)(features, function (data, splitName) {
|
|
44
44
|
var treatment = data;
|
|
45
45
|
var config = null;
|
|
46
|
-
if (lang_1.isObject(data)) {
|
|
46
|
+
if ((0, lang_1.isObject)(data)) {
|
|
47
47
|
treatment = data.treatment;
|
|
48
48
|
config = data.config || config;
|
|
49
49
|
}
|
|
@@ -52,7 +52,7 @@ function splitsParserFromSettingsFactory() {
|
|
|
52
52
|
configurations[treatment] = config;
|
|
53
53
|
splitObjects[splitName] = {
|
|
54
54
|
trafficTypeName: 'localhost',
|
|
55
|
-
conditions: [parseCondition_1.parseCondition({ treatment: treatment })],
|
|
55
|
+
conditions: [(0, parseCondition_1.parseCondition)({ treatment: treatment })],
|
|
56
56
|
configurations: configurations
|
|
57
57
|
};
|
|
58
58
|
});
|
|
@@ -19,7 +19,7 @@ function syncManagerOfflineFactory(splitsParserFactory) {
|
|
|
19
19
|
*/
|
|
20
20
|
return function (_a) {
|
|
21
21
|
var settings = _a.settings, readiness = _a.readiness, storage = _a.storage;
|
|
22
|
-
return objectAssign_1.objectAssign(fromObjectSyncTask_1.fromObjectSyncTaskFactory(splitsParserFactory(), storage, readiness, settings), {
|
|
22
|
+
return (0, objectAssign_1.objectAssign)((0, fromObjectSyncTask_1.fromObjectSyncTaskFactory)(splitsParserFactory(), storage, readiness, settings), {
|
|
23
23
|
// fake flush, that resolves immediately
|
|
24
24
|
flush: flush,
|
|
25
25
|
// [Only used for client-side]
|
|
@@ -25,7 +25,7 @@ function fromObjectUpdaterFactory(splitsParser, storage, readiness, settings) {
|
|
|
25
25
|
}
|
|
26
26
|
if (!loadError && splitsMock) {
|
|
27
27
|
log.debug(constants_3.SYNC_OFFLINE_DATA, [JSON.stringify(splitsMock)]);
|
|
28
|
-
lang_1.forOwn(splitsMock, function (val, name) {
|
|
28
|
+
(0, lang_1.forOwn)(splitsMock, function (val, name) {
|
|
29
29
|
splits.push([
|
|
30
30
|
name,
|
|
31
31
|
JSON.stringify({
|
|
@@ -68,6 +68,6 @@ exports.fromObjectUpdaterFactory = fromObjectUpdaterFactory;
|
|
|
68
68
|
* PollingManager in Offline mode
|
|
69
69
|
*/
|
|
70
70
|
function fromObjectSyncTaskFactory(splitsParser, storage, readiness, settings) {
|
|
71
|
-
return syncTask_1.syncTaskFactory(settings.log, fromObjectUpdaterFactory(splitsParser, storage, readiness, settings), settings.scheduler.offlineRefreshRate, 'offlineUpdater');
|
|
71
|
+
return (0, syncTask_1.syncTaskFactory)(settings.log, fromObjectUpdaterFactory(splitsParser, storage, readiness, settings), settings.scheduler.offlineRefreshRate, 'offlineUpdater');
|
|
72
72
|
}
|
|
73
73
|
exports.fromObjectSyncTaskFactory = fromObjectSyncTaskFactory;
|
|
@@ -12,7 +12,7 @@ function greedyFetch(fetchSegmentChanges, since, segmentName, noCache) {
|
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
14
|
return Promise.all([json, greedyFetch(fetchSegmentChanges, till, segmentName, noCache)]).then(function (flatMe) {
|
|
15
|
-
return tslib_1.
|
|
15
|
+
return (0, tslib_1.__spreadArray)([flatMe[0]], flatMe[1], true);
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
});
|