@splitsoftware/splitio-commons 1.13.2-rc.8 → 1.14.0

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 (119) hide show
  1. package/CHANGES.txt +3 -3
  2. package/cjs/evaluator/matchers/all.js +1 -3
  3. package/cjs/evaluator/matchers/between.js +1 -3
  4. package/cjs/evaluator/matchers/boolean.js +1 -3
  5. package/cjs/evaluator/matchers/cont_all.js +1 -3
  6. package/cjs/evaluator/matchers/cont_any.js +1 -3
  7. package/cjs/evaluator/matchers/cont_str.js +1 -3
  8. package/cjs/evaluator/matchers/dependency.js +1 -1
  9. package/cjs/evaluator/matchers/eq.js +1 -3
  10. package/cjs/evaluator/matchers/eq_set.js +1 -3
  11. package/cjs/evaluator/matchers/ew.js +1 -3
  12. package/cjs/evaluator/matchers/gte.js +1 -3
  13. package/cjs/evaluator/matchers/index.js +1 -1
  14. package/cjs/evaluator/matchers/lte.js +1 -3
  15. package/cjs/evaluator/matchers/part_of.js +1 -3
  16. package/cjs/evaluator/matchers/segment.js +1 -6
  17. package/cjs/evaluator/matchers/semver_between.js +1 -1
  18. package/cjs/evaluator/matchers/semver_eq.js +1 -1
  19. package/cjs/evaluator/matchers/semver_gte.js +1 -1
  20. package/cjs/evaluator/matchers/semver_inlist.js +1 -1
  21. package/cjs/evaluator/matchers/semver_lte.js +1 -1
  22. package/cjs/evaluator/matchers/string.js +1 -3
  23. package/cjs/evaluator/matchers/sw.js +1 -3
  24. package/cjs/evaluator/matchers/whitelist.js +1 -3
  25. package/cjs/evaluator/parser/index.js +7 -4
  26. package/cjs/logger/constants.js +4 -19
  27. package/cjs/logger/messages/debug.js +5 -20
  28. package/cjs/logger/messages/warn.js +1 -1
  29. package/cjs/services/splitApi.js +1 -1
  30. package/esm/evaluator/matchers/all.js +1 -3
  31. package/esm/evaluator/matchers/between.js +1 -3
  32. package/esm/evaluator/matchers/boolean.js +1 -3
  33. package/esm/evaluator/matchers/cont_all.js +1 -3
  34. package/esm/evaluator/matchers/cont_any.js +1 -3
  35. package/esm/evaluator/matchers/cont_str.js +1 -3
  36. package/esm/evaluator/matchers/dependency.js +1 -1
  37. package/esm/evaluator/matchers/eq.js +1 -3
  38. package/esm/evaluator/matchers/eq_set.js +1 -3
  39. package/esm/evaluator/matchers/ew.js +1 -3
  40. package/esm/evaluator/matchers/gte.js +1 -3
  41. package/esm/evaluator/matchers/index.js +1 -1
  42. package/esm/evaluator/matchers/lte.js +1 -3
  43. package/esm/evaluator/matchers/part_of.js +1 -3
  44. package/esm/evaluator/matchers/segment.js +1 -6
  45. package/esm/evaluator/matchers/semver_between.js +1 -1
  46. package/esm/evaluator/matchers/semver_eq.js +1 -1
  47. package/esm/evaluator/matchers/semver_gte.js +1 -1
  48. package/esm/evaluator/matchers/semver_inlist.js +1 -1
  49. package/esm/evaluator/matchers/semver_lte.js +1 -1
  50. package/esm/evaluator/matchers/string.js +1 -3
  51. package/esm/evaluator/matchers/sw.js +1 -3
  52. package/esm/evaluator/matchers/whitelist.js +1 -3
  53. package/esm/evaluator/parser/index.js +8 -5
  54. package/esm/logger/constants.js +1 -16
  55. package/esm/logger/messages/debug.js +5 -20
  56. package/esm/logger/messages/warn.js +1 -1
  57. package/esm/services/splitApi.js +1 -1
  58. package/package.json +1 -1
  59. package/src/evaluator/matchers/all.ts +1 -5
  60. package/src/evaluator/matchers/between.ts +3 -7
  61. package/src/evaluator/matchers/boolean.ts +2 -6
  62. package/src/evaluator/matchers/cont_all.ts +1 -5
  63. package/src/evaluator/matchers/cont_any.ts +1 -5
  64. package/src/evaluator/matchers/cont_str.ts +2 -6
  65. package/src/evaluator/matchers/dependency.ts +1 -1
  66. package/src/evaluator/matchers/eq.ts +2 -6
  67. package/src/evaluator/matchers/eq_set.ts +1 -5
  68. package/src/evaluator/matchers/ew.ts +2 -6
  69. package/src/evaluator/matchers/gte.ts +2 -6
  70. package/src/evaluator/matchers/index.ts +1 -1
  71. package/src/evaluator/matchers/lte.ts +2 -6
  72. package/src/evaluator/matchers/part_of.ts +1 -5
  73. package/src/evaluator/matchers/segment.ts +1 -8
  74. package/src/evaluator/matchers/semver_between.ts +1 -2
  75. package/src/evaluator/matchers/semver_eq.ts +1 -2
  76. package/src/evaluator/matchers/semver_gte.ts +1 -2
  77. package/src/evaluator/matchers/semver_inlist.ts +2 -2
  78. package/src/evaluator/matchers/semver_lte.ts +1 -2
  79. package/src/evaluator/matchers/string.ts +1 -6
  80. package/src/evaluator/matchers/sw.ts +2 -6
  81. package/src/evaluator/matchers/whitelist.ts +1 -5
  82. package/src/evaluator/parser/index.ts +9 -5
  83. package/src/logger/constants.ts +1 -16
  84. package/src/logger/messages/debug.ts +5 -20
  85. package/src/logger/messages/warn.ts +1 -1
  86. package/src/services/splitApi.ts +1 -1
  87. package/types/evaluator/matchers/all.d.ts +1 -2
  88. package/types/evaluator/matchers/between.d.ts +1 -2
  89. package/types/evaluator/matchers/boolean.d.ts +1 -2
  90. package/types/evaluator/matchers/cont_all.d.ts +1 -2
  91. package/types/evaluator/matchers/cont_any.d.ts +1 -2
  92. package/types/evaluator/matchers/cont_str.d.ts +1 -2
  93. package/types/evaluator/matchers/dependency.d.ts +1 -1
  94. package/types/evaluator/matchers/eq.d.ts +1 -2
  95. package/types/evaluator/matchers/eq_set.d.ts +1 -2
  96. package/types/evaluator/matchers/ew.d.ts +1 -2
  97. package/types/evaluator/matchers/gte.d.ts +1 -2
  98. package/types/evaluator/matchers/lte.d.ts +1 -2
  99. package/types/evaluator/matchers/part_of.d.ts +1 -2
  100. package/types/evaluator/matchers/segment.d.ts +1 -2
  101. package/types/evaluator/matchers/sember_inlist.d.ts +3 -0
  102. package/types/evaluator/matchers/semver_between.d.ts +1 -2
  103. package/types/evaluator/matchers/semver_eq.d.ts +1 -2
  104. package/types/evaluator/matchers/semver_gte.d.ts +1 -2
  105. package/types/evaluator/matchers/semver_inlist.d.ts +1 -2
  106. package/types/evaluator/matchers/semver_lte.d.ts +1 -2
  107. package/types/evaluator/matchers/string.d.ts +1 -2
  108. package/types/evaluator/matchers/sw.d.ts +1 -2
  109. package/types/evaluator/matchers/whitelist.d.ts +1 -2
  110. package/types/evaluator/matchersTransform/set.d.ts +2 -2
  111. package/types/evaluator/matchersTransform/string.d.ts +7 -0
  112. package/types/logger/constants.d.ts +1 -16
  113. package/types/sdkClient/identity.d.ts +6 -0
  114. package/types/storages/AbstractSplitsCache.d.ts +46 -0
  115. package/types/sync/streaming/mySegmentsV2utils.d.ts +27 -0
  116. package/types/trackers/impressionObserver/utils.d.ts +1 -1
  117. package/types/utils/inputValidation/sdkKey.d.ts +7 -0
  118. package/types/utils/settingsValidation/logger/globalLogLevel.d.ts +8 -0
  119. /package/types/utils/{Semver.d.ts → semVer.d.ts} +0 -0
