@splitsoftware/splitio-commons 1.6.2-rc.0 → 1.6.2-rc.3

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/cjs/sdkFactory/index.js +1 -0
  2. package/cjs/services/splitApi.js +1 -0
  3. package/cjs/utils/key/index.js +1 -1
  4. package/cjs/utils/settingsValidation/index.js +1 -0
  5. package/esm/sdkFactory/index.js +1 -0
  6. package/esm/services/splitApi.js +1 -0
  7. package/esm/utils/key/index.js +1 -1
  8. package/esm/utils/settingsValidation/index.js +1 -0
  9. package/package.json +2 -2
  10. package/src/consent/sdkUserConsent.ts +4 -3
  11. package/src/dtos/types.ts +0 -8
  12. package/src/evaluator/Engine.ts +3 -3
  13. package/src/evaluator/combiners/and.ts +1 -1
  14. package/src/evaluator/combiners/ifelseif.ts +3 -3
  15. package/src/evaluator/condition/engineUtils.ts +1 -1
  16. package/src/evaluator/condition/index.ts +6 -6
  17. package/src/evaluator/index.ts +10 -10
  18. package/src/evaluator/matchers/all.ts +1 -1
  19. package/src/evaluator/matchers/between.ts +1 -1
  20. package/src/evaluator/matchers/boolean.ts +1 -1
  21. package/src/evaluator/matchers/cont_all.ts +1 -1
  22. package/src/evaluator/matchers/cont_any.ts +1 -1
  23. package/src/evaluator/matchers/cont_str.ts +1 -1
  24. package/src/evaluator/matchers/dependency.ts +1 -1
  25. package/src/evaluator/matchers/eq.ts +1 -1
  26. package/src/evaluator/matchers/eq_set.ts +1 -1
  27. package/src/evaluator/matchers/ew.ts +1 -1
  28. package/src/evaluator/matchers/gte.ts +1 -1
  29. package/src/evaluator/matchers/index.ts +1 -1
  30. package/src/evaluator/matchers/lte.ts +1 -1
  31. package/src/evaluator/matchers/part_of.ts +1 -1
  32. package/src/evaluator/matchers/segment.ts +1 -1
  33. package/src/evaluator/matchers/string.ts +1 -1
  34. package/src/evaluator/matchers/sw.ts +1 -1
  35. package/src/evaluator/matchers/whitelist.ts +1 -1
  36. package/src/evaluator/parser/index.ts +3 -3
  37. package/src/evaluator/types.ts +6 -6
  38. package/src/evaluator/value/index.ts +4 -4
  39. package/src/evaluator/value/sanitize.ts +4 -4
  40. package/src/integrations/ga/GaToSplit.ts +6 -6
  41. package/src/integrations/ga/SplitToGa.ts +10 -10
  42. package/src/integrations/ga/types.ts +4 -4
  43. package/src/integrations/pluggable.ts +3 -3
  44. package/src/integrations/types.ts +2 -2
  45. package/src/logger/index.ts +3 -3
  46. package/src/logger/sdkLogger.ts +1 -2
  47. package/src/logger/types.ts +0 -16
  48. package/src/readiness/sdkReadinessManager.ts +1 -1
  49. package/src/readiness/types.ts +2 -9
  50. package/src/sdkClient/client.ts +13 -13
  51. package/src/sdkClient/clientAttributesDecoration.ts +9 -9
  52. package/src/sdkClient/clientCS.ts +3 -4
  53. package/src/sdkClient/clientInputValidation.ts +15 -15
  54. package/src/sdkClient/sdkClient.ts +2 -2
  55. package/src/sdkClient/sdkClientMethod.ts +2 -2
  56. package/src/sdkClient/sdkClientMethodCS.ts +9 -9
  57. package/src/sdkClient/sdkClientMethodCSWithTT.ts +9 -9
  58. package/src/sdkFactory/index.ts +3 -2
  59. package/src/sdkFactory/types.ts +4 -4
  60. package/src/sdkManager/index.ts +5 -5
  61. package/src/services/splitApi.ts +1 -0
  62. package/src/storages/dataLoader.ts +2 -2
  63. package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +1 -1
  64. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +2 -2
  65. package/src/storages/inLocalStorage/index.ts +3 -2
  66. package/src/storages/inMemory/EventsCacheInMemory.ts +4 -4
  67. package/src/storages/inRedis/EventsCacheInRedis.ts +4 -4
  68. package/src/storages/inRedis/ImpressionsCacheInRedis.ts +1 -1
  69. package/src/storages/inRedis/RedisAdapter.ts +1 -1
  70. package/src/storages/inRedis/SegmentsCacheInRedis.ts +1 -1
  71. package/src/storages/inRedis/SplitsCacheInRedis.ts +1 -1
  72. package/src/storages/inRedis/TelemetryCacheInRedis.ts +1 -1
  73. package/src/storages/inRedis/index.ts +3 -2
  74. package/src/storages/pluggable/EventsCachePluggable.ts +4 -4
  75. package/src/storages/pluggable/ImpressionsCachePluggable.ts +1 -1
  76. package/src/storages/pluggable/SegmentsCachePluggable.ts +1 -1
  77. package/src/storages/pluggable/SplitsCachePluggable.ts +1 -1
  78. package/src/storages/pluggable/TelemetryCachePluggable.ts +1 -1
  79. package/src/storages/pluggable/index.ts +3 -3
  80. package/src/storages/pluggable/wrapperAdapter.ts +1 -1
  81. package/src/storages/types.ts +42 -18
  82. package/src/sync/offline/LocalhostFromObject.ts +4 -4
  83. package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +8 -8
  84. package/src/sync/polling/updaters/mySegmentsUpdater.ts +1 -1
  85. package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
  86. package/src/sync/polling/updaters/splitChangesUpdater.ts +1 -1
  87. package/src/sync/streaming/SSEHandler/index.ts +1 -1
  88. package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
  89. package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +1 -1
  90. package/src/sync/submitters/submitter.ts +1 -1
  91. package/src/sync/submitters/types.ts +2 -2
  92. package/src/sync/syncTask.ts +1 -1
  93. package/src/trackers/eventTracker.ts +3 -3
  94. package/src/trackers/impressionsTracker.ts +3 -3
  95. package/src/trackers/types.ts +4 -4
  96. package/src/{splitio.d.ts → types.d.ts} +826 -782
  97. package/src/utils/constants/index.ts +1 -1
  98. package/src/utils/inputValidation/apiKey.ts +1 -1
  99. package/src/utils/inputValidation/attribute.ts +1 -1
  100. package/src/utils/inputValidation/attributes.ts +3 -3
  101. package/src/utils/inputValidation/event.ts +1 -1
  102. package/src/utils/inputValidation/eventProperties.ts +3 -3
  103. package/src/utils/inputValidation/eventValue.ts +1 -1
  104. package/src/utils/inputValidation/isOperational.ts +1 -1
  105. package/src/utils/inputValidation/key.ts +3 -3
  106. package/src/utils/inputValidation/preloadedData.ts +3 -3
  107. package/src/utils/inputValidation/split.ts +1 -1
  108. package/src/utils/inputValidation/splitExistance.ts +1 -1
  109. package/src/utils/inputValidation/splits.ts +1 -1
  110. package/src/utils/inputValidation/trafficType.ts +1 -1
  111. package/src/utils/inputValidation/trafficTypeExistance.ts +1 -1
  112. package/src/utils/key/index.ts +9 -9
  113. package/src/utils/settingsValidation/consent.ts +1 -2
  114. package/src/utils/settingsValidation/impressionsMode.ts +3 -3
  115. package/src/utils/settingsValidation/index.ts +1 -0
  116. package/src/utils/settingsValidation/integrations/common.ts +1 -1
  117. package/src/utils/settingsValidation/integrations/configurable.ts +1 -1
  118. package/src/utils/settingsValidation/integrations/pluggable.ts +1 -2
  119. package/src/utils/settingsValidation/localhost/builtin.ts +1 -2
  120. package/src/utils/settingsValidation/localhost/pluggable.ts +1 -2
  121. package/src/utils/settingsValidation/logger/builtinLogger.ts +1 -2
  122. package/src/utils/settingsValidation/logger/pluggableLogger.ts +1 -2
  123. package/src/utils/settingsValidation/splitFilters.ts +7 -9
  124. package/src/utils/settingsValidation/storage/storageCS.ts +1 -2
  125. package/types/consent/sdkUserConsent.d.ts +2 -9
  126. package/types/dtos/types.d.ts +0 -6
  127. package/types/evaluator/Engine.d.ts +3 -3
  128. package/types/evaluator/combiners/and.d.ts +1 -1
  129. package/types/evaluator/combiners/ifelseif.d.ts +1 -1
  130. package/types/evaluator/condition/engineUtils.d.ts +1 -1
  131. package/types/evaluator/condition/index.d.ts +1 -1
  132. package/types/evaluator/index.d.ts +4 -4
  133. package/types/evaluator/matchers/all.d.ts +1 -1
  134. package/types/evaluator/matchers/between.d.ts +1 -1
  135. package/types/evaluator/matchers/boolean.d.ts +1 -1
  136. package/types/evaluator/matchers/cont_all.d.ts +1 -1
  137. package/types/evaluator/matchers/cont_any.d.ts +1 -1
  138. package/types/evaluator/matchers/cont_str.d.ts +1 -1
  139. package/types/evaluator/matchers/dependency.d.ts +1 -1
  140. package/types/evaluator/matchers/eq.d.ts +1 -1
  141. package/types/evaluator/matchers/eq_set.d.ts +1 -1
  142. package/types/evaluator/matchers/ew.d.ts +1 -1
  143. package/types/evaluator/matchers/gte.d.ts +1 -1
  144. package/types/evaluator/matchers/index.d.ts +1 -1
  145. package/types/evaluator/matchers/lte.d.ts +1 -1
  146. package/types/evaluator/matchers/part_of.d.ts +1 -1
  147. package/types/evaluator/matchers/segment.d.ts +1 -1
  148. package/types/evaluator/matchers/string.d.ts +1 -1
  149. package/types/evaluator/matchers/sw.d.ts +1 -1
  150. package/types/evaluator/matchers/whitelist.d.ts +1 -1
  151. package/types/evaluator/parser/index.d.ts +1 -1
  152. package/types/evaluator/types.d.ts +6 -6
  153. package/types/evaluator/value/index.d.ts +3 -3
  154. package/types/evaluator/value/sanitize.d.ts +3 -3
  155. package/types/integrations/ga/GaToSplit.d.ts +4 -4
  156. package/types/integrations/ga/SplitToGa.d.ts +4 -4
  157. package/types/integrations/ga/types.d.ts +4 -4
  158. package/types/integrations/types.d.ts +2 -2
  159. package/types/logger/browser/{debugLogger.d.ts → DebugLogger.d.ts} +0 -0
  160. package/types/logger/browser/{errorLogger.d.ts → ErrorLogger.d.ts} +0 -0
  161. package/types/logger/browser/{infoLogger.d.ts → InfoLogger.d.ts} +0 -0
  162. package/types/logger/browser/{warnLogger.d.ts → WarnLogger.d.ts} +0 -0
  163. package/types/logger/index.d.ts +3 -5
  164. package/types/logger/sdkLogger.d.ts +1 -2
  165. package/types/logger/types.d.ts +0 -11
  166. package/types/readiness/sdkReadinessManager.d.ts +1 -1
  167. package/types/readiness/types.d.ts +2 -8
  168. package/types/sdkClient/client.d.ts +2 -2
  169. package/types/sdkClient/clientAttributesDecoration.d.ts +8 -8
  170. package/types/sdkClient/clientCS.d.ts +2 -3
  171. package/types/sdkClient/clientInputValidation.d.ts +2 -2
  172. package/types/sdkClient/sdkClient.d.ts +2 -2
  173. package/types/sdkClient/sdkClientMethod.d.ts +2 -2
  174. package/types/sdkClient/sdkClientMethodCS.d.ts +2 -2
  175. package/types/sdkClient/sdkClientMethodCSWithTT.d.ts +2 -2
  176. package/types/sdkFactory/index.d.ts +2 -2
  177. package/types/sdkFactory/types.d.ts +6 -6
  178. package/types/sdkManager/index.d.ts +3 -3
  179. package/types/storages/dataLoader.d.ts +2 -2
  180. package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +1 -1
  181. package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +1 -2
  182. package/types/storages/inLocalStorage/index.d.ts +2 -2
  183. package/types/storages/inMemory/EventsCacheInMemory.d.ts +3 -3
  184. package/types/storages/inMemory/InMemoryStorage.d.ts +1 -1
  185. package/types/storages/inMemory/InMemoryStorageCS.d.ts +1 -1
  186. package/types/storages/inRedis/EventsCacheInRedis.d.ts +3 -3
  187. package/types/storages/inRedis/ImpressionsCacheInRedis.d.ts +1 -1
  188. package/types/storages/inRedis/RedisAdapter.d.ts +1 -1
  189. package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +1 -1
  190. package/types/storages/inRedis/SplitsCacheInRedis.d.ts +1 -1
  191. package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +1 -1
  192. package/types/storages/inRedis/index.d.ts +2 -2
  193. package/types/storages/pluggable/EventsCachePluggable.d.ts +3 -3
  194. package/types/storages/pluggable/ImpressionsCachePluggable.d.ts +1 -1
  195. package/types/storages/pluggable/SegmentsCachePluggable.d.ts +1 -1
  196. package/types/storages/pluggable/SplitsCachePluggable.d.ts +1 -1
  197. package/types/storages/pluggable/TelemetryCachePluggable.d.ts +1 -1
  198. package/types/storages/pluggable/index.d.ts +3 -2
  199. package/types/storages/pluggable/wrapperAdapter.d.ts +1 -1
  200. package/types/storages/types.d.ts +42 -16
  201. package/types/sync/offline/LocalhostFromObject.d.ts +2 -2
  202. package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +1 -1
  203. package/types/sync/polling/updaters/segmentChangesUpdater.d.ts +1 -1
  204. package/types/sync/polling/updaters/splitChangesUpdater.d.ts +1 -1
  205. package/types/sync/streaming/SSEHandler/index.d.ts +1 -1
  206. package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +1 -1
  207. package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +1 -1
  208. package/types/sync/submitters/submitter.d.ts +1 -1
  209. package/types/sync/submitters/types.d.ts +2 -2
  210. package/types/sync/syncTask.d.ts +1 -1
  211. package/types/trackers/types.d.ts +4 -4
  212. package/types/utils/constants/index.d.ts +1 -1
  213. package/types/utils/inputValidation/apiKey.d.ts +1 -1
  214. package/types/utils/inputValidation/attribute.d.ts +1 -1
  215. package/types/utils/inputValidation/attributes.d.ts +3 -3
  216. package/types/utils/inputValidation/event.d.ts +1 -1
  217. package/types/utils/inputValidation/eventProperties.d.ts +3 -3
  218. package/types/utils/inputValidation/eventValue.d.ts +1 -1
  219. package/types/utils/inputValidation/isOperational.d.ts +1 -1
  220. package/types/utils/inputValidation/key.d.ts +3 -3
  221. package/types/utils/inputValidation/preloadedData.d.ts +3 -3
  222. package/types/utils/inputValidation/split.d.ts +1 -1
  223. package/types/utils/inputValidation/splitExistance.d.ts +1 -1
  224. package/types/utils/inputValidation/splits.d.ts +1 -1
  225. package/types/utils/inputValidation/trafficType.d.ts +1 -1
  226. package/types/utils/inputValidation/trafficTypeExistance.d.ts +1 -1
  227. package/types/utils/key/index.d.ts +4 -4
  228. package/types/utils/settingsValidation/consent.d.ts +1 -2
  229. package/types/utils/settingsValidation/impressionsMode.d.ts +3 -3
  230. package/types/utils/settingsValidation/integrations/common.d.ts +1 -1
  231. package/types/utils/settingsValidation/integrations/configurable.d.ts +1 -1
  232. package/types/utils/settingsValidation/integrations/pluggable.d.ts +1 -2
  233. package/types/utils/settingsValidation/localhost/builtin.d.ts +1 -2
  234. package/types/utils/settingsValidation/localhost/pluggable.d.ts +1 -2
  235. package/types/utils/settingsValidation/logger/builtinLogger.d.ts +1 -1
  236. package/types/utils/settingsValidation/logger/pluggableLogger.d.ts +1 -1
  237. package/types/utils/settingsValidation/splitFilters.d.ts +1 -2
  238. package/types/utils/settingsValidation/storage/storageCS.d.ts +2 -3
  239. package/cjs/types.js +0 -2
  240. package/esm/types.js +0 -1
  241. package/src/types.ts +0 -1263
  242. package/types/integrations/ga/GaToSplitPlugin.d.ts +0 -3
  243. package/types/integrations/ga/SplitToGaPlugin.d.ts +0 -4
  244. package/types/integrations/ga/autoRequire.d.ts +0 -4
  245. package/types/logger/codes.d.ts +0 -2
  246. package/types/logger/codesConstants.d.ts +0 -117
  247. package/types/logger/codesConstantsBrowser.d.ts +0 -2
  248. package/types/logger/codesConstantsNode.d.ts +0 -14
  249. package/types/logger/codesDebug.d.ts +0 -1
  250. package/types/logger/codesDebugBrowser.d.ts +0 -1
  251. package/types/logger/codesDebugNode.d.ts +0 -1
  252. package/types/logger/codesError.d.ts +0 -1
  253. package/types/logger/codesErrorNode.d.ts +0 -1
  254. package/types/logger/codesInfo.d.ts +0 -1
  255. package/types/logger/codesWarn.d.ts +0 -1
  256. package/types/logger/codesWarnNode.d.ts +0 -1
  257. package/types/logger/debugLogger.d.ts +0 -2
  258. package/types/logger/errorLogger.d.ts +0 -2
  259. package/types/logger/infoLogger.d.ts +0 -2
  260. package/types/logger/messages/debugBrowser.d.ts +0 -1
  261. package/types/logger/messages/debugNode.d.ts +0 -1
  262. package/types/logger/messages/errorNode.d.ts +0 -1
  263. package/types/logger/messages/warnNode.d.ts +0 -1
  264. package/types/logger/noopLogger.d.ts +0 -2
  265. package/types/logger/warnLogger.d.ts +0 -2
  266. package/types/sdkClient/types.d.ts +0 -18
  267. package/types/sdkFactory/userConsentProps.d.ts +0 -6
  268. package/types/sdkManager/sdkManagerMethod.d.ts +0 -6
  269. package/types/storages/getRegisteredSegments.d.ts +0 -10
  270. package/types/storages/inMemory/CountsCacheInMemory.d.ts +0 -20
  271. package/types/storages/inMemory/LatenciesCacheInMemory.d.ts +0 -20
  272. package/types/storages/inMemory/index.d.ts +0 -10
  273. package/types/storages/inRedis/CountsCacheInRedis.d.ts +0 -9
  274. package/types/storages/inRedis/LatenciesCacheInRedis.d.ts +0 -9
  275. package/types/storages/parseSegments.d.ts +0 -6
  276. package/types/sync/offline/LocalhostFromFile.d.ts +0 -2
  277. package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +0 -2
  278. package/types/sync/polling/syncTasks/splitsSyncTask.copy.d.ts +0 -35
  279. package/types/sync/polling/syncTasks/splitsSyncTask.morelikeoriginal.d.ts +0 -35
  280. package/types/sync/streaming/AuthClient/indexV1.d.ts +0 -12
  281. package/types/sync/streaming/AuthClient/indexV2.d.ts +0 -8
  282. package/types/sync/streaming/pushManagerCS.d.ts +0 -1
  283. package/types/sync/streaming/pushManagerNoUsers.d.ts +0 -13
  284. package/types/sync/streaming/pushManagerSS.d.ts +0 -1
  285. package/types/sync/submitters/eventsSyncTask.d.ts +0 -8
  286. package/types/sync/submitters/impressionCountsSyncTask.d.ts +0 -13
  287. package/types/sync/submitters/impressionsSyncTask.d.ts +0 -14
  288. package/types/sync/submitters/metricsSyncTask.d.ts +0 -12
  289. package/types/sync/submitters/submitterSyncTask.d.ts +0 -10
  290. package/types/sync/submitters/telemetrySyncTask.d.ts +0 -0
  291. package/types/sync/submitters/uniqueKeysSubmitter.d.ts +0 -13
  292. package/types/sync/syncManagerFromFile.d.ts +0 -2
  293. package/types/sync/syncManagerFromObject.d.ts +0 -2
  294. package/types/sync/syncManagerOffline.d.ts +0 -9
  295. package/types/sync/syncTaskComposite.d.ts +0 -5
  296. package/types/trackers/strategy/strategyDebug.d.ts +0 -9
  297. package/types/trackers/strategy/strategyNone.d.ts +0 -10
  298. package/types/trackers/strategy/strategyOptimized.d.ts +0 -11
  299. package/types/trackers/telemetryRecorder.d.ts +0 -0
  300. package/types/trackers/uniqueKeysTracker.d.ts +0 -13
  301. package/types/types.d.ts +0 -1261
  302. package/types/utils/EventEmitter.d.ts +0 -4
  303. package/types/utils/consent.d.ts +0 -2
  304. package/types/utils/lang/errors.d.ts +0 -10
  305. package/types/utils/murmur3/commons.d.ts +0 -12
  306. package/types/utils/settingsValidation/buildMetadata.d.ts +0 -3
  307. package/types/utils/settingsValidation/localhost/index.d.ts +0 -9
  308. package/types/utils/settingsValidation/logger.d.ts +0 -11
  309. package/types/utils/settingsValidation/runtime/browser.d.ts +0 -2
  310. package/types/utils/settingsValidation/runtime/node.d.ts +0 -2
  311. package/types/utils/settingsValidation/userConsent.d.ts +0 -5
  312. package/types/utils/timeTracker/index.d.ts +0 -1
