@splitsoftware/splitio-commons 1.0.1-rc.1 → 1.0.1-rc.5

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 (88) hide show
  1. package/cjs/evaluator/index.js +3 -4
  2. package/cjs/logger/constants.js +4 -4
  3. package/cjs/logger/messages/error.js +2 -1
  4. package/cjs/logger/messages/warn.js +0 -1
  5. package/cjs/sdkFactory/index.js +1 -1
  6. package/cjs/storages/inRedis/index.js +1 -2
  7. package/cjs/storages/pluggable/SplitsCachePluggable.js +1 -1
  8. package/cjs/storages/pluggable/constants.js +1 -1
  9. package/cjs/storages/pluggable/inMemoryWrapper.js +3 -3
  10. package/cjs/storages/pluggable/index.js +6 -6
  11. package/cjs/storages/pluggable/wrapperAdapter.js +3 -3
  12. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +1 -1
  13. package/cjs/sync/streaming/SSEClient/index.js +0 -1
  14. package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +0 -1
  15. package/cjs/utils/MinEventEmitter.js +5 -5
  16. package/cjs/utils/MinEvents.js +13 -15
  17. package/cjs/utils/constants/index.js +2 -2
  18. package/cjs/utils/env/isNode.js +4 -1
  19. package/cjs/utils/settingsValidation/storage/storageCS.js +11 -8
  20. package/esm/evaluator/index.js +3 -4
  21. package/esm/logger/constants.js +3 -3
  22. package/esm/logger/messages/error.js +2 -1
  23. package/esm/logger/messages/warn.js +0 -1
  24. package/esm/sdkFactory/index.js +1 -1
  25. package/esm/storages/inRedis/index.js +1 -2
  26. package/esm/storages/pluggable/SplitsCachePluggable.js +1 -1
  27. package/esm/storages/pluggable/constants.js +1 -1
  28. package/esm/storages/pluggable/inMemoryWrapper.js +3 -3
  29. package/esm/storages/pluggable/index.js +7 -7
  30. package/esm/storages/pluggable/wrapperAdapter.js +3 -3
  31. package/esm/sync/polling/updaters/mySegmentsUpdater.js +1 -1
  32. package/esm/sync/streaming/SSEClient/index.js +0 -1
  33. package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +0 -1
  34. package/esm/utils/MinEventEmitter.js +5 -5
  35. package/esm/utils/MinEvents.js +2 -5
  36. package/esm/utils/constants/index.js +1 -1
  37. package/esm/utils/env/isNode.js +4 -1
  38. package/esm/utils/settingsValidation/storage/storageCS.js +13 -10
  39. package/package.json +3 -4
  40. package/src/evaluator/index.ts +3 -4
  41. package/src/logger/constants.ts +3 -3
  42. package/src/logger/messages/error.ts +2 -1
  43. package/src/logger/messages/warn.ts +0 -1
  44. package/src/sdkFactory/index.ts +1 -1
  45. package/src/sdkFactory/types.ts +2 -2
  46. package/src/services/splitApi.ts +4 -1
  47. package/src/services/types.ts +16 -2
  48. package/src/storages/inRedis/index.ts +1 -1
  49. package/src/storages/pluggable/EventsCachePluggable.ts +3 -3
  50. package/src/storages/pluggable/ImpressionsCachePluggable.ts +3 -3
  51. package/src/storages/pluggable/SegmentsCachePluggable.ts +3 -3
  52. package/src/storages/pluggable/SplitsCachePluggable.ts +4 -4
  53. package/src/storages/pluggable/constants.ts +1 -1
  54. package/src/storages/pluggable/inMemoryWrapper.ts +5 -5
  55. package/src/storages/pluggable/index.ts +10 -10
  56. package/src/storages/pluggable/wrapperAdapter.ts +5 -5
  57. package/src/storages/types.ts +7 -7
  58. package/src/sync/polling/updaters/mySegmentsUpdater.ts +1 -1
  59. package/src/sync/streaming/SSEClient/index.ts +5 -5
  60. package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +0 -1
  61. package/src/trackers/impressionObserver/ImpressionObserver.ts +1 -1
  62. package/src/types.ts +10 -9
  63. package/src/utils/MinEventEmitter.ts +10 -10
  64. package/src/utils/MinEvents.ts +2 -7
  65. package/src/utils/constants/index.ts +1 -1
  66. package/src/utils/env/isNode.ts +4 -1
  67. package/src/utils/settingsValidation/storage/storageCS.ts +12 -8
  68. package/types/logger/constants.d.ts +3 -3
  69. package/types/sdkFactory/types.d.ts +2 -2
  70. package/types/services/splitApi.d.ts +1 -1
  71. package/types/services/types.d.ts +11 -0
  72. package/types/storages/pluggable/EventsCachePluggable.d.ts +2 -2
  73. package/types/storages/pluggable/ImpressionsCachePluggable.d.ts +2 -2
  74. package/types/storages/pluggable/SegmentsCachePluggable.d.ts +2 -2
  75. package/types/storages/pluggable/SplitsCachePluggable.d.ts +3 -3
  76. package/types/storages/pluggable/constants.d.ts +1 -1
  77. package/types/storages/pluggable/inMemoryWrapper.d.ts +3 -3
  78. package/types/storages/pluggable/index.d.ts +2 -2
  79. package/types/storages/pluggable/wrapperAdapter.d.ts +4 -4
  80. package/types/storages/types.d.ts +6 -6
  81. package/types/sync/streaming/SSEClient/index.d.ts +4 -3
  82. package/types/trackers/impressionObserver/ImpressionObserver.d.ts +1 -1
  83. package/types/types.d.ts +10 -10
  84. package/types/utils/MinEventEmitter.d.ts +6 -6
  85. package/types/utils/MinEvents.d.ts +3 -2
  86. package/types/utils/constants/index.d.ts +1 -1
  87. package/types/utils/env/isNode.d.ts +4 -0
  88. package/types/utils/settingsValidation/storage/storageCS.d.ts +3 -1
@@ -5,7 +5,6 @@ var tslib_1 = require("tslib");
5
5
  var Engine_1 = tslib_1.__importDefault(require("./Engine"));
6
6
  var thenable_1 = tslib_1.__importDefault(require("../utils/promise/thenable"));
7
7
  var LabelsConstants = tslib_1.__importStar(require("../utils/labels"));
8
- var lang_1 = require("../utils/lang");
9
8
  var constants_1 = require("../utils/constants");
