@splitsoftware/splitio-commons 1.6.2-rc.4 → 1.6.2-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (475) hide show
  1. package/cjs/consent/sdkUserConsent.js +2 -2
  2. package/cjs/listeners/browser.js +2 -1
  3. package/cjs/logger/constants.js +2 -1
  4. package/cjs/sdkClient/clientAttributesDecoration.js +1 -1
  5. package/cjs/sdkFactory/index.js +23 -6
  6. package/cjs/services/splitApi.js +20 -1
  7. package/cjs/storages/KeyBuilderSS.js +6 -0
  8. package/cjs/storages/inLocalStorage/index.js +4 -0
  9. package/cjs/storages/inMemory/AttributesCacheInMemory.js +1 -1
  10. package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +12 -1
  11. package/cjs/storages/inMemory/InMemoryStorage.js +5 -1
  12. package/cjs/storages/inMemory/InMemoryStorageCS.js +5 -1
  13. package/cjs/storages/inMemory/uniqueKeysCacheInMemory.js +73 -0
  14. package/cjs/storages/inMemory/uniqueKeysCacheInMemoryCS.js +78 -0
  15. package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +46 -0
  16. package/cjs/storages/inRedis/constants.js +4 -1
  17. package/cjs/storages/inRedis/index.js +15 -1
  18. package/cjs/storages/inRedis/uniqueKeysCacheInRedis.js +55 -0
  19. package/cjs/sync/submitters/submitterManager.js +3 -0
  20. package/cjs/sync/submitters/telemetrySubmitter.js +1 -0
  21. package/cjs/sync/submitters/uniqueKeysSubmitter.js +26 -0
  22. package/cjs/trackers/impressionsTracker.js +22 -41
  23. package/cjs/trackers/strategy/strategyDebug.js +25 -0
  24. package/cjs/trackers/strategy/strategyNone.js +29 -0
  25. package/cjs/trackers/strategy/strategyOptimized.js +34 -0
  26. package/cjs/trackers/uniqueKeysTracker.js +31 -0
  27. package/cjs/types.js +2 -0
  28. package/cjs/utils/constants/index.js +4 -2
  29. package/cjs/utils/key/index.js +1 -1
  30. package/cjs/utils/settingsValidation/impressionsMode.js +2 -2
  31. package/cjs/utils/settingsValidation/index.js +3 -1
  32. package/esm/consent/sdkUserConsent.js +2 -2
  33. package/esm/listeners/browser.js +3 -2
  34. package/esm/logger/constants.js +1 -0
  35. package/esm/sdkClient/clientAttributesDecoration.js +1 -1
  36. package/esm/sdkFactory/index.js +23 -6
  37. package/esm/services/splitApi.js +20 -1
  38. package/esm/storages/KeyBuilderSS.js +6 -0
  39. package/esm/storages/inLocalStorage/index.js +5 -1
  40. package/esm/storages/inMemory/AttributesCacheInMemory.js +1 -1
  41. package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +12 -1
  42. package/esm/storages/inMemory/InMemoryStorage.js +6 -2
  43. package/esm/storages/inMemory/InMemoryStorageCS.js +6 -2
  44. package/esm/storages/inMemory/uniqueKeysCacheInMemory.js +70 -0
  45. package/esm/storages/inMemory/uniqueKeysCacheInMemoryCS.js +75 -0
  46. package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +43 -0
  47. package/esm/storages/inRedis/constants.js +3 -0
  48. package/esm/storages/inRedis/index.js +16 -2
  49. package/esm/storages/inRedis/uniqueKeysCacheInRedis.js +52 -0
  50. package/esm/sync/submitters/submitterManager.js +3 -0
  51. package/esm/sync/submitters/telemetrySubmitter.js +2 -1
  52. package/esm/sync/submitters/uniqueKeysSubmitter.js +22 -0
  53. package/esm/trackers/impressionsTracker.js +22 -41
  54. package/esm/trackers/strategy/strategyDebug.js +21 -0
  55. package/esm/trackers/strategy/strategyNone.js +25 -0
  56. package/esm/trackers/strategy/strategyOptimized.js +30 -0
  57. package/esm/trackers/uniqueKeysTracker.js +27 -0
  58. package/esm/types.js +1 -0
  59. package/esm/utils/constants/index.js +2 -0
  60. package/esm/utils/key/index.js +1 -1
  61. package/esm/utils/settingsValidation/impressionsMode.js +3 -3
  62. package/esm/utils/settingsValidation/index.js +3 -1
  63. package/package.json +5 -4
  64. package/src/consent/sdkUserConsent.ts +5 -6
  65. package/src/dtos/types.ts +8 -0
  66. package/src/evaluator/Engine.ts +3 -3
  67. package/src/evaluator/combiners/and.ts +1 -1
  68. package/src/evaluator/combiners/ifelseif.ts +3 -3
  69. package/src/evaluator/condition/engineUtils.ts +1 -1
  70. package/src/evaluator/condition/index.ts +6 -6
  71. package/src/evaluator/index.ts +10 -10
  72. package/src/evaluator/matchers/all.ts +1 -1
  73. package/src/evaluator/matchers/between.ts +1 -1
  74. package/src/evaluator/matchers/boolean.ts +1 -1
  75. package/src/evaluator/matchers/cont_all.ts +1 -1
  76. package/src/evaluator/matchers/cont_any.ts +1 -1
  77. package/src/evaluator/matchers/cont_str.ts +1 -1
  78. package/src/evaluator/matchers/dependency.ts +1 -1
  79. package/src/evaluator/matchers/eq.ts +1 -1
  80. package/src/evaluator/matchers/eq_set.ts +1 -1
  81. package/src/evaluator/matchers/ew.ts +1 -1
  82. package/src/evaluator/matchers/gte.ts +1 -1
  83. package/src/evaluator/matchers/index.ts +1 -1
  84. package/src/evaluator/matchers/lte.ts +1 -1
  85. package/src/evaluator/matchers/part_of.ts +1 -1
  86. package/src/evaluator/matchers/segment.ts +1 -1
  87. package/src/evaluator/matchers/string.ts +1 -1
  88. package/src/evaluator/matchers/sw.ts +1 -1
  89. package/src/evaluator/matchers/whitelist.ts +1 -1
  90. package/src/evaluator/parser/index.ts +3 -3
  91. package/src/evaluator/types.ts +6 -6
  92. package/src/evaluator/value/index.ts +4 -4
  93. package/src/evaluator/value/sanitize.ts +4 -4
  94. package/src/integrations/ga/GaToSplit.ts +6 -6
  95. package/src/integrations/ga/SplitToGa.ts +10 -10
  96. package/src/integrations/ga/types.ts +4 -4
  97. package/src/integrations/pluggable.ts +3 -3
  98. package/src/integrations/types.ts +2 -2
  99. package/src/listeners/browser.ts +3 -2
  100. package/src/logger/constants.ts +1 -0
  101. package/src/logger/index.ts +3 -3
  102. package/src/logger/sdkLogger.ts +2 -1
  103. package/src/logger/types.ts +16 -0
  104. package/src/readiness/sdkReadinessManager.ts +1 -1
  105. package/src/readiness/types.ts +9 -2
  106. package/src/sdkClient/client.ts +13 -13
  107. package/src/sdkClient/clientAttributesDecoration.ts +13 -13
  108. package/src/sdkClient/clientCS.ts +4 -3
  109. package/src/sdkClient/clientInputValidation.ts +15 -15
  110. package/src/sdkClient/sdkClient.ts +2 -2
  111. package/src/sdkClient/sdkClientMethod.ts +2 -2
  112. package/src/sdkClient/sdkClientMethodCS.ts +9 -9
  113. package/src/sdkClient/sdkClientMethodCSWithTT.ts +9 -9
  114. package/src/sdkFactory/index.ts +28 -8
  115. package/src/sdkFactory/types.ts +11 -8
  116. package/src/sdkManager/index.ts +5 -5
  117. package/src/services/splitApi.ts +22 -1
  118. package/src/services/types.ts +6 -0
  119. package/src/storages/KeyBuilderSS.ts +8 -0
  120. package/src/storages/dataLoader.ts +2 -2
  121. package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +1 -1
  122. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +2 -2
  123. package/src/storages/inLocalStorage/index.ts +6 -4
  124. package/src/storages/inMemory/AttributesCacheInMemory.ts +12 -13
  125. package/src/storages/inMemory/EventsCacheInMemory.ts +4 -4
  126. package/src/storages/inMemory/ImpressionCountsCacheInMemory.ts +16 -1
  127. package/src/storages/inMemory/InMemoryStorage.ts +5 -2
  128. package/src/storages/inMemory/InMemoryStorageCS.ts +6 -2
  129. package/src/storages/inMemory/uniqueKeysCacheInMemory.ts +82 -0
  130. package/src/storages/inMemory/uniqueKeysCacheInMemoryCS.ts +88 -0
  131. package/src/storages/inRedis/EventsCacheInRedis.ts +4 -4
  132. package/src/storages/inRedis/ImpressionCountsCacheInRedis.ts +48 -0
  133. package/src/storages/inRedis/ImpressionsCacheInRedis.ts +1 -1
  134. package/src/storages/inRedis/RedisAdapter.ts +1 -1
  135. package/src/storages/inRedis/SegmentsCacheInRedis.ts +1 -1
  136. package/src/storages/inRedis/SplitsCacheInRedis.ts +1 -1
  137. package/src/storages/inRedis/TelemetryCacheInRedis.ts +1 -1
  138. package/src/storages/inRedis/constants.ts +3 -0
  139. package/src/storages/inRedis/index.ts +14 -6
  140. package/src/storages/inRedis/uniqueKeysCacheInRedis.ts +61 -0
  141. package/src/storages/pluggable/EventsCachePluggable.ts +4 -4
  142. package/src/storages/pluggable/ImpressionsCachePluggable.ts +1 -1
  143. package/src/storages/pluggable/SegmentsCachePluggable.ts +1 -1
  144. package/src/storages/pluggable/SplitsCachePluggable.ts +1 -1
  145. package/src/storages/pluggable/TelemetryCachePluggable.ts +1 -1
  146. package/src/storages/pluggable/index.ts +3 -3
  147. package/src/storages/pluggable/wrapperAdapter.ts +1 -1
  148. package/src/storages/types.ts +45 -50
  149. package/src/sync/offline/LocalhostFromObject.ts +4 -4
  150. package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +8 -8
  151. package/src/sync/polling/updaters/mySegmentsUpdater.ts +1 -1
  152. package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
  153. package/src/sync/polling/updaters/splitChangesUpdater.ts +1 -1
  154. package/src/sync/streaming/SSEHandler/index.ts +1 -1
  155. package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
  156. package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +1 -1
  157. package/src/sync/submitters/submitter.ts +1 -1
  158. package/src/sync/submitters/submitterManager.ts +2 -0
  159. package/src/sync/submitters/telemetrySubmitter.ts +4 -3
  160. package/src/sync/submitters/types.ts +22 -3
  161. package/src/sync/submitters/uniqueKeysSubmitter.ts +35 -0
  162. package/src/sync/syncTask.ts +1 -1
  163. package/src/trackers/eventTracker.ts +3 -3
  164. package/src/trackers/impressionsTracker.ts +30 -51
  165. package/src/trackers/strategy/strategyDebug.ts +28 -0
  166. package/src/trackers/strategy/strategyNone.ts +34 -0
  167. package/src/trackers/strategy/strategyOptimized.ts +42 -0
  168. package/src/trackers/types.ts +30 -4
  169. package/src/trackers/uniqueKeysTracker.ts +37 -0
  170. package/src/types.ts +1265 -0
  171. package/src/utils/constants/index.ts +3 -1
  172. package/src/utils/inputValidation/apiKey.ts +1 -1
  173. package/src/utils/inputValidation/attribute.ts +1 -1
  174. package/src/utils/inputValidation/attributes.ts +3 -3
  175. package/src/utils/inputValidation/event.ts +1 -1
  176. package/src/utils/inputValidation/eventProperties.ts +3 -3
  177. package/src/utils/inputValidation/eventValue.ts +1 -1
  178. package/src/utils/inputValidation/isOperational.ts +1 -1
  179. package/src/utils/inputValidation/key.ts +3 -3
  180. package/src/utils/inputValidation/preloadedData.ts +3 -3
  181. package/src/utils/inputValidation/split.ts +1 -1
  182. package/src/utils/inputValidation/splitExistance.ts +1 -1
  183. package/src/utils/inputValidation/splits.ts +1 -1
  184. package/src/utils/inputValidation/trafficType.ts +1 -1
  185. package/src/utils/inputValidation/trafficTypeExistance.ts +1 -1
  186. package/src/utils/key/index.ts +9 -9
  187. package/src/utils/settingsValidation/consent.ts +2 -1
  188. package/src/utils/settingsValidation/impressionsMode.ts +6 -6
  189. package/src/utils/settingsValidation/index.ts +4 -1
  190. package/src/utils/settingsValidation/integrations/common.ts +1 -1
  191. package/src/utils/settingsValidation/integrations/configurable.ts +1 -1
  192. package/src/utils/settingsValidation/integrations/pluggable.ts +2 -1
  193. package/src/utils/settingsValidation/localhost/builtin.ts +2 -1
  194. package/src/utils/settingsValidation/localhost/pluggable.ts +2 -1
  195. package/src/utils/settingsValidation/logger/builtinLogger.ts +2 -1
  196. package/src/utils/settingsValidation/logger/pluggableLogger.ts +2 -1
  197. package/src/utils/settingsValidation/splitFilters.ts +9 -7
  198. package/src/utils/settingsValidation/storage/storageCS.ts +2 -1
  199. package/types/consent/index.d.ts +2 -0
  200. package/types/consent/sdkUserConsent.d.ts +13 -0
  201. package/types/dtos/types.d.ts +172 -0
  202. package/types/evaluator/Engine.d.ts +15 -0
  203. package/types/evaluator/combiners/and.d.ts +4 -0
  204. package/types/evaluator/combiners/ifelseif.d.ts +3 -0
  205. package/types/evaluator/condition/engineUtils.d.ts +11 -0
  206. package/types/evaluator/condition/index.d.ts +6 -0
  207. package/types/evaluator/convertions/index.d.ts +2 -0
  208. package/types/evaluator/index.d.ts +7 -0
  209. package/types/evaluator/matchers/all.d.ts +2 -0
  210. package/types/evaluator/matchers/between.d.ts +3 -0
  211. package/types/evaluator/matchers/boolean.d.ts +2 -0
  212. package/types/evaluator/matchers/cont_all.d.ts +2 -0
  213. package/types/evaluator/matchers/cont_any.d.ts +2 -0
  214. package/types/evaluator/matchers/cont_str.d.ts +2 -0
  215. package/types/evaluator/matchers/dependency.d.ts +5 -0
  216. package/types/evaluator/matchers/eq.d.ts +2 -0
  217. package/types/evaluator/matchers/eq_set.d.ts +2 -0
  218. package/types/evaluator/matchers/ew.d.ts +2 -0
  219. package/types/evaluator/matchers/gte.d.ts +2 -0
  220. package/types/evaluator/matchers/index.d.ts +7 -0
  221. package/types/evaluator/matchers/lte.d.ts +2 -0
  222. package/types/evaluator/matchers/matcherTypes.d.ts +10 -0
  223. package/types/evaluator/matchers/part_of.d.ts +2 -0
  224. package/types/evaluator/matchers/segment.d.ts +6 -0
  225. package/types/evaluator/matchers/string.d.ts +2 -0
  226. package/types/evaluator/matchers/sw.d.ts +2 -0
  227. package/types/evaluator/matchers/whitelist.d.ts +3 -0
  228. package/types/evaluator/matchersTransform/index.d.ts +6 -0
  229. package/types/evaluator/matchersTransform/segment.d.ts +5 -0
  230. package/types/evaluator/matchersTransform/set.d.ts +5 -0
  231. package/types/evaluator/matchersTransform/unaryNumeric.d.ts +5 -0
  232. package/types/evaluator/matchersTransform/whitelist.d.ts +5 -0
  233. package/types/evaluator/parser/index.d.ts +5 -0
  234. package/types/evaluator/treatments/index.d.ts +8 -0
  235. package/types/evaluator/types.d.ts +28 -0
  236. package/types/evaluator/value/index.d.ts +7 -0
  237. package/types/evaluator/value/sanitize.d.ts +7 -0
  238. package/types/index.d.ts +5 -0
  239. package/types/integrations/browser.d.ts +12 -0
  240. package/types/integrations/ga/GaToSplit.d.ts +40 -0
  241. package/types/integrations/ga/GoogleAnalyticsToSplit.d.ts +3 -0
  242. package/types/integrations/ga/SplitToGa.d.ts +34 -0
  243. package/types/integrations/ga/SplitToGoogleAnalytics.d.ts +3 -0
  244. package/types/integrations/ga/types.d.ts +148 -0
  245. package/types/integrations/pluggable.d.ts +11 -0
  246. package/types/integrations/types.d.ts +17 -0
  247. package/types/listeners/browser.d.ts +40 -0
  248. package/types/listeners/node.d.ts +22 -0
  249. package/types/listeners/types.d.ts +4 -0
  250. package/types/logger/browser/DebugLogger.d.ts +2 -0
  251. package/types/logger/browser/ErrorLogger.d.ts +2 -0
  252. package/types/logger/browser/InfoLogger.d.ts +2 -0
  253. package/types/logger/browser/WarnLogger.d.ts +2 -0
  254. package/types/logger/constants.d.ts +142 -0
  255. package/types/logger/index.d.ts +22 -0
  256. package/types/logger/messages/debug.d.ts +1 -0
  257. package/types/logger/messages/error.d.ts +1 -0
  258. package/types/logger/messages/info.d.ts +1 -0
  259. package/types/logger/messages/warn.d.ts +1 -0
  260. package/types/logger/sdkLogger.d.ts +8 -0
  261. package/types/logger/types.d.ts +17 -0
  262. package/types/readiness/constants.d.ts +7 -0
  263. package/types/readiness/readinessManager.d.ts +6 -0
  264. package/types/readiness/sdkReadinessManager.d.ts +11 -0
  265. package/types/readiness/types.d.ts +60 -0
  266. package/types/sdkClient/client.d.ts +6 -0
  267. package/types/sdkClient/clientAttributesDecoration.d.ts +51 -0
  268. package/types/sdkClient/clientCS.d.ts +10 -0
  269. package/types/sdkClient/clientInputValidation.d.ts +7 -0
  270. package/types/sdkClient/sdkClient.d.ts +6 -0
  271. package/types/sdkClient/sdkClientMethod.d.ts +6 -0
  272. package/types/sdkClient/sdkClientMethodCS.d.ts +7 -0
  273. package/types/sdkClient/sdkClientMethodCSWithTT.d.ts +8 -0
  274. package/types/sdkClient/types.d.ts +18 -0
  275. package/types/sdkFactory/index.d.ts +6 -0
  276. package/types/sdkFactory/types.d.ts +82 -0
  277. package/types/sdkManager/index.d.ts +5 -0
  278. package/types/services/splitApi.d.ts +11 -0
  279. package/types/services/splitHttpClient.d.ts +10 -0
  280. package/types/services/types.d.ts +54 -0
  281. package/types/storages/AbstractSegmentsCacheSync.d.ts +55 -0
  282. package/types/storages/AbstractSplitsCacheAsync.d.ts +36 -0
  283. package/types/storages/AbstractSplitsCacheSync.d.ts +42 -0
  284. package/types/storages/KeyBuilder.d.ts +14 -0
  285. package/types/storages/KeyBuilderCS.d.ts +16 -0
  286. package/types/storages/KeyBuilderSS.d.ts +17 -0
  287. package/types/storages/dataLoader.d.ts +10 -0
  288. package/types/storages/findLatencyIndex.d.ts +7 -0
  289. package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +25 -0
  290. package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +51 -0
  291. package/types/storages/inLocalStorage/constants.d.ts +2 -0
  292. package/types/storages/inLocalStorage/index.d.ts +8 -0
  293. package/types/storages/inMemory/AttributesCacheInMemory.d.ts +43 -0
  294. package/types/storages/inMemory/CountsCacheInMemory.d.ts +20 -0
  295. package/types/storages/inMemory/EventsCacheInMemory.d.ts +35 -0
  296. package/types/storages/inMemory/ImpressionCountsCacheInMemory.d.ts +28 -0
  297. package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +30 -0
  298. package/types/storages/inMemory/InMemoryStorage.d.ts +10 -0
  299. package/types/storages/inMemory/InMemoryStorageCS.d.ts +10 -0
  300. package/types/storages/inMemory/LatenciesCacheInMemory.d.ts +20 -0
  301. package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +22 -0
  302. package/types/storages/inMemory/SegmentsCacheInMemory.d.ts +19 -0
  303. package/types/storages/inMemory/SplitsCacheInMemory.d.ts +20 -0
  304. package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +53 -0
  305. package/types/storages/inMemory/uniqueKeysCacheInMemory.d.ts +35 -0
  306. package/types/storages/inMemory/uniqueKeysCacheInMemoryCS.d.ts +37 -0
  307. package/types/storages/inRedis/CountsCacheInRedis.d.ts +9 -0
  308. package/types/storages/inRedis/EventsCacheInRedis.d.ts +32 -0
  309. package/types/storages/inRedis/ImpressionCountsCacheInRedis.d.ts +13 -0
  310. package/types/storages/inRedis/ImpressionsCacheInRedis.d.ts +18 -0
  311. package/types/storages/inRedis/LatenciesCacheInRedis.d.ts +9 -0
  312. package/types/storages/inRedis/RedisAdapter.d.ts +24 -0
  313. package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +18 -0
  314. package/types/storages/inRedis/SplitsCacheInRedis.d.ts +91 -0
  315. package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +20 -0
  316. package/types/storages/inRedis/constants.d.ts +4 -0
  317. package/types/storages/inRedis/index.d.ts +10 -0
  318. package/types/storages/inRedis/uniqueKeysCacheInRedis.d.ts +14 -0
  319. package/types/storages/metadataBuilder.d.ts +3 -0
  320. package/types/storages/pluggable/EventsCachePluggable.d.ts +38 -0
  321. package/types/storages/pluggable/ImpressionsCachePluggable.d.ts +35 -0
  322. package/types/storages/pluggable/SegmentsCachePluggable.d.ts +54 -0
  323. package/types/storages/pluggable/SplitsCachePluggable.d.ts +89 -0
  324. package/types/storages/pluggable/TelemetryCachePluggable.d.ts +18 -0
  325. package/types/storages/pluggable/constants.d.ts +1 -0
  326. package/types/storages/pluggable/inMemoryWrapper.d.ts +13 -0
  327. package/types/storages/pluggable/index.d.ts +9 -0
  328. package/types/storages/pluggable/wrapperAdapter.d.ts +12 -0
  329. package/types/storages/types.d.ts +414 -0
  330. package/types/sync/offline/LocalhostFromFile.d.ts +2 -0
  331. package/types/sync/offline/LocalhostFromObject.d.ts +2 -0
  332. package/types/sync/offline/splitsParser/parseCondition.d.ts +7 -0
  333. package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +2 -0
  334. package/types/sync/offline/splitsParser/splitsParserFromSettings.d.ts +3 -0
  335. package/types/sync/offline/splitsParser/types.d.ts +3 -0
  336. package/types/sync/offline/syncManagerOffline.d.ts +10 -0
  337. package/types/sync/offline/syncTasks/fromObjectSyncTask.d.ts +17 -0
  338. package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +7 -0
  339. package/types/sync/polling/fetchers/segmentChangesFetcher.d.ts +7 -0
  340. package/types/sync/polling/fetchers/splitChangesFetcher.d.ts +7 -0
  341. package/types/sync/polling/fetchers/types.d.ts +5 -0
  342. package/types/sync/polling/pollingManagerCS.d.ts +7 -0
  343. package/types/sync/polling/pollingManagerSS.d.ts +6 -0
  344. package/types/sync/polling/syncTasks/mySegmentsSyncTask.d.ts +9 -0
  345. package/types/sync/polling/syncTasks/segmentsSyncTask.d.ts +9 -0
  346. package/types/sync/polling/syncTasks/splitsSyncTask.d.ts +9 -0
  347. package/types/sync/polling/types.d.ts +26 -0
  348. package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +13 -0
  349. package/types/sync/polling/updaters/segmentChangesUpdater.d.ts +18 -0
  350. package/types/sync/polling/updaters/splitChangesUpdater.d.ts +39 -0
  351. package/types/sync/streaming/AuthClient/index.d.ts +12 -0
  352. package/types/sync/streaming/AuthClient/types.d.ts +17 -0
  353. package/types/sync/streaming/SSEClient/index.d.ts +34 -0
  354. package/types/sync/streaming/SSEClient/types.d.ts +11 -0
  355. package/types/sync/streaming/SSEHandler/NotificationKeeper.d.ts +14 -0
  356. package/types/sync/streaming/SSEHandler/NotificationParser.d.ts +20 -0
  357. package/types/sync/streaming/SSEHandler/index.d.ts +11 -0
  358. package/types/sync/streaming/SSEHandler/types.d.ts +67 -0
  359. package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +6 -0
  360. package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +8 -0
  361. package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +12 -0
  362. package/types/sync/streaming/UpdateWorkers/constants.d.ts +3 -0
  363. package/types/sync/streaming/UpdateWorkers/types.d.ts +4 -0
  364. package/types/sync/streaming/constants.d.ts +34 -0
  365. package/types/sync/streaming/mySegmentsV2utils.d.ts +27 -0
  366. package/types/sync/streaming/pushManager.d.ts +9 -0
  367. package/types/sync/streaming/types.d.ts +35 -0
  368. package/types/sync/submitters/eventsSubmitter.d.ts +5 -0
  369. package/types/sync/submitters/eventsSyncTask.d.ts +8 -0
  370. package/types/sync/submitters/impressionCountsSubmitter.d.ts +10 -0
  371. package/types/sync/submitters/impressionCountsSubmitterInRedis.d.ts +5 -0
  372. package/types/sync/submitters/impressionCountsSyncTask.d.ts +13 -0
  373. package/types/sync/submitters/impressionsSubmitter.d.ts +11 -0
  374. package/types/sync/submitters/impressionsSyncTask.d.ts +14 -0
  375. package/types/sync/submitters/metricsSyncTask.d.ts +12 -0
  376. package/types/sync/submitters/submitter.d.ts +12 -0
  377. package/types/sync/submitters/submitterManager.d.ts +3 -0
  378. package/types/sync/submitters/submitterSyncTask.d.ts +10 -0
  379. package/types/sync/submitters/telemetrySubmitter.d.ts +25 -0
  380. package/types/sync/submitters/types.d.ts +194 -0
  381. package/types/sync/submitters/uniqueKeysSubmitter.d.ts +5 -0
  382. package/types/sync/submitters/uniqueKeysSubmitterInRedis.d.ts +5 -0
  383. package/types/sync/syncManagerOnline.d.ts +13 -0
  384. package/types/sync/syncTask.d.ts +13 -0
  385. package/types/sync/syncTaskComposite.d.ts +5 -0
  386. package/types/sync/types.d.ts +43 -0
  387. package/types/trackers/eventTracker.d.ts +10 -0
  388. package/types/trackers/filter/bloomFilter.d.ts +10 -0
  389. package/types/trackers/filter/dictionaryFilter.d.ts +8 -0
  390. package/types/trackers/filter/types.d.ts +5 -0
  391. package/types/trackers/impressionObserver/ImpressionObserver.d.ts +8 -0
  392. package/types/trackers/impressionObserver/buildKey.d.ts +2 -0
  393. package/types/trackers/impressionObserver/impressionObserverCS.d.ts +4 -0
  394. package/types/trackers/impressionObserver/impressionObserverSS.d.ts +4 -0
  395. package/types/trackers/impressionObserver/types.d.ts +4 -0
  396. package/types/trackers/impressionObserver/utils.d.ts +13 -0
  397. package/types/trackers/impressionsTracker.d.ts +13 -0
  398. package/types/trackers/strategy/strategyDebug.d.ts +9 -0
  399. package/types/trackers/strategy/strategyNone.d.ts +10 -0
  400. package/types/trackers/strategy/strategyOptimized.d.ts +11 -0
  401. package/types/trackers/telemetryTracker.d.ts +3 -0
  402. package/types/trackers/types.d.ts +57 -0
  403. package/types/trackers/uniqueKeysTracker.d.ts +13 -0
  404. package/types/types.d.ts +1263 -0
  405. package/types/utils/Backoff.d.ts +25 -0
  406. package/types/utils/LRUCache/LinkedList.d.ts +34 -0
  407. package/types/utils/LRUCache/index.d.ts +16 -0
  408. package/types/utils/MinEventEmitter.d.ts +12 -0
  409. package/types/utils/MinEvents.d.ts +4 -0
  410. package/types/utils/base64/index.d.ts +30 -0
  411. package/types/utils/constants/browser.d.ts +3 -0
  412. package/types/utils/constants/index.d.ts +64 -0
  413. package/types/utils/decompress/index.d.ts +16 -0
  414. package/types/utils/env/isLocalStorageAvailable.d.ts +1 -0
  415. package/types/utils/env/isNode.d.ts +5 -0
  416. package/types/utils/inputValidation/apiKey.d.ts +7 -0
  417. package/types/utils/inputValidation/attribute.d.ts +2 -0
  418. package/types/utils/inputValidation/attributes.d.ts +4 -0
  419. package/types/utils/inputValidation/event.d.ts +2 -0
  420. package/types/utils/inputValidation/eventProperties.d.ts +6 -0
  421. package/types/utils/inputValidation/eventValue.d.ts +2 -0
  422. package/types/utils/inputValidation/index.d.ts +13 -0
  423. package/types/utils/inputValidation/isOperational.d.ts +4 -0
  424. package/types/utils/inputValidation/key.d.ts +3 -0
  425. package/types/utils/inputValidation/preloadedData.d.ts +3 -0
  426. package/types/utils/inputValidation/split.d.ts +2 -0
  427. package/types/utils/inputValidation/splitExistance.d.ts +7 -0
  428. package/types/utils/inputValidation/splits.d.ts +2 -0
  429. package/types/utils/inputValidation/trafficType.d.ts +2 -0
  430. package/types/utils/inputValidation/trafficTypeExistance.d.ts +9 -0
  431. package/types/utils/jwt/index.d.ts +5 -0
  432. package/types/utils/jwt/types.d.ts +5 -0
  433. package/types/utils/key/index.d.ts +8 -0
  434. package/types/utils/labels/index.d.ts +7 -0
  435. package/types/utils/lang/binarySearch.d.ts +9 -0
  436. package/types/utils/lang/getFnName.d.ts +4 -0
  437. package/types/utils/lang/getGlobal.d.ts +4 -0
  438. package/types/utils/lang/index.d.ts +105 -0
  439. package/types/utils/lang/maps.d.ts +55 -0
  440. package/types/utils/lang/objectAssign.d.ts +3 -0
  441. package/types/utils/lang/sets.d.ts +60 -0
  442. package/types/utils/murmur3/common.d.ts +12 -0
  443. package/types/utils/murmur3/legacy.d.ts +2 -0
  444. package/types/utils/murmur3/murmur3.d.ts +2 -0
  445. package/types/utils/murmur3/murmur3_128.d.ts +6 -0
  446. package/types/utils/murmur3/murmur3_128_x86.d.ts +7 -0
  447. package/types/utils/murmur3/murmur3_64.d.ts +10 -0
  448. package/types/utils/murmur3/utfx.d.ts +27 -0
  449. package/types/utils/promise/thenable.d.ts +1 -0
  450. package/types/utils/promise/timeout.d.ts +1 -0
  451. package/types/utils/promise/wrapper.d.ts +21 -0
  452. package/types/utils/settingsValidation/consent.d.ts +6 -0
  453. package/types/utils/settingsValidation/impressionsMode.d.ts +3 -0
  454. package/types/utils/settingsValidation/index.d.ts +52 -0
  455. package/types/utils/settingsValidation/integrations/common.d.ts +14 -0
  456. package/types/utils/settingsValidation/integrations/configurable.d.ts +13 -0
  457. package/types/utils/settingsValidation/integrations/pluggable.d.ts +13 -0
  458. package/types/utils/settingsValidation/localhost/builtin.d.ts +16 -0
  459. package/types/utils/settingsValidation/localhost/pluggable.d.ts +16 -0
  460. package/types/utils/settingsValidation/logger/builtinLogger.d.ts +10 -0
  461. package/types/utils/settingsValidation/logger/commons.d.ts +9 -0
  462. package/types/utils/settingsValidation/logger/pluggableLogger.d.ts +11 -0
  463. package/types/utils/settingsValidation/mode.d.ts +1 -0
  464. package/types/utils/settingsValidation/runtime.d.ts +2 -0
  465. package/types/utils/settingsValidation/splitFilters.d.ts +16 -0
  466. package/types/utils/settingsValidation/storage/storageCS.d.ts +21 -0
  467. package/types/utils/settingsValidation/types.d.ts +32 -0
  468. package/types/utils/settingsValidation/url.d.ts +10 -0
  469. package/types/utils/time/index.d.ts +4 -0
  470. package/types/utils/timeTracker/index.d.ts +70 -0
  471. package/types/utils/timeTracker/now/browser.d.ts +1 -0
  472. package/types/utils/timeTracker/now/node.d.ts +1 -0
  473. package/types/utils/timeTracker/timer.d.ts +1 -0
  474. package/src/logger/.DS_Store +0 -0
  475. package/src/types.d.ts +0 -1581
