diff --git a/package-lock.json b/package-lock.json index 8fc190d7..6de71997 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@splitsoftware/splitio-commons", - "version": "1.17.1-rc.1", + "version": "1.17.1-rc.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio-commons", - "version": "1.17.1-rc.1", + "version": "1.17.1-rc.2", "license": "Apache-2.0", "dependencies": { "tslib": "^2.3.1" diff --git a/package.json b/package.json index 883888e7..dc7467df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio-commons", - "version": "1.17.1-rc.1", + "version": "1.17.1-rc.2", "description": "Split JavaScript SDK common components", "main": "cjs/index.js", "module": "esm/index.js", diff --git a/src/storages/__tests__/dataLoader.spec.ts b/src/storages/__tests__/dataLoader.spec.ts index fe779046..c9f77849 100644 --- a/src/storages/__tests__/dataLoader.spec.ts +++ b/src/storages/__tests__/dataLoader.spec.ts @@ -24,9 +24,7 @@ test('loadData & getSnapshot', () => { expect(dataLoader.getSnapshot(clientStorage, [fullSettings.core.key as string])).toEqual(preloadedData); expect(preloadedData).toEqual({ since: 123, - splitsData: { - split1: { name: 'split1' } - }, + splitsData: [{ name: 'split1' }], mySegmentsData: { [fullSettings.core.key as string]: ['segment1'] }, segmentsData: undefined }); diff --git a/src/storages/dataLoader.ts b/src/storages/dataLoader.ts index c8b34354..69b28274 100644 --- a/src/storages/dataLoader.ts +++ b/src/storages/dataLoader.ts @@ -19,7 +19,7 @@ export function loadData(preloadedData: SplitIO.PreloadedData, storage: { splits // Do not load data if current preloadedData is empty if (Object.keys(preloadedData).length === 0) return; - const { segmentsData = {}, since = -1, splitsData = {} } = preloadedData; + const { segmentsData = {}, since = -1, splitsData = [] } = preloadedData; if (storage.splits) { const storedSince = storage.splits.getChangeNumber(); @@ -32,7 +32,7 @@ export function loadData(preloadedData: SplitIO.PreloadedData, storage: { splits storage.splits.setChangeNumber(since); // splitsData in an object where the property is the split name and the pertaining value is a stringified json of its data - storage.splits.addSplits(Object.keys(splitsData).map(splitName => ([splitName, splitsData[splitName]]))); + storage.splits.addSplits(splitsData.map(split => ([split.name, split]))); } if (userKey) { // add mySegments data (client-side) @@ -57,8 +57,8 @@ export function getSnapshot(storage: IStorageSync, userKeys?: string[]): SplitIO return { // lastUpdated: Date.now(), // @ts-ignore accessing private prop - since: storage.splits.changeNumber, // @ts-ignore accessing private prop - splitsData: storage.splits.splitsCache, + since: storage.splits.changeNumber, + splitsData: storage.splits.getAll(), segmentsData: userKeys ? undefined : // @ts-ignore accessing private prop Object.keys(storage.segments.segmentCache).reduce((prev, cur) => { // @ts-ignore accessing private prop diff --git a/src/types.ts b/src/types.ts index a2942a17..777b3258 100644 --- a/src/types.ts +++ b/src/types.ts @@ -779,12 +779,10 @@ export namespace SplitIO { */ since: number, /** - * Map of feature flags to their stringified definitions. + * List of feature flag definitions. * @TODO rename to flags */ - splitsData: { - [splitName: string]: ISplit - }, + splitsData: ISplit[], /** * Optional map of user keys to their list of segments. * @TODO rename to memberships