@splitsoftware/splitio-commons 1.17.1-rc.4 → 2.0.0-rc.1

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 (177) hide show
  1. package/CHANGES.txt +4 -0
  2. package/cjs/evaluator/Engine.js +1 -1
  3. package/cjs/evaluator/index.js +1 -1
  4. package/cjs/evaluator/matchers/semver_inlist.js +1 -2
  5. package/cjs/evaluator/matchers/whitelist.js +1 -2
  6. package/cjs/listeners/browser.js +1 -2
  7. package/cjs/logger/browser/DebugLogger.js +1 -2
  8. package/cjs/logger/browser/ErrorLogger.js +1 -2
  9. package/cjs/logger/browser/InfoLogger.js +1 -2
  10. package/cjs/logger/browser/WarnLogger.js +1 -2
  11. package/cjs/logger/index.js +1 -2
  12. package/cjs/sdkClient/clientCS.js +5 -8
  13. package/cjs/sdkClient/sdkClientMethodCS.js +1 -1
  14. package/cjs/services/decorateHeaders.js +1 -2
  15. package/cjs/storages/KeyBuilderCS.js +0 -9
  16. package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
  17. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +4 -4
  18. package/cjs/storages/inLocalStorage/index.js +1 -1
  19. package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -1
  20. package/cjs/storages/inMemory/SegmentsCacheInMemory.js +2 -3
  21. package/cjs/storages/inMemory/SplitsCacheInMemory.js +2 -3
  22. package/cjs/storages/inMemory/UniqueKeysCacheInMemory.js +2 -2
  23. package/cjs/storages/inMemory/UniqueKeysCacheInMemoryCS.js +2 -2
  24. package/cjs/storages/inRedis/RedisAdapter.js +2 -2
  25. package/cjs/storages/inRedis/SplitsCacheInRedis.js +1 -1
  26. package/cjs/storages/inRedis/TelemetryCacheInRedis.js +3 -4
  27. package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
  28. package/cjs/storages/pluggable/SplitsCachePluggable.js +1 -1
  29. package/cjs/storages/pluggable/TelemetryCachePluggable.js +6 -7
  30. package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
  31. package/cjs/storages/pluggable/inMemoryWrapper.js +6 -6
  32. package/cjs/sync/polling/updaters/splitChangesUpdater.js +3 -3
  33. package/cjs/sync/streaming/parseUtils.js +0 -1
  34. package/cjs/sync/streaming/pushManager.js +2 -3
  35. package/cjs/utils/LRUCache/index.js +1 -2
  36. package/cjs/utils/constants/browser.js +1 -4
  37. package/cjs/utils/lang/index.js +6 -9
  38. package/cjs/utils/lang/objectAssign.js +12 -77
  39. package/cjs/utils/lang/sets.js +10 -107
  40. package/cjs/utils/settingsValidation/index.js +0 -9
  41. package/cjs/utils/settingsValidation/logger/builtinLogger.js +1 -2
  42. package/esm/evaluator/Engine.js +1 -1
  43. package/esm/evaluator/index.js +2 -2
  44. package/esm/evaluator/matchers/semver_inlist.js +1 -2
  45. package/esm/evaluator/matchers/whitelist.js +1 -2
  46. package/esm/listeners/browser.js +1 -2
  47. package/esm/logger/browser/DebugLogger.js +1 -2
  48. package/esm/logger/browser/ErrorLogger.js +1 -2
  49. package/esm/logger/browser/InfoLogger.js +1 -2
  50. package/esm/logger/browser/WarnLogger.js +1 -2
  51. package/esm/logger/index.js +1 -2
  52. package/esm/sdkClient/clientCS.js +5 -8
  53. package/esm/sdkClient/sdkClientMethodCS.js +1 -1
  54. package/esm/services/decorateHeaders.js +1 -2
  55. package/esm/storages/KeyBuilderCS.js +0 -9
  56. package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
  57. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +4 -4
  58. package/esm/storages/inLocalStorage/index.js +1 -1
  59. package/esm/storages/inMemory/InMemoryStorageCS.js +1 -1
  60. package/esm/storages/inMemory/SegmentsCacheInMemory.js +2 -3
  61. package/esm/storages/inMemory/SplitsCacheInMemory.js +2 -3
  62. package/esm/storages/inMemory/UniqueKeysCacheInMemory.js +2 -2
  63. package/esm/storages/inMemory/UniqueKeysCacheInMemoryCS.js +2 -2
  64. package/esm/storages/inRedis/RedisAdapter.js +2 -2
  65. package/esm/storages/inRedis/SplitsCacheInRedis.js +2 -2
  66. package/esm/storages/inRedis/TelemetryCacheInRedis.js +3 -4
  67. package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
  68. package/esm/storages/pluggable/SplitsCachePluggable.js +2 -2
  69. package/esm/storages/pluggable/TelemetryCachePluggable.js +6 -7
  70. package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
  71. package/esm/storages/pluggable/inMemoryWrapper.js +7 -7
  72. package/esm/sync/polling/updaters/splitChangesUpdater.js +3 -3
  73. package/esm/sync/streaming/parseUtils.js +0 -1
  74. package/esm/sync/streaming/pushManager.js +2 -3
  75. package/esm/utils/LRUCache/index.js +1 -2
  76. package/esm/utils/constants/browser.js +0 -3
  77. package/esm/utils/lang/index.js +6 -9
  78. package/esm/utils/lang/objectAssign.js +12 -77
  79. package/esm/utils/lang/sets.js +9 -105
  80. package/esm/utils/settingsValidation/index.js +0 -9
  81. package/esm/utils/settingsValidation/logger/builtinLogger.js +1 -2
  82. package/package.json +2 -2
  83. package/src/evaluator/Engine.ts +1 -1
  84. package/src/evaluator/index.ts +4 -4
  85. package/src/evaluator/matchers/semver_inlist.ts +1 -2
  86. package/src/evaluator/matchers/whitelist.ts +1 -3
  87. package/src/listeners/browser.ts +1 -2
  88. package/src/logger/browser/DebugLogger.ts +1 -2
  89. package/src/logger/browser/ErrorLogger.ts +1 -2
  90. package/src/logger/browser/InfoLogger.ts +1 -2
  91. package/src/logger/browser/WarnLogger.ts +1 -2
  92. package/src/logger/index.ts +3 -4
  93. package/src/sdkClient/clientCS.ts +5 -8
  94. package/src/sdkClient/sdkClientMethodCS.ts +1 -1
  95. package/src/sdkFactory/types.ts +1 -1
  96. package/src/services/decorateHeaders.ts +1 -2
  97. package/src/storages/AbstractSplitsCacheAsync.ts +1 -2
  98. package/src/storages/AbstractSplitsCacheSync.ts +1 -2
  99. package/src/storages/KeyBuilderCS.ts +0 -13
  100. package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +1 -21
  101. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +5 -5
  102. package/src/storages/inLocalStorage/index.ts +1 -1
  103. package/src/storages/inMemory/InMemoryStorageCS.ts +1 -1
  104. package/src/storages/inMemory/SegmentsCacheInMemory.ts +3 -4
  105. package/src/storages/inMemory/SplitsCacheInMemory.ts +4 -5
  106. package/src/storages/inMemory/UniqueKeysCacheInMemory.ts +4 -4
  107. package/src/storages/inMemory/UniqueKeysCacheInMemoryCS.ts +4 -4
  108. package/src/storages/inRedis/RedisAdapter.ts +3 -3
  109. package/src/storages/inRedis/SplitsCacheInRedis.ts +3 -3
  110. package/src/storages/inRedis/TelemetryCacheInRedis.ts +3 -4
  111. package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +1 -1
  112. package/src/storages/pluggable/SegmentsCachePluggable.ts +0 -1
  113. package/src/storages/pluggable/SplitsCachePluggable.ts +3 -3
  114. package/src/storages/pluggable/TelemetryCachePluggable.ts +6 -7
  115. package/src/storages/pluggable/UniqueKeysCachePluggable.ts +1 -1
  116. package/src/storages/pluggable/inMemoryWrapper.ts +9 -9
  117. package/src/storages/types.ts +3 -4
  118. package/src/sync/polling/updaters/splitChangesUpdater.ts +4 -4
  119. package/src/sync/streaming/parseUtils.ts +0 -1
  120. package/src/sync/streaming/pushManager.ts +3 -4
  121. package/src/sync/submitters/types.ts +3 -4
  122. package/src/types.ts +1 -9
  123. package/src/utils/LRUCache/index.ts +2 -3
  124. package/src/utils/constants/browser.ts +0 -4
  125. package/src/utils/lang/index.ts +6 -7
  126. package/src/utils/lang/objectAssign.ts +13 -92
  127. package/src/utils/lang/sets.ts +10 -122
  128. package/src/utils/settingsValidation/index.ts +0 -10
  129. package/src/utils/settingsValidation/logger/builtinLogger.ts +1 -2
  130. package/src/utils/settingsValidation/types.ts +0 -2
  131. package/types/logger/index.d.ts +1 -2
  132. package/types/sdkClient/clientCS.d.ts +2 -3
  133. package/types/sdkFactory/types.d.ts +1 -1
  134. package/types/storages/AbstractSplitsCacheAsync.d.ts +1 -2
  135. package/types/storages/AbstractSplitsCacheSync.d.ts +1 -2
  136. package/types/storages/KeyBuilderCS.d.ts +0 -2
  137. package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +1 -2
  138. package/types/storages/inMemory/SplitsCacheInMemory.d.ts +1 -2
  139. package/types/storages/inMemory/UniqueKeysCacheInMemory.d.ts +2 -3
  140. package/types/storages/inRedis/SplitsCacheInRedis.d.ts +1 -2
  141. package/types/storages/pluggable/SplitsCachePluggable.d.ts +1 -2
  142. package/types/storages/pluggable/inMemoryWrapper.d.ts +1 -2
  143. package/types/storages/types.d.ts +3 -4
  144. package/types/sync/polling/updaters/splitChangesUpdater.d.ts +1 -2
  145. package/types/sync/submitters/types.d.ts +3 -4
  146. package/types/types.d.ts +1 -9
  147. package/types/utils/LRUCache/index.d.ts +1 -2
  148. package/types/utils/constants/browser.d.ts +0 -2
  149. package/types/utils/lang/objectAssign.d.ts +3 -0
  150. package/types/utils/lang/sets.d.ts +2 -61
  151. package/types/utils/settingsValidation/index.d.ts +0 -1
  152. package/types/utils/settingsValidation/types.d.ts +0 -2
  153. package/cjs/integrations/browser.js +0 -31
  154. package/cjs/integrations/ga/GaToSplit.js +0 -257
  155. package/cjs/integrations/ga/GoogleAnalyticsToSplit.js +0 -14
  156. package/cjs/integrations/ga/SplitToGa.js +0 -123
  157. package/cjs/integrations/ga/SplitToGoogleAnalytics.js +0 -14
  158. package/cjs/integrations/ga/types.js +0 -2
  159. package/cjs/sdkClient/sdkClientMethodCSWithTT.js +0 -75
  160. package/cjs/utils/lang/maps.js +0 -96
  161. package/esm/integrations/browser.js +0 -27
  162. package/esm/integrations/ga/GaToSplit.js +0 -250
  163. package/esm/integrations/ga/GoogleAnalyticsToSplit.js +0 -10
  164. package/esm/integrations/ga/SplitToGa.js +0 -120
  165. package/esm/integrations/ga/SplitToGoogleAnalytics.js +0 -10
  166. package/esm/integrations/ga/types.js +0 -1
  167. package/esm/sdkClient/sdkClientMethodCSWithTT.js +0 -71
  168. package/esm/utils/lang/maps.js +0 -92
  169. package/src/integrations/browser.ts +0 -35
  170. package/src/integrations/ga/GaToSplit.ts +0 -299
  171. package/src/integrations/ga/GoogleAnalyticsToSplit.ts +0 -14
  172. package/src/integrations/ga/SplitToGa.ts +0 -135
  173. package/src/integrations/ga/SplitToGoogleAnalytics.ts +0 -14
  174. package/src/integrations/ga/autoRequire.js +0 -33
  175. package/src/integrations/ga/types.ts +0 -153
  176. package/src/sdkClient/sdkClientMethodCSWithTT.ts +0 -96
  177. package/src/utils/lang/maps.ts +0 -108
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.splitChangesUpdaterFactory = exports.computeSplitsMutation = exports.parseSegments = void 0;
4
- var sets_1 = require("../../../utils/lang/sets");
5
4
  var timeout_1 = require("../../../utils/promise/timeout");
