@splitsoftware/splitio-commons 1.17.1-rc.2 → 1.17.1-rc.4
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 +4 -3
- package/cjs/readiness/readinessManager.js +13 -2
- package/cjs/sdkClient/sdkClientMethodCS.js +0 -1
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +0 -1
- package/cjs/sdkFactory/index.js +27 -11
- package/cjs/storages/{AbstractSegmentsCacheSync.js → AbstractMySegmentsCacheSync.js} +15 -17
- package/cjs/storages/AbstractSplitsCacheAsync.js +7 -0
- package/cjs/storages/AbstractSplitsCacheSync.js +7 -0
- package/cjs/storages/dataLoader.js +32 -65
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +5 -5
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +9 -1
- package/cjs/storages/inLocalStorage/index.js +1 -4
- package/cjs/storages/inMemory/InMemoryStorageCS.js +5 -17
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +5 -5
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +13 -27
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +0 -1
- package/cjs/storages/inRedis/SegmentsCacheInRedis.js +13 -19
- package/cjs/storages/pluggable/SegmentsCachePluggable.js +11 -32
- package/cjs/sync/offline/syncManagerOffline.js +18 -11
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +7 -2
- package/cjs/sync/polling/pollingManagerSS.js +3 -3
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +12 -28
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +10 -1
- package/cjs/sync/syncManagerOnline.js +20 -21
- package/cjs/trackers/eventTracker.js +12 -10
- package/cjs/trackers/impressionsTracker.js +16 -14
- package/cjs/trackers/uniqueKeysTracker.js +5 -3
- package/cjs/utils/settingsValidation/storage/storageCS.js +12 -1
- package/esm/readiness/readinessManager.js +13 -2
- package/esm/sdkClient/sdkClientMethodCS.js +0 -1
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +0 -1
- package/esm/sdkFactory/index.js +28 -12
- package/esm/storages/{AbstractSegmentsCacheSync.js → AbstractMySegmentsCacheSync.js} +14 -16
- package/esm/storages/AbstractSplitsCacheAsync.js +7 -0
- package/esm/storages/AbstractSplitsCacheSync.js +7 -0
- package/esm/storages/dataLoader.js +30 -62
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +5 -5
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +9 -1
- package/esm/storages/inLocalStorage/index.js +2 -5
- package/esm/storages/inMemory/InMemoryStorageCS.js +5 -17
- package/esm/storages/inMemory/MySegmentsCacheInMemory.js +5 -5
- package/esm/storages/inMemory/SegmentsCacheInMemory.js +13 -27
- package/esm/storages/inMemory/SplitsCacheInMemory.js +0 -1
- package/esm/storages/inRedis/SegmentsCacheInRedis.js +13 -19
- package/esm/storages/pluggable/SegmentsCachePluggable.js +11 -32
- package/esm/sync/offline/syncManagerOffline.js +18 -11
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +8 -3
- package/esm/sync/polling/pollingManagerSS.js +3 -3
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +12 -28
- package/esm/sync/polling/updaters/splitChangesUpdater.js +11 -2
- package/esm/sync/syncManagerOnline.js +20 -21
- package/esm/trackers/eventTracker.js +12 -10
- package/esm/trackers/impressionsTracker.js +16 -14
- package/esm/trackers/uniqueKeysTracker.js +5 -3
- package/esm/utils/settingsValidation/storage/storageCS.js +10 -0
- package/package.json +1 -1
- package/src/readiness/readinessManager.ts +12 -3
- package/src/readiness/types.ts +3 -0
- package/src/sdkClient/sdkClientMethodCS.ts +0 -2
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +0 -2
- package/src/sdkFactory/index.ts +30 -14
- package/src/sdkFactory/types.ts +2 -0
- package/src/storages/{AbstractSegmentsCacheSync.ts → AbstractMySegmentsCacheSync.ts} +13 -28
- package/src/storages/AbstractSplitsCacheAsync.ts +8 -0
- package/src/storages/AbstractSplitsCacheSync.ts +8 -0
- package/src/storages/dataLoader.ts +32 -63
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +5 -5
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +10 -1
- package/src/storages/inLocalStorage/index.ts +2 -6
- package/src/storages/inMemory/InMemoryStorageCS.ts +5 -20
- package/src/storages/inMemory/MySegmentsCacheInMemory.ts +5 -5
- package/src/storages/inMemory/SegmentsCacheInMemory.ts +12 -26
- package/src/storages/inMemory/SplitsCacheInMemory.ts +0 -1
- package/src/storages/inRedis/SegmentsCacheInRedis.ts +13 -22
- package/src/storages/pluggable/SegmentsCachePluggable.ts +11 -35
- package/src/storages/types.ts +9 -10
- package/src/sync/offline/syncManagerOffline.ts +21 -13
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +7 -3
- package/src/sync/polling/pollingManagerSS.ts +2 -3
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +13 -29
- package/src/sync/polling/updaters/splitChangesUpdater.ts +11 -3
- package/src/sync/syncManagerOnline.ts +17 -17
- package/src/sync/types.ts +1 -1
- package/src/trackers/eventTracker.ts +11 -8
- package/src/trackers/impressionsTracker.ts +13 -10
- package/src/trackers/types.ts +1 -0
- package/src/trackers/uniqueKeysTracker.ts +6 -4
- package/src/types.ts +8 -9
- package/src/utils/settingsValidation/storage/storageCS.ts +13 -0
- package/types/readiness/types.d.ts +3 -0
- package/types/sdkFactory/types.d.ts +1 -0
- package/types/storages/AbstractSplitsCacheAsync.d.ts +5 -0
- package/types/storages/AbstractSplitsCacheSync.d.ts +5 -0
- package/types/storages/dataLoader.d.ts +6 -17
- package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +5 -5
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +6 -0
- package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +5 -5
- package/types/storages/inMemory/SegmentsCacheInMemory.d.ts +5 -7
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +0 -1
- package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +6 -3
- package/types/storages/pluggable/SegmentsCachePluggable.d.ts +4 -16
- package/types/storages/types.d.ts +7 -10
- package/types/sync/types.d.ts +1 -1
- package/types/trackers/eventTracker.d.ts +1 -1
- package/types/trackers/impressionsTracker.d.ts +1 -1
- package/types/trackers/types.d.ts +1 -0
- package/types/types.d.ts +8 -8
- package/types/utils/settingsValidation/storage/storageCS.d.ts +5 -0
|
@@ -192,6 +192,7 @@ 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>;
|
|
195
196
|
killLocally(name: string, defaultTreatment: string, changeNumber: number): MaybeThenable<boolean>;
|
|
196
197
|
getNamesByFlagSets(flagSets: string[]): MaybeThenable<ISet<string>[]>;
|
|
197
198
|
}
|
|
@@ -207,6 +208,7 @@ export interface ISplitsCacheSync extends ISplitsCacheBase {
|
|
|
207
208
|
trafficTypeExists(trafficType: string): boolean;
|
|
208
209
|
usesSegments(): boolean;
|
|
209
210
|
clear(): void;
|
|
211
|
+
checkCache(): boolean;
|
|
210
212
|
killLocally(name: string, defaultTreatment: string, changeNumber: number): boolean;
|
|
211
213
|
getNamesByFlagSets(flagSets: string[]): ISet<string>[];
|
|
212
214
|
}
|
|
@@ -222,40 +224,35 @@ export interface ISplitsCacheAsync extends ISplitsCacheBase {
|
|
|
222
224
|
trafficTypeExists(trafficType: string): Promise<boolean>;
|
|
223
225
|
usesSegments(): Promise<boolean>;
|
|
224
226
|
clear(): Promise<boolean | void>;
|
|
227
|
+
checkCache(): Promise<boolean>;
|
|
225
228
|
killLocally(name: string, defaultTreatment: string, changeNumber: number): Promise<boolean>;
|
|
226
229
|
getNamesByFlagSets(flagSets: string[]): Promise<ISet<string>[]>;
|
|
227
230
|
}
|
|
228
231
|
/** Segments cache */
|
|
229
232
|
export interface ISegmentsCacheBase {
|
|
230
|
-
addToSegment(name: string, segmentKeys: string[]): MaybeThenable<boolean | void>;
|
|
231
|
-
removeFromSegment(name: string, segmentKeys: string[]): MaybeThenable<boolean | void>;
|
|
232
233
|
isInSegment(name: string, key?: string): MaybeThenable<boolean>;
|
|
233
234
|
registerSegments(names: string[]): MaybeThenable<boolean | void>;
|
|
234
235
|
getRegisteredSegments(): MaybeThenable<string[]>;
|
|
235
|
-
setChangeNumber(name: string, changeNumber: number): MaybeThenable<boolean | void>;
|
|
236
236
|
getChangeNumber(name: string): MaybeThenable<number>;
|
|
237
|
+
update(name: string, addedKeys: string[], removedKeys: string[], changeNumber: number): MaybeThenable<boolean>;
|
|
237
238
|
clear(): MaybeThenable<boolean | void>;
|
|
238
239
|
}
|
|
239
240
|
export interface ISegmentsCacheSync extends ISegmentsCacheBase {
|
|
240
|
-
addToSegment(name: string, segmentKeys?: string[]): boolean;
|
|
241
|
-
removeFromSegment(name: string, segmentKeys?: string[]): boolean;
|
|
242
241
|
isInSegment(name: string, key?: string): boolean;
|
|
243
242
|
registerSegments(names: string[]): boolean;
|
|
244
243
|
getRegisteredSegments(): string[];
|
|
245
244
|
getKeysCount(): number;
|
|
246
|
-
setChangeNumber(name: string, changeNumber: number): boolean | void;
|
|
247
245
|
getChangeNumber(name?: string): number;
|
|
246
|
+
update(name: string, addedKeys: string[], removedKeys: string[], changeNumber: number): boolean;
|
|
248
247
|
resetSegments(segmentsData: MySegmentsData | IMySegmentsResponse): boolean;
|
|
249
248
|
clear(): void;
|
|
250
249
|
}
|
|
251
250
|
export interface ISegmentsCacheAsync extends ISegmentsCacheBase {
|
|
252
|
-
addToSegment(name: string, segmentKeys: string[]): Promise<boolean | void>;
|
|
253
|
-
removeFromSegment(name: string, segmentKeys: string[]): Promise<boolean | void>;
|
|
254
251
|
isInSegment(name: string, key: string): Promise<boolean>;
|
|
255
252
|
registerSegments(names: string[]): Promise<boolean | void>;
|
|
256
253
|
getRegisteredSegments(): Promise<string[]>;
|
|
257
|
-
setChangeNumber(name: string, changeNumber: number): Promise<boolean | void>;
|
|
258
254
|
getChangeNumber(name: string): Promise<number>;
|
|
255
|
+
update(name: string, addedKeys: string[], removedKeys: string[], changeNumber: number): Promise<boolean>;
|
|
259
256
|
clear(): Promise<boolean | void>;
|
|
260
257
|
}
|
|
261
258
|
/** Recorder storages (impressions, events and telemetry) */
|
|
@@ -391,6 +388,7 @@ export interface IStorageSync extends IStorageBase<ISplitsCacheSync, ISegmentsCa
|
|
|
391
388
|
export interface IStorageAsync extends IStorageBase<ISplitsCacheAsync, ISegmentsCacheAsync, IImpressionsCacheAsync | IImpressionsCacheSync, IImpressionCountsCacheBase, IEventsCacheAsync | IEventsCacheSync, ITelemetryCacheAsync | ITelemetryCacheSync, IUniqueKeysCacheBase> {
|
|
392
389
|
}
|
|
393
390
|
/** StorageFactory */
|
|
391
|
+
export declare type DataLoader = (storage: IStorageSync, matchingKey: string) => void;
|
|
394
392
|
export interface IStorageFactoryParams {
|
|
395
393
|
settings: ISettings;
|
|
396
394
|
/**
|
|
@@ -398,7 +396,6 @@ export interface IStorageFactoryParams {
|
|
|
398
396
|
* It is meant for emitting SDK_READY event in consumer mode, and waiting before using the storage in the synchronizer.
|
|
399
397
|
*/
|
|
400
398
|
onReadyCb: (error?: any) => void;
|
|
401
|
-
onReadyFromCacheCb: (error?: any) => void;
|
|
402
399
|
}
|
|
403
400
|
export declare type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS' | 'PLUGGABLE';
|
|
404
401
|
export declare type IStorageSyncFactory = {
|
package/types/sync/types.d.ts
CHANGED
|
@@ -39,5 +39,5 @@ export interface ISyncManager extends ITask {
|
|
|
39
39
|
submitterManager?: ISubmitterManager;
|
|
40
40
|
}
|
|
41
41
|
export interface ISyncManagerCS extends ISyncManager {
|
|
42
|
-
shared(matchingKey: string, readinessManager: IReadinessManager, storage: IStorageSync): ISyncManager | undefined;
|
|
42
|
+
shared(matchingKey: string, readinessManager: IReadinessManager, storage: IStorageSync): Pick<ISyncManager, 'stop' | 'flush'> | undefined;
|
|
43
43
|
}
|
|
@@ -7,4 +7,4 @@ import { ISettings } from '../types';
|
|
|
7
7
|
* @param eventsCache cache to save events
|
|
8
8
|
* @param integrationsManager optional event handler used for integrations
|
|
9
9
|
*/
|
|
10
|
-
export declare function eventTrackerFactory(settings: ISettings, eventsCache: IEventsCacheBase, integrationsManager?: IEventsHandler, telemetryCache?: ITelemetryCacheSync | ITelemetryCacheAsync): IEventTracker;
|
|
10
|
+
export declare function eventTrackerFactory(settings: ISettings, eventsCache: IEventsCacheBase, whenInit: (cb: () => void) => void, integrationsManager?: IEventsHandler, telemetryCache?: ITelemetryCacheSync | ITelemetryCacheAsync): IEventTracker;
|
|
@@ -10,4 +10,4 @@ import { ISettings } from '../types';
|
|
|
10
10
|
* @param integrationsManager optional integrations manager
|
|
11
11
|
* @param strategy strategy for impressions tracking.
|
|
12
12
|
*/
|
|
13
|
-
export declare function impressionsTrackerFactory(settings: ISettings, impressionsCache: IImpressionsCacheBase, strategy: IStrategy, integrationsManager?: IImpressionsHandler, telemetryCache?: ITelemetryCacheSync | ITelemetryCacheAsync): IImpressionsTracker;
|
|
13
|
+
export declare function impressionsTrackerFactory(settings: ISettings, impressionsCache: IImpressionsCacheBase, strategy: IStrategy, whenInit: (cb: () => void) => void, integrationsManager?: IImpressionsHandler, telemetryCache?: ITelemetryCacheSync | ITelemetryCacheAsync): IImpressionsTracker;
|
package/types/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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,7 +92,6 @@ export interface ISettings {
|
|
|
92
92
|
eventsFirstPushWindow: number;
|
|
93
93
|
};
|
|
94
94
|
readonly storage: IStorageSyncFactory | IStorageAsyncFactory;
|
|
95
|
-
readonly preloadedData?: SplitIO.PreloadedData;
|
|
96
95
|
readonly integrations: Array<{
|
|
97
96
|
readonly type: string;
|
|
98
97
|
(params: IIntegrationFactoryParams): IIntegration | void;
|
|
@@ -771,19 +770,21 @@ export declare namespace SplitIO {
|
|
|
771
770
|
* If this value is older than 10 days ago (expiration time policy), the data is not used to update the storage content.
|
|
772
771
|
* @TODO configurable expiration time policy?
|
|
773
772
|
*/
|
|
773
|
+
lastUpdated: number;
|
|
774
774
|
/**
|
|
775
775
|
* Change number of the preloaded data.
|
|
776
776
|
* If this value is older than the current changeNumber at the storage, the data is not used to update the storage content.
|
|
777
777
|
*/
|
|
778
778
|
since: number;
|
|
779
779
|
/**
|
|
780
|
-
*
|
|
781
|
-
* @TODO rename to flags
|
|
780
|
+
* Map of feature flags to their stringified definitions.
|
|
782
781
|
*/
|
|
783
|
-
splitsData:
|
|
782
|
+
splitsData: {
|
|
783
|
+
[splitName: string]: string;
|
|
784
|
+
};
|
|
784
785
|
/**
|
|
785
786
|
* Optional map of user keys to their list of segments.
|
|
786
|
-
* @TODO
|
|
787
|
+
* @TODO remove when releasing first version
|
|
787
788
|
*/
|
|
788
789
|
mySegmentsData?: {
|
|
789
790
|
[key: string]: string[];
|
|
@@ -791,10 +792,9 @@ export declare namespace SplitIO {
|
|
|
791
792
|
/**
|
|
792
793
|
* Optional map of segments to their stringified definitions.
|
|
793
794
|
* This property is ignored if `mySegmentsData` was provided.
|
|
794
|
-
* @TODO rename to segments
|
|
795
795
|
*/
|
|
796
796
|
segmentsData?: {
|
|
797
|
-
[segmentName: string]: string
|
|
797
|
+
[segmentName: string]: string;
|
|
798
798
|
};
|
|
799
799
|
}
|
|
800
800
|
/**
|
|
@@ -1,5 +1,10 @@
|
|
|
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
|
+
}
|
|
3
8
|
/**
|
|
4
9
|
* This function validates `settings.storage` object
|
|
5
10
|
*
|