@@ -4,489 +4,368 @@
4
4
  // Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
5
5
 
6
6
  /// <reference types="google.analytics" />
7
- import { RedisOptions } from 'ioredis';
8
7
 
9
8
  export as namespace SplitIO;
10
9
  export = SplitIO;
11
10
 
11
+ /****** Exposed namespace ******/
12
12
  /**
13
- * NodeJS.EventEmitter interface
14
- * @see {@link https://nodejs.org/api/events.html}
15
- */
16
- interface EventEmitter {
17
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
18
- on(event: string | symbol, listener: (...args: any[]) => void): this;
19
- once(event: string | symbol, listener: (...args: any[]) => void): this;
20
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
21
- off(event: string | symbol, listener: (...args: any[]) => void): this;
22
- removeAllListeners(event?: string | symbol): this;
23
- setMaxListeners(n: number): this;
24
- getMaxListeners(): number;
25
- listeners(event: string | symbol): Function[];
26
- rawListeners(event: string | symbol): Function[];
27
- emit(event: string | symbol, ...args: any[]): boolean;
28
- listenerCount(type: string | symbol): number;
29
- // Added in Node 6...
30
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
31
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
32
- eventNames(): Array<string | symbol>;
33
- }
34
- /**
35
- * @typedef {Object} EventConsts
36
- * @property {string} SDK_READY The ready event.
37
- * @property {string} SDK_READY_FROM_CACHE The ready event when fired with cached data.
38
- * @property {string} SDK_READY_TIMED_OUT The timeout event.
39
- * @property {string} SDK_UPDATE The update event.
40
- */
41
- type EventConsts = {
42
- SDK_READY: 'init::ready',
43
- SDK_READY_FROM_CACHE: 'init::cache-ready',
44
- SDK_READY_TIMED_OUT: 'init::timeout',
45
- SDK_UPDATE: 'state::update'
46
- };
47
- /**
48
- * SDK Modes.
49
- * @typedef {string} SDKMode
50
- */
51
- type SDKMode = 'standalone' | 'consumer';
52
- /**
53
- * Storage types.
54
- * @typedef {string} StorageType
55
- */
56
- type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS';
57
- /**
58
- * Settings interface. This is a representation of the settings the SDK expose, that's why
59
- * most of it's props are readonly. Only features should be rewritten when localhost mode is active.
60
- * @interface ISettings
61
- */
62
- interface ISettings {
63
- readonly core: {
64
- authorizationKey: string,
65
- key: SplitIO.SplitKey,
66
- trafficType: string,
67
- labelsEnabled: boolean,
68
- IPAddressesEnabled: boolean
69
- },
70
- readonly mode: SDKMode,
71
- readonly scheduler: {
72
- featuresRefreshRate: number,
73
- impressionsRefreshRate: number,
74
- impressionsQueueSize: number,
75
- /**
76
- * @deprecated
77
- */
78
- metricsRefreshRate?: number,
79
- telemetryRefreshRate: number,
80
- segmentsRefreshRate: number,
81
- offlineRefreshRate: number,
82
- eventsPushRate: number,
83
- eventsQueueSize: number,
84
- pushRetryBackoffBase: number
85
- },
86
- readonly startup: {
87
- readyTimeout: number,
88
- requestTimeoutBeforeReady: number,
89
- retriesOnFailureBeforeReady: number,
90
- eventsFirstPushWindow: number
91
- },
92
- readonly storage: {
93
- prefix: string,
94
- options: Object,
95
- type: StorageType
96
- },
97
- readonly urls: {
98
- events: string,
99
- sdk: string,
100
- auth: string,
101
- streaming: string,
102
- telemetry: string
103
- },
104
- readonly debug: boolean | LogLevel,
105
- readonly version: string,
106
- /**
107
- * Mocked features map if using in browser, or mocked features file path string if using in NodeJS.
108
- */
109
- features: SplitIO.MockedFeaturesMap | SplitIO.MockedFeaturesFilePath,
110
- readonly streamingEnabled: boolean,
111
- readonly sync: {
112
- splitFilters: SplitIO.SplitFilter[],
113
- impressionsMode: SplitIO.ImpressionsMode,
114
- enabled: boolean
115
- }
116
- /**
117
- * User consent status if using in browser. Undefined if using in NodeJS.
118
- */
119
- readonly userConsent?: SplitIO.ConsentStatus
120
- }
121
- /**
122
- * Log levels.
123
- * @typedef {string} LogLevel
124
- */
125
- type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'NONE';
126
- /**
127
- * Logger API
128
- * @interface ILoggerAPI
13
+ * Types and interfaces for @splitsoftware/splitio package for usage when integrating javascript sdk on typescript apps.
14
+ * For the SDK package information
15
+ * @see {@link https://www.npmjs.com/package/@splitsoftware/splitio}
129
16
  */
