@splitsoftware/splitio-commons 2.0.0-rc.4 → 2.0.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/CHANGES.txt +1 -0
  2. package/cjs/integrations/pluggable.js +2 -2
  3. package/cjs/logger/sdkLogger.js +2 -2
  4. package/cjs/readiness/sdkReadinessManager.js +2 -21
  5. package/cjs/sdkClient/client.js +0 -1
  6. package/cjs/sdkClient/clientAttributesDecoration.js +9 -9
  7. package/cjs/sdkClient/clientCS.js +2 -2
  8. package/cjs/services/splitApi.js +13 -13
  9. package/cjs/services/splitHttpClient.js +2 -2
  10. package/cjs/storages/AbstractSplitsCacheAsync.js +1 -4
  11. package/cjs/storages/AbstractSplitsCacheSync.js +1 -4
  12. package/cjs/storages/dataLoader.js +5 -6
  13. package/cjs/storages/findLatencyIndex.js +1 -1
  14. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +1 -6
  15. package/cjs/storages/inMemory/AttributesCacheInMemory.js +10 -10
  16. package/cjs/storages/inMemory/EventsCacheInMemory.js +1 -1
  17. package/cjs/storages/inMemory/ImpressionsCacheInMemory.js +1 -1
  18. package/cjs/storages/inMemory/InMemoryStorage.js +1 -1
  19. package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -1
  20. package/cjs/storages/inMemory/UniqueKeysCacheInMemoryCS.js +0 -5
  21. package/cjs/storages/inRedis/SplitsCacheInRedis.js +1 -3
  22. package/cjs/storages/inRedis/TelemetryCacheInRedis.js +3 -3
  23. package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
  24. package/cjs/storages/pluggable/EventsCachePluggable.js +1 -1
  25. package/cjs/storages/pluggable/ImpressionsCachePluggable.js +1 -1
  26. package/cjs/storages/pluggable/SegmentsCachePluggable.js +1 -1
  27. package/cjs/storages/pluggable/SplitsCachePluggable.js +3 -3
  28. package/cjs/storages/pluggable/TelemetryCachePluggable.js +3 -3
  29. package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
  30. package/cjs/storages/pluggable/inMemoryWrapper.js +1 -1
  31. package/cjs/storages/pluggable/index.js +1 -1
  32. package/cjs/storages/pluggable/wrapperAdapter.js +2 -2
  33. package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +1 -1
  34. package/cjs/sync/offline/syncManagerOffline.js +1 -1
  35. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
  36. package/cjs/sync/polling/updaters/segmentChangesUpdater.js +8 -8
  37. package/cjs/sync/polling/updaters/splitChangesUpdater.js +13 -13
  38. package/cjs/sync/streaming/AuthClient/index.js +2 -2
  39. package/cjs/sync/streaming/SSEClient/index.js +4 -7
  40. package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
  41. package/cjs/sync/streaming/SSEHandler/NotificationParser.js +5 -4
  42. package/cjs/sync/streaming/SSEHandler/index.js +2 -2
  43. package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +3 -3
  44. package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
  45. package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
  46. package/cjs/sync/streaming/parseUtils.js +13 -13
  47. package/cjs/sync/syncManagerOnline.js +2 -2
  48. package/cjs/sync/syncTask.js +4 -4
  49. package/cjs/trackers/eventTracker.js +2 -2
  50. package/cjs/trackers/impressionsTracker.js +5 -5
  51. package/cjs/trackers/strategy/strategyDebug.js +1 -1
  52. package/cjs/trackers/strategy/strategyNone.js +2 -2
  53. package/cjs/trackers/strategy/strategyOptimized.js +2 -2
  54. package/cjs/trackers/uniqueKeysTracker.js +3 -3
  55. package/cjs/utils/Backoff.js +0 -4
  56. package/cjs/utils/Semver.js +1 -1
  57. package/cjs/utils/base64/index.js +2 -2
  58. package/cjs/utils/decompress/index.js +4 -4
  59. package/cjs/utils/lang/binarySearch.js +2 -2
  60. package/cjs/utils/murmur3/murmur3_128.js +1 -1
  61. package/cjs/utils/murmur3/murmur3_128_x86.js +1 -1
  62. package/cjs/utils/murmur3/murmur3_64.js +1 -1
  63. package/cjs/utils/murmur3/utfx.js +10 -17
  64. package/cjs/utils/promise/wrapper.js +2 -2
  65. package/cjs/utils/settingsValidation/index.js +2 -2
  66. package/cjs/utils/settingsValidation/integrations/common.js +4 -4
  67. package/cjs/utils/settingsValidation/integrations/configurable.js +3 -3
  68. package/cjs/utils/settingsValidation/integrations/pluggable.js +2 -2
  69. package/cjs/utils/settingsValidation/logger/builtinLogger.js +1 -1
  70. package/cjs/utils/settingsValidation/logger/commons.js +1 -1
  71. package/cjs/utils/settingsValidation/logger/pluggableLogger.js +1 -1
  72. package/cjs/utils/settingsValidation/splitFilters.js +8 -11
  73. package/cjs/utils/settingsValidation/storage/storageCS.js +2 -2
  74. package/cjs/utils/settingsValidation/url.js +3 -3
  75. package/esm/integrations/pluggable.js +2 -2
  76. package/esm/logger/sdkLogger.js +2 -2
  77. package/esm/readiness/sdkReadinessManager.js +2 -21
  78. package/esm/sdkClient/client.js +0 -1
  79. package/esm/sdkClient/clientAttributesDecoration.js +9 -9
  80. package/esm/sdkClient/clientCS.js +2 -2
  81. package/esm/services/splitApi.js +13 -13
  82. package/esm/services/splitHttpClient.js +2 -2
  83. package/esm/storages/AbstractSplitsCacheAsync.js +1 -4
  84. package/esm/storages/AbstractSplitsCacheSync.js +1 -4
  85. package/esm/storages/dataLoader.js +5 -6
  86. package/esm/storages/findLatencyIndex.js +1 -1
  87. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +1 -6
  88. package/esm/storages/inMemory/AttributesCacheInMemory.js +10 -10
  89. package/esm/storages/inMemory/EventsCacheInMemory.js +1 -1
  90. package/esm/storages/inMemory/ImpressionsCacheInMemory.js +1 -1
  91. package/esm/storages/inMemory/InMemoryStorage.js +1 -1
  92. package/esm/storages/inMemory/InMemoryStorageCS.js +1 -1
  93. package/esm/storages/inMemory/UniqueKeysCacheInMemoryCS.js +0 -5
  94. package/esm/storages/inRedis/SplitsCacheInRedis.js +1 -3
  95. package/esm/storages/inRedis/TelemetryCacheInRedis.js +3 -3
  96. package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
  97. package/esm/storages/pluggable/EventsCachePluggable.js +1 -1
  98. package/esm/storages/pluggable/ImpressionsCachePluggable.js +1 -1
  99. package/esm/storages/pluggable/SegmentsCachePluggable.js +1 -1
  100. package/esm/storages/pluggable/SplitsCachePluggable.js +3 -3
  101. package/esm/storages/pluggable/TelemetryCachePluggable.js +3 -3
  102. package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
  103. package/esm/storages/pluggable/inMemoryWrapper.js +1 -1
  104. package/esm/storages/pluggable/index.js +1 -1
  105. package/esm/storages/pluggable/wrapperAdapter.js +2 -2
  106. package/esm/sync/offline/splitsParser/splitsParserFromSettings.js +1 -1
  107. package/esm/sync/offline/syncManagerOffline.js +1 -1
  108. package/esm/sync/polling/updaters/mySegmentsUpdater.js +3 -3
  109. package/esm/sync/polling/updaters/segmentChangesUpdater.js +8 -8
  110. package/esm/sync/polling/updaters/splitChangesUpdater.js +13 -13
  111. package/esm/sync/streaming/AuthClient/index.js +2 -2
  112. package/esm/sync/streaming/SSEClient/index.js +4 -7
  113. package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
  114. package/esm/sync/streaming/SSEHandler/NotificationParser.js +5 -4
  115. package/esm/sync/streaming/SSEHandler/index.js +2 -2
  116. package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +3 -3
  117. package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
  118. package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
  119. package/esm/sync/streaming/parseUtils.js +13 -13
  120. package/esm/sync/syncManagerOnline.js +2 -2
  121. package/esm/sync/syncTask.js +4 -4
  122. package/esm/trackers/eventTracker.js +2 -2
  123. package/esm/trackers/impressionsTracker.js +5 -5
  124. package/esm/trackers/strategy/strategyDebug.js +1 -1
  125. package/esm/trackers/strategy/strategyNone.js +2 -2
  126. package/esm/trackers/strategy/strategyOptimized.js +2 -2
  127. package/esm/trackers/uniqueKeysTracker.js +3 -3
  128. package/esm/utils/Backoff.js +0 -4
  129. package/esm/utils/Semver.js +1 -1
  130. package/esm/utils/base64/index.js +2 -2
  131. package/esm/utils/decompress/index.js +4 -4
  132. package/esm/utils/lang/binarySearch.js +2 -2
  133. package/esm/utils/murmur3/murmur3_128.js +1 -1
  134. package/esm/utils/murmur3/murmur3_128_x86.js +1 -1
  135. package/esm/utils/murmur3/murmur3_64.js +1 -1
  136. package/esm/utils/murmur3/utfx.js +10 -17
  137. package/esm/utils/promise/wrapper.js +2 -2
  138. package/esm/utils/settingsValidation/index.js +2 -2
  139. package/esm/utils/settingsValidation/integrations/common.js +4 -4
  140. package/esm/utils/settingsValidation/integrations/configurable.js +3 -3
  141. package/esm/utils/settingsValidation/integrations/pluggable.js +2 -2
  142. package/esm/utils/settingsValidation/logger/builtinLogger.js +1 -1
  143. package/esm/utils/settingsValidation/logger/commons.js +1 -1
  144. package/esm/utils/settingsValidation/logger/pluggableLogger.js +1 -1
  145. package/esm/utils/settingsValidation/splitFilters.js +8 -11
  146. package/esm/utils/settingsValidation/storage/storageCS.js +2 -2
  147. package/esm/utils/settingsValidation/url.js +3 -3
  148. package/package.json +3 -2
  149. package/src/dtos/types.ts +1 -1
  150. package/src/evaluator/Engine.ts +1 -1
  151. package/src/evaluator/combiners/ifelseif.ts +1 -1
  152. package/src/evaluator/condition/index.ts +1 -1
  153. package/src/evaluator/index.ts +1 -1
  154. package/src/evaluator/parser/index.ts +1 -1
  155. package/src/evaluator/types.ts +1 -1
  156. package/src/evaluator/value/index.ts +1 -1
  157. package/src/evaluator/value/sanitize.ts +1 -1
  158. package/src/integrations/pluggable.ts +3 -3
  159. package/src/integrations/types.ts +3 -2
  160. package/src/listeners/browser.ts +3 -2
  161. package/src/logger/index.ts +6 -6
  162. package/src/logger/sdkLogger.ts +4 -4
  163. package/src/logger/types.ts +11 -13
  164. package/src/readiness/readinessManager.ts +5 -4
  165. package/src/readiness/sdkReadinessManager.ts +6 -23
  166. package/src/readiness/types.ts +5 -4
  167. package/src/sdkClient/client.ts +5 -6
  168. package/src/sdkClient/clientAttributesDecoration.ts +10 -10
  169. package/src/sdkClient/clientCS.ts +5 -5
  170. package/src/sdkClient/clientInputValidation.ts +2 -1
  171. package/src/sdkClient/identity.ts +1 -1
  172. package/src/sdkClient/sdkClient.ts +2 -2
  173. package/src/sdkClient/sdkClientMethod.ts +1 -1
  174. package/src/sdkClient/sdkClientMethodCS.ts +3 -3
  175. package/src/sdkFactory/index.ts +3 -3
  176. package/src/sdkFactory/types.ts +8 -7
  177. package/src/sdkManager/index.ts +2 -1
  178. package/src/services/splitApi.ts +13 -13
  179. package/src/services/splitHttpClient.ts +2 -2
  180. package/src/storages/AbstractMySegmentsCacheSync.ts +1 -1
  181. package/src/storages/AbstractSplitsCacheAsync.ts +1 -4
  182. package/src/storages/AbstractSplitsCacheSync.ts +1 -4
  183. package/src/storages/dataLoader.ts +7 -8
  184. package/src/storages/findLatencyIndex.ts +1 -1
  185. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +1 -6
  186. package/src/storages/inMemory/AttributesCacheInMemory.ts +11 -11
  187. package/src/storages/inMemory/EventsCacheInMemory.ts +2 -2
  188. package/src/storages/inMemory/ImpressionsCacheInMemory.ts +5 -5
  189. package/src/storages/inMemory/InMemoryStorage.ts +1 -1
  190. package/src/storages/inMemory/InMemoryStorageCS.ts +1 -1
  191. package/src/storages/inMemory/UniqueKeysCacheInMemoryCS.ts +0 -5
  192. package/src/storages/inRedis/EventsCacheInRedis.ts +1 -1
  193. package/src/storages/inRedis/ImpressionsCacheInRedis.ts +2 -2
  194. package/src/storages/inRedis/SplitsCacheInRedis.ts +1 -3
  195. package/src/storages/inRedis/TelemetryCacheInRedis.ts +3 -3
  196. package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +1 -1
  197. package/src/storages/pluggable/EventsCachePluggable.ts +2 -2
  198. package/src/storages/pluggable/ImpressionsCachePluggable.ts +3 -3
  199. package/src/storages/pluggable/SegmentsCachePluggable.ts +1 -1
  200. package/src/storages/pluggable/SplitsCachePluggable.ts +3 -3
  201. package/src/storages/pluggable/TelemetryCachePluggable.ts +3 -3
  202. package/src/storages/pluggable/UniqueKeysCachePluggable.ts +1 -1
  203. package/src/storages/pluggable/inMemoryWrapper.ts +1 -1
  204. package/src/storages/pluggable/index.ts +1 -1
  205. package/src/storages/pluggable/wrapperAdapter.ts +2 -2
  206. package/src/storages/types.ts +51 -68
  207. package/src/storages/utils.ts +3 -2
  208. package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +3 -3
  209. package/src/sync/offline/syncManagerOffline.ts +1 -1
  210. package/src/sync/polling/updaters/mySegmentsUpdater.ts +3 -3
  211. package/src/sync/polling/updaters/segmentChangesUpdater.ts +8 -8
  212. package/src/sync/polling/updaters/splitChangesUpdater.ts +13 -13
  213. package/src/sync/streaming/AuthClient/index.ts +2 -2
  214. package/src/sync/streaming/SSEClient/index.ts +4 -7
  215. package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +1 -1
  216. package/src/sync/streaming/SSEHandler/NotificationParser.ts +5 -4
  217. package/src/sync/streaming/SSEHandler/index.ts +2 -2
  218. package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +3 -3
  219. package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +2 -2
  220. package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +4 -4
  221. package/src/sync/streaming/parseUtils.ts +13 -13
  222. package/src/sync/streaming/types.ts +2 -2
  223. package/src/sync/submitters/impressionsSubmitter.ts +2 -2
  224. package/src/sync/submitters/telemetrySubmitter.ts +4 -3
  225. package/src/sync/submitters/types.ts +1 -1
  226. package/src/sync/syncManagerOnline.ts +2 -2
  227. package/src/sync/syncTask.ts +4 -4
  228. package/src/trackers/eventTracker.ts +4 -3
  229. package/src/trackers/impressionObserver/ImpressionObserver.ts +4 -4
  230. package/src/trackers/impressionObserver/buildKey.ts +2 -2
  231. package/src/trackers/impressionObserver/impressionObserverCS.ts +2 -2
  232. package/src/trackers/impressionObserver/impressionObserverSS.ts +2 -2
  233. package/src/trackers/impressionObserver/types.ts +2 -2
  234. package/src/trackers/impressionsTracker.ts +8 -7
  235. package/src/trackers/strategy/strategyDebug.ts +3 -3
  236. package/src/trackers/strategy/strategyNone.ts +4 -4
  237. package/src/trackers/strategy/strategyOptimized.ts +5 -5
  238. package/src/trackers/types.ts +5 -5
  239. package/src/trackers/uniqueKeysTracker.ts +3 -3
  240. package/src/types.ts +37 -1355
  241. package/src/utils/Backoff.ts +0 -4
  242. package/src/utils/MinEventEmitter.ts +2 -3
  243. package/src/utils/MinEvents.ts +2 -2
  244. package/src/utils/Semver.ts +1 -1
  245. package/src/utils/base64/index.ts +2 -2
  246. package/src/utils/constants/index.ts +9 -10
  247. package/src/utils/decompress/index.ts +4 -4
  248. package/src/utils/inputValidation/attributes.ts +1 -1
  249. package/src/utils/inputValidation/eventProperties.ts +1 -1
  250. package/src/utils/inputValidation/key.ts +1 -1
  251. package/src/utils/inputValidation/preloadedData.ts +1 -2
  252. package/src/utils/inputValidation/trafficTypeExistence.ts +2 -2
  253. package/src/utils/key/index.ts +1 -1
  254. package/src/utils/lang/binarySearch.ts +2 -2
  255. package/src/utils/murmur3/murmur3_128.ts +1 -1
  256. package/src/utils/murmur3/murmur3_128_x86.ts +1 -1
  257. package/src/utils/murmur3/murmur3_64.ts +1 -1
  258. package/src/utils/murmur3/utfx.ts +10 -17
  259. package/src/utils/promise/wrapper.ts +2 -2
  260. package/src/utils/settingsValidation/consent.ts +2 -2
  261. package/src/utils/settingsValidation/impressionsMode.ts +1 -1
  262. package/src/utils/settingsValidation/index.ts +2 -2
  263. package/src/utils/settingsValidation/integrations/common.ts +4 -4
  264. package/src/utils/settingsValidation/integrations/configurable.ts +3 -3
  265. package/src/utils/settingsValidation/integrations/pluggable.ts +2 -2
  266. package/src/utils/settingsValidation/logger/builtinLogger.ts +3 -3
  267. package/src/utils/settingsValidation/logger/commons.ts +3 -3
  268. package/src/utils/settingsValidation/logger/pluggableLogger.ts +3 -3
  269. package/src/utils/settingsValidation/splitFilters.ts +9 -12
  270. package/src/utils/settingsValidation/storage/storageCS.ts +5 -4
  271. package/src/utils/settingsValidation/url.ts +3 -3
  272. package/types/splitio.d.ts +1019 -1381
