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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/CHANGES.txt +1 -3
  2. package/cjs/logger/constants.js +1 -2
  3. package/cjs/logger/messages/error.js +0 -1
  4. package/cjs/sdkFactory/index.js +1 -3
  5. package/cjs/storages/dataLoader.js +37 -99
  6. package/cjs/storages/inMemory/InMemoryStorageCS.js +4 -16
  7. package/cjs/sync/offline/LocalhostFromObject.js +3 -8
  8. package/cjs/utils/settingsValidation/index.js +1 -4
  9. package/esm/logger/constants.js +0 -1
  10. package/esm/logger/messages/error.js +0 -1
  11. package/esm/sdkFactory/index.js +2 -4
  12. package/esm/storages/dataLoader.js +35 -96
  13. package/esm/storages/inMemory/InMemoryStorageCS.js +4 -16
  14. package/esm/sync/offline/LocalhostFromObject.js +2 -6
  15. package/esm/utils/settingsValidation/index.js +1 -4
  16. package/package.json +3 -2
  17. package/src/logger/constants.ts +0 -1
  18. package/src/logger/messages/error.ts +0 -1
  19. package/src/sdkFactory/index.ts +3 -6
  20. package/src/storages/dataLoader.ts +38 -97
  21. package/src/storages/inMemory/InMemoryStorageCS.ts +4 -19
  22. package/src/storages/types.ts +2 -4
  23. package/src/sync/offline/LocalhostFromObject.ts +2 -8
  24. package/src/types.ts +14 -26
  25. package/src/utils/settingsValidation/index.ts +1 -4
  26. package/src/utils/settingsValidation/types.ts +0 -2
  27. package/types/index.d.ts +5 -5
  28. package/types/splitio.d.ts +2293 -0
  29. package/cjs/utils/settingsValidation/localhost/builtin.js +0 -18
  30. package/cjs/utils/settingsValidation/localhost/pluggable.js +0 -22
  31. package/esm/utils/settingsValidation/localhost/builtin.js +0 -14
  32. package/esm/utils/settingsValidation/localhost/pluggable.js +0 -18
  33. package/src/utils/settingsValidation/localhost/builtin.ts +0 -16
  34. package/src/utils/settingsValidation/localhost/pluggable.ts +0 -22
  35. package/types/consent/index.d.ts +0 -2
  36. package/types/consent/sdkUserConsent.d.ts +0 -13
  37. package/types/dtos/types.d.ts +0 -209
  38. package/types/evaluator/Engine.d.ts +0 -15
  39. package/types/evaluator/combiners/and.d.ts +0 -4
  40. package/types/evaluator/combiners/ifelseif.d.ts +0 -3
  41. package/types/evaluator/condition/engineUtils.d.ts +0 -11
  42. package/types/evaluator/condition/index.d.ts +0 -6
  43. package/types/evaluator/convertions/index.d.ts +0 -2
  44. package/types/evaluator/index.d.ts +0 -8
  45. package/types/evaluator/matchers/all.d.ts +0 -1
  46. package/types/evaluator/matchers/between.d.ts +0 -2
  47. package/types/evaluator/matchers/boolean.d.ts +0 -1
  48. package/types/evaluator/matchers/cont_all.d.ts +0 -1
  49. package/types/evaluator/matchers/cont_any.d.ts +0 -1
  50. package/types/evaluator/matchers/cont_str.d.ts +0 -1
  51. package/types/evaluator/matchers/dependency.d.ts +0 -5
  52. package/types/evaluator/matchers/eq.d.ts +0 -1
  53. package/types/evaluator/matchers/eq_set.d.ts +0 -1
  54. package/types/evaluator/matchers/ew.d.ts +0 -1
  55. package/types/evaluator/matchers/gte.d.ts +0 -1
  56. package/types/evaluator/matchers/index.d.ts +0 -7
  57. package/types/evaluator/matchers/large_segment.d.ts +0 -5
  58. package/types/evaluator/matchers/lte.d.ts +0 -1
  59. package/types/evaluator/matchers/matcherTypes.d.ts +0 -10
  60. package/types/evaluator/matchers/part_of.d.ts +0 -1
  61. package/types/evaluator/matchers/segment.d.ts +0 -5
  62. package/types/evaluator/matchers/sember_inlist.d.ts +0 -3
  63. package/types/evaluator/matchers/semver_between.d.ts +0 -2
  64. package/types/evaluator/matchers/semver_eq.d.ts +0 -1
  65. package/types/evaluator/matchers/semver_gte.d.ts +0 -1
  66. package/types/evaluator/matchers/semver_inlist.d.ts +0 -1
  67. package/types/evaluator/matchers/semver_lte.d.ts +0 -1
  68. package/types/evaluator/matchers/string.d.ts +0 -1
  69. package/types/evaluator/matchers/sw.d.ts +0 -1
  70. package/types/evaluator/matchers/whitelist.d.ts +0 -1
  71. package/types/evaluator/matchersTransform/index.d.ts +0 -6
  72. package/types/evaluator/matchersTransform/segment.d.ts +0 -5
  73. package/types/evaluator/matchersTransform/set.d.ts +0 -5
  74. package/types/evaluator/matchersTransform/string.d.ts +0 -7
  75. package/types/evaluator/matchersTransform/unaryNumeric.d.ts +0 -5
  76. package/types/evaluator/matchersTransform/whitelist.d.ts +0 -5
  77. package/types/evaluator/parser/index.d.ts +0 -5
  78. package/types/evaluator/treatments/index.d.ts +0 -8
  79. package/types/evaluator/types.d.ts +0 -28
  80. package/types/evaluator/value/index.d.ts +0 -7
  81. package/types/evaluator/value/sanitize.d.ts +0 -7
  82. package/types/integrations/browser.d.ts +0 -12
  83. package/types/integrations/ga/GaToSplit.d.ts +0 -40
  84. package/types/integrations/ga/GoogleAnalyticsToSplit.d.ts +0 -3
  85. package/types/integrations/ga/SplitToGa.d.ts +0 -34
  86. package/types/integrations/ga/SplitToGoogleAnalytics.d.ts +0 -3
  87. package/types/integrations/ga/types.d.ts +0 -148
  88. package/types/integrations/pluggable.d.ts +0 -11
  89. package/types/integrations/types.d.ts +0 -18
  90. package/types/listeners/browser.d.ts +0 -40
  91. package/types/listeners/node.d.ts +0 -22
  92. package/types/listeners/types.d.ts +0 -4
  93. package/types/logger/browser/DebugLogger.d.ts +0 -2
  94. package/types/logger/browser/ErrorLogger.d.ts +0 -2
  95. package/types/logger/browser/InfoLogger.d.ts +0 -2
  96. package/types/logger/browser/WarnLogger.d.ts +0 -2
  97. package/types/logger/constants.d.ts +0 -135
  98. package/types/logger/index.d.ts +0 -21
  99. package/types/logger/messages/debug.d.ts +0 -1
  100. package/types/logger/messages/error.d.ts +0 -1
  101. package/types/logger/messages/info.d.ts +0 -1
  102. package/types/logger/messages/warn.d.ts +0 -1
  103. package/types/logger/sdkLogger.d.ts +0 -8
  104. package/types/logger/types.d.ts +0 -17
  105. package/types/readiness/constants.d.ts +0 -7
  106. package/types/readiness/readinessManager.d.ts +0 -6
  107. package/types/readiness/sdkReadinessManager.d.ts +0 -10
  108. package/types/readiness/types.d.ts +0 -67
  109. package/types/sdkClient/client.d.ts +0 -6
  110. package/types/sdkClient/clientAttributesDecoration.d.ts +0 -55
  111. package/types/sdkClient/clientCS.d.ts +0 -9
  112. package/types/sdkClient/clientInputValidation.d.ts +0 -7
  113. package/types/sdkClient/identity.d.ts +0 -2
  114. package/types/sdkClient/sdkClient.d.ts +0 -6
  115. package/types/sdkClient/sdkClientMethod.d.ts +0 -6
  116. package/types/sdkClient/sdkClientMethodCS.d.ts +0 -7
  117. package/types/sdkClient/sdkClientMethodCSWithTT.d.ts +0 -8
  118. package/types/sdkFactory/index.d.ts +0 -6
  119. package/types/sdkFactory/types.d.ts +0 -85
  120. package/types/sdkManager/index.d.ts +0 -4
  121. package/types/services/decorateHeaders.d.ts +0 -2
  122. package/types/services/splitApi.d.ts +0 -12
  123. package/types/services/splitHttpClient.d.ts +0 -10
  124. package/types/services/types.d.ts +0 -54
  125. package/types/storages/AbstractMySegmentsCacheSync.d.ts +0 -39
  126. package/types/storages/AbstractSegmentsCacheSync.d.ts +0 -54
  127. package/types/storages/AbstractSplitsCache.d.ts +0 -46
  128. package/types/storages/AbstractSplitsCacheAsync.d.ts +0 -38
  129. package/types/storages/AbstractSplitsCacheSync.d.ts +0 -43
  130. package/types/storages/KeyBuilder.d.ts +0 -22
  131. package/types/storages/KeyBuilderCS.d.ts +0 -20
  132. package/types/storages/KeyBuilderSS.d.ts +0 -20
  133. package/types/storages/dataLoader.d.ts +0 -21
  134. package/types/storages/findLatencyIndex.d.ts +0 -7
  135. package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +0 -15
  136. package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +0 -54
  137. package/types/storages/inLocalStorage/constants.d.ts +0 -2
  138. package/types/storages/inLocalStorage/index.d.ts +0 -8
  139. package/types/storages/inMemory/AttributesCacheInMemory.d.ts +0 -44
  140. package/types/storages/inMemory/EventsCacheInMemory.d.ts +0 -35
  141. package/types/storages/inMemory/ImpressionCountsCacheInMemory.d.ts +0 -28
  142. package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +0 -30
  143. package/types/storages/inMemory/InMemoryStorage.d.ts +0 -10
  144. package/types/storages/inMemory/InMemoryStorageCS.d.ts +0 -10
  145. package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +0 -16
  146. package/types/storages/inMemory/SegmentsCacheInMemory.d.ts +0 -17
  147. package/types/storages/inMemory/SplitsCacheInMemory.d.ts +0 -27
  148. package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +0 -71
  149. package/types/storages/inMemory/UniqueKeysCacheInMemory.d.ts +0 -34
  150. package/types/storages/inMemory/UniqueKeysCacheInMemoryCS.d.ts +0 -35
  151. package/types/storages/inRedis/EventsCacheInRedis.d.ts +0 -32
  152. package/types/storages/inRedis/ImpressionCountsCacheInRedis.d.ts +0 -17
  153. package/types/storages/inRedis/ImpressionsCacheInRedis.d.ts +0 -17
  154. package/types/storages/inRedis/RedisAdapter.d.ts +0 -24
  155. package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +0 -21
  156. package/types/storages/inRedis/SplitsCacheInRedis.d.ts +0 -95
  157. package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +0 -35
  158. package/types/storages/inRedis/UniqueKeysCacheInRedis.d.ts +0 -22
  159. package/types/storages/inRedis/constants.d.ts +0 -4
  160. package/types/storages/inRedis/index.d.ts +0 -10
  161. package/types/storages/pluggable/EventsCachePluggable.d.ts +0 -38
  162. package/types/storages/pluggable/ImpressionCountsCachePluggable.d.ts +0 -16
  163. package/types/storages/pluggable/ImpressionsCachePluggable.d.ts +0 -34
  164. package/types/storages/pluggable/SegmentsCachePluggable.d.ts +0 -42
  165. package/types/storages/pluggable/SplitsCachePluggable.d.ts +0 -98
  166. package/types/storages/pluggable/TelemetryCachePluggable.d.ts +0 -34
  167. package/types/storages/pluggable/UniqueKeysCachePluggable.d.ts +0 -20
  168. package/types/storages/pluggable/constants.d.ts +0 -1
  169. package/types/storages/pluggable/inMemoryWrapper.d.ts +0 -12
  170. package/types/storages/pluggable/index.d.ts +0 -9
  171. package/types/storages/pluggable/wrapperAdapter.d.ts +0 -12
  172. package/types/storages/types.d.ts +0 -410
  173. package/types/storages/utils.d.ts +0 -8
  174. package/types/sync/offline/LocalhostFromObject.d.ts +0 -2
  175. package/types/sync/offline/splitsParser/parseCondition.d.ts +0 -7
  176. package/types/sync/offline/splitsParser/splitsParserFromSettings.d.ts +0 -3
  177. package/types/sync/offline/splitsParser/types.d.ts +0 -3
  178. package/types/sync/offline/syncManagerOffline.d.ts +0 -10
  179. package/types/sync/offline/syncTasks/fromObjectSyncTask.d.ts +0 -17
  180. package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +0 -7
  181. package/types/sync/polling/fetchers/segmentChangesFetcher.d.ts +0 -7
  182. package/types/sync/polling/fetchers/splitChangesFetcher.d.ts +0 -7
  183. package/types/sync/polling/fetchers/types.d.ts +0 -5
  184. package/types/sync/polling/pollingManagerCS.d.ts +0 -7
  185. package/types/sync/polling/pollingManagerSS.d.ts +0 -6
  186. package/types/sync/polling/syncTasks/mySegmentsSyncTask.d.ts +0 -9
  187. package/types/sync/polling/syncTasks/segmentsSyncTask.d.ts +0 -9
  188. package/types/sync/polling/syncTasks/splitsSyncTask.d.ts +0 -9
  189. package/types/sync/polling/types.d.ts +0 -33
  190. package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +0 -14
  191. package/types/sync/polling/updaters/segmentChangesUpdater.d.ts +0 -18
  192. package/types/sync/polling/updaters/splitChangesUpdater.d.ts +0 -41
  193. package/types/sync/streaming/AuthClient/index.d.ts +0 -12
  194. package/types/sync/streaming/AuthClient/types.d.ts +0 -17
  195. package/types/sync/streaming/SSEClient/index.d.ts +0 -34
  196. package/types/sync/streaming/SSEClient/types.d.ts +0 -11
  197. package/types/sync/streaming/SSEHandler/NotificationKeeper.d.ts +0 -14
  198. package/types/sync/streaming/SSEHandler/NotificationParser.d.ts +0 -20
  199. package/types/sync/streaming/SSEHandler/index.d.ts +0 -11
  200. package/types/sync/streaming/SSEHandler/types.d.ts +0 -72
  201. package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +0 -9
  202. package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +0 -9
  203. package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +0 -14
  204. package/types/sync/streaming/UpdateWorkers/constants.d.ts +0 -3
  205. package/types/sync/streaming/UpdateWorkers/types.d.ts +0 -4
  206. package/types/sync/streaming/constants.d.ts +0 -34
  207. package/types/sync/streaming/mySegmentsV2utils.d.ts +0 -27
  208. package/types/sync/streaming/parseUtils.d.ts +0 -34
  209. package/types/sync/streaming/pushManager.d.ts +0 -9
  210. package/types/sync/streaming/pushManagerCS_Spec1_3.d.ts +0 -9
  211. package/types/sync/streaming/pushManager_Spec1_3.d.ts +0 -9
  212. package/types/sync/streaming/types.d.ts +0 -35
  213. package/types/sync/submitters/eventsSubmitter.d.ts +0 -5
  214. package/types/sync/submitters/impressionCountsSubmitter.d.ts +0 -10
  215. package/types/sync/submitters/impressionsSubmitter.d.ts +0 -11
  216. package/types/sync/submitters/submitter.d.ts +0 -12
  217. package/types/sync/submitters/submitterManager.d.ts +0 -3
  218. package/types/sync/submitters/telemetrySubmitter.d.ts +0 -17
  219. package/types/sync/submitters/types.d.ts +0 -217
  220. package/types/sync/submitters/uniqueKeysSubmitter.d.ts +0 -5
  221. package/types/sync/syncManagerOnline.d.ts +0 -13
  222. package/types/sync/syncTask.d.ts +0 -13
  223. package/types/sync/types.d.ts +0 -43
  224. package/types/trackers/eventTracker.d.ts +0 -10
  225. package/types/trackers/impressionObserver/ImpressionObserver.d.ts +0 -8
  226. package/types/trackers/impressionObserver/buildKey.d.ts +0 -2
  227. package/types/trackers/impressionObserver/impressionObserverCS.d.ts +0 -4
  228. package/types/trackers/impressionObserver/impressionObserverSS.d.ts +0 -4
  229. package/types/trackers/impressionObserver/types.d.ts +0 -4
  230. package/types/trackers/impressionObserver/utils.d.ts +0 -5
  231. package/types/trackers/impressionsTracker.d.ts +0 -13
  232. package/types/trackers/strategy/strategyDebug.d.ts +0 -9
  233. package/types/trackers/strategy/strategyNone.d.ts +0 -10
  234. package/types/trackers/strategy/strategyOptimized.d.ts +0 -11
  235. package/types/trackers/telemetryTracker.d.ts +0 -3
  236. package/types/trackers/types.d.ts +0 -68
  237. package/types/trackers/uniqueKeysTracker.d.ts +0 -13
  238. package/types/types.d.ts +0 -1408
  239. package/types/utils/Backoff.d.ts +0 -25
  240. package/types/utils/LRUCache/LinkedList.d.ts +0 -34
  241. package/types/utils/LRUCache/index.d.ts +0 -15
  242. package/types/utils/MinEventEmitter.d.ts +0 -12
  243. package/types/utils/MinEvents.d.ts +0 -4
  244. package/types/utils/base64/index.d.ts +0 -30
  245. package/types/utils/constants/browser.d.ts +0 -1
  246. package/types/utils/constants/index.d.ts +0 -83
  247. package/types/utils/decompress/index.d.ts +0 -16
  248. package/types/utils/env/isLocalStorageAvailable.d.ts +0 -1
  249. package/types/utils/env/isNode.d.ts +0 -5
  250. package/types/utils/inputValidation/apiKey.d.ts +0 -7
  251. package/types/utils/inputValidation/attribute.d.ts +0 -2
  252. package/types/utils/inputValidation/attributes.d.ts +0 -4
  253. package/types/utils/inputValidation/event.d.ts +0 -2
  254. package/types/utils/inputValidation/eventProperties.d.ts +0 -6
  255. package/types/utils/inputValidation/eventValue.d.ts +0 -2
  256. package/types/utils/inputValidation/index.d.ts +0 -13
  257. package/types/utils/inputValidation/isOperational.d.ts +0 -4
  258. package/types/utils/inputValidation/key.d.ts +0 -3
  259. package/types/utils/inputValidation/preloadedData.d.ts +0 -3
  260. package/types/utils/inputValidation/sdkKey.d.ts +0 -7
  261. package/types/utils/inputValidation/split.d.ts +0 -2
  262. package/types/utils/inputValidation/splitExistance.d.ts +0 -7
  263. package/types/utils/inputValidation/splitExistence.d.ts +0 -7
  264. package/types/utils/inputValidation/splits.d.ts +0 -2
  265. package/types/utils/inputValidation/trafficType.d.ts +0 -2
  266. package/types/utils/inputValidation/trafficTypeExistance.d.ts +0 -9
  267. package/types/utils/inputValidation/trafficTypeExistence.d.ts +0 -9
  268. package/types/utils/jwt/index.d.ts +0 -5
  269. package/types/utils/jwt/types.d.ts +0 -5
  270. package/types/utils/key/index.d.ts +0 -8
  271. package/types/utils/labels/index.d.ts +0 -8
  272. package/types/utils/lang/binarySearch.d.ts +0 -9
  273. package/types/utils/lang/getFnName.d.ts +0 -4
  274. package/types/utils/lang/getGlobal.d.ts +0 -4
  275. package/types/utils/lang/index.d.ts +0 -105
  276. package/types/utils/lang/maps.d.ts +0 -59
  277. package/types/utils/lang/objectAssign.d.ts +0 -6
  278. package/types/utils/lang/sets.d.ts +0 -3
  279. package/types/utils/murmur3/common.d.ts +0 -12
  280. package/types/utils/murmur3/legacy.d.ts +0 -2
  281. package/types/utils/murmur3/murmur3.d.ts +0 -2
  282. package/types/utils/murmur3/murmur3_128.d.ts +0 -6
  283. package/types/utils/murmur3/murmur3_128_x86.d.ts +0 -7
  284. package/types/utils/murmur3/murmur3_64.d.ts +0 -10
  285. package/types/utils/murmur3/utfx.d.ts +0 -27
  286. package/types/utils/promise/thenable.d.ts +0 -1
  287. package/types/utils/promise/timeout.d.ts +0 -1
  288. package/types/utils/promise/wrapper.d.ts +0 -21
  289. package/types/utils/redis/RedisMock.d.ts +0 -4
  290. package/types/utils/semVer.d.ts +0 -15
  291. package/types/utils/settingsValidation/consent.d.ts +0 -6
  292. package/types/utils/settingsValidation/impressionsMode.d.ts +0 -3
  293. package/types/utils/settingsValidation/index.d.ts +0 -51
  294. package/types/utils/settingsValidation/integrations/common.d.ts +0 -14
  295. package/types/utils/settingsValidation/integrations/configurable.d.ts +0 -13
  296. package/types/utils/settingsValidation/integrations/pluggable.d.ts +0 -13
  297. package/types/utils/settingsValidation/localhost/builtin.d.ts +0 -16
  298. package/types/utils/settingsValidation/localhost/pluggable.d.ts +0 -16
  299. package/types/utils/settingsValidation/logger/builtinLogger.d.ts +0 -10
  300. package/types/utils/settingsValidation/logger/commons.d.ts +0 -9
  301. package/types/utils/settingsValidation/logger/globalLogLevel.d.ts +0 -8
  302. package/types/utils/settingsValidation/logger/pluggableLogger.d.ts +0 -11
  303. package/types/utils/settingsValidation/mode.d.ts +0 -5
  304. package/types/utils/settingsValidation/runtime.d.ts +0 -2
  305. package/types/utils/settingsValidation/splitFilters.d.ts +0 -17
  306. package/types/utils/settingsValidation/storage/storageCS.d.ts +0 -21
  307. package/types/utils/settingsValidation/types.d.ts +0 -32
  308. package/types/utils/settingsValidation/url.d.ts +0 -10
  309. package/types/utils/time/index.d.ts +0 -4
  310. package/types/utils/timeTracker/now/browser.d.ts +0 -1
  311. package/types/utils/timeTracker/now/node.d.ts +0 -1
  312. package/types/utils/timeTracker/timer.d.ts +0 -1
