diff --git a/package-lock.json b/package-lock.json index cdecc850..43488ed1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio-commons", - "version": "1.0.1-rc.4", + "version": "1.0.1-rc.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 68610a2a..b2483879 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio-commons", - "version": "1.0.1-rc.4", + "version": "1.0.1-rc.5", "description": "Split Javascript SDK common components", "main": "cjs/index.js", "module": "esm/index.js", diff --git a/src/__tests__/testUtils/eventSourceMock.ts b/src/__tests__/testUtils/eventSourceMock.ts index 281421b3..f47615ed 100644 --- a/src/__tests__/testUtils/eventSourceMock.ts +++ b/src/__tests__/testUtils/eventSourceMock.ts @@ -12,7 +12,7 @@ * */ -import EventEmitter from '../../utils/MinEvents'; +import { EventEmitter } from '../../utils/MinEvents'; import { IEventEmitter } from '../../types'; type ReadyStateType = 0 | 1 | 2; diff --git a/src/evaluator/index.ts b/src/evaluator/index.ts index 3c12c9b3..df9d5ef8 100644 --- a/src/evaluator/index.ts +++ b/src/evaluator/index.ts @@ -1,7 +1,6 @@ import Engine from './Engine'; import thenable from '../utils/promise/thenable'; import * as LabelsConstants from '../utils/labels'; -import { get } from '../utils/lang'; import { CONTROL } from '../utils/constants'; import { ISplit, MaybeThenable } from '../dtos/types'; import { IStorageAsync, IStorageSync } from '../storages/types'; @@ -106,17 +105,17 @@ function getEvaluation( const split = Engine.parse(log, splitJSON, storage); evaluation = split.getTreatment(key, attributes, evaluateFeature); - // If the storage is async, evaluation and changeNumber will return a thenable + // If the storage is async and the evaluated split uses segment, evaluation is thenable if (thenable(evaluation)) { return evaluation.then(result => { result.changeNumber = split.getChangeNumber(); - result.config = get(splitJSON, `configurations.${result.treatment}`, null); + result.config = splitJSON.configurations && splitJSON.configurations[result.treatment] || null; return result; }); } else { evaluation.changeNumber = split.getChangeNumber(); // Always sync and optional - evaluation.config = get(splitJSON, `configurations.${evaluation.treatment}`, null); + evaluation.config = splitJSON.configurations && splitJSON.configurations[evaluation.treatment] || null; } } diff --git a/src/logger/messages/warn.ts b/src/logger/messages/warn.ts index 8c35e311..f6a66eec 100644 --- a/src/logger/messages/warn.ts +++ b/src/logger/messages/warn.ts @@ -21,9 +21,9 @@ export const codesWarn: [number, string][] = codesError.concat([ [c.WARN_TRIMMING_PROPERTIES, '%s: Event has more than 300 properties. Some of them will be trimmed when processed.'], [c.WARN_CONVERTING, '%s: %s "%s" is not of type string, converting.'], [c.WARN_TRIMMING, '%s: %s "%s" has extra whitespace, trimming.'], - [c.WARN_NOT_EXISTENT_SPLIT, '%s: split "%s" does not exist in this environment, please double check what splits exist in the web console.'], + [c.WARN_NOT_EXISTENT_SPLIT, '%s: split "%s" does not exist in this environment, please double check what splits exist in the Split web console.'], [c.WARN_LOWERCASE_TRAFFIC_TYPE, '%s: traffic_type_name should be all lowercase - converting string to lowercase.'], - [c.WARN_NOT_EXISTENT_TT, '%s: traffic type "%s" does not have any corresponding split in this environment, make sure you\'re tracking your events to a valid traffic type defined in the web console.'], + [c.WARN_NOT_EXISTENT_TT, '%s: traffic type "%s" does not have any corresponding split in this environment, make sure you\'re tracking your events to a valid traffic type defined in the Split web console.'], // initialization / settings validation [c.WARN_INTEGRATION_INVALID, c.LOG_PREFIX_SETTINGS+': %s integration item(s) at settings is invalid. %s'], [c.WARN_SPLITS_FILTER_IGNORED, c.LOG_PREFIX_SETTINGS+': split filters have been configured but will have no effect if mode is not "%s", since synchronization is being deferred to an external tool.'], diff --git a/src/readiness/__tests__/readinessManager.spec.ts b/src/readiness/__tests__/readinessManager.spec.ts index ae30b7cb..0a6726c5 100644 --- a/src/readiness/__tests__/readinessManager.spec.ts +++ b/src/readiness/__tests__/readinessManager.spec.ts @@ -1,5 +1,5 @@ import { readinessManagerFactory } from '../readinessManager'; -import EventEmitter from '../../utils/MinEvents'; +import { EventEmitter } from '../../utils/MinEvents'; import { IReadinessManager } from '../types'; import { SDK_READY, SDK_UPDATE, SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED, SDK_READY_FROM_CACHE, SDK_SPLITS_CACHE_LOADED, SDK_READY_TIMED_OUT } from '../constants'; diff --git a/src/sdkFactory/__tests__/index.spec.ts b/src/sdkFactory/__tests__/index.spec.ts index 3e758f68..58a1144f 100644 --- a/src/sdkFactory/__tests__/index.spec.ts +++ b/src/sdkFactory/__tests__/index.spec.ts @@ -2,7 +2,7 @@ import { ISdkFactoryParams } from '../types'; import { sdkFactory } from '../index'; import { fullSettings } from '../../utils/settingsValidation/__tests__/settings.mocks'; import { SplitIO } from '../../types'; -import EventEmitter from '../../utils/MinEvents'; +import { EventEmitter } from '../../utils/MinEvents'; /** Mocks */ diff --git a/src/sdkFactory/index.ts b/src/sdkFactory/index.ts index 2d2b89cd..f074f387 100644 --- a/src/sdkFactory/index.ts +++ b/src/sdkFactory/index.ts @@ -46,7 +46,7 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO. // Callback used to emit SDK_READY in consumer mode, where `syncManagerFactory` is undefined // or only instantiates submitters, and therefore it is not able to emit readiness events. onReadyCb: (error) => { - if (error) return; // don't emit SDK_READY if storage failed to connect. + if (error) return; // Don't emit SDK_READY if storage failed to connect. Error message is logged by wrapperAdapter readinessManager.splits.emit(SDK_SPLITS_ARRIVED); readinessManager.segments.emit(SDK_SEGMENTS_ARRIVED); }, diff --git a/src/storages/types.ts b/src/storages/types.ts index 5ce0d1e9..0e3a6001 100644 --- a/src/storages/types.ts +++ b/src/storages/types.ts @@ -70,7 +70,7 @@ export interface IPluggableStorageWrapper { /** Integer operations */ /** - * Increments in 1 the given `key` value or set it in 1 if the value doesn't exist. + * Increments in 1 the given `key` value or set it to 1 if the value doesn't exist. * * @function incr * @param {string} key Key to increment @@ -79,7 +79,7 @@ export interface IPluggableStorageWrapper { */ incr: (key: string) => Promise /** - * Decrements in 1 the given `key` value or set it in -1 if the value doesn't exist. + * Decrements in 1 the given `key` value or set it to -1 if the value doesn't exist. * * @function decr * @param {string} key Key to decrement diff --git a/src/sync/polling/updaters/__tests__/splitChangesUpdater.spec.ts b/src/sync/polling/updaters/__tests__/splitChangesUpdater.spec.ts index cfe8dac6..bc68243c 100644 --- a/src/sync/polling/updaters/__tests__/splitChangesUpdater.spec.ts +++ b/src/sync/polling/updaters/__tests__/splitChangesUpdater.spec.ts @@ -8,7 +8,7 @@ import { splitChangesUpdaterFactory, parseSegments, computeSplitsMutation } from import splitChangesMock1 from '../../../../__tests__/mocks/splitchanges.since.-1.json'; import fetchMock from '../../../../__tests__/testUtils/fetchMock'; import { settingsSplitApi } from '../../../../utils/settingsValidation/__tests__/settings.mocks'; -import EventEmitter from '../../../../utils/MinEvents'; +import { EventEmitter } from '../../../../utils/MinEvents'; import { loggerMock } from '../../../../logger/__tests__/sdkLogger.mock'; const activeSplitWithSegments = { diff --git a/src/sync/streaming/AuthClient/__tests__/index.spec.ts b/src/sync/streaming/AuthClient/__tests__/index.spec.ts index afaf5f73..70604400 100644 --- a/src/sync/streaming/AuthClient/__tests__/index.spec.ts +++ b/src/sync/streaming/AuthClient/__tests__/index.spec.ts @@ -3,7 +3,7 @@ import { splitApiFactory } from '../../../../services/splitApi'; import { authDataResponseSample, authDataSample, jwtSampleInvalid, jwtSampleNoChannels, jwtSampleNoIat, userKeySample, userKeyBase64HashSample } from '../../__tests__/dataMocks'; import fetchMock from '../../../../__tests__/testUtils/fetchMock'; import { settingsSplitApi } from '../../../../utils/settingsValidation/__tests__/settings.mocks'; -import EventEmitter from '../../../../utils/MinEvents'; +import { EventEmitter } from '../../../../utils/MinEvents'; // module to test import { authenticateFactory, hashUserKey } from '../index'; diff --git a/src/sync/streaming/__tests__/pushManager.spec.ts b/src/sync/streaming/__tests__/pushManager.spec.ts index 9b6fb784..02161150 100644 --- a/src/sync/streaming/__tests__/pushManager.spec.ts +++ b/src/sync/streaming/__tests__/pushManager.spec.ts @@ -1,5 +1,5 @@ import pushManagerFactory from '../pushManager'; -import EventEmitter from '../../../utils/MinEvents'; +import { EventEmitter } from '../../../utils/MinEvents'; import { fullSettings } from '../../../utils/settingsValidation/__tests__/settings.mocks'; import { IPushManagerCS } from '../types'; diff --git a/src/utils/MinEvents.ts b/src/utils/MinEvents.ts index e32e255b..71aa3626 100644 --- a/src/utils/MinEvents.ts +++ b/src/utils/MinEvents.ts @@ -39,14 +39,9 @@ var ReflectApply = R && typeof R.apply === 'function' return Function.prototype.apply.call(target, receiver, args); }; -function EventEmitter() { +export const EventEmitter: { new(): IEventEmitter } = function EventEmitter() { EventEmitter.init.call(this); -} - -export default EventEmitter as new () => IEventEmitter; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; +}; EventEmitter.prototype._events = undefined; EventEmitter.prototype._eventsCount = 0;