@splitsoftware/splitio-commons 2.2.1-rc.3 → 2.2.1-rc.5
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 +5 -2
- package/README.md +1 -0
- package/cjs/consent/sdkUserConsent.js +5 -3
- package/cjs/evaluator/combiners/and.js +2 -6
- package/cjs/evaluator/combiners/ifelseif.js +6 -6
- package/cjs/evaluator/condition/index.js +6 -5
- package/cjs/evaluator/index.js +7 -7
- package/cjs/evaluator/matchers/index.js +3 -1
- package/cjs/evaluator/matchers/matcherTypes.js +1 -0
- package/cjs/evaluator/matchers/rbsegment.js +56 -0
- package/cjs/evaluator/matchersTransform/index.js +4 -0
- package/cjs/evaluator/parser/index.js +2 -2
- package/cjs/evaluator/value/sanitize.js +1 -0
- package/cjs/listeners/browser.js +2 -5
- package/cjs/logger/constants.js +4 -3
- package/cjs/logger/messages/debug.js +3 -2
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/services/splitApi.js +3 -4
- package/cjs/services/splitHttpClient.js +3 -1
- package/cjs/storages/AbstractSplitsCacheSync.js +5 -2
- package/cjs/storages/KeyBuilder.js +9 -0
- package/cjs/storages/KeyBuilderCS.js +3 -0
- package/cjs/storages/KeyBuilderSS.js +3 -0
- package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +117 -0
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +9 -14
- package/cjs/storages/inLocalStorage/index.js +5 -1
- package/cjs/storages/inLocalStorage/validateCache.js +2 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +3 -0
- package/cjs/storages/inMemory/InMemoryStorageCS.js +4 -0
- package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +61 -0
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +1 -0
- package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +64 -0
- package/cjs/storages/inRedis/index.js +5 -3
- package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +64 -0
- package/cjs/storages/pluggable/index.js +2 -0
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +54 -4
- package/cjs/sync/polling/pollingManagerCS.js +7 -7
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +59 -33
- package/cjs/sync/streaming/SSEHandler/index.js +1 -0
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +106 -77
- package/cjs/sync/streaming/constants.js +2 -1
- package/cjs/sync/streaming/pushManager.js +3 -16
- package/cjs/sync/syncManagerOnline.js +2 -2
- package/cjs/utils/constants/index.js +6 -2
- package/esm/consent/sdkUserConsent.js +5 -3
- package/esm/evaluator/combiners/and.js +2 -6
- package/esm/evaluator/combiners/ifelseif.js +7 -7
- package/esm/evaluator/condition/index.js +6 -5
- package/esm/evaluator/index.js +7 -7
- package/esm/evaluator/matchers/index.js +3 -1
- package/esm/evaluator/matchers/matcherTypes.js +1 -0
- package/esm/evaluator/matchers/rbsegment.js +52 -0
- package/esm/evaluator/matchersTransform/index.js +4 -0
- package/esm/evaluator/parser/index.js +2 -2
- package/esm/evaluator/value/sanitize.js +1 -0
- package/esm/listeners/browser.js +2 -5
- package/esm/logger/constants.js +1 -0
- package/esm/logger/messages/debug.js +3 -2
- package/esm/logger/messages/warn.js +1 -1
- package/esm/services/splitApi.js +3 -4
- package/esm/services/splitHttpClient.js +3 -1
- package/esm/storages/AbstractSplitsCacheSync.js +5 -2
- package/esm/storages/KeyBuilder.js +9 -0
- package/esm/storages/KeyBuilderCS.js +3 -0
- package/esm/storages/KeyBuilderSS.js +3 -0
- package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +114 -0
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +9 -14
- package/esm/storages/inLocalStorage/index.js +5 -1
- package/esm/storages/inLocalStorage/validateCache.js +2 -1
- package/esm/storages/inMemory/InMemoryStorage.js +3 -0
- package/esm/storages/inMemory/InMemoryStorageCS.js +4 -0
- package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +58 -0
- package/esm/storages/inMemory/SplitsCacheInMemory.js +1 -0
- package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +61 -0
- package/esm/storages/inRedis/index.js +5 -3
- package/esm/storages/pluggable/RBSegmentsCachePluggable.js +61 -0
- package/esm/storages/pluggable/index.js +2 -0
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +54 -4
- package/esm/sync/polling/pollingManagerCS.js +7 -7
- package/esm/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/esm/sync/polling/updaters/splitChangesUpdater.js +59 -33
- package/esm/sync/streaming/SSEHandler/index.js +2 -1
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +102 -73
- package/esm/sync/streaming/constants.js +1 -0
- package/esm/sync/streaming/pushManager.js +6 -19
- package/esm/sync/syncManagerOnline.js +2 -2
- package/esm/utils/constants/index.js +5 -1
- package/package.json +1 -1
- package/src/consent/sdkUserConsent.ts +3 -2
- package/src/dtos/types.ts +37 -8
- package/src/evaluator/Engine.ts +1 -1
- package/src/evaluator/combiners/and.ts +5 -4
- package/src/evaluator/combiners/ifelseif.ts +7 -9
- package/src/evaluator/condition/engineUtils.ts +1 -1
- package/src/evaluator/condition/index.ts +12 -12
- package/src/evaluator/index.ts +7 -7
- package/src/evaluator/matchers/index.ts +3 -1
- package/src/evaluator/matchers/matcherTypes.ts +1 -0
- package/src/evaluator/matchers/rbsegment.ts +74 -0
- package/src/evaluator/matchersTransform/index.ts +3 -0
- package/src/evaluator/parser/index.ts +3 -3
- package/src/evaluator/types.ts +2 -2
- package/src/evaluator/value/index.ts +2 -2
- package/src/evaluator/value/sanitize.ts +5 -4
- package/src/listeners/browser.ts +2 -3
- package/src/logger/constants.ts +1 -0
- package/src/logger/messages/debug.ts +3 -2
- package/src/logger/messages/warn.ts +1 -1
- package/src/sdkManager/index.ts +1 -1
- package/src/services/splitApi.ts +3 -4
- package/src/services/splitHttpClient.ts +3 -1
- package/src/services/types.ts +1 -1
- package/src/storages/AbstractSplitsCacheSync.ts +6 -3
- package/src/storages/KeyBuilder.ts +12 -0
- package/src/storages/KeyBuilderCS.ts +4 -0
- package/src/storages/KeyBuilderSS.ts +4 -0
- package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +136 -0
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +10 -14
- package/src/storages/inLocalStorage/index.ts +5 -1
- package/src/storages/inLocalStorage/validateCache.ts +3 -1
- package/src/storages/inMemory/InMemoryStorage.ts +3 -0
- package/src/storages/inMemory/InMemoryStorageCS.ts +4 -0
- package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +68 -0
- package/src/storages/inMemory/SplitsCacheInMemory.ts +1 -0
- package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +79 -0
- package/src/storages/inRedis/index.ts +5 -3
- package/src/storages/pluggable/RBSegmentsCachePluggable.ts +76 -0
- package/src/storages/pluggable/index.ts +2 -0
- package/src/storages/types.ts +33 -1
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +65 -4
- package/src/sync/polling/fetchers/types.ts +1 -0
- package/src/sync/polling/pollingManagerCS.ts +7 -7
- package/src/sync/polling/syncTasks/splitsSyncTask.ts +1 -1
- package/src/sync/polling/types.ts +2 -2
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -2
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
- package/src/sync/polling/updaters/splitChangesUpdater.ts +70 -43
- package/src/sync/streaming/SSEHandler/index.ts +2 -1
- package/src/sync/streaming/SSEHandler/types.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +98 -68
- package/src/sync/streaming/constants.ts +1 -0
- package/src/sync/streaming/parseUtils.ts +2 -2
- package/src/sync/streaming/pushManager.ts +6 -18
- package/src/sync/streaming/types.ts +3 -2
- package/src/sync/syncManagerOnline.ts +2 -2
- package/src/utils/constants/index.ts +6 -1
- package/src/utils/lang/index.ts +1 -1
|
@@ -1,103 +1,132 @@
|
|
|
1
|
+
import { STREAMING_PARSING_SPLIT_UPDATE } from '../../../logger/constants';
|
|
1
2
|
import { SDK_SPLITS_ARRIVED } from '../../../readiness/constants';
|
|
2
3
|
import { Backoff } from '../../../utils/Backoff';
|
|
3
4
|
import { SPLITS } from '../../../utils/constants';
|
|
5
|
+
import { RB_SEGMENT_UPDATE } from '../constants';
|
|
6
|
+
import { parseFFUpdatePayload } from '../parseUtils';
|
|
4
7
|
import { FETCH_BACKOFF_BASE, FETCH_BACKOFF_MAX_WAIT, FETCH_BACKOFF_MAX_RETRIES } from './constants';
|
|
5
8
|
/**
|
|
6
9
|
* SplitsUpdateWorker factory
|
|
7
10
|
*/
|
|
8
|
-
export function SplitsUpdateWorker(log,
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (splitUpdateNotification_1)
|
|
29
|
-
telemetryTracker.trackUpdatesFromSSE(SPLITS);
|
|
30
|
-
// fetch new registered segments for server-side API. Not retrying on error
|
|
31
|
-
if (segmentsSyncTask)
|
|
32
|
-
segmentsSyncTask.execute(true);
|
|
33
|
-
var attempts = backoff.attempts + 1;
|
|
34
|
-
if (maxChangeNumber <= splitsCache.getChangeNumber()) {
|
|
35
|
-
log.debug("Refresh completed" + (cdnBypass ? ' bypassing the CDN' : '') + " in " + attempts + " attempts.");
|
|
36
|
-
isHandlingEvent = false;
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if (attempts < FETCH_BACKOFF_MAX_RETRIES) {
|
|
40
|
-
backoff.scheduleCall();
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (cdnBypass) {
|
|
44
|
-
log.debug("No changes fetched after " + attempts + " attempts with CDN bypassed.");
|
|
45
|
-
isHandlingEvent = false;
|
|
11
|
+
export function SplitsUpdateWorker(log, storage, splitsSyncTask, splitsEventEmitter, telemetryTracker, segmentsSyncTask) {
|
|
12
|
+
var ff = SplitsUpdateWorker(storage.splits);
|
|
13
|
+
var rbs = SplitsUpdateWorker(storage.rbSegments);
|
|
14
|
+
function SplitsUpdateWorker(cache) {
|
|
15
|
+
var maxChangeNumber = -1;
|
|
16
|
+
var handleNewEvent = false;
|
|
17
|
+
var isHandlingEvent;
|
|
18
|
+
var cdnBypass;
|
|
19
|
+
var instantUpdate;
|
|
20
|
+
var backoff = new Backoff(__handleSplitUpdateCall, FETCH_BACKOFF_BASE, FETCH_BACKOFF_MAX_WAIT);
|
|
21
|
+
function __handleSplitUpdateCall() {
|
|
22
|
+
isHandlingEvent = true;
|
|
23
|
+
if (maxChangeNumber > cache.getChangeNumber()) {
|
|
24
|
+
handleNewEvent = false;
|
|
25
|
+
// fetch splits revalidating data if cached
|
|
26
|
+
splitsSyncTask.execute(true, cdnBypass ? maxChangeNumber : undefined, instantUpdate).then(function () {
|
|
27
|
+
if (!isHandlingEvent)
|
|
28
|
+
return; // halt if `stop` has been called
|
|
29
|
+
if (handleNewEvent) {
|
|
30
|
+
__handleSplitUpdateCall();
|
|
46
31
|
}
|
|
47
32
|
else {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
if (instantUpdate)
|
|
34
|
+
telemetryTracker.trackUpdatesFromSSE(SPLITS);
|
|
35
|
+
// fetch new registered segments for server-side API. Not retrying on error
|
|
36
|
+
if (segmentsSyncTask)
|
|
37
|
+
segmentsSyncTask.execute(true);
|
|
38
|
+
var attempts = backoff.attempts + 1;
|
|
39
|
+
if (ff.isSync() && rbs.isSync()) {
|
|
40
|
+
log.debug("Refresh completed" + (cdnBypass ? ' bypassing the CDN' : '') + " in " + attempts + " attempts.");
|
|
41
|
+
isHandlingEvent = false;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (attempts < FETCH_BACKOFF_MAX_RETRIES) {
|
|
45
|
+
backoff.scheduleCall();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (cdnBypass) {
|
|
49
|
+
log.debug("No changes fetched after " + attempts + " attempts with CDN bypassed.");
|
|
50
|
+
isHandlingEvent = false;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
backoff.reset();
|
|
54
|
+
cdnBypass = true;
|
|
55
|
+
__handleSplitUpdateCall();
|
|
56
|
+
}
|
|
51
57
|
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Invoked by NotificationProcessor on SPLIT_UPDATE event
|
|
61
|
-
*
|
|
62
|
-
* @param changeNumber - change number of the SPLIT_UPDATE notification
|
|
63
|
-
*/
|
|
64
|
-
function put(_a, _payload) {
|
|
65
|
-
var changeNumber = _a.changeNumber, pcn = _a.pcn;
|
|
66
|
-
var currentChangeNumber = splitsCache.getChangeNumber();
|
|
67
|
-
if (changeNumber <= currentChangeNumber || changeNumber <= maxChangeNumber)
|
|
68
|
-
return;
|
|
69
|
-
maxChangeNumber = changeNumber;
|
|
70
|
-
handleNewEvent = true;
|
|
71
|
-
cdnBypass = false;
|
|
72
|
-
payload = undefined;
|
|
73
|
-
if (_payload && currentChangeNumber === pcn) {
|
|
74
|
-
payload = _payload;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
isHandlingEvent = false;
|
|
62
|
+
}
|
|
75
63
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
64
|
+
return {
|
|
65
|
+
/**
|
|
66
|
+
* Invoked by NotificationProcessor on SPLIT_UPDATE or RB_SEGMENT_UPDATE event
|
|
67
|
+
*
|
|
68
|
+
* @param changeNumber - change number of the notification
|
|
69
|
+
*/
|
|
70
|
+
put: function (_a, payload) {
|
|
71
|
+
var changeNumber = _a.changeNumber, pcn = _a.pcn, type = _a.type;
|
|
72
|
+
var currentChangeNumber = cache.getChangeNumber();
|
|
73
|
+
if (changeNumber <= currentChangeNumber || changeNumber <= maxChangeNumber)
|
|
74
|
+
return;
|
|
75
|
+
maxChangeNumber = changeNumber;
|
|
76
|
+
handleNewEvent = true;
|
|
77
|
+
cdnBypass = false;
|
|
78
|
+
instantUpdate = undefined;
|
|
79
|
+
if (payload && currentChangeNumber === pcn) {
|
|
80
|
+
instantUpdate = { payload: payload, changeNumber: changeNumber, type: type };
|
|
81
|
+
}
|
|
82
|
+
if (backoff.timeoutID || !isHandlingEvent)
|
|
83
|
+
__handleSplitUpdateCall();
|
|
84
|
+
backoff.reset();
|
|
85
|
+
},
|
|
86
|
+
stop: function () {
|
|
87
|
+
isHandlingEvent = false;
|
|
88
|
+
backoff.reset();
|
|
89
|
+
},
|
|
90
|
+
isSync: function () {
|
|
91
|
+
return maxChangeNumber <= cache.getChangeNumber();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
79
94
|
}
|
|
80
95
|
return {
|
|
81
|
-
put:
|
|
96
|
+
put: function (parsedData) {
|
|
97
|
+
if (parsedData.d && parsedData.c !== undefined) {
|
|
98
|
+
try {
|
|
99
|
+
var payload = parseFFUpdatePayload(parsedData.c, parsedData.d);
|
|
100
|
+
if (payload) {
|
|
101
|
+
(parsedData.type === RB_SEGMENT_UPDATE ? rbs : ff).put(parsedData, payload);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
log.warn(STREAMING_PARSING_SPLIT_UPDATE, [parsedData.type, e]);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
(parsedData.type === RB_SEGMENT_UPDATE ? rbs : ff).put(parsedData);
|
|
110
|
+
},
|
|
82
111
|
/**
|
|
83
112
|
* Invoked by NotificationProcessor on SPLIT_KILL event
|
|
84
113
|
*
|
|
85
|
-
* @param changeNumber - change number of the
|
|
114
|
+
* @param changeNumber - change number of the notification
|
|
86
115
|
* @param splitName - name of split to kill
|
|
87
116
|
* @param defaultTreatment - default treatment value
|
|
88
117
|
*/
|
|
89
118
|
killSplit: function (_a) {
|
|
90
119
|
var changeNumber = _a.changeNumber, splitName = _a.splitName, defaultTreatment = _a.defaultTreatment;
|
|
91
|
-
if (
|
|
120
|
+
if (storage.splits.killLocally(splitName, defaultTreatment, changeNumber)) {
|
|
92
121
|
// trigger an SDK_UPDATE if Split was killed locally
|
|
93
122
|
splitsEventEmitter.emit(SDK_SPLITS_ARRIVED, true);
|
|
94
123
|
}
|
|
95
124
|
// queues the SplitChanges fetch (only if changeNumber is newer)
|
|
96
|
-
put({ changeNumber: changeNumber });
|
|
125
|
+
ff.put({ changeNumber: changeNumber });
|
|
97
126
|
},
|
|
98
127
|
stop: function () {
|
|
99
|
-
|
|
100
|
-
|
|
128
|
+
ff.stop();
|
|
129
|
+
rbs.stop();
|
|
101
130
|
}
|
|
102
131
|
};
|
|
103
132
|
}
|
|
@@ -27,6 +27,7 @@ export var MEMBERSHIPS_LS_UPDATE = 'MEMBERSHIPS_LS_UPDATE';
|
|
|
27
27
|
export var SEGMENT_UPDATE = 'SEGMENT_UPDATE';
|
|
28
28
|
export var SPLIT_KILL = 'SPLIT_KILL';
|
|
29
29
|
export var SPLIT_UPDATE = 'SPLIT_UPDATE';
|
|
30
|
+
export var RB_SEGMENT_UPDATE = 'RB_SEGMENT_UPDATE';
|
|
30
31
|
// Control-type push notifications, handled by NotificationKeeper
|
|
31
32
|
export var CONTROL = 'CONTROL';
|
|
32
33
|
export var OCCUPANCY = 'OCCUPANCY';
|
|
@@ -8,10 +8,10 @@ import { authenticateFactory, hashUserKey } from './AuthClient';
|
|
|
8
8
|
import { forOwn } from '../../utils/lang';
|
|
9
9
|
import { SSEClient } from './SSEClient';
|
|
10
10
|
import { getMatching } from '../../utils/key';
|
|
11
|
-
import { MEMBERSHIPS_MS_UPDATE, MEMBERSHIPS_LS_UPDATE, PUSH_NONRETRYABLE_ERROR, PUSH_SUBSYSTEM_DOWN, SECONDS_BEFORE_EXPIRATION, SEGMENT_UPDATE, SPLIT_KILL, SPLIT_UPDATE, PUSH_RETRYABLE_ERROR, PUSH_SUBSYSTEM_UP, ControlType } from './constants';
|
|
12
|
-
import { STREAMING_FALLBACK, STREAMING_REFRESH_TOKEN, STREAMING_CONNECTING, STREAMING_DISABLED, ERROR_STREAMING_AUTH, STREAMING_DISCONNECTING, STREAMING_RECONNECT, STREAMING_PARSING_MEMBERSHIPS_UPDATE
|
|
11
|
+
import { MEMBERSHIPS_MS_UPDATE, MEMBERSHIPS_LS_UPDATE, PUSH_NONRETRYABLE_ERROR, PUSH_SUBSYSTEM_DOWN, SECONDS_BEFORE_EXPIRATION, SEGMENT_UPDATE, SPLIT_KILL, SPLIT_UPDATE, RB_SEGMENT_UPDATE, PUSH_RETRYABLE_ERROR, PUSH_SUBSYSTEM_UP, ControlType } from './constants';
|
|
12
|
+
import { STREAMING_FALLBACK, STREAMING_REFRESH_TOKEN, STREAMING_CONNECTING, STREAMING_DISABLED, ERROR_STREAMING_AUTH, STREAMING_DISCONNECTING, STREAMING_RECONNECT, STREAMING_PARSING_MEMBERSHIPS_UPDATE } from '../../logger/constants';
|
|
13
13
|
import { UpdateStrategy } from './SSEHandler/types';
|
|
14
|
-
import { getDelay, isInBitmap, parseBitmap,
|
|
14
|
+
import { getDelay, isInBitmap, parseBitmap, parseKeyList } from './parseUtils';
|
|
15
15
|
import { hash64 } from '../../utils/murmur3/murmur3_64';
|
|
16
16
|
import { TOKEN_REFRESH, AUTH_REJECTION } from '../../utils/constants';
|
|
17
17
|
/**
|
|
@@ -43,7 +43,7 @@ export function pushManagerFactory(params, pollingManager) {
|
|
|
43
43
|
// MySegmentsUpdateWorker (client-side) are initiated in `add` method
|
|
44
44
|
var segmentsUpdateWorker = userKey ? undefined : SegmentsUpdateWorker(log, pollingManager.segmentsSyncTask, storage.segments);
|
|
45
45
|
// For server-side we pass the segmentsSyncTask, used by SplitsUpdateWorker to fetch new segments
|
|
46
|
-
var splitsUpdateWorker = SplitsUpdateWorker(log, storage
|
|
46
|
+
var splitsUpdateWorker = SplitsUpdateWorker(log, storage, pollingManager.splitsSyncTask, readiness.splits, telemetryTracker, userKey ? undefined : pollingManager.segmentsSyncTask);
|
|
47
47
|
// [Only for client-side] map of hashes to user keys, to dispatch membership update events to the corresponding MySegmentsUpdateWorker
|
|
48
48
|
var userKeyHashes = {};
|
|
49
49
|
// [Only for client-side] map of user keys to their corresponding hash64 and MySegmentsUpdateWorkers.
|
|
@@ -179,21 +179,8 @@ export function pushManagerFactory(params, pollingManager) {
|
|
|
179
179
|
});
|
|
180
180
|
/** Functions related to synchronization (Queues and Workers in the spec) */
|
|
181
181
|
pushEmitter.on(SPLIT_KILL, splitsUpdateWorker.killSplit);
|
|
182
|
-
pushEmitter.on(SPLIT_UPDATE,
|
|
183
|
-
|
|
184
|
-
try {
|
|
185
|
-
var payload = parseFFUpdatePayload(parsedData.c, parsedData.d);
|
|
186
|
-
if (payload) {
|
|
187
|
-
splitsUpdateWorker.put(parsedData, payload);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
catch (e) {
|
|
192
|
-
log.warn(STREAMING_PARSING_SPLIT_UPDATE, [e]);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
splitsUpdateWorker.put(parsedData);
|
|
196
|
-
});
|
|
182
|
+
pushEmitter.on(SPLIT_UPDATE, splitsUpdateWorker.put);
|
|
183
|
+
pushEmitter.on(RB_SEGMENT_UPDATE, splitsUpdateWorker.put);
|
|
197
184
|
function handleMySegmentsUpdate(parsedData) {
|
|
198
185
|
switch (parsedData.u) {
|
|
199
186
|
case UpdateStrategy.BoundedFetchRequest: {
|
|
@@ -127,7 +127,7 @@ export function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFacto
|
|
|
127
127
|
if (pushManager) {
|
|
128
128
|
if (pollingManager.isRunning()) {
|
|
129
129
|
// if doing polling, we must start the periodic fetch of data
|
|
130
|
-
if (storage.splits.usesSegments())
|
|
130
|
+
if (storage.splits.usesSegments() || storage.rbSegments.usesSegments())
|
|
131
131
|
mySegmentsSyncTask.start();
|
|
132
132
|
}
|
|
133
133
|
else {
|
|
@@ -137,7 +137,7 @@ export function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFacto
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
else {
|
|
140
|
-
if (storage.splits.usesSegments())
|
|
140
|
+
if (storage.splits.usesSegments() || storage.rbSegments.usesSegments())
|
|
141
141
|
mySegmentsSyncTask.start();
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -86,7 +86,11 @@ export var NON_REQUESTED = 1;
|
|
|
86
86
|
export var DISABLED = 0;
|
|
87
87
|
export var ENABLED = 1;
|
|
88
88
|
export var PAUSED = 2;
|
|
89
|
-
export var FLAG_SPEC_VERSION = '1.
|
|
89
|
+
export var FLAG_SPEC_VERSION = '1.3';
|
|
90
90
|
// Matcher types
|
|
91
91
|
export var IN_SEGMENT = 'IN_SEGMENT';
|
|
92
92
|
export var IN_LARGE_SEGMENT = 'IN_LARGE_SEGMENT';
|
|
93
|
+
export var IN_RULE_BASED_SEGMENT = 'IN_RULE_BASED_SEGMENT';
|
|
94
|
+
export var STANDARD_SEGMENT = 'standard';
|
|
95
|
+
export var LARGE_SEGMENT = 'large';
|
|
96
|
+
export var RULE_BASED_SEGMENT = 'rule-based';
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@ const ConsentStatus = {
|
|
|
15
15
|
* The public user consent API exposed via SplitFactory, used to control if the SDK tracks and sends impressions and events or not.
|
|
16
16
|
*/
|
|
17
17
|
export function createUserConsentAPI(params: ISdkFactoryContext) {
|
|
18
|
-
const { settings, settings: { log }, syncManager, storage: { events, impressions, impressionCounts } } = params;
|
|
18
|
+
const { settings, settings: { log }, syncManager, storage: { events, impressions, impressionCounts, uniqueKeys } } = params;
|
|
19
19
|
|
|
20
20
|
if (!isConsentGranted(settings)) log.info(USER_CONSENT_INITIAL, [settings.userConsent]);
|
|
21
21
|
|
|
@@ -41,7 +41,8 @@ export function createUserConsentAPI(params: ISdkFactoryContext) {
|
|
|
41
41
|
// @ts-ignore, clear method is present in storage for standalone and partial consumer mode
|
|
42
42
|
if (events.clear) events.clear(); // @ts-ignore
|
|
43
43
|
if (impressions.clear) impressions.clear(); // @ts-ignore
|
|
44
|
-
if (impressionCounts
|
|
44
|
+
if (impressionCounts.clear) impressionCounts.clear(); // @ts-ignore
|
|
45
|
+
if (uniqueKeys.clear) uniqueKeys.clear();
|
|
45
46
|
}
|
|
46
47
|
} else {
|
|
47
48
|
log.info(USER_CONSENT_NOT_UPDATED, [newConsentStatus]);
|
package/src/dtos/types.ts
CHANGED
|
@@ -66,6 +66,11 @@ interface IInSegmentMatcher extends ISplitMatcherBase {
|
|
|
66
66
|
userDefinedSegmentMatcherData: IInSegmentMatcherData
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
interface IInRBSegmentMatcher extends ISplitMatcherBase {
|
|
70
|
+
matcherType: 'IN_RULE_BASED_SEGMENT',
|
|
71
|
+
userDefinedSegmentMatcherData: IInSegmentMatcherData
|
|
72
|
+
}
|
|
73
|
+
|
|
69
74
|
interface IInLargeSegmentMatcher extends ISplitMatcherBase {
|
|
70
75
|
matcherType: 'IN_LARGE_SEGMENT',
|
|
71
76
|
userDefinedLargeSegmentMatcherData: IInLargeSegmentMatcherData
|
|
@@ -176,7 +181,7 @@ export type ISplitMatcher = IAllKeysMatcher | IInSegmentMatcher | IWhitelistMatc
|
|
|
176
181
|
ILessThanOrEqualToMatcher | IBetweenMatcher | IEqualToSetMatcher | IContainsAnyOfSetMatcher | IContainsAllOfSetMatcher | IPartOfSetMatcher |
|
|
177
182
|
IStartsWithMatcher | IEndsWithMatcher | IContainsStringMatcher | IInSplitTreatmentMatcher | IEqualToBooleanMatcher | IMatchesStringMatcher |
|
|
178
183
|
IEqualToSemverMatcher | IGreaterThanOrEqualToSemverMatcher | ILessThanOrEqualToSemverMatcher | IBetweenSemverMatcher | IInListSemverMatcher |
|
|
179
|
-
IInLargeSegmentMatcher
|
|
184
|
+
IInLargeSegmentMatcher | IInRBSegmentMatcher
|
|
180
185
|
|
|
181
186
|
/** Split object */
|
|
182
187
|
export interface ISplitPartition {
|
|
@@ -189,19 +194,35 @@ export interface ISplitCondition {
|
|
|
189
194
|
combiner: 'AND',
|
|
190
195
|
matchers: ISplitMatcher[]
|
|
191
196
|
}
|
|
192
|
-
partitions
|
|
193
|
-
label
|
|
194
|
-
conditionType
|
|
197
|
+
partitions?: ISplitPartition[]
|
|
198
|
+
label?: string
|
|
199
|
+
conditionType?: 'ROLLOUT' | 'WHITELIST'
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface IExcludedSegment {
|
|
203
|
+
type: 'standard' | 'large' | 'rule-based',
|
|
204
|
+
name: string,
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface IRBSegment {
|
|
208
|
+
name: string,
|
|
209
|
+
changeNumber: number,
|
|
210
|
+
status: 'ACTIVE' | 'ARCHIVED',
|
|
211
|
+
conditions?: ISplitCondition[],
|
|
212
|
+
excluded?: {
|
|
213
|
+
keys?: string[] | null,
|
|
214
|
+
segments?: IExcludedSegment[] | null
|
|
215
|
+
}
|
|
195
216
|
}
|
|
196
217
|
|
|
197
218
|
export interface ISplit {
|
|
198
219
|
name: string,
|
|
199
220
|
changeNumber: number,
|
|
221
|
+
status: 'ACTIVE' | 'ARCHIVED',
|
|
222
|
+
conditions: ISplitCondition[],
|
|
200
223
|
killed: boolean,
|
|
201
224
|
defaultTreatment: string,
|
|
202
225
|
trafficTypeName: string,
|
|
203
|
-
conditions: ISplitCondition[],
|
|
204
|
-
status: 'ACTIVE' | 'ARCHIVED',
|
|
205
226
|
seed: number,
|
|
206
227
|
trafficAllocation?: number,
|
|
207
228
|
trafficAllocationSeed?: number
|
|
@@ -217,8 +238,16 @@ export type ISplitPartial = Pick<ISplit, 'conditions' | 'configurations' | 'traf
|
|
|
217
238
|
|
|
218
239
|
/** Interface of the parsed JSON response of `/splitChanges` */
|
|
219
240
|
export interface ISplitChangesResponse {
|
|
220
|
-
|
|
221
|
-
|
|
241
|
+
ff?: {
|
|
242
|
+
t: number,
|
|
243
|
+
s?: number,
|
|
244
|
+
d: ISplit[]
|
|
245
|
+
},
|
|
246
|
+
rbs?: {
|
|
247
|
+
t: number,
|
|
248
|
+
s?: number,
|
|
249
|
+
d: IRBSegment[]
|
|
250
|
+
}
|
|
222
251
|
}
|
|
223
252
|
|
|
224
253
|
/** Interface of the parsed JSON response of `/segmentChanges/{segmentName}` */
|
package/src/evaluator/Engine.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { findIndex } from '../../utils/lang';
|
|
|
2
2
|
import { ILogger } from '../../logger/types';
|
|
3
3
|
import { thenable } from '../../utils/promise/thenable';
|
|
4
4
|
import { MaybeThenable } from '../../dtos/types';
|
|
5
|
-
import {
|
|
5
|
+
import { ISplitEvaluator } from '../types';
|
|
6
6
|
import { ENGINE_COMBINER_AND } from '../../logger/constants';
|
|
7
|
+
import SplitIO from '../../../types/splitio';
|
|
7
8
|
|
|
8
|
-
export function andCombinerContext(log: ILogger, matchers:
|
|
9
|
+
export function andCombinerContext(log: ILogger, matchers: Array<(key: SplitIO.SplitKey, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) => MaybeThenable<boolean>>) {
|
|
9
10
|
|
|
10
11
|
function andResults(results: boolean[]): boolean {
|
|
11
12
|
// Array.prototype.every is supported by target environments
|
|
@@ -15,8 +16,8 @@ export function andCombinerContext(log: ILogger, matchers: IMatcher[]) {
|
|
|
15
16
|
return hasMatchedAll;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
return function andCombiner(
|
|
19
|
-
const matcherResults = matchers.map(matcher => matcher(
|
|
19
|
+
return function andCombiner(key: SplitIO.SplitKey, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator): MaybeThenable<boolean> {
|
|
20
|
+
const matcherResults = matchers.map(matcher => matcher(key, attributes, splitEvaluator));
|
|
20
21
|
|
|
21
22
|
// If any matching result is a thenable we should use Promise.all
|
|
22
23
|
if (findIndex(matcherResults, thenable) !== -1) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { findIndex } from '../../utils/lang';
|
|
1
|
+
import { findIndex, isBoolean } from '../../utils/lang';
|
|
2
2
|
import { ILogger } from '../../logger/types';
|
|
3
3
|
import { thenable } from '../../utils/promise/thenable';
|
|
4
4
|
import { UNSUPPORTED_MATCHER_TYPE } from '../../utils/labels';
|
|
@@ -18,14 +18,12 @@ export function ifElseIfCombinerContext(log: ILogger, predicates: IEvaluator[]):
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
for (let i = 0; i < len; i++) {
|
|
21
|
+
function computeEvaluation(predicateResults: Array<IEvaluation | boolean | undefined>): IEvaluation | boolean | undefined {
|
|
22
|
+
for (let i = 0, len = predicateResults.length; i < len; i++) {
|
|
25
23
|
const evaluation = predicateResults[i];
|
|
26
24
|
|
|
27
25
|
if (evaluation !== undefined) {
|
|
28
|
-
log.debug(ENGINE_COMBINER_IFELSEIF, [evaluation.treatment]);
|
|
26
|
+
if (!isBoolean(evaluation)) log.debug(ENGINE_COMBINER_IFELSEIF, [evaluation.treatment]);
|
|
29
27
|
|
|
30
28
|
return evaluation;
|
|
31
29
|
}
|
|
@@ -35,7 +33,7 @@ export function ifElseIfCombinerContext(log: ILogger, predicates: IEvaluator[]):
|
|
|
35
33
|
return undefined;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
function ifElseIfCombiner(key: SplitIO.
|
|
36
|
+
function ifElseIfCombiner(key: SplitIO.SplitKeyObject, seed?: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) {
|
|
39
37
|
// In Async environments we are going to have async predicates. There is none way to know
|
|
40
38
|
// before hand so we need to evaluate all the predicates, verify for thenables, and finally,
|
|
41
39
|
// define how to return the treatment (wrap result into a Promise or not).
|
|
@@ -43,10 +41,10 @@ export function ifElseIfCombinerContext(log: ILogger, predicates: IEvaluator[]):
|
|
|
43
41
|
|
|
44
42
|
// if we find a thenable
|
|
45
43
|
if (findIndex(predicateResults, thenable) !== -1) {
|
|
46
|
-
return Promise.all(predicateResults).then(results =>
|
|
44
|
+
return Promise.all(predicateResults).then(results => computeEvaluation(results));
|
|
47
45
|
}
|
|
48
46
|
|
|
49
|
-
return
|
|
47
|
+
return computeEvaluation(predicateResults as IEvaluation[]);
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
// if there is none predicates, then there was an error in parsing phase
|
|
@@ -5,7 +5,7 @@ import { bucket } from '../../utils/murmur3/murmur3';
|
|
|
5
5
|
/**
|
|
6
6
|
* Get the treatment name given a key, a seed, and the percentage of each treatment.
|
|
7
7
|
*/
|
|
8
|
-
export function getTreatment(log: ILogger, key: string, seed: number, treatments: { getTreatmentFor: (x: number) => string }) {
|
|
8
|
+
export function getTreatment(log: ILogger, key: string, seed: number | undefined, treatments: { getTreatmentFor: (x: number) => string }) {
|
|
9
9
|
const _bucket = bucket(key, seed);
|
|
10
10
|
|
|
11
11
|
const treatment = treatments.getTreatmentFor(_bucket);
|
|
@@ -7,14 +7,14 @@ import SplitIO from '../../../types/splitio';
|
|
|
7
7
|
import { ILogger } from '../../logger/types';
|
|
8
8
|
|
|
9
9
|
// Build Evaluation object if and only if matchingResult is true
|
|
10
|
-
function match(log: ILogger, matchingResult: boolean, bucketingKey: string | undefined, seed
|
|
10
|
+
function match(log: ILogger, matchingResult: boolean, bucketingKey: string | undefined, seed?: number, treatments?: { getTreatmentFor: (x: number) => string }, label?: string): IEvaluation | boolean | undefined {
|
|
11
11
|
if (matchingResult) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
return treatments ? // Feature flag
|
|
13
|
+
{
|
|
14
|
+
treatment: getTreatment(log, bucketingKey as string, seed, treatments),
|
|
15
|
+
label: label!
|
|
16
|
+
} : // Rule-based segment
|
|
17
|
+
true;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// else we should notify the engine to continue evaluating
|
|
@@ -22,12 +22,12 @@ function match(log: ILogger, matchingResult: boolean, bucketingKey: string | und
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// Condition factory
|
|
25
|
-
export function conditionContext(log: ILogger, matcherEvaluator: (
|
|
25
|
+
export function conditionContext(log: ILogger, matcherEvaluator: (key: SplitIO.SplitKeyObject, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) => MaybeThenable<boolean>, treatments?: { getTreatmentFor: (x: number) => string }, label?: string, conditionType?: 'ROLLOUT' | 'WHITELIST'): IEvaluator {
|
|
26
26
|
|
|
27
|
-
return function conditionEvaluator(key: SplitIO.
|
|
27
|
+
return function conditionEvaluator(key: SplitIO.SplitKeyObject, seed?: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) {
|
|
28
28
|
|
|
29
29
|
// Whitelisting has more priority than traffic allocation, so we don't apply this filtering to those conditions.
|
|
30
|
-
if (conditionType === 'ROLLOUT' && !shouldApplyRollout(trafficAllocation
|
|
30
|
+
if (conditionType === 'ROLLOUT' && !shouldApplyRollout(trafficAllocation!, key.bucketingKey, trafficAllocationSeed!)) {
|
|
31
31
|
return {
|
|
32
32
|
treatment: undefined, // treatment value is assigned later
|
|
33
33
|
label: NOT_IN_SPLIT
|
|
@@ -41,10 +41,10 @@ export function conditionContext(log: ILogger, matcherEvaluator: (...args: any)
|
|
|
41
41
|
const matches = matcherEvaluator(key, attributes, splitEvaluator);
|
|
42
42
|
|
|
43
43
|
if (thenable(matches)) {
|
|
44
|
-
return matches.then(result => match(log, result,
|
|
44
|
+
return matches.then(result => match(log, result, key.bucketingKey, seed, treatments, label));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
return match(log, matches,
|
|
47
|
+
return match(log, matches, key.bucketingKey, seed, treatments, label);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
}
|
package/src/evaluator/index.ts
CHANGED
|
@@ -43,8 +43,8 @@ export function evaluateFeature(
|
|
|
43
43
|
if (thenable(parsedSplit)) {
|
|
44
44
|
return parsedSplit.then((split) => getEvaluation(
|
|
45
45
|
log,
|
|
46
|
-
split,
|
|
47
46
|
key,
|
|
47
|
+
split,
|
|
48
48
|
attributes,
|
|
49
49
|
storage,
|
|
50
50
|
)).catch(
|
|
@@ -56,8 +56,8 @@ export function evaluateFeature(
|
|
|
56
56
|
|
|
57
57
|
return getEvaluation(
|
|
58
58
|
log,
|
|
59
|
-
parsedSplit,
|
|
60
59
|
key,
|
|
60
|
+
parsedSplit,
|
|
61
61
|
attributes,
|
|
62
62
|
storage,
|
|
63
63
|
);
|
|
@@ -80,13 +80,13 @@ export function evaluateFeatures(
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
return thenable(parsedSplits) ?
|
|
83
|
-
parsedSplits.then(splits => getEvaluations(log, splitNames, splits,
|
|
83
|
+
parsedSplits.then(splits => getEvaluations(log, key, splitNames, splits, attributes, storage))
|
|
84
84
|
.catch(() => {
|
|
85
85
|
// Exception on async `getSplits` storage. For example, when the storage is redis or
|
|
86
86
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
87
87
|
return treatmentsException(splitNames);
|
|
88
88
|
}) :
|
|
89
|
-
getEvaluations(log, splitNames, parsedSplits,
|
|
89
|
+
getEvaluations(log, key, splitNames, parsedSplits, attributes, storage);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
export function evaluateFeaturesByFlagSets(
|
|
@@ -136,8 +136,8 @@ export function evaluateFeaturesByFlagSets(
|
|
|
136
136
|
|
|
137
137
|
function getEvaluation(
|
|
138
138
|
log: ILogger,
|
|
139
|
-
splitJSON: ISplit | null,
|
|
140
139
|
key: SplitIO.SplitKey,
|
|
140
|
+
splitJSON: ISplit | null,
|
|
141
141
|
attributes: SplitIO.Attributes | undefined,
|
|
142
142
|
storage: IStorageSync | IStorageAsync,
|
|
143
143
|
): MaybeThenable<IEvaluationResult> {
|
|
@@ -172,9 +172,9 @@ function getEvaluation(
|
|
|
172
172
|
|
|
173
173
|
function getEvaluations(
|
|
174
174
|
log: ILogger,
|
|
175
|
+
key: SplitIO.SplitKey,
|
|
175
176
|
splitNames: string[],
|
|
176
177
|
splits: Record<string, ISplit | null>,
|
|
177
|
-
key: SplitIO.SplitKey,
|
|
178
178
|
attributes: SplitIO.Attributes | undefined,
|
|
179
179
|
storage: IStorageSync | IStorageAsync,
|
|
180
180
|
): MaybeThenable<Record<string, IEvaluationResult>> {
|
|
@@ -183,8 +183,8 @@ function getEvaluations(
|
|
|
183
183
|
splitNames.forEach(splitName => {
|
|
184
184
|
const evaluation = getEvaluation(
|
|
185
185
|
log,
|
|
186
|
-
splits[splitName],
|
|
187
186
|
key,
|
|
187
|
+
splits[splitName],
|
|
188
188
|
attributes,
|
|
189
189
|
storage
|
|
190
190
|
);
|
|
@@ -24,6 +24,7 @@ import { inListSemverMatcherContext } from './semver_inlist';
|
|
|
24
24
|
import { IStorageAsync, IStorageSync } from '../../storages/types';
|
|
25
25
|
import { IMatcher, IMatcherDto } from '../types';
|
|
26
26
|
import { ILogger } from '../../logger/types';
|
|
27
|
+
import { ruleBasedSegmentMatcherContext } from './rbsegment';
|
|
27
28
|
|
|
28
29
|
const matchers = [
|
|
29
30
|
undefined, // UNDEFINED: 0
|
|
@@ -50,6 +51,7 @@ const matchers = [
|
|
|
50
51
|
betweenSemverMatcherContext, // BETWEEN_SEMVER: 21
|
|
51
52
|
inListSemverMatcherContext, // IN_LIST_SEMVER: 22
|
|
52
53
|
largeSegmentMatcherContext, // IN_LARGE_SEGMENT: 23
|
|
54
|
+
ruleBasedSegmentMatcherContext // IN_RULE_BASED_SEGMENT: 24
|
|
53
55
|
];
|
|
54
56
|
|
|
55
57
|
/**
|
|
@@ -64,5 +66,5 @@ export function matcherFactory(log: ILogger, matcherDto: IMatcherDto, storage?:
|
|
|
64
66
|
let matcherFn;
|
|
65
67
|
// @ts-ignore
|
|
66
68
|
if (matchers[type]) matcherFn = matchers[type](value, storage, log); // There is no index-out-of-bound exception in JavaScript
|
|
67
|
-
return matcherFn;
|
|
69
|
+
return matcherFn as IMatcher;
|
|
68
70
|
}
|