@splitsoftware/splitio 10.16.0 → 10.16.2-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.
Files changed (67) hide show
  1. package/CHANGES.txt +9 -0
  2. package/CONTRIBUTORS-GUIDE.md +13 -12
  3. package/README.md +2 -1
  4. package/es/client/attributesDecoration.js +116 -0
  5. package/es/client/browser.js +2 -2
  6. package/es/engine/engine/murmur3/murmur3_128.js +1 -1
  7. package/es/engine/engine/murmur3/murmur3_128_x86.js +2 -3
  8. package/es/engine/evaluator/index.js +3 -4
  9. package/es/engine/matchers/index.js +20 -37
  10. package/es/engine/matchers/types.js +19 -72
  11. package/es/engine/transforms/matcherGroup.js +2 -2
  12. package/es/engine/transforms/matchers.js +2 -2
  13. package/es/engine/value/sanitize.js +12 -14
  14. package/es/impressions/hasher/hashImpression128.js +1 -1
  15. package/es/impressions/observer/observer.js +0 -1
  16. package/es/producer/updater/SplitChangesFromObject.js +3 -2
  17. package/es/storage/AttributesCache/InMemory.js +84 -0
  18. package/es/sync/PushManager/index.js +3 -11
  19. package/es/utils/inputValidation/attribute.js +22 -0
  20. package/es/utils/inputValidation/attributes.js +9 -0
  21. package/es/utils/logger/LoggerFactory.js +23 -16
  22. package/es/utils/settings/index.js +1 -1
  23. package/es/utils/settings/storage/browser.js +19 -4
  24. package/lib/client/attributesDecoration.js +128 -0
  25. package/lib/client/browser.js +5 -5
  26. package/lib/engine/engine/murmur3/murmur3_128.js +1 -1
  27. package/lib/engine/engine/murmur3/murmur3_128_x86.js +2 -3
  28. package/lib/engine/evaluator/index.js +3 -5
  29. package/lib/engine/matchers/index.js +21 -39
  30. package/lib/engine/matchers/types.js +23 -77
  31. package/lib/engine/transforms/matcherGroup.js +3 -3
  32. package/lib/engine/transforms/matchers.js +22 -22
  33. package/lib/engine/value/sanitize.js +11 -13
  34. package/lib/impressions/hasher/hashImpression128.js +2 -2
  35. package/lib/impressions/observer/observer.js +0 -1
  36. package/lib/producer/updater/SplitChangesFromObject.js +4 -2
  37. package/lib/storage/AttributesCache/InMemory.js +92 -0
  38. package/lib/sync/PushManager/index.js +3 -11
  39. package/lib/utils/inputValidation/attribute.js +32 -0
  40. package/lib/utils/inputValidation/attributes.js +12 -0
  41. package/lib/utils/logger/LoggerFactory.js +23 -17
  42. package/lib/utils/settings/index.js +1 -1
  43. package/lib/utils/settings/storage/browser.js +18 -3
  44. package/package.json +17 -17
  45. package/src/client/attributesDecoration.js +112 -0
  46. package/src/client/browser.js +2 -2
  47. package/src/engine/engine/murmur3/murmur3_128.js +1 -1
  48. package/src/engine/engine/murmur3/murmur3_128_x86.js +2 -3
  49. package/src/engine/evaluator/index.js +3 -4
  50. package/src/engine/matchers/index.js +22 -36
  51. package/src/engine/matchers/types.js +20 -55
  52. package/src/engine/transforms/matcherGroup.js +2 -5
  53. package/src/engine/transforms/matchers.js +2 -6
  54. package/src/engine/value/sanitize.js +12 -17
  55. package/src/impressions/hasher/hashImpression128.js +1 -1
  56. package/src/impressions/observer/observer.js +0 -2
  57. package/src/producer/updater/SplitChangesFromObject.js +2 -2
  58. package/src/storage/AttributesCache/InMemory.js +75 -0
  59. package/src/sync/PushManager/index.js +3 -10
  60. package/src/sync/constants.js +1 -1
  61. package/src/utils/inputValidation/attribute.js +22 -0
  62. package/src/utils/inputValidation/attributes.js +14 -0
  63. package/src/utils/logger/LoggerFactory.js +25 -16
  64. package/src/utils/settings/index.js +1 -1
  65. package/src/utils/settings/storage/browser.js +18 -3
  66. package/types/index.d.ts +1 -1
  67. package/types/splitio.d.ts +102 -27
