@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
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitsParserFromFileFactory = void 0;
3
4
  var tslib_1 = require("tslib");
4
5
  /* eslint-disable no-undef */
5
6
  // @TODO consider moving it to Node-SDK and remove js-yaml dependency from Js-commons
@@ -11,7 +12,6 @@ var lang_1 = require("../../../utils/lang");
11
12
  var parseCondition_1 = tslib_1.__importDefault(require("./parseCondition"));
12
13
  var logPrefix = 'sync:offline:splits-fetcher: ';
13
14
  var DEFAULT_FILENAME = '.split';
14
- var previousMock = 'NO_MOCK_LOADED';
15
15
  function configFilesPath(configFilePath) {
16
16
  if (configFilePath === DEFAULT_FILENAME || !lang_1.isString(configFilePath)) {
17
17
  var root = process.env.HOME;
@@ -28,81 +28,6 @@ function configFilesPath(configFilePath) {
28
28
  throw new Error("Split configuration not found in " + configFilePath + " - Please review your Split file location.");
29
29
  return configFilePath;
30
30
  }
31
- // Parse `.split` configuration file and return a map of "Split Objects"
32
- function readSplitConfigFile(log, filePath) {
33
- var SPLIT_POSITION = 0;
34
- var TREATMENT_POSITION = 1;
35
- var data;
36
- try {
37
- data = fs_1.default.readFileSync(filePath, 'utf-8');
38
- }
39
- catch (e) {
40
- log.error(e.message);
41
- return {};
42
- }
43
- if (data === previousMock)
44
- return false;
45
- previousMock = data;
46
- var splitObjects = data.split(/\r?\n/).reduce(function (accum, line, index) {
47
- var tuple = line.trim();
48
- if (tuple === '' || tuple.charAt(0) === '#') {
49
- log.debug(logPrefix + ("Ignoring empty line or comment at #" + index));
50
- }
51
- else {
52
- tuple = tuple.split(/\s+/);
53
- if (tuple.length !== 2) {
54
- log.debug(logPrefix + ("Ignoring line since it does not have exactly two columns #" + index));
55
- }
56
- else {
57
- var splitName = tuple[SPLIT_POSITION];
58
- var condition = parseCondition_1.default({ treatment: tuple[TREATMENT_POSITION] });
59
- accum[splitName] = { conditions: [condition], configurations: {}, trafficTypeName: 'localhost' };
60
- }
61
- }
62
- return accum;
63
- }, {});
64
- return splitObjects;
65
- }
66
- // Parse `.yml` or `.yaml` configuration files and return a map of "Split Objects"
67
- function readYAMLConfigFile(log, filePath) {
68
- var data = '';
69
- var yamldoc = null;
70
- try {
71
- data = fs_1.default.readFileSync(filePath, 'utf8');
72
- if (data === previousMock)
73
- return false;
74
- previousMock = data;
75
- yamldoc = js_yaml_1.default.safeLoad(data);
76
- }
77
- catch (e) {
78
- log.error(e);
79
- return {};
80
- }
81
- // Each entry will be mapped to a condition, but we'll also keep the configurations map.
82
- var mocksData = yamldoc.reduce(function (accum, splitEntry) {
83
- var splitName = Object.keys(splitEntry)[0];
84
- if (!splitName || !lang_1.isString(splitEntry[splitName].treatment))
85
- log.error(logPrefix + 'Ignoring entry on YAML since the format is incorrect.');
86
- var mockData = splitEntry[splitName];
87
- // "Template" for each split accumulated data
88
- if (!accum[splitName]) {
89
- accum[splitName] = {
90
- configurations: {}, conditions: [], treatments: [], trafficTypeName: 'localhost'
91
- };
92
- }
93
- // Assign the config if there is one on the mock
94
- if (mockData.config)
95
- accum[splitName].configurations[mockData.treatment] = mockData.config;
96
- // Parse the condition from the entry.
97
- var condition = parseCondition_1.default(mockData);
98
- accum[splitName].conditions[condition.conditionType === 'ROLLOUT' ? 'push' : 'unshift'](condition);
99
- // Also keep track of the treatments, will be useful for manager functionality.
100
- accum[splitName].treatments.push(mockData.treatment);
101
- return accum;
102
- }, {});
103
- arrangeConditions(mocksData);
104
- return mocksData;
105
- }
106
31
  // This function is not pure nor meant to be. Here we apply modifications to cover
107
32
  // for behaviour that's ensured by the BE.
108
33
  function arrangeConditions(mocksData) {
@@ -130,19 +55,97 @@ function arrangeConditions(mocksData) {
130
55
  delete data.treatments;
131
56
  });
132
57
  }
133
- // Load the content of a configuration file into an Object
134
- function splitsParserFromFile(_a) {
135
- var features = _a.features, log = _a.log;
136
- var filePath = configFilesPath(features);
137
- var mockData;
138
- // If we have a filePath, it means the extension is correct, choose the parser.
139
- if (lang_1.endsWith(filePath, '.split')) {
140
- log.warn(logPrefix + '.split mocks will be deprecated soon in favor of YAML files, which provide more targeting power. Take a look in our documentation.');
141
- mockData = readSplitConfigFile(log, filePath);
58
+ function splitsParserFromFileFactory() {
59
+ var previousMock = 'NO_MOCK_LOADED';
60
+ // Parse `.split` configuration file and return a map of "Split Objects"
61
+ function readSplitConfigFile(log, filePath) {
62
+ var SPLIT_POSITION = 0;
63
+ var TREATMENT_POSITION = 1;
64
+ var data;
65
+ try {
66
+ data = fs_1.default.readFileSync(filePath, 'utf-8');
67
+ }
68
+ catch (e) {
69
+ log.error(e.message);
70
+ return {};
71
+ }
72
+ if (data === previousMock)
73
+ return false;
74
+ previousMock = data;
75
+ var splitObjects = data.split(/\r?\n/).reduce(function (accum, line, index) {
76
+ var tuple = line.trim();
77
+ if (tuple === '' || tuple.charAt(0) === '#') {
78
+ log.debug(logPrefix + ("Ignoring empty line or comment at #" + index));
79
+ }
80
+ else {
81
+ tuple = tuple.split(/\s+/);
82
+ if (tuple.length !== 2) {
83
+ log.debug(logPrefix + ("Ignoring line since it does not have exactly two columns #" + index));
84
+ }
85
+ else {
86
+ var splitName = tuple[SPLIT_POSITION];
87
+ var condition = parseCondition_1.default({ treatment: tuple[TREATMENT_POSITION] });
88
+ accum[splitName] = { conditions: [condition], configurations: {}, trafficTypeName: 'localhost' };
89
+ }
90
+ }
91
+ return accum;
92
+ }, {});
93
+ return splitObjects;
142
94
  }
143
- else {
144
- mockData = readYAMLConfigFile(log, filePath);
95
+ // Parse `.yml` or `.yaml` configuration files and return a map of "Split Objects"
96
+ function readYAMLConfigFile(log, filePath) {
97
+ var data = '';
98
+ var yamldoc = null;
99
+ try {
100
+ data = fs_1.default.readFileSync(filePath, 'utf8');
101
+ if (data === previousMock)
102
+ return false;
103
+ previousMock = data;
104
+ yamldoc = js_yaml_1.default.safeLoad(data);
105
+ }
106
+ catch (e) {
107
+ log.error(e);
108
+ return {};
109
+ }
110
+ // Each entry will be mapped to a condition, but we'll also keep the configurations map.
111
+ var mocksData = yamldoc.reduce(function (accum, splitEntry) {
112
+ var splitName = Object.keys(splitEntry)[0];
113
+ if (!splitName || !lang_1.isString(splitEntry[splitName].treatment))
114
+ log.error(logPrefix + 'Ignoring entry on YAML since the format is incorrect.');
115
+ var mockData = splitEntry[splitName];
116
+ // "Template" for each split accumulated data
117
+ if (!accum[splitName]) {
118
+ accum[splitName] = {
119
+ configurations: {}, conditions: [], treatments: [], trafficTypeName: 'localhost'
120
+ };
121
+ }
122
+ // Assign the config if there is one on the mock
123
+ if (mockData.config)
124
+ accum[splitName].configurations[mockData.treatment] = mockData.config;
125
+ // Parse the condition from the entry.
126
+ var condition = parseCondition_1.default(mockData);
127
+ accum[splitName].conditions[condition.conditionType === 'ROLLOUT' ? 'push' : 'unshift'](condition);
128
+ // Also keep track of the treatments, will be useful for manager functionality.
129
+ accum[splitName].treatments.push(mockData.treatment);
130
+ return accum;
131
+ }, {});
132
+ arrangeConditions(mocksData);
133
+ return mocksData;
145
134
  }
146
- return mockData;
135
+ // Load the content of a configuration file into an Object
136
+ return function splitsParserFromFile(_a) {
137
+ var features = _a.features, log = _a.log;
138
+ var filePath = configFilesPath(features);
139
+ var mockData;
140
+ // If we have a filePath, it means the extension is correct, choose the parser.
141
+ if (lang_1.endsWith(filePath, '.split')) {
142
+ log.warn(logPrefix + '.split mocks will be deprecated soon in favor of YAML files, which provide more targeting power. Take a look in our documentation.');
143
+ mockData = readSplitConfigFile(log, filePath);
144
+ }
145
+ else {
146
+ mockData = readYAMLConfigFile(log, filePath);
147
+ }
148
+ return mockData;
149
+ };
147
150
  }
148
- exports.default = splitsParserFromFile;
151
+ exports.splitsParserFromFileFactory = splitsParserFromFileFactory;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitsParserFromSettingsFactory = void 0;
3
4
  var tslib_1 = require("tslib");
4
5
  var lang_1 = require("../../../utils/lang");
5
6
  var parseCondition_1 = tslib_1.__importDefault(require("./parseCondition"));
6
- var previousMock = { 'emptyMock': '1' };
7
7
  function hasTreatmentChanged(prev, curr) {
8
8
  if (typeof prev !== typeof curr)
9
9
  return true;
@@ -14,47 +14,50 @@ function hasTreatmentChanged(prev, curr) {
14
14
  return prev.treatment !== curr.treatment || prev.config !== curr.config;
15
15
  }
16
16
  }
17
- function mockUpdated(currentData) {
18
- var names = Object.keys(currentData);
19
- // Different amount of items
20
- if (names.length !== Object.keys(previousMock).length) {
21
- previousMock = currentData;
22
- return true;
23
- }
24
- return names.some(function (name) {
25
- var newSplit = !previousMock[name];
26
- var newTreatment = hasTreatmentChanged(previousMock[name], currentData[name]);
27
- var changed = newSplit || newTreatment;
28
- if (changed)
17
+ function splitsParserFromSettingsFactory() {
18
+ var previousMock = { 'emptyMock': '1' };
19
+ function mockUpdated(currentData) {
20
+ var names = Object.keys(currentData);
21
+ // Different amount of items
22
+ if (names.length !== Object.keys(previousMock).length) {
29
23
  previousMock = currentData;
30
- return changed;
31
- });
32
- }
33
- /**
34
- *
35
- * @param features validated object with mocked features mapping.
36
- */
37
- function splitsParserFromSettings(settings) {
38
- var features = settings.features || {};
39
- if (!mockUpdated(features))
40
- return false;
41
- var splitObjects = {};
42
- lang_1.forOwn(features, function (data, splitName) {
43
- var treatment = data;
44
- var config = null;
45
- if (lang_1.isObject(data)) {
46
- treatment = data.treatment;
47
- config = data.config || config;
24
+ return true;
48
25
  }
49
- var configurations = {};
50
- if (config !== null)
51
- configurations[treatment] = config;
52
- splitObjects[splitName] = {
53
- trafficTypeName: 'localhost',
54
- conditions: [parseCondition_1.default({ treatment: treatment })],
55
- configurations: configurations
56
- };
57
- });
58
- return splitObjects;
26
+ return names.some(function (name) {
27
+ var newSplit = !previousMock[name];
28
+ var newTreatment = hasTreatmentChanged(previousMock[name], currentData[name]);
29
+ var changed = newSplit || newTreatment;
30
+ if (changed)
31
+ previousMock = currentData;
32
+ return changed;
33
+ });
34
+ }
35
+ /**
36
+ *
37
+ * @param settings validated object with mocked features mapping.
38
+ */
39
+ return function splitsParserFromSettings(settings) {
40
+ var features = settings.features || {};
41
+ if (!mockUpdated(features))
42
+ return false;
43
+ var splitObjects = {};
44
+ lang_1.forOwn(features, function (data, splitName) {
45
+ var treatment = data;
46
+ var config = null;
47
+ if (lang_1.isObject(data)) {
48
+ treatment = data.treatment;
49
+ config = data.config || config;
50
+ }
51
+ var configurations = {};
52
+ if (config !== null)
53
+ configurations[treatment] = config;
54
+ splitObjects[splitName] = {
55
+ trafficTypeName: 'localhost',
56
+ conditions: [parseCondition_1.default({ treatment: treatment })],
57
+ configurations: configurations
58
+ };
59
+ });
60
+ return splitObjects;
61
+ };
59
62
  }
60
- exports.default = splitsParserFromSettings;
63
+ exports.splitsParserFromSettingsFactory = splitsParserFromSettingsFactory;
@@ -11,7 +11,8 @@ var constants_3 = require("../../../logger/constants");
11
11
  * Offline equivalent of `splitChangesUpdaterFactory`
12
12
  */
13
13
  function fromObjectUpdaterFactory(splitsParser, storage, readiness, settings) {
14
- var log = settings.log;
14
+ var log = settings.log, splitsCache = storage.splits;
15
+ var startingUp = true;
15
16
  return function objectUpdater() {
16
17
  var splits = [];
17
18
  var loadError = null;
@@ -41,11 +42,20 @@ function fromObjectUpdaterFactory(splitsParser, storage, readiness, settings) {
41
42
  ]);
42
43
  });
43
44
  return Promise.all([
44
- storage.splits.clear(),
45
- storage.splits.addSplits(splits)
45
+ splitsCache.clear(),
46
+ splitsCache.addSplits(splits)
46
47
  ]).then(function () {
47
48
  readiness.splits.emit(constants_2.SDK_SPLITS_ARRIVED);
48
- readiness.segments.emit(constants_2.SDK_SEGMENTS_ARRIVED);
49
+ if (startingUp) {
50
+ startingUp = false;
51
+ Promise.resolve(splitsCache.checkCache()).then(function (cacheReady) {
52
+ // Emits SDK_READY_FROM_CACHE
53
+ if (cacheReady)
54
+ readiness.splits.emit(constants_2.SDK_SPLITS_CACHE_LOADED);
55
+ // Emits SDK_READY
56
+ readiness.segments.emit(constants_2.SDK_SEGMENTS_ARRIVED);
57
+ });
58
+ }
49
59
  return true;
50
60
  });
51
61
  }
@@ -14,14 +14,6 @@ function greedyFetch(fetchSegmentChanges, since, segmentName, noCache) {
14
14
  return tslib_1.__spreadArrays([flatMe[0]], flatMe[1]);
15
15
  });
16
16
  }
17
- })
18
- .catch(function (err) {
19
- // If the operation is forbidden it may be due to permissions, don't recover and propagate the error.
20
- if (err.statusCode === 403)
21
- throw err;
22
- // if something goes wrong with the request to the server, we are going to
23
- // stop requesting information till the next round of downloading
24
- return [];
25
17
  });
