@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,113 +1,17 @@
1
- /**
2
- * Set implementation based on es6-set polyfill (https://github.com/medikoo/es6-set/blob/master/polyfill.js),
3
- * with the minimal features used by the SDK.
4
-
5
- Copyright (C) 2013 Mariusz Nowak (www.medikoo.com)
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in
15
- all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- THE SOFTWARE.
24
- **/
25
- var SetPoly = /** @class */ (function () {
26
- // unlike ES6 `Set`, it only accepts an array as first argument iterable
27
- function SetPoly(values) {
28
- var _this = this;
29
- this.__setData__ = [];
30
- if (Array.isArray(values))
31
- values.forEach(function (value) { _this.add(value); });
32
- }
33
- SetPoly.prototype.clear = function () {
34
- if (!this.__setData__.length)
35
- return;
36
- this.__setData__.length = 0;
37
- };
38
- SetPoly.prototype.add = function (value) {
39
- if (this.has(value))
40
- return this;
41
- this.__setData__.push(value);
42
- return this;
43
- };
44
- SetPoly.prototype.delete = function (value) {
45
- var index = this.__setData__.indexOf(value);
46
- if (index === -1)
47
- return false;
48
- this.__setData__.splice(index, 1);
49
- return true;
50
- };
51
- SetPoly.prototype.has = function (value) {
52
- return this.__setData__.indexOf(value) !== -1;
53
- };
54
- SetPoly.prototype.forEach = function (callbackfn, thisArg) {
55
- if (typeof callbackfn !== 'function')
56
- throw new TypeError(callbackfn + ' is not a function');
57
- for (var i = 0; i < this.__setData__.length; i++) {
58
- var value = this.__setData__[i];
59
- callbackfn.call(thisArg, value, value, this);
60
- }
61
- };
62
- Object.defineProperty(SetPoly.prototype, "size", {
63
- get: function () {
64
- return this.__setData__.length;
65
- },
66
- enumerable: false,
67
- configurable: true
68
- });
69
- return SetPoly;
70
- }());
71
- export { SetPoly };
72
- /**
73
- * return an array containing the items of the given set.
74
- * @param set Set or SetPoly instance
75
- */
76
1
  export function setToArray(set) {
77
- if (set instanceof SetPoly) {
78
- return set.__setData__.slice();
79
- }
80
- // if not using SetPoly as set, it means Array.from is supported
81
- // eslint-disable-next-line compat/compat
82
- return Array.from(set);
83
- }
84
- /**
85
- * 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,
86
- * a ponyfill with minimal features is returned instead.
87
- *
88
- * Exported for testing purposes only.
89
- */
90
- export function __getSetConstructor() {
91
- // eslint-disable-next-line compat/compat
92
- if (typeof Array.from === 'function' && typeof Set === 'function' && Set.prototype && Set.prototype.values) {
93
- return Set;
94
- }
95
- return SetPoly;
2
+ if (Array.from)
3
+ return Array.from(set);
4
+ var array = [];
5
+ set.forEach(function (value) {
6
+ array.push(value);
7
+ });
8
+ return array;
96
9
  }
97
- export var _Set = __getSetConstructor();
98
10
  export function returnSetsUnion(set, set2) {
99
- var result = new _Set(setToArray(set));
100
- set2.forEach(function (value) {
101
- result.add(value);
102
- });
103
- return result;
11
+ return new Set(setToArray(set).concat(setToArray(set2)));
104
12
  }
105
13
  export function returnDifference(list, list2) {
106
14
  if (list === void 0) { list = []; }
107
15
  if (list2 === void 0) { list2 = []; }
108
- var result = new _Set(list);
109
- list2.forEach(function (item) {
110
- result.delete(item);
111
- });
112
- return setToArray(result);
16
+ return list.filter(function (item) { return list2.indexOf(item) === -1; });
113
17
  }
@@ -4,7 +4,6 @@ import { validateSplitFilters } from './splitFilters';
4
4
  import { STANDALONE_MODE, OPTIMIZED, LOCALHOST_MODE, DEBUG, FLAG_SPEC_VERSION } from '../constants';
5
5
  import { validImpressionsMode } from './impressionsMode';
6
6
  import { validateKey } from '../inputValidation/key';