@@ -53,6 +53,6 @@ export function matcherFactory(log, matcherDto, storage) {
53
53
  var matcherFn;
54
54
  // @ts-ignore
55
55
  if (matchers[type])
56
- matcherFn = matchers[type](log, value, storage); // There is no index-out-of-bound exception in JavaScript
56
+ matcherFn = matchers[type](value, storage, log); // There is no index-out-of-bound exception in JavaScript
57
57
  return matcherFn;
58
58
  }
@@ -1,8 +1,6 @@
1
- import { ENGINE_MATCHER_LESS } from '../../logger/constants';
2
- export function lessThanEqualMatcherContext(log, ruleAttr) {
1
+ export function lessThanEqualMatcherContext(ruleAttr) {
3
2
  return function lessThanEqualMatcher(runtimeAttr) {
4
3
  var isLessThanEqual = runtimeAttr <= ruleAttr;
5
- log.debug(ENGINE_MATCHER_LESS, [runtimeAttr, ruleAttr, isLessThanEqual]);
6
4
  return isLessThanEqual;
7
5
  };
8
6
  }
@@ -1,6 +1,5 @@
1
1
  import { findIndex } from '../../utils/lang';
2
- import { ENGINE_MATCHER_PART_OF } from '../../logger/constants';
3
- export function partOfSetMatcherContext(log, ruleAttr) {
2
+ export function partOfSetMatcherContext(ruleAttr) {
4
3
  return function partOfMatcher(runtimeAttr) {
5
4
  // To be part of the length should be minor or equal.
6
5
  var isPartOf = runtimeAttr.length <= ruleAttr.length;
@@ -12,7 +11,6 @@ export function partOfSetMatcherContext(log, ruleAttr) {
12
11
  for (var i = 0; i < runtimeAttr.length && isPartOf; i++) {
13
12
  _loop_1(i);
14
13
  }
15
- log.debug(ENGINE_MATCHER_PART_OF, [runtimeAttr, ruleAttr, isPartOf]);
16
14
  return isPartOf;
17
15
  };
18
16
  }
@@ -1,17 +1,12 @@
1
1
  import { thenable } from '../../utils/promise/thenable';
2
- import { ENGINE_MATCHER_SEGMENT } from '../../logger/constants';
3
- export function segmentMatcherContext(log, segmentName, storage) {
2
+ export function segmentMatcherContext(segmentName, storage) {
4
3
  return function segmentMatcher(key) {
5
4
  var isInSegment = storage.segments.isInSegment(segmentName, key);
6
5
  if (thenable(isInSegment)) {
7
6
  isInSegment.then(function (result) {
8
- log.debug(ENGINE_MATCHER_SEGMENT, [segmentName, key, isInSegment]);
9
7
  return result;
10
8
  });
11
9
  }
12
- else {
13
- log.debug(ENGINE_MATCHER_SEGMENT, [segmentName, key, isInSegment]);
14
- }
15
10
  return isInSegment;
16
11
  };
17
12
  }
@@ -1,5 +1,5 @@
1
1
  import { Semver } from '../../utils/Semver';
2
- export function betweenSemverMatcherContext(log, ruleAttr) {
2
+ export function betweenSemverMatcherContext(ruleAttr) {
3
3
  var startSemver = new Semver(ruleAttr.start);
4
4
  var endSemver = new Semver(ruleAttr.end);
5
5
  return function betweenSemverMatcher(runtimeAttr) {
@@ -1,5 +1,5 @@
1
1
  import { Semver } from '../../utils/Semver';
2
- export function equalToSemverMatcherContext(log, ruleAttr) {
2
+ export function equalToSemverMatcherContext(ruleAttr) {
3
3
  var ruleSemver = new Semver(ruleAttr);
4
4
  return function equalToSemverMatcher(runtimeAttr) {
5
5
  var runtimeSemver = new Semver(runtimeAttr);
@@ -1,5 +1,5 @@
1
1
  import { Semver } from '../../utils/Semver';
2
- export function greaterThanEqualToSemverMatcherContext(log, ruleAttr) {
2
+ export function greaterThanEqualToSemverMatcherContext(ruleAttr) {
3
3
  var ruleSemver = new Semver(ruleAttr);
4
4
  return function greaterThanEqualToSemverMatcher(runtimeAttr) {
5
5
  var runtimeSemver = new Semver(runtimeAttr);
@@ -1,6 +1,6 @@
1
1
  import { _Set } from '../../utils/lang/sets';
2
2
  import { Semver } from '../../utils/Semver';
3
- export function inListSemverMatcherContext(log, ruleAttr) {
3
+ export function inListSemverMatcherContext(ruleAttr) {
4
4
  // @TODO ruleAttr validation should be done at the `parser` or `matchersTransform` level to reuse for all matchers
5
5
  if (!ruleAttr || ruleAttr.length === 0)
6
6
  throw new Error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type');
@@ -1,5 +1,5 @@
1
1
  import { Semver } from '../../utils/Semver';
2
- export function lessThanEqualToSemverMatcherContext(log, ruleAttr) {
2
+ export function lessThanEqualToSemverMatcherContext(ruleAttr) {
3
3
  var ruleSemver = new Semver(ruleAttr);
4
4
  return function lessThanEqualToSemverMatcher(runtimeAttr) {
5
5
  var runtimeSemver = new Semver(runtimeAttr);
@@ -1,9 +1,7 @@
1
- import { ENGINE_MATCHER_STRING } from '../../logger/constants';
2
- export function stringMatcherContext(log, ruleAttr) {
1
+ export function stringMatcherContext(ruleAttr) {
3
2
  var regex = new RegExp(ruleAttr);
4
3
  return function stringMatcher(runtimeAttr) {
5
4
  var regexMatches = regex.test(runtimeAttr);
6
- log.debug(ENGINE_MATCHER_STRING, [runtimeAttr, ruleAttr, regexMatches ? 'yes' : 'no']);
7
5
  return regexMatches;
8
6
  };
9
7
  }
@@ -1,9 +1,7 @@
1
- import { ENGINE_MATCHER_STARTS_WITH } from '../../logger/constants';
2
1
  import { startsWith } from '../../utils/lang';
3
- export function startsWithMatcherContext(log, ruleAttr) {
2
+ export function startsWithMatcherContext(ruleAttr) {
4
3
  return function startsWithMatcher(runtimeAttr) {
5
4
  var matches = ruleAttr.some(function (e) { return startsWith(runtimeAttr, e); });
6
- log.debug(ENGINE_MATCHER_STARTS_WITH, [runtimeAttr, ruleAttr, matches]);
7
5
  return matches;
8
6
  };
9
7
  }
@@ -1,10 +1,8 @@
1
1
  import { _Set } from '../../utils/lang/sets';
2
- import { ENGINE_MATCHER_WHITELIST } from '../../logger/constants';
3
- export function whitelistMatcherContext(log, ruleAttr) {
2
+ export function whitelistMatcherContext(ruleAttr) {
4
3
  var whitelistSet = new _Set(ruleAttr);
5
4
  return function whitelistMatcher(runtimeAttr) {
6
5
  var isInWhitelist = whitelistSet.has(runtimeAttr);
7
- log.debug(ENGINE_MATCHER_WHITELIST, [runtimeAttr, ruleAttr.join(','), isInWhitelist]);
8
6
  return isInWhitelist;
9
7
  };
10
8
  }
@@ -6,7 +6,7 @@ import { conditionContext } from '../condition';
6
6
  import { ifElseIfCombinerContext } from '../combiners/ifelseif';
7
7
  import { andCombinerContext } from '../combiners/and';
8
8
  import { thenable } from '../../utils/promise/thenable';
9
- import { ENGINE_MATCHER_ERROR } from '../../logger/constants';
9
+ import { ENGINE_MATCHER_ERROR, ENGINE_MATCHER_RESULT } from '../../logger/constants';
10
10
  export function parser(log, conditions, storage) {
11
11
  var predicates = [];
12
12
  for (var i = 0; i < conditions.length; i++) {
@@ -34,10 +34,13 @@ export function parser(log, conditions, storage) {
34
34
  log.error(ENGINE_MATCHER_ERROR, [matcherDto.name, error]);
35
35
  }
36
36
  }
37
- if (thenable(result)) { // @ts-ignore
38
- return result.then(function (res) { return Boolean(res ^ matcherDto.negate); });
39
- } // @ts-ignore
40
- return Boolean(result ^ matcherDto.negate);
37
+ function handleResult(result) {
38
+ log.debug(ENGINE_MATCHER_RESULT, [matcherDto.name, result, matcherDto.value, value]); // @ts-ignore
39
+ return Boolean(result ^ matcherDto.negate);
40
+ }
41
+ return thenable(result) ?
42
+ result.then(handleResult) :
43
+ handleResult(result);
41
44
  };
42
45
  });
43
46
  // if matcher's factory can't instantiate the matchers, the expressions array will be empty
@@ -9,24 +9,8 @@ export var ENGINE_COMBINER_AND = 0;
9
9
  export var ENGINE_COMBINER_IFELSEIF = 1;
10
10
  export var ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = 2;
11
11
  export var ENGINE_BUCKET = 3;
12
- export var ENGINE_MATCHER_ALL = 4;
13
- export var ENGINE_MATCHER_BETWEEN = 5;
14
- export var ENGINE_MATCHER_BOOLEAN = 6;
15
- export var ENGINE_MATCHER_CONTAINS_ALL = 7;
16
- export var ENGINE_MATCHER_CONTAINS_ANY = 8;
17
- export var ENGINE_MATCHER_CONTAINS_STRING = 9;
18
12
  export var ENGINE_MATCHER_DEPENDENCY = 10;
19
13
  export var ENGINE_MATCHER_DEPENDENCY_PRE = 11;
20
- export var ENGINE_MATCHER_EQUAL = 12;
21
- export var ENGINE_MATCHER_EQUAL_TO_SET = 13;
22
- export var ENGINE_MATCHER_ENDS_WITH = 14;
23
- export var ENGINE_MATCHER_GREATER = 15;
24
- export var ENGINE_MATCHER_LESS = 16;
25
- export var ENGINE_MATCHER_PART_OF = 17;
26
- export var ENGINE_MATCHER_SEGMENT = 18;
27
- export var ENGINE_MATCHER_STRING = 19;
28
- export var ENGINE_MATCHER_STARTS_WITH = 21;
29
- export var ENGINE_MATCHER_WHITELIST = 22;
30
14
  export var ENGINE_VALUE = 23;
31
15
  export var ENGINE_SANITIZE = 24;
32
16
  export var CLEANUP_REGISTERING = 25;
@@ -44,6 +28,7 @@ export var SYNC_TASK_START = 36;
44
28
  export var SYNC_TASK_EXECUTE = 37;
45
29
  export var SYNC_TASK_STOP = 38;
46
30
  export var SETTINGS_SPLITS_FILTER = 39;
31
+ export var ENGINE_MATCHER_RESULT = 40;
47
32
  export var CLIENT_READY_FROM_CACHE = 100;
48
33
  export var CLIENT_READY = 101;
49
34
  export var IMPRESSION = 102;
@@ -6,26 +6,11 @@ export var codesDebug = codesInfo.concat([
6
6
  [c.ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Treatment found: %s'],
7
7
  [c.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT, c.LOG_PREFIX_ENGINE_COMBINER + 'All predicates evaluated, no treatment found.'],
8
8
  [c.ENGINE_BUCKET, c.LOG_PREFIX_ENGINE + ': using algo "murmur" bucket %s for key %s using seed %s - treatment %s'],
9
- [c.ENGINE_MATCHER_ALL, c.LOG_PREFIX_ENGINE_MATCHER + '[allMatcher] is always true'],
10
- [c.ENGINE_MATCHER_BETWEEN, c.LOG_PREFIX_ENGINE_MATCHER + '[betweenMatcher] is %s between %s and %s? %s'],
11
- [c.ENGINE_MATCHER_BOOLEAN, c.LOG_PREFIX_ENGINE_MATCHER + '[booleanMatcher] %s === %s'],
12
- [c.ENGINE_MATCHER_CONTAINS_ALL, c.LOG_PREFIX_ENGINE_MATCHER + '[containsAllMatcher] %s contains all elements of %s? %s'],
13
- [c.ENGINE_MATCHER_CONTAINS_ANY, c.LOG_PREFIX_ENGINE_MATCHER + '[containsAnyMatcher] %s contains at least an element of %s? %s'],
14
- [c.ENGINE_MATCHER_CONTAINS_STRING, c.LOG_PREFIX_ENGINE_MATCHER + '[containsStringMatcher] %s contains %s? %s'],
15
- [c.ENGINE_MATCHER_DEPENDENCY, c.LOG_PREFIX_ENGINE_MATCHER + '[dependencyMatcher] parent feature flag "%s" evaluated to "%s" with label "%s". %s evaluated treatment is part of [%s] ? %s.'],
16
- [c.ENGINE_MATCHER_DEPENDENCY_PRE, c.LOG_PREFIX_ENGINE_MATCHER + '[dependencyMatcher] will evaluate parent feature flag: "%s" with key: %s %s'],
17
- [c.ENGINE_MATCHER_EQUAL, c.LOG_PREFIX_ENGINE_MATCHER + '[equalToMatcher] is %s equal to %s? %s'],
18
- [c.ENGINE_MATCHER_EQUAL_TO_SET, c.LOG_PREFIX_ENGINE_MATCHER + '[equalToSetMatcher] is %s equal to set %s? %s'],
19
- [c.ENGINE_MATCHER_ENDS_WITH, c.LOG_PREFIX_ENGINE_MATCHER + '[endsWithMatcher] %s ends with %s? %s'],
20
- [c.ENGINE_MATCHER_GREATER, c.LOG_PREFIX_ENGINE_MATCHER + '[greaterThanEqualMatcher] is %s greater than %s? %s'],
21
- [c.ENGINE_MATCHER_LESS, c.LOG_PREFIX_ENGINE_MATCHER + '[lessThanEqualMatcher] is %s less than %s? %s'],
22
- [c.ENGINE_MATCHER_PART_OF, c.LOG_PREFIX_ENGINE_MATCHER + '[partOfMatcher] %s is part of %s? %s'],
23
- [c.ENGINE_MATCHER_SEGMENT, c.LOG_PREFIX_ENGINE_MATCHER + '[segmentMatcher] evaluated %s / %s => %s'],
24
- [c.ENGINE_MATCHER_STRING, c.LOG_PREFIX_ENGINE_MATCHER + '[stringMatcher] does %s matches with %s? %s'],
25
- [c.ENGINE_MATCHER_STARTS_WITH, c.LOG_PREFIX_ENGINE_MATCHER + '[startsWithMatcher] %s starts with %s? %s'],
26
- [c.ENGINE_MATCHER_WHITELIST, c.LOG_PREFIX_ENGINE_MATCHER + '[whitelistMatcher] evaluated %s in [%s] => %s'],
27
- [c.ENGINE_VALUE, c.LOG_PREFIX_ENGINE_VALUE + 'Extracted attribute [%s], [%s] will be used for matching.'],
28
- [c.ENGINE_SANITIZE, c.LOG_PREFIX_ENGINE + ':sanitize: Attempted to sanitize [%s] which should be of type [%s]. Sanitized and processed value => [%s]'],
9
+ [c.ENGINE_MATCHER_DEPENDENCY, c.LOG_PREFIX_ENGINE_MATCHER + '[IN_SPLIT_TREATMENT] parent feature flag "%s" evaluated to "%s" with label "%s". %s evaluated treatment is part of %s ? %s.'],
10
+ [c.ENGINE_MATCHER_DEPENDENCY_PRE, c.LOG_PREFIX_ENGINE_MATCHER + '[IN_SPLIT_TREATMENT] will evaluate parent feature flag: "%s" with key: %s %s'],
11
+ [c.ENGINE_VALUE, c.LOG_PREFIX_ENGINE_VALUE + 'Extracted attribute `%s`. %s will be used for matching.'],
12
+ [c.ENGINE_SANITIZE, c.LOG_PREFIX_ENGINE + ':sanitize: Attempted to sanitize %s which should be of type %s. Sanitized and processed value => %s'],
13
+ [c.ENGINE_MATCHER_RESULT, c.LOG_PREFIX_ENGINE_MATCHER + '[%s] Result: %s. Rule value: %s. Evaluation value: %s'],
29
14
  // SDK
30
15
  [c.CLEANUP_REGISTERING, c.LOG_PREFIX_CLEANUP + 'Registering cleanup handler %s'],
31
16
  [c.CLEANUP_DEREGISTERING, c.LOG_PREFIX_CLEANUP + 'Deregistering cleanup handler %s'],
@@ -3,7 +3,7 @@ import { codesError } from './error';
3
3
  export var codesWarn = codesError.concat([
4
4
  // evaluator
5
5
  [c.ENGINE_VALUE_INVALID, c.LOG_PREFIX_ENGINE_VALUE + 'Value %s doesn\'t match with expected type.'],
6
- [c.ENGINE_VALUE_NO_ATTRIBUTES, c.LOG_PREFIX_ENGINE_VALUE + 'Defined attribute [%s], no attributes received.'],
6
+ [c.ENGINE_VALUE_NO_ATTRIBUTES, c.LOG_PREFIX_ENGINE_VALUE + 'Defined attribute `%s`. No attributes received.'],
7
7
  // synchronizer
8
8
  [c.SYNC_MYSEGMENTS_FETCH_RETRY, c.LOG_PREFIX_SYNC_MYSEGMENTS + 'Retrying download of segments #%s. Reason: %s'],
9
9
  [c.SYNC_SPLITS_FETCH_FAILS, c.LOG_PREFIX_SYNC_SPLITS + 'Error while doing fetch of feature flags. %s'],
@@ -38,7 +38,7 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
38
38
  return splitHttpClient(url, undefined, telemetryTracker.trackHttp(TOKEN));
39
39
  },
40
40
  fetchSplitChanges: function (since, noCache, till) {
41
- var url = urls.sdk + "/splitChanges?s=" + FLAGS_SPEC + "&since=" + since + (till ? '&till=' + till : '') + (filterQueryString || '');
41
+ var url = urls.sdk + "/splitChanges?s=" + FLAGS_SPEC + "&since=" + since + (filterQueryString || '') + (till ? '&till=' + till : '');
42
42
  return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(SPLITS))
43
43
  .catch(function (err) {
44
44
  if (err.statusCode === 414)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.13.2-rc.8",
3
+ "version": "1.14.0",
4
4
  "description": "Split JavaScript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -1,10 +1,6 @@
1
- import { ENGINE_MATCHER_ALL } from '../../logger/constants';
2
- import { ILogger } from '../../logger/types';
1
+ export function allMatcherContext() {
3
2
 
4
- export function allMatcherContext(log: ILogger) {
5
3
  return function allMatcher(runtimeAttr: string): boolean {
6
- log.debug(ENGINE_MATCHER_ALL);
7
-
8
4
  return runtimeAttr != null;
9
5
  };
10
6
  }
@@ -1,13 +1,9 @@
1
1
  import { IBetweenMatcherData } from '../../dtos/types';
2
- import { ENGINE_MATCHER_BETWEEN } from '../../logger/constants';
3
- import { ILogger } from '../../logger/types';
4
2
 
5
- export function betweenMatcherContext(log: ILogger, ruleVO: IBetweenMatcherData) {
6
- return function betweenMatcher(runtimeAttr: number): boolean {
7
-
8
- let isBetween = runtimeAttr >= ruleVO.start && runtimeAttr <= ruleVO.end;
3
+ export function betweenMatcherContext(ruleVO: IBetweenMatcherData) {
9
4
 
10
- log.debug(ENGINE_MATCHER_BETWEEN, [runtimeAttr, ruleVO.start, ruleVO.end, isBetween]);
5
+ return function betweenMatcher(runtimeAttr: number): boolean {
6
+ const isBetween = runtimeAttr >= ruleVO.start && runtimeAttr <= ruleVO.end;
11
7
 
12
8
  return isBetween;
13
9
  };
@@ -1,11 +1,7 @@
1
- import { ENGINE_MATCHER_BOOLEAN } from '../../logger/constants';
2
- import { ILogger } from '../../logger/types';
1
+ export function booleanMatcherContext(ruleAttr: boolean) {
3
2
 
4
- export function booleanMatcherContext(log: ILogger, ruleAttr: boolean) {
5
3
  return function booleanMatcher(runtimeAttr: boolean): boolean {
6
- let booleanMatches = ruleAttr === runtimeAttr;
7
-
8
- log.debug(ENGINE_MATCHER_BOOLEAN, [ruleAttr, runtimeAttr]);
4
+ const booleanMatches = ruleAttr === runtimeAttr;
9
5
 
10
6
  return booleanMatches;
11
7
  };
@@ -1,8 +1,6 @@
1
- import { ENGINE_MATCHER_CONTAINS_ALL } from '../../logger/constants';
2
- import { ILogger } from '../../logger/types';
3
1
  import { findIndex } from '../../utils/lang';
4
2
 
5
- export function containsAllSetMatcherContext(log: ILogger, ruleAttr: string[]) {
3
+ export function containsAllSetMatcherContext(ruleAttr: string[]) {
6
4
  return function containsAllMatcher(runtimeAttr: string[]): boolean {
7
5
  let containsAll = true;
8
6
 
@@ -15,8 +13,6 @@ export function containsAllSetMatcherContext(log: ILogger, ruleAttr: string[]) {
15
13
  }
16
14
  }
17
15
 
18
- log.debug(ENGINE_MATCHER_CONTAINS_ALL, [runtimeAttr, ruleAttr, containsAll]);
19
-
20
16
  return containsAll;
21
17
  };
22
18
  }
@@ -1,8 +1,6 @@
1
- import { ENGINE_MATCHER_CONTAINS_ANY } from '../../logger/constants';
2
- import { ILogger } from '../../logger/types';
3
1
  import { findIndex } from '../../utils/lang';
4
2
 
5
- export function containsAnySetMatcherContext(log: ILogger, ruleAttr: string[]) {
3
+ export function containsAnySetMatcherContext(ruleAttr: string[]) {
6
4
  return function containsAnyMatcher(runtimeAttr: string[]): boolean {
7
5
  let containsAny = false;
8
6
 
@@ -10,8 +8,6 @@ export function containsAnySetMatcherContext(log: ILogger, ruleAttr: string[]) {
10
8
  if (findIndex(runtimeAttr, e => e === ruleAttr[i]) >= 0) containsAny = true;
11
9
  }
12
10
 
13
- log.debug(ENGINE_MATCHER_CONTAINS_ANY, [runtimeAttr, ruleAttr, containsAny]);
14
-
15
11
  return containsAny;
16
12
  };
17
13
  }
@@ -1,12 +1,8 @@
1
1
  import { isString } from '../../utils/lang';
2
- import { ILogger } from '../../logger/types';
3
- import { ENGINE_MATCHER_CONTAINS_STRING } from '../../logger/constants';
4
2
 
5
- export function containsStringMatcherContext(log: ILogger, ruleAttr: string[]) {
3
+ export function containsStringMatcherContext(ruleAttr: string[]) {
6
4
  return function containsStringMatcher(runtimeAttr: string): boolean {
7
- let contains = ruleAttr.some(e => isString(runtimeAttr) && runtimeAttr.indexOf(e) > -1);
8
-
9
- log.debug(ENGINE_MATCHER_CONTAINS_STRING, [runtimeAttr, ruleAttr, contains]);
5
+ const contains = ruleAttr.some(e => isString(runtimeAttr) && runtimeAttr.indexOf(e) > -1);
10
6
 
11
7
  return contains;
12
8
  };
@@ -5,7 +5,7 @@ import { thenable } from '../../utils/promise/thenable';
5
5
  import { IDependencyMatcherValue, IEvaluation, ISplitEvaluator } from '../types';
6
6
  import { ENGINE_MATCHER_DEPENDENCY, ENGINE_MATCHER_DEPENDENCY_PRE } from '../../logger/constants';
7
7
 
8
- export function dependencyMatcherContext(log: ILogger, { split, treatments }: IDependencyMatcherData, storage: IStorageSync | IStorageAsync) {
8
+ export function dependencyMatcherContext({ split, treatments }: IDependencyMatcherData, storage: IStorageSync | IStorageAsync, log: ILogger) {
9
9
 
10
10
  function checkTreatment(evaluation: IEvaluation, acceptableTreatments: string[], parentName: string) {
11
11
  let matches = false;
@@ -1,11 +1,7 @@
1
- import { ENGINE_MATCHER_EQUAL } from '../../logger/constants';
2
- import { ILogger } from '../../logger/types';
1
+ export function equalToMatcherContext(ruleAttr: number) {
3
2
 
4
- export function equalToMatcherContext(log: ILogger, ruleAttr: number) {
5
3
  return function equalToMatcher(runtimeAttr: number): boolean {
6
- let isEqual = runtimeAttr === ruleAttr;
7
-
8
- log.debug(ENGINE_MATCHER_EQUAL, [runtimeAttr, ruleAttr, isEqual]);
4
+ const isEqual = runtimeAttr === ruleAttr;
9
5
 
10
6
  return isEqual;
11
7
  };
@@ -1,8 +1,6 @@
1
- import { ENGINE_MATCHER_EQUAL_TO_SET } from '../../logger/constants';
2
- import { ILogger } from '../../logger/types';
3
1
  import { findIndex } from '../../utils/lang';
4
2
 
5
- export function equalToSetMatcherContext(log: ILogger, ruleAttr: string[]) {
3
+ export function equalToSetMatcherContext(ruleAttr: string[]) {
6
4
  return function equalToSetMatcher(runtimeAttr: string[]): boolean {
7
5
  // Length being the same is the first condition.
8
6
  let isEqual = runtimeAttr.length === ruleAttr.length;
@@ -12,8 +10,6 @@ export function equalToSetMatcherContext(log: ILogger, ruleAttr: string[]) {
12
10
  if (findIndex(ruleAttr, e => e === runtimeAttr[i]) < 0) isEqual = false;
13
11
  }
14
12
 
15
- log.debug(ENGINE_MATCHER_EQUAL_TO_SET, [runtimeAttr, ruleAttr, isEqual]);
16
-
17
13
  return isEqual;
18
14
  };
19
15
  }
@@ -1,12 +1,8 @@
1
- import { ENGINE_MATCHER_ENDS_WITH } from '../../logger/constants';
2
- import { ILogger } from '../../logger/types';
3
1
  import { endsWith } from '../../utils/lang';
4
2
 
5
- export function endsWithMatcherContext(log: ILogger, ruleAttr: string[]) {
3
+ export function endsWithMatcherContext(ruleAttr: string[]) {
6
4
  return function endsWithMatcher(runtimeAttr: string): boolean {
7
- let strEndsWith = ruleAttr.some(e => endsWith(runtimeAttr, e));
8
-
9
- log.debug(ENGINE_MATCHER_ENDS_WITH, [runtimeAttr, ruleAttr, strEndsWith]);
5
+ const strEndsWith = ruleAttr.some(e => endsWith(runtimeAttr, e));
10
6
 
11
7
  return strEndsWith;
12
8
  };
@@ -1,11 +1,7 @@
1
- import { ENGINE_MATCHER_GREATER } from '../../logger/constants';
2
- import { ILogger } from '../../logger/types';
1
+ export function greaterThanEqualMatcherContext(ruleAttr: number) {
3
2
 
4
- export function greaterThanEqualMatcherContext(log: ILogger, ruleAttr: number) {
5
3
  return function greaterThanEqualMatcher(runtimeAttr: number): boolean {
6
- let isGreaterThanEqual = runtimeAttr >= ruleAttr;
7
-
8
- log.debug(ENGINE_MATCHER_GREATER, [runtimeAttr, ruleAttr, isGreaterThanEqual]);
4
+ const isGreaterThanEqual = runtimeAttr >= ruleAttr;
9
5
 
10
6
  return isGreaterThanEqual;
11
7
  };
@@ -61,6 +61,6 @@ export function matcherFactory(log: ILogger, matcherDto: IMatcherDto, storage?:
61
61
 
62
62
  let matcherFn;
63
63
  // @ts-ignore
64
- if (matchers[type]) matcherFn = matchers[type](log, value, storage); // There is no index-out-of-bound exception in JavaScript
64
+ if (matchers[type]) matcherFn = matchers[type](value, storage, log); // There is no index-out-of-bound exception in JavaScript
65
65
  return matcherFn;
66
66
  }
@@ -1,11 +1,7 @@
1
- import { ENGINE_MATCHER_LESS } from '../../logger/constants';
2
- import { ILogger } from '../../logger/types';
1
+ export function lessThanEqualMatcherContext(ruleAttr: number) {
3
2
 
4
- export function lessThanEqualMatcherContext(log: ILogger, ruleAttr: number) {
5
3
  return function lessThanEqualMatcher(runtimeAttr: number): boolean {
6
- let isLessThanEqual = runtimeAttr <= ruleAttr;
7
-
8
- log.debug(ENGINE_MATCHER_LESS, [runtimeAttr, ruleAttr, isLessThanEqual]);
4
+ const isLessThanEqual = runtimeAttr <= ruleAttr;
9
5
 
10
6
  return isLessThanEqual;
11
7
  };
@@ -1,8 +1,6 @@
1
1
  import { findIndex } from '../../utils/lang';
2
- import { ILogger } from '../../logger/types';
3
- import { ENGINE_MATCHER_PART_OF } from '../../logger/constants';
4
2
 
5
- export function partOfSetMatcherContext(log: ILogger, ruleAttr: string[]) {
3
+ export function partOfSetMatcherContext(ruleAttr: string[]) {
6
4
  return function partOfMatcher(runtimeAttr: string[]): boolean {
7
5
  // To be part of the length should be minor or equal.
8
6
  let isPartOf = runtimeAttr.length <= ruleAttr.length;
@@ -12,8 +10,6 @@ export function partOfSetMatcherContext(log: ILogger, ruleAttr: string[]) {
12
10
  if (findIndex(ruleAttr, e => e === runtimeAttr[i]) < 0) isPartOf = false;
13
11
  }
14
12
 
15
- log.debug(ENGINE_MATCHER_PART_OF, [runtimeAttr, ruleAttr, isPartOf]);
16
-
17
13
  return isPartOf;
18
14
  };
19
15
  }
@@ -1,25 +1,18 @@
1
1
  import { MaybeThenable } from '../../dtos/types';
2
2
  import { ISegmentsCacheBase } from '../../storages/types';
3
- import { ILogger } from '../../logger/types';
4
3
  import { thenable } from '../../utils/promise/thenable';
5
- import { ENGINE_MATCHER_SEGMENT } from '../../logger/constants';
6
4
 
7
- export function segmentMatcherContext(log: ILogger, segmentName: string, storage: { segments: ISegmentsCacheBase }) {
5
+ export function segmentMatcherContext(segmentName: string, storage: { segments: ISegmentsCacheBase }) {
8
6
 
9
7
  return function segmentMatcher(key: string): MaybeThenable<boolean> {
10
8
  const isInSegment = storage.segments.isInSegment(segmentName, key);
11
9
 
12
10
  if (thenable(isInSegment)) {
13
11
  isInSegment.then(result => {
14
- log.debug(ENGINE_MATCHER_SEGMENT, [segmentName, key, isInSegment]);
15
-
16
12
  return result;
17
13
  });
18
- } else {
19
- log.debug(ENGINE_MATCHER_SEGMENT, [segmentName, key, isInSegment]);
20
14
  }
21
15
 
22
16
  return isInSegment;
23
17
  };
24
-
25
18
  }
@@ -1,8 +1,7 @@
1
1
  import { IBetweenStringMatcherData } from '../../dtos/types';
2
- import { ILogger } from '../../logger/types';
3
2
  import { Semver } from '../../utils/Semver';
4
3
 
5
- export function betweenSemverMatcherContext(log: ILogger, ruleAttr: IBetweenStringMatcherData) {
4
+ export function betweenSemverMatcherContext(ruleAttr: IBetweenStringMatcherData) {
6
5
  const startSemver = new Semver(ruleAttr.start);
7
6
  const endSemver = new Semver(ruleAttr.end);
8
7
 
@@ -1,7 +1,6 @@
1
- import { ILogger } from '../../logger/types';
2
1
  import { Semver } from '../../utils/Semver';
3
2
 
4
- export function equalToSemverMatcherContext(log: ILogger, ruleAttr: string) {
3
+ export function equalToSemverMatcherContext(ruleAttr: string) {
5
4
  const ruleSemver = new Semver(ruleAttr);
6
5
 
7
6
  return function equalToSemverMatcher(runtimeAttr: string): boolean {
@@ -1,7 +1,6 @@
1
- import { ILogger } from '../../logger/types';
2
1
  import { Semver } from '../../utils/Semver';
3
2
 
4
- export function greaterThanEqualToSemverMatcherContext(log: ILogger, ruleAttr: string) {
3
+ export function greaterThanEqualToSemverMatcherContext(ruleAttr: string) {
5
4
  const ruleSemver = new Semver(ruleAttr);
6
5
 
7
6
  return function greaterThanEqualToSemverMatcher(runtimeAttr: string): boolean {
@@ -1,8 +1,7 @@
1
1
  import { _Set } from '../../utils/lang/sets';
2
- import { ILogger } from '../../logger/types';
3
2
  import { Semver } from '../../utils/Semver';
4
3
 
5
- export function inListSemverMatcherContext(log: ILogger, ruleAttr: string[]) {
4
+ export function inListSemverMatcherContext(ruleAttr: string[]) {
6
5
  // @TODO ruleAttr validation should be done at the `parser` or `matchersTransform` level to reuse for all matchers
7
6
  if (!ruleAttr || ruleAttr.length === 0) throw new Error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type');
8
7
 
@@ -10,6 +9,7 @@ export function inListSemverMatcherContext(log: ILogger, ruleAttr: string[]) {
10
9
 
11
10
  return function inListSemverMatcher(runtimeAttr: string): boolean {
12
11
  const runtimeSemver = new Semver(runtimeAttr).version;
12
+
13
13
  const isInList = listOfSemvers.has(runtimeSemver);
14
14
 
15
15
  return isInList;
@@ -1,7 +1,6 @@
1
- import { ILogger } from '../../logger/types';
2
1
  import { Semver } from '../../utils/Semver';
3
2
 
4
- export function lessThanEqualToSemverMatcherContext(log: ILogger, ruleAttr: string) {
3
+ export function lessThanEqualToSemverMatcherContext(ruleAttr: string) {
5
4
  const ruleSemver = new Semver(ruleAttr);
6
5
 
7
6
  return function lessThanEqualToSemverMatcher(runtimeAttr: string): boolean {
@@ -1,14 +1,9 @@
1
- import { ENGINE_MATCHER_STRING } from '../../logger/constants';
2
- import { ILogger } from '../../logger/types';
3
-
4
- export function stringMatcherContext(log: ILogger, ruleAttr: string) {
1
+ export function stringMatcherContext(ruleAttr: string) {
5
2
  const regex = new RegExp(ruleAttr);
6
3
 
7
4
  return function stringMatcher(runtimeAttr: string): boolean {
8
5
  const regexMatches = regex.test(runtimeAttr);
9
6
 
10
- log.debug(ENGINE_MATCHER_STRING, [runtimeAttr, ruleAttr, regexMatches ? 'yes' : 'no']);
11
-
12
7
  return regexMatches;
13
8
  };
14
9
  }
@@ -1,12 +1,8 @@
1
- import { ENGINE_MATCHER_STARTS_WITH } from '../../logger/constants';
2
- import { ILogger } from '../../logger/types';
3
1
  import { startsWith } from '../../utils/lang';
4
2
 
5
- export function startsWithMatcherContext(log: ILogger, ruleAttr: string[]) {
3
+ export function startsWithMatcherContext(ruleAttr: string[]) {
6
4
  return function startsWithMatcher(runtimeAttr: string): boolean {
7
- let matches = ruleAttr.some(e => startsWith(runtimeAttr, e));
8
-
9
- log.debug(ENGINE_MATCHER_STARTS_WITH, [runtimeAttr, ruleAttr, matches]);
5
+ const matches = ruleAttr.some(e => startsWith(runtimeAttr, e));
10
6
 
11
7
  return matches;
12
8
  };
@@ -1,15 +1,11 @@
1
1
  import { _Set } from '../../utils/lang/sets';
2
- import { ILogger } from '../../logger/types';
3
- import { ENGINE_MATCHER_WHITELIST } from '../../logger/constants';
4
2
 
5
- export function whitelistMatcherContext(log: ILogger, ruleAttr: string[]) {
3
+ export function whitelistMatcherContext(ruleAttr: string[]) {
6
4
  const whitelistSet = new _Set(ruleAttr);
7
5
 
8
6
  return function whitelistMatcher(runtimeAttr: string): boolean {
9
7
  const isInWhitelist = whitelistSet.has(runtimeAttr);
10
8
 
11
- log.debug(ENGINE_MATCHER_WHITELIST, [runtimeAttr, ruleAttr.join(','), isInWhitelist]);
12
-
13
9
  return isInWhitelist;
14
10
  };
15
11
  }