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

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