6
5
  var constants_1 = require("../../../readiness/constants");
7
6
  var constants_2 = require("../../../logger/constants");
8
7
  var lang_1 = require("../../../utils/lang");
9
8
  var constants_3 = require("../../../utils/constants");
9
+ var sets_1 = require("../../../utils/lang/sets");
10
10
  // Checks that all registered segments have been fetched (changeNumber !== -1 for every segment).
11
11
  // Returns a promise that could be rejected.
12
12
  // @TODO review together with Segments and MySegments storage APIs
@@ -23,7 +23,7 @@ function checkAllSegmentsExist(segments) {
23
23
  */
24
24
  function parseSegments(_a) {
25
25
  var conditions = _a.conditions;
26
- var segments = new sets_1._Set();
26
+ var segments = new Set();
27
27
  for (var i = 0; i < conditions.length; i++) {
28
28
  var matchers = conditions[i].matcherGroup.matchers;
29
29
  matchers.forEach(function (matcher) {
@@ -59,7 +59,7 @@ function matchFilters(featureFlag, filters) {
59
59
  * Exported for testing purposes.
60
60
  */
61
61
  function computeSplitsMutation(entries, filters) {
62
- var segments = new sets_1._Set();
62
+ var segments = new Set();
63
63
  var computed = entries.reduce(function (accum, split) {
64
64
  if (split.status === 'ACTIVE' && matchFilters(split, filters)) {
65
65
  accum.added.push([split.name, split]);
@@ -11,7 +11,6 @@ function Uint8ArrayToString(myUint8Arr) {
11
11
  }
12
12
  function StringToUint8Array(myString) {
13
13
  var charCodes = myString.split('').map(function (e) { return e.charCodeAt(0); });
14
- // eslint-disable-next-line compat/compat
15
14
  return new Uint8Array(charCodes);
16
15
  }
17
16
  /**
@@ -15,7 +15,6 @@ var constants_1 = require("./constants");
15
15
  var constants_2 = require("../../logger/constants");
16
16
  var types_1 = require("./SSEHandler/types");
17
17
  var parseUtils_1 = require("./parseUtils");
18
- var sets_1 = require("../../utils/lang/sets");
19
18
  var murmur3_64_1 = require("../../utils/murmur3/murmur3_64");
20
19
  var constants_3 = require("../../utils/constants");
21
20
  /**
@@ -221,8 +220,8 @@ function pushManagerFactory(params, pollingManager) {
221
220
  var keyList = void 0, added_1, removed_1;
222
221
  try {
223
222
  keyList = (0, parseUtils_1.parseKeyList)(parsedData.d, parsedData.c);
224
- added_1 = new sets_1._Set(keyList.a);
225
- removed_1 = new sets_1._Set(keyList.r);
223
+ added_1 = new Set(keyList.a);
224
+ removed_1 = new Set(keyList.r);
226
225
  }
227
226
  catch (e) {
228
227
  log.warn(constants_2.STREAMING_PARSING_MEMBERSHIPS_UPDATE, ['KeyList', e]);
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LRUCache = void 0;
4
- var maps_1 = require("../lang/maps");
5
4
  var LinkedList_1 = require("./LinkedList");
6
5
  var LRUCache = /** @class */ (function () {
7
6
  function LRUCache(maxSize) {
8
7
  this.maxLen = maxSize || 1;
9
- this.items = new maps_1._Map();
8
+ this.items = new Map();
10
9
  this.lru = new LinkedList_1.LinkedList();
11
10
  }
12
11
  LRUCache.prototype.get = function (key) {
@@ -1,8 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_CACHE_EXPIRATION_IN_MILLIS = exports.SPLIT_TO_GOOGLE_ANALYTICS = exports.GOOGLE_ANALYTICS_TO_SPLIT = void 0;
4
- // Integration types
5
- exports.GOOGLE_ANALYTICS_TO_SPLIT = 'GOOGLE_ANALYTICS_TO_SPLIT';
6
- exports.SPLIT_TO_GOOGLE_ANALYTICS = 'SPLIT_TO_GOOGLE_ANALYTICS';
3
+ exports.DEFAULT_CACHE_EXPIRATION_IN_MILLIS = void 0;
7
4
  // This value might be eventually set via a config parameter
8
5
  exports.DEFAULT_CACHE_EXPIRATION_IN_MILLIS = 864000000; // 10 days
@@ -121,11 +121,9 @@ exports.isBoolean = isBoolean;
121
121
  function isFiniteNumber(val) {
122
122
  if (val instanceof Number)
123
123
  val = val.valueOf();
124
- // @TODO remove `isFinite` once `Number.isFinite` is fully supported by targets
125
- // eslint-disable-next-line compat/compat
126
- if (typeof val === 'number')
127
- return Number.isFinite ? Number.isFinite(val) : isFinite(val);
128
- return false;
124
+ return typeof val === 'number' ?
125
+ Number.isFinite ? Number.isFinite(val) : isFinite(val) :
126
+ false;
129
127
  }
130
128
  exports.isFiniteNumber = isFiniteNumber;
131
129
  /**
@@ -135,10 +133,9 @@ exports.isFiniteNumber = isFiniteNumber;
135
133
  function isIntegerNumber(val) {
136
134
  if (val instanceof Number)
137
135
  val = val.valueOf();
138
- // eslint-disable-next-line compat/compat
139
- if (typeof val === 'number')
140
- return Number.isInteger ? Number.isInteger(val) : isFinite(val) && Math.floor(val) === val;
141
- return false;
136
+ return typeof val === 'number' ?
137
+ Number.isInteger ? Number.isInteger(val) : isFinite(val) && Math.floor(val) === val :
138
+ false;
142
139
  }
143
140
  exports.isIntegerNumber = isIntegerNumber;
144
141
  /**
@@ -1,85 +1,20 @@
1
1
  "use strict";
2
- /*
3
- Adaptation of "object-assign" library (https://www.npmjs.com/package/object-assign)
4
- exported as an ES module instead of CommonJS, to avoid extra configuration steps when using
5
- the ESM build of the SDK with tools that doesn't support CommonJS by default (e.g. Rollup).
6
-
7
- object-assign
8
- (c) Sindre Sorhus
9
- @license MIT
10
- */
2
+ /**
3
+ * A tiny polyfill for Object.assign
4
+ */
11
5
  Object.defineProperty(exports, "__esModule", { value: true });
12
6
  exports.objectAssign = void 0;
13
- /* eslint-disable */
14
- // @ts-nocheck
15
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
16
- var hasOwnProperty = Object.prototype.hasOwnProperty;
17
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
18
- function toObject(val) {
19
- if (val === null || val === undefined) {
7
+ exports.objectAssign = Object.assign || function (target) {
8
+ if (target === null || target === undefined)
20
9
  throw new TypeError('Object.assign cannot be called with null or undefined');
21
- }
22
- return Object(val);
23
- }
24
- function shouldUseNative() {
25
- try {
26
- if (!Object.assign) {
27
- return false;
28
- }
29
- // Detect buggy property enumeration order in older V8 versions.
30
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
31
- var test1 = new String('abc');
32
- test1[5] = 'de';
33
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
34
- return false;
35
- }
36
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
37
- var test2 = {};
38
- for (var i = 0; i < 10; i++) {
39
- test2['_' + String.fromCharCode(i)] = i;
40
- }
41
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
42
- return test2[n];
43
- });
44
- if (order2.join('') !== '0123456789') {
45
- return false;
46
- }
47
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
48
- var test3 = {};
49
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
50
- test3[letter] = letter;
51
- });
52
- if (Object.keys(Object.assign({}, test3)).join('') !==
53
- 'abcdefghijklmnopqrst') {
54
- return false;
55
- }
56
- return true;
57
- }
58
- catch (err) {
59
- // We don't expect any of the above to throw, but better to be safe.
60
- return false;
61
- }
62
- }
63
- exports.objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
64
- var from;
65
- var to = toObject(target);
66
- var symbols;
67
- for (var s = 1; s < arguments.length; s++) {
68
- from = Object(arguments[s]);
69
- // eslint-disable-next-line no-restricted-syntax
70
- for (var key in from) {
71
- if (hasOwnProperty.call(from, key)) {
72
- to[key] = from[key];
73
- }
74
- }
75
- if (getOwnPropertySymbols) {
76
- symbols = getOwnPropertySymbols(from);
77
- for (var i = 0; i < symbols.length; i++) {
78
- if (propIsEnumerable.call(from, symbols[i])) {
79
- to[symbols[i]] = from[symbols[i]];
80
- }
10
+ target = Object(target);
11
+ for (var i = 1; i < arguments.length; i++) {
12
+ var source = Object(arguments[i]); // eslint-disable-next-line no-restricted-syntax
13
+ for (var key in source) {
14
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
15
+ target[key] = source[key];
81
16
  }
82
17
  }
83
18
  }
84
- return to;
19
+ return target;
85
20
  };
@@ -1,120 +1,23 @@
1
1
  "use strict";
2
- /**
3
- * Set implementation based on es6-set polyfill (https://github.com/medikoo/es6-set/blob/master/polyfill.js),
4
- * with the minimal features used by the SDK.
5
-
6
- Copyright (C) 2013 Mariusz Nowak (www.medikoo.com)
7
-
8
- Permission is hereby granted, free of charge, to any person obtaining a copy
9
- of this software and associated documentation files (the "Software"), to deal
10
- in the Software without restriction, including without limitation the rights
11
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
- copies of the Software, and to permit persons to whom the Software is
13
- furnished to do so, subject to the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be included in
16
- all copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
- THE SOFTWARE.
25
- **/
26
2
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.returnDifference = exports.returnSetsUnion = exports._Set = exports.__getSetConstructor = exports.setToArray = exports.SetPoly = void 0;
28
- var SetPoly = /** @class */ (function () {
29
- // unlike ES6 `Set`, it only accepts an array as first argument iterable
30
- function SetPoly(values) {
31
- var _this = this;
32
- this.__setData__ = [];
33
- if (Array.isArray(values))
34
- values.forEach(function (value) { _this.add(value); });
35
- }
36
- SetPoly.prototype.clear = function () {
37
- if (!this.__setData__.length)
38
- return;
39
- this.__setData__.length = 0;
40
- };
41
- SetPoly.prototype.add = function (value) {
42
- if (this.has(value))
43
- return this;
44
- this.__setData__.push(value);
45
- return this;
46
- };
47
- SetPoly.prototype.delete = function (value) {
48
- var index = this.__setData__.indexOf(value);
49
- if (index === -1)
50
- return false;
51
- this.__setData__.splice(index, 1);
52
- return true;
53
- };
54
- SetPoly.prototype.has = function (value) {
55
- return this.__setData__.indexOf(value) !== -1;
56
- };
57
- SetPoly.prototype.forEach = function (callbackfn, thisArg) {
58
- if (typeof callbackfn !== 'function')
59
- throw new TypeError(callbackfn + ' is not a function');
60
- for (var i = 0; i < this.__setData__.length; i++) {
61
- var value = this.__setData__[i];
62
- callbackfn.call(thisArg, value, value, this);
63
- }
64
- };
65
- Object.defineProperty(SetPoly.prototype, "size", {
66
- get: function () {
67
- return this.__setData__.length;
68
- },
69
- enumerable: false,
70
- configurable: true
71
- });
72
- return SetPoly;
73
- }());
74
- exports.SetPoly = SetPoly;
75
- /**
76
- * return an array containing the items of the given set.
77
- * @param set Set or SetPoly instance
78
- */
3
+ exports.returnDifference = exports.returnSetsUnion = exports.setToArray = void 0;
79
4
  function setToArray(set) {
80
- if (set instanceof SetPoly) {
81
- return set.__setData__.slice();
82
- }
83
- // if not using SetPoly as set, it means Array.from is supported
84
- // eslint-disable-next-line compat/compat
85
- return Array.from(set);
5
+ if (Array.from)
6
+ return Array.from(set);
7
+ var array = [];
8
+ set.forEach(function (value) {
9
+ array.push(value);
10
+ });
11
+ return array;
86
12
  }
87
13
  exports.setToArray = setToArray;
88
- /**
89
- * return the Set constructor to use. If `Array.from` built-in or native Set is not available or it doesn't support the required features,
90
- * a ponyfill with minimal features is returned instead.
91
- *
92
- * Exported for testing purposes only.
93
- */
94
- function __getSetConstructor() {
95
- // eslint-disable-next-line compat/compat
96
- if (typeof Array.from === 'function' && typeof Set === 'function' && Set.prototype && Set.prototype.values) {
97
- return Set;
98
- }
99
- return SetPoly;
100
- }
101
- exports.__getSetConstructor = __getSetConstructor;
102
- exports._Set = __getSetConstructor();
103
14
  function returnSetsUnion(set, set2) {
104
- var result = new exports._Set(setToArray(set));
105
- set2.forEach(function (value) {
106
- result.add(value);
107
- });
108
- return result;
15
+ return new Set(setToArray(set).concat(setToArray(set2)));
109
16
  }
110
17
  exports.returnSetsUnion = returnSetsUnion;
111
18
  function returnDifference(list, list2) {
112
19
  if (list === void 0) { list = []; }
113
20
  if (list2 === void 0) { list2 = []; }
114
- var result = new exports._Set(list);
115
- list2.forEach(function (item) {
116
- result.delete(item);
117
- });
118
- return setToArray(result);
21
+ return list.filter(function (item) { return list2.indexOf(item) === -1; });
119
22
  }
120
23
  exports.returnDifference = returnDifference;
@@ -7,7 +7,6 @@ var splitFilters_1 = require("./splitFilters");
7
7
  var constants_1 = require("../constants");
8
8
  var impressionsMode_1 = require("./impressionsMode");
9
9
  var key_1 = require("../inputValidation/key");
10
- var trafficType_1 = require("../inputValidation/trafficType");
11
10
  var constants_2 = require("../../logger/constants");
12
11
  // Exported for telemetry
13
12
  exports.base = {
@@ -18,8 +17,6 @@ exports.base = {
18
17
  authorizationKey: undefined,
19
18
  // key used in your system (only required for browser version)
20
19
  key: undefined,
21
- // traffic type for the given key (only used on browser version)
22
- trafficType: undefined,
23
20
  // toggle impressions tracking of labels
24
21
  labelsEnabled: true,
25
22
  // toggle sendind (true) or not sending (false) IP and Host Name with impressions, events, and telemetries requests (only used on nodejs version)
@@ -148,12 +145,6 @@ function settingsValidation(config, validationParams) {
148
145
  // @ts-ignore, @TODO handle invalid keys as a non-recoverable error?
149
146
  withDefaults.core.key = (0, key_1.validateKey)(log, maybeKey, constants_2.LOG_PREFIX_CLIENT_INSTANTIATION);
150
147
  }
151
- if (validationParams.acceptTT) {
152
- var maybeTT = withDefaults.core.trafficType;
153
- if (maybeTT !== undefined) { // @ts-ignore
154
- withDefaults.core.trafficType = (0, trafficType_1.validateTrafficType)(log, maybeTT, constants_2.LOG_PREFIX_CLIENT_INSTANTIATION);
155
- }
156
- }
157
148
  }
158
149
  else {
159
150
  // On server-side, key is undefined and used to distinguish from client-side
@@ -5,9 +5,8 @@ var logger_1 = require("../../../logger");
5
5
  var isLocalStorageAvailable_1 = require("../../env/isLocalStorageAvailable");
6
6
  var isNode_1 = require("../../env/isNode");
7
7
  var debug_1 = require("../../../logger/messages/debug");
8
- var maps_1 = require("../../lang/maps");
9
8
  var commons_1 = require("./commons");
10
- var allCodes = new maps_1._Map(debug_1.codesDebug);
9
+ var allCodes = new Map(debug_1.codesDebug);
11
10
  // @TODO set default debug setting instead of initialLogLevel when integrating in JS and Node packages
12
11
  var LS_KEY = 'splitio_debug';
13
12
  var ENV_VAR_KEY = 'SPLITIO_DEBUG';
@@ -14,7 +14,7 @@ var Engine = /** @class */ (function () {
14
14
  function Engine(baseInfo, evaluator) {
15
15
  this.baseInfo = baseInfo;
16
16
  this.evaluator = evaluator;
17
- // in case we don't have a default treatment in the instanciation, use 'control'
17
+ // in case we don't have a default treatment in the instantiation, use 'control'
18
18
  if (typeof this.baseInfo.defaultTreatment !== 'string') {
19
19
  this.baseInfo.defaultTreatment = CONTROL;
20
20
  }
@@ -2,7 +2,7 @@ import { Engine } from './Engine';
2
2
  import { thenable } from '../utils/promise/thenable';
3
3
  import { EXCEPTION, SPLIT_NOT_FOUND } from '../utils/labels';
4
4
  import { CONTROL } from '../utils/constants';
5
- import { setToArray, returnSetsUnion, _Set } from '../utils/lang/sets';
5
+ import { returnSetsUnion, setToArray } from '../utils/lang/sets';
6
6
  import { WARN_FLAGSET_WITHOUT_FLAGS } from '../logger/constants';
7
7
  var treatmentException = {
8
8
  treatment: CONTROL,
@@ -54,7 +54,7 @@ export function evaluateFeatures(log, key, splitNames, attributes, storage) {
54
54
  export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method) {
55
55
  var storedFlagNames;
56
56
  function evaluate(featureFlagsByFlagSets) {
57
- var featureFlags = new _Set();
57
+ var featureFlags = new Set();
58
58
  for (var i = 0; i < flagSets.length; i++) {
59
59
  var featureFlagByFlagSet = featureFlagsByFlagSets[i];
60
60
  if (featureFlagByFlagSet.size) {
@@ -1,10 +1,9 @@
1
- import { _Set } from '../../utils/lang/sets';
2
1
  import { Semver } from '../../utils/Semver';
3
2
  export function inListSemverMatcherContext(ruleAttr) {
4
3
  // @TODO ruleAttr validation should be done at the `parser` or `matchersTransform` level to reuse for all matchers
5
4
  if (!ruleAttr || ruleAttr.length === 0)
6
5
  throw new Error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type');
7
- var listOfSemvers = new _Set(ruleAttr.map(function (version) { return new Semver(version).version; }));
6
+ var listOfSemvers = new Set(ruleAttr.map(function (version) { return new Semver(version).version; }));
8
7
  return function inListSemverMatcher(runtimeAttr) {
9
8
  var runtimeSemver = new Semver(runtimeAttr).version;
10
9
  var isInList = listOfSemvers.has(runtimeSemver);
@@ -1,6 +1,5 @@
1
- import { _Set } from '../../utils/lang/sets';
2
1
  export function whitelistMatcherContext(ruleAttr) {
3
- var whitelistSet = new _Set(ruleAttr);
2
+ var whitelistSet = new Set(ruleAttr);
4
3
  return function whitelistMatcher(runtimeAttr) {
5
4
  var isInWhitelist = whitelistSet.has(runtimeAttr);
6
5
  return isInWhitelist;
@@ -97,7 +97,6 @@ var BrowserSignalListener = /** @class */ (function () {
97
97
  * Returns true if beacon API was used successfully, false otherwise.
98
98
  */
99
99
  BrowserSignalListener.prototype._sendBeacon = function (url, data, extraMetadata) {
100
- // eslint-disable-next-line compat/compat
101
100
  if (typeof navigator !== 'undefined' && navigator.sendBeacon) {
102
101
  var json = {
103
102
  entries: data,
@@ -110,7 +109,7 @@ var BrowserSignalListener = /** @class */ (function () {
110
109
  // Stringify the payload
111
110
  var payload = JSON.stringify(json);
112
111
  // https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
113
- try { // eslint-disable-next-line compat/compat
112
+ try {
114
113
  return navigator.sendBeacon(url, payload);
115
114
  }
116
115
  catch (e) {
@@ -1,6 +1,5 @@
1
1
  import { Logger } from '../index';
2
2
  import { codesDebug } from '../messages/debug';
3
- import { _Map } from '../../utils/lang/maps';
4
3
  export function DebugLogger() {
5
- return new Logger({ logLevel: 'DEBUG' }, new _Map(codesDebug));
4
+ return new Logger({ logLevel: 'DEBUG' }, new Map(codesDebug));
6
5
  }
@@ -1,6 +1,5 @@
1
1
  import { Logger } from '../index';
2
2
  import { codesError } from '../messages/error';
3
- import { _Map } from '../../utils/lang/maps';
4
3
  export function ErrorLogger() {
5
- return new Logger({ logLevel: 'ERROR' }, new _Map(codesError));
4
+ return new Logger({ logLevel: 'ERROR' }, new Map(codesError));
6
5
  }
@@ -1,6 +1,5 @@
1
1
  import { Logger } from '../index';
2
2
  import { codesInfo } from '../messages/info';
3
- import { _Map } from '../../utils/lang/maps';
4
3
  export function InfoLogger() {
5
- return new Logger({ logLevel: 'INFO' }, new _Map(codesInfo));
4
+ return new Logger({ logLevel: 'INFO' }, new Map(codesInfo));
6
5
  }
@@ -1,6 +1,5 @@
1
1
  import { Logger } from '../index';
2
2
  import { codesWarn } from '../messages/warn';
3
- import { _Map } from '../../utils/lang/maps';
4
3
  export function WarnLogger() {
5
- return new Logger({ logLevel: 'WARN' }, new _Map(codesWarn));
4
+ return new Logger({ logLevel: 'WARN' }, new Map(codesWarn));
6
5
  }
@@ -1,6 +1,5 @@
1
1
  import { objectAssign } from '../utils/lang/objectAssign';
2
2
  import { find, isObject } from '../utils/lang';
3
- import { _Map } from '../utils/lang/maps';
4
3
  export var LogLevels = {
5
4
  DEBUG: 'DEBUG',
6
5
  INFO: 'INFO',
@@ -42,7 +41,7 @@ var defaultOptions = {
42
41
  var Logger = /** @class */ (function () {
43
42
  function Logger(options, codes) {
44
43
  this.options = objectAssign({}, defaultOptions, options);
45
- this.codes = codes || new _Map();
44
+ this.codes = codes || new Map();
46
45
  this.logLevel = LogLevelIndexes[this.options.logLevel];
47
46
  }
48
47
  Logger.prototype.setLogLevel = function (logLevel) {
@@ -1,16 +1,15 @@
1
1
  import { objectAssign } from '../utils/lang/objectAssign';
2
2
  import { clientAttributesDecoration } from './clientAttributesDecoration';
3
3
  /**
4
- * Decorator that binds a key and (optionally) a traffic type to client methods
4
+ * Decorator that binds a key to client methods
5
5
  *
6
6
  * @param client sync client instance
7
7
  * @param key validated split key
8
- * @param trafficType validated traffic type
9
8
  */
10
- export function clientCSDecorator(log, client, key, trafficType) {
9
+ export function clientCSDecorator(log, client, key) {
11
10
  var clientCS = clientAttributesDecoration(log, client);
12
11
  return objectAssign(clientCS, {
13
- // In the client-side API, we bind a key to the client `getTreatment*` methods
12
+ // In the client-side API, we bind a key to the client `getTreatment*` and `track` methods
14
13
  getTreatment: clientCS.getTreatment.bind(clientCS, key),
15
14
  getTreatmentWithConfig: clientCS.getTreatmentWithConfig.bind(clientCS, key),
16
15
  getTreatments: clientCS.getTreatments.bind(clientCS, key),
@@ -19,11 +18,9 @@ export function clientCSDecorator(log, client, key, trafficType) {
19
18
  getTreatmentsWithConfigByFlagSets: clientCS.getTreatmentsWithConfigByFlagSets.bind(clientCS, key),
20
19
  getTreatmentsByFlagSet: clientCS.getTreatmentsByFlagSet.bind(clientCS, key),
21
20
  getTreatmentsWithConfigByFlagSet: clientCS.getTreatmentsWithConfigByFlagSet.bind(clientCS, key),
22
- // Key is bound to the `track` method. Same thing happens with trafficType but only if provided
23
- track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key),
21
+ track: clientCS.track.bind(clientCS, key),
24
22
  // Not part of the public API. These properties are used to support other modules (e.g., Split Suite)
25
23
  isClientSide: true,
26
- key: key,
27
- trafficType: trafficType
24
+ key: key
28
25
  });
29
26
  }
@@ -22,7 +22,7 @@ export function sdkClientMethodCSFactory(params) {
22
22
  log.debug(RETRIEVE_CLIENT_DEFAULT);
23
23
  return mainClientInstance;
24
24
  }
25
- // Validate the key value. The trafficType (2nd argument) is ignored
25
+ // Validate the key value
26
26
  var validKey = validateKey(log, key, LOG_PREFIX_CLIENT_INSTANTIATION);
27
27
  if (validKey === false) {
28
28
  throw new Error('Shared Client needs a valid key.');
@@ -1,6 +1,5 @@
1
1
  import { objectAssign } from '../utils/lang/objectAssign';
2
- import { _Set } from '../utils/lang/sets';
3
- var FORBIDDEN_HEADERS = new _Set([
2
+ var FORBIDDEN_HEADERS = new Set([
4
3
  'splitsdkclientkey',
5
4
  'splitsdkversion',
6
5
  'splitsdkmachineip',
@@ -20,12 +20,6 @@ var KeyBuilderCS = /** @class */ (function (_super) {
20
20
  if (startsWith(builtSegmentKeyName, prefix))
21
21
  return builtSegmentKeyName.substr(prefix.length);
22
22
  };
23
- // @BREAKING: The key used to start with the matching key instead of the prefix, this was changed on version 10.17.3
24
- KeyBuilderCS.prototype.extractOldSegmentKey = function (builtSegmentKeyName) {
25
- var prefix = this.matchingKey + "." + this.prefix + ".segment.";
26
- if (startsWith(builtSegmentKeyName, prefix))
27
- return builtSegmentKeyName.substr(prefix.length);
28
- };
29
23
  KeyBuilderCS.prototype.buildLastUpdatedKey = function () {
30
24
  return this.prefix + ".splits.lastUpdated";
31
25
  };
@@ -48,9 +42,6 @@ export function myLargeSegmentsKeyBuilder(prefix, matchingKey) {
48
42
  if (startsWith(builtSegmentKeyName, p))
49
43
  return builtSegmentKeyName.substr(p.length);
50
44
  },
51
- extractOldSegmentKey: function () {
52
- return undefined;
53
- },
54
45
  buildTillKey: function () {
55
46
  return prefix + "." + matchingKey + ".largeSegments.till";
56
47
  }
@@ -45,28 +45,8 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
45
45
  // Scan current values from localStorage
46
46
  return Object.keys(localStorage).reduce(function (accum, key) {
47
47
  var segmentName = _this.keys.extractSegmentName(key);
48
- if (segmentName) {
48
+ if (segmentName)
49
49
  accum.push(segmentName);
50
- }
51
- else {
52
- // @TODO @BREAKING: This is only to clean up "old" keys. Remove this whole else code block
53
- segmentName = _this.keys.extractOldSegmentKey(key);
54
- if (segmentName) { // this was an old segment key, let's clean up.
55
- var newSegmentKey = _this.keys.buildSegmentNameKey(segmentName);
56
- try {
57
- // If the new format key is not there, create it.
58
- if (!localStorage.getItem(newSegmentKey)) {
59
- localStorage.setItem(newSegmentKey, DEFINED);
60
- // we are migrating a segment, let's track it.
61
- accum.push(segmentName);
62
- }
63
- localStorage.removeItem(key); // we migrated the current key, let's delete it.
64
- }
65
- catch (e) {
66
- _this.log.error(e);
67
- }
68
- }
69
- }
70
50
  return accum;
71
51
  }, []);
72
52
  };