@splitsoftware/splitio-commons 0.1.1-canary.6 → 0.1.1-rc.18

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 (269) hide show
  1. package/cjs/evaluator/matchers/matcherTypes.js +4 -4
  2. package/cjs/evaluator/matchersTransform/index.js +11 -11
  3. package/cjs/evaluator/value/sanitize.js +6 -6
  4. package/cjs/listeners/browser.js +5 -2
  5. package/cjs/listeners/node.js +9 -2
  6. package/cjs/logger/constants.js +3 -1
  7. package/cjs/logger/messages/error.js +3 -2
  8. package/cjs/logger/messages/info.js +2 -2
  9. package/cjs/logger/messages/warn.js +2 -1
  10. package/cjs/readiness/readinessManager.js +10 -7
  11. package/cjs/sdkFactory/index.js +1 -1
  12. package/cjs/services/splitApi.js +9 -1
  13. package/cjs/services/splitHttpClient.js +5 -4
  14. package/cjs/storages/AbstractSplitsCacheSync.js +1 -1
  15. package/cjs/storages/inLocalStorage/index.js +5 -2
  16. package/cjs/storages/inMemory/InMemoryStorage.js +2 -0
  17. package/cjs/storages/inMemory/InMemoryStorageCS.js +2 -0
  18. package/cjs/storages/inRedis/SplitsCacheInRedis.js +6 -2
  19. package/cjs/storages/inRedis/index.js +5 -2
  20. package/cjs/storages/pluggable/SplitsCachePluggable.js +6 -2
  21. package/cjs/storages/pluggable/inMemoryWrapper.js +6 -7
  22. package/cjs/storages/pluggable/index.js +5 -2
  23. package/cjs/storages/pluggable/wrapperAdapter.js +0 -1
  24. package/cjs/sync/offline/splitsParser/splitsParserFromFile.js +92 -89
  25. package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +45 -42
  26. package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +14 -4
  27. package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +0 -8
  28. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +30 -10
  29. package/cjs/sync/polling/updaters/segmentChangesUpdater.js +2 -4
  30. package/cjs/sync/streaming/SSEClient/index.js +38 -20
  31. package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +7 -0
  32. package/cjs/sync/streaming/SSEHandler/NotificationParser.js +4 -1
  33. package/cjs/sync/streaming/SSEHandler/index.js +8 -9
  34. package/cjs/sync/streaming/SSEHandler/types.js +14 -0
  35. package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +5 -5
  36. package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -1
  37. package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +5 -3
  38. package/cjs/sync/streaming/constants.js +3 -1
  39. package/cjs/sync/streaming/mySegmentsV2utils.js +75 -0
  40. package/cjs/sync/streaming/pushManager.js +148 -40
  41. package/cjs/sync/submitters/metricsSyncTask.js +1 -1
  42. package/cjs/sync/submitters/submitterSyncTask.js +2 -2
  43. package/cjs/sync/syncManagerFromFile.js +15 -0
  44. package/cjs/sync/syncManagerFromObject.js +14 -0
  45. package/cjs/sync/syncManagerOffline.js +3 -3
  46. package/cjs/sync/syncManagerOnline.js +18 -5
  47. package/cjs/sync/syncTask.js +1 -1
  48. package/cjs/trackers/impressionObserver/ImpressionObserver.js +0 -2
  49. package/cjs/trackers/impressionObserver/buildKey.js +3 -9
  50. package/cjs/trackers/impressionObserver/impressionObserverCS.js +2 -2
  51. package/cjs/trackers/impressionObserver/impressionObserverSS.js +3 -3
  52. package/cjs/utils/constants/index.js +4 -1
  53. package/cjs/utils/decompress/index.js +427 -0
  54. package/cjs/utils/murmur3/{commons.js → common.js} +2 -6
  55. package/cjs/utils/murmur3/murmur3.js +11 -12
  56. package/cjs/utils/murmur3/murmur3_128.js +7 -142
  57. package/cjs/utils/murmur3/murmur3_128_x86.js +154 -0
  58. package/cjs/utils/murmur3/murmur3_64.js +36 -0
  59. package/cjs/utils/murmur3/utfx.js +100 -106
  60. package/cjs/utils/promise/wrapper.js +14 -11
  61. package/cjs/utils/settingsValidation/index.js +5 -2
  62. package/cjs/utils/settingsValidation/localhost/index.js +20 -0
  63. package/cjs/utils/settingsValidation/splitFilters.js +0 -1
  64. package/cjs/utils/settingsValidation/storage/storageCS.js +18 -8
  65. package/cjs/utils/settingsValidation/url.js +1 -1
  66. package/esm/evaluator/matchers/matcherTypes.js +2 -2
  67. package/esm/evaluator/matchersTransform/index.js +12 -12
  68. package/esm/evaluator/value/sanitize.js +7 -7
  69. package/esm/listeners/browser.js +5 -2
  70. package/esm/listeners/node.js +9 -2
  71. package/esm/logger/constants.js +2 -0
  72. package/esm/logger/messages/error.js +3 -2
  73. package/esm/logger/messages/info.js +2 -2
  74. package/esm/logger/messages/warn.js +2 -1
  75. package/esm/readiness/readinessManager.js +10 -7
  76. package/esm/sdkFactory/index.js +1 -1
  77. package/esm/services/splitApi.js +9 -1
  78. package/esm/services/splitHttpClient.js +5 -4
  79. package/esm/storages/AbstractSplitsCacheSync.js +1 -1
  80. package/esm/storages/inLocalStorage/index.js +5 -2
  81. package/esm/storages/inMemory/InMemoryStorage.js +2 -0
  82. package/esm/storages/inMemory/InMemoryStorageCS.js +2 -0
  83. package/esm/storages/inRedis/SplitsCacheInRedis.js +6 -2
  84. package/esm/storages/inRedis/index.js +5 -2
  85. package/esm/storages/pluggable/SplitsCachePluggable.js +6 -2
  86. package/esm/storages/pluggable/inMemoryWrapper.js +6 -7
  87. package/esm/storages/pluggable/index.js +5 -2
  88. package/esm/storages/pluggable/wrapperAdapter.js +0 -1
  89. package/esm/sync/offline/splitsParser/splitsParserFromFile.js +90 -88
  90. package/esm/sync/offline/splitsParser/splitsParserFromSettings.js +43 -41
  91. package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +15 -5
  92. package/esm/sync/polling/fetchers/segmentChangesFetcher.js +0 -8
  93. package/esm/sync/polling/updaters/mySegmentsUpdater.js +30 -10
  94. package/esm/sync/polling/updaters/segmentChangesUpdater.js +2 -4
  95. package/esm/sync/streaming/SSEClient/index.js +38 -20
  96. package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +7 -0
  97. package/esm/sync/streaming/SSEHandler/NotificationParser.js +4 -1
  98. package/esm/sync/streaming/SSEHandler/index.js +9 -10
  99. package/esm/sync/streaming/SSEHandler/types.js +13 -1
  100. package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +5 -5
  101. package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -1
  102. package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +5 -3
  103. package/esm/sync/streaming/constants.js +2 -0
  104. package/esm/sync/streaming/mySegmentsV2utils.js +69 -0
  105. package/esm/sync/streaming/pushManager.js +150 -42
  106. package/esm/sync/submitters/metricsSyncTask.js +1 -1
  107. package/esm/sync/submitters/submitterSyncTask.js +2 -2
  108. package/esm/sync/syncManagerFromFile.js +11 -0
  109. package/esm/sync/syncManagerFromObject.js +10 -0
  110. package/esm/sync/syncManagerOffline.js +3 -3
  111. package/esm/sync/syncManagerOnline.js +18 -5
  112. package/esm/sync/syncTask.js +1 -1
  113. package/esm/trackers/impressionObserver/ImpressionObserver.js +0 -2
  114. package/esm/trackers/impressionObserver/buildKey.js +2 -9
  115. package/esm/trackers/impressionObserver/impressionObserverCS.js +2 -2
  116. package/esm/trackers/impressionObserver/impressionObserverSS.js +3 -3
  117. package/esm/utils/constants/index.js +3 -0
  118. package/esm/utils/decompress/index.js +424 -0
  119. package/esm/utils/murmur3/{commons.js → common.js} +1 -4
  120. package/esm/utils/murmur3/murmur3.js +1 -2
  121. package/esm/utils/murmur3/murmur3_128.js +7 -142
  122. package/esm/utils/murmur3/murmur3_128_x86.js +150 -0
  123. package/esm/utils/murmur3/murmur3_64.js +32 -0
  124. package/esm/utils/murmur3/utfx.js +96 -106
  125. package/esm/utils/promise/wrapper.js +14 -11
  126. package/esm/utils/settingsValidation/index.js +5 -2
  127. package/esm/utils/settingsValidation/localhost/index.js +16 -0
  128. package/esm/utils/settingsValidation/splitFilters.js +0 -1
  129. package/esm/utils/settingsValidation/storage/storageCS.js +16 -7
  130. package/esm/utils/settingsValidation/url.js +1 -1
  131. package/package.json +5 -5
  132. package/src/evaluator/matchers/matcherTypes.ts +2 -2
  133. package/src/evaluator/matchersTransform/index.ts +12 -12
  134. package/src/evaluator/value/sanitize.ts +7 -7
  135. package/src/listeners/browser.ts +5 -2
  136. package/src/listeners/node.ts +14 -2
  137. package/src/logger/constants.ts +2 -0
  138. package/src/logger/messages/error.ts +3 -2
  139. package/src/logger/messages/info.ts +2 -2
  140. package/src/logger/messages/warn.ts +3 -1
  141. package/src/readiness/readinessManager.ts +9 -7
  142. package/src/sdkFactory/index.ts +1 -1
  143. package/src/sdkFactory/types.ts +4 -5
  144. package/src/services/splitApi.ts +12 -3
  145. package/src/services/splitHttpClient.ts +6 -5
  146. package/src/services/types.ts +7 -3
  147. package/src/storages/AbstractSplitsCacheSync.ts +1 -1
  148. package/src/storages/inLocalStorage/index.ts +8 -4
  149. package/src/storages/inMemory/InMemoryStorage.ts +3 -0
  150. package/src/storages/inMemory/InMemoryStorageCS.ts +3 -0
  151. package/src/storages/inRedis/SplitsCacheInRedis.ts +3 -1
  152. package/src/storages/inRedis/index.ts +8 -4
  153. package/src/storages/pluggable/SegmentsCachePluggable.ts +1 -1
  154. package/src/storages/pluggable/SplitsCachePluggable.ts +3 -1
  155. package/src/storages/pluggable/inMemoryWrapper.ts +6 -7
  156. package/src/storages/pluggable/index.ts +8 -4
  157. package/src/storages/pluggable/wrapperAdapter.ts +0 -1
  158. package/src/storages/types.ts +18 -15
  159. package/src/sync/offline/splitsParser/splitsParserFromFile.ts +110 -105
  160. package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +45 -41
  161. package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +15 -5
  162. package/src/sync/polling/fetchers/segmentChangesFetcher.ts +0 -7
  163. package/src/sync/polling/types.ts +2 -1
  164. package/src/sync/polling/updaters/mySegmentsUpdater.ts +28 -10
  165. package/src/sync/polling/updaters/segmentChangesUpdater.ts +2 -3
  166. package/src/sync/streaming/AuthClient/types.ts +3 -0
  167. package/src/sync/streaming/SSEClient/index.ts +43 -23
  168. package/src/sync/streaming/SSEClient/types.ts +0 -1
  169. package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +8 -0
  170. package/src/sync/streaming/SSEHandler/NotificationParser.ts +4 -2
  171. package/src/sync/streaming/SSEHandler/index.ts +11 -20
  172. package/src/sync/streaming/SSEHandler/types.ts +37 -3
  173. package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +7 -6
  174. package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +2 -1
  175. package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +4 -3
  176. package/src/sync/streaming/UpdateWorkers/types.ts +1 -1
  177. package/src/sync/streaming/constants.ts +2 -0
  178. package/src/sync/streaming/mySegmentsV2utils.ts +77 -0
  179. package/src/sync/streaming/pushManager.ts +145 -42
  180. package/src/sync/streaming/types.ts +14 -22
  181. package/src/sync/submitters/metricsSyncTask.ts +1 -1
  182. package/src/sync/submitters/submitterSyncTask.ts +2 -1
  183. package/src/sync/syncManagerFromFile.ts +13 -0
  184. package/src/sync/syncManagerFromObject.ts +12 -0
  185. package/src/sync/syncManagerOffline.ts +3 -3
  186. package/src/sync/syncManagerOnline.ts +19 -5
  187. package/src/sync/syncTask.ts +1 -1
  188. package/src/sync/types.ts +3 -1
  189. package/src/trackers/impressionObserver/ImpressionObserver.ts +4 -6
  190. package/src/trackers/impressionObserver/buildKey.ts +2 -16
  191. package/src/trackers/impressionObserver/impressionObserverCS.ts +2 -2
  192. package/src/trackers/impressionObserver/impressionObserverSS.ts +3 -3
  193. package/src/types.ts +16 -2
  194. package/src/utils/constants/index.ts +6 -1
  195. package/src/utils/decompress/index.ts +429 -0
  196. package/src/utils/lang/index.ts +1 -1
  197. package/src/utils/murmur3/{commons.ts → common.ts} +1 -5
  198. package/src/utils/murmur3/murmur3.ts +5 -5
  199. package/src/utils/murmur3/murmur3_128.ts +7 -180
  200. package/src/utils/murmur3/murmur3_128_x86.ts +188 -0
  201. package/src/utils/murmur3/murmur3_64.ts +36 -0
  202. package/src/utils/murmur3/utfx.ts +92 -110
  203. package/src/utils/promise/wrapper.ts +12 -9
  204. package/src/utils/settingsValidation/index.ts +8 -4
  205. package/src/utils/settingsValidation/localhost/index.ts +19 -0
  206. package/src/utils/settingsValidation/splitFilters.ts +0 -1
  207. package/src/utils/settingsValidation/storage/storageCS.ts +21 -8
  208. package/src/utils/settingsValidation/types.ts +2 -11
  209. package/src/utils/settingsValidation/url.ts +1 -1
  210. package/types/evaluator/matchers/matcherTypes.d.ts +2 -2
  211. package/types/listeners/browser.d.ts +3 -3
  212. package/types/listeners/node.d.ts +3 -2
  213. package/types/logger/constants.d.ts +2 -0
  214. package/types/sdkFactory/types.d.ts +4 -5
  215. package/types/services/types.d.ts +4 -0
  216. package/types/storages/inLocalStorage/index.d.ts +2 -2
  217. package/types/storages/inMemory/InMemoryStorage.d.ts +3 -0
  218. package/types/storages/inMemory/InMemoryStorageCS.d.ts +3 -0
  219. package/types/storages/inRedis/index.d.ts +2 -2
  220. package/types/storages/pluggable/index.d.ts +2 -2
  221. package/types/storages/types.d.ts +15 -15
  222. package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +2 -7
  223. package/types/sync/offline/splitsParser/splitsParserFromSettings.d.ts +1 -5
  224. package/types/sync/polling/types.d.ts +2 -1
  225. package/types/sync/streaming/AuthClient/indexV1.d.ts +12 -0
  226. package/types/sync/streaming/AuthClient/indexV2.d.ts +8 -0
  227. package/types/sync/streaming/AuthClient/types.d.ts +2 -0
  228. package/types/sync/streaming/SSEClient/index.d.ts +9 -12
  229. package/types/sync/streaming/SSEClient/types.d.ts +0 -1
  230. package/types/sync/streaming/SSEHandler/NotificationParser.d.ts +3 -2
  231. package/types/sync/streaming/SSEHandler/types.d.ts +30 -2
  232. package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +4 -3
  233. package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +2 -1
  234. package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +3 -2
  235. package/types/sync/streaming/UpdateWorkers/types.d.ts +1 -1
  236. package/types/sync/streaming/constants.d.ts +3 -1
  237. package/types/sync/streaming/mySegmentsV2utils.d.ts +27 -0
  238. package/types/sync/streaming/pushManagerNoUsers.d.ts +13 -0
  239. package/types/sync/streaming/types.d.ts +9 -5
  240. package/types/sync/submitters/submitterSyncTask.d.ts +1 -1
  241. package/types/sync/syncManagerFromFile.d.ts +2 -0
  242. package/types/sync/syncManagerFromObject.d.ts +2 -0
  243. package/types/sync/syncManagerOffline.d.ts +1 -1
  244. package/types/sync/syncTask.d.ts +1 -1
  245. package/types/sync/types.d.ts +2 -0
  246. package/types/trackers/impressionObserver/ImpressionObserver.d.ts +2 -2
  247. package/types/trackers/impressionObserver/buildKey.d.ts +1 -1
  248. package/types/trackers/impressionObserver/impressionObserverCS.d.ts +2 -2
  249. package/types/trackers/impressionObserver/impressionObserverSS.d.ts +2 -2
  250. package/types/types.d.ts +16 -2
  251. package/types/utils/constants/index.d.ts +5 -1
  252. package/types/utils/decompress/index.d.ts +16 -0
  253. package/types/utils/lang/index.d.ts +1 -1
  254. package/types/utils/murmur3/common.d.ts +12 -0
  255. package/types/utils/murmur3/murmur3.d.ts +2 -2
  256. package/types/utils/murmur3/murmur3_128.d.ts +5 -0
  257. package/types/utils/murmur3/murmur3_128_x86.d.ts +7 -0
  258. package/types/utils/murmur3/murmur3_64.d.ts +10 -0
  259. package/types/utils/murmur3/utfx.d.ts +24 -6
  260. package/types/utils/settingsValidation/index.d.ts +3 -2
  261. package/types/utils/settingsValidation/localhost/index.d.ts +9 -0
  262. package/types/utils/settingsValidation/storage/storageCS.d.ts +7 -1
  263. package/types/utils/settingsValidation/types.d.ts +2 -10
  264. package/cjs/sync/streaming/pushManagerCS.js +0 -178
  265. package/cjs/sync/streaming/pushManagerSS.js +0 -128
  266. package/esm/sync/streaming/pushManagerCS.js +0 -174
  267. package/esm/sync/streaming/pushManagerSS.js +0 -124
  268. package/src/sync/streaming/pushManagerCS.ts +0 -237
  269. package/src/sync/streaming/pushManagerSS.ts +0 -177
