@splitsoftware/splitio-commons 3.0.0-rc.0 → 3.0.0-rc.1

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 (180) hide show
  1. package/CHANGES.txt +8 -3
  2. package/cjs/evaluator/index.js +11 -11
  3. package/cjs/logger/constants.js +4 -4
  4. package/cjs/logger/messages/warn.js +0 -1
  5. package/cjs/readiness/constants.js +4 -4
  6. package/cjs/readiness/readinessManager.js +22 -22
  7. package/cjs/readiness/sdkReadinessManager.js +0 -16
  8. package/cjs/sdkClient/sdkLifecycle.js +2 -1
  9. package/cjs/sdkClient/trackMethod.js +2 -2
  10. package/cjs/sdkFactory/index.js +5 -5
  11. package/cjs/sdkManager/index.js +2 -2
  12. package/cjs/services/authProvider.js +67 -0
  13. package/cjs/services/secureSplitHttpClient.js +39 -0
  14. package/cjs/services/splitApi.js +7 -2
  15. package/cjs/storages/AbstractDefinitionsCacheAsync.js +51 -0
  16. package/cjs/storages/AbstractDefinitionsCacheSync.js +76 -0
  17. package/cjs/storages/KeyBuilder.js +6 -6
  18. package/cjs/storages/KeyBuilderCS.js +5 -5
  19. package/cjs/storages/KeyBuilderSS.js +2 -2
  20. package/cjs/storages/getRolloutPlan.js +3 -3
  21. package/cjs/storages/inLocalStorage/DefinitionsCacheInLocal.js +194 -0
  22. package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +9 -9
  23. package/cjs/storages/inLocalStorage/index.js +6 -6
  24. package/cjs/storages/inLocalStorage/validateCache.js +3 -3
  25. package/cjs/storages/inMemory/DefinitionsCacheInMemory.js +121 -0
  26. package/cjs/storages/inMemory/InMemoryStorage.js +4 -4
  27. package/cjs/storages/inMemory/InMemoryStorageCS.js +5 -5
  28. package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +4 -4
  29. package/cjs/storages/inMemory/SegmentsCacheInMemory.js +1 -1
  30. package/cjs/storages/inMemory/TelemetryCacheInMemory.js +3 -3
  31. package/cjs/storages/inRedis/{SplitsCacheInRedis.js → DefinitionsCacheInRedis.js} +77 -77
  32. package/cjs/storages/inRedis/index.js +2 -2
  33. package/cjs/storages/pluggable/DefinitionsCachePluggable.js +212 -0
  34. package/cjs/storages/pluggable/index.js +2 -2
  35. package/cjs/storages/setRolloutPlan.js +5 -5
  36. package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +5 -5
  37. package/cjs/sync/polling/fetchers/splitChangesFetcher.js +1 -1
  38. package/cjs/sync/polling/pollingManagerCS.js +7 -7
  39. package/cjs/sync/polling/syncTasks/definitionsSyncTask.js +1 -1
  40. package/cjs/sync/polling/updaters/definitionChangesUpdater.js +8 -8
  41. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +2 -2
  42. package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
  43. package/cjs/sync/streaming/SSEHandler/index.js +1 -1
  44. package/cjs/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.js → DefinitionsUpdateWorker.js} +15 -15
  45. package/cjs/sync/streaming/constants.js +3 -3
  46. package/cjs/sync/streaming/pushManager.js +13 -13
  47. package/cjs/sync/submitters/telemetrySubmitter.js +1 -2
  48. package/cjs/sync/syncManagerOnline.js +4 -4
  49. package/cjs/utils/Backoff.js +20 -0
  50. package/cjs/utils/lang/sets.js +4 -4
  51. package/cjs/utils/settingsValidation/url.js +1 -1
  52. package/esm/evaluator/index.js +11 -11
  53. package/esm/logger/constants.js +1 -1
  54. package/esm/logger/messages/warn.js +0 -1
  55. package/esm/readiness/constants.js +3 -3
  56. package/esm/readiness/readinessManager.js +23 -23
  57. package/esm/readiness/sdkReadinessManager.js +1 -17
  58. package/esm/sdkClient/sdkLifecycle.js +2 -1
  59. package/esm/sdkClient/trackMethod.js +2 -2
  60. package/esm/sdkFactory/index.js +6 -6
  61. package/esm/sdkManager/index.js +2 -2
  62. package/esm/services/authProvider.js +63 -0
  63. package/esm/services/secureSplitHttpClient.js +35 -0
  64. package/esm/services/splitApi.js +7 -2
  65. package/esm/storages/AbstractDefinitionsCacheAsync.js +48 -0
  66. package/esm/storages/AbstractDefinitionsCacheSync.js +71 -0
  67. package/esm/storages/KeyBuilder.js +6 -6
  68. package/esm/storages/KeyBuilderCS.js +5 -5
  69. package/esm/storages/KeyBuilderSS.js +2 -2
  70. package/esm/storages/getRolloutPlan.js +3 -3
  71. package/esm/storages/inLocalStorage/DefinitionsCacheInLocal.js +191 -0
  72. package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +6 -6
  73. package/esm/storages/inLocalStorage/index.js +6 -6
  74. package/esm/storages/inLocalStorage/validateCache.js +3 -3
  75. package/esm/storages/inMemory/DefinitionsCacheInMemory.js +118 -0
  76. package/esm/storages/inMemory/InMemoryStorage.js +4 -4
  77. package/esm/storages/inMemory/InMemoryStorageCS.js +5 -5
  78. package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +1 -1
  79. package/esm/storages/inMemory/SegmentsCacheInMemory.js +1 -1
  80. package/esm/storages/inMemory/TelemetryCacheInMemory.js +3 -3
  81. package/esm/storages/inRedis/{SplitsCacheInRedis.js → DefinitionsCacheInRedis.js} +76 -76
  82. package/esm/storages/inRedis/index.js +2 -2
  83. package/esm/storages/pluggable/DefinitionsCachePluggable.js +209 -0
  84. package/esm/storages/pluggable/index.js +2 -2
  85. package/esm/storages/setRolloutPlan.js +5 -5
  86. package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +6 -6
  87. package/esm/sync/polling/fetchers/splitChangesFetcher.js +1 -1
  88. package/esm/sync/polling/pollingManagerCS.js +4 -4
  89. package/esm/sync/polling/syncTasks/definitionsSyncTask.js +1 -1
  90. package/esm/sync/polling/updaters/definitionChangesUpdater.js +9 -9
  91. package/esm/sync/polling/updaters/mySegmentsUpdater.js +1 -1
  92. package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +2 -2
  93. package/esm/sync/streaming/SSEHandler/index.js +2 -2
  94. package/esm/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.js → DefinitionsUpdateWorker.js} +14 -14
  95. package/esm/sync/streaming/constants.js +2 -2
  96. package/esm/sync/streaming/pushManager.js +14 -14
  97. package/esm/sync/submitters/telemetrySubmitter.js +1 -2
  98. package/esm/sync/syncManagerOnline.js +3 -3
  99. package/esm/utils/Backoff.js +20 -0
  100. package/esm/utils/lang/sets.js +4 -4
  101. package/esm/utils/settingsValidation/url.js +1 -1
  102. package/package.json +1 -1
  103. package/src/dtos/types.ts +2 -2
  104. package/src/evaluator/index.ts +11 -11
  105. package/src/logger/constants.ts +1 -1
  106. package/src/logger/messages/warn.ts +0 -1
  107. package/src/readiness/constants.ts +3 -3
  108. package/src/readiness/readinessManager.ts +22 -22
  109. package/src/readiness/sdkReadinessManager.ts +1 -16
  110. package/src/readiness/types.ts +10 -16
  111. package/src/sdkClient/sdkLifecycle.ts +2 -1
  112. package/src/sdkClient/trackMethod.ts +2 -2
  113. package/src/sdkFactory/index.ts +5 -5
  114. package/src/sdkManager/index.ts +6 -6
  115. package/src/services/authProvider.ts +86 -0
  116. package/src/services/secureSplitHttpClient.ts +44 -0
  117. package/src/services/splitApi.ts +9 -3
  118. package/src/services/types.ts +4 -0
  119. package/src/storages/AbstractDefinitionsCacheAsync.ts +63 -0
  120. package/src/storages/AbstractDefinitionsCacheSync.ts +95 -0
  121. package/src/storages/KeyBuilder.ts +6 -6
  122. package/src/storages/KeyBuilderCS.ts +6 -6
  123. package/src/storages/KeyBuilderSS.ts +2 -2
  124. package/src/storages/getRolloutPlan.ts +3 -3
  125. package/src/storages/inLocalStorage/DefinitionsCacheInLocal.ts +234 -0
  126. package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +6 -6
  127. package/src/storages/inLocalStorage/index.ts +6 -6
  128. package/src/storages/inLocalStorage/validateCache.ts +4 -4
  129. package/src/storages/inMemory/DefinitionsCacheInMemory.ts +130 -0
  130. package/src/storages/inMemory/InMemoryStorage.ts +4 -4
  131. package/src/storages/inMemory/InMemoryStorageCS.ts +5 -5
  132. package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +1 -1
  133. package/src/storages/inMemory/SegmentsCacheInMemory.ts +1 -1
  134. package/src/storages/inMemory/TelemetryCacheInMemory.ts +3 -3
  135. package/src/storages/inRedis/{SplitsCacheInRedis.ts → DefinitionsCacheInRedis.ts} +67 -67
  136. package/src/storages/inRedis/index.ts +2 -2
  137. package/src/storages/pluggable/DefinitionsCachePluggable.ts +230 -0
  138. package/src/storages/pluggable/index.ts +2 -2
  139. package/src/storages/setRolloutPlan.ts +7 -7
  140. package/src/storages/types.ts +19 -19
  141. package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +8 -8
  142. package/src/sync/polling/fetchers/splitChangesFetcher.ts +3 -3
  143. package/src/sync/polling/pollingManagerCS.ts +4 -4
  144. package/src/sync/polling/syncTasks/definitionsSyncTask.ts +1 -1
  145. package/src/sync/polling/types.ts +1 -1
  146. package/src/sync/polling/updaters/definitionChangesUpdater.ts +11 -11
  147. package/src/sync/polling/updaters/mySegmentsUpdater.ts +1 -1
  148. package/src/sync/streaming/AuthClient/index.ts +2 -2
  149. package/src/sync/streaming/AuthClient/types.ts +14 -11
  150. package/src/sync/streaming/SSEClient/index.ts +2 -2
  151. package/src/sync/streaming/SSEClient/types.ts +2 -2
  152. package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +2 -2
  153. package/src/sync/streaming/SSEHandler/index.ts +2 -2
  154. package/src/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.ts → DefinitionsUpdateWorker.ts} +16 -16
  155. package/src/sync/streaming/constants.ts +2 -2
  156. package/src/sync/streaming/pushManager.ts +16 -16
  157. package/src/sync/streaming/types.ts +2 -2
  158. package/src/sync/submitters/telemetrySubmitter.ts +1 -2
  159. package/src/sync/syncManagerOnline.ts +3 -3
  160. package/src/utils/Backoff.ts +21 -0
  161. package/src/utils/inputValidation/trafficTypeExistence.ts +2 -2
  162. package/src/utils/jwt/types.ts +1 -1
  163. package/src/utils/lang/sets.ts +4 -2
  164. package/src/utils/settingsValidation/url.ts +1 -1
  165. package/types/splitio.d.ts +23 -5
  166. package/cjs/storages/AbstractSplitsCacheAsync.js +0 -51
  167. package/cjs/storages/AbstractSplitsCacheSync.js +0 -76
  168. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +0 -194
  169. package/cjs/storages/inMemory/SplitsCacheInMemory.js +0 -121
  170. package/cjs/storages/pluggable/SplitsCachePluggable.js +0 -212
  171. package/esm/storages/AbstractSplitsCacheAsync.js +0 -48
  172. package/esm/storages/AbstractSplitsCacheSync.js +0 -71
  173. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +0 -191
  174. package/esm/storages/inMemory/SplitsCacheInMemory.js +0 -118
  175. package/esm/storages/pluggable/SplitsCachePluggable.js +0 -209
  176. package/src/storages/AbstractSplitsCacheAsync.ts +0 -63
  177. package/src/storages/AbstractSplitsCacheSync.ts +0 -95
  178. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +0 -234
  179. package/src/storages/inMemory/SplitsCacheInMemory.ts +0 -130
  180. package/src/storages/pluggable/SplitsCachePluggable.ts +0 -230