26
18
  }
27
19
  /**
@@ -24,19 +24,36 @@ function mySegmentsUpdaterFactory(log, mySegmentsFetcher, splitsCache, mySegment
24
24
  // mySegmentsPromise = tracker.start(tracker.TaskNames.MY_SEGMENTS_FETCH, startingUp ? metricCollectors : false, mySegmentsPromise);
25
25
  }
26
26
  // @TODO if allowing custom storages, handle async execution
27
- function updateSegments(segments) {
28
- // Update the list of segment names available
29
- var shouldNotifyUpdate = mySegmentsCache.resetSegments(segments);
27
+ function updateSegments(segmentsData) {
28
+ var shouldNotifyUpdate;
29
+ if (Array.isArray(segmentsData)) {
30
+ // Update the list of segment names available
31
+ shouldNotifyUpdate = mySegmentsCache.resetSegments(segmentsData);
32
+ }
33
+ else {
34
+ // Add/Delete the segment
35
+ var name_1 = segmentsData.name, add = segmentsData.add;
36
+ if (mySegmentsCache.isInSegment(name_1) !== add) {
37
+ shouldNotifyUpdate = true;
38
+ if (add)
39
+ mySegmentsCache.addToSegment(name_1);
40
+ else
41
+ mySegmentsCache.removeFromSegment(name_1);
42
+ }
43
+ else {
44
+ shouldNotifyUpdate = false;
45
+ }
46
+ }
30
47
  // Notify update if required
31
48
  if (splitsCache.usesSegments() && (shouldNotifyUpdate || readyOnAlreadyExistentState)) {
32
49
  readyOnAlreadyExistentState = false;
33
50
  segmentsEventEmitter.emit(constants_1.SDK_SEGMENTS_ARRIVED);
34
51
  }
35
52
  }
36
- function _mySegmentsUpdater(retry, segmentList, noCache) {
37
- var updaterPromise = segmentList ?
38
- // If segmentList is provided, there is no need to fetch mySegments
39
- new Promise(function (res) { updateSegments(segmentList); res(true); }) :
53
+ function _mySegmentsUpdater(retry, segmentsData, noCache) {
54
+ var updaterPromise = segmentsData ?
55
+ // If segmentsData is provided, there is no need to fetch mySegments
56
+ new Promise(function (res) { updateSegments(segmentsData); res(true); }) :
40
57
  // If not provided, fetch mySegments
41
58
  mySegmentsFetcher(noCache, _promiseDecorator).then(function (segments) {
42
59
  // Only when we have downloaded segments completely, we should not keep retrying anymore
@@ -60,11 +77,14 @@ function mySegmentsUpdaterFactory(log, mySegmentsFetcher, splitsCache, mySegment
60
77
  * MySegments updater returns a promise that resolves with a `false` boolean value if it fails to fetch mySegments or synchronize them with the storage.
61
78
  * Returned promise will not be rejected.
62
79
  *
63
- * @param {string[] | undefined} segmentList list of mySegments names to sync in the storage. If the list is `undefined`, it fetches them before syncing in the storage.
80
+ * @param {SegmentsData | undefined} segmentsData it can be:
81
+ * (1) the list of mySegments names to sync in the storage,
82
+ * (2) an object with a segment name and action (true: add, or false: delete) to update the storage,
83
+ * (3) or `undefined`, for which the updater will fetch mySegments in order to sync the storage.
64
84
  * @param {boolean | undefined} noCache true to revalidate data to fetch
65
85
  */