@@ -2,6 +2,7 @@ import { ISplitsEventEmitter } from '../../../readiness/types';
2
2
  import { ISplitsCacheSync } from '../../../storages/types';
3
3
  import Backoff from '../../../utils/Backoff';
4
4
  import { ISegmentsSyncTask, ISplitsSyncTask } from '../../polling/types';
5
+ import { ISplitKillData, ISplitUpdateData } from '../SSEHandler/types';
5
6
  import { IUpdateWorker } from './types';
6
7
  /**
7
8
  * SplitsUpdateWorker class
@@ -26,7 +27,7 @@ export default class SplitsUpdateWorker implements IUpdateWorker {
26
27
  *
27
28
  * @param {number} changeNumber change number of the SPLIT_UPDATE notification
28
29
  */
29
- put(changeNumber: number): void;
30
+ put({ changeNumber }: Pick<ISplitUpdateData, 'changeNumber'>): void;
30
31
  /**
31
32
  * Invoked by NotificationProcessor on SPLIT_KILL event
32
33
  *
@@ -34,5 +35,5 @@ export default class SplitsUpdateWorker implements IUpdateWorker {
34
35
  * @param {string} splitName name of split to kill
35
36
  * @param {string} defaultTreatment default treatment value
36
37
  */
37
- killSplit(changeNumber: number, splitName: string, defaultTreatment: string): void;
38
+ killSplit({ changeNumber, splitName, defaultTreatment }: ISplitKillData): void;
38
39
  }