130
- interface ILoggerAPI {
131
- /**
132
- * Enables SDK logging to the console.
133
- * @function enable
134
- * @returns {void}
135
- */
136
- enable(): void,
137
- /**
138
- * Disables SDK logging.
139
- * @function disable
140
- * @returns {void}
141
- */
142
- disable(): void,
143
- /**
144
- * Sets a log level for the SDK logs.
145
- * @function setLogLevel
146
- * @returns {void}
147
- */
148
- setLogLevel(logLevel: LogLevel): void,
17
+ declare namespace SplitIO {
149
18
  /**
150
- * Log level constants. Use this to pass them to setLogLevel function.
151
- */
152
- LogLevel: {
153
- [level in LogLevel]: LogLevel
19
+ * Reduced version of NodeJS.EventEmitter interface with the minimal methods used by the SDK
20
+ * @see {@link https://nodejs.org/api/events.html}
21
+ */
22
+ interface IEventEmitter {
23
+ addListener(event: string, listener: (...args: any[]) => void): this
24
+ on(event: string, listener: (...args: any[]) => void): this
25
+ once(event: string, listener: (...args: any[]) => void): this
26
+ removeListener(event: string, listener: (...args: any[]) => void): this
27
+ off(event: string, listener: (...args: any[]) => void): this
28
+ removeAllListeners(event?: string): this
29
+ emit(event: string, ...args: any[]): boolean
154
30
  }
155
- }
156
- /**
157
- * User consent API
158
- * @interface IUserConsentAPI
159
- */
160
- interface IUserConsentAPI {
161
- /**
162
- * Set or update the user consent status. Possible values are `true` and `false`, which represent user consent `'GRANTED'` and `'DECLINED'` respectively.
163
- * - `true ('GRANTED')`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud.
164
- * - `false ('DECLINED')`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud.
165
- *
166
- * NOTE: calling this method updates the user consent at a factory level, affecting all clients of the same factory.
167
- *
168
- * @function setStatus
169
- * @param {boolean} userConsent The user consent status, true for 'GRANTED' and false for 'DECLINED'.
170
- * @returns {boolean} Whether the provided param is a valid value (i.e., a boolean value) or not.
171
- */
172
- setStatus(userConsent: boolean): boolean;
173
31
  /**
174
- * Get the user consent status.
175
- *
176
- * @function getStatus
177
- * @returns {ConsentStatus} The user consent status.
178
- */
179
- getStatus(): SplitIO.ConsentStatus;
32
+ * NodeJS.EventEmitter interface
33
+ * @see {@link https://nodejs.org/api/events.html}
34
+ */
35
+ interface EventEmitter extends IEventEmitter {
36
+ addListener(event: string, listener: (...args: any[]) => void): this;
37
+ on(event: string, listener: (...args: any[]) => void): this;
38
+ once(event: string, listener: (...args: any[]) => void): this;
39
+ removeListener(event: string, listener: (...args: any[]) => void): this;
40
+ off(event: string, listener: (...args: any[]) => void): this;
41
+ removeAllListeners(event?: string): this;
42
+ setMaxListeners(n: number): this;
43
+ getMaxListeners(): number;
44
+ listeners(event: string): Function[];
45
+ rawListeners(event: string): Function[];
46
+ emit(event: string, ...args: any[]): boolean;
47
+ listenerCount(type: string): number;
48
+ // Added in Node 6...
49
+ prependListener(event: string, listener: (...args: any[]) => void): this;
50
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
51
+ eventNames(): Array<string | symbol>;
52
+ }
53
+
180
54
  /**
181
- * Consent status constants. Use this to compare with the getStatus function result.
55
+ * impression DTO generated by the Sdk client when processing evaluations
182
56
  */
183
- Status: {
184
- [status in SplitIO.ConsentStatus]: SplitIO.ConsentStatus
57
+ type ImpressionDTO = {
58
+ feature: string,
59
+ keyName: string,
60
+ treatment: string,
61
+ time: number,
62
+ bucketingKey?: string,
63
+ label: string,
64
+ changeNumber: number,
65
+ pt?: number,
185
66
  }
186
- }
187
- /**
188
- * Common settings between Browser and NodeJS settings interface.
189
- * @interface ISharedSettings
190
- */
191
- interface ISharedSettings {
192
67
  /**
193
- * Whether the logger should be enabled or disabled by default.
194
- * @property {Boolean} debug
195
- * @default false
196
- */
197
- debug?: boolean | LogLevel,
68
+ * @typedef {Object} EventConsts
69
+ * @property {string} SDK_READY The ready event.
70
+ * @property {string} SDK_READY_FROM_CACHE The ready event when fired with cached data.
71
+ * @property {string} SDK_READY_TIMED_OUT The timeout event.
72
+ * @property {string} SDK_UPDATE The update event.
73
+ */
74
+ type EventConsts = {
75
+ SDK_READY: 'init::ready',
76
+ SDK_READY_FROM_CACHE: 'init::cache-ready',
77
+ SDK_READY_TIMED_OUT: 'init::timeout',
78
+ SDK_UPDATE: 'state::update'
79
+ };
198
80
  /**
199
- * The impression listener, which is optional. Whatever you provide here needs to comply with the SplitIO.IImpressionListener interface,
200
- * which will check for the logImpression method.
201
- * @property {IImpressionListener} impressionListener
202
- * @default undefined
81
+ * SDK Modes.
82
+ * @typedef {string} SDKMode
203
83
  */
204
- impressionListener?: SplitIO.IImpressionListener,
84
+ type SDKMode = 'standalone' | 'localhost' | 'consumer' | 'consumer_partial';
205
85
  /**
206
- * Boolean flag to enable the streaming service as default synchronization mechanism. In the event of any issue with streaming,
207
- * the SDK would fallback to the polling mechanism. If false, the SDK would poll for changes as usual without attempting to use streaming.
208
- * @property {boolean} streamingEnabled
209
- * @default true
86
+ * Storage types.
87
+ * @typedef {string} StorageType
210
88
  */
211
- streamingEnabled?: boolean,
89
+ type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS' | 'PLUGGABLE';
212
90
  /**
213
- * SDK synchronization settings.
214
- * @property {Object} sync
91
+ * Settings interface. This is a representation of the settings the SDK expose, that's why
92
+ * most of it's props are readonly. Only features should be rewritten when localhost mode is active.
93
+ * @interface ISettings
215
94
  */
216
- sync?: {
217
- /**
218
- * List of Split filters. These filters are used to fetch a subset of the Splits definitions in your environment, in order to reduce the delay of the SDK to be ready.
219
- * This configuration is only meaningful when the SDK is working in "standalone" mode.
220
- *
221
- * At the moment, two types of split filters are supported: by name and by prefix.
222
- *
223
- * Example:
224
- * `splitFilter: [
225
- * { type: 'byName', values: ['my_split_1', 'my_split_2'] }, // will fetch splits named 'my_split_1' and 'my_split_2'
226
- * { type: 'byPrefix', values: ['testing'] } // will fetch splits whose names start with 'testing__' prefix
227
- * ]`
228
- * @property {SplitIO.SplitFilter[]} splitFilters
229
- */
230
- splitFilters?: SplitIO.SplitFilter[]
231
- /**
232
- * Impressions Collection Mode. Option to determine how impressions are going to be sent to Split Servers.
233
- * Possible values are 'DEBUG' and 'OPTIMIZED'.
234
- * - DEBUG: will send all the impressions generated (recommended only for debugging purposes).
235
- * - OPTIMIZED: will send unique impressions to Split Servers avoiding a considerable amount of traffic that duplicated impressions could generate.
236
- * @property {string} impressionsMode
237
- * @default 'OPTIMIZED'
238
- */
239
- impressionsMode?: SplitIO.ImpressionsMode,
95
+ interface ISettings {
96
+ readonly core: {
97
+ authorizationKey: string,
98
+ key?: SplitKey,
99
+ trafficType?: string,
100
+ labelsEnabled: boolean,
101
+ IPAddressesEnabled?: boolean
102
+ },
103
+ readonly mode: SDKMode,
104
+ readonly scheduler: {
105
+ featuresRefreshRate: number,
106
+ impressionsRefreshRate: number,
107
+ impressionsQueueSize: number,
108
+ /**
109
+ * @deprecated
110
+ */
111
+ metricsRefreshRate?: number,
112
+ telemetryRefreshRate: number,
113
+ segmentsRefreshRate: number,
114
+ offlineRefreshRate: number,
115
+ eventsPushRate: number,
116
+ eventsQueueSize: number,
117
+ pushRetryBackoffBase: number
118
+ },
119
+ readonly startup: {
120
+ readyTimeout: number,
121
+ requestTimeoutBeforeReady: number,
122
+ retriesOnFailureBeforeReady: number,
123
+ eventsFirstPushWindow: number
124
+ },
125
+ readonly storage: {
126
+ prefix: string,
127
+ options: Object,
128
+ type: StorageType
129
+ } | StorageSyncFactory | StorageAsyncFactory,
130
+ readonly urls: {
131
+ events: string,
132
+ sdk: string,
133
+ auth: string,
134
+ streaming: string,
135
+ telemetry: string
136
+ },
137
+ readonly integrations?: BrowserIntegration[] | IntegrationFactory[],
138
+ readonly debug: boolean | LogLevel | ILogger,
139
+ readonly version: string,
140
+ /**
141
+ * Mocked features map.
142
+ */
143
+ features?: MockedFeaturesMap | MockedFeaturesFilePath,
144
+ readonly streamingEnabled: boolean,
145
+ readonly sync: {
146
+ splitFilters: SplitFilter[],
147
+ impressionsMode: ImpressionsMode,
148
+ enabled: boolean,
149
+ localhostMode?: LocalhostFactory,
150
+ __splitFiltersValidation: ISplitFiltersValidation,
151
+ },
152
+ readonly runtime: {
153
+ ip: string | false
154
+ hostname: string | false
155
+ },
156
+ readonly log: ILogger
157
+ readonly impressionListener?: unknown
240
158
  /**
241
- * Controls the SDK continuous synchronization flags.
242
- *
243
- * When `true` a running SDK will process rollout plan updates performed on the UI (default).
244
- * When false it'll just fetch all data upon init.
245
- *
246
- * @property {boolean} enabled
247
- * @default true
159
+ * User consent status if using in browser. Undefined if using in NodeJS.
248
160
  */
249
- enabled?: boolean
161
+ readonly userConsent?: ConsentStatus
250
162
  }
251
- }
252
- /**
253
- * Common settings interface for SDK instances on NodeJS.
254
- * @interface INodeBasicSettings
255
- * @extends ISharedSettings
256
- */
257
- interface INodeBasicSettings extends ISharedSettings {
258
163
  /**
259
- * SDK Startup settings for NodeJS.
260
- * @property {Object} startup
164
+ * Log levels.
165
+ * @typedef {string} LogLevel
261
166
  */
262
- startup?: {
167
+ type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'NONE';
168
+ /**
169
+ * Logger API
170
+ * @interface ILoggerAPI
171
+ */
172
+ interface ILoggerAPI {
263
173
  /**
264
- * Maximum amount of time used before notify a timeout.
265
- * @property {number} readyTimeout
266
- * @default 15
174
+ * Enables SDK logging to the console.
175
+ * @function enable
176
+ * @returns {void}
267
177
  */
268
- readyTimeout?: number,
178
+ enable(): void,
269
179
  /**
270
- * 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'.
271
- * @property {number} requestTimeoutBeforeReady
272
- * @default 15
180
+ * Disables SDK logging.
181
+ * @function disable
182
+ * @returns {void}
273
183
  */
274
- requestTimeoutBeforeReady?: number,
184
+ disable(): void,
275
185
  /**
276
- * How many quick retries we will do while starting up the SDK.
277
- * @property {number} retriesOnFailureBeforeReady
278
- * @default 1
186
+ * Sets a log level for the SDK logs.
187
+ * @function setLogLevel
188
+ * @returns {void}
279
189
  */
280
- retriesOnFailureBeforeReady?: number,
190
+ setLogLevel(logLevel: LogLevel): void,
281
191
  /**
282
- * For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
283
- * to better control on browsers. This number defines that window before the first events push.
284
- *
285
- * @property {number} eventsFirstPushWindow
286
- * @default 0
192
+ * Log level constants. Use this to pass them to setLogLevel function.
287
193
  */
288
- eventsFirstPushWindow?: number,
289
- },
194
+ LogLevel: {
195
+ [level in LogLevel]: LogLevel
196
+ }
197
+ }
290
198
  /**
291
- * SDK scheduler settings.
292
- * @property {Object} scheduler
199
+ * User consent API
200
+ * @interface IUserConsentAPI
293
201
  */
294
- scheduler?: {
295
- /**
296
- * The SDK polls Split servers for changes to feature roll-out plans. This parameter controls this polling period in seconds.
297
- * @property {number} featuresRefreshRate
298
- * @default 5
299
- */
300
- featuresRefreshRate?: number,
202
+ interface IUserConsentAPI {
301
203
  /**
302
- * 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.
303
- * @property {number} impressionsRefreshRate
304
- * @default 300
204
+ * Set or update the user consent status. Possible values are `true` and `false`, which represent user consent `'GRANTED'` and `'DECLINED'` respectively.
205
+ * - `true ('GRANTED')`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud.
206
+ * - `false ('DECLINED')`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud.
207
+ *
208
+ * NOTE: calling this method updates the user consent at a factory level, affecting all clients of the same factory.
209
+ *
210
+ * @function setStatus
211
+ * @param {boolean} userConsent The user consent status, true for 'GRANTED' and false for 'DECLINED'.
212
+ * @returns {boolean} Whether the provided param is a valid value (i.e., a boolean value) or not.
305
213
  */
306
- impressionsRefreshRate?: number,
214
+ setStatus(userConsent: boolean): boolean;
307
215
  /**
308
- * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
309
- * If you use a 0 here, the queue will have no maximum size.
310
- * @property {number} impressionsQueueSize
311
- * @default 30000
216
+ * Get the user consent status.
217
+ *
218
+ * @function getStatus
219
+ * @returns {ConsentStatus} The user consent status.
312
220
  */
313
- impressionsQueueSize?: number,
221
+ getStatus(): ConsentStatus;
314
222
  /**
315
- * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
316
- * @property {number} metricsRefreshRate
317
- * @default 120
318
- * @deprecated This parameter is ignored now. Use `telemetryRefreshRate` instead.
223
+ * Consent status constants. Use this to compare with the getStatus function result.
319
224
  */
320
- metricsRefreshRate?: number,
225
+ Status: {
226
+ [status in ConsentStatus]: ConsentStatus
227
+ }
228
+ }
229
+ /**
230
+ * Common settings between Browser and NodeJS settings interface.
231
+ * @interface ISharedSettings
232
+ */
233
+ interface ISharedSettings {
321
234
  /**
322
- * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
323
- * @property {number} telemetryRefreshRate
324
- * @default 3600
235
+ * SDK Core settings.
236
+ * @property {Object} core
325
237
  */
326
- telemetryRefreshRate?: number,
238
+ core: {
239
+ /**
240
+ * Your API key. More information: @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
241
+ * @property {string} authorizationKey
242
+ */
243
+ authorizationKey: string,
244
+ /**
245
+ * Disable labels from being sent to Split backend. Labels may contain sensitive information.
246
+ * This configuration is applicable if the SDK is running in "standalone" or "partial consumer" mode.
247
+ * @property {boolean} labelsEnabled
248
+ * @default true
249
+ */
250
+ labelsEnabled?: boolean
251
+ },
327
252
  /**
328
- * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
329
- * @property {number} segmentsRefreshRate
330
- * @default 60
253
+ * The SDK mode. Possible values are "standalone", which is the default when using a synchronous storage, like 'MEMORY' and 'LOCALSTORAGE',
254
+ * and "consumer", which must be set when using an asynchronous storage, like 'REDIS'. For "localhost" mode, use "localhost" as authorizationKey.
255
+ * @property {SDKMode} mode
256
+ * @default standalone
331
257
  */
332
- segmentsRefreshRate?: number,
258
+ mode?: SDKMode,
333
259
  /**
334
- * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
335
- * @property {number} eventsPushRate
336
- * @default 60
260
+ * The impression listener, which is optional. Whatever you provide here needs to comply with the IImpressionListener interface,
261
+ * which will check for the logImpression method.
262
+ * @property {IImpressionListener} impressionListener
263
+ * @default undefined
337
264
  */
338
- eventsPushRate?: number,
265
+ impressionListener?: IImpressionListener,
339
266
  /**
340
- * The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
341
- * If you use a 0 here, the queue will have no maximum size.
342
- * @property {number} eventsQueueSize
343
- * @default 500
267
+ * Boolean flag to enable the streaming service as default synchronization mechanism. In the event of any issue with streaming,
268
+ * the SDK would fallback to the polling mechanism. If false, the SDK would poll for changes as usual without attempting to use streaming.
269
+ * This configuration is applicable if the SDK is running in "standalone" mode.
270
+ * @property {boolean} streamingEnabled
271
+ * @default true
344
272
  */
345
- eventsQueueSize?: number,
273
+ streamingEnabled?: boolean,
346
274
  /**
347
- * For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
348
- * For more information @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
349
- * @property {number} offlineRefreshRate
350
- * @default 15
275
+ * SDK synchronization settings.
276
+ * @property {Object} sync
351
277
  */
352
- offlineRefreshRate?: number
278
+ sync?: {
279
+ /**
280
+ * List of Split filters. These filters are used to fetch a subset of the Splits definitions in your environment, in order to reduce the delay of the SDK to be ready.
281
+ * This configuration is applicable if the SDK is running in "standalone" mode.
282
+ *
283
+ * At the moment, two types of split filters are supported: by name and by prefix.
284
+ *
285
+ * Example:
286
+ * `splitFilter: [
287
+ * { type: 'byName', values: ['my_split_1', 'my_split_2'] }, // will fetch splits named 'my_split_1' and 'my_split_2'
288
+ * { type: 'byPrefix', values: ['testing'] } // will fetch splits whose names start with 'testing__' prefix
289
+ * ]`
290
+ * @property {SplitFilter[]} splitFilters
291
+ */
292
+ splitFilters?: SplitFilter[]
293
+ /**
294
+ * Impressions Collection Mode. Option to determine how impressions are going to be sent to Split Servers.
295
+ * Possible values are 'DEBUG' and 'OPTIMIZED'.
296
+ * - DEBUG: will send all the impressions generated (recommended only for debugging purposes).
297
+ * - OPTIMIZED: will send unique impressions to Split Servers avoiding a considerable amount of traffic that duplicated impressions could generate.
298
+ * @property {string} impressionsMode
299
+ * @default 'OPTIMIZED'
300
+ */
301
+ impressionsMode?: ImpressionsMode,
302
+ /**
303
+ * Controls the SDK continuous synchronization flags.
304
+ *
305
+ * When `true` a running SDK will process rollout plan updates performed on the UI (default).
306
+ * When false it'll just fetch all data upon init.
307
+ * This configuration is applicable if the SDK is running in "standalone" mode.
308
+ *
309
+ * @property {boolean} enabled
310
+ * @default true
311
+ */
312
+ enabled?: boolean
313
+ },
353
314
  /**
354
- * When using streaming mode, seconds to wait before re attempting to connect for push notifications.
355
- * Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
356
- * @property {number} pushRetryBackoffBase
357
- * @default 1
315
+ * List of URLs that the SDK will use as base for it's synchronization functionalities.
316
+ * This configuration is applicable if the SDK is running in "standalone" or "partial consumer" mode.
317
+ * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
318
+ * @property {Object} urls
358
319
  */
359
- pushRetryBackoffBase?: number,
360
- },
320
+ urls?: UrlSettings,
321
+ }
322
+ // @TODO Should extends IEventEmitter for React Native and JS Browser SDK
361
323
  /**
362
- * SDK Core settings for NodeJS.
363
- * @property {Object} core
324
+ * Common API for entities that expose status handlers.
325
+ * @interface IStatusInterface
326
+ * @extends IEventEmitter
364
327
  */
365
- core: {
366
- /**
367
- * Your API key. More information: @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
368
- * @property {string} authorizationKey
369
- */
370
- authorizationKey: string,
328
+ interface IStatusInterface extends IEventEmitter {
371
329
  /**
372
- * Disable labels from being sent to Split backend. Labels may contain sensitive information.
373
- * @property {boolean} labelsEnabled
374
- * @default true
330
+ * Constant object containing the SDK events for you to use.
331
+ * @property {EventConsts} Event
375
332
  */
376
- labelsEnabled?: boolean
333
+ Event: EventConsts,
377
334
  /**
378
- * Disable machine IP and Name from being sent to Split backend.
379
- * @property {boolean} IPAddressesEnabled
380
- * @default true
335
+ * Returns a promise that will be resolved once the SDK has finished loading (SDK_READY event emitted) or rejected if the SDK has timedout (SDK_READY_TIMED_OUT event emitted).
336
+ * As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, calling the `ready` method after the
337
+ * SDK had timed out will return a new promise that should eventually resolve if the SDK gets ready.
338
+ *
339
+ * 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.
340
+ * However, when using async/await syntax, the rejection should be explicitly propagated like in the following example:
341
+ * ```
342
+ * try {
343
+ * await client.ready().catch((e) => { throw e; });
344
+ * // SDK is ready
345
+ * } catch(e) {
346
+ * // SDK has timedout
347
+ * }
348
+ * ```
349
+ *
350
+ * @function ready
351
+ * @returns {Promise<void>}
381
352
  */
382
- IPAddressesEnabled?: boolean
383
- },
353
+ ready(): Promise<void>
354
+ }
384
355
  /**
385
- * Defines which kind of storage we should instantiate.
386
- * @property {Object} storage
356
+ * Common definitions between clients for different environments interface.
357
+ * @interface IBasicClient
358
+ * @extends IStatusInterface
387
359
  */
388
- storage?: {
389
- /**
390
- * Storage type to be instantiated by the SDK.
391
- * @property {StorageType} type
392
- * @default MEMORY
393
- */
394
- type?: StorageType,
360
+ interface IBasicClient extends IStatusInterface {
395
361
  /**
396
- * Options to be passed to the selected storage.
397
- * @property {Object} options
362
+ * Destroy the client instance.
363
+ * @function destroy
364
+ * @returns {Promise<void>}
398
365
  */
399
- options?: Object,
400
- /**
401
- * Optional prefix to prevent any kind of data collision between SDK versions.
402
- * @property {string} prefix
403
- * @default SPLITIO
404
- */
405
- prefix?: string
406
- },
407
- /**
408
- * The SDK mode. Possible values are "standalone", which is the default when using a synchronous storage, like 'MEMORY' and 'LOCALSTORAGE',
409
- * and "consumer", which must be set when using an asynchronous storage, like 'REDIS'. For "localhost" mode, use "localhost" as authorizationKey.
410
- * @property {SDKMode} mode
411
- * @default standalone
412
- */
413
- mode?: SDKMode,
414
- /**
415
- * Mocked features file path. For testing purposses only. For using this you should specify "localhost" as authorizationKey on core settings.
416
- * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
417
- * @property {MockedFeaturesFilePath} features
418
- * @default $HOME/.split
419
- */
420
- features?: SplitIO.MockedFeaturesFilePath,
421
- }
422
- /**
423
- * Common API for entities that expose status handlers.
424
- * @interface IStatusInterface
425
- * @extends EventEmitter
426
- */
427
- interface IStatusInterface extends EventEmitter {
428
- /**
429
- * Constant object containing the SDK events for you to use.
430
- * @property {EventConsts} Event
431
- */
432
- Event: EventConsts,
433
- /**
434
- * Returns a promise that will be resolved once the SDK has finished loading (SDK_READY event emitted) or rejected if the SDK has timedout (SDK_READY_TIMED_OUT event emitted).
435
- * As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, calling the `ready` method after the
436
- * SDK had timed out will return a new promise that should eventually resolve if the SDK gets ready.
437
- *
438
- * 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.
439
- * However, when using async/await syntax, the rejection should be explicitly propagated like in the following example:
440
- * ```
441
- * try {
442
- * await client.ready().catch((e) => { throw e; });
443
- * // SDK is ready
444
- * } catch(e) {
445
- * // SDK has timedout
446
- * }
447
- * ```
448
- *
449
- * @function ready
450
- * @returns {Promise<void>}
451
- */
452
- ready(): Promise<void>
453
- }
454
- /**
455
- * Common definitions between clients for different environments interface.
456
- * @interface IBasicClient
457
- * @extends IStatusInterface
458
- */
459
- interface IBasicClient extends IStatusInterface {
460
- /**
461
- * Destroy the client instance.
462
- * @function destroy
463
- * @returns {Promise<void>}
464
- */
465
- destroy(): Promise<void>
466
- }
467
- /**
468
- * Common definitions between SDK instances for different environments interface.
469
- * @interface IBasicSDK
470
- */
471
- interface IBasicSDK {
472
- /**
473
- * Current settings of the SDK instance.
474
- * @property settings
475
- */
476
- settings: ISettings,
477
- /**
478
- * Logger API.
479
- * @property Logger
480
- */
481
- Logger: ILoggerAPI
482
- }
483
- /****** Exposed namespace ******/
484
- /**
485
- * Types and interfaces for @splitsoftware/splitio package for usage when integrating javascript sdk on typescript apps.
486
- * For the SDK package information
487
- * @see {@link https://www.npmjs.com/package/@splitsoftware/splitio}
488
- */
489
- declare namespace SplitIO {
366
+ destroy(): Promise<void>
367
+ }
368
+
490
369
  /**
491
370
  * Split treatment value, returned by getTreatment.
492
371
  * @typedef {string} Treatment
@@ -509,7 +388,7 @@ declare namespace SplitIO {
509
388
  [featureName: string]: Treatment
510
389
  };
511
390
  /**
512
- * Split treatments promise that will resolve to the actual SplitIO.Treatments object.
391
+ * Split treatments promise that will resolve to the actual Treatments object.
513
392
  * @typedef {Promise<Treatments>} AsyncTreatments
514
393
  */
515
394
  type AsyncTreatments = Promise<Treatments>;
@@ -541,7 +420,7 @@ declare namespace SplitIO {
541
420
  [featureName: string]: TreatmentWithConfig
542
421
  };
543
422
  /**
544
- * Split treatments promise that will resolve to the actual SplitIO.TreatmentsWithConfig object.
423
+ * Split treatments promise that will resolve to the actual TreatmentsWithConfig object.
545
424
  * @typedef {Promise<TreatmentsWithConfig>} AsyncTreatmentsWithConfig
546
425
  */
547
426
  type AsyncTreatmentsWithConfig = Promise<TreatmentsWithConfig>;
@@ -596,25 +475,21 @@ declare namespace SplitIO {
596
475
  type MockedFeaturesMap = {
597
476
  [featureName: string]: string | TreatmentWithConfig
598
477
  };
478
+ /**
479
+ * Localhost types.
480
+ * @typedef {string} LocalhostType
481
+ */
482
+ type LocalhostType = 'LocalhostFromObject'
599
483
  /**
600
484
  * Object with information about an impression. It contains the generated impression DTO as well as
601
485
  * complementary information around where and how it was generated in that way.
602
486
  * @typedef {Object} ImpressionData
603
487
  */
604
488
  type ImpressionData = {
605
- impression: {
606
- feature: string,
607
- keyName: string,
608
- treatment: string,
609
- time: number,
610
- bucketingKey?: string,
611
- label: string,
612
- changeNumber: number,
613
- pt?: number,
614
- },
615
- attributes?: SplitIO.Attributes,
616
- ip: string,
617
- hostname: string,
489
+ impression: ImpressionDTO,
490
+ attributes?: Attributes,
491
+ ip: string | false,
492
+ hostname: string | false,
618
493
  sdkLanguageVersion: string
619
494
  };
620
495
  /**
@@ -662,11 +537,11 @@ declare namespace SplitIO {
662
537
  */
663
538
  type SplitViewAsync = Promise<SplitView | null>;
664
539
  /**
665
- * An array containing the SplitIO.SplitView elements.
540
+ * An array containing the SplitView elements.
666
541
  */
667
542
  type SplitViews = Array<SplitView>;
668
543
  /**
669
- * A promise that will be resolved with an SplitIO.SplitViews array.
544
+ * A promise that will be resolved with an SplitViews array.
670
545
  * @typedef {Promise<SplitViews>} SplitViewsAsync
671
546
  */
672
547
  type SplitViewsAsync = Promise<SplitViews>;
@@ -695,6 +570,68 @@ declare namespace SplitIO {
695
570
  * @typedef {string} BrowserStorage
696
571
  */
697
572
  type BrowserStorage = 'MEMORY' | 'LOCALSTORAGE';
573
+ /**
574
+ * Storage for synchronous (standalone) SDK.
575
+ * Its interface details are not part of the public API.
576
+ */
577
+ type StorageSync = any;
578
+ /**
579
+ * Storage builder for synchronous (standalone) SDK.
580
+ * By returning undefined, the SDK will use the default IN MEMORY storage.
581
+ * Input parameter details are not part of the public API.
582
+ */
583
+ type StorageSyncFactory = {
584
+ readonly type: StorageType
585
+ (params: any): (StorageSync | undefined)
586
+ }
587
+ /**
588
+ * Configuration params for `InLocalStorage`
589
+ */
590
+ type InLocalStorageOptions = {
591
+ /**
592
+ * Optional prefix to prevent any kind of data collision when having multiple factories using the same storage type.
593
+ * @property {string} prefix
594
+ * @default SPLITIO
595
+ */
596
+ prefix?: string
597
+ }
598
+ /**
599
+ * Storage for asynchronous (consumer) SDK.
600
+ * Its interface details are not part of the public API.
601
+ */
602
+ type StorageAsync = any
603
+ /**
604
+ * Storage builder for asynchronous (consumer) SDK.
605
+ * Input parameter details are not part of the public API.
606
+ */
607
+ type StorageAsyncFactory = {
608
+ readonly type: StorageType
609
+ (params: any): StorageAsync
610
+ }
611
+ /**
612
+ * Configuration params for `PluggableStorage`
613
+ */
614
+ type PluggableStorageOptions = {
615
+ /**
616
+ * Optional prefix to prevent any kind of data collision when having multiple factories using the same storage wrapper.
617
+ * @property {string} prefix
618
+ * @default SPLITIO
619
+ */
620
+ prefix?: string,
621
+ /**
622
+ * Storage wrapper.
623
+ * @property {Object} wrapper
624
+ */
625
+ wrapper: Object
626
+ }
627
+ /**
628
+ * Localhost mode factory.
629
+ * Its interface details are not part of the public API.
630
+ */
631
+ type LocalhostFactory = {
632
+ readonly type: LocalhostType
633
+ (params: any): any
634
+ }
698
635
  /**
699
636
  * Impression listener interface. This is the interface that needs to be implemented
700
637
  * by the element you provide to the SDK as impression listener.
@@ -702,7 +639,21 @@ declare namespace SplitIO {
702
639
  * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#listener}
703
640
  */
704
641
  interface IImpressionListener {
705
- logImpression(data: SplitIO.ImpressionData): void
642
+ logImpression(data: ImpressionData): void
643
+ }
644
+ /**
645
+ * SDK integration instance.
646
+ * Its interface details are not part of the public API.
647
+ */
648
+ type Integration = any;
649
+ /**
650
+ * SDK integration factory.
651
+ * By returning an integration, the SDK will queue events and impressions into it.
652
+ * Input parameter details are not part of the public API.
653
+ */
654
+ type IntegrationFactory = {
655
+ readonly type: string
656
+ (params: any): (Integration | void)
706
657
  }
707
658
  /**
708
659
  * A pair of user key and it's trafficType, required for tracking valid Split events.
@@ -731,8 +682,15 @@ declare namespace SplitIO {
731
682
  *
732
683
  * @see {@link https://help.split.io/hc/en-us/articles/360040838752#google-analytics-to-split}
733
684
  */
734
- interface IGoogleAnalyticsToSplitConfig {
685
+ interface IGoogleAnalyticsToSplitConfig extends GoogleAnalyticsToSplitOptions {
735
686
  type: 'GOOGLE_ANALYTICS_TO_SPLIT',
687
+ }
688
+ /**
689
+ * Configuration params for 'Google Analytics to Split' integration plugin, to track Google Analytics hits as Split events.
690
+ *
691
+ * @see {@link https://help.split.io/hc/en-us/articles/360040838752#google-analytics-to-split}
692
+ */
693
+ interface GoogleAnalyticsToSplitOptions {
736
694
  /**
737
695
  * Optional flag to filter GA hits from being tracked as Split events.
738
696
  * @property {boolean} hits
@@ -759,7 +717,7 @@ declare namespace SplitIO {
759
717
  * return defaultMapping;
760
718
  * }`
761
719
  */
762
- mapper?: (model: UniversalAnalytics.Model, defaultMapping: SplitIO.EventData) => SplitIO.EventData,
720
+ mapper?: (model: UniversalAnalytics.Model, defaultMapping: EventData) => EventData,
763
721
  /**
764
722
  * Optional prefix for EventTypeId, to prevent any kind of data collision between events.
765
723
  * @property {string} prefix
@@ -768,7 +726,7 @@ declare namespace SplitIO {
768
726
  prefix?: string,
769
727
  /**
770
728
  * List of Split identities (key & traffic type pairs) used to track events.
771
- * If not provided, events are sent using the key and traffic type provided at SDK config
729
+ * If not provided, events are sent using the key and traffic type provided at SDK config.
772
730
  */
773
731
  identities?: Identity[],
774
732
  /**
@@ -789,14 +747,21 @@ declare namespace SplitIO {
789
747
  * @property {string} type The type of Split data, either 'IMPRESSION' or 'EVENT'.
790
748
  * @property {ImpressionData | EventData} payload The data instance itself.
791
749
  */
792
- type IntegrationData = { type: 'IMPRESSION', payload: SplitIO.ImpressionData } | { type: 'EVENT', payload: SplitIO.EventData };
750
+ type IntegrationData = { type: 'IMPRESSION', payload: ImpressionData } | { type: 'EVENT', payload: EventData };
793
751
  /**
794
752
  * Enable 'Split to Google Analytics' integration, to track Split impressions and events as Google Analytics hits.
795
753
  *
796
754
  * @see {@link https://help.split.io/hc/en-us/articles/360040838752#split-to-google-analytics}
797
755
  */
798
- interface ISplitToGoogleAnalyticsConfig {
756
+ interface ISplitToGoogleAnalyticsConfig extends SplitToGoogleAnalyticsOptions {
799
757
  type: 'SPLIT_TO_GOOGLE_ANALYTICS',
758
+ }
759
+ /**
760
+ * Configuration params for 'Split to Google Analytics' integration plugin, to track Split impressions and events as Google Analytics hits.
761
+ *
762
+ * @see {@link https://help.split.io/hc/en-us/articles/360040838752#split-to-google-analytics}
763
+ */
764
+ interface SplitToGoogleAnalyticsOptions {
800
765
  /**
801
766
  * Optional flag to filter Split impressions from being tracked as GA hits.
802
767
  * @property {boolean} impressions
@@ -814,7 +779,7 @@ declare namespace SplitIO {
814
779
  * For example, the following filter allows to track only impressions, equivalent to setting events to false:
815
780
  * `(data) => data.type === 'IMPRESSION'`
816
781
  */
817
- filter?: (data: SplitIO.IntegrationData) => boolean,
782
+ filter?: (data: IntegrationData) => boolean,
818
783
  /**
819
784
  * Optional function useful when you need to modify the GA hit before sending it.
820
785
  * This function is invoked with two arguments:
@@ -845,7 +810,7 @@ declare namespace SplitIO {
845
810
  * nonInteraction: true,
846
811
  * }`
847
812
  */
848
- mapper?: (data: SplitIO.IntegrationData, defaultMapping: UniversalAnalytics.FieldsObject) => UniversalAnalytics.FieldsObject,
813
+ mapper?: (data: IntegrationData, defaultMapping: UniversalAnalytics.FieldsObject) => UniversalAnalytics.FieldsObject,
849
814
  /**
850
815
  * List of tracker names to send the hit. An empty string represents the default tracker.
851
816
  * If not provided, hits are only sent to default tracker.
@@ -912,6 +877,11 @@ declare namespace SplitIO {
912
877
  */
913
878
  values: string[],
914
879
  }
880
+ type ISplitFiltersValidation = {
881
+ queryString: string | null,
882
+ groupedFilters: Record<SplitFilterType, string[]>,
883
+ validFilters: SplitFilter[]
884
+ };
915
885
  /**
916
886
  * ImpressionsMode type
917
887
  * @typedef {string} ImpressionsMode
@@ -923,31 +893,117 @@ declare namespace SplitIO {
923
893
  */
924
894
  type ConsentStatus = 'GRANTED' | 'DECLINED' | 'UNKNOWN';
925
895
  /**
926
- * Settings interface for SDK instances created on the browser
927
- * @interface IBrowserSettings
896
+ * Logger
897
+ * Its interface details are not part of the public API. It shouldn't be used directly.
898
+ * @interface ILogger
899
+ */
900
+ interface ILogger {
901
+ setLogLevel(logLevel: LogLevel): void
902
+ debug(msg: any): void
903
+ debug(msg: string | number, args?: any[]): void
904
+ info(msg: any): void
905
+ info(msg: string | number, args?: any[]): void
906
+ warn(msg: any): void
907
+ warn(msg: string | number, args?: any[]): void
908
+ error(msg: any): void
909
+ error(msg: string | number, args?: any[]): void
910
+ }
911
+ /**
912
+ * Common settings interface with non-pluggable API (JS SDK).
913
+ * @interface IStaticSettings
914
+ * @extends ISharedSettings
915
+ */
916
+ interface IStaticSettings {
917
+ /**
918
+ * Whether the logger should be enabled or disabled by default.
919
+ * @property {Boolean} debug
920
+ * @default false
921
+ */
922
+ debug?: boolean | LogLevel,
923
+ }
924
+ /**
925
+ * Common settings interface with pluggable API (JS Browser and React Native SDKs).
926
+ * @interface IPluggableSettings
927
+ * @extends ISharedSettings
928
+ */
929
+ interface IPluggableSettings {
930
+ /**
931
+ * Boolean value to indicate whether the logger should be enabled or disabled by default, or a log level string or a Logger object.
932
+ * Passing a logger object is required to get descriptive log messages. Otherwise most logs will print with message codes.
933
+ * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging}
934
+ *
935
+ * Examples:
936
+ * ```typescript
937
+ * config.debug = true
938
+ * config.debug = 'WARN'
939
+ * config.debug = ErrorLogger()
940
+ * ```
941
+ * @property {boolean | LogLevel | ILogger} debug
942
+ * @default false
943
+ */
944
+ debug?: boolean | LogLevel | ILogger,
945
+ /**
946
+ * Defines an optional list of factory functions used to instantiate SDK integrations.
947
+ *
948
+ * Example:
949
+ * ```typescript
950
+ * SplitFactory({
951
+ * ...
952
+ * integrations: [SplitToGoogleAnalytics(), GoogleAnalyticsToSplit()]
953
+ * })
954
+ * ```
955
+ * @property {Object} integrations
956
+ */
957
+ integrations?: IntegrationFactory[],
958
+ }
959
+ /**
960
+ * Common settings interface for SDK instances on NodeJS.
961
+ * @interface IServerSideSharedSettings
928
962
  * @extends ISharedSettings
929
- * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#configuration}
930
963
  */
931
- interface IBrowserSettings extends ISharedSettings {
964
+ interface IServerSideSharedSettings extends ISharedSettings {
932
965
  /**
933
- * SDK Startup settings for the Browser.
966
+ * SDK Core settings for NodeJS.
967
+ * @property {Object} core
968
+ */
969
+ core: ISharedSettings['core'] & {
970
+ /**
971
+ * Disable machine IP and Name from being sent to Split backend.
972
+ * @property {boolean} IPAddressesEnabled
973
+ * @default true
974
+ */
975
+ IPAddressesEnabled?: boolean
976
+ },
977
+ /**
978
+ * Mocked features file path. For testing purposses only. For using this you should specify "localhost" as authorizationKey on core settings.
979
+ * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
980
+ * @property {MockedFeaturesFilePath} features
981
+ * @default $HOME/.split
982
+ */
983
+ features?: MockedFeaturesFilePath,
984
+ /**
985
+ * SDK Startup settings for NodeJS.
934
986
  * @property {Object} startup
935
987
  */
936
988
  startup?: {
937
989
  /**
938
990
  * Maximum amount of time used before notify a timeout.
939
991
  * @property {number} readyTimeout
940
- * @default 1.5
992
+ * @default 15
941
993
  */
942
994
  readyTimeout?: number,
943
995
  /**
944
996
  * 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'.
997
+ *
998
+ * NOTE: this param is applicable in "standalone" mode.
945
999
  * @property {number} requestTimeoutBeforeReady
946
- * @default 1.5
1000
+ * @default 15
947
1001
  */
948
1002
  requestTimeoutBeforeReady?: number,
949
1003
  /**
950
1004
  * How many quick retries we will do while starting up the SDK.
1005
+ *
1006
+ * NOTE: this param is applicable in "standalone" mode.
951
1007
  * @property {number} retriesOnFailureBeforeReady
952
1008
  * @default 1
953
1009
  */
@@ -956,8 +1012,9 @@ declare namespace SplitIO {
956
1012
  * For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
957
1013
  * to better control on browsers. This number defines that window before the first events push.
958
1014
  *
1015
+ * NOTE: this param is ignored in "consumer" mode.
959
1016
  * @property {number} eventsFirstPushWindow
960
- * @default 10
1017
+ * @default 0
961
1018
  */
962
1019
  eventsFirstPushWindow?: number,
963
1020
  },
@@ -968,19 +1025,33 @@ declare namespace SplitIO {
968
1025
  scheduler?: {
969
1026
  /**
970
1027
  * The SDK polls Split servers for changes to feature roll-out plans. This parameter controls this polling period in seconds.
1028
+ *
1029
+ * NOTE: this param is applicable in "standalone" mode.
971
1030
  * @property {number} featuresRefreshRate
972
- * @default 30
1031
+ * @default 5
973
1032
  */
974
1033
  featuresRefreshRate?: number,
1034
+ /**
1035
+ * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
1036
+ *
1037
+ * NOTE: this param is applicable in "standalone" mode.
1038
+ * @property {number} segmentsRefreshRate
1039
+ * @default 60
1040
+ */
1041
+ segmentsRefreshRate?: number,
975
1042
  /**
976
1043
  * 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.
1044
+ *
1045
+ * NOTE: this param is ignored in "consumer" mode.
977
1046
  * @property {number} impressionsRefreshRate
978
- * @default 60
1047
+ * @default 300
979
1048
  */
980
1049
  impressionsRefreshRate?: number,
981
1050
  /**
982
1051
  * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
983
1052
  * If you use a 0 here, the queue will have no maximum size.
1053
+ *
1054
+ * NOTE: this param is ignored in "consumer" mode.
984
1055
  * @property {number} impressionsQueueSize
985
1056
  * @default 30000
986
1057
  */
@@ -994,18 +1065,16 @@ declare namespace SplitIO {
994
1065
  metricsRefreshRate?: number,
995
1066
  /**
996
1067
  * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
1068
+ *
1069
+ * NOTE: this param is ignored in "consumer" mode.
997
1070
  * @property {number} telemetryRefreshRate
998
1071
  * @default 3600
999
1072
  */
1000
1073
  telemetryRefreshRate?: number,
1001
- /**
1002
- * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
1003
- * @property {number} segmentsRefreshRate
1004
- * @default 60
1005
- */
1006
- segmentsRefreshRate?: number,
1007
1074
  /**
1008
1075
  * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
1076
+ *
1077
+ * NOTE: this param is ignored in "consumer" mode.
1009
1078
  * @property {number} eventsPushRate
1010
1079
  * @default 60
1011
1080
  */
@@ -1013,52 +1082,46 @@ declare namespace SplitIO {
1013
1082
  /**
1014
1083
  * The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
1015
1084
  * If you use a 0 here, the queue will have no maximum size.
1085
+ *
1086
+ * NOTE: this param is ignored in "consumer" mode.
1016
1087
  * @property {number} eventsQueueSize
1017
1088
  * @default 500
1018
1089
  */
1019
1090
  eventsQueueSize?: number,
1020
1091
  /**
1021
1092
  * For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
1022
- * For more information @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#localhost-mode}
1093
+ * For more information @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
1023
1094
  * @property {number} offlineRefreshRate
1024
1095
  * @default 15
1025
1096
  */
1026
- offlineRefreshRate?: number,
1097
+ offlineRefreshRate?: number
1027
1098
  /**
1028
1099
  * When using streaming mode, seconds to wait before re attempting to connect for push notifications.
1029
1100
  * Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
1101
+ *
1102
+ * NOTE: this param is applicable in "standalone" mode.
1030
1103
  * @property {number} pushRetryBackoffBase
1031
1104
  * @default 1
1032
1105
  */
1033
1106
  pushRetryBackoffBase?: number,
1034
1107
  },
1108
+ }
1109
+ /**
1110
+ * Common settings interface for SDK instances created on client-side (Browser & React Native).
1111
+ * @interface IClientSideSharedSettings
1112
+ * @extends ISharedSettings
1113
+ */
1114
+ interface IClientSideSharedSettings extends ISharedSettings {
1035
1115
  /**
1036
- * SDK Core settings for the browser.
1116
+ * SDK Core settings for client-side.
1037
1117
  * @property {Object} core
1038
1118
  */
1039
- core: {
1040
- /**
1041
- * Your API key. More information: @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
1042
- * @property {string} authorizationKey
1043
- */
1044
- authorizationKey: string,
1119
+ core: ISharedSettings['core'] & {
1045
1120
  /**
1046
1121
  * Customer identifier. Whatever this means to you. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
1047
1122
  * @property {SplitKey} key
1048
1123
  */
1049
1124
  key: SplitKey,
1050
- /**
1051
- * Traffic type associated with the customer identifier. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
1052
- * If no provided as a setting it will be required on the client.track() calls.
1053
- * @property {string} trafficType
1054
- */
1055
- trafficType?: string,
1056
- /**
1057
- * Disable labels from being sent to Split backend. Labels may contain sensitive information.
1058
- * @property {boolean} labelsEnabled
1059
- * @default true
1060
- */
1061
- labelsEnabled?: boolean
1062
1125
  },
1063
1126
  /**
1064
1127
  * Mocked features map. For testing purposses only. For using this you should specify "localhost" as authorizationKey on core settings.
@@ -1066,268 +1129,188 @@ declare namespace SplitIO {
1066
1129
  */
1067
1130
  features?: MockedFeaturesMap,
1068
1131
  /**
1069
- * Defines which kind of storage we can instantiate on the browser.
1070
- * Possible storage types are 'MEMORY', which is the default, and 'LOCALSTORAGE'.
1071
- * @property {Object} storage
1132
+ * SDK Startup settings for client-side.
1133
+ * @property {Object} startup
1072
1134
  */
1073
- storage?: {
1135
+ startup?: {
1074
1136
  /**
1075
- * Storage type to be instantiated by the SDK.
1076
- * @property {BrowserStorage} type
1077
- * @default MEMORY
1137
+ * Maximum amount of time used before notify a timeout.
1138
+ * @property {number} readyTimeout
1139
+ * @default 1.5
1078
1140
  */
1079
- type?: BrowserStorage,
1141
+ readyTimeout?: number,
1080
1142
  /**
1081
- * Optional prefix to prevent any kind of data collision between SDK versions.
1082
- * @property {string} prefix
1083
- * @default SPLITIO
1143
+ * 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'.
1144
+ *
1145
+ * NOTE: this param is applicable in "standalone" mode.
1146
+ * @property {number} requestTimeoutBeforeReady
1147
+ * @default 1.5
1084
1148
  */
1085
- prefix?: string
1086
- },
1087
- /**
1088
- * List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
1089
- * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
1090
- * @property {Object} urls
1091
- */
1092
- urls?: UrlSettings,
1093
- /**
1094
- * SDK integration settings for the Browser.
1095
- * @property {Object} integrations
1096
- */
1097
- integrations?: BrowserIntegration[],
1098
- /**
1099
- * User consent status. Possible values are `'GRANTED'`, which is the default, `'DECLINED'` or `'UNKNOWN'`.
1100
- * - `'GRANTED'`: the user grants consent for tracking events and impressions. The SDK sends them to Split cloud.
1101
- * - `'DECLINED'`: the user declines consent for tracking events and impressions. The SDK does not send them to Split cloud.
1102
- * - `'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
1103
- * 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.
1104
- *
1105
- * @typedef {string} userConsent
1106
- * @default 'GRANTED'
1107
- */
1108
- userConsent?: ConsentStatus
1109
- }
1110
- /**
1111
- * Settings interface for SDK instances created on NodeJS.
1112
- * If your storage is asynchronous (Redis for example) use SplitIO.INodeAsyncSettings instead.
1113
- * @interface INodeSettings
1114
- * @extends INodeBasicSettings
1115
- * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
1116
- */
1117
- interface INodeSettings extends INodeBasicSettings {
1118
- /**
1119
- * List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
1120
- * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
1121
- * @property {Object} urls
1122
- */
1123
- urls?: UrlSettings,
1124
- /**
1125
- * Defines which kind of storage we can instantiate on NodeJS for 'standalone' mode.
1126
- * The only possible storage type is 'MEMORY', which is the default.
1127
- * @property {Object} storage
1128
- */
1129
- storage?: {
1149
+ requestTimeoutBeforeReady?: number,
1130
1150
  /**
1131
- * Synchronous storage type to be instantiated by the SDK.
1132
- * @property {NodeSyncStorage} type
1133
- * @default MEMORY
1151
+ * How many quick retries we will do while starting up the SDK.
1152
+ *
1153
+ * NOTE: this param is applicable in "standalone" mode.
1154
+ * @property {number} retriesOnFailureBeforeReady
1155
+ * @default 1
1134
1156
  */
1135
- type?: NodeSyncStorage,
1157
+ retriesOnFailureBeforeReady?: number,
1136
1158
  /**
1137
- * Optional prefix to prevent any kind of data collision between SDK versions.
1138
- * @property {string} prefix
1139
- * @default SPLITIO
1159
+ * For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
1160
+ * to better control on browsers. This number defines that window before the first events push.
1161
+ *
1162
+ * NOTE: this param is ignored in "consumer" mode.
1163
+ * @property {number} eventsFirstPushWindow
1164
+ * @default 10
1140
1165
  */
1141
- prefix?: string
1166
+ eventsFirstPushWindow?: number,
1142
1167
  },
1143
1168
  /**
1144
- * The SDK mode. When using the default 'MEMORY' storage, the only possible value is "standalone", which is the default.
1145
- * For "localhost" mode, use "localhost" as authorizationKey.
1146
- *
1147
- * @property {'standalone'} mode
1148
- * @default standalone
1149
- */
1150
- mode?: 'standalone'
1151
- }
1152
- /**
1153
- * Settings interface with async storage for SDK instances created on NodeJS.
1154
- * If your storage is synchronous (by defaut we use memory, which is sync) use SplitIO.INodeSettings instead.
1155
- * @interface INodeAsyncSettings
1156
- * @extends INodeBasicSettings
1157
- * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
1158
- */
1159
- interface INodeAsyncSettings extends INodeBasicSettings {
1160
- /**
1161
- * Defines which kind of async storage we can instantiate on NodeJS for 'consumer' mode.
1162
- * The only possible storage type is 'REDIS'.
1163
- * @property {Object} storage
1169
+ * SDK scheduler settings.
1170
+ * @property {Object} scheduler
1164
1171
  */
1165
- storage: {
1172
+ scheduler?: {
1166
1173
  /**
1167
- * 'REDIS' storage type to be instantiated by the SDK.
1168
- * @property {NodeAsyncStorage} type
1174
+ * The SDK polls Split servers for changes to feature roll-out plans. This parameter controls this polling period in seconds.
1175
+ *
1176
+ * NOTE: this param is applicable in "standalone" mode.
1177
+ * @property {number} featuresRefreshRate
1178
+ * @default 30
1169
1179
  */
1170
- type: NodeAsyncStorage,
1180
+ featuresRefreshRate?: number,
1171
1181
  /**
1172
- * Options to be passed to the Redis storage. Use it with storage type: 'REDIS'.
1173
- * @property {Object} options
1182
+ * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
1183
+ *
1184
+ * NOTE: this param is applicable in "standalone" mode.
1185
+ * @property {number} segmentsRefreshRate
1186
+ * @default 60
1174
1187
  */
1175
- options?: {
1176
- /**
1177
- * Redis URL. If set, `host`, `port`, `db` and `pass` params will be ignored.
1178
- *
1179
- * Examples:
1180
- * ```
1181
- * url: 'localhost'
1182
- * url: '127.0.0.1:6379'
1183
- * url: 'redis://:authpassword@127.0.0.1:6379/0'
1184
- * ```
1185
- * @property {string=} url
1186
- */
1187
- url?: string,
1188
- /**
1189
- * Redis host.
1190
- * @property {string=} host
1191
- * @default 'localhost'
1192
- */
1193
- host?: string,
1194
- /**
1195
- * Redis port.
1196
- * @property {number=} port
1197
- * @default 6379
1198
- */
1199
- port?: number,
1200
- /**
1201
- * Redis database to be used.
1202
- * @property {number=} db
1203
- * @default 0
1204
- */
1205
- db?: number,
1206
- /**
1207
- * Redis password. Don't define if no password is used.
1208
- * @property {string=} pass
1209
- * @default undefined
1210
- */
1211
- pass?: string,
1212
- /**
1213
- * The milliseconds before a timeout occurs during the initial connection to the Redis server.
1214
- * @property {number=} connectionTimeout
1215
- * @default 10000
1216
- */
1217
- connectionTimeout?: number,
1218
- /**
1219
- * The milliseconds before Redis commands are timeout by the SDK.
1220
- * Method calls that involve Redis commands, like `client.getTreatment` or `client.track` calls, are resolved when the commands success or timeout.
1221
- * @property {number=} operationTimeout
1222
- * @default 5000
1223
- */
1224
- operationTimeout?: number,
1225
- /**
1226
- * TLS configuration for Redis connection.
1227
- * @see {@link https://www.npmjs.com/package/ioredis#tls-options }
1228
- *
1229
- * @property {Object=} tls
1230
- * @default undefined
1231
- */
1232
- tls?: RedisOptions['tls'],
1233
- },
1188
+ segmentsRefreshRate?: number,
1234
1189
  /**
1235
- * Optional prefix to prevent any kind of data collision between SDK versions.
1236
- * @property {string} prefix
1237
- * @default SPLITIO
1190
+ * 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.
1191
+ *
1192
+ * NOTE: this param is ignored in "consumer" mode.
1193
+ * @property {number} impressionsRefreshRate
1194
+ * @default 60
1238
1195
  */
1239
- prefix?: string
1240
- },
1196
+ impressionsRefreshRate?: number,
1197
+ /**
1198
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
1199
+ * If you use a 0 here, the queue will have no maximum size.
1200
+ *
1201
+ * NOTE: this param is ignored in "consumer" mode.
1202
+ * @property {number} impressionsQueueSize
1203
+ * @default 30000
1204
+ */
1205
+ impressionsQueueSize?: number,
1206
+ /**
1207
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
1208
+ * @property {number} metricsRefreshRate
1209
+ * @default 120
1210
+ * @deprecated This parameter is ignored now. Use `telemetryRefreshRate` instead.
1211
+ */
1212
+ metricsRefreshRate?: number,
1213
+ /**
1214
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
1215
+ *
1216
+ * NOTE: this param is ignored in "consumer" mode.
1217
+ * @property {number} telemetryRefreshRate
1218
+ * @default 3600
1219
+ */
1220
+ telemetryRefreshRate?: number,
1221
+ /**
1222
+ * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
1223
+ *
1224
+ * NOTE: this param is ignored in "consumer" mode.
1225
+ * @property {number} eventsPushRate
1226
+ * @default 60
1227
+ */
1228
+ eventsPushRate?: number,
1229
+ /**
1230
+ * The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
1231
+ * If you use a 0 here, the queue will have no maximum size.
1232
+ *
1233
+ * NOTE: this param is ignored in "consumer" mode.
1234
+ * @property {number} eventsQueueSize
1235
+ * @default 500
1236
+ */
1237
+ eventsQueueSize?: number,
1238
+ /**
1239
+ * For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
1240
+ * For more information @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#localhost-mode}
1241
+ * @property {number} offlineRefreshRate
1242
+ * @default 15
1243
+ */
1244
+ offlineRefreshRate?: number,
1245
+ /**
1246
+ * When using streaming, seconds to wait before re attempting to connect for push notifications.
1247
+ * Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
1248
+ *
1249
+ * NOTE: this param is applicable in "standalone" mode.
1250
+ * @property {number} pushRetryBackoffBase
1251
+ * @default 1
1252
+ */
1253
+ pushRetryBackoffBase?: number,
1254
+ }
1241
1255
  /**
1242
- * The SDK mode. When using 'REDIS' storage type, the only possible value is "consumer", which is required.
1243
- *
1244
- * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#state-sharing-redis-integration}
1256
+ * User consent status. Possible values are `'GRANTED'`, which is the default, `'DECLINED'` or `'UNKNOWN'`.
1257
+ * - `'GRANTED'`: the user grants consent for tracking events and impressions. The SDK sends them to Split cloud.
1258
+ * - `'DECLINED'`: the user declines consent for tracking events and impressions. The SDK does not send them to Split cloud.
1259
+ * - `'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
1260
+ * 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.
1245
1261
  *
1246
- * @property {'consumer'} mode
1262
+ * @typedef {string} userConsent
1263
+ * @default 'GRANTED'
1247
1264
  */
1248
- mode: 'consumer'
1265
+ userConsent?: ConsentStatus
1249
1266
  }
1250
1267
  /**
1251
- * This represents the interface for the SDK instance with synchronous storage.
1252
- * @interface ISDK
1253
- * @extends IBasicSDK
1268
+ * Common definitions between SDK instances for different environments interface.
1269
+ * @interface IBasicSDK
1254
1270
  */
1255
- interface ISDK extends IBasicSDK {
1271
+ interface IBasicSDK<TClient, TManager> {
1256
1272
  /**
1257
1273
  * Returns the default client instance of the SDK.
1258
1274
  * @function client
1259
1275
  * @returns {IClient} The client instance.
1260
1276
  */
1261
- client(): IClient,
1262
- /**
1263
- * Returns a shared client of the SDK. For usage on the browser.
1264
- * @function client
1265
- * @param {SplitKey} key The key for the new client instance.
1266
- * @param {string=} trafficType The traffic type of the provided key.
1267
- * @returns {IClient} The client instance.
1268
- */
1269
- client(key: SplitKey, trafficType?: string): IClient,
1277
+ client(): TClient,
1270
1278
  /**
1271
1279
  * Returns a manager instance of the SDK to explore available information.
1272
1280
  * @function manager
1273
1281
  * @returns {IManager} The manager instance.
1274
1282
  */
1275
- manager(): IManager
1276
- }
1277
- /**
1278
- * This represents the interface for the SDK instance with synchronous storage.
1279
- * @interface ISDK
1280
- * @extends IBasicSDK
1281
- */
1282
- interface IBrowserSDK extends ISDK {
1283
- /**
1284
- * Returns the default client instance of the SDK.
1285
- * @function client
1286
- * @returns {IBrowserClient} The client instance.
1287
- */
1288
- client(): IBrowserClient,
1283
+ manager(): TManager
1289
1284
  /**
1290
- * Returns a shared client of the SDK. For usage on the browser.
1291
- * @function client
1292
- * @param {SplitKey} key The key for the new client instance.
1293
- * @param {string=} trafficType The traffic type of the provided key.
1294
- * @returns {IBrowserClient} The client instance.
1285
+ * Current settings of the SDK instance.
1286
+ * @property settings
1295
1287
  */
1296
- client(key: SplitKey, trafficType?: string): IBrowserClient
1288
+ settings: ISettings,
1297
1289
  /**
1298
- * User consent API.
1299
- * @property UserConsent
1290
+ * Logger API.
1291
+ * @property Logger
1300
1292
  */
1301
- UserConsent: IUserConsentAPI
1293
+ Logger: ILoggerAPI
1302
1294
  }
1303
1295
  /**
1304
- * This represents the interface for the SDK instance with asynchronous storage.
1305
- * @interface IAsyncSDK
1306
- * @extends IBasicSDK
1296
+ * Common interface between client-side SDK instances.
1297
+ * @interface ISDKCs
1307
1298
  */
1308
- interface IAsyncSDK extends IBasicSDK {
1299
+ interface ISDKWithUserConsent<TClient, TManager> extends IBasicSDK<TClient, TManager> {
1309
1300
  /**
1310
- * Returns the default client instance of the SDK.
1311
- * @function client
1312
- * @returns {IAsyncClient} The asynchronous client instance.
1313
- */
1314
- client(): IAsyncClient,
1315
- /**
1316
- * Returns a manager instance of the SDK to explore available information.
1317
- * @function manager
1318
- * @returns {IManager} The manager instance.
1301
+ * User consent API.
1302
+ * @property UserConsent
1319
1303
  */
1320
- manager(): IAsyncManager
1304
+ UserConsent: IUserConsentAPI
1321
1305
  }
1322
1306
  /**
1323
- * This represents the interface for the Client instance with synchronous storage.
1307
+ * This represents the interface for the Client instance with synchronous method calls and server-side API, where we don't have only one key.
1324
1308
  * @interface IClient
1325
1309
  * @extends IBasicClient
1326
1310
  */
1327
- interface IClient extends IBasicClient {
1311
+ interface IClientSS extends IBasicClient {
1328
1312
  /**
1329
1313
  * Returns a Treatment value, which is the treatment string for the given feature.
1330
- * For usage on NodeJS as we don't have only one key.
1331
1314
  * @function getTreatment
1332
1315
  * @param {string} key - The string key representing the consumer.
1333
1316
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
@@ -1335,18 +1318,8 @@ declare namespace SplitIO {
1335
1318
  * @returns {Treatment} The treatment string.
1336
1319
  */
1337
1320
  getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): Treatment,
1338
- /**
1339
- * Returns a Treatment value, which is the treatment string for the given feature.
1340
- * For usage on the Browser as we defined the key on the settings.
1341
- * @function getTreatment
1342
- * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1343
- * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1344
- * @returns {Treatment} The treatment string.
1345
- */
1346
- getTreatment(splitName: string, attributes?: Attributes): Treatment,
1347
1321
  /**
1348
1322
  * Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
1349
- * For usage on NodeJS as we don't have only one key.
1350
1323
  * @function getTreatmentWithConfig
1351
1324
  * @param {string} key - The string key representing the consumer.
1352
1325
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
@@ -1355,20 +1328,8 @@ declare namespace SplitIO {
1355
1328
  * configuration stringified JSON (or null if there was no config for that treatment).
1356
1329
  */
1357
1330
  getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): TreatmentWithConfig,
1358
- /**
1359
- * Returns a TreatmentWithConfig value, which an object with both treatment and config string for the given feature.
1360
- * For usage on the Browser as we defined the key on the settings.
1361
- * @function getTreatment
1362
- * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1363
- * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1364
- * @returns {TreatmentWithConfig} The TreatmentWithConfig, the object containing the treatment string and the
1365
- * configuration stringified JSON (or null if there was no config for that treatment).
1366
- */
1367
- getTreatmentWithConfig(splitName: string, attributes?: Attributes): TreatmentWithConfig,
1368
1331
  /**
1369
1332
  * Returns a Treatments value, which is an object map with the treatments for the given features.
1370
- * For usage on NodeJS as we don't have only one key.
1371
- * NOTE: Treatment will be a promise only in async storages, like REDIS.
1372
1333
  * @function getTreatments
1373
1334
  * @param {string} key - The string key representing the consumer.
1374
1335
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
@@ -1376,19 +1337,8 @@ declare namespace SplitIO {
1376
1337
  * @returns {Treatments} The treatments object map.
1377
1338
  */
1378
1339
  getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): Treatments,
1379
- /**
1380
- * Returns a Treatments value, which is an object map with the treatments for the given features.
1381
- * For usage on the Browser as we defined the key on the settings.
1382
- * NOTE: Treatment will be a promise only in async storages, like REDIS.
1383
- * @function getTreatments
1384
- * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1385
- * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1386
- * @returns {Treatments} The treatments object map.
1387
- */
1388
- getTreatments(splitNames: string[], attributes?: Attributes): Treatments,
1389
1340
  /**
1390
1341
  * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
1391
- * For usage on NodeJS as we don't have only one key.
1392
1342
  * @function getTreatmentsWithConfig
1393
1343
  * @param {string} key - The string key representing the consumer.
1394
1344
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
@@ -1396,18 +1346,8 @@ declare namespace SplitIO {
1396
1346
  * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
1397
1347
  */
1398
1348
  getTreatmentsWithConfig(key: SplitKey, splitNames: string[], attributes?: Attributes): TreatmentsWithConfig,
1399
- /**
1400
- * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
1401
- * For usage on the Browser as we defined the key on the settings.
1402
- * @function getTreatmentsWithConfig
1403
- * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1404
- * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1405
- * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
1406
- */
1407
- getTreatmentsWithConfig(splitNames: string[], attributes?: Attributes): TreatmentsWithConfig,
1408
1349
  /**
1409
1350
  * Tracks an event to be fed to the results product on Split Webconsole.
1410
- * For usage on NodeJS as we don't have only one key.
1411
1351
  * @function track
1412
1352
  * @param {SplitKey} key - The key that identifies the entity related to this event.
1413
1353
  * @param {string} trafficType - The traffic type of the entity related to this event.
@@ -1416,35 +1356,74 @@ declare namespace SplitIO {
1416
1356
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1417
1357
  * @returns {boolean} Whether the event was added to the queue successfully or not.
1418
1358
  */
1419
- track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
1359
+ track(key: SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
1360
+ }
1361
+ /**
1362
+ * This represents the interface for the Client instance with asynchronous method calls and server-side SDK, where we don't have only one key.
1363
+ * @interface IAsyncClient
1364
+ * @extends IBasicClient
1365
+ */
1366
+ interface IAsyncClientSS extends IBasicClient {
1420
1367
  /**
1421
- * Tracks an event to be fed to the results product on Split Webconsole.
1422
- * For usage on the Browser as we defined the key on the settings.
1423
- * @function track
1424
- * @param {string} trafficType - The traffic type of the entity related to this event.
1425
- * @param {string} eventType - The event type corresponding to this event.
1426
- * @param {number=} value - The value of this event.
1427
- * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1428
- * @returns {boolean} Whether the event was added to the queue successfully or not.
1368
+ * Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
1369
+ * For usage on NodeJS as we don't have only one key.
1370
+ * NOTE: Treatment will be a promise only in async storages, like REDIS.
1371
+ * @function getTreatment
1372
+ * @param {string} key - The string key representing the consumer.
1373
+ * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1374
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1375
+ * @returns {AsyncTreatment} Treatment promise which will resolve to the treatment string.
1429
1376
  */
1430
- track(trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
1377
+ getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatment,
1431
1378
  /**
1432
- * Tracks an event to be fed to the results product on Split Webconsole.
1433
- * For usage on the Browser if we defined the key and also the trafficType on the settings.
1379
+ * Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
1380
+ * For usage on NodeJS as we don't have only one key.
1381
+ * NOTE: Treatment will be a promise only in async storages, like REDIS.
1382
+ * @function getTreatmentWithConfig
1383
+ * @param {string} key - The string key representing the consumer.
1384
+ * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1385
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1386
+ * @returns {AsyncTreatmentWithConfig} TreatmentWithConfig promise which will resolve to the TreatmentWithConfig object.
1387
+ */
1388
+ getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatmentWithConfig,
1389
+ /**
1390
+ * Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
1391
+ * For usage on NodeJS as we don't have only one key.
1392
+ * @function getTreatments
1393
+ * @param {string} key - The string key representing the consumer.
1394
+ * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1395
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1396
+ * @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object map.
1397
+ */
1398
+ getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): AsyncTreatments,
1399
+ /**
1400
+ * 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.
1401
+ * For usage on NodeJS as we don't have only one key.
1402
+ * @function getTreatmentsWithConfig
1403
+ * @param {string} key - The string key representing the consumer.
1404
+ * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1405
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1406
+ * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise which will resolve to the map of TreatmentsWithConfig objects.
1407
+ */
1408
+ getTreatmentsWithConfig(key: SplitKey, splitNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig,
1409
+ /**
1410
+ * Tracks an event to be fed to the results product on Split Webconsole and returns a promise to signal when the event was successfully queued (or not).
1434
1411
  * @function track
1412
+ * @param {SplitKey} key - The key that identifies the entity related to this event.
1413
+ * @param {string} trafficType - The traffic type of the entity related to this event.
1435
1414
  * @param {string} eventType - The event type corresponding to this event.
1436
1415
  * @param {number=} value - The value of this event.
1437
1416
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1438
- * @returns {boolean} Whether the event was added to the queue successfully or not.
1417
+ * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
1439
1418
  */
1440
- track(eventType: string, value?: number, properties?: Properties): boolean
1419
+ track(key: SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>
1441
1420
  }
1442
1421
  /**
1443
- * This represents the interface for the Client instance with attributes binding.
1444
- * @interface IBrowserClient
1445
- * @Extends IClient
1422
+ * This represents the interface for the Client instance with attributes binding
1423
+ * @interface IClientWithAttributeBinding
1424
+ * @extends IBasicClient
1446
1425
  */
1447
- interface IBrowserClient extends IClient {
1426
+ interface IClientWithAttributeBinding extends IBasicClient {
1448
1427
  /**
1449
1428
  * Add an attribute to client's in memory attributes storage.
1450
1429
  *
@@ -1488,64 +1467,129 @@ declare namespace SplitIO {
1488
1467
  clearAttributes(): boolean
1489
1468
  }
1490
1469
  /**
1491
- * This represents the interface for the Client instance with asynchronous storage.
1492
- * @interface IAsyncClient
1493
- * @extends IBasicClient
1470
+ * This represents the interface for the Client instance with attributes binding, synchronous method calls, and client-side API, where each client has a key associated.
1471
+ * @interface IClientWithKey
1472
+ * @extends IClientWithAttributeBinding
1473
+ */
1474
+ interface IClientWithKey extends IClientWithAttributeBinding {
1475
+ /**
1476
+ * Returns a Treatment value, which is the treatment string for the given feature.
1477
+ * @function getTreatment
1478
+ * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1479
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1480
+ * @returns {Treatment} The treatment string.
1481
+ */
1482
+ getTreatment(splitName: string, attributes?: Attributes): Treatment,
1483
+ /**
1484
+ * Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
1485
+ * @function getTreatmentWithConfig
1486
+ * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1487
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1488
+ * @returns {TreatmentWithConfig} The map containing the treatment and the configuration stringified JSON (or null if there was no config for that treatment).
1489
+ */
1490
+ getTreatmentWithConfig(splitName: string, attributes?: Attributes): TreatmentWithConfig,
1491
+ /**
1492
+ * Returns a Treatments value, which is an object map with the treatments for the given features.
1493
+ * @function getTreatments
1494
+ * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1495
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1496
+ * @returns {Treatments} The treatments object map.
1497
+ */
1498
+ getTreatments(splitNames: string[], attributes?: Attributes): Treatments,
1499
+ /**
1500
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
1501
+ * @function getTreatmentsWithConfig
1502
+ * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1503
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1504
+ * @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
1505
+ */
1506
+ getTreatmentsWithConfig(splitNames: string[], attributes?: Attributes): TreatmentsWithConfig,
1507
+ /**
1508
+ * Tracks an event to be fed to the results product on Split Webconsole.
1509
+ * @function track
1510
+ * @param {string} trafficType - The traffic type of the entity related to this event.
1511
+ * @param {string} eventType - The event type corresponding to this event.
1512
+ * @param {number=} value - The value of this event.
1513
+ * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1514
+ * @returns {boolean} Whether the event was added to the queue successfully or not.
1515
+ */
1516
+ track(trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
1517
+ }
1518
+ /**
1519
+ * This represents the interface for the Client instance with attributes binding, synchronous method calls, and client-side API, where each client has a key associated and optionally a traffic type.
1520
+ * @interface IClientWithKeyLegacy
1521
+ * @extends IClientWithKey
1494
1522
  */
1495
- interface IAsyncClient extends IBasicClient {
1523
+ interface IClientWithKeyLegacy extends IClientWithKey {
1524
+ /**
1525
+ * Tracks an event to be fed to the results product on Split Webconsole.
1526
+ * @function track
1527
+ * @param {string} trafficType - The traffic type of the entity related to this event.
1528
+ * @param {string} eventType - The event type corresponding to this event.
1529
+ * @param {number=} value - The value of this event.
1530
+ * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1531
+ * @returns {boolean} Whether the event was added to the queue successfully or not.
1532
+ */
1533
+ track(trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
1534
+ /**
1535
+ * Tracks an event to be fed to the results product on Split Webconsole.
1536
+ * For usage on the Browser if we defined the key and also the trafficType on the settings.
1537
+ * @function track
1538
+ * @param {string} eventType - The event type corresponding to this event.
1539
+ * @param {number=} value - The value of this event.
1540
+ * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1541
+ * @returns {boolean} Whether the event was added to the queue successfully or not.
1542
+ */
1543
+ track(eventType: string, value?: number, properties?: Properties): boolean
1544
+ }
1545
+ /**
1546
+ * This represents the interface for the Client instance with attributes binding, asynchronous method calls, and client-side API, where each client has a key associated.
1547
+ * @interface IAsyncClientWithKey
1548
+ * @extends IClientWithAttributeBinding
1549
+ */
1550
+ interface IAsyncClientWithKey extends IClientWithAttributeBinding {
1496
1551
  /**
1497
1552
  * Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
1498
- * For usage on NodeJS as we don't have only one key.
1499
- * NOTE: Treatment will be a promise only in async storages, like REDIS.
1500
1553
  * @function getTreatment
1501
- * @param {string} key - The string key representing the consumer.
1502
1554
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1503
1555
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1504
1556
  * @returns {AsyncTreatment} Treatment promise which will resolve to the treatment string.
1505
1557
  */
1506
- getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatment,
1558
+ getTreatment(splitName: string, attributes?: Attributes): AsyncTreatment,
1507
1559
  /**
1508
1560
  * Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
1509
- * For usage on NodeJS as we don't have only one key.
1510
- * NOTE: Treatment will be a promise only in async storages, like REDIS.
1511
1561
  * @function getTreatmentWithConfig
1512
- * @param {string} key - The string key representing the consumer.
1513
1562
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1514
1563
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1515
1564
  * @returns {AsyncTreatmentWithConfig} TreatmentWithConfig promise which will resolve to the TreatmentWithConfig object.
1516
1565
  */
1517
- getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatmentWithConfig,
1566
+ getTreatmentWithConfig(splitName: string, attributes?: Attributes): AsyncTreatmentWithConfig,
1518
1567
  /**
1519
1568
  * Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
1520
- * For usage on NodeJS as we don't have only one key.
1521
1569
  * @function getTreatments
1522
- * @param {string} key - The string key representing the consumer.
1523
1570
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1524
1571
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1525
1572
  * @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object map.
1526
1573
  */
1527
- getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): AsyncTreatments,
1574
+ getTreatments(splitNames: string[], attributes?: Attributes): AsyncTreatments,
1528
1575
  /**
1529
1576
  * 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.
1530
- * For usage on NodeJS as we don't have only one key.
1531
1577
  * @function getTreatmentsWithConfig
1532
- * @param {string} key - The string key representing the consumer.
1533
1578
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1534
1579
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1535
- * @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise which will resolve to the map of TreatmentsWithConfig objects.
1580
+ * @returns {TreatmentsWithConfig} TreatmentsWithConfig promise which will resolve to the map of TreatmentsWithConfig objects.
1536
1581
  */
1537
- getTreatmentsWithConfig(key: SplitKey, splitNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig,
1582
+ getTreatmentsWithConfig(splitNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig,
1538
1583
  /**
1539
1584
  * Tracks an event to be fed to the results product on Split Webconsole and returns a promise to signal when the event was successfully queued (or not).
1540
1585
  * @function track
1541
- * @param {SplitKey} key - The key that identifies the entity related to this event.
1542
1586
  * @param {string} trafficType - The traffic type of the entity related to this event.
1543
1587
  * @param {string} eventType - The event type corresponding to this event.
1544
1588
  * @param {number=} value - The value of this event.
1545
1589
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1546
- * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
1590
+ * @returns {boolean} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
1547
1591
  */
1548
- track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>
1592
+ track(trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>,
1549
1593
  }
1550
1594
  /**
1551
1595
  * Representation of a manager instance with synchronous storage of the SDK.
@@ -1562,14 +1606,14 @@ declare namespace SplitIO {
1562
1606
  /**
1563
1607
  * Get the array of splits data in SplitView format.
1564
1608
  * @function splits
1565
- * @returns {SplitViews} The list of SplitIO.SplitView.
1609
+ * @returns {SplitViews} The list of SplitView.
1566
1610
  */
1567
1611
  splits(): SplitViews;
1568
1612
  /**
1569
1613
  * Get the data of a split in SplitView format.
1570
1614
  * @function split
1571
1615
  * @param {string} splitName The name of the split we wan't to get info of.
1572
- * @returns {SplitView | null} The SplitIO.SplitView of the given split or null if the split is not found.
1616
+ * @returns {SplitView | null} The SplitView of the given split or null if the split is not found.
1573
1617
  */
1574
1618
  split(splitName: string): SplitView | null;
1575
1619
  }
@@ -1588,14 +1632,14 @@ declare namespace SplitIO {
1588
1632
  /**
1589
1633
  * Get the array of splits data in SplitView format.
1590
1634
  * @function splits
1591
- * @returns {SplitViewsAsync} A promise that will resolve to the SplitIO.SplitView list.
1635
+ * @returns {SplitViewsAsync} A promise that will resolve to the SplitView list.
1592
1636
  */
1593
1637
  splits(): SplitViewsAsync;
1594
1638
  /**
1595
1639
  * Get the data of a split in SplitView format.
1596
1640
  * @function split
1597
1641
  * @param {string} splitName The name of the split we wan't to get info of.
1598
- * @returns {SplitViewAsync} A promise that will resolve to the SplitIO.SplitView value or null if the split is not found.
1642
+ * @returns {SplitViewAsync} A promise that will resolve to the SplitView value or null if the split is not found.
1599
1643
  */
1600
1644
  split(splitName: string): SplitViewAsync;
1601
1645
  }