7
- import { validateTrafficType } from '../inputValidation/trafficType';
8
7
  import { ERROR_MIN_CONFIG_PARAM, LOG_PREFIX_CLIENT_INSTANTIATION } from '../../logger/constants';
9
8
  // Exported for telemetry
10
9
  export var base = {
@@ -15,8 +14,6 @@ export var base = {
15
14
  authorizationKey: undefined,
16
15
  // key used in your system (only required for browser version)
17
16
  key: undefined,
18
- // traffic type for the given key (only used on browser version)
19
- trafficType: undefined,
20
17
  // toggle impressions tracking of labels
21
18
  labelsEnabled: true,
22
19
  // toggle sendind (true) or not sending (false) IP and Host Name with impressions, events, and telemetries requests (only used on nodejs version)
@@ -145,12 +142,6 @@ export function settingsValidation(config, validationParams) {
145
142
  // @ts-ignore, @TODO handle invalid keys as a non-recoverable error?
146
143
  withDefaults.core.key = validateKey(log, maybeKey, LOG_PREFIX_CLIENT_INSTANTIATION);
147
144
  }
148
- if (validationParams.acceptTT) {
149
- var maybeTT = withDefaults.core.trafficType;
150
- if (maybeTT !== undefined) { // @ts-ignore
151
- withDefaults.core.trafficType = validateTrafficType(log, maybeTT, LOG_PREFIX_CLIENT_INSTANTIATION);
152
- }
153
- }
154
145
  }
155
146
  else {
156
147
  // On server-side, key is undefined and used to distinguish from client-side
@@ -2,9 +2,8 @@ import { isLogLevelString, Logger, LogLevels } from '../../../logger';
2
2
  import { isLocalStorageAvailable } from '../../env/isLocalStorageAvailable';
3
3
  import { isNode } from '../../env/isNode';
4
4
  import { codesDebug } from '../../../logger/messages/debug';
5
- import { _Map } from '../../lang/maps';
6
5
  import { getLogLevel } from './commons';
7
- var allCodes = new _Map(codesDebug);
6
+ var allCodes = new Map(codesDebug);
8
7
  // @TODO set default debug setting instead of initialLogLevel when integrating in JS and Node packages
9
8
  var LS_KEY = 'splitio_debug';
10
9
  var ENV_VAR_KEY = 'SPLITIO_DEBUG';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.17.1-rc.4",
3
+ "version": "2.0.0-rc.1",
4
4
  "description": "Split JavaScript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -64,7 +64,7 @@
64
64
  "@typescript-eslint/parser": "^6.6.0",
65
65
  "cross-env": "^7.0.2",
66
66
  "eslint": "^8.48.0",
67
- "eslint-plugin-compat": "^4.2.0",
67
+ "eslint-plugin-compat": "^6.0.1",
68
68
  "eslint-plugin-import": "^2.25.3",
69
69
  "fetch-mock": "^9.11.0",
70
70
  "ioredis": "^4.28.0",
@@ -21,7 +21,7 @@ export class Engine {
21
21
 
22
22
  constructor(private baseInfo: ISplit, private evaluator: IEvaluator) {
23
23
 
24
- // in case we don't have a default treatment in the instanciation, use 'control'
24
+ // in case we don't have a default treatment in the instantiation, use 'control'
25
25
  if (typeof this.baseInfo.defaultTreatment !== 'string') {
26
26
  this.baseInfo.defaultTreatment = CONTROL;
27
27
  }
@@ -7,7 +7,7 @@ import { IStorageAsync, IStorageSync } from '../storages/types';
7
7
  import { IEvaluationResult } from './types';
8
8
  import { SplitIO } from '../types';
9
9
  import { ILogger } from '../logger/types';
10
- import { ISet, setToArray, returnSetsUnion, _Set } from '../utils/lang/sets';
10
+ import { returnSetsUnion, setToArray } from '../utils/lang/sets';
11
11
  import { WARN_FLAGSET_WITHOUT_FLAGS } from '../logger/constants';
12
12
 
13
13
  const treatmentException = {
@@ -97,12 +97,12 @@ export function evaluateFeaturesByFlagSets(
97
97
  storage: IStorageSync | IStorageAsync,
98
98
  method: string,
99
99
  ): MaybeThenable<Record<string, IEvaluationResult>> {
100
- let storedFlagNames: MaybeThenable<ISet<string>[]>;
100
+ let storedFlagNames: MaybeThenable<Set<string>[]>;
101
101
 
102
102
  function evaluate(
103
- featureFlagsByFlagSets: ISet<string>[],
103
+ featureFlagsByFlagSets: Set<string>[],
104
104
  ) {
105
- let featureFlags = new _Set();
105
+ let featureFlags = new Set<string>();
106
106
  for (let i = 0; i < flagSets.length; i++) {
107
107
  const featureFlagByFlagSet = featureFlagsByFlagSets[i];
108
108
  if (featureFlagByFlagSet.size) {
@@ -1,11 +1,10 @@
1
- import { _Set } from '../../utils/lang/sets';
2
1
  import { Semver } from '../../utils/Semver';
3
2
 
4
3
  export function inListSemverMatcherContext(ruleAttr: string[]) {
5
4
  // @TODO ruleAttr validation should be done at the `parser` or `matchersTransform` level to reuse for all matchers
6
5
  if (!ruleAttr || ruleAttr.length === 0) throw new Error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type');
7
6
 
8
- const listOfSemvers = new _Set(ruleAttr.map((version) => new Semver(version).version));
7
+ const listOfSemvers = new Set(ruleAttr.map((version) => new Semver(version).version));
9
8
 
10
9
  return function inListSemverMatcher(runtimeAttr: string): boolean {
11
10
  const runtimeSemver = new Semver(runtimeAttr).version;
@@ -1,7 +1,5 @@
1
- import { _Set } from '../../utils/lang/sets';
2
-
3
1
  export function whitelistMatcherContext(ruleAttr: string[]) {
4
- const whitelistSet = new _Set(ruleAttr);
2
+ const whitelistSet = new Set(ruleAttr);
5
3
 
6
4
  return function whitelistMatcher(runtimeAttr: string): boolean {
7
5
  const isInWhitelist = whitelistSet.has(runtimeAttr);
@@ -115,7 +115,6 @@ export class BrowserSignalListener implements ISignalListener {
115
115
  * Returns true if beacon API was used successfully, false otherwise.
116
116
  */
117
117
  private _sendBeacon(url: string, data: any, extraMetadata?: {}) {
118
- // eslint-disable-next-line compat/compat
119
118
  if (typeof navigator !== 'undefined' && navigator.sendBeacon) {
120
119
  const json = {
121
120
  entries: data,
@@ -130,7 +129,7 @@ export class BrowserSignalListener implements ISignalListener {
130
129
  const payload = JSON.stringify(json);
131
130
 
132
131
  // https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
133
- try { // eslint-disable-next-line compat/compat
132
+ try {
134
133
  return navigator.sendBeacon(url, payload);
135
134
  } catch (e) {
136
135
  return false;
@@ -1,7 +1,6 @@
1
1
  import { Logger } from '../index';
2
2
  import { codesDebug } from '../messages/debug';
3
- import { _Map } from '../../utils/lang/maps';
4
3
 
5
4
  export function DebugLogger() {
6
- return new Logger({ logLevel: 'DEBUG' }, new _Map(codesDebug));
5
+ return new Logger({ logLevel: 'DEBUG' }, new Map(codesDebug));
7
6
  }
@@ -1,7 +1,6 @@
1
1
  import { Logger } from '../index';
2
2
  import { codesError } from '../messages/error';
3
- import { _Map } from '../../utils/lang/maps';
4
3
 
5
4
  export function ErrorLogger() {
6
- return new Logger({ logLevel: 'ERROR' }, new _Map(codesError));
5
+ return new Logger({ logLevel: 'ERROR' }, new Map(codesError));
7
6
  }
@@ -1,7 +1,6 @@
1
1
  import { Logger } from '../index';
2
2
  import { codesInfo } from '../messages/info';
3
- import { _Map } from '../../utils/lang/maps';
4
3
 
5
4
  export function InfoLogger() {
6
- return new Logger({ logLevel: 'INFO' }, new _Map(codesInfo));
5
+ return new Logger({ logLevel: 'INFO' }, new Map(codesInfo));
7
6
  }
@@ -1,7 +1,6 @@
1
1
  import { Logger } from '../index';
2
2
  import { codesWarn } from '../messages/warn';
3
- import { _Map } from '../../utils/lang/maps';
4
3
 
5
4
  export function WarnLogger() {
6
- return new Logger({ logLevel: 'WARN' }, new _Map(codesWarn));
5
+ return new Logger({ logLevel: 'WARN' }, new Map(codesWarn));
7
6
  }
@@ -2,7 +2,6 @@ import { objectAssign } from '../utils/lang/objectAssign';
2
2
  import { ILoggerOptions, ILogger } from './types';
3
3
  import { find, isObject } from '../utils/lang';
4
4
  import { LogLevel } from '../types';
5
- import { IMap, _Map } from '../utils/lang/maps';
6
5
 
7
6
  export const LogLevels: { [level: string]: LogLevel } = {
8
7
  DEBUG: 'DEBUG',
@@ -47,12 +46,12 @@ const defaultOptions = {
47
46
  export class Logger implements ILogger {
48
47
 
49
48
  private options: Required<ILoggerOptions>;
50
- private codes: IMap<number, string>;
49
+ private codes: Map<number, string>;
51
50
  private logLevel: number;
52
51
 
53
- constructor(options?: ILoggerOptions, codes?: IMap<number, string>) {
52
+ constructor(options?: ILoggerOptions, codes?: Map<number, string>) {
54
53
  this.options = objectAssign({}, defaultOptions, options);
55
- this.codes = codes || new _Map();
54
+ this.codes = codes || new Map();
56
55
  this.logLevel = LogLevelIndexes[this.options.logLevel];
57
56
  }
58
57
 
@@ -5,18 +5,17 @@ import { clientAttributesDecoration } from './clientAttributesDecoration';
5
5
 
6
6
 
7
7
  /**
8
- * Decorator that binds a key and (optionally) a traffic type to client methods
8
+ * Decorator that binds a key to client methods
9
9
  *
10
10
  * @param client sync client instance
11
11
  * @param key validated split key
12
- * @param trafficType validated traffic type
13
12
  */
14
- export function clientCSDecorator(log: ILogger, client: SplitIO.IClient, key: SplitIO.SplitKey, trafficType?: string): SplitIO.ICsClient {
13
+ export function clientCSDecorator(log: ILogger, client: SplitIO.IClient, key: SplitIO.SplitKey): SplitIO.ICsClient {
15
14
 
16
15
  let clientCS = clientAttributesDecoration(log, client);
17
16
 
18
17
  return objectAssign(clientCS, {
19
- // In the client-side API, we bind a key to the client `getTreatment*` methods
18
+ // In the client-side API, we bind a key to the client `getTreatment*` and `track` methods
20
19
  getTreatment: clientCS.getTreatment.bind(clientCS, key),
21
20
  getTreatmentWithConfig: clientCS.getTreatmentWithConfig.bind(clientCS, key),
22
21
  getTreatments: clientCS.getTreatments.bind(clientCS, key),
@@ -26,12 +25,10 @@ export function clientCSDecorator(log: ILogger, client: SplitIO.IClient, key: Sp
26
25
  getTreatmentsByFlagSet: clientCS.getTreatmentsByFlagSet.bind(clientCS, key),
27
26
  getTreatmentsWithConfigByFlagSet: clientCS.getTreatmentsWithConfigByFlagSet.bind(clientCS, key),
28
27
 
29
- // Key is bound to the `track` method. Same thing happens with trafficType but only if provided
30
- track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key),
28
+ track: clientCS.track.bind(clientCS, key),
31
29
 
32
30
  // Not part of the public API. These properties are used to support other modules (e.g., Split Suite)
33
31
  isClientSide: true,
34
- key,
35
- trafficType
32
+ key
36
33
  }) as SplitIO.ICsClient;
37
34
  }
@@ -35,7 +35,7 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl
35
35
  return mainClientInstance;
36
36
  }
37
37
 
38
- // Validate the key value. The trafficType (2nd argument) is ignored
38
+ // Validate the key value
39
39
  const validKey = validateKey(log, key, LOG_PREFIX_CLIENT_INSTANTIATION);
40
40
  if (validKey === false) {
41
41
  throw new Error('Shared Client needs a valid key.');
@@ -95,7 +95,7 @@ export interface ISdkFactoryParams {
95
95
 
96
96
  // Sdk client method factory (ISDK::client method).
97
97
  // It Allows to distinguish SDK clients with the client-side API (`ICsSDK`) or server-side API (`ISDK` or `IAsyncSDK`).
98
- sdkClientMethodFactory: (params: ISdkFactoryContext) => ({ (): SplitIO.ICsClient; (key: SplitIO.SplitKey, trafficType?: string | undefined): SplitIO.ICsClient; } | (() => SplitIO.IClient) | (() => SplitIO.IAsyncClient))
98
+ sdkClientMethodFactory: (params: ISdkFactoryContext) => ({ (): SplitIO.ICsClient; (key: SplitIO.SplitKey): SplitIO.ICsClient; } | (() => SplitIO.IClient) | (() => SplitIO.IAsyncClient))
99
99
 
100
100
  // Impression observer factory.
101
101
  impressionsObserverFactory: () => IImpressionObserver
@@ -1,8 +1,7 @@
1
1
  import { objectAssign } from '../utils/lang/objectAssign';
2
- import { _Set } from '../utils/lang/sets';
3
2
  import { ISettings } from '../types';
4
3
 
5
- const FORBIDDEN_HEADERS = new _Set([
4
+ const FORBIDDEN_HEADERS = new Set([
6
5
  'splitsdkclientkey',
7
6
  'splitsdkversion',
8
7
  'splitsdkmachineip',
@@ -1,7 +1,6 @@
1
1
  import { ISplitsCacheAsync } from './types';
2
2
  import { ISplit } from '../dtos/types';
3
3
  import { objectAssign } from '../utils/lang/objectAssign';
4
- import { ISet } from '../utils/lang/sets';
5
4
 
6
5
  /**
7
6
  * This class provides a skeletal implementation of the ISplitsCacheAsync interface
@@ -18,7 +17,7 @@ export abstract class AbstractSplitsCacheAsync implements ISplitsCacheAsync {
18
17
  abstract getChangeNumber(): Promise<number>
19
18
  abstract getAll(): Promise<ISplit[]>
20
19
  abstract getSplitNames(): Promise<string[]>
21
- abstract getNamesByFlagSets(flagSets: string[]): Promise<ISet<string>[]>
20
+ abstract getNamesByFlagSets(flagSets: string[]): Promise<Set<string>[]>
22
21
  abstract trafficTypeExists(trafficType: string): Promise<boolean>
23
22
  abstract clear(): Promise<boolean | void>
24
23
 
@@ -1,7 +1,6 @@
1
1
  import { ISplitsCacheSync } from './types';
2
2
  import { ISplit } from '../dtos/types';
3
3
  import { objectAssign } from '../utils/lang/objectAssign';
4
- import { ISet } from '../utils/lang/sets';
5
4
  import { IN_SEGMENT, IN_LARGE_SEGMENT } from '../utils/constants';
6
5
 
7
6
  /**
@@ -80,7 +79,7 @@ export abstract class AbstractSplitsCacheSync implements ISplitsCacheSync {
80
79
  return false;
81
80
  }
82
81
 
83
- abstract getNamesByFlagSets(flagSets: string[]): ISet<string>[]
82
+ abstract getNamesByFlagSets(flagSets: string[]): Set<string>[]
84
83
 
85
84
  }
86
85
 
@@ -4,7 +4,6 @@ import { KeyBuilder } from './KeyBuilder';
4
4
  export interface MySegmentsKeyBuilder {
5
5
  buildSegmentNameKey(segmentName: string): string;
6
6
  extractSegmentName(builtSegmentKeyName: string): string | undefined;
7
- extractOldSegmentKey(builtSegmentKeyName: string): string | undefined;
8
7
  buildTillKey(): string;
9
8
  }
10
9
 
@@ -33,14 +32,6 @@ export class KeyBuilderCS extends KeyBuilder implements MySegmentsKeyBuilder {
33
32
  return builtSegmentKeyName.substr(prefix.length);
34
33
  }
35
34
 
36
- // @BREAKING: The key used to start with the matching key instead of the prefix, this was changed on version 10.17.3
37
- extractOldSegmentKey(builtSegmentKeyName: string) {
38
- const prefix = `${this.matchingKey}.${this.prefix}.segment.`;
39
-
40
- if (startsWith(builtSegmentKeyName, prefix))
41
- return builtSegmentKeyName.substr(prefix.length);
42
- }
43
-
44
35
  buildLastUpdatedKey() {
45
36
  return `${this.prefix}.splits.lastUpdated`;
46
37
  }
@@ -66,10 +57,6 @@ export function myLargeSegmentsKeyBuilder(prefix: string, matchingKey: string):
66
57
  if (startsWith(builtSegmentKeyName, p)) return builtSegmentKeyName.substr(p.length);
67
58
  },
68
59
 
69
- extractOldSegmentKey() {
70
- return undefined;
71
- },
72
-
73
60
  buildTillKey() {
74
61
  return `${prefix}.${matchingKey}.largeSegments.till`;
75
62
  }
@@ -51,27 +51,7 @@ export class MySegmentsCacheInLocal extends AbstractMySegmentsCacheSync {
51
51
  return Object.keys(localStorage).reduce((accum, key) => {
52
52
  let segmentName = this.keys.extractSegmentName(key);
53
53
 
54
- if (segmentName) {
55
- accum.push(segmentName);
56
- } else {
57
- // @TODO @BREAKING: This is only to clean up "old" keys. Remove this whole else code block
58
- segmentName = this.keys.extractOldSegmentKey(key);
59
-
60
- if (segmentName) { // this was an old segment key, let's clean up.
61
- const newSegmentKey = this.keys.buildSegmentNameKey(segmentName);
62
- try {
63
- // If the new format key is not there, create it.
64
- if (!localStorage.getItem(newSegmentKey)) {
65
- localStorage.setItem(newSegmentKey, DEFINED);
66
- // we are migrating a segment, let's track it.
67
- accum.push(segmentName);
68
- }
69
- localStorage.removeItem(key); // we migrated the current key, let's delete it.
70
- } catch (e) {
71
- this.log.error(e);
72
- }
73
- }
74
- }
54
+ if (segmentName) accum.push(segmentName);
75
55
 
76
56
  return accum;
77
57
  }, [] as string[]);
@@ -4,9 +4,9 @@ import { isFiniteNumber, toNumber, isNaNNumber } from '../../utils/lang';
4
4
  import { KeyBuilderCS } from '../KeyBuilderCS';
5
5
  import { ILogger } from '../../logger/types';
6
6
  import { LOG_PREFIX } from './constants';
7
- import { ISet, _Set, setToArray } from '../../utils/lang/sets';
8
7
  import { ISettings } from '../../types';
9
8
  import { getStorageHash } from '../KeyBuilder';
9
+ import { setToArray } from '../../utils/lang/sets';
10
10
 
11
11
  /**
12
12
  * ISplitsCacheSync implementation that stores split definitions in browser LocalStorage.
@@ -259,12 +259,12 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
259
259
  // if the filter didn't change, nothing is done
260
260
  }
261
261
 
262
- getNamesByFlagSets(flagSets: string[]): ISet<string>[] {
262
+ getNamesByFlagSets(flagSets: string[]): Set<string>[] {
263
263
  return flagSets.map(flagSet => {
264
264
  const flagSetKey = this.keys.buildFlagSetKey(flagSet);
265
265
  const flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
266
266
 
267
- return new _Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
267
+ return new Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
268
268
  });
269
269
  }
270
270
 
@@ -279,7 +279,7 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
279
279
 
280
280
  const flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
281
281
 
282
- const flagSetCache = new _Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
282
+ const flagSetCache = new Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
283
283
  flagSetCache.add(featureFlag.name);
284
284
 
285
285
  localStorage.setItem(flagSetKey, JSON.stringify(setToArray(flagSetCache)));
@@ -301,7 +301,7 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
301
301
 
302
302
  if (!flagSetFromLocalStorage) return;
303
303
 
304
- const flagSetCache = new _Set(JSON.parse(flagSetFromLocalStorage));
304
+ const flagSetCache = new Set(JSON.parse(flagSetFromLocalStorage));
305
305
  flagSetCache.delete(featureFlagName);
306
306
 
307
307
  if (flagSetCache.size === 0) {
@@ -65,7 +65,7 @@ export function InLocalStorage(options: InLocalStorageOptions = {}): IStorageSyn
65
65
  this.uniqueKeys?.clear();
66
66
  },
67
67
 
68
- // When using shared instanciation with MEMORY we reuse everything but segments (they are customer per key).
68
+ // When using shared instantiation with MEMORY we reuse everything but segments (they are customer per key).
69
69
  shared(matchingKey: string) {
70
70
 
71
71
  return {
@@ -41,7 +41,7 @@ export function InMemoryStorageCSFactory(params: IStorageFactoryParams): IStorag
41
41
  this.uniqueKeys && this.uniqueKeys.clear();
42
42
  },
43
43
 
44
- // When using shared instanciation with MEMORY we reuse everything but segments (they are unique per key)
44
+ // When using shared instantiation with MEMORY we reuse everything but segments (they are unique per key)
45
45
  shared() {
46
46
  return {
47
47
  splits: this.splits,
@@ -1,4 +1,3 @@
1
- import { ISet, _Set } from '../../utils/lang/sets';
2
1
  import { isIntegerNumber } from '../../utils/lang';
3
2
  import { ISegmentsCacheSync } from '../types';
4
3
 
@@ -7,11 +6,11 @@ import { ISegmentsCacheSync } from '../types';
7
6
  */
8
7
  export class SegmentsCacheInMemory implements ISegmentsCacheSync {
9
8
 
10
- private segmentCache: Record<string, ISet<string>> = {};
9
+ private segmentCache: Record<string, Set<string>> = {};
11
10
  private segmentChangeNumber: Record<string, number> = {};
12
11
 
13
12
  update(name: string, addedKeys: string[], removedKeys: string[], changeNumber: number) {
14
- const keySet = this.segmentCache[name] || new _Set<string>();
13
+ const keySet = this.segmentCache[name] || new Set<string>();
15
14
 
16
15
  addedKeys.forEach(k => keySet.add(k));
17
16
  removedKeys.forEach(k => keySet.delete(k));
@@ -39,7 +38,7 @@ export class SegmentsCacheInMemory implements ISegmentsCacheSync {
39
38
 
40
39
  private _registerSegment(name: string) {
41
40
  if (!this.segmentCache[name]) {
42
- this.segmentCache[name] = new _Set<string>();
41
+ this.segmentCache[name] = new Set<string>();
43
42
  }
44
43
 
45
44
  return true;
@@ -1,7 +1,6 @@
1
1
  import { ISplit, ISplitFiltersValidation } from '../../dtos/types';
2
2
  import { AbstractSplitsCacheSync, usesSegments } from '../AbstractSplitsCacheSync';
3
3
  import { isFiniteNumber } from '../../utils/lang';
4
- import { ISet, _Set } from '../../utils/lang/sets';
5
4
 
6
5
  /**
7
6
  * Default ISplitsCacheSync implementation that stores split definitions in memory.
@@ -13,7 +12,7 @@ export class SplitsCacheInMemory extends AbstractSplitsCacheSync {
13
12
  private ttCache: Record<string, number> = {};
14
13
  private changeNumber: number = -1;
15
14
  private segmentsCount: number = 0;
16
- private flagSetsCache: Record<string, ISet<string>> = {};
15
+ private flagSetsCache: Record<string, Set<string>> = {};
17
16
 
18
17
  constructor(splitFiltersValidation?: ISplitFiltersValidation) {
19
18
  super();
@@ -103,8 +102,8 @@ export class SplitsCacheInMemory extends AbstractSplitsCacheSync {
103
102
  return this.getChangeNumber() === -1 || this.segmentsCount > 0;
104
103
  }
105
104
 
106
- getNamesByFlagSets(flagSets: string[]): ISet<string>[] {
107
- return flagSets.map(flagSet => this.flagSetsCache[flagSet] || new _Set());
105
+ getNamesByFlagSets(flagSets: string[]): Set<string>[] {
106
+ return flagSets.map(flagSet => this.flagSetsCache[flagSet] || new Set());
108
107
  }
109
108
 
110
109
  private addToFlagSets(featureFlag: ISplit) {
@@ -113,7 +112,7 @@ export class SplitsCacheInMemory extends AbstractSplitsCacheSync {
113
112
 
114
113
  if (this.flagSetsFilter.length > 0 && !this.flagSetsFilter.some(filterFlagSet => filterFlagSet === featureFlagSet)) return;
115
114
 
116
- if (!this.flagSetsCache[featureFlagSet]) this.flagSetsCache[featureFlagSet] = new _Set([]);
115
+ if (!this.flagSetsCache[featureFlagSet]) this.flagSetsCache[featureFlagSet] = new Set([]);
117
116
 
118
117
  this.flagSetsCache[featureFlagSet].add(featureFlag.name);
119
118
  });