10
9
  var treatmentException = {
11
10
  treatment: constants_1.CONTROL,
@@ -66,17 +65,17 @@ function getEvaluation(log, stringifiedSplit, key, attributes, storage) {
66
65
  var splitJSON_1 = JSON.parse(stringifiedSplit);
67
66
  var split_1 = Engine_1.default.parse(log, splitJSON_1, storage);
68
67
  evaluation = split_1.getTreatment(key, attributes, evaluateFeature);
69
- // If the storage is async, evaluation and changeNumber will return a thenable
68
+ // If the storage is async and the evaluated split uses segment, evaluation is thenable
70
69
  if (thenable_1.default(evaluation)) {
71
70
  return evaluation.then(function (result) {
72
71
  result.changeNumber = split_1.getChangeNumber();
73
- result.config = lang_1.get(splitJSON_1, "configurations." + result.treatment, null);
72
+ result.config = splitJSON_1.configurations && splitJSON_1.configurations[result.treatment] || null;
74
73
  return result;
75
74
  });
76
75
  }
77
76
  else {
78
77
  evaluation.changeNumber = split_1.getChangeNumber(); // Always sync and optional
79
- evaluation.config = lang_1.get(splitJSON_1, "configurations." + evaluation.treatment, null);
78
+ evaluation.config = splitJSON_1.configurations && splitJSON_1.configurations[evaluation.treatment] || null;
80
79
  }
81
80
  }
82
81
  return evaluation;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ERROR_LOCALHOST_MODULE_REQUIRED = exports.ERROR_HTTP = exports.ERROR_INVALID_IMPRESSIONS_MODE = exports.ERROR_EMPTY_ARRAY = exports.ERROR_EMPTY = exports.ERROR_INVALID = exports.ERROR_INVALID_KEY_OBJECT = exports.ERROR_TOO_LONG = exports.ERROR_NULL = exports.ERROR_CLIENT_DESTROYED = exports.ERROR_NOT_FINITE = exports.ERROR_SIZE_EXCEEDED = exports.ERROR_NOT_PLAIN_OBJECT = exports.ERROR_EVENT_TYPE_FORMAT = exports.ERROR_EVENTS_TRACKER = exports.ERROR_IMPRESSIONS_LISTENER = exports.ERROR_IMPRESSIONS_TRACKER = exports.ERROR_STREAMING_AUTH = exports.ERROR_STREAMING_SSE = exports.ERROR_SYNC_OFFLINE_LOADING = exports.ERROR_CLIENT_CANNOT_GET_READY = exports.ERROR_CLIENT_LISTENER = exports.ERROR_LOGLEVEL_INVALID = exports.ERROR_ENGINE_COMBINER_IFELSEIF = exports.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = exports.WARN_API_KEY = exports.WARN_STORAGE_INVALID = exports.WARN_SPLITS_FILTER_EMPTY = exports.WARN_SPLITS_FILTER_INVALID = exports.WARN_SPLITS_FILTER_IGNORED = exports.WARN_INTEGRATION_INVALID = exports.WARN_NOT_EXISTENT_TT = exports.WARN_LOWERCASE_TRAFFIC_TYPE = exports.WARN_NOT_EXISTENT_SPLIT = exports.WARN_TRIMMING = exports.WARN_CONVERTING = exports.WARN_TRIMMING_PROPERTIES = exports.WARN_SETTING_NULL = exports.SUBMITTERS_PUSH_RETRY = exports.SUBMITTERS_PUSH_FAILS = exports.STREAMING_FALLBACK = exports.STREAMING_PARSING_MESSAGE_FAILS = exports.STREAMING_PARSING_ERROR_FAILS = exports.SYNC_SPLITS_FETCH_FAILS = exports.SYNC_MYSEGMENTS_FETCH_RETRY = exports.CLIENT_NOT_READY = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = exports.ENGINE_VALUE_INVALID = exports.IMPRESSIONS_TRACKER_SUCCESS = exports.EVENTS_TRACKER_SUCCESS = exports.SYNC_STOP_POLLING = exports.SYNC_CONTINUE_POLLING = exports.SYNC_START_POLLING = exports.SUBMITTERS_PUSH = exports.SUBMITTERS_PUSH_FULL_EVENTS_QUEUE = exports.STREAMING_DISCONNECTING = exports.STREAMING_DISABLED = exports.STREAMING_CONNECTING = exports.STREAMING_RECONNECT = exports.STREAMING_REFRESH_TOKEN = exports.SYNC_SPLITS_FETCH_RETRY = exports.POLLING_STOP = exports.POLLING_START = exports.POLLING_SMART_PAUSING = exports.NEW_FACTORY = exports.NEW_SHARED_CLIENT = exports.IMPRESSION_QUEUEING = exports.IMPRESSION = exports.CLIENT_READY = exports.CLIENT_READY_FROM_CACHE = exports.SETTINGS_SPLITS_FILTER = exports.SYNC_TASK_STOP = exports.SYNC_TASK_EXECUTE = exports.SYNC_TASK_START = exports.STREAMING_NEW_MESSAGE = exports.SYNC_SPLITS_SEGMENTS = exports.SYNC_SPLITS_REMOVED = exports.SYNC_SPLITS_NEW = exports.SYNC_SPLITS_FETCH = exports.SYNC_OFFLINE_DATA = exports.RETRIEVE_MANAGER = exports.RETRIEVE_CLIENT_EXISTING = exports.RETRIEVE_CLIENT_DEFAULT = exports.CLEANUP_DEREGISTERING = exports.CLEANUP_REGISTERING = exports.ENGINE_SANITIZE = exports.ENGINE_VALUE = exports.ENGINE_MATCHER_WHITELIST = exports.ENGINE_MATCHER_STARTS_WITH = exports.ENGINE_MATCHER_STRING_INVALID = exports.ENGINE_MATCHER_STRING = exports.ENGINE_MATCHER_SEGMENT = exports.ENGINE_MATCHER_PART_OF = exports.ENGINE_MATCHER_LESS = exports.ENGINE_MATCHER_GREATER = exports.ENGINE_MATCHER_ENDS_WITH = exports.ENGINE_MATCHER_EQUAL_TO_SET = exports.ENGINE_MATCHER_EQUAL = exports.ENGINE_MATCHER_DEPENDENCY_PRE = exports.ENGINE_MATCHER_DEPENDENCY = exports.ENGINE_MATCHER_CONTAINS_STRING = exports.ENGINE_MATCHER_CONTAINS_ANY = exports.ENGINE_MATCHER_CONTAINS_ALL = exports.ENGINE_MATCHER_BOOLEAN = exports.ENGINE_MATCHER_BETWEEN = exports.ENGINE_MATCHER_ALL = exports.ENGINE_BUCKET = exports.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = exports.ENGINE_COMBINER_IFELSEIF = exports.ENGINE_COMBINER_AND = void 0;
3
+ exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ERROR_STORAGE_INVALID = exports.ERROR_LOCALHOST_MODULE_REQUIRED = exports.ERROR_HTTP = exports.ERROR_INVALID_IMPRESSIONS_MODE = exports.ERROR_EMPTY_ARRAY = exports.ERROR_EMPTY = exports.ERROR_INVALID = exports.ERROR_INVALID_KEY_OBJECT = exports.ERROR_TOO_LONG = exports.ERROR_NULL = exports.ERROR_CLIENT_DESTROYED = exports.ERROR_NOT_FINITE = exports.ERROR_SIZE_EXCEEDED = exports.ERROR_NOT_PLAIN_OBJECT = exports.ERROR_EVENT_TYPE_FORMAT = exports.ERROR_EVENTS_TRACKER = exports.ERROR_IMPRESSIONS_LISTENER = exports.ERROR_IMPRESSIONS_TRACKER = exports.ERROR_STREAMING_AUTH = exports.ERROR_STREAMING_SSE = exports.ERROR_SYNC_OFFLINE_LOADING = exports.ERROR_CLIENT_CANNOT_GET_READY = exports.ERROR_CLIENT_LISTENER = exports.ERROR_LOGLEVEL_INVALID = exports.ERROR_ENGINE_COMBINER_IFELSEIF = exports.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = exports.WARN_API_KEY = exports.WARN_SPLITS_FILTER_EMPTY = exports.WARN_SPLITS_FILTER_INVALID = exports.WARN_SPLITS_FILTER_IGNORED = exports.WARN_INTEGRATION_INVALID = exports.WARN_NOT_EXISTENT_TT = exports.WARN_LOWERCASE_TRAFFIC_TYPE = exports.WARN_NOT_EXISTENT_SPLIT = exports.WARN_TRIMMING = exports.WARN_CONVERTING = exports.WARN_TRIMMING_PROPERTIES = exports.WARN_SETTING_NULL = exports.SUBMITTERS_PUSH_RETRY = exports.SUBMITTERS_PUSH_FAILS = exports.STREAMING_FALLBACK = exports.STREAMING_PARSING_MESSAGE_FAILS = exports.STREAMING_PARSING_ERROR_FAILS = exports.SYNC_SPLITS_FETCH_FAILS = exports.SYNC_MYSEGMENTS_FETCH_RETRY = exports.CLIENT_NOT_READY = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = exports.ENGINE_VALUE_INVALID = exports.IMPRESSIONS_TRACKER_SUCCESS = exports.EVENTS_TRACKER_SUCCESS = exports.SYNC_STOP_POLLING = exports.SYNC_CONTINUE_POLLING = exports.SYNC_START_POLLING = exports.SUBMITTERS_PUSH = exports.SUBMITTERS_PUSH_FULL_EVENTS_QUEUE = exports.STREAMING_DISCONNECTING = exports.STREAMING_DISABLED = exports.STREAMING_CONNECTING = exports.STREAMING_RECONNECT = exports.STREAMING_REFRESH_TOKEN = exports.SYNC_SPLITS_FETCH_RETRY = exports.POLLING_STOP = exports.POLLING_START = exports.POLLING_SMART_PAUSING = exports.NEW_FACTORY = exports.NEW_SHARED_CLIENT = exports.IMPRESSION_QUEUEING = exports.IMPRESSION = exports.CLIENT_READY = exports.CLIENT_READY_FROM_CACHE = exports.SETTINGS_SPLITS_FILTER = exports.SYNC_TASK_STOP = exports.SYNC_TASK_EXECUTE = exports.SYNC_TASK_START = exports.STREAMING_NEW_MESSAGE = exports.SYNC_SPLITS_SEGMENTS = exports.SYNC_SPLITS_REMOVED = exports.SYNC_SPLITS_NEW = exports.SYNC_SPLITS_FETCH = exports.SYNC_OFFLINE_DATA = exports.RETRIEVE_MANAGER = exports.RETRIEVE_CLIENT_EXISTING = exports.RETRIEVE_CLIENT_DEFAULT = exports.CLEANUP_DEREGISTERING = exports.CLEANUP_REGISTERING = exports.ENGINE_SANITIZE = exports.ENGINE_VALUE = exports.ENGINE_MATCHER_WHITELIST = exports.ENGINE_MATCHER_STARTS_WITH = exports.ENGINE_MATCHER_STRING_INVALID = exports.ENGINE_MATCHER_STRING = exports.ENGINE_MATCHER_SEGMENT = exports.ENGINE_MATCHER_PART_OF = exports.ENGINE_MATCHER_LESS = exports.ENGINE_MATCHER_GREATER = exports.ENGINE_MATCHER_ENDS_WITH = exports.ENGINE_MATCHER_EQUAL_TO_SET = exports.ENGINE_MATCHER_EQUAL = exports.ENGINE_MATCHER_DEPENDENCY_PRE = exports.ENGINE_MATCHER_DEPENDENCY = exports.ENGINE_MATCHER_CONTAINS_STRING = exports.ENGINE_MATCHER_CONTAINS_ANY = exports.ENGINE_MATCHER_CONTAINS_ALL = exports.ENGINE_MATCHER_BOOLEAN = exports.ENGINE_MATCHER_BETWEEN = exports.ENGINE_MATCHER_ALL = exports.ENGINE_BUCKET = exports.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = exports.ENGINE_COMBINER_IFELSEIF = exports.ENGINE_COMBINER_AND = void 0;
4
4
  /**
5
5
  * Message codes used to trim string log messages from commons and client-side API modules,
6
6
  * in order to reduce the minimal SDK size for Browser and eventually other client-side environments.
@@ -92,9 +92,8 @@ exports.WARN_INTEGRATION_INVALID = 218;
92
92
  exports.WARN_SPLITS_FILTER_IGNORED = 219;
93
93
  exports.WARN_SPLITS_FILTER_INVALID = 220;
94
94
  exports.WARN_SPLITS_FILTER_EMPTY = 221;
95
- exports.WARN_STORAGE_INVALID = 222;
96
- exports.WARN_API_KEY = 223;
97
- exports.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = 224;
95
+ exports.WARN_API_KEY = 222;
96
+ exports.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = 223;
98
97
  exports.ERROR_ENGINE_COMBINER_IFELSEIF = 300;
99
98
  exports.ERROR_LOGLEVEL_INVALID = 301;
100
99
  exports.ERROR_CLIENT_LISTENER = 302;
@@ -119,6 +118,7 @@ exports.ERROR_EMPTY_ARRAY = 320;
119
118
  exports.ERROR_INVALID_IMPRESSIONS_MODE = 321;
120
119
  exports.ERROR_HTTP = 322;
121
120
  exports.ERROR_LOCALHOST_MODULE_REQUIRED = 323;
121
+ exports.ERROR_STORAGE_INVALID = 324;
122
122
  // Log prefixes (a.k.a. tags or categories)
123
123
  exports.LOG_PREFIX_SETTINGS = 'settings';
124
124
  exports.LOG_PREFIX_INSTANTIATION = 'Factory instantiation';
@@ -33,5 +33,6 @@ exports.codesError = [
33
33
  [c.ERROR_EMPTY_ARRAY, '%s: %s must be a non-empty array.'],
34
34
  // initialization / settings validation
35
35
  [c.ERROR_INVALID_IMPRESSIONS_MODE, c.LOG_PREFIX_SETTINGS + ': you passed an invalid "impressionsMode". It should be one of the following values: %s. Defaulting to "%s" mode.'],
36
- [c.ERROR_LOCALHOST_MODULE_REQUIRED, c.LOG_PREFIX_SETTINGS + ': an invalid value was received for "sync.localhostMode" config. A valid entity should be provided for localhost mode.']
36
+ [c.ERROR_LOCALHOST_MODULE_REQUIRED, c.LOG_PREFIX_SETTINGS + ': an invalid value was received for "sync.localhostMode" config. A valid entity should be provided for localhost mode.'],
37
+ [c.ERROR_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS + ': The provided storage is invalid.%s Fallbacking into default MEMORY storage'],
37
38
  ];
@@ -32,7 +32,6 @@ exports.codesWarn = error_1.codesError.concat([
32
32
  [c.WARN_SPLITS_FILTER_IGNORED, c.LOG_PREFIX_SETTINGS + ': split filters have been configured but will have no effect if mode is not "%s", since synchronization is being deferred to an external tool.'],
33
33
  [c.WARN_SPLITS_FILTER_INVALID, c.LOG_PREFIX_SETTINGS + ': split filter at position %s is invalid. It must be an object with a valid filter type ("byName" or "byPrefix") and a list of "values".'],
34
34
  [c.WARN_SPLITS_FILTER_EMPTY, c.LOG_PREFIX_SETTINGS + ': splitFilters configuration must be a non-empty array of filter objects.'],
35
- [c.WARN_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS + ': The provided storage is invalid. Fallbacking into default MEMORY storage'],
36
35
  [c.WARN_API_KEY, c.LOG_PREFIX_SETTINGS + ': You already have %s. We recommend keeping only one instance of the factory at all times (Singleton pattern) and reusing it throughout your application'],
37
36
  [c.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching MySegments due to an error processing %s notification: %s'],
38
37
  ]);
@@ -31,7 +31,7 @@ function sdkFactory(params) {
31
31
  // ATM, only used by InLocalStorage
32
32
  matchingKey: key_1.getMatching(settings.core.key),
33
33
  splitFiltersValidation: settings.sync.__splitFiltersValidation,
34
- // ATM, only used by CustomStorage. true for partial consumer mode
34
+ // ATM, only used by PluggableStorage
35
35
  mode: settings.mode,
36
36
  // Callback used to emit SDK_READY in consumer mode, where `syncManagerFactory` is undefined
37
37
  // or only instantiates submitters, and therefore it is not able to emit readiness events.
@@ -25,8 +25,7 @@ function InRedisStorage(options) {
25
25
  var redisClient = new RedisAdapter_1.default(log, options.options || {});
26
26
  // subscription to Redis connect event in order to emit SDK_READY event on consumer mode
27
27
  redisClient.on('connect', function () {
28
- if (onReadyCb)
29
- onReadyCb();
28
+ onReadyCb();
30
29
  });
31
30
  return {
32
31
  splits: new SplitsCacheInRedis_1.default(log, keys, redisClient),
@@ -11,7 +11,7 @@ var AbstractSplitsCacheAsync_1 = tslib_1.__importDefault(require("../AbstractSpl
11
11
  var SplitsCachePluggable = /** @class */ (function (_super) {
12
12
  tslib_1.__extends(SplitsCachePluggable, _super);
13
13
  /**
14
- * Create a SplitsCache that uses a custom storage wrapper.
14
+ * Create a SplitsCache that uses a storage wrapper.
15
15
  * @param log Logger instance.
16
16
  * @param keys Key builder.
17
17
  * @param wrapper Adapted wrapper storage.
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LOG_PREFIX = void 0;
4
- exports.LOG_PREFIX = 'storage:pluggable:';
4
+ exports.LOG_PREFIX = 'storage:pluggable: ';
@@ -4,7 +4,7 @@ exports.inMemoryWrapperFactory = void 0;
4
4
  var lang_1 = require("../../utils/lang");
5
5
  var sets_1 = require("../../utils/lang/sets");
6
6
  /**
7
- * Creates a ICustomStorageWrapper implementation that stores items in memory.
7
+ * Creates a IPluggableStorageWrapper implementation that stores items in memory.
8
8
  * The `_cache` property is the object were items are stored.
9
9
  * Intended for testing purposes.
10
10
  *
@@ -120,7 +120,7 @@ function inMemoryWrapperFactory(connDelay) {
120
120
  return Promise.resolve(sets_1.setToArray(set));
121
121
  return Promise.reject('key is not a set');
122
122
  },
123
- // always connects and close
123
+ // always connects and disconnects
124
124
  connect: function () {
125
125
  if (typeof _connDelay === 'number') {
126
126
  return new Promise(function (res) { return setTimeout(res, _connDelay); });
@@ -129,7 +129,7 @@ function inMemoryWrapperFactory(connDelay) {
129
129
  return Promise.resolve();
130
130
  }
131
131
  },
132
- close: function () { return Promise.resolve(); },
132
+ disconnect: function () { return Promise.resolve(); },
133
133
  // for testing
134
134
  _setConnDelay: function (connDelay) {
135
135
  _connDelay = connDelay;
@@ -14,7 +14,7 @@ var constants_1 = require("../../utils/constants");
14
14
  var ImpressionsCacheInMemory_1 = tslib_1.__importDefault(require("../inMemory/ImpressionsCacheInMemory"));
15
15
  var EventsCacheInMemory_1 = tslib_1.__importDefault(require("../inMemory/EventsCacheInMemory"));
16
16
  var ImpressionCountsCacheInMemory_1 = tslib_1.__importDefault(require("../inMemory/ImpressionCountsCacheInMemory"));
17
- var NO_VALID_WRAPPER = 'Expecting custom storage `wrapper` in options, but no valid wrapper instance was provided.';
17
+ var NO_VALID_WRAPPER = 'Expecting pluggable storage `wrapper` in options, but no valid wrapper instance was provided.';
18
18
  var NO_VALID_WRAPPER_INTERFACE = 'The provided wrapper instance doesn’t follow the expected interface. Check our docs.';
19
19
  /**
20
20
  * Validate pluggable storage factory options.
@@ -58,7 +58,7 @@ function PluggableStorage(options) {
58
58
  var keys = new KeyBuilderSS_1.default(prefix, metadata);
59
59
  var wrapper = wrapperAdapter_1.wrapperAdapter(log, options.wrapper);
60
60
  var isPartialConsumer = mode === constants_1.CONSUMER_PARTIAL_MODE;
61
- // emit SDK_READY event on main client
61
+ // Connects to wrapper and emits SDK_READY event on main client
62
62
  wrapperConnect(wrapper, onReadyCb);
63
63
  return {
64
64
  splits: new SplitsCachePluggable_1.SplitsCachePluggable(log, keys, wrapper),
@@ -67,20 +67,20 @@ function PluggableStorage(options) {
67
67
  impressionCounts: optimize ? new ImpressionCountsCacheInMemory_1.default() : undefined,
68
68
  events: isPartialConsumer ? promisifyEventsTrack(new EventsCacheInMemory_1.default(eventsQueueSize)) : new EventsCachePluggable_1.EventsCachePluggable(log, keys.buildEventsKey(), wrapper, metadata),
69
69
  // @TODO add telemetry cache when required
70
- // Disconnect the underlying storage, to release its resources (such as open files, database connections, etc).
70
+ // Disconnect the underlying storage
71
71
  destroy: function () {
72
- return wrapper.close();
72
+ return wrapper.disconnect();
73
73
  },
74
74
  // emits SDK_READY event on shared clients and returns a reference to the storage
75
75
  shared: function (_, onReadyCb) {
76
76
  wrapperConnect(wrapper, onReadyCb);
77
77
  return tslib_1.__assign(tslib_1.__assign({}, this), {
78
- // no-op destroy, to close the wrapper only when the main client is destroyed
78
+ // no-op destroy, to disconnect the wrapper only when the main client is destroyed
79
79
  destroy: function () { } });
80
80
  }
81
81
  };
82
82
  }
83
- PluggableStorageFactory.type = constants_1.STORAGE_CUSTOM;
83
+ PluggableStorageFactory.type = constants_1.STORAGE_PLUGGABLE;
84
84
  return PluggableStorageFactory;
85
85
  }
86
86
  exports.PluggableStorage = PluggableStorage;
@@ -19,14 +19,14 @@ exports.METHODS_TO_PROMISE_WRAP = [
19
19
  'removeItems',
20
20
  'getItems',
21
21
  'connect',
22
- 'close'
22
+ 'disconnect'
23
23
  ];
24
24
  /**
25
- * Adapter of the Custom Storage Wrapper.
25
+ * Adapter of the Pluggable Storage Wrapper.
26
26
  * Used to handle exceptions as rejected promises, in order to simplify the error handling on storages.
27
27
  *
28
28
  * @param log logger instance
29
- * @param wrapper custom storage wrapper to adapt
29
+ * @param wrapper storage wrapper to adapt
30
30
  * @returns an adapted version of the given storage wrapper
31
31
  */
32
32
  function wrapperAdapter(log, wrapper) {
@@ -23,7 +23,7 @@ function mySegmentsUpdaterFactory(log, mySegmentsFetcher, splitsCache, mySegment
23
23
  // NOTE: We only collect metrics on startup.
24
24
  // mySegmentsPromise = tracker.start(tracker.TaskNames.MY_SEGMENTS_FETCH, startingUp ? metricCollectors : false, mySegmentsPromise);
25
25
  }
26
- // @TODO if allowing custom storages, handle async execution
26
+ // @TODO if allowing pluggable storages, handle async execution
27
27
  function updateSegments(segmentsData) {
28
28
  var shouldNotifyUpdate;
29
29
  if (Array.isArray(segmentsData)) {
@@ -34,7 +34,6 @@ var SSEClient = /** @class */ (function () {
34
34
  * @throws 'EventSource API is not available. ' if EventSource is not available.
35
35
  */
36
36
  function SSEClient(settings, useHeaders, getEventSource) {
37
- // @ts-expect-error
38
37
  this.eventSource = getEventSource && getEventSource();
39
38
  // if eventSource is not available, throw an exception
40
39
  if (!this.eventSource)
@@ -70,7 +70,6 @@ var SplitsUpdateWorker = /** @class */ (function () {
70
70
  */
71
71
  SplitsUpdateWorker.prototype.killSplit = function (_a) {
72
72
  var changeNumber = _a.changeNumber, splitName = _a.splitName, defaultTreatment = _a.defaultTreatment;
73
- // @TODO handle retry due to errors in storage, once we allow the definition of custom async storages
74
73
  if (this.splitsCache.killLocally(splitName, defaultTreatment, changeNumber)) {
75
74
  // trigger an SDK_UPDATE if Split was killed locally
76
75
  this.splitsEventEmitter.emit(constants_1.SDK_SPLITS_ARRIVED, true);
@@ -35,13 +35,13 @@ var EventEmitter = /** @class */ (function () {
35
35
  EventEmitter.prototype.once = function (type, listener) {
36
36
  return this.registerListener(type, listener, true);
37
37
  };
38
- // eslint-disable-next-line
39
- EventEmitter.prototype.removeListener = function (type, listener) {
38
+ // @ts-ignore
39
+ EventEmitter.prototype.removeListener = function ( /* type: string, listener: (...args: any[]) => void */) {
40
40
  throw new Error('Method not implemented.');
41
41
  };
42
- // alias of removeListener
43
- EventEmitter.prototype.off = function (type, listener) {
44
- return this.removeListener(type, listener);
42
+ // @ts-ignore alias of removeListener
43
+ EventEmitter.prototype.off = function ( /* type: string, listener: (...args: any[]) => void */) {
44
+ return this.removeListener( /* type, listener */);
45
45
  };
46
46
  EventEmitter.prototype.emit = function (type) {
47
47
  var args = [];
@@ -31,33 +31,31 @@
31
31
  // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
32
32
  // USE OR OTHER DEALINGS IN THE SOFTWARE.
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.EventEmitter = void 0;
34
35
  var R = typeof Reflect === 'object' ? Reflect : null;
35
36
  var ReflectApply = R && typeof R.apply === 'function'
36
37
  ? R.apply
37
38
  : function ReflectApply(target, receiver, args) {
38
39
  return Function.prototype.apply.call(target, receiver, args);
39
40
  };
40
- function EventEmitter() {
41
+ exports.EventEmitter = function EventEmitter() {
41
42
  EventEmitter.init.call(this);
42
- }
43
- exports.default = EventEmitter;
44
- // Backwards-compat with node 0.10.x
45
- EventEmitter.EventEmitter = EventEmitter;
46
- EventEmitter.prototype._events = undefined;
47
- EventEmitter.prototype._eventsCount = 0;
43
+ };
44
+ exports.EventEmitter.prototype._events = undefined;
45
+ exports.EventEmitter.prototype._eventsCount = 0;
48
46
  function checkListener(listener) {
49
47
  if (typeof listener !== 'function') {
50
48
  throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
51
49
  }
52
50
  }
53
- EventEmitter.init = function () {
51
+ exports.EventEmitter.init = function () {
54
52
  if (this._events === undefined ||
55
53
  this._events === Object.getPrototypeOf(this)._events) {
56
54
  this._events = Object.create(null);
57
55
  this._eventsCount = 0;
58
56
  }
59
57
  };
60
- EventEmitter.prototype.emit = function emit(type) {
58
+ exports.EventEmitter.prototype.emit = function emit(type) {
61
59
  var args = [];
62
60
  for (var i = 1; i < arguments.length; i++)
63
61
  args.push(arguments[i]);
@@ -137,10 +135,10 @@ function _addListener(target, type, listener, prepend) {
137
135
  }
138
136
  return target;
139
137
  }
140
- EventEmitter.prototype.addListener = function addListener(type, listener) {
138
+ exports.EventEmitter.prototype.addListener = function addListener(type, listener) {
141
139
  return _addListener(this, type, listener, false);
142
140
  };
143
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
141
+ exports.EventEmitter.prototype.on = exports.EventEmitter.prototype.addListener;
144
142
  function onceWrapper() {
145
143
  if (!this.fired) {
146
144
  this.target.removeListener(this.type, this.wrapFn);
@@ -157,13 +155,13 @@ function _onceWrap(target, type, listener) {
157
155
  state.wrapFn = wrapped;
158
156
  return wrapped;
159
157
  }
160
- EventEmitter.prototype.once = function once(type, listener) {
158
+ exports.EventEmitter.prototype.once = function once(type, listener) {
161
159
  checkListener(listener);
162
160
  this.on(type, _onceWrap(this, type, listener));
163
161
  return this;
164
162
  };
165
163
  // Emits a 'removeListener' event if and only if the listener was removed.
166
- EventEmitter.prototype.removeListener =
164
+ exports.EventEmitter.prototype.removeListener =
167
165
  function removeListener(type, listener) {
168
166
  var list, events, position, i, originalListener;
169
167
  checkListener(listener);
@@ -205,8 +203,8 @@ EventEmitter.prototype.removeListener =
205
203
  }
206
204
  return this;
207
205
  };
208
- EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
209
- EventEmitter.prototype.removeAllListeners =
206
+ exports.EventEmitter.prototype.off = exports.EventEmitter.prototype.removeListener;
207
+ exports.EventEmitter.prototype.removeAllListeners =
210
208
  function removeAllListeners(type) {
211
209
  var listeners, events, i;
212
210
  events = this._events;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STORAGE_CUSTOM = exports.STORAGE_REDIS = exports.STORAGE_LOCALSTORAGE = exports.STORAGE_MEMORY = exports.CONSUMER_PARTIAL_MODE = exports.CONSUMER_MODE = exports.PRODUCER_MODE = exports.STANDALONE_MODE = exports.LOCALHOST_MODE = exports.OPTIMIZED = exports.DEBUG = exports.SPLIT_EVENT = exports.SPLIT_IMPRESSION = exports.NA = exports.UNKNOWN = exports.CONTROL_WITH_CONFIG = exports.CONTROL = void 0;
3
+ exports.STORAGE_PLUGGABLE = exports.STORAGE_REDIS = exports.STORAGE_LOCALSTORAGE = exports.STORAGE_MEMORY = exports.CONSUMER_PARTIAL_MODE = exports.CONSUMER_MODE = exports.PRODUCER_MODE = exports.STANDALONE_MODE = exports.LOCALHOST_MODE = exports.OPTIMIZED = exports.DEBUG = exports.SPLIT_EVENT = exports.SPLIT_IMPRESSION = exports.NA = exports.UNKNOWN = exports.CONTROL_WITH_CONFIG = exports.CONTROL = void 0;
4
4
  // Special treatments
5
5
  exports.CONTROL = 'control';
6
6
  exports.CONTROL_WITH_CONFIG = {
@@ -26,4 +26,4 @@ exports.CONSUMER_PARTIAL_MODE = 'consumer_partial';
26
26
  exports.STORAGE_MEMORY = 'MEMORY';
27
27
  exports.STORAGE_LOCALSTORAGE = 'LOCALSTORAGE';
28
28
  exports.STORAGE_REDIS = 'REDIS';
29
- exports.STORAGE_CUSTOM = 'CUSTOM';
29
+ exports.STORAGE_PLUGGABLE = 'PLUGGABLE';
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isNode = void 0;
4
- // We check for version truthiness since most shims will have that as empty string.
4
+ /**
5
+ * 'true' if running in Node.js, or 'false' otherwise.
6
+ * We check for version truthiness since most shims will have that as empty string.
7
+ */
5
8
  // eslint-disable-next-line no-undef
6
9
  exports.isNode = typeof process !== 'undefined' && typeof process.version !== 'undefined' && !!process.version ? true : false;
@@ -16,29 +16,32 @@ __InLocalStorageMockFactory.type = constants_2.STORAGE_MEMORY;
16
16
  *
17
17
  * @param {any} settings config object provided by the user to initialize the sdk
18
18
  *
19
- * @returns {Object} valid storage factory. It might be the default `InMemoryStorageCSFactory` if the provided storage is invalid.
19
+ * @returns {Object} valid storage factory. Default to `InMemoryStorageCSFactory` if the provided storage is invalid or not compatible with the sdk mode if mode is standalone or localhost
20
+ *
21
+ * @throws error if mode is consumer and the provided storage is not compatible
20
22
  */
21
23
  function validateStorageCS(settings) {
22
24
  var _a = settings.storage, storage = _a === void 0 ? InMemoryStorageCS_1.InMemoryStorageCSFactory : _a, log = settings.log, mode = settings.mode;
23
25
  // If an invalid storage is provided, fallback into MEMORY
24
- if (typeof storage !== 'function' || [constants_2.STORAGE_MEMORY, constants_2.STORAGE_LOCALSTORAGE, constants_2.STORAGE_CUSTOM].indexOf(storage.type) === -1) {
26
+ if (typeof storage !== 'function' || [constants_2.STORAGE_MEMORY, constants_2.STORAGE_LOCALSTORAGE, constants_2.STORAGE_PLUGGABLE].indexOf(storage.type) === -1) {
25
27
  storage = InMemoryStorageCS_1.InMemoryStorageCSFactory;
26
- log.warn(constants_1.WARN_STORAGE_INVALID);
28
+ log.error(constants_1.ERROR_STORAGE_INVALID);
27
29
  }
28
30
  // In localhost mode with InLocalStorage, fallback to a mock InLocalStorage to emit SDK_READY_FROM_CACHE
29
31
  if (mode === constants_2.LOCALHOST_MODE && storage.type === constants_2.STORAGE_LOCALSTORAGE) {
30
32
  return __InLocalStorageMockFactory;
31
33
  }
32
- // @TODO check behaviour
33
34
  if ([constants_2.LOCALHOST_MODE, constants_2.STANDALONE_MODE].indexOf(mode) === -1) {
34
35
  // Consumer modes require an async storage
35
- if (storage.type !== constants_2.STORAGE_CUSTOM)
36
- throw new Error('A CustomStorage instance is required on consumer modes');
36
+ if (storage.type !== constants_2.STORAGE_PLUGGABLE)
37
+ throw new Error('A PluggableStorage instance is required on consumer mode');
37
38
  }
38
39
  else {
39
40
  // Standalone and localhost modes require a sync storage
40
- if (storage.type === constants_2.STORAGE_CUSTOM)
41
- throw new Error('A CustomStorage instance cannot be used on standalone and localhost modes');
41
+ if (storage.type === constants_2.STORAGE_PLUGGABLE) {
42
+ storage = InMemoryStorageCS_1.InMemoryStorageCSFactory;
43
+ log.error(constants_1.ERROR_STORAGE_INVALID, [' It requires consumer mode.']);
44
+ }
42
45
  }
43
46
  // return default InMemory storage if provided one is not valid
44
47
  return storage;
@@ -1,7 +1,6 @@
1
1
  import Engine from './Engine';
2
2
  import thenable from '../utils/promise/thenable';
3
3
  import * as LabelsConstants from '../utils/labels';
4
- import { get } from '../utils/lang';
5
4
  import { CONTROL } from '../utils/constants';
6
5
  var treatmentException = {
7
6
  treatment: CONTROL,
@@ -60,17 +59,17 @@ function getEvaluation(log, stringifiedSplit, key, attributes, storage) {
60
59
  var splitJSON_1 = JSON.parse(stringifiedSplit);
61
60
  var split_1 = Engine.parse(log, splitJSON_1, storage);
62
61
  evaluation = split_1.getTreatment(key, attributes, evaluateFeature);
63
- // If the storage is async, evaluation and changeNumber will return a thenable
62
+ // If the storage is async and the evaluated split uses segment, evaluation is thenable
64
63
  if (thenable(evaluation)) {
65
64
  return evaluation.then(function (result) {
66
65
  result.changeNumber = split_1.getChangeNumber();
67
- result.config = get(splitJSON_1, "configurations." + result.treatment, null);
66
+ result.config = splitJSON_1.configurations && splitJSON_1.configurations[result.treatment] || null;
68
67
  return result;
69
68
  });
70
69
  }
71
70
  else {
72
71
  evaluation.changeNumber = split_1.getChangeNumber(); // Always sync and optional
73
- evaluation.config = get(splitJSON_1, "configurations." + evaluation.treatment, null);
72
+ evaluation.config = splitJSON_1.configurations && splitJSON_1.configurations[evaluation.treatment] || null;
74
73
  }
75
74
  }
76
75
  return evaluation;
@@ -89,9 +89,8 @@ export var WARN_INTEGRATION_INVALID = 218;
89
89
  export var WARN_SPLITS_FILTER_IGNORED = 219;
90
90
  export var WARN_SPLITS_FILTER_INVALID = 220;
91
91
  export var WARN_SPLITS_FILTER_EMPTY = 221;
92
- export var WARN_STORAGE_INVALID = 222;
93
- export var WARN_API_KEY = 223;
94
- export var STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = 224;
92
+ export var WARN_API_KEY = 222;
93
+ export var STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = 223;
95
94
  export var ERROR_ENGINE_COMBINER_IFELSEIF = 300;
96
95
  export var ERROR_LOGLEVEL_INVALID = 301;
97
96
  export var ERROR_CLIENT_LISTENER = 302;
@@ -116,6 +115,7 @@ export var ERROR_EMPTY_ARRAY = 320;
116
115
  export var ERROR_INVALID_IMPRESSIONS_MODE = 321;
117
116
  export var ERROR_HTTP = 322;
118
117
  export var ERROR_LOCALHOST_MODULE_REQUIRED = 323;
118
+ export var ERROR_STORAGE_INVALID = 324;
119
119
  // Log prefixes (a.k.a. tags or categories)
120
120
  export var LOG_PREFIX_SETTINGS = 'settings';
121
121
  export var LOG_PREFIX_INSTANTIATION = 'Factory instantiation';
@@ -29,5 +29,6 @@ export var codesError = [
29
29
  [c.ERROR_EMPTY_ARRAY, '%s: %s must be a non-empty array.'],
30
30
  // initialization / settings validation
31
31
  [c.ERROR_INVALID_IMPRESSIONS_MODE, c.LOG_PREFIX_SETTINGS + ': you passed an invalid "impressionsMode". It should be one of the following values: %s. Defaulting to "%s" mode.'],
32
- [c.ERROR_LOCALHOST_MODULE_REQUIRED, c.LOG_PREFIX_SETTINGS + ': an invalid value was received for "sync.localhostMode" config. A valid entity should be provided for localhost mode.']
32
+ [c.ERROR_LOCALHOST_MODULE_REQUIRED, c.LOG_PREFIX_SETTINGS + ': an invalid value was received for "sync.localhostMode" config. A valid entity should be provided for localhost mode.'],
33
+ [c.ERROR_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS + ': The provided storage is invalid.%s Fallbacking into default MEMORY storage'],
33
34
  ];
@@ -28,7 +28,6 @@ export var codesWarn = codesError.concat([
28
28
  [c.WARN_SPLITS_FILTER_IGNORED, c.LOG_PREFIX_SETTINGS + ': split filters have been configured but will have no effect if mode is not "%s", since synchronization is being deferred to an external tool.'],
29
29
  [c.WARN_SPLITS_FILTER_INVALID, c.LOG_PREFIX_SETTINGS + ': split filter at position %s is invalid. It must be an object with a valid filter type ("byName" or "byPrefix") and a list of "values".'],
30
30
  [c.WARN_SPLITS_FILTER_EMPTY, c.LOG_PREFIX_SETTINGS + ': splitFilters configuration must be a non-empty array of filter objects.'],
31
- [c.WARN_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS + ': The provided storage is invalid. Fallbacking into default MEMORY storage'],
32
31
  [c.WARN_API_KEY, c.LOG_PREFIX_SETTINGS + ': You already have %s. We recommend keeping only one instance of the factory at all times (Singleton pattern) and reusing it throughout your application'],
33
32
  [c.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching MySegments due to an error processing %s notification: %s'],
34
33
  ]);
@@ -27,7 +27,7 @@ export function sdkFactory(params) {
27
27
  // ATM, only used by InLocalStorage
28
28
  matchingKey: getMatching(settings.core.key),
29
29
  splitFiltersValidation: settings.sync.__splitFiltersValidation,
30
- // ATM, only used by CustomStorage. true for partial consumer mode
30
+ // ATM, only used by PluggableStorage
31
31
  mode: settings.mode,
32
32
  // Callback used to emit SDK_READY in consumer mode, where `syncManagerFactory` is undefined
33
33
  // or only instantiates submitters, and therefore it is not able to emit readiness events.
@@ -21,8 +21,7 @@ export function InRedisStorage(options) {
21
21
  var redisClient = new RedisAdapter(log, options.options || {});
22
22
  // subscription to Redis connect event in order to emit SDK_READY event on consumer mode
23
23
  redisClient.on('connect', function () {
24
- if (onReadyCb)
25
- onReadyCb();
24
+ onReadyCb();
26
25
  });
27
26
  return {
28
27
  splits: new SplitsCacheInRedis(log, keys, redisClient),
@@ -8,7 +8,7 @@ import AbstractSplitsCacheAsync from '../AbstractSplitsCacheAsync';
8
8
  var SplitsCachePluggable = /** @class */ (function (_super) {
9
9
  __extends(SplitsCachePluggable, _super);
10
10
  /**
11
- * Create a SplitsCache that uses a custom storage wrapper.
11
+ * Create a SplitsCache that uses a storage wrapper.
12
12
  * @param log Logger instance.
13
13
  * @param keys Key builder.
14
14
  * @param wrapper Adapted wrapper storage.
@@ -1 +1 @@
1
- export var LOG_PREFIX = 'storage:pluggable:';
1
+ export var LOG_PREFIX = 'storage:pluggable: ';
@@ -1,7 +1,7 @@
1
1
  import { startsWith, toNumber } from '../../utils/lang';
2
2
  import { setToArray, _Set } from '../../utils/lang/sets';
3
3
  /**
4
- * Creates a ICustomStorageWrapper implementation that stores items in memory.
4
+ * Creates a IPluggableStorageWrapper implementation that stores items in memory.
5
5
  * The `_cache` property is the object were items are stored.
6
6
  * Intended for testing purposes.
7
7
  *
@@ -117,7 +117,7 @@ export function inMemoryWrapperFactory(connDelay) {
117
117
  return Promise.resolve(setToArray(set));
118
118
  return Promise.reject('key is not a set');
119
119
  },
120
- // always connects and close
120
+ // always connects and disconnects
121
121
  connect: function () {
122
122
  if (typeof _connDelay === 'number') {
123
123
  return new Promise(function (res) { return setTimeout(res, _connDelay); });
@@ -126,7 +126,7 @@ export function inMemoryWrapperFactory(connDelay) {
126
126
  return Promise.resolve();
127
127
  }
128
128
  },
129
- close: function () { return Promise.resolve(); },
129
+ disconnect: function () { return Promise.resolve(); },
130
130
  // for testing
131
131
  _setConnDelay: function (connDelay) {
132
132
  _connDelay = connDelay;
@@ -7,11 +7,11 @@ import { EventsCachePluggable } from './EventsCachePluggable';
7
7
  import { wrapperAdapter, METHODS_TO_PROMISE_WRAP } from './wrapperAdapter';
8
8
  import { isObject } from '../../utils/lang';
9
9
  import { validatePrefix } from '../KeyBuilder';
10
- import { CONSUMER_PARTIAL_MODE, STORAGE_CUSTOM } from '../../utils/constants';
10
+ import { CONSUMER_PARTIAL_MODE, STORAGE_PLUGGABLE } from '../../utils/constants';
11
11
  import ImpressionsCacheInMemory from '../inMemory/ImpressionsCacheInMemory';
12
12
  import EventsCacheInMemory from '../inMemory/EventsCacheInMemory';
13
13
  import ImpressionCountsCacheInMemory from '../inMemory/ImpressionCountsCacheInMemory';
14
- var NO_VALID_WRAPPER = 'Expecting custom storage `wrapper` in options, but no valid wrapper instance was provided.';
14
+ var NO_VALID_WRAPPER = 'Expecting pluggable storage `wrapper` in options, but no valid wrapper instance was provided.';
15
15
  var NO_VALID_WRAPPER_INTERFACE = 'The provided wrapper instance doesn’t follow the expected interface. Check our docs.';
16
16
  /**
17
17
  * Validate pluggable storage factory options.
@@ -55,7 +55,7 @@ export function PluggableStorage(options) {
55
55
  var keys = new KeyBuilderSS(prefix, metadata);
56
56
  var wrapper = wrapperAdapter(log, options.wrapper);
57
57
  var isPartialConsumer = mode === CONSUMER_PARTIAL_MODE;
58
- // emit SDK_READY event on main client
58
+ // Connects to wrapper and emits SDK_READY event on main client
59
59
  wrapperConnect(wrapper, onReadyCb);
60
60
  return {
61
61
  splits: new SplitsCachePluggable(log, keys, wrapper),
@@ -64,19 +64,19 @@ export function PluggableStorage(options) {
64
64
  impressionCounts: optimize ? new ImpressionCountsCacheInMemory() : undefined,
65
65
  events: isPartialConsumer ? promisifyEventsTrack(new EventsCacheInMemory(eventsQueueSize)) : new EventsCachePluggable(log, keys.buildEventsKey(), wrapper, metadata),
66
66
  // @TODO add telemetry cache when required
67
- // Disconnect the underlying storage, to release its resources (such as open files, database connections, etc).
67
+ // Disconnect the underlying storage
68
68
  destroy: function () {
69
- return wrapper.close();
69
+ return wrapper.disconnect();
70
70
  },
71
71
  // emits SDK_READY event on shared clients and returns a reference to the storage
72
72
  shared: function (_, onReadyCb) {
73
73
  wrapperConnect(wrapper, onReadyCb);
74
74
  return __assign(__assign({}, this), {
75
- // no-op destroy, to close the wrapper only when the main client is destroyed
75
+ // no-op destroy, to disconnect the wrapper only when the main client is destroyed
76
76
  destroy: function () { } });
77
77
  }
78
78
  };
79
79
  }
80
- PluggableStorageFactory.type = STORAGE_CUSTOM;
80
+ PluggableStorageFactory.type = STORAGE_PLUGGABLE;
81
81
  return PluggableStorageFactory;
82
82
  }
@@ -16,14 +16,14 @@ export var METHODS_TO_PROMISE_WRAP = [
16
16
  'removeItems',
17
17
  'getItems',
18
18
  'connect',
19
- 'close'
19
+ 'disconnect'
20
20
  ];
21
21
  /**
22
- * Adapter of the Custom Storage Wrapper.
22
+ * Adapter of the Pluggable Storage Wrapper.
23
23
  * Used to handle exceptions as rejected promises, in order to simplify the error handling on storages.
24
24
  *
25
25
  * @param log logger instance
26
- * @param wrapper custom storage wrapper to adapt
26
+ * @param wrapper storage wrapper to adapt
27
27
  * @returns an adapted version of the given storage wrapper
28
28
  */
29
29
  export function wrapperAdapter(log, wrapper) {