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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (395) hide show
  1. package/CHANGES.txt +19 -1
  2. package/cjs/evaluator/condition/engineUtils.js +2 -2
  3. package/cjs/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.js +70 -0
  4. package/cjs/evaluator/fallbackConfigsCalculator/index.js +25 -0
  5. package/cjs/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +5 -8
  6. package/cjs/evaluator/fallbackTreatmentsCalculator/index.js +21 -32
  7. package/cjs/evaluator/index.js +73 -48
  8. package/cjs/evaluator/matchers/whitelist.js +1 -1
  9. package/cjs/integrations/pluggable.js +1 -1
  10. package/cjs/listeners/browser.js +4 -3
  11. package/cjs/listeners/node.js +4 -4
  12. package/cjs/logger/constants.js +15 -21
  13. package/cjs/logger/index.js +1 -1
  14. package/cjs/logger/messages/debug.js +6 -7
  15. package/cjs/logger/messages/error.js +4 -4
  16. package/cjs/logger/messages/info.js +2 -4
  17. package/cjs/logger/messages/warn.js +9 -10
  18. package/cjs/platform/browser.js +15 -0
  19. package/cjs/platform/getEventSource/browser.js +8 -0
  20. package/cjs/platform/getEventSource/eventsource.js +480 -0
  21. package/cjs/platform/getEventSource/node.js +26 -0
  22. package/cjs/platform/getFetch/browser.js +9 -0
  23. package/cjs/platform/getFetch/node.js +27 -0
  24. package/cjs/platform/getOptions/node.js +25 -0
  25. package/cjs/platform/node.js +17 -0
  26. package/cjs/readiness/constants.js +5 -4
  27. package/cjs/readiness/readinessManager.js +22 -22
  28. package/cjs/readiness/sdkReadinessManager.js +0 -16
  29. package/cjs/sdkClient/client.js +9 -35
  30. package/cjs/sdkClient/clientAttributesDecoration.js +3 -3
  31. package/cjs/sdkClient/clientInputValidation.js +38 -81
  32. package/cjs/sdkClient/identity.js +1 -1
  33. package/cjs/sdkClient/sdkClient.js +4 -49
  34. package/cjs/sdkClient/sdkLifecycle.js +71 -0
  35. package/cjs/sdkClient/trackMethod.js +56 -0
  36. package/cjs/sdkFactory/index.js +13 -50
  37. package/cjs/sdkManager/index.js +5 -5
  38. package/cjs/services/authProvider.js +67 -0
  39. package/cjs/services/secureSplitHttpClient.js +39 -0
  40. package/cjs/services/splitApi.js +24 -14
  41. package/cjs/services/splitHttpClient.js +1 -1
  42. package/cjs/storages/AbstractDefinitionsCacheAsync.js +51 -0
  43. package/cjs/storages/AbstractDefinitionsCacheSync.js +76 -0
  44. package/cjs/storages/KeyBuilder.js +16 -16
  45. package/cjs/storages/KeyBuilderCS.js +17 -17
  46. package/cjs/storages/KeyBuilderSS.js +16 -16
  47. package/cjs/storages/getRolloutPlan.js +4 -4
  48. package/cjs/storages/inLocalStorage/DefinitionsCacheInLocal.js +194 -0
  49. package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -1
  50. package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +10 -10
  51. package/cjs/storages/inLocalStorage/index.js +6 -6
  52. package/cjs/storages/inLocalStorage/validateCache.js +3 -3
  53. package/cjs/storages/inMemory/DefinitionsCacheInMemory.js +121 -0
  54. package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
  55. package/cjs/storages/inMemory/InMemoryStorage.js +4 -4
  56. package/cjs/storages/inMemory/InMemoryStorageCS.js +5 -5
  57. package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
  58. package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +5 -5
  59. package/cjs/storages/inMemory/SegmentsCacheInMemory.js +1 -1
  60. package/cjs/storages/inMemory/TelemetryCacheInMemory.js +5 -5
  61. package/cjs/storages/inRedis/DefinitionsCacheInRedis.js +243 -0
  62. package/cjs/storages/inRedis/EventsCacheInRedis.js +1 -1
  63. package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +5 -5
  64. package/cjs/storages/inRedis/ImpressionsCacheInRedis.js +1 -1
  65. package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +1 -1
  66. package/cjs/storages/inRedis/RedisAdapter.js +8 -8
  67. package/cjs/storages/inRedis/TelemetryCacheInRedis.js +7 -7
  68. package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +3 -3
  69. package/cjs/storages/inRedis/index.js +2 -2
  70. package/cjs/storages/pluggable/DefinitionsCachePluggable.js +212 -0
  71. package/cjs/storages/pluggable/EventsCachePluggable.js +1 -1
  72. package/cjs/storages/pluggable/ImpressionCountsCachePluggable.js +6 -6
  73. package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +1 -1
  74. package/cjs/storages/pluggable/TelemetryCachePluggable.js +7 -7
  75. package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +2 -2
  76. package/cjs/storages/pluggable/index.js +5 -5
  77. package/cjs/storages/pluggable/wrapperAdapter.js +1 -1
  78. package/cjs/storages/setRolloutPlan.js +6 -6
  79. package/cjs/storages/utils.js +6 -6
  80. package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
  81. package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +5 -5
  82. package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
  83. package/cjs/sync/polling/fetchers/splitChangesFetcher.js +24 -15
  84. package/cjs/sync/polling/pollingManagerCS.js +18 -18
  85. package/cjs/sync/polling/pollingManagerSS.js +13 -13
  86. package/cjs/sync/polling/syncTasks/definitionsSyncTask.js +12 -0
  87. package/cjs/sync/polling/updaters/{splitChangesUpdater.js → definitionChangesUpdater.js} +72 -64
  88. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
  89. package/cjs/sync/polling/updaters/segmentChangesUpdater.js +6 -6
  90. package/cjs/sync/streaming/SSEClient/index.js +2 -2
  91. package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
  92. package/cjs/sync/streaming/SSEHandler/index.js +1 -1
  93. package/cjs/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.js → DefinitionsUpdateWorker.js} +18 -18
  94. package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
  95. package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
  96. package/cjs/sync/streaming/constants.js +3 -3
  97. package/cjs/sync/streaming/parseUtils.js +12 -12
  98. package/cjs/sync/streaming/pushManager.js +14 -14
  99. package/cjs/sync/submitters/impressionsSubmitter.js +6 -6
  100. package/cjs/sync/submitters/submitter.js +1 -1
  101. package/cjs/sync/submitters/telemetrySubmitter.js +1 -2
  102. package/cjs/sync/syncManagerOnline.js +9 -6
  103. package/cjs/trackers/eventTracker.js +10 -12
  104. package/cjs/trackers/impressionObserver/buildKey.js +1 -1
  105. package/cjs/trackers/impressionsTracker.js +37 -20
  106. package/cjs/trackers/uniqueKeysTracker.js +1 -1
  107. package/cjs/utils/Backoff.js +20 -0
  108. package/cjs/utils/EventEmitter.js +391 -0
  109. package/cjs/utils/filter/bloomFilter.js +37 -0
  110. package/cjs/utils/inputValidation/apiKey.js +1 -1
  111. package/cjs/utils/inputValidation/attribute.js +2 -2
  112. package/cjs/utils/inputValidation/{split.js → definition.js} +10 -10
  113. package/cjs/utils/inputValidation/{splitExistence.js → definitionExistence.js} +6 -6
  114. package/cjs/utils/inputValidation/definitions.js +25 -0
  115. package/cjs/utils/inputValidation/eventProperties.js +1 -1
  116. package/cjs/utils/inputValidation/index.js +7 -7
  117. package/cjs/utils/inputValidation/isOperational.js +4 -4
  118. package/cjs/utils/inputValidation/target.js +22 -0
  119. package/cjs/utils/labels/index.js +3 -3
  120. package/cjs/utils/lang/index.js +1 -1
  121. package/cjs/utils/lang/sets.js +4 -4
  122. package/cjs/utils/promise/timeout.js +1 -1
  123. package/cjs/utils/settingsValidation/splitFilters.js +4 -4
  124. package/cjs/utils/settingsValidation/url.js +6 -6
  125. package/esm/evaluator/condition/engineUtils.js +2 -2
  126. package/esm/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.js +64 -0
  127. package/esm/evaluator/fallbackConfigsCalculator/index.js +21 -0
  128. package/esm/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +5 -8
  129. package/esm/evaluator/fallbackTreatmentsCalculator/index.js +21 -33
  130. package/esm/evaluator/index.js +72 -48
  131. package/esm/evaluator/matchers/whitelist.js +1 -1
  132. package/esm/integrations/pluggable.js +1 -1
  133. package/esm/listeners/browser.js +4 -3
  134. package/esm/listeners/node.js +4 -4
  135. package/esm/logger/constants.js +12 -18
  136. package/esm/logger/index.js +1 -1
  137. package/esm/logger/messages/debug.js +5 -6
  138. package/esm/logger/messages/error.js +3 -3
  139. package/esm/logger/messages/info.js +1 -3
  140. package/esm/logger/messages/warn.js +8 -9
  141. package/esm/platform/browser.js +12 -0
  142. package/esm/platform/getEventSource/browser.js +4 -0
  143. package/esm/platform/getEventSource/eventsource.js +480 -0
  144. package/esm/platform/getEventSource/node.js +20 -0
  145. package/esm/platform/getFetch/browser.js +5 -0
  146. package/esm/platform/getFetch/node.js +22 -0
  147. package/esm/platform/getOptions/node.js +20 -0
  148. package/esm/platform/node.js +14 -0
  149. package/esm/readiness/constants.js +4 -3
  150. package/esm/readiness/readinessManager.js +23 -23
  151. package/esm/readiness/sdkReadinessManager.js +1 -17
  152. package/esm/sdkClient/client.js +10 -37
  153. package/esm/sdkClient/clientAttributesDecoration.js +3 -3
  154. package/esm/sdkClient/clientInputValidation.js +40 -83
  155. package/esm/sdkClient/identity.js +1 -1
  156. package/esm/sdkClient/sdkClient.js +4 -49
  157. package/esm/sdkClient/sdkLifecycle.js +67 -0
  158. package/esm/sdkClient/trackMethod.js +52 -0
  159. package/esm/sdkFactory/index.js +14 -51
  160. package/esm/sdkManager/index.js +6 -6
  161. package/esm/services/authProvider.js +63 -0
  162. package/esm/services/secureSplitHttpClient.js +35 -0
  163. package/esm/services/splitApi.js +24 -14
  164. package/esm/services/splitHttpClient.js +1 -1
  165. package/esm/storages/AbstractDefinitionsCacheAsync.js +48 -0
  166. package/esm/storages/AbstractDefinitionsCacheSync.js +71 -0
  167. package/esm/storages/KeyBuilder.js +16 -16
  168. package/esm/storages/KeyBuilderCS.js +16 -16
  169. package/esm/storages/KeyBuilderSS.js +15 -15
  170. package/esm/storages/getRolloutPlan.js +4 -4
  171. package/esm/storages/inLocalStorage/DefinitionsCacheInLocal.js +191 -0
  172. package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +7 -7
  173. package/esm/storages/inLocalStorage/index.js +6 -6
  174. package/esm/storages/inLocalStorage/validateCache.js +3 -3
  175. package/esm/storages/inMemory/DefinitionsCacheInMemory.js +118 -0
  176. package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
  177. package/esm/storages/inMemory/InMemoryStorage.js +4 -4
  178. package/esm/storages/inMemory/InMemoryStorageCS.js +5 -5
  179. package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +2 -2
  180. package/esm/storages/inMemory/SegmentsCacheInMemory.js +1 -1
  181. package/esm/storages/inMemory/TelemetryCacheInMemory.js +5 -5
  182. package/esm/storages/inRedis/DefinitionsCacheInRedis.js +240 -0
  183. package/esm/storages/inRedis/EventsCacheInRedis.js +1 -1
  184. package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +4 -4
  185. package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +1 -1
  186. package/esm/storages/inRedis/RedisAdapter.js +7 -7
  187. package/esm/storages/inRedis/TelemetryCacheInRedis.js +7 -7
  188. package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
  189. package/esm/storages/inRedis/index.js +2 -2
  190. package/esm/storages/pluggable/DefinitionsCachePluggable.js +209 -0
  191. package/esm/storages/pluggable/EventsCachePluggable.js +1 -1
  192. package/esm/storages/pluggable/ImpressionCountsCachePluggable.js +5 -5
  193. package/esm/storages/pluggable/RBSegmentsCachePluggable.js +1 -1
  194. package/esm/storages/pluggable/TelemetryCachePluggable.js +7 -7
  195. package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
  196. package/esm/storages/pluggable/index.js +4 -4
  197. package/esm/storages/pluggable/wrapperAdapter.js +1 -1
  198. package/esm/storages/setRolloutPlan.js +6 -6
  199. package/esm/storages/utils.js +6 -6
  200. package/esm/sync/offline/splitsParser/parseCondition.js +1 -1
  201. package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +6 -6
  202. package/esm/sync/polling/fetchers/splitChangesFetcher.js +25 -16
  203. package/esm/sync/polling/pollingManagerCS.js +15 -15
  204. package/esm/sync/polling/pollingManagerSS.js +13 -13
  205. package/esm/sync/polling/syncTasks/definitionsSyncTask.js +8 -0
  206. package/esm/sync/polling/updaters/definitionChangesUpdater.js +200 -0
  207. package/esm/sync/polling/updaters/mySegmentsUpdater.js +3 -3
  208. package/esm/sync/polling/updaters/segmentChangesUpdater.js +7 -7
  209. package/esm/sync/streaming/SSEClient/index.js +2 -2
  210. package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +2 -2
  211. package/esm/sync/streaming/SSEHandler/index.js +2 -2
  212. package/esm/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.js → DefinitionsUpdateWorker.js} +17 -17
  213. package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
  214. package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
  215. package/esm/sync/streaming/constants.js +2 -2
  216. package/esm/sync/streaming/parseUtils.js +10 -10
  217. package/esm/sync/streaming/pushManager.js +16 -16
  218. package/esm/sync/submitters/impressionsSubmitter.js +6 -6
  219. package/esm/sync/submitters/submitter.js +1 -1
  220. package/esm/sync/submitters/telemetrySubmitter.js +1 -2
  221. package/esm/sync/syncManagerOnline.js +8 -5
  222. package/esm/trackers/eventTracker.js +10 -12
  223. package/esm/trackers/impressionObserver/buildKey.js +1 -1
  224. package/esm/trackers/impressionsTracker.js +38 -21
  225. package/esm/trackers/uniqueKeysTracker.js +1 -1
  226. package/esm/utils/Backoff.js +20 -0
  227. package/esm/utils/EventEmitter.js +387 -0
  228. package/esm/utils/filter/bloomFilter.js +33 -0
  229. package/esm/utils/inputValidation/apiKey.js +1 -1
  230. package/esm/utils/inputValidation/attribute.js +2 -2
  231. package/esm/utils/inputValidation/{split.js → definition.js} +8 -8
  232. package/esm/utils/inputValidation/definitionExistence.js +15 -0
  233. package/esm/utils/inputValidation/definitions.js +21 -0
  234. package/esm/utils/inputValidation/index.js +3 -3
  235. package/esm/utils/inputValidation/isOperational.js +4 -4
  236. package/esm/utils/inputValidation/target.js +18 -0
  237. package/esm/utils/labels/index.js +2 -2
  238. package/esm/utils/lang/sets.js +4 -4
  239. package/esm/utils/promise/timeout.js +1 -1
  240. package/esm/utils/settingsValidation/splitFilters.js +4 -4
  241. package/esm/utils/settingsValidation/url.js +6 -6
  242. package/package.json +15 -6
  243. package/src/dtos/types.ts +65 -70
  244. package/src/evaluator/Engine.ts +4 -4
  245. package/src/evaluator/combiners/and.ts +3 -3
  246. package/src/evaluator/combiners/ifelseif.ts +2 -2
  247. package/src/evaluator/condition/engineUtils.ts +2 -2
  248. package/src/evaluator/condition/index.ts +3 -3
  249. package/src/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.ts +76 -0
  250. package/src/evaluator/fallbackConfigsCalculator/index.ts +24 -0
  251. package/src/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.ts +5 -7
  252. package/src/evaluator/fallbackTreatmentsCalculator/index.ts +27 -41
  253. package/src/evaluator/index.ts +86 -51
  254. package/src/evaluator/matchers/dependency.ts +2 -2
  255. package/src/evaluator/matchers/matcherTypes.ts +2 -2
  256. package/src/evaluator/matchers/prerequisites.ts +4 -4
  257. package/src/evaluator/matchers/rbsegment.ts +2 -2
  258. package/src/evaluator/matchers/whitelist.ts +2 -2
  259. package/src/evaluator/matchersTransform/index.ts +2 -2
  260. package/src/evaluator/matchersTransform/whitelist.ts +2 -2
  261. package/src/evaluator/parser/index.ts +4 -4
  262. package/src/evaluator/treatments/index.ts +2 -2
  263. package/src/evaluator/types.ts +6 -6
  264. package/src/evaluator/value/index.ts +1 -1
  265. package/src/integrations/pluggable.ts +1 -1
  266. package/src/listeners/browser.ts +11 -8
  267. package/src/listeners/node.ts +2 -5
  268. package/src/logger/constants.ts +12 -18
  269. package/src/logger/messages/debug.ts +5 -6
  270. package/src/logger/messages/error.ts +3 -3
  271. package/src/logger/messages/info.ts +1 -3
  272. package/src/logger/messages/warn.ts +8 -9
  273. package/src/platform/browser.ts +14 -0
  274. package/src/platform/getEventSource/browser.ts +4 -0
  275. package/src/platform/getEventSource/eventsource.js +519 -0
  276. package/src/platform/getEventSource/node.ts +23 -0
  277. package/src/platform/getFetch/browser.ts +5 -0
  278. package/src/platform/getFetch/node.ts +27 -0
  279. package/src/platform/getOptions/node.ts +24 -0
  280. package/src/platform/node.ts +16 -0
  281. package/src/readiness/constants.ts +4 -3
  282. package/src/readiness/readinessManager.ts +22 -22
  283. package/src/readiness/sdkReadinessManager.ts +1 -16
  284. package/src/readiness/types.ts +10 -16
  285. package/src/sdkClient/client.ts +11 -41
  286. package/src/sdkClient/clientInputValidation.ts +44 -84
  287. package/src/sdkClient/sdkClient.ts +5 -54
  288. package/src/sdkClient/sdkLifecycle.ts +79 -0
  289. package/src/sdkClient/trackMethod.ts +59 -0
  290. package/src/sdkFactory/index.ts +15 -59
  291. package/src/sdkFactory/types.ts +19 -16
  292. package/src/sdkManager/index.ts +15 -15
  293. package/src/services/authProvider.ts +86 -0
  294. package/src/services/secureSplitHttpClient.ts +44 -0
  295. package/src/services/splitApi.ts +14 -2
  296. package/src/services/types.ts +7 -2
  297. package/src/storages/AbstractDefinitionsCacheAsync.ts +63 -0
  298. package/src/storages/AbstractDefinitionsCacheSync.ts +95 -0
  299. package/src/storages/KeyBuilder.ts +6 -6
  300. package/src/storages/KeyBuilderCS.ts +6 -6
  301. package/src/storages/KeyBuilderSS.ts +2 -2
  302. package/src/storages/getRolloutPlan.ts +3 -3
  303. package/src/storages/inLocalStorage/DefinitionsCacheInLocal.ts +234 -0
  304. package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +8 -8
  305. package/src/storages/inLocalStorage/index.ts +6 -6
  306. package/src/storages/inLocalStorage/validateCache.ts +4 -4
  307. package/src/storages/inMemory/DefinitionsCacheInMemory.ts +130 -0
  308. package/src/storages/inMemory/InMemoryStorage.ts +4 -4
  309. package/src/storages/inMemory/InMemoryStorageCS.ts +5 -5
  310. package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +3 -3
  311. package/src/storages/inMemory/SegmentsCacheInMemory.ts +1 -1
  312. package/src/storages/inMemory/TelemetryCacheInMemory.ts +5 -5
  313. package/src/storages/inRedis/{SplitsCacheInRedis.ts → DefinitionsCacheInRedis.ts} +69 -69
  314. package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +2 -2
  315. package/src/storages/inRedis/index.ts +2 -2
  316. package/src/storages/pluggable/DefinitionsCachePluggable.ts +230 -0
  317. package/src/storages/pluggable/RBSegmentsCachePluggable.ts +2 -2
  318. package/src/storages/pluggable/index.ts +2 -2
  319. package/src/storages/setRolloutPlan.ts +7 -7
  320. package/src/storages/types.ts +34 -29
  321. package/src/sync/offline/splitsParser/parseCondition.ts +2 -2
  322. package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +3 -3
  323. package/src/sync/offline/splitsParser/types.ts +6 -3
  324. package/src/sync/offline/syncManagerOffline.ts +2 -2
  325. package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +14 -14
  326. package/src/sync/polling/fetchers/splitChangesFetcher.ts +58 -23
  327. package/src/sync/polling/fetchers/types.ts +5 -3
  328. package/src/sync/polling/pollingManagerCS.ts +16 -14
  329. package/src/sync/polling/pollingManagerSS.ts +15 -13
  330. package/src/sync/polling/syncTasks/{splitsSyncTask.ts → definitionsSyncTask.ts} +11 -12
  331. package/src/sync/polling/types.ts +3 -3
  332. package/src/sync/polling/updaters/definitionChangesUpdater.ts +239 -0
  333. package/src/sync/polling/updaters/mySegmentsUpdater.ts +3 -3
  334. package/src/sync/polling/updaters/segmentChangesUpdater.ts +7 -7
  335. package/src/sync/streaming/AuthClient/index.ts +2 -2
  336. package/src/sync/streaming/AuthClient/types.ts +14 -11
  337. package/src/sync/streaming/SSEClient/index.ts +2 -2
  338. package/src/sync/streaming/SSEClient/types.ts +2 -2
  339. package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +2 -2
  340. package/src/sync/streaming/SSEHandler/index.ts +2 -2
  341. package/src/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.ts → DefinitionsUpdateWorker.ts} +21 -21
  342. package/src/sync/streaming/constants.ts +2 -2
  343. package/src/sync/streaming/parseUtils.ts +12 -12
  344. package/src/sync/streaming/pushManager.ts +18 -18
  345. package/src/sync/streaming/types.ts +2 -2
  346. package/src/sync/submitters/impressionsSubmitter.ts +9 -9
  347. package/src/sync/submitters/telemetrySubmitter.ts +1 -2
  348. package/src/sync/submitters/types.ts +3 -0
  349. package/src/sync/syncManagerOnline.ts +9 -5
  350. package/src/trackers/eventTracker.ts +7 -10
  351. package/src/trackers/impressionsTracker.ts +42 -26
  352. package/src/trackers/types.ts +3 -1
  353. package/src/utils/Backoff.ts +21 -0
  354. package/src/utils/EventEmitter.js +444 -0
  355. package/src/utils/filter/bloomFilter.ts +38 -0
  356. package/src/utils/inputValidation/definition.ts +27 -0
  357. package/src/utils/inputValidation/definitionExistence.ts +19 -0
  358. package/src/utils/inputValidation/definitions.ts +21 -0
  359. package/src/utils/inputValidation/index.ts +3 -3
  360. package/src/utils/inputValidation/isOperational.ts +4 -4
  361. package/src/utils/inputValidation/target.ts +21 -0
  362. package/src/utils/inputValidation/trafficTypeExistence.ts +2 -2
  363. package/src/utils/jwt/types.ts +1 -1
  364. package/src/utils/labels/index.ts +2 -2
  365. package/src/utils/lang/sets.ts +4 -2
  366. package/src/utils/settingsValidation/splitFilters.ts +3 -3
  367. package/src/utils/settingsValidation/url.ts +1 -1
  368. package/types/splitio.d.ts +222 -11
  369. package/cjs/storages/AbstractSplitsCacheAsync.js +0 -51
  370. package/cjs/storages/AbstractSplitsCacheSync.js +0 -76
  371. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +0 -194
  372. package/cjs/storages/inMemory/SplitsCacheInMemory.js +0 -121
  373. package/cjs/storages/inRedis/SplitsCacheInRedis.js +0 -243
  374. package/cjs/storages/pluggable/SplitsCachePluggable.js +0 -212
  375. package/cjs/sync/polling/syncTasks/splitsSyncTask.js +0 -13
  376. package/cjs/utils/inputValidation/splits.js +0 -25
  377. package/esm/storages/AbstractSplitsCacheAsync.js +0 -48
  378. package/esm/storages/AbstractSplitsCacheSync.js +0 -71
  379. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +0 -191
  380. package/esm/storages/inMemory/SplitsCacheInMemory.js +0 -118
  381. package/esm/storages/inRedis/SplitsCacheInRedis.js +0 -240
  382. package/esm/storages/pluggable/SplitsCachePluggable.js +0 -209
  383. package/esm/sync/polling/syncTasks/splitsSyncTask.js +0 -9
  384. package/esm/sync/polling/updaters/splitChangesUpdater.js +0 -192
  385. package/esm/utils/inputValidation/splitExistence.js +0 -15
  386. package/esm/utils/inputValidation/splits.js +0 -21
  387. package/src/storages/AbstractSplitsCacheAsync.ts +0 -63
  388. package/src/storages/AbstractSplitsCacheSync.ts +0 -95
  389. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +0 -234
  390. package/src/storages/inMemory/SplitsCacheInMemory.ts +0 -130
  391. package/src/storages/pluggable/SplitsCachePluggable.ts +0 -230
  392. package/src/sync/polling/updaters/splitChangesUpdater.ts +0 -230
  393. package/src/utils/inputValidation/split.ts +0 -27
  394. package/src/utils/inputValidation/splitExistence.ts +0 -19
  395. package/src/utils/inputValidation/splits.ts +0 -21