@@ -8,10 +8,9 @@
8
8
  */
9
9
  /**
10
10
  * Encodes UTF8 code points to UTF8 bytes.
11
- * @param {(!function():number|null) | number} src Code points source, either as a function returning the next code point
11
+ * @param src - Code points source, either as a function returning the next code point
12
12
  * respectively `null` if there are no more code points left or a single numeric code point.
13
- * @param {!function(number)} dst Bytes destination as a function successively called with the next byte
14
- * @expose
13
+ * @param dst - Bytes destination as a function successively called with the next byte
15
14
  */
16
15
  function encodeUTF8(src, dst) {
17
16
  var cp = null;
@@ -31,11 +30,10 @@ function encodeUTF8(src, dst) {
31
30
  }
32
31
  /**
33
32
  * Converts UTF16 characters to UTF8 code points.
34
- * @param {!function():number|null} src Characters source as a function returning the next char code respectively
33
+ * @param src - Characters source as a function returning the next char code respectively
35
34
  * `null` if there are no more characters left.
36
- * @param {!function(number)} dst Code points destination as a function successively called with each converted code
35
+ * @param dst - Code points destination as a function successively called with each converted code
37
36
  * point.
38
- * @expose
39
37
  */
40
38
  function UTF16toUTF8(src, dst) {
41
39
  var c1, c2 = null;
@@ -59,10 +57,9 @@ function UTF16toUTF8(src, dst) {
59
57
  }
60
58
  /**
61
59
  * Converts and encodes UTF16 characters to UTF8 bytes.
62
- * @param {!function():number|null} src Characters source as a function returning the next char code respectively `null`
60
+ * @param src - Characters source as a function returning the next char code respectively `null`
63
61
  * if there are no more characters left.
64
- * @param {!function(number)} dst Bytes destination as a function successively called with the next byte.
65
- * @expose
62
+ * @param dst - Bytes destination as a function successively called with the next byte.
66
63
  */
67
64
  export function encodeUTF16toUTF8(src, dst) {
68
65
  UTF16toUTF8(src, function (cp) {
@@ -71,17 +68,14 @@ export function encodeUTF16toUTF8(src, dst) {
71
68
  }
72
69
  /**
73
70
  * String.fromCharCode reference for compile time renaming.
74
- * @type {!function(...[number]):string}
75
- * @inner
76
71
  */
77
72
  var stringFromCharCode = String.fromCharCode;
78
73
  /**
79
74
  * Creates a source function for a string.
80
- * @param {string} s String to read from
81
- * @returns {!function():number|null} Source function returning the next char code respectively `null` if there are
75
+ * @param s - String to read from
76
+ * @returns Source function returning the next char code respectively `null` if there are
82
77
  * no more characters left.
83
- * @throws {TypeError} If the argument is invalid
84
- * @expose
78
+ * @throws If the argument is invalid
85
79
  */
86
80
  export function stringSource(s) {
87
81
  if (typeof s !== 'string')
@@ -93,9 +87,8 @@ export function stringSource(s) {
93
87
  }
94
88
  /**
95
89
  * Creates a destination function for a string.
96
- * @returns {function(number=):undefined|string} Destination function successively called with the next char code.
90
+ * @returns Destination function successively called with the next char code.
97
91
  * Returns the final string when called without arguments.
98
- * @expose
99
92
  */
100
93
  export function stringDestination() {
101
94
  var cs = [], ps = [];
@@ -11,8 +11,8 @@
11
11
  * - If the wrapped promise is rejected when using native async/await syntax, the `defaultOnRejected` handler is invoked
12
12
  * and neither the catch block nor the remaining try block are executed.
13
13
  *
14
- * @param customPromise promise to wrap
15
- * @param defaultOnRejected default onRejected function
14
+ * @param customPromise - promise to wrap
15
+ * @param defaultOnRejected - default onRejected function
16
16
  * @returns a promise that doesn't need to be handled for rejection (except when using async/await syntax) and
17
17
  * includes a method named `hasOnFulfilled` that returns true if the promise has attached an onFulfilled handler.
18
18
  */
@@ -80,8 +80,8 @@ function fromSecondsToMillis(n) {
80
80
  * Validates the given config and use it to build a settings object.
81
81
  * NOTE: it doesn't validate the SDK Key. Call `validateApiKey` or `validateAndTrackApiKey` for that after settings validation.
82
82
  *
83
- * @param config user defined configuration
84
- * @param validationParams defaults and fields validators used to validate and creates a settings object from a given config
83
+ * @param config - user defined configuration
84
+ * @param validationParams - defaults and fields validators used to validate and creates a settings object from a given config
85
85
  */
86
86
  export function settingsValidation(config, validationParams) {
87
87
  var defaults = validationParams.defaults, runtime = validationParams.runtime, storage = validationParams.storage, integrations = validationParams.integrations, logger = validationParams.logger, consent = validationParams.consent, flagSpec = validationParams.flagSpec;
@@ -2,11 +2,11 @@ import { WARN_INTEGRATION_INVALID } from '../../../logger/constants';
2
2
  /**
3
3
  * This function validates `settings.integrations` object
4
4
  *
5
- * @param {any} settings config object provided by the user to initialize the sdk
6
- * @param {function} integrationValidator filter used to remove invalid integration items
7
- * @param {string} extraWarning optional string used to better describe why an item might be invalid
5
+ * @param settings - config object provided by the user to initialize the sdk
6
+ * @param integrationValidator - filter used to remove invalid integration items
7
+ * @param extraWarning - optional string used to better describe why an item might be invalid
8
8
  *
9
- * @returns {Array} array of valid integration items. The array might be empty if `settings` object does not have valid integrations.
9
+ * @returns array of valid integration items. The array might be empty if `settings` object does not have valid integrations.
10
10
  */
11
11
  export function validateIntegrations(settings, integrationValidator, extraWarning) {
12
12
  var integrations = settings.integrations, log = settings.log;
@@ -3,10 +3,10 @@ import { isString } from '../../lang';
3
3
  /**
4
4
  * This function validates `settings.integrations` object that consists of a list of configuration items, used by the isomorphic JS SDK.
5
5
  *
6
- * @param {any} settings config object provided by the user to initialize the sdk
7
- * @param {Array<string>} validIntegrationTypes list of integration types to filter from `settings.integrations`
6
+ * @param settings - config object provided by the user to initialize the sdk
7
+ * @param validIntegrationTypes - list of integration types to filter from `settings.integrations`
8
8
  *
9
- * @returns {Array} array of valid integration items. The array might be empty if `settings` object does not have valid integrations.
9
+ * @returns array of valid integration items. The array might be empty if `settings` object does not have valid integrations.
10
10
  */
11
11
  export function validateConfigurableIntegrations(settings, validIntegrationTypes) {
12
12
  if (validIntegrationTypes === void 0) { validIntegrationTypes = []; }
@@ -2,9 +2,9 @@ import { validateIntegrations } from './common';
2
2
  /**
3
3
  * This function validates `settings.integrations` object that consists of a list of pluggable integration factories.
4
4
  *
5
- * @param {any} settings config object provided by the user to initialize the sdk
5
+ * @param settings - config object provided by the user to initialize the sdk
6
6
  *
7
- * @returns {Array} array of valid integration factories. The array might be empty if `settings` object does not have valid integrations.
7
+ * @returns array of valid integration factories. The array might be empty if `settings` object does not have valid integrations.
8
8
  */
9
9
  export function validatePluggableIntegrations(settings) {
10
10
  return validateIntegrations(settings, function (integration) { return typeof integration === 'function'; }, 'Integration items must be functions that initialize the integrations');
@@ -28,7 +28,7 @@ else if (isLogLevelString(initialState)) {
28
28
  /**
29
29
  * Validates the `debug` property at config and use it to set the log level.
30
30
  *
31
- * @param settings user config object, with an optional `debug` property of type boolean or string log level.
31
+ * @param settings - user config object, with an optional `debug` property of type boolean or string log level.
32
32
  * @returns a logger instance with the log level at `settings.debug`. If `settings.debug` is invalid or not provided, `initialLogLevel` is used.
33
33
  */
34
34
  export function validateLogger(settings) {
@@ -3,7 +3,7 @@ import { LogLevels, isLogLevelString } from '../../../logger';
3
3
  * Returns the LogLevel for the given debugValue or undefined if it is invalid,
4
4
  * i.e., if the debugValue is not a boolean or LogLevel string.
5
5
  *
6
- * @param debugValue debug value at config
6
+ * @param debugValue - debug value at config
7
7
  * @returns LogLevel of the given debugValue or undefined if the provided value is invalid
8
8
  */
9
9
  export function getLogLevel(debugValue) {
@@ -8,7 +8,7 @@ var initialLogLevel = LogLevels.NONE;
8
8
  /**
9
9
  * Validates the `debug` property at config and use it to set the logger.
10
10
  *
11
- * @param settings user config object, with an optional `debug` property of type boolean, string log level or a Logger object.
11
+ * @param settings - user config object, with an optional `debug` property of type boolean, string log level or a Logger object.
12
12
  * @returns a logger instance, that might be: the provided logger at `settings.debug`, or one with the given `debug` log level,
13
13
  * or one with NONE log level if `debug` is not defined or invalid.
14
14
  */
@@ -33,9 +33,9 @@ function validateFilterType(maybeFilterType) {
33
33
  /**
34
34
  * Validate, deduplicate and sort a given list of filter values.
35
35
  *
36
- * @param {string} type filter type string used for log messages
37
- * @param {string[]} values list of values to validate, deduplicate and sort
38
- * @param {number} maxLength
36
+ * @param type - filter type string used for log messages
37
+ * @param values - list of values to validate, deduplicate and sort
38
+ * @param maxLength - max length allowed for the list of values
39
39
  * @returns list of valid, unique and alphabetically sorted non-empty strings. The list is empty if `values` param is not a non-empty array or all its values are invalid.
40
40
  *
41
41
  * @throws Error if the sanitized list exceeds the length indicated by `maxLength`
@@ -64,7 +64,7 @@ function validateSplitFilter(log, type, values, maxLength) {
64
64
  * - '&prefixes=<comma-separated-values>': if only `byName` filter is undefined
65
65
  * - '&names=<comma-separated-values>&prefixes=<comma-separated-values>': if no one is undefined
66
66
  *
67
- * @param {Object} groupedFilters object of filters. Each filter must be a list of valid, unique and ordered string values.
67
+ * @param groupedFilters - object of filters. Each filter must be a list of valid, unique and ordered string values.
68
68
  * @returns null or string with the `split filter query` component of the URL.
69
69
  */
70
70
  function queryStringBuilder(groupedFilters) {
@@ -80,15 +80,12 @@ function queryStringBuilder(groupedFilters) {
80
80
  /**
81
81
  * Sanitizes set names list taking into account:
82
82
  * - It should be lowercase
83
- * - Must adhere the following regular expression /^[a-z0-9][_a-z0-9]{0,49}$/ that means
83
+ * - Must adhere the following regular expression `/^[a-z0-9][_a-z0-9]{0,49}$/` that means
84
84
  * - must start with a letter or number
85
85
  * - Be in lowercase
86
86
  * - Be alphanumeric
87
87
  * - have a max length of 50 characters
88
88
  *
89
- * @param {ILogger} log
90
- * @param {string[]} flagSets
91
- * @param {string} method
92
89
  * @returns sanitized list of set names
93
90
  */
94
91
  function sanitizeFlagSets(log, flagSets, method) {
@@ -117,9 +114,9 @@ function configuredFilter(validFilters, filterType) {
117
114
  /**
118
115
  * Validates `splitFilters` configuration object and parses it into a query string for filtering splits on `/splitChanges` fetch.
119
116
  *
120
- * @param {ILogger} log logger
121
- * @param {any} maybeSplitFilters split filters configuration param provided by the user
122
- * @param {string} mode settings mode
117
+ * @param log - logger
118
+ * @param maybeSplitFilters - split filters configuration param provided by the user
119
+ * @param mode - settings mode
123
120
  * @returns it returns an object with the following properties:
124
121
  * - `validFilters`: the validated `splitFilters` configuration object defined by the user.
125
122
  * - `queryString`: the parsed split filter query. it is null if all filters are invalid or all values in filters are invalid.
@@ -10,9 +10,9 @@ __InLocalStorageMockFactory.type = STORAGE_MEMORY;
10
10
  /**
11
11
  * This function validates `settings.storage` object
12
12
  *
13
- * @param {any} settings config object provided by the user to initialize the sdk
13
+ * @param settings - config object provided by the user to initialize the sdk
14
14
  *
15
- * @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
15
+ * @returns 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
16
16
  *
17
17
  * @throws error if mode is consumer and the provided storage is not compatible
18
18
  */
@@ -6,9 +6,9 @@ var streamingEndpointMatcher = /^\/(sse|event-stream)/;
6
6
  * Get URL based on a given target (path).
7
7
  * ATM, it is only used for testing purposes.
8
8
  *
9
- * @param settings settings object
10
- * @param target url path
11
- * @return complete url
9
+ * @param settings - settings object
10
+ * @param target - url path
11
+ * @returns complete url
12
12
  */
13
13
  export function url(settings, target) {
14
14
  if (telemetryEndpointMatcher.test(target)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "2.0.0-rc.4",
3
+ "version": "2.0.0-rc.6",
4
4
  "description": "Split JavaScript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "scripts": {
19
19
  "check": "npm run check:lint && npm run check:types",
20
- "check:lint": "eslint src --ext .js,.ts",
20
+ "check:lint": "eslint src types --ext .js,.ts",
21
21
  "check:types": "tsc --noEmit",
22
22
  "build": "npm run build:cjs && npm run build:esm",
23
23
  "build:esm": "rimraf esm && tsc -m es2015 --outDir esm",
@@ -67,6 +67,7 @@
67
67
  "eslint": "^8.48.0",
68
68
  "eslint-plugin-compat": "^6.0.1",
69
69
  "eslint-plugin-import": "^2.25.3",
70
+ "eslint-plugin-tsdoc": "^0.3.0",
70
71
  "fetch-mock": "^9.11.0",
71
72
  "ioredis": "^4.28.0",
72
73
  "jest": "^27.2.3",
package/src/dtos/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SplitIO } from '../types';
1
+ import SplitIO from '../../types/splitio';
2
2
 
3
3
  export type MaybeThenable<T> = T | Promise<T>
4
4
 
@@ -5,7 +5,7 @@ import { thenable } from '../utils/promise/thenable';
5
5
  import { EXCEPTION, NO_CONDITION_MATCH, SPLIT_ARCHIVED, SPLIT_KILLED } from '../utils/labels';
6
6
  import { CONTROL } from '../utils/constants';
7
7
  import { ISplit, MaybeThenable } from '../dtos/types';
8
- import { SplitIO } from '../types';
8
+ import SplitIO from '../../types/splitio';
9
9
  import { IStorageAsync, IStorageSync } from '../storages/types';
10
10
  import { IEvaluation, IEvaluationResult, IEvaluator, ISplitEvaluator } from './types';
11
11
  import { ILogger } from '../logger/types';
@@ -3,7 +3,7 @@ import { ILogger } from '../../logger/types';
3
3
  import { thenable } from '../../utils/promise/thenable';
4
4
  import { UNSUPPORTED_MATCHER_TYPE } from '../../utils/labels';
5
5
  import { CONTROL } from '../../utils/constants';
6
- import { SplitIO } from '../../types';
6
+ import SplitIO from '../../../types/splitio';
7
7
  import { IEvaluation, IEvaluator, ISplitEvaluator } from '../types';
8
8
  import { ENGINE_COMBINER_IFELSEIF, ENGINE_COMBINER_IFELSEIF_NO_TREATMENT, ERROR_ENGINE_COMBINER_IFELSEIF } from '../../logger/constants';
9
9
 
@@ -3,7 +3,7 @@ import { thenable } from '../../utils/promise/thenable';
3
3
  import { NOT_IN_SPLIT } from '../../utils/labels';
4
4
  import { MaybeThenable } from '../../dtos/types';
5
5
  import { IEvaluation, IEvaluator, ISplitEvaluator } from '../types';
6
- import { SplitIO } from '../../types';
6
+ import SplitIO from '../../../types/splitio';
7
7
  import { ILogger } from '../../logger/types';
8
8
 
9
9
  // Build Evaluation object if and only if matchingResult is true
@@ -5,7 +5,7 @@ import { CONTROL } from '../utils/constants';
5
5
  import { ISplit, MaybeThenable } from '../dtos/types';
6
6
  import { IStorageAsync, IStorageSync } from '../storages/types';
7
7
  import { IEvaluationResult } from './types';
8
- import { SplitIO } from '../types';
8
+ import SplitIO from '../../types/splitio';
9
9
  import { ILogger } from '../logger/types';
10
10
  import { returnSetsUnion, setToArray } from '../utils/lang/sets';
11
11
  import { WARN_FLAGSET_WITHOUT_FLAGS } from '../logger/constants';
@@ -9,7 +9,7 @@ import { thenable } from '../../utils/promise/thenable';
9
9
  import { IEvaluator, IMatcherDto, ISplitEvaluator } from '../types';
10
10
  import { ISplitCondition, MaybeThenable } from '../../dtos/types';
11
11
  import { IStorageAsync, IStorageSync } from '../../storages/types';
12
- import { SplitIO } from '../../types';
12
+ import SplitIO from '../../../types/splitio';
13
13
  import { ILogger } from '../../logger/types';
14
14
  import { ENGINE_MATCHER_ERROR, ENGINE_MATCHER_RESULT } from '../../logger/constants';
15
15
 
@@ -1,6 +1,6 @@
1
1
  import { IBetweenMatcherData, IBetweenStringMatcherData, IDependencyMatcherData, MaybeThenable } from '../dtos/types';
2
2
  import { IStorageAsync, IStorageSync } from '../storages/types';
3
- import { SplitIO } from '../types';
3
+ import SplitIO from '../../types/splitio';
4
4
  import { ILogger } from '../logger/types';
5
5
 
6
6
  export interface IDependencyMatcherValue {
@@ -1,4 +1,4 @@
1
- import { SplitIO } from '../../types';
1
+ import SplitIO from '../../../types/splitio';
2
2
  import { IMatcherDto } from '../types';
3
3
  import { ILogger } from '../../logger/types';
4
4
  import { sanitize } from './sanitize';
@@ -1,4 +1,4 @@
1
- import { SplitIO } from '../../types';
1
+ import SplitIO from '../../../types/splitio';
2
2
  import { IDependencyMatcherValue } from '../types';
3
3
  import { ILogger } from '../../logger/types';
4
4
  import { isObject, uniq, toString, toNumber } from '../../utils/lang';
@@ -1,13 +1,13 @@
1
1
  import { SPLIT_IMPRESSION, SPLIT_EVENT } from '../utils/constants';
2
- import { SplitIO } from '../types';
2
+ import SplitIO from '../../types/splitio';
3
3
  import { IIntegration, IIntegrationManager, IIntegrationFactoryParams } from './types';
4
4
 
5
5
  /**
6
6
  * Factory function for IntegrationsManager with pluggable integrations.
7
7
  * The integrations manager instantiates integration, and bypass tracked events and impressions to them.
8
8
  *
9
- * @param integrations validated list of integration factories
10
- * @param params information of the Sdk factory instance that integrations can access to
9
+ * @param integrations - validated list of integration factories
10
+ * @param params - information of the Sdk factory instance that integrations can access to
11
11
  *
12
12
  * @returns integration manager or undefined if `integrations` are not present in settings.
13
13
  */
@@ -1,6 +1,7 @@
1
1
  import { IEventsCacheBase } from '../storages/types';
2
2
  import { IEventsHandler, IImpressionsHandler, ITelemetryTracker } from '../trackers/types';
3
- import { ISettings, SplitIO } from '../types';
3
+ import { ISettings } from '../types';
4
+ import SplitIO from '../../types/splitio';
4
5
 
5
6
  export interface IIntegration {
6
7
  queue(data: SplitIO.IntegrationData): void
@@ -14,7 +15,7 @@ export interface IIntegrationFactoryParams {
14
15
  telemetryTracker: ITelemetryTracker
15
16
  }
16
17
 
17
- export type IntegrationFactory = {
18
+ export type IntegrationFactory = SplitIO.IntegrationFactory & {
18
19
  readonly type: string
19
20
  (params: IIntegrationFactoryParams): IIntegration | void
20
21
  }
@@ -5,7 +5,8 @@ import { IRecorderCacheSync, IStorageSync } from '../storages/types';
5
5
  import { fromImpressionsCollector } from '../sync/submitters/impressionsSubmitter';
6
6
  import { fromImpressionCountsCollector } from '../sync/submitters/impressionCountsSubmitter';
7
7
  import { IResponse, ISplitApi } from '../services/types';
8
- import { ImpressionDTO, ISettings } from '../types';
8
+ import { ISettings } from '../types';
9
+ import SplitIO from '../../types/splitio';
9
10
  import { ImpressionsPayload } from '../sync/submitters/types';
10
11
  import { OPTIMIZED, DEBUG, NONE } from '../utils/constants';
11
12
  import { objectAssign } from '../utils/lang/objectAssign';
@@ -22,7 +23,7 @@ const EVENT_NAME = 'for visibilitychange and pagehide events.';
22
23
  */
23
24
  export class BrowserSignalListener implements ISignalListener {
24
25
 
25
- private fromImpressionsCollector: (data: ImpressionDTO[]) => ImpressionsPayload;
26
+ private fromImpressionsCollector: (data: SplitIO.ImpressionDTO[]) => ImpressionsPayload;
26
27
 
27
28
  constructor(
28
29
  private syncManager: ISyncManager | undefined,
@@ -1,9 +1,9 @@
1
1
  import { objectAssign } from '../utils/lang/objectAssign';
2
2
  import { ILoggerOptions, ILogger } from './types';
3
3
  import { find, isObject } from '../utils/lang';
4
- import { LogLevel } from '../types';
4
+ import SplitIO from '../../types/splitio';
5
5
 
6
- export const LogLevels: { [level: string]: LogLevel } = {
6
+ export const LogLevels: SplitIO.ILoggerAPI['LogLevel'] = {
7
7
  DEBUG: 'DEBUG',
8
8
  INFO: 'INFO',
9
9
  WARN: 'WARN',
@@ -19,7 +19,7 @@ const LogLevelIndexes = {
19
19
  NONE: 5
20
20
  };
21
21
 
22
- export function isLogLevelString(str: string): str is LogLevel {
22
+ export function isLogLevelString(str: string): str is SplitIO.LogLevel {
23
23
  return !!find(LogLevels, (lvl: string) => str === lvl);
24
24
  }
25
25
 
@@ -55,7 +55,7 @@ export class Logger implements ILogger {
55
55
  this.logLevel = LogLevelIndexes[this.options.logLevel];
56
56
  }
57
57
 
58
- setLogLevel(logLevel: LogLevel) {
58
+ setLogLevel(logLevel: SplitIO.LogLevel) {
59
59
  this.options.logLevel = logLevel;
60
60
  this.logLevel = LogLevelIndexes[logLevel];
61
61
  }
@@ -76,7 +76,7 @@ export class Logger implements ILogger {
76
76
  if (this._shouldLog(LogLevelIndexes.ERROR)) this._log(LogLevels.ERROR, msg, args);
77
77
  }
78
78
 
79
- private _log(level: LogLevel, msg: string | number, args?: any[]) {
79
+ private _log(level: SplitIO.LogLevel, msg: string | number, args?: any[]) {
80
80
  if (typeof msg === 'number') {
81
81
  const format = this.codes.get(msg);
82
82
  msg = format ? _sprintf(format, args) : `Message code ${msg}${args ? ', with args: ' + args.toString() : ''}`;
@@ -89,7 +89,7 @@ export class Logger implements ILogger {
89
89
  console.log(formattedText);
90
90
  }
91
91
 
92
- private _generateLogMessage(level: LogLevel, text: string) {
92
+ private _generateLogMessage(level: SplitIO.LogLevel, text: string) {
93
93
  const textPre = ' => ';
94
94
  let result = '';
95
95
 
@@ -1,14 +1,14 @@
1
1
  import { LogLevels, isLogLevelString } from './index';
2
- import { ILoggerAPI } from '../types';
2
+ import SplitIO from '../../types/splitio';
3
3
  import { ILogger } from './types';
4
4
  import { ERROR_LOGLEVEL_INVALID } from './constants';
5
5
 
6
6
  /**
7
7
  * The public Logger utility API exposed via SplitFactory, used to update the log level.
8
8
  *
9
- * @param log the factory logger instance to handle
9
+ * @param log - the factory logger instance to handle
10
10
  */
11
- export function createLoggerAPI(log: ILogger): ILoggerAPI {
11
+ export function createLoggerAPI(log: ILogger): SplitIO.ILoggerAPI {
12
12
 
13
13
  function setLogLevel(logLevel: string) {
14
14
  if (isLogLevelString(logLevel)) {
@@ -27,7 +27,7 @@ export function createLoggerAPI(log: ILogger): ILoggerAPI {
27
27
  },
28
28
  /**
29
29
  * Sets a custom log Level for the SDK.
30
- * @param {string} logLevel - Custom LogLevel value.
30
+ * @param logLevel - Custom LogLevel value.
31
31
  */
32
32
  setLogLevel,
33
33
  /**
@@ -1,23 +1,21 @@
1
- import { LogLevel } from '../types';
1
+ import SplitIO from '../../types/splitio';
2
2
 
3
3
  export interface ILoggerOptions {
4
4
  prefix?: string,
5
- logLevel?: LogLevel,
5
+ logLevel?: SplitIO.LogLevel,
6
6
  showLevel?: boolean, // @TODO remove this param eventually since it is not being set `false` anymore
7
7
  }
8
8
 
9
- export interface ILogger {
10
- setLogLevel(logLevel: LogLevel): void
9
+ export interface ILogger extends SplitIO.ILogger {
10
+ debug(msg: any): void;
11
+ debug(msg: string | number, args?: any[]): void;
11
12
 
12
- debug(msg: any): void
13
- debug(msg: string | number, args?: any[]): void
13
+ info(msg: any): void;
14
+ info(msg: string | number, args?: any[]): void;
14
15
 
15
- info(msg: any): void
16
- info(msg: string | number, args?: any[]): void
16
+ warn(msg: any): void;
17
+ warn(msg: string | number, args?: any[]): void;
17
18
 
18
- warn(msg: any): void
19
- warn(msg: string | number, args?: any[]): void
20
-
21
- error(msg: any): void
22
- error(msg: string | number, args?: any[]): void
19
+ error(msg: any): void;
20
+ error(msg: string | number, args?: any[]): void;
23
21
  }
@@ -1,9 +1,10 @@
1
1
  import { objectAssign } from '../utils/lang/objectAssign';
2
- import { IEventEmitter, ISettings } from '../types';
2
+ import { ISettings } from '../types';
3
+ import SplitIO from '../../types/splitio';
3
4
  import { SDK_SPLITS_ARRIVED, SDK_SPLITS_CACHE_LOADED, SDK_SEGMENTS_ARRIVED, SDK_READY_TIMED_OUT, SDK_READY_FROM_CACHE, SDK_UPDATE, SDK_READY } from './constants';
4
5
  import { IReadinessEventEmitter, IReadinessManager, ISegmentsEventEmitter, ISplitsEventEmitter } from './types';
5
6
 
6
- function splitsEventEmitterFactory(EventEmitter: new () => IEventEmitter): ISplitsEventEmitter {
7
+ function splitsEventEmitterFactory(EventEmitter: new () => SplitIO.IEventEmitter): ISplitsEventEmitter {
7
8
  const splitsEventEmitter = objectAssign(new EventEmitter(), {
8
9
  splitsArrived: false,
9
10
  splitsCacheLoaded: false,
@@ -20,7 +21,7 @@ function splitsEventEmitterFactory(EventEmitter: new () => IEventEmitter): ISpli
20
21
  return splitsEventEmitter;
21
22
  }
22
23
 
23
- function segmentsEventEmitterFactory(EventEmitter: new () => IEventEmitter): ISegmentsEventEmitter {
24
+ function segmentsEventEmitterFactory(EventEmitter: new () => SplitIO.IEventEmitter): ISegmentsEventEmitter {
24
25
  const segmentsEventEmitter = objectAssign(new EventEmitter(), {
25
26
  segmentsArrived: false
26
27
  });
@@ -34,7 +35,7 @@ function segmentsEventEmitterFactory(EventEmitter: new () => IEventEmitter): ISe
34
35
  * Factory of readiness manager, which handles the ready / update event propagation.
35
36
  */
36
37
  export function readinessManagerFactory(
37
- EventEmitter: new () => IEventEmitter,
38
+ EventEmitter: new () => SplitIO.IEventEmitter,
38
39
  settings: ISettings,
39
40
  splits: ISplitsEventEmitter = splitsEventEmitterFactory(EventEmitter)): IReadinessManager {
40
41
 
@@ -2,7 +2,8 @@ import { objectAssign } from '../utils/lang/objectAssign';
2
2
  import { promiseWrapper } from '../utils/promise/wrapper';
3
3
  import { readinessManagerFactory } from './readinessManager';
4
4
  import { ISdkReadinessManager } from './types';
5
- import { IEventEmitter, ISettings } from '../types';
5
+ import { ISettings } from '../types';
6
+ import SplitIO from '../../types/splitio';
6
7
  import { SDK_READY, SDK_READY_TIMED_OUT, SDK_READY_FROM_CACHE, SDK_UPDATE } from './constants';
7
8
  import { ERROR_CLIENT_LISTENER, CLIENT_READY_FROM_CACHE, CLIENT_READY, CLIENT_NO_LISTENER } from '../logger/constants';
8
9
 
@@ -13,11 +14,11 @@ const REMOVE_LISTENER_EVENT = 'removeListener';
13
14
  * SdkReadinessManager factory, which provides the public status API of SDK clients and manager: ready promise, readiness event emitter and constants (SDK_READY, etc).
14
15
  * It also updates logs related warnings and errors.
15
16
  *
16
- * @param readyTimeout time in millis to emit SDK_READY_TIME_OUT event
17
- * @param readinessManager optional readinessManager to use. only used internally for `shared` method
17
+ * @param readyTimeout - time in millis to emit SDK_READY_TIME_OUT event
18
+ * @param readinessManager - optional readinessManager to use. only used internally for `shared` method
18
19
  */
19
20
  export function sdkReadinessManagerFactory(
20
- EventEmitter: new () => IEventEmitter,
21
+ EventEmitter: new () => SplitIO.IEventEmitter,
21
22
  settings: ISettings,
22
23
  readinessManager = readinessManagerFactory(EventEmitter, settings)): ISdkReadinessManager {
23
24
 
@@ -91,25 +92,7 @@ export function sdkReadinessManagerFactory(
91
92
  SDK_UPDATE,
92
93
  SDK_READY_TIMED_OUT,
93
94
  },
94
- /**
95
- * Returns a promise that will be resolved once the SDK has finished loading (SDK_READY event emitted) or rejected if the SDK has timedout (SDK_READY_TIMED_OUT event emitted).
96
- * As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, calling the `ready` method after the
97
- * SDK had timed out will return a new promise that should eventually resolve if the SDK gets ready.
98
- *
99
- * Caveats: the method was designed to avoid an unhandled Promise rejection if the rejection case is not handled, so that `onRejected` handler is optional when using promises.
100
- * However, when using async/await syntax, the rejection should be explicitly propagated like in the following example:
101
- * ```
102
- * try {
103
- * await client.ready().catch((e) => { throw e; });
104
- * // SDK is ready
105
- * } catch(e) {
106
- * // SDK has timedout
107
- * }
108
- * ```
109
- *
110
- * @function ready
111
- * @returns {Promise<void>}
112
- */
95
+
113
96
  ready() {
114
97
  if (readinessManager.hasTimedout()) {
115
98
  if (!readinessManager.isReady()) {