diff --git a/CHANGES.txt b/CHANGES.txt index 92f937b5..a893bd27 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ -1.11.0 (November XX, 2023) +1.11.0 (November 3, 2023) - Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation): - Added new variations of the get treatment methods to support evaluating flags in given flag set/s. - getTreatmentsByFlagSet and getTreatmentsByFlagSets @@ -6,6 +6,7 @@ - Added a new optional Split Filter configuration option. This allows the SDK and Split services to only synchronize the flags in the specified flag sets, avoiding unused or unwanted flags from being synced on the SDK instance, bringing all the benefits from a reduced payload. - Note: Only applicable when the SDK is in charge of the rollout data synchronization. When not applicable, the SDK will log a warning on init. - Added `sets` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager to expose flag sets on flag views. + - Bugfixing - Fixed SDK key validation in NodeJS to ensure the SDK_READY_TIMED_OUT event is emitted when a client-side type SDK key is provided instead of a server-side one (Related to issue https://github.com/splitio/javascript-client/issues/768). 1.10.0 (October 20, 2023) - Added `defaultTreatment` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager (Related to issue https://github.com/splitio/javascript-commons/issues/225). diff --git a/package-lock.json b/package-lock.json index db3d8b54..5c28d3a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@splitsoftware/splitio-commons", - "version": "1.10.1-rc.3", + "version": "1.11.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio-commons", - "version": "1.10.1-rc.3", + "version": "1.11.0", "license": "Apache-2.0", "dependencies": { "tslib": "^2.3.1" diff --git a/package.json b/package.json index 2bd2eed9..2fda9f0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio-commons", - "version": "1.10.1-rc.3", + "version": "1.11.0", "description": "Split Javascript SDK common components", "main": "cjs/index.js", "module": "esm/index.js", diff --git a/src/evaluator/index.ts b/src/evaluator/index.ts index 70dad68a..62f82e98 100644 --- a/src/evaluator/index.ts +++ b/src/evaluator/index.ts @@ -94,7 +94,7 @@ export function evaluateFeaturesByFlagSets( flagSets: string[], attributes: SplitIO.Attributes | undefined, storage: IStorageSync | IStorageAsync, -): MaybeThenable> { +): MaybeThenable> { let storedFlagNames: MaybeThenable>; // get features by flag sets @@ -107,7 +107,10 @@ export function evaluateFeaturesByFlagSets( // evaluate related features return thenable(storedFlagNames) ? - storedFlagNames.then((splitNames) => evaluateFeatures(log, key, setToArray(splitNames), attributes, storage)) : + storedFlagNames.then((splitNames) => evaluateFeatures(log, key, setToArray(splitNames), attributes, storage)) + .catch(() => { + return {}; + }) : evaluateFeatures(log, key, setToArray(storedFlagNames), attributes, storage); } diff --git a/src/readiness/readinessManager.ts b/src/readiness/readinessManager.ts index b4557dc9..c5ac1c35 100644 --- a/src/readiness/readinessManager.ts +++ b/src/readiness/readinessManager.ts @@ -112,7 +112,12 @@ export function readinessManagerFactory( return readinessManagerFactory(EventEmitter, readyTimeout, splits); }, + // @TODO review/remove next methods when non-recoverable errors are reworked + // Called on consumer mode, when storage fails to connect timeout, + // Called on 403 error (client-side SDK key on server-side), to set the SDK as destroyed for + // tracking and evaluations, while keeping event listeners to emit SDK_READY_TIMED_OUT event + setDestroyed() { isDestroyed = true; }, destroy() { isDestroyed = true; diff --git a/src/readiness/types.ts b/src/readiness/types.ts index 71c8b215..d126b5ec 100644 --- a/src/readiness/types.ts +++ b/src/readiness/types.ts @@ -55,6 +55,7 @@ export interface IReadinessManager { isOperational(): boolean, timeout(): void, + setDestroyed(): void, destroy(): void, /** for client-side */ diff --git a/src/storages/__tests__/KeyBuilder.spec.ts b/src/storages/__tests__/KeyBuilder.spec.ts index 0965f3d1..01a09efa 100644 --- a/src/storages/__tests__/KeyBuilder.spec.ts +++ b/src/storages/__tests__/KeyBuilder.spec.ts @@ -72,7 +72,7 @@ test('KEYS / flag set keys', () => { const builder = new KeyBuilder(prefix); const flagSetName = 'flagset_x'; - const expectedKey = `${prefix}.flagset.${flagSetName}`; + const expectedKey = `${prefix}.flagSet.${flagSetName}`; expect(builder.buildFlagSetKey(flagSetName)).toBe(expectedKey); diff --git a/src/storages/inRedis/SplitsCacheInRedis.ts b/src/storages/inRedis/SplitsCacheInRedis.ts index f83ee21a..83c06472 100644 --- a/src/storages/inRedis/SplitsCacheInRedis.ts +++ b/src/storages/inRedis/SplitsCacheInRedis.ts @@ -5,7 +5,7 @@ import { ILogger } from '../../logger/types'; import { LOG_PREFIX } from './constants'; import { ISplit } from '../../dtos/types'; import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync'; -import { ISet, _Set } from '../../utils/lang/sets'; +import { ISet } from '../../utils/lang/sets'; /** * Discard errors for an answer of multiple operations. diff --git a/src/storages/pluggable/SplitsCachePluggable.ts b/src/storages/pluggable/SplitsCachePluggable.ts index c6dce829..786fb8a5 100644 --- a/src/storages/pluggable/SplitsCachePluggable.ts +++ b/src/storages/pluggable/SplitsCachePluggable.ts @@ -5,7 +5,7 @@ import { ILogger } from '../../logger/types'; import { ISplit } from '../../dtos/types'; import { LOG_PREFIX } from './constants'; import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync'; -import { ISet, _Set } from '../../utils/lang/sets'; +import { ISet } from '../../utils/lang/sets'; /** * ISplitsCacheAsync implementation for pluggable storages. @@ -162,8 +162,8 @@ export class SplitsCachePluggable extends AbstractSplitsCacheAsync { * @todo this is a no-op method to be implemented */ getNamesByFlagSets(): Promise> { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - return new Promise(flagSets => new _Set([])); + this.log.error(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported with pluggable storage yet.'); + return Promise.reject(); } /** diff --git a/src/sync/polling/updaters/segmentChangesUpdater.ts b/src/sync/polling/updaters/segmentChangesUpdater.ts index 32f3fe7f..39d147ff 100644 --- a/src/sync/polling/updaters/segmentChangesUpdater.ts +++ b/src/sync/polling/updaters/segmentChangesUpdater.ts @@ -96,7 +96,7 @@ export function segmentChangesUpdaterFactory( if (error && error.statusCode === 403) { // If the operation is forbidden, it may be due to permissions. Destroy the SDK instance. // @TODO although factory status is destroyed, synchronization is not stopped - if (readiness) readiness.destroy(); + if (readiness) readiness.setDestroyed(); log.error(`${LOG_PREFIX_INSTANTIATION}: you passed a client-side type authorizationKey, please grab an SDK Key from the Split user interface that is of type server-side.`); } else { log.warn(`${LOG_PREFIX_SYNC_SEGMENTS}Error while doing fetch of segments. ${error}`);