@@ -22,7 +22,7 @@ function uniqueKeysTrackerFactory(log, uniqueKeysCache, filterAdapter) {
22
22
  return {
23
23
  track: function (key, featureName) {
24
24
  if (!filterAdapter.add(key, featureName)) {
25
- log.debug(constants_1.LOG_PREFIX_UNIQUE_KEYS_TRACKER + "The feature " + featureName + " and key " + key + " exist in the filter");
25
+ log.debug("".concat(constants_1.LOG_PREFIX_UNIQUE_KEYS_TRACKER, "The feature ").concat(featureName, " and key ").concat(key, " exist in the filter"));
26
26
  return;
27
27
  }
28
28
  uniqueKeysCache.track(key, featureName);
@@ -27,6 +27,26 @@ var Backoff = /** @class */ (function () {
27
27
  this.attempts++;
28
28
  return delayInMillis;
29
29
  };
30
+ /**
31
+ * Schedule a delayed call to `cb`
32
+ * @returns a promise that resolves/rejects with the result of the `cb` function, which must return a promise.
33
+ */
34
+ Backoff.prototype.scheduleCallAsync = function () {
35
+ var _this = this;
36
+ var delayInMillis = Math.min(this.baseMillis * Math.pow(2, this.attempts), this.maxMillis);
37
+ if (this.timeoutID)
38
+ clearTimeout(this.timeoutID);
39
+ this.attempts++;
40
+ return new Promise(function (resolve, reject) {
41
+ _this.timeoutID = setTimeout(function () {
42
+ _this.timeoutID = undefined;
43
+ _this.cb().then(resolve, reject);
44
+ }, delayInMillis);
45
+ });
46
+ };
47
+ /**
48
+ * Reset the backoff attempts
49
+ */
30
50
  Backoff.prototype.reset = function () {
31
51
  this.attempts = 0;
32
52
  if (this.timeoutID) {
@@ -0,0 +1,391 @@
1
+ "use strict";
2
+ // Copyright Joyent, Inc. and other Node contributors.
3
+ //
4
+ // Permission is hereby granted, free of charge, to any person obtaining a
5
+ // copy of this software and associated documentation files (the
6
+ // "Software"), to deal in the Software without restriction, including
7
+ // without limitation the rights to use, copy, modify, merge, publish,
8
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
9
+ // persons to whom the Software is furnished to do so, subject to the
10
+ // following conditions:
11
+ //
12
+ // The above copyright notice and this permission notice shall be included
13
+ // in all copies or substantial portions of the Software.
14
+ //
15
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
18
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.EventEmitter = void 0;
24
+ // Adaptation of "events" library (https://www.npmjs.com/package/events)
25
+ // exported as an ES module instead of CommonJS, to avoid extra configuration steps when using
26
+ // the ESM build of the SDK with tools that doesn't support CommonJS by default (e.g. Rollup).
27
+ var R = typeof Reflect === 'object' ? Reflect : null;
28
+ var ReflectApply = R && typeof R.apply === 'function'
29
+ ? R.apply
30
+ : function ReflectApply(target, receiver, args) {
31
+ return Function.prototype.apply.call(target, receiver, args);
32
+ };
33
+ var ReflectOwnKeys;
34
+ if (R && typeof R.ownKeys === 'function') {
35
+ ReflectOwnKeys = R.ownKeys;
36
+ }
37
+ else if (Object.getOwnPropertySymbols) {
38
+ ReflectOwnKeys = function ReflectOwnKeys(target) {
39
+ return Object.getOwnPropertyNames(target)
40
+ .concat(Object.getOwnPropertySymbols(target));
41
+ };
42
+ }
43
+ else {
44
+ ReflectOwnKeys = function ReflectOwnKeys(target) {
45
+ return Object.getOwnPropertyNames(target);
46
+ };
47
+ }
48
+ function ProcessEmitWarning(warning) {
49
+ if (console && console.warn)
50
+ console.warn(warning);
51
+ }
52
+ // eslint-disable-next-line compat/compat
53
+ var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
54
+ return value !== value;
55
+ };
56
+ function EventEmitter() {
57
+ EventEmitter.init.call(this);
58
+ }
59
+ exports.EventEmitter = EventEmitter;
60
+ EventEmitter.prototype._events = undefined;
61
+ EventEmitter.prototype._eventsCount = 0;
62
+ EventEmitter.prototype._maxListeners = undefined;
63
+ // By default EventEmitters will print a warning if more than 10 listeners are
64
+ // added to it. This is a useful default which helps finding memory leaks.
65
+ var defaultMaxListeners = 10;
66
+ function checkListener(listener) {
67
+ if (typeof listener !== 'function') {
68
+ throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
69
+ }
70
+ }
71
+ Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
72
+ enumerable: true,
73
+ get: function () {
74
+ return defaultMaxListeners;
75
+ },
76
+ set: function (arg) {
77
+ if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
78
+ throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
79
+ }
80
+ defaultMaxListeners = arg;
81
+ }
82
+ });
83
+ EventEmitter.init = function () {
84
+ if (this._events === undefined ||
85
+ this._events === Object.getPrototypeOf(this)._events) {
86
+ this._events = Object.create(null);
87
+ this._eventsCount = 0;
88
+ }
89
+ this._maxListeners = this._maxListeners || undefined;
90
+ };
91
+ // Obviously not all Emitters should be limited to 10. This function allows
92
+ // that to be increased. Set to zero for unlimited.
93
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
94
+ if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
95
+ throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
96
+ }
97
+ this._maxListeners = n;
98
+ return this;
99
+ };
100
+ function _getMaxListeners(that) {
101
+ if (that._maxListeners === undefined)
102
+ return EventEmitter.defaultMaxListeners;
103
+ return that._maxListeners;
104
+ }
105
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
106
+ return _getMaxListeners(this);
107
+ };
108
+ EventEmitter.prototype.emit = function emit(type) {
109
+ var args = [];
110
+ for (var i = 1; i < arguments.length; i++)
111
+ args.push(arguments[i]);
112
+ var doError = (type === 'error');
113
+ var events = this._events;
114
+ if (events !== undefined)
115
+ doError = (doError && events.error === undefined);
116
+ else if (!doError)
117
+ return false;
118
+ // If there is no 'error' event listener then throw.
119
+ if (doError) {
120
+ var er;
121
+ if (args.length > 0)
122
+ er = args[0];
123
+ if (er instanceof Error) {
124
+ // Note: The comments on the `throw` lines are intentional, they show
125
+ // up in Node.js output if this results in an unhandled exception.
126
+ throw er; // Unhandled 'error' event
127
+ }
128
+ // At least give some kind of context to the user
129
+ var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
130
+ err.context = er;
131
+ throw err; // Unhandled 'error' event
132
+ }
133
+ var handler = events[type];
134
+ if (handler === undefined)
135
+ return false;
136
+ if (typeof handler === 'function') {
137
+ ReflectApply(handler, this, args);
138
+ }
139
+ else {
140
+ var len = handler.length;
141
+ var listeners = arrayClone(handler, len); // eslint-disable-next-line no-redeclare
142
+ for (var i = 0; i < len; ++i)
143
+ ReflectApply(listeners[i], this, args);
144
+ }
145
+ return true;
146
+ };
147
+ function _addListener(target, type, listener, prepend) {
148
+ var m;
149
+ var events;
150
+ var existing;
151
+ checkListener(listener);
152
+ events = target._events;
153
+ if (events === undefined) {
154
+ events = target._events = Object.create(null);
155
+ target._eventsCount = 0;
156
+ }
157
+ else {
158
+ // To avoid recursion in the case that type === "newListener"! Before
159
+ // adding it to the listeners, first emit "newListener".
160
+ if (events.newListener !== undefined) {
161
+ target.emit('newListener', type, listener.listener ? listener.listener : listener);
162
+ // Re-assign `events` because a newListener handler could have caused the
163
+ // this._events to be assigned to a new object
164
+ events = target._events;
165
+ }
166
+ existing = events[type];
167
+ }
168
+ if (existing === undefined) {
169
+ // Optimize the case of one listener. Don't need the extra array object.
170
+ existing = events[type] = listener;
171
+ ++target._eventsCount;
172
+ }
173
+ else {
174
+ if (typeof existing === 'function') {
175
+ // Adding the second element, need to change to array.
176
+ existing = events[type] =
177
+ prepend ? [listener, existing] : [existing, listener];
178
+ // If we've already got an array, just append.
179
+ }
180
+ else if (prepend) {
181
+ existing.unshift(listener);
182
+ }
183
+ else {
184
+ existing.push(listener);
185
+ }
186
+ // Check for listener leak
187
+ m = _getMaxListeners(target);
188
+ if (m > 0 && existing.length > m && !existing.warned) {
189
+ existing.warned = true;
190
+ // No error code for this since it is a Warning
191
+ // eslint-disable-next-line no-restricted-syntax
192
+ var w = new Error('Possible EventEmitter memory leak detected. ' +
193
+ existing.length + ' ' + String(type) + ' listeners ' +
194
+ 'added. Use emitter.setMaxListeners() to ' +
195
+ 'increase limit');
196
+ w.name = 'MaxListenersExceededWarning';
197
+ w.emitter = target;
198
+ w.type = type;
199
+ w.count = existing.length;
200
+ ProcessEmitWarning(w);
201
+ }
202
+ }
203
+ return target;
204
+ }
205
+ EventEmitter.prototype.addListener = function addListener(type, listener) {
206
+ return _addListener(this, type, listener, false);
207
+ };
208
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
209
+ EventEmitter.prototype.prependListener =
210
+ function prependListener(type, listener) {
211
+ return _addListener(this, type, listener, true);
212
+ };
213
+ function onceWrapper() {
214
+ if (!this.fired) {
215
+ this.target.removeListener(this.type, this.wrapFn);
216
+ this.fired = true;
217
+ if (arguments.length === 0)
218
+ return this.listener.call(this.target);
219
+ return this.listener.apply(this.target, arguments);
220
+ }
221
+ }
222
+ function _onceWrap(target, type, listener) {
223
+ var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
224
+ var wrapped = onceWrapper.bind(state);
225
+ wrapped.listener = listener;
226
+ state.wrapFn = wrapped;
227
+ return wrapped;
228
+ }
229
+ EventEmitter.prototype.once = function once(type, listener) {
230
+ checkListener(listener);
231
+ this.on(type, _onceWrap(this, type, listener));
232
+ return this;
233
+ };
234
+ EventEmitter.prototype.prependOnceListener =
235
+ function prependOnceListener(type, listener) {
236
+ checkListener(listener);
237
+ this.prependListener(type, _onceWrap(this, type, listener));
238
+ return this;
239
+ };
240
+ // Emits a 'removeListener' event if and only if the listener was removed.
241
+ EventEmitter.prototype.removeListener =
242
+ function removeListener(type, listener) {
243
+ var list, events, position, i, originalListener;
244
+ checkListener(listener);
245
+ events = this._events;
246
+ if (events === undefined)
247
+ return this;
248
+ list = events[type];
249
+ if (list === undefined)
250
+ return this;
251
+ if (list === listener || list.listener === listener) {
252
+ if (--this._eventsCount === 0)
253
+ this._events = Object.create(null);
254
+ else {
255
+ delete events[type];
256
+ if (events.removeListener)
257
+ this.emit('removeListener', type, list.listener || listener);
258
+ }
259
+ }
260
+ else if (typeof list !== 'function') {
261
+ position = -1;
262
+ for (i = list.length - 1; i >= 0; i--) {
263
+ if (list[i] === listener || list[i].listener === listener) {
264
+ originalListener = list[i].listener;
265
+ position = i;
266
+ break;
267
+ }
268
+ }
269
+ if (position < 0)
270
+ return this;
271
+ if (position === 0)
272
+ list.shift();
273
+ else {
274
+ spliceOne(list, position);
275
+ }
276
+ if (list.length === 1)
277
+ events[type] = list[0];
278
+ if (events.removeListener !== undefined)
279
+ this.emit('removeListener', type, originalListener || listener);
280
+ }
281
+ return this;
282
+ };
283
+ EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
284
+ EventEmitter.prototype.removeAllListeners =
285
+ function removeAllListeners(type) {
286
+ var listeners, events, i;
287
+ events = this._events;
288
+ if (events === undefined)
289
+ return this;
290
+ // not listening for removeListener, no need to emit
291
+ if (events.removeListener === undefined) {
292
+ if (arguments.length === 0) {
293
+ this._events = Object.create(null);
294
+ this._eventsCount = 0;
295
+ }
296
+ else if (events[type] !== undefined) {
297
+ if (--this._eventsCount === 0)
298
+ this._events = Object.create(null);
299
+ else
300
+ delete events[type];
301
+ }
302
+ return this;
303
+ }
304
+ // emit removeListener for all listeners on all events
305
+ if (arguments.length === 0) {
306
+ var keys = Object.keys(events);
307
+ var key;
308
+ for (i = 0; i < keys.length; ++i) {
309
+ key = keys[i];
310
+ if (key === 'removeListener')
311
+ continue;
312
+ this.removeAllListeners(key);
313
+ }
314
+ this.removeAllListeners('removeListener');
315
+ this._events = Object.create(null);
316
+ this._eventsCount = 0;
317
+ return this;
318
+ }
319
+ listeners = events[type];
320
+ if (typeof listeners === 'function') {
321
+ this.removeListener(type, listeners);
322
+ }
323
+ else if (listeners !== undefined) {
324
+ // LIFO order
325
+ for (i = listeners.length - 1; i >= 0; i--) {
326
+ this.removeListener(type, listeners[i]);
327
+ }
328
+ }
329
+ return this;
330
+ };
331
+ function _listeners(target, type, unwrap) {
332
+ var events = target._events;
333
+ if (events === undefined)
334
+ return [];
335
+ var evlistener = events[type];
336
+ if (evlistener === undefined)
337
+ return [];
338
+ if (typeof evlistener === 'function')
339
+ return unwrap ? [evlistener.listener || evlistener] : [evlistener];
340
+ return unwrap ?
341
+ unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
342
+ }
343
+ EventEmitter.prototype.listeners = function listeners(type) {
344
+ return _listeners(this, type, true);
345
+ };
346
+ EventEmitter.prototype.rawListeners = function rawListeners(type) {
347
+ return _listeners(this, type, false);
348
+ };
349
+ EventEmitter.listenerCount = function (emitter, type) {
350
+ if (typeof emitter.listenerCount === 'function') {
351
+ return emitter.listenerCount(type);
352
+ }
353
+ else {
354
+ return listenerCount.call(emitter, type);
355
+ }
356
+ };
357
+ EventEmitter.prototype.listenerCount = listenerCount;
358
+ function listenerCount(type) {
359
+ var events = this._events;
360
+ if (events !== undefined) {
361
+ var evlistener = events[type];
362
+ if (typeof evlistener === 'function') {
363
+ return 1;
364
+ }
365
+ else if (evlistener !== undefined) {
366
+ return evlistener.length;
367
+ }
368
+ }
369
+ return 0;
370
+ }
371
+ EventEmitter.prototype.eventNames = function eventNames() {
372
+ return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
373
+ };
374
+ function arrayClone(arr, n) {
375
+ var copy = new Array(n);
376
+ for (var i = 0; i < n; ++i)
377
+ copy[i] = arr[i];
378
+ return copy;
379
+ }
380
+ function spliceOne(list, index) {
381
+ for (; index + 1 < list.length; index++)
382
+ list[index] = list[index + 1];
383
+ list.pop();
384
+ }
385
+ function unwrapListeners(arr) {
386
+ var ret = new Array(arr.length);
387
+ for (var i = 0; i < ret.length; ++i) {
388
+ ret[i] = arr[i].listener || arr[i];
389
+ }
390
+ return ret;
391
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bloomFilterFactory = void 0;
4
+ // bloom-filters is supported on the following platforms:
5
+ // - Node.js: v4.0.0 or higher
6
+ // - Google Chrome: v41 or higher
7
+ // - Mozilla Firefox: v34 or higher
8
+ // - Microsoft Edge: v12 or higher
9
+ var bloom_filters_1 = require("bloom-filters");
10
+ var EXPECTED_INSERTIONS = 10000000;
11
+ var ERROR_RATE = 0.01;
12
+ var REFRESH_RATE = 24 * 60 * 60000; // 24HS
13
+ function bloomFilterFactory(expectedInsertions, errorRate, refreshRate) {
14
+ if (expectedInsertions === void 0) { expectedInsertions = EXPECTED_INSERTIONS; }
15
+ if (errorRate === void 0) { errorRate = ERROR_RATE; }
16
+ if (refreshRate === void 0) { refreshRate = REFRESH_RATE; }
17
+ var filter = bloom_filters_1.BloomFilter.create(expectedInsertions, errorRate);
18
+ return {
19
+ refreshRate: refreshRate,
20
+ add: function (key, value) {
21
+ var data = "".concat(key, ":").concat(value);
22
+ if (filter.has(data)) {
23
+ return false;
24
+ }
25
+ filter.add(data);
26
+ return true;
27
+ },
28
+ contains: function (key, value) {
29
+ var data = "".concat(key, ":").concat(value);
30
+ return filter.has(data);
31
+ },
32
+ clear: function () {
33
+ filter = bloom_filters_1.BloomFilter.create(expectedInsertions, errorRate);
34
+ }
35
+ };
36
+ }
37
+ exports.bloomFilterFactory = bloomFilterFactory;
@@ -38,7 +38,7 @@ function validateAndTrackApiKey(log, maybeSdkKey) {
38
38
  }
39
39
  }