package/src/types.ts ADDED
@@ -0,0 +1,1265 @@
1
+ import { ISplitFiltersValidation } from './dtos/types';
2
+ import { IIntegration, IIntegrationFactoryParams } from './integrations/types';
3
+ import { ILogger } from './logger/types';
4
+ import { ISdkFactoryContext } from './sdkFactory/types';
5
+ /* eslint-disable no-use-before-define */
6
+
7
+ import { IStorageFactoryParams, IStorageSync, IStorageAsync, IStorageSyncFactory, IStorageAsyncFactory } from './storages/types';
8
+ import { ISyncManagerCS } from './sync/types';
9
+
10
+ /**
11
+ * Reduced version of NodeJS.EventEmitter interface with the minimal methods used by the SDK
12
+ * @see {@link https://nodejs.org/api/events.html}
13
+ */
14
+ export interface IEventEmitter {
15
+ addListener(event: string, listener: (...args: any[]) => void): this;
16
+ on(event: string, listener: (...args: any[]) => void): this
17
+ once(event: string, listener: (...args: any[]) => void): this
18
+ removeListener(event: string, listener: (...args: any[]) => void): this;
19
+ off(event: string, listener: (...args: any[]) => void): this;
20
+ removeAllListeners(event?: string): this
21
+ emit(event: string, ...args: any[]): boolean
22
+ }
23
+
24
+ /**
25
+ * impression DTO generated by the Sdk client when processing evaluations
26
+ */
27
+ export type ImpressionDTO = {
28
+ feature: string,
29
+ keyName: string,
30
+ treatment: string,
31
+ time: number,
32
+ bucketingKey?: string,
33
+ label: string,
34
+ changeNumber: number,
35
+ pt?: number,
36
+ }
37
+
38
+ /** splitio.d.ts */
39
+
40
+ /**
41
+ * @typedef {Object} EventConsts
42
+ * @property {string} SDK_READY The ready event.
43
+ * @property {string} SDK_READY_FROM_CACHE The ready event when fired with cached data.
44
+ * @property {string} SDK_READY_TIMED_OUT The timeout event.
45
+ * @property {string} SDK_UPDATE The update event.
46
+ */
47
+ type EventConsts = {
48
+ SDK_READY: 'init::ready',
49
+ SDK_READY_FROM_CACHE: 'init::cache-ready',
50
+ SDK_READY_TIMED_OUT: 'init::timeout',
51
+ SDK_UPDATE: 'state::update'
52
+ };
53
+ /**
54
+ * SDK Modes.
55
+ * @typedef {string} SDKMode
56
+ */
57
+ export type SDKMode = 'standalone' | 'consumer' | 'localhost' | 'consumer_partial';
58
+ /**
59
+ * User consent status.
60
+ * @typedef {string} ConsentStatus
61
+ */
62
+ export type ConsentStatus = 'GRANTED' | 'DECLINED' | 'UNKNOWN';
63
+ /**
64
+ * Settings interface. This is a representation of the settings the SDK expose, that's why
65
+ * most of it's props are readonly. Only features should be rewritten when localhost mode is active.
66
+ * @interface ISettings
67
+ *
68
+ * NOTE: same ISettings interface from public type declarations extended with private properties.
69
+ */
70
+ export interface ISettings {
71
+ readonly core: {
72
+ authorizationKey: string,
73
+ key: SplitIO.SplitKey,
74
+ trafficType?: string,
75
+ labelsEnabled: boolean,
76
+ IPAddressesEnabled: boolean
77
+ },
78
+ readonly mode: SDKMode,
79
+ readonly scheduler: {
80
+ featuresRefreshRate: number,
81
+ impressionsRefreshRate: number,
82
+ impressionsQueueSize: number,
83
+ uniqueKeysRefreshRate: number,
84
+ uniqueKeysCacheSize: number,
85
+ /**
86
+ * @deprecated
87
+ */
88
+ metricsRefreshRate?: number,
89
+ telemetryRefreshRate: number,
90
+ segmentsRefreshRate: number,
91
+ offlineRefreshRate: number,
92
+ eventsPushRate: number,
93
+ eventsQueueSize: number,
94
+ pushRetryBackoffBase: number
95
+ },
96
+ readonly startup: {
97
+ readyTimeout: number,
98
+ requestTimeoutBeforeReady: number,
99
+ retriesOnFailureBeforeReady: number,
100
+ eventsFirstPushWindow: number
101
+ },
102
+ readonly storage: IStorageSyncFactory | IStorageAsyncFactory,
103
+ readonly integrations: Array<{
104
+ readonly type: string,
105
+ (params: IIntegrationFactoryParams): IIntegration | void
106
+ }>,
107
+ readonly urls: {
108
+ events: string,
109
+ sdk: string,
110
+ auth: string,
111
+ streaming: string,
112
+ telemetry: string
113
+ },
114
+ readonly debug: boolean | LogLevel | ILogger,
115
+ readonly version: string,
116
+ features: SplitIO.MockedFeaturesFilePath | SplitIO.MockedFeaturesMap,
117
+ readonly streamingEnabled: boolean,
118
+ readonly sync: {
119
+ splitFilters: SplitIO.SplitFilter[],
120
+ impressionsMode: SplitIO.ImpressionsMode,
121
+ __splitFiltersValidation: ISplitFiltersValidation,
122
+ localhostMode?: SplitIO.LocalhostFactory,
123
+ enabled: boolean
124
+ },
125
+ readonly runtime: {
126
+ ip: string | false
127
+ hostname: string | false
128
+ },
129
+ readonly log: ILogger
130
+ readonly impressionListener?: unknown
131
+ readonly userConsent?: ConsentStatus
132
+ }
133
+ /**
134
+ * Log levels.
135
+ * @typedef {string} LogLevel
136
+ */
137
+ export type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'NONE';
138
+ /**
139
+ * Logger API
140
+ * @interface ILoggerAPI
141
+ */
142
+ export interface ILoggerAPI {
143
+ /**
144
+ * Enables SDK logging to the console.
145
+ * @function enable
146
+ * @returns {void}
147
+ */
148
+ enable(): void,
149
+ /**
150
+ * Disables SDK logging.
151
+ * @function disable
152
+ * @returns {void}
153
+ */
154
+ disable(): void,
155
+ /**
156
+ * Sets a log level for the SDK logs.
157
+ * @function setLogLevel
158
+ * @returns {void}
159
+ */
160
+ setLogLevel(logLevel: LogLevel): void,
161
+ /**
162
+ * Log level constants. Use this to pass them to setLogLevel function.
163
+ */
164
+ LogLevel: {
165
+ [level: string]: LogLevel
166
+ }
167
+ }
168
+ /**
169
+ * Common settings between Browser and NodeJS settings interface.
170
+ * @interface ISharedSettings
171
+ */
172
+ interface ISharedSettings {
173
+ /**
174
+ * Whether the logger should be enabled or disabled by default.
175
+ * @property {Boolean} debug
176
+ * @default false
177
+ */
178
+ debug?: boolean,
179
+ /**
180
+ * The impression listener, which is optional. Whatever you provide here needs to comply with the SplitIO.IImpressionListener interface,
181
+ * which will check for the logImpression method.
182
+ * @property {IImpressionListener} impressionListener
183
+ * @default undefined
184
+ */
185
+ impressionListener?: SplitIO.IImpressionListener,
186
+ /**
187
+ * Boolean flag to enable the streaming service as default synchronization mechanism. In the event of any issue with streaming,
188
+ * the SDK would fallback to the polling mechanism. If false, the SDK would poll for changes as usual without attempting to use streaming.
189
+ * @property {boolean} streamingEnabled
190
+ * @default true
191
+ */
192
+ streamingEnabled?: boolean,
193
+ /**
194
+ * SDK synchronization settings.
195
+ * @property {Object} sync
196
+ */
197
+ sync?: {
198
+ /**
199
+ * List of Split filters. These filters are used to fetch a subset of the Splits definitions in your environment, in order to reduce the delay of the SDK to be ready.
200
+ * This configuration is only meaningful when the SDK is working in "standalone" mode.
201
+ *
202
+ * At the moment, two types of split filters are supported: by name and by prefix.
203
+ * Example:
204
+ * `splitFilter: [
205
+ * { type: 'byName', values: ['my_split_1', 'my_split_2'] }, // will fetch splits named 'my_split_1' and 'my_split_2'
206
+ * { type: 'byPrefix', values: ['testing'] } // will fetch splits whose names start with 'testing__' prefix
207
+ * ]`
208
+ * @property {SplitIO.SplitFilter[]} splitFilters
209
+ */
210
+ splitFilters?: SplitIO.SplitFilter[]
211
+ /**
212
+ * Impressions Collection Mode. Option to determine how impressions are going to be sent to Split Servers.
213
+ * Possible values are 'DEBUG' and 'OPTIMIZED'.
214
+ * - DEBUG: will send all the impressions generated (recommended only for debugging purposes).
215
+ * - OPTIMIZED: will send unique impressions to Split Servers avoiding a considerable amount of traffic that duplicated impressions could generate.
216
+ * @property {String} impressionsMode
217
+ * @default 'OPTIMIZED'
218
+ */
219
+ impressionsMode?: SplitIO.ImpressionsMode,
220
+ /**
221
+ * Enables synchronization.
222
+ * @property {boolean} enabled
223
+ */
224
+ enabled: boolean
225
+ }
226
+ }
227
+ /**
228
+ * Common settings interface for SDK instances on NodeJS.
229
+ * @interface INodeBasicSettings
230
+ * @extends ISharedSettings
231
+ */
232
+ interface INodeBasicSettings extends ISharedSettings {
233
+ /**
234
+ * SDK Startup settings for NodeJS.
235
+ * @property {Object} startup
236
+ */
237
+ startup?: {
238
+ /**
239
+ * Maximum amount of time used before notify a timeout.
240
+ * @property {number} readyTimeout
241
+ * @default 15
242
+ */
243
+ readyTimeout?: number,
244
+ /**
245
+ * Time to wait for a request before the SDK is ready. If this time expires, JS Sdk will retry 'retriesOnFailureBeforeReady' times before notifying its failure to be 'ready'.
246
+ * @property {number} requestTimeoutBeforeReady
247
+ * @default 15
248
+ */
249
+ requestTimeoutBeforeReady?: number,
250
+ /**
251
+ * How many quick retries we will do while starting up the SDK.
252
+ * @property {number} retriesOnFailureBeforeReady
253
+ * @default 1
254
+ */
255
+ retriesOnFailureBeforeReady?: number,
256
+ /**
257
+ * For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
258
+ * to better control on browsers. This number defines that window before the first events push.
259
+ *
260
+ * @property {number} eventsFirstPushWindow
261
+ * @default 0
262
+ */
263
+ eventsFirstPushWindow?: number,
264
+ },
265
+ /**
266
+ * SDK scheduler settings.
267
+ * @property {Object} scheduler
268
+ */
269
+ scheduler?: {
270
+ /**
271
+ * The SDK polls Split servers for changes to feature roll-out plans. This parameter controls this polling period in seconds.
272
+ * @property {number} featuresRefreshRate
273
+ * @default 5
274
+ */
275
+ featuresRefreshRate?: number,
276
+ /**
277
+ * The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers. The parameter should be in seconds.
278
+ * @property {number} impressionsRefreshRate
279
+ * @default 300
280
+ */
281
+ impressionsRefreshRate?: number,
282
+ /**
283
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
284
+ * If you use a 0 here, the queue will have no maximum size.
285
+ * @property {number} impressionsQueueSize
286
+ * @default 30000
287
+ */
288
+ impressionsQueueSize?: number,
289
+ /**
290
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
291
+ * @property {number} metricsRefreshRate
292
+ * @default 120
293
+ * @deprecated This parameter is ignored now.
294
+ */
295
+ metricsRefreshRate?: number,
296
+ /**
297
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
298
+ * @property {number} telemetryRefreshRate
299
+ * @default 3600
300
+ */
301
+ telemetryRefreshRate?: number,
302
+ /**
303
+ * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
304
+ * @property {number} segmentsRefreshRate
305
+ * @default 60
306
+ */
307
+ segmentsRefreshRate?: number,
308
+ /**
309
+ * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
310
+ * @property {number} eventsPushRate
311
+ * @default 60
312
+ */
313
+ eventsPushRate?: number,
314
+ /**
315
+ * The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
316
+ * If you use a 0 here, the queue will have no maximum size.
317
+ * @property {number} eventsQueueSize
318
+ * @default 500
319
+ */
320
+ eventsQueueSize?: number,
321
+ /**
322
+ * For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
323
+ * For more information @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
324
+ * @property {number} offlineRefreshRate
325
+ * @default 15
326
+ */
327
+ offlineRefreshRate?: number
328
+ /**
329
+ * When using streaming mode, seconds to wait before re attempting to connect for push notifications.
330
+ * Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
331
+ * @property {number} pushRetryBackoffBase
332
+ * @default 1
333
+ */
334
+ pushRetryBackoffBase?: number,
335
+ },
336
+ /**
337
+ * SDK Core settings for NodeJS.
338
+ * @property {Object} core
339
+ */
340
+ core: {
341
+ /**
342
+ * Your API key. More information: @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
343
+ * @property {string} authorizationKey
344
+ */
345
+ authorizationKey: string,
346
+ /**
347
+ * Disable labels from being sent to Split backend. Labels may contain sensitive information.
348
+ * @property {boolean} labelsEnabled
349
+ * @default true
350
+ */
351
+ labelsEnabled?: boolean
352
+ /**
353
+ * Disable machine IP and Name from being sent to Split backend.
354
+ * @property {boolean} IPAddressesEnabled
355
+ * @default true
356
+ */
357
+ IPAddressesEnabled?: boolean
358
+ },
359
+ /**
360
+ * Defines which kind of storage we should instanciate.
361
+ * @property {Object} storage
362
+ */
363
+ storage?: (params: any) => any,
364
+ /**
365
+ * The SDK mode. Possible values are "standalone" (which is the default) and "consumer". For "localhost" mode, use "localhost" as authorizationKey.
366
+ * @property {SDKMode} mode
367
+ * @default standalone
368
+ */
369
+ mode?: SDKMode,
370
+ /**
371
+ * Mocked features file path. For testing purposses only. For using this you should specify "localhost" as authorizationKey on core settings.
372
+ * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
373
+ * @property {MockedFeaturesFilePath} features
374
+ * @default $HOME/.split
375
+ */
376
+ features?: SplitIO.MockedFeaturesFilePath,
377
+ }
378
+ /**
379
+ * Common API for entities that expose status handlers.
380
+ * @interface IStatusInterface
381
+ * @extends IEventEmitter
382
+ */
383
+ export interface IStatusInterface extends IEventEmitter {
384
+ /**
385
+ * Constant object containing the SDK events for you to use.
386
+ * @property {EventConsts} Event
387
+ */
388
+ Event: EventConsts,
389
+ /**
390
+ * Returns a promise that will be resolved once the SDK has finished loading (SDK_READY event emitted) or rejected if the SDK has timedout (SDK_READY_TIMED_OUT event emitted).
391
+ * As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, calling the `ready` method after the
392
+ * SDK had timed out will return a new promise that should eventually resolve if the SDK gets ready.
393
+ *
394
+ * Caveats: the method was designed to avoid an unhandled Promise rejection if the rejection case is not handled, so that `onRejected` handler is optional when using promises.
395
+ * However, when using async/await syntax, the rejection should be explicitly propagated like in the following example:
396
+ * ```
397
+ * try {
398
+ * await client.ready().catch((e) => { throw e; });
399
+ * // SDK is ready
400
+ * } catch(e) {
401
+ * // SDK has timedout
402
+ * }
403
+ * ```
404
+ *
405
+ * @function ready
406
+ * @returns {Promise<void>}
407
+ */
408
+ ready(): Promise<void>
409
+ }
410
+ /**
411
+ * Common definitions between clients for different environments interface.
412
+ * @interface IBasicClient
413
+ * @extends IStatusInterface
414
+ */
415
+ interface IBasicClient extends IStatusInterface {
416
+ /**
417
+ * Destroy the client instance.
418
+ * @function destroy
419
+ * @returns {Promise<void>}
420
+ */
421
+ destroy(): Promise<void>
422
+
423
+ // Whether the client implements the client-side API, i.e, with bound key, (true), or the server-side API (false).
424
+ // Exposed for internal purposes only. Not considered part of the public API, and might be renamed eventually.
425
+ isClientSide: boolean
426
+ }
427
+ /**
428
+ * Common definitions between SDK instances for different environments interface.
429
+ * @interface IBasicSDK
430
+ */
431
+ interface IBasicSDK {
432
+ /**
433
+ * Current settings of the SDK instance.
434
+ * @property settings
435
+ */
436
+ settings: ISettings,
437
+ /**
438
+ * Logger API.
439
+ * @property Logger
440
+ */
441
+ Logger: ILoggerAPI
442
+ }
443
+ /****** Exposed namespace ******/
444
+ /**
445
+ * Types and interfaces for @splitsoftware/splitio package for usage when integrating javascript sdk on typescript apps.
446
+ * For the SDK package information
447
+ * @see {@link https://www.npmjs.com/package/@splitsoftware/splitio}
448
+ */
449
+ export namespace SplitIO {
450
+ /**
451
+ * Split treatment value, returned by getTreatment.
452
+ * @typedef {string} Treatment
453
+ */
454
+ export type Treatment = string;
455
+ /**
456
+ * Split treatment promise that will resolve to actual treatment value.
457
+ * @typedef {Promise<string>} AsyncTreatment
458
+ */
459
+ export type AsyncTreatment = Promise<string>;
460
+ /**
461
+ * An object with the treatments for a bulk of splits, returned by getTreatments. For example:
462
+ * {
463
+ * feature1: 'on',
464
+ * feature2: 'off
465
+ * }
466
+ * @typedef {Object.<Treatment>} Treatments
467
+ */
468
+ export type Treatments = {
469
+ [featureName: string]: Treatment
470
+ };
471
+ /**
472
+ * Split treatments promise that will resolve to the actual SplitIO.Treatments object.
473
+ * @typedef {Promise<Treatments>} AsyncTreatments
474
+ */
475
+ export type AsyncTreatments = Promise<Treatments>;
476
+ /**
477
+ * Split evaluation result with treatment and configuration, returned by getTreatmentWithConfig.
478
+ * @typedef {Object} TreatmentWithConfig
479
+ * @property {string} treatment The treatment result
480
+ * @property {string | null} config The stringified version of the JSON config defined for that treatment, null if there is no config for the resulting treatment.
481
+ */
482
+ export type TreatmentWithConfig = {
483
+ treatment: string,
484
+ config: string | null
485
+ };
486
+ /**
487
+ * Split treatment promise that will resolve to actual treatment with config value.
488
+ * @typedef {Promise<TreatmentWithConfig>} AsyncTreatmentWithConfig
489
+ */
490
+ export type AsyncTreatmentWithConfig = Promise<TreatmentWithConfig>;
491
+ /**
492
+ * An object with the treatments with configs for a bulk of splits, returned by getTreatmentsWithConfig.
493
+ * Each existing configuration is a stringified version of the JSON you defined on the Split web console. For example:
494
+ * {
495
+ * feature1: { treatment: 'on', config: null }
496
+ * feature2: { treatment: 'off', config: '{"bannerText":"Click here."}' }
497
+ * }
498
+ * @typedef {Object.<TreatmentWithConfig>} Treatments
499
+ */
500
+ export type TreatmentsWithConfig = {
501
+ [featureName: string]: TreatmentWithConfig
502
+ };
503
+ /**
504
+ * Split treatments promise that will resolve to the actual SplitIO.TreatmentsWithConfig object.
505
+ * @typedef {Promise<TreatmentsWithConfig>} AsyncTreatmentsWithConfig
506
+ */
507
+ export type AsyncTreatmentsWithConfig = Promise<TreatmentsWithConfig>;
508
+ /**
509
+ * Possible Split SDK events.
510
+ * @typedef {string} Event
511
+ */
512
+ export type Event = 'init::timeout' | 'init::ready' | 'init::cache-ready' | 'state::update';
513
+ /**
514
+ * Split attributes should be on object with values of type string or number (dates should be sent as millis since epoch).
515
+ * @typedef {Object.<number, string, boolean, string[], number[]>} Attributes
516
+ * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#attribute-syntax}
517
+ */
518
+ export type Attributes = {
519
+ [attributeName: string]: string | number | boolean | Array<string | number>
520
+ };
521
+ /**
522
+ * Split properties should be an object with values of type string, number, boolean or null. Size limit of ~31kb.
523
+ * @typedef {Object.<number, string, boolean, null>} Attributes
524
+ * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#track
525
+ */
526
+ export type Properties = {
527
+ [propertyName: string]: string | number | boolean | null
528
+ };
529
+ /**
530
+ * The SplitKey object format.
531
+ * @typedef {Object.<string>} SplitKeyObject
532
+ */
533
+ export type SplitKeyObject = {
534
+ matchingKey: string,
535
+ bucketingKey: string
536
+ };
537
+ /**
538
+ * The customer identifier. Could be a SplitKeyObject or a string.
539
+ * @typedef {SplitKeyObject|string} SplitKey
540
+ */
541
+ export type SplitKey = SplitKeyObject | string;
542
+ /**
543
+ * Path to file with mocked features (for node).
544
+ * @typedef {string} MockedFeaturesFilePath
545
+ */
546
+ export type MockedFeaturesFilePath = string;
547
+ /**
548
+ * Object with mocked features mapping (for browser). We need to specify the featureName as key, and the mocked treatment as value.
549
+ * @typedef {Object} MockedFeaturesMap
550
+ */
551
+ export type MockedFeaturesMap = {
552
+ [featureName: string]: string | TreatmentWithConfig
553
+ };
554
+ /**
555
+ * Object with information about an impression. It contains the generated impression DTO as well as
556
+ * complementary information around where and how it was generated in that way.
557
+ * @typedef {Object} ImpressionData
558
+ */
559
+ export type ImpressionData = {
560
+ impression: ImpressionDTO,
561
+ attributes?: SplitIO.Attributes,
562
+ ip: string| false,
563
+ hostname: string | false,
564
+ sdkLanguageVersion: string
565
+ };
566
+ /**
567
+ * Data corresponding to one Split view.
568
+ * @typedef {Object} SplitView
569
+ */
570
+ export type SplitView = {
571
+ /**
572
+ * The name of the split.
573
+ * @property {string} name
574
+ */
575
+ name: string,
576
+ /**
577
+ * The traffic type of the split.
578
+ * @property {string} trafficType
579
+ */
580
+ trafficType: string,
581
+ /**
582
+ * Whether the split is killed or not.
583
+ * @property {boolean} killed
584
+ */
585
+ killed: boolean,
586
+ /**
587
+ * The list of treatments available for the split.
588
+ * @property {Array<string>} treatments
589
+ */
590
+ treatments: Array<string>,
591
+ /**
592
+ * Current change number of the split.
593
+ * @property {number} changeNumber
594
+ */
595
+ changeNumber: number,
596
+ /**
597
+ * Map of configurations per treatment.
598
+ * Each existing configuration is a stringified version of the JSON you defined on the Split web console.
599
+ * @property {Object.<string>} configs
600
+ */
601
+ configs: {
602
+ [treatmentName: string]: string
603
+ }
604
+ };
605
+ /**
606
+ * A promise that will be resolved with that SplitView.
607
+ * @typedef {Promise<SplitView>} SplitView
608
+ */
609
+ export type SplitViewAsync = Promise<SplitView>;
610
+ /**
611
+ * An array containing the SplitIO.SplitView elements.
612
+ */
613
+ export type SplitViews = Array<SplitView>;
614
+ /**
615
+ * A promise that will be resolved with an SplitIO.SplitViews array.
616
+ * @typedef {Promise<SplitViews>} SplitViewsAsync
617
+ */
618
+ export type SplitViewsAsync = Promise<SplitViews>;
619
+ /**
620
+ * An array of split names.
621
+ * @typedef {Array<string>} SplitNames
622
+ */
623
+ export type SplitNames = Array<string>;
624
+ /**
625
+ * A promise that will be resolved with an array of split names.
626
+ * @typedef {Promise<SplitNames>} SplitNamesAsync
627
+ */
628
+ export type SplitNamesAsync = Promise<SplitNames>;
629
+ /**
630
+ * Localhost mode factory.
631
+ */
632
+ export type LocalhostFactory = {
633
+ type: 'LocalhostFromObject' | 'LocalhostFromFile'
634
+ (params: ISdkFactoryContext): ISyncManagerCS
635
+ }
636
+ /**
637
+ * Impression listener interface. This is the interface that needs to be implemented
638
+ * by the element you provide to the SDK as impression listener.
639
+ * @interface IImpressionListener
640
+ * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#listener}
641
+ */
642
+ export interface IImpressionListener {
643
+ logImpression(data: SplitIO.ImpressionData): void
644
+ }
645
+ /**
646
+ * Object with information about a Split event.
647
+ * @typedef {Object} EventData
648
+ */
649
+ export type EventData = {
650
+ eventTypeId: string;
651
+ value?: number;
652
+ properties?: Properties;
653
+ trafficTypeName?: string;
654
+ key?: string; // matching user key
655
+ timestamp: number;
656
+ };
657
+ /**
658
+ * Object representing the data sent by Split (events and impressions).
659
+ * @typedef {Object} IntegrationData
660
+ * @property {string} type The type of Split data, either 'IMPRESSION' or 'EVENT'.
661
+ * @property {ImpressionData | EventData} payload The data instance itself.
662
+ */
663
+ export type IntegrationData = { type: 'IMPRESSION', payload: SplitIO.ImpressionData } | { type: 'EVENT', payload: SplitIO.EventData };
664
+ /**
665
+ * Available URL settings for the SDKs.
666
+ */
667
+ export type UrlSettings = {
668
+ /**
669
+ * String property to override the base URL where the SDK will get feature flagging related data like a Split rollout plan or segments information.
670
+ * @property {string} sdk
671
+ * @default 'https://sdk.split.io/api'
672
+ */
673
+ sdk?: string,
674
+ /**
675
+ * String property to override the base URL where the SDK will post event-related information like impressions.
676
+ * @property {string} events
677
+ * @default 'https://events.split.io/api'
678
+ */
679
+ events?: string,
680
+ /**
681
+ * String property to override the base URL where the SDK will get authorization tokens to be used with functionality that requires it, like streaming.
682
+ * @property {string} auth
683
+ * @default 'https://auth.split.io/api'
684
+ */
685
+ auth?: string,
686
+ /**
687
+ * String property to override the base URL where the SDK will connect to receive streaming updates.
688
+ * @property {string} streaming
689
+ * @default 'https://streaming.split.io'
690
+ */
691
+ streaming?: string,
692
+ /**
693
+ * String property to override the base URL where the SDK will post telemetry data.
694
+ * @property {string} telemetry
695
+ * @default 'https://telemetry.split.io/api'
696
+ */
697
+ telemetry?: string
698
+ };
699
+ /**
700
+ * SplitFilter type.
701
+ * @typedef {string} SplitFilterType
702
+ */
703
+ export type SplitFilterType = 'byName' | 'byPrefix';
704
+ /**
705
+ * Defines a split filter, described by a type and list of values.
706
+ */
707
+ export interface SplitFilter {
708
+ /**
709
+ * Type of the filter.
710
+ * @property {SplitFilterType} type
711
+ */
712
+ type: SplitFilterType,
713
+ /**
714
+ * List of values: split names for 'byName' filter type, and split prefixes for 'byPrefix' type.
715
+ * @property {string[]} values
716
+ */
717
+ values: string[],
718
+ }
719
+ /**
720
+ * ImpressionsMode type
721
+ * @typedef {string} ImpressionsMode
722
+ */
723
+ export type ImpressionsMode = 'OPTIMIZED' | 'DEBUG' | 'NONE'
724
+ /**
725
+ * Defines the format of Split data to preload on the factory storage (cache).
726
+ */
727
+ export interface PreloadedData {
728
+ /**
729
+ * Timestamp of the last moment the data was synchronized with Split servers.
730
+ * If this value is older than 10 days ago (expiration time policy), the data is not used to update the storage content.
731
+ * @TODO configurable expiration time policy?
732
+ */
733
+ lastUpdated: number,
734
+ /**
735
+ * Change number of the preloaded data.
736
+ * If this value is older than the current changeNumber at the storage, the data is not used to update the storage content.
737
+ */
738
+ since: number,
739
+ /**
740
+ * Map of splits to their serialized definitions.
741
+ */
742
+ splitsData: {
743
+ [splitName: string]: string
744
+ },
745
+ /**
746
+ * Optional map of user keys to their list of segments.
747
+ * @TODO remove when releasing first version
748
+ */
749
+ mySegmentsData?: {
750
+ [key: string]: string[]
751
+ },
752
+ /**
753
+ * Optional map of segments to their serialized definitions.
754
+ * This property is ignored if `mySegmentsData` was provided.
755
+ */
756
+ segmentsData?: {
757
+ [segmentName: string]: string
758
+ },
759
+ }
760
+ /**
761
+ * Settings interface for SDK instances created on the browser
762
+ * @interface IBrowserSettings
763
+ * @extends ISharedSettings
764
+ * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#configuration}
765
+ */
766
+ export interface IBrowserSettings extends ISharedSettings {
767
+ /**
768
+ * SDK Startup settings for the Browser.
769
+ * @property {Object} startup
770
+ */
771
+ startup?: {
772
+ /**
773
+ * Maximum amount of time used before notify a timeout.
774
+ * @property {number} readyTimeout
775
+ * @default 1.5
776
+ */
777
+ readyTimeout?: number,
778
+ /**
779
+ * Time to wait for a request before the SDK is ready. If this time expires, JS Sdk will retry 'retriesOnFailureBeforeReady' times before notifying its failure to be 'ready'.
780
+ * @property {number} requestTimeoutBeforeReady
781
+ * @default 1.5
782
+ */
783
+ requestTimeoutBeforeReady?: number,
784
+ /**
785
+ * How many quick retries we will do while starting up the SDK.
786
+ * @property {number} retriesOnFailureBeforeReady
787
+ * @default 1
788
+ */
789
+ retriesOnFailureBeforeReady?: number,
790
+ /**
791
+ * For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
792
+ * to better control on browsers. This number defines that window before the first events push.
793
+ *
794
+ * @property {number} eventsFirstPushWindow
795
+ * @default 10
796
+ */
797
+ eventsFirstPushWindow?: number,
798
+ },
799
+ /**
800
+ * SDK scheduler settings.
801
+ * @property {Object} scheduler
802
+ */
803
+ scheduler?: {
804
+ /**
805
+ * The SDK polls Split servers for changes to feature roll-out plans. This parameter controls this polling period in seconds.
806
+ * @property {number} featuresRefreshRate
807
+ * @default 30
808
+ */
809
+ featuresRefreshRate?: number,
810
+ /**
811
+ * The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers. The parameter should be in seconds.
812
+ * @property {number} impressionsRefreshRate
813
+ * @default 60
814
+ */
815
+ impressionsRefreshRate?: number,
816
+ /**
817
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
818
+ * If you use a 0 here, the queue will have no maximum size.
819
+ * @property {number} impressionsQueueSize
820
+ * @default 30000
821
+ */
822
+ impressionsQueueSize?: number,
823
+ /**
824
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
825
+ * @property {number} metricsRefreshRate
826
+ * @default 120
827
+ * @deprecated This parameter is ignored now.
828
+ */
829
+ metricsRefreshRate?: number,
830
+ /**
831
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
832
+ * @property {number} telemetryRefreshRate
833
+ * @default 3600
834
+ */
835
+ telemetryRefreshRate?: number,
836
+ /**
837
+ * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
838
+ * @property {number} segmentsRefreshRate
839
+ * @default 60
840
+ */
841
+ segmentsRefreshRate?: number,
842
+ /**
843
+ * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
844
+ * @property {number} eventsPushRate
845
+ * @default 60
846
+ */
847
+ eventsPushRate?: number,
848
+ /**
849
+ * The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
850
+ * If you use a 0 here, the queue will have no maximum size.
851
+ * @property {number} eventsQueueSize
852
+ * @default 500
853
+ */
854
+ eventsQueueSize?: number,
855
+ /**
856
+ * For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
857
+ * For more information @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
858
+ * @property {number} offlineRefreshRate
859
+ * @default 15
860
+ */
861
+ offlineRefreshRate?: number
862
+ /**
863
+ * When using streaming mode, seconds to wait before re attempting to connect for push notifications.
864
+ * Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
865
+ * @property {number} pushRetryBackoffBase
866
+ * @default 1
867
+ */
868
+ pushRetryBackoffBase?: number,
869
+ },
870
+ /**
871
+ * SDK Core settings for the browser.
872
+ * @property {Object} core
873
+ */
874
+ core: {
875
+ /**
876
+ * Your API key. More information: @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
877
+ * @property {string} authorizationKey
878
+ */
879
+ authorizationKey: string,
880
+ /**
881
+ * Customer identifier. Whatever this means to you. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
882
+ * @property {SplitKey} key
883
+ */
884
+ key: SplitKey,
885
+ /**
886
+ * Traffic type associated with the customer identifier. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
887
+ * If no provided as a setting it will be required on the client.track() calls.
888
+ * @property {string} trafficType
889
+ */
890
+ trafficType?: string,
891
+ /**
892
+ * Disable labels from being sent to Split backend. Labels may contain sensitive information.
893
+ * @property {boolean} labelsEnabled
894
+ * @default true
895
+ */
896
+ labelsEnabled?: boolean
897
+ },
898
+ /**
899
+ * Mocked features map. For testing purposses only. For using this you should specify "localhost" as authorizationKey on core settings.
900
+ * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
901
+ */
902
+ features?: MockedFeaturesMap,
903
+ /**
904
+ * Defines which kind of storage we should instanciate.
905
+ * @property {Object} storage
906
+ */
907
+ storage?: (params: IStorageFactoryParams) => IStorageSync | IStorageAsync,
908
+ /**
909
+ * List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
910
+ * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
911
+ * @property {Object} urls
912
+ */
913
+ urls?: UrlSettings,
914
+ }
915
+ /**
916
+ * Settings interface for SDK instances created on NodeJS.
917
+ * If your storage is asynchronous (Redis for example) use SplitIO.INodeAsyncSettings instead.
918
+ * @interface INodeSettings
919
+ * @extends INodeBasicSettings
920
+ * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
921
+ */
922
+ export interface INodeSettings extends INodeBasicSettings {
923
+ /**
924
+ * List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
925
+ * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
926
+ * @property {Object} urls
927
+ */
928
+ urls?: UrlSettings,
929
+ /**
930
+ * Defines which kind of storage we should instanciate.
931
+ * @property {Object} storage
932
+ */
933
+ storage?: (params: IStorageFactoryParams) => IStorageSync,
934
+ }
935
+ /**
936
+ * Settings interface with async storage for SDK instances created on NodeJS.
937
+ * If your storage is synchronous (by defaut we use memory, which is sync) use SplitIO.INodeSyncSettings instead.
938
+ * @interface INodeAsyncSettings
939
+ * @extends INodeBasicSettings
940
+ * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
941
+ */
942
+ export interface INodeAsyncSettings extends INodeBasicSettings {
943
+ storage?: (params: IStorageFactoryParams) => IStorageAsync,
944
+ }
945
+ /**
946
+ * This represents the interface for the Server-side SDK instance with synchronous storage.
947
+ * @interface ISDK
948
+ * @extends IBasicSDK
949
+ */
950
+ export interface ISDK extends IBasicSDK {
951
+ /**
952
+ * Returns the client instance of the SDK.
953
+ * @function client
954
+ * @returns {IClient} The client instance.
955
+ */
956
+ client(): IClient,
957
+ /**
958
+ * Returns a manager instance of the SDK to explore available information.
959
+ * @function manager
960
+ * @returns {IManager} The manager instance.
961
+ */
962
+ manager(): IManager
963
+ }
964
+ /**
965
+ * This represents the interface for the Server-side SDK instance with asynchronous storage.
966
+ * @interface IAsyncSDK
967
+ * @extends IBasicSDK
968
+ */
969
+ export interface IAsyncSDK extends IBasicSDK {
970
+ /**
971
+ * Returns the default client instance of the SDK.
972
+ * @function client
973
+ * @returns {IAsyncClient} The asynchronous client instance.
974
+ */
975
+ client(): IAsyncClient,
976
+ /**
977
+ * Returns a manager instance of the SDK to explore available information.
978
+ * @function manager
979
+ * @returns {IManager} The manager instance.
980
+ */
981
+ manager(): IAsyncManager
982
+ }
983
+ /**
984
+ * This represents the interface for the Client-side SDK instance with synchronous storage.
985
+ * @interface ICsSDK
986
+ * @extends IBasicSDK
987
+ */
988
+ export interface ICsSDK extends IBasicSDK {
989
+ /**
990
+ * Returns the default client instance of the SDK, with the key and optional traffic type from settings.
991
+ * @function client
992
+ * @returns {ICsClient} The client instance.
993
+ */
994
+ client(): ICsClient,
995
+ /**
996
+ * Returns a shared client of the SDK, with the given key and optional traffic type.
997
+ * @function client
998
+ * @param {SplitKey} key The key for the new client instance.
999
+ * @param {string=} trafficType The traffic type of the provided key.
1000
+ * @returns {ICsClient} The client instance.
1001
+ */
1002
+ client(key: SplitKey, trafficType?: string): ICsClient,
1003
+ /**
1004
+ * Returns a manager instance of the SDK to explore available information.
1005
+ * @function manager
1006
+ * @returns {IManager} The manager instance.
1007
+ */
1008
+ manager(): IManager
1009
+ }
1010
+ /**
1011
+ * This represents the interface for the Client instance with synchronous storage for server-side SDK, where we don't have only one key.
1012
+ * @interface IClient
1013
+ * @extends IBasicClient
1014
+ */
1015
+ export interface IClient extends IBasicClient {
1016
+ /**
1017
+ * Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
1018
+ * @function getTreatment
1019
+ * @param {string} key - The string key representing the consumer.
1020
+ * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1021
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1022
+ * @returns {Treatment} The treatment or treatment promise which will resolve to the treatment string.
1023
+ */
1024
+ getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): Treatment,
1025
+ /**
1026
+ * Returns a TreatmentWithConfig value (a map of treatment and config), which will be (or eventually be) the map with treatment and config for the given feature.
1027
+ * @function getTreatmentWithConfig
1028
+ * @param {string} key - The string key representing the consumer.
1029
+ * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1030
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1031
+ * @returns {TreatmentWithConfig} The TreatmentWithConfig or TreatmentWithConfig promise which will resolve to the map containing
1032
+ * the treatment and the configuration stringified JSON (or null if there was no config for that treatment).
1033
+ */
1034
+ getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): TreatmentWithConfig,
1035
+ /**
1036
+ * Returns a Treatments value, whick will be (or eventually be) an object with the treatments for the given features.
1037
+ * @function getTreatments
1038
+ * @param {string} key - The string key representing the consumer.
1039
+ * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1040
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1041
+ * @returns {Treatments} The treatments or treatments promise which will resolve to the treatments object.
1042
+ */
1043
+ getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): Treatments,
1044
+ /**
1045
+ * Returns a TreatmentsWithConfig value, whick will be an object with the TreatmentWithConfig (a map with both treatment and config string) for the given features.
1046
+ * @function getTreatmentsWithConfig
1047
+ * @param {string} key - The string key representing the consumer.
1048
+ * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1049
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1050
+ * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
1051
+ */
1052
+ getTreatmentsWithConfig(key: SplitKey, splitNames: string[], attributes?: Attributes): TreatmentsWithConfig,
1053
+ /**
1054
+ * Tracks an event to be fed to the results product on Split Webconsole.
1055
+ * @function track
1056
+ * @param {SplitKey} key - The key that identifies the entity related to this event.
1057
+ * @param {string} trafficType - The traffic type of the entity related to this event.
1058
+ * @param {string} eventType - The event type corresponding to this event.
1059
+ * @param {number=} value - The value of this event.
1060
+ * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1061
+ * @returns {boolean} Whether the event was added to the queue succesfully or not.
1062
+ */
1063
+ track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
1064
+ }
1065
+ /**
1066
+ * This represents the interface for the Client instance with asynchronous storage for server-side SDK, where we don't have only one key.
1067
+ * @interface IAsyncClient
1068
+ * @extends IBasicClient
1069
+ */
1070
+ export interface IAsyncClient extends IBasicClient {
1071
+ /**
1072
+ * Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
1073
+ * For usage on NodeJS as we don't have only one key.
1074
+ * NOTE: Treatment will be a promise only in async storages, like REDIS.
1075
+ * @function getTreatment
1076
+ * @param {string} key - The string key representing the consumer.
1077
+ * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1078
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1079
+ * @returns {AsyncTreatment} Treatment promise which will resolve to the treatment string.
1080
+ */
1081
+ getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatment,
1082
+ /**
1083
+ * Returns a TreatmentWithConfig value, which will be (or eventually be) a map with both treatment and config string for the given feature.
1084
+ * For usage on NodeJS as we don't have only one key.
1085
+ * NOTE: Treatment will be a promise only in async storages, like REDIS.
1086
+ * @function getTreatmentWithConfig
1087
+ * @param {string} key - The string key representing the consumer.
1088
+ * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1089
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1090
+ * @returns {AsyncTreatmentWithConfig} TreatmentWithConfig promise which will resolve to the TreatmentWithConfig object.
1091
+ */
1092
+ getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatmentWithConfig,
1093
+ /**
1094
+ * Returns a Treatments value, whick will be (or eventually be) an object with the treatments for the given features.
1095
+ * For usage on NodeJS as we don't have only one key.
1096
+ * @function getTreatments
1097
+ * @param {string} key - The string key representing the consumer.
1098
+ * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1099
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1100
+ * @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object.
1101
+ */
1102
+ getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): AsyncTreatments,
1103
+ /**
1104
+ * Returns a Treatments value, whick will be (or eventually be) an object with all the maps of treatment and config string for the given features.
1105
+ * For usage on NodeJS as we don't have only one key.
1106
+ * @function getTreatmentsWithConfig
1107
+ * @param {string} key - The string key representing the consumer.
1108
+ * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1109
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1110
+ * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise which will resolve to the map of TreatmentsWithConfig objects.
1111
+ */
1112
+ getTreatmentsWithConfig(key: SplitKey, splitNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig,
1113
+ /**
1114
+ * Tracks an event to be fed to the results product on Split Webconsole and returns a promise to signal when the event was successfully queued (or not).
1115
+ * @function track
1116
+ * @param {SplitKey} key - The key that identifies the entity related to this event.
1117
+ * @param {string} trafficType - The traffic type of the entity related to this event.
1118
+ * @param {string} eventType - The event type corresponding to this event.
1119
+ * @param {number=} value - The value of this event.
1120
+ * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1121
+ * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue succesfully or not.
1122
+ */
1123
+ track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>
1124
+ }
1125
+ /**
1126
+ * This represents the interface for the Client instance with synchronous storage for client-side SDK, where each client has associated a key and optionally a traffic type.
1127
+ * @interface IClient
1128
+ * @extends IBasicClient
1129
+ */
1130
+ export interface ICsClient extends IBasicClient {
1131
+ /**
1132
+ * Returns a Treatment value, which will be the treatment string for the given feature.
1133
+ * @function getTreatment
1134
+ * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1135
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1136
+ * @returns {Treatment} The treatment result.
1137
+ */
1138
+ getTreatment(splitName: string, attributes?: Attributes): Treatment,
1139
+ /**
1140
+ * Returns a TreatmentWithConfig value, which will be a map of treatment and the config for that treatment.
1141
+ * @function getTreatment
1142
+ * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1143
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1144
+ * @returns {TreatmentWithConfig} The treatment or treatment promise which will resolve to the treatment string.
1145
+ */
1146
+ getTreatmentWithConfig(splitName: string, attributes?: Attributes): TreatmentWithConfig,
1147
+ /**
1148
+ * Returns a Treatments value, whick will be (or eventually be) an object with the treatments for the given features.
1149
+ * @function getTreatments
1150
+ * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1151
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1152
+ * @returns {Treatments} The treatments or treatments promise which will resolve to the treatments object.
1153
+ */
1154
+ getTreatments(splitNames: string[], attributes?: Attributes): Treatments,
1155
+ /**
1156
+ * Returns a TreatmentsWithConfig value, whick will be an object with the TreatmentWithConfig (a map with both treatment and config string) for the given features.
1157
+ * @function getTreatmentsWithConfig
1158
+ * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1159
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1160
+ * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
1161
+ */
1162
+ getTreatmentsWithConfig(splitNames: string[], attributes?: Attributes): TreatmentsWithConfig,
1163
+ /**
1164
+ * Tracks an event to be fed to the results product on Split Webconsole.
1165
+ * @function track
1166
+ * @param {string} trafficType - The traffic type of the entity related to this event. NOTE: only has to be provided if the client doesn't have a traffic type
1167
+ * @param {string} eventType - The event type corresponding to this event.
1168
+ * @param {number=} value - The value of this event.
1169
+ * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1170
+ * @returns {boolean} Whether the event was added to the queue succesfully or not.
1171
+ */
1172
+ track(...args: [trafficType: string, eventType: string, value?: number, properties?: Properties] | [eventType: string, value?: number, properties?: Properties]): boolean,
1173
+ /**
1174
+ * Add an attribute to client's in memory attributes storage
1175
+ * @function setAttribute
1176
+ * @param {string} attributeName Attrinute name
1177
+ * @param {string, number, boolean, list} attributeValue Attribute value
1178
+ * @returns {boolean} true if the attribute was stored and false otherways
1179
+ */
1180
+ setAttribute(attributeName: string, attributeValue: Object): boolean,
1181
+ /**
1182
+ * Returns the attribute with the given key
1183
+ * @function getAttribute
1184
+ * @param {string} attributeName Attribute name
1185
+ * @returns {Object} Attribute with the given key
1186
+ */
1187
+ getAttribute(attributeName: string): Object,
1188
+ /**
1189
+ * Add to client's in memory attributes storage the attributes in 'attributes'
1190
+ * @function setAttributes
1191
+ * @param {Object} attributes Object with attributes to store
1192
+ * @returns true if attributes were stored an false otherways
1193
+ */
1194
+ setAttributes(attributes: Record<string, Object>): boolean,
1195
+ /**
1196
+ * Return all the attributes stored in client's in memory attributes storage
1197
+ * @function getAttributes
1198
+ * @returns {Object} returns all the stored attributes
1199
+ */
1200
+ getAttributes(): Record<string, Object>,
1201
+ /**
1202
+ * Removes from client's in memory attributes storage the attribute with the given key
1203
+ * @function removeAttribute
1204
+ * @param {string} attributeName
1205
+ * @returns {boolean} true if attribute was removed and false otherways
1206
+ */
1207
+ removeAttribute(attributeName: string): boolean,
1208
+ /**
1209
+ * Remove all the stored attributes in the client's in memory attribute storage
1210
+ */
1211
+ clearAttributes(): boolean
1212
+ }
1213
+ /**
1214
+ * Representation of a manager instance with synchronous storage of the SDK.
1215
+ * @interface IManager
1216
+ * @extends IStatusInterface
1217
+ */
1218
+ export interface IManager extends IStatusInterface {
1219
+ /**
1220
+ * Get the array of Split names.
1221
+ * @function names
1222
+ * @returns {SplitNames} The lists of Split names.
1223
+ */
1224
+ names(): SplitNames;
1225
+ /**
1226
+ * Get the array of splits data in SplitView format.
1227
+ * @function splits
1228
+ * @returns {SplitViews} The list of SplitIO.SplitView.
1229
+ */
1230
+ splits(): SplitViews;
1231
+ /**
1232
+ * Get the data of a split in SplitView format.
1233
+ * @function split
1234
+ * @param {string} splitName The name of the split we wan't to get info of.
1235
+ * @returns {SplitView} The SplitIO.SplitView of the given split.
1236
+ */
1237
+ split(splitName: string): SplitView;
1238
+ }
1239
+ /**
1240
+ * Representation of a manager instance with asynchronous storage of the SDK.
1241
+ * @interface IAsyncManager
1242
+ * @extends IStatusInterface
1243
+ */
1244
+ export interface IAsyncManager extends IStatusInterface {
1245
+ /**
1246
+ * Get the array of Split names.
1247
+ * @function names
1248
+ * @returns {SplitNamesAsync} A promise that will resolve to the array of Splitio.SplitNames.
1249
+ */
1250
+ names(): SplitNamesAsync;
1251
+ /**
1252
+ * Get the array of splits data in SplitView format.
1253
+ * @function splits
1254
+ * @returns {SplitViewsAsync} A promise that will resolve to the SplitIO.SplitView list.
1255
+ */
1256
+ splits(): SplitViewsAsync;
1257
+ /**
1258
+ * Get the data of a split in SplitView format.
1259
+ * @function split
1260
+ * @param {string} splitName The name of the split we wan't to get info of.
1261
+ * @returns {SplitViewAsync} A promise that will resolve to the SplitIO.SplitView value.
1262
+ */
1263
+ split(splitName: string): SplitViewAsync;
1264
+ }
1265
+ }