@splitsoftware/splitio-commons 1.6.2-rc.3 → 1.6.2-rc.6
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/index.js +10 -11
- package/cjs/integrations/ga/GaToSplit.js +8 -5
- package/cjs/sdkFactory/index.js +2 -3
- package/cjs/sdkManager/index.js +3 -11
- package/cjs/services/splitApi.js +0 -1
- package/cjs/storages/AbstractSplitsCacheAsync.js +7 -9
- package/cjs/storages/AbstractSplitsCacheSync.js +7 -9
- package/cjs/storages/dataLoader.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +5 -6
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +7 -10
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +15 -9
- package/cjs/storages/pluggable/SplitsCachePluggable.js +14 -9
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +2 -3
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +1 -1
- package/cjs/trackers/telemetryTracker.js +6 -0
- package/cjs/types.js +2 -0
- package/cjs/utils/key/index.js +1 -1
- package/cjs/utils/settingsValidation/index.js +0 -1
- package/esm/evaluator/index.js +10 -11
- package/esm/integrations/ga/GaToSplit.js +8 -5
- package/esm/sdkFactory/index.js +2 -3
- package/esm/sdkManager/index.js +3 -11
- package/esm/services/splitApi.js +0 -1
- package/esm/storages/AbstractSplitsCacheAsync.js +7 -9
- package/esm/storages/AbstractSplitsCacheSync.js +7 -9
- package/esm/storages/dataLoader.js +1 -1
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +5 -6
- package/esm/storages/inMemory/SplitsCacheInMemory.js +7 -10
- package/esm/storages/inRedis/SplitsCacheInRedis.js +15 -9
- package/esm/storages/pluggable/SplitsCachePluggable.js +14 -9
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +2 -3
- package/esm/sync/polling/updaters/splitChangesUpdater.js +1 -1
- package/esm/trackers/telemetryTracker.js +6 -0
- package/esm/types.js +1 -0
- package/esm/utils/key/index.js +1 -1
- package/esm/utils/settingsValidation/index.js +0 -1
- package/package.json +2 -2
- package/src/consent/sdkUserConsent.ts +3 -4
- package/src/dtos/types.ts +8 -0
- package/src/evaluator/Engine.ts +3 -3
- package/src/evaluator/combiners/and.ts +1 -1
- package/src/evaluator/combiners/ifelseif.ts +3 -3
- package/src/evaluator/condition/engineUtils.ts +1 -1
- package/src/evaluator/condition/index.ts +6 -6
- package/src/evaluator/index.ts +18 -19
- package/src/evaluator/matchers/all.ts +1 -1
- package/src/evaluator/matchers/between.ts +1 -1
- package/src/evaluator/matchers/boolean.ts +1 -1
- package/src/evaluator/matchers/cont_all.ts +1 -1
- package/src/evaluator/matchers/cont_any.ts +1 -1
- package/src/evaluator/matchers/cont_str.ts +1 -1
- package/src/evaluator/matchers/dependency.ts +1 -1
- package/src/evaluator/matchers/eq.ts +1 -1
- package/src/evaluator/matchers/eq_set.ts +1 -1
- package/src/evaluator/matchers/ew.ts +1 -1
- package/src/evaluator/matchers/gte.ts +1 -1
- package/src/evaluator/matchers/index.ts +1 -1
- package/src/evaluator/matchers/lte.ts +1 -1
- package/src/evaluator/matchers/part_of.ts +1 -1
- package/src/evaluator/matchers/segment.ts +1 -1
- package/src/evaluator/matchers/string.ts +1 -1
- package/src/evaluator/matchers/sw.ts +1 -1
- package/src/evaluator/matchers/whitelist.ts +1 -1
- package/src/evaluator/parser/index.ts +3 -3
- package/src/evaluator/types.ts +6 -6
- package/src/evaluator/value/index.ts +4 -4
- package/src/evaluator/value/sanitize.ts +4 -4
- package/src/integrations/ga/GaToSplit.ts +15 -11
- package/src/integrations/ga/SplitToGa.ts +10 -10
- package/src/integrations/ga/types.ts +4 -4
- package/src/integrations/pluggable.ts +3 -3
- package/src/integrations/types.ts +4 -3
- package/src/logger/index.ts +3 -3
- package/src/logger/sdkLogger.ts +2 -1
- package/src/logger/types.ts +16 -0
- package/src/readiness/sdkReadinessManager.ts +1 -1
- package/src/readiness/types.ts +9 -2
- package/src/sdkClient/client.ts +13 -13
- package/src/sdkClient/clientAttributesDecoration.ts +9 -9
- package/src/sdkClient/clientCS.ts +4 -3
- package/src/sdkClient/clientInputValidation.ts +15 -15
- package/src/sdkClient/sdkClient.ts +2 -2
- package/src/sdkClient/sdkClientMethod.ts +2 -2
- package/src/sdkClient/sdkClientMethodCS.ts +9 -9
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +9 -9
- package/src/sdkFactory/index.ts +4 -5
- package/src/sdkFactory/types.ts +4 -4
- package/src/sdkManager/index.ts +7 -16
- package/src/services/splitApi.ts +0 -1
- package/src/storages/AbstractSplitsCacheAsync.ts +13 -14
- package/src/storages/AbstractSplitsCacheSync.ts +14 -16
- package/src/storages/dataLoader.ts +3 -3
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +1 -1
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +10 -12
- package/src/storages/inLocalStorage/index.ts +2 -3
- package/src/storages/inMemory/EventsCacheInMemory.ts +4 -4
- package/src/storages/inMemory/SplitsCacheInMemory.ts +10 -14
- package/src/storages/inRedis/EventsCacheInRedis.ts +4 -4
- package/src/storages/inRedis/ImpressionsCacheInRedis.ts +1 -1
- package/src/storages/inRedis/RedisAdapter.ts +1 -1
- package/src/storages/inRedis/SegmentsCacheInRedis.ts +1 -1
- package/src/storages/inRedis/SplitsCacheInRedis.ts +22 -18
- package/src/storages/inRedis/TelemetryCacheInRedis.ts +1 -1
- package/src/storages/inRedis/index.ts +2 -3
- package/src/storages/pluggable/EventsCachePluggable.ts +4 -4
- package/src/storages/pluggable/ImpressionsCachePluggable.ts +1 -1
- package/src/storages/pluggable/SegmentsCachePluggable.ts +1 -1
- package/src/storages/pluggable/SplitsCachePluggable.ts +21 -18
- package/src/storages/pluggable/TelemetryCachePluggable.ts +1 -1
- package/src/storages/pluggable/index.ts +3 -3
- package/src/storages/pluggable/wrapperAdapter.ts +1 -1
- package/src/storages/types.ts +30 -54
- package/src/sync/offline/LocalhostFromObject.ts +4 -4
- package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +8 -8
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +5 -6
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +1 -1
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
- package/src/sync/polling/updaters/splitChangesUpdater.ts +3 -3
- package/src/sync/streaming/SSEHandler/index.ts +1 -1
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +1 -1
- package/src/sync/submitters/submitter.ts +1 -1
- package/src/sync/submitters/types.ts +2 -2
- package/src/sync/syncTask.ts +1 -1
- package/src/trackers/eventTracker.ts +3 -3
- package/src/trackers/impressionsTracker.ts +3 -3
- package/src/trackers/telemetryTracker.ts +7 -2
- package/src/trackers/types.ts +8 -4
- package/src/types.ts +1263 -0
- package/src/utils/constants/index.ts +1 -1
- package/src/utils/inputValidation/apiKey.ts +1 -1
- package/src/utils/inputValidation/attribute.ts +1 -1
- package/src/utils/inputValidation/attributes.ts +3 -3
- package/src/utils/inputValidation/event.ts +1 -1
- package/src/utils/inputValidation/eventProperties.ts +3 -3
- package/src/utils/inputValidation/eventValue.ts +1 -1
- package/src/utils/inputValidation/isOperational.ts +1 -1
- package/src/utils/inputValidation/key.ts +3 -3
- package/src/utils/inputValidation/preloadedData.ts +3 -3
- package/src/utils/inputValidation/split.ts +1 -1
- package/src/utils/inputValidation/splitExistance.ts +1 -1
- package/src/utils/inputValidation/splits.ts +1 -1
- package/src/utils/inputValidation/trafficType.ts +1 -1
- package/src/utils/inputValidation/trafficTypeExistance.ts +1 -1
- package/src/utils/key/index.ts +9 -9
- package/src/utils/settingsValidation/consent.ts +2 -1
- package/src/utils/settingsValidation/impressionsMode.ts +3 -3
- package/src/utils/settingsValidation/index.ts +0 -1
- package/src/utils/settingsValidation/integrations/common.ts +1 -1
- package/src/utils/settingsValidation/integrations/configurable.ts +1 -1
- package/src/utils/settingsValidation/integrations/pluggable.ts +2 -1
- package/src/utils/settingsValidation/localhost/builtin.ts +2 -1
- package/src/utils/settingsValidation/localhost/pluggable.ts +2 -1
- package/src/utils/settingsValidation/logger/builtinLogger.ts +2 -1
- package/src/utils/settingsValidation/logger/pluggableLogger.ts +2 -1
- package/src/utils/settingsValidation/splitFilters.ts +9 -7
- package/src/utils/settingsValidation/storage/storageCS.ts +2 -1
- package/types/consent/sdkUserConsent.d.ts +9 -2
- package/types/dtos/types.d.ts +6 -0
- package/types/evaluator/Engine.d.ts +3 -3
- package/types/evaluator/combiners/and.d.ts +1 -1
- package/types/evaluator/combiners/ifelseif.d.ts +1 -1
- package/types/evaluator/condition/engineUtils.d.ts +1 -1
- package/types/evaluator/condition/index.d.ts +1 -1
- package/types/evaluator/index.d.ts +4 -4
- package/types/evaluator/matchers/all.d.ts +1 -1
- package/types/evaluator/matchers/between.d.ts +1 -1
- package/types/evaluator/matchers/boolean.d.ts +1 -1
- package/types/evaluator/matchers/cont_all.d.ts +1 -1
- package/types/evaluator/matchers/cont_any.d.ts +1 -1
- package/types/evaluator/matchers/cont_str.d.ts +1 -1
- package/types/evaluator/matchers/dependency.d.ts +1 -1
- package/types/evaluator/matchers/eq.d.ts +1 -1
- package/types/evaluator/matchers/eq_set.d.ts +1 -1
- package/types/evaluator/matchers/ew.d.ts +1 -1
- package/types/evaluator/matchers/gte.d.ts +1 -1
- package/types/evaluator/matchers/index.d.ts +1 -1
- package/types/evaluator/matchers/lte.d.ts +1 -1
- package/types/evaluator/matchers/part_of.d.ts +1 -1
- package/types/evaluator/matchers/segment.d.ts +1 -1
- package/types/evaluator/matchers/string.d.ts +1 -1
- package/types/evaluator/matchers/sw.d.ts +1 -1
- package/types/evaluator/matchers/whitelist.d.ts +1 -1
- package/types/evaluator/parser/index.d.ts +1 -1
- package/types/evaluator/types.d.ts +6 -6
- package/types/evaluator/value/index.d.ts +3 -3
- package/types/evaluator/value/sanitize.d.ts +3 -3
- package/types/integrations/ga/GaToSplit.d.ts +4 -4
- package/types/integrations/ga/SplitToGa.d.ts +4 -4
- package/types/integrations/ga/types.d.ts +4 -4
- package/types/integrations/types.d.ts +4 -3
- package/types/logger/index.d.ts +5 -3
- package/types/logger/sdkLogger.d.ts +2 -1
- package/types/logger/types.d.ts +11 -0
- package/types/readiness/sdkReadinessManager.d.ts +1 -1
- package/types/readiness/types.d.ts +8 -2
- package/types/sdkClient/client.d.ts +2 -2
- package/types/sdkClient/clientAttributesDecoration.d.ts +8 -8
- package/types/sdkClient/clientCS.d.ts +3 -2
- package/types/sdkClient/clientInputValidation.d.ts +2 -2
- package/types/sdkClient/sdkClient.d.ts +2 -2
- package/types/sdkClient/sdkClientMethod.d.ts +2 -2
- package/types/sdkClient/sdkClientMethodCS.d.ts +2 -2
- package/types/sdkClient/sdkClientMethodCSWithTT.d.ts +2 -2
- package/types/sdkFactory/index.d.ts +2 -2
- package/types/sdkFactory/types.d.ts +6 -6
- package/types/sdkManager/index.d.ts +3 -3
- package/types/storages/AbstractSplitsCacheAsync.d.ts +6 -5
- package/types/storages/AbstractSplitsCacheSync.d.ts +5 -5
- package/types/storages/dataLoader.d.ts +2 -2
- package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +1 -1
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +4 -3
- package/types/storages/inLocalStorage/index.d.ts +2 -2
- package/types/storages/inMemory/EventsCacheInMemory.d.ts +3 -3
- package/types/storages/inMemory/InMemoryStorage.d.ts +1 -1
- package/types/storages/inMemory/InMemoryStorageCS.d.ts +1 -1
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +3 -2
- package/types/storages/inRedis/EventsCacheInRedis.d.ts +3 -3
- package/types/storages/inRedis/ImpressionsCacheInRedis.d.ts +1 -1
- package/types/storages/inRedis/RedisAdapter.d.ts +1 -1
- package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +1 -1
- package/types/storages/inRedis/SplitsCacheInRedis.d.ts +7 -6
- package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +1 -1
- package/types/storages/inRedis/index.d.ts +2 -2
- package/types/storages/pluggable/EventsCachePluggable.d.ts +3 -3
- package/types/storages/pluggable/ImpressionsCachePluggable.d.ts +1 -1
- package/types/storages/pluggable/SegmentsCachePluggable.d.ts +1 -1
- package/types/storages/pluggable/SplitsCachePluggable.d.ts +7 -6
- package/types/storages/pluggable/TelemetryCachePluggable.d.ts +1 -1
- package/types/storages/pluggable/index.d.ts +2 -3
- package/types/storages/pluggable/wrapperAdapter.d.ts +1 -1
- package/types/storages/types.d.ts +28 -54
- package/types/sync/offline/LocalhostFromObject.d.ts +2 -2
- package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +1 -1
- package/types/sync/polling/updaters/segmentChangesUpdater.d.ts +1 -1
- package/types/sync/polling/updaters/splitChangesUpdater.d.ts +2 -2
- package/types/sync/streaming/SSEHandler/index.d.ts +1 -1
- package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +1 -1
- package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +1 -1
- package/types/sync/submitters/submitter.d.ts +1 -1
- package/types/sync/submitters/types.d.ts +2 -2
- package/types/sync/syncTask.d.ts +1 -1
- package/types/trackers/types.d.ts +8 -4
- package/types/types.d.ts +1261 -0
- package/types/utils/constants/index.d.ts +1 -1
- package/types/utils/inputValidation/apiKey.d.ts +1 -1
- package/types/utils/inputValidation/attribute.d.ts +1 -1
- package/types/utils/inputValidation/attributes.d.ts +3 -3
- package/types/utils/inputValidation/event.d.ts +1 -1
- package/types/utils/inputValidation/eventProperties.d.ts +3 -3
- package/types/utils/inputValidation/eventValue.d.ts +1 -1
- package/types/utils/inputValidation/isOperational.d.ts +1 -1
- package/types/utils/inputValidation/key.d.ts +3 -3
- package/types/utils/inputValidation/preloadedData.d.ts +3 -3
- package/types/utils/inputValidation/split.d.ts +1 -1
- package/types/utils/inputValidation/splitExistance.d.ts +1 -1
- package/types/utils/inputValidation/splits.d.ts +1 -1
- package/types/utils/inputValidation/trafficType.d.ts +1 -1
- package/types/utils/inputValidation/trafficTypeExistance.d.ts +1 -1
- package/types/utils/key/index.d.ts +4 -4
- package/types/utils/settingsValidation/consent.d.ts +2 -1
- package/types/utils/settingsValidation/impressionsMode.d.ts +3 -3
- package/types/utils/settingsValidation/integrations/common.d.ts +1 -1
- package/types/utils/settingsValidation/integrations/configurable.d.ts +1 -1
- package/types/utils/settingsValidation/integrations/pluggable.d.ts +2 -1
- package/types/utils/settingsValidation/localhost/builtin.d.ts +2 -1
- package/types/utils/settingsValidation/localhost/pluggable.d.ts +2 -1
- package/types/utils/settingsValidation/logger/builtinLogger.d.ts +1 -1
- package/types/utils/settingsValidation/logger/pluggableLogger.d.ts +1 -1
- package/types/utils/settingsValidation/splitFilters.d.ts +2 -1
- package/types/utils/settingsValidation/storage/storageCS.d.ts +3 -2
- package/src/types.d.ts +0 -1646
package/esm/sdkFactory/index.js
CHANGED
|
@@ -29,7 +29,6 @@ export function sdkFactory(params) {
|
|
|
29
29
|
optimize: shouldBeOptimized(settings),
|
|
30
30
|
// ATM, only used by InLocalStorage
|
|
31
31
|
matchingKey: getMatching(settings.core.key),
|
|
32
|
-
// @ts-ignore
|
|
33
32
|
splitFiltersValidation: settings.sync.__splitFiltersValidation,
|
|
34
33
|
// ATM, only used by PluggableStorage
|
|
35
34
|
mode: settings.mode,
|
|
@@ -46,12 +45,12 @@ export function sdkFactory(params) {
|
|
|
46
45
|
};
|
|
47
46
|
var storage = storageFactory(storageFactoryParams);
|
|
48
47
|
// @TODO add support for dataloader: `if (params.dataLoader) params.dataLoader(storage);`
|
|
49
|
-
var
|
|
48
|
+
var telemetryTracker = telemetryTrackerFactory(storage.telemetry, platform.now);
|
|
49
|
+
var integrationsManager = integrationsManagerFactory && integrationsManagerFactory({ settings: settings, storage: storage, telemetryTracker: telemetryTracker });
|
|
50
50
|
// trackers
|
|
51
51
|
var observer = impressionsObserverFactory && impressionsObserverFactory();
|
|
52
52
|
var impressionsTracker = impressionsTrackerFactory(settings, storage.impressions, integrationsManager, observer, storage.impressionCounts, storage.telemetry);
|
|
53
53
|
var eventTracker = eventTrackerFactory(settings, storage.events, integrationsManager, storage.telemetry);
|
|
54
|
-
var telemetryTracker = telemetryTrackerFactory(storage.telemetry, platform.now);
|
|
55
54
|
// splitApi is used by SyncManager and Browser signal listener
|
|
56
55
|
var splitApi = splitApiFactory && splitApiFactory(settings, platform, telemetryTracker);
|
|
57
56
|
var ctx = { splitApi: splitApi, eventTracker: eventTracker, impressionsTracker: impressionsTracker, telemetryTracker: telemetryTracker, sdkReadinessManager: sdkReadinessManager, readiness: readiness, settings: settings, storage: storage, platform: platform };
|
package/esm/sdkManager/index.js
CHANGED
|
@@ -12,15 +12,7 @@ function collectTreatments(splitObject) {
|
|
|
12
12
|
// Then extract the treatments from the partitions
|
|
13
13
|
return allTreatmentsCondition ? allTreatmentsCondition.partitions.map(function (v) { return v.treatment; }) : [];
|
|
14
14
|
}
|
|
15
|
-
function objectToView(
|
|
16
|
-
var splitObject;
|
|
17
|
-
try {
|
|
18
|
-
// @ts-expect-error
|
|
19
|
-
splitObject = JSON.parse(json);
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
15
|
+
function objectToView(splitObject) {
|
|
24
16
|
if (!splitObject)
|
|
25
17
|
return null;
|
|
26
18
|
return {
|
|
@@ -32,9 +24,9 @@ function objectToView(json) {
|
|
|
32
24
|
configs: splitObject.configurations || {}
|
|
33
25
|
};
|
|
34
26
|
}
|
|
35
|
-
function objectsToViews(
|
|
27
|
+
function objectsToViews(splitObjects) {
|
|
36
28
|
var views = [];
|
|
37
|
-
|
|
29
|
+
splitObjects.forEach(function (split) {
|
|
38
30
|
var view = objectToView(split);
|
|
39
31
|
if (view)
|
|
40
32
|
views.push(view);
|
package/esm/services/splitApi.js
CHANGED
|
@@ -13,7 +13,6 @@ function userKeyToQueryParam(userKey) {
|
|
|
13
13
|
*/
|
|
14
14
|
export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
15
15
|
var urls = settings.urls;
|
|
16
|
-
// @ts-ignore
|
|
17
16
|
var filterQueryString = settings.sync.__splitFiltersValidation && settings.sync.__splitFiltersValidation.queryString;
|
|
18
17
|
var SplitSDKImpressionsMode = settings.sync.impressionsMode;
|
|
19
18
|
var splitHttpClient = splitHttpClientFactory(settings, platform.getFetch, platform.getOptions);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
1
2
|
/**
|
|
2
3
|
* This class provides a skeletal implementation of the ISplitsCacheAsync interface
|
|
3
4
|
* to minimize the effort required to implement this interface.
|
|
@@ -31,15 +32,12 @@ var AbstractSplitsCacheAsync = /** @class */ (function () {
|
|
|
31
32
|
AbstractSplitsCacheAsync.prototype.killLocally = function (name, defaultTreatment, changeNumber) {
|
|
32
33
|
var _this = this;
|
|
33
34
|
return this.getSplit(name).then(function (split) {
|
|
34
|
-
if (split) {
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var newSplit = JSON.stringify(parsedSplit);
|
|
41
|
-
return _this.addSplit(name, newSplit);
|
|
42
|
-
}
|
|
35
|
+
if (split && (!split.changeNumber || split.changeNumber < changeNumber)) {
|
|
36
|
+
var newSplit = objectAssign({}, split);
|
|
37
|
+
newSplit.killed = true;
|
|
38
|
+
newSplit.defaultTreatment = defaultTreatment;
|
|
39
|
+
newSplit.changeNumber = changeNumber;
|
|
40
|
+
return _this.addSplit(name, newSplit);
|
|
43
41
|
}
|
|
44
42
|
return false;
|
|
45
43
|
}).catch(function () { return false; });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
1
2
|
/**
|
|
2
3
|
* This class provides a skeletal implementation of the ISplitsCacheSync interface
|
|
3
4
|
* to minimize the effort required to implement this interface.
|
|
@@ -44,15 +45,12 @@ var AbstractSplitsCacheSync = /** @class */ (function () {
|
|
|
44
45
|
*/
|
|
45
46
|
AbstractSplitsCacheSync.prototype.killLocally = function (name, defaultTreatment, changeNumber) {
|
|
46
47
|
var split = this.getSplit(name);
|
|
47
|
-
if (split) {
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var newSplit = JSON.stringify(parsedSplit);
|
|
54
|
-
return this.addSplit(name, newSplit);
|
|
55
|
-
}
|
|
48
|
+
if (split && (!split.changeNumber || split.changeNumber < changeNumber)) {
|
|
49
|
+
var newSplit = objectAssign({}, split);
|
|
50
|
+
newSplit.killed = true;
|
|
51
|
+
newSplit.defaultTreatment = defaultTreatment;
|
|
52
|
+
newSplit.changeNumber = changeNumber;
|
|
53
|
+
return this.addSplit(name, newSplit);
|
|
56
54
|
}
|
|
57
55
|
return false;
|
|
58
56
|
};
|
|
@@ -32,7 +32,7 @@ export function dataLoaderFactory(preloadedData) {
|
|
|
32
32
|
storage.splits.clear();
|
|
33
33
|
storage.splits.setChangeNumber(since);
|
|
34
34
|
// splitsData in an object where the property is the split name and the pertaining value is a stringified json of its data
|
|
35
|
-
storage.splits.addSplits(Object.keys(splitsData).map(function (splitName) { return
|
|
35
|
+
storage.splits.addSplits(Object.keys(splitsData).map(function (splitName) { return JSON.parse(splitsData[splitName]); }));
|
|
36
36
|
// add mySegments data
|
|
37
37
|
var mySegmentsData = preloadedData.mySegmentsData && preloadedData.mySegmentsData[userId];
|
|
38
38
|
if (!mySegmentsData) {
|
|
@@ -93,9 +93,8 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
93
93
|
var splitFromLocalStorage = localStorage.getItem(splitKey);
|
|
94
94
|
var previousSplit = splitFromLocalStorage ? JSON.parse(splitFromLocalStorage) : null;
|
|
95
95
|
this._decrementCounts(previousSplit);
|
|
96
|
-
localStorage.setItem(splitKey, split);
|
|
97
|
-
|
|
98
|
-
this._incrementCounts(parsedSplit);
|
|
96
|
+
localStorage.setItem(splitKey, JSON.stringify(split));
|
|
97
|
+
this._incrementCounts(split);
|
|
99
98
|
return true;
|
|
100
99
|
}
|
|
101
100
|
catch (e) {
|
|
@@ -107,8 +106,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
107
106
|
try {
|
|
108
107
|
var split = this.getSplit(name);
|
|
109
108
|
localStorage.removeItem(this.keys.buildSplitKey(name));
|
|
110
|
-
|
|
111
|
-
this._decrementCounts(parsedSplit);
|
|
109
|
+
this._decrementCounts(split);
|
|
112
110
|
return true;
|
|
113
111
|
}
|
|
114
112
|
catch (e) {
|
|
@@ -117,7 +115,8 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
117
115
|
}
|
|
118
116
|
};
|
|
119
117
|
SplitsCacheInLocal.prototype.getSplit = function (name) {
|
|
120
|
-
|
|
118
|
+
var item = localStorage.getItem(this.keys.buildSplitKey(name));
|
|
119
|
+
return item && JSON.parse(item);
|
|
121
120
|
};
|
|
122
121
|
SplitsCacheInLocal.prototype.setChangeNumber = function (changeNumber) {
|
|
123
122
|
// when cache is ready but using a new split query, we must clear all split data
|
|
@@ -22,9 +22,8 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
22
22
|
this.splitsWithSegmentsCount = 0;
|
|
23
23
|
};
|
|
24
24
|
SplitsCacheInMemory.prototype.addSplit = function (name, split) {
|
|
25
|
-
var
|
|
26
|
-
if (
|
|
27
|
-
var previousSplit = JSON.parse(splitFromMemory);
|
|
25
|
+
var previousSplit = this.getSplit(name);
|
|
26
|
+
if (previousSplit) { // We had this Split already
|
|
28
27
|
if (previousSplit.trafficTypeName) {
|
|
29
28
|
var previousTtName = previousSplit.trafficTypeName;
|
|
30
29
|
this.ttCache[previousTtName]--;
|
|
@@ -35,19 +34,18 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
35
34
|
this.splitsWithSegmentsCount--;
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
if (parsedSplit) {
|
|
37
|
+
if (split) {
|
|
40
38
|
// Store the Split.
|
|
41
39
|
this.splitsCache[name] = split;
|
|
42
40
|
// Update TT cache
|
|
43
|
-
var ttName =
|
|
41
|
+
var ttName = split.trafficTypeName;
|
|
44
42
|
if (ttName) { // safeguard
|
|
45
43
|
if (!this.ttCache[ttName])
|
|
46
44
|
this.ttCache[ttName] = 0;
|
|
47
45
|
this.ttCache[ttName]++;
|
|
48
46
|
}
|
|
49
47
|
// Add to segments count for the new version of the Split
|
|
50
|
-
if (usesSegments(
|
|
48
|
+
if (usesSegments(split))
|
|
51
49
|
this.splitsWithSegmentsCount++;
|
|
52
50
|
return true;
|
|
53
51
|
}
|
|
@@ -60,15 +58,14 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
60
58
|
if (split) {
|
|
61
59
|
// Delete the Split
|
|
62
60
|
delete this.splitsCache[name];
|
|
63
|
-
var
|
|
64
|
-
var ttName = parsedSplit.trafficTypeName;
|
|
61
|
+
var ttName = split.trafficTypeName;
|
|
65
62
|
if (ttName) { // safeguard
|
|
66
63
|
this.ttCache[ttName]--; // Update tt cache
|
|
67
64
|
if (!this.ttCache[ttName])
|
|
68
65
|
delete this.ttCache[ttName];
|
|
69
66
|
}
|
|
70
67
|
// Update the segments count.
|
|
71
|
-
if (usesSegments(
|
|
68
|
+
if (usesSegments(split))
|
|
72
69
|
this.splitsWithSegmentsCount--;
|
|
73
70
|
return true;
|
|
74
71
|
}
|
|
@@ -59,17 +59,17 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
59
59
|
var splitKey = this.keys.buildSplitKey(name);
|
|
60
60
|
return this.redis.get(splitKey).then(function (splitFromStorage) {
|
|
61
61
|
// handling parsing errors
|
|
62
|
-
var parsedPreviousSplit,
|
|
62
|
+
var parsedPreviousSplit, newStringifiedSplit;
|
|
63
63
|
try {
|
|
64
64
|
parsedPreviousSplit = splitFromStorage ? JSON.parse(splitFromStorage) : undefined;
|
|
65
|
-
|
|
65
|
+
newStringifiedSplit = JSON.stringify(split);
|
|
66
66
|
}
|
|
67
67
|
catch (e) {
|
|
68
68
|
throw new Error('Error parsing split definition: ' + e);
|
|
69
69
|
}
|
|
70
70
|
return Promise.all([
|
|
71
|
-
_this.redis.set(splitKey,
|
|
72
|
-
_this._incrementCounts(
|
|
71
|
+
_this.redis.set(splitKey, newStringifiedSplit),
|
|
72
|
+
_this._incrementCounts(split),
|
|
73
73
|
// If it's an update, we decrement the traffic type of the existing split,
|
|
74
74
|
parsedPreviousSplit && _this._decrementCounts(parsedPreviousSplit)
|
|
75
75
|
]);
|
|
@@ -96,8 +96,7 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
96
96
|
var _this = this;
|
|
97
97
|
return this.getSplit(name).then(function (split) {
|
|
98
98
|
if (split) {
|
|
99
|
-
|
|
100
|
-
_this._decrementCounts(parsedSplit);
|
|
99
|
+
_this._decrementCounts(split);
|
|
101
100
|
}
|
|
102
101
|
return _this.redis.del(_this.keys.buildSplitKey(name));
|
|
103
102
|
});
|
|
@@ -120,7 +119,8 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
120
119
|
this.log.error(LOG_PREFIX + this.redisError);
|
|
121
120
|
return Promise.reject(this.redisError);
|
|
122
121
|
}
|
|
123
|
-
return this.redis.get(this.keys.buildSplitKey(name))
|
|
122
|
+
return this.redis.get(this.keys.buildSplitKey(name))
|
|
123
|
+
.then(function (maybeSplit) { return maybeSplit && JSON.parse(maybeSplit); });
|
|
124
124
|
};
|
|
125
125
|
/**
|
|
126
126
|
* Set till number.
|
|
@@ -155,7 +155,12 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
155
155
|
*/
|
|
156
156
|
SplitsCacheInRedis.prototype.getAll = function () {
|
|
157
157
|
var _this = this;
|
|
158
|
-
return this.redis.keys(this.keys.searchPatternForSplitKeys())
|
|
158
|
+
return this.redis.keys(this.keys.searchPatternForSplitKeys())
|
|
159
|
+
.then(function (listOfKeys) { return _this.redis.pipeline(listOfKeys.map(function (k) { return ['get', k]; })).exec(); })
|
|
160
|
+
.then(processPipelineAnswer)
|
|
161
|
+
.then(function (splitDefinitions) { return splitDefinitions.map(function (splitDefinition) {
|
|
162
|
+
return JSON.parse(splitDefinition);
|
|
163
|
+
}); });
|
|
159
164
|
};
|
|
160
165
|
/**
|
|
161
166
|
* Get list of split names.
|
|
@@ -215,7 +220,8 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
215
220
|
var keys = names.map(function (name) { return _this.keys.buildSplitKey(name); });
|
|
216
221
|
return (_a = this.redis).mget.apply(_a, keys).then(function (splitDefinitions) {
|
|
217
222
|
names.forEach(function (name, idx) {
|
|
218
|
-
|
|
223
|
+
var split = splitDefinitions[idx];
|
|
224
|
+
splits[name] = split && JSON.parse(split);
|
|
219
225
|
});
|
|
220
226
|
return Promise.resolve(splits);
|
|
221
227
|
})
|
|
@@ -46,17 +46,17 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
46
46
|
var splitKey = this.keys.buildSplitKey(name);
|
|
47
47
|
return this.wrapper.get(splitKey).then(function (splitFromStorage) {
|
|
48
48
|
// handling parsing error
|
|
49
|
-
var parsedPreviousSplit,
|
|
49
|
+
var parsedPreviousSplit, stringifiedNewSplit;
|
|
50
50
|
try {
|
|
51
51
|
parsedPreviousSplit = splitFromStorage ? JSON.parse(splitFromStorage) : undefined;
|
|
52
|
-
|
|
52
|
+
stringifiedNewSplit = JSON.stringify(split);
|
|
53
53
|
}
|
|
54
54
|
catch (e) {
|
|
55
55
|
throw new Error('Error parsing split definition: ' + e);
|
|
56
56
|
}
|
|
57
57
|
return Promise.all([
|
|
58
|
-
_this.wrapper.set(splitKey,
|
|
59
|
-
_this._incrementCounts(
|
|
58
|
+
_this.wrapper.set(splitKey, stringifiedNewSplit),
|
|
59
|
+
_this._incrementCounts(split),
|
|
60
60
|
// If it's an update, we decrement the traffic type and segment count of the existing split,
|
|
61
61
|
parsedPreviousSplit && _this._decrementCounts(parsedPreviousSplit)
|
|
62
62
|
]);
|
|
@@ -80,8 +80,7 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
80
80
|
var _this = this;
|
|
81
81
|
return this.getSplit(name).then(function (split) {
|
|
82
82
|
if (split) {
|
|
83
|
-
|
|
84
|
-
_this._decrementCounts(parsedSplit);
|
|
83
|
+
_this._decrementCounts(split);
|
|
85
84
|
}
|
|
86
85
|
return _this.wrapper.del(_this.keys.buildSplitKey(name));
|
|
87
86
|
});
|
|
@@ -101,7 +100,8 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
101
100
|
* or rejected if wrapper operation fails.
|
|
102
101
|
*/
|
|
103
102
|
SplitsCachePluggable.prototype.getSplit = function (name) {
|
|
104
|
-
return this.wrapper.get(this.keys.buildSplitKey(name))
|
|
103
|
+
return this.wrapper.get(this.keys.buildSplitKey(name))
|
|
104
|
+
.then(function (maybeSplit) { return maybeSplit && JSON.parse(maybeSplit); });
|
|
105
105
|
};
|
|
106
106
|
/**
|
|
107
107
|
* Get list of splits.
|
|
@@ -114,7 +114,8 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
114
114
|
return this.wrapper.getMany(keys).then(function (splitDefinitions) {
|
|
115
115
|
var splits = {};
|
|
116
116
|
names.forEach(function (name, idx) {
|
|
117
|
-
|
|
117
|
+
var split = splitDefinitions[idx];
|
|
118
|
+
splits[name] = split && JSON.parse(split);
|
|
118
119
|
});
|
|
119
120
|
return Promise.resolve(splits);
|
|
120
121
|
});
|
|
@@ -126,7 +127,11 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
126
127
|
*/
|
|
127
128
|
SplitsCachePluggable.prototype.getAll = function () {
|
|
128
129
|
var _this = this;
|
|
129
|
-
return this.wrapper.getKeysByPrefix(this.keys.buildSplitKeyPrefix())
|
|
130
|
+
return this.wrapper.getKeysByPrefix(this.keys.buildSplitKeyPrefix())
|
|
131
|
+
.then(function (listOfKeys) { return _this.wrapper.getMany(listOfKeys); })
|
|
132
|
+
.then(function (splitDefinitions) { return splitDefinitions.map(function (splitDefinition) {
|
|
133
|
+
return JSON.parse(splitDefinition);
|
|
134
|
+
}); });
|
|
130
135
|
};
|
|
131
136
|
/**
|
|
132
137
|
* Get list of split names.
|
|
@@ -24,8 +24,7 @@ export function fromObjectUpdaterFactory(splitsParser, storage, readiness, setti
|
|
|
24
24
|
log.debug(SYNC_OFFLINE_DATA, [JSON.stringify(splitsMock)]);
|
|
25
25
|
forOwn(splitsMock, function (val, name) {
|
|
26
26
|
splits.push([
|
|
27
|
-
name,
|
|
28
|
-
JSON.stringify({
|
|
27
|
+
name, {
|
|
29
28
|
name: name,
|
|
30
29
|
status: 'ACTIVE',
|
|
31
30
|
killed: false,
|
|
@@ -34,7 +33,7 @@ export function fromObjectUpdaterFactory(splitsParser, storage, readiness, setti
|
|
|
34
33
|
conditions: val.conditions || [],
|
|
35
34
|
configurations: val.configurations,
|
|
36
35
|
trafficTypeName: val.trafficTypeName
|
|
37
|
-
}
|
|
36
|
+
}
|
|
38
37
|
]);
|
|
39
38
|
});
|
|
40
39
|
return Promise.all([
|
|
@@ -37,7 +37,7 @@ export function computeSplitsMutation(entries) {
|
|
|
37
37
|
var segments = new _Set();
|
|
38
38
|
var computed = entries.reduce(function (accum, split) {
|
|
39
39
|
if (split.status === 'ACTIVE') {
|
|
40
|
-
accum.added.push([split.name,
|
|
40
|
+
accum.added.push([split.name, split]);
|
|
41
41
|
parseSegments(split).forEach(function (segmentName) {
|
|
42
42
|
segments.add(segmentName);
|
|
43
43
|
});
|
|
@@ -46,6 +46,11 @@ export function telemetryTrackerFactory(telemetryCache, now) {
|
|
|
46
46
|
if (e === TOKEN_REFRESH)
|
|
47
47
|
telemetryCache.recordTokenRefreshes();
|
|
48
48
|
}
|
|
49
|
+
},
|
|
50
|
+
addTag: function (tag) {
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
if (telemetryCache.addTag)
|
|
53
|
+
telemetryCache.addTag(tag);
|
|
49
54
|
}
|
|
50
55
|
};
|
|
51
56
|
}
|
|
@@ -56,6 +61,7 @@ export function telemetryTrackerFactory(telemetryCache, now) {
|
|
|
56
61
|
trackHttp: noopTrack,
|
|
57
62
|
sessionLength: function () { },
|
|
58
63
|
streamingEvent: function () { },
|
|
64
|
+
addTag: function () { }
|
|
59
65
|
};
|
|
60
66
|
}
|
|
61
67
|
}
|
package/esm/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/utils/key/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isObject } from '../lang';
|
|
2
|
-
// function isSplitKeyObject(key: any): key is SplitKeyObject {
|
|
2
|
+
// function isSplitKeyObject(key: any): key is SplitIO.SplitKeyObject {
|
|
3
3
|
// return key !== undefined && key !== null && typeof key.matchingKey === 'string';
|
|
4
4
|
// }
|
|
5
5
|
// returns the matchingKey if the Key is defined as an object or the key itself if it is a string
|
|
@@ -172,7 +172,6 @@ export function settingsValidation(config, validationParams) {
|
|
|
172
172
|
// validate the `splitFilters` settings and parse splits query
|
|
173
173
|
var splitFiltersValidation = validateSplitFilters(log, withDefaults.sync.splitFilters, withDefaults.mode);
|
|
174
174
|
withDefaults.sync.splitFilters = splitFiltersValidation.validFilters;
|
|
175
|
-
// @ts-ignore
|
|
176
175
|
withDefaults.sync.__splitFiltersValidation = splitFiltersValidation;
|
|
177
176
|
// ensure a valid user consent value
|
|
178
177
|
// @ts-ignore, modify readonly prop
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splitsoftware/splitio-commons",
|
|
3
|
-
"version": "1.6.2-rc.
|
|
3
|
+
"version": "1.6.2-rc.6",
|
|
4
4
|
"description": "Split Javascript SDK common components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"check:lint": "eslint src --ext .js,.ts",
|
|
21
21
|
"check:types": "tsc --noEmit",
|
|
22
22
|
"build": "npm run build:cjs && npm run build:esm",
|
|
23
|
-
"build:esm": "rimraf esm
|
|
23
|
+
"build:esm": "rimraf esm && tsc -m es2015 --outDir esm -d true --declarationDir types",
|
|
24
24
|
"build:cjs": "rimraf cjs && tsc -m CommonJS --outDir cjs",
|
|
25
25
|
"test": "jest",
|
|
26
26
|
"test:coverage": "jest --coverage",
|
|
@@ -3,10 +3,9 @@ import { isConsentGranted } from './index';
|
|
|
3
3
|
import { CONSENT_GRANTED, CONSENT_DECLINED, CONSENT_UNKNOWN } from '../utils/constants';
|
|
4
4
|
import { isBoolean } from '../utils/lang';
|
|
5
5
|
import { ISdkFactoryContext } from '../sdkFactory/types';
|
|
6
|
-
import { IUserConsentAPI } from '../types';
|
|
7
6
|
|
|
8
7
|
// User consent enum
|
|
9
|
-
const ConsentStatus
|
|
8
|
+
const ConsentStatus = {
|
|
10
9
|
GRANTED: CONSENT_GRANTED,
|
|
11
10
|
DECLINED: CONSENT_DECLINED,
|
|
12
11
|
UNKNOWN: CONSENT_UNKNOWN,
|
|
@@ -15,7 +14,7 @@ const ConsentStatus: IUserConsentAPI['Status'] = {
|
|
|
15
14
|
/**
|
|
16
15
|
* The public user consent API exposed via SplitFactory, used to control if the SDK tracks and sends impressions and events or not.
|
|
17
16
|
*/
|
|
18
|
-
export function createUserConsentAPI(params: ISdkFactoryContext)
|
|
17
|
+
export function createUserConsentAPI(params: ISdkFactoryContext) {
|
|
19
18
|
const { settings, settings: { log }, syncManager, storage: { events, impressions, impressionCounts } } = params;
|
|
20
19
|
|
|
21
20
|
if (!isConsentGranted(settings)) log.info(USER_CONSENT_INITIAL, [settings.userConsent]);
|
|
@@ -52,7 +51,7 @@ export function createUserConsentAPI(params: ISdkFactoryContext): IUserConsentAP
|
|
|
52
51
|
},
|
|
53
52
|
|
|
54
53
|
getStatus() {
|
|
55
|
-
return settings.userConsent
|
|
54
|
+
return settings.userConsent;
|
|
56
55
|
},
|
|
57
56
|
|
|
58
57
|
Status: ConsentStatus
|
package/src/dtos/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SplitIO } from '../types';
|
|
2
|
+
|
|
1
3
|
export type MaybeThenable<T> = T | Promise<T>
|
|
2
4
|
|
|
3
5
|
/** Split Matchers */
|
|
@@ -202,3 +204,9 @@ export interface IMetadata {
|
|
|
202
204
|
/** host name */
|
|
203
205
|
n: string
|
|
204
206
|
}
|
|
207
|
+
|
|
208
|
+
export type ISplitFiltersValidation = {
|
|
209
|
+
queryString: string | null,
|
|
210
|
+
groupedFilters: Record<SplitIO.SplitFilterType, string[]>,
|
|
211
|
+
validFilters: SplitIO.SplitFilter[]
|
|
212
|
+
};
|
package/src/evaluator/Engine.ts
CHANGED
|
@@ -5,10 +5,10 @@ import { thenable } from '../utils/promise/thenable';
|
|
|
5
5
|
import * as LabelsConstants from '../utils/labels';
|
|
6
6
|
import { CONTROL } from '../utils/constants';
|
|
7
7
|
import { ISplit, MaybeThenable } from '../dtos/types';
|
|
8
|
-
import {
|
|
8
|
+
import { SplitIO } from '../types';
|
|
9
9
|
import { IStorageAsync, IStorageSync } from '../storages/types';
|
|
10
10
|
import { IEvaluation, IEvaluationResult, IEvaluator, ISplitEvaluator } from './types';
|
|
11
|
-
import { ILogger } from '../types';
|
|
11
|
+
import { ILogger } from '../logger/types';
|
|
12
12
|
|
|
13
13
|
function evaluationResult(result: IEvaluation | undefined, defaultTreatment: string): IEvaluationResult {
|
|
14
14
|
return {
|
|
@@ -38,7 +38,7 @@ export class Engine {
|
|
|
38
38
|
return this.baseInfo.name;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
getTreatment(key: SplitKey, attributes: Attributes | undefined, splitEvaluator: ISplitEvaluator): MaybeThenable<IEvaluationResult> {
|
|
41
|
+
getTreatment(key: SplitIO.SplitKey, attributes: SplitIO.Attributes | undefined, splitEvaluator: ISplitEvaluator): MaybeThenable<IEvaluationResult> {
|
|
42
42
|
const {
|
|
43
43
|
killed,
|
|
44
44
|
seed,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { findIndex } from '../../utils/lang';
|
|
2
|
-
import { ILogger } from '../../types';
|
|
2
|
+
import { ILogger } from '../../logger/types';
|
|
3
3
|
import { thenable } from '../../utils/promise/thenable';
|
|
4
4
|
import { MaybeThenable } from '../../dtos/types';
|
|
5
5
|
import { IMatcher } from '../types';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { findIndex } from '../../utils/lang';
|
|
2
|
-
import { ILogger } from '../../types';
|
|
2
|
+
import { ILogger } from '../../logger/types';
|
|
3
3
|
import { thenable } from '../../utils/promise/thenable';
|
|
4
4
|
import * as LabelsConstants from '../../utils/labels';
|
|
5
5
|
import { CONTROL } from '../../utils/constants';
|
|
6
|
-
import {
|
|
6
|
+
import { SplitIO } from '../../types';
|
|
7
7
|
import { IEvaluation, IEvaluator, ISplitEvaluator } from '../types';
|
|
8
8
|
import { ENGINE_COMBINER_IFELSEIF, ENGINE_COMBINER_IFELSEIF_NO_TREATMENT, ERROR_ENGINE_COMBINER_IFELSEIF } from '../../logger/constants';
|
|
9
9
|
|
|
@@ -35,7 +35,7 @@ export function ifElseIfCombinerContext(log: ILogger, predicates: IEvaluator[]):
|
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function ifElseIfCombiner(key: SplitKey, seed: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: Attributes, splitEvaluator?: ISplitEvaluator) {
|
|
38
|
+
function ifElseIfCombiner(key: SplitIO.SplitKey, seed: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) {
|
|
39
39
|
// In Async environments we are going to have async predicates. There is none way to know
|
|
40
40
|
// before hand so we need to evaluate all the predicates, verify for thenables, and finally,
|
|
41
41
|
// define how to return the treatment (wrap result into a Promise or not).
|
|
@@ -3,8 +3,8 @@ import { thenable } from '../../utils/promise/thenable';
|
|
|
3
3
|
import * as LabelsConstants from '../../utils/labels';
|
|
4
4
|
import { MaybeThenable } from '../../dtos/types';
|
|
5
5
|
import { IEvaluation, IEvaluator, ISplitEvaluator } from '../types';
|
|
6
|
-
import {
|
|
7
|
-
import { ILogger } from '../../types';
|
|
6
|
+
import { SplitIO } from '../../types';
|
|
7
|
+
import { ILogger } from '../../logger/types';
|
|
8
8
|
|
|
9
9
|
// Build Evaluation object if and only if matchingResult is true
|
|
10
10
|
function match(log: ILogger, matchingResult: boolean, bucketingKey: string | undefined, seed: number, treatments: { getTreatmentFor: (x: number) => string }, label: string): IEvaluation | undefined {
|
|
@@ -24,10 +24,10 @@ function match(log: ILogger, matchingResult: boolean, bucketingKey: string | und
|
|
|
24
24
|
// Condition factory
|
|
25
25
|
export function conditionContext(log: ILogger, matcherEvaluator: (...args: any) => MaybeThenable<boolean>, treatments: { getTreatmentFor: (x: number) => string }, label: string, conditionType: 'ROLLOUT' | 'WHITELIST'): IEvaluator {
|
|
26
26
|
|
|
27
|
-
return function conditionEvaluator(key: SplitKey, seed: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: Attributes, splitEvaluator?: ISplitEvaluator) {
|
|
27
|
+
return function conditionEvaluator(key: SplitIO.SplitKey, seed: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) {
|
|
28
28
|
|
|
29
29
|
// Whitelisting has more priority than traffic allocation, so we don't apply this filtering to those conditions.
|
|
30
|
-
if (conditionType === 'ROLLOUT' && !shouldApplyRollout(trafficAllocation as number, (key as SplitKeyObject).bucketingKey as string, trafficAllocationSeed as number)) {
|
|
30
|
+
if (conditionType === 'ROLLOUT' && !shouldApplyRollout(trafficAllocation as number, (key as SplitIO.SplitKeyObject).bucketingKey as string, trafficAllocationSeed as number)) {
|
|
31
31
|
return {
|
|
32
32
|
treatment: undefined, // treatment value is assigned later
|
|
33
33
|
label: LabelsConstants.NOT_IN_SPLIT
|
|
@@ -41,10 +41,10 @@ export function conditionContext(log: ILogger, matcherEvaluator: (...args: any)
|
|
|
41
41
|
const matches = matcherEvaluator(key, attributes, splitEvaluator);
|
|
42
42
|
|
|
43
43
|
if (thenable(matches)) {
|
|
44
|
-
return matches.then(result => match(log, result, (key as SplitKeyObject).bucketingKey, seed, treatments, label));
|
|
44
|
+
return matches.then(result => match(log, result, (key as SplitIO.SplitKeyObject).bucketingKey, seed, treatments, label));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
return match(log, matches, (key as SplitKeyObject).bucketingKey, seed, treatments, label);
|
|
47
|
+
return match(log, matches, (key as SplitIO.SplitKeyObject).bucketingKey, seed, treatments, label);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
}
|