@@ -32,7 +32,6 @@ export const codesError: [number, string][] = [
32
32
  [c.ERROR_NOT_BOOLEAN, '%s: provided param must be a boolean value.'],
33
33
  // initialization / settings validation
34
34
  [c.ERROR_INVALID_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': you passed an invalid "%s" config param. It should be one of the following values: %s. Defaulting to "%s".'],
35
- [c.ERROR_LOCALHOST_MODULE_REQUIRED, c.LOG_PREFIX_SETTINGS + ': an invalid value was received for "sync.localhostMode" config. A valid entity should be provided for localhost mode.'],
36
35
  [c.ERROR_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS+': the provided storage is invalid.%s Falling back into default MEMORY storage'],
37
36
  [c.ERROR_MIN_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': the provided "%s" config param is lower than allowed. Setting to the minimum value %s seconds'],
38
37
  [c.ERROR_TOO_MANY_SETS, c.LOG_PREFIX_SETTINGS + ': the amount of flag sets provided are big causing uri length error.'],
@@ -7,7 +7,7 @@ import { IBasicClient, SplitIO } from '../types';
7
7
  import { validateAndTrackApiKey } from '../utils/inputValidation/apiKey';
8
8
  import { createLoggerAPI } from '../logger/sdkLogger';
9
9
  import { NEW_FACTORY, RETRIEVE_MANAGER } from '../logger/constants';
10
- import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED, SDK_SPLITS_CACHE_LOADED } from '../readiness/constants';
10
+ import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
11
11
  import { objectAssign } from '../utils/lang/objectAssign';