@@ -48,52 +48,52 @@ function transform(matchers) {
48
48
  booleanMatcherData = matcher.booleanMatcherData,
49
49
  stringMatcherData = matcher.stringMatcherData;
50
50
  var attribute = keySelector && keySelector.attribute;
51
- var type = (0, _types.mapper)(matcherType); // As default input data type we use string (even for ALL_KEYS)
51
+ var type = (0, _types.matcherTypesMapper)(matcherType); // As default input data type we use string (even for ALL_KEYS)
52
52
 
53
- var dataType = _types.dataTypes.STRING;
53
+ var dataType = _types.matcherDataTypes.STRING;
54
54
  var value = undefined;
55
55
 
56
- if (type === _types.types.SEGMENT) {
56
+ if (type === _types.matcherTypes.IN_SEGMENT) {
57
57
  value = (0, _segment.default)(segmentObject);
58
- } else if (type === _types.types.WHITELIST) {
58
+ } else if (type === _types.matcherTypes.WHITELIST) {
59
59
  value = (0, _whitelist.default)(whitelistObject);
60
- } else if (type === _types.types.EQUAL_TO) {
60
+ } else if (type === _types.matcherTypes.EQUAL_TO) {
61
61
  value = (0, _unaryNumeric.default)(unaryNumericObject);
62
- dataType = _types.dataTypes.NUMBER;
62
+ dataType = _types.matcherDataTypes.NUMBER;
63
63
 
64
64
  if (unaryNumericObject.dataType === 'DATETIME') {
65
65
  value = (0, _convertions.zeroSinceHH)(value);
66
- dataType = _types.dataTypes.DATETIME;
66
+ dataType = _types.matcherDataTypes.DATETIME;
67
67
  }
68
- } else if (type === _types.types.GREATER_THAN_OR_EQUAL_TO || type === _types.types.LESS_THAN_OR_EQUAL_TO) {
68
+ } else if (type === _types.matcherTypes.GREATER_THAN_OR_EQUAL_TO || type === _types.matcherTypes.LESS_THAN_OR_EQUAL_TO) {
69
69
  value = (0, _unaryNumeric.default)(unaryNumericObject);
70
- dataType = _types.dataTypes.NUMBER;
70
+ dataType = _types.matcherDataTypes.NUMBER;
71
71
 
72
72
  if (unaryNumericObject.dataType === 'DATETIME') {
73
73
  value = (0, _convertions.zeroSinceSS)(value);
74
- dataType = _types.dataTypes.DATETIME;
74
+ dataType = _types.matcherDataTypes.DATETIME;
75
75
  }
76
- } else if (type === _types.types.BETWEEN) {
76
+ } else if (type === _types.matcherTypes.BETWEEN) {
77
77
  value = betweenObject;
78
- dataType = _types.dataTypes.NUMBER;
78
+ dataType = _types.matcherDataTypes.NUMBER;
79
79
 
80
80
  if (betweenObject.dataType === 'DATETIME') {
81
81
  value.start = (0, _convertions.zeroSinceSS)(value.start);
82
82
  value.end = (0, _convertions.zeroSinceSS)(value.end);
83
- dataType = _types.dataTypes.DATETIME;
83
+ dataType = _types.matcherDataTypes.DATETIME;
84
84
  }
85
- } else if (type === _types.types.EQUAL_TO_SET || type === _types.types.CONTAINS_ANY_OF_SET || type === _types.types.CONTAINS_ALL_OF_SET || type === _types.types.PART_OF_SET) {
85
+ } else if (type === _types.matcherTypes.EQUAL_TO_SET || type === _types.matcherTypes.CONTAINS_ANY_OF_SET || type === _types.matcherTypes.CONTAINS_ALL_OF_SET || type === _types.matcherTypes.PART_OF_SET) {
86
86
  value = (0, _set.default)(whitelistObject);
87
- dataType = _types.dataTypes.SET;
88
- } else if (type === _types.types.STARTS_WITH || type === _types.types.ENDS_WITH || type === _types.types.CONTAINS_STRING) {
87
+ dataType = _types.matcherDataTypes.SET;
88
+ } else if (type === _types.matcherTypes.STARTS_WITH || type === _types.matcherTypes.ENDS_WITH || type === _types.matcherTypes.CONTAINS_STRING) {
89
89
  value = (0, _set.default)(whitelistObject);
90
- } else if (type === _types.types.IN_SPLIT_TREATMENT) {
90
+ } else if (type === _types.matcherTypes.IN_SPLIT_TREATMENT) {
91
91
  value = dependencyObject;
92
- dataType = _types.dataTypes.NOT_SPECIFIED;
93
- } else if (type === _types.types.EQUAL_TO_BOOLEAN) {
94
- dataType = _types.dataTypes.BOOLEAN;
92
+ dataType = _types.matcherDataTypes.NOT_SPECIFIED;
93
+ } else if (type === _types.matcherTypes.EQUAL_TO_BOOLEAN) {
94
+ dataType = _types.matcherDataTypes.BOOLEAN;
95
95
  value = booleanMatcherData;
96
- } else if (type === _types.types.MATCHES_STRING) {
96
+ } else if (type === _types.matcherTypes.MATCHES_STRING) {
97
97
  value = stringMatcherData;
98
98
  }
99
99
 
@@ -112,7 +112,7 @@ function transform(matchers) {
112
112
  });
113
113
 
114
114
  if ((0, _lang.findIndex)(parsedMatchers, function (m) {
115
- return m.type === _types.types.UNDEFINED;
115
+ return m.type === _types.matcherTypes.UNDEFINED;
116
116
  }) === -1) {
117
117
  return parsedMatchers;
118
118
  } else {
@@ -29,8 +29,6 @@ See the License for the specific language governing permissions and
29
29
  limitations under the License.
30
30
  **/
31
31
  var log = (0, _logger.default)('splitio-engine:sanitize');
32
- var MATCHERS = _types.types;
33
- var DATA_TYPES = _types.dataTypes;
34
32
 
35
33
  function sanitizeNumber(val) {
36
34
  var num = (0, _lang.toNumber)(val);
@@ -81,15 +79,15 @@ function dependencyProcessor(sanitizedValue, attributes) {
81
79
 
82
80
  function getProcessingFunction(matcherTypeID, dataType) {
83
81
  switch (matcherTypeID) {
84
- case MATCHERS.EQUAL_TO:
82
+ case _types.matcherTypes.EQUAL_TO:
85
83
  return dataType === 'DATETIME' ? _convertions.zeroSinceHH : undefined;
86
84
 
87
- case MATCHERS.GREATER_THAN_OR_EQUAL_TO:
88
- case MATCHERS.LESS_THAN_OR_EQUAL_TO:
89
- case MATCHERS.BETWEEN:
85
+ case _types.matcherTypes.GREATER_THAN_OR_EQUAL_TO:
86
+ case _types.matcherTypes.LESS_THAN_OR_EQUAL_TO:
87
+ case _types.matcherTypes.BETWEEN:
90
88
  return dataType === 'DATETIME' ? _convertions.zeroSinceSS : undefined;
91
89
 
92
- case MATCHERS.IN_SPLIT_TREATMENT:
90
+ case _types.matcherTypes.IN_SPLIT_TREATMENT:
93
91
  return dependencyProcessor;
94
92
 
95
93
  default:
@@ -102,24 +100,24 @@ function sanitizeValue(matcherTypeID, value, dataType, attributes) {
102
100
  var sanitizedValue;
103
101
 
104
102
  switch (dataType) {
105
- case DATA_TYPES.NUMBER:
106
- case DATA_TYPES.DATETIME:
103
+ case _types.matcherDataTypes.NUMBER:
104
+ case _types.matcherDataTypes.DATETIME:
107
105
  sanitizedValue = sanitizeNumber(value);
108
106
  break;
109
107
 
110
- case DATA_TYPES.STRING:
108
+ case _types.matcherDataTypes.STRING:
111
109
  sanitizedValue = sanitizeString(value);
112
110
  break;
113
111
 
114
- case DATA_TYPES.SET:
112
+ case _types.matcherDataTypes.SET:
115
113
  sanitizedValue = sanitizeArray(value);
116
114
  break;
117
115
 
118
- case DATA_TYPES.BOOLEAN:
116
+ case _types.matcherDataTypes.BOOLEAN:
119
117
  sanitizedValue = sanitizeBoolean(value);
120
118
  break;
121
119
 
122
- case DATA_TYPES.NOT_SPECIFIED:
120
+ case _types.matcherDataTypes.NOT_SPECIFIED:
123
121
  sanitizedValue = value;
124
122
  break;
125
123
 
@@ -3,10 +3,10 @@
3
3
  exports.__esModule = true;
4
4
  exports.hashImpression128 = hashImpression128;
5
5
 
6
- var _murmur3_ = require("../../engine/engine/murmur3/murmur3_128");
6
+ var _murmur3_128_x = require("../../engine/engine/murmur3/murmur3_128_x86");
7
7
 
8
8
  var _buildKey = require("./buildKey");
9
9
 
10
10
  function hashImpression128(impression) {
11
- return (0, _murmur3_.hash128)((0, _buildKey.buildKey)(impression));
11
+ return (0, _murmur3_128_x.hash128)((0, _buildKey.buildKey)(impression));
12
12
  }
@@ -16,7 +16,6 @@ var ImpressionObserver = /*#__PURE__*/function () {
16
16
  var _proto = ImpressionObserver.prototype;
17
17
 
18
18
  _proto.testAndSet = function testAndSet(impression) {
19
- if (!impression) return null;
20
19
  var hash = this.hasher(impression);
21
20
  var previous = this.cache.get(hash);
22
21
  this.cache.set(hash, impression.time);
@@ -5,6 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  exports.__esModule = true;
6
6
  exports.default = void 0;
7
7
 
8
+ var _constants = require("../../utils/constants");
9
+
8
10
  var _lang = require("../../utils/lang");
9
11
 
10
12
  var _logger = _interopRequireDefault(require("../../utils/logger"));
@@ -61,13 +63,13 @@ function FromObjectUpdaterFactory(Fetcher, context) {
61
63
  })]);
62
64
  });
63
65
  return Promise.all([storage.splits.flush(), // required to sync removed splits from mock
64
- storage.splits.setChangeNumber(Date.now()), storage.splits.addSplits(splits)]).then(function () {
66
+ storage.splits.addSplits(splits)]).then(function () {
65
67
  readiness.splits.emit(readiness.splits.SDK_SPLITS_ARRIVED);
66
68
 
67
69
  if (startingUp) {
68
70
  startingUp = false; // Emits SDK_READY_FROM_CACHE
69
71
 
70
- if (storage.splits.checkCache()) readiness.splits.emit(readiness.splits.SDK_SPLITS_CACHE_LOADED); // Only emits SDK_SEGMENTS_ARRIVED the first time for SDK_READY
72
+ if (settings.storage.__originalType === _constants.STORAGE_LOCALSTORAGE) readiness.splits.emit(readiness.splits.SDK_SPLITS_CACHE_LOADED); // Only emits SDK_SEGMENTS_ARRIVED the first time for SDK_READY
71
73
 
72
74
  readiness.segments.emit(readiness.segments.SDK_SEGMENTS_ARRIVED);
73
75
  }
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports.default = void 0;
7
+
8
+ var _objectAssign = _interopRequireDefault(require("object-assign"));
9
+
10
+ var AttributesCacheInMemory = /*#__PURE__*/function () {
11
+ function AttributesCacheInMemory() {
12
+ this.attributesCache = {};
13
+ }
14
+ /**
15
+ * Create or update the value for the given attribute
16
+ *
17
+ * @param {string} attributeName attribute name
18
+ * @param {Object} attributeValue attribute value
19
+ * @returns {boolean} the attribute was stored
20
+ */
21
+
22
+
23
+ var _proto = AttributesCacheInMemory.prototype;
24
+
25
+ _proto.setAttribute = function setAttribute(attributeName, attributeValue) {
26
+ this.attributesCache[attributeName] = attributeValue;
27
+ return true;
28
+ }
29
+ /**
30
+ * Retrieves the value of a given attribute
31
+ *
32
+ * @param {string} attributeName attribute name
33
+ * @returns {Object?} stored attribute value
34
+ */
35
+ ;
36
+
37
+ _proto.getAttribute = function getAttribute(attributeName) {
38
+ return this.attributesCache[attributeName];
39
+ }
40
+ /**
41
+ * Create or update all the given attributes
42
+ *
43
+ * @param {[string, Object]} attributes attributes to create or update
44
+ * @returns {boolean} attributes were stored
45
+ */
46
+ ;
47
+
48
+ _proto.setAttributes = function setAttributes(attributes) {
49
+ this.attributesCache = (0, _objectAssign.default)(this.attributesCache, attributes);
50
+ return true;
51
+ }
52
+ /**
53
+ * Retrieve the full attributes map
54
+ *
55
+ * @returns {Map<string, Object>} stored attributes
56
+ */
57
+ ;
58
+
59
+ _proto.getAll = function getAll() {
60
+ return this.attributesCache;
61
+ }
62
+ /**
63
+ * Removes a given attribute from the map
64
+ *
65
+ * @param {string} attributeName attribute to remove
66
+ * @returns {boolean} attribute removed
67
+ */
68
+ ;
69
+
70
+ _proto.removeAttribute = function removeAttribute(attributeName) {
71
+ if (Object.keys(this.attributesCache).indexOf(attributeName) >= 0) {
72
+ delete this.attributesCache[attributeName];
73
+ return true;
74
+ }
75
+
76
+ return false;
77
+ }
78
+ /**
79
+ * Clears all attributes stored in the SDK
80
+ *
81
+ */
82
+ ;
83
+
84
+ _proto.clear = function clear() {
85
+ this.attributesCache = {};
86
+ };
87
+
88
+ return AttributesCacheInMemory;
89
+ }();
90
+
91
+ var _default = AttributesCacheInMemory;
92
+ exports.default = _default;
@@ -257,21 +257,13 @@ function PushManagerFactory(context, clientContexts
257
257
  (0, _lang.forOwn)(clients, function (_ref3) {
258
258
  var hash64 = _ref3.hash64,
259
259
  worker = _ref3.worker;
260
+ var add = added.has(hash64.dec) ? true : removed.has(hash64.dec) ? false : undefined;
260
261
 
261
- if (added.has(hash64.dec)) {
262
+ if (add !== undefined) {
262
263
  worker.put(parsedData.changeNumber, {
263
264
  name: parsedData.segmentName,
264
- add: true
265
+ add: add
265
266
  });
266
- return;
267
- }
268
-
269
- if (removed.has(hash64.dec)) {
270
- worker.put(parsedData.changeNumber, {
271
- name: parsedData.segmentName,
272
- add: false
273
- });
274
- return;
275
267
  }
276
268
  });
277
269
  return;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports.validateAttribute = validateAttribute;
7
+
8
+ var _lang = require("../lang");
9
+
10
+ var _logger = _interopRequireDefault(require("../logger"));
11
+
12
+ var log = (0, _logger.default)('');
13
+
14
+ function validateAttribute(attributeKey, attributeValue, method) {
15
+ if (!(0, _lang.isString)(attributeKey) || attributeKey.length === 0) {
16
+ log.warn(method + ": you passed an invalid attribute name, attribute name must be a non-empty string.");
17
+ return false;
18
+ }
19
+
20
+ var isStringVal = (0, _lang.isString)(attributeValue);
21
+ var isFiniteVal = (0, _lang.numberIsFinite)(attributeValue);
22
+ var isBoolVal = (0, _lang.isBoolean)(attributeValue);
23
+ var isArrayVal = Array.isArray(attributeValue);
24
+
25
+ if (!(isStringVal || isFiniteVal || isBoolVal || isArrayVal)) {
26
+ // If it's not of valid type.
27
+ log.warn(method + ": you passed an invalid attribute value for " + attributeKey + ". Acceptable types are: string, number, boolean and array of strings.");
28
+ return false;
29
+ }
30
+
31
+ return true;
32
+ }
@@ -4,11 +4,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
 
5
5
  exports.__esModule = true;
6
6
  exports.validateAttributes = validateAttributes;
7
+ exports.validateAttributesDeep = validateAttributesDeep;
7
8
 
8
9
  var _lang = require("../lang");
9
10
 
10
11
  var _logger = _interopRequireDefault(require("../logger"));
11
12
 
13
+ var _attribute = require("./attribute");
14
+
12
15
  var log = (0, _logger.default)('');
13
16
 
14
17
  function validateAttributes(maybeAttrs, method) {
@@ -17,4 +20,13 @@ function validateAttributes(maybeAttrs, method) {
17
20
  return maybeAttrs;
18
21
  log.error(method + ": attributes must be a plain object.");
19
22
  return false;
23
+ }
24
+
25
+ function validateAttributesDeep(maybeAttributes, method) {
26
+ if (!validateAttributes(maybeAttributes, method)) return false;
27
+ var result = true;
28
+ Object.keys(maybeAttributes).forEach(function (attributeKey) {
29
+ if (!(0, _attribute.validateAttribute)(attributeKey, maybeAttributes[attributeKey], method)) result = false;
30
+ });
31
+ return result;
20
32
  }
@@ -14,13 +14,23 @@ var LogLevels = {
14
14
  'WARN': 'WARN',
15
15
  'ERROR': 'ERROR',
16
16
  'NONE': 'NONE'
17
+ };
18
+ exports.LogLevels = LogLevels;
19
+ var LogLevelIndexes = {
20
+ DEBUG: 1,
21
+ INFO: 2,
22
+ WARN: 3,
23
+ ERROR: 4,
24
+ NONE: 5
17
25
  }; // DEBUG is the default. The log level is not specific to an SDK instance.
18
26
 
19
- exports.LogLevels = LogLevels;
20
- var GlobalLogLevel = LogLevels.DEBUG;
27
+ var GlobalLogLevel = LogLevelIndexes.DEBUG;
28
+ /**
29
+ * @param {'DEBUG'|'INFO'|'WARN'|'ERROR'|'NONE'} level
30
+ */
21
31
 
22
32
  var setLogLevel = function setLogLevel(level) {
23
- GlobalLogLevel = level;
33
+ GlobalLogLevel = LogLevelIndexes[level];
24
34
  };
25
35
 
26
36
  exports.setLogLevel = setLogLevel;
@@ -38,19 +48,19 @@ var Logger = /*#__PURE__*/function () {
38
48
  var _proto = Logger.prototype;
39
49
 
40
50
  _proto.debug = function debug(msg) {
41
- if (this._shouldLog(LogLevels.DEBUG)) this._log(LogLevels.DEBUG, msg);
51
+ if (this._shouldLog(LogLevelIndexes.DEBUG)) this._log(LogLevels.DEBUG, msg);
42
52
  };
43
53
 
44
54
  _proto.info = function info(msg) {
45
- if (this._shouldLog(LogLevels.INFO)) this._log(LogLevels.INFO, msg);
55
+ if (this._shouldLog(LogLevelIndexes.INFO)) this._log(LogLevels.INFO, msg);
46
56
  };
47
57
 
48
58
  _proto.warn = function warn(msg) {
49
- if (this._shouldLog(LogLevels.WARN)) this._log(LogLevels.WARN, msg);
59
+ if (this._shouldLog(LogLevelIndexes.WARN)) this._log(LogLevels.WARN, msg);
50
60
  };
51
61
 
52
62
  _proto.error = function error(msg) {
53
- if (this.options.displayAllErrors || this._shouldLog(LogLevels.ERROR)) this._log(LogLevels.ERROR, msg);
63
+ if (this.options.displayAllErrors || this._shouldLog(LogLevelIndexes.ERROR)) this._log(LogLevels.ERROR, msg);
54
64
  };
55
65
 
56
66
  _proto._log = function _log(level, text) {
@@ -72,18 +82,14 @@ var Logger = /*#__PURE__*/function () {
72
82
  }
73
83
 
74
84
  return result += text;
75
- };
85
+ }
86
+ /**
87
+ * @param {number} level
88
+ */
89
+ ;
76
90
 
77
91
  _proto._shouldLog = function _shouldLog(level) {
78
- var logLevel = GlobalLogLevel;
79
- var levels = Object.keys(LogLevels).map(function (f) {
80
- return LogLevels[f];
81
- });
82
- var index = levels.indexOf(level); // What's the index of what it's trying to check if it should log
83
-
84
- var levelIdx = levels.indexOf(logLevel); // What's the current log level index.
85
-
86
- return index >= levelIdx;
92
+ return level >= GlobalLogLevel;
87
93
  };
88
94
 
89
95
  return Logger;
@@ -44,7 +44,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44
44
  See the License for the specific language governing permissions and
45
45
  limitations under the License.
46
46
  **/
47
- var version = '10.16.0';
47
+ var version = '10.16.2-rc.0';
48
48
  var eventsEndpointMatcher = /^\/(testImpressions|metrics|events)/;
49
49
  var authEndpointMatcher = /^\/v2\/auth/;
50
50
  var streamingEndpointMatcher = /^\/(sse|event-stream)/;
@@ -29,30 +29,45 @@ limitations under the License.
29
29
  var log = (0, _logger.default)('splitio-settings');
30
30
 
31
31
  var ParseStorageSettings = function ParseStorageSettings(settings) {
32
- var _settings$storage = settings.storage,
32
+ var mode = settings.mode,
33
+ _settings$storage = settings.storage,
33
34
  _settings$storage$typ = _settings$storage.type,
34
35
  type = _settings$storage$typ === void 0 ? _constants.STORAGE_MEMORY : _settings$storage$typ,
35
36
  _settings$storage$opt = _settings$storage.options,
36
37
  options = _settings$storage$opt === void 0 ? {} : _settings$storage$opt,
37
38
  prefix = _settings$storage.prefix;
38
39
 
40
+ var __originalType;
41
+
39
42
  if (prefix) {
40
43
  prefix += '.SPLITIO';
41
44
  } else {
42
45
  prefix = 'SPLITIO';
46
+ }
47
+
48
+ var fallbackToMemory = function fallbackToMemory() {
49
+ __originalType = type;
50
+ type = _constants.STORAGE_MEMORY;
51
+ }; // In localhost mode, fallback to Memory storage and track original
52
+ // type to emit SDK_READY_FROM_CACHE if corresponds
53
+
54
+
55
+ if (mode === _constants.LOCALHOST_MODE && type === _constants.STORAGE_LOCALSTORAGE) {
56
+ fallbackToMemory();
43
57
  } // If an invalid storage type is provided OR we want to use LOCALSTORAGE and
44
58
  // it's not available, fallback into MEMORY
45
59
 
46
60
 
47
61
  if (type !== _constants.STORAGE_MEMORY && type !== _constants.STORAGE_LOCALSTORAGE || type === _constants.STORAGE_LOCALSTORAGE && !(0, _isAvailable.default)()) {
48
- type = _constants.STORAGE_MEMORY;
62
+ fallbackToMemory();
49
63
  log.warn('Invalid or unavailable storage. Fallbacking into MEMORY storage');
50
64
  }
51
65
 
52
66
  return {
53
67
  type: type,
54
68
  options: options,
55
- prefix: prefix
69
+ prefix: prefix,
70
+ __originalType: __originalType
56
71
  };
57
72
  };
58
73
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio",
3
- "version": "10.16.0",
3
+ "version": "10.16.2-rc.0",
4
4
  "description": "Split SDK",
5
5
  "files": [
6
6
  "README.md",
@@ -35,7 +35,7 @@
35
35
  "@babel/runtime": "^7.13.10",
36
36
  "@types/google.analytics": "0.0.40",
37
37
  "events": "3.1.0",
38
- "ioredis": "^4.26.0",
38
+ "ioredis": "^4.28.0",
39
39
  "ip": "1.1.5",
40
40
  "js-yaml": "3.13.1",
41
41
  "node-fetch": "^2.6.1",
@@ -46,7 +46,7 @@
46
46
  "eventsource": "^1.0.7"
47
47
  },
48
48
  "devDependencies": {
49
- "@babel/cli": "^7.14.8",
49
+ "@babel/cli": "^7.15.7",
50
50
  "@babel/core": "^7.13.10",
51
51
  "@babel/plugin-transform-runtime": "^7.13.10",
52
52
  "@babel/preset-env": "^7.13.10",
@@ -55,8 +55,8 @@
55
55
  "copyfiles": "^2.4.1",
56
56
  "cross-env": "^7.0.3",
57
57
  "csv-streamify": "4.0.0",
58
- "eslint": "^6.8.0",
59
- "eslint-plugin-compat": "^3.9.0",
58
+ "eslint": "^8.0.1",
59
+ "eslint-plugin-compat": "^3.13.0",
60
60
  "fetch-mock": "^9.11.0",
61
61
  "karma": "^6.3.2",
62
62
  "karma-chrome-launcher": "^3.1.0",
@@ -84,25 +84,27 @@
84
84
  "build-umd:stats": "webpack --progress --env production --json > ./stats/stat_results.json",
85
85
  "build-cjs": "rimraf lib && cross-env NODE_ENV=cjs babel ./src -d lib --ignore 'src/**/__tests__/*'",
86
86
  "postbuild-cjs": "cross-env NODE_ENV=cjs node scripts/copy.packages.json.js",
87
- "build-umd:ci": "webpack --config webpack.ci.dev.js --env branch=$BUILD_BRANCH --env commit_hash=$BUILD_COMMIT && webpack --config webpack.ci.prod.js --env branch=$BUILD_BRANCH --env commit_hash=$BUILD_COMMIT && ./scripts/clean_umd_build.sh",
88
- "build-umd": "webpack --config webpack.dev.js && webpack --config webpack.prod.js && ./scripts/clean_umd_build.sh",
89
- "build": "rimraf lib umd es && npm run build-cjs && npm run build-es && npm run build-umd",
87
+ "build-umd": "webpack --config webpack.ci.dev.js --env branch=$BUILD_BRANCH --env commit_hash=$BUILD_COMMIT && webpack --config webpack.ci.prod.js --env branch=$BUILD_BRANCH --env commit_hash=$BUILD_COMMIT && ./scripts/clean_umd_build.sh",
88
+ "build-umd:local": "webpack --config webpack.dev.js && webpack --config webpack.prod.js && ./scripts/clean_umd_build.sh",
89
+ "build:local": "rimraf lib umd es && npm run build-cjs && npm run build-es && npm run build-umd:local",
90
90
  "build:npm": "rimraf lib es && npm run build-cjs && npm run build-es",
91
- "build:ci": "rimraf lib umd es && npm run build-cjs && npm run build-es && npm run build-umd:ci",
92
- "check": "npm run check:lint && npm run check:version ",
91
+ "build": "rimraf lib umd es && npm run build-cjs && npm run build-es && npm run build-umd",
92
+ "check": "npm run check:lint && npm run check:version",
93
93
  "check:lint": "eslint src",
94
94
  "check:version": "cross-env NODE_ENV=test tape -r @babel/register src/utils/__tests__/settings/index.spec.js",
95
95
  "test-browser-local": "cross-env NODE_ENV=test karma start karma/local.karma.conf.js",
96
96
  "test-browser-e2e-local": "cross-env NODE_ENV=test karma start karma/e2e.local.karma.conf.js",
97
- "test-browser-ci": "cross-env NODE_ENV=test karma start karma/ci.karma.conf.js",
98
- "test-browser-e2e-ci": "cross-env NODE_ENV=test karma start karma/e2e.ci.karma.conf.js",
97
+ "test-browser": "npm run test-browser-unit && npm run test-browser-online && npm run test-browser-offline && npm run test-browser-destroy && npm run test-browser-errors && npm run test-browser-push && npm run test-browser-gaintegration",
98
+ "test-browser-unit": "cross-env NODE_ENV=test karma start karma/ci.karma.conf.js",
99
+ "test-browser-online": "cross-env NODE_ENV=test karma start karma/e2e.ci.karma.conf.js",
99
100
  "test-browser-offline": "cross-env NODE_ENV=test karma start karma/offline.karma.conf.js",
100
101
  "test-browser-destroy": "cross-env NODE_ENV=test karma start karma/destroy.ci.karma.conf.js",
101
102
  "test-browser-errors": "cross-env NODE_ENV=test karma start karma/errors.ci.karma.conf.js",
102
103
  "test-browser-gaintegration": "cross-env NODE_ENV=test karma start karma/gaintegration.ci.karma.conf.js",
103
104
  "test-browser-push": "cross-env NODE_ENV=test karma start karma/push.ci.karma.conf.js",
104
- "test-node": "cross-env NODE_ENV=test tape -r @babel/register \"src/*/**/__tests__/**/!(browser).spec.js\" | tap-min",
105
- "test-node-e2e": "cross-env NODE_ENV=test tape -r @babel/register src/__tests__/node.spec.js | tap-min",
105
+ "test-node": "npm run test-node-unit && npm run test-node-online && npm run test-node-redis && npm run test-node-offline && npm run test-node-destroy && npm run test-node-errors && npm run test-node-push",
106
+ "test-node-unit": "cross-env NODE_ENV=test tape -r @babel/register \"src/*/**/__tests__/**/!(browser).spec.js\" | tap-min",
107
+ "test-node-online": "cross-env NODE_ENV=test tape -r @babel/register src/__tests__/node.spec.js | tap-min",
106
108
  "test-node-destroy": "cross-env NODE_ENV=test tape -r @babel/register src/__tests__/destroy/node.spec.js | tap-min",
107
109
  "test-node-errors": "cross-env NODE_ENV=test tape -r @babel/register src/__tests__/errorCatching/node.spec.js | tap-min",
108
110
  "test-node-offline": "cross-env NODE_ENV=test tape -r @babel/register src/__tests__/offline/node.spec.js | tap-min",
@@ -111,9 +113,7 @@
111
113
  "pretest-ts-decls": "npm run build-es && npm run build-cjs && npm link",
112
114
  "test-ts-decls": "./scripts/ts-tests.sh",
113
115
  "posttest-ts-decls": "npm unlink && npm install",
114
- "browser-test-suite": "npm run test-browser-ci && npm run test-browser-e2e-ci && npm run test-browser-offline && npm run test-browser-destroy && npm run test-browser-errors && npm run test-browser-gaintegration",
115
- "node-test-suite": "npm run test-node && npm run test-node-e2e && npm run test-node-destroy && npm run test-node-offline && npm run test-node-redis && npm run test-node-errors",
116
- "test": "npm run browser-test-suite && npm run node-test-suite",
116
+ "test": "npm run test-node && npm run test-browser",
117
117
  "publish:rc": "npm run check && npm run build && npm publish --tag canary",
118
118
  "publish:stable": "npm run check && npm run build && npm publish"
119
119
  },