@splitsoftware/splitio 10.15.10-rc.2 → 10.16.1-rc.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.
- package/CHANGES.txt +12 -3
- package/README.md +2 -1
- package/es/engine/engine/murmur3/murmur3_128.js +1 -1
- package/es/engine/engine/murmur3/murmur3_128_x86.js +2 -3
- package/es/engine/matchers/index.js +20 -37
- package/es/engine/matchers/types.js +19 -72
- package/es/engine/transforms/matcherGroup.js +2 -2
- package/es/engine/transforms/matchers.js +2 -2
- package/es/engine/value/sanitize.js +12 -14
- package/es/impressions/hasher/hashImpression128.js +1 -1
- package/es/impressions/observer/observer.js +0 -1
- package/es/listeners/browser.js +2 -12
- package/es/producer/updater/SplitChangesFromObject.js +3 -2
- package/es/storage/SplitCache/InLocalStorage.js +11 -0
- package/es/sync/PushManager/index.js +5 -13
- package/es/utils/inputValidation/splitFilters.js +4 -5
- package/es/utils/logger/LoggerFactory.js +23 -16
- package/es/utils/settings/index.js +1 -1
- package/es/utils/settings/storage/browser.js +19 -4
- package/lib/engine/engine/murmur3/murmur3_128.js +1 -1
- package/lib/engine/engine/murmur3/murmur3_128_x86.js +2 -3
- package/lib/engine/matchers/index.js +21 -39
- package/lib/engine/matchers/types.js +23 -77
- package/lib/engine/transforms/matcherGroup.js +3 -3
- package/lib/engine/transforms/matchers.js +22 -22
- package/lib/engine/value/sanitize.js +11 -13
- package/lib/impressions/hasher/hashImpression128.js +2 -2
- package/lib/impressions/observer/observer.js +0 -1
- package/lib/listeners/browser.js +2 -12
- package/lib/producer/updater/SplitChangesFromObject.js +4 -2
- package/lib/storage/SplitCache/InLocalStorage.js +11 -0
- package/lib/sync/PushManager/index.js +5 -13
- package/lib/utils/inputValidation/splitFilters.js +4 -6
- package/lib/utils/logger/LoggerFactory.js +23 -17
- package/lib/utils/settings/index.js +1 -1
- package/lib/utils/settings/storage/browser.js +18 -3
- package/package.json +18 -15
- package/src/engine/engine/murmur3/murmur3_128.js +1 -1
- package/src/engine/engine/murmur3/murmur3_128_x86.js +2 -3
- package/src/engine/matchers/index.js +22 -36
- package/src/engine/matchers/types.js +20 -55
- package/src/engine/transforms/matcherGroup.js +2 -5
- package/src/engine/transforms/matchers.js +2 -6
- package/src/engine/value/sanitize.js +12 -17
- package/src/impressions/hasher/hashImpression128.js +1 -1
- package/src/impressions/observer/observer.js +0 -2
- package/src/listeners/browser.js +2 -10
- package/src/producer/updater/SplitChangesFromObject.js +2 -2
- package/src/storage/SplitCache/InLocalStorage.js +3 -3
- package/src/sync/PushManager/index.js +5 -12
- package/src/sync/constants.js +1 -1
- package/src/utils/inputValidation/splitFilters.js +1 -5
- package/src/utils/logger/LoggerFactory.js +25 -16
- package/src/utils/settings/index.js +1 -1
- package/src/utils/settings/storage/browser.js +18 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splitsoftware/splitio",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.16.1-rc.0",
|
|
4
4
|
"description": "Split SDK",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@babel/runtime": "^7.13.10",
|
|
36
36
|
"@types/google.analytics": "0.0.40",
|
|
37
37
|
"events": "3.1.0",
|
|
38
|
-
"ioredis": "^4.
|
|
38
|
+
"ioredis": "^4.28.0",
|
|
39
39
|
"ip": "1.1.5",
|
|
40
40
|
"js-yaml": "3.13.1",
|
|
41
41
|
"node-fetch": "^2.6.1",
|
|
@@ -61,8 +61,9 @@
|
|
|
61
61
|
"karma": "^6.3.2",
|
|
62
62
|
"karma-chrome-launcher": "^3.1.0",
|
|
63
63
|
"karma-tap": "4.1.4",
|
|
64
|
-
"karma-webpack": "^
|
|
64
|
+
"karma-webpack": "^5.0.0",
|
|
65
65
|
"lodash": "^4.17.21",
|
|
66
|
+
"node-polyfill-webpack-plugin": "^1.1.4",
|
|
66
67
|
"proxyquire": "^2.1.3",
|
|
67
68
|
"puppeteer": "^3.3.0",
|
|
68
69
|
"redis-dumpz": "0.1.11",
|
|
@@ -73,9 +74,9 @@
|
|
|
73
74
|
"tap-min": "^2.0.0",
|
|
74
75
|
"tape": "4.13.2",
|
|
75
76
|
"tape-catch": "1.0.6",
|
|
76
|
-
"webpack": "^
|
|
77
|
-
"webpack-cli": "^
|
|
78
|
-
"webpack-merge": "^
|
|
77
|
+
"webpack": "^5.53.0",
|
|
78
|
+
"webpack-cli": "^4.8.0",
|
|
79
|
+
"webpack-merge": "^5.8.0"
|
|
79
80
|
},
|
|
80
81
|
"scripts": {
|
|
81
82
|
"build-es": "rimraf es && cross-env NODE_ENV=es babel ./src -d es --ignore 'src/**/__tests__/*'",
|
|
@@ -83,25 +84,27 @@
|
|
|
83
84
|
"build-umd:stats": "webpack --progress --env production --json > ./stats/stat_results.json",
|
|
84
85
|
"build-cjs": "rimraf lib && cross-env NODE_ENV=cjs babel ./src -d lib --ignore 'src/**/__tests__/*'",
|
|
85
86
|
"postbuild-cjs": "cross-env NODE_ENV=cjs node scripts/copy.packages.json.js",
|
|
86
|
-
"build-umd
|
|
87
|
-
"build-umd": "webpack --config webpack.dev.js && webpack --config webpack.prod.js && ./scripts/clean_umd_build.sh",
|
|
88
|
-
"build": "rimraf lib umd es && npm run build-cjs && npm run build-es && npm run build-umd",
|
|
87
|
+
"build-umd": "webpack --config webpack.ci.dev.js --env branch=$BUILD_BRANCH --env commit_hash=$BUILD_COMMIT && webpack --config webpack.ci.prod.js --env branch=$BUILD_BRANCH --env commit_hash=$BUILD_COMMIT && ./scripts/clean_umd_build.sh",
|
|
88
|
+
"build-umd:local": "webpack --config webpack.dev.js && webpack --config webpack.prod.js && ./scripts/clean_umd_build.sh",
|
|
89
|
+
"build:local": "rimraf lib umd es && npm run build-cjs && npm run build-es && npm run build-umd:local",
|
|
89
90
|
"build:npm": "rimraf lib es && npm run build-cjs && npm run build-es",
|
|
90
|
-
"build
|
|
91
|
-
"check": "npm run check:lint && npm run check:version
|
|
91
|
+
"build": "rimraf lib umd es && npm run build-cjs && npm run build-es && npm run build-umd",
|
|
92
|
+
"check": "npm run check:lint && npm run check:version",
|
|
92
93
|
"check:lint": "eslint src",
|
|
93
94
|
"check:version": "cross-env NODE_ENV=test tape -r @babel/register src/utils/__tests__/settings/index.spec.js",
|
|
94
95
|
"test-browser-local": "cross-env NODE_ENV=test karma start karma/local.karma.conf.js",
|
|
95
96
|
"test-browser-e2e-local": "cross-env NODE_ENV=test karma start karma/e2e.local.karma.conf.js",
|
|
96
|
-
"test-browser
|
|
97
|
-
"test-browser-
|
|
97
|
+
"test-browser": "npm run test-browser-unit && npm run test-browser-online && npm run test-browser-offline && npm run test-browser-destroy && npm run test-browser-errors && npm run test-browser-push",
|
|
98
|
+
"test-browser-unit": "cross-env NODE_ENV=test karma start karma/ci.karma.conf.js",
|
|
99
|
+
"test-browser-online": "cross-env NODE_ENV=test karma start karma/e2e.ci.karma.conf.js",
|
|
98
100
|
"test-browser-offline": "cross-env NODE_ENV=test karma start karma/offline.karma.conf.js",
|
|
99
101
|
"test-browser-destroy": "cross-env NODE_ENV=test karma start karma/destroy.ci.karma.conf.js",
|
|
100
102
|
"test-browser-errors": "cross-env NODE_ENV=test karma start karma/errors.ci.karma.conf.js",
|
|
101
103
|
"test-browser-gaintegration": "cross-env NODE_ENV=test karma start karma/gaintegration.ci.karma.conf.js",
|
|
102
104
|
"test-browser-push": "cross-env NODE_ENV=test karma start karma/push.ci.karma.conf.js",
|
|
103
|
-
"test-node": "
|
|
104
|
-
"test-node-
|
|
105
|
+
"test-node": "npm run test-node-unit && npm run test-node-online && npm run test-node-redis && npm run test-node-offline && npm run test-node-destroy && npm run test-node-errors && npm run test-node-push",
|
|
106
|
+
"test-node-unit": "cross-env NODE_ENV=test tape -r @babel/register \"src/*/**/__tests__/**/!(browser).spec.js\" | tap-min",
|
|
107
|
+
"test-node-online": "cross-env NODE_ENV=test tape -r @babel/register src/__tests__/node.spec.js | tap-min",
|
|
105
108
|
"test-node-destroy": "cross-env NODE_ENV=test tape -r @babel/register src/__tests__/destroy/node.spec.js | tap-min",
|
|
106
109
|
"test-node-errors": "cross-env NODE_ENV=test tape -r @babel/register src/__tests__/errorCatching/node.spec.js | tap-min",
|
|
107
110
|
"test-node-offline": "cross-env NODE_ENV=test tape -r @babel/register src/__tests__/offline/node.spec.js | tap-min",
|
|
@@ -265,7 +265,7 @@ function hash128x64(key /*: string */, seed /*: number */) /*: string */ {
|
|
|
265
265
|
|
|
266
266
|
/**
|
|
267
267
|
* x64 version of Murmur3 for 128bits.
|
|
268
|
-
*
|
|
268
|
+
*
|
|
269
269
|
* @param {string} str
|
|
270
270
|
*/
|
|
271
271
|
export function hash128(str /*: string */, seed /*: number */) /*: string */ {
|
|
@@ -179,10 +179,9 @@ function hash128x86(key /*: string */, seed /*: number */) /*: string */ {
|
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
181
|
* x86 version of Murmur3 for 128bits.
|
|
182
|
-
*
|
|
182
|
+
* Used by hashImpression128 because in JS it is more efficient than the x64 version, no matter the underlying OS/CPU arch.
|
|
183
183
|
*
|
|
184
|
-
* @
|
|
185
|
-
* because it is more time efficient in JS, no matter the underlying CPU arch.
|
|
184
|
+
* @param {string} str
|
|
186
185
|
*/
|
|
187
186
|
export function hash128(str /*: string */, seed /*: number */) /*: string */ {
|
|
188
187
|
return hash128x86(UTF16ToUTF8(str), seed >>> 0);
|
|
@@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
**/
|
|
16
|
-
import { types } from './types';
|
|
17
16
|
import allMatcher from './all';
|
|
18
17
|
import segmentMatcher from './segment';
|
|
19
18
|
import whitelistMatcher from './whitelist';
|
|
@@ -32,6 +31,27 @@ import dependencyMatcher from './dependency';
|
|
|
32
31
|
import booleanMatcher from './boolean';
|
|
33
32
|
import stringMatcher from './string';
|
|
34
33
|
|
|
34
|
+
const matchers = [
|
|
35
|
+
undefined, // UNDEFINED: 0,
|
|
36
|
+
allMatcher, // ALL_KEYS: 1,
|
|
37
|
+
segmentMatcher, // IN_SEGMENT: 2,
|
|
38
|
+
whitelistMatcher, // WHITELIST: 3,
|
|
39
|
+
eqMatcher, // EQUAL_TO: 4,
|
|
40
|
+
gteMatcher, // GREATER_THAN_OR_EQUAL_TO: 5,
|
|
41
|
+
lteMatcher, // LESS_THAN_OR_EQUAL_TO: 6,
|
|
42
|
+
betweenMatcher, // BETWEEN: 7,
|
|
43
|
+
equalToSetMatcher, // EQUAL_TO_SET: 8,
|
|
44
|
+
containsAnySetMatcher, // CONTAINS_ANY_OF_SET: 9,
|
|
45
|
+
containsAllSetMatcher, // CONTAINS_ALL_OF_SET: 10,
|
|
46
|
+
partOfSetMatcher, // PART_OF_SET: 11,
|
|
47
|
+
ewMatcher, // ENDS_WITH: 12,
|
|
48
|
+
swMatcher, // STARTS_WITH: 13,
|
|
49
|
+
containsStrMatcher, // CONTAINS_STRING: 14,
|
|
50
|
+
dependencyMatcher, // IN_SPLIT_TREATMENT: 15,
|
|
51
|
+
booleanMatcher, // EQUAL_TO_BOOLEAN: 16,
|
|
52
|
+
stringMatcher // MATCHES_STRING: 17
|
|
53
|
+
];
|
|
54
|
+
|
|
35
55
|
/**
|
|
36
56
|
* Matcher factory.
|
|
37
57
|
*/
|
|
@@ -43,41 +63,7 @@ function MatcherFactory(matcherDto, storage) {
|
|
|
43
63
|
|
|
44
64
|
let matcherFn;
|
|
45
65
|
|
|
46
|
-
if (type
|
|
47
|
-
matcherFn = allMatcher(value);
|
|
48
|
-
} else if (type === types.SEGMENT) {
|
|
49
|
-
matcherFn = segmentMatcher(value, storage);
|
|
50
|
-
} else if (type === types.WHITELIST) {
|
|
51
|
-
matcherFn = whitelistMatcher(value);
|
|
52
|
-
} else if (type === types.EQUAL_TO) {
|
|
53
|
-
matcherFn = eqMatcher(value);
|
|
54
|
-
} else if (type === types.GREATER_THAN_OR_EQUAL_TO) {
|
|
55
|
-
matcherFn = gteMatcher(value);
|
|
56
|
-
} else if (type === types.LESS_THAN_OR_EQUAL_TO) {
|
|
57
|
-
matcherFn = lteMatcher(value);
|
|
58
|
-
} else if (type === types.BETWEEN) {
|
|
59
|
-
matcherFn = betweenMatcher(value);
|
|
60
|
-
} else if (type === types.EQUAL_TO_SET) {
|
|
61
|
-
matcherFn = equalToSetMatcher(value);
|
|
62
|
-
} else if (type === types.CONTAINS_ANY_OF_SET) {
|
|
63
|
-
matcherFn = containsAnySetMatcher(value);
|
|
64
|
-
} else if (type === types.CONTAINS_ALL_OF_SET) {
|
|
65
|
-
matcherFn = containsAllSetMatcher(value);
|
|
66
|
-
} else if (type === types.PART_OF_SET) {
|
|
67
|
-
matcherFn = partOfSetMatcher(value);
|
|
68
|
-
} else if (type === types.STARTS_WITH) {
|
|
69
|
-
matcherFn = swMatcher(value);
|
|
70
|
-
} else if (type === types.ENDS_WITH) {
|
|
71
|
-
matcherFn = ewMatcher(value);
|
|
72
|
-
} else if (type === types.CONTAINS_STRING) {
|
|
73
|
-
matcherFn = containsStrMatcher(value);
|
|
74
|
-
} else if (type === types.IN_SPLIT_TREATMENT) {
|
|
75
|
-
matcherFn = dependencyMatcher(value, storage);
|
|
76
|
-
} else if (type === types.EQUAL_TO_BOOLEAN) {
|
|
77
|
-
matcherFn = booleanMatcher(value);
|
|
78
|
-
} else if (type === types.MATCHES_STRING) {
|
|
79
|
-
matcherFn = stringMatcher(value);
|
|
80
|
-
}
|
|
66
|
+
if (matchers[type]) matcherFn = matchers[type](value, storage); // There is no index-out-of-bound exception in JavaScript
|
|
81
67
|
|
|
82
68
|
return matcherFn;
|
|
83
69
|
}
|
|
@@ -15,28 +15,28 @@ limitations under the License.
|
|
|
15
15
|
**/
|
|
16
16
|
|
|
17
17
|
// @WARNING Symbol is not correctly working in PhantomJS
|
|
18
|
-
export const
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export const matcherTypes = {
|
|
19
|
+
UNDEFINED: 0,
|
|
20
|
+
ALL_KEYS: 1,
|
|
21
|
+
IN_SEGMENT: 2,
|
|
21
22
|
WHITELIST: 3,
|
|
22
23
|
EQUAL_TO: 4,
|
|
23
24
|
GREATER_THAN_OR_EQUAL_TO: 5,
|
|
24
25
|
LESS_THAN_OR_EQUAL_TO: 6,
|
|
25
26
|
BETWEEN: 7,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
MATCHES_STRING: 18
|
|
27
|
+
EQUAL_TO_SET: 8,
|
|
28
|
+
CONTAINS_ANY_OF_SET: 9,
|
|
29
|
+
CONTAINS_ALL_OF_SET: 10,
|
|
30
|
+
PART_OF_SET: 11,
|
|
31
|
+
ENDS_WITH: 12,
|
|
32
|
+
STARTS_WITH: 13,
|
|
33
|
+
CONTAINS_STRING: 14,
|
|
34
|
+
IN_SPLIT_TREATMENT: 15,
|
|
35
|
+
EQUAL_TO_BOOLEAN: 16,
|
|
36
|
+
MATCHES_STRING: 17
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
export const
|
|
39
|
+
export const matcherDataTypes = {
|
|
40
40
|
BOOLEAN: 'BOOLEAN',
|
|
41
41
|
STRING: 'STRING',
|
|
42
42
|
NUMBER: 'NUMBER',
|
|
@@ -45,43 +45,8 @@ export const dataTypes = {
|
|
|
45
45
|
NOT_SPECIFIED: 'NOT_SPECIFIED'
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return types.SEGMENT;
|
|
54
|
-
case 'WHITELIST':
|
|
55
|
-
return types.WHITELIST;
|
|
56
|
-
case 'EQUAL_TO':
|
|
57
|
-
return types.EQUAL_TO;
|
|
58
|
-
case 'GREATER_THAN_OR_EQUAL_TO':
|
|
59
|
-
return types.GREATER_THAN_OR_EQUAL_TO;
|
|
60
|
-
case 'LESS_THAN_OR_EQUAL_TO':
|
|
61
|
-
return types.LESS_THAN_OR_EQUAL_TO;
|
|
62
|
-
case 'BETWEEN':
|
|
63
|
-
return types.BETWEEN;
|
|
64
|
-
case 'EQUAL_TO_SET':
|
|
65
|
-
return types.EQUAL_TO_SET;
|
|
66
|
-
case 'CONTAINS_ANY_OF_SET':
|
|
67
|
-
return types.CONTAINS_ANY_OF_SET;
|
|
68
|
-
case 'CONTAINS_ALL_OF_SET':
|
|
69
|
-
return types.CONTAINS_ALL_OF_SET;
|
|
70
|
-
case 'PART_OF_SET':
|
|
71
|
-
return types.PART_OF_SET;
|
|
72
|
-
case 'ENDS_WITH':
|
|
73
|
-
return types.ENDS_WITH;
|
|
74
|
-
case 'STARTS_WITH':
|
|
75
|
-
return types.STARTS_WITH;
|
|
76
|
-
case 'CONTAINS_STRING':
|
|
77
|
-
return types.CONTAINS_STRING;
|
|
78
|
-
case 'IN_SPLIT_TREATMENT':
|
|
79
|
-
return types.IN_SPLIT_TREATMENT;
|
|
80
|
-
case 'EQUAL_TO_BOOLEAN':
|
|
81
|
-
return types.EQUAL_TO_BOOLEAN;
|
|
82
|
-
case 'MATCHES_STRING':
|
|
83
|
-
return types.MATCHES_STRING;
|
|
84
|
-
default:
|
|
85
|
-
return types.UNDEFINED;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
48
|
+
export function matcherTypesMapper(matcherType) {
|
|
49
|
+
const type = matcherTypes[matcherType];
|
|
50
|
+
if (type) return type;
|
|
51
|
+
else return matcherTypes.UNDEFINED;
|
|
52
|
+
}
|
|
@@ -13,10 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
**/
|
|
16
|
-
import {
|
|
17
|
-
types as matcherTypes,
|
|
18
|
-
mapper as matcherTypesMapper
|
|
19
|
-
} from '../matchers/types';
|
|
16
|
+
import { matcherTypes, matcherTypesMapper } from '../matchers/types';
|
|
20
17
|
import segmentTransform from './segment';
|
|
21
18
|
import whitelistTransform from './whitelist';
|
|
22
19
|
|
|
@@ -33,7 +30,7 @@ function transform(matcherGroup) {
|
|
|
33
30
|
let type = matcherTypesMapper(matcherType);
|
|
34
31
|
let value = undefined;
|
|
35
32
|
|
|
36
|
-
if (type === matcherTypes.
|
|
33
|
+
if (type === matcherTypes.IN_SEGMENT) {
|
|
37
34
|
value = segmentTransform(segmentObject);
|
|
38
35
|
} else if (type === matcherTypes.WHITELIST) {
|
|
39
36
|
value = whitelistTransform(whitelistObject);
|
|
@@ -15,11 +15,7 @@ limitations under the License.
|
|
|
15
15
|
**/
|
|
16
16
|
|
|
17
17
|
import { findIndex } from '../../utils/lang';
|
|
18
|
-
import {
|
|
19
|
-
types as matcherTypes,
|
|
20
|
-
mapper as matcherTypesMapper,
|
|
21
|
-
dataTypes as matcherDataTypes
|
|
22
|
-
} from '../matchers/types';
|
|
18
|
+
import { matcherTypes, matcherTypesMapper, matcherDataTypes } from '../matchers/types';
|
|
23
19
|
import segmentTransform from './segment';
|
|
24
20
|
import whitelistTransform from './whitelist';
|
|
25
21
|
import setTransform from './set';
|
|
@@ -49,7 +45,7 @@ function transform(matchers) {
|
|
|
49
45
|
let dataType = matcherDataTypes.STRING;
|
|
50
46
|
let value = undefined;
|
|
51
47
|
|
|
52
|
-
if (type === matcherTypes.
|
|
48
|
+
if (type === matcherTypes.IN_SEGMENT) {
|
|
53
49
|
value = segmentTransform(segmentObject);
|
|
54
50
|
} else if (type === matcherTypes.WHITELIST) {
|
|
55
51
|
value = whitelistTransform(whitelistObject);
|
|
@@ -18,12 +18,7 @@ import logFactory from '../../utils/logger';
|
|
|
18
18
|
const log = logFactory('splitio-engine:sanitize');
|
|
19
19
|
import { isObject, uniq, toString, toNumber } from '../../utils/lang';
|
|
20
20
|
import { zeroSinceHH, zeroSinceSS } from '../convertions';
|
|
21
|
-
import {
|
|
22
|
-
types as matcherTypes,
|
|
23
|
-
dataTypes as matcherDataTypes
|
|
24
|
-
} from '../matchers/types';
|
|
25
|
-
const MATCHERS = matcherTypes;
|
|
26
|
-
const DATA_TYPES = matcherDataTypes;
|
|
21
|
+
import { matcherTypes, matcherDataTypes } from '../matchers/types';
|
|
27
22
|
|
|
28
23
|
function sanitizeNumber(val) {
|
|
29
24
|
const num = toNumber(val);
|
|
@@ -72,13 +67,13 @@ function dependencyProcessor(sanitizedValue, attributes) {
|
|
|
72
67
|
*/
|
|
73
68
|
function getProcessingFunction(matcherTypeID, dataType) {
|
|
74
69
|
switch (matcherTypeID) {
|
|
75
|
-
case
|
|
70
|
+
case matcherTypes.EQUAL_TO:
|
|
76
71
|
return dataType === 'DATETIME' ? zeroSinceHH : undefined;
|
|
77
|
-
case
|
|
78
|
-
case
|
|
79
|
-
case
|
|
72
|
+
case matcherTypes.GREATER_THAN_OR_EQUAL_TO:
|
|
73
|
+
case matcherTypes.LESS_THAN_OR_EQUAL_TO:
|
|
74
|
+
case matcherTypes.BETWEEN:
|
|
80
75
|
return dataType === 'DATETIME' ? zeroSinceSS : undefined;
|
|
81
|
-
case
|
|
76
|
+
case matcherTypes.IN_SPLIT_TREATMENT:
|
|
82
77
|
return dependencyProcessor;
|
|
83
78
|
default:
|
|
84
79
|
return undefined;
|
|
@@ -90,20 +85,20 @@ function sanitizeValue(matcherTypeID, value, dataType, attributes) {
|
|
|
90
85
|
let sanitizedValue;
|
|
91
86
|
|
|
92
87
|
switch (dataType) {
|
|
93
|
-
case
|
|
94
|
-
case
|
|
88
|
+
case matcherDataTypes.NUMBER:
|
|
89
|
+
case matcherDataTypes.DATETIME:
|
|
95
90
|
sanitizedValue = sanitizeNumber(value);
|
|
96
91
|
break;
|
|
97
|
-
case
|
|
92
|
+
case matcherDataTypes.STRING:
|
|
98
93
|
sanitizedValue = sanitizeString(value);
|
|
99
94
|
break;
|
|
100
|
-
case
|
|
95
|
+
case matcherDataTypes.SET:
|
|
101
96
|
sanitizedValue = sanitizeArray(value);
|
|
102
97
|
break;
|
|
103
|
-
case
|
|
98
|
+
case matcherDataTypes.BOOLEAN:
|
|
104
99
|
sanitizedValue = sanitizeBoolean(value);
|
|
105
100
|
break;
|
|
106
|
-
case
|
|
101
|
+
case matcherDataTypes.NOT_SPECIFIED:
|
|
107
102
|
sanitizedValue = value;
|
|
108
103
|
break;
|
|
109
104
|
default:
|
package/src/listeners/browser.js
CHANGED
|
@@ -10,16 +10,8 @@ import objectAssign from 'object-assign';
|
|
|
10
10
|
|
|
11
11
|
const log = logFactory('splitio-client:cleanup');
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// since it is not a cancelable event and no other listeners can stop the event from occurring.
|
|
16
|
-
if (typeof navigator == 'object' && navigator.userAgent && navigator.userAgent.indexOf('Firefox') !== -1) {
|
|
17
|
-
return 'beforeunload';
|
|
18
|
-
}
|
|
19
|
-
return 'unload';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const UNLOAD_DOM_EVENT = getUnloadDomEvent();
|
|
13
|
+
// 'unload' event is used instead of 'beforeunload', since 'unload' is not a cancelable event, so no other listeners can stop the event from occurring.
|
|
14
|
+
const UNLOAD_DOM_EVENT = 'unload';
|
|
23
15
|
|
|
24
16
|
/**
|
|
25
17
|
* We'll listen for 'unload' event over the window object, since it's the standard way to listen page reload and close.
|
|
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
**/
|
|
16
|
+
import { STORAGE_LOCALSTORAGE } from '../../utils/constants';
|
|
16
17
|
import { forOwn } from '../../utils/lang';
|
|
17
18
|
import logFactory from '../../utils/logger';
|
|
18
19
|
const log = logFactory('splitio-producer:offline');
|
|
@@ -59,7 +60,6 @@ function FromObjectUpdaterFactory(Fetcher, context) {
|
|
|
59
60
|
|
|
60
61
|
return Promise.all([
|
|
61
62
|
storage.splits.flush(), // required to sync removed splits from mock
|
|
62
|
-
storage.splits.setChangeNumber(Date.now()),
|
|
63
63
|
storage.splits.addSplits(splits)
|
|
64
64
|
]).then(() => {
|
|
65
65
|
readiness.splits.emit(readiness.splits.SDK_SPLITS_ARRIVED);
|
|
@@ -67,7 +67,7 @@ function FromObjectUpdaterFactory(Fetcher, context) {
|
|
|
67
67
|
if (startingUp) {
|
|
68
68
|
startingUp = false;
|
|
69
69
|
// Emits SDK_READY_FROM_CACHE
|
|
70
|
-
if (storage.
|
|
70
|
+
if (settings.storage.__originalType === STORAGE_LOCALSTORAGE) readiness.splits.emit(readiness.splits.SDK_SPLITS_CACHE_LOADED);
|
|
71
71
|
// Only emits SDK_SEGMENTS_ARRIVED the first time for SDK_READY
|
|
72
72
|
readiness.segments.emit(readiness.segments.SDK_SEGMENTS_ARRIVED);
|
|
73
73
|
}
|
|
@@ -11,7 +11,7 @@ class SplitCacheLocalStorage {
|
|
|
11
11
|
* @param {number} expirationTimestamp
|
|
12
12
|
* @param {Object} splitFiltersValidation
|
|
13
13
|
*/
|
|
14
|
-
constructor(keys, expirationTimestamp, splitFiltersValidation) {
|
|
14
|
+
constructor(keys, expirationTimestamp, splitFiltersValidation = { validFilters: [], queryString: null, groupedFilters: { byName: [], byPrefix: [] } }) {
|
|
15
15
|
this.keys = keys;
|
|
16
16
|
this.splitFiltersValidation = splitFiltersValidation;
|
|
17
17
|
|
|
@@ -129,13 +129,13 @@ class SplitCacheLocalStorage {
|
|
|
129
129
|
|
|
130
130
|
setChangeNumber(changeNumber) {
|
|
131
131
|
// when cache is ready but using a new split query, we must flush all split data
|
|
132
|
-
if(this.cacheReadyButNeedsToFlush) {
|
|
132
|
+
if (this.cacheReadyButNeedsToFlush) {
|
|
133
133
|
this.flush();
|
|
134
134
|
this.cacheReadyButNeedsToFlush = false;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
// when using a new split query, we must update it at the store
|
|
138
|
-
if(this.updateNewFilter) {
|
|
138
|
+
if (this.updateNewFilter) {
|
|
139
139
|
log.info('Split filter query was modified. Updating cache.');
|
|
140
140
|
const queryKey = this.keys.buildSplitsFilterQueryKey();
|
|
141
141
|
const { queryString } = this.splitFiltersValidation;
|
|
@@ -73,8 +73,8 @@ export default function PushManagerFactory(context, clientContexts /* undefined
|
|
|
73
73
|
// Set token refresh 10 minutes before expirationTime - issuedAt
|
|
74
74
|
const decodedToken = authData.decodedToken;
|
|
75
75
|
const refreshTokenDelay = decodedToken.exp - decodedToken.iat - SECONDS_BEFORE_EXPIRATION;
|
|
76
|
-
// connDelay
|
|
77
|
-
const connDelay = authData.connDelay
|
|
76
|
+
// Default connDelay of 60 secs
|
|
77
|
+
const connDelay = typeof authData.connDelay === 'number' && authData.connDelay >= 0 ? authData.connDelay : 60;
|
|
78
78
|
|
|
79
79
|
log.info(`Refreshing streaming token in ${refreshTokenDelay} seconds, and connecting streaming in ${connDelay} seconds`);
|
|
80
80
|
|
|
@@ -247,19 +247,12 @@ export default function PushManagerFactory(context, clientContexts /* undefined
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
forOwn(clients, ({ hash64, worker }) => {
|
|
250
|
-
|
|
250
|
+
const add = added.has(hash64.dec) ? true : removed.has(hash64.dec) ? false : undefined;
|
|
251
|
+
if (add !== undefined) {
|
|
251
252
|
worker.put(parsedData.changeNumber, {
|
|
252
253
|
name: parsedData.segmentName,
|
|
253
|
-
add
|
|
254
|
+
add
|
|
254
255
|
});
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
if (removed.has(hash64.dec)) {
|
|
258
|
-
worker.put(parsedData.changeNumber, {
|
|
259
|
-
name: parsedData.segmentName,
|
|
260
|
-
add: false
|
|
261
|
-
});
|
|
262
|
-
return;
|
|
263
256
|
}
|
|
264
257
|
});
|
|
265
258
|
return;
|
package/src/sync/constants.js
CHANGED
|
@@ -69,7 +69,7 @@ export default function validateSplitFilters(splitFilters, mode) {
|
|
|
69
69
|
const res = {
|
|
70
70
|
validFilters: [],
|
|
71
71
|
queryString: null,
|
|
72
|
-
groupedFilters: {}
|
|
72
|
+
groupedFilters: { byName: [], byPrefix: [] }
|
|
73
73
|
};
|
|
74
74
|
// do nothing if `splitFilters` param is not a non-empty array or mode is not STANDALONE
|
|
75
75
|
if (!splitFilters) return res;
|
|
@@ -85,10 +85,6 @@ export default function validateSplitFilters(splitFilters, mode) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// Validate filters and group their values by filter type inside `groupedFilters` object
|
|
88
|
-
FILTERS_METADATA.forEach(function (metadata) {
|
|
89
|
-
res.groupedFilters[metadata.type] = [];
|
|
90
|
-
});
|
|
91
|
-
// Assign the valid filters to the output of the validator by using filter function
|
|
92
88
|
res.validFilters = splitFilters.filter((filter, index) => {
|
|
93
89
|
if (filter && validateFilterType(filter.type) && Array.isArray(filter.values)) {
|
|
94
90
|
res.groupedFilters[filter.type] = res.groupedFilters[filter.type].concat(filter.values);
|
|
@@ -5,17 +5,28 @@ import objectAssign from 'object-assign';
|
|
|
5
5
|
|
|
6
6
|
export const LogLevels = {
|
|
7
7
|
'DEBUG': 'DEBUG',
|
|
8
|
-
'INFO':
|
|
9
|
-
'WARN':
|
|
8
|
+
'INFO': 'INFO',
|
|
9
|
+
'WARN': 'WARN',
|
|
10
10
|
'ERROR': 'ERROR',
|
|
11
11
|
'NONE': 'NONE'
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
const LogLevelIndexes = {
|
|
15
|
+
DEBUG: 1,
|
|
16
|
+
INFO: 2,
|
|
17
|
+
WARN: 3,
|
|
18
|
+
ERROR: 4,
|
|
19
|
+
NONE: 5
|
|
20
|
+
};
|
|
21
|
+
|
|
14
22
|
// DEBUG is the default. The log level is not specific to an SDK instance.
|
|
15
|
-
let GlobalLogLevel =
|
|
23
|
+
let GlobalLogLevel = LogLevelIndexes.DEBUG;
|
|
16
24
|
|
|
25
|
+
/**
|
|
26
|
+
* @param {'DEBUG'|'INFO'|'WARN'|'ERROR'|'NONE'} level
|
|
27
|
+
*/
|
|
17
28
|
export const setLogLevel = (level) => {
|
|
18
|
-
GlobalLogLevel = level;
|
|
29
|
+
GlobalLogLevel = LogLevelIndexes[level];
|
|
19
30
|
};
|
|
20
31
|
|
|
21
32
|
const defaultOptions = {
|
|
@@ -30,22 +41,22 @@ export class Logger {
|
|
|
30
41
|
}
|
|
31
42
|
|
|
32
43
|
debug(msg) {
|
|
33
|
-
if(this._shouldLog(
|
|
44
|
+
if (this._shouldLog(LogLevelIndexes.DEBUG))
|
|
34
45
|
this._log(LogLevels.DEBUG, msg);
|
|
35
46
|
}
|
|
36
47
|
|
|
37
48
|
info(msg) {
|
|
38
|
-
if(this._shouldLog(
|
|
49
|
+
if (this._shouldLog(LogLevelIndexes.INFO))
|
|
39
50
|
this._log(LogLevels.INFO, msg);
|
|
40
51
|
}
|
|
41
52
|
|
|
42
53
|
warn(msg) {
|
|
43
|
-
if(this._shouldLog(
|
|
54
|
+
if (this._shouldLog(LogLevelIndexes.WARN))
|
|
44
55
|
this._log(LogLevels.WARN, msg);
|
|
45
56
|
}
|
|
46
57
|
|
|
47
58
|
error(msg) {
|
|
48
|
-
if(this.options.displayAllErrors || this._shouldLog(
|
|
59
|
+
if (this.options.displayAllErrors || this._shouldLog(LogLevelIndexes.ERROR))
|
|
49
60
|
this._log(LogLevels.ERROR, msg);
|
|
50
61
|
}
|
|
51
62
|
|
|
@@ -59,8 +70,8 @@ export class Logger {
|
|
|
59
70
|
const textPre = ' => ';
|
|
60
71
|
let result = '';
|
|
61
72
|
|
|
62
|
-
if(this.options.showLevel) {
|
|
63
|
-
result += '[' + level +']' + (level === LogLevels.INFO || level === LogLevels.WARN ? ' ' : '') + ' ';
|
|
73
|
+
if (this.options.showLevel) {
|
|
74
|
+
result += '[' + level + ']' + (level === LogLevels.INFO || level === LogLevels.WARN ? ' ' : '') + ' ';
|
|
64
75
|
}
|
|
65
76
|
|
|
66
77
|
if (this.category) {
|
|
@@ -70,12 +81,10 @@ export class Logger {
|
|
|
70
81
|
return result += text;
|
|
71
82
|
}
|
|
72
83
|
|
|
84
|
+
/**
|
|
85
|
+
* @param {number} level
|
|
86
|
+
*/
|
|
73
87
|
_shouldLog(level) {
|
|
74
|
-
|
|
75
|
-
const levels = Object.keys(LogLevels).map(f => LogLevels[f]);
|
|
76
|
-
const index = levels.indexOf(level); // What's the index of what it's trying to check if it should log
|
|
77
|
-
const levelIdx = levels.indexOf(logLevel); // What's the current log level index.
|
|
78
|
-
|
|
79
|
-
return index >= levelIdx;
|
|
88
|
+
return level >= GlobalLogLevel;
|
|
80
89
|
}
|
|
81
90
|
}
|
|
@@ -27,7 +27,7 @@ import { API } from '../../utils/logger';
|
|
|
27
27
|
import { STANDALONE_MODE, STORAGE_MEMORY, CONSUMER_MODE, OPTIMIZED } from '../../utils/constants';
|
|
28
28
|
import validImpressionsMode from './impressionsMode';
|
|
29
29
|
|
|
30
|
-
const version = '10.
|
|
30
|
+
const version = '10.16.1-rc.0';
|
|
31
31
|
const eventsEndpointMatcher = /^\/(testImpressions|metrics|events)/;
|
|
32
32
|
const authEndpointMatcher = /^\/v2\/auth/;
|
|
33
33
|
const streamingEndpointMatcher = /^\/(sse|event-stream)/;
|