@@ -1,5 +1,5 @@
1
1
  import Backoff from '../../../utils/Backoff';
2
2
  export interface IUpdateWorker {
3
3
  readonly backoff: Backoff;
4
- put(changeNumber: number, ...args: any[]): void;
4
+ put(...args: any[]): void;
5
5
  }
@@ -20,6 +20,7 @@ export declare const PUSH_SUBSYSTEM_UP = "PUSH_SUBSYSTEM_UP";
20
20
  */
21
21
  export declare const PUSH_SUBSYSTEM_DOWN = "PUSH_SUBSYSTEM_DOWN";
22
22
  export declare const MY_SEGMENTS_UPDATE = "MY_SEGMENTS_UPDATE";
23
+ export declare const MY_SEGMENTS_UPDATE_V2 = "MY_SEGMENTS_UPDATE_V2";
23
24
  export declare const SEGMENT_UPDATE = "SEGMENT_UPDATE";
24
25
  export declare const SPLIT_KILL = "SPLIT_KILL";
25
26
  export declare const SPLIT_UPDATE = "SPLIT_UPDATE";
@@ -28,5 +29,6 @@ export declare const OCCUPANCY = "OCCUPANCY";
28
29
  export declare enum ControlType {
29
30
  STREAMING_DISABLED = "STREAMING_DISABLED",
30
31
  STREAMING_PAUSED = "STREAMING_PAUSED",
31
- STREAMING_RESUMED = "STREAMING_RESUMED"
32
+ STREAMING_RESUMED = "STREAMING_RESUMED",
33
+ STREAMING_RESET = "STREAMING_RESET"
32
34
  }
