@splitsoftware/splitio-commons 2.4.2-rc.3 → 11.5.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (884) hide show
  1. package/CHANGES.txt +895 -152
  2. package/CONTRIBUTORS-GUIDE.md +26 -16
  3. package/README.md +43 -5
  4. package/cjs/factory/browser.js +73 -0
  5. package/cjs/factory/node.js +79 -0
  6. package/cjs/factory/package.json +4 -0
  7. package/cjs/index.js +3 -16
  8. package/cjs/{utils/MinEvents.js → platform/EventEmitter.js} +153 -27
  9. package/cjs/platform/browser.js +15 -0
  10. package/cjs/platform/filter/bloomFilter.js +32 -0
  11. package/cjs/platform/getEventSource/browser.js +7 -0
  12. package/cjs/platform/getEventSource/eventsource.js +480 -0
  13. package/cjs/platform/getEventSource/node.js +25 -0
  14. package/cjs/platform/getEventSource/package.json +4 -0
  15. package/cjs/platform/getFetch/browser.js +9 -0
  16. package/cjs/platform/getFetch/node.js +26 -0
  17. package/cjs/platform/getFetch/package.json +4 -0
  18. package/cjs/platform/getOptions/node.js +25 -0
  19. package/cjs/platform/node.js +18 -0
  20. package/cjs/platform/package.json +4 -0
  21. package/cjs/settings/browser.js +21 -0
  22. package/cjs/settings/defaults/browser.js +21 -0
  23. package/cjs/settings/defaults/node.js +23 -0
  24. package/cjs/{listeners/types.js → settings/defaults/version.js} +2 -0
  25. package/cjs/settings/integrations/browser.js +9 -0
  26. package/cjs/settings/node.js +22 -0
  27. package/cjs/settings/package.json +4 -0
  28. package/cjs/settings/runtime/node.js +22 -0
  29. package/cjs/settings/storage/browser.js +35 -0
  30. package/cjs/settings/storage/node.js +67 -0
  31. package/cjs/sync/offline/LocalhostFromFile.js +8 -0
  32. package/cjs/sync/offline/splitsParserFromFile.js +148 -0
  33. package/cjs/umd.js +5 -0
  34. package/cjs/utils/ip.js +114 -0
  35. package/client/package.json +5 -0
  36. package/esm/factory/browser.js +69 -0
  37. package/esm/factory/node.js +75 -0
  38. package/esm/factory/package.json +4 -0
  39. package/esm/index.js +1 -10
  40. package/esm/{utils/MinEvents.js → platform/EventEmitter.js} +143 -17
  41. package/esm/platform/browser.js +12 -0
  42. package/esm/platform/filter/bloomFilter.js +28 -0
  43. package/esm/platform/getEventSource/browser.js +3 -0
  44. package/esm/platform/getEventSource/eventsource.js +480 -0
  45. package/esm/platform/getEventSource/node.js +19 -0
  46. package/esm/platform/getEventSource/package.json +4 -0
  47. package/esm/platform/getFetch/browser.js +4 -0
  48. package/esm/platform/getFetch/node.js +21 -0
  49. package/esm/platform/getFetch/package.json +4 -0
  50. package/esm/platform/getOptions/node.js +20 -0
  51. package/esm/platform/node.js +14 -0
  52. package/esm/platform/package.json +4 -0
  53. package/esm/settings/browser.js +17 -0
  54. package/esm/settings/defaults/browser.js +18 -0
  55. package/esm/settings/defaults/node.js +20 -0
  56. package/esm/settings/defaults/version.js +1 -0
  57. package/esm/settings/integrations/browser.js +5 -0
  58. package/esm/settings/node.js +18 -0
  59. package/esm/settings/package.json +4 -0
  60. package/esm/settings/runtime/node.js +17 -0
  61. package/esm/settings/storage/browser.js +31 -0
  62. package/esm/settings/storage/node.js +63 -0
  63. package/esm/sync/offline/LocalhostFromFile.js +5 -0
  64. package/esm/sync/offline/splitsParserFromFile.js +143 -0
  65. package/esm/umd.js +3 -0
  66. package/esm/utils/ip.js +109 -0
  67. package/package.json +99 -58
  68. package/server/package.json +5 -0
  69. package/src/factory/browser.js +85 -0
  70. package/src/factory/node.js +92 -0
  71. package/src/factory/package.json +4 -0
  72. package/src/index.js +1 -0
  73. package/src/{utils/MinEvents.ts → platform/EventEmitter.js} +164 -19
  74. package/src/platform/browser.js +14 -0
  75. package/src/platform/filter/bloomFilter.js +33 -0
  76. package/src/platform/getEventSource/browser.js +3 -0
  77. package/src/platform/getEventSource/eventsource.js +519 -0
  78. package/src/platform/getEventSource/node.js +20 -0
  79. package/src/platform/getEventSource/package.json +4 -0
  80. package/src/platform/getFetch/browser.js +5 -0
  81. package/src/platform/getFetch/node.js +24 -0
  82. package/src/platform/getFetch/package.json +4 -0
  83. package/src/platform/getOptions/node.js +23 -0
  84. package/src/platform/node.js +16 -0
  85. package/src/platform/package.json +4 -0
  86. package/src/settings/browser.js +20 -0
  87. package/src/settings/defaults/browser.js +21 -0
  88. package/src/settings/defaults/node.js +23 -0
  89. package/src/settings/defaults/version.js +1 -0
  90. package/src/settings/integrations/browser.js +6 -0
  91. package/src/settings/node.js +21 -0
  92. package/src/settings/package.json +4 -0
  93. package/src/settings/runtime/node.js +21 -0
  94. package/src/settings/storage/browser.js +47 -0
  95. package/src/settings/storage/node.js +84 -0
  96. package/src/sync/offline/LocalhostFromFile.js +6 -0
  97. package/src/sync/offline/splitsParserFromFile.js +173 -0
  98. package/src/umd.js +4 -0
  99. package/src/utils/ip.js +123 -0
  100. package/types/client/index.d.ts +15 -0
  101. package/types/index.d.ts +24 -1
  102. package/types/server/index.d.ts +21 -0
  103. package/types/splitio.d.ts +2 -2083
  104. package/cjs/consent/index.js +0 -10
  105. package/cjs/consent/sdkUserConsent.js +0 -60
  106. package/cjs/dtos/types.js +0 -2
  107. package/cjs/evaluator/Engine.js +0 -58
  108. package/cjs/evaluator/combiners/and.js +0 -25
  109. package/cjs/evaluator/combiners/ifelseif.js +0 -48
  110. package/cjs/evaluator/condition/engineUtils.js +0 -29
  111. package/cjs/evaluator/condition/index.js +0 -41
  112. package/cjs/evaluator/convertions/index.js +0 -11
  113. package/cjs/evaluator/index.js +0 -134
  114. package/cjs/evaluator/matchers/all.js +0 -9
  115. package/cjs/evaluator/matchers/between.js +0 -10
  116. package/cjs/evaluator/matchers/boolean.js +0 -10
  117. package/cjs/evaluator/matchers/cont_all.js +0 -23
  118. package/cjs/evaluator/matchers/cont_any.js +0 -18
  119. package/cjs/evaluator/matchers/cont_str.js +0 -11
  120. package/cjs/evaluator/matchers/dependency.js +0 -28
  121. package/cjs/evaluator/matchers/eq.js +0 -10
  122. package/cjs/evaluator/matchers/eq_set.js +0 -20
  123. package/cjs/evaluator/matchers/ew.js +0 -11
  124. package/cjs/evaluator/matchers/gte.js +0 -10
  125. package/cjs/evaluator/matchers/index.js +0 -66
  126. package/cjs/evaluator/matchers/large_segment.js +0 -10
  127. package/cjs/evaluator/matchers/lte.js +0 -10
  128. package/cjs/evaluator/matchers/matcherTypes.js +0 -46
  129. package/cjs/evaluator/matchers/part_of.js +0 -20
  130. package/cjs/evaluator/matchers/prerequisites.js +0 -22
  131. package/cjs/evaluator/matchers/rbsegment.js +0 -56
  132. package/cjs/evaluator/matchers/segment.js +0 -10
  133. package/cjs/evaluator/matchers/semver_between.js +0 -14
  134. package/cjs/evaluator/matchers/semver_eq.js +0 -13
  135. package/cjs/evaluator/matchers/semver_gte.js +0 -13
  136. package/cjs/evaluator/matchers/semver_inlist.js +0 -16
  137. package/cjs/evaluator/matchers/semver_lte.js +0 -13
  138. package/cjs/evaluator/matchers/string.js +0 -11
  139. package/cjs/evaluator/matchers/sw.js +0 -11
  140. package/cjs/evaluator/matchers/whitelist.js +0 -11
  141. package/cjs/evaluator/matchersTransform/index.js +0 -104
  142. package/cjs/evaluator/matchersTransform/segment.js +0 -12
  143. package/cjs/evaluator/matchersTransform/unaryNumeric.js +0 -10
  144. package/cjs/evaluator/matchersTransform/whitelist.js +0 -10
  145. package/cjs/evaluator/parser/index.js +0 -61
  146. package/cjs/evaluator/treatments/index.js +0 -42
  147. package/cjs/evaluator/types.js +0 -2
  148. package/cjs/evaluator/value/index.js +0 -37
  149. package/cjs/evaluator/value/sanitize.js +0 -94
  150. package/cjs/integrations/pluggable.js +0 -35
  151. package/cjs/integrations/types.js +0 -2
  152. package/cjs/listeners/browser.js +0 -121
  153. package/cjs/listeners/node.js +0 -68
  154. package/cjs/logger/browser/DebugLogger.js +0 -9
  155. package/cjs/logger/browser/ErrorLogger.js +0 -9
  156. package/cjs/logger/browser/InfoLogger.js +0 -9
  157. package/cjs/logger/browser/WarnLogger.js +0 -9
  158. package/cjs/logger/constants.js +0 -140
  159. package/cjs/logger/index.js +0 -100
  160. package/cjs/logger/messages/debug.js +0 -36
  161. package/cjs/logger/messages/error.js +0 -42
  162. package/cjs/logger/messages/info.js +0 -37
  163. package/cjs/logger/messages/warn.js +0 -42
  164. package/cjs/logger/sdkLogger.js +0 -45
  165. package/cjs/logger/types.js +0 -2
  166. package/cjs/readiness/constants.js +0 -13
  167. package/cjs/readiness/readinessManager.js +0 -154
  168. package/cjs/readiness/sdkReadinessManager.js +0 -104
  169. package/cjs/readiness/types.js +0 -2
  170. package/cjs/sdkClient/client.js +0 -183
  171. package/cjs/sdkClient/clientAttributesDecoration.js +0 -122
  172. package/cjs/sdkClient/clientCS.js +0 -30
  173. package/cjs/sdkClient/clientInputValidation.js +0 -147
  174. package/cjs/sdkClient/identity.js +0 -7
  175. package/cjs/sdkClient/sdkClient.js +0 -64
  176. package/cjs/sdkClient/sdkClientMethod.js +0 -22
  177. package/cjs/sdkClient/sdkClientMethodCS.js +0 -66
  178. package/cjs/sdkFactory/index.js +0 -108
  179. package/cjs/sdkFactory/types.js +0 -2
  180. package/cjs/sdkManager/index.js +0 -96
  181. package/cjs/services/decorateHeaders.js +0 -40
  182. package/cjs/services/splitApi.js +0 -131
  183. package/cjs/services/splitHttpClient.js +0 -82
  184. package/cjs/services/types.js +0 -2
  185. package/cjs/storages/AbstractMySegmentsCacheSync.js +0 -60
  186. package/cjs/storages/AbstractSplitsCacheAsync.js +0 -51
  187. package/cjs/storages/AbstractSplitsCacheSync.js +0 -75
  188. package/cjs/storages/KeyBuilder.js +0 -68
  189. package/cjs/storages/KeyBuilderCS.js +0 -65
  190. package/cjs/storages/KeyBuilderSS.js +0 -60
  191. package/cjs/storages/dataLoader.js +0 -50
  192. package/cjs/storages/findLatencyIndex.js +0 -18
  193. package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +0 -81
  194. package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +0 -117
  195. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +0 -204
  196. package/cjs/storages/inLocalStorage/constants.js +0 -5
  197. package/cjs/storages/inLocalStorage/index.js +0 -91
  198. package/cjs/storages/inLocalStorage/storageAdapter.js +0 -54
  199. package/cjs/storages/inLocalStorage/validateCache.js +0 -85
  200. package/cjs/storages/inMemory/AttributesCacheInMemory.js +0 -70
  201. package/cjs/storages/inMemory/EventsCacheInMemory.js +0 -63
  202. package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +0 -65
  203. package/cjs/storages/inMemory/ImpressionsCacheInMemory.js +0 -51
  204. package/cjs/storages/inMemory/InMemoryStorage.js +0 -46
  205. package/cjs/storages/inMemory/InMemoryStorageCS.js +0 -63
  206. package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +0 -46
  207. package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +0 -61
  208. package/cjs/storages/inMemory/SegmentsCacheInMemory.js +0 -61
  209. package/cjs/storages/inMemory/SplitsCacheInMemory.js +0 -121
  210. package/cjs/storages/inMemory/TelemetryCacheInMemory.js +0 -207
  211. package/cjs/storages/inMemory/UniqueKeysCacheInMemory.js +0 -72
  212. package/cjs/storages/inMemory/UniqueKeysCacheInMemoryCS.js +0 -71
  213. package/cjs/storages/inRedis/EventsCacheInRedis.js +0 -60
  214. package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +0 -85
  215. package/cjs/storages/inRedis/ImpressionsCacheInRedis.js +0 -45
  216. package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +0 -64
  217. package/cjs/storages/inRedis/RedisAdapter.js +0 -195
  218. package/cjs/storages/inRedis/SegmentsCacheInRedis.js +0 -57
  219. package/cjs/storages/inRedis/SplitsCacheInRedis.js +0 -243
  220. package/cjs/storages/inRedis/TelemetryCacheInRedis.js +0 -124
  221. package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +0 -69
  222. package/cjs/storages/inRedis/constants.js +0 -7
  223. package/cjs/storages/inRedis/index.js +0 -73
  224. package/cjs/storages/pluggable/EventsCachePluggable.js +0 -64
  225. package/cjs/storages/pluggable/ImpressionCountsCachePluggable.js +0 -81
  226. package/cjs/storages/pluggable/ImpressionsCachePluggable.js +0 -48
  227. package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +0 -64
  228. package/cjs/storages/pluggable/SegmentsCachePluggable.js +0 -80
  229. package/cjs/storages/pluggable/SplitsCachePluggable.js +0 -212
  230. package/cjs/storages/pluggable/TelemetryCachePluggable.js +0 -141
  231. package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +0 -62
  232. package/cjs/storages/pluggable/constants.js +0 -4
  233. package/cjs/storages/pluggable/inMemoryWrapper.js +0 -141
  234. package/cjs/storages/pluggable/index.js +0 -135
  235. package/cjs/storages/pluggable/wrapperAdapter.js +0 -53
  236. package/cjs/storages/types.js +0 -2
  237. package/cjs/storages/utils.js +0 -74
  238. package/cjs/sync/offline/LocalhostFromObject.js +0 -8
  239. package/cjs/sync/offline/splitsParser/parseCondition.js +0 -55
  240. package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +0 -62
  241. package/cjs/sync/offline/splitsParser/types.js +0 -2
  242. package/cjs/sync/offline/syncManagerOffline.js +0 -52
  243. package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +0 -71
  244. package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +0 -18
  245. package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +0 -34
  246. package/cjs/sync/polling/fetchers/splitChangesFetcher.js +0 -68
  247. package/cjs/sync/polling/fetchers/types.js +0 -2
  248. package/cjs/sync/polling/pollingManagerCS.js +0 -100
  249. package/cjs/sync/polling/pollingManagerSS.js +0 -49
  250. package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +0 -13
  251. package/cjs/sync/polling/syncTasks/segmentsSyncTask.js +0 -13
  252. package/cjs/sync/polling/syncTasks/splitsSyncTask.js +0 -13
  253. package/cjs/sync/polling/types.js +0 -2
  254. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +0 -83
  255. package/cjs/sync/polling/updaters/segmentChangesUpdater.js +0 -80
  256. package/cjs/sync/polling/updaters/splitChangesUpdater.js +0 -190
  257. package/cjs/sync/streaming/AuthClient/index.js +0 -43
  258. package/cjs/sync/streaming/AuthClient/types.js +0 -2
  259. package/cjs/sync/streaming/SSEClient/index.js +0 -86
  260. package/cjs/sync/streaming/SSEClient/types.js +0 -2
  261. package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +0 -98
  262. package/cjs/sync/streaming/SSEHandler/NotificationParser.js +0 -41
  263. package/cjs/sync/streaming/SSEHandler/index.js +0 -97
  264. package/cjs/sync/streaming/SSEHandler/types.js +0 -16
  265. package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +0 -124
  266. package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +0 -92
  267. package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +0 -136
  268. package/cjs/sync/streaming/UpdateWorkers/constants.js +0 -6
  269. package/cjs/sync/streaming/UpdateWorkers/types.js +0 -2
  270. package/cjs/sync/streaming/constants.js +0 -43
  271. package/cjs/sync/streaming/parseUtils.js +0 -98
  272. package/cjs/sync/streaming/pushManager.js +0 -317
  273. package/cjs/sync/streaming/types.js +0 -2
  274. package/cjs/sync/submitters/eventsSubmitter.js +0 -28
  275. package/cjs/sync/submitters/impressionCountsSubmitter.js +0 -36
  276. package/cjs/sync/submitters/impressionsSubmitter.js +0 -54
  277. package/cjs/sync/submitters/submitter.js +0 -66
  278. package/cjs/sync/submitters/submitterManager.js +0 -46
  279. package/cjs/sync/submitters/telemetrySubmitter.js +0 -125
  280. package/cjs/sync/submitters/types.js +0 -2
  281. package/cjs/sync/submitters/uniqueKeysSubmitter.js +0 -27
  282. package/cjs/sync/syncManagerOnline.js +0 -176
  283. package/cjs/sync/syncTask.js +0 -84
  284. package/cjs/sync/types.js +0 -2
  285. package/cjs/trackers/eventTracker.js +0 -62
  286. package/cjs/trackers/impressionObserver/ImpressionObserver.js +0 -18
  287. package/cjs/trackers/impressionObserver/buildKey.js +0 -7
  288. package/cjs/trackers/impressionObserver/impressionObserverCS.js +0 -15
  289. package/cjs/trackers/impressionObserver/impressionObserverSS.js +0 -15
  290. package/cjs/trackers/impressionObserver/types.js +0 -2
  291. package/cjs/trackers/impressionsTracker.js +0 -78
  292. package/cjs/trackers/strategy/strategyDebug.js +0 -20
  293. package/cjs/trackers/strategy/strategyNone.js +0 -24
  294. package/cjs/trackers/strategy/strategyOptimized.js +0 -28
  295. package/cjs/trackers/telemetryTracker.js +0 -75
  296. package/cjs/trackers/types.js +0 -2
  297. package/cjs/trackers/uniqueKeysTracker.js +0 -40
  298. package/cjs/types.js +0 -2
  299. package/cjs/utils/Backoff.js +0 -41
  300. package/cjs/utils/LRUCache/LinkedList.js +0 -114
  301. package/cjs/utils/LRUCache/index.js +0 -42
  302. package/cjs/utils/MinEventEmitter.js +0 -100
  303. package/cjs/utils/Semver.js +0 -103
  304. package/cjs/utils/base64/index.js +0 -75
  305. package/cjs/utils/constants/index.js +0 -100
  306. package/cjs/utils/decompress/index.js +0 -427
  307. package/cjs/utils/env/isLocalStorageAvailable.js +0 -39
  308. package/cjs/utils/env/isNode.js +0 -9
  309. package/cjs/utils/inputValidation/apiKey.js +0 -54
  310. package/cjs/utils/inputValidation/attribute.js +0 -20
  311. package/cjs/utils/inputValidation/attributes.js +0 -25
  312. package/cjs/utils/inputValidation/event.js +0 -28
  313. package/cjs/utils/inputValidation/eventProperties.js +0 -74
  314. package/cjs/utils/inputValidation/eventValue.js +0 -12
  315. package/cjs/utils/inputValidation/index.js +0 -34
  316. package/cjs/utils/inputValidation/isOperational.js +0 -18
  317. package/cjs/utils/inputValidation/key.js +0 -51
  318. package/cjs/utils/inputValidation/preloadedData.js +0 -59
  319. package/cjs/utils/inputValidation/split.js +0 -30
  320. package/cjs/utils/inputValidation/splitExistence.js +0 -19
  321. package/cjs/utils/inputValidation/splits.js +0 -25
  322. package/cjs/utils/inputValidation/trafficType.js +0 -29
  323. package/cjs/utils/inputValidation/trafficTypeExistence.js +0 -31
  324. package/cjs/utils/jwt/index.js +0 -17
  325. package/cjs/utils/jwt/types.js +0 -2
  326. package/cjs/utils/key/index.js +0 -36
  327. package/cjs/utils/labels/index.js +0 -12
  328. package/cjs/utils/lang/binarySearch.js +0 -42
  329. package/cjs/utils/lang/getFnName.js +0 -12
  330. package/cjs/utils/lang/getGlobal.js +0 -18
  331. package/cjs/utils/lang/index.js +0 -281
  332. package/cjs/utils/lang/objectAssign.js +0 -20
  333. package/cjs/utils/lang/sets.js +0 -23
  334. package/cjs/utils/murmur3/common.js +0 -46
  335. package/cjs/utils/murmur3/legacy.js +0 -44
  336. package/cjs/utils/murmur3/murmur3.js +0 -62
  337. package/cjs/utils/murmur3/murmur3_128.js +0 -219
  338. package/cjs/utils/murmur3/murmur3_128_x86.js +0 -154
  339. package/cjs/utils/murmur3/murmur3_64.js +0 -36
  340. package/cjs/utils/murmur3/utfx.js +0 -108
  341. package/cjs/utils/promise/thenable.js +0 -8
  342. package/cjs/utils/promise/timeout.js +0 -20
  343. package/cjs/utils/promise/wrapper.js +0 -58
  344. package/cjs/utils/settingsValidation/consent.js +0 -16
  345. package/cjs/utils/settingsValidation/impressionsMode.js +0 -14
  346. package/cjs/utils/settingsValidation/index.js +0 -184
  347. package/cjs/utils/settingsValidation/integrations/common.js +0 -27
  348. package/cjs/utils/settingsValidation/integrations/configurable.js +0 -18
  349. package/cjs/utils/settingsValidation/integrations/pluggable.js +0 -15
  350. package/cjs/utils/settingsValidation/logger/builtinLogger.js +0 -46
  351. package/cjs/utils/settingsValidation/logger/commons.js +0 -28
  352. package/cjs/utils/settingsValidation/logger/pluggableLogger.js +0 -32
  353. package/cjs/utils/settingsValidation/mode.js +0 -20
  354. package/cjs/utils/settingsValidation/runtime.js +0 -11
  355. package/cjs/utils/settingsValidation/splitFilters.js +0 -188
  356. package/cjs/utils/settingsValidation/storage/storageCS.js +0 -49
  357. package/cjs/utils/settingsValidation/types.js +0 -2
  358. package/cjs/utils/settingsValidation/url.js +0 -31
  359. package/cjs/utils/time/index.js +0 -11
  360. package/cjs/utils/timeTracker/now/browser.js +0 -15
  361. package/cjs/utils/timeTracker/now/node.js +0 -9
  362. package/cjs/utils/timeTracker/timer.js +0 -10
  363. package/esm/consent/index.js +0 -6
  364. package/esm/consent/sdkUserConsent.js +0 -56
  365. package/esm/dtos/types.js +0 -1
  366. package/esm/evaluator/Engine.js +0 -54
  367. package/esm/evaluator/combiners/and.js +0 -21
  368. package/esm/evaluator/combiners/ifelseif.js +0 -44
  369. package/esm/evaluator/condition/engineUtils.js +0 -24
  370. package/esm/evaluator/condition/index.js +0 -37
  371. package/esm/evaluator/convertions/index.js +0 -6
  372. package/esm/evaluator/index.js +0 -128
  373. package/esm/evaluator/matchers/all.js +0 -5
  374. package/esm/evaluator/matchers/between.js +0 -6
  375. package/esm/evaluator/matchers/boolean.js +0 -6
  376. package/esm/evaluator/matchers/cont_all.js +0 -19
  377. package/esm/evaluator/matchers/cont_any.js +0 -14
  378. package/esm/evaluator/matchers/cont_str.js +0 -7
  379. package/esm/evaluator/matchers/dependency.js +0 -24
  380. package/esm/evaluator/matchers/eq.js +0 -6
  381. package/esm/evaluator/matchers/eq_set.js +0 -16
  382. package/esm/evaluator/matchers/ew.js +0 -7
  383. package/esm/evaluator/matchers/gte.js +0 -6
  384. package/esm/evaluator/matchers/index.js +0 -62
  385. package/esm/evaluator/matchers/large_segment.js +0 -6
  386. package/esm/evaluator/matchers/lte.js +0 -6
  387. package/esm/evaluator/matchers/matcherTypes.js +0 -42
  388. package/esm/evaluator/matchers/part_of.js +0 -16
  389. package/esm/evaluator/matchers/prerequisites.js +0 -18
  390. package/esm/evaluator/matchers/rbsegment.js +0 -52
  391. package/esm/evaluator/matchers/segment.js +0 -6
  392. package/esm/evaluator/matchers/semver_between.js +0 -10
  393. package/esm/evaluator/matchers/semver_eq.js +0 -9
  394. package/esm/evaluator/matchers/semver_gte.js +0 -9
  395. package/esm/evaluator/matchers/semver_inlist.js +0 -12
  396. package/esm/evaluator/matchers/semver_lte.js +0 -9
  397. package/esm/evaluator/matchers/string.js +0 -7
  398. package/esm/evaluator/matchers/sw.js +0 -7
  399. package/esm/evaluator/matchers/whitelist.js +0 -7
  400. package/esm/evaluator/matchersTransform/index.js +0 -100
  401. package/esm/evaluator/matchersTransform/segment.js +0 -8
  402. package/esm/evaluator/matchersTransform/unaryNumeric.js +0 -6
  403. package/esm/evaluator/matchersTransform/whitelist.js +0 -6
  404. package/esm/evaluator/parser/index.js +0 -57
  405. package/esm/evaluator/treatments/index.js +0 -39
  406. package/esm/evaluator/types.js +0 -1
  407. package/esm/evaluator/value/index.js +0 -33
  408. package/esm/evaluator/value/sanitize.js +0 -90
  409. package/esm/integrations/pluggable.js +0 -31
  410. package/esm/integrations/types.js +0 -1
  411. package/esm/listeners/browser.js +0 -118
  412. package/esm/listeners/node.js +0 -65
  413. package/esm/listeners/types.js +0 -1
  414. package/esm/logger/browser/DebugLogger.js +0 -5
  415. package/esm/logger/browser/ErrorLogger.js +0 -5
  416. package/esm/logger/browser/InfoLogger.js +0 -5
  417. package/esm/logger/browser/WarnLogger.js +0 -5
  418. package/esm/logger/constants.js +0 -135
  419. package/esm/logger/index.js +0 -95
  420. package/esm/logger/messages/debug.js +0 -32
  421. package/esm/logger/messages/error.js +0 -38
  422. package/esm/logger/messages/info.js +0 -33
  423. package/esm/logger/messages/warn.js +0 -38
  424. package/esm/logger/sdkLogger.js +0 -41
  425. package/esm/logger/types.js +0 -1
  426. package/esm/readiness/constants.js +0 -10
  427. package/esm/readiness/readinessManager.js +0 -150
  428. package/esm/readiness/sdkReadinessManager.js +0 -100
  429. package/esm/readiness/types.js +0 -1
  430. package/esm/sdkClient/client.js +0 -179
  431. package/esm/sdkClient/clientAttributesDecoration.js +0 -118
  432. package/esm/sdkClient/clientCS.js +0 -26
  433. package/esm/sdkClient/clientInputValidation.js +0 -143
  434. package/esm/sdkClient/identity.js +0 -3
  435. package/esm/sdkClient/sdkClient.js +0 -60
  436. package/esm/sdkClient/sdkClientMethod.js +0 -18
  437. package/esm/sdkClient/sdkClientMethodCS.js +0 -62
  438. package/esm/sdkFactory/index.js +0 -104
  439. package/esm/sdkFactory/types.js +0 -1
  440. package/esm/sdkManager/index.js +0 -92
  441. package/esm/services/decorateHeaders.js +0 -35
  442. package/esm/services/splitApi.js +0 -127
  443. package/esm/services/splitHttpClient.js +0 -78
  444. package/esm/services/types.js +0 -1
  445. package/esm/storages/AbstractMySegmentsCacheSync.js +0 -57
  446. package/esm/storages/AbstractSplitsCacheAsync.js +0 -48
  447. package/esm/storages/AbstractSplitsCacheSync.js +0 -70
  448. package/esm/storages/KeyBuilder.js +0 -63
  449. package/esm/storages/KeyBuilderCS.js +0 -61
  450. package/esm/storages/KeyBuilderSS.js +0 -57
  451. package/esm/storages/dataLoader.js +0 -46
  452. package/esm/storages/findLatencyIndex.js +0 -14
  453. package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +0 -78
  454. package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +0 -114
  455. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +0 -201
  456. package/esm/storages/inLocalStorage/constants.js +0 -2
  457. package/esm/storages/inLocalStorage/index.js +0 -87
  458. package/esm/storages/inLocalStorage/storageAdapter.js +0 -50
  459. package/esm/storages/inLocalStorage/validateCache.js +0 -81
  460. package/esm/storages/inMemory/AttributesCacheInMemory.js +0 -67
  461. package/esm/storages/inMemory/EventsCacheInMemory.js +0 -60
  462. package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +0 -62
  463. package/esm/storages/inMemory/ImpressionsCacheInMemory.js +0 -48
  464. package/esm/storages/inMemory/InMemoryStorage.js +0 -42
  465. package/esm/storages/inMemory/InMemoryStorageCS.js +0 -59
  466. package/esm/storages/inMemory/MySegmentsCacheInMemory.js +0 -43
  467. package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +0 -58
  468. package/esm/storages/inMemory/SegmentsCacheInMemory.js +0 -58
  469. package/esm/storages/inMemory/SplitsCacheInMemory.js +0 -118
  470. package/esm/storages/inMemory/TelemetryCacheInMemory.js +0 -202
  471. package/esm/storages/inMemory/UniqueKeysCacheInMemory.js +0 -68
  472. package/esm/storages/inMemory/UniqueKeysCacheInMemoryCS.js +0 -68
  473. package/esm/storages/inRedis/EventsCacheInRedis.js +0 -57
  474. package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +0 -82
  475. package/esm/storages/inRedis/ImpressionsCacheInRedis.js +0 -42
  476. package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +0 -61
  477. package/esm/storages/inRedis/RedisAdapter.js +0 -192
  478. package/esm/storages/inRedis/SegmentsCacheInRedis.js +0 -54
  479. package/esm/storages/inRedis/SplitsCacheInRedis.js +0 -240
  480. package/esm/storages/inRedis/TelemetryCacheInRedis.js +0 -121
  481. package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +0 -66
  482. package/esm/storages/inRedis/constants.js +0 -4
  483. package/esm/storages/inRedis/index.js +0 -69
  484. package/esm/storages/pluggable/EventsCachePluggable.js +0 -61
  485. package/esm/storages/pluggable/ImpressionCountsCachePluggable.js +0 -78
  486. package/esm/storages/pluggable/ImpressionsCachePluggable.js +0 -45
  487. package/esm/storages/pluggable/RBSegmentsCachePluggable.js +0 -61
  488. package/esm/storages/pluggable/SegmentsCachePluggable.js +0 -77
  489. package/esm/storages/pluggable/SplitsCachePluggable.js +0 -209
  490. package/esm/storages/pluggable/TelemetryCachePluggable.js +0 -138
  491. package/esm/storages/pluggable/UniqueKeysCachePluggable.js +0 -59
  492. package/esm/storages/pluggable/constants.js +0 -1
  493. package/esm/storages/pluggable/inMemoryWrapper.js +0 -137
  494. package/esm/storages/pluggable/index.js +0 -131
  495. package/esm/storages/pluggable/wrapperAdapter.js +0 -49
  496. package/esm/storages/types.js +0 -1
  497. package/esm/storages/utils.js +0 -66
  498. package/esm/sync/offline/LocalhostFromObject.js +0 -5
  499. package/esm/sync/offline/splitsParser/parseCondition.js +0 -51
  500. package/esm/sync/offline/splitsParser/splitsParserFromSettings.js +0 -58
  501. package/esm/sync/offline/splitsParser/types.js +0 -1
  502. package/esm/sync/offline/syncManagerOffline.js +0 -48
  503. package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +0 -66
  504. package/esm/sync/polling/fetchers/mySegmentsFetcher.js +0 -14
  505. package/esm/sync/polling/fetchers/segmentChangesFetcher.js +0 -30
  506. package/esm/sync/polling/fetchers/splitChangesFetcher.js +0 -64
  507. package/esm/sync/polling/fetchers/types.js +0 -1
  508. package/esm/sync/polling/pollingManagerCS.js +0 -96
  509. package/esm/sync/polling/pollingManagerSS.js +0 -45
  510. package/esm/sync/polling/syncTasks/mySegmentsSyncTask.js +0 -9
  511. package/esm/sync/polling/syncTasks/segmentsSyncTask.js +0 -9
  512. package/esm/sync/polling/syncTasks/splitsSyncTask.js +0 -9
  513. package/esm/sync/polling/types.js +0 -1
  514. package/esm/sync/polling/updaters/mySegmentsUpdater.js +0 -79
  515. package/esm/sync/polling/updaters/segmentChangesUpdater.js +0 -76
  516. package/esm/sync/polling/updaters/splitChangesUpdater.js +0 -184
  517. package/esm/sync/streaming/AuthClient/index.js +0 -38
  518. package/esm/sync/streaming/AuthClient/types.js +0 -1
  519. package/esm/sync/streaming/SSEClient/index.js +0 -83
  520. package/esm/sync/streaming/SSEClient/types.js +0 -1
  521. package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +0 -94
  522. package/esm/sync/streaming/SSEHandler/NotificationParser.js +0 -36
  523. package/esm/sync/streaming/SSEHandler/index.js +0 -93
  524. package/esm/sync/streaming/SSEHandler/types.js +0 -13
  525. package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +0 -120
  526. package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +0 -88
  527. package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +0 -132
  528. package/esm/sync/streaming/UpdateWorkers/constants.js +0 -3
  529. package/esm/sync/streaming/UpdateWorkers/types.js +0 -1
  530. package/esm/sync/streaming/constants.js +0 -40
  531. package/esm/sync/streaming/parseUtils.js +0 -90
  532. package/esm/sync/streaming/pushManager.js +0 -313
  533. package/esm/sync/streaming/types.js +0 -1
  534. package/esm/sync/submitters/eventsSubmitter.js +0 -24
  535. package/esm/sync/submitters/impressionCountsSubmitter.js +0 -31
  536. package/esm/sync/submitters/impressionsSubmitter.js +0 -49
  537. package/esm/sync/submitters/submitter.js +0 -61
  538. package/esm/sync/submitters/submitterManager.js +0 -42
  539. package/esm/sync/submitters/telemetrySubmitter.js +0 -119
  540. package/esm/sync/submitters/types.js +0 -1
  541. package/esm/sync/submitters/uniqueKeysSubmitter.js +0 -23
  542. package/esm/sync/syncManagerOnline.js +0 -172
  543. package/esm/sync/syncTask.js +0 -80
  544. package/esm/sync/types.js +0 -1
  545. package/esm/trackers/eventTracker.js +0 -58
  546. package/esm/trackers/impressionObserver/ImpressionObserver.js +0 -15
  547. package/esm/trackers/impressionObserver/buildKey.js +0 -3
  548. package/esm/trackers/impressionObserver/impressionObserverCS.js +0 -10
  549. package/esm/trackers/impressionObserver/impressionObserverSS.js +0 -10
  550. package/esm/trackers/impressionObserver/types.js +0 -1
  551. package/esm/trackers/impressionsTracker.js +0 -74
  552. package/esm/trackers/strategy/strategyDebug.js +0 -16
  553. package/esm/trackers/strategy/strategyNone.js +0 -20
  554. package/esm/trackers/strategy/strategyOptimized.js +0 -24
  555. package/esm/trackers/telemetryTracker.js +0 -71
  556. package/esm/trackers/types.js +0 -1
  557. package/esm/trackers/uniqueKeysTracker.js +0 -36
  558. package/esm/types.js +0 -1
  559. package/esm/utils/Backoff.js +0 -38
  560. package/esm/utils/LRUCache/LinkedList.js +0 -111
  561. package/esm/utils/LRUCache/index.js +0 -39
  562. package/esm/utils/MinEventEmitter.js +0 -97
  563. package/esm/utils/Semver.js +0 -100
  564. package/esm/utils/base64/index.js +0 -70
  565. package/esm/utils/constants/index.js +0 -96
  566. package/esm/utils/decompress/index.js +0 -424
  567. package/esm/utils/env/isLocalStorageAvailable.js +0 -33
  568. package/esm/utils/env/isNode.js +0 -6
  569. package/esm/utils/inputValidation/apiKey.js +0 -48
  570. package/esm/utils/inputValidation/attribute.js +0 -16
  571. package/esm/utils/inputValidation/attributes.js +0 -20
  572. package/esm/utils/inputValidation/event.js +0 -24
  573. package/esm/utils/inputValidation/eventProperties.js +0 -69
  574. package/esm/utils/inputValidation/eventValue.js +0 -8
  575. package/esm/utils/inputValidation/index.js +0 -14
  576. package/esm/utils/inputValidation/isOperational.js +0 -13
  577. package/esm/utils/inputValidation/key.js +0 -47
  578. package/esm/utils/inputValidation/preloadedData.js +0 -55
  579. package/esm/utils/inputValidation/split.js +0 -26
  580. package/esm/utils/inputValidation/splitExistence.js +0 -15
  581. package/esm/utils/inputValidation/splits.js +0 -21
  582. package/esm/utils/inputValidation/trafficType.js +0 -25
  583. package/esm/utils/inputValidation/trafficTypeExistence.js +0 -27
  584. package/esm/utils/jwt/index.js +0 -13
  585. package/esm/utils/jwt/types.js +0 -1
  586. package/esm/utils/key/index.js +0 -30
  587. package/esm/utils/labels/index.js +0 -9
  588. package/esm/utils/lang/binarySearch.js +0 -38
  589. package/esm/utils/lang/getFnName.js +0 -8
  590. package/esm/utils/lang/getGlobal.js +0 -14
  591. package/esm/utils/lang/index.js +0 -258
  592. package/esm/utils/lang/objectAssign.js +0 -17
  593. package/esm/utils/lang/sets.js +0 -17
  594. package/esm/utils/murmur3/common.js +0 -39
  595. package/esm/utils/murmur3/legacy.js +0 -39
  596. package/esm/utils/murmur3/murmur3.js +0 -57
  597. package/esm/utils/murmur3/murmur3_128.js +0 -215
  598. package/esm/utils/murmur3/murmur3_128_x86.js +0 -150
  599. package/esm/utils/murmur3/murmur3_64.js +0 -32
  600. package/esm/utils/murmur3/utfx.js +0 -102
  601. package/esm/utils/promise/thenable.js +0 -4
  602. package/esm/utils/promise/timeout.js +0 -16
  603. package/esm/utils/promise/wrapper.js +0 -54
  604. package/esm/utils/settingsValidation/consent.js +0 -12
  605. package/esm/utils/settingsValidation/impressionsMode.js +0 -10
  606. package/esm/utils/settingsValidation/index.js +0 -180
  607. package/esm/utils/settingsValidation/integrations/common.js +0 -23
  608. package/esm/utils/settingsValidation/integrations/configurable.js +0 -14
  609. package/esm/utils/settingsValidation/integrations/pluggable.js +0 -11
  610. package/esm/utils/settingsValidation/logger/builtinLogger.js +0 -42
  611. package/esm/utils/settingsValidation/logger/commons.js +0 -24
  612. package/esm/utils/settingsValidation/logger/pluggableLogger.js +0 -28
  613. package/esm/utils/settingsValidation/mode.js +0 -15
  614. package/esm/utils/settingsValidation/runtime.js +0 -7
  615. package/esm/utils/settingsValidation/splitFilters.js +0 -183
  616. package/esm/utils/settingsValidation/storage/storageCS.js +0 -44
  617. package/esm/utils/settingsValidation/types.js +0 -1
  618. package/esm/utils/settingsValidation/url.js +0 -27
  619. package/esm/utils/time/index.js +0 -7
  620. package/esm/utils/timeTracker/now/browser.js +0 -12
  621. package/esm/utils/timeTracker/now/node.js +0 -5
  622. package/esm/utils/timeTracker/timer.js +0 -6
  623. package/src/consent/index.ts +0 -8
  624. package/src/consent/sdkUserConsent.ts +0 -60
  625. package/src/dtos/types.ts +0 -294
  626. package/src/evaluator/Engine.ts +0 -73
  627. package/src/evaluator/combiners/and.ts +0 -29
  628. package/src/evaluator/combiners/ifelseif.ts +0 -56
  629. package/src/evaluator/condition/engineUtils.ts +0 -31
  630. package/src/evaluator/condition/index.ts +0 -50
  631. package/src/evaluator/convertions/index.ts +0 -7
  632. package/src/evaluator/index.ts +0 -199
  633. package/src/evaluator/matchers/all.ts +0 -6
  634. package/src/evaluator/matchers/between.ts +0 -10
  635. package/src/evaluator/matchers/boolean.ts +0 -8
  636. package/src/evaluator/matchers/cont_all.ts +0 -18
  637. package/src/evaluator/matchers/cont_any.ts +0 -13
  638. package/src/evaluator/matchers/cont_str.ts +0 -9
  639. package/src/evaluator/matchers/dependency.ts +0 -32
  640. package/src/evaluator/matchers/eq.ts +0 -8
  641. package/src/evaluator/matchers/eq_set.ts +0 -15
  642. package/src/evaluator/matchers/ew.ts +0 -9
  643. package/src/evaluator/matchers/gte.ts +0 -8
  644. package/src/evaluator/matchers/index.ts +0 -70
  645. package/src/evaluator/matchers/large_segment.ts +0 -11
  646. package/src/evaluator/matchers/lte.ts +0 -8
  647. package/src/evaluator/matchers/matcherTypes.ts +0 -42
  648. package/src/evaluator/matchers/part_of.ts +0 -15
  649. package/src/evaluator/matchers/prerequisites.ts +0 -24
  650. package/src/evaluator/matchers/rbsegment.ts +0 -74
  651. package/src/evaluator/matchers/segment.ts +0 -11
  652. package/src/evaluator/matchers/semver_between.ts +0 -15
  653. package/src/evaluator/matchers/semver_eq.ts +0 -13
  654. package/src/evaluator/matchers/semver_gte.ts +0 -13
  655. package/src/evaluator/matchers/semver_inlist.ts +0 -16
  656. package/src/evaluator/matchers/semver_lte.ts +0 -13
  657. package/src/evaluator/matchers/string.ts +0 -9
  658. package/src/evaluator/matchers/sw.ts +0 -9
  659. package/src/evaluator/matchers/whitelist.ts +0 -9
  660. package/src/evaluator/matchersTransform/index.ts +0 -118
  661. package/src/evaluator/matchersTransform/segment.ts +0 -10
  662. package/src/evaluator/matchersTransform/unaryNumeric.ts +0 -8
  663. package/src/evaluator/matchersTransform/whitelist.ts +0 -8
  664. package/src/evaluator/parser/index.ts +0 -82
  665. package/src/evaluator/treatments/index.ts +0 -53
  666. package/src/evaluator/types.ts +0 -34
  667. package/src/evaluator/value/index.ts +0 -37
  668. package/src/evaluator/value/sanitize.ts +0 -106
  669. package/src/index.ts +0 -14
  670. package/src/integrations/pluggable.ts +0 -39
  671. package/src/integrations/types.ts +0 -21
  672. package/src/listeners/browser.ts +0 -138
  673. package/src/listeners/node.ts +0 -81
  674. package/src/listeners/types.ts +0 -4
  675. package/src/logger/browser/DebugLogger.ts +0 -6
  676. package/src/logger/browser/ErrorLogger.ts +0 -6
  677. package/src/logger/browser/InfoLogger.ts +0 -6
  678. package/src/logger/browser/WarnLogger.ts +0 -6
  679. package/src/logger/constants.ts +0 -139
  680. package/src/logger/index.ts +0 -110
  681. package/src/logger/messages/debug.ts +0 -33
  682. package/src/logger/messages/error.ts +0 -39
  683. package/src/logger/messages/info.ts +0 -36
  684. package/src/logger/messages/warn.ts +0 -40
  685. package/src/logger/sdkLogger.ts +0 -46
  686. package/src/logger/types.ts +0 -21
  687. package/src/readiness/constants.ts +0 -12
  688. package/src/readiness/readinessManager.ts +0 -170
  689. package/src/readiness/sdkReadinessManager.ts +0 -121
  690. package/src/readiness/types.ts +0 -85
  691. package/src/sdkClient/client.ts +0 -217
  692. package/src/sdkClient/clientAttributesDecoration.ts +0 -139
  693. package/src/sdkClient/clientCS.ts +0 -34
  694. package/src/sdkClient/clientInputValidation.ts +0 -178
  695. package/src/sdkClient/identity.ts +0 -5
  696. package/src/sdkClient/sdkClient.ts +0 -77
  697. package/src/sdkClient/sdkClientMethod.ts +0 -24
  698. package/src/sdkClient/sdkClientMethodCS.ts +0 -85
  699. package/src/sdkFactory/index.ts +0 -131
  700. package/src/sdkFactory/types.ts +0 -119
  701. package/src/sdkManager/index.ts +0 -114
  702. package/src/services/decorateHeaders.ts +0 -37
  703. package/src/services/splitApi.ts +0 -148
  704. package/src/services/splitHttpClient.ts +0 -84
  705. package/src/services/types.ts +0 -86
  706. package/src/storages/AbstractMySegmentsCacheSync.ts +0 -94
  707. package/src/storages/AbstractSplitsCacheAsync.ts +0 -63
  708. package/src/storages/AbstractSplitsCacheSync.ts +0 -94
  709. package/src/storages/KeyBuilder.ts +0 -81
  710. package/src/storages/KeyBuilderCS.ts +0 -79
  711. package/src/storages/KeyBuilderSS.ts +0 -74
  712. package/src/storages/dataLoader.ts +0 -55
  713. package/src/storages/findLatencyIndex.ts +0 -16
  714. package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +0 -87
  715. package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +0 -137
  716. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +0 -241
  717. package/src/storages/inLocalStorage/constants.ts +0 -2
  718. package/src/storages/inLocalStorage/index.ts +0 -104
  719. package/src/storages/inLocalStorage/storageAdapter.ts +0 -62
  720. package/src/storages/inLocalStorage/validateCache.ts +0 -99
  721. package/src/storages/inMemory/AttributesCacheInMemory.ts +0 -74
  722. package/src/storages/inMemory/EventsCacheInMemory.ts +0 -76
  723. package/src/storages/inMemory/ImpressionCountsCacheInMemory.ts +0 -69
  724. package/src/storages/inMemory/ImpressionsCacheInMemory.ts +0 -58
  725. package/src/storages/inMemory/InMemoryStorage.ts +0 -50
  726. package/src/storages/inMemory/InMemoryStorageCS.ts +0 -69
  727. package/src/storages/inMemory/MySegmentsCacheInMemory.ts +0 -49
  728. package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +0 -68
  729. package/src/storages/inMemory/SegmentsCacheInMemory.ts +0 -74
  730. package/src/storages/inMemory/SplitsCacheInMemory.ts +0 -130
  731. package/src/storages/inMemory/TelemetryCacheInMemory.ts +0 -263
  732. package/src/storages/inMemory/UniqueKeysCacheInMemory.ts +0 -79
  733. package/src/storages/inMemory/UniqueKeysCacheInMemoryCS.ts +0 -80
  734. package/src/storages/inRedis/EventsCacheInRedis.ts +0 -75
  735. package/src/storages/inRedis/ImpressionCountsCacheInRedis.ts +0 -95
  736. package/src/storages/inRedis/ImpressionsCacheInRedis.ts +0 -61
  737. package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +0 -79
  738. package/src/storages/inRedis/RedisAdapter.ts +0 -209
  739. package/src/storages/inRedis/SegmentsCacheInRedis.ts +0 -70
  740. package/src/storages/inRedis/SplitsCacheInRedis.ts +0 -268
  741. package/src/storages/inRedis/TelemetryCacheInRedis.ts +0 -144
  742. package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +0 -75
  743. package/src/storages/inRedis/constants.ts +0 -4
  744. package/src/storages/inRedis/index.ts +0 -85
  745. package/src/storages/package.json +0 -3
  746. package/src/storages/pluggable/EventsCachePluggable.ts +0 -79
  747. package/src/storages/pluggable/ImpressionCountsCachePluggable.ts +0 -92
  748. package/src/storages/pluggable/ImpressionsCachePluggable.ts +0 -63
  749. package/src/storages/pluggable/RBSegmentsCachePluggable.ts +0 -76
  750. package/src/storages/pluggable/SegmentsCachePluggable.ts +0 -90
  751. package/src/storages/pluggable/SplitsCachePluggable.ts +0 -230
  752. package/src/storages/pluggable/TelemetryCachePluggable.ts +0 -159
  753. package/src/storages/pluggable/UniqueKeysCachePluggable.ts +0 -67
  754. package/src/storages/pluggable/constants.ts +0 -1
  755. package/src/storages/pluggable/inMemoryWrapper.ts +0 -130
  756. package/src/storages/pluggable/index.ts +0 -152
  757. package/src/storages/pluggable/wrapperAdapter.ts +0 -58
  758. package/src/storages/types.ts +0 -538
  759. package/src/storages/utils.ts +0 -80
  760. package/src/sync/offline/LocalhostFromObject.ts +0 -6
  761. package/src/sync/offline/splitsParser/parseCondition.ts +0 -59
  762. package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +0 -72
  763. package/src/sync/offline/splitsParser/types.ts +0 -5
  764. package/src/sync/offline/syncManagerOffline.ts +0 -66
  765. package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +0 -97
  766. package/src/sync/polling/fetchers/mySegmentsFetcher.ts +0 -25
  767. package/src/sync/polling/fetchers/segmentChangesFetcher.ts +0 -41
  768. package/src/sync/polling/fetchers/splitChangesFetcher.ts +0 -85
  769. package/src/sync/polling/fetchers/types.ts +0 -25
  770. package/src/sync/polling/pollingManagerCS.ts +0 -116
  771. package/src/sync/polling/pollingManagerSS.ts +0 -56
  772. package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +0 -34
  773. package/src/sync/polling/syncTasks/segmentsSyncTask.ts +0 -30
  774. package/src/sync/polling/syncTasks/splitsSyncTask.ts +0 -35
  775. package/src/sync/polling/types.ts +0 -33
  776. package/src/sync/polling/updaters/mySegmentsUpdater.ts +0 -104
  777. package/src/sync/polling/updaters/segmentChangesUpdater.ts +0 -92
  778. package/src/sync/polling/updaters/splitChangesUpdater.ts +0 -220
  779. package/src/sync/streaming/AuthClient/index.ts +0 -42
  780. package/src/sync/streaming/AuthClient/types.ts +0 -20
  781. package/src/sync/streaming/SSEClient/index.ts +0 -103
  782. package/src/sync/streaming/SSEClient/types.ts +0 -13
  783. package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +0 -107
  784. package/src/sync/streaming/SSEHandler/NotificationParser.ts +0 -40
  785. package/src/sync/streaming/SSEHandler/index.ts +0 -105
  786. package/src/sync/streaming/SSEHandler/types.ts +0 -73
  787. package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +0 -134
  788. package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +0 -99
  789. package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +0 -145
  790. package/src/sync/streaming/UpdateWorkers/constants.ts +0 -3
  791. package/src/sync/streaming/UpdateWorkers/types.ts +0 -4
  792. package/src/sync/streaming/constants.ts +0 -44
  793. package/src/sync/streaming/parseUtils.ts +0 -100
  794. package/src/sync/streaming/pushManager.ts +0 -358
  795. package/src/sync/streaming/types.ts +0 -51
  796. package/src/sync/submitters/eventsSubmitter.ts +0 -35
  797. package/src/sync/submitters/impressionCountsSubmitter.ts +0 -44
  798. package/src/sync/submitters/impressionsSubmitter.ts +0 -66
  799. package/src/sync/submitters/submitter.ts +0 -76
  800. package/src/sync/submitters/submitterManager.ts +0 -48
  801. package/src/sync/submitters/telemetrySubmitter.ts +0 -148
  802. package/src/sync/submitters/types.ts +0 -241
  803. package/src/sync/submitters/uniqueKeysSubmitter.ts +0 -35
  804. package/src/sync/syncManagerOnline.ts +0 -195
  805. package/src/sync/syncTask.ts +0 -83
  806. package/src/sync/types.ts +0 -48
  807. package/src/trackers/eventTracker.ts +0 -72
  808. package/src/trackers/impressionObserver/ImpressionObserver.ts +0 -20
  809. package/src/trackers/impressionObserver/buildKey.ts +0 -5
  810. package/src/trackers/impressionObserver/impressionObserverCS.ts +0 -14
  811. package/src/trackers/impressionObserver/impressionObserverSS.ts +0 -14
  812. package/src/trackers/impressionObserver/types.ts +0 -5
  813. package/src/trackers/impressionsTracker.ts +0 -87
  814. package/src/trackers/strategy/strategyDebug.ts +0 -23
  815. package/src/trackers/strategy/strategyNone.ts +0 -28
  816. package/src/trackers/strategy/strategyOptimized.ts +0 -35
  817. package/src/trackers/telemetryTracker.ts +0 -73
  818. package/src/trackers/types.ts +0 -86
  819. package/src/trackers/uniqueKeysTracker.ts +0 -50
  820. package/src/types.ts +0 -79
  821. package/src/utils/Backoff.ts +0 -51
  822. package/src/utils/LRUCache/LinkedList.ts +0 -130
  823. package/src/utils/LRUCache/index.ts +0 -43
  824. package/src/utils/MinEventEmitter.ts +0 -102
  825. package/src/utils/Semver.ts +0 -111
  826. package/src/utils/base64/index.ts +0 -74
  827. package/src/utils/constants/index.ts +0 -116
  828. package/src/utils/decompress/index.ts +0 -429
  829. package/src/utils/env/isLocalStorageAvailable.ts +0 -32
  830. package/src/utils/env/isNode.ts +0 -6
  831. package/src/utils/inputValidation/apiKey.ts +0 -52
  832. package/src/utils/inputValidation/attribute.ts +0 -21
  833. package/src/utils/inputValidation/attributes.ts +0 -26
  834. package/src/utils/inputValidation/event.ts +0 -24
  835. package/src/utils/inputValidation/eventProperties.ts +0 -78
  836. package/src/utils/inputValidation/eventValue.ts +0 -11
  837. package/src/utils/inputValidation/index.ts +0 -14
  838. package/src/utils/inputValidation/isOperational.ts +0 -17
  839. package/src/utils/inputValidation/key.ts +0 -51
  840. package/src/utils/inputValidation/preloadedData.ts +0 -57
  841. package/src/utils/inputValidation/split.ts +0 -27
  842. package/src/utils/inputValidation/splitExistence.ts +0 -19
  843. package/src/utils/inputValidation/splits.ts +0 -21
  844. package/src/utils/inputValidation/trafficType.ts +0 -27
  845. package/src/utils/inputValidation/trafficTypeExistence.ts +0 -33
  846. package/src/utils/jwt/index.ts +0 -16
  847. package/src/utils/jwt/types.ts +0 -10
  848. package/src/utils/key/index.ts +0 -34
  849. package/src/utils/labels/index.ts +0 -9
  850. package/src/utils/lang/binarySearch.ts +0 -41
  851. package/src/utils/lang/getFnName.ts +0 -8
  852. package/src/utils/lang/getGlobal.ts +0 -17
  853. package/src/utils/lang/index.ts +0 -279
  854. package/src/utils/lang/objectAssign.ts +0 -25
  855. package/src/utils/lang/sets.ts +0 -17
  856. package/src/utils/murmur3/common.ts +0 -54
  857. package/src/utils/murmur3/legacy.ts +0 -48
  858. package/src/utils/murmur3/murmur3.ts +0 -74
  859. package/src/utils/murmur3/murmur3_128.ts +0 -273
  860. package/src/utils/murmur3/murmur3_128_x86.ts +0 -188
  861. package/src/utils/murmur3/murmur3_64.ts +0 -36
  862. package/src/utils/murmur3/utfx.ts +0 -109
  863. package/src/utils/promise/thenable.ts +0 -4
  864. package/src/utils/promise/timeout.ts +0 -17
  865. package/src/utils/promise/wrapper.ts +0 -60
  866. package/src/utils/settingsValidation/consent.ts +0 -16
  867. package/src/utils/settingsValidation/impressionsMode.ts +0 -14
  868. package/src/utils/settingsValidation/index.ts +0 -207
  869. package/src/utils/settingsValidation/integrations/common.ts +0 -27
  870. package/src/utils/settingsValidation/integrations/configurable.ts +0 -20
  871. package/src/utils/settingsValidation/integrations/pluggable.ts +0 -19
  872. package/src/utils/settingsValidation/logger/builtinLogger.ts +0 -54
  873. package/src/utils/settingsValidation/logger/commons.ts +0 -24
  874. package/src/utils/settingsValidation/logger/pluggableLogger.ts +0 -35
  875. package/src/utils/settingsValidation/mode.ts +0 -17
  876. package/src/utils/settingsValidation/runtime.ts +0 -9
  877. package/src/utils/settingsValidation/splitFilters.ts +0 -197
  878. package/src/utils/settingsValidation/storage/storageCS.ts +0 -52
  879. package/src/utils/settingsValidation/types.ts +0 -27
  880. package/src/utils/settingsValidation/url.ts +0 -30
  881. package/src/utils/time/index.ts +0 -8
  882. package/src/utils/timeTracker/now/browser.ts +0 -12
  883. package/src/utils/timeTracker/now/node.ts +0 -6
  884. package/src/utils/timeTracker/timer.ts +0 -7