@@ -1,7 +1,7 @@
1
1
  import { __extends, __spreadArray } from "tslib";
2
2
  import { isFiniteNumber, isNaNNumber } from '../../utils/lang';
3
3
  import { LOG_PREFIX } from './constants';
4
- import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync';
4
+ import { AbstractDefinitionsCacheAsync } from '../AbstractDefinitionsCacheAsync';
5
5
  import { returnDifference } from '../../utils/lang/sets';
6
6
  /**
7
7
  * Discard errors for an answer of multiple operations.
@@ -14,17 +14,17 @@ function processPipelineAnswer(results) {
14
14
  }, []) : [];
15
15
  }
16
16
  /**
17
- * ISplitsCacheAsync implementation that stores split definitions in Redis.
17
+ * IDefinitionsCacheAsync implementation that stores definitions in Redis.
18
18
  * Supported by Node.js
19
19
  */
20
- var SplitsCacheInRedis = /** @class */ (function (_super) {
21
- __extends(SplitsCacheInRedis, _super);
22
- function SplitsCacheInRedis(log, keys, redis, splitFiltersValidation) {
20
+ var DefinitionsCacheInRedis = /** @class */ (function (_super) {
21
+ __extends(DefinitionsCacheInRedis, _super);
22
+ function DefinitionsCacheInRedis(log, keys, redis, splitFiltersValidation) {
23
23
  var _this = _super.call(this) || this;
24
24
  _this.log = log;
25
25
  _this.redis = redis;
26
26
  _this.keys = keys;
27
- _this.flagSetsFilter = splitFiltersValidation ? splitFiltersValidation.groupedFilters.bySet : [];
27
+ _this.setsFilter = splitFiltersValidation ? splitFiltersValidation.groupedFilters.bySet : [];
28
28
  // There is no need to listen for redis 'error' event, because in that case ioredis calls will be rejected and handled by redis storage adapters.
29
29
  // But it is done just to avoid getting the ioredis message `Unhandled error event`.
30
30
  _this.redis.on('error', function (e) {
@@ -35,104 +35,104 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
35
35
  });
36
36
  return _this;
37
37
  }
38
- SplitsCacheInRedis.prototype._decrementCounts = function (split) {
38
+ DefinitionsCacheInRedis.prototype._decrementCounts = function (definition) {
39
39
  var _this = this;
40
- var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
40
+ var ttKey = this.keys.buildTrafficTypeKey(definition.trafficTypeName);
41
41
  return this.redis.decr(ttKey).then(function (count) {
42
42
  if (count === 0)
43
43
  return _this.redis.del(ttKey);
44
44
  });
45
45
  };
46
- SplitsCacheInRedis.prototype._incrementCounts = function (split) {
47
- var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
46
+ DefinitionsCacheInRedis.prototype._incrementCounts = function (definition) {
47
+ var ttKey = this.keys.buildTrafficTypeKey(definition.trafficTypeName);
48
48
  return this.redis.incr(ttKey);
49
49
  };
50
- SplitsCacheInRedis.prototype._updateFlagSets = function (featureFlagName, flagSetsOfRemovedFlag, flagSetsOfAddedFlag) {
50
+ DefinitionsCacheInRedis.prototype._updateSets = function (definitionName, setsOfRemovedDefinition, setsOfAddedDefinition) {
51
51
  var _this = this;
52
- var removeFromFlagSets = returnDifference(flagSetsOfRemovedFlag, flagSetsOfAddedFlag);
53
- var addToFlagSets = returnDifference(flagSetsOfAddedFlag, flagSetsOfRemovedFlag);
54
- if (this.flagSetsFilter.length > 0) {
55
- addToFlagSets = addToFlagSets.filter(function (flagSet) {
56
- return _this.flagSetsFilter.some(function (filterFlagSet) { return filterFlagSet === flagSet; });
52
+ var removeFromSets = returnDifference(setsOfRemovedDefinition, setsOfAddedDefinition);
53
+ var addToSets = returnDifference(setsOfAddedDefinition, setsOfRemovedDefinition);
54
+ if (this.setsFilter.length > 0) {
55
+ addToSets = addToSets.filter(function (set) {
56
+ return _this.setsFilter.some(function (filterSet) { return filterSet === set; });
57
57
  });
58
58
  }
59
- var items = [featureFlagName];
60
- return Promise.all(__spreadArray(__spreadArray([], removeFromFlagSets.map(function (flagSetName) { return _this.redis.srem(_this.keys.buildFlagSetKey(flagSetName), items); }), true), addToFlagSets.map(function (flagSetName) { return _this.redis.sadd(_this.keys.buildFlagSetKey(flagSetName), items); }), true));
59
+ var items = [definitionName];
60
+ return Promise.all(__spreadArray(__spreadArray([], removeFromSets.map(function (setName) { return _this.redis.srem(_this.keys.buildSetKey(setName), items); }), true), addToSets.map(function (setName) { return _this.redis.sadd(_this.keys.buildSetKey(setName), items); }), true));
61
61
  };
62
62
  /**
63
- * Add a given split.
63
+ * Add a given definition.
64
64
  * The returned promise is resolved when the operation success
65
65
  * or rejected if it fails (e.g., redis operation fails)
66
66
  */
67
- SplitsCacheInRedis.prototype.addSplit = function (split) {
67
+ DefinitionsCacheInRedis.prototype.add = function (definition) {
68
68
  var _this = this;
69
- var name = split.name;
70
- var splitKey = this.keys.buildSplitKey(name);
71
- return this.redis.get(splitKey).then(function (splitFromStorage) {
69
+ var name = definition.name;
70
+ var definitionKey = this.keys.buildDefinitionKey(name);
71
+ return this.redis.get(definitionKey).then(function (definitionFromStorage) {
72
72
  // handling parsing error
73
- var parsedPreviousSplit, stringifiedNewSplit;
73
+ var parsedPreviousDefinition, stringifiedNewDefinition;
74
74
  try {
75
- parsedPreviousSplit = splitFromStorage ? JSON.parse(splitFromStorage) : undefined;
76
- stringifiedNewSplit = JSON.stringify(split);
75
+ parsedPreviousDefinition = definitionFromStorage ? JSON.parse(definitionFromStorage) : undefined;
76
+ stringifiedNewDefinition = JSON.stringify(definition);
77
77
  }
78
78
  catch (e) {
79
79
  throw new Error('Error parsing feature flag definition: ' + e);
80
80
  }
81
- return _this.redis.set(splitKey, stringifiedNewSplit).then(function () {
81
+ return _this.redis.set(definitionKey, stringifiedNewDefinition).then(function () {
82
82
  // avoid unnecessary increment/decrement operations
83
- if (parsedPreviousSplit && parsedPreviousSplit.trafficTypeName === split.trafficTypeName)
83
+ if (parsedPreviousDefinition && parsedPreviousDefinition.trafficTypeName === definition.trafficTypeName)
84
84
  return;
85
85
  // update traffic type counts
86
- return _this._incrementCounts(split).then(function () {
87
- if (parsedPreviousSplit)
88
- return _this._decrementCounts(parsedPreviousSplit);
86
+ return _this._incrementCounts(definition).then(function () {
87
+ if (parsedPreviousDefinition)
88
+ return _this._decrementCounts(parsedPreviousDefinition);
89
89
  });
90
- }).then(function () { return _this._updateFlagSets(name, parsedPreviousSplit && parsedPreviousSplit.sets, split.sets); });
90
+ }).then(function () { return _this._updateSets(name, parsedPreviousDefinition && parsedPreviousDefinition.sets, definition.sets); });
91
91
  }).then(function () { return true; });
92
92
  };
93
93
  /**
94
- * Remove a given split.
95
- * The returned promise is resolved when the operation success, with true or false indicating if the split existed (and was removed) or not.
94
+ * Remove a given definition.
95
+ * The returned promise is resolved when the operation success, with true or false indicating if the definition existed (and was removed) or not.
96
96
  * or rejected if it fails (e.g., redis operation fails).
97
97
  */
98
- SplitsCacheInRedis.prototype.removeSplit = function (name) {
98
+ DefinitionsCacheInRedis.prototype.remove = function (name) {
99
99
  var _this = this;
100
- return this.getSplit(name).then(function (split) {
101
- if (split) {
102
- return _this._decrementCounts(split).then(function () { return _this._updateFlagSets(name, split.sets); });
100
+ return this.get(name).then(function (definition) {
101
+ if (definition) {
102
+ return _this._decrementCounts(definition).then(function () { return _this._updateSets(name, definition.sets); });
103
103
  }
104
104
  }).then(function () {
105
- return _this.redis.del(_this.keys.buildSplitKey(name)).then(function (status) { return status === 1; });
105
+ return _this.redis.del(_this.keys.buildDefinitionKey(name)).then(function (status) { return status === 1; });
106
106
  });
107
107
  };
108
108
  /**
109
- * Get split definition or null if it's not defined.
109
+ * Get definition or null if it's not defined.
110
110
  * Returned promise is rejected if redis operation fails.
111
111
  */
112
- SplitsCacheInRedis.prototype.getSplit = function (name) {
112
+ DefinitionsCacheInRedis.prototype.get = function (name) {
113
113
  if (this.redisError) {
114
114
  this.log.error(LOG_PREFIX + this.redisError);
115
115
  return Promise.reject(this.redisError);
116
116
  }
117
- return this.redis.get(this.keys.buildSplitKey(name))
118
- .then(function (maybeSplit) { return maybeSplit && JSON.parse(maybeSplit); });
117
+ return this.redis.get(this.keys.buildDefinitionKey(name))
118
+ .then(function (maybeDefinition) { return maybeDefinition && JSON.parse(maybeDefinition); });
119
119
  };
120
120
  /**
121
121
  * Set till number.
122
122
  * The returned promise is resolved when the operation success,
123
123
  * or rejected if it fails.
124
124
  */
125
- SplitsCacheInRedis.prototype.setChangeNumber = function (changeNumber) {
126
- return this.redis.set(this.keys.buildSplitsTillKey(), changeNumber + '').then(function (status) { return status === 'OK'; });
125
+ DefinitionsCacheInRedis.prototype.setChangeNumber = function (changeNumber) {
126
+ return this.redis.set(this.keys.buildDefinitionsTillKey(), changeNumber + '').then(function (status) { return status === 'OK'; });
127
127
  };
128
128
  /**
129
129
  * Get till number or -1 if it's not defined.
130
130
  * The returned promise is resolved with the changeNumber or -1 if it doesn't exist or a redis operation fails.
131
131
  * The promise will never be rejected.
132
132
  */
133
- SplitsCacheInRedis.prototype.getChangeNumber = function () {
133
+ DefinitionsCacheInRedis.prototype.getChangeNumber = function () {
134
134
  var _this = this;
135
- return this.redis.get(this.keys.buildSplitsTillKey()).then(function (value) {
135
+ return this.redis.get(this.keys.buildDefinitionsTillKey()).then(function (value) {
136
136
  var i = parseInt(value, 10);
137
137
  return isNaNNumber(i) ? -1 : i;
138
138
  }).catch(function (e) {
@@ -141,44 +141,44 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
141
141
  });
142
142
  };
143
143
  /**
144
- * Get list of all split definitions.
145
- * The returned promise is resolved with the list of split definitions,
144
+ * Get list of all definitions.
145
+ * The returned promise is resolved with the list of definitions,
146
146
  * or rejected if redis operation fails.
147
147
  */
148
148
  // @TODO we need to benchmark which is the maximun number of commands we could pipeline without kill redis performance.
149
- SplitsCacheInRedis.prototype.getAll = function () {
149
+ DefinitionsCacheInRedis.prototype.getAll = function () {
150
150
  var _this = this;
151
- return this.redis.keys(this.keys.searchPatternForSplitKeys())
151
+ return this.redis.keys(this.keys.searchPatternForDefinitionKeys())
152
152
  .then(function (listOfKeys) { return _this.redis.pipeline(listOfKeys.map(function (k) { return ['get', k]; })).exec(); })
153
153
  .then(processPipelineAnswer)
154
- .then(function (splitDefinitions) { return splitDefinitions.map(function (splitDefinition) {
155
- return JSON.parse(splitDefinition);
154
+ .then(function (definitions) { return definitions.map(function (definition) {
155
+ return JSON.parse(definition);
156
156
  }); });
157
157
  };
158
158
  /**
159
- * Get list of split names.
160
- * The returned promise is resolved with the list of split names,
159
+ * Get list of definition names.
160
+ * The returned promise is resolved with the list of names,
161
161
  * or rejected if redis operation fails.
162
162
  */
163
- SplitsCacheInRedis.prototype.getSplitNames = function () {
163
+ DefinitionsCacheInRedis.prototype.getNames = function () {
164
164
  var _this = this;
165
- return this.redis.keys(this.keys.searchPatternForSplitKeys()).then(function (listOfKeys) { return listOfKeys.map(_this.keys.extractKey); });
165
+ return this.redis.keys(this.keys.searchPatternForDefinitionKeys()).then(function (listOfKeys) { return listOfKeys.map(_this.keys.extractKey); });
166
166
  };
167
167
  /**
168
- * Get list of feature flag names related to a given list of flag set names.
169
- * The returned promise is resolved with the list of feature flag names per flag set,
168
+ * Get list of definition names related to a given list of set names.
169
+ * The returned promise is resolved with the list of names per set,
170
170
  * or rejected if the pipelined redis operation fails (e.g., timeout).
171
171
  */
172
- SplitsCacheInRedis.prototype.getNamesByFlagSets = function (flagSets) {
172
+ DefinitionsCacheInRedis.prototype.getNamesBySets = function (sets) {
173
173
  var _this = this;
174
- return this.redis.pipeline(flagSets.map(function (flagSet) { return ['smembers', _this.keys.buildFlagSetKey(flagSet)]; })).exec()
174
+ return this.redis.pipeline(sets.map(function (set) { return ['smembers', _this.keys.buildSetKey(set)]; })).exec()
175
175
  .then(function (results) { return results ? results.map(function (_a, index) {
176
176
  var e = _a[0], value = _a[1];
177
177
  if (e === null)
178
178
  return value;
179
- _this.log.error(LOG_PREFIX + "Could not read result from get members of flag set ".concat(flagSets[index], " due to an error: ").concat(e));
179
+ _this.log.error(LOG_PREFIX + "Could not read result from get members of set ".concat(sets[index], " due to an error: ").concat(e));
180
180
  }) : []; })
181
- .then(function (namesByFlagSets) { return namesByFlagSets.map(function (namesByFlagSet) { return new Set(namesByFlagSet); }); });
181
+ .then(function (namesBySets) { return namesBySets.map(function (namesBySet) { return new Set(namesBySet); }); });
182
182
  };
183
183
  /**
184
184
  * Check traffic type existence.
@@ -186,7 +186,7 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
186
186
  * In case of redis operation failure, the promise resolves with a true value, assuming that the TT might exist.
187
187
  * It will never be rejected.
188
188
  */
189
- SplitsCacheInRedis.prototype.trafficTypeExists = function (trafficType) {
189
+ DefinitionsCacheInRedis.prototype.trafficTypeExists = function (trafficType) {
190
190
  var _this = this;
191
191
  // If there is a number there should be > 0, otherwise the TT is considered as not existent.
192
192
  return this.redis.get(this.keys.buildTrafficTypeKey(trafficType))
@@ -207,34 +207,34 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
207
207
  });
208
208
  };
209
209
  // @TODO remove or implement. It is not being used.
210
- SplitsCacheInRedis.prototype.clear = function () {
210
+ DefinitionsCacheInRedis.prototype.clear = function () {
211
211
  return Promise.resolve();
212
212
  };
213
213
  /**
214
- * Fetches multiple splits definitions.
214
+ * Fetches multiple definitions.
215
215
  * Returned promise is rejected if redis operation fails.
216
216
  */
217
- SplitsCacheInRedis.prototype.getSplits = function (names) {
217
+ DefinitionsCacheInRedis.prototype.getMany = function (names) {
218
218
  var _a;
219
219
  var _this = this;
220
220
  if (this.redisError) {
221
221
  this.log.error(LOG_PREFIX + this.redisError);
222
222
  return Promise.reject(this.redisError);
223
223
  }
224
- var keys = names.map(function (name) { return _this.keys.buildSplitKey(name); });
225
- return (_a = this.redis).mget.apply(_a, keys).then(function (splitDefinitions) {
226
- var splits = {};
224
+ var keys = names.map(function (name) { return _this.keys.buildDefinitionKey(name); });
225
+ return (_a = this.redis).mget.apply(_a, keys).then(function (stringifiedDefinitions) {
226
+ var definitions = {};
227
227
  names.forEach(function (name, idx) {
228
- var split = splitDefinitions[idx];
229
- splits[name] = split && JSON.parse(split);
228
+ var definition = stringifiedDefinitions[idx];
229
+ definitions[name] = definition && JSON.parse(definition);
230
230
  });
231
- return Promise.resolve(splits);
231
+ return Promise.resolve(definitions);
232
232
  })
233
233
  .catch(function (e) {
234
234
  _this.log.error(LOG_PREFIX + "Could not grab feature flags due to an error: ".concat(e, "."));
235
235
  return Promise.reject(e);
236
236
  });
237
237
  };
238
- return SplitsCacheInRedis;
239
- }(AbstractSplitsCacheAsync));
240
- export { SplitsCacheInRedis };
238
+ return DefinitionsCacheInRedis;
239
+ }(AbstractDefinitionsCacheAsync));
240
+ export { DefinitionsCacheInRedis };
@@ -1,6 +1,6 @@
1
1
  import { validatePrefix } from '../KeyBuilder';
2
2
  import { KeyBuilderSS } from '../KeyBuilderSS';
3
- import { SplitsCacheInRedis } from './SplitsCacheInRedis';
3
+ import { DefinitionsCacheInRedis } from './DefinitionsCacheInRedis';
4
4
  import { SegmentsCacheInRedis } from './SegmentsCacheInRedis';
5
5
  import { ImpressionsCacheInRedis } from './ImpressionsCacheInRedis';
6
6
  import { EventsCacheInRedis } from './EventsCacheInRedis';
@@ -45,7 +45,7 @@ export function InRedisStorage(options) {
45
45
  telemetry.recordConfig();
46
46
  });
47
47
  return {
48
- splits: new SplitsCacheInRedis(log, keys, redisClient, settings.sync.__splitFiltersValidation),
48
+ definitions: new DefinitionsCacheInRedis(log, keys, redisClient, settings.sync.__splitFiltersValidation),
49
49
  rbSegments: new RBSegmentsCacheInRedis(log, keys, redisClient),
50
50
  segments: new SegmentsCacheInRedis(log, keys, redisClient),
51
51
  impressions: new ImpressionsCacheInRedis(log, keys.buildImpressionsKey(), redisClient, metadata),
@@ -0,0 +1,209 @@
1
+ import { __extends, __spreadArray } from "tslib";
2
+ import { isFiniteNumber, isNaNNumber } from '../../utils/lang';
3
+ import { LOG_PREFIX } from './constants';
4
+ import { AbstractDefinitionsCacheAsync } from '../AbstractDefinitionsCacheAsync';
5
+ import { returnDifference } from '../../utils/lang/sets';
6
+ /**
7
+ * IDefinitionsCacheAsync implementation for pluggable storages.
8
+ */
9
+ var DefinitionsCachePluggable = /** @class */ (function (_super) {
10
+ __extends(DefinitionsCachePluggable, _super);
11
+ /**
12
+ * Create a DefinitionsCache that uses a storage wrapper.
13
+ * @param log - Logger instance.
14
+ * @param keys - Key builder.
15
+ * @param wrapper - Adapted wrapper storage.
16
+ */
17
+ function DefinitionsCachePluggable(log, keys, wrapper, splitFiltersValidation) {
18
+ var _this = _super.call(this) || this;
19
+ _this.log = log;
20
+ _this.keys = keys;
21
+ _this.wrapper = wrapper;
22
+ _this.setsFilter = splitFiltersValidation ? splitFiltersValidation.groupedFilters.bySet : [];
23
+ return _this;
24
+ }
25
+ DefinitionsCachePluggable.prototype._decrementCounts = function (definition) {
26
+ var _this = this;
27
+ var ttKey = this.keys.buildTrafficTypeKey(definition.trafficTypeName);
28
+ return this.wrapper.decr(ttKey).then(function (count) {
29
+ if (count === 0)
30
+ return _this.wrapper.del(ttKey);
31
+ });
32
+ };
33
+ DefinitionsCachePluggable.prototype._incrementCounts = function (definition) {
34
+ var ttKey = this.keys.buildTrafficTypeKey(definition.trafficTypeName);
35
+ return this.wrapper.incr(ttKey);
36
+ };
37
+ DefinitionsCachePluggable.prototype._updateSets = function (definitionName, setsOfRemovedDefinition, setsOfAddedDefinition) {
38
+ var _this = this;
39
+ var removeFromSets = returnDifference(setsOfRemovedDefinition, setsOfAddedDefinition);
40
+ var addToSets = returnDifference(setsOfAddedDefinition, setsOfRemovedDefinition);
41
+ if (this.setsFilter.length > 0) {
42
+ addToSets = addToSets.filter(function (set) {
43
+ return _this.setsFilter.some(function (filterSet) { return filterSet === set; });
44
+ });
45
+ }
46
+ var items = [definitionName];
47
+ return Promise.all(__spreadArray(__spreadArray([], removeFromSets.map(function (setName) { return _this.wrapper.removeItems(_this.keys.buildSetKey(setName), items); }), true), addToSets.map(function (setName) { return _this.wrapper.addItems(_this.keys.buildSetKey(setName), items); }), true));
48
+ };
49
+ /**
50
+ * Add a given definition.
51
+ * The returned promise is resolved when the operation success
52
+ * or rejected if it fails (e.g., wrapper operation fails)
53
+ */
54
+ DefinitionsCachePluggable.prototype.add = function (definition) {
55
+ var _this = this;
56
+ var name = definition.name;
57
+ var definitionKey = this.keys.buildDefinitionKey(name);
58
+ return this.wrapper.get(definitionKey).then(function (definitionFromStorage) {
59
+ // handling parsing error
60
+ var parsedPreviousDefinition, stringifiedNewDefinition;
61
+ try {
62
+ parsedPreviousDefinition = definitionFromStorage ? JSON.parse(definitionFromStorage) : undefined;
63
+ stringifiedNewDefinition = JSON.stringify(definition);
64
+ }
65
+ catch (e) {
66
+ throw new Error('Error parsing feature flag definition: ' + e);
67
+ }
68
+ return _this.wrapper.set(definitionKey, stringifiedNewDefinition).then(function () {
69
+ // avoid unnecessary increment/decrement operations
70
+ if (parsedPreviousDefinition && parsedPreviousDefinition.trafficTypeName === definition.trafficTypeName)
71
+ return;
72
+ // update traffic type counts
73
+ return _this._incrementCounts(definition).then(function () {
74
+ if (parsedPreviousDefinition)
75
+ return _this._decrementCounts(parsedPreviousDefinition);
76
+ });
77
+ }).then(function () { return _this._updateSets(name, parsedPreviousDefinition && parsedPreviousDefinition.sets, definition.sets); });
78
+ }).then(function () { return true; });
79
+ };
80
+ /**
81
+ * Remove a given definition.
82
+ * The returned promise is resolved when the operation success, with a boolean indicating if the definition existed or not.
83
+ * or rejected if it fails (e.g., wrapper operation fails).
84
+ */
85
+ DefinitionsCachePluggable.prototype.remove = function (name) {
86
+ var _this = this;
87
+ return this.get(name).then(function (definition) {
88
+ if (definition) {
89
+ return _this._decrementCounts(definition).then(function () { return _this._updateSets(name, definition.sets); });
90
+ }
91
+ }).then(function () {
92
+ return _this.wrapper.del(_this.keys.buildDefinitionKey(name));
93
+ });
94
+ };
95
+ /**
96
+ * Get definition.
97
+ * The returned promise is resolved with the definition or null if it's not defined,
98
+ * or rejected if wrapper operation fails.
99
+ */
100
+ DefinitionsCachePluggable.prototype.get = function (name) {
101
+ return this.wrapper.get(this.keys.buildDefinitionKey(name))
102
+ .then(function (maybeDefinition) { return maybeDefinition && JSON.parse(maybeDefinition); });
103
+ };
104
+ /**
105
+ * Get list of definitions.
106
+ * The returned promise is resolved with a map of names to their definition or null if it's not defined,
107
+ * or rejected if wrapper operation fails.
108
+ */
109
+ DefinitionsCachePluggable.prototype.getMany = function (names) {
110
+ var _this = this;
111
+ var keys = names.map(function (name) { return _this.keys.buildDefinitionKey(name); });
112
+ return this.wrapper.getMany(keys).then(function (stringifiedDefinitions) {
113
+ var definitions = {};
114
+ names.forEach(function (name, idx) {
115
+ var definition = stringifiedDefinitions[idx];
116
+ definitions[name] = definition && JSON.parse(definition);
117
+ });
118
+ return Promise.resolve(definitions);
119
+ });
120
+ };
121
+ /**
122
+ * Get list of all definitions.
123
+ * The returned promise is resolved with the list of definitions,
124
+ * or rejected if wrapper operation fails.
125
+ */
126
+ DefinitionsCachePluggable.prototype.getAll = function () {
127
+ var _this = this;
128
+ return this.wrapper.getKeysByPrefix(this.keys.buildDefinitionKeyPrefix())
129
+ .then(function (listOfKeys) { return _this.wrapper.getMany(listOfKeys); })
130
+ .then(function (definitions) { return definitions.map(function (definition) {
131
+ return JSON.parse(definition);
132
+ }); });
133
+ };
134
+ /**
135
+ * Get list of definition names.
136
+ * The returned promise is resolved with the list of names,
137
+ * or rejected if wrapper operation fails.
138
+ */
139
+ DefinitionsCachePluggable.prototype.getNames = function () {
140
+ var _this = this;
141
+ return this.wrapper.getKeysByPrefix(this.keys.buildDefinitionKeyPrefix()).then(function (listOfKeys) { return listOfKeys.map(_this.keys.extractKey); });
142
+ };
143
+ /**
144
+ * Get list of definition names related to a given list of set names.
145
+ * The returned promise is resolved with the list of names per set.
146
+ * It never rejects (If there is a wrapper error for some set, an empty set is returned for it).
147
+ */
148
+ DefinitionsCachePluggable.prototype.getNamesBySets = function (sets) {
149
+ var _this = this;
150
+ return Promise.all(sets.map(function (set) {
151
+ var setKey = _this.keys.buildSetKey(set);
152
+ return _this.wrapper.getItems(setKey).catch(function () { return []; });
153
+ })).then(function (namesBySets) { return namesBySets.map(function (namesBySet) { return new Set(namesBySet); }); });
154
+ };
155
+ /**
156
+ * Check traffic type existence.
157
+ * The returned promise is resolved with a boolean indicating whether the TT exist or not.
158
+ * In case of wrapper operation failures, the promise resolves with a true value, assuming that the TT might exist.
159
+ * It will never be rejected.
160
+ */
161
+ DefinitionsCachePluggable.prototype.trafficTypeExists = function (trafficType) {
162
+ var _this = this;
163
+ // If there is a number there should be > 0, otherwise the TT is considered as not existent.
164
+ return this.wrapper.get(this.keys.buildTrafficTypeKey(trafficType))
165
+ .then(function (ttCount) {
166
+ if (ttCount === null)
167
+ return false; // if entry doesn't exist, means that TT doesn't exist
168
+ ttCount = parseInt(ttCount, 10);
169
+ if (!isFiniteNumber(ttCount) || ttCount < 0) {
170
+ _this.log.info(LOG_PREFIX + "Could not validate traffic type existence of ".concat(trafficType, " due to data corruption of some sorts."));
171
+ return false;
172
+ }
173
+ return ttCount > 0;
174
+ }).catch(function (e) {
175
+ _this.log.error(LOG_PREFIX + "Could not validate traffic type existence of ".concat(trafficType, " due to an error: ").concat(e, "."));
176
+ // If there is an error, bypass the validation so the event can get tracked.
177
+ return true;
178
+ });
179
+ };
180
+ /**
181
+ * Set till number.
182
+ * The returned promise is resolved when the operation success,
183
+ * or rejected if it fails (e.g., wrapper operation fails).
184
+ */
185
+ DefinitionsCachePluggable.prototype.setChangeNumber = function (changeNumber) {
186
+ return this.wrapper.set(this.keys.buildDefinitionsTillKey(), changeNumber + '');
187
+ };
188
+ /**
189
+ * Get till number or -1 if it's not defined.
190
+ * The returned promise is resolved with the changeNumber or -1 if it doesn't exist or a wrapper operation fails.
191
+ * The promise will never be rejected.
192
+ */
193
+ DefinitionsCachePluggable.prototype.getChangeNumber = function () {
194
+ var _this = this;
195
+ return this.wrapper.get(this.keys.buildDefinitionsTillKey()).then(function (value) {
196
+ var i = parseInt(value, 10);
197
+ return isNaNNumber(i) ? -1 : i;
198
+ }).catch(function (e) {
199
+ _this.log.error(LOG_PREFIX + 'Could not retrieve changeNumber from storage. Error: ' + e);
200
+ return -1;
201
+ });
202
+ };
203
+ // @TODO implement if required by DataLoader or producer mode
204
+ DefinitionsCachePluggable.prototype.clear = function () {
205
+ return Promise.resolve(true);
206
+ };
207
+ return DefinitionsCachePluggable;
208
+ }(AbstractDefinitionsCacheAsync));
209
+ export { DefinitionsCachePluggable };
@@ -1,6 +1,6 @@
1
1
  import { __assign } from "tslib";
2
2
  import { KeyBuilderSS } from '../KeyBuilderSS';
3
- import { SplitsCachePluggable } from './SplitsCachePluggable';
3
+ import { DefinitionsCachePluggable } from './DefinitionsCachePluggable';
4
4
  import { SegmentsCachePluggable } from './SegmentsCachePluggable';
5
5
  import { ImpressionsCachePluggable } from './ImpressionsCachePluggable';
6
6
  import { EventsCachePluggable } from './EventsCachePluggable';
@@ -103,7 +103,7 @@ export function PluggableStorage(options) {
103
103
  return e; // Propagate error for shared clients
104
104
  });
105
105
  return {
106
- splits: new SplitsCachePluggable(log, keys, wrapper, settings.sync.__splitFiltersValidation),
106
+ definitions: new DefinitionsCachePluggable(log, keys, wrapper, settings.sync.__splitFiltersValidation),
107
107
  rbSegments: new RBSegmentsCachePluggable(log, keys, wrapper),
108
108
  segments: new SegmentsCachePluggable(log, keys, wrapper),
109
109
  impressions: isPartialConsumer ? new ImpressionsCacheInMemory(impressionsQueueSize) : new ImpressionsCachePluggable(log, keys.buildImpressionsKey(), wrapper, metadata),
@@ -20,16 +20,16 @@ export function validateRolloutPlan(log, settings) {
20
20
  * Otherwise, the storage is handled as a server-side storage (segments is an instance of SegmentsCache).
21
21
  */
22
22
  export function setRolloutPlan(log, rolloutPlan, storage, matchingKey) {
23
- var splits = storage.splits, rbSegments = storage.rbSegments, segments = storage.segments, largeSegments = storage.largeSegments;
23
+ var definitions = storage.definitions, rbSegments = storage.rbSegments, segments = storage.segments, largeSegments = storage.largeSegments;
24
24
  var _a = rolloutPlan.splitChanges, ff = _a.ff, rbs = _a.rbs;
25
25
  log.debug("storage: set feature flags and segments".concat(matchingKey ? " for key ".concat(matchingKey) : ''));
26
- if (splits && ff) {
27
- splits.clear();
28
- splits.update(ff.d, [], ff.t);
26
+ if (definitions && ff) {
27
+ definitions.clear();
28
+ definitions.update(ff.d || [], [], ff.t);
29
29
  }
30
30
  if (rbSegments && rbs) {
31
31
  rbSegments.clear();
32
- rbSegments.update(rbs.d, [], rbs.t);
32
+ rbSegments.update(rbs.d || [], [], rbs.t);
33
33
  }
34
34
  var segmentChanges = rolloutPlan.segmentChanges;
35
35
  if (matchingKey) { // add memberships data (client-side)
@@ -1,13 +1,13 @@
1
1
  import { forOwn } from '../../../utils/lang';
2
2
  import { syncTaskFactory } from '../../syncTask';
3
3
  import { CONTROL } from '../../../utils/constants';
4
- import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED, SDK_SPLITS_CACHE_LOADED, FLAGS_UPDATE, SEGMENTS_UPDATE } from '../../../readiness/constants';
4
+ import { SDK_DEFINITIONS_ARRIVED, SDK_SEGMENTS_ARRIVED, SDK_DEFINITIONS_CACHE_LOADED, FLAGS_UPDATE, SEGMENTS_UPDATE } from '../../../readiness/constants';
5
5
  import { SYNC_OFFLINE_DATA, ERROR_SYNC_OFFLINE_LOADING } from '../../../logger/constants';
6
6
  /**
7
7
  * Offline equivalent of `splitChangesUpdaterFactory`
8
8
  */
9
9
  export function fromObjectUpdaterFactory(splitsParser, storage, readiness, settings) {
10
- var log = settings.log, splitsCache = storage.splits;
10
+ var log = settings.log, definitions = storage.definitions;
11
11
  var startingUp = true;
12
12
  return function objectUpdater() {
13
13
  var splits = [];
@@ -36,16 +36,16 @@ export function fromObjectUpdaterFactory(splitsParser, storage, readiness, setti
36
36
  });
37
37
  });
38
38
  return Promise.all([
39
- splitsCache.clear(),
40
- splitsCache.update(splits, [], Date.now())
39
+ definitions.clear(),
40
+ definitions.update(splits, [], Date.now())
41
41
  ]).then(function () {
42
- readiness.splits.emit(SDK_SPLITS_ARRIVED, { type: FLAGS_UPDATE, names: [] });
42
+ readiness.definitions.emit(SDK_DEFINITIONS_ARRIVED, { type: FLAGS_UPDATE, names: [] });
43
43
  if (startingUp) {
44
44
  startingUp = false;
45
45
  Promise.resolve(storage.validateCache ? storage.validateCache() : { initialCacheLoad: true /* Fallback: assume initial load when validateCache doesn't exist */ }).then(function (cacheMetadata) {
46
46
  // Emits SDK_READY_FROM_CACHE
47
47
  if (!cacheMetadata.initialCacheLoad) {
48
- readiness.splits.emit(SDK_SPLITS_CACHE_LOADED, cacheMetadata);
48
+ readiness.definitions.emit(SDK_DEFINITIONS_CACHE_LOADED, cacheMetadata);
49
49
  }
50
50
  // Emits SDK_READY
51
51
  readiness.segments.emit(SDK_SEGMENTS_ARRIVED, { type: SEGMENTS_UPDATE, names: [] });
@@ -58,7 +58,7 @@ export function splitChangesFetcherFactory(params) {
58
58
  lastProxyCheckTimestamp = undefined;
59
59
  return splitChangesFetcher(-1, undefined, undefined, -1)
60
60
  .then(function (splitChangesResponse) {
61
- return Promise.all([storage.splits.clear(), storage.rbSegments.clear()])
61
+ return Promise.all([storage.definitions.clear(), storage.rbSegments.clear()])
62
62
  .then(function () { return splitChangesResponse; });
63
63
  });
64
64
  }
@@ -2,9 +2,9 @@ import { forOwn } from '../../utils/lang';
2
2
  import { mySegmentsSyncTaskFactory } from './syncTasks/mySegmentsSyncTask';
3
3
  import { definitionsSyncTaskFactory } from './syncTasks/definitionsSyncTask';
4
4
  import { getMatching } from '../../utils/key';
5
- import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../../readiness/constants';
5
+ import { SDK_DEFINITIONS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../../readiness/constants';
6
6
  import { POLLING_SMART_PAUSING, POLLING_START, POLLING_STOP } from '../../logger/constants';
7
- import { usesSegmentsSync } from '../../storages/AbstractSplitsCacheSync';
7
+ import { usesSegmentsSync } from '../../storages/AbstractDefinitionsCacheSync';
8
8
  /**
9
9
  * Expose start / stop mechanism for polling data from services.
10
10
  * For client-side API with multiple clients.
@@ -29,7 +29,7 @@ export function pollingManagerCSFactory(params, definitionChangesFetcher) {
29
29
  });
30
30
  }
31
31
  // smart pausing
32
- readiness.splits.on(SDK_SPLITS_ARRIVED, function () {
32
+ readiness.definitions.on(SDK_DEFINITIONS_ARRIVED, function () {
33
33
  if (!definitionsSyncTask.isRunning())
34
34
  return; // noop if not doing polling
35
35
  var usingSegments = usesSegmentsSync(storage);
@@ -53,7 +53,7 @@ export function pollingManagerCSFactory(params, definitionChangesFetcher) {
53
53
  if (!usesSegmentsSync(storage))
54
54
  setTimeout(smartReady, 0);
55
55
  else
56
- readiness.splits.once(SDK_SPLITS_ARRIVED, smartReady);
56
+ readiness.definitions.once(SDK_DEFINITIONS_ARRIVED, smartReady);
57
57
  mySegmentsSyncTasks[matchingKey] = mySegmentsSyncTask;
58
58
  return mySegmentsSyncTask;
59
59
  }