@splitsoftware/splitio-commons 2.0.0-rc.4 → 2.0.0-rc.6
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 +1 -0
- package/cjs/integrations/pluggable.js +2 -2
- package/cjs/logger/sdkLogger.js +2 -2
- package/cjs/readiness/sdkReadinessManager.js +2 -21
- package/cjs/sdkClient/client.js +0 -1
- package/cjs/sdkClient/clientAttributesDecoration.js +9 -9
- package/cjs/sdkClient/clientCS.js +2 -2
- package/cjs/services/splitApi.js +13 -13
- package/cjs/services/splitHttpClient.js +2 -2
- package/cjs/storages/AbstractSplitsCacheAsync.js +1 -4
- package/cjs/storages/AbstractSplitsCacheSync.js +1 -4
- package/cjs/storages/dataLoader.js +5 -6
- package/cjs/storages/findLatencyIndex.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +1 -6
- package/cjs/storages/inMemory/AttributesCacheInMemory.js +10 -10
- package/cjs/storages/inMemory/EventsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/ImpressionsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +1 -1
- package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/cjs/storages/inMemory/UniqueKeysCacheInMemoryCS.js +0 -5
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +1 -3
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +3 -3
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/cjs/storages/pluggable/EventsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/ImpressionsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SegmentsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SplitsCachePluggable.js +3 -3
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +3 -3
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/cjs/storages/pluggable/inMemoryWrapper.js +1 -1
- package/cjs/storages/pluggable/index.js +1 -1
- package/cjs/storages/pluggable/wrapperAdapter.js +2 -2
- package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +1 -1
- package/cjs/sync/offline/syncManagerOffline.js +1 -1
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +8 -8
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +13 -13
- package/cjs/sync/streaming/AuthClient/index.js +2 -2
- package/cjs/sync/streaming/SSEClient/index.js +4 -7
- package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
- package/cjs/sync/streaming/SSEHandler/NotificationParser.js +5 -4
- package/cjs/sync/streaming/SSEHandler/index.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +3 -3
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
- package/cjs/sync/streaming/parseUtils.js +13 -13
- package/cjs/sync/syncManagerOnline.js +2 -2
- package/cjs/sync/syncTask.js +4 -4
- package/cjs/trackers/eventTracker.js +2 -2
- package/cjs/trackers/impressionsTracker.js +5 -5
- package/cjs/trackers/strategy/strategyDebug.js +1 -1
- package/cjs/trackers/strategy/strategyNone.js +2 -2
- package/cjs/trackers/strategy/strategyOptimized.js +2 -2
- package/cjs/trackers/uniqueKeysTracker.js +3 -3
- package/cjs/utils/Backoff.js +0 -4
- package/cjs/utils/Semver.js +1 -1
- package/cjs/utils/base64/index.js +2 -2
- package/cjs/utils/decompress/index.js +4 -4
- package/cjs/utils/lang/binarySearch.js +2 -2
- package/cjs/utils/murmur3/murmur3_128.js +1 -1
- package/cjs/utils/murmur3/murmur3_128_x86.js +1 -1
- package/cjs/utils/murmur3/murmur3_64.js +1 -1
- package/cjs/utils/murmur3/utfx.js +10 -17
- package/cjs/utils/promise/wrapper.js +2 -2
- package/cjs/utils/settingsValidation/index.js +2 -2
- package/cjs/utils/settingsValidation/integrations/common.js +4 -4
- package/cjs/utils/settingsValidation/integrations/configurable.js +3 -3
- package/cjs/utils/settingsValidation/integrations/pluggable.js +2 -2
- package/cjs/utils/settingsValidation/logger/builtinLogger.js +1 -1
- package/cjs/utils/settingsValidation/logger/commons.js +1 -1
- package/cjs/utils/settingsValidation/logger/pluggableLogger.js +1 -1
- package/cjs/utils/settingsValidation/splitFilters.js +8 -11
- package/cjs/utils/settingsValidation/storage/storageCS.js +2 -2
- package/cjs/utils/settingsValidation/url.js +3 -3
- package/esm/integrations/pluggable.js +2 -2
- package/esm/logger/sdkLogger.js +2 -2
- package/esm/readiness/sdkReadinessManager.js +2 -21
- package/esm/sdkClient/client.js +0 -1
- package/esm/sdkClient/clientAttributesDecoration.js +9 -9
- package/esm/sdkClient/clientCS.js +2 -2
- package/esm/services/splitApi.js +13 -13
- package/esm/services/splitHttpClient.js +2 -2
- package/esm/storages/AbstractSplitsCacheAsync.js +1 -4
- package/esm/storages/AbstractSplitsCacheSync.js +1 -4
- package/esm/storages/dataLoader.js +5 -6
- package/esm/storages/findLatencyIndex.js +1 -1
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +1 -6
- package/esm/storages/inMemory/AttributesCacheInMemory.js +10 -10
- package/esm/storages/inMemory/EventsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/ImpressionsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/InMemoryStorage.js +1 -1
- package/esm/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/esm/storages/inMemory/UniqueKeysCacheInMemoryCS.js +0 -5
- package/esm/storages/inRedis/SplitsCacheInRedis.js +1 -3
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +3 -3
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/esm/storages/pluggable/EventsCachePluggable.js +1 -1
- package/esm/storages/pluggable/ImpressionsCachePluggable.js +1 -1
- package/esm/storages/pluggable/SegmentsCachePluggable.js +1 -1
- package/esm/storages/pluggable/SplitsCachePluggable.js +3 -3
- package/esm/storages/pluggable/TelemetryCachePluggable.js +3 -3
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/esm/storages/pluggable/inMemoryWrapper.js +1 -1
- package/esm/storages/pluggable/index.js +1 -1
- package/esm/storages/pluggable/wrapperAdapter.js +2 -2
- package/esm/sync/offline/splitsParser/splitsParserFromSettings.js +1 -1
- package/esm/sync/offline/syncManagerOffline.js +1 -1
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +8 -8
- package/esm/sync/polling/updaters/splitChangesUpdater.js +13 -13
- package/esm/sync/streaming/AuthClient/index.js +2 -2
- package/esm/sync/streaming/SSEClient/index.js +4 -7
- package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
- package/esm/sync/streaming/SSEHandler/NotificationParser.js +5 -4
- package/esm/sync/streaming/SSEHandler/index.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +3 -3
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
- package/esm/sync/streaming/parseUtils.js +13 -13
- package/esm/sync/syncManagerOnline.js +2 -2
- package/esm/sync/syncTask.js +4 -4
- package/esm/trackers/eventTracker.js +2 -2
- package/esm/trackers/impressionsTracker.js +5 -5
- package/esm/trackers/strategy/strategyDebug.js +1 -1
- package/esm/trackers/strategy/strategyNone.js +2 -2
- package/esm/trackers/strategy/strategyOptimized.js +2 -2
- package/esm/trackers/uniqueKeysTracker.js +3 -3
- package/esm/utils/Backoff.js +0 -4
- package/esm/utils/Semver.js +1 -1
- package/esm/utils/base64/index.js +2 -2
- package/esm/utils/decompress/index.js +4 -4
- package/esm/utils/lang/binarySearch.js +2 -2
- package/esm/utils/murmur3/murmur3_128.js +1 -1
- package/esm/utils/murmur3/murmur3_128_x86.js +1 -1
- package/esm/utils/murmur3/murmur3_64.js +1 -1
- package/esm/utils/murmur3/utfx.js +10 -17
- package/esm/utils/promise/wrapper.js +2 -2
- package/esm/utils/settingsValidation/index.js +2 -2
- package/esm/utils/settingsValidation/integrations/common.js +4 -4
- package/esm/utils/settingsValidation/integrations/configurable.js +3 -3
- package/esm/utils/settingsValidation/integrations/pluggable.js +2 -2
- package/esm/utils/settingsValidation/logger/builtinLogger.js +1 -1
- package/esm/utils/settingsValidation/logger/commons.js +1 -1
- package/esm/utils/settingsValidation/logger/pluggableLogger.js +1 -1
- package/esm/utils/settingsValidation/splitFilters.js +8 -11
- package/esm/utils/settingsValidation/storage/storageCS.js +2 -2
- package/esm/utils/settingsValidation/url.js +3 -3
- package/package.json +3 -2
- package/src/dtos/types.ts +1 -1
- package/src/evaluator/Engine.ts +1 -1
- package/src/evaluator/combiners/ifelseif.ts +1 -1
- package/src/evaluator/condition/index.ts +1 -1
- package/src/evaluator/index.ts +1 -1
- package/src/evaluator/parser/index.ts +1 -1
- package/src/evaluator/types.ts +1 -1
- package/src/evaluator/value/index.ts +1 -1
- package/src/evaluator/value/sanitize.ts +1 -1
- package/src/integrations/pluggable.ts +3 -3
- package/src/integrations/types.ts +3 -2
- package/src/listeners/browser.ts +3 -2
- package/src/logger/index.ts +6 -6
- package/src/logger/sdkLogger.ts +4 -4
- package/src/logger/types.ts +11 -13
- package/src/readiness/readinessManager.ts +5 -4
- package/src/readiness/sdkReadinessManager.ts +6 -23
- package/src/readiness/types.ts +5 -4
- package/src/sdkClient/client.ts +5 -6
- package/src/sdkClient/clientAttributesDecoration.ts +10 -10
- package/src/sdkClient/clientCS.ts +5 -5
- package/src/sdkClient/clientInputValidation.ts +2 -1
- package/src/sdkClient/identity.ts +1 -1
- package/src/sdkClient/sdkClient.ts +2 -2
- package/src/sdkClient/sdkClientMethod.ts +1 -1
- package/src/sdkClient/sdkClientMethodCS.ts +3 -3
- package/src/sdkFactory/index.ts +3 -3
- package/src/sdkFactory/types.ts +8 -7
- package/src/sdkManager/index.ts +2 -1
- package/src/services/splitApi.ts +13 -13
- package/src/services/splitHttpClient.ts +2 -2
- package/src/storages/AbstractMySegmentsCacheSync.ts +1 -1
- package/src/storages/AbstractSplitsCacheAsync.ts +1 -4
- package/src/storages/AbstractSplitsCacheSync.ts +1 -4
- package/src/storages/dataLoader.ts +7 -8
- package/src/storages/findLatencyIndex.ts +1 -1
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +1 -6
- package/src/storages/inMemory/AttributesCacheInMemory.ts +11 -11
- package/src/storages/inMemory/EventsCacheInMemory.ts +2 -2
- package/src/storages/inMemory/ImpressionsCacheInMemory.ts +5 -5
- package/src/storages/inMemory/InMemoryStorage.ts +1 -1
- package/src/storages/inMemory/InMemoryStorageCS.ts +1 -1
- package/src/storages/inMemory/UniqueKeysCacheInMemoryCS.ts +0 -5
- package/src/storages/inRedis/EventsCacheInRedis.ts +1 -1
- package/src/storages/inRedis/ImpressionsCacheInRedis.ts +2 -2
- package/src/storages/inRedis/SplitsCacheInRedis.ts +1 -3
- package/src/storages/inRedis/TelemetryCacheInRedis.ts +3 -3
- package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +1 -1
- package/src/storages/pluggable/EventsCachePluggable.ts +2 -2
- package/src/storages/pluggable/ImpressionsCachePluggable.ts +3 -3
- package/src/storages/pluggable/SegmentsCachePluggable.ts +1 -1
- package/src/storages/pluggable/SplitsCachePluggable.ts +3 -3
- package/src/storages/pluggable/TelemetryCachePluggable.ts +3 -3
- package/src/storages/pluggable/UniqueKeysCachePluggable.ts +1 -1
- package/src/storages/pluggable/inMemoryWrapper.ts +1 -1
- package/src/storages/pluggable/index.ts +1 -1
- package/src/storages/pluggable/wrapperAdapter.ts +2 -2
- package/src/storages/types.ts +51 -68
- package/src/storages/utils.ts +3 -2
- package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +3 -3
- package/src/sync/offline/syncManagerOffline.ts +1 -1
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +3 -3
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +8 -8
- package/src/sync/polling/updaters/splitChangesUpdater.ts +13 -13
- package/src/sync/streaming/AuthClient/index.ts +2 -2
- package/src/sync/streaming/SSEClient/index.ts +4 -7
- package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +1 -1
- package/src/sync/streaming/SSEHandler/NotificationParser.ts +5 -4
- package/src/sync/streaming/SSEHandler/index.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +3 -3
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +4 -4
- package/src/sync/streaming/parseUtils.ts +13 -13
- package/src/sync/streaming/types.ts +2 -2
- package/src/sync/submitters/impressionsSubmitter.ts +2 -2
- package/src/sync/submitters/telemetrySubmitter.ts +4 -3
- package/src/sync/submitters/types.ts +1 -1
- package/src/sync/syncManagerOnline.ts +2 -2
- package/src/sync/syncTask.ts +4 -4
- package/src/trackers/eventTracker.ts +4 -3
- package/src/trackers/impressionObserver/ImpressionObserver.ts +4 -4
- package/src/trackers/impressionObserver/buildKey.ts +2 -2
- package/src/trackers/impressionObserver/impressionObserverCS.ts +2 -2
- package/src/trackers/impressionObserver/impressionObserverSS.ts +2 -2
- package/src/trackers/impressionObserver/types.ts +2 -2
- package/src/trackers/impressionsTracker.ts +8 -7
- package/src/trackers/strategy/strategyDebug.ts +3 -3
- package/src/trackers/strategy/strategyNone.ts +4 -4
- package/src/trackers/strategy/strategyOptimized.ts +5 -5
- package/src/trackers/types.ts +5 -5
- package/src/trackers/uniqueKeysTracker.ts +3 -3
- package/src/types.ts +37 -1355
- package/src/utils/Backoff.ts +0 -4
- package/src/utils/MinEventEmitter.ts +2 -3
- package/src/utils/MinEvents.ts +2 -2
- package/src/utils/Semver.ts +1 -1
- package/src/utils/base64/index.ts +2 -2
- package/src/utils/constants/index.ts +9 -10
- package/src/utils/decompress/index.ts +4 -4
- package/src/utils/inputValidation/attributes.ts +1 -1
- package/src/utils/inputValidation/eventProperties.ts +1 -1
- package/src/utils/inputValidation/key.ts +1 -1
- package/src/utils/inputValidation/preloadedData.ts +1 -2
- package/src/utils/inputValidation/trafficTypeExistence.ts +2 -2
- package/src/utils/key/index.ts +1 -1
- package/src/utils/lang/binarySearch.ts +2 -2
- package/src/utils/murmur3/murmur3_128.ts +1 -1
- package/src/utils/murmur3/murmur3_128_x86.ts +1 -1
- package/src/utils/murmur3/murmur3_64.ts +1 -1
- package/src/utils/murmur3/utfx.ts +10 -17
- package/src/utils/promise/wrapper.ts +2 -2
- package/src/utils/settingsValidation/consent.ts +2 -2
- package/src/utils/settingsValidation/impressionsMode.ts +1 -1
- package/src/utils/settingsValidation/index.ts +2 -2
- package/src/utils/settingsValidation/integrations/common.ts +4 -4
- package/src/utils/settingsValidation/integrations/configurable.ts +3 -3
- package/src/utils/settingsValidation/integrations/pluggable.ts +2 -2
- package/src/utils/settingsValidation/logger/builtinLogger.ts +3 -3
- package/src/utils/settingsValidation/logger/commons.ts +3 -3
- package/src/utils/settingsValidation/logger/pluggableLogger.ts +3 -3
- package/src/utils/settingsValidation/splitFilters.ts +9 -12
- package/src/utils/settingsValidation/storage/storageCS.ts +5 -4
- package/src/utils/settingsValidation/url.ts +3 -3
- package/types/splitio.d.ts +1019 -1381
|
@@ -8,10 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* Encodes UTF8 code points to UTF8 bytes.
|
|
11
|
-
* @param
|
|
11
|
+
* @param src - Code points source, either as a function returning the next code point
|
|
12
12
|
* respectively `null` if there are no more code points left or a single numeric code point.
|
|
13
|
-
* @param
|
|
14
|
-
* @expose
|
|
13
|
+
* @param dst - Bytes destination as a function successively called with the next byte
|
|
15
14
|
*/
|
|
16
15
|
function encodeUTF8(src, dst) {
|
|
17
16
|
var cp = null;
|
|
@@ -31,11 +30,10 @@ function encodeUTF8(src, dst) {
|
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
32
|
* Converts UTF16 characters to UTF8 code points.
|
|
34
|
-
* @param
|
|
33
|
+
* @param src - Characters source as a function returning the next char code respectively
|
|
35
34
|
* `null` if there are no more characters left.
|
|
36
|
-
* @param
|
|
35
|
+
* @param dst - Code points destination as a function successively called with each converted code
|
|
37
36
|
* point.
|
|
38
|
-
* @expose
|
|
39
37
|
*/
|
|
40
38
|
function UTF16toUTF8(src, dst) {
|
|
41
39
|
var c1, c2 = null;
|
|
@@ -59,10 +57,9 @@ function UTF16toUTF8(src, dst) {
|
|
|
59
57
|
}
|
|
60
58
|
/**
|
|
61
59
|
* Converts and encodes UTF16 characters to UTF8 bytes.
|
|
62
|
-
* @param
|
|
60
|
+
* @param src - Characters source as a function returning the next char code respectively `null`
|
|
63
61
|
* if there are no more characters left.
|
|
64
|
-
* @param
|
|
65
|
-
* @expose
|
|
62
|
+
* @param dst - Bytes destination as a function successively called with the next byte.
|
|
66
63
|
*/
|
|
67
64
|
export function encodeUTF16toUTF8(src, dst) {
|
|
68
65
|
UTF16toUTF8(src, function (cp) {
|
|
@@ -71,17 +68,14 @@ export function encodeUTF16toUTF8(src, dst) {
|
|
|
71
68
|
}
|
|
72
69
|
/**
|
|
73
70
|
* String.fromCharCode reference for compile time renaming.
|
|
74
|
-
* @type {!function(...[number]):string}
|
|
75
|
-
* @inner
|
|
76
71
|
*/
|
|
77
72
|
var stringFromCharCode = String.fromCharCode;
|
|
78
73
|
/**
|
|
79
74
|
* Creates a source function for a string.
|
|
80
|
-
* @param
|
|
81
|
-
* @returns
|
|
75
|
+
* @param s - String to read from
|
|
76
|
+
* @returns Source function returning the next char code respectively `null` if there are
|
|
82
77
|
* no more characters left.
|
|
83
|
-
* @throws
|
|
84
|
-
* @expose
|
|
78
|
+
* @throws If the argument is invalid
|
|
85
79
|
*/
|
|
86
80
|
export function stringSource(s) {
|
|
87
81
|
if (typeof s !== 'string')
|
|
@@ -93,9 +87,8 @@ export function stringSource(s) {
|
|
|
93
87
|
}
|
|
94
88
|
/**
|
|
95
89
|
* Creates a destination function for a string.
|
|
96
|
-
* @returns
|
|
90
|
+
* @returns Destination function successively called with the next char code.
|
|
97
91
|
* Returns the final string when called without arguments.
|
|
98
|
-
* @expose
|
|
99
92
|
*/
|
|
100
93
|
export function stringDestination() {
|
|
101
94
|
var cs = [], ps = [];
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* - If the wrapped promise is rejected when using native async/await syntax, the `defaultOnRejected` handler is invoked
|
|
12
12
|
* and neither the catch block nor the remaining try block are executed.
|
|
13
13
|
*
|
|
14
|
-
* @param customPromise promise to wrap
|
|
15
|
-
* @param defaultOnRejected default onRejected function
|
|
14
|
+
* @param customPromise - promise to wrap
|
|
15
|
+
* @param defaultOnRejected - default onRejected function
|
|
16
16
|
* @returns a promise that doesn't need to be handled for rejection (except when using async/await syntax) and
|
|
17
17
|
* includes a method named `hasOnFulfilled` that returns true if the promise has attached an onFulfilled handler.
|
|
18
18
|
*/
|
|
@@ -80,8 +80,8 @@ function fromSecondsToMillis(n) {
|
|
|
80
80
|
* Validates the given config and use it to build a settings object.
|
|
81
81
|
* NOTE: it doesn't validate the SDK Key. Call `validateApiKey` or `validateAndTrackApiKey` for that after settings validation.
|
|
82
82
|
*
|
|
83
|
-
* @param config user defined configuration
|
|
84
|
-
* @param validationParams defaults and fields validators used to validate and creates a settings object from a given config
|
|
83
|
+
* @param config - user defined configuration
|
|
84
|
+
* @param validationParams - defaults and fields validators used to validate and creates a settings object from a given config
|
|
85
85
|
*/
|
|
86
86
|
export function settingsValidation(config, validationParams) {
|
|
87
87
|
var defaults = validationParams.defaults, runtime = validationParams.runtime, storage = validationParams.storage, integrations = validationParams.integrations, logger = validationParams.logger, consent = validationParams.consent, flagSpec = validationParams.flagSpec;
|
|
@@ -2,11 +2,11 @@ import { WARN_INTEGRATION_INVALID } from '../../../logger/constants';
|
|
|
2
2
|
/**
|
|
3
3
|
* This function validates `settings.integrations` object
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
5
|
+
* @param settings - config object provided by the user to initialize the sdk
|
|
6
|
+
* @param integrationValidator - filter used to remove invalid integration items
|
|
7
|
+
* @param extraWarning - optional string used to better describe why an item might be invalid
|
|
8
8
|
*
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns array of valid integration items. The array might be empty if `settings` object does not have valid integrations.
|
|
10
10
|
*/
|
|
11
11
|
export function validateIntegrations(settings, integrationValidator, extraWarning) {
|
|
12
12
|
var integrations = settings.integrations, log = settings.log;
|
|
@@ -3,10 +3,10 @@ import { isString } from '../../lang';
|
|
|
3
3
|
/**
|
|
4
4
|
* This function validates `settings.integrations` object that consists of a list of configuration items, used by the isomorphic JS SDK.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
6
|
+
* @param settings - config object provided by the user to initialize the sdk
|
|
7
|
+
* @param validIntegrationTypes - list of integration types to filter from `settings.integrations`
|
|
8
8
|
*
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns array of valid integration items. The array might be empty if `settings` object does not have valid integrations.
|
|
10
10
|
*/
|
|
11
11
|
export function validateConfigurableIntegrations(settings, validIntegrationTypes) {
|
|
12
12
|
if (validIntegrationTypes === void 0) { validIntegrationTypes = []; }
|
|
@@ -2,9 +2,9 @@ import { validateIntegrations } from './common';
|
|
|
2
2
|
/**
|
|
3
3
|
* This function validates `settings.integrations` object that consists of a list of pluggable integration factories.
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
5
|
+
* @param settings - config object provided by the user to initialize the sdk
|
|
6
6
|
*
|
|
7
|
-
* @returns
|
|
7
|
+
* @returns array of valid integration factories. The array might be empty if `settings` object does not have valid integrations.
|
|
8
8
|
*/
|
|
9
9
|
export function validatePluggableIntegrations(settings) {
|
|
10
10
|
return validateIntegrations(settings, function (integration) { return typeof integration === 'function'; }, 'Integration items must be functions that initialize the integrations');
|
|
@@ -28,7 +28,7 @@ else if (isLogLevelString(initialState)) {
|
|
|
28
28
|
/**
|
|
29
29
|
* Validates the `debug` property at config and use it to set the log level.
|
|
30
30
|
*
|
|
31
|
-
* @param settings user config object, with an optional `debug` property of type boolean or string log level.
|
|
31
|
+
* @param settings - user config object, with an optional `debug` property of type boolean or string log level.
|
|
32
32
|
* @returns a logger instance with the log level at `settings.debug`. If `settings.debug` is invalid or not provided, `initialLogLevel` is used.
|
|
33
33
|
*/
|
|
34
34
|
export function validateLogger(settings) {
|
|
@@ -3,7 +3,7 @@ import { LogLevels, isLogLevelString } from '../../../logger';
|
|
|
3
3
|
* Returns the LogLevel for the given debugValue or undefined if it is invalid,
|
|
4
4
|
* i.e., if the debugValue is not a boolean or LogLevel string.
|
|
5
5
|
*
|
|
6
|
-
* @param debugValue debug value at config
|
|
6
|
+
* @param debugValue - debug value at config
|
|
7
7
|
* @returns LogLevel of the given debugValue or undefined if the provided value is invalid
|
|
8
8
|
*/
|
|
9
9
|
export function getLogLevel(debugValue) {
|
|
@@ -8,7 +8,7 @@ var initialLogLevel = LogLevels.NONE;
|
|
|
8
8
|
/**
|
|
9
9
|
* Validates the `debug` property at config and use it to set the logger.
|
|
10
10
|
*
|
|
11
|
-
* @param settings user config object, with an optional `debug` property of type boolean, string log level or a Logger object.
|
|
11
|
+
* @param settings - user config object, with an optional `debug` property of type boolean, string log level or a Logger object.
|
|
12
12
|
* @returns a logger instance, that might be: the provided logger at `settings.debug`, or one with the given `debug` log level,
|
|
13
13
|
* or one with NONE log level if `debug` is not defined or invalid.
|
|
14
14
|
*/
|
|
@@ -33,9 +33,9 @@ function validateFilterType(maybeFilterType) {
|
|
|
33
33
|
/**
|
|
34
34
|
* Validate, deduplicate and sort a given list of filter values.
|
|
35
35
|
*
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
36
|
+
* @param type - filter type string used for log messages
|
|
37
|
+
* @param values - list of values to validate, deduplicate and sort
|
|
38
|
+
* @param maxLength - max length allowed for the list of values
|
|
39
39
|
* @returns list of valid, unique and alphabetically sorted non-empty strings. The list is empty if `values` param is not a non-empty array or all its values are invalid.
|
|
40
40
|
*
|
|
41
41
|
* @throws Error if the sanitized list exceeds the length indicated by `maxLength`
|
|
@@ -64,7 +64,7 @@ function validateSplitFilter(log, type, values, maxLength) {
|
|
|
64
64
|
* - '&prefixes=<comma-separated-values>': if only `byName` filter is undefined
|
|
65
65
|
* - '&names=<comma-separated-values>&prefixes=<comma-separated-values>': if no one is undefined
|
|
66
66
|
*
|
|
67
|
-
* @param
|
|
67
|
+
* @param groupedFilters - object of filters. Each filter must be a list of valid, unique and ordered string values.
|
|
68
68
|
* @returns null or string with the `split filter query` component of the URL.
|
|
69
69
|
*/
|
|
70
70
|
function queryStringBuilder(groupedFilters) {
|
|
@@ -80,15 +80,12 @@ function queryStringBuilder(groupedFilters) {
|
|
|
80
80
|
/**
|
|
81
81
|
* Sanitizes set names list taking into account:
|
|
82
82
|
* - It should be lowercase
|
|
83
|
-
* - Must adhere the following regular expression
|
|
83
|
+
* - Must adhere the following regular expression `/^[a-z0-9][_a-z0-9]{0,49}$/` that means
|
|
84
84
|
* - must start with a letter or number
|
|
85
85
|
* - Be in lowercase
|
|
86
86
|
* - Be alphanumeric
|
|
87
87
|
* - have a max length of 50 characters
|
|
88
88
|
*
|
|
89
|
-
* @param {ILogger} log
|
|
90
|
-
* @param {string[]} flagSets
|
|
91
|
-
* @param {string} method
|
|
92
89
|
* @returns sanitized list of set names
|
|
93
90
|
*/
|
|
94
91
|
function sanitizeFlagSets(log, flagSets, method) {
|
|
@@ -117,9 +114,9 @@ function configuredFilter(validFilters, filterType) {
|
|
|
117
114
|
/**
|
|
118
115
|
* Validates `splitFilters` configuration object and parses it into a query string for filtering splits on `/splitChanges` fetch.
|
|
119
116
|
*
|
|
120
|
-
* @param
|
|
121
|
-
* @param
|
|
122
|
-
* @param
|
|
117
|
+
* @param log - logger
|
|
118
|
+
* @param maybeSplitFilters - split filters configuration param provided by the user
|
|
119
|
+
* @param mode - settings mode
|
|
123
120
|
* @returns it returns an object with the following properties:
|
|
124
121
|
* - `validFilters`: the validated `splitFilters` configuration object defined by the user.
|
|
125
122
|
* - `queryString`: the parsed split filter query. it is null if all filters are invalid or all values in filters are invalid.
|
|
@@ -10,9 +10,9 @@ __InLocalStorageMockFactory.type = STORAGE_MEMORY;
|
|
|
10
10
|
/**
|
|
11
11
|
* This function validates `settings.storage` object
|
|
12
12
|
*
|
|
13
|
-
* @param
|
|
13
|
+
* @param settings - config object provided by the user to initialize the sdk
|
|
14
14
|
*
|
|
15
|
-
* @returns
|
|
15
|
+
* @returns valid storage factory. Default to `InMemoryStorageCSFactory` if the provided storage is invalid or not compatible with the sdk mode if mode is standalone or localhost
|
|
16
16
|
*
|
|
17
17
|
* @throws error if mode is consumer and the provided storage is not compatible
|
|
18
18
|
*/
|
|
@@ -6,9 +6,9 @@ var streamingEndpointMatcher = /^\/(sse|event-stream)/;
|
|
|
6
6
|
* Get URL based on a given target (path).
|
|
7
7
|
* ATM, it is only used for testing purposes.
|
|
8
8
|
*
|
|
9
|
-
* @param settings settings object
|
|
10
|
-
* @param target url path
|
|
11
|
-
* @
|
|
9
|
+
* @param settings - settings object
|
|
10
|
+
* @param target - url path
|
|
11
|
+
* @returns complete url
|
|
12
12
|
*/
|
|
13
13
|
export function url(settings, target) {
|
|
14
14
|
if (telemetryEndpointMatcher.test(target)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splitsoftware/splitio-commons",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.6",
|
|
4
4
|
"description": "Split JavaScript SDK common components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"check": "npm run check:lint && npm run check:types",
|
|
20
|
-
"check:lint": "eslint src --ext .js,.ts",
|
|
20
|
+
"check:lint": "eslint src types --ext .js,.ts",
|
|
21
21
|
"check:types": "tsc --noEmit",
|
|
22
22
|
"build": "npm run build:cjs && npm run build:esm",
|
|
23
23
|
"build:esm": "rimraf esm && tsc -m es2015 --outDir esm",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"eslint": "^8.48.0",
|
|
68
68
|
"eslint-plugin-compat": "^6.0.1",
|
|
69
69
|
"eslint-plugin-import": "^2.25.3",
|
|
70
|
+
"eslint-plugin-tsdoc": "^0.3.0",
|
|
70
71
|
"fetch-mock": "^9.11.0",
|
|
71
72
|
"ioredis": "^4.28.0",
|
|
72
73
|
"jest": "^27.2.3",
|
package/src/dtos/types.ts
CHANGED
package/src/evaluator/Engine.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { thenable } from '../utils/promise/thenable';
|
|
|
5
5
|
import { EXCEPTION, NO_CONDITION_MATCH, SPLIT_ARCHIVED, SPLIT_KILLED } from '../utils/labels';
|
|
6
6
|
import { CONTROL } from '../utils/constants';
|
|
7
7
|
import { ISplit, MaybeThenable } from '../dtos/types';
|
|
8
|
-
import
|
|
8
|
+
import SplitIO from '../../types/splitio';
|
|
9
9
|
import { IStorageAsync, IStorageSync } from '../storages/types';
|
|
10
10
|
import { IEvaluation, IEvaluationResult, IEvaluator, ISplitEvaluator } from './types';
|
|
11
11
|
import { ILogger } from '../logger/types';
|
|
@@ -3,7 +3,7 @@ import { ILogger } from '../../logger/types';
|
|
|
3
3
|
import { thenable } from '../../utils/promise/thenable';
|
|
4
4
|
import { UNSUPPORTED_MATCHER_TYPE } from '../../utils/labels';
|
|
5
5
|
import { CONTROL } from '../../utils/constants';
|
|
6
|
-
import
|
|
6
|
+
import SplitIO from '../../../types/splitio';
|
|
7
7
|
import { IEvaluation, IEvaluator, ISplitEvaluator } from '../types';
|
|
8
8
|
import { ENGINE_COMBINER_IFELSEIF, ENGINE_COMBINER_IFELSEIF_NO_TREATMENT, ERROR_ENGINE_COMBINER_IFELSEIF } from '../../logger/constants';
|
|
9
9
|
|
|
@@ -3,7 +3,7 @@ import { thenable } from '../../utils/promise/thenable';
|
|
|
3
3
|
import { NOT_IN_SPLIT } from '../../utils/labels';
|
|
4
4
|
import { MaybeThenable } from '../../dtos/types';
|
|
5
5
|
import { IEvaluation, IEvaluator, ISplitEvaluator } from '../types';
|
|
6
|
-
import
|
|
6
|
+
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
|
package/src/evaluator/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { CONTROL } from '../utils/constants';
|
|
|
5
5
|
import { ISplit, MaybeThenable } from '../dtos/types';
|
|
6
6
|
import { IStorageAsync, IStorageSync } from '../storages/types';
|
|
7
7
|
import { IEvaluationResult } from './types';
|
|
8
|
-
import
|
|
8
|
+
import SplitIO from '../../types/splitio';
|
|
9
9
|
import { ILogger } from '../logger/types';
|
|
10
10
|
import { returnSetsUnion, setToArray } from '../utils/lang/sets';
|
|
11
11
|
import { WARN_FLAGSET_WITHOUT_FLAGS } from '../logger/constants';
|
|
@@ -9,7 +9,7 @@ import { thenable } from '../../utils/promise/thenable';
|
|
|
9
9
|
import { IEvaluator, IMatcherDto, ISplitEvaluator } from '../types';
|
|
10
10
|
import { ISplitCondition, MaybeThenable } from '../../dtos/types';
|
|
11
11
|
import { IStorageAsync, IStorageSync } from '../../storages/types';
|
|
12
|
-
import
|
|
12
|
+
import SplitIO from '../../../types/splitio';
|
|
13
13
|
import { ILogger } from '../../logger/types';
|
|
14
14
|
import { ENGINE_MATCHER_ERROR, ENGINE_MATCHER_RESULT } from '../../logger/constants';
|
|
15
15
|
|
package/src/evaluator/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IBetweenMatcherData, IBetweenStringMatcherData, IDependencyMatcherData, MaybeThenable } from '../dtos/types';
|
|
2
2
|
import { IStorageAsync, IStorageSync } from '../storages/types';
|
|
3
|
-
import
|
|
3
|
+
import SplitIO from '../../types/splitio';
|
|
4
4
|
import { ILogger } from '../logger/types';
|
|
5
5
|
|
|
6
6
|
export interface IDependencyMatcherValue {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { SPLIT_IMPRESSION, SPLIT_EVENT } from '../utils/constants';
|
|
2
|
-
import
|
|
2
|
+
import SplitIO from '../../types/splitio';
|
|
3
3
|
import { IIntegration, IIntegrationManager, IIntegrationFactoryParams } from './types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Factory function for IntegrationsManager with pluggable integrations.
|
|
7
7
|
* The integrations manager instantiates integration, and bypass tracked events and impressions to them.
|
|
8
8
|
*
|
|
9
|
-
* @param integrations validated list of integration factories
|
|
10
|
-
* @param params information of the Sdk factory instance that integrations can access to
|
|
9
|
+
* @param integrations - validated list of integration factories
|
|
10
|
+
* @param params - information of the Sdk factory instance that integrations can access to
|
|
11
11
|
*
|
|
12
12
|
* @returns integration manager or undefined if `integrations` are not present in settings.
|
|
13
13
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IEventsCacheBase } from '../storages/types';
|
|
2
2
|
import { IEventsHandler, IImpressionsHandler, ITelemetryTracker } from '../trackers/types';
|
|
3
|
-
import { ISettings
|
|
3
|
+
import { ISettings } from '../types';
|
|
4
|
+
import SplitIO from '../../types/splitio';
|
|
4
5
|
|
|
5
6
|
export interface IIntegration {
|
|
6
7
|
queue(data: SplitIO.IntegrationData): void
|
|
@@ -14,7 +15,7 @@ export interface IIntegrationFactoryParams {
|
|
|
14
15
|
telemetryTracker: ITelemetryTracker
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export type IntegrationFactory = {
|
|
18
|
+
export type IntegrationFactory = SplitIO.IntegrationFactory & {
|
|
18
19
|
readonly type: string
|
|
19
20
|
(params: IIntegrationFactoryParams): IIntegration | void
|
|
20
21
|
}
|
package/src/listeners/browser.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { IRecorderCacheSync, IStorageSync } from '../storages/types';
|
|
|
5
5
|
import { fromImpressionsCollector } from '../sync/submitters/impressionsSubmitter';
|
|
6
6
|
import { fromImpressionCountsCollector } from '../sync/submitters/impressionCountsSubmitter';
|
|
7
7
|
import { IResponse, ISplitApi } from '../services/types';
|
|
8
|
-
import {
|
|
8
|
+
import { ISettings } from '../types';
|
|
9
|
+
import SplitIO from '../../types/splitio';
|
|
9
10
|
import { ImpressionsPayload } from '../sync/submitters/types';
|
|
10
11
|
import { OPTIMIZED, DEBUG, NONE } from '../utils/constants';
|
|
11
12
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
@@ -22,7 +23,7 @@ const EVENT_NAME = 'for visibilitychange and pagehide events.';
|
|
|
22
23
|
*/
|
|
23
24
|
export class BrowserSignalListener implements ISignalListener {
|
|
24
25
|
|
|
25
|
-
private fromImpressionsCollector: (data: ImpressionDTO[]) => ImpressionsPayload;
|
|
26
|
+
private fromImpressionsCollector: (data: SplitIO.ImpressionDTO[]) => ImpressionsPayload;
|
|
26
27
|
|
|
27
28
|
constructor(
|
|
28
29
|
private syncManager: ISyncManager | undefined,
|
package/src/logger/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
2
|
import { ILoggerOptions, ILogger } from './types';
|
|
3
3
|
import { find, isObject } from '../utils/lang';
|
|
4
|
-
import
|
|
4
|
+
import SplitIO from '../../types/splitio';
|
|
5
5
|
|
|
6
|
-
export const LogLevels:
|
|
6
|
+
export const LogLevels: SplitIO.ILoggerAPI['LogLevel'] = {
|
|
7
7
|
DEBUG: 'DEBUG',
|
|
8
8
|
INFO: 'INFO',
|
|
9
9
|
WARN: 'WARN',
|
|
@@ -19,7 +19,7 @@ const LogLevelIndexes = {
|
|
|
19
19
|
NONE: 5
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export function isLogLevelString(str: string): str is LogLevel {
|
|
22
|
+
export function isLogLevelString(str: string): str is SplitIO.LogLevel {
|
|
23
23
|
return !!find(LogLevels, (lvl: string) => str === lvl);
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -55,7 +55,7 @@ export class Logger implements ILogger {
|
|
|
55
55
|
this.logLevel = LogLevelIndexes[this.options.logLevel];
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
setLogLevel(logLevel: LogLevel) {
|
|
58
|
+
setLogLevel(logLevel: SplitIO.LogLevel) {
|
|
59
59
|
this.options.logLevel = logLevel;
|
|
60
60
|
this.logLevel = LogLevelIndexes[logLevel];
|
|
61
61
|
}
|
|
@@ -76,7 +76,7 @@ export class Logger implements ILogger {
|
|
|
76
76
|
if (this._shouldLog(LogLevelIndexes.ERROR)) this._log(LogLevels.ERROR, msg, args);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
private _log(level: LogLevel, msg: string | number, args?: any[]) {
|
|
79
|
+
private _log(level: SplitIO.LogLevel, msg: string | number, args?: any[]) {
|
|
80
80
|
if (typeof msg === 'number') {
|
|
81
81
|
const format = this.codes.get(msg);
|
|
82
82
|
msg = format ? _sprintf(format, args) : `Message code ${msg}${args ? ', with args: ' + args.toString() : ''}`;
|
|
@@ -89,7 +89,7 @@ export class Logger implements ILogger {
|
|
|
89
89
|
console.log(formattedText);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
private _generateLogMessage(level: LogLevel, text: string) {
|
|
92
|
+
private _generateLogMessage(level: SplitIO.LogLevel, text: string) {
|
|
93
93
|
const textPre = ' => ';
|
|
94
94
|
let result = '';
|
|
95
95
|
|
package/src/logger/sdkLogger.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { LogLevels, isLogLevelString } from './index';
|
|
2
|
-
import
|
|
2
|
+
import SplitIO from '../../types/splitio';
|
|
3
3
|
import { ILogger } from './types';
|
|
4
4
|
import { ERROR_LOGLEVEL_INVALID } from './constants';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The public Logger utility API exposed via SplitFactory, used to update the log level.
|
|
8
8
|
*
|
|
9
|
-
* @param log the factory logger instance to handle
|
|
9
|
+
* @param log - the factory logger instance to handle
|
|
10
10
|
*/
|
|
11
|
-
export function createLoggerAPI(log: ILogger): ILoggerAPI {
|
|
11
|
+
export function createLoggerAPI(log: ILogger): SplitIO.ILoggerAPI {
|
|
12
12
|
|
|
13
13
|
function setLogLevel(logLevel: string) {
|
|
14
14
|
if (isLogLevelString(logLevel)) {
|
|
@@ -27,7 +27,7 @@ export function createLoggerAPI(log: ILogger): ILoggerAPI {
|
|
|
27
27
|
},
|
|
28
28
|
/**
|
|
29
29
|
* Sets a custom log Level for the SDK.
|
|
30
|
-
* @param
|
|
30
|
+
* @param logLevel - Custom LogLevel value.
|
|
31
31
|
*/
|
|
32
32
|
setLogLevel,
|
|
33
33
|
/**
|
package/src/logger/types.ts
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import SplitIO from '../../types/splitio';
|
|
2
2
|
|
|
3
3
|
export interface ILoggerOptions {
|
|
4
4
|
prefix?: string,
|
|
5
|
-
logLevel?: LogLevel,
|
|
5
|
+
logLevel?: SplitIO.LogLevel,
|
|
6
6
|
showLevel?: boolean, // @TODO remove this param eventually since it is not being set `false` anymore
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export interface ILogger {
|
|
10
|
-
|
|
9
|
+
export interface ILogger extends SplitIO.ILogger {
|
|
10
|
+
debug(msg: any): void;
|
|
11
|
+
debug(msg: string | number, args?: any[]): void;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
info(msg: any): void;
|
|
14
|
+
info(msg: string | number, args?: any[]): void;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
warn(msg: any): void;
|
|
17
|
+
warn(msg: string | number, args?: any[]): void;
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
error(msg: any): void
|
|
22
|
-
error(msg: string | number, args?: any[]): void
|
|
19
|
+
error(msg: any): void;
|
|
20
|
+
error(msg: string | number, args?: any[]): void;
|
|
23
21
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
|
-
import {
|
|
2
|
+
import { ISettings } from '../types';
|
|
3
|
+
import SplitIO from '../../types/splitio';
|
|
3
4
|
import { SDK_SPLITS_ARRIVED, SDK_SPLITS_CACHE_LOADED, SDK_SEGMENTS_ARRIVED, SDK_READY_TIMED_OUT, SDK_READY_FROM_CACHE, SDK_UPDATE, SDK_READY } from './constants';
|
|
4
5
|
import { IReadinessEventEmitter, IReadinessManager, ISegmentsEventEmitter, ISplitsEventEmitter } from './types';
|
|
5
6
|
|
|
6
|
-
function splitsEventEmitterFactory(EventEmitter: new () => IEventEmitter): ISplitsEventEmitter {
|
|
7
|
+
function splitsEventEmitterFactory(EventEmitter: new () => SplitIO.IEventEmitter): ISplitsEventEmitter {
|
|
7
8
|
const splitsEventEmitter = objectAssign(new EventEmitter(), {
|
|
8
9
|
splitsArrived: false,
|
|
9
10
|
splitsCacheLoaded: false,
|
|
@@ -20,7 +21,7 @@ function splitsEventEmitterFactory(EventEmitter: new () => IEventEmitter): ISpli
|
|
|
20
21
|
return splitsEventEmitter;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
function segmentsEventEmitterFactory(EventEmitter: new () => IEventEmitter): ISegmentsEventEmitter {
|
|
24
|
+
function segmentsEventEmitterFactory(EventEmitter: new () => SplitIO.IEventEmitter): ISegmentsEventEmitter {
|
|
24
25
|
const segmentsEventEmitter = objectAssign(new EventEmitter(), {
|
|
25
26
|
segmentsArrived: false
|
|
26
27
|
});
|
|
@@ -34,7 +35,7 @@ function segmentsEventEmitterFactory(EventEmitter: new () => IEventEmitter): ISe
|
|
|
34
35
|
* Factory of readiness manager, which handles the ready / update event propagation.
|
|
35
36
|
*/
|
|
36
37
|
export function readinessManagerFactory(
|
|
37
|
-
EventEmitter: new () => IEventEmitter,
|
|
38
|
+
EventEmitter: new () => SplitIO.IEventEmitter,
|
|
38
39
|
settings: ISettings,
|
|
39
40
|
splits: ISplitsEventEmitter = splitsEventEmitterFactory(EventEmitter)): IReadinessManager {
|
|
40
41
|
|
|
@@ -2,7 +2,8 @@ import { objectAssign } from '../utils/lang/objectAssign';
|
|
|
2
2
|
import { promiseWrapper } from '../utils/promise/wrapper';
|
|
3
3
|
import { readinessManagerFactory } from './readinessManager';
|
|
4
4
|
import { ISdkReadinessManager } from './types';
|
|
5
|
-
import {
|
|
5
|
+
import { ISettings } from '../types';
|
|
6
|
+
import SplitIO from '../../types/splitio';
|
|
6
7
|
import { SDK_READY, SDK_READY_TIMED_OUT, SDK_READY_FROM_CACHE, SDK_UPDATE } from './constants';
|
|
7
8
|
import { ERROR_CLIENT_LISTENER, CLIENT_READY_FROM_CACHE, CLIENT_READY, CLIENT_NO_LISTENER } from '../logger/constants';
|
|
8
9
|
|
|
@@ -13,11 +14,11 @@ const REMOVE_LISTENER_EVENT = 'removeListener';
|
|
|
13
14
|
* SdkReadinessManager factory, which provides the public status API of SDK clients and manager: ready promise, readiness event emitter and constants (SDK_READY, etc).
|
|
14
15
|
* It also updates logs related warnings and errors.
|
|
15
16
|
*
|
|
16
|
-
* @param readyTimeout time in millis to emit SDK_READY_TIME_OUT event
|
|
17
|
-
* @param readinessManager optional readinessManager to use. only used internally for `shared` method
|
|
17
|
+
* @param readyTimeout - time in millis to emit SDK_READY_TIME_OUT event
|
|
18
|
+
* @param readinessManager - optional readinessManager to use. only used internally for `shared` method
|
|
18
19
|
*/
|
|
19
20
|
export function sdkReadinessManagerFactory(
|
|
20
|
-
EventEmitter: new () => IEventEmitter,
|
|
21
|
+
EventEmitter: new () => SplitIO.IEventEmitter,
|
|
21
22
|
settings: ISettings,
|
|
22
23
|
readinessManager = readinessManagerFactory(EventEmitter, settings)): ISdkReadinessManager {
|
|
23
24
|
|
|
@@ -91,25 +92,7 @@ export function sdkReadinessManagerFactory(
|
|
|
91
92
|
SDK_UPDATE,
|
|
92
93
|
SDK_READY_TIMED_OUT,
|
|
93
94
|
},
|
|
94
|
-
|
|
95
|
-
* Returns a promise that will be resolved once the SDK has finished loading (SDK_READY event emitted) or rejected if the SDK has timedout (SDK_READY_TIMED_OUT event emitted).
|
|
96
|
-
* As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, calling the `ready` method after the
|
|
97
|
-
* SDK had timed out will return a new promise that should eventually resolve if the SDK gets ready.
|
|
98
|
-
*
|
|
99
|
-
* Caveats: the method was designed to avoid an unhandled Promise rejection if the rejection case is not handled, so that `onRejected` handler is optional when using promises.
|
|
100
|
-
* However, when using async/await syntax, the rejection should be explicitly propagated like in the following example:
|
|
101
|
-
* ```
|
|
102
|
-
* try {
|
|
103
|
-
* await client.ready().catch((e) => { throw e; });
|
|
104
|
-
* // SDK is ready
|
|
105
|
-
* } catch(e) {
|
|
106
|
-
* // SDK has timedout
|
|
107
|
-
* }
|
|
108
|
-
* ```
|
|
109
|
-
*
|
|
110
|
-
* @function ready
|
|
111
|
-
* @returns {Promise<void>}
|
|
112
|
-
*/
|
|
95
|
+
|
|
113
96
|
ready() {
|
|
114
97
|
if (readinessManager.hasTimedout()) {
|
|
115
98
|
if (!readinessManager.isReady()) {
|