@@ -0,0 +1,27 @@
1
+ import { Compression, KeyList } from './SSEHandler/types';
2
+ /**
3
+ * Decode, decompress and parse the provided 'data' into a KeyList object
4
+ *
5
+ * @param {string} data
6
+ * @param {number} compression
7
+ * @returns {{a?: string[], r?: string[] }}
8
+ * @throws if data string cannot be decoded, decompressed or parsed
9
+ */
10
+ export declare function parseKeyList(data: string, compression: Compression): KeyList;
11
+ /**
12
+ * Decode, decompress and parse the provided 'data' into a Bitmap object
13
+ *
14
+ * @param {string} data
15
+ * @param {number} compression
16
+ * @returns {Uint8Array}
17
+ * @throws if data string cannot be decoded or decompressed
18
+ */
19
+ export declare function parseBitmap(data: string, compression: Compression): Uint8Array;
20
+ /**
21
+ * Check if the 'bitmap' bit at 'hash64hex' position is 1
22
+ *
23
+ * @param {Uint8Array} bitmap
24
+ * @param {string} hash64hex 16-chars string, representing a number in hexa
25
+ * @returns {boolean}
26
+ */
27
+ export declare function isInBitmap(bitmap: Uint8Array, hash64hex: string): boolean;
@@ -0,0 +1,13 @@
1
+ import { IPushManagerCS } from './types';
2
+ import { IStorageSync } from '../../storages/types';
3
+ import { IReadinessManager } from '../../readiness/types';
4
+ import { IPollingManager } from '../polling/types';
5
+ import { IFetchAuthV2 } from '../../services/types';
6
+ import { ISettings } from '../../types';
7
+ import { IPlatform } from '../../sdkFactory/types';
8
+ /**
9
+ * PushManager factory:
10
+ * - for server-side if key is not provided in settings.
11
+ * - for client-side, with support for multiple clients, if key is provided in settings
12
+ */
13
+ export default function pushManagerFactory(pollingManager: IPollingManager, storage: IStorageSync, readiness: IReadinessManager, fetchAuthV2: IFetchAuthV2, platform: IPlatform, settings: ISettings): IPushManagerCS | undefined;
@@ -1,4 +1,4 @@
1
- import { IMySegmentsUpdateData } from './SSEHandler/types';
1
+ import { IMySegmentsUpdateData, IMySegmentsUpdateV2Data, ISegmentUpdateData, ISplitUpdateData, ISplitKillData } from './SSEHandler/types';
2
2
  import { ITask } from '../types';
