@splitsoftware/splitio-commons 1.17.1-rc.0 → 1.17.1-rc.2
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 +3 -0
- package/cjs/sdkClient/identity.js +7 -0
- package/cjs/sdkClient/sdkClient.js +5 -5
- package/cjs/sdkClient/sdkClientMethod.js +3 -1
- package/cjs/sdkClient/sdkClientMethodCS.js +8 -13
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +8 -13
- package/cjs/sdkFactory/index.js +8 -2
- package/cjs/storages/AbstractSplitsCacheAsync.js +0 -7
- package/cjs/storages/AbstractSplitsCacheSync.js +0 -7
- package/cjs/storages/dataLoader.js +65 -32
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +1 -9
- package/cjs/storages/inLocalStorage/index.js +4 -1
- package/cjs/storages/inMemory/InMemoryStorageCS.js +16 -4
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +2 -7
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +1 -10
- package/cjs/utils/settingsValidation/storage/storageCS.js +1 -12
- package/esm/sdkClient/identity.js +3 -0
- package/esm/sdkClient/sdkClient.js +5 -5
- package/esm/sdkClient/sdkClientMethod.js +3 -1
- package/esm/sdkClient/sdkClientMethodCS.js +6 -11
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +6 -11
- package/esm/sdkFactory/index.js +9 -3
- package/esm/storages/AbstractSplitsCacheAsync.js +0 -7
- package/esm/storages/AbstractSplitsCacheSync.js +0 -7
- package/esm/storages/dataLoader.js +62 -30
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +1 -9
- package/esm/storages/inLocalStorage/index.js +5 -2
- package/esm/storages/inMemory/InMemoryStorageCS.js +16 -4
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +3 -8
- package/esm/sync/polling/updaters/splitChangesUpdater.js +2 -11
- package/esm/utils/settingsValidation/storage/storageCS.js +0 -10
- package/package.json +1 -1
- package/src/sdkClient/identity.ts +5 -0
- package/src/sdkClient/sdkClient.ts +5 -5
- package/src/sdkClient/sdkClientMethod.ts +4 -1
- package/src/sdkClient/sdkClientMethodCS.ts +6 -12
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +6 -12
- package/src/sdkFactory/index.ts +11 -4
- package/src/sdkFactory/types.ts +2 -1
- package/src/storages/AbstractSplitsCacheAsync.ts +0 -8
- package/src/storages/AbstractSplitsCacheSync.ts +0 -8
- package/src/storages/dataLoader.ts +63 -32
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +1 -10
- package/src/storages/inLocalStorage/index.ts +6 -2
- package/src/storages/inMemory/InMemoryStorageCS.ts +19 -4
- package/src/storages/types.ts +1 -6
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +3 -7
- package/src/sync/polling/updaters/splitChangesUpdater.ts +3 -11
- package/src/types.ts +16 -9
- package/src/utils/settingsValidation/storage/storageCS.ts +0 -13
- package/types/sdkClient/identity.d.ts +0 -4
- package/types/sdkClient/sdkClientMethod.d.ts +1 -1
- package/types/sdkFactory/types.d.ts +2 -1
- package/types/storages/AbstractMySegmentsCacheSync.d.ts +39 -0
- package/types/storages/AbstractSplitsCacheAsync.d.ts +0 -5
- package/types/storages/AbstractSplitsCacheSync.d.ts +0 -5
- package/types/storages/dataLoader.d.ts +17 -6
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +0 -6
- package/types/storages/types.d.ts +1 -4
- package/types/types.d.ts +15 -9
- package/types/utils/settingsValidation/storage/storageCS.d.ts +0 -5
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { SplitIO } from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import { ISegmentsCacheSync, ISplitsCacheSync, IStorageSync } from './types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Storage-agnostic adaptation of `loadDataIntoLocalStorage` function
|
|
5
|
+
* (https://github.com/godaddy/split-javascript-data-loader/blob/master/src/load-data.js)
|
|
5
6
|
*
|
|
6
|
-
* @param preloadedData validated data following the format proposed in https://github.com/godaddy/split-javascript-data-loader
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
7
|
+
* @param preloadedData validated data following the format proposed in https://github.com/godaddy/split-javascript-data-loader and extended with a `mySegmentsData` property.
|
|
8
|
+
* @param storage object containing `splits` and `segments` cache (client-side variant)
|
|
9
|
+
* @param userKey user key (matching key) of the provided MySegmentsCache
|
|
10
|
+
*
|
|
11
|
+
* @TODO extend to load largeSegments
|
|
12
|
+
* @TODO extend to load data on shared mySegments storages. Be specific when emitting SDK_READY_FROM_CACHE on shared clients. Maybe the serializer should provide the `useSegments` flag.
|
|
13
|
+
* @TODO add logs, and input validation in this module, in favor of size reduction.
|
|
14
|
+
* @TODO unit tests
|
|
9
15
|
*/
|
|
10
|
-
export declare function
|
|
16
|
+
export declare function loadData(preloadedData: SplitIO.PreloadedData, storage: {
|
|
17
|
+
splits?: ISplitsCacheSync;
|
|
18
|
+
segments: ISegmentsCacheSync;
|
|
19
|
+
largeSegments?: ISegmentsCacheSync;
|
|
20
|
+
}, userKey?: string): void;
|
|
21
|
+
export declare function getSnapshot(storage: IStorageSync, userKeys?: string[]): SplitIO.PreloadedData;
|
|
@@ -35,12 +35,6 @@ export declare class SplitsCacheInLocal extends AbstractSplitsCacheSync {
|
|
|
35
35
|
getSplitNames(): string[];
|
|
36
36
|
trafficTypeExists(trafficType: string): boolean;
|
|
37
37
|
usesSegments(): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Check if the splits information is already stored in browser LocalStorage.
|
|
40
|
-
* In this function we could add more code to check if the data is valid.
|
|
41
|
-
* @override
|
|
42
|
-
*/
|
|
43
|
-
checkCache(): boolean;
|
|
44
38
|
/**
|
|
45
39
|
* Clean Splits cache if its `lastUpdated` timestamp is older than the given `expirationTimestamp`,
|
|
46
40
|
*
|
|
@@ -192,7 +192,6 @@ export interface ISplitsCacheBase {
|
|
|
192
192
|
trafficTypeExists(trafficType: string): MaybeThenable<boolean>;
|
|
193
193
|
usesSegments(): MaybeThenable<boolean>;
|
|
194
194
|
clear(): MaybeThenable<boolean | void>;
|
|
195
|
-
checkCache(): MaybeThenable<boolean>;
|
|
196
195
|
killLocally(name: string, defaultTreatment: string, changeNumber: number): MaybeThenable<boolean>;
|
|
197
196
|
getNamesByFlagSets(flagSets: string[]): MaybeThenable<ISet<string>[]>;
|
|
198
197
|
}
|
|
@@ -208,7 +207,6 @@ export interface ISplitsCacheSync extends ISplitsCacheBase {
|
|
|
208
207
|
trafficTypeExists(trafficType: string): boolean;
|
|
209
208
|
usesSegments(): boolean;
|
|
210
209
|
clear(): void;
|
|
211
|
-
checkCache(): boolean;
|
|
212
210
|
killLocally(name: string, defaultTreatment: string, changeNumber: number): boolean;
|
|
213
211
|
getNamesByFlagSets(flagSets: string[]): ISet<string>[];
|
|
214
212
|
}
|
|
@@ -224,7 +222,6 @@ export interface ISplitsCacheAsync extends ISplitsCacheBase {
|
|
|
224
222
|
trafficTypeExists(trafficType: string): Promise<boolean>;
|
|
225
223
|
usesSegments(): Promise<boolean>;
|
|
226
224
|
clear(): Promise<boolean | void>;
|
|
227
|
-
checkCache(): Promise<boolean>;
|
|
228
225
|
killLocally(name: string, defaultTreatment: string, changeNumber: number): Promise<boolean>;
|
|
229
226
|
getNamesByFlagSets(flagSets: string[]): Promise<ISet<string>[]>;
|
|
230
227
|
}
|
|
@@ -394,7 +391,6 @@ export interface IStorageSync extends IStorageBase<ISplitsCacheSync, ISegmentsCa
|
|
|
394
391
|
export interface IStorageAsync extends IStorageBase<ISplitsCacheAsync, ISegmentsCacheAsync, IImpressionsCacheAsync | IImpressionsCacheSync, IImpressionCountsCacheBase, IEventsCacheAsync | IEventsCacheSync, ITelemetryCacheAsync | ITelemetryCacheSync, IUniqueKeysCacheBase> {
|
|
395
392
|
}
|
|
396
393
|
/** StorageFactory */
|
|
397
|
-
export declare type DataLoader = (storage: IStorageSync, matchingKey: string) => void;
|
|
398
394
|
export interface IStorageFactoryParams {
|
|
399
395
|
settings: ISettings;
|
|
400
396
|
/**
|
|
@@ -402,6 +398,7 @@ export interface IStorageFactoryParams {
|
|
|
402
398
|
* It is meant for emitting SDK_READY event in consumer mode, and waiting before using the storage in the synchronizer.
|
|
403
399
|
*/
|
|
404
400
|
onReadyCb: (error?: any) => void;
|
|
401
|
+
onReadyFromCacheCb: (error?: any) => void;
|
|
405
402
|
}
|
|
406
403
|
export declare type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS' | 'PLUGGABLE';
|
|
407
404
|
export declare type IStorageSyncFactory = {
|
package/types/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISplitFiltersValidation } from './dtos/types';
|
|
1
|
+
import { ISplit, ISplitFiltersValidation } from './dtos/types';
|
|
2
2
|
import { IIntegration, IIntegrationFactoryParams } from './integrations/types';
|
|
3
3
|
import { ILogger } from './logger/types';
|
|
4
4
|
import { ISdkFactoryContext } from './sdkFactory/types';
|
|
@@ -92,6 +92,7 @@ export interface ISettings {
|
|
|
92
92
|
eventsFirstPushWindow: number;
|
|
93
93
|
};
|
|
94
94
|
readonly storage: IStorageSyncFactory | IStorageAsyncFactory;
|
|
95
|
+
readonly preloadedData?: SplitIO.PreloadedData;
|
|
95
96
|
readonly integrations: Array<{
|
|
96
97
|
readonly type: string;
|
|
97
98
|
(params: IIntegrationFactoryParams): IIntegration | void;
|
|
@@ -422,7 +423,7 @@ export interface IStatusInterface extends IEventEmitter {
|
|
|
422
423
|
* @interface IBasicClient
|
|
423
424
|
* @extends IStatusInterface
|
|
424
425
|
*/
|
|
425
|
-
interface IBasicClient extends IStatusInterface {
|
|
426
|
+
export interface IBasicClient extends IStatusInterface {
|
|
426
427
|
/**
|
|
427
428
|
* Flush data
|
|
428
429
|
* @function flush
|
|
@@ -452,6 +453,12 @@ interface IBasicSDK {
|
|
|
452
453
|
* @property Logger
|
|
453
454
|
*/
|
|
454
455
|
Logger: ILoggerAPI;
|
|
456
|
+
/**
|
|
457
|
+
* Destroy all the clients created by this factory.
|
|
458
|
+
* @function destroy
|
|
459
|
+
* @returns {Promise<void>}
|
|
460
|
+
*/
|
|
461
|
+
destroy(): Promise<void>;
|
|
455
462
|
}
|
|
456
463
|
/****** Exposed namespace ******/
|
|
457
464
|
/**
|
|
@@ -764,21 +771,19 @@ export declare namespace SplitIO {
|
|
|
764
771
|
* If this value is older than 10 days ago (expiration time policy), the data is not used to update the storage content.
|
|
765
772
|
* @TODO configurable expiration time policy?
|
|
766
773
|
*/
|
|
767
|
-
lastUpdated: number;
|
|
768
774
|
/**
|
|
769
775
|
* Change number of the preloaded data.
|
|
770
776
|
* If this value is older than the current changeNumber at the storage, the data is not used to update the storage content.
|
|
771
777
|
*/
|
|
772
778
|
since: number;
|
|
773
779
|
/**
|
|
774
|
-
*
|
|
780
|
+
* List of feature flag definitions.
|
|
781
|
+
* @TODO rename to flags
|
|
775
782
|
*/
|
|
776
|
-
splitsData:
|
|
777
|
-
[splitName: string]: string;
|
|
778
|
-
};
|
|
783
|
+
splitsData: ISplit[];
|
|
779
784
|
/**
|
|
780
785
|
* Optional map of user keys to their list of segments.
|
|
781
|
-
* @TODO
|
|
786
|
+
* @TODO rename to memberships
|
|
782
787
|
*/
|
|
783
788
|
mySegmentsData?: {
|
|
784
789
|
[key: string]: string[];
|
|
@@ -786,9 +791,10 @@ export declare namespace SplitIO {
|
|
|
786
791
|
/**
|
|
787
792
|
* Optional map of segments to their stringified definitions.
|
|
788
793
|
* This property is ignored if `mySegmentsData` was provided.
|
|
794
|
+
* @TODO rename to segments
|
|
789
795
|
*/
|
|
790
796
|
segmentsData?: {
|
|
791
|
-
[segmentName: string]: string;
|
|
797
|
+
[segmentName: string]: string[];
|
|
792
798
|
};
|
|
793
799
|
}
|
|
794
800
|
/**
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { ISettings, SDKMode } from '../../../types';
|
|
2
2
|
import { ILogger } from '../../../logger/types';
|
|
3
|
-
import { IStorageFactoryParams, IStorageSync } from '../../../storages/types';
|
|
4
|
-
export declare function __InLocalStorageMockFactory(params: IStorageFactoryParams): IStorageSync;
|
|
5
|
-
export declare namespace __InLocalStorageMockFactory {
|
|
6
|
-
var type: import("../../../storages/types").StorageType;
|
|
7
|
-
}
|
|
8
3
|
/**
|
|
9
4
|
* This function validates `settings.storage` object
|
|
10
5
|
*
|