@splitsoftware/splitio-commons 1.17.1-rc.2 → 2.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 +7 -3
- package/cjs/evaluator/index.js +2 -2
- package/cjs/evaluator/matchers/semver_inlist.js +1 -2
- package/cjs/evaluator/matchers/whitelist.js +1 -2
- package/cjs/listeners/browser.js +1 -2
- package/cjs/logger/browser/DebugLogger.js +1 -2
- package/cjs/logger/browser/ErrorLogger.js +1 -2
- package/cjs/logger/browser/InfoLogger.js +1 -2
- package/cjs/logger/browser/WarnLogger.js +1 -2
- package/cjs/logger/index.js +1 -2
- package/cjs/sdkClient/clientCS.js +5 -8
- package/cjs/sdkClient/sdkClientMethodCS.js +1 -1
- package/cjs/sdkFactory/index.js +1 -3
- package/cjs/services/decorateHeaders.js +1 -2
- package/cjs/storages/AbstractSplitsCacheAsync.js +7 -0
- package/cjs/storages/AbstractSplitsCacheSync.js +7 -0
- package/cjs/storages/KeyBuilderCS.js +0 -9
- package/cjs/storages/dataLoader.js +32 -65
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +14 -7
- package/cjs/storages/inLocalStorage/index.js +1 -4
- package/cjs/storages/inMemory/InMemoryStorageCS.js +4 -16
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +3 -4
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +2 -3
- package/cjs/storages/inMemory/UniqueKeysCacheInMemory.js +2 -3
- package/cjs/storages/inMemory/UniqueKeysCacheInMemoryCS.js +2 -3
- package/cjs/storages/inRedis/RedisAdapter.js +2 -3
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +3 -4
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +1 -2
- package/cjs/storages/pluggable/SplitsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +6 -7
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +1 -2
- package/cjs/storages/pluggable/inMemoryWrapper.js +7 -8
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +7 -2
- package/cjs/sync/polling/pollingManagerSS.js +3 -3
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +13 -5
- package/cjs/sync/streaming/parseUtils.js +0 -1
- package/cjs/sync/streaming/pushManager.js +2 -3
- package/cjs/utils/LRUCache/index.js +1 -2
- package/cjs/utils/constants/browser.js +1 -4
- package/cjs/utils/lang/index.js +6 -9
- package/cjs/utils/lang/objectAssign.js +12 -77
- package/cjs/utils/lang/sets.js +3 -110
- package/cjs/utils/settingsValidation/index.js +0 -9
- package/cjs/utils/settingsValidation/logger/builtinLogger.js +1 -2
- package/cjs/utils/settingsValidation/storage/storageCS.js +12 -1
- package/esm/evaluator/index.js +3 -3
- package/esm/evaluator/matchers/semver_inlist.js +1 -2
- package/esm/evaluator/matchers/whitelist.js +1 -2
- package/esm/listeners/browser.js +1 -2
- package/esm/logger/browser/DebugLogger.js +1 -2
- package/esm/logger/browser/ErrorLogger.js +1 -2
- package/esm/logger/browser/InfoLogger.js +1 -2
- package/esm/logger/browser/WarnLogger.js +1 -2
- package/esm/logger/index.js +1 -2
- package/esm/sdkClient/clientCS.js +5 -8
- package/esm/sdkClient/sdkClientMethodCS.js +1 -1
- package/esm/sdkFactory/index.js +2 -4
- package/esm/services/decorateHeaders.js +1 -2
- package/esm/storages/AbstractSplitsCacheAsync.js +7 -0
- package/esm/storages/AbstractSplitsCacheSync.js +7 -0
- package/esm/storages/KeyBuilderCS.js +0 -9
- package/esm/storages/dataLoader.js +30 -62
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +14 -7
- package/esm/storages/inLocalStorage/index.js +2 -5
- package/esm/storages/inMemory/InMemoryStorageCS.js +4 -16
- package/esm/storages/inMemory/SegmentsCacheInMemory.js +3 -4
- package/esm/storages/inMemory/SplitsCacheInMemory.js +2 -3
- package/esm/storages/inMemory/UniqueKeysCacheInMemory.js +2 -3
- package/esm/storages/inMemory/UniqueKeysCacheInMemoryCS.js +2 -3
- package/esm/storages/inRedis/RedisAdapter.js +2 -3
- package/esm/storages/inRedis/SplitsCacheInRedis.js +2 -2
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +3 -4
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -2
- package/esm/storages/pluggable/SplitsCachePluggable.js +2 -2
- package/esm/storages/pluggable/TelemetryCachePluggable.js +6 -7
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -2
- package/esm/storages/pluggable/inMemoryWrapper.js +7 -8
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +8 -3
- package/esm/sync/polling/pollingManagerSS.js +3 -3
- package/esm/sync/polling/updaters/splitChangesUpdater.js +14 -6
- package/esm/sync/streaming/parseUtils.js +0 -1
- package/esm/sync/streaming/pushManager.js +2 -3
- package/esm/utils/LRUCache/index.js +1 -2
- package/esm/utils/constants/browser.js +0 -3
- package/esm/utils/lang/index.js +6 -9
- package/esm/utils/lang/objectAssign.js +12 -77
- package/esm/utils/lang/sets.js +2 -107
- package/esm/utils/settingsValidation/index.js +0 -9
- package/esm/utils/settingsValidation/logger/builtinLogger.js +1 -2
- package/esm/utils/settingsValidation/storage/storageCS.js +10 -0
- package/package.json +2 -2
- package/src/evaluator/index.ts +5 -5
- package/src/evaluator/matchers/semver_inlist.ts +1 -2
- package/src/evaluator/matchers/whitelist.ts +1 -3
- package/src/listeners/browser.ts +1 -2
- package/src/logger/browser/DebugLogger.ts +1 -2
- package/src/logger/browser/ErrorLogger.ts +1 -2
- package/src/logger/browser/InfoLogger.ts +1 -2
- package/src/logger/browser/WarnLogger.ts +1 -2
- package/src/logger/index.ts +3 -4
- package/src/sdkClient/clientCS.ts +5 -8
- package/src/sdkClient/sdkClientMethodCS.ts +1 -1
- package/src/sdkFactory/index.ts +2 -5
- package/src/sdkFactory/types.ts +1 -1
- package/src/services/decorateHeaders.ts +1 -2
- package/src/storages/AbstractSplitsCacheAsync.ts +9 -2
- package/src/storages/AbstractSplitsCacheSync.ts +9 -2
- package/src/storages/KeyBuilderCS.ts +0 -13
- package/src/storages/dataLoader.ts +32 -63
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +1 -21
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +16 -8
- package/src/storages/inLocalStorage/index.ts +2 -6
- package/src/storages/inMemory/InMemoryStorageCS.ts +4 -19
- package/src/storages/inMemory/SegmentsCacheInMemory.ts +4 -5
- package/src/storages/inMemory/SplitsCacheInMemory.ts +4 -5
- package/src/storages/inMemory/UniqueKeysCacheInMemory.ts +4 -5
- package/src/storages/inMemory/UniqueKeysCacheInMemoryCS.ts +4 -5
- package/src/storages/inRedis/RedisAdapter.ts +3 -4
- package/src/storages/inRedis/SplitsCacheInRedis.ts +3 -3
- package/src/storages/inRedis/TelemetryCacheInRedis.ts +3 -4
- package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +1 -2
- package/src/storages/pluggable/SegmentsCachePluggable.ts +0 -1
- package/src/storages/pluggable/SplitsCachePluggable.ts +3 -3
- package/src/storages/pluggable/TelemetryCachePluggable.ts +6 -7
- package/src/storages/pluggable/UniqueKeysCachePluggable.ts +1 -2
- package/src/storages/pluggable/inMemoryWrapper.ts +8 -9
- package/src/storages/types.ts +9 -5
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +7 -3
- package/src/sync/polling/pollingManagerSS.ts +2 -3
- package/src/sync/polling/updaters/splitChangesUpdater.ts +15 -8
- package/src/sync/streaming/parseUtils.ts +0 -1
- package/src/sync/streaming/pushManager.ts +3 -4
- package/src/sync/submitters/types.ts +3 -4
- package/src/types.ts +9 -18
- package/src/utils/LRUCache/index.ts +2 -3
- package/src/utils/constants/browser.ts +0 -4
- package/src/utils/lang/index.ts +6 -7
- package/src/utils/lang/objectAssign.ts +13 -92
- package/src/utils/lang/sets.ts +3 -125
- package/src/utils/settingsValidation/index.ts +0 -10
- package/src/utils/settingsValidation/logger/builtinLogger.ts +1 -2
- package/src/utils/settingsValidation/storage/storageCS.ts +13 -0
- package/src/utils/settingsValidation/types.ts +0 -2
- package/types/logger/index.d.ts +1 -2
- package/types/sdkClient/clientCS.d.ts +2 -3
- package/types/sdkFactory/types.d.ts +1 -1
- package/types/storages/AbstractSplitsCacheAsync.d.ts +6 -2
- package/types/storages/AbstractSplitsCacheSync.d.ts +6 -2
- package/types/storages/KeyBuilderCS.d.ts +0 -2
- package/types/storages/dataLoader.d.ts +6 -17
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +7 -2
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +1 -2
- package/types/storages/inMemory/UniqueKeysCacheInMemory.d.ts +2 -3
- package/types/storages/inRedis/SplitsCacheInRedis.d.ts +1 -2
- package/types/storages/pluggable/SplitsCachePluggable.d.ts +1 -2
- package/types/storages/pluggable/inMemoryWrapper.d.ts +1 -2
- package/types/storages/types.d.ts +7 -5
- package/types/sync/polling/updaters/splitChangesUpdater.d.ts +1 -2
- package/types/sync/submitters/types.d.ts +3 -4
- package/types/types.d.ts +9 -17
- package/types/utils/LRUCache/index.d.ts +1 -2
- package/types/utils/constants/browser.d.ts +0 -2
- package/types/utils/lang/objectAssign.d.ts +3 -0
- package/types/utils/lang/sets.d.ts +1 -61
- package/types/utils/settingsValidation/index.d.ts +0 -1
- package/types/utils/settingsValidation/storage/storageCS.d.ts +5 -0
- package/types/utils/settingsValidation/types.d.ts +0 -2
- package/cjs/integrations/browser.js +0 -31
- package/cjs/integrations/ga/GaToSplit.js +0 -257
- package/cjs/integrations/ga/GoogleAnalyticsToSplit.js +0 -14
- package/cjs/integrations/ga/SplitToGa.js +0 -123
- package/cjs/integrations/ga/SplitToGoogleAnalytics.js +0 -14
- package/cjs/integrations/ga/types.js +0 -2
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +0 -76
- package/cjs/utils/lang/maps.js +0 -96
- package/esm/integrations/browser.js +0 -27
- package/esm/integrations/ga/GaToSplit.js +0 -250
- package/esm/integrations/ga/GoogleAnalyticsToSplit.js +0 -10
- package/esm/integrations/ga/SplitToGa.js +0 -120
- package/esm/integrations/ga/SplitToGoogleAnalytics.js +0 -10
- package/esm/integrations/ga/types.js +0 -1
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +0 -72
- package/esm/utils/lang/maps.js +0 -92
- package/src/integrations/browser.ts +0 -35
- package/src/integrations/ga/GaToSplit.ts +0 -299
- package/src/integrations/ga/GoogleAnalyticsToSplit.ts +0 -14
- package/src/integrations/ga/SplitToGa.ts +0 -135
- package/src/integrations/ga/SplitToGoogleAnalytics.ts +0 -14
- package/src/integrations/ga/autoRequire.js +0 -33
- package/src/integrations/ga/types.ts +0 -153
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +0 -98
- package/src/utils/lang/maps.ts +0 -108
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
// Integration types
|
|
2
|
-
export var GOOGLE_ANALYTICS_TO_SPLIT = 'GOOGLE_ANALYTICS_TO_SPLIT';
|
|
3
|
-
export var SPLIT_TO_GOOGLE_ANALYTICS = 'SPLIT_TO_GOOGLE_ANALYTICS';
|
|
4
1
|
// This value might be eventually set via a config parameter
|
|
5
2
|
export var DEFAULT_CACHE_EXPIRATION_IN_MILLIS = 864000000; // 10 days
|
package/esm/utils/lang/index.js
CHANGED
|
@@ -111,11 +111,9 @@ export function isBoolean(val) {
|
|
|
111
111
|
export function isFiniteNumber(val) {
|
|
112
112
|
if (val instanceof Number)
|
|
113
113
|
val = val.valueOf();
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return Number.isFinite ? Number.isFinite(val) : isFinite(val);
|
|
118
|
-
return false;
|
|
114
|
+
return typeof val === 'number' ?
|
|
115
|
+
Number.isFinite ? Number.isFinite(val) : isFinite(val) :
|
|
116
|
+
false;
|
|
119
117
|
}
|
|
120
118
|
/**
|
|
121
119
|
* Checks if a given value is an integer value of number type or Number object.
|
|
@@ -124,10 +122,9 @@ export function isFiniteNumber(val) {
|
|
|
124
122
|
export function isIntegerNumber(val) {
|
|
125
123
|
if (val instanceof Number)
|
|
126
124
|
val = val.valueOf();
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return false;
|
|
125
|
+
return typeof val === 'number' ?
|
|
126
|
+
Number.isInteger ? Number.isInteger(val) : isFinite(val) && Math.floor(val) === val :
|
|
127
|
+
false;
|
|
131
128
|
}
|
|
132
129
|
/**
|
|
133
130
|
* Checks if a given value is a NaN value of number type or Number object.
|
|
@@ -1,82 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
object-assign
|
|
7
|
-
(c) Sindre Sorhus
|
|
8
|
-
@license MIT
|
|
9
|
-
*/
|
|
10
|
-
/* eslint-disable */
|
|
11
|
-
// @ts-nocheck
|
|
12
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
13
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
14
|
-
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
15
|
-
function toObject(val) {
|
|
16
|
-
if (val === null || val === undefined) {
|
|
1
|
+
/**
|
|
2
|
+
* A tiny polyfill for Object.assign
|
|
3
|
+
*/
|
|
4
|
+
export var objectAssign = Object.assign || function (target) {
|
|
5
|
+
if (target === null || target === undefined)
|
|
17
6
|
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
// Detect buggy property enumeration order in older V8 versions.
|
|
27
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
28
|
-
var test1 = new String('abc');
|
|
29
|
-
test1[5] = 'de';
|
|
30
|
-
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
34
|
-
var test2 = {};
|
|
35
|
-
for (var i = 0; i < 10; i++) {
|
|
36
|
-
test2['_' + String.fromCharCode(i)] = i;
|
|
37
|
-
}
|
|
38
|
-
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
39
|
-
return test2[n];
|
|
40
|
-
});
|
|
41
|
-
if (order2.join('') !== '0123456789') {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
45
|
-
var test3 = {};
|
|
46
|
-
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
47
|
-
test3[letter] = letter;
|
|
48
|
-
});
|
|
49
|
-
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
50
|
-
'abcdefghijklmnopqrst') {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
catch (err) {
|
|
56
|
-
// We don't expect any of the above to throw, but better to be safe.
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
export var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
61
|
-
var from;
|
|
62
|
-
var to = toObject(target);
|
|
63
|
-
var symbols;
|
|
64
|
-
for (var s = 1; s < arguments.length; s++) {
|
|
65
|
-
from = Object(arguments[s]);
|
|
66
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
67
|
-
for (var key in from) {
|
|
68
|
-
if (hasOwnProperty.call(from, key)) {
|
|
69
|
-
to[key] = from[key];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (getOwnPropertySymbols) {
|
|
73
|
-
symbols = getOwnPropertySymbols(from);
|
|
74
|
-
for (var i = 0; i < symbols.length; i++) {
|
|
75
|
-
if (propIsEnumerable.call(from, symbols[i])) {
|
|
76
|
-
to[symbols[i]] = from[symbols[i]];
|
|
77
|
-
}
|
|
7
|
+
target = Object(target);
|
|
8
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
9
|
+
var source = Object(arguments[i]); // eslint-disable-next-line no-restricted-syntax
|
|
10
|
+
for (var key in source) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
12
|
+
target[key] = source[key];
|
|
78
13
|
}
|
|
79
14
|
}
|
|
80
15
|
}
|
|
81
|
-
return
|
|
16
|
+
return target;
|
|
82
17
|
};
|
package/esm/utils/lang/sets.js
CHANGED
|
@@ -1,113 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Set implementation based on es6-set polyfill (https://github.com/medikoo/es6-set/blob/master/polyfill.js),
|
|
3
|
-
* with the minimal features used by the SDK.
|
|
4
|
-
|
|
5
|
-
Copyright (C) 2013 Mariusz Nowak (www.medikoo.com)
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
**/
|
|
25
|
-
var SetPoly = /** @class */ (function () {
|
|
26
|
-
// unlike ES6 `Set`, it only accepts an array as first argument iterable
|
|
27
|
-
function SetPoly(values) {
|
|
28
|
-
var _this = this;
|
|
29
|
-
this.__setData__ = [];
|
|
30
|
-
if (Array.isArray(values))
|
|
31
|
-
values.forEach(function (value) { _this.add(value); });
|
|
32
|
-
}
|
|
33
|
-
SetPoly.prototype.clear = function () {
|
|
34
|
-
if (!this.__setData__.length)
|
|
35
|
-
return;
|
|
36
|
-
this.__setData__.length = 0;
|
|
37
|
-
};
|
|
38
|
-
SetPoly.prototype.add = function (value) {
|
|
39
|
-
if (this.has(value))
|
|
40
|
-
return this;
|
|
41
|
-
this.__setData__.push(value);
|
|
42
|
-
return this;
|
|
43
|
-
};
|
|
44
|
-
SetPoly.prototype.delete = function (value) {
|
|
45
|
-
var index = this.__setData__.indexOf(value);
|
|
46
|
-
if (index === -1)
|
|
47
|
-
return false;
|
|
48
|
-
this.__setData__.splice(index, 1);
|
|
49
|
-
return true;
|
|
50
|
-
};
|
|
51
|
-
SetPoly.prototype.has = function (value) {
|
|
52
|
-
return this.__setData__.indexOf(value) !== -1;
|
|
53
|
-
};
|
|
54
|
-
SetPoly.prototype.forEach = function (callbackfn, thisArg) {
|
|
55
|
-
if (typeof callbackfn !== 'function')
|
|
56
|
-
throw new TypeError(callbackfn + ' is not a function');
|
|
57
|
-
for (var i = 0; i < this.__setData__.length; i++) {
|
|
58
|
-
var value = this.__setData__[i];
|
|
59
|
-
callbackfn.call(thisArg, value, value, this);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
Object.defineProperty(SetPoly.prototype, "size", {
|
|
63
|
-
get: function () {
|
|
64
|
-
return this.__setData__.length;
|
|
65
|
-
},
|
|
66
|
-
enumerable: false,
|
|
67
|
-
configurable: true
|
|
68
|
-
});
|
|
69
|
-
return SetPoly;
|
|
70
|
-
}());
|
|
71
|
-
export { SetPoly };
|
|
72
|
-
/**
|
|
73
|
-
* return an array containing the items of the given set.
|
|
74
|
-
* @param set Set or SetPoly instance
|
|
75
|
-
*/
|
|
76
|
-
export function setToArray(set) {
|
|
77
|
-
if (set instanceof SetPoly) {
|
|
78
|
-
return set.__setData__.slice();
|
|
79
|
-
}
|
|
80
|
-
// if not using SetPoly as set, it means Array.from is supported
|
|
81
|
-
// eslint-disable-next-line compat/compat
|
|
82
|
-
return Array.from(set);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* return the Set constructor to use. If `Array.from` built-in or native Set is not available or it doesn't support the required features,
|
|
86
|
-
* a ponyfill with minimal features is returned instead.
|
|
87
|
-
*
|
|
88
|
-
* Exported for testing purposes only.
|
|
89
|
-
*/
|
|
90
|
-
export function __getSetConstructor() {
|
|
91
|
-
// eslint-disable-next-line compat/compat
|
|
92
|
-
if (typeof Array.from === 'function' && typeof Set === 'function' && Set.prototype && Set.prototype.values) {
|
|
93
|
-
return Set;
|
|
94
|
-
}
|
|
95
|
-
return SetPoly;
|
|
96
|
-
}
|
|
97
|
-
export var _Set = __getSetConstructor();
|
|
98
1
|
export function returnSetsUnion(set, set2) {
|
|
99
|
-
|
|
100
|
-
set2.forEach(function (value) {
|
|
101
|
-
result.add(value);
|
|
102
|
-
});
|
|
103
|
-
return result;
|
|
2
|
+
return new Set(Array.from(set).concat(Array.from(set2)));
|
|
104
3
|
}
|
|
105
4
|
export function returnDifference(list, list2) {
|
|
106
5
|
if (list === void 0) { list = []; }
|
|
107
6
|
if (list2 === void 0) { list2 = []; }
|
|
108
|
-
|
|
109
|
-
list2.forEach(function (item) {
|
|
110
|
-
result.delete(item);
|
|
111
|
-
});
|
|
112
|
-
return setToArray(result);
|
|
7
|
+
return list.filter(function (item) { return list2.indexOf(item) === -1; });
|
|
113
8
|
}
|
|
@@ -4,7 +4,6 @@ import { validateSplitFilters } from './splitFilters';
|
|
|
4
4
|
import { STANDALONE_MODE, OPTIMIZED, LOCALHOST_MODE, DEBUG, FLAG_SPEC_VERSION } from '../constants';
|
|
5
5
|
import { validImpressionsMode } from './impressionsMode';
|
|
6
6
|
import { validateKey } from '../inputValidation/key';
|
|
7
|
-
import { validateTrafficType } from '../inputValidation/trafficType';
|
|
8
7
|
import { ERROR_MIN_CONFIG_PARAM, LOG_PREFIX_CLIENT_INSTANTIATION } from '../../logger/constants';
|
|
9
8
|
// Exported for telemetry
|
|
10
9
|
export var base = {
|
|
@@ -15,8 +14,6 @@ export var base = {
|
|
|
15
14
|
authorizationKey: undefined,
|
|
16
15
|
// key used in your system (only required for browser version)
|
|
17
16
|
key: undefined,
|
|
18
|
-
// traffic type for the given key (only used on browser version)
|
|
19
|
-
trafficType: undefined,
|
|
20
17
|
// toggle impressions tracking of labels
|
|
21
18
|
labelsEnabled: true,
|
|
22
19
|
// toggle sendind (true) or not sending (false) IP and Host Name with impressions, events, and telemetries requests (only used on nodejs version)
|
|
@@ -145,12 +142,6 @@ export function settingsValidation(config, validationParams) {
|
|
|
145
142
|
// @ts-ignore, @TODO handle invalid keys as a non-recoverable error?
|
|
146
143
|
withDefaults.core.key = validateKey(log, maybeKey, LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
147
144
|
}
|
|
148
|
-
if (validationParams.acceptTT) {
|
|
149
|
-
var maybeTT = withDefaults.core.trafficType;
|
|
150
|
-
if (maybeTT !== undefined) { // @ts-ignore
|
|
151
|
-
withDefaults.core.trafficType = validateTrafficType(log, maybeTT, LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
145
|
}
|
|
155
146
|
else {
|
|
156
147
|
// On server-side, key is undefined and used to distinguish from client-side
|
|
@@ -2,9 +2,8 @@ import { isLogLevelString, Logger, LogLevels } from '../../../logger';
|
|
|
2
2
|
import { isLocalStorageAvailable } from '../../env/isLocalStorageAvailable';
|
|
3
3
|
import { isNode } from '../../env/isNode';
|
|
4
4
|
import { codesDebug } from '../../../logger/messages/debug';
|
|
5
|
-
import { _Map } from '../../lang/maps';
|
|
6
5
|
import { getLogLevel } from './commons';
|
|
7
|
-
var allCodes = new
|
|
6
|
+
var allCodes = new Map(codesDebug);
|
|
8
7
|
// @TODO set default debug setting instead of initialLogLevel when integrating in JS and Node packages
|
|
9
8
|
var LS_KEY = 'splitio_debug';
|
|
10
9
|
var ENV_VAR_KEY = 'SPLITIO_DEBUG';
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { InMemoryStorageCSFactory } from '../../../storages/inMemory/InMemoryStorageCS';
|
|
2
2
|
import { ERROR_STORAGE_INVALID } from '../../../logger/constants';
|
|
3
3
|
import { LOCALHOST_MODE, STANDALONE_MODE, STORAGE_PLUGGABLE, STORAGE_LOCALSTORAGE, STORAGE_MEMORY } from '../../../utils/constants';
|
|
4
|
+
export function __InLocalStorageMockFactory(params) {
|
|
5
|
+
var result = InMemoryStorageCSFactory(params);
|
|
6
|
+
result.splits.checkCache = function () { return true; }; // to emit SDK_READY_FROM_CACHE
|
|
7
|
+
return result;
|
|
8
|
+
}
|
|
9
|
+
__InLocalStorageMockFactory.type = STORAGE_MEMORY;
|
|
4
10
|
/**
|
|
5
11
|
* This function validates `settings.storage` object
|
|
6
12
|
*
|
|
@@ -17,6 +23,10 @@ export function validateStorageCS(settings) {
|
|
|
17
23
|
storage = InMemoryStorageCSFactory;
|
|
18
24
|
log.error(ERROR_STORAGE_INVALID);
|
|
19
25
|
}
|
|
26
|
+
// In localhost mode with InLocalStorage, fallback to a mock InLocalStorage to emit SDK_READY_FROM_CACHE
|
|
27
|
+
if (mode === LOCALHOST_MODE && storage.type === STORAGE_LOCALSTORAGE) {
|
|
28
|
+
return __InLocalStorageMockFactory;
|
|
29
|
+
}
|
|
20
30
|
if ([LOCALHOST_MODE, STANDALONE_MODE].indexOf(mode) === -1) {
|
|
21
31
|
// Consumer modes require an async storage
|
|
22
32
|
if (storage.type !== STORAGE_PLUGGABLE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splitsoftware/splitio-commons",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-rc.0",
|
|
4
4
|
"description": "Split JavaScript SDK common components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@typescript-eslint/parser": "^6.6.0",
|
|
65
65
|
"cross-env": "^7.0.2",
|
|
66
66
|
"eslint": "^8.48.0",
|
|
67
|
-
"eslint-plugin-compat": "^
|
|
67
|
+
"eslint-plugin-compat": "^6.0.1",
|
|
68
68
|
"eslint-plugin-import": "^2.25.3",
|
|
69
69
|
"fetch-mock": "^9.11.0",
|
|
70
70
|
"ioredis": "^4.28.0",
|
package/src/evaluator/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { IStorageAsync, IStorageSync } from '../storages/types';
|
|
|
7
7
|
import { IEvaluationResult } from './types';
|
|
8
8
|
import { SplitIO } from '../types';
|
|
9
9
|
import { ILogger } from '../logger/types';
|
|
10
|
-
import {
|
|
10
|
+
import { returnSetsUnion } from '../utils/lang/sets';
|
|
11
11
|
import { WARN_FLAGSET_WITHOUT_FLAGS } from '../logger/constants';
|
|
12
12
|
|
|
13
13
|
const treatmentException = {
|
|
@@ -97,12 +97,12 @@ export function evaluateFeaturesByFlagSets(
|
|
|
97
97
|
storage: IStorageSync | IStorageAsync,
|
|
98
98
|
method: string,
|
|
99
99
|
): MaybeThenable<Record<string, IEvaluationResult>> {
|
|
100
|
-
let storedFlagNames: MaybeThenable<
|
|
100
|
+
let storedFlagNames: MaybeThenable<Set<string>[]>;
|
|
101
101
|
|
|
102
102
|
function evaluate(
|
|
103
|
-
featureFlagsByFlagSets:
|
|
103
|
+
featureFlagsByFlagSets: Set<string>[],
|
|
104
104
|
) {
|
|
105
|
-
let featureFlags = new
|
|
105
|
+
let featureFlags = new Set<string>();
|
|
106
106
|
for (let i = 0; i < flagSets.length; i++) {
|
|
107
107
|
const featureFlagByFlagSet = featureFlagsByFlagSets[i];
|
|
108
108
|
if (featureFlagByFlagSet.size) {
|
|
@@ -113,7 +113,7 @@ export function evaluateFeaturesByFlagSets(
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
return featureFlags.size ?
|
|
116
|
-
evaluateFeatures(log, key,
|
|
116
|
+
evaluateFeatures(log, key, Array.from(featureFlags), attributes, storage) :
|
|
117
117
|
{};
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { _Set } from '../../utils/lang/sets';
|
|
2
1
|
import { Semver } from '../../utils/Semver';
|
|
3
2
|
|
|
4
3
|
export function inListSemverMatcherContext(ruleAttr: string[]) {
|
|
5
4
|
// @TODO ruleAttr validation should be done at the `parser` or `matchersTransform` level to reuse for all matchers
|
|
6
5
|
if (!ruleAttr || ruleAttr.length === 0) throw new Error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type');
|
|
7
6
|
|
|
8
|
-
const listOfSemvers = new
|
|
7
|
+
const listOfSemvers = new Set(ruleAttr.map((version) => new Semver(version).version));
|
|
9
8
|
|
|
10
9
|
return function inListSemverMatcher(runtimeAttr: string): boolean {
|
|
11
10
|
const runtimeSemver = new Semver(runtimeAttr).version;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { _Set } from '../../utils/lang/sets';
|
|
2
|
-
|
|
3
1
|
export function whitelistMatcherContext(ruleAttr: string[]) {
|
|
4
|
-
const whitelistSet = new
|
|
2
|
+
const whitelistSet = new Set(ruleAttr);
|
|
5
3
|
|
|
6
4
|
return function whitelistMatcher(runtimeAttr: string): boolean {
|
|
7
5
|
const isInWhitelist = whitelistSet.has(runtimeAttr);
|
package/src/listeners/browser.ts
CHANGED
|
@@ -115,7 +115,6 @@ export class BrowserSignalListener implements ISignalListener {
|
|
|
115
115
|
* Returns true if beacon API was used successfully, false otherwise.
|
|
116
116
|
*/
|
|
117
117
|
private _sendBeacon(url: string, data: any, extraMetadata?: {}) {
|
|
118
|
-
// eslint-disable-next-line compat/compat
|
|
119
118
|
if (typeof navigator !== 'undefined' && navigator.sendBeacon) {
|
|
120
119
|
const json = {
|
|
121
120
|
entries: data,
|
|
@@ -130,7 +129,7 @@ export class BrowserSignalListener implements ISignalListener {
|
|
|
130
129
|
const payload = JSON.stringify(json);
|
|
131
130
|
|
|
132
131
|
// https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
|
|
133
|
-
try {
|
|
132
|
+
try {
|
|
134
133
|
return navigator.sendBeacon(url, payload);
|
|
135
134
|
} catch (e) {
|
|
136
135
|
return false;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Logger } from '../index';
|
|
2
2
|
import { codesDebug } from '../messages/debug';
|
|
3
|
-
import { _Map } from '../../utils/lang/maps';
|
|
4
3
|
|
|
5
4
|
export function DebugLogger() {
|
|
6
|
-
return new Logger({ logLevel: 'DEBUG' }, new
|
|
5
|
+
return new Logger({ logLevel: 'DEBUG' }, new Map(codesDebug));
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Logger } from '../index';
|
|
2
2
|
import { codesError } from '../messages/error';
|
|
3
|
-
import { _Map } from '../../utils/lang/maps';
|
|
4
3
|
|
|
5
4
|
export function ErrorLogger() {
|
|
6
|
-
return new Logger({ logLevel: 'ERROR' }, new
|
|
5
|
+
return new Logger({ logLevel: 'ERROR' }, new Map(codesError));
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Logger } from '../index';
|
|
2
2
|
import { codesInfo } from '../messages/info';
|
|
3
|
-
import { _Map } from '../../utils/lang/maps';
|
|
4
3
|
|
|
5
4
|
export function InfoLogger() {
|
|
6
|
-
return new Logger({ logLevel: 'INFO' }, new
|
|
5
|
+
return new Logger({ logLevel: 'INFO' }, new Map(codesInfo));
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Logger } from '../index';
|
|
2
2
|
import { codesWarn } from '../messages/warn';
|
|
3
|
-
import { _Map } from '../../utils/lang/maps';
|
|
4
3
|
|
|
5
4
|
export function WarnLogger() {
|
|
6
|
-
return new Logger({ logLevel: 'WARN' }, new
|
|
5
|
+
return new Logger({ logLevel: 'WARN' }, new Map(codesWarn));
|
|
7
6
|
}
|
package/src/logger/index.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { objectAssign } from '../utils/lang/objectAssign';
|
|
|
2
2
|
import { ILoggerOptions, ILogger } from './types';
|
|
3
3
|
import { find, isObject } from '../utils/lang';
|
|
4
4
|
import { LogLevel } from '../types';
|
|
5
|
-
import { IMap, _Map } from '../utils/lang/maps';
|
|
6
5
|
|
|
7
6
|
export const LogLevels: { [level: string]: LogLevel } = {
|
|
8
7
|
DEBUG: 'DEBUG',
|
|
@@ -47,12 +46,12 @@ const defaultOptions = {
|
|
|
47
46
|
export class Logger implements ILogger {
|
|
48
47
|
|
|
49
48
|
private options: Required<ILoggerOptions>;
|
|
50
|
-
private codes:
|
|
49
|
+
private codes: Map<number, string>;
|
|
51
50
|
private logLevel: number;
|
|
52
51
|
|
|
53
|
-
constructor(options?: ILoggerOptions, codes?:
|
|
52
|
+
constructor(options?: ILoggerOptions, codes?: Map<number, string>) {
|
|
54
53
|
this.options = objectAssign({}, defaultOptions, options);
|
|
55
|
-
this.codes = codes || new
|
|
54
|
+
this.codes = codes || new Map();
|
|
56
55
|
this.logLevel = LogLevelIndexes[this.options.logLevel];
|
|
57
56
|
}
|
|
58
57
|
|
|
@@ -5,18 +5,17 @@ import { clientAttributesDecoration } from './clientAttributesDecoration';
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Decorator that binds a key
|
|
8
|
+
* Decorator that binds a key to client methods
|
|
9
9
|
*
|
|
10
10
|
* @param client sync client instance
|
|
11
11
|
* @param key validated split key
|
|
12
|
-
* @param trafficType validated traffic type
|
|
13
12
|
*/
|
|
14
|
-
export function clientCSDecorator(log: ILogger, client: SplitIO.IClient, key: SplitIO.SplitKey
|
|
13
|
+
export function clientCSDecorator(log: ILogger, client: SplitIO.IClient, key: SplitIO.SplitKey): SplitIO.ICsClient {
|
|
15
14
|
|
|
16
15
|
let clientCS = clientAttributesDecoration(log, client);
|
|
17
16
|
|
|
18
17
|
return objectAssign(clientCS, {
|
|
19
|
-
// In the client-side API, we bind a key to the client `getTreatment*` methods
|
|
18
|
+
// In the client-side API, we bind a key to the client `getTreatment*` and `track` methods
|
|
20
19
|
getTreatment: clientCS.getTreatment.bind(clientCS, key),
|
|
21
20
|
getTreatmentWithConfig: clientCS.getTreatmentWithConfig.bind(clientCS, key),
|
|
22
21
|
getTreatments: clientCS.getTreatments.bind(clientCS, key),
|
|
@@ -26,12 +25,10 @@ export function clientCSDecorator(log: ILogger, client: SplitIO.IClient, key: Sp
|
|
|
26
25
|
getTreatmentsByFlagSet: clientCS.getTreatmentsByFlagSet.bind(clientCS, key),
|
|
27
26
|
getTreatmentsWithConfigByFlagSet: clientCS.getTreatmentsWithConfigByFlagSet.bind(clientCS, key),
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key),
|
|
28
|
+
track: clientCS.track.bind(clientCS, key),
|
|
31
29
|
|
|
32
30
|
// Not part of the public API. These properties are used to support other modules (e.g., Split Suite)
|
|
33
31
|
isClientSide: true,
|
|
34
|
-
key
|
|
35
|
-
trafficType
|
|
32
|
+
key
|
|
36
33
|
}) as SplitIO.ICsClient;
|
|
37
34
|
}
|
|
@@ -35,7 +35,7 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl
|
|
|
35
35
|
return mainClientInstance;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// Validate the key value
|
|
38
|
+
// Validate the key value
|
|
39
39
|
const validKey = validateKey(log, key, LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
40
40
|
if (validKey === false) {
|
|
41
41
|
throw new Error('Shared Client needs a valid key.');
|
package/src/sdkFactory/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { IBasicClient, SplitIO } from '../types';
|
|
|
7
7
|
import { validateAndTrackApiKey } from '../utils/inputValidation/apiKey';
|
|
8
8
|
import { createLoggerAPI } from '../logger/sdkLogger';
|
|
9
9
|
import { NEW_FACTORY, RETRIEVE_MANAGER } from '../logger/constants';
|
|
10
|
-
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED
|
|
10
|
+
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
|
|
11
11
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
12
12
|
import { strategyDebugFactory } from '../trackers/strategy/strategyDebug';
|
|
13
13
|
import { strategyOptimizedFactory } from '../trackers/strategy/strategyOptimized';
|
|
@@ -46,11 +46,8 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
|
|
|
46
46
|
readiness.splits.emit(SDK_SPLITS_ARRIVED);
|
|
47
47
|
readiness.segments.emit(SDK_SEGMENTS_ARRIVED);
|
|
48
48
|
},
|
|
49
|
-
onReadyFromCacheCb: () => {
|
|
50
|
-
readiness.splits.emit(SDK_SPLITS_CACHE_LOADED);
|
|
51
|
-
}
|
|
52
49
|
});
|
|
53
|
-
|
|
50
|
+
// @TODO add support for dataloader: `if (params.dataLoader) params.dataLoader(storage);`
|
|
54
51
|
const clients: Record<string, IBasicClient> = {};
|
|
55
52
|
const telemetryTracker = telemetryTrackerFactory(storage.telemetry, platform.now);
|
|
56
53
|
const integrationsManager = integrationsManagerFactory && integrationsManagerFactory({ settings, storage, telemetryTracker });
|
package/src/sdkFactory/types.ts
CHANGED
|
@@ -93,7 +93,7 @@ export interface ISdkFactoryParams {
|
|
|
93
93
|
|
|
94
94
|
// Sdk client method factory (ISDK::client method).
|
|
95
95
|
// It Allows to distinguish SDK clients with the client-side API (`ICsSDK`) or server-side API (`ISDK` or `IAsyncSDK`).
|
|
96
|
-
sdkClientMethodFactory: (params: ISdkFactoryContext) => ({ (): SplitIO.ICsClient; (key: SplitIO.SplitKey
|
|
96
|
+
sdkClientMethodFactory: (params: ISdkFactoryContext) => ({ (): SplitIO.ICsClient; (key: SplitIO.SplitKey): SplitIO.ICsClient; } | (() => SplitIO.IClient) | (() => SplitIO.IAsyncClient))
|
|
97
97
|
|
|
98
98
|
// Impression observer factory.
|
|
99
99
|
impressionsObserverFactory: () => IImpressionObserver
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
|
-
import { _Set } from '../utils/lang/sets';
|
|
3
2
|
import { ISettings } from '../types';
|
|
4
3
|
|
|
5
|
-
const FORBIDDEN_HEADERS = new
|
|
4
|
+
const FORBIDDEN_HEADERS = new Set([
|
|
6
5
|
'splitsdkclientkey',
|
|
7
6
|
'splitsdkversion',
|
|
8
7
|
'splitsdkmachineip',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ISplitsCacheAsync } from './types';
|
|
2
2
|
import { ISplit } from '../dtos/types';
|
|
3
3
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
4
|
-
import { ISet } from '../utils/lang/sets';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* This class provides a skeletal implementation of the ISplitsCacheAsync interface
|
|
@@ -18,7 +17,7 @@ export abstract class AbstractSplitsCacheAsync implements ISplitsCacheAsync {
|
|
|
18
17
|
abstract getChangeNumber(): Promise<number>
|
|
19
18
|
abstract getAll(): Promise<ISplit[]>
|
|
20
19
|
abstract getSplitNames(): Promise<string[]>
|
|
21
|
-
abstract getNamesByFlagSets(flagSets: string[]): Promise<
|
|
20
|
+
abstract getNamesByFlagSets(flagSets: string[]): Promise<Set<string>[]>
|
|
22
21
|
abstract trafficTypeExists(trafficType: string): Promise<boolean>
|
|
23
22
|
abstract clear(): Promise<boolean | void>
|
|
24
23
|
|
|
@@ -28,6 +27,14 @@ export abstract class AbstractSplitsCacheAsync implements ISplitsCacheAsync {
|
|
|
28
27
|
return Promise.resolve(true);
|
|
29
28
|
}
|
|
30
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Check if the splits information is already stored in cache.
|
|
32
|
+
* Noop, just keeping the interface. This is used by client-side implementations only.
|
|
33
|
+
*/
|
|
34
|
+
checkCache(): Promise<boolean> {
|
|
35
|
+
return Promise.resolve(false);
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
/**
|
|
32
39
|
* Kill `name` split and set `defaultTreatment` and `changeNumber`.
|
|
33
40
|
* Used for SPLIT_KILL push notifications.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ISplitsCacheSync } from './types';
|
|
2
2
|
import { ISplit } from '../dtos/types';
|
|
3
3
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
4
|
-
import { ISet } from '../utils/lang/sets';
|
|
5
4
|
import { IN_SEGMENT, IN_LARGE_SEGMENT } from '../utils/constants';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -48,6 +47,14 @@ export abstract class AbstractSplitsCacheSync implements ISplitsCacheSync {
|
|
|
48
47
|
|
|
49
48
|
abstract clear(): void
|
|
50
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Check if the splits information is already stored in cache. This data can be preloaded.
|
|
52
|
+
* It is used as condition to emit SDK_SPLITS_CACHE_LOADED, and then SDK_READY_FROM_CACHE.
|
|
53
|
+
*/
|
|
54
|
+
checkCache(): boolean {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
51
58
|
/**
|
|
52
59
|
* Kill `name` split and set `defaultTreatment` and `changeNumber`.
|
|
53
60
|
* Used for SPLIT_KILL push notifications.
|
|
@@ -72,7 +79,7 @@ export abstract class AbstractSplitsCacheSync implements ISplitsCacheSync {
|
|
|
72
79
|
return false;
|
|
73
80
|
}
|
|
74
81
|
|
|
75
|
-
abstract getNamesByFlagSets(flagSets: string[]):
|
|
82
|
+
abstract getNamesByFlagSets(flagSets: string[]): Set<string>[]
|
|
76
83
|
|
|
77
84
|
}
|
|
78
85
|
|