3
3
  import { IPollingManager, ISegmentsSyncTask } from '../polling/types';
4
4
  import { IReadinessManager } from '../../readiness/types';
@@ -6,25 +6,28 @@ import { IFetchAuth } from '../../services/types';
6
6
  import { IStorageSync } from '../../storages/types';
7
7
  import { IEventEmitter, ISettings } from '../../types';
8
8
  import { IPlatform } from '../../sdkFactory/types';
9
+ import { ControlType } from './constants';
9
10
  export declare type PUSH_SUBSYSTEM_UP = 'PUSH_SUBSYSTEM_UP';
10
11
  export declare type PUSH_SUBSYSTEM_DOWN = 'PUSH_SUBSYSTEM_DOWN';
11
12
  export declare type PUSH_NONRETRYABLE_ERROR = 'PUSH_NONRETRYABLE_ERROR';
12
13
  export declare type PUSH_RETRYABLE_ERROR = 'PUSH_RETRYABLE_ERROR';
13
14
  export declare type MY_SEGMENTS_UPDATE = 'MY_SEGMENTS_UPDATE';
15
+ export declare type MY_SEGMENTS_UPDATE_V2 = 'MY_SEGMENTS_UPDATE_V2';
14
16
  export declare type SEGMENT_UPDATE = 'SEGMENT_UPDATE';
15
17
  export declare type SPLIT_KILL = 'SPLIT_KILL';
16
18
  export declare type SPLIT_UPDATE = 'SPLIT_UPDATE';
17
19
  export declare type CONTROL = 'CONTROL';
18
20
  export declare type OCCUPANCY = 'OCCUPANCY';
19
- export declare type IPushEvent = PUSH_SUBSYSTEM_UP | PUSH_SUBSYSTEM_DOWN | PUSH_NONRETRYABLE_ERROR | PUSH_RETRYABLE_ERROR | MY_SEGMENTS_UPDATE | SEGMENT_UPDATE | SPLIT_UPDATE | SPLIT_KILL;
21
+ export declare type IPushEvent = PUSH_SUBSYSTEM_UP | PUSH_SUBSYSTEM_DOWN | PUSH_NONRETRYABLE_ERROR | PUSH_RETRYABLE_ERROR | MY_SEGMENTS_UPDATE | MY_SEGMENTS_UPDATE_V2 | SEGMENT_UPDATE | SPLIT_UPDATE | SPLIT_KILL | ControlType.STREAMING_RESET;
22
+ declare type IParsedData<T extends IPushEvent> = T extends MY_SEGMENTS_UPDATE ? IMySegmentsUpdateData : T extends MY_SEGMENTS_UPDATE_V2 ? IMySegmentsUpdateV2Data : T extends SEGMENT_UPDATE ? ISegmentUpdateData : T extends SPLIT_UPDATE ? ISplitUpdateData : T extends SPLIT_KILL ? ISplitKillData : undefined;
20
23
  /**
21
24
  * EventEmitter used as Feedback Loop between the SyncManager and PushManager,
22
25
  * where the latter pushes messages and the former consumes it
23
26
  */
24
27
  export interface IPushEventEmitter extends IEventEmitter {
25
- once<T extends IPushEvent>(event: T, listener: (...args: T extends MY_SEGMENTS_UPDATE ? [parsedData: IMySegmentsUpdateData, channel: string] : T extends SEGMENT_UPDATE ? [changeNumber: number, segmentName: string] : T extends SPLIT_UPDATE ? [changeNumber: number] : T extends SPLIT_KILL ? [changeNumber: number, splitName: string, defaultTreatment: string] : any[]) => void): this;
26
- on<T extends IPushEvent>(event: T, listener: (...args: T extends MY_SEGMENTS_UPDATE ? [parsedData: IMySegmentsUpdateData, channel: string] : T extends SEGMENT_UPDATE ? [changeNumber: number, segmentName: string] : T extends SPLIT_UPDATE ? [changeNumber: number] : T extends SPLIT_KILL ? [changeNumber: number, splitName: string, defaultTreatment: string] : any[]) => void): this;
27
- emit<T extends IPushEvent>(event: T, ...args: T extends MY_SEGMENTS_UPDATE ? [parsedData: IMySegmentsUpdateData, channel: string] : T extends SEGMENT_UPDATE ? [changeNumber: number, segmentName: string] : T extends SPLIT_UPDATE ? [changeNumber: number] : T extends SPLIT_KILL ? [changeNumber: number, splitName: string, defaultTreatment: string] : any[]): boolean;
28
+ once<T extends IPushEvent>(event: T, listener: (parsedData: IParsedData<T>, channel: T extends MY_SEGMENTS_UPDATE ? string : undefined) => void): this;
29
+ on<T extends IPushEvent>(event: T, listener: (parsedData: IParsedData<T>, channel: T extends MY_SEGMENTS_UPDATE ? string : undefined) => void): this;
30
+ emit<T extends IPushEvent>(event: T, parsedData?: IParsedData<T>, channel?: T extends MY_SEGMENTS_UPDATE ? string : undefined): boolean;
28
31
  }