66
- return function mySegmentsUpdater(segmentList, noCache) {
67
- return _mySegmentsUpdater(0, segmentList, noCache);
86
+ return function mySegmentsUpdater(segmentsData, noCache) {
87
+ return _mySegmentsUpdater(0, segmentsData, noCache);
68
88
  };
69
89
  }
70
90
  exports.mySegmentsUpdaterFactory = mySegmentsUpdaterFactory;
@@ -82,15 +82,13 @@ function segmentChangesUpdaterFactory(log, segmentChangesFetcher, segments, read
82
82
  if (readiness)
83
83
  readiness.segments.emit(constants_1.SDK_SEGMENTS_ARRIVED);
84
84
  }
85
- // if at least one segment fetch fails, return false to indicate that there was some error (e.g., invalid json, HTTP error, etc)
86
- if (shouldUpdateFlags.indexOf(-1) !== -1)
87
- return false;
88
85
  return true;
89
86
  });
90
87
  })
91
88
  // Handles rejected promises at `segmentChangesFetcher`, `segments.getRegisteredSegments` and other segment storage operations.
92
89
  .catch(function (error) {
93
- if (error.statusCode === 403) {
90
+ if (error && error.statusCode === 403) {
91
+ // If the operation is forbidden, it may be due to permissions. Destroy the SDK instance.
94
92
  // @TODO although factory status is destroyed, synchronization is not stopped
95
93
  if (readiness)
96
94
  readiness.destroy();
@@ -2,6 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var VERSION = '1.1';
4
4
  var CONTROL_CHANNEL_REGEX = /^control_/;
5
+ /**
6
+ * Build metadata headers for SSE connection.
7
+ *
8
+ * @param {ISettings} settings Validated settings.
9
+ * @returns {Record<string, string>} Headers object
10
+ */
11
+ function buildSSEHeaders(settings) {
12
+ var headers = {
13
+ SplitSDKClientKey: settings.core.authorizationKey.slice(-4),
14
+ SplitSDKVersion: settings.version,
15
+ };
16
+ // ip and hostname are false if IPAddressesEnabled is false
17
+ var _a = settings.runtime, ip = _a.ip, hostname = _a.hostname;
18
+ if (ip)
19
+ headers['SplitSDKMachineIP'] = ip;
20
+ if (hostname)
21
+ headers['SplitSDKMachineName'] = hostname;
22
+ return headers;
23
+ }
5
24
  /**
6
25
  * Handles streaming connections with EventSource API
7
26
  */
@@ -9,18 +28,21 @@ var SSEClient = /** @class */ (function () {
9
28
  /**
10
29
  * SSEClient constructor.
11
30
  *
12
- * @param streamingUrl URL
13
- * @param eventSource optional EventSource constructor to use instead of the global one
14
- * @throws 'EventSource API is not available. ' if EventSource is not passed and global one is not available
31
+ * @param settings Validated settings.
32
+ * @param useHeaders True to send metadata as headers or false to send as query params. If `true`, the provided EventSource must support headers.
33
+ * @param getEventSource Function to get the EventSource constructor.
34
+ * @throws 'EventSource API is not available. ' if EventSource is not available.
15
35
  */
16
- function SSEClient(streamingUrl, getEventSource) {
36
+ function SSEClient(settings, useHeaders, getEventSource) {
17
37
  // @ts-expect-error
18
38
  this.eventSource = getEventSource && getEventSource();
19
39
  // if eventSource is not available, throw an exception
20
40
  if (!this.eventSource)
21
41
  throw new Error('EventSource API is not available. ');
22
- this.streamingUrl = streamingUrl + '/sse';
23
- this.reopen = this.reopen.bind(this);
42
+ this.streamingUrl = settings.urls.streaming + '/sse';
43
+ // @TODO get `useHeaders` flag from `getEventSource`, to use EventSource headers on client-side SDKs when possible.
44
+ this.useHeaders = useHeaders;
45
+ this.headers = buildSSEHeaders(settings);
24
46
  }
25
47
  SSEClient.prototype.setEventHandler = function (handler) {
26
48
  this.handler = handler;
@@ -29,21 +51,25 @@ var SSEClient = /** @class */ (function () {
29
51
  * Open the connection with a given authToken
30
52
  *
31
53
  * @param {IAuthTokenPushEnabled} authToken
32
- * @throws {TypeError} if `authToken` is undefined
54
+ * @throws {TypeError} Will throw an error if `authToken` is undefined
33
55
  */
34
56
  SSEClient.prototype.open = function (authToken) {
35
57
  this.close(); // it closes connection if previously opened
36
- this.authToken = authToken;
37
58
  var channelsQueryParam = Object.keys(authToken.channels).map(function (channel) {
38
59
  var params = CONTROL_CHANNEL_REGEX.test(channel) ? '[?occupancy=metrics.publishers]' : '';
39
60
  return encodeURIComponent(params + channel);
40
61
  }).join(',');
41
62
  var url = this.streamingUrl + "?channels=" + channelsQueryParam + "&accessToken=" + authToken.token + "&v=" + VERSION + "&heartbeats=true"; // same results using `&heartbeats=false`
42
- this.connection = new this.eventSource(url);
63
+ this.connection = new this.eventSource(
64
+ // For client-side SDKs, SplitSDKClientKey and SplitSDKClientKey metadata is passed as query params,
65
+ // because native EventSource implementations for browser doesn't support headers.
66
+ this.useHeaders ? url : url + ("&SplitSDKVersion=" + this.headers.SplitSDKVersion + "&SplitSDKClientKey=" + this.headers.SplitSDKClientKey),
67
+ // @ts-ignore. For server-side SDKs, metadata is passed via headers. EventSource must support headers, like 'eventsource' package for Node.
68
+ this.useHeaders ? { headers: this.headers } : undefined);
43
69
  if (this.handler) { // no need to check if SSEClient is used only by PushManager
44
- this.connection.onopen = this.handler.handleOpen;
45
- this.connection.onmessage = this.handler.handleMessage;
46
- this.connection.onerror = this.handler.handleError;
70
+ this.connection.addEventListener('open', this.handler.handleOpen);
71
+ this.connection.addEventListener('message', this.handler.handleMessage);
72
+ this.connection.addEventListener('error', this.handler.handleError);
47
73
  }
48
74
  };
49
75
  /** Close connection */
@@ -51,14 +77,6 @@ var SSEClient = /** @class */ (function () {
51
77
  if (this.connection)
52
78
  this.connection.close();
53
79
  };
54
- /**
55
- * Re-open the connection with the last given authToken.
56
- *
57
- * @throws {TypeError} if `open` has not been previously called with an authToken
58
- */
59
- SSEClient.prototype.reopen = function () {
60
- this.open(this.authToken);
61
- };
62
80
  return SSEClient;
63
81
  }());
64
82
  exports.default = SSEClient;
@@ -54,6 +54,13 @@ function notificationKeeperFactory(pushEmitter) {
54
54
  }
55
55
  },
56
56
  handleControlEvent: function (controlType, channel, timestamp) {
57
+ /* STREAMING_RESET control event is handled by PushManager directly since it doesn't require
58
+ * tracking timestamp and state like OCCUPANCY or CONTROL. It also ignores previous
59
+ * OCCUPANCY and CONTROL notifications, and whether PUSH_SUBSYSTEM_DOWN has been emitted or not */
60
+ if (controlType === constants_1.ControlType.STREAMING_RESET) {
61
+ pushEmitter.emit(controlType);
62
+ return;
63
+ }
57
64
  for (var i = 0; i < channels.length; i++) {
58
65
  var c = channels[i];
59
66
  if (c.regex.test(channel)) {
@@ -23,10 +23,13 @@ exports.errorParser = errorParser;
23
23
  * Also assigns the type OCCUPANCY, if it corresponds, so that all supported messages (e.g., SPLIT_UPDATE, CONTROL) have a type.
24
24
  *
25
25
  * @param message
26
- * @returns parsed notification message
26
+ * @returns parsed notification message or undefined if the given event data is falsy (e.g, '' or undefined).
27
+ * For example, the EventSource implementation of React-Native for iOS emits a message event with empty data for Ably keepalive comments.
27
28
  * @throws {SyntaxError} if `message.data` or `JSON.parse(message.data).data` are invalid JSON strings
28
29
  */
29
30
  function messageParser(message) {
31
+ if (!message.data)
32
+ return;
30
33
  var messageData = JSON.parse(message.data);
31
34
  messageData.parsedData = JSON.parse(messageData.data);
32
35
  // set the event type to OCCUPANCY, to handle all events uniformely
@@ -39,7 +39,7 @@ function SSEHandlerFactory(log, pushEmitter) {
39
39
  catch (err) {
40
40
  log.warn(constants_2.STREAMING_PARSING_ERROR_FAILS, [err]);
41
41
  }
42
- var errorMessage = errorWithParsedData.parsedData && errorWithParsedData.parsedData.message;
42
+ var errorMessage = (errorWithParsedData.parsedData && errorWithParsedData.parsedData.message) || errorWithParsedData.message;
43
43
  log.error(constants_2.ERROR_STREAMING_SSE, [errorMessage]);
44
44
  if (isRetryableError(errorWithParsedData)) {
45
45
  pushEmitter.emit(constants_1.PUSH_RETRYABLE_ERROR);
@@ -53,6 +53,8 @@ function SSEHandlerFactory(log, pushEmitter) {
53
53
  var messageWithParsedData;
54
54
  try {
55
55
  messageWithParsedData = NotificationParser_1.messageParser(message);
56
+ if (!messageWithParsedData)
57
+ return; // Messages with empty data are ignored
56
58
  }
57
59
  catch (err) {
58
60
  log.warn(constants_2.STREAMING_PARSING_MESSAGE_FAILS, [err]);
@@ -61,21 +63,18 @@ function SSEHandlerFactory(log, pushEmitter) {
61
63
  var parsedData = messageWithParsedData.parsedData, data = messageWithParsedData.data, channel = messageWithParsedData.channel, timestamp = messageWithParsedData.timestamp;
62
64
  log.debug(constants_2.STREAMING_NEW_MESSAGE, [data]);
63
65
  // we only handle update events if streaming is up.
64
- if (!notificationKeeper.isStreamingUp() && parsedData.type !== constants_1.OCCUPANCY && parsedData.type !== constants_1.CONTROL)
66
+ if (!notificationKeeper.isStreamingUp() && [constants_1.OCCUPANCY, constants_1.CONTROL].indexOf(parsedData.type) === -1)
65
67
  return;
66
68
  switch (parsedData.type) {
67
69
  /* update events */
68
70
  case constants_1.SPLIT_UPDATE:
69
- pushEmitter.emit(constants_1.SPLIT_UPDATE, parsedData.changeNumber);
70
- break;
71
71
  case constants_1.SEGMENT_UPDATE:
72
- pushEmitter.emit(constants_1.SEGMENT_UPDATE, parsedData.changeNumber, parsedData.segmentName);
72
+ case constants_1.MY_SEGMENTS_UPDATE_V2:
73
+ case constants_1.SPLIT_KILL:
74
+ pushEmitter.emit(parsedData.type, parsedData);
73
75
  break;
74
76
  case constants_1.MY_SEGMENTS_UPDATE:
75
- pushEmitter.emit(constants_1.MY_SEGMENTS_UPDATE, parsedData, channel);
76
- break;
77
- case constants_1.SPLIT_KILL:
78
- pushEmitter.emit(constants_1.SPLIT_KILL, parsedData.changeNumber, parsedData.splitName, parsedData.defaultTreatment);
77
+ pushEmitter.emit(parsedData.type, parsedData, channel);
79
78
  break;
80
79
  /* occupancy & control events, handled by NotificationManagerKeeper */
81
80
  case constants_1.OCCUPANCY:
@@ -1,2 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateStrategy = exports.Compression = void 0;
4
+ var Compression;
5
+ (function (Compression) {
6
+ Compression[Compression["None"] = 0] = "None";
7
+ Compression[Compression["Gzip"] = 1] = "Gzip";
8
+ Compression[Compression["Zlib"] = 2] = "Zlib";
9
+ })(Compression = exports.Compression || (exports.Compression = {}));
10
+ var UpdateStrategy;
11
+ (function (UpdateStrategy) {
12
+ UpdateStrategy[UpdateStrategy["UnboundedFetchRequest"] = 0] = "UnboundedFetchRequest";
13
+ UpdateStrategy[UpdateStrategy["BoundedFetchRequest"] = 1] = "BoundedFetchRequest";
14
+ UpdateStrategy[UpdateStrategy["KeyList"] = 2] = "KeyList";
15
+ UpdateStrategy[UpdateStrategy["SegmentRemoval"] = 3] = "SegmentRemoval";
16
+ })(UpdateStrategy = exports.UpdateStrategy || (exports.UpdateStrategy = {}));