12
12
  import { strategyDebugFactory } from '../trackers/strategy/strategyDebug';
13
13
  import { strategyOptimizedFactory } from '../trackers/strategy/strategyOptimized';
@@ -43,7 +43,7 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
43
43
 
44
44
  const storage = storageFactory({
45
45
  settings,
46
- onReadyCb(error) {
46
+ onReadyCb: (error) => {
47
47
  if (error) {
48
48
  // If storage fails to connect, SDK_READY_TIMED_OUT event is emitted immediately. Review when timeout and non-recoverable errors are reworked
49
49
  readiness.timeout();
@@ -52,11 +52,8 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
52
52
  readiness.splits.emit(SDK_SPLITS_ARRIVED);
53
53
  readiness.segments.emit(SDK_SEGMENTS_ARRIVED);
54
54
  },
55
- onReadyFromCacheCb() {
56
- readiness.splits.emit(SDK_SPLITS_CACHE_LOADED);
57
- }
58
55
  });
59
-
56
+ // @TODO add support for dataloader: `if (params.dataLoader) params.dataLoader(storage);`
60
57
  const clients: Record<string, IBasicClient> = {};
61
58
  const telemetryTracker = telemetryTrackerFactory(storage.telemetry, platform.now);
62
59
  const integrationsManager = integrationsManagerFactory && integrationsManagerFactory({ settings, storage, telemetryTracker });
@@ -1,114 +1,55 @@
1
1
  import { SplitIO } from '../types';
2
- import { ISegmentsCacheSync, ISplitsCacheSync, IStorageSync } from './types';
3
- import { setToArray } from '../utils/lang/sets';
4
- import { getMatching } from '../utils/key';
5
- import { IMembershipsResponse, IMySegmentsResponse } from '../dtos/types';
2
+ import { DEFAULT_CACHE_EXPIRATION_IN_MILLIS } from '../utils/constants/browser';
3
+ import { DataLoader, ISegmentsCacheSync, ISplitsCacheSync } from './types';
6
4
 
7
5
  /**
8
- * Storage-agnostic adaptation of `loadDataIntoLocalStorage` function
9
- * (https://github.com/godaddy/split-javascript-data-loader/blob/master/src/load-data.js)
6
+ * Factory of client-side storage loader
10
7
  *
11
- * @param preloadedData validated data following the format proposed in https://github.com/godaddy/split-javascript-data-loader and extended with a `mySegmentsData` property.
12
- * @param storage object containing `splits` and `segments` cache (client-side variant)
13
- * @param userKey user key (matching key) of the provided MySegmentsCache
14
- *
15
- * @TODO extend to load largeSegments
16
- * @TODO extend to load data on shared mySegments storages. Be specific when emitting SDK_READY_FROM_CACHE on shared clients. Maybe the serializer should provide the `useSegments` flag.
17
- * @TODO add logs, and input validation in this module, in favor of size reduction.
18
- * @TODO unit tests
8
+ * @param preloadedData validated data following the format proposed in https://github.com/godaddy/split-javascript-data-loader
9
+ * and extended with a `mySegmentsData` property.
10
+ * @returns function to preload the storage
19
11
  */
20
- export function loadData(preloadedData: SplitIO.PreloadedData, storage: { splits?: ISplitsCacheSync, segments: ISegmentsCacheSync, largeSegments?: ISegmentsCacheSync }, matchingKey?: string) {
21
- // Do not load data if current preloadedData is empty
22
- if (Object.keys(preloadedData).length === 0) return;
23
-
24
- const { segmentsData = {}, since = -1, splitsData = [] } = preloadedData;
12
+ export function dataLoaderFactory(preloadedData: SplitIO.PreloadedData): DataLoader {
13
+
14
+ /**
15
+ * Storage-agnostic adaptation of `loadDataIntoLocalStorage` function
16
+ * (https://github.com/godaddy/split-javascript-data-loader/blob/master/src/load-data.js)
17
+ *
18
+ * @param storage object containing `splits` and `segments` cache (client-side variant)
19
+ * @param userId user key string of the provided MySegmentsCache
20
+ *
21
+ * @TODO extend to support SegmentsCache (server-side variant) by making `userId` optional and adding the corresponding logic.
22
+ * @TODO extend to load data on shared mySegments storages. Be specific when emitting SDK_READY_FROM_CACHE on shared clients. Maybe the serializer should provide the `useSegments` flag.
23
+ */
24
+ return function loadData(storage: { splits: ISplitsCacheSync, segments: ISegmentsCacheSync }, userId: string) {
25
+ // Do not load data if current preloadedData is empty
26
+ if (Object.keys(preloadedData).length === 0) return;
27
+
28
+ const { lastUpdated = -1, segmentsData = {}, since = -1, splitsData = {} } = preloadedData;
25
29
 
26
- if (storage.splits) {
27
30
  const storedSince = storage.splits.getChangeNumber();
31
+ const expirationTimestamp = Date.now() - DEFAULT_CACHE_EXPIRATION_IN_MILLIS;
28
32
 
29
- // Do not load data if current data is more recent
30
- if (storedSince > since) return;
33
+ // Do not load data if current localStorage data is more recent,
34
+ // or if its `lastUpdated` timestamp is older than the given `expirationTimestamp`,
35
+ if (storedSince > since || lastUpdated < expirationTimestamp) return;
31
36
 
32
37
  // cleaning up the localStorage data, since some cached splits might need be part of the preloaded data
33
38
  storage.splits.clear();
34
39
  storage.splits.setChangeNumber(since);
35
40
 
36
41
  // splitsData in an object where the property is the split name and the pertaining value is a stringified json of its data
37
- storage.splits.addSplits(splitsData.map(split => ([split.name, split])));
38
- }
39
-
40
- if (matchingKey) { // add mySegments data (client-side)
41
- let membershipsData = preloadedData.membershipsData && preloadedData.membershipsData[matchingKey];
42
- if (!membershipsData && segmentsData) {
43
- membershipsData = {
44
- ms: {
45
- k: Object.keys(segmentsData).filter(segmentName => {
46
- const segmentKeys = segmentsData[segmentName];
47
- return segmentKeys.indexOf(matchingKey) > -1;
48
- }).map(segmentName => ({ n: segmentName }))
49
- }
50
- };
51
- }
52
- if (membershipsData) {
53
- if (membershipsData.ms) storage.segments.resetSegments(membershipsData.ms);
54
- if (membershipsData.ls && storage.largeSegments) storage.largeSegments.resetSegments(membershipsData.ls);
42
+ storage.splits.addSplits(Object.keys(splitsData).map(splitName => JSON.parse(splitsData[splitName])));
43
+
44
+ // add mySegments data
45
+ let mySegmentsData = preloadedData.mySegmentsData && preloadedData.mySegmentsData[userId];
46
+ if (!mySegmentsData) {
47
+ // segmentsData in an object where the property is the segment name and the pertaining value is a stringified object that contains the `added` array of userIds
48
+ mySegmentsData = Object.keys(segmentsData).filter(segmentName => {
49
+ const userIds = JSON.parse(segmentsData[segmentName]).added;
50
+ return Array.isArray(userIds) && userIds.indexOf(userId) > -1;
51
+ });
55
52
  }
56
-
57
- } else { // add segments data (server-side)
58
- Object.keys(segmentsData).forEach(segmentName => {
59
- const segmentKeys = segmentsData[segmentName];
60
- storage.segments.update(segmentName, segmentKeys, [], -1);
61
- });
62
- }
63
- }
64
-
65
- export function getSnapshot(storage: IStorageSync, userKeys?: SplitIO.SplitKey[]): SplitIO.PreloadedData {
66
- return {
67
- // lastUpdated: Date.now(),
68
- since: storage.splits.getChangeNumber(),
69
- splitsData: storage.splits.getAll(),
70
- segmentsData: userKeys ?
71
- undefined : // @ts-ignore accessing private prop
72
- Object.keys(storage.segments.segmentCache).reduce((prev, cur) => { // @ts-ignore accessing private prop
73
- prev[cur] = setToArray(storage.segments.segmentCache[cur] as Set<string>);
74
- return prev;
75
- }, {}),
76
- membershipsData: userKeys ?
77
- userKeys.reduce<Record<string, IMembershipsResponse>>((prev, userKey) => {
78
- if (storage.shared) {
79
- // Client-side segments
80
- // @ts-ignore accessing private prop
81
- const sharedStorage = storage.shared(userKey);
82
- prev[getMatching(userKey)] = {
83
- ms: {
84
- // @ts-ignore accessing private prop
85
- k: Object.keys(sharedStorage.segments.segmentCache).map(segmentName => ({ n: segmentName })),
86
- // cn: sharedStorage.segments.getChangeNumber()
87
- },
88
- ls: sharedStorage.largeSegments ? {
89
- // @ts-ignore accessing private prop
90
- k: Object.keys(sharedStorage.largeSegments.segmentCache).map(segmentName => ({ n: segmentName })),
91
- // cn: sharedStorage.largeSegments.getChangeNumber()
92
- } : undefined
93
- };
94
- } else {
95
- prev[getMatching(userKey)] = {
96
- ms: {
97
- // Server-side segments
98
- // @ts-ignore accessing private prop
99
- k: Object.keys(storage.segments.segmentCache).reduce<IMySegmentsResponse['k']>((prev, segmentName) => { // @ts-ignore accessing private prop
100
- return storage.segments.segmentCache[segmentName].has(userKey) ?
101
- prev!.concat({ n: segmentName }) :
102
- prev;
103
- }, [])
104
- },
105
- ls: {
106
- k: []
107
- }
108
- };
109
- }
110
- return prev;
111
- }, {}) :
112
- undefined
53
+ storage.segments.resetSegments({ k: mySegmentsData.map(s => ({ n: s })) });
113
54
  };
114
55
  }
@@ -7,8 +7,6 @@ import { ImpressionCountsCacheInMemory } from './ImpressionCountsCacheInMemory';
7
7
  import { DEBUG, LOCALHOST_MODE, NONE, STORAGE_MEMORY } from '../../utils/constants';
8
8
  import { shouldRecordTelemetry, TelemetryCacheInMemory } from './TelemetryCacheInMemory';
9
9
  import { UniqueKeysCacheInMemoryCS } from './UniqueKeysCacheInMemoryCS';
10
- import { getMatching } from '../../utils/key';
11
- import { loadData } from '../dataLoader';
12
10
 
13
11
  /**
14
12
  * InMemory storage factory for standalone client-side SplitFactory
@@ -16,7 +14,7 @@ import { loadData } from '../dataLoader';
16
14
  * @param params parameters required by EventsCacheSync
17
15
  */
18
16
  export function InMemoryStorageCSFactory(params: IStorageFactoryParams): IStorageSync {
19
- const { settings: { scheduler: { impressionsQueueSize, eventsQueueSize, }, sync: { impressionsMode, __splitFiltersValidation }, preloadedData }, onReadyFromCacheCb } = params;
17
+ const { settings: { scheduler: { impressionsQueueSize, eventsQueueSize, }, sync: { impressionsMode, __splitFiltersValidation } } } = params;
20
18
 
21
19
  const splits = new SplitsCacheInMemory(__splitFiltersValidation);
22
20
  const segments = new MySegmentsCacheInMemory();
@@ -44,18 +42,11 @@ export function InMemoryStorageCSFactory(params: IStorageFactoryParams): IStorag
44
42
  },
45
43
 
46
44
  // When using shared instantiation with MEMORY we reuse everything but segments (they are unique per key)
47
- shared(matchingKey: string) {
48
- const segments = new MySegmentsCacheInMemory();
49
- const largeSegments = new MySegmentsCacheInMemory();
50
-
51
- if (preloadedData) {
52
- loadData(preloadedData, { segments, largeSegments }, matchingKey);
53
- }
54
-
45
+ shared() {
55
46
  return {
56
47
  splits: this.splits,
57
- segments,
58
- largeSegments,
48
+ segments: new MySegmentsCacheInMemory(),
49
+ largeSegments: new MySegmentsCacheInMemory(),
59
50
  impressions: this.impressions,
60
51
  impressionCounts: this.impressionCounts,
61
52
  events: this.events,
@@ -81,12 +72,6 @@ export function InMemoryStorageCSFactory(params: IStorageFactoryParams): IStorag
81
72
  if (storage.uniqueKeys) storage.uniqueKeys.track = noopTrack;
82
73
  }
83
74
 
84
-
85
- if (preloadedData) {
86
- loadData(preloadedData, storage, getMatching(params.settings.core.key));
87
- if (splits.getChangeNumber() > -1) onReadyFromCacheCb();
88
- }
89
-
90
75
  return storage;
91
76
  }
92
77
 
@@ -488,6 +488,8 @@ export interface IStorageAsync extends IStorageBase<
488
488
 
489
489
  /** StorageFactory */
490
490
 
491
+ export type DataLoader = (storage: IStorageSync, matchingKey: string) => void
492
+
491
493
  export interface IStorageFactoryParams {
492
494
  settings: ISettings,
493
495
  /**
@@ -495,10 +497,6 @@ export interface IStorageFactoryParams {
495
497
  * It is meant for emitting SDK_READY event in consumer mode, and waiting before using the storage in the synchronizer.
496
498
  */
497
499
  onReadyCb: (error?: any) => void,
498
- /**
499
- * It is meant for emitting SDK_READY_FROM_CACHE event in standalone mode with preloaded data
500
- */
501
- onReadyFromCacheCb: () => void,
502
500
  }
503
501
 
504
502
  export type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS' | 'PLUGGABLE';
@@ -1,12 +1,6 @@
1
1
  import { splitsParserFromSettingsFactory } from './splitsParser/splitsParserFromSettings';
2
2
  import { syncManagerOfflineFactory } from './syncManagerOffline';
3
- import { SplitIO } from '../../types';
4
3
 
5
- // Singleton instance of the factory function for offline SyncManager from object (a.k.a. localhostFromObject)
4
+ // Singleton instance of the factory function for offline SyncManager from object
6
5
  // SDK instances instantiate their SyncManagers with the same factory
7
- const localhostFromObject = syncManagerOfflineFactory(splitsParserFromSettingsFactory) as SplitIO.LocalhostFactory;
8
- localhostFromObject.type = 'LocalhostFromObject';
9
-
10
- export function LocalhostFromObject(): SplitIO.LocalhostFactory {
11
- return localhostFromObject;
12
- }
6
+ export const localhostFromObjectFactory = syncManagerOfflineFactory(splitsParserFromSettingsFactory);
package/src/types.ts CHANGED
@@ -1,11 +1,8 @@
1
- import { IMembershipsResponse, ISplit, ISplitFiltersValidation } from './dtos/types';
1
+ /* eslint-disable no-use-before-define */
2
+ import { ISplitFiltersValidation } from './dtos/types';
2
3
  import { IIntegration, IIntegrationFactoryParams } from './integrations/types';
3
4
  import { ILogger } from './logger/types';
4
- import { ISdkFactoryContext } from './sdkFactory/types';
5
- /* eslint-disable no-use-before-define */
6
-
7
5
  import { IStorageFactoryParams, IStorageSync, IStorageAsync, IStorageSyncFactory, IStorageAsyncFactory } from './storages/types';
8
- import { ISyncManagerCS } from './sync/types';
9
6
 
10
7
  /**
11
8
  * Reduced version of NodeJS.EventEmitter interface with the minimal methods used by the SDK
@@ -97,7 +94,6 @@ export interface ISettings {
97
94
  eventsFirstPushWindow: number
98
95
  },
99
96
  readonly storage: IStorageSyncFactory | IStorageAsyncFactory,
100
- readonly preloadedData?: SplitIO.PreloadedData,
101
97
  readonly integrations: Array<{
102
98
  readonly type: string,
103
99
  (params: IIntegrationFactoryParams): IIntegration | void
@@ -117,7 +113,6 @@ export interface ISettings {
117
113
  splitFilters: SplitIO.SplitFilter[],
118
114
  impressionsMode: SplitIO.ImpressionsMode,
119
115
  __splitFiltersValidation: ISplitFiltersValidation,
120
- localhostMode?: SplitIO.LocalhostFactory,
121
116
  enabled: boolean,
122
117
  flagSpecVersion: string,
123
118
  requestOptions?: {
@@ -667,13 +662,6 @@ export namespace SplitIO {
667
662
  * @typedef {Promise<SplitNames>} SplitNamesAsync
668
663
  */
669
664
  export type SplitNamesAsync = Promise<SplitNames>;
670
- /**
671
- * Localhost mode factory.
672
- */
673
- export type LocalhostFactory = {
674
- type: 'LocalhostFromObject' | 'LocalhostFromFile'
675
- (params: ISdkFactoryContext): ISyncManagerCS
676
- }
677
665
  /**
678
666
  * Impression listener interface. This is the interface that needs to be implemented
679
667
  * by the element you provide to the SDK as impression listener.
@@ -771,31 +759,31 @@ export namespace SplitIO {
771
759
  * If this value is older than 10 days ago (expiration time policy), the data is not used to update the storage content.
772
760
  * @TODO configurable expiration time policy?
773
761
  */
774
- // lastUpdated: number,
762
+ lastUpdated: number,
775
763
  /**
776
764
  * Change number of the preloaded data.
777
765
  * If this value is older than the current changeNumber at the storage, the data is not used to update the storage content.
778
766
  */
779
767
  since: number,
780
768
  /**
781
- * List of feature flag definitions.
782
- * @TODO rename to flags
769
+ * Map of feature flags to their stringified definitions.
783
770
  */
784
- splitsData: ISplit[],
771
+ splitsData: {
772
+ [splitName: string]: string
773
+ },
785
774
  /**
786
- * Optional map of user keys to their memberships.
787
- * @TODO rename to memberships
775
+ * Optional map of user keys to their list of segments.
776
+ * @TODO remove when releasing first version
788
777
  */
789
- membershipsData?: {
790
- [key: string]: IMembershipsResponse
778
+ mySegmentsData?: {
779
+ [key: string]: string[]
791
780
  },
792
781
  /**
793
- * Optional map of segments to their list of keys.
794
- * This property is ignored if `membershipsData` was provided.
795
- * @TODO rename to segments
782
+ * Optional map of segments to their stringified definitions.
783
+ * This property is ignored if `mySegmentsData` was provided.
796
784
  */
797
785
  segmentsData?: {
798
- [segmentName: string]: string[]
786
+ [segmentName: string]: string
799
787
  },
800
788
  }
801
789
  /**
@@ -80,7 +80,6 @@ export const base = {
80
80
  splitFilters: undefined,
81
81
  // impressions collection mode
82
82
  impressionsMode: OPTIMIZED,
83
- localhostMode: undefined,
84
83
  enabled: true,
85
84
  flagSpecVersion: FLAG_SPEC_VERSION
86
85
  },
@@ -102,7 +101,7 @@ function fromSecondsToMillis(n: number) {
102
101
  */
103
102
  export function settingsValidation(config: unknown, validationParams: ISettingsValidationParams) {
104
103
 
105
- const { defaults, runtime, storage, integrations, logger, localhost, consent, flagSpec } = validationParams;
104
+ const { defaults, runtime, storage, integrations, logger, consent, flagSpec } = validationParams;
106
105
 
107
106
  // creates a settings object merging base, defaults and config objects.
108
107
  const withDefaults = merge({}, base, defaults, config) as ISettings;
@@ -180,8 +179,6 @@ export function settingsValidation(config: unknown, validationParams: ISettingsV
180
179
  // @ts-ignore, modify readonly prop
181
180
  if (integrations) withDefaults.integrations = integrations(withDefaults);
182
181
 
183
- if (localhost) sync.localhostMode = localhost(withDefaults);
184
-
185
182
  // validate push options
186
183
  if (withDefaults.streamingEnabled !== false) { // @ts-ignore, modify readonly prop
187
184
  withDefaults.streamingEnabled = true;
@@ -20,8 +20,6 @@ export interface ISettingsValidationParams {
20
20
  integrations?: (settings: ISettings) => ISettings['integrations'],
21
21
  /** Logger validator (`settings.debug`) */
22
22
  logger: (settings: ISettings) => ISettings['log'],
23
- /** Localhost mode validator (`settings.sync.localhostMode`) */
24
- localhost?: (settings: ISettings) => ISettings['sync']['localhostMode'],
25
23
  /** User consent validator (`settings.userConsent`) */
26
24
  consent?: (settings: ISettings) => ISettings['userConsent'],
27
25
  /** Flag spec version validation. Configurable by the JS Synchronizer but not by the SDKs */
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { InMemoryStorageFactory } from './storages/inMemory/InMemoryStorage';
2
- export { InMemoryStorageCSFactory } from './storages/inMemory/InMemoryStorageCS';
3
- export { InLocalStorage } from './storages/inLocalStorage';
4
- export { PluggableStorage } from './storages/pluggable';
5
- export { InRedisStorage } from './storages/inRedis';
1
+ // Declaration file for JavaScript Browser Split Software SDK
2
+ // Project: http://www.split.io/
3
+ // Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
4
+
5
+ /// <reference path="./splitio.d.ts" />