@splitsoftware/splitio-commons 2.0.0-rc.2 → 2.0.0-rc.4

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 (312) hide show
  1. package/CHANGES.txt +1 -3
  2. package/cjs/logger/constants.js +1 -2
  3. package/cjs/logger/messages/error.js +0 -1
  4. package/cjs/sdkFactory/index.js +1 -3
  5. package/cjs/storages/dataLoader.js +37 -99
  6. package/cjs/storages/inMemory/InMemoryStorageCS.js +4 -16
  7. package/cjs/sync/offline/LocalhostFromObject.js +3 -8
  8. package/cjs/utils/settingsValidation/index.js +1 -4
  9. package/esm/logger/constants.js +0 -1
  10. package/esm/logger/messages/error.js +0 -1
  11. package/esm/sdkFactory/index.js +2 -4
  12. package/esm/storages/dataLoader.js +35 -96
  13. package/esm/storages/inMemory/InMemoryStorageCS.js +4 -16
  14. package/esm/sync/offline/LocalhostFromObject.js +2 -6
  15. package/esm/utils/settingsValidation/index.js +1 -4
  16. package/package.json +3 -2
  17. package/src/logger/constants.ts +0 -1
  18. package/src/logger/messages/error.ts +0 -1
  19. package/src/sdkFactory/index.ts +3 -6
  20. package/src/storages/dataLoader.ts +38 -97
  21. package/src/storages/inMemory/InMemoryStorageCS.ts +4 -19
  22. package/src/storages/types.ts +2 -4
  23. package/src/sync/offline/LocalhostFromObject.ts +2 -8
  24. package/src/types.ts +14 -26
  25. package/src/utils/settingsValidation/index.ts +1 -4
  26. package/src/utils/settingsValidation/types.ts +0 -2
  27. package/types/index.d.ts +5 -5
  28. package/types/splitio.d.ts +2293 -0
  29. package/cjs/utils/settingsValidation/localhost/builtin.js +0 -18
  30. package/cjs/utils/settingsValidation/localhost/pluggable.js +0 -22
  31. package/esm/utils/settingsValidation/localhost/builtin.js +0 -14
  32. package/esm/utils/settingsValidation/localhost/pluggable.js +0 -18
  33. package/src/utils/settingsValidation/localhost/builtin.ts +0 -16
  34. package/src/utils/settingsValidation/localhost/pluggable.ts +0 -22
  35. package/types/consent/index.d.ts +0 -2
  36. package/types/consent/sdkUserConsent.d.ts +0 -13
  37. package/types/dtos/types.d.ts +0 -209
  38. package/types/evaluator/Engine.d.ts +0 -15
  39. package/types/evaluator/combiners/and.d.ts +0 -4
  40. package/types/evaluator/combiners/ifelseif.d.ts +0 -3
  41. package/types/evaluator/condition/engineUtils.d.ts +0 -11
  42. package/types/evaluator/condition/index.d.ts +0 -6
  43. package/types/evaluator/convertions/index.d.ts +0 -2
  44. package/types/evaluator/index.d.ts +0 -8
  45. package/types/evaluator/matchers/all.d.ts +0 -1
  46. package/types/evaluator/matchers/between.d.ts +0 -2
  47. package/types/evaluator/matchers/boolean.d.ts +0 -1
  48. package/types/evaluator/matchers/cont_all.d.ts +0 -1
  49. package/types/evaluator/matchers/cont_any.d.ts +0 -1
  50. package/types/evaluator/matchers/cont_str.d.ts +0 -1
  51. package/types/evaluator/matchers/dependency.d.ts +0 -5
  52. package/types/evaluator/matchers/eq.d.ts +0 -1
  53. package/types/evaluator/matchers/eq_set.d.ts +0 -1
  54. package/types/evaluator/matchers/ew.d.ts +0 -1
  55. package/types/evaluator/matchers/gte.d.ts +0 -1
  56. package/types/evaluator/matchers/index.d.ts +0 -7
  57. package/types/evaluator/matchers/large_segment.d.ts +0 -5
  58. package/types/evaluator/matchers/lte.d.ts +0 -1
  59. package/types/evaluator/matchers/matcherTypes.d.ts +0 -10
  60. package/types/evaluator/matchers/part_of.d.ts +0 -1
  61. package/types/evaluator/matchers/segment.d.ts +0 -5
  62. package/types/evaluator/matchers/sember_inlist.d.ts +0 -3
  63. package/types/evaluator/matchers/semver_between.d.ts +0 -2
  64. package/types/evaluator/matchers/semver_eq.d.ts +0 -1
  65. package/types/evaluator/matchers/semver_gte.d.ts +0 -1
  66. package/types/evaluator/matchers/semver_inlist.d.ts +0 -1
  67. package/types/evaluator/matchers/semver_lte.d.ts +0 -1
  68. package/types/evaluator/matchers/string.d.ts +0 -1
  69. package/types/evaluator/matchers/sw.d.ts +0 -1
  70. package/types/evaluator/matchers/whitelist.d.ts +0 -1
  71. package/types/evaluator/matchersTransform/index.d.ts +0 -6
  72. package/types/evaluator/matchersTransform/segment.d.ts +0 -5
  73. package/types/evaluator/matchersTransform/set.d.ts +0 -5
  74. package/types/evaluator/matchersTransform/string.d.ts +0 -7
  75. package/types/evaluator/matchersTransform/unaryNumeric.d.ts +0 -5
  76. package/types/evaluator/matchersTransform/whitelist.d.ts +0 -5
  77. package/types/evaluator/parser/index.d.ts +0 -5
  78. package/types/evaluator/treatments/index.d.ts +0 -8
  79. package/types/evaluator/types.d.ts +0 -28
  80. package/types/evaluator/value/index.d.ts +0 -7
  81. package/types/evaluator/value/sanitize.d.ts +0 -7
  82. package/types/integrations/browser.d.ts +0 -12
  83. package/types/integrations/ga/GaToSplit.d.ts +0 -40
  84. package/types/integrations/ga/GoogleAnalyticsToSplit.d.ts +0 -3
  85. package/types/integrations/ga/SplitToGa.d.ts +0 -34
  86. package/types/integrations/ga/SplitToGoogleAnalytics.d.ts +0 -3
  87. package/types/integrations/ga/types.d.ts +0 -148
  88. package/types/integrations/pluggable.d.ts +0 -11
  89. package/types/integrations/types.d.ts +0 -18
  90. package/types/listeners/browser.d.ts +0 -40
  91. package/types/listeners/node.d.ts +0 -22
  92. package/types/listeners/types.d.ts +0 -4
  93. package/types/logger/browser/DebugLogger.d.ts +0 -2
  94. package/types/logger/browser/ErrorLogger.d.ts +0 -2
  95. package/types/logger/browser/InfoLogger.d.ts +0 -2
  96. package/types/logger/browser/WarnLogger.d.ts +0 -2
  97. package/types/logger/constants.d.ts +0 -135
  98. package/types/logger/index.d.ts +0 -21
  99. package/types/logger/messages/debug.d.ts +0 -1
  100. package/types/logger/messages/error.d.ts +0 -1
  101. package/types/logger/messages/info.d.ts +0 -1
  102. package/types/logger/messages/warn.d.ts +0 -1
  103. package/types/logger/sdkLogger.d.ts +0 -8
  104. package/types/logger/types.d.ts +0 -17
  105. package/types/readiness/constants.d.ts +0 -7
  106. package/types/readiness/readinessManager.d.ts +0 -6
  107. package/types/readiness/sdkReadinessManager.d.ts +0 -10
  108. package/types/readiness/types.d.ts +0 -67
  109. package/types/sdkClient/client.d.ts +0 -6
  110. package/types/sdkClient/clientAttributesDecoration.d.ts +0 -55
  111. package/types/sdkClient/clientCS.d.ts +0 -9
  112. package/types/sdkClient/clientInputValidation.d.ts +0 -7
  113. package/types/sdkClient/identity.d.ts +0 -2
  114. package/types/sdkClient/sdkClient.d.ts +0 -6
  115. package/types/sdkClient/sdkClientMethod.d.ts +0 -6
  116. package/types/sdkClient/sdkClientMethodCS.d.ts +0 -7
  117. package/types/sdkClient/sdkClientMethodCSWithTT.d.ts +0 -8
  118. package/types/sdkFactory/index.d.ts +0 -6
  119. package/types/sdkFactory/types.d.ts +0 -85
  120. package/types/sdkManager/index.d.ts +0 -4
  121. package/types/services/decorateHeaders.d.ts +0 -2
  122. package/types/services/splitApi.d.ts +0 -12
  123. package/types/services/splitHttpClient.d.ts +0 -10
  124. package/types/services/types.d.ts +0 -54
  125. package/types/storages/AbstractMySegmentsCacheSync.d.ts +0 -39
  126. package/types/storages/AbstractSegmentsCacheSync.d.ts +0 -54
  127. package/types/storages/AbstractSplitsCache.d.ts +0 -46
  128. package/types/storages/AbstractSplitsCacheAsync.d.ts +0 -38
  129. package/types/storages/AbstractSplitsCacheSync.d.ts +0 -43
  130. package/types/storages/KeyBuilder.d.ts +0 -22
  131. package/types/storages/KeyBuilderCS.d.ts +0 -20
  132. package/types/storages/KeyBuilderSS.d.ts +0 -20
  133. package/types/storages/dataLoader.d.ts +0 -21
  134. package/types/storages/findLatencyIndex.d.ts +0 -7
  135. package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +0 -15
  136. package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +0 -54
  137. package/types/storages/inLocalStorage/constants.d.ts +0 -2
  138. package/types/storages/inLocalStorage/index.d.ts +0 -8
  139. package/types/storages/inMemory/AttributesCacheInMemory.d.ts +0 -44
  140. package/types/storages/inMemory/EventsCacheInMemory.d.ts +0 -35
  141. package/types/storages/inMemory/ImpressionCountsCacheInMemory.d.ts +0 -28
  142. package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +0 -30
  143. package/types/storages/inMemory/InMemoryStorage.d.ts +0 -10
  144. package/types/storages/inMemory/InMemoryStorageCS.d.ts +0 -10
  145. package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +0 -16
  146. package/types/storages/inMemory/SegmentsCacheInMemory.d.ts +0 -17
  147. package/types/storages/inMemory/SplitsCacheInMemory.d.ts +0 -27
  148. package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +0 -71
  149. package/types/storages/inMemory/UniqueKeysCacheInMemory.d.ts +0 -34
  150. package/types/storages/inMemory/UniqueKeysCacheInMemoryCS.d.ts +0 -35
  151. package/types/storages/inRedis/EventsCacheInRedis.d.ts +0 -32
  152. package/types/storages/inRedis/ImpressionCountsCacheInRedis.d.ts +0 -17
  153. package/types/storages/inRedis/ImpressionsCacheInRedis.d.ts +0 -17
  154. package/types/storages/inRedis/RedisAdapter.d.ts +0 -24
  155. package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +0 -21
  156. package/types/storages/inRedis/SplitsCacheInRedis.d.ts +0 -95
  157. package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +0 -35
  158. package/types/storages/inRedis/UniqueKeysCacheInRedis.d.ts +0 -22
  159. package/types/storages/inRedis/constants.d.ts +0 -4
  160. package/types/storages/inRedis/index.d.ts +0 -10
  161. package/types/storages/pluggable/EventsCachePluggable.d.ts +0 -38
  162. package/types/storages/pluggable/ImpressionCountsCachePluggable.d.ts +0 -16
  163. package/types/storages/pluggable/ImpressionsCachePluggable.d.ts +0 -34
  164. package/types/storages/pluggable/SegmentsCachePluggable.d.ts +0 -42
  165. package/types/storages/pluggable/SplitsCachePluggable.d.ts +0 -98
  166. package/types/storages/pluggable/TelemetryCachePluggable.d.ts +0 -34
  167. package/types/storages/pluggable/UniqueKeysCachePluggable.d.ts +0 -20
  168. package/types/storages/pluggable/constants.d.ts +0 -1
  169. package/types/storages/pluggable/inMemoryWrapper.d.ts +0 -12
  170. package/types/storages/pluggable/index.d.ts +0 -9
  171. package/types/storages/pluggable/wrapperAdapter.d.ts +0 -12
  172. package/types/storages/types.d.ts +0 -410
  173. package/types/storages/utils.d.ts +0 -8
  174. package/types/sync/offline/LocalhostFromObject.d.ts +0 -2
  175. package/types/sync/offline/splitsParser/parseCondition.d.ts +0 -7
  176. package/types/sync/offline/splitsParser/splitsParserFromSettings.d.ts +0 -3
  177. package/types/sync/offline/splitsParser/types.d.ts +0 -3
  178. package/types/sync/offline/syncManagerOffline.d.ts +0 -10
  179. package/types/sync/offline/syncTasks/fromObjectSyncTask.d.ts +0 -17
  180. package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +0 -7
  181. package/types/sync/polling/fetchers/segmentChangesFetcher.d.ts +0 -7
  182. package/types/sync/polling/fetchers/splitChangesFetcher.d.ts +0 -7
  183. package/types/sync/polling/fetchers/types.d.ts +0 -5
  184. package/types/sync/polling/pollingManagerCS.d.ts +0 -7
  185. package/types/sync/polling/pollingManagerSS.d.ts +0 -6
  186. package/types/sync/polling/syncTasks/mySegmentsSyncTask.d.ts +0 -9
  187. package/types/sync/polling/syncTasks/segmentsSyncTask.d.ts +0 -9
  188. package/types/sync/polling/syncTasks/splitsSyncTask.d.ts +0 -9
  189. package/types/sync/polling/types.d.ts +0 -33
  190. package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +0 -14
  191. package/types/sync/polling/updaters/segmentChangesUpdater.d.ts +0 -18
  192. package/types/sync/polling/updaters/splitChangesUpdater.d.ts +0 -41
  193. package/types/sync/streaming/AuthClient/index.d.ts +0 -12
  194. package/types/sync/streaming/AuthClient/types.d.ts +0 -17
  195. package/types/sync/streaming/SSEClient/index.d.ts +0 -34
  196. package/types/sync/streaming/SSEClient/types.d.ts +0 -11
  197. package/types/sync/streaming/SSEHandler/NotificationKeeper.d.ts +0 -14
  198. package/types/sync/streaming/SSEHandler/NotificationParser.d.ts +0 -20
  199. package/types/sync/streaming/SSEHandler/index.d.ts +0 -11
  200. package/types/sync/streaming/SSEHandler/types.d.ts +0 -72
  201. package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +0 -9
  202. package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +0 -9
  203. package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +0 -14
  204. package/types/sync/streaming/UpdateWorkers/constants.d.ts +0 -3
  205. package/types/sync/streaming/UpdateWorkers/types.d.ts +0 -4
  206. package/types/sync/streaming/constants.d.ts +0 -34
  207. package/types/sync/streaming/mySegmentsV2utils.d.ts +0 -27
  208. package/types/sync/streaming/parseUtils.d.ts +0 -34
  209. package/types/sync/streaming/pushManager.d.ts +0 -9
  210. package/types/sync/streaming/pushManagerCS_Spec1_3.d.ts +0 -9
  211. package/types/sync/streaming/pushManager_Spec1_3.d.ts +0 -9
  212. package/types/sync/streaming/types.d.ts +0 -35
  213. package/types/sync/submitters/eventsSubmitter.d.ts +0 -5
  214. package/types/sync/submitters/impressionCountsSubmitter.d.ts +0 -10
  215. package/types/sync/submitters/impressionsSubmitter.d.ts +0 -11
  216. package/types/sync/submitters/submitter.d.ts +0 -12
  217. package/types/sync/submitters/submitterManager.d.ts +0 -3
  218. package/types/sync/submitters/telemetrySubmitter.d.ts +0 -17
  219. package/types/sync/submitters/types.d.ts +0 -217
  220. package/types/sync/submitters/uniqueKeysSubmitter.d.ts +0 -5
  221. package/types/sync/syncManagerOnline.d.ts +0 -13
  222. package/types/sync/syncTask.d.ts +0 -13
  223. package/types/sync/types.d.ts +0 -43
  224. package/types/trackers/eventTracker.d.ts +0 -10
  225. package/types/trackers/impressionObserver/ImpressionObserver.d.ts +0 -8
  226. package/types/trackers/impressionObserver/buildKey.d.ts +0 -2
  227. package/types/trackers/impressionObserver/impressionObserverCS.d.ts +0 -4
  228. package/types/trackers/impressionObserver/impressionObserverSS.d.ts +0 -4
  229. package/types/trackers/impressionObserver/types.d.ts +0 -4
  230. package/types/trackers/impressionObserver/utils.d.ts +0 -5
  231. package/types/trackers/impressionsTracker.d.ts +0 -13
  232. package/types/trackers/strategy/strategyDebug.d.ts +0 -9
  233. package/types/trackers/strategy/strategyNone.d.ts +0 -10
  234. package/types/trackers/strategy/strategyOptimized.d.ts +0 -11
  235. package/types/trackers/telemetryTracker.d.ts +0 -3
  236. package/types/trackers/types.d.ts +0 -68
  237. package/types/trackers/uniqueKeysTracker.d.ts +0 -13
  238. package/types/types.d.ts +0 -1408
  239. package/types/utils/Backoff.d.ts +0 -25
  240. package/types/utils/LRUCache/LinkedList.d.ts +0 -34
  241. package/types/utils/LRUCache/index.d.ts +0 -15
  242. package/types/utils/MinEventEmitter.d.ts +0 -12
  243. package/types/utils/MinEvents.d.ts +0 -4
  244. package/types/utils/base64/index.d.ts +0 -30
  245. package/types/utils/constants/browser.d.ts +0 -1
  246. package/types/utils/constants/index.d.ts +0 -83
  247. package/types/utils/decompress/index.d.ts +0 -16
  248. package/types/utils/env/isLocalStorageAvailable.d.ts +0 -1
  249. package/types/utils/env/isNode.d.ts +0 -5
  250. package/types/utils/inputValidation/apiKey.d.ts +0 -7
  251. package/types/utils/inputValidation/attribute.d.ts +0 -2
  252. package/types/utils/inputValidation/attributes.d.ts +0 -4
  253. package/types/utils/inputValidation/event.d.ts +0 -2
  254. package/types/utils/inputValidation/eventProperties.d.ts +0 -6
  255. package/types/utils/inputValidation/eventValue.d.ts +0 -2
  256. package/types/utils/inputValidation/index.d.ts +0 -13
  257. package/types/utils/inputValidation/isOperational.d.ts +0 -4
  258. package/types/utils/inputValidation/key.d.ts +0 -3
  259. package/types/utils/inputValidation/preloadedData.d.ts +0 -3
  260. package/types/utils/inputValidation/sdkKey.d.ts +0 -7
  261. package/types/utils/inputValidation/split.d.ts +0 -2
  262. package/types/utils/inputValidation/splitExistance.d.ts +0 -7
  263. package/types/utils/inputValidation/splitExistence.d.ts +0 -7
  264. package/types/utils/inputValidation/splits.d.ts +0 -2
  265. package/types/utils/inputValidation/trafficType.d.ts +0 -2
  266. package/types/utils/inputValidation/trafficTypeExistance.d.ts +0 -9
  267. package/types/utils/inputValidation/trafficTypeExistence.d.ts +0 -9
  268. package/types/utils/jwt/index.d.ts +0 -5
  269. package/types/utils/jwt/types.d.ts +0 -5
  270. package/types/utils/key/index.d.ts +0 -8
  271. package/types/utils/labels/index.d.ts +0 -8
  272. package/types/utils/lang/binarySearch.d.ts +0 -9
  273. package/types/utils/lang/getFnName.d.ts +0 -4
  274. package/types/utils/lang/getGlobal.d.ts +0 -4
  275. package/types/utils/lang/index.d.ts +0 -105
  276. package/types/utils/lang/maps.d.ts +0 -59
  277. package/types/utils/lang/objectAssign.d.ts +0 -6
  278. package/types/utils/lang/sets.d.ts +0 -3
  279. package/types/utils/murmur3/common.d.ts +0 -12
  280. package/types/utils/murmur3/legacy.d.ts +0 -2
  281. package/types/utils/murmur3/murmur3.d.ts +0 -2
  282. package/types/utils/murmur3/murmur3_128.d.ts +0 -6
  283. package/types/utils/murmur3/murmur3_128_x86.d.ts +0 -7
  284. package/types/utils/murmur3/murmur3_64.d.ts +0 -10
  285. package/types/utils/murmur3/utfx.d.ts +0 -27
  286. package/types/utils/promise/thenable.d.ts +0 -1
  287. package/types/utils/promise/timeout.d.ts +0 -1
  288. package/types/utils/promise/wrapper.d.ts +0 -21
  289. package/types/utils/redis/RedisMock.d.ts +0 -4
  290. package/types/utils/semVer.d.ts +0 -15
  291. package/types/utils/settingsValidation/consent.d.ts +0 -6
  292. package/types/utils/settingsValidation/impressionsMode.d.ts +0 -3
  293. package/types/utils/settingsValidation/index.d.ts +0 -51
  294. package/types/utils/settingsValidation/integrations/common.d.ts +0 -14
  295. package/types/utils/settingsValidation/integrations/configurable.d.ts +0 -13
  296. package/types/utils/settingsValidation/integrations/pluggable.d.ts +0 -13
  297. package/types/utils/settingsValidation/localhost/builtin.d.ts +0 -16
  298. package/types/utils/settingsValidation/localhost/pluggable.d.ts +0 -16
  299. package/types/utils/settingsValidation/logger/builtinLogger.d.ts +0 -10
  300. package/types/utils/settingsValidation/logger/commons.d.ts +0 -9
  301. package/types/utils/settingsValidation/logger/globalLogLevel.d.ts +0 -8
  302. package/types/utils/settingsValidation/logger/pluggableLogger.d.ts +0 -11
  303. package/types/utils/settingsValidation/mode.d.ts +0 -5
  304. package/types/utils/settingsValidation/runtime.d.ts +0 -2
  305. package/types/utils/settingsValidation/splitFilters.d.ts +0 -17
  306. package/types/utils/settingsValidation/storage/storageCS.d.ts +0 -21
  307. package/types/utils/settingsValidation/types.d.ts +0 -32
  308. package/types/utils/settingsValidation/url.d.ts +0 -10
  309. package/types/utils/time/index.d.ts +0 -4
  310. package/types/utils/timeTracker/now/browser.d.ts +0 -1
  311. package/types/utils/timeTracker/now/node.d.ts +0 -1
  312. package/types/utils/timeTracker/timer.d.ts +0 -1