29
32
  /**
30
33
  * PushManager for server-side
@@ -49,3 +52,4 @@ export declare type IPushManagerFactoryParams = [
49
52
  platform: IPlatform,
50
53
  settings: ISettings
51
54
  ];
55
+ export {};
@@ -7,4 +7,4 @@ import { IResponse } from '../../services/types';
7
7
  */
8
8
  export declare function submitterSyncTaskFactory<TState extends {
9
9
  length?: number;
10
- }>(log: ILogger, postClient: (body: string) => Promise<IResponse>, sourceCache: IRecorderCacheProducerSync<TState>, postRate: number, dataName: string, latencyTracker?: ITimeTracker, fromCacheToPayload?: (cacheData: TState) => any, maxRetries?: number): ISyncTask<[], void>;
10
+ }>(log: ILogger, postClient: (body: string) => Promise<IResponse>, sourceCache: IRecorderCacheProducerSync<TState>, postRate: number, dataName: string, latencyTracker?: ITimeTracker, fromCacheToPayload?: (cacheData: TState) => any, maxRetries?: number, debugLogs?: boolean): ISyncTask<[], void>;
@@ -0,0 +1,2 @@
1
+ import { SplitIO } from '../types';
2
+ export declare function LocalhostFromFile(): SplitIO.LocalhostFactory;
@@ -0,0 +1,2 @@
1
+ import { SplitIO } from '../types';
2
+ export declare function LocalhostFromObject(): SplitIO.LocalhostFactory;
@@ -6,4 +6,4 @@ import { ISplitsParser } from './offline/splitsParser/types';
6
6
  *
7
7
  * @param splitsParser e.g., `splitsParserFromFile`, `splitsParserFromSettings`.
8
8
  */
9
- export declare function syncManagerOfflineFactory(splitsParser: ISplitsParser): (params: ISyncManagerFactoryParams) => ISyncManagerCS;
9
+ export declare function syncManagerOfflineFactory(splitsParserFactory: () => ISplitsParser): (params: ISyncManagerFactoryParams) => ISyncManagerCS;
@@ -1,7 +1,7 @@
1
1
  import { ILogger } from '../logger/types';
2
2
  import { ISyncTask } from './types';
3
3
  /**
4
- * Creates a syncTask that handles the periodic execution of a givan task ("start" and "stop" methods).
4
+ * Creates a syncTask that handles the periodic execution of a given task ("start" and "stop" methods).
5
5
  * The task can be executed once calling the "execute" method.
6
6
  * NOTE: Multiple calls to "execute" are not queued. Use "isExecuting" method to handle synchronization.
7
7
  *
@@ -3,6 +3,7 @@ import { IPlatform } from '../sdkFactory/types';
3
3
  import { ISplitApi } from '../services/types';
4
4
  import { IStorageSync } from '../storages/types';
5
5
  import { ISettings } from '../types';
6
+ import { IPushManager } from './streaming/types';
6
7
  export interface ITask<Input extends any[] = []> {
7
8
  /**
8
9
  * Start periodic execution of the task
@@ -37,6 +38,7 @@ export interface ITimeTracker {
37
38
  /** SyncManager */
38
39
  export interface ISyncManager extends ITask {
39
40
  flush(): Promise<any>;
41
+ pushManager?: IPushManager;
40
42
  }
