diff --git a/src/storages/AbstractSplitsCacheAsync.ts b/src/storages/AbstractSplitsCacheAsync.ts index ea2c25fc..bbd33e78 100644 --- a/src/storages/AbstractSplitsCacheAsync.ts +++ b/src/storages/AbstractSplitsCacheAsync.ts @@ -18,7 +18,7 @@ export abstract class AbstractSplitsCacheAsync implements ISplitsCacheAsync { abstract getChangeNumber(): Promise abstract getAll(): Promise abstract getSplitNames(): Promise - abstract getNamesByFlagSets(flagsets: string[]): Promise> + abstract getNamesByFlagSets(flagSets: string[]): Promise> abstract trafficTypeExists(trafficType: string): Promise abstract clear(): Promise diff --git a/src/storages/AbstractSplitsCacheSync.ts b/src/storages/AbstractSplitsCacheSync.ts index 26b5f473..92a29c18 100644 --- a/src/storages/AbstractSplitsCacheSync.ts +++ b/src/storages/AbstractSplitsCacheSync.ts @@ -1,7 +1,7 @@ import { ISplitsCacheSync } from './types'; import { ISplit } from '../dtos/types'; import { objectAssign } from '../utils/lang/objectAssign'; -import { ISet, _Set } from '../utils/lang/sets'; +import { ISet } from '../utils/lang/sets'; /** * This class provides a skeletal implementation of the ISplitsCacheSync interface @@ -78,11 +78,8 @@ export abstract class AbstractSplitsCacheSync implements ISplitsCacheSync { } return false; } - /** NO-OP */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - getNamesByFlagSets(flagsets: string[]): ISet { - return new _Set([]); - } + + abstract getNamesByFlagSets(flagSets: string[]): ISet } diff --git a/src/storages/inLocalStorage/SplitsCacheInLocal.ts b/src/storages/inLocalStorage/SplitsCacheInLocal.ts index b959cd2b..8fff22fd 100644 --- a/src/storages/inLocalStorage/SplitsCacheInLocal.ts +++ b/src/storages/inLocalStorage/SplitsCacheInLocal.ts @@ -257,15 +257,15 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync { // if the filter didn't change, nothing is done } - getNamesByFlagSets(flagsets: string[]): ISet{ + getNamesByFlagSets(flagSets: string[]): ISet{ let toReturn: ISet = new _Set([]); - flagsets.forEach(flagset => { - const flagsetKey = this.keys.buildFlagSetKey(flagset); - let flagsetFromLocalStorage = localStorage.getItem(flagsetKey); + flagSets.forEach(flagSet => { + const flagSetKey = this.keys.buildFlagSetKey(flagSet); + let flagSetFromLocalStorage = localStorage.getItem(flagSetKey); - if (flagsetFromLocalStorage) { - const flagsetCache = new _Set(JSON.parse(flagsetFromLocalStorage)); - toReturn = returnSetsUnion(toReturn, flagsetCache); + if (flagSetFromLocalStorage) { + const flagSetCache = new _Set(JSON.parse(flagSetFromLocalStorage)); + toReturn = returnSetsUnion(toReturn, flagSetCache); } }); return toReturn; diff --git a/src/storages/inMemory/SplitsCacheInMemory.ts b/src/storages/inMemory/SplitsCacheInMemory.ts index 66a72dcc..223dae9f 100644 --- a/src/storages/inMemory/SplitsCacheInMemory.ts +++ b/src/storages/inMemory/SplitsCacheInMemory.ts @@ -9,16 +9,16 @@ import { ISet, _Set, returnSetsUnion } from '../../utils/lang/sets'; */ export class SplitsCacheInMemory extends AbstractSplitsCacheSync { - private flagsetsFilter: string[]; + private flagSetsFilter: string[]; private splitsCache: Record = {}; private ttCache: Record = {}; private changeNumber: number = -1; private splitsWithSegmentsCount: number = 0; - private flagsetsCache: Record> = {}; + private flagSetsCache: Record> = {}; constructor(splitFiltersValidation: ISplitFiltersValidation = { queryString: null, groupedFilters: { bySet: [], byName: [], byPrefix: [] }, validFilters: [] }) { super(); - this.flagsetsFilter = splitFiltersValidation.groupedFilters.bySet; + this.flagSetsFilter = splitFiltersValidation.groupedFilters.bySet; } clear() { @@ -105,10 +105,10 @@ export class SplitsCacheInMemory extends AbstractSplitsCacheSync { return this.getChangeNumber() === -1 || this.splitsWithSegmentsCount > 0; } - getNamesByFlagSets(flagsets: string[]): ISet{ + getNamesByFlagSets(flagSets: string[]): ISet{ let toReturn: ISet = new _Set([]); - flagsets.forEach(flagset => { - const featureFlagNames = this.flagsetsCache[flagset]; + flagSets.forEach(flagSet => { + const featureFlagNames = this.flagSetsCache[flagSet]; if (featureFlagNames) { toReturn = returnSetsUnion(toReturn, featureFlagNames); } @@ -121,11 +121,11 @@ export class SplitsCacheInMemory extends AbstractSplitsCacheSync { if (!featureFlag.sets) return; featureFlag.sets.forEach(featureFlagSet => { - if (this.flagsetsFilter.length > 0 && !this.flagsetsFilter.some(filterFlagSet => filterFlagSet === featureFlagSet)) return; + if (this.flagSetsFilter.length > 0 && !this.flagSetsFilter.some(filterFlagSet => filterFlagSet === featureFlagSet)) return; - if (!this.flagsetsCache[featureFlagSet]) this.flagsetsCache[featureFlagSet] = new _Set([]); + if (!this.flagSetsCache[featureFlagSet]) this.flagSetsCache[featureFlagSet] = new _Set([]); - this.flagsetsCache[featureFlagSet].add(featureFlag.name); + this.flagSetsCache[featureFlagSet].add(featureFlag.name); }); } @@ -137,9 +137,9 @@ export class SplitsCacheInMemory extends AbstractSplitsCacheSync { } private removeNames(flagsetName: string, featureFlagName: string) { - if (!this.flagsetsCache[flagsetName]) return; - this.flagsetsCache[flagsetName].delete(featureFlagName); - if (this.flagsetsCache[flagsetName].size === 0) delete this.flagsetsCache[flagsetName]; + if (!this.flagSetsCache[flagsetName]) return; + this.flagSetsCache[flagsetName].delete(featureFlagName); + if (this.flagSetsCache[flagsetName].size === 0) delete this.flagSetsCache[flagsetName]; } } diff --git a/src/storages/types.ts b/src/storages/types.ts index ab24a479..30832f5e 100644 --- a/src/storages/types.ts +++ b/src/storages/types.ts @@ -210,7 +210,7 @@ export interface ISplitsCacheBase { // should never reject or throw an exception. Instead return false by default, to avoid emitting SDK_READY_FROM_CACHE. checkCache(): MaybeThenable, killLocally(name: string, defaultTreatment: string, changeNumber: number): MaybeThenable, - getNamesByFlagSets(flagsets: string[]): MaybeThenable> + getNamesByFlagSets(flagSets: string[]): MaybeThenable> } export interface ISplitsCacheSync extends ISplitsCacheBase { @@ -227,7 +227,7 @@ export interface ISplitsCacheSync extends ISplitsCacheBase { clear(): void, checkCache(): boolean, killLocally(name: string, defaultTreatment: string, changeNumber: number): boolean, - getNamesByFlagSets(flagsets: string[]): ISet + getNamesByFlagSets(flagSets: string[]): ISet } export interface ISplitsCacheAsync extends ISplitsCacheBase { @@ -244,7 +244,7 @@ export interface ISplitsCacheAsync extends ISplitsCacheBase { clear(): Promise, checkCache(): Promise, killLocally(name: string, defaultTreatment: string, changeNumber: number): Promise, - getNamesByFlagSets(flagsets: string[]): Promise> + getNamesByFlagSets(flagSets: string[]): Promise> } /** Segments cache */