@@ -0,0 +1,2293 @@
1
+ // Type definitions for Split Software SDKs
2
+ // Project: http://www.split.io/
3
+
4
+ import { RedisOptions } from 'ioredis';
5
+ import { RequestOptions } from 'http';
6
+
7
+ export as namespace SplitIO;
8
+ export = SplitIO;
9
+
10
+ /**
11
+ * EventEmitter interface based on a subset of the NodeJS.EventEmitter methods.
12
+ */
13
+ interface IEventEmitter {
14
+ addListener(event: string, listener: (...args: any[]) => void): this;
15
+ on(event: string, listener: (...args: any[]) => void): this;
16
+ once(event: string, listener: (...args: any[]) => void): this;
17
+ removeListener(event: string, listener: (...args: any[]) => void): this;
18
+ off(event: string, listener: (...args: any[]) => void): this;
19
+ removeAllListeners(event?: string): this;
20
+ emit(event: string, ...args: any[]): boolean;
21
+ }
22
+ /**
23
+ * NodeJS.EventEmitter interface
24
+ * @see {@link https://nodejs.org/api/events.html}
25
+ */
26
+ interface EventEmitter extends IEventEmitter {
27
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
28
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
29
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
30
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
31
+ off(event: string | symbol, listener: (...args: any[]) => void): this;
32
+ removeAllListeners(event?: string | symbol): this;
33
+ emit(event: string | symbol, ...args: any[]): boolean;
34
+ setMaxListeners(n: number): this;
35
+ getMaxListeners(): number;
36
+ listeners(event: string | symbol): Function[];
37
+ rawListeners(event: string | symbol): Function[];
38
+ listenerCount(type: string | symbol): number;
39
+ // Added in Node 6...
40
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
41
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
42
+ eventNames(): Array<string | symbol>;
43
+ }
44
+ /**
45
+ * @typedef {Object} EventConsts
46
+ * @property {string} SDK_READY The ready event.
47
+ * @property {string} SDK_READY_FROM_CACHE The ready event when fired with cached data.
48
+ * @property {string} SDK_READY_TIMED_OUT The timeout event.
49
+ * @property {string} SDK_UPDATE The update event.
50
+ */
51
+ type EventConsts = {
52
+ SDK_READY: 'init::ready';
53
+ SDK_READY_FROM_CACHE: 'init::cache-ready';
54
+ SDK_READY_TIMED_OUT: 'init::timeout';
55
+ SDK_UPDATE: 'state::update';
56
+ };
57
+ /**
58
+ * SDK Modes.
59
+ * @typedef {string} SDKMode
60
+ */
61
+ type SDKMode = 'standalone' | 'localhost' | 'consumer' | 'consumer_partial';
62
+ /**
63
+ * Storage types.
64
+ * @typedef {string} StorageType
65
+ */
66
+ type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS' | 'PLUGGABLE';
67
+ /**
68
+ * Settings interface. This is a representation of the settings the SDK expose, that's why
69
+ * most of it's props are readonly. Only features should be rewritten when localhost mode is active.
70
+ * @interface ISettings
71
+ */
72
+ interface ISettings {
73
+ readonly core: {
74
+ authorizationKey: string;
75
+ key: SplitIO.SplitKey;
76
+ labelsEnabled: boolean;
77
+ IPAddressesEnabled: boolean;
78
+ };
79
+ readonly mode: SDKMode;
80
+ readonly scheduler: {
81
+ featuresRefreshRate: number;
82
+ impressionsRefreshRate: number;
83
+ impressionsQueueSize: number;
84
+ /**
85
+ * @deprecated
86
+ */
87
+ metricsRefreshRate?: number;
88
+ telemetryRefreshRate: number;
89
+ segmentsRefreshRate: number;
90
+ offlineRefreshRate: number;
91
+ eventsPushRate: number;
92
+ eventsQueueSize: number;
93
+ pushRetryBackoffBase: number;
94
+ };
95
+ readonly startup: {
96
+ readyTimeout: number;
97
+ requestTimeoutBeforeReady: number;
98
+ retriesOnFailureBeforeReady: number;
99
+ eventsFirstPushWindow: number;
100
+ };
101
+ readonly storage: SplitIO.StorageSyncFactory | SplitIO.StorageAsyncFactory | SplitIO.StorageOptions;
102
+ readonly urls: {
103
+ events: string;
104
+ sdk: string;
105
+ auth: string;
106
+ streaming: string;
107
+ telemetry: string;
108
+ };
109
+ readonly integrations?: SplitIO.IntegrationFactory[];
110
+ readonly debug: boolean | LogLevel | SplitIO.ILogger;
111
+ readonly version: string;
112
+ /**
113
+ * Mocked features map if using in client-side, or mocked features file path string if using in server-side (NodeJS).
114
+ */
115
+ features: SplitIO.MockedFeaturesMap | SplitIO.MockedFeaturesFilePath;
116
+ readonly streamingEnabled: boolean;
117
+ readonly sync: {
118
+ splitFilters: SplitIO.SplitFilter[];
119
+ impressionsMode: SplitIO.ImpressionsMode;
120
+ enabled: boolean;
121
+ flagSpecVersion: string;
122
+ requestOptions?: {
123
+ getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>;
124
+ };
125
+ };
126
+ /**
127
+ * User consent status if using in client-side. Undefined if using in server-side (NodeJS).
128
+ */
129
+ readonly userConsent?: SplitIO.ConsentStatus
130
+ }
131
+ /**
132
+ * Log levels.
133
+ * @typedef {string} LogLevel
134
+ */
135
+ type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'NONE';
136
+ /**
137
+ * Logger API
138
+ * @interface ILoggerAPI
139
+ */
140
+ interface ILoggerAPI {
141
+ /**
142
+ * Enables SDK logging to the console.
143
+ * @function enable
144
+ * @returns {void}
145
+ */
146
+ enable(): void;
147
+ /**
148
+ * Disables SDK logging.
149
+ * @function disable
150
+ * @returns {void}
151
+ */
152
+ disable(): void;
153
+ /**
154
+ * Sets a log level for the SDK logs.
155
+ * @function setLogLevel
156
+ * @returns {void}
157
+ */
158
+ setLogLevel(logLevel: LogLevel): void;
159
+ /**
160
+ * Log level constants. Use this to pass them to setLogLevel function.
161
+ */
162
+ LogLevel: {
163
+ [level in LogLevel]: LogLevel;
164
+ };
165
+ }
166
+ /**
167
+ * User consent API
168
+ * @interface IUserConsentAPI
169
+ */
170
+ interface IUserConsentAPI {
171
+ /**
172
+ * Sets or updates the user consent status. Possible values are `true` and `false`, which represent user consent `'GRANTED'` and `'DECLINED'` respectively.
173
+ * - `true ('GRANTED')`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud.
174
+ * - `false ('DECLINED')`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud.
175
+ *
176
+ * NOTE: calling this method updates the user consent at a factory level, affecting all clients of the same factory.
177
+ *
178
+ * @function setStatus
179
+ * @param {boolean} userConsent The user consent status, true for 'GRANTED' and false for 'DECLINED'.
180
+ * @returns {boolean} Whether the provided param is a valid value (i.e., a boolean value) or not.
181
+ */
182
+ setStatus(userConsent: boolean): boolean;
183
+ /**
184
+ * Gets the user consent status.
185
+ *
186
+ * @function getStatus
187
+ * @returns {ConsentStatus} The user consent status.
188
+ */
189
+ getStatus(): SplitIO.ConsentStatus;
190
+ /**
191
+ * Consent status constants. Use this to compare with the getStatus function result.
192
+ */
193
+ Status: {
194
+ [status in SplitIO.ConsentStatus]: SplitIO.ConsentStatus;
195
+ };
196
+ }
197
+ /**
198
+ * Common API for entities that expose status handlers.
199
+ * @interface IStatusInterface
200
+ * @extends EventEmitter
201
+ */
202
+ interface IStatusInterface extends EventEmitter {
203
+ /**
204
+ * Constant object containing the SDK events for you to use.
205
+ * @property {EventConsts} Event
206
+ */
207
+ Event: EventConsts;
208
+ /**
209
+ * Returns a promise that resolves once the SDK has finished loading (`SDK_READY` event emitted) or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
210
+ * As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, the `ready` method will return a resolved promise once the SDK is ready.
211
+ *
212
+ * 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.
213
+ * However, when using async/await syntax, the rejection should be explicitly propagated like in the following example:
214
+ * ```
215
+ * try {
216
+ * await client.ready().catch((e) => { throw e; });
217
+ * // SDK is ready
218
+ * } catch(e) {
219
+ * // SDK has timedout
220
+ * }
221
+ * ```
222
+ *
223
+ * @function ready
224
+ * @returns {Promise<void>}
225
+ */
226
+ ready(): Promise<void>;
227
+ }
228
+ /**
229
+ * Common definitions between clients for different environments interface.
230
+ * @interface IBasicClient
231
+ * @extends IStatusInterface
232
+ */
233
+ interface IBasicClient extends IStatusInterface {
234
+ /**
235
+ * Destroys the client instance.
236
+ *
237
+ * In 'standalone' and 'partial consumer' modes, this method will flush any pending impressions and events.
238
+ * In 'standalone' mode, it also stops the synchronization of feature flag definitions with the backend.
239
+ * In 'consumer' and 'partial consumer' modes, this method also disconnects the SDK from the Pluggable storage.
240
+ *
241
+ * @function destroy
242
+ * @returns {Promise<void>} A promise that resolves once the client is destroyed.
243
+ */
244
+ destroy(): Promise<void>;
245
+ }
246
+ /**
247
+ * Common definitions between SDK instances for different environments interface.
248
+ * @interface IBasicSDK
249
+ */
250
+ interface IBasicSDK {
251
+ /**
252
+ * Current settings of the SDK instance.
253
+ * @property settings
254
+ */
255
+ settings: ISettings;
256
+ /**
257
+ * Logger API.
258
+ * @property Logger
259
+ */
260
+ Logger: ILoggerAPI;
261
+ /**
262
+ * Destroys all the clients created by this factory.
263
+ * @function destroy
264
+ * @returns {Promise<void>}
265
+ */
266
+ destroy(): Promise<void>;
267
+ }
268
+ /****** Exposed namespace ******/
269
+ /**
270
+ * Shared types and interfaces for `@splitsoftware` packages for usage when integrating JavaScript SDKs with TypeScript.
271
+ */
272
+ declare namespace SplitIO {
273
+ /**
274
+ * Feature flag treatment value, returned by getTreatment.
275
+ * @typedef {string} Treatment
276
+ */
277
+ type Treatment = string;
278
+ /**
279
+ * Feature flag treatment promise that resolves to actual treatment value.
280
+ * @typedef {Promise<string>} AsyncTreatment
281
+ */
282
+ type AsyncTreatment = Promise<string>;
283
+ /**
284
+ * An object with the treatments for a bulk of feature flags, returned by getTreatments. For example:
285
+ * {
286
+ * feature1: 'on',
287
+ * feature2: 'off
288
+ * }
289
+ * @typedef {Object.<Treatment>} Treatments
290
+ */
291
+ type Treatments = {
292
+ [featureName: string]: Treatment;
293
+ };
294
+ /**
295
+ * Feature flag treatments promise that resolves to the actual SplitIO.Treatments object.
296
+ * @typedef {Promise<Treatments>} AsyncTreatments
297
+ */
298
+ type AsyncTreatments = Promise<Treatments>;
299
+ /**
300
+ * Feature flag evaluation result with treatment and configuration, returned by getTreatmentWithConfig.
301
+ * @typedef {Object} TreatmentWithConfig
302
+ * @property {string} treatment The treatment string
303
+ * @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.
304
+ */
305
+ type TreatmentWithConfig = {
306
+ treatment: string;
307
+ config: string | null;
308
+ };
309
+ /**
310
+ * Feature flag treatment promise that resolves to actual treatment with config value.
311
+ * @typedef {Promise<TreatmentWithConfig>} AsyncTreatmentWithConfig
312
+ */
313
+ type AsyncTreatmentWithConfig = Promise<TreatmentWithConfig>;
314
+ /**
315
+ * An object with the treatments with configs for a bulk of feature flags, returned by getTreatmentsWithConfig.
316
+ * Each existing configuration is a stringified version of the JSON you defined on the Split user interface. For example:
317
+ * {
318
+ * feature1: { treatment: 'on', config: null }
319
+ * feature2: { treatment: 'off', config: '{"bannerText":"Click here."}' }
320
+ * }
321
+ * @typedef {Object.<TreatmentWithConfig>} Treatments
322
+ */
323
+ type TreatmentsWithConfig = {
324
+ [featureName: string]: TreatmentWithConfig;
325
+ };
326
+ /**
327
+ * Feature flag treatments promise that resolves to the actual SplitIO.TreatmentsWithConfig object.
328
+ * @typedef {Promise<TreatmentsWithConfig>} AsyncTreatmentsWithConfig
329
+ */
330
+ type AsyncTreatmentsWithConfig = Promise<TreatmentsWithConfig>;
331
+ /**
332
+ * Possible Split SDK events.
333
+ * @typedef {string} Event
334
+ */
335
+ type Event = 'init::timeout' | 'init::ready' | 'init::cache-ready' | 'state::update';
336
+ /**
337
+ * Attributes should be on object with values of type string, boolean, number (dates should be sent as millis since epoch) or array of strings or numbers.
338
+ * @typedef {Object.<AttributeType>} Attributes
339
+ * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#attribute-syntax}
340
+ */
341
+ type Attributes = {
342
+ [attributeName: string]: AttributeType;
343
+ };
344
+ /**
345
+ * Type of an attribute value
346
+ * @typedef {string | number | boolean | Array<string | number>} AttributeType
347
+ */
348
+ type AttributeType = string | number | boolean | Array<string | number>;
349
+ /**
350
+ * Properties should be an object with values of type string, number, boolean or null. Size limit of ~31kb.
351
+ * @typedef {Object.<number, string, boolean, null>} Properties
352
+ * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#track
353
+ */
354
+ type Properties = {
355
+ [propertyName: string]: string | number | boolean | null;
356
+ };
357
+ /**
358
+ * The SplitKey object format.
359
+ * @typedef {Object.<string>} SplitKeyObject
360
+ */
361
+ type SplitKeyObject = {
362
+ matchingKey: string;
363
+ bucketingKey: string;
364
+ };
365
+ /**
366
+ * The customer identifier. Could be a SplitKeyObject or a string.
367
+ * @typedef {SplitKeyObject|string} SplitKey
368
+ */
369
+ type SplitKey = SplitKeyObject | string;
370
+ /**
371
+ * Path to file with mocked features (for node).
372
+ * @typedef {string} MockedFeaturesFilePath
373
+ */
374
+ type MockedFeaturesFilePath = string;
375
+ /**
376
+ * Object with mocked features mapping for client-side (e.g., Browser or React Native). We need to specify the featureName as key, and the mocked treatment as value.
377
+ * @typedef {Object} MockedFeaturesMap
378
+ */
379
+ type MockedFeaturesMap = {
380
+ [featureName: string]: string | TreatmentWithConfig;
381
+ };
382
+ /**
383
+ * Object with information about an impression. It contains the generated impression DTO as well as
384
+ * complementary information around where and how it was generated in that way.
385
+ * @typedef {Object} ImpressionData
386
+ */
387
+ type ImpressionData = {
388
+ impression: {
389
+ feature: string;
390
+ keyName: string;
391
+ treatment: string;
392
+ time: number;
393
+ bucketingKey?: string;
394
+ label: string;
395
+ changeNumber: number;
396
+ pt?: number;
397
+ };
398
+ attributes?: SplitIO.Attributes;
399
+ ip: string;
400
+ hostname: string;
401
+ sdkLanguageVersion: string;
402
+ };
403
+ /**
404
+ * Data corresponding to one feature flag view.
405
+ * @typedef {Object} SplitView
406
+ */
407
+ type SplitView = {
408
+ /**
409
+ * The name of the feature flag.
410
+ * @property {string} name
411
+ */
412
+ name: string;
413
+ /**
414
+ * The traffic type of the feature flag.
415
+ * @property {string} trafficType
416
+ */
417
+ trafficType: string;
418
+ /**
419
+ * Whether the feature flag is killed or not.
420
+ * @property {boolean} killed
421
+ */
422
+ killed: boolean;
423
+ /**
424
+ * The list of treatments available for the feature flag.
425
+ * @property {Array<string>} treatments
426
+ */
427
+ treatments: Array<string>;
428
+ /**
429
+ * Current change number of the feature flag.
430
+ * @property {number} changeNumber
431
+ */
432
+ changeNumber: number;
433
+ /**
434
+ * Map of configurations per treatment.
435
+ * Each existing configuration is a stringified version of the JSON you defined on the Split user interface.
436
+ * @property {Object.<string>} configs
437
+ */
438
+ configs: {
439
+ [treatmentName: string]: string;
440
+ };
441
+ /**
442
+ * List of sets of the feature flag.
443
+ * @property {string[]} sets
444
+ */
445
+ sets: string[];
446
+ /**
447
+ * The default treatment of the feature flag.
448
+ * @property {string} defaultTreatment
449
+ */
450
+ defaultTreatment: string;
451
+ };
452
+ /**
453
+ * A promise that resolves to a feature flag view.
454
+ * @typedef {Promise<SplitView>} SplitView
455
+ */
456
+ type SplitViewAsync = Promise<SplitView>;
457
+ /**
458
+ * An array containing the SplitIO.SplitView elements.
459
+ */
460
+ type SplitViews = Array<SplitView>;
461
+ /**
462
+ * A promise that resolves to an SplitIO.SplitViews array.
463
+ * @typedef {Promise<SplitViews>} SplitViewsAsync
464
+ */
465
+ type SplitViewsAsync = Promise<SplitViews>;
466
+ /**
467
+ * An array of feature flag names.
468
+ * @typedef {Array<string>} SplitNames
469
+ */
470
+ type SplitNames = Array<string>;
471
+ /**
472
+ * A promise that resolves to an array of feature flag names.
473
+ * @typedef {Promise<SplitNames>} SplitNamesAsync
474
+ */
475
+ type SplitNamesAsync = Promise<SplitNames>;
476
+ /**
477
+ * Storage for synchronous (standalone) SDK.
478
+ * Its interface details are not part of the public API.
479
+ */
480
+ type StorageSync = {};
481
+ /**
482
+ * Storage builder for synchronous (standalone) SDK.
483
+ * By returning undefined, the SDK will use the default IN MEMORY storage.
484
+ * Input parameter details are not part of the public API.
485
+ */
486
+ type StorageSyncFactory = {
487
+ readonly type: StorageType;
488
+ (params: {}): (StorageSync | undefined);
489
+ }
490
+ /**
491
+ * Configuration params for `InLocalStorage`
492
+ */
493
+ type InLocalStorageOptions = {
494
+ /**
495
+ * Optional prefix to prevent any kind of data collision when having multiple factories using the same storage type.
496
+ * @property {string} prefix
497
+ * @default 'SPLITIO'
498
+ */
499
+ prefix?: string;
500
+ }
501
+ /**
502
+ * Storage for asynchronous (consumer) SDK.
503
+ * Its interface details are not part of the public API.
504
+ */
505
+ type StorageAsync = {}
506
+ /**
507
+ * Storage builder for asynchronous (consumer) SDK.
508
+ * Input parameter details are not part of the public API.
509
+ */
510
+ type StorageAsyncFactory = {
511
+ readonly type: 'PLUGGABLE';
512
+ (params: {}): StorageAsync;
513
+ }
514
+ /**
515
+ * Configuration params for `PluggableStorage`
516
+ */
517
+ type PluggableStorageOptions = {
518
+ /**
519
+ * Optional prefix to prevent any kind of data collision when having multiple factories using the same storage wrapper.
520
+ * @property {string} prefix
521
+ * @default 'SPLITIO'
522
+ */
523
+ prefix?: string;
524
+ /**
525
+ * Storage wrapper.
526
+ * @property {Object} wrapper
527
+ */
528
+ wrapper: Object;
529
+ }
530
+ /**
531
+ * Synchronous storage valid types for NodeJS.
532
+ * @typedef {string} NodeSyncStorage
533
+ */
534
+ type NodeSyncStorage = 'MEMORY';
535
+ /**
536
+ * Asynchronous storages valid types for NodeJS.
537
+ * @typedef {string} NodeAsyncStorage
538
+ */
539
+ type NodeAsyncStorage = 'REDIS';
540
+ /**
541
+ * Storage valid types for the browser.
542
+ * @typedef {string} BrowserStorage
543
+ */
544
+ type BrowserStorage = 'MEMORY' | 'LOCALSTORAGE';
545
+ /**
546
+ * Storage options for the SDK with no pluggable storage.
547
+ */
548
+ type StorageOptions = {
549
+ type: NodeSyncStorage | NodeAsyncStorage | BrowserStorage;
550
+ prefix?: string;
551
+ options?: Object;
552
+ }
553
+ /**
554
+ * Impression listener interface. This is the interface that needs to be implemented
555
+ * by the element you provide to the SDK as impression listener.
556
+ * @interface IImpressionListener
557
+ * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#listener}
558
+ */
559
+ interface IImpressionListener {
560
+ logImpression(data: SplitIO.ImpressionData): void;
561
+ }
562
+ /**
563
+ * SDK integration instance.
564
+ * Its interface details are not part of the public API.
565
+ */
566
+ type Integration = {};
567
+ /**
568
+ * SDK integration factory.
569
+ * By returning an integration, the SDK will queue events and impressions into it.
570
+ * Input parameter details are not part of the public API.
571
+ */
572
+ type IntegrationFactory = {
573
+ readonly type: string;
574
+ (params: {}): (Integration | void);
575
+ }
576
+ /**
577
+ * A pair of user key and it's trafficType, required for tracking valid Split events.
578
+ * @typedef {Object} Identity
579
+ * @property {string} key The user key.
580
+ * @property {string} trafficType The key traffic type.
581
+ */
582
+ type Identity = {
583
+ key: string;
584
+ trafficType: string;
585
+ };
586
+ /**
587
+ * Object with information about a Split event.
588
+ * @typedef {Object} EventData
589
+ */
590
+ type EventData = {
591
+ eventTypeId: string;
592
+ value?: number;
593
+ properties?: Properties;
594
+ trafficTypeName?: string;
595
+ key?: string;
596
+ timestamp?: number;
597
+ };
598
+ /**
599
+ * Object representing the data sent by Split (events and impressions).
600
+ * @typedef {Object} IntegrationData
601
+ * @property {string} type The type of Split data, either 'IMPRESSION' or 'EVENT'.
602
+ * @property {ImpressionData | EventData} payload The data instance itself.
603
+ */
604
+ type IntegrationData = { type: 'IMPRESSION', payload: SplitIO.ImpressionData } | { type: 'EVENT', payload: SplitIO.EventData };
605
+ /**
606
+ * Available URL settings for the SDKs.
607
+ */
608
+ type UrlSettings = {
609
+ /**
610
+ * String property to override the base URL where the SDK will get rollout plan related data, like feature flags and segments definitions.
611
+ * @property {string} sdk
612
+ * @default 'https://sdk.split.io/api'
613
+ */
614
+ sdk?: string;
615
+ /**
616
+ * String property to override the base URL where the SDK will post event-related information like impressions.
617
+ * @property {string} events
618
+ * @default 'https://events.split.io/api'
619
+ */
620
+ events?: string;
621
+ /**
622
+ * String property to override the base URL where the SDK will get authorization tokens to be used with functionality that requires it, like streaming.
623
+ * @property {string} auth
624
+ * @default 'https://auth.split.io/api'
625
+ */
626
+ auth?: string;
627
+ /**
628
+ * String property to override the base URL where the SDK will connect to receive streaming updates.
629
+ * @property {string} streaming
630
+ * @default 'https://streaming.split.io'
631
+ */
632
+ streaming?: string;
633
+ /**
634
+ * String property to override the base URL where the SDK will post telemetry data.
635
+ * @property {string} telemetry
636
+ * @default 'https://telemetry.split.io/api'
637
+ */
638
+ telemetry?: string;
639
+ };
640
+
641
+ /**
642
+ * SplitFilter type.
643
+ *
644
+ * @typedef {string} SplitFilterType
645
+ */
646
+ type SplitFilterType = 'bySet' | 'byName' | 'byPrefix';
647
+ /**
648
+ * Defines a feature flag filter, described by a type and list of values.
649
+ */
650
+ interface SplitFilter {
651
+ /**
652
+ * Type of the filter.
653
+ *
654
+ * @property {SplitFilterType} type
655
+ */
656
+ type: SplitFilterType;
657
+ /**
658
+ * List of values: feature flag names for 'byName' filter type, and feature flag name prefixes for 'byPrefix' type.
659
+ *
660
+ * @property {string[]} values
661
+ */
662
+ values: string[];
663
+ }
664
+ /**
665
+ * ImpressionsMode type
666
+ * @typedef {string} ImpressionsMode
667
+ */
668
+ type ImpressionsMode = 'OPTIMIZED' | 'DEBUG' | 'NONE';
669
+ /**
670
+ * User consent status.
671
+ * @typedef {string} ConsentStatus
672
+ */
673
+ type ConsentStatus = 'GRANTED' | 'DECLINED' | 'UNKNOWN';
674
+ /**
675
+ * Logger
676
+ * Its interface details are not part of the public API. It shouldn't be used directly.
677
+ * @interface ILogger
678
+ */
679
+ interface ILogger {
680
+ setLogLevel(logLevel: LogLevel): void;
681
+ }
682
+ /**
683
+ * Common settings interface for SDK instances created for client-side.
684
+ *
685
+ * @interface IClientSideBasicSettings
686
+ */
687
+ interface IClientSideBasicSettings {
688
+ /**
689
+ * SDK Core settings for client-side.
690
+ * @property {Object} core
691
+ */
692
+ core: {
693
+ /**
694
+ * Your SDK key.
695
+ * @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
696
+ * @property {string} authorizationKey
697
+ */
698
+ authorizationKey: string;
699
+ /**
700
+ * Customer identifier. Whatever this means to you.
701
+ * @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
702
+ * @property {SplitKey} key
703
+ */
704
+ key: SplitKey;
705
+ /**
706
+ * Disable labels from being sent to Split backend. Labels may contain sensitive information.
707
+ * @property {boolean} labelsEnabled
708
+ * @default true
709
+ */
710
+ labelsEnabled?: boolean;
711
+ };
712
+ /**
713
+ * Boolean value to indicate whether the logger should be enabled or disabled by default, or a log level string or a Logger object.
714
+ * Passing a logger object is required to get descriptive log messages. Otherwise most logs will print with message codes.
715
+ * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging}.
716
+ *
717
+ * Examples:
718
+ * ```
719
+ * config.debug = true
720
+ * config.debug = 'WARN'
721
+ * config.debug = ErrorLogger()
722
+ * ```
723
+ * @property {boolean | LogLevel | ILogger} debug
724
+ * @default false
725
+ */
726
+ debug?: boolean | LogLevel | SplitIO.ILogger;
727
+ /**
728
+ * The impression listener, which is optional. Whatever you provide here needs to comply with the SplitIO.IImpressionListener interface,
729
+ * which will check for the logImpression method.
730
+ * @property {IImpressionListener} impressionListener
731
+ * @default undefined
732
+ */
733
+ impressionListener?: SplitIO.IImpressionListener;
734
+ /**
735
+ * Boolean flag to enable the streaming service as default synchronization mechanism. In the event of any issue with streaming,
736
+ * the SDK would fallback to the polling mechanism. If false, the SDK would poll for changes as usual without attempting to use streaming.
737
+ * @property {boolean} streamingEnabled
738
+ * @default true
739
+ */
740
+ streamingEnabled?: boolean;
741
+ /**
742
+ * SDK synchronization settings.
743
+ * @property {Object} sync
744
+ */
745
+ sync?: {
746
+ /**
747
+ * List of feature flag filters. These filters are used to fetch a subset of the feature flag definitions in your environment, in order to reduce the delay of the SDK to be ready.
748
+ * This configuration is only meaningful when the SDK is working in "standalone" mode.
749
+ *
750
+ * Example:
751
+ * `splitFilter: [
752
+ * { type: 'byName', values: ['my_feature_flag_1', 'my_feature_flag_2'] }, // will fetch feature flags named 'my_feature_flag_1' and 'my_feature_flag_2'
753
+ * ]`
754
+ * @property {SplitIO.SplitFilter[]} splitFilters
755
+ */
756
+ splitFilters?: SplitIO.SplitFilter[]
757
+ /**
758
+ * Impressions Collection Mode. Option to determine how impressions are going to be sent to Split servers.
759
+ * Possible values are 'DEBUG', 'OPTIMIZED', and 'NONE'.
760
+ * - DEBUG: will send all the impressions generated (recommended only for debugging purposes).
761
+ * - OPTIMIZED: will send unique impressions to Split servers, avoiding a considerable amount of traffic that duplicated impressions could generate.
762
+ * - NONE: will send unique keys evaluated per feature to Split servers instead of full blown impressions, avoiding a considerable amount of traffic that impressions could generate.
763
+ *
764
+ * @property {string} impressionsMode
765
+ * @default 'OPTIMIZED'
766
+ */
767
+ impressionsMode?: SplitIO.ImpressionsMode;
768
+ /**
769
+ * Controls the SDK continuous synchronization flags.
770
+ *
771
+ * When `true` a running SDK will process rollout plan updates performed on the UI (default).
772
+ * When false it'll just fetch all data upon init.
773
+ *
774
+ * @property {boolean} enabled
775
+ * @default true
776
+ */
777
+ enabled?: boolean
778
+ /**
779
+ * Custom options object for HTTP(S) requests.
780
+ * If provided, this object is merged with the options object passed by the SDK for EventSource and Fetch calls.
781
+ * This configuration has no effect in "consumer" mode, as no HTTP(S) requests are made by the SDK.
782
+ */
783
+ requestOptions?: {
784
+ /**
785
+ * Custom function called before each request, allowing you to add or update headers in SDK HTTP requests.
786
+ * Some headers, such as `SplitSDKVersion`, are required by the SDK and cannot be overridden.
787
+ * To pass multiple headers with the same name, combine their values into a single line, separated by commas. Example: `{ 'Authorization': 'value1, value2' }`
788
+ * Or provide keys with different case since headers are case-insensitive. Example: `{ 'authorization': 'value1', 'Authorization': 'value2' }`
789
+ *
790
+ * NOTE: to pass custom headers to the streaming connection in Browser, you should polyfill the `window.EventSource` object with a library that supports headers,
791
+ * like https://www.npmjs.com/package/event-source-polyfill, since native EventSource does not support them and will be ignored.
792
+ *
793
+ * @property getHeaderOverrides
794
+ * @default undefined
795
+ *
796
+ * @param context - The context for the request.
797
+ * @param context.headers - The current headers in the request.
798
+ * @returns A set of headers to be merged with the current headers.
799
+ *
800
+ * @example
801
+ * const getHeaderOverrides = (context) => {
802
+ * return {
803
+ * 'Authorization': context.headers['Authorization'] + ', other-value',
804
+ * 'custom-header': 'custom-value'
805
+ * };
806
+ * };
807
+ */
808
+ getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>;
809
+ };
810
+ };
811
+ /**
812
+ * List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
813
+ * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
814
+ * @property {Object} urls
815
+ */
816
+ urls?: UrlSettings;
817
+ /**
818
+ * Defines an optional list of factory functions used to instantiate SDK integrations.
819
+ *
820
+ * NOTE: at the moment there are not integrations to plug in.
821
+ *
822
+ * @property {Object} integrations
823
+ */
824
+ integrations?: IntegrationFactory[];
825
+ /**
826
+ * User consent status. Possible values are `'GRANTED'`, which is the default, `'DECLINED'` or `'UNKNOWN'`.
827
+ * - `'GRANTED'`: the user grants consent for tracking events and impressions. The SDK sends them to Split cloud.
828
+ * - `'DECLINED'`: the user declines consent for tracking events and impressions. The SDK does not send them to Split cloud.
829
+ * - `'UNKNOWN'`: the user neither grants nor declines consent for tracking events and impressions. The SDK tracks them in its internal storage, and eventually either sends
830
+ * them or not if the consent status is updated to 'GRANTED' or 'DECLINED' respectively. The status can be updated at any time with the `UserConsent.setStatus` factory method.
831
+ *
832
+ * @typedef {string} userConsent
833
+ * @default 'GRANTED'
834
+ */
835
+ userConsent?: ConsentStatus;
836
+ }
837
+ /**
838
+ * Settings interface for SDK instances created for client-side with synchronous storage (e.g., Browser or React Native).
839
+ *
840
+ * @interface IClientSideSettings
841
+ * @extends IClientSideBasicSettings
842
+ * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration}
843
+ */
844
+ interface IClientSideSettings extends IClientSideBasicSettings {
845
+ /**
846
+ * The SDK mode. When using the default in memory storage or `InLocalStorage` as storage, the only possible value is "standalone", which is the default.
847
+ * For "localhost" mode, use "localhost" as authorizationKey.
848
+ *
849
+ * @property {'standalone'} mode
850
+ * @default 'standalone'
851
+ */
852
+ mode?: 'standalone';
853
+ /**
854
+ * Mocked features map. For testing purposes only. For using this you should specify "localhost" as authorizationKey on core settings.
855
+ * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode}
856
+ */
857
+ features?: MockedFeaturesMap;
858
+ /**
859
+ * Defines the factory function to instantiate the storage. If not provided, the default IN MEMORY storage is used.
860
+ *
861
+ * NOTE: at the moment there are not storages to plug in React Native SDK, only `InLocalStorage` for Browser SDK.
862
+ *
863
+ * Example:
864
+ * ```
865
+ * SplitFactory({
866
+ * ...
867
+ * storage: InLocalStorage()
868
+ * })
869
+ * ```
870
+ * @property {Object} storage
871
+ */
872
+ storage?: StorageSyncFactory;
873
+ /**
874
+ * SDK Startup settings.
875
+ * @property {Object} startup
876
+ */
877
+ startup?: {
878
+ /**
879
+ * Maximum amount of time used before notify a timeout.
880
+ * @property {number} readyTimeout
881
+ * @default 1.5
882
+ */
883
+ readyTimeout?: number;
884
+ /**
885
+ * 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'.
886
+ * @property {number} requestTimeoutBeforeReady
887
+ * @default 1.5
888
+ */
889
+ requestTimeoutBeforeReady?: number;
890
+ /**
891
+ * How many quick retries we will do while starting up the SDK.
892
+ * @property {number} retriesOnFailureBeforeReady
893
+ * @default 1
894
+ */
895
+ retriesOnFailureBeforeReady?: number;
896
+ /**
897
+ * For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
898
+ * to better control on browsers or mobile. This number defines that window before the first events push.
899
+ *
900
+ * @property {number} eventsFirstPushWindow
901
+ * @default 10
902
+ */
903
+ eventsFirstPushWindow?: number;
904
+ };
905
+ /**
906
+ * SDK scheduler settings.
907
+ * @property {Object} scheduler
908
+ */
909
+ scheduler?: {
910
+ /**
911
+ * The SDK polls Split servers for changes to feature flag definitions. This parameter controls this polling period in seconds.
912
+ * @property {number} featuresRefreshRate
913
+ * @default 60
914
+ */
915
+ featuresRefreshRate?: number;
916
+ /**
917
+ * 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.
918
+ * @property {number} impressionsRefreshRate
919
+ * @default 60
920
+ */
921
+ impressionsRefreshRate?: number;
922
+ /**
923
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
924
+ * If you use a 0 here, the queue will have no maximum size.
925
+ * @property {number} impressionsQueueSize
926
+ * @default 30000
927
+ */
928
+ impressionsQueueSize?: number;
929
+ /**
930
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
931
+ * @property {number} telemetryRefreshRate
932
+ * @default 3600
933
+ */
934
+ telemetryRefreshRate?: number;
935
+ /**
936
+ * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
937
+ * @property {number} segmentsRefreshRate
938
+ * @default 60
939
+ */
940
+ segmentsRefreshRate?: number;
941
+ /**
942
+ * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
943
+ * @property {number} eventsPushRate
944
+ * @default 60
945
+ */
946
+ eventsPushRate?: number;
947
+ /**
948
+ * The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
949
+ * If you use a 0 here, the queue will have no maximum size.
950
+ * @property {number} eventsQueueSize
951
+ * @default 500
952
+ */
953
+ eventsQueueSize?: number;
954
+ /**
955
+ * For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
956
+ * For more information see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode}
957
+ * @property {number} offlineRefreshRate
958
+ * @default 15
959
+ */
960
+ offlineRefreshRate?: number;
961
+ /**
962
+ * When using streaming mode, seconds to wait before re attempting to connect for push notifications.
963
+ * Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
964
+ * @property {number} pushRetryBackoffBase
965
+ * @default 1
966
+ */
967
+ pushRetryBackoffBase?: number;
968
+ }
969
+ }
970
+ /**
971
+ * Settings interface with async storage for SDK instances created for client-side (e.g., Serverless environments).
972
+ * If your storage is synchronous (by defaut we use memory, which is sync) use SplitIO.IClientSideSettings instead.
973
+ * @interface IClientSideAsyncSettings
974
+ * @extends IClientSideBasicSettings
975
+ */
976
+ interface IClientSideAsyncSettings extends IClientSideBasicSettings {
977
+ /**
978
+ * The SDK mode. When using `PluggableStorage` as storage, the possible values are "consumer" and "consumer_partial".
979
+ *
980
+ * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#sharing-state-with-a-pluggable-storage}
981
+ *
982
+ * @property {'consumer' | 'consumer_partial'} mode
983
+ */
984
+ mode: 'consumer' | 'consumer_partial';
985
+ /**
986
+ * Defines the factory function to instantiate the storage.
987
+ *
988
+ * Example:
989
+ * ```
990
+ * SplitFactory({
991
+ * ...
992
+ * storage: PluggableStorage({ wrapper: SomeWrapper })
993
+ * })
994
+ * ```
995
+ * @property {Object} storage
996
+ */
997
+ storage: StorageAsyncFactory;
998
+ /**
999
+ * SDK Startup settings.
1000
+ * @property {Object} startup
1001
+ */
1002
+ startup?: {
1003
+ /**
1004
+ * Maximum amount of time used before notify a timeout.
1005
+ * @property {number} readyTimeout
1006
+ * @default 1.5
1007
+ */
1008
+ readyTimeout?: number;
1009
+ /**
1010
+ * For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
1011
+ * to better control on browsers or mobile. This number defines that window before the first events push.
1012
+ *
1013
+ * NOTE: this param is ignored in 'consumer' mode.
1014
+ * @property {number} eventsFirstPushWindow
1015
+ * @default 10
1016
+ */
1017
+ eventsFirstPushWindow?: number;
1018
+ };
1019
+ /**
1020
+ * SDK scheduler settings.
1021
+ * @property {Object} scheduler
1022
+ */
1023
+ scheduler?: {
1024
+ /**
1025
+ * 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.
1026
+ *
1027
+ * NOTE: this param is ignored in 'consumer' mode.
1028
+ * @property {number} impressionsRefreshRate
1029
+ * @default 60
1030
+ */
1031
+ impressionsRefreshRate?: number;
1032
+ /**
1033
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
1034
+ * If you use a 0 here, the queue will have no maximum size.
1035
+ * @property {number} impressionsQueueSize
1036
+ * @default 30000
1037
+ */
1038
+ impressionsQueueSize?: number;
1039
+ /**
1040
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
1041
+ * @property {number} telemetryRefreshRate
1042
+ * @default 3600
1043
+ */
1044
+ telemetryRefreshRate?: number;
1045
+ /**
1046
+ * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
1047
+ *
1048
+ * NOTE: this param is ignored in 'consumer' mode.
1049
+ * @property {number} eventsPushRate
1050
+ * @default 60
1051
+ */
1052
+ eventsPushRate?: number;
1053
+ /**
1054
+ * The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
1055
+ * If you use a 0 here, the queue will have no maximum size.
1056
+ *
1057
+ * NOTE: this param is ignored in 'consumer' mode.
1058
+ * @property {number} eventsQueueSize
1059
+ * @default 500
1060
+ */
1061
+ eventsQueueSize?: number;
1062
+ }
1063
+ }
1064
+ /**
1065
+ * Common settings between Browser and NodeJS settings interface.
1066
+ * @interface ISharedSettings
1067
+ */
1068
+ interface ISharedSettings {
1069
+ /**
1070
+ * Boolean value to indicate whether the logger should be enabled or disabled, or a log level string.
1071
+ *
1072
+ * Examples:
1073
+ * ```
1074
+ * config.debug = true
1075
+ * config.debug = 'WARN'
1076
+ * ```
1077
+ * @property {boolean | LogLevel} debug
1078
+ * @default false
1079
+ */
1080
+ debug?: boolean | LogLevel,
1081
+ /**
1082
+ * The impression listener, which is optional. Whatever you provide here needs to comply with the SplitIO.IImpressionListener interface,
1083
+ * which will check for the logImpression method.
1084
+ * @property {IImpressionListener} impressionListener
1085
+ * @default undefined
1086
+ */
1087
+ impressionListener?: SplitIO.IImpressionListener,
1088
+ /**
1089
+ * Boolean flag to enable the streaming service as default synchronization mechanism. In the event of any issue with streaming,
1090
+ * the SDK would fallback to the polling mechanism. If false, the SDK would poll for changes as usual without attempting to use streaming.
1091
+ * @property {boolean} streamingEnabled
1092
+ * @default true
1093
+ */
1094
+ streamingEnabled?: boolean,
1095
+ /**
1096
+ * SDK synchronization settings.
1097
+ * @property {Object} sync
1098
+ */
1099
+ sync?: {
1100
+ /**
1101
+ * List of feature flag filters. These filters are used to fetch a subset of the feature flag definitions in your environment, in order to reduce the delay of the SDK to be ready.
1102
+ * This configuration is only meaningful when the SDK is working in "standalone" mode.
1103
+ *
1104
+ * Example:
1105
+ * `splitFilter: [
1106
+ * { type: 'byName', values: ['my_feature_flag_1', 'my_feature_flag_2'] }, // will fetch feature flags named 'my_feature_flag_1' and 'my_feature_flag_2'
1107
+ * ]`
1108
+ * @property {SplitIO.SplitFilter[]} splitFilters
1109
+ */
1110
+ splitFilters?: SplitIO.SplitFilter[]
1111
+ /**
1112
+ * Impressions Collection Mode. Option to determine how impressions are going to be sent to Split servers.
1113
+ * Possible values are 'DEBUG', 'OPTIMIZED', and 'NONE'.
1114
+ * - DEBUG: will send all the impressions generated (recommended only for debugging purposes).
1115
+ * - OPTIMIZED: will send unique impressions to Split servers, avoiding a considerable amount of traffic that duplicated impressions could generate.
1116
+ * - NONE: will send unique keys evaluated per feature to Split servers instead of full blown impressions, avoiding a considerable amount of traffic that impressions could generate.
1117
+ *
1118
+ * @property {string} impressionsMode
1119
+ * @default 'OPTIMIZED'
1120
+ */
1121
+ impressionsMode?: SplitIO.ImpressionsMode,
1122
+ /**
1123
+ * Controls the SDK continuous synchronization flags.
1124
+ *
1125
+ * When `true` a running SDK will process rollout plan updates performed on the UI (default).
1126
+ * When false it'll just fetch all data upon init.
1127
+ *
1128
+ * @property {boolean} enabled
1129
+ * @default true
1130
+ */
1131
+ enabled?: boolean
1132
+ }
1133
+ }
1134
+ /**
1135
+ * Common settings interface for SDK instances on NodeJS.
1136
+ * @interface INodeBasicSettings
1137
+ * @extends ISharedSettings
1138
+ */
1139
+ interface INodeBasicSettings extends ISharedSettings {
1140
+ /**
1141
+ * SDK Startup settings for NodeJS.
1142
+ * @property {Object} startup
1143
+ */
1144
+ startup?: {
1145
+ /**
1146
+ * Maximum amount of time used before notify a timeout.
1147
+ * @property {number} readyTimeout
1148
+ * @default 15
1149
+ */
1150
+ readyTimeout?: number,
1151
+ /**
1152
+ * 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'.
1153
+ * @property {number} requestTimeoutBeforeReady
1154
+ * @default 15
1155
+ */
1156
+ requestTimeoutBeforeReady?: number,
1157
+ /**
1158
+ * How many quick retries we will do while starting up the SDK.
1159
+ * @property {number} retriesOnFailureBeforeReady
1160
+ * @default 1
1161
+ */
1162
+ retriesOnFailureBeforeReady?: number,
1163
+ /**
1164
+ * For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
1165
+ * to better control on browsers. This number defines that window before the first events push.
1166
+ *
1167
+ * @property {number} eventsFirstPushWindow
1168
+ * @default 0
1169
+ */
1170
+ eventsFirstPushWindow?: number,
1171
+ },
1172
+ /**
1173
+ * SDK scheduler settings.
1174
+ * @property {Object} scheduler
1175
+ */
1176
+ scheduler?: {
1177
+ /**
1178
+ * The SDK polls Split servers for changes to feature flag definitions. This parameter controls this polling period in seconds.
1179
+ * @property {number} featuresRefreshRate
1180
+ * @default 60
1181
+ */
1182
+ featuresRefreshRate?: number,
1183
+ /**
1184
+ * 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.
1185
+ * @property {number} impressionsRefreshRate
1186
+ * @default 300
1187
+ */
1188
+ impressionsRefreshRate?: number,
1189
+ /**
1190
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
1191
+ * If you use a 0 here, the queue will have no maximum size.
1192
+ * @property {number} impressionsQueueSize
1193
+ * @default 30000
1194
+ */
1195
+ impressionsQueueSize?: number,
1196
+ /**
1197
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
1198
+ * @property {number} metricsRefreshRate
1199
+ * @default 120
1200
+ * @deprecated This parameter is ignored now. Use `telemetryRefreshRate` instead.
1201
+ */
1202
+ metricsRefreshRate?: number,
1203
+ /**
1204
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
1205
+ * @property {number} telemetryRefreshRate
1206
+ * @default 3600
1207
+ */
1208
+ telemetryRefreshRate?: number,
1209
+ /**
1210
+ * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
1211
+ * @property {number} segmentsRefreshRate
1212
+ * @default 60
1213
+ */
1214
+ segmentsRefreshRate?: number,
1215
+ /**
1216
+ * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
1217
+ * @property {number} eventsPushRate
1218
+ * @default 60
1219
+ */
1220
+ eventsPushRate?: number,
1221
+ /**
1222
+ * The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
1223
+ * If you use a 0 here, the queue will have no maximum size.
1224
+ * @property {number} eventsQueueSize
1225
+ * @default 500
1226
+ */
1227
+ eventsQueueSize?: number,
1228
+ /**
1229
+ * For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
1230
+ * For more information see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
1231
+ * @property {number} offlineRefreshRate
1232
+ * @default 15
1233
+ */
1234
+ offlineRefreshRate?: number
1235
+ /**
1236
+ * When using streaming mode, seconds to wait before re attempting to connect for push notifications.
1237
+ * Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
1238
+ * @property {number} pushRetryBackoffBase
1239
+ * @default 1
1240
+ */
1241
+ pushRetryBackoffBase?: number,
1242
+ },
1243
+ /**
1244
+ * SDK Core settings for NodeJS.
1245
+ * @property {Object} core
1246
+ */
1247
+ core: {
1248
+ /**
1249
+ * Your SDK key.
1250
+ * @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
1251
+ * @property {string} authorizationKey
1252
+ */
1253
+ authorizationKey: string,
1254
+ /**
1255
+ * Disable labels from being sent to Split backend. Labels may contain sensitive information.
1256
+ * @property {boolean} labelsEnabled
1257
+ * @default true
1258
+ */
1259
+ labelsEnabled?: boolean
1260
+ /**
1261
+ * Disable machine IP and Name from being sent to Split backend.
1262
+ * @property {boolean} IPAddressesEnabled
1263
+ * @default true
1264
+ */
1265
+ IPAddressesEnabled?: boolean
1266
+ },
1267
+ /**
1268
+ * Defines which kind of storage we should instantiate.
1269
+ * @property {Object} storage
1270
+ */
1271
+ storage?: {
1272
+ /**
1273
+ * Storage type to be instantiated by the SDK.
1274
+ * @property {StorageType} type
1275
+ * @default 'MEMORY'
1276
+ */
1277
+ type?: StorageType,
1278
+ /**
1279
+ * Options to be passed to the selected storage.
1280
+ * @property {Object} options
1281
+ */
1282
+ options?: Object,
1283
+ /**
1284
+ * Optional prefix to prevent any kind of data collision between SDK versions.
1285
+ * @property {string} prefix
1286
+ * @default 'SPLITIO'
1287
+ */
1288
+ prefix?: string
1289
+ },
1290
+ /**
1291
+ * The SDK mode. Possible values are "standalone", which is the default when using a synchronous storage, like 'MEMORY' and 'LOCALSTORAGE',
1292
+ * and "consumer", which must be set when using an asynchronous storage, like 'REDIS'. For "localhost" mode, use "localhost" as authorizationKey.
1293
+ * @property {SDKMode} mode
1294
+ * @default 'standalone'
1295
+ */
1296
+ mode?: SDKMode,
1297
+ /**
1298
+ * Mocked features file path. For testing purposes only. For using this you should specify "localhost" as authorizationKey on core settings.
1299
+ * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
1300
+ * @property {MockedFeaturesFilePath} features
1301
+ * @default '$HOME/.split'
1302
+ */
1303
+ features?: SplitIO.MockedFeaturesFilePath,
1304
+ }
1305
+ /**
1306
+ * Settings interface for SDK instances created on the browser
1307
+ * @interface IBrowserSettings
1308
+ * @extends ISharedSettings
1309
+ * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#configuration}
1310
+ */
1311
+ interface IBrowserSettings extends ISharedSettings {
1312
+ /**
1313
+ * SDK Startup settings for the Browser.
1314
+ * @property {Object} startup
1315
+ */
1316
+ startup?: {
1317
+ /**
1318
+ * Maximum amount of time used before notify a timeout.
1319
+ * @property {number} readyTimeout
1320
+ * @default 1.5
1321
+ */
1322
+ readyTimeout?: number,
1323
+ /**
1324
+ * 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'.
1325
+ * @property {number} requestTimeoutBeforeReady
1326
+ * @default 1.5
1327
+ */
1328
+ requestTimeoutBeforeReady?: number,
1329
+ /**
1330
+ * How many quick retries we will do while starting up the SDK.
1331
+ * @property {number} retriesOnFailureBeforeReady
1332
+ * @default 1
1333
+ */
1334
+ retriesOnFailureBeforeReady?: number,
1335
+ /**
1336
+ * For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
1337
+ * to better control on browsers. This number defines that window before the first events push.
1338
+ *
1339
+ * @property {number} eventsFirstPushWindow
1340
+ * @default 10
1341
+ */
1342
+ eventsFirstPushWindow?: number,
1343
+ },
1344
+ /**
1345
+ * SDK scheduler settings.
1346
+ * @property {Object} scheduler
1347
+ */
1348
+ scheduler?: {
1349
+ /**
1350
+ * The SDK polls Split servers for changes to feature flag definitions. This parameter controls this polling period in seconds.
1351
+ * @property {number} featuresRefreshRate
1352
+ * @default 60
1353
+ */
1354
+ featuresRefreshRate?: number,
1355
+ /**
1356
+ * 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.
1357
+ * @property {number} impressionsRefreshRate
1358
+ * @default 60
1359
+ */
1360
+ impressionsRefreshRate?: number,
1361
+ /**
1362
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
1363
+ * If you use a 0 here, the queue will have no maximum size.
1364
+ * @property {number} impressionsQueueSize
1365
+ * @default 30000
1366
+ */
1367
+ impressionsQueueSize?: number,
1368
+ /**
1369
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
1370
+ * @property {number} metricsRefreshRate
1371
+ * @default 120
1372
+ * @deprecated This parameter is ignored now. Use `telemetryRefreshRate` instead.
1373
+ */
1374
+ metricsRefreshRate?: number,
1375
+ /**
1376
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
1377
+ * @property {number} telemetryRefreshRate
1378
+ * @default 3600
1379
+ */
1380
+ telemetryRefreshRate?: number,
1381
+ /**
1382
+ * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
1383
+ * @property {number} segmentsRefreshRate
1384
+ * @default 60
1385
+ */
1386
+ segmentsRefreshRate?: number,
1387
+ /**
1388
+ * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
1389
+ * @property {number} eventsPushRate
1390
+ * @default 60
1391
+ */
1392
+ eventsPushRate?: number,
1393
+ /**
1394
+ * The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
1395
+ * If you use a 0 here, the queue will have no maximum size.
1396
+ * @property {number} eventsQueueSize
1397
+ * @default 500
1398
+ */
1399
+ eventsQueueSize?: number,
1400
+ /**
1401
+ * For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
1402
+ * For more information see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#localhost-mode}
1403
+ * @property {number} offlineRefreshRate
1404
+ * @default 15
1405
+ */
1406
+ offlineRefreshRate?: number,
1407
+ /**
1408
+ * When using streaming mode, seconds to wait before re attempting to connect for push notifications.
1409
+ * Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
1410
+ * @property {number} pushRetryBackoffBase
1411
+ * @default 1
1412
+ */
1413
+ pushRetryBackoffBase?: number,
1414
+ },
1415
+ /**
1416
+ * SDK Core settings for the browser.
1417
+ * @property {Object} core
1418
+ */
1419
+ core: {
1420
+ /**
1421
+ * Your SDK key.
1422
+ * @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
1423
+ * @property {string} authorizationKey
1424
+ */
1425
+ authorizationKey: string,
1426
+ /**
1427
+ * Customer identifier. Whatever this means to you.
1428
+ * @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
1429
+ * @property {SplitKey} key
1430
+ */
1431
+ key: SplitKey,
1432
+ /**
1433
+ * Disable labels from being sent to Split backend. Labels may contain sensitive information.
1434
+ * @property {boolean} labelsEnabled
1435
+ * @default true
1436
+ */
1437
+ labelsEnabled?: boolean
1438
+ },
1439
+ /**
1440
+ * Mocked features map. For testing purposes only. For using this you should specify "localhost" as authorizationKey on core settings.
1441
+ * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#localhost-mode}
1442
+ */
1443
+ features?: MockedFeaturesMap,
1444
+ /**
1445
+ * Defines which kind of storage we can instantiate on the browser.
1446
+ * Possible storage types are 'MEMORY', which is the default, and 'LOCALSTORAGE'.
1447
+ * @property {Object} storage
1448
+ */
1449
+ storage?: {
1450
+ /**
1451
+ * Storage type to be instantiated by the SDK.
1452
+ * @property {BrowserStorage} type
1453
+ * @default 'MEMORY'
1454
+ */
1455
+ type?: BrowserStorage,
1456
+ /**
1457
+ * Optional prefix to prevent any kind of data collision between SDK versions.
1458
+ * @property {string} prefix
1459
+ * @default 'SPLITIO'
1460
+ */
1461
+ prefix?: string
1462
+ },
1463
+ /**
1464
+ * List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
1465
+ * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
1466
+ * @property {Object} urls
1467
+ */
1468
+ urls?: UrlSettings,
1469
+ /**
1470
+ * User consent status. Possible values are `'GRANTED'`, which is the default, `'DECLINED'` or `'UNKNOWN'`.
1471
+ * - `'GRANTED'`: the user grants consent for tracking events and impressions. The SDK sends them to Split cloud.
1472
+ * - `'DECLINED'`: the user declines consent for tracking events and impressions. The SDK does not send them to Split cloud.
1473
+ * - `'UNKNOWN'`: the user neither grants nor declines consent for tracking events and impressions. The SDK tracks them in its internal storage, and eventually either sends
1474
+ * them or not if the consent status is updated to 'GRANTED' or 'DECLINED' respectively. The status can be updated at any time with the `UserConsent.setStatus` factory method.
1475
+ *
1476
+ * @typedef {string} userConsent
1477
+ * @default 'GRANTED'
1478
+ */
1479
+ userConsent?: ConsentStatus,
1480
+ sync?: ISharedSettings['sync'] & {
1481
+ /**
1482
+ * Custom options object for HTTP(S) requests in the Browser.
1483
+ * If provided, this object is merged with the options object passed by the SDK for EventSource and Fetch calls.
1484
+ */
1485
+ requestOptions?: {
1486
+ /**
1487
+ * Custom function called before each request, allowing you to add or update headers in SDK HTTP requests.
1488
+ * Some headers, such as `SplitSDKVersion`, are required by the SDK and cannot be overridden.
1489
+ * To pass multiple headers with the same name, combine their values into a single line, separated by commas. Example: `{ 'Authorization': 'value1, value2' }`
1490
+ * Or provide keys with different case since headers are case-insensitive. Example: `{ 'authorization': 'value1', 'Authorization': 'value2' }`
1491
+ *
1492
+ * NOTE: to pass custom headers to the streaming connection in Browser, you should polyfill the `window.EventSource` object with a library that supports headers,
1493
+ * like https://www.npmjs.com/package/event-source-polyfill, since native EventSource does not support them and will be ignored.
1494
+ *
1495
+ * @property getHeaderOverrides
1496
+ * @default undefined
1497
+ *
1498
+ * @param context - The context for the request.
1499
+ * @param context.headers - The current headers in the request.
1500
+ * @returns A set of headers to be merged with the current headers.
1501
+ *
1502
+ * @example
1503
+ * const getHeaderOverrides = (context) => {
1504
+ * return {
1505
+ * 'Authorization': context.headers['Authorization'] + ', other-value',
1506
+ * 'custom-header': 'custom-value'
1507
+ * };
1508
+ * };
1509
+ */
1510
+ getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>
1511
+ },
1512
+ }
1513
+ }
1514
+ /**
1515
+ * Settings interface for SDK instances created on NodeJS.
1516
+ * If your storage is asynchronous (Redis for example) use SplitIO.INodeAsyncSettings instead.
1517
+ * @interface INodeSettings
1518
+ * @extends INodeBasicSettings
1519
+ * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
1520
+ */
1521
+ interface INodeSettings extends INodeBasicSettings {
1522
+ /**
1523
+ * List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
1524
+ * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
1525
+ * @property {Object} urls
1526
+ */
1527
+ urls?: UrlSettings,
1528
+ /**
1529
+ * Defines which kind of storage we can instantiate on NodeJS for 'standalone' mode.
1530
+ * The only possible storage type is 'MEMORY', which is the default.
1531
+ * @property {Object} storage
1532
+ */
1533
+ storage?: {
1534
+ /**
1535
+ * Synchronous storage type to be instantiated by the SDK.
1536
+ * @property {NodeSyncStorage} type
1537
+ * @default 'MEMORY'
1538
+ */
1539
+ type?: NodeSyncStorage,
1540
+ /**
1541
+ * Optional prefix to prevent any kind of data collision between SDK versions.
1542
+ * @property {string} prefix
1543
+ * @default 'SPLITIO'
1544
+ */
1545
+ prefix?: string
1546
+ },
1547
+ /**
1548
+ * The SDK mode. When using the default 'MEMORY' storage, the only possible value is "standalone", which is the default.
1549
+ * For "localhost" mode, use "localhost" as authorizationKey.
1550
+ *
1551
+ * @property {'standalone'} mode
1552
+ * @default 'standalone'
1553
+ */
1554
+ mode?: 'standalone'
1555
+ sync?: INodeBasicSettings['sync'] & {
1556
+ /**
1557
+ * Custom options object for HTTP(S) requests in NodeJS.
1558
+ * If provided, this object is merged with the options object passed by the SDK for EventSource and Node-Fetch calls.
1559
+ * @see {@link https://www.npmjs.com/package/node-fetch#options}
1560
+ */
1561
+ requestOptions?: {
1562
+ /**
1563
+ * Custom function called before each request, allowing you to add or update headers in SDK HTTP requests.
1564
+ * Some headers, such as `SplitSDKVersion`, are required by the SDK and cannot be overridden.
1565
+ * To pass multiple headers with the same name, combine their values into a single line, separated by commas. Example: `{ 'Authorization': 'value1, value2' }`
1566
+ * Or provide keys with different case since headers are case-insensitive. Example: `{ 'authorization': 'value1', 'Authorization': 'value2' }`
1567
+ *
1568
+ * @property getHeaderOverrides
1569
+ * @default undefined
1570
+ *
1571
+ * @param context - The context for the request.
1572
+ * @param context.headers - The current headers in the request.
1573
+ * @returns A set of headers to be merged with the current headers.
1574
+ *
1575
+ * @example
1576
+ * const getHeaderOverrides = (context) => {
1577
+ * return {
1578
+ * 'Authorization': context.headers['Authorization'] + ', other-value',
1579
+ * 'custom-header': 'custom-value'
1580
+ * };
1581
+ * };
1582
+ */
1583
+ getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>
1584
+ /**
1585
+ * Custom NodeJS HTTP(S) Agent used by the SDK for HTTP(S) requests.
1586
+ *
1587
+ * You can use it, for example, for certificate pinning or setting a network proxy:
1588
+ *
1589
+ * ```
1590
+ * const { HttpsProxyAgent } = require('https-proxy-agent');
1591
+ *
1592
+ * const proxyAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY || 'http://10.10.1.10:1080');
1593
+ *
1594
+ * const factory = SplitFactory({
1595
+ * ...
1596
+ * sync: {
1597
+ * requestOptions: {
1598
+ * agent: proxyAgent
1599
+ * }
1600
+ * }
1601
+ * })
1602
+ * ```
1603
+ *
1604
+ * @see {@link https://nodejs.org/api/https.html#class-httpsagent}
1605
+ *
1606
+ * @property {http.Agent | https.Agent} agent
1607
+ * @default undefined
1608
+ */
1609
+ agent?: RequestOptions["agent"]
1610
+ },
1611
+ }
1612
+ }
1613
+ /**
1614
+ * Settings interface with async storage for SDK instances created on NodeJS.
1615
+ * If your storage is synchronous (by defaut we use memory, which is sync) use SplitIO.INodeSettings instead.
1616
+ * @interface INodeAsyncSettings
1617
+ * @extends INodeBasicSettings
1618
+ * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
1619
+ */
1620
+ interface INodeAsyncSettings extends INodeBasicSettings {
1621
+ /**
1622
+ * Defines which kind of async storage we can instantiate on NodeJS for 'consumer' mode.
1623
+ * The only possible storage type is 'REDIS'.
1624
+ * @property {Object} storage
1625
+ */
1626
+ storage: {
1627
+ /**
1628
+ * 'REDIS' storage type to be instantiated by the SDK.
1629
+ * @property {NodeAsyncStorage} type
1630
+ */
1631
+ type: NodeAsyncStorage,
1632
+ /**
1633
+ * Options to be passed to the Redis storage. Use it with storage type: 'REDIS'.
1634
+ * @property {Object} options
1635
+ */
1636
+ options?: {
1637
+ /**
1638
+ * Redis URL. If set, `host`, `port`, `db` and `pass` params will be ignored.
1639
+ *
1640
+ * Examples:
1641
+ * ```
1642
+ * url: 'localhost'
1643
+ * url: '127.0.0.1:6379'
1644
+ * url: 'redis://:authpassword@127.0.0.1:6379/0'
1645
+ * ```
1646
+ * @property {string=} url
1647
+ */
1648
+ url?: string,
1649
+ /**
1650
+ * Redis host.
1651
+ * @property {string=} host
1652
+ * @default 'localhost'
1653
+ */
1654
+ host?: string,
1655
+ /**
1656
+ * Redis port.
1657
+ * @property {number=} port
1658
+ * @default 6379
1659
+ */
1660
+ port?: number,
1661
+ /**
1662
+ * Redis database to be used.
1663
+ * @property {number=} db
1664
+ * @default 0
1665
+ */
1666
+ db?: number,
1667
+ /**
1668
+ * Redis password. Don't define if no password is used.
1669
+ * @property {string=} pass
1670
+ * @default undefined
1671
+ */
1672
+ pass?: string,
1673
+ /**
1674
+ * The milliseconds before a timeout occurs during the initial connection to the Redis server.
1675
+ * @property {number=} connectionTimeout
1676
+ * @default 10000
1677
+ */
1678
+ connectionTimeout?: number,
1679
+ /**
1680
+ * The milliseconds before Redis commands are timeout by the SDK.
1681
+ * Method calls that involve Redis commands, like `client.getTreatment` or `client.track` calls, are resolved when the commands success or timeout.
1682
+ * @property {number=} operationTimeout
1683
+ * @default 5000
1684
+ */
1685
+ operationTimeout?: number,
1686
+ /**
1687
+ * TLS configuration for Redis connection.
1688
+ * @see {@link https://www.npmjs.com/package/ioredis#tls-options }
1689
+ *
1690
+ * @property {Object=} tls
1691
+ * @default undefined
1692
+ */
1693
+ tls?: RedisOptions['tls'],
1694
+ },
1695
+ /**
1696
+ * Optional prefix to prevent any kind of data collision between SDK versions.
1697
+ * @property {string} prefix
1698
+ * @default 'SPLITIO'
1699
+ */
1700
+ prefix?: string
1701
+ },
1702
+ /**
1703
+ * The SDK mode. When using 'REDIS' storage type, the only possible value is "consumer", which is required.
1704
+ *
1705
+ * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#state-sharing-redis-integration}
1706
+ *
1707
+ * @property {'consumer'} mode
1708
+ */
1709
+ mode: 'consumer'
1710
+ }
1711
+ /**
1712
+ * This represents the interface for the SDK instance with synchronous storage and client-side API,
1713
+ * i.e., where client instances have a bound user key.
1714
+ * @interface ISDK
1715
+ * @extends IBasicSDK
1716
+ */
1717
+ interface ISDK extends IBasicSDK {
1718
+ /**
1719
+ * Returns the default client instance of the SDK, associated with the key provided on settings.
1720
+ * @function client
1721
+ * @returns {IClient} The client instance.
1722
+ */
1723
+ client(): IClient;
1724
+ /**
1725
+ * Returns a shared client of the SDK, associated with the given key.
1726
+ * @function client
1727
+ * @param {SplitKey} key The key for the new client instance.
1728
+ * @returns {IClient} The client instance.
1729
+ */
1730
+ client(key: SplitKey): IClient;
1731
+ /**
1732
+ * Returns a manager instance of the SDK to explore available information.
1733
+ * @function manager
1734
+ * @returns {IManager} The manager instance.
1735
+ */
1736
+ manager(): IManager;
1737
+ /**
1738
+ * User consent API.
1739
+ * @property UserConsent
1740
+ */
1741
+ UserConsent: IUserConsentAPI;
1742
+ }
1743
+ /**
1744
+ * This represents the interface for the SDK instance with asynchronous storage and client-side API,
1745
+ * i.e., where client instances have a bound user key.
1746
+ * @interface IAsyncSDK
1747
+ * @extends IBasicSDK
1748
+ */
1749
+ interface IAsyncSDK extends IBasicSDK {
1750
+ /**
1751
+ * Returns the default client instance of the SDK, associated with the key provided on settings.
1752
+ * @function client
1753
+ * @returns {IAsyncClient} The asynchronous client instance.
1754
+ */
1755
+ client(): IAsyncClient;
1756
+ /**
1757
+ * Returns a shared client of the SDK, associated with the given key.
1758
+ * @function client
1759
+ * @param {SplitKey} key The key for the new client instance.
1760
+ * @returns {IAsyncClient} The asynchronous client instance.
1761
+ */
1762
+ client(key: SplitKey): IAsyncClient;
1763
+ /**
1764
+ * Returns a manager instance of the SDK to explore available information.
1765
+ * @function manager
1766
+ * @returns {IManager} The manager instance.
1767
+ */
1768
+ manager(): IAsyncManager;
1769
+ /**
1770
+ * User consent API.
1771
+ * @property UserConsent
1772
+ */
1773
+ UserConsent: IUserConsentAPI;
1774
+ }
1775
+ /**
1776
+ * This represents the interface for the SDK instance for server-side with synchronous storage.
1777
+ * @interface INodeSDK
1778
+ * @extends IBasicSDK
1779
+ */
1780
+ interface INodeSDK extends IBasicSDK {
1781
+ /**
1782
+ * Returns the default client instance of the SDK.
1783
+ * @function client
1784
+ * @returns {INodeClient} The client instance.
1785
+ */
1786
+ client(): INodeClient;
1787
+ /**
1788
+ * Returns a manager instance of the SDK to explore available information.
1789
+ * @function manager
1790
+ * @returns {IManager} The manager instance.
1791
+ */
1792
+ manager(): IManager;
1793
+ }
1794
+ /**
1795
+ * This represents the interface for the SDK instance for server-side with asynchronous storage.
1796
+ * @interface INodeAsyncSDK
1797
+ * @extends IBasicSDK
1798
+ */
1799
+ interface INodeAsyncSDK extends IBasicSDK {
1800
+ /**
1801
+ * Returns the default client instance of the SDK.
1802
+ * @function client
1803
+ * @returns {INodeAsyncClient} The asynchronous client instance.
1804
+ */
1805
+ client(): INodeAsyncClient;
1806
+ /**
1807
+ * Returns a manager instance of the SDK to explore available information.
1808
+ * @function manager
1809
+ * @returns {IManager} The manager instance.
1810
+ */
1811
+ manager(): IAsyncManager;
1812
+ }
1813
+ /**
1814
+ * This represents the interface for the Client instance on server-side, where the user key is not bound to the instance and must be provided on each method call.
1815
+ * This interface is available in NodeJS, or when importing the 'server' sub-package of JS SDK (e.g., `import { SplitFactory } from '@splitsoftware/splitio/server'`).
1816
+ *
1817
+ * @interface INodeClient
1818
+ * @extends IBasicClient
1819
+ */
1820
+ interface INodeClient extends IBasicClient {
1821
+ /**
1822
+ * Returns a Treatment value, which is the treatment string for the given feature.
1823
+ *
1824
+ * @function getTreatment
1825
+ * @param {string} key - The string key representing the consumer.
1826
+ * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment.
1827
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1828
+ * @returns {Treatment} The treatment string.
1829
+ */
1830
+ getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes): Treatment;
1831
+ /**
1832
+ * Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
1833
+ *
1834
+ * @function getTreatmentWithConfig
1835
+ * @param {string} key - The string key representing the consumer.
1836
+ * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment.
1837
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1838
+ * @returns {TreatmentWithConfig} The TreatmentWithConfig, the object containing the treatment string and the
1839
+ * configuration stringified JSON (or null if there was no config for that treatment).
1840
+ */
1841
+ getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes): TreatmentWithConfig;
1842
+ /**
1843
+ * Returns a Treatments value, which is an object map with the treatments for the given features.
1844
+ *
1845
+ * @function getTreatments
1846
+ * @param {string} key - The string key representing the consumer.
1847
+ * @param {Array<string>} featureFlagNames - An array of the feature flag names we want to get the treatments.
1848
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1849
+ * @returns {Treatments} The treatments object map.
1850
+ */
1851
+ getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): Treatments;
1852
+ /**
1853
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
1854
+ *
1855
+ * @function getTreatmentsWithConfig
1856
+ * @param {string} key - The string key representing the consumer.
1857
+ * @param {Array<string>} featureFlagNames - An array of the feature flag names we want to get the treatments.
1858
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1859
+ * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
1860
+ */
1861
+ getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig;
1862
+ /**
1863
+ * Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
1864
+ *
1865
+ * @function getTreatmentsByFlagSet
1866
+ * @param {string} key - The string key representing the consumer.
1867
+ * @param {string} flagSet - The flag set name we want to get the treatments.
1868
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1869
+ * @returns {Treatments} The map with all the Treatment objects
1870
+ */
1871
+ getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): Treatments;
1872
+ /**
1873
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
1874
+ *
1875
+ * @function getTreatmentsWithConfigByFlagSet
1876
+ * @param {string} key - The string key representing the consumer.
1877
+ * @param {string} flagSet - The flag set name we want to get the treatments.
1878
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1879
+ * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
1880
+ */
1881
+ getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): TreatmentsWithConfig;
1882
+ /**
1883
+ * Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
1884
+ *
1885
+ * @function getTreatmentsByFlagSets
1886
+ * @param {string} key - The string key representing the consumer.
1887
+ * @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
1888
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1889
+ * @returns {Treatments} The map with all the Treatment objects
1890
+ */
1891
+ getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): Treatments;
1892
+ /**
1893
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
1894
+ *
1895
+ * @function getTreatmentsWithConfigByFlagSets
1896
+ * @param {string} key - The string key representing the consumer.
1897
+ * @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
1898
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1899
+ * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
1900
+ */
1901
+ getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): TreatmentsWithConfig;
1902
+ /**
1903
+ * Tracks an event to be fed to the results product on Split user interface.
1904
+ *
1905
+ * @function track
1906
+ * @param {SplitKey} key - The key that identifies the entity related to this event.
1907
+ * @param {string} trafficType - The traffic type of the entity related to this event. See {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
1908
+ * @param {string} eventType - The event type corresponding to this event.
1909
+ * @param {number=} value - The value of this event.
1910
+ * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1911
+ * @returns {boolean} Whether the event was added to the queue successfully or not.
1912
+ */
1913
+ track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): boolean;
1914
+ }
1915
+ /**
1916
+ * This represents the interface for the Client instance on server-side with asynchronous storage, like REDIS.
1917
+ * User key is not bound to the instance and must be provided on each method call, which returns a promise.
1918
+ * This interface is available in NodeJS, or when importing the 'server' sub-package in JS SDK (e.g., `import { SplitFactory } from '@splitsoftware/splitio/server'`).
1919
+ *
1920
+ * @interface INodeAsyncClient
1921
+ * @extends IBasicClient
1922
+ */
1923
+ interface INodeAsyncClient extends IBasicClient {
1924
+ /**
1925
+ * Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
1926
+ *
1927
+ * @function getTreatment
1928
+ * @param {string} key - The string key representing the consumer.
1929
+ * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment.
1930
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1931
+ * @returns {AsyncTreatment} Treatment promise that resolves to the treatment string.
1932
+ */
1933
+ getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes): AsyncTreatment;
1934
+ /**
1935
+ * Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
1936
+ *
1937
+ * @function getTreatmentWithConfig
1938
+ * @param {string} key - The string key representing the consumer.
1939
+ * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment.
1940
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1941
+ * @returns {AsyncTreatmentWithConfig} TreatmentWithConfig promise that resolves to the TreatmentWithConfig object.
1942
+ */
1943
+ getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes): AsyncTreatmentWithConfig;
1944
+ /**
1945
+ * Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
1946
+ *
1947
+ * @function getTreatments
1948
+ * @param {string} key - The string key representing the consumer.
1949
+ * @param {Array<string>} featureFlagNames - An array of the feature flag names we want to get the treatments.
1950
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1951
+ * @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map.
1952
+ */
1953
+ getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): AsyncTreatments;
1954
+ /**
1955
+ * Returns a TreatmentsWithConfig value, which will be (or eventually be) an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
1956
+ *
1957
+ * @function getTreatmentsWithConfig
1958
+ * @param {string} key - The string key representing the consumer.
1959
+ * @param {Array<string>} featureFlagNames - An array of the feature flag names we want to get the treatments.
1960
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1961
+ * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
1962
+ */
1963
+ getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
1964
+ /**
1965
+ * Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
1966
+ *
1967
+ * @function getTreatmentsByFlagSet
1968
+ * @param {string} key - The string key representing the consumer.
1969
+ * @param {string} flagSet - The flag set name we want to get the treatments.
1970
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1971
+ * @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map.
1972
+ */
1973
+ getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): AsyncTreatments;
1974
+ /**
1975
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
1976
+ *
1977
+ * @function getTreatmentsWithConfigByFlagSet
1978
+ * @param {string} key - The string key representing the consumer.
1979
+ * @param {string} flagSet - The flag set name we want to get the treatments.
1980
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1981
+ * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
1982
+ */
1983
+ getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): AsyncTreatmentsWithConfig;
1984
+ /**
1985
+ * Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
1986
+ *
1987
+ * @function getTreatmentsByFlagSets
1988
+ * @param {string} key - The string key representing the consumer.
1989
+ * @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
1990
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1991
+ * @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map.
1992
+ */
1993
+ getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): AsyncTreatments;
1994
+ /**
1995
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
1996
+ *
1997
+ * @function getTreatmentsWithConfigByFlagSets
1998
+ * @param {string} key - The string key representing the consumer.
1999
+ * @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
2000
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2001
+ * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
2002
+ */
2003
+ getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
2004
+ /**
2005
+ * Tracks an event to be fed to the results product on Split user interface, and returns a promise to signal when the event was successfully queued (or not).
2006
+ *
2007
+ * @function track
2008
+ * @param {SplitKey} key - The key that identifies the entity related to this event.
2009
+ * @param {string} trafficType - The traffic type of the entity related to this event. See {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
2010
+ * @param {string} eventType - The event type corresponding to this event.
2011
+ * @param {number=} value - The value of this event.
2012
+ * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
2013
+ * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
2014
+ */
2015
+ track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>;
2016
+ }
2017
+ interface IClientWithAttributes extends IBasicClient {
2018
+ /**
2019
+ * Add an attribute to client's in memory attributes storage.
2020
+ *
2021
+ * @param {string} attributeName Attribute name
2022
+ * @param {AttributeType} attributeValue Attribute value
2023
+ * @returns {boolean} true if the attribute was stored and false otherwise
2024
+ */
2025
+ setAttribute(attributeName: string, attributeValue: AttributeType): boolean;
2026
+ /**
2027
+ * Returns the attribute with the given name.
2028
+ *
2029
+ * @param {string} attributeName Attribute name
2030
+ * @returns {AttributeType} Attribute with the given name
2031
+ */
2032
+ getAttribute(attributeName: string): AttributeType;
2033
+ /**
2034
+ * Removes from client's in memory attributes storage the attribute with the given name.
2035
+ *
2036
+ * @param {string} attributeName
2037
+ * @returns {boolean} true if attribute was removed and false otherwise
2038
+ */
2039
+ removeAttribute(attributeName: string): boolean;
2040
+ /**
2041
+ * Add to client's in memory attributes storage the attributes in 'attributes'.
2042
+ *
2043
+ * @param {Attributes} attributes Object with attributes to store
2044
+ * @returns true if attributes were stored an false otherwise
2045
+ */
2046
+ setAttributes(attributes: Attributes): boolean;
2047
+ /**
2048
+ * Return all the attributes stored in client's in memory attributes storage.
2049
+ *
2050
+ * @returns {Attributes} returns all the stored attributes
2051
+ */
2052
+ getAttributes(): Attributes;
2053
+ /**
2054
+ * Remove all the stored attributes in the client's in memory attribute storage.
2055
+ *
2056
+ * @returns {boolean} true if all attribute were removed and false otherwise
2057
+ */
2058
+ clearAttributes(): boolean;
2059
+ }
2060
+ /**
2061
+ * This represents the interface for the Client instance on client-side, where the user key is bound to the instance on creation and does not need to be provided on each method call.
2062
+ *
2063
+ * @interface IClient
2064
+ * @extends IClientWithAttributes
2065
+ */
2066
+ interface IClient extends IClientWithAttributes {
2067
+ /**
2068
+ * Returns a Treatment value, which is the treatment string for the given feature.
2069
+ *
2070
+ * @function getTreatment
2071
+ * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment.
2072
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2073
+ * @returns {Treatment} The treatment string.
2074
+ */
2075
+ getTreatment(featureFlagName: string, attributes?: Attributes): Treatment;
2076
+ /**
2077
+ * Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
2078
+ *
2079
+ * @function getTreatmentWithConfig
2080
+ * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment.
2081
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2082
+ * @returns {TreatmentWithConfig} The map containing the treatment and the configuration stringified JSON (or null if there was no config for that treatment).
2083
+ */
2084
+ getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes): TreatmentWithConfig;
2085
+ /**
2086
+ * Returns a Treatments value, which is an object map with the treatments for the given features.
2087
+ *
2088
+ * @function getTreatments
2089
+ * @param {Array<string>} featureFlagNames - An array of the feature flag names we want to get the treatments.
2090
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2091
+ * @returns {Treatments} The treatments object map.
2092
+ */
2093
+ getTreatments(featureFlagNames: string[], attributes?: Attributes): Treatments;
2094
+ /**
2095
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
2096
+ *
2097
+ * @function getTreatmentsWithConfig
2098
+ * @param {Array<string>} featureFlagNames - An array of the feature flag names we want to get the treatments.
2099
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2100
+ * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
2101
+ */
2102
+ getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig;
2103
+ /**
2104
+ * Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
2105
+ *
2106
+ * @function getTreatmentsByFlagSet
2107
+ * @param {string} flagSet - The flag set name we want to get the treatments.
2108
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2109
+ * @returns {Treatments} The map with all the Treatments objects
2110
+ */
2111
+ getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes): Treatments;
2112
+ /**
2113
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
2114
+ *
2115
+ * @function getTreatmentsWithConfigByFlagSet
2116
+ * @param {string} flagSet - The flag set name we want to get the treatments.
2117
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2118
+ * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
2119
+ */
2120
+ getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes): TreatmentsWithConfig;
2121
+ /**
2122
+ * Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
2123
+ *
2124
+ * @function getTreatmentsByFlagSets
2125
+ * @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
2126
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2127
+ * @returns {Treatments} The map with all the Treatments objects
2128
+ */
2129
+ getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes): Treatments;
2130
+ /**
2131
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
2132
+ *
2133
+ * @function getTreatmentsWithConfigByFlagSets
2134
+ * @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
2135
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2136
+ * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
2137
+ */
2138
+ getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes): TreatmentsWithConfig;
2139
+ /**
2140
+ * Tracks an event to be fed to the results product on Split user interface.
2141
+ *
2142
+ * @function track
2143
+ * @param {string} trafficType - The traffic type of the entity related to this event. See {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
2144
+ * @param {string} eventType - The event type corresponding to this event.
2145
+ * @param {number=} value - The value of this event.
2146
+ * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
2147
+ * @returns {boolean} Whether the event was added to the queue successfully or not.
2148
+ */
2149
+ track(trafficType: string, eventType: string, value?: number, properties?: Properties): boolean;
2150
+ }
2151
+ /**
2152
+ * This represents the interface for the Client instance with asynchronous storage for client-side SDK, where each client has associated a key.
2153
+ * @interface IAsyncClient
2154
+ * @extends IClientWithAttributes
2155
+ */
2156
+ interface IAsyncClient extends IClientWithAttributes {
2157
+ /**
2158
+ * Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
2159
+ *
2160
+ * @function getTreatment
2161
+ * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment.
2162
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2163
+ * @returns {AsyncTreatment} Treatment promise that resolves to the treatment string.
2164
+ */
2165
+ getTreatment(featureFlagName: string, attributes?: Attributes): AsyncTreatment;
2166
+ /**
2167
+ * Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
2168
+ *
2169
+ * @function getTreatmentWithConfig
2170
+ * @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment.
2171
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2172
+ * @returns {AsyncTreatmentWithConfig} TreatmentWithConfig promise that resolves to the TreatmentWithConfig object.
2173
+ */
2174
+ getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes): AsyncTreatmentWithConfig;
2175
+ /**
2176
+ * Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
2177
+ *
2178
+ * @function getTreatments
2179
+ * @param {Array<string>} featureFlagNames - An array of the feature flag names we want to get the treatments.
2180
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2181
+ * @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map.
2182
+ */
2183
+ getTreatments(featureFlagNames: string[], attributes?: Attributes): AsyncTreatments;
2184
+ /**
2185
+ * Returns a TreatmentsWithConfig value, which will be (or eventually be) an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
2186
+ *
2187
+ * @function getTreatmentsWithConfig
2188
+ * @param {Array<string>} featureFlagNames - An array of the feature flag names we want to get the treatments.
2189
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2190
+ * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
2191
+ */
2192
+ getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
2193
+ /**
2194
+ * Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
2195
+ *
2196
+ * @function getTreatmentsByFlagSet
2197
+ * @param {string} flagSet - The flag set name we want to get the treatments.
2198
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2199
+ * @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map.
2200
+ */
2201
+ getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes): AsyncTreatments;
2202
+ /**
2203
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
2204
+ *
2205
+ * @function getTreatmentsWithConfigByFlagSet
2206
+ * @param {string} flagSet - The flag set name we want to get the treatments.
2207
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2208
+ * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
2209
+ */
2210
+ getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes): AsyncTreatmentsWithConfig;
2211
+ /**
2212
+ * Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
2213
+ *
2214
+ * @function getTreatmentsByFlagSets
2215
+ * @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
2216
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2217
+ * @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map.
2218
+ */
2219
+ getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes): AsyncTreatments;
2220
+ /**
2221
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
2222
+ *
2223
+ * @function getTreatmentsWithConfigByFlagSets
2224
+ * @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
2225
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
2226
+ * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
2227
+ */
2228
+ getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
2229
+ /**
2230
+ * Tracks an event to be fed to the results product on Split user interface, and returns a promise to signal when the event was successfully queued (or not).
2231
+ *
2232
+ * @function track
2233
+ * @param {string} trafficType - The traffic type of the entity related to this event.
2234
+ * @param {string} eventType - The event type corresponding to this event.
2235
+ * @param {number=} value - The value of this event.
2236
+ * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
2237
+ * @returns {boolean} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
2238
+ */
2239
+ track(trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>;
2240
+ }
2241
+ /**
2242
+ * Representation of a manager instance with synchronous storage of the SDK.
2243
+ * @interface IManager
2244
+ * @extends IStatusInterface
2245
+ */
2246
+ interface IManager extends IStatusInterface {
2247
+ /**
2248
+ * Get the array of feature flag names.
2249
+ * @function names
2250
+ * @returns {SplitNames} The list of feature flag names.
2251
+ */
2252
+ names(): SplitNames;
2253
+ /**
2254
+ * Get the array of feature flags data in SplitView format.
2255
+ * @function splits
2256
+ * @returns {SplitViews} The list of SplitIO.SplitView.
2257
+ */
2258
+ splits(): SplitViews;
2259
+ /**
2260
+ * Get the data of a feature flag in SplitView format.
2261
+ * @function split
2262
+ * @param {string} featureFlagName The name of the feature flag we want to get info of.
2263
+ * @returns {SplitView | null} The SplitIO.SplitView of the given feature flag name or null if the feature flag is not found.
2264
+ */
2265
+ split(featureFlagName: string): SplitView | null;
2266
+ }
2267
+ /**
2268
+ * Representation of a manager instance with asynchronous storage of the SDK.
2269
+ * @interface IAsyncManager
2270
+ * @extends IStatusInterface
2271
+ */
2272
+ interface IAsyncManager extends IStatusInterface {
2273
+ /**
2274
+ * Get the array of feature flag names.
2275
+ * @function names
2276
+ * @returns {SplitNamesAsync} A promise that resolves to the list of feature flag names.
2277
+ */
2278
+ names(): SplitNamesAsync;
2279
+ /**
2280
+ * Get the array of feature flags data in SplitView format.
2281
+ * @function splits
2282
+ * @returns {SplitViewsAsync} A promise that resolves to the SplitIO.SplitView list.
2283
+ */
2284
+ splits(): SplitViewsAsync;
2285
+ /**
2286
+ * Get the data of a feature flag in SplitView format.
2287
+ * @function split
2288
+ * @param {string} featureFlagName The name of the feature flag we want to get info of.
2289
+ * @returns {SplitViewAsync} A promise that resolves to the SplitIO.SplitView value.
2290
+ */
2291
+ split(featureFlagName: string): SplitViewAsync;
2292
+ }
2293
+ }