41
43
  export interface ISyncManagerCS extends ISyncManager {
42
44
  shared(matchingKey: string, readinessManager: IReadinessManager, storage: IStorageSync): ISyncManager;
@@ -1,8 +1,8 @@
1
1
  import { ImpressionDTO } from '../../types';
2
2
  import { IImpressionObserver } from './types';
3
- export default class ImpressionObserver implements IImpressionObserver {
3
+ export default class ImpressionObserver<K extends string | number> implements IImpressionObserver {
4
4
  private cache;
5
5
  private hasher;
6
- constructor(size: number, hasher: (impression: ImpressionDTO) => string | null);
6
+ constructor(size: number, hasher: (impression: ImpressionDTO) => K);
7
7
  testAndSet(impression: ImpressionDTO): number | undefined;
8
8
  }
@@ -1,2 +1,2 @@
1
1
  import { ImpressionDTO } from '../../types';
2
- export default function buildKey(impression: ImpressionDTO): string;
2
+ export declare function buildKey(impression: ImpressionDTO): string;
@@ -1,4 +1,4 @@
1
1
  import ImpressionObserver from './ImpressionObserver';
2
2
  import { ImpressionDTO } from '../../types';
3
- export declare function hashImpression32(impression: ImpressionDTO): string | null;
4
- export declare function impressionObserverCSFactory(): ImpressionObserver;
3
+ export declare function hashImpression32(impression: ImpressionDTO): number;
4
+ export declare function impressionObserverCSFactory(): ImpressionObserver<number>;
@@ -1,4 +1,4 @@
1
1
  import ImpressionObserver from './ImpressionObserver';
2
2
  import { ImpressionDTO } from '../../types';
3
- export declare function hashImpression128(impression: ImpressionDTO): string | null;
4
- export declare function impressionObserverSSFactory(): ImpressionObserver;
3
+ export declare function hashImpression128(impression: ImpressionDTO): string;
4
+ export declare function impressionObserverSSFactory(): ImpressionObserver<string>;
package/types/types.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  /// <reference types="node" />
2
+ import { ISplitFiltersValidation } from './dtos/types';
2
3
  import { IIntegration, IIntegrationFactoryParams } from './integrations/types';
3
4
  import { ILogger } from './logger/types';
4
- import { IStorageFactoryParams, IStorageSyncCS, IStorageSync, IStorageAsync } from './storages/types';
5
+ import { IStorageFactoryParams, IStorageSyncCS, IStorageSync, IStorageAsync, IStorageSyncFactory } from './storages/types';
6
+ import { ISyncManagerFactoryParams, ISyncManagerCS } from './sync/types';
5
7
  /**
6
8
  * EventEmitter interface with the minimal methods used by the SDK
7
9
  */
@@ -50,6 +52,8 @@ export declare type SDKMode = 'standalone' | 'consumer' | 'localhost';
50
52
  * Settings interface. This is a representation of the settings the SDK expose, that's why
51
53
  * most of it's props are readonly. Only features should be rewritten when localhost mode is active.
52
54
  * @interface ISettings
55
+ *
56
+ * NOTE: same ISettings interface from public type declarations extended with private properties.
53
57
  */
54
58
  export interface ISettings {
55
59
  readonly core: {
@@ -76,7 +80,7 @@ export interface ISettings {
76
80
  retriesOnFailureBeforeReady: number;
77
81
  eventsFirstPushWindow: number;
78
82
  };
79
- readonly storage: (params: IStorageFactoryParams) => IStorageSyncCS;
83
+ readonly storage: IStorageSyncFactory;
80
84
  readonly integrations?: Array<(params: IIntegrationFactoryParams) => IIntegration | void>;
81
85
  readonly urls: {
82
86
  events: string;
@@ -91,12 +95,15 @@ export interface ISettings {
91
95
  readonly sync: {
92
96
  splitFilters: SplitIO.SplitFilter[];
93
97
  impressionsMode: SplitIO.ImpressionsMode;
98
+ __splitFiltersValidation: ISplitFiltersValidation;
99
+ localhostMode: SplitIO.LocalhostFactory;
94
100
  };
95
101
  readonly runtime: {
96
102
  ip: string | false;
97
103
  hostname: string | false;
98
104
  };
99
105
  readonly log: ILogger;
106
+ readonly impressionListener?: unknown;
100
107
  }
101
108
  /**
102
109
  * Log levels.
@@ -571,6 +578,13 @@ export declare namespace SplitIO {
571
578
  * @typedef {Promise<SplitNames>} SplitNamesAsync
572
579
  */
573
580
  type SplitNamesAsync = Promise<SplitNames>;
581
+ /**
582
+ * Localhost mode factory.
583
+ */
584
+ type LocalhostFactory = {
585
+ type?: 'localhost';
586
+ (params: ISyncManagerFactoryParams): ISyncManagerCS;
587
+ };
574
588
  /**
575
589
  * Impression listener interface. This is the interface that needs to be implemented
576
590
  * by the element you provide to the SDK as impression listener.
@@ -1,3 +1,4 @@
1
+ import { StorageType } from '../../storages/types';
1
2
  export declare const CONTROL = "control";
2
3
  export declare const CONTROL_WITH_CONFIG: {
3
4
  treatment: string;
@@ -13,4 +14,7 @@ export declare const LOCALHOST_MODE = "localhost";
13
14
  export declare const STANDALONE_MODE = "standalone";
14
15
  export declare const PRODUCER_MODE = "producer";
15
16
  export declare const CONSUMER_MODE = "consumer";
16
- export declare const STORAGE_MEMORY = "MEMORY";
17
+ export declare const STORAGE_MEMORY: StorageType;
18
+ export declare const STORAGE_LOCALSTORAGE: StorageType;
19
+ export declare const STORAGE_REDIS: StorageType;
20
+ export declare const STORAGE_CUSTOM: StorageType;
@@ -0,0 +1,16 @@
1
+ export declare const algorithms: string | {
2
+ /**
3
+ * Expands GZIP data
4
+ * @param data The data to decompress
5
+ * @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.
6
+ * @returns The decompressed version of the data
7
+ */
8
+ gunzipSync(data: Uint8Array, out?: Uint8Array | undefined): Uint8Array;
9
+ /**
10
+ * Expands Zlib data
11
+ * @param data The data to decompress
12
+ * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
13
+ * @returns The decompressed version of the data
14
+ */
15
+ unzlibSync(data: Uint8Array, out?: Uint8Array | undefined): Uint8Array;
16
+ };
@@ -32,7 +32,7 @@ export declare function get(obj: any, prop: any, val: any): any;
32
32
  /**
33
33
  * Parses an array into a map of different arrays, grouping by the specified prop value.
34
34
  */
35
- export declare function groupBy(source: any, prop: string): Record<string, any[]>;
35
+ export declare function groupBy<T extends Record<string, any>>(source: T[], prop: string): Record<string, T[]>;
36
36
  /**
37
37
  * Checks if a given value is a boolean.
38
38
  */
@@ -0,0 +1,12 @@
1
+ export declare function UTF16ToUTF8(key: string): string | undefined;
2
+ /*!
3
+ * +----------------------------------------------------------------------------------+
4
+ * | murmurHash3.js v3.0.0 (http://github.com/karanlyons/murmurHash3.js) |
5
+ * | A TypeScript/JavaScript implementation of MurmurHash3's hashing algorithms. |
6
+ * |----------------------------------------------------------------------------------|
7
+ * | Copyright (c) 2012-2020 Karan Lyons. Freely distributable under the MIT license. |
8
+ * +----------------------------------------------------------------------------------+
9
+ */
10
+ export declare function x86Multiply(m: number, n: number): number;
11
+ export declare function x86Rotl(m: number, n: number): number;
12
+ export declare function x86Fmix(h: number): number;
@@ -1,2 +1,2 @@
1
- export declare function hash(str?: string, seed?: number): number;
2
- export declare function bucket(str?: string, seed?: number): number;
1
+ export declare function hash(str: string, seed?: number): number;
2
+ export declare function bucket(str: string, seed?: number): number;
@@ -1 +1,6 @@
1
+ /**
2
+ * x64 version of Murmur3 for 128bits.
3
+ *
4
+ * @param {string} str
5
+ */
1
6
  export declare function hash128(str: string, seed?: number): string;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * x86 version of Murmur3 for 128bits.
3
+ * Used by hashImpression128 because in JS it is more efficient than the x64 version, no matter the underlying OS/CPU arch.
4
+ *
5
+ * @param {string} str
6
+ */
7
+ export declare function hash128(str: string, seed?: number): string;
@@ -0,0 +1,10 @@
1
+ export declare type Hash64 = {
2
+ hex: string;
3
+ dec: string;
4
+ };
5
+ /**
6
+ * Gets the higher 64 bits of the x64 version of Murmur3 for 128bits, as decimal and hexadecimal number strings.
7
+ * Used for MySegments channel V2 notifications.
8
+ * @param {string} str
9
+ */
10
+ export declare function hash64(str: string): Hash64;
@@ -1,9 +1,27 @@
1
1
  export interface utfx {
2
- stringSource(key: string): () => number | null;
3
- stringDestination(): (...args: number[]) => string | undefined;
4
2
  encodeUTF16toUTF8(src: () => number | null, dst: (...args: number[]) => string | undefined): void;
5
- UTF16toUTF8(src: () => number | null, dst: (cp: number) => void): void;
6
- encodeUTF8(src: (() => number | null) | number, dst: (cp: number) => void): void;
7
3
  }
8
- declare const _default: utfx;
9
- export default _default;
4
+ /**
5
+ * Converts and encodes UTF16 characters to UTF8 bytes.
6
+ * @param {!function():number|null} src Characters source as a function returning the next char code respectively `null`
7
+ * if there are no more characters left.
8
+ * @param {!function(number)} dst Bytes destination as a function successively called with the next byte.
9
+ * @expose
10
+ */
11
+ export declare function encodeUTF16toUTF8(src: () => number | null, dst: (...args: number[]) => string | undefined): void;
12
+ /**
13
+ * Creates a source function for a string.
14
+ * @param {string} s String to read from
15
+ * @returns {!function():number|null} Source function returning the next char code respectively `null` if there are
16
+ * no more characters left.
17
+ * @throws {TypeError} If the argument is invalid
18
+ * @expose
19
+ */
20
+ export declare function stringSource(s: string): () => number | null;
21
+ /**
22
+ * Creates a destination function for a string.
23
+ * @returns {function(number=):undefined|string} Destination function successively called with the next char code.
24
+ * Returns the final string when called without arguments.
25
+ * @expose
26
+ */
27
+ export declare function stringDestination(): (...args: number[]) => string | undefined;
@@ -1,4 +1,5 @@
1
- import { ISettingsInternal, ISettingsValidationParams } from './types';
1
+ import { ISettingsValidationParams } from './types';
2
+ import { ISettings } from '../../types';
2
3
  /**
3
4
  * Validates the given config and use it to build a settings object.
4
5
  * NOTE: it doesn't validate the Api Key. Call `validateApikey` or `validateAndTrackApiKey` for that after settings validation.
@@ -6,4 +7,4 @@ import { ISettingsInternal, ISettingsValidationParams } from './types';
6
7
  * @param config user defined configuration
7
8
  * @param validationParams defaults and fields validators used to validate and creates a settings object from a given config
8
9
  */
9
- export declare function settingsValidation(config: unknown, validationParams: ISettingsValidationParams): ISettingsInternal;
10
+ export declare function settingsValidation(config: unknown, validationParams: ISettingsValidationParams): ISettings;
@@ -0,0 +1,9 @@
1
+ import { ISettings } from '../../../types';
2
+ /**
3
+ * This function validates `settings.storage` object
4
+ *
5
+ * @param {any} settings config object provided by the user to initialize the sdk
6
+ *
7
+ * @returns {Object} valid storage factory. It might be the default `InMemoryStorageCSFactory` if the provided storage is invalid.
8
+ */
9
+ export declare function validateLocalhost(settings: ISettings): import("../../../types").SplitIO.LocalhostFactory;
@@ -1,5 +1,10 @@
1
- import { ISettings } from '../../../types';
1
+ import { ISettings, SDKMode } from '../../../types';
2
2
  import { ILogger } from '../../../logger/types';
3
+ import { IStorageFactoryParams, IStorageSyncCS } from '../../../storages/types';
4
+ export declare function __InLocalStorageMockFactory(params: IStorageFactoryParams): IStorageSyncCS;
5
+ export declare namespace __InLocalStorageMockFactory {
6
+ var type: import("../../../storages/types").StorageType;
7
+ }
3
8
  /**
4
9
  * This function validates `settings.storage` object
5
10
  *
@@ -10,4 +15,5 @@ import { ILogger } from '../../../logger/types';
10
15
  export declare function validateStorageCS(settings: {
11
16
  log: ILogger;
12
17
  storage?: any;
18
+ mode?: SDKMode;
13
19
  }): ISettings['storage'];
@@ -1,4 +1,3 @@
1
- import { ISplitFiltersValidation } from '../../dtos/types';
2
1
  import { ISettings } from '../../types';
3
2
  /**
4
3
  * Parameters used to specialize the settings validation for each API variant
@@ -22,13 +21,6 @@ export interface ISettingsValidationParams {
22
21
  integrations?: (settings: ISettings) => ISettings['integrations'];
23
22
  /** Logger validator */
24
23
  logger: (settings: ISettings) => ISettings['log'];
25
- }
26
- /**
27
- * Settings interface extended with private properties used for internal purposes.
28
- */
29
- export interface ISettingsInternal extends ISettings {
30
- readonly sync: ISettings['sync'] & {
31
- __splitFiltersValidation: ISplitFiltersValidation;
32
- };
33
- readonly impressionListener?: unknown;
24
+ /** Localhost mode validator */
25
+ localhost?: (settings: ISettings) => ISettings['sync']['localhostMode'];
34
26
  }