@splitsoftware/splitio-commons 2.11.1-rc.2 → 3.0.0-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 +15 -2
- package/cjs/evaluator/condition/engineUtils.js +2 -2
- package/cjs/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.js +70 -0
- package/cjs/evaluator/fallbackConfigsCalculator/index.js +25 -0
- package/cjs/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +5 -8
- package/cjs/evaluator/fallbackTreatmentsCalculator/index.js +21 -32
- package/cjs/evaluator/index.js +67 -42
- package/cjs/evaluator/matchers/whitelist.js +1 -1
- package/cjs/integrations/pluggable.js +1 -1
- package/cjs/listeners/browser.js +4 -3
- package/cjs/listeners/node.js +4 -4
- package/cjs/logger/constants.js +14 -20
- package/cjs/logger/index.js +1 -1
- package/cjs/logger/messages/debug.js +6 -7
- package/cjs/logger/messages/error.js +4 -4
- package/cjs/logger/messages/info.js +2 -4
- package/cjs/logger/messages/warn.js +9 -9
- package/cjs/platform/browser.js +15 -0
- package/cjs/platform/getEventSource/browser.js +8 -0
- package/cjs/platform/getEventSource/eventsource.js +480 -0
- package/cjs/platform/getEventSource/node.js +26 -0
- package/cjs/platform/getFetch/browser.js +9 -0
- package/cjs/platform/getFetch/node.js +27 -0
- package/cjs/platform/getOptions/node.js +25 -0
- package/cjs/platform/node.js +17 -0
- package/cjs/readiness/constants.js +2 -1
- package/cjs/sdkClient/client.js +9 -35
- package/cjs/sdkClient/clientAttributesDecoration.js +3 -3
- package/cjs/sdkClient/clientInputValidation.js +38 -81
- package/cjs/sdkClient/identity.js +1 -1
- package/cjs/sdkClient/sdkClient.js +4 -49
- package/cjs/sdkClient/sdkLifecycle.js +70 -0
- package/cjs/sdkClient/trackMethod.js +56 -0
- package/cjs/sdkFactory/index.js +8 -45
- package/cjs/sdkManager/index.js +3 -3
- package/cjs/services/splitApi.js +18 -13
- package/cjs/services/splitHttpClient.js +1 -1
- package/cjs/storages/AbstractSplitsCacheAsync.js +1 -1
- package/cjs/storages/AbstractSplitsCacheSync.js +1 -1
- package/cjs/storages/KeyBuilder.js +12 -12
- package/cjs/storages/KeyBuilderCS.js +13 -13
- package/cjs/storages/KeyBuilderSS.js +15 -15
- package/cjs/storages/getRolloutPlan.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -1
- package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +1 -1
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/TelemetryCacheInMemory.js +2 -2
- package/cjs/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +5 -5
- package/cjs/storages/inRedis/ImpressionsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RedisAdapter.js +8 -8
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +6 -6
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +7 -7
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +3 -3
- package/cjs/storages/pluggable/EventsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/ImpressionCountsCachePluggable.js +6 -6
- package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SplitsCachePluggable.js +4 -4
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +7 -7
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +2 -2
- package/cjs/storages/pluggable/index.js +3 -3
- package/cjs/storages/pluggable/wrapperAdapter.js +1 -1
- package/cjs/storages/setRolloutPlan.js +1 -1
- package/cjs/storages/utils.js +6 -6
- package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +23 -14
- package/cjs/sync/polling/pollingManagerCS.js +11 -11
- package/cjs/sync/polling/pollingManagerSS.js +13 -13
- package/cjs/sync/polling/syncTasks/definitionsSyncTask.js +12 -0
- package/cjs/sync/polling/updaters/{splitChangesUpdater.js → definitionChangesUpdater.js} +67 -59
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +1 -1
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +6 -6
- package/cjs/sync/streaming/SSEClient/index.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
- package/cjs/sync/streaming/parseUtils.js +12 -12
- package/cjs/sync/streaming/pushManager.js +2 -2
- package/cjs/sync/submitters/impressionsSubmitter.js +6 -6
- package/cjs/sync/submitters/submitter.js +1 -1
- package/cjs/sync/syncManagerOnline.js +5 -2
- package/cjs/trackers/eventTracker.js +10 -12
- package/cjs/trackers/impressionObserver/buildKey.js +1 -1
- package/cjs/trackers/impressionsTracker.js +37 -20
- package/cjs/trackers/uniqueKeysTracker.js +1 -1
- package/cjs/utils/EventEmitter.js +391 -0
- package/cjs/utils/filter/bloomFilter.js +37 -0
- package/cjs/utils/inputValidation/apiKey.js +1 -1
- package/cjs/utils/inputValidation/attribute.js +2 -2
- package/cjs/utils/inputValidation/{split.js → definition.js} +10 -10
- package/cjs/utils/inputValidation/{splitExistence.js → definitionExistence.js} +6 -6
- package/cjs/utils/inputValidation/definitions.js +25 -0
- package/cjs/utils/inputValidation/eventProperties.js +1 -1
- package/cjs/utils/inputValidation/index.js +7 -7
- package/cjs/utils/inputValidation/isOperational.js +4 -4
- package/cjs/utils/inputValidation/target.js +22 -0
- package/cjs/utils/labels/index.js +3 -3
- package/cjs/utils/lang/index.js +1 -1
- package/cjs/utils/promise/timeout.js +1 -1
- package/cjs/utils/settingsValidation/splitFilters.js +4 -4
- package/cjs/utils/settingsValidation/url.js +5 -5
- package/esm/evaluator/condition/engineUtils.js +2 -2
- package/esm/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.js +64 -0
- package/esm/evaluator/fallbackConfigsCalculator/index.js +21 -0
- package/esm/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +5 -8
- package/esm/evaluator/fallbackTreatmentsCalculator/index.js +21 -33
- package/esm/evaluator/index.js +66 -42
- package/esm/evaluator/matchers/whitelist.js +1 -1
- package/esm/integrations/pluggable.js +1 -1
- package/esm/listeners/browser.js +4 -3
- package/esm/listeners/node.js +4 -4
- package/esm/logger/constants.js +11 -17
- package/esm/logger/index.js +1 -1
- package/esm/logger/messages/debug.js +5 -6
- package/esm/logger/messages/error.js +3 -3
- package/esm/logger/messages/info.js +1 -3
- package/esm/logger/messages/warn.js +8 -8
- package/esm/platform/browser.js +12 -0
- package/esm/platform/getEventSource/browser.js +4 -0
- package/esm/platform/getEventSource/eventsource.js +480 -0
- package/esm/platform/getEventSource/node.js +20 -0
- package/esm/platform/getFetch/browser.js +5 -0
- package/esm/platform/getFetch/node.js +22 -0
- package/esm/platform/getOptions/node.js +20 -0
- package/esm/platform/node.js +14 -0
- package/esm/readiness/constants.js +1 -0
- package/esm/sdkClient/client.js +10 -37
- package/esm/sdkClient/clientAttributesDecoration.js +3 -3
- package/esm/sdkClient/clientInputValidation.js +40 -83
- package/esm/sdkClient/identity.js +1 -1
- package/esm/sdkClient/sdkClient.js +4 -49
- package/esm/sdkClient/sdkLifecycle.js +66 -0
- package/esm/sdkClient/trackMethod.js +52 -0
- package/esm/sdkFactory/index.js +8 -45
- package/esm/sdkManager/index.js +4 -4
- package/esm/services/splitApi.js +18 -13
- package/esm/services/splitHttpClient.js +1 -1
- package/esm/storages/AbstractSplitsCacheAsync.js +1 -1
- package/esm/storages/AbstractSplitsCacheSync.js +1 -1
- package/esm/storages/KeyBuilder.js +12 -12
- package/esm/storages/KeyBuilderCS.js +12 -12
- package/esm/storages/KeyBuilderSS.js +14 -14
- package/esm/storages/getRolloutPlan.js +1 -1
- package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +1 -1
- package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/TelemetryCacheInMemory.js +2 -2
- package/esm/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +4 -4
- package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/RedisAdapter.js +7 -7
- package/esm/storages/inRedis/SplitsCacheInRedis.js +4 -4
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +7 -7
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/esm/storages/pluggable/EventsCachePluggable.js +1 -1
- package/esm/storages/pluggable/ImpressionCountsCachePluggable.js +5 -5
- package/esm/storages/pluggable/RBSegmentsCachePluggable.js +1 -1
- package/esm/storages/pluggable/SplitsCachePluggable.js +2 -2
- package/esm/storages/pluggable/TelemetryCachePluggable.js +7 -7
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/esm/storages/pluggable/index.js +2 -2
- package/esm/storages/pluggable/wrapperAdapter.js +1 -1
- package/esm/storages/setRolloutPlan.js +1 -1
- package/esm/storages/utils.js +6 -6
- package/esm/sync/offline/splitsParser/parseCondition.js +1 -1
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +24 -15
- package/esm/sync/polling/pollingManagerCS.js +11 -11
- package/esm/sync/polling/pollingManagerSS.js +13 -13
- package/esm/sync/polling/syncTasks/definitionsSyncTask.js +8 -0
- package/esm/sync/polling/updaters/{splitChangesUpdater.js → definitionChangesUpdater.js} +67 -59
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +7 -7
- package/esm/sync/streaming/SSEClient/index.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
- package/esm/sync/streaming/parseUtils.js +10 -10
- package/esm/sync/streaming/pushManager.js +3 -3
- package/esm/sync/submitters/impressionsSubmitter.js +6 -6
- package/esm/sync/submitters/submitter.js +1 -1
- package/esm/sync/syncManagerOnline.js +5 -2
- package/esm/trackers/eventTracker.js +10 -12
- package/esm/trackers/impressionObserver/buildKey.js +1 -1
- package/esm/trackers/impressionsTracker.js +38 -21
- package/esm/trackers/uniqueKeysTracker.js +1 -1
- package/esm/utils/EventEmitter.js +387 -0
- package/esm/utils/filter/bloomFilter.js +33 -0
- package/esm/utils/inputValidation/apiKey.js +1 -1
- package/esm/utils/inputValidation/attribute.js +2 -2
- package/esm/utils/inputValidation/{split.js → definition.js} +8 -8
- package/esm/utils/inputValidation/definitionExistence.js +15 -0
- package/esm/utils/inputValidation/definitions.js +21 -0
- package/esm/utils/inputValidation/index.js +3 -3
- package/esm/utils/inputValidation/isOperational.js +4 -4
- package/esm/utils/inputValidation/target.js +18 -0
- package/esm/utils/labels/index.js +2 -2
- package/esm/utils/promise/timeout.js +1 -1
- package/esm/utils/settingsValidation/splitFilters.js +4 -4
- package/esm/utils/settingsValidation/url.js +5 -5
- package/package.json +15 -6
- package/src/dtos/types.ts +65 -70
- package/src/evaluator/Engine.ts +4 -4
- package/src/evaluator/combiners/and.ts +3 -3
- package/src/evaluator/combiners/ifelseif.ts +2 -2
- package/src/evaluator/condition/engineUtils.ts +2 -2
- package/src/evaluator/condition/index.ts +3 -3
- package/src/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.ts +76 -0
- package/src/evaluator/fallbackConfigsCalculator/index.ts +24 -0
- package/src/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.ts +5 -7
- package/src/evaluator/fallbackTreatmentsCalculator/index.ts +27 -41
- package/src/evaluator/index.ts +80 -45
- package/src/evaluator/matchers/dependency.ts +2 -2
- package/src/evaluator/matchers/matcherTypes.ts +2 -2
- package/src/evaluator/matchers/prerequisites.ts +4 -4
- package/src/evaluator/matchers/rbsegment.ts +2 -2
- package/src/evaluator/matchers/whitelist.ts +2 -2
- package/src/evaluator/matchersTransform/index.ts +2 -2
- package/src/evaluator/matchersTransform/whitelist.ts +2 -2
- package/src/evaluator/parser/index.ts +4 -4
- package/src/evaluator/treatments/index.ts +2 -2
- package/src/evaluator/types.ts +6 -6
- package/src/evaluator/value/index.ts +1 -1
- package/src/integrations/pluggable.ts +1 -1
- package/src/listeners/browser.ts +11 -8
- package/src/listeners/node.ts +2 -5
- package/src/logger/constants.ts +11 -17
- package/src/logger/messages/debug.ts +5 -6
- package/src/logger/messages/error.ts +3 -3
- package/src/logger/messages/info.ts +1 -3
- package/src/logger/messages/warn.ts +8 -8
- package/src/platform/browser.ts +14 -0
- package/src/platform/getEventSource/browser.ts +4 -0
- package/src/platform/getEventSource/eventsource.js +519 -0
- package/src/platform/getEventSource/node.ts +23 -0
- package/src/platform/getFetch/browser.ts +5 -0
- package/src/platform/getFetch/node.ts +27 -0
- package/src/platform/getOptions/node.ts +24 -0
- package/src/platform/node.ts +16 -0
- package/src/readiness/constants.ts +1 -0
- package/src/sdkClient/client.ts +11 -41
- package/src/sdkClient/clientInputValidation.ts +44 -84
- package/src/sdkClient/sdkClient.ts +5 -54
- package/src/sdkClient/sdkLifecycle.ts +78 -0
- package/src/sdkClient/trackMethod.ts +59 -0
- package/src/sdkFactory/index.ts +10 -54
- package/src/sdkFactory/types.ts +19 -16
- package/src/sdkManager/index.ts +9 -9
- package/src/services/splitApi.ts +6 -0
- package/src/services/types.ts +3 -2
- package/src/storages/AbstractSplitsCacheAsync.ts +7 -7
- package/src/storages/AbstractSplitsCacheSync.ts +10 -10
- package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +2 -2
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +6 -6
- package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +2 -2
- package/src/storages/inMemory/SplitsCacheInMemory.ts +5 -5
- package/src/storages/inMemory/TelemetryCacheInMemory.ts +2 -2
- package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +2 -2
- package/src/storages/inRedis/SplitsCacheInRedis.ts +9 -9
- package/src/storages/pluggable/RBSegmentsCachePluggable.ts +2 -2
- package/src/storages/pluggable/SplitsCachePluggable.ts +9 -9
- package/src/storages/types.ts +21 -16
- package/src/sync/offline/splitsParser/parseCondition.ts +2 -2
- package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +3 -3
- package/src/sync/offline/splitsParser/types.ts +6 -3
- package/src/sync/offline/syncManagerOffline.ts +2 -2
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +6 -6
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +57 -22
- package/src/sync/polling/fetchers/types.ts +5 -3
- package/src/sync/polling/pollingManagerCS.ts +12 -10
- package/src/sync/polling/pollingManagerSS.ts +15 -13
- package/src/sync/polling/syncTasks/{splitsSyncTask.ts → definitionsSyncTask.ts} +10 -11
- package/src/sync/polling/types.ts +3 -3
- package/src/sync/polling/updaters/{splitChangesUpdater.ts → definitionChangesUpdater.ts} +77 -68
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -2
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +7 -7
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +6 -6
- package/src/sync/streaming/parseUtils.ts +12 -12
- package/src/sync/streaming/pushManager.ts +3 -3
- package/src/sync/submitters/impressionsSubmitter.ts +9 -9
- package/src/sync/submitters/types.ts +3 -0
- package/src/sync/syncManagerOnline.ts +6 -2
- package/src/trackers/eventTracker.ts +7 -10
- package/src/trackers/impressionsTracker.ts +42 -26
- package/src/trackers/types.ts +3 -1
- package/src/utils/EventEmitter.js +444 -0
- package/src/utils/filter/bloomFilter.ts +38 -0
- package/src/utils/inputValidation/definition.ts +27 -0
- package/src/utils/inputValidation/definitionExistence.ts +19 -0
- package/src/utils/inputValidation/definitions.ts +21 -0
- package/src/utils/inputValidation/index.ts +3 -3
- package/src/utils/inputValidation/isOperational.ts +4 -4
- package/src/utils/inputValidation/target.ts +21 -0
- package/src/utils/labels/index.ts +2 -2
- package/src/utils/settingsValidation/splitFilters.ts +3 -3
- package/types/splitio.d.ts +202 -9
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +0 -13
- package/cjs/utils/inputValidation/splits.js +0 -25
- package/esm/sync/polling/syncTasks/splitsSyncTask.js +0 -9
- package/esm/utils/inputValidation/splitExistence.js +0 -15
- package/esm/utils/inputValidation/splits.js +0 -21
- package/src/utils/inputValidation/split.ts +0 -27
- package/src/utils/inputValidation/splitExistence.ts +0 -19
- package/src/utils/inputValidation/splits.ts +0 -21
|
@@ -34,7 +34,7 @@ var RBSegmentsCacheInRedis = /** @class */ (function () {
|
|
|
34
34
|
return _this.redis.set(key, stringifiedNewRBSegment).then(function () { return true; });
|
|
35
35
|
})),
|
|
36
36
|
Promise.all(toRemove.map(function (toRemove) {
|
|
37
|
-
var key = _this.keys.buildRBSegmentKey(toRemove
|
|
37
|
+
var key = _this.keys.buildRBSegmentKey(toRemove);
|
|
38
38
|
return _this.redis.del(key).then(function (status) { return status === 1; });
|
|
39
39
|
}))
|
|
40
40
|
]).then(function (_a) {
|
|
@@ -49,7 +49,7 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
49
49
|
this._runningCommands = new Set();
|
|
50
50
|
// Instantiate the client using the dynamic constructor
|
|
51
51
|
var librarySettings = RedisAdapter._defineLibrarySettings(options);
|
|
52
|
-
this.client = new (RedisConstructor.bind.apply(RedisConstructor,
|
|
52
|
+
this.client = new (RedisConstructor.bind.apply(RedisConstructor, tslib_1.__spreadArray([void 0], librarySettings, false)))();
|
|
53
53
|
this._listenToEvents();
|
|
54
54
|
this._setTimeoutWrappers();
|
|
55
55
|
this._setDisconnectWrapper();
|
|
@@ -61,9 +61,9 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
61
61
|
var _this = this;
|
|
62
62
|
this.client.once('ready', function () {
|
|
63
63
|
var commandsCount = _this._notReadyCommandsQueue ? _this._notReadyCommandsQueue.length : 0;
|
|
64
|
-
_this.log.info(LOG_PREFIX +
|
|
64
|
+
_this.log.info(LOG_PREFIX + "Redis connection established. Queued commands: ".concat(commandsCount, "."));
|
|
65
65
|
_this._notReadyCommandsQueue && _this._notReadyCommandsQueue.forEach(function (queued) {
|
|
66
|
-
_this.log.info(LOG_PREFIX +
|
|
66
|
+
_this.log.info(LOG_PREFIX + "Executing queued ".concat(queued.name, " command."));
|
|
67
67
|
queued.command().then(queued.resolve).catch(queued.reject);
|
|
68
68
|
});
|
|
69
69
|
// After the SDK is ready for the first time we'll stop queueing commands. This is just so we can keep handling BUR for them.
|
|
@@ -85,7 +85,7 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
85
85
|
params[_i] = arguments[_i];
|
|
86
86
|
}
|
|
87
87
|
function commandWrapper() {
|
|
88
|
-
instance.log.debug(LOG_PREFIX
|
|
88
|
+
instance.log.debug("".concat(LOG_PREFIX, "Executing ").concat(methodName, "."));
|
|
89
89
|
var result = originalMethod.apply(bindTarget, params);
|
|
90
90
|
if ((0, thenable_1.thenable)(result)) {
|
|
91
91
|
// For handling pending commands on disconnect, add to the set and remove once finished.
|
|
@@ -97,7 +97,7 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
97
97
|
// Both success and error remove from queue.
|
|
98
98
|
result.then(cleanUpRunningCommandsCb, cleanUpRunningCommandsCb);
|
|
99
99
|
return (0, timeout_1.timeout)(instance._options.operationTimeout, result).catch(function (err) {
|
|
100
|
-
instance.log.error(""
|
|
100
|
+
instance.log.error("".concat(LOG_PREFIX).concat(methodName, " operation threw an error or exceeded configured timeout of ").concat(instance._options.operationTimeout, "ms. Message: ").concat(err));
|
|
101
101
|
// Handling is not the adapter responsibility.
|
|
102
102
|
throw err;
|
|
103
103
|
});
|
|
@@ -135,7 +135,7 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
135
135
|
}
|
|
136
136
|
var res = originalFn.apply(instance.client, args);
|
|
137
137
|
var originalExec = res.exec;
|
|
138
|
-
res.exec = wrapCommand(originalExec, methodName
|
|
138
|
+
res.exec = wrapCommand(originalExec, "".concat(methodName, ".exec"), res);
|
|
139
139
|
return res;
|
|
140
140
|
};
|
|
141
141
|
});
|
|
@@ -150,14 +150,14 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
150
150
|
}
|
|
151
151
|
setTimeout(function deferredDisconnect() {
|
|
152
152
|
if (instance._runningCommands.size > 0) {
|
|
153
|
-
instance.log.info(LOG_PREFIX +
|
|
153
|
+
instance.log.info(LOG_PREFIX + "Attempting to disconnect but there are ".concat(instance._runningCommands.size, " commands still waiting for resolution. Defering disconnection until those finish."));
|
|
154
154
|
Promise.all((0, sets_1.setToArray)(instance._runningCommands))
|
|
155
155
|
.then(function () {
|
|
156
156
|
instance.log.debug(LOG_PREFIX + 'Pending commands finished successfully, disconnecting.');
|
|
157
157
|
originalMethod.apply(instance.client, params);
|
|
158
158
|
})
|
|
159
159
|
.catch(function (e) {
|
|
160
|
-
instance.log.warn(LOG_PREFIX +
|
|
160
|
+
instance.log.warn(LOG_PREFIX + "Pending commands finished with error: ".concat(e, ". Proceeding with disconnection."));
|
|
161
161
|
originalMethod.apply(instance.client, params);
|
|
162
162
|
});
|
|
163
163
|
}
|
|
@@ -21,7 +21,7 @@ function processPipelineAnswer(results) {
|
|
|
21
21
|
* Supported by Node.js
|
|
22
22
|
*/
|
|
23
23
|
var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
24
|
-
|
|
24
|
+
tslib_1.__extends(SplitsCacheInRedis, _super);
|
|
25
25
|
function SplitsCacheInRedis(log, keys, redis, splitFiltersValidation) {
|
|
26
26
|
var _this = _super.call(this) || this;
|
|
27
27
|
_this.log = log;
|
|
@@ -60,7 +60,7 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
var items = [featureFlagName];
|
|
63
|
-
return Promise.all(
|
|
63
|
+
return Promise.all(tslib_1.__spreadArray(tslib_1.__spreadArray([], removeFromFlagSets.map(function (flagSetName) { return _this.redis.srem(_this.keys.buildFlagSetKey(flagSetName), items); }), true), addToFlagSets.map(function (flagSetName) { return _this.redis.sadd(_this.keys.buildFlagSetKey(flagSetName), items); }), true));
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
66
66
|
* Add a given split.
|
|
@@ -179,7 +179,7 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
179
179
|
var e = _a[0], value = _a[1];
|
|
180
180
|
if (e === null)
|
|
181
181
|
return value;
|
|
182
|
-
_this.log.error(constants_1.LOG_PREFIX +
|
|
182
|
+
_this.log.error(constants_1.LOG_PREFIX + "Could not read result from get members of flag set ".concat(flagSets[index], " due to an error: ").concat(e));
|
|
183
183
|
}) : []; })
|
|
184
184
|
.then(function (namesByFlagSets) { return namesByFlagSets.map(function (namesByFlagSet) { return new Set(namesByFlagSet); }); });
|
|
185
185
|
};
|
|
@@ -198,13 +198,13 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
198
198
|
return false; // if entry doesn't exist, means that TT doesn't exist
|
|
199
199
|
ttCount = parseInt(ttCount, 10);
|
|
200
200
|
if (!(0, lang_1.isFiniteNumber)(ttCount) || ttCount < 0) {
|
|
201
|
-
_this.log.info(constants_1.LOG_PREFIX +
|
|
201
|
+
_this.log.info(constants_1.LOG_PREFIX + "Could not validate traffic type existence of ".concat(trafficType, " due to data corruption of some sorts."));
|
|
202
202
|
return false;
|
|
203
203
|
}
|
|
204
204
|
return ttCount > 0;
|
|
205
205
|
})
|
|
206
206
|
.catch(function (e) {
|
|
207
|
-
_this.log.error(constants_1.LOG_PREFIX +
|
|
207
|
+
_this.log.error(constants_1.LOG_PREFIX + "Could not validate traffic type existence of ".concat(trafficType, " due to an error: ").concat(e, "."));
|
|
208
208
|
// If there is an error, bypass the validation so the event can get tracked.
|
|
209
209
|
return true;
|
|
210
210
|
});
|
|
@@ -234,7 +234,7 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
234
234
|
return Promise.resolve(splits);
|
|
235
235
|
})
|
|
236
236
|
.catch(function (e) {
|
|
237
|
-
_this.log.error(constants_1.LOG_PREFIX +
|
|
237
|
+
_this.log.error(constants_1.LOG_PREFIX + "Could not grab feature flags due to an error: ".concat(e, "."));
|
|
238
238
|
return Promise.reject(e);
|
|
239
239
|
});
|
|
240
240
|
};
|
|
@@ -45,17 +45,17 @@ var TelemetryCacheInRedis = /** @class */ (function () {
|
|
|
45
45
|
Object.keys(latencies).forEach(function (field) {
|
|
46
46
|
var parsedField = (0, utils_1.parseLatencyField)(field);
|
|
47
47
|
if ((0, lang_1.isString)(parsedField)) {
|
|
48
|
-
_this.log.error("Ignoring invalid latency field: "
|
|
48
|
+
_this.log.error("Ignoring invalid latency field: ".concat(field, ": ").concat(parsedField));
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
var count = parseInt(latencies[field]);
|
|
52
52
|
if ((0, lang_1.isNaNNumber)(count)) {
|
|
53
|
-
_this.log.error("Ignoring latency with invalid count: "
|
|
53
|
+
_this.log.error("Ignoring latency with invalid count: ".concat(latencies[field]));
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
var metadata = parsedField[0], method = parsedField[1], bucket = parsedField[2];
|
|
57
57
|
if (bucket >= TelemetryCacheInMemory_1.MAX_LATENCY_BUCKET_COUNT) {
|
|
58
|
-
_this.log.error("Ignoring latency with invalid bucket: "
|
|
58
|
+
_this.log.error("Ignoring latency with invalid bucket: ".concat(bucket));
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
var methodLatencies = result.get(metadata) || {};
|
|
@@ -77,12 +77,12 @@ var TelemetryCacheInRedis = /** @class */ (function () {
|
|
|
77
77
|
Object.keys(exceptions).forEach(function (field) {
|
|
78
78
|
var parsedField = (0, utils_1.parseExceptionField)(field);
|
|
79
79
|
if ((0, lang_1.isString)(parsedField)) {
|
|
80
|
-
_this.log.error("Ignoring invalid exception field: "
|
|
80
|
+
_this.log.error("Ignoring invalid exception field: ".concat(field, ": ").concat(parsedField));
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
var count = parseInt(exceptions[field]);
|
|
84
84
|
if ((0, lang_1.isNaNNumber)(count)) {
|
|
85
|
-
_this.log.error("Ignoring exception with invalid count: "
|
|
85
|
+
_this.log.error("Ignoring exception with invalid count: ".concat(exceptions[field]));
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
var metadata = parsedField[0], method = parsedField[1];
|
|
@@ -104,7 +104,7 @@ var TelemetryCacheInRedis = /** @class */ (function () {
|
|
|
104
104
|
Object.keys(configs).forEach(function (field) {
|
|
105
105
|
var parsedField = (0, utils_1.parseMetadata)(field);
|
|
106
106
|
if ((0, lang_1.isString)(parsedField)) {
|
|
107
|
-
_this.log.error("Ignoring invalid config field: "
|
|
107
|
+
_this.log.error("Ignoring invalid config field: ".concat(field, ": ").concat(parsedField));
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
110
|
var metadata = parsedField[0];
|
|
@@ -113,7 +113,7 @@ var TelemetryCacheInRedis = /** @class */ (function () {
|
|
|
113
113
|
result.set(metadata, config);
|
|
114
114
|
}
|
|
115
115
|
catch (e) {
|
|
116
|
-
_this.log.error("Ignoring invalid config: "
|
|
116
|
+
_this.log.error("Ignoring invalid config: ".concat(configs[field]));
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
return _this.redis.del(_this.keys.initPrefix).then(function () { return result; });
|
|
@@ -7,7 +7,7 @@ var constants_1 = require("./constants");
|
|
|
7
7
|
var constants_2 = require("./constants");
|
|
8
8
|
var sets_1 = require("../../utils/lang/sets");
|
|
9
9
|
var UniqueKeysCacheInRedis = /** @class */ (function (_super) {
|
|
10
|
-
|
|
10
|
+
tslib_1.__extends(UniqueKeysCacheInRedis, _super);
|
|
11
11
|
function UniqueKeysCacheInRedis(log, key, redis, uniqueKeysQueueSize, refreshRate) {
|
|
12
12
|
if (uniqueKeysQueueSize === void 0) { uniqueKeysQueueSize = constants_1.DEFAULT_CACHE_SIZE; }
|
|
13
13
|
if (refreshRate === void 0) { refreshRate = constants_1.REFRESH_RATE; }
|
|
@@ -34,14 +34,14 @@ var UniqueKeysCacheInRedis = /** @class */ (function (_super) {
|
|
|
34
34
|
return JSON.stringify(uniqueKeysPayload);
|
|
35
35
|
});
|
|
36
36
|
this.clear();
|
|
37
|
-
return (_a = this.redis).rpush.apply(_a,
|
|
37
|
+
return (_a = this.redis).rpush.apply(_a, tslib_1.__spreadArray([this.key], uniqueKeysArray, false)).then(function (data) {
|
|
38
38
|
// If this is the creation of the key on Redis, set the expiration for it in 3600 seconds.
|
|
39
39
|
if (data === featureNames.length) {
|
|
40
40
|
return _this.redis.expire(_this.key, constants_1.TTL_REFRESH);
|
|
41
41
|
}
|
|
42
42
|
})
|
|
43
43
|
.catch(function (err) {
|
|
44
|
-
_this.log.error(constants_2.LOG_PREFIX
|
|
44
|
+
_this.log.error("".concat(constants_2.LOG_PREFIX, "Error in uniqueKeys pipeline: ").concat(err, "."));
|
|
45
45
|
return false;
|
|
46
46
|
});
|
|
47
47
|
};
|
|
@@ -21,7 +21,7 @@ var EventsCachePluggable = /** @class */ (function () {
|
|
|
21
21
|
// We use boolean values to signal successful queueing
|
|
22
22
|
.then(function () { return true; })
|
|
23
23
|
.catch(function (e) {
|
|
24
|
-
_this.log.error(constants_1.LOG_PREFIX
|
|
24
|
+
_this.log.error("".concat(constants_1.LOG_PREFIX, "Error adding event to queue: ").concat(e, "."));
|
|
25
25
|
return false;
|
|
26
26
|
});
|
|
27
27
|
};
|
|
@@ -6,7 +6,7 @@ var ImpressionCountsCacheInMemory_1 = require("../inMemory/ImpressionCountsCache
|
|
|
6
6
|
var constants_1 = require("../inRedis/constants");
|
|
7
7
|
var constants_2 = require("./constants");
|
|
8
8
|
var ImpressionCountsCachePluggable = /** @class */ (function (_super) {
|
|
9
|
-
|
|
9
|
+
tslib_1.__extends(ImpressionCountsCachePluggable, _super);
|
|
10
10
|
function ImpressionCountsCachePluggable(log, key, wrapper, impressionCountsCacheSize, refreshRate) {
|
|
11
11
|
if (refreshRate === void 0) { refreshRate = constants_1.REFRESH_RATE; }
|
|
12
12
|
var _this = _super.call(this, impressionCountsCacheSize) || this;
|
|
@@ -24,10 +24,10 @@ var ImpressionCountsCachePluggable = /** @class */ (function (_super) {
|
|
|
24
24
|
if (!keys.length)
|
|
25
25
|
return Promise.resolve(false);
|
|
26
26
|
var pipeline = keys.reduce(function (pipeline, key) {
|
|
27
|
-
return pipeline.then(function () { return _this.wrapper.incr(_this.key
|
|
27
|
+
return pipeline.then(function () { return _this.wrapper.incr("".concat(_this.key, "::").concat(key), counts[key]); });
|
|
28
28
|
}, Promise.resolve());
|
|
29
29
|
return pipeline.catch(function (err) {
|
|
30
|
-
_this.log.error(constants_2.LOG_PREFIX
|
|
30
|
+
_this.log.error("".concat(constants_2.LOG_PREFIX, "Error in impression counts pipeline: ").concat(err, "."));
|
|
31
31
|
return false;
|
|
32
32
|
});
|
|
33
33
|
};
|
|
@@ -52,18 +52,18 @@ var ImpressionCountsCachePluggable = /** @class */ (function (_super) {
|
|
|
52
52
|
var count = counts[i];
|
|
53
53
|
var keyFeatureNameAndTime = key.split('::');
|
|
54
54
|
if (keyFeatureNameAndTime.length !== 3) {
|
|
55
|
-
_this.log.error(constants_2.LOG_PREFIX
|
|
55
|
+
_this.log.error("".concat(constants_2.LOG_PREFIX, "Error spliting key ").concat(key));
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
58
|
var timeFrame = parseInt(keyFeatureNameAndTime[2]);
|
|
59
59
|
if (isNaN(timeFrame)) {
|
|
60
|
-
_this.log.error(constants_2.LOG_PREFIX
|
|
60
|
+
_this.log.error("".concat(constants_2.LOG_PREFIX, "Error parsing time frame ").concat(keyFeatureNameAndTime[2]));
|
|
61
61
|
continue;
|
|
62
62
|
}
|
|
63
63
|
// @ts-ignore
|
|
64
64
|
var rawCount = parseInt(count);
|
|
65
65
|
if (isNaN(rawCount)) {
|
|
66
|
-
_this.log.error(constants_2.LOG_PREFIX
|
|
66
|
+
_this.log.error("".concat(constants_2.LOG_PREFIX, "Error parsing raw count ").concat(count));
|
|
67
67
|
continue;
|
|
68
68
|
}
|
|
69
69
|
pf.push({
|
|
@@ -34,7 +34,7 @@ var RBSegmentsCachePluggable = /** @class */ (function () {
|
|
|
34
34
|
return _this.wrapper.set(key, stringifiedNewRBSegment).then(function () { return true; });
|
|
35
35
|
})),
|
|
36
36
|
Promise.all(toRemove.map(function (toRemove) {
|
|
37
|
-
var key = _this.keys.buildRBSegmentKey(toRemove
|
|
37
|
+
var key = _this.keys.buildRBSegmentKey(toRemove);
|
|
38
38
|
return _this.wrapper.del(key);
|
|
39
39
|
}))
|
|
40
40
|
]).then(function (_a) {
|
|
@@ -10,7 +10,7 @@ var sets_1 = require("../../utils/lang/sets");
|
|
|
10
10
|
* ISplitsCacheAsync implementation for pluggable storages.
|
|
11
11
|
*/
|
|
12
12
|
var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
13
|
-
|
|
13
|
+
tslib_1.__extends(SplitsCachePluggable, _super);
|
|
14
14
|
/**
|
|
15
15
|
* Create a SplitsCache that uses a storage wrapper.
|
|
16
16
|
* @param log - Logger instance.
|
|
@@ -47,7 +47,7 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
var items = [featureFlagName];
|
|
50
|
-
return Promise.all(
|
|
50
|
+
return Promise.all(tslib_1.__spreadArray(tslib_1.__spreadArray([], removeFromFlagSets.map(function (flagSetName) { return _this.wrapper.removeItems(_this.keys.buildFlagSetKey(flagSetName), items); }), true), addToFlagSets.map(function (flagSetName) { return _this.wrapper.addItems(_this.keys.buildFlagSetKey(flagSetName), items); }), true));
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
53
|
* Add a given split.
|
|
@@ -170,12 +170,12 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
170
170
|
return false; // if entry doesn't exist, means that TT doesn't exist
|
|
171
171
|
ttCount = parseInt(ttCount, 10);
|
|
172
172
|
if (!(0, lang_1.isFiniteNumber)(ttCount) || ttCount < 0) {
|
|
173
|
-
_this.log.info(constants_1.LOG_PREFIX +
|
|
173
|
+
_this.log.info(constants_1.LOG_PREFIX + "Could not validate traffic type existence of ".concat(trafficType, " due to data corruption of some sorts."));
|
|
174
174
|
return false;
|
|
175
175
|
}
|
|
176
176
|
return ttCount > 0;
|
|
177
177
|
}).catch(function (e) {
|
|
178
|
-
_this.log.error(constants_1.LOG_PREFIX +
|
|
178
|
+
_this.log.error(constants_1.LOG_PREFIX + "Could not validate traffic type existence of ".concat(trafficType, " due to an error: ").concat(e, "."));
|
|
179
179
|
// If there is an error, bypass the validation so the event can get tracked.
|
|
180
180
|
return true;
|
|
181
181
|
});
|
|
@@ -45,18 +45,18 @@ var TelemetryCachePluggable = /** @class */ (function () {
|
|
|
45
45
|
var field = latencyKeys[i].split('::')[1];
|
|
46
46
|
var parsedField = (0, utils_1.parseLatencyField)(field);
|
|
47
47
|
if ((0, lang_1.isString)(parsedField)) {
|
|
48
|
-
_this.log.error("Ignoring invalid latency field: "
|
|
48
|
+
_this.log.error("Ignoring invalid latency field: ".concat(field, ": ").concat(parsedField));
|
|
49
49
|
continue;
|
|
50
50
|
}
|
|
51
51
|
// @ts-ignore
|
|
52
52
|
var count = parseInt(latencies[i]);
|
|
53
53
|
if ((0, lang_1.isNaNNumber)(count)) {
|
|
54
|
-
_this.log.error("Ignoring latency with invalid count: "
|
|
54
|
+
_this.log.error("Ignoring latency with invalid count: ".concat(latencies[i]));
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
57
|
var metadata = parsedField[0], method = parsedField[1], bucket = parsedField[2];
|
|
58
58
|
if (bucket >= TelemetryCacheInMemory_1.MAX_LATENCY_BUCKET_COUNT) {
|
|
59
|
-
_this.log.error("Ignoring latency with invalid bucket: "
|
|
59
|
+
_this.log.error("Ignoring latency with invalid bucket: ".concat(bucket));
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
62
62
|
var methodLatencies = result.get(metadata) || {};
|
|
@@ -84,13 +84,13 @@ var TelemetryCachePluggable = /** @class */ (function () {
|
|
|
84
84
|
var field = exceptionKeys[i].split('::')[1];
|
|
85
85
|
var parsedField = (0, utils_1.parseExceptionField)(field);
|
|
86
86
|
if ((0, lang_1.isString)(parsedField)) {
|
|
87
|
-
_this.log.error("Ignoring invalid exception field: "
|
|
87
|
+
_this.log.error("Ignoring invalid exception field: ".concat(field, ": ").concat(parsedField));
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
90
90
|
// @ts-ignore
|
|
91
91
|
var count = parseInt(exceptions[i]);
|
|
92
92
|
if ((0, lang_1.isNaNNumber)(count)) {
|
|
93
|
-
_this.log.error("Ignoring exception with invalid count: "
|
|
93
|
+
_this.log.error("Ignoring exception with invalid count: ".concat(exceptions[i]));
|
|
94
94
|
continue;
|
|
95
95
|
}
|
|
96
96
|
var metadata = parsedField[0], method = parsedField[1];
|
|
@@ -118,7 +118,7 @@ var TelemetryCachePluggable = /** @class */ (function () {
|
|
|
118
118
|
var field = configKeys[i].split('::')[1];
|
|
119
119
|
var parsedField = (0, utils_1.parseMetadata)(field);
|
|
120
120
|
if ((0, lang_1.isString)(parsedField)) {
|
|
121
|
-
_this.log.error("Ignoring invalid config field: "
|
|
121
|
+
_this.log.error("Ignoring invalid config field: ".concat(field, ": ").concat(parsedField));
|
|
122
122
|
continue;
|
|
123
123
|
}
|
|
124
124
|
var metadata = parsedField[0];
|
|
@@ -127,7 +127,7 @@ var TelemetryCachePluggable = /** @class */ (function () {
|
|
|
127
127
|
result.set(metadata, config);
|
|
128
128
|
}
|
|
129
129
|
catch (e) {
|
|
130
|
-
_this.log.error("Ignoring invalid config: "
|
|
130
|
+
_this.log.error("Ignoring invalid config: ".concat(configs[i]));
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
return Promise.all(configKeys.map(function (configKey) { return _this.wrapper.del(configKey); })).then(function () { return result; });
|
|
@@ -7,7 +7,7 @@ var constants_1 = require("../inRedis/constants");
|
|
|
7
7
|
var constants_2 = require("./constants");
|
|
8
8
|
var sets_1 = require("../../utils/lang/sets");
|
|
9
9
|
var UniqueKeysCachePluggable = /** @class */ (function (_super) {
|
|
10
|
-
|
|
10
|
+
tslib_1.__extends(UniqueKeysCachePluggable, _super);
|
|
11
11
|
function UniqueKeysCachePluggable(log, key, wrapper, uniqueKeysQueueSize, refreshRate) {
|
|
12
12
|
if (uniqueKeysQueueSize === void 0) { uniqueKeysQueueSize = constants_1.DEFAULT_CACHE_SIZE; }
|
|
13
13
|
if (refreshRate === void 0) { refreshRate = constants_1.REFRESH_RATE; }
|
|
@@ -35,7 +35,7 @@ var UniqueKeysCachePluggable = /** @class */ (function (_super) {
|
|
|
35
35
|
this.clear();
|
|
36
36
|
return this.wrapper.pushItems(this.key, uniqueKeysArray)
|
|
37
37
|
.catch(function (err) {
|
|
38
|
-
_this.log.error(constants_2.LOG_PREFIX
|
|
38
|
+
_this.log.error("".concat(constants_2.LOG_PREFIX, "Error in uniqueKeys pipeline: ").concat(err, "."));
|
|
39
39
|
return false;
|
|
40
40
|
});
|
|
41
41
|
};
|
|
@@ -38,7 +38,7 @@ function validatePluggableStorageOptions(options) {
|
|
|
38
38
|
var wrapper = options.wrapper;
|
|
39
39
|
var missingMethods = wrapperAdapter_1.METHODS_TO_PROMISE_WRAP.filter(function (method) { return typeof wrapper[method] !== 'function'; });
|
|
40
40
|
if (missingMethods.length)
|
|
41
|
-
throw new Error(NO_VALID_WRAPPER_INTERFACE
|
|
41
|
+
throw new Error("".concat(NO_VALID_WRAPPER_INTERFACE, " The following methods are missing or invalid: ").concat(missingMethods));
|
|
42
42
|
}
|
|
43
43
|
// Async return type in `client.track` method on consumer partial mode
|
|
44
44
|
// No need to promisify impressions cache
|
|
@@ -82,7 +82,7 @@ function PluggableStorage(options) {
|
|
|
82
82
|
var currentHash = (0, KeyBuilder_1.getStorageHash)(settings);
|
|
83
83
|
if (hash !== currentHash) {
|
|
84
84
|
log.info(constants_2.LOG_PREFIX + 'Storage HASH has changed (SDK key, flags filter criteria or flags spec version was modified). Clearing cache');
|
|
85
|
-
return wrapper.getKeysByPrefix(keys.prefix
|
|
85
|
+
return wrapper.getKeysByPrefix("".concat(keys.prefix, ".")).then(function (storageKeys) {
|
|
86
86
|
return Promise.all(storageKeys.map(function (storageKey) { return wrapper.del(storageKey); }));
|
|
87
87
|
}).then(function () { return wrapper.set(keys.buildHashKey(), currentHash); });
|
|
88
88
|
}
|
|
@@ -124,7 +124,7 @@ function PluggableStorage(options) {
|
|
|
124
124
|
// emits SDK_READY event on shared clients and returns a reference to the storage
|
|
125
125
|
shared: function (_, onReadyCb) {
|
|
126
126
|
connectPromise.then(onReadyCb);
|
|
127
|
-
return
|
|
127
|
+
return tslib_1.__assign(tslib_1.__assign({}, this), {
|
|
128
128
|
// no-op destroy, to disconnect the wrapper only when the main client is destroyed
|
|
129
129
|
destroy: function () { } });
|
|
130
130
|
}
|
|
@@ -34,7 +34,7 @@ function wrapperAdapter(log, wrapper) {
|
|
|
34
34
|
exports.METHODS_TO_PROMISE_WRAP.forEach(function (method) {
|
|
35
35
|
// Logs error and wraps it into a rejected promise.
|
|
36
36
|
function handleError(e) {
|
|
37
|
-
log.error(constants_1.LOG_PREFIX
|
|
37
|
+
log.error("".concat(constants_1.LOG_PREFIX, " Wrapper '").concat(method, "' operation threw an error. Message: ").concat(e));
|
|
38
38
|
return Promise.reject(e);
|
|
39
39
|
}
|
|
40
40
|
wrapperAdapter[method] = function () {
|
|
@@ -26,7 +26,7 @@ exports.validateRolloutPlan = validateRolloutPlan;
|
|
|
26
26
|
function setRolloutPlan(log, rolloutPlan, storage, matchingKey) {
|
|
27
27
|
var splits = storage.splits, rbSegments = storage.rbSegments, segments = storage.segments, largeSegments = storage.largeSegments;
|
|
28
28
|
var _a = rolloutPlan.splitChanges, ff = _a.ff, rbs = _a.rbs;
|
|
29
|
-
log.debug("storage: set feature flags and segments"
|
|
29
|
+
log.debug("storage: set feature flags and segments".concat(matchingKey ? " for key ".concat(matchingKey) : ''));
|
|
30
30
|
if (splits && ff) {
|
|
31
31
|
splits.clear();
|
|
32
32
|
splits.update(ff.d, [], ff.t);
|
package/cjs/storages/utils.js
CHANGED
|
@@ -42,7 +42,7 @@ var REVERSE_METHOD_NAMES = Object.keys(KeyBuilderSS_1.METHOD_NAMES).reduce(funct
|
|
|
42
42
|
function parseMetadata(field) {
|
|
43
43
|
var parts = field.split('/');
|
|
44
44
|
if (parts.length !== 3)
|
|
45
|
-
return "invalid subsection count. Expected 3, got: "
|
|
45
|
+
return "invalid subsection count. Expected 3, got: ".concat(parts.length);
|
|
46
46
|
var s = parts[0] /* metadata.s */, n = parts[1] /* metadata.n */, i = parts[2] /* metadata.i */;
|
|
47
47
|
return [JSON.stringify({ s: s, n: n, i: i })];
|
|
48
48
|
}
|
|
@@ -50,25 +50,25 @@ exports.parseMetadata = parseMetadata;
|
|
|
50
50
|
function parseExceptionField(field) {
|
|
51
51
|
var parts = field.split('/');
|
|
52
52
|
if (parts.length !== 4)
|
|
53
|
-
return "invalid subsection count. Expected 4, got: "
|
|
53
|
+
return "invalid subsection count. Expected 4, got: ".concat(parts.length);
|
|
54
54
|
var s = parts[0] /* metadata.s */, n = parts[1] /* metadata.n */, i = parts[2] /* metadata.i */, m = parts[3];
|
|
55
55
|
var method = REVERSE_METHOD_NAMES[m];
|
|
56
56
|
if (!method)
|
|
57
|
-
return "unknown method '"
|
|
57
|
+
return "unknown method '".concat(m, "'");
|
|
58
58
|
return [JSON.stringify({ s: s, n: n, i: i }), method];
|
|
59
59
|
}
|
|
60
60
|
exports.parseExceptionField = parseExceptionField;
|
|
61
61
|
function parseLatencyField(field) {
|
|
62
62
|
var parts = field.split('/');
|
|
63
63
|
if (parts.length !== 5)
|
|
64
|
-
return "invalid subsection count. Expected 5, got: "
|
|
64
|
+
return "invalid subsection count. Expected 5, got: ".concat(parts.length);
|
|
65
65
|
var s = parts[0] /* metadata.s */, n = parts[1] /* metadata.n */, i = parts[2] /* metadata.i */, m = parts[3], b = parts[4];
|
|
66
66
|
var method = REVERSE_METHOD_NAMES[m];
|
|
67
67
|
if (!method)
|
|
68
|
-
return "unknown method '"
|
|
68
|
+
return "unknown method '".concat(m, "'");
|
|
69
69
|
var bucket = parseInt(b);
|
|
70
70
|
if (isNaN(bucket) || bucket >= TelemetryCacheInMemory_1.MAX_LATENCY_BUCKET_COUNT)
|
|
71
|
-
return "invalid bucket. Expected a number between 0 and "
|
|
71
|
+
return "invalid bucket. Expected a number between 0 and ".concat(TelemetryCacheInMemory_1.MAX_LATENCY_BUCKET_COUNT - 1, ", got: ").concat(b);
|
|
72
72
|
return [JSON.stringify({ s: s, n: n, i: i }), method, bucket];
|
|
73
73
|
}
|
|
74
74
|
exports.parseLatencyField = parseLatencyField;
|
|
@@ -12,7 +12,7 @@ function greedyFetch(fetchSegmentChanges, since, segmentName, noCache, targetTil
|
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
14
|
return Promise.all([json, greedyFetch(fetchSegmentChanges, till, segmentName, noCache, targetTill)]).then(function (flatMe) {
|
|
15
|
-
return
|
|
15
|
+
return tslib_1.__spreadArray([flatMe[0]], flatMe[1], true);
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
});
|
|
@@ -10,16 +10,25 @@ var PROXY_CHECK_INTERVAL_MILLIS_SS = 24 * PROXY_CHECK_INTERVAL_MILLIS_CS; // 24
|
|
|
10
10
|
function sdkEndpointOverridden(settings) {
|
|
11
11
|
return settings.urls.sdk !== settingsValidation_1.base.urls.sdk;
|
|
12
12
|
}
|
|
13
|
+
function isSplitChangesLegacyResponse(data) {
|
|
14
|
+
return data.splits != null;
|
|
15
|
+
}
|
|
16
|
+
function partitionByStatus(items, till, since) {
|
|
17
|
+
var updated = [], removed = [];
|
|
18
|
+
items.forEach(function (item) { return item.status === 'ARCHIVED' ? removed.push(item.name) : updated.push(item); });
|
|
19
|
+
return { updated: updated, removed: removed, till: till, since: since };
|
|
20
|
+
}
|
|
13
21
|
/**
|
|
14
22
|
* Factory of SplitChanges fetcher.
|
|
15
23
|
* SplitChanges fetcher is a wrapper around `splitChanges` API service that parses the response and handle errors.
|
|
16
24
|
*/
|
|
17
25
|
// @TODO breaking: drop support for Split Proxy below v5.10.0 and simplify the implementation
|
|
18
|
-
function splitChangesFetcherFactory(
|
|
26
|
+
function splitChangesFetcherFactory(params) {
|
|
27
|
+
var fetchSplitChanges = params.splitApi.fetchSplitChanges, settings = params.settings, storage = params.storage;
|
|
19
28
|
var log = settings.log;
|
|
20
29
|
var PROXY_CHECK_INTERVAL_MILLIS = (0, key_1.checkIfServerSide)(settings) ? PROXY_CHECK_INTERVAL_MILLIS_SS : PROXY_CHECK_INTERVAL_MILLIS_CS;
|
|
21
30
|
var lastProxyCheckTimestamp;
|
|
22
|
-
|
|
31
|
+
function splitChangesFetcher(since, noCache, till, rbSince,
|
|
23
32
|
// Optional decorator for `fetchSplitChanges` promise, such as timeout or time tracker
|
|
24
33
|
decorator) {
|
|
25
34
|
// Recheck proxy
|
|
@@ -30,7 +39,7 @@ function splitChangesFetcherFactory(fetchSplitChanges, settings, storage) {
|
|
|
30
39
|
.catch(function (err) {
|
|
31
40
|
// Handle proxy error with spec 1.3
|
|
32
41
|
if ((!err.statusCode || err.statusCode === 400) && sdkEndpointOverridden(settings) && settings.sync.flagSpecVersion === constants_1.FLAG_SPEC_VERSION) {
|
|
33
|
-
log.error(constants_2.
|
|
42
|
+
log.error(constants_2.LOG_PREFIX_SYNC + 'Proxy error detected. Retrying with spec 1.2. If you are using Split Proxy, please upgrade to latest version');
|
|
34
43
|
lastProxyCheckTimestamp = Date.now();
|
|
35
44
|
settings.sync.flagSpecVersion = '1.2'; // fallback to 1.2 spec
|
|
36
45
|
return fetchSplitChanges(since, noCache, till); // retry request without rbSince
|
|
@@ -43,18 +52,12 @@ function splitChangesFetcherFactory(fetchSplitChanges, settings, storage) {
|
|
|
43
52
|
.then(function (resp) { return resp.json(); })
|
|
44
53
|
.then(function (data) {
|
|
45
54
|
// Using flag spec version 1.2 or below
|
|
46
|
-
if (data
|
|
47
|
-
return {
|
|
48
|
-
ff: {
|
|
49
|
-
d: data.splits,
|
|
50
|
-
s: data.since,
|
|
51
|
-
t: data.till
|
|
52
|
-
}
|
|
53
|
-
};
|
|
55
|
+
if (isSplitChangesLegacyResponse(data)) {
|
|
56
|
+
return { d: partitionByStatus(data.splits || [], data.till, data.since) };
|
|
54
57
|
}
|
|
55
58
|
// Proxy recovery
|
|
56
59
|
if (lastProxyCheckTimestamp) {
|
|
57
|
-
log.info(constants_2.
|
|
60
|
+
log.info(constants_2.LOG_PREFIX_SYNC + 'Proxy error recovered');
|
|
58
61
|
lastProxyCheckTimestamp = undefined;
|
|
59
62
|
return splitChangesFetcher(-1, undefined, undefined, -1)
|
|
60
63
|
.then(function (splitChangesResponse) {
|
|
@@ -62,8 +65,14 @@ function splitChangesFetcherFactory(fetchSplitChanges, settings, storage) {
|
|
|
62
65
|
.then(function () { return splitChangesResponse; });
|
|
63
66
|
});
|
|
64
67
|
}
|
|
65
|
-
|
|
68
|
+
var ff = data.ff, rbs = data.rbs;
|
|
69
|
+
return {
|
|
70
|
+
d: (ff === null || ff === void 0 ? void 0 : ff.d) ? partitionByStatus(ff.d, ff.t, ff.s) : undefined,
|
|
71
|
+
rbs: (rbs === null || rbs === void 0 ? void 0 : rbs.d) ? partitionByStatus(rbs.d, rbs.t, rbs.s) : undefined,
|
|
72
|
+
};
|
|
66
73
|
});
|
|
67
|
-
}
|
|
74
|
+
}
|
|
75
|
+
splitChangesFetcher.type = 'feature flags';
|
|
76
|
+
return splitChangesFetcher;
|
|
68
77
|
}
|
|
69
78
|
exports.splitChangesFetcherFactory = splitChangesFetcherFactory;
|