40
40
  else {
41
- log.warn(constants_1.WARN_SDK_KEY, [exports.usedKeysMap[sdkKey] + " factory/ies with this SDK Key"]);
41
+ log.warn(constants_1.WARN_SDK_KEY, ["".concat(exports.usedKeysMap[sdkKey], " factory/ies with this SDK Key")]);
42
42
  exports.usedKeysMap[sdkKey]++;
43
43
  }
44
44
  }
@@ -4,7 +4,7 @@ exports.validateAttribute = void 0;
4
4
  var lang_1 = require("../../utils/lang");
5
5
  function validateAttribute(log, attributeKey, attributeValue, method) {
6
6
  if (!(0, lang_1.isString)(attributeKey) || attributeKey.length === 0) {
7
- log.warn(method + ": you passed an invalid attribute name, attribute name must be a non-empty string.");
7
+ log.warn("".concat(method, ": you passed an invalid attribute name, attribute name must be a non-empty string."));
8
8
  return false;
9
9
  }
10
10
  var isStringVal = (0, lang_1.isString)(attributeValue);
@@ -12,7 +12,7 @@ function validateAttribute(log, attributeKey, attributeValue, method) {
12
12
  var isBoolVal = (0, lang_1.isBoolean)(attributeValue);
13
13
  var isArrayVal = Array.isArray(attributeValue);
14
14
  if (!(isStringVal || isFiniteVal || isBoolVal || isArrayVal)) { // If it's not of valid type.
15
- log.warn(method + ": you passed an invalid attribute value for " + attributeKey + ". Acceptable types are: string, number, boolean and array of strings.");
15
+ log.warn("".concat(method, ": you passed an invalid attribute value for ").concat(attributeKey, ". Acceptable types are: string, number, boolean and array of strings."));
16
16
  return false;
17
17
  }
18
18
  return true;
@@ -1,25 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateSplit = void 0;
3
+ exports.validateDefinition = void 0;
4
4
  var constants_1 = require("../../logger/constants");
5
5
  var lang_1 = require("../lang");
6
6
  // include BOM and nbsp
7
7
  var TRIMMABLE_SPACES_REGEX = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/;
8
- function validateSplit(log, maybeSplit, method, item) {
8
+ function validateDefinition(log, maybeDefinition, method, item) {
9
9
  if (item === void 0) { item = 'feature flag name'; }
10
- if (maybeSplit == undefined) { // eslint-disable-line eqeqeq
10
+ if (maybeDefinition == undefined) { // eslint-disable-line eqeqeq
11
11
  log.error(constants_1.ERROR_NULL, [method, item]);
12
12
  }
13
- else if (!(0, lang_1.isString)(maybeSplit)) {
13
+ else if (!(0, lang_1.isString)(maybeDefinition)) {
14
14
  log.error(constants_1.ERROR_INVALID, [method, item]);
15
15
  }
16
16
  else {
17
- if (TRIMMABLE_SPACES_REGEX.test(maybeSplit)) {
18
- log.warn(constants_1.WARN_TRIMMING, [method, item, maybeSplit]);
19
- maybeSplit = maybeSplit.trim();
17
+ if (TRIMMABLE_SPACES_REGEX.test(maybeDefinition)) {
18
+ log.warn(constants_1.WARN_TRIMMING, [method, item, maybeDefinition]);
19
+ maybeDefinition = maybeDefinition.trim();
20
20
  }
21
- if (maybeSplit.length > 0) {
22
- return maybeSplit;
21
+ if (maybeDefinition.length > 0) {
22
+ return maybeDefinition;
23
23
  }
24
24
  else {
25
25
  log.error(constants_1.ERROR_EMPTY, [method, item]);
@@ -27,4 +27,4 @@ function validateSplit(log, maybeSplit, method, item) {
27
27
  }
28
28
  return false;
29
29
  }
30
- exports.validateSplit = validateSplit;
30
+ exports.validateDefinition = validateDefinition;
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateSplitExistence = void 0;
3
+ exports.validateDefinitionExistence = void 0;
4
4
  var labels_1 = require("../labels");
5
5
  var constants_1 = require("../../logger/constants");
6
6
  /**
7
7
  * This is defined here and in this format mostly because of the logger and the fact that it's considered a validation at product level.
8
- * But it's not going to run on the input validation layer. In any case, the most compelling reason to use it as we do is to avoid going to Redis and get a split twice.
8
+ * But it's not going to run on the input validation layer. In any case, the most compelling reason to use it as we do is to avoid going to Redis and get a definition twice.
9
9
  */
10
- function validateSplitExistence(log, readinessManager, splitName, labelOrSplitObj, method) {
10
+ function validateDefinitionExistence(log, readinessManager, definitionName, labelOrDefinitionObj, method) {
11
11
  if (readinessManager.isReady()) { // Only if it's ready (synced with BE) we validate this, otherwise it may just be that the SDK is still syncing
12
- if (labelOrSplitObj === labels_1.SPLIT_NOT_FOUND || labelOrSplitObj === labels_1.FALLBACK_SPLIT_NOT_FOUND || labelOrSplitObj == null) {
13
- log.warn(constants_1.WARN_NOT_EXISTENT_SPLIT, [method, splitName]);
12
+ if (labelOrDefinitionObj === labels_1.DEFINITION_NOT_FOUND || labelOrDefinitionObj === labels_1.FALLBACK_DEFINITION_NOT_FOUND || labelOrDefinitionObj == null) {
13
+ log.warn(constants_1.WARN_NOT_EXISTENT_DEFINITION, [method, definitionName]);
14
14
  return false;
15
15
  }
16
16
  }
17
17
  return true;
18
18
  }
19
- exports.validateSplitExistence = validateSplitExistence;
19
+ exports.validateDefinitionExistence = validateDefinitionExistence;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateDefinitions = void 0;
4
+ var constants_1 = require("../../logger/constants");
5
+ var lang_1 = require("../lang");
6
+ var definition_1 = require("./definition");
7
+ function validateDefinitions(log, maybeDefinitions, method, listName, item) {
8
+ if (listName === void 0) { listName = 'feature flag names'; }
9
+ if (item === void 0) { item = 'feature flag name'; }
10
+ if (Array.isArray(maybeDefinitions) && maybeDefinitions.length > 0) {
11
+ var validatedArray_1 = [];
12
+ // Remove invalid values
13
+ maybeDefinitions.forEach(function (maybeDefinition) {
14
+ var definitionName = (0, definition_1.validateDefinition)(log, maybeDefinition, method, item);
15
+ if (definitionName)
16
+ validatedArray_1.push(definitionName);
17
+ });
18
+ // Strip off duplicated values if we have valid definition names then return
19
+ if (validatedArray_1.length)
20
+ return (0, lang_1.uniq)(validatedArray_1);
21
+ }
22
+ log.error(constants_1.ERROR_EMPTY_ARRAY, [method, listName]);
23
+ return false;
24
+ }
25
+ exports.validateDefinitions = validateDefinitions;
@@ -70,7 +70,7 @@ function validateEvaluationOptions(log, maybeOptions, method) {
70
70
  if (!impressionsDisabled)
71
71
  return options;
72
72
  // @ts-expect-error impressionsDisabled is not exposed in the public typings yet.
73
- return options ? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, options), { impressionsDisabled: impressionsDisabled }) : { impressionsDisabled: impressionsDisabled };
73
+ return options ? tslib_1.__assign(tslib_1.__assign({}, options), { impressionsDisabled: impressionsDisabled }) : { impressionsDisabled: impressionsDisabled };
74
74
  }
75
75
  else if (maybeOptions) {
76
76
  log.error(constants_1.ERROR_NOT_PLAIN_OBJECT, [method, 'evaluation options']);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateEvaluationOptions = exports.validateTrafficTypeExistence = exports.validateSplitExistence = exports.validateIfOperational = exports.validateIfReadyFromCache = exports.validateIfNotDestroyed = exports.validateTrafficType = exports.validateSplits = exports.validateSplit = exports.validateKey = exports.validateEventProperties = exports.validateEventValue = exports.validateEvent = exports.validateAttributes = exports.releaseApiKey = exports.validateAndTrackApiKey = exports.validateApiKey = void 0;
3
+ exports.validateEvaluationOptions = exports.validateTrafficTypeExistence = exports.validateDefinitionExistence = exports.validateIfOperational = exports.validateIfReadyFromCache = exports.validateIfNotDestroyed = exports.validateTrafficType = exports.validateDefinitions = exports.validateDefinition = exports.validateKey = exports.validateEventProperties = exports.validateEventValue = exports.validateEvent = exports.validateAttributes = exports.releaseApiKey = exports.validateAndTrackApiKey = exports.validateApiKey = void 0;
4
4
  var apiKey_1 = require("./apiKey");
5
5
  Object.defineProperty(exports, "validateApiKey", { enumerable: true, get: function () { return apiKey_1.validateApiKey; } });
6
6
  Object.defineProperty(exports, "validateAndTrackApiKey", { enumerable: true, get: function () { return apiKey_1.validateAndTrackApiKey; } });
@@ -15,18 +15,18 @@ var eventProperties_1 = require("./eventProperties");
15
15
  Object.defineProperty(exports, "validateEventProperties", { enumerable: true, get: function () { return eventProperties_1.validateEventProperties; } });
16
16
  var key_1 = require("./key");
17
17
  Object.defineProperty(exports, "validateKey", { enumerable: true, get: function () { return key_1.validateKey; } });
18
- var split_1 = require("./split");
19
- Object.defineProperty(exports, "validateSplit", { enumerable: true, get: function () { return split_1.validateSplit; } });
20
- var splits_1 = require("./splits");
21
- Object.defineProperty(exports, "validateSplits", { enumerable: true, get: function () { return splits_1.validateSplits; } });
18
+ var definition_1 = require("./definition");
19
+ Object.defineProperty(exports, "validateDefinition", { enumerable: true, get: function () { return definition_1.validateDefinition; } });
20
+ var definitions_1 = require("./definitions");
21
+ Object.defineProperty(exports, "validateDefinitions", { enumerable: true, get: function () { return definitions_1.validateDefinitions; } });
22
22
  var trafficType_1 = require("./trafficType");
23
23
  Object.defineProperty(exports, "validateTrafficType", { enumerable: true, get: function () { return trafficType_1.validateTrafficType; } });
24
24
  var isOperational_1 = require("./isOperational");
25
25
  Object.defineProperty(exports, "validateIfNotDestroyed", { enumerable: true, get: function () { return isOperational_1.validateIfNotDestroyed; } });
26
26
  Object.defineProperty(exports, "validateIfReadyFromCache", { enumerable: true, get: function () { return isOperational_1.validateIfReadyFromCache; } });
27
27
  Object.defineProperty(exports, "validateIfOperational", { enumerable: true, get: function () { return isOperational_1.validateIfOperational; } });
28
- var splitExistence_1 = require("./splitExistence");
29
- Object.defineProperty(exports, "validateSplitExistence", { enumerable: true, get: function () { return splitExistence_1.validateSplitExistence; } });
28
+ var definitionExistence_1 = require("./definitionExistence");
29
+ Object.defineProperty(exports, "validateDefinitionExistence", { enumerable: true, get: function () { return definitionExistence_1.validateDefinitionExistence; } });
30
30
  var trafficTypeExistence_1 = require("./trafficTypeExistence");
31
31
  Object.defineProperty(exports, "validateTrafficTypeExistence", { enumerable: true, get: function () { return trafficTypeExistence_1.validateTrafficTypeExistence; } });
32
32
  var eventProperties_2 = require("./eventProperties");
@@ -9,15 +9,15 @@ function validateIfNotDestroyed(log, readinessManager, method) {
9
9
  return false;
10
10
  }
11
11
  exports.validateIfNotDestroyed = validateIfNotDestroyed;
12
- function validateIfReadyFromCache(log, readinessManager, method, featureFlagNameOrNames) {
12
+ function validateIfReadyFromCache(log, readinessManager, method) {
13
13
  if (readinessManager.isReadyFromCache())
14
14
  return true;
15
- log.warn(constants_1.CLIENT_NOT_READY_FROM_CACHE, [method, featureFlagNameOrNames ? " for feature flag " + featureFlagNameOrNames.toString() : '']);
15
+ log.warn(constants_1.CLIENT_NOT_READY_FROM_CACHE, [method]);
16
16
  return false;
17
17
  }
18
18
  exports.validateIfReadyFromCache = validateIfReadyFromCache;
19
19
  // Operational means that the SDK is ready to evaluate (not destroyed and ready from cache)
20
- function validateIfOperational(log, readinessManager, method, featureFlagNameOrNames) {
21
- return validateIfNotDestroyed(log, readinessManager, method) && validateIfReadyFromCache(log, readinessManager, method, featureFlagNameOrNames);
20
+ function validateIfOperational(log, readinessManager, method) {
21
+ return validateIfNotDestroyed(log, readinessManager, method) && validateIfReadyFromCache(log, readinessManager, method);
22
22
  }
23
23
  exports.validateIfOperational = validateIfOperational;