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