@@ -1,145 +0,0 @@
1
- import { IRBSegment, ISplit } from '../../../dtos/types';
2
- import { STREAMING_PARSING_SPLIT_UPDATE } from '../../../logger/constants';
3
- import { ILogger } from '../../../logger/types';
4
- import { SDK_SPLITS_ARRIVED } from '../../../readiness/constants';
5
- import { ISplitsEventEmitter } from '../../../readiness/types';
6
- import { IRBSegmentsCacheSync, ISplitsCacheSync, IStorageSync } from '../../../storages/types';
7
- import { ITelemetryTracker } from '../../../trackers/types';
8
- import { Backoff } from '../../../utils/Backoff';
9
- import { SPLITS } from '../../../utils/constants';
10
- import { ISegmentsSyncTask, ISplitsSyncTask } from '../../polling/types';
11
- import { InstantUpdate } from '../../polling/updaters/splitChangesUpdater';
12
- import { RB_SEGMENT_UPDATE } from '../constants';
13
- import { parseFFUpdatePayload } from '../parseUtils';
14
- import { ISplitKillData, ISplitUpdateData } from '../SSEHandler/types';
15
- import { FETCH_BACKOFF_BASE, FETCH_BACKOFF_MAX_WAIT, FETCH_BACKOFF_MAX_RETRIES } from './constants';
16
- import { IUpdateWorker } from './types';
17
-
18
- /**
19
- * SplitsUpdateWorker factory
20
- */
21
- export function SplitsUpdateWorker(log: ILogger, storage: IStorageSync, splitsSyncTask: ISplitsSyncTask, splitsEventEmitter: ISplitsEventEmitter, telemetryTracker: ITelemetryTracker, segmentsSyncTask?: ISegmentsSyncTask): IUpdateWorker<[updateData: ISplitUpdateData]> & { killSplit(event: ISplitKillData): void } {
22
-
23
- const ff = SplitsUpdateWorker(storage.splits);
24
- const rbs = SplitsUpdateWorker(storage.rbSegments);
25
-
26
- function SplitsUpdateWorker(cache: ISplitsCacheSync | IRBSegmentsCacheSync) {
27
- let maxChangeNumber = -1;
28
- let handleNewEvent = false;
29
- let isHandlingEvent: boolean;
30
- let cdnBypass: boolean;
31
- let instantUpdate: InstantUpdate | undefined;
32
- const backoff = new Backoff(__handleSplitUpdateCall, FETCH_BACKOFF_BASE, FETCH_BACKOFF_MAX_WAIT);
33
-
34
- function __handleSplitUpdateCall() {
35
- isHandlingEvent = true;
36
- if (maxChangeNumber > cache.getChangeNumber()) {
37
- handleNewEvent = false;
38
- // fetch splits revalidating data if cached
39
- splitsSyncTask.execute(true, cdnBypass ? maxChangeNumber : undefined, instantUpdate).then(() => {
40
- if (!isHandlingEvent) return; // halt if `stop` has been called
41
- if (handleNewEvent) {
42
- __handleSplitUpdateCall();
43
- } else {
44
- if (instantUpdate) telemetryTracker.trackUpdatesFromSSE(SPLITS);
45
- // fetch new registered segments for server-side API. Not retrying on error
46
- if (segmentsSyncTask) segmentsSyncTask.execute(true);
47
-
48
- const attempts = backoff.attempts + 1;
49
-
50
- if (ff.isSync() && rbs.isSync()) {
51
- log.debug(`Refresh completed${cdnBypass ? ' bypassing the CDN' : ''} in ${attempts} attempts.`);
52
- isHandlingEvent = false;
53
- return;
54
- }
55
-
56
- if (attempts < FETCH_BACKOFF_MAX_RETRIES) {
57
- backoff.scheduleCall();
58
- return;
59
- }
60
-
61
- if (cdnBypass) {
62
- log.debug(`No changes fetched after ${attempts} attempts with CDN bypassed.`);
63
- isHandlingEvent = false;
64
- } else {
65
- backoff.reset();
66
- cdnBypass = true;
67
- __handleSplitUpdateCall();
68
- }
69
- }
70
- });
71
- } else {
72
- isHandlingEvent = false;
73
- }
74
- }
75
-
76
- return {
77
- /**
78
- * Invoked by NotificationProcessor on SPLIT_UPDATE or RB_SEGMENT_UPDATE event
79
- *
80
- * @param changeNumber - change number of the notification
81
- */
82
- put({ changeNumber, pcn, type }: ISplitUpdateData, payload?: ISplit | IRBSegment) {
83
- const currentChangeNumber = cache.getChangeNumber();
84
-
85
- if (changeNumber <= currentChangeNumber || changeNumber <= maxChangeNumber) return;
86
-
87
- maxChangeNumber = changeNumber;
88
- handleNewEvent = true;
89
- cdnBypass = false;
90
- instantUpdate = undefined;
91
-
92
- if (payload && currentChangeNumber === pcn) {
93
- instantUpdate = { payload, changeNumber, type };
94
- }
95
-
96
- if (backoff.timeoutID || !isHandlingEvent) __handleSplitUpdateCall();
97
- backoff.reset();
98
- },
99
- stop() {
100
- isHandlingEvent = false;
101
- backoff.reset();
102
- },
103
- isSync() {
104
- return maxChangeNumber <= cache.getChangeNumber();
105
- }
106
- };
107
- }
108
-
109
- return {
110
- put(parsedData) {
111
- if (parsedData.d && parsedData.c !== undefined) {
112
- try {
113
- const payload = parseFFUpdatePayload(parsedData.c, parsedData.d);
114
- if (payload) {
115
- (parsedData.type === RB_SEGMENT_UPDATE ? rbs : ff).put(parsedData, payload);
116
- return;
117
- }
118
- } catch (e) {
119
- log.warn(STREAMING_PARSING_SPLIT_UPDATE, [parsedData.type, e]);
120
- }
121
- }
122
- (parsedData.type === RB_SEGMENT_UPDATE ? rbs : ff).put(parsedData);
123
- },
124
- /**
125
- * Invoked by NotificationProcessor on SPLIT_KILL event
126
- *
127
- * @param changeNumber - change number of the notification
128
- * @param splitName - name of split to kill
129
- * @param defaultTreatment - default treatment value
130
- */
131
- killSplit({ changeNumber, splitName, defaultTreatment }: ISplitKillData) {
132
- if (storage.splits.killLocally(splitName, defaultTreatment, changeNumber)) {
133
- // trigger an SDK_UPDATE if Split was killed locally
134
- splitsEventEmitter.emit(SDK_SPLITS_ARRIVED, true);
135
- }
136
- // queues the SplitChanges fetch (only if changeNumber is newer)
137
- ff.put({ changeNumber } as ISplitUpdateData);
138
- },
139
-
140
- stop() {
141
- ff.stop();
142
- rbs.stop();
143
- }
144
- };
145
- }
@@ -1,3 +0,0 @@
1
- export const FETCH_BACKOFF_BASE = 10000; // backoff base starting at 10 seconds
2
- export const FETCH_BACKOFF_MAX_WAIT = 60000; // don't wait for more than 1 minute
3
- export const FETCH_BACKOFF_MAX_RETRIES = 10; // max retries
@@ -1,4 +0,0 @@
1
- export interface IUpdateWorker<T extends any[]> {
2
- stop(): void // clear scheduled tasks (backoff)
3
- put(...args: T): void // handle new update event
4
- }
@@ -1,44 +0,0 @@
1
- // time for refresh token
2
- export const SECONDS_BEFORE_EXPIRATION = 600;
3
-
4
- // Internal SDK events, subscribed by SyncManager and PushManager
5
- /**
6
- * emitted on SSE and Authenticate non-recoverable errors, STREAMING_DISABLED control notification and authentication with pushEnabled false
7
- * triggers `handleNonRetryableError` call
8
- */
9
- export const PUSH_NONRETRYABLE_ERROR = 'PUSH_NONRETRYABLE_ERROR';
10
- /**
11
- * emitted on SSE and Authenticate recoverable errors
12
- * triggers `handleRetryableError` call
13
- */
14
- export const PUSH_RETRYABLE_ERROR = 'PUSH_RETRYABLE_ERROR';
15
- /**
16
- * emitted on STREAMING_RESUMED control notification, OCCUPANCY different than 0, and SSE onopen event
17
- * triggers `stopPollingAndSyncAll` call
18
- */
19
- export const PUSH_SUBSYSTEM_UP = 'PUSH_SUBSYSTEM_UP';
20
-
21
- /**
22
- * emitted on STREAMING_PAUSED control notification, OCCUPANCY equal to 0, PUSH_NONRETRYABLE_ERROR and PUSH_RETRYABLE_ERROR events.
23
- * triggers `startPolling` and `stopWorkers` calls
24
- */
25
- export const PUSH_SUBSYSTEM_DOWN = 'PUSH_SUBSYSTEM_DOWN';
26
-
27
- // Update-type push notifications, handled by NotificationProcessor
28
- export const MEMBERSHIPS_MS_UPDATE = 'MEMBERSHIPS_MS_UPDATE';
29
- export const MEMBERSHIPS_LS_UPDATE = 'MEMBERSHIPS_LS_UPDATE';
30
- export const SEGMENT_UPDATE = 'SEGMENT_UPDATE';
31
- export const SPLIT_KILL = 'SPLIT_KILL';
32
- export const SPLIT_UPDATE = 'SPLIT_UPDATE';
33
- export const RB_SEGMENT_UPDATE = 'RB_SEGMENT_UPDATE';
34
-
35
- // Control-type push notifications, handled by NotificationKeeper
36
- export const CONTROL = 'CONTROL';
37
- export const OCCUPANCY = 'OCCUPANCY';
38
-
39
- export enum ControlType {
40
- STREAMING_DISABLED = 'STREAMING_DISABLED',
41
- STREAMING_PAUSED = 'STREAMING_PAUSED',
42
- STREAMING_RESUMED = 'STREAMING_RESUMED',
43
- STREAMING_RESET = 'STREAMING_RESET',
44
- }
@@ -1,100 +0,0 @@
1
- import { algorithms } from '../../utils/decompress';
2
- import { decodeFromBase64 } from '../../utils/base64';
3
- import { hash } from '../../utils/murmur3/murmur3';
4
- import { Compression, IMembershipMSUpdateData, KeyList } from './SSEHandler/types';
5
- import { IRBSegment, ISplit } from '../../dtos/types';
6
-
7
- const GZIP = 1;
8
- const ZLIB = 2;
9
-
10
- function Uint8ArrayToString(myUint8Arr: Uint8Array) { // @ts-ignore
11
- return String.fromCharCode.apply(null, myUint8Arr);
12
- }
13
-
14
- function StringToUint8Array(myString: string) {
15
- const charCodes = myString.split('').map((e) => e.charCodeAt(0));
16
- return new Uint8Array(charCodes);
17
- }
18
-
19
- /**
20
- * Decode and decompress 'data' with 'compression' algorithm
21
- *
22
- * @param data - base64 encoded string
23
- * @param compression - 1 GZIP, 2 ZLIB
24
- * @returns
25
- * @throws if data string cannot be decoded, decompressed or the provided compression value is invalid (not 1 or 2)
26
- */
27
- function decompress(data: string, compression: Compression) {
28
- let compressData = decodeFromBase64(data);
29
- const binData = StringToUint8Array(compressData);
30
-
31
- if (typeof algorithms === 'string') throw new Error(algorithms);
32
- if (compression === GZIP) return algorithms.gunzipSync(binData);
33
- if (compression === ZLIB) return algorithms.unzlibSync(binData);
34
- throw new Error(`Invalid compression algorithm #${compression}`);
35
- }
36
-
37
- /**
38
- * Decode, decompress and parse the provided 'data' into a KeyList object
39
- *
40
- * @param data - base64 encoded string
41
- * @param compression - 1 GZIP, 2 ZLIB
42
- * @param avoidPrecisionLoss - true as default, set it as false if dont need to avoid precission loss
43
- * @returns keyList
44
- * @throws if data string cannot be decoded, decompressed or parsed
45
- */
46
- export function parseKeyList(data: string, compression: Compression, avoidPrecisionLoss = true): KeyList {
47
- const binKeyList = decompress(data, compression);
48
- let strKeyList = Uint8ArrayToString(binKeyList);
49
- // replace numbers to strings, to avoid losing precision
50
- if (avoidPrecisionLoss) strKeyList = strKeyList.replace(/\d+/g, '"$&"');
51
- return JSON.parse(strKeyList);
52
- }
53
-
54
- /**
55
- * Decode, decompress and parse the provided 'data' into a Bitmap object
56
- *
57
- * @param data - base64 encoded string
58
- * @param compression - 1 GZIP, 2 ZLIB
59
- * @returns Bitmap
60
- * @throws if data string cannot be decoded or decompressed
61
- */
62
- export function parseBitmap(data: string, compression: Compression) {
63
- return decompress(data, compression);
64
- }
65
-
66
- /**
67
- * Check if the 'bitmap' bit at 'hash64hex' position is 1
68
- *
69
- * @param bitmap - Uint8Array bitmap
70
- * @param hash64hex - 16-chars string, representing a number in hexa
71
- * @returns whether the provided 'hash64hex' index is set in the bitmap
72
- */
73
- export function isInBitmap(bitmap: Uint8Array, hash64hex: string) {
74
- // using the lowest 32 bits as index, to avoid losing precision when converting to number
75
- const index = parseInt(hash64hex.slice(8), 16) % (bitmap.length * 8);
76
-
77
- const internal = Math.floor(index / 8);
78
- const offset = index % 8;
79
- return (bitmap[internal] & 1 << offset) > 0;
80
- }
81
-
82
- /**
83
- * Parse feature flags notifications for instant feature flag updates
84
- */
85
- export function parseFFUpdatePayload(compression: Compression, data: string): ISplit | IRBSegment | undefined {
86
- return compression > 0 ?
87
- parseKeyList(data, compression, false) :
88
- JSON.parse(decodeFromBase64(data));
89
- }
90
-
91
- const DEFAULT_MAX_INTERVAL = 60000;
92
-
93
- export function getDelay(parsedData: Pick<IMembershipMSUpdateData, 'i' | 'h' | 's'>, matchingKey: string) {
94
- if (parsedData.h === 0) return 0;
95
-
96
- const interval = parsedData.i || DEFAULT_MAX_INTERVAL;
97
- const seed = parsedData.s || 0;
98
-
99
- return hash(matchingKey, seed) % interval;
100
- }
@@ -1,358 +0,0 @@
1
- import { IPushEventEmitter, IPushManager } from './types';
2
- import { ISSEClient } from './SSEClient/types';
3
- import { IMySegmentsSyncTask, IPollingManager, ISegmentsSyncTask } from '../polling/types';
4
- import { objectAssign } from '../../utils/lang/objectAssign';
5
- import { Backoff } from '../../utils/Backoff';
6
- import { SSEHandlerFactory } from './SSEHandler';
7
- import { MySegmentsUpdateWorker } from './UpdateWorkers/MySegmentsUpdateWorker';
8
- import { SegmentsUpdateWorker } from './UpdateWorkers/SegmentsUpdateWorker';
9
- import { SplitsUpdateWorker } from './UpdateWorkers/SplitsUpdateWorker';
10
- import { authenticateFactory, hashUserKey } from './AuthClient';
11
- import { forOwn } from '../../utils/lang';
12
- import { SSEClient } from './SSEClient';
13
- import { getMatching } from '../../utils/key';
14
- import { MEMBERSHIPS_MS_UPDATE, MEMBERSHIPS_LS_UPDATE, PUSH_NONRETRYABLE_ERROR, PUSH_SUBSYSTEM_DOWN, SECONDS_BEFORE_EXPIRATION, SEGMENT_UPDATE, SPLIT_KILL, SPLIT_UPDATE, RB_SEGMENT_UPDATE, PUSH_RETRYABLE_ERROR, PUSH_SUBSYSTEM_UP, ControlType } from './constants';
15
- import { STREAMING_FALLBACK, STREAMING_REFRESH_TOKEN, STREAMING_CONNECTING, STREAMING_DISABLED, ERROR_STREAMING_AUTH, STREAMING_DISCONNECTING, STREAMING_RECONNECT, STREAMING_PARSING_MEMBERSHIPS_UPDATE } from '../../logger/constants';
16
- import { IMembershipMSUpdateData, IMembershipLSUpdateData, KeyList, UpdateStrategy } from './SSEHandler/types';
17
- import { getDelay, isInBitmap, parseBitmap, parseKeyList } from './parseUtils';
18
- import { Hash64, hash64 } from '../../utils/murmur3/murmur3_64';
19
- import { IAuthTokenPushEnabled } from './AuthClient/types';
20
- import { TOKEN_REFRESH, AUTH_REJECTION } from '../../utils/constants';
21
- import { ISdkFactoryContextSync } from '../../sdkFactory/types';
22
-
23
- /**
24
- * PushManager factory:
25
- * - for server-side if key is not provided in settings.
26
- * - for client-side, with support for multiple clients, if key is provided in settings
27
- */
28
- export function pushManagerFactory(
29
- params: ISdkFactoryContextSync,
30
- pollingManager: IPollingManager,
31
- ): IPushManager | undefined {
32
-
33
- const { settings, storage, splitApi, readiness, platform, telemetryTracker } = params;
34
-
35
- // `userKey` is the matching key of main client in client-side SDK.
36
- // It can be used to check if running on client-side or server-side SDK.
37
- const userKey = settings.core.key ? getMatching(settings.core.key) : undefined;
38
- const log = settings.log;
39
-
40
- let sseClient: ISSEClient;
41
- try {
42
- // `useHeaders` false for client-side, even if the platform EventSource supports headers (e.g., React Native).
43
- sseClient = new SSEClient(settings, platform);
44
- } catch (e) {
45
- log.warn(STREAMING_FALLBACK, [e]);
46
- return;
47
- }
48
- const authenticate = authenticateFactory(splitApi.fetchAuth);
49
-
50
- // init feedback loop
51
- const pushEmitter = new platform.EventEmitter() as IPushEventEmitter;
52
- const sseHandler = SSEHandlerFactory(log, pushEmitter, telemetryTracker);
53
- sseClient.setEventHandler(sseHandler);
54
-
55
- // init workers
56
- // MySegmentsUpdateWorker (client-side) are initiated in `add` method
57
- const segmentsUpdateWorker = userKey ? undefined : SegmentsUpdateWorker(log, pollingManager.segmentsSyncTask as ISegmentsSyncTask, storage.segments);
58
- // For server-side we pass the segmentsSyncTask, used by SplitsUpdateWorker to fetch new segments
59
- const splitsUpdateWorker = SplitsUpdateWorker(log, storage, pollingManager.splitsSyncTask, readiness.splits, telemetryTracker, userKey ? undefined : pollingManager.segmentsSyncTask as ISegmentsSyncTask);
60
-
61
- // [Only for client-side] map of hashes to user keys, to dispatch membership update events to the corresponding MySegmentsUpdateWorker
62
- const userKeyHashes: Record<string, string> = {};
63
- // [Only for client-side] map of user keys to their corresponding hash64 and MySegmentsUpdateWorkers.
64
- // Hash64 is used to process membership update events and dispatch actions to the corresponding MySegmentsUpdateWorker.
65
- const clients: Record<string, { hash64: Hash64, worker: ReturnType<typeof MySegmentsUpdateWorker> }> = {};
66
-
67
- // [Only for client-side] variable to flag that a new client was added. It is needed to reconnect streaming.
68
- let connectForNewClient = false;
69
-
70
- // flag that indicates if `stop/disconnectPush` was called, either by the SyncManager, when the client is destroyed, or due to a PUSH_NONRETRYABLE_ERROR error.
71
- // It is used to halt the `connectPush` process if it was in progress.
72
- let disconnected: boolean | undefined;
73
- // flag that indicates a PUSH_NONRETRYABLE_ERROR, condition with which starting pushManager again is ignored.
74
- // true if STREAMING_DISABLED control event, or 'pushEnabled: false', or non-recoverable SSE or Auth errors.
75
- let disabled: boolean | undefined; // `disabled` implies `disconnected === true`
76
-
77
- /** PushManager functions related to initialization */
78
-
79
- const connectPushRetryBackoff = new Backoff(connectPush, settings.scheduler.pushRetryBackoffBase);
80
-
81
- let timeoutIdTokenRefresh: ReturnType<typeof setTimeout>;
82
- let timeoutIdSseOpen: ReturnType<typeof setTimeout>;
83
-
84
- function scheduleTokenRefreshAndSse(authData: IAuthTokenPushEnabled) {
85
- // clear scheduled tasks if exist
86
- if (timeoutIdTokenRefresh) clearTimeout(timeoutIdTokenRefresh);
87
- if (timeoutIdSseOpen) clearTimeout(timeoutIdSseOpen);
88
-
89
- // Set token refresh 10 minutes before `expirationTime - issuedAt`
90
- const decodedToken = authData.decodedToken;
91
- const refreshTokenDelay = decodedToken.exp - decodedToken.iat - SECONDS_BEFORE_EXPIRATION;
92
- // Default connDelay of 60 secs
93
- const connDelay = typeof authData.connDelay === 'number' && authData.connDelay >= 0 ? authData.connDelay : 60;
94
-
95
- log.info(STREAMING_REFRESH_TOKEN, [refreshTokenDelay, connDelay]);
96
-
97
- timeoutIdTokenRefresh = setTimeout(connectPush, refreshTokenDelay * 1000);
98
-
99
- timeoutIdSseOpen = setTimeout(() => {
100
- // halt if disconnected
101
- if (disconnected) return;
102
- sseClient.open(authData);
103
- }, connDelay * 1000);
104
-
105
- telemetryTracker.streamingEvent(TOKEN_REFRESH, decodedToken.exp);
106
- }
107
-
108
- function connectPush() {
109
- // Guard condition in case `stop/disconnectPush` has been called (e.g., calling SDK destroy, or app signal close/background)
110
- if (disconnected) return;
111
- // @TODO distinguish log for 'Connecting' (1st time) and 'Re-connecting'
112
- log.info(STREAMING_CONNECTING);
113
- disconnected = false;
114
-
115
- const userKeys = userKey ? Object.keys(clients) : undefined;
116
- authenticate(userKeys).then(
117
- function (authData) {
118
- if (disconnected) return;
119
-
120
- // 'pushEnabled: false' is handled as a PUSH_NONRETRYABLE_ERROR instead of PUSH_SUBSYSTEM_DOWN, in order to
121
- // close the sseClient in case the org has been bloqued while the instance was connected to streaming
122
- if (!authData.pushEnabled) {
123
- log.info(STREAMING_DISABLED);
124
- pushEmitter.emit(PUSH_NONRETRYABLE_ERROR);
125
- return;
126
- }
127
-
128
- // [Only for client-side] don't open SSE connection if a new shared client was added, since it means that a new authentication is taking place
129
- if (userKeys && userKeys.length < Object.keys(clients).length) return;
130
-
131
- // Schedule SSE connection and refresh token
132
- scheduleTokenRefreshAndSse(authData);
133
- }
134
- ).catch(
135
- function (error) {
136
- if (disconnected) return;
137
-
138
- log.error(ERROR_STREAMING_AUTH, [error.message]);
139
-
140
- // Handle 4XX HTTP errors: 401 (invalid SDK Key) or 400 (using incorrect SDK Key, i.e., client-side SDK Key on server-side)
141
- if (error.statusCode >= 400 && error.statusCode < 500) {
142
- telemetryTracker.streamingEvent(AUTH_REJECTION);
143
- pushEmitter.emit(PUSH_NONRETRYABLE_ERROR);
144
- return;
145
- }
146
-
147
- // Handle other HTTP and network errors as recoverable errors
148
- pushEmitter.emit(PUSH_RETRYABLE_ERROR);
149
- }
150
- );
151
- }
152
-
153
- // close SSE connection and cancel scheduled tasks
154
- function disconnectPush() {
155
- // Halt disconnecting, just to avoid redundant logs if called multiple times
156
- if (disconnected) return;
157
- disconnected = true;
158
-
159
- sseClient.close();
160
- log.info(STREAMING_DISCONNECTING);
161
-
162
- if (timeoutIdTokenRefresh) clearTimeout(timeoutIdTokenRefresh);
163
- if (timeoutIdSseOpen) clearTimeout(timeoutIdSseOpen);
164
- connectPushRetryBackoff.reset();
165
-
166
- stopWorkers();
167
- }
168
-
169
- // cancel scheduled fetch retries of Splits, Segments, and MySegments Update Workers
170
- function stopWorkers() {
171
- splitsUpdateWorker.stop();
172
- if (userKey) forOwn(clients, ({ worker }) => worker.stop());
173
- else segmentsUpdateWorker!.stop();
174
- }
175
-
176
- pushEmitter.on(PUSH_SUBSYSTEM_DOWN, stopWorkers);
177
-
178
- // Only required when streaming connects after a PUSH_RETRYABLE_ERROR.
179
- // Otherwise it is unnecessary (e.g, STREAMING_RESUMED).
180
- pushEmitter.on(PUSH_SUBSYSTEM_UP, () => {
181
- connectPushRetryBackoff.reset();
182
- });
183
-
184
- /** Fallback to polling without retry due to: STREAMING_DISABLED control event, or 'pushEnabled: false', or non-recoverable SSE and Authentication errors */
185
-
186
- pushEmitter.on(PUSH_NONRETRYABLE_ERROR, function handleNonRetryableError() {
187
- disabled = true;
188
- // Note: `stopWorkers` is been called twice, but it is not harmful
189
- disconnectPush();
190
- pushEmitter.emit(PUSH_SUBSYSTEM_DOWN); // no harm if polling already
191
- });
192
-
193
- /** Fallback to polling with retry due to recoverable SSE and Authentication errors */
194
-
195
- pushEmitter.on(PUSH_RETRYABLE_ERROR, function handleRetryableError() { // HTTP or network error in SSE connection
196
- // SSE connection is closed to avoid repeated errors due to retries
197
- sseClient.close();
198
-
199
- // retry streaming reconnect with backoff algorithm
200
- let delayInMillis = connectPushRetryBackoff.scheduleCall();
201
-
202
- log.info(STREAMING_RECONNECT, [delayInMillis / 1000]);
203
-
204
- pushEmitter.emit(PUSH_SUBSYSTEM_DOWN); // no harm if polling already
205
- });
206
-
207
- /** STREAMING_RESET notification. Unlike a PUSH_RETRYABLE_ERROR, it doesn't emit PUSH_SUBSYSTEM_DOWN to fallback polling */
208
-
209
- pushEmitter.on(ControlType.STREAMING_RESET, function handleStreamingReset() {
210
- if (disconnected) return; // should never happen
211
-
212
- // Minimum required clean-up.
213
- // `disconnectPush` cannot be called because it sets `disconnected` and thus `connectPush` will not execute
214
- if (timeoutIdTokenRefresh) clearTimeout(timeoutIdTokenRefresh);
215
-
216
- connectPush();
217
- });
218
-
219
- /** Functions related to synchronization (Queues and Workers in the spec) */
220
-
221
- pushEmitter.on(SPLIT_KILL, splitsUpdateWorker.killSplit);
222
- pushEmitter.on(SPLIT_UPDATE, splitsUpdateWorker.put);
223
- pushEmitter.on(RB_SEGMENT_UPDATE, splitsUpdateWorker.put);
224
-
225
- function handleMySegmentsUpdate(parsedData: IMembershipMSUpdateData | IMembershipLSUpdateData) {
226
- switch (parsedData.u) {
227
- case UpdateStrategy.BoundedFetchRequest: {
228
- let bitmap: Uint8Array;
229
- try {
230
- bitmap = parseBitmap(parsedData.d!, parsedData.c!);
231
- } catch (e) {
232
- log.warn(STREAMING_PARSING_MEMBERSHIPS_UPDATE, ['BoundedFetchRequest', e]);
233
- break;
234
- }
235
-
236
- forOwn(clients, ({ hash64, worker }, matchingKey) => {
237
- if (isInBitmap(bitmap, hash64.hex)) {
238
- worker.put(parsedData, undefined, getDelay(parsedData, matchingKey));
239
- }
240
- });
241
- return;
242
- }
243
- case UpdateStrategy.KeyList: {
244
- let keyList: KeyList, added: Set<string>, removed: Set<string>;
245
- try {
246
- keyList = parseKeyList(parsedData.d!, parsedData.c!);
247
- added = new Set(keyList.a);
248
- removed = new Set(keyList.r);
249
- } catch (e) {
250
- log.warn(STREAMING_PARSING_MEMBERSHIPS_UPDATE, ['KeyList', e]);
251
- break;
252
- }
253
-
254
- if (!parsedData.n || !parsedData.n.length) {
255
- log.warn(STREAMING_PARSING_MEMBERSHIPS_UPDATE, ['KeyList', 'No segment name was provided']);
256
- break;
257
- }
258
-
259
- forOwn(clients, ({ hash64, worker }) => {
260
- const add = added.has(hash64.dec) ? true : removed.has(hash64.dec) ? false : undefined;
261
- if (add !== undefined) {
262
- worker.put(parsedData, {
263
- added: add ? [parsedData.n![0]] : [],
264
- removed: add ? [] : [parsedData.n![0]]
265
- });
266
- }
267
- });
268
- return;
269
- }
270
- case UpdateStrategy.SegmentRemoval:
271
- if (!parsedData.n || !parsedData.n.length) {
272
- log.warn(STREAMING_PARSING_MEMBERSHIPS_UPDATE, ['SegmentRemoval', 'No segment name was provided']);
273
- break;
274
- }
275
-
276
- forOwn(clients, ({ worker }) => {
277
- worker.put(parsedData, {
278
- added: [],
279
- removed: parsedData.n!
280
- });
281
- });
282
- return;
283
- }
284
-
285
- // `UpdateStrategy.UnboundedFetchRequest` and fallbacks of other cases
286
- forOwn(clients, ({ worker }, matchingKey) => {
287
- worker.put(parsedData, undefined, getDelay(parsedData, matchingKey));
288
- });
289
- }
290
-
291
- if (userKey) {
292
- pushEmitter.on(MEMBERSHIPS_MS_UPDATE, handleMySegmentsUpdate);
293
- pushEmitter.on(MEMBERSHIPS_LS_UPDATE, handleMySegmentsUpdate);
294
- } else {
295
- pushEmitter.on(SEGMENT_UPDATE, segmentsUpdateWorker!.put);
296
- }
297
-
298
- return objectAssign(
299
- // Expose Event Emitter functionality and Event constants
300
- Object.create(pushEmitter),
301
- {
302
- // Stop/pause push mode.
303
- // It doesn't emit events. Neither PUSH_SUBSYSTEM_DOWN to start polling.
304
- stop() {
305
- disconnectPush(); // `handleNonRetryableError` cannot be used as `stop`, because it emits PUSH_SUBSYSTEM_DOWN event, which starts polling.
306
- if (userKey) this.remove(userKey); // Necessary to properly resume streaming in client-side (e.g., RN SDK transition to foreground).
307
- },
308
-
309
- // Start/resume push mode.
310
- // It eventually emits PUSH_SUBSYSTEM_DOWN, that starts polling, or PUSH_SUBSYSTEM_UP, that executes a syncAll
311
- start() {
312
- // Guard condition to avoid calling `connectPush` again if the `start` method is called multiple times or if push has been disabled.
313
- if (disabled || disconnected === false) return;
314
- disconnected = false;
315
-
316
- if (userKey) this.add(userKey, pollingManager.segmentsSyncTask); // client-side
317
- else setTimeout(connectPush); // server-side runs in next cycle as in client-side, for consistency with client-side
318
- },
319
-
320
- // true/false if start or stop was called last respectively
321
- isRunning() {
322
- return disconnected === false;
323
- },
324
-
325
- // [Only for client-side]
326
- add(userKey: string, mySegmentsSyncTask: IMySegmentsSyncTask) {
327
- const hash = hashUserKey(userKey);
328
-
329
- if (!userKeyHashes[hash]) {
330
- userKeyHashes[hash] = userKey;
331
- clients[userKey] = {
332
- hash64: hash64(userKey),
333
- worker: MySegmentsUpdateWorker(log, storage, mySegmentsSyncTask, telemetryTracker)
334
- };
335
- connectForNewClient = true; // we must reconnect on start, to listen the channel for the new user key
336
-
337
- // Reconnects in case of a new client.
338
- // Run in next event-loop cycle to save authentication calls
339
- // in case multiple clients are created in the current cycle.
340
- if (this.isRunning()) {
341
- setTimeout(function checkForReconnect() {
342
- if (connectForNewClient) {
343
- connectForNewClient = false;
344
- connectPush();
345
- }
346
- }, 0);
347
- }
348
- }
349
- },
350
- // [Only for client-side]
351
- remove(userKey: string) {
352
- const hash = hashUserKey(userKey);
353
- delete userKeyHashes[hash];
354
- delete clients[userKey];
355
- }
356
- }
357
- );
358
- }