@splitsoftware/splitio-commons 2.0.0-rc.4 → 2.0.0-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 +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 +1 -1
- 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 +1 -1
- 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 +7 -8
- package/src/sdkClient/clientAttributesDecoration.ts +11 -11
- package/src/sdkClient/clientCS.ts +5 -5
- package/src/sdkClient/clientInputValidation.ts +3 -2
- package/src/sdkClient/identity.ts +1 -1
- package/src/sdkClient/sdkClient.ts +3 -3
- package/src/sdkClient/sdkClientMethod.ts +2 -2
- package/src/sdkClient/sdkClientMethodCS.ts +5 -5
- package/src/sdkFactory/index.ts +3 -3
- package/src/sdkFactory/types.ts +7 -6
- 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 +1 -1
- 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 +885 -1237
package/src/utils/Backoff.ts
CHANGED
|
@@ -15,10 +15,6 @@ export class Backoff {
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Schedule function calls with exponential backoff
|
|
18
|
-
*
|
|
19
|
-
* @param {function} cb
|
|
20
|
-
* @param {number} baseMillis
|
|
21
|
-
* @param {number} maxMillis
|
|
22
18
|
*/
|
|
23
19
|
constructor(cb: (...args: any[]) => any, baseMillis?: number, maxMillis?: number) {
|
|
24
20
|
this.baseMillis = Backoff.__TEST__BASE_MILLIS || baseMillis || Backoff.DEFAULT_BASE_MILLIS;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { IEventEmitter } from '../types';
|
|
1
|
+
import SplitIO from '../../types/splitio';
|
|
3
2
|
|
|
4
3
|
const NEW_LISTENER_EVENT = 'newListener';
|
|
5
4
|
const REMOVE_LISTENER_EVENT = 'removeListener';
|
|
@@ -11,7 +10,7 @@ function checkListener(listener: unknown) {
|
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
// @TODO implement missing methods, check spec and add UTs
|
|
14
|
-
export class EventEmitter implements IEventEmitter {
|
|
13
|
+
export class EventEmitter implements SplitIO.IEventEmitter {
|
|
15
14
|
|
|
16
15
|
private listeners: Record<string, Array<[
|
|
17
16
|
(...args: any[]) => void, // the event listener
|
package/src/utils/MinEvents.ts
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
31
31
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
32
32
|
|
|
33
|
-
import
|
|
33
|
+
import SplitIO from '../../types/splitio';
|
|
34
34
|
|
|
35
35
|
var R = typeof Reflect === 'object' ? Reflect : null;
|
|
36
36
|
var ReflectApply = R && typeof R.apply === 'function'
|
|
@@ -39,7 +39,7 @@ var ReflectApply = R && typeof R.apply === 'function'
|
|
|
39
39
|
return Function.prototype.apply.call(target, receiver, args);
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
export const EventEmitter: { new(): IEventEmitter } = function EventEmitter() {
|
|
42
|
+
export const EventEmitter: { new(): SplitIO.IEventEmitter } = function EventEmitter() {
|
|
43
43
|
EventEmitter.init.call(this);
|
|
44
44
|
};
|
|
45
45
|
|
package/src/utils/Semver.ts
CHANGED
|
@@ -84,7 +84,7 @@ export class Semver {
|
|
|
84
84
|
/**
|
|
85
85
|
* Precedence comparision between 2 Semver objects.
|
|
86
86
|
*
|
|
87
|
-
* @
|
|
87
|
+
* @returns `0` if `this === toCompare`, `-1` if `this < toCompare`, and `1` if `this > toCompare`
|
|
88
88
|
*/
|
|
89
89
|
public compare(toCompare: Semver): number {
|
|
90
90
|
if (this.version === toCompare.version) return 0;
|
|
@@ -22,7 +22,7 @@ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
|
22
22
|
/**
|
|
23
23
|
* Decode a given string value in Base64 format
|
|
24
24
|
*
|
|
25
|
-
* @param
|
|
25
|
+
* @param input - value to decode
|
|
26
26
|
*/
|
|
27
27
|
export function decodeFromBase64(input: string): string {
|
|
28
28
|
const str = (String(input)).replace(/[=]+$/, ''); // #31: ExtendScript bad parse of /=
|
|
@@ -48,7 +48,7 @@ export function decodeFromBase64(input: string): string {
|
|
|
48
48
|
/**
|
|
49
49
|
* Encode a given string value to Base64 format.
|
|
50
50
|
*
|
|
51
|
-
* @param
|
|
51
|
+
* @param input - value to encode
|
|
52
52
|
*/
|
|
53
53
|
export function encodeToBase64(input: string): string {
|
|
54
54
|
const str = String(input);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { SDKMode } from '../../types';
|
|
1
|
+
import SplitIO from '../../../types/splitio';
|
|
3
2
|
|
|
4
3
|
// Special treatments
|
|
5
4
|
export const CONTROL = 'control';
|
|
@@ -22,17 +21,17 @@ export const OPTIMIZED = 'OPTIMIZED';
|
|
|
22
21
|
export const NONE = 'NONE';
|
|
23
22
|
|
|
24
23
|
// SDK Modes
|
|
25
|
-
export const LOCALHOST_MODE
|
|
26
|
-
export const STANDALONE_MODE
|
|
24
|
+
export const LOCALHOST_MODE = 'localhost';
|
|
25
|
+
export const STANDALONE_MODE = 'standalone';
|
|
27
26
|
export const PRODUCER_MODE = 'producer';
|
|
28
|
-
export const CONSUMER_MODE
|
|
29
|
-
export const CONSUMER_PARTIAL_MODE
|
|
27
|
+
export const CONSUMER_MODE = 'consumer';
|
|
28
|
+
export const CONSUMER_PARTIAL_MODE = 'consumer_partial';
|
|
30
29
|
|
|
31
30
|
// Storage types
|
|
32
|
-
export const STORAGE_MEMORY: StorageType = 'MEMORY';
|
|
33
|
-
export const STORAGE_LOCALSTORAGE: StorageType = 'LOCALSTORAGE';
|
|
34
|
-
export const STORAGE_REDIS: StorageType = 'REDIS';
|
|
35
|
-
export const STORAGE_PLUGGABLE: StorageType = 'PLUGGABLE';
|
|
31
|
+
export const STORAGE_MEMORY: SplitIO.StorageType = 'MEMORY';
|
|
32
|
+
export const STORAGE_LOCALSTORAGE: SplitIO.StorageType = 'LOCALSTORAGE';
|
|
33
|
+
export const STORAGE_REDIS: SplitIO.StorageType = 'REDIS';
|
|
34
|
+
export const STORAGE_PLUGGABLE: SplitIO.StorageType = 'PLUGGABLE';
|
|
36
35
|
|
|
37
36
|
// User consent
|
|
38
37
|
export const CONSENT_GRANTED = 'GRANTED'; // The user has granted consent for tracking events and impressions
|
|
@@ -409,8 +409,8 @@ export const algorithms = (function iifeDecompress() {
|
|
|
409
409
|
return {
|
|
410
410
|
/**
|
|
411
411
|
* Expands GZIP data
|
|
412
|
-
* @param data The data to decompress
|
|
413
|
-
* @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.
|
|
412
|
+
* @param data - The data to decompress
|
|
413
|
+
* @param out - Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.
|
|
414
414
|
* @returns The decompressed version of the data
|
|
415
415
|
*/
|
|
416
416
|
gunzipSync(data: Uint8Array, out?: Uint8Array): Uint8Array {
|
|
@@ -418,8 +418,8 @@ export const algorithms = (function iifeDecompress() {
|
|
|
418
418
|
},
|
|
419
419
|
/**
|
|
420
420
|
* Expands Zlib data
|
|
421
|
-
* @param data The data to decompress
|
|
422
|
-
* @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
|
|
421
|
+
* @param data - The data to decompress
|
|
422
|
+
* @param out - Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
|
|
423
423
|
* @returns The decompressed version of the data
|
|
424
424
|
*/
|
|
425
425
|
unzlibSync(data: Uint8Array, out?: Uint8Array): Uint8Array {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isObject } from '../lang';
|
|
2
|
-
import
|
|
2
|
+
import SplitIO from '../../../types/splitio';
|
|
3
3
|
import { ILogger } from '../../logger/types';
|
|
4
4
|
import { validateAttribute } from './attribute';
|
|
5
5
|
import { ERROR_NOT_PLAIN_OBJECT } from '../../logger/constants';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isObject, isString, isFiniteNumber, isBoolean } from '../lang';
|
|
2
2
|
import { objectAssign } from '../lang/objectAssign';
|
|
3
|
-
import
|
|
3
|
+
import SplitIO from '../../../types/splitio';
|
|
4
4
|
import { ILogger } from '../../logger/types';
|
|
5
5
|
import { ERROR_NOT_PLAIN_OBJECT, ERROR_SIZE_EXCEEDED, WARN_SETTING_NULL, WARN_TRIMMING_PROPERTIES } from '../../logger/constants';
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isObject, isString, isFiniteNumber, toString } from '../lang';
|
|
2
|
-
import
|
|
2
|
+
import SplitIO from '../../../types/splitio';
|
|
3
3
|
import { ILogger } from '../../logger/types';
|
|
4
4
|
import { ERROR_NULL, WARN_CONVERTING, ERROR_EMPTY, ERROR_TOO_LONG, ERROR_INVALID, ERROR_INVALID_KEY_OBJECT } from '../../logger/constants';
|
|
5
5
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isObject, isString, isFiniteNumber } from '../lang';
|
|
2
2
|
import { validateSplit } from './split';
|
|
3
|
-
import { SplitIO } from '../../types';
|
|
4
3
|
import { ILogger } from '../../logger/types';
|
|
5
4
|
|
|
6
5
|
function validateTimestampData(log: ILogger, maybeTimestamp: any, method: string, item: string) {
|
|
@@ -42,7 +41,7 @@ function validateSegmentsData(log: ILogger, maybeSegmentsData: any, method: stri
|
|
|
42
41
|
return false;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
export function validatePreloadedData(log: ILogger, maybePreloadedData: any, method: string)
|
|
44
|
+
export function validatePreloadedData(log: ILogger, maybePreloadedData: any, method: string) {
|
|
46
45
|
if (!isObject(maybePreloadedData)) {
|
|
47
46
|
log.error(`${method}: preloadedData must be an object.`);
|
|
48
47
|
} else if (
|
|
@@ -2,7 +2,7 @@ import { thenable } from '../promise/thenable';
|
|
|
2
2
|
import { LOCALHOST_MODE } from '../constants';
|
|
3
3
|
import { ISplitsCacheBase } from '../../storages/types';
|
|
4
4
|
import { IReadinessManager } from '../../readiness/types';
|
|
5
|
-
import
|
|
5
|
+
import SplitIO from '../../../types/splitio';
|
|
6
6
|
import { MaybeThenable } from '../../dtos/types';
|
|
7
7
|
import { ILogger } from '../../logger/types';
|
|
8
8
|
import { WARN_NOT_EXISTENT_TT } from '../../logger/constants';
|
|
@@ -14,7 +14,7 @@ function logTTExistenceWarning(log: ILogger, maybeTT: string, method: string) {
|
|
|
14
14
|
/**
|
|
15
15
|
* Separated from the previous method since on some cases it'll be async.
|
|
16
16
|
*/
|
|
17
|
-
export function validateTrafficTypeExistence(log: ILogger, readinessManager: IReadinessManager, splitsCache: ISplitsCacheBase, mode: SDKMode, maybeTT: string, method: string): MaybeThenable<boolean> {
|
|
17
|
+
export function validateTrafficTypeExistence(log: ILogger, readinessManager: IReadinessManager, splitsCache: ISplitsCacheBase, mode: SplitIO.SDKMode, maybeTT: string, method: string): MaybeThenable<boolean> {
|
|
18
18
|
|
|
19
19
|
// If not ready or in localhost mode, we won't run the validation
|
|
20
20
|
if (!readinessManager.isReady() || mode === LOCALHOST_MODE) return true;
|
package/src/utils/key/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Searches the index of the specified `value` inside an ordered array of `items` using the binary search algorithm.
|
|
3
3
|
*
|
|
4
|
-
* @param items the array to be searched
|
|
5
|
-
* @param value the value to be searched for
|
|
4
|
+
* @param items - the array to be searched
|
|
5
|
+
* @param value - the value to be searched for
|
|
6
6
|
* @returns integer number between 0 and `items.length`. This value is the index of the search value,
|
|
7
7
|
* if it is contained in the array, or the index at which the value should be inserted to keep the array ordered.
|
|
8
8
|
*/
|
|
@@ -266,7 +266,7 @@ function hash128x64(key?: string, seed?: number) {
|
|
|
266
266
|
/**
|
|
267
267
|
* x64 version of Murmur3 for 128bits.
|
|
268
268
|
*
|
|
269
|
-
* @param
|
|
269
|
+
* @param str - The string to hash.
|
|
270
270
|
*/
|
|
271
271
|
export function hash128(str: string, seed?: number): string {
|
|
272
272
|
return hash128x64(UTF16ToUTF8(str), (seed as number) >>> 0);
|
|
@@ -181,7 +181,7 @@ function hash128x86(key?: string, seed?: number): string {
|
|
|
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
|
-
* @param
|
|
184
|
+
* @param str - The string to hash.
|
|
185
185
|
*/
|
|
186
186
|
export function hash128(str: string, seed?: number): string {
|
|
187
187
|
return hash128x86(UTF16ToUTF8(str), (seed as number) >>> 0);
|
|
@@ -25,7 +25,7 @@ function hex2dec(s: string): string {
|
|
|
25
25
|
/**
|
|
26
26
|
* Gets the higher 64 bits of the x64 version of Murmur3 for 128bits, as decimal and hexadecimal number strings.
|
|
27
27
|
* Used for MySegments channel V2 notifications.
|
|
28
|
-
* @param
|
|
28
|
+
* @param str - The string to hash
|
|
29
29
|
*/
|
|
30
30
|
export function hash64(str: string): Hash64 {
|
|
31
31
|
const hex = hash128(str).slice(0, 16);
|
|
@@ -14,10 +14,9 @@ export interface utfx {
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Encodes UTF8 code points to UTF8 bytes.
|
|
17
|
-
* @param
|
|
17
|
+
* @param src - Code points source, either as a function returning the next code point
|
|
18
18
|
* respectively `null` if there are no more code points left or a single numeric code point.
|
|
19
|
-
* @param
|
|
20
|
-
* @expose
|
|
19
|
+
* @param dst - Bytes destination as a function successively called with the next byte
|
|
21
20
|
*/
|
|
22
21
|
function encodeUTF8(src: (() => number | null) | number, dst: (cp: number) => void): void {
|
|
23
22
|
var cp = null;
|
|
@@ -38,11 +37,10 @@ function encodeUTF8(src: (() => number | null) | number, dst: (cp: number) => vo
|
|
|
38
37
|
|
|
39
38
|
/**
|
|
40
39
|
* Converts UTF16 characters to UTF8 code points.
|
|
41
|
-
* @param
|
|
40
|
+
* @param src - Characters source as a function returning the next char code respectively
|
|
42
41
|
* `null` if there are no more characters left.
|
|
43
|
-
* @param
|
|
42
|
+
* @param dst - Code points destination as a function successively called with each converted code
|
|
44
43
|
* point.
|
|
45
|
-
* @expose
|
|
46
44
|
*/
|
|
47
45
|
function UTF16toUTF8(src: () => number | null, dst: (cp: number) => void): void {
|
|
48
46
|
var c1, c2 = null;
|
|
@@ -65,10 +63,9 @@ function UTF16toUTF8(src: () => number | null, dst: (cp: number) => void): void
|
|
|
65
63
|
|
|
66
64
|
/**
|
|
67
65
|
* Converts and encodes UTF16 characters to UTF8 bytes.
|
|
68
|
-
* @param
|
|
66
|
+
* @param src - Characters source as a function returning the next char code respectively `null`
|
|
69
67
|
* if there are no more characters left.
|
|
70
|
-
* @param
|
|
71
|
-
* @expose
|
|
68
|
+
* @param dst - Bytes destination as a function successively called with the next byte.
|
|
72
69
|
*/
|
|
73
70
|
export function encodeUTF16toUTF8(src: () => number | null, dst: (...args: number[]) => string | undefined): void {
|
|
74
71
|
UTF16toUTF8(src, function (cp) {
|
|
@@ -78,18 +75,15 @@ export function encodeUTF16toUTF8(src: () => number | null, dst: (...args: numbe
|
|
|
78
75
|
|
|
79
76
|
/**
|
|
80
77
|
* String.fromCharCode reference for compile time renaming.
|
|
81
|
-
* @type {!function(...[number]):string}
|
|
82
|
-
* @inner
|
|
83
78
|
*/
|
|
84
79
|
var stringFromCharCode = String.fromCharCode;
|
|
85
80
|
|
|
86
81
|
/**
|
|
87
82
|
* Creates a source function for a string.
|
|
88
|
-
* @param
|
|
89
|
-
* @returns
|
|
83
|
+
* @param s - String to read from
|
|
84
|
+
* @returns Source function returning the next char code respectively `null` if there are
|
|
90
85
|
* no more characters left.
|
|
91
|
-
* @throws
|
|
92
|
-
* @expose
|
|
86
|
+
* @throws If the argument is invalid
|
|
93
87
|
*/
|
|
94
88
|
export function stringSource(s: string): () => number | null {
|
|
95
89
|
if (typeof s !== 'string')
|
|
@@ -101,9 +95,8 @@ export function stringSource(s: string): () => number | null {
|
|
|
101
95
|
|
|
102
96
|
/**
|
|
103
97
|
* Creates a destination function for a string.
|
|
104
|
-
* @returns
|
|
98
|
+
* @returns Destination function successively called with the next char code.
|
|
105
99
|
* Returns the final string when called without arguments.
|
|
106
|
-
* @expose
|
|
107
100
|
*/
|
|
108
101
|
export function stringDestination(): (...args: number[]) => string | undefined {
|
|
109
102
|
const cs: number[] = [], ps: string[] = []; return function () {
|
|
@@ -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
|
*/
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ERROR_INVALID_CONFIG_PARAM } from '../../logger/constants';
|
|
2
2
|
import { ILogger } from '../../logger/types';
|
|
3
|
-
import
|
|
3
|
+
import SplitIO from '../../../types/splitio';
|
|
4
4
|
import { CONSENT_DECLINED, CONSENT_GRANTED, CONSENT_UNKNOWN } from '../constants';
|
|
5
5
|
import { stringToUpperCase } from '../lang';
|
|
6
6
|
|
|
7
7
|
const userConsentValues = [CONSENT_DECLINED, CONSENT_GRANTED, CONSENT_UNKNOWN];
|
|
8
8
|
|
|
9
|
-
export function validateConsent({ userConsent, log }: { userConsent?: any, log: ILogger }): ConsentStatus {
|
|
9
|
+
export function validateConsent({ userConsent, log }: { userConsent?: any, log: ILogger }): SplitIO.ConsentStatus {
|
|
10
10
|
userConsent = stringToUpperCase(userConsent);
|
|
11
11
|
|
|
12
12
|
if (userConsentValues.indexOf(userConsent) > -1) return userConsent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ERROR_INVALID_CONFIG_PARAM } from '../../logger/constants';
|
|
2
2
|
import { ILogger } from '../../logger/types';
|
|
3
|
-
import
|
|
3
|
+
import SplitIO from '../../../types/splitio';
|
|
4
4
|
import { DEBUG, OPTIMIZED, NONE } from '../constants';
|
|
5
5
|
import { stringToUpperCase } from '../lang';
|
|
6
6
|
|
|
@@ -96,8 +96,8 @@ function fromSecondsToMillis(n: number) {
|
|
|
96
96
|
* Validates the given config and use it to build a settings object.
|
|
97
97
|
* NOTE: it doesn't validate the SDK Key. Call `validateApiKey` or `validateAndTrackApiKey` for that after settings validation.
|
|
98
98
|
*
|
|
99
|
-
* @param config user defined configuration
|
|
100
|
-
* @param validationParams defaults and fields validators used to validate and creates a settings object from a given config
|
|
99
|
+
* @param config - user defined configuration
|
|
100
|
+
* @param validationParams - defaults and fields validators used to validate and creates a settings object from a given config
|
|
101
101
|
*/
|
|
102
102
|
export function settingsValidation(config: unknown, validationParams: ISettingsValidationParams) {
|
|
103
103
|
|
|
@@ -4,11 +4,11 @@ import { ILogger } from '../../../logger/types';
|
|
|
4
4
|
/**
|
|
5
5
|
* This function validates `settings.integrations` object
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
7
|
+
* @param settings - config object provided by the user to initialize the sdk
|
|
8
|
+
* @param integrationValidator - filter used to remove invalid integration items
|
|
9
|
+
* @param extraWarning - optional string used to better describe why an item might be invalid
|
|
10
10
|
*
|
|
11
|
-
* @returns
|
|
11
|
+
* @returns array of valid integration items. The array might be empty if `settings` object does not have valid integrations.
|
|
12
12
|
*/
|
|
13
13
|
export function validateIntegrations(settings: { log: ILogger, integrations?: any }, integrationValidator: (integrationItem: any) => boolean, extraWarning?: string) {
|
|
14
14
|
const { integrations, log } = settings;
|
|
@@ -5,10 +5,10 @@ import { ILogger } from '../../../logger/types';
|
|
|
5
5
|
/**
|
|
6
6
|
* This function validates `settings.integrations` object that consists of a list of configuration items, used by the isomorphic JS SDK.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
8
|
+
* @param settings - config object provided by the user to initialize the sdk
|
|
9
|
+
* @param validIntegrationTypes - list of integration types to filter from `settings.integrations`
|
|
10
10
|
*
|
|
11
|
-
* @returns
|
|
11
|
+
* @returns array of valid integration items. The array might be empty if `settings` object does not have valid integrations.
|
|
12
12
|
*/
|
|
13
13
|
export function validateConfigurableIntegrations(settings: { log: ILogger, integrations?: any }, validIntegrationTypes: string[] = []) {
|
|
14
14
|
|
|
@@ -5,9 +5,9 @@ import { ILogger } from '../../../logger/types';
|
|
|
5
5
|
/**
|
|
6
6
|
* This function validates `settings.integrations` object that consists of a list of pluggable integration factories.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
8
|
+
* @param settings - config object provided by the user to initialize the sdk
|
|
9
9
|
*
|
|
10
|
-
* @returns
|
|
10
|
+
* @returns array of valid integration factories. The array might be empty if `settings` object does not have valid integrations.
|
|
11
11
|
*/
|
|
12
12
|
export function validatePluggableIntegrations(settings: { log: ILogger, integrations?: any }): ISettings['integrations'] {
|
|
13
13
|
|
|
@@ -4,7 +4,7 @@ import { isLocalStorageAvailable } from '../../env/isLocalStorageAvailable';
|
|
|
4
4
|
import { isNode } from '../../env/isNode';
|
|
5
5
|
import { codesDebug } from '../../../logger/messages/debug';
|
|
6
6
|
import { getLogLevel } from './commons';
|
|
7
|
-
import
|
|
7
|
+
import SplitIO from '../../../../types/splitio';
|
|
8
8
|
|
|
9
9
|
const allCodes = new Map(codesDebug);
|
|
10
10
|
|
|
@@ -37,13 +37,13 @@ if (/^(enabled?|on)/i.test(initialState)) {
|
|
|
37
37
|
/**
|
|
38
38
|
* Validates the `debug` property at config and use it to set the log level.
|
|
39
39
|
*
|
|
40
|
-
* @param settings user config object, with an optional `debug` property of type boolean or string log level.
|
|
40
|
+
* @param settings - user config object, with an optional `debug` property of type boolean or string log level.
|
|
41
41
|
* @returns a logger instance with the log level at `settings.debug`. If `settings.debug` is invalid or not provided, `initialLogLevel` is used.
|
|
42
42
|
*/
|
|
43
43
|
export function validateLogger(settings: { debug: unknown }): ILogger {
|
|
44
44
|
const { debug } = settings;
|
|
45
45
|
|
|
46
|
-
const logLevel: LogLevel | undefined = debug !== undefined ? getLogLevel(debug) : initialLogLevel;
|
|
46
|
+
const logLevel: SplitIO.LogLevel | undefined = debug !== undefined ? getLogLevel(debug) : initialLogLevel;
|
|
47
47
|
|
|
48
48
|
const log = new Logger({ logLevel: logLevel || initialLogLevel }, allCodes);
|
|
49
49
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import { LogLevels, isLogLevelString } from '../../../logger';
|
|
3
|
-
import
|
|
3
|
+
import SplitIO from '../../../../types/splitio';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns the LogLevel for the given debugValue or undefined if it is invalid,
|
|
7
7
|
* i.e., if the debugValue is not a boolean or LogLevel string.
|
|
8
8
|
*
|
|
9
|
-
* @param debugValue debug value at config
|
|
9
|
+
* @param debugValue - debug value at config
|
|
10
10
|
* @returns LogLevel of the given debugValue or undefined if the provided value is invalid
|
|
11
11
|
*/
|
|
12
|
-
export function getLogLevel(debugValue: unknown): LogLevel | undefined {
|
|
12
|
+
export function getLogLevel(debugValue: unknown): SplitIO.LogLevel | undefined {
|
|
13
13
|
if (typeof debugValue === 'boolean') {
|
|
14
14
|
if (debugValue) {
|
|
15
15
|
return LogLevels.DEBUG;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Logger, LogLevels } from '../../../logger';
|
|
2
2
|
import { ILogger } from '../../../logger/types';
|
|
3
|
-
import
|
|
3
|
+
import SplitIO from '../../../../types/splitio';
|
|
4
4
|
import { getLogLevel } from './commons';
|
|
5
5
|
|
|
6
6
|
function isLogger(log: any): log is ILogger {
|
|
@@ -13,13 +13,13 @@ let initialLogLevel = LogLevels.NONE;
|
|
|
13
13
|
/**
|
|
14
14
|
* Validates the `debug` property at config and use it to set the logger.
|
|
15
15
|
*
|
|
16
|
-
* @param settings user config object, with an optional `debug` property of type boolean, string log level or a Logger object.
|
|
16
|
+
* @param settings - user config object, with an optional `debug` property of type boolean, string log level or a Logger object.
|
|
17
17
|
* @returns a logger instance, that might be: the provided logger at `settings.debug`, or one with the given `debug` log level,
|
|
18
18
|
* or one with NONE log level if `debug` is not defined or invalid.
|
|
19
19
|
*/
|
|
20
20
|
export function validateLogger(settings: { debug: unknown }): ILogger {
|
|
21
21
|
const { debug } = settings;
|
|
22
|
-
let logLevel: LogLevel | undefined = initialLogLevel;
|
|
22
|
+
let logLevel: SplitIO.LogLevel | undefined = initialLogLevel;
|
|
23
23
|
|
|
24
24
|
if (debug !== undefined) {
|
|
25
25
|
if (isLogger(debug)) return debug;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { validateSplits } from '../inputValidation/splits';
|
|
2
2
|
import { ISplitFiltersValidation } from '../../dtos/types';
|
|
3
|
-
import
|
|
3
|
+
import SplitIO from '../../../types/splitio';
|
|
4
4
|
import { ILogger } from '../../logger/types';
|
|
5
5
|
import { WARN_SPLITS_FILTER_IGNORED, WARN_SPLITS_FILTER_EMPTY, WARN_SPLITS_FILTER_INVALID, SETTINGS_SPLITS_FILTER, LOG_PREFIX_SETTINGS, ERROR_SETS_FILTER_EXCLUSIVE, WARN_LOWERCASE_FLAGSET, WARN_INVALID_FLAGSET, WARN_FLAGSET_NOT_CONFIGURED } from '../../logger/constants';
|
|
6
6
|
import { objectAssign } from '../lang/objectAssign';
|
|
@@ -40,9 +40,9 @@ function validateFilterType(maybeFilterType: any): maybeFilterType is SplitIO.Sp
|
|
|
40
40
|
/**
|
|
41
41
|
* Validate, deduplicate and sort a given list of filter values.
|
|
42
42
|
*
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
43
|
+
* @param type - filter type string used for log messages
|
|
44
|
+
* @param values - list of values to validate, deduplicate and sort
|
|
45
|
+
* @param maxLength - max length allowed for the list of values
|
|
46
46
|
* @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.
|
|
47
47
|
*
|
|
48
48
|
* @throws Error if the sanitized list exceeds the length indicated by `maxLength`
|
|
@@ -75,7 +75,7 @@ function validateSplitFilter(log: ILogger, type: SplitIO.SplitFilterType, values
|
|
|
75
75
|
* - '&prefixes=<comma-separated-values>': if only `byName` filter is undefined
|
|
76
76
|
* - '&names=<comma-separated-values>&prefixes=<comma-separated-values>': if no one is undefined
|
|
77
77
|
*
|
|
78
|
-
* @param
|
|
78
|
+
* @param groupedFilters - object of filters. Each filter must be a list of valid, unique and ordered string values.
|
|
79
79
|
* @returns null or string with the `split filter query` component of the URL.
|
|
80
80
|
*/
|
|
81
81
|
function queryStringBuilder(groupedFilters: Record<SplitIO.SplitFilterType, string[]>) {
|
|
@@ -90,15 +90,12 @@ function queryStringBuilder(groupedFilters: Record<SplitIO.SplitFilterType, stri
|
|
|
90
90
|
/**
|
|
91
91
|
* Sanitizes set names list taking into account:
|
|
92
92
|
* - It should be lowercase
|
|
93
|
-
* - Must adhere the following regular expression
|
|
93
|
+
* - Must adhere the following regular expression `/^[a-z0-9][_a-z0-9]{0,49}$/` that means
|
|
94
94
|
* - must start with a letter or number
|
|
95
95
|
* - Be in lowercase
|
|
96
96
|
* - Be alphanumeric
|
|
97
97
|
* - have a max length of 50 characters
|
|
98
98
|
*
|
|
99
|
-
* @param {ILogger} log
|
|
100
|
-
* @param {string[]} flagSets
|
|
101
|
-
* @param {string} method
|
|
102
99
|
* @returns sanitized list of set names
|
|
103
100
|
*/
|
|
104
101
|
function sanitizeFlagSets(log: ILogger, flagSets: string[], method: string) {
|
|
@@ -128,9 +125,9 @@ function configuredFilter(validFilters: SplitIO.SplitFilter[], filterType: Split
|
|
|
128
125
|
/**
|
|
129
126
|
* Validates `splitFilters` configuration object and parses it into a query string for filtering splits on `/splitChanges` fetch.
|
|
130
127
|
*
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
133
|
-
* @param
|
|
128
|
+
* @param log - logger
|
|
129
|
+
* @param maybeSplitFilters - split filters configuration param provided by the user
|
|
130
|
+
* @param mode - settings mode
|
|
134
131
|
* @returns it returns an object with the following properties:
|
|
135
132
|
* - `validFilters`: the validated `splitFilters` configuration object defined by the user.
|
|
136
133
|
* - `queryString`: the parsed split filter query. it is null if all filters are invalid or all values in filters are invalid.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InMemoryStorageCSFactory } from '../../../storages/inMemory/InMemoryStorageCS';
|
|
2
|
-
import { ISettings
|
|
2
|
+
import { ISettings } from '../../../types';
|
|
3
|
+
import SplitIO from '../../../../types/splitio';
|
|
3
4
|
import { ILogger } from '../../../logger/types';
|
|
4
5
|
import { ERROR_STORAGE_INVALID } from '../../../logger/constants';
|
|
5
6
|
import { LOCALHOST_MODE, STANDALONE_MODE, STORAGE_PLUGGABLE, STORAGE_LOCALSTORAGE, STORAGE_MEMORY } from '../../../utils/constants';
|
|
@@ -15,13 +16,13 @@ __InLocalStorageMockFactory.type = STORAGE_MEMORY;
|
|
|
15
16
|
/**
|
|
16
17
|
* This function validates `settings.storage` object
|
|
17
18
|
*
|
|
18
|
-
* @param
|
|
19
|
+
* @param settings - config object provided by the user to initialize the sdk
|
|
19
20
|
*
|
|
20
|
-
* @returns
|
|
21
|
+
* @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
|
|
21
22
|
*
|
|
22
23
|
* @throws error if mode is consumer and the provided storage is not compatible
|
|
23
24
|
*/
|
|
24
|
-
export function validateStorageCS(settings: { log: ILogger, storage?: any, mode: SDKMode }): ISettings['storage'] {
|
|
25
|
+
export function validateStorageCS(settings: { log: ILogger, storage?: any, mode: SplitIO.SDKMode }): ISettings['storage'] {
|
|
25
26
|
let { storage = InMemoryStorageCSFactory, log, mode } = settings;
|
|
26
27
|
|
|
27
28
|
// If an invalid storage is provided, fallback into MEMORY
|
|
@@ -9,9 +9,9 @@ const streamingEndpointMatcher = /^\/(sse|event-stream)/;
|
|
|
9
9
|
* Get URL based on a given target (path).
|
|
10
10
|
* ATM, it is only used for testing purposes.
|
|
11
11
|
*
|
|
12
|
-
* @param settings settings object
|
|
13
|
-
* @param target url path
|
|
14
|
-
* @
|
|
12
|
+
* @param settings - settings object
|
|
13
|
+
* @param target - url path
|
|
14
|
+
* @returns complete url
|
|
15
15
|
*/
|
|
16
16
|
export function url(settings: ISettings, target: string) {
|
|
17
17
|
if (telemetryEndpointMatcher.test(target)) {
|