@splitsoftware/splitio-commons 1.17.1-rc.3 → 1.17.1-rc.5
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 +28 -28
- package/LICENSE +1 -1
- package/README.md +4 -3
- package/cjs/consent/sdkUserConsent.js +4 -2
- package/cjs/evaluator/matchers/index.js +1 -3
- package/cjs/evaluator/matchers/matcherTypes.js +0 -1
- package/cjs/evaluator/matchers/segment.js +0 -6
- package/cjs/evaluator/matchersTransform/index.js +1 -4
- package/cjs/evaluator/matchersTransform/segment.js +1 -3
- package/cjs/logger/constants.js +2 -2
- package/cjs/logger/messages/info.js +1 -1
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/readiness/readinessManager.js +11 -12
- package/cjs/readiness/sdkReadinessManager.js +6 -5
- package/cjs/sdkClient/sdkClient.js +5 -5
- package/cjs/sdkClient/sdkClientMethod.js +1 -3
- package/cjs/sdkClient/sdkClientMethodCS.js +17 -15
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +17 -15
- package/cjs/sdkFactory/index.js +11 -38
- package/cjs/services/decorateHeaders.js +6 -1
- package/cjs/services/splitApi.js +5 -5
- package/cjs/services/splitHttpClient.js +5 -2
- package/cjs/storages/AbstractSegmentsCacheSync.js +12 -41
- package/cjs/storages/AbstractSplitsCacheAsync.js +7 -0
- package/cjs/storages/AbstractSplitsCacheSync.js +8 -2
- package/cjs/storages/KeyBuilderCS.js +5 -23
- package/cjs/storages/dataLoader.js +33 -65
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +52 -29
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +9 -1
- package/cjs/storages/inLocalStorage/index.js +3 -12
- package/cjs/storages/inMemory/InMemoryStorageCS.js +3 -20
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +40 -9
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +8 -8
- package/cjs/storages/inMemory/TelemetryCacheInMemory.js +10 -7
- package/cjs/storages/inRedis/RedisAdapter.js +1 -1
- package/cjs/storages/inRedis/SegmentsCacheInRedis.js +2 -2
- package/cjs/storages/inRedis/index.js +11 -5
- package/cjs/storages/pluggable/SegmentsCachePluggable.js +2 -2
- package/cjs/storages/pluggable/inMemoryWrapper.js +1 -1
- package/cjs/storages/pluggable/index.js +32 -37
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +7 -2
- package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +8 -5
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/pollingManagerCS.js +1 -1
- package/cjs/sync/polling/pollingManagerSS.js +3 -3
- package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +2 -2
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +21 -15
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +2 -2
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +11 -2
- package/cjs/sync/streaming/AuthClient/index.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +5 -3
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +48 -107
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +3 -3
- package/cjs/sync/streaming/constants.js +3 -3
- package/cjs/sync/streaming/parseUtils.js +9 -14
- package/cjs/sync/streaming/pushManager.js +67 -69
- package/cjs/sync/syncTask.js +2 -2
- package/cjs/trackers/eventTracker.js +9 -11
- package/cjs/trackers/impressionsTracker.js +13 -15
- package/cjs/trackers/uniqueKeysTracker.js +3 -5
- package/cjs/utils/constants/index.js +4 -5
- package/cjs/utils/settingsValidation/index.js +1 -2
- package/cjs/utils/settingsValidation/storage/storageCS.js +12 -1
- package/esm/consent/sdkUserConsent.js +4 -2
- package/esm/evaluator/matchers/index.js +1 -3
- package/esm/evaluator/matchers/matcherTypes.js +0 -1
- package/esm/evaluator/matchers/segment.js +0 -6
- package/esm/evaluator/matchersTransform/index.js +1 -4
- package/esm/evaluator/matchersTransform/segment.js +1 -3
- package/esm/logger/constants.js +1 -1
- package/esm/logger/messages/info.js +1 -1
- package/esm/logger/messages/warn.js +1 -1
- package/esm/readiness/readinessManager.js +11 -12
- package/esm/readiness/sdkReadinessManager.js +6 -5
- package/esm/sdkClient/sdkClient.js +5 -5
- package/esm/sdkClient/sdkClientMethod.js +1 -3
- package/esm/sdkClient/sdkClientMethodCS.js +15 -13
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +15 -13
- package/esm/sdkFactory/index.js +12 -39
- package/esm/services/decorateHeaders.js +4 -0
- package/esm/services/splitApi.js +6 -6
- package/esm/services/splitHttpClient.js +6 -3
- package/esm/storages/AbstractSegmentsCacheSync.js +12 -41
- package/esm/storages/AbstractSplitsCacheAsync.js +7 -0
- package/esm/storages/AbstractSplitsCacheSync.js +9 -3
- package/esm/storages/KeyBuilderCS.js +4 -21
- package/esm/storages/dataLoader.js +31 -62
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +52 -29
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +9 -1
- package/esm/storages/inLocalStorage/index.js +5 -14
- package/esm/storages/inMemory/InMemoryStorageCS.js +3 -20
- package/esm/storages/inMemory/MySegmentsCacheInMemory.js +40 -9
- package/esm/storages/inMemory/SegmentsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/SplitsCacheInMemory.js +8 -8
- package/esm/storages/inMemory/TelemetryCacheInMemory.js +10 -7
- package/esm/storages/inRedis/RedisAdapter.js +1 -1
- package/esm/storages/inRedis/SegmentsCacheInRedis.js +2 -2
- package/esm/storages/inRedis/index.js +11 -5
- package/esm/storages/pluggable/SegmentsCachePluggable.js +2 -2
- package/esm/storages/pluggable/inMemoryWrapper.js +1 -1
- package/esm/storages/pluggable/index.js +32 -37
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +8 -3
- package/esm/sync/polling/fetchers/mySegmentsFetcher.js +8 -5
- package/esm/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/esm/sync/polling/pollingManagerCS.js +1 -1
- package/esm/sync/polling/pollingManagerSS.js +3 -3
- package/esm/sync/polling/syncTasks/mySegmentsSyncTask.js +2 -2
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +21 -15
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +2 -2
- package/esm/sync/polling/updaters/splitChangesUpdater.js +12 -3
- package/esm/sync/streaming/AuthClient/index.js +1 -1
- package/esm/sync/streaming/SSEHandler/index.js +6 -4
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +49 -108
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +3 -3
- package/esm/sync/streaming/constants.js +2 -2
- package/esm/sync/streaming/parseUtils.js +8 -12
- package/esm/sync/streaming/pushManager.js +70 -72
- package/esm/sync/syncTask.js +2 -2
- package/esm/trackers/eventTracker.js +9 -11
- package/esm/trackers/impressionsTracker.js +13 -15
- package/esm/trackers/uniqueKeysTracker.js +3 -5
- package/esm/utils/constants/index.js +2 -3
- package/esm/utils/settingsValidation/index.js +1 -2
- package/esm/utils/settingsValidation/storage/storageCS.js +10 -0
- package/package.json +1 -1
- package/src/consent/sdkUserConsent.ts +3 -2
- package/src/dtos/types.ts +7 -21
- package/src/evaluator/matchers/index.ts +0 -2
- package/src/evaluator/matchers/matcherTypes.ts +0 -1
- package/src/evaluator/matchers/segment.ts +0 -7
- package/src/evaluator/matchersTransform/index.ts +1 -4
- package/src/evaluator/matchersTransform/segment.ts +3 -5
- package/src/logger/constants.ts +1 -1
- package/src/logger/messages/info.ts +1 -1
- package/src/logger/messages/warn.ts +1 -1
- package/src/readiness/readinessManager.ts +12 -16
- package/src/readiness/sdkReadinessManager.ts +7 -7
- package/src/readiness/types.ts +2 -3
- package/src/sdkClient/sdkClient.ts +5 -5
- package/src/sdkClient/sdkClientMethod.ts +1 -4
- package/src/sdkClient/sdkClientMethodCS.ts +14 -11
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +14 -11
- package/src/sdkFactory/index.ts +13 -42
- package/src/sdkFactory/types.ts +1 -5
- package/src/services/decorateHeaders.ts +5 -0
- package/src/services/splitApi.ts +7 -7
- package/src/services/splitHttpClient.ts +7 -4
- package/src/services/types.ts +2 -2
- package/src/storages/AbstractSegmentsCacheSync.ts +12 -53
- package/src/storages/AbstractSplitsCacheAsync.ts +8 -0
- package/src/storages/AbstractSplitsCacheSync.ts +11 -4
- package/src/storages/KeyBuilderCS.ts +5 -34
- package/src/storages/dataLoader.ts +33 -63
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +59 -29
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +10 -1
- package/src/storages/inLocalStorage/index.ts +6 -16
- package/src/storages/inMemory/InMemoryStorageCS.ts +3 -23
- package/src/storages/inMemory/MySegmentsCacheInMemory.ts +44 -10
- package/src/storages/inMemory/SegmentsCacheInMemory.ts +1 -1
- package/src/storages/inMemory/SplitsCacheInMemory.ts +8 -7
- package/src/storages/inMemory/TelemetryCacheInMemory.ts +11 -7
- package/src/storages/inRedis/RedisAdapter.ts +1 -1
- package/src/storages/inRedis/SegmentsCacheInRedis.ts +2 -2
- package/src/storages/inRedis/index.ts +12 -6
- package/src/storages/pluggable/SegmentsCachePluggable.ts +2 -2
- package/src/storages/pluggable/inMemoryWrapper.ts +1 -1
- package/src/storages/pluggable/index.ts +33 -38
- package/src/storages/types.ts +15 -15
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +7 -3
- package/src/sync/polling/fetchers/mySegmentsFetcher.ts +10 -8
- package/src/sync/polling/fetchers/segmentChangesFetcher.ts +1 -1
- package/src/sync/polling/fetchers/types.ts +2 -3
- package/src/sync/polling/pollingManagerCS.ts +4 -4
- package/src/sync/polling/pollingManagerSS.ts +2 -3
- package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +5 -4
- package/src/sync/polling/types.ts +6 -7
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +22 -19
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +2 -2
- package/src/sync/polling/updaters/splitChangesUpdater.ts +12 -4
- package/src/sync/streaming/AuthClient/index.ts +1 -1
- package/src/sync/streaming/SSEClient/index.ts +6 -4
- package/src/sync/streaming/SSEHandler/index.ts +8 -5
- package/src/sync/streaming/SSEHandler/types.ts +15 -15
- package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +49 -116
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +4 -4
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +1 -1
- package/src/sync/streaming/UpdateWorkers/types.ts +2 -2
- package/src/sync/streaming/constants.ts +2 -2
- package/src/sync/streaming/parseUtils.ts +11 -19
- package/src/sync/streaming/pushManager.ts +72 -73
- package/src/sync/streaming/types.ts +10 -10
- package/src/sync/submitters/types.ts +5 -8
- package/src/sync/syncTask.ts +2 -2
- package/src/trackers/eventTracker.ts +7 -10
- package/src/trackers/impressionsTracker.ts +9 -12
- package/src/trackers/types.ts +0 -1
- package/src/trackers/uniqueKeysTracker.ts +4 -6
- package/src/types.ts +9 -16
- package/src/utils/constants/index.ts +2 -3
- package/src/utils/settingsValidation/index.ts +2 -3
- package/src/utils/settingsValidation/storage/storageCS.ts +13 -0
- package/src/utils/settingsValidation/types.ts +1 -1
- package/types/dtos/types.d.ts +7 -18
- package/types/evaluator/matchersTransform/segment.d.ts +2 -2
- package/types/logger/constants.d.ts +1 -1
- package/types/readiness/readinessManager.d.ts +2 -2
- package/types/readiness/sdkReadinessManager.d.ts +3 -2
- package/types/readiness/types.d.ts +2 -3
- package/types/sdkClient/sdkClientMethod.d.ts +1 -1
- package/types/sdkFactory/types.d.ts +1 -4
- package/types/services/decorateHeaders.d.ts +1 -0
- package/types/services/splitApi.d.ts +1 -1
- package/types/services/splitHttpClient.d.ts +1 -1
- package/types/services/types.d.ts +2 -2
- package/types/storages/AbstractSegmentsCacheSync.d.ts +11 -9
- package/types/storages/AbstractSplitsCacheAsync.d.ts +5 -0
- package/types/storages/AbstractSplitsCacheSync.d.ts +6 -1
- package/types/storages/KeyBuilderCS.d.ts +2 -9
- package/types/storages/dataLoader.d.ts +6 -17
- package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +14 -4
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +6 -0
- package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +9 -3
- package/types/storages/inMemory/SegmentsCacheInMemory.d.ts +1 -1
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +1 -1
- package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +6 -4
- package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +1 -1
- package/types/storages/inRedis/index.d.ts +1 -1
- package/types/storages/pluggable/SegmentsCachePluggable.d.ts +1 -1
- package/types/storages/pluggable/inMemoryWrapper.d.ts +1 -1
- package/types/storages/types.d.ts +11 -11
- package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +2 -2
- package/types/sync/polling/fetchers/types.d.ts +2 -2
- package/types/sync/polling/syncTasks/mySegmentsSyncTask.d.ts +2 -2
- package/types/sync/polling/types.d.ts +4 -7
- package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +3 -4
- package/types/sync/streaming/SSEHandler/types.d.ts +14 -16
- package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +2 -4
- package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +1 -2
- package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +2 -3
- package/types/sync/streaming/UpdateWorkers/types.d.ts +2 -2
- package/types/sync/streaming/constants.d.ts +2 -2
- package/types/sync/streaming/parseUtils.d.ts +5 -4
- package/types/sync/streaming/types.d.ts +8 -8
- package/types/sync/submitters/types.d.ts +4 -7
- package/types/trackers/eventTracker.d.ts +1 -1
- package/types/trackers/impressionsTracker.d.ts +1 -1
- package/types/trackers/types.d.ts +0 -1
- package/types/types.d.ts +9 -15
- package/types/utils/constants/index.d.ts +2 -3
- package/types/utils/settingsValidation/storage/storageCS.d.ts +5 -0
- package/types/utils/settingsValidation/types.d.ts +1 -1
- package/cjs/evaluator/matchers/large_segment.js +0 -16
- package/cjs/sdkClient/identity.js +0 -7
- package/esm/evaluator/matchers/large_segment.js +0 -12
- package/esm/sdkClient/identity.js +0 -3
- package/src/evaluator/matchers/large_segment.ts +0 -18
- package/src/sdkClient/identity.ts +0 -5
- package/types/evaluator/matchers/large_segment.d.ts +0 -5
- package/types/evaluator/matchers/sember_inlist.d.ts +0 -3
- package/types/evaluator/matchersTransform/set.d.ts +0 -5
- package/types/evaluator/matchersTransform/string.d.ts +0 -7
- package/types/sdkClient/identity.d.ts +0 -2
- package/types/storages/AbstractMySegmentsCacheSync.d.ts +0 -39
- package/types/storages/AbstractSplitsCache.d.ts +0 -46
- package/types/sync/streaming/mySegmentsV2utils.d.ts +0 -27
- package/types/sync/streaming/pushManagerCS_Spec1_3.d.ts +0 -9
- package/types/sync/streaming/pushManager_Spec1_3.d.ts +0 -9
- package/types/trackers/impressionObserver/utils.d.ts +0 -5
- package/types/utils/inputValidation/sdkKey.d.ts +0 -7
- package/types/utils/inputValidation/splitExistance.d.ts +0 -7
- package/types/utils/inputValidation/trafficTypeExistance.d.ts +0 -9
- package/types/utils/redis/RedisMock.d.ts +0 -4
- package/types/utils/settingsValidation/logger/globalLogLevel.d.ts +0 -8
- /package/types/utils/{semVer.d.ts → Semver.d.ts} +0 -0
|
@@ -19,7 +19,6 @@ export function impressionsTrackerFactory(
|
|
|
19
19
|
settings: ISettings,
|
|
20
20
|
impressionsCache: IImpressionsCacheBase,
|
|
21
21
|
strategy: IStrategy,
|
|
22
|
-
whenInit: (cb: () => void) => void,
|
|
23
22
|
integrationsManager?: IImpressionsHandler,
|
|
24
23
|
telemetryCache?: ITelemetryCacheSync | ITelemetryCacheAsync,
|
|
25
24
|
): IImpressionsTracker {
|
|
@@ -68,18 +67,16 @@ export function impressionsTrackerFactory(
|
|
|
68
67
|
};
|
|
69
68
|
|
|
70
69
|
// Wrap in a timeout because we don't want it to be blocking.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (integrationsManager) integrationsManager.handleImpression(impressionData);
|
|
70
|
+
setTimeout(function () {
|
|
71
|
+
// integrationsManager.handleImpression does not throw errors
|
|
72
|
+
if (integrationsManager) integrationsManager.handleImpression(impressionData);
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
74
|
+
try { // @ts-ignore. An exception on the listeners should not break the SDK.
|
|
75
|
+
if (impressionListener) impressionListener.logImpression(impressionData);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
log.error(ERROR_IMPRESSIONS_LISTENER, [err]);
|
|
78
|
+
}
|
|
79
|
+
}, 0);
|
|
83
80
|
}
|
|
84
81
|
}
|
|
85
82
|
}
|
package/src/trackers/types.ts
CHANGED
|
@@ -25,6 +25,10 @@ export function uniqueKeysTrackerFactory(
|
|
|
25
25
|
): IUniqueKeysTracker {
|
|
26
26
|
let intervalId: any;
|
|
27
27
|
|
|
28
|
+
if (filterAdapter.refreshRate) {
|
|
29
|
+
intervalId = setInterval(filterAdapter.clear, filterAdapter.refreshRate);
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
return {
|
|
29
33
|
|
|
30
34
|
track(key: string, featureName: string): void {
|
|
@@ -35,12 +39,6 @@ export function uniqueKeysTrackerFactory(
|
|
|
35
39
|
uniqueKeysCache.track(key, featureName);
|
|
36
40
|
},
|
|
37
41
|
|
|
38
|
-
start(): void {
|
|
39
|
-
if (filterAdapter.refreshRate) {
|
|
40
|
-
intervalId = setInterval(filterAdapter.clear, filterAdapter.refreshRate);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
|
|
44
42
|
stop(): void {
|
|
45
43
|
clearInterval(intervalId);
|
|
46
44
|
}
|
package/src/types.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';
|
|
@@ -98,7 +98,6 @@ export interface ISettings {
|
|
|
98
98
|
eventsFirstPushWindow: number
|
|
99
99
|
},
|
|
100
100
|
readonly storage: IStorageSyncFactory | IStorageAsyncFactory,
|
|
101
|
-
readonly preloadedData?: SplitIO.PreloadedData,
|
|
102
101
|
readonly integrations: Array<{
|
|
103
102
|
readonly type: string,
|
|
104
103
|
(params: IIntegrationFactoryParams): IIntegration | void
|
|
@@ -427,7 +426,7 @@ export interface IStatusInterface extends IEventEmitter {
|
|
|
427
426
|
* @interface IBasicClient
|
|
428
427
|
* @extends IStatusInterface
|
|
429
428
|
*/
|
|
430
|
-
|
|
429
|
+
interface IBasicClient extends IStatusInterface {
|
|
431
430
|
/**
|
|
432
431
|
* Flush data
|
|
433
432
|
* @function flush
|
|
@@ -460,12 +459,6 @@ interface IBasicSDK {
|
|
|
460
459
|
* @property Logger
|
|
461
460
|
*/
|
|
462
461
|
Logger: ILoggerAPI
|
|
463
|
-
/**
|
|
464
|
-
* Destroy all the clients created by this factory.
|
|
465
|
-
* @function destroy
|
|
466
|
-
* @returns {Promise<void>}
|
|
467
|
-
*/
|
|
468
|
-
destroy(): Promise<void>
|
|
469
462
|
}
|
|
470
463
|
/****** Exposed namespace ******/
|
|
471
464
|
/**
|
|
@@ -772,20 +765,21 @@ export namespace SplitIO {
|
|
|
772
765
|
* If this value is older than 10 days ago (expiration time policy), the data is not used to update the storage content.
|
|
773
766
|
* @TODO configurable expiration time policy?
|
|
774
767
|
*/
|
|
775
|
-
|
|
768
|
+
lastUpdated: number,
|
|
776
769
|
/**
|
|
777
770
|
* Change number of the preloaded data.
|
|
778
771
|
* If this value is older than the current changeNumber at the storage, the data is not used to update the storage content.
|
|
779
772
|
*/
|
|
780
773
|
since: number,
|
|
781
774
|
/**
|
|
782
|
-
*
|
|
783
|
-
* @TODO rename to flags
|
|
775
|
+
* Map of feature flags to their stringified definitions.
|
|
784
776
|
*/
|
|
785
|
-
splitsData:
|
|
777
|
+
splitsData: {
|
|
778
|
+
[splitName: string]: string
|
|
779
|
+
},
|
|
786
780
|
/**
|
|
787
781
|
* Optional map of user keys to their list of segments.
|
|
788
|
-
* @TODO
|
|
782
|
+
* @TODO remove when releasing first version
|
|
789
783
|
*/
|
|
790
784
|
mySegmentsData?: {
|
|
791
785
|
[key: string]: string[]
|
|
@@ -793,10 +787,9 @@ export namespace SplitIO {
|
|
|
793
787
|
/**
|
|
794
788
|
* Optional map of segments to their stringified definitions.
|
|
795
789
|
* This property is ignored if `mySegmentsData` was provided.
|
|
796
|
-
* @TODO rename to segments
|
|
797
790
|
*/
|
|
798
791
|
segmentsData?: {
|
|
799
|
-
[segmentName: string]: string
|
|
792
|
+
[segmentName: string]: string
|
|
800
793
|
},
|
|
801
794
|
}
|
|
802
795
|
/**
|
|
@@ -75,7 +75,7 @@ export const EVENTS = 'ev';
|
|
|
75
75
|
export const TELEMETRY = 'te';
|
|
76
76
|
export const TOKEN = 'to';
|
|
77
77
|
export const SEGMENT = 'se';
|
|
78
|
-
export const
|
|
78
|
+
export const MY_SEGMENT = 'ms';
|
|
79
79
|
|
|
80
80
|
export const TREATMENT = 't';
|
|
81
81
|
export const TREATMENTS = 'ts';
|
|
@@ -105,8 +105,7 @@ export const DISABLED = 0;
|
|
|
105
105
|
export const ENABLED = 1;
|
|
106
106
|
export const PAUSED = 2;
|
|
107
107
|
|
|
108
|
-
export const FLAG_SPEC_VERSION = '1.
|
|
108
|
+
export const FLAG_SPEC_VERSION = '1.1';
|
|
109
109
|
|
|
110
110
|
// Matcher types
|
|
111
111
|
export const IN_SEGMENT = 'IN_SEGMENT';
|
|
112
|
-
export const IN_LARGE_SEGMENT = 'IN_LARGE_SEGMENT';
|
|
@@ -209,12 +209,11 @@ export function settingsValidation(config: unknown, validationParams: ISettingsV
|
|
|
209
209
|
const splitFiltersValidation = validateSplitFilters(log, sync.splitFilters, withDefaults.mode);
|
|
210
210
|
sync.splitFilters = splitFiltersValidation.validFilters;
|
|
211
211
|
sync.__splitFiltersValidation = splitFiltersValidation;
|
|
212
|
-
|
|
213
|
-
// ensure a valid flag spec version
|
|
214
212
|
sync.flagSpecVersion = flagSpec ? flagSpec(withDefaults) : FLAG_SPEC_VERSION;
|
|
213
|
+
|
|
215
214
|
// ensure a valid user consent value
|
|
216
215
|
// @ts-ignore, modify readonly prop
|
|
217
|
-
withDefaults.userConsent = consent
|
|
216
|
+
withDefaults.userConsent = consent(withDefaults);
|
|
218
217
|
|
|
219
218
|
return withDefaults;
|
|
220
219
|
}
|
|
@@ -3,6 +3,14 @@ import { ISettings, SDKMode } from '../../../types';
|
|
|
3
3
|
import { ILogger } from '../../../logger/types';
|
|
4
4
|
import { ERROR_STORAGE_INVALID } from '../../../logger/constants';
|
|
5
5
|
import { LOCALHOST_MODE, STANDALONE_MODE, STORAGE_PLUGGABLE, STORAGE_LOCALSTORAGE, STORAGE_MEMORY } from '../../../utils/constants';
|
|
6
|
+
import { IStorageFactoryParams, IStorageSync } from '../../../storages/types';
|
|
7
|
+
|
|
8
|
+
export function __InLocalStorageMockFactory(params: IStorageFactoryParams): IStorageSync {
|
|
9
|
+
const result = InMemoryStorageCSFactory(params);
|
|
10
|
+
result.splits.checkCache = () => true; // to emit SDK_READY_FROM_CACHE
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
__InLocalStorageMockFactory.type = STORAGE_MEMORY;
|
|
6
14
|
|
|
7
15
|
/**
|
|
8
16
|
* This function validates `settings.storage` object
|
|
@@ -22,6 +30,11 @@ export function validateStorageCS(settings: { log: ILogger, storage?: any, mode:
|
|
|
22
30
|
log.error(ERROR_STORAGE_INVALID);
|
|
23
31
|
}
|
|
24
32
|
|
|
33
|
+
// In localhost mode with InLocalStorage, fallback to a mock InLocalStorage to emit SDK_READY_FROM_CACHE
|
|
34
|
+
if (mode === LOCALHOST_MODE && storage.type === STORAGE_LOCALSTORAGE) {
|
|
35
|
+
return __InLocalStorageMockFactory;
|
|
36
|
+
}
|
|
37
|
+
|
|
25
38
|
if ([LOCALHOST_MODE, STANDALONE_MODE].indexOf(mode) === -1) {
|
|
26
39
|
// Consumer modes require an async storage
|
|
27
40
|
if (storage.type !== STORAGE_PLUGGABLE) throw new Error('A PluggableStorage instance is required on consumer mode');
|
|
@@ -25,7 +25,7 @@ export interface ISettingsValidationParams {
|
|
|
25
25
|
/** Localhost mode validator (`settings.sync.localhostMode`) */
|
|
26
26
|
localhost?: (settings: ISettings) => ISettings['sync']['localhostMode'],
|
|
27
27
|
/** User consent validator (`settings.userConsent`) */
|
|
28
|
-
consent
|
|
28
|
+
consent: (settings: ISettings) => ISettings['userConsent'],
|
|
29
29
|
/** Flag spec version validation. Configurable by the JS Synchronizer but not by the SDKs */
|
|
30
30
|
flagSpec?: (settings: ISettings) => ISettings['sync']['flagSpecVersion']
|
|
31
31
|
}
|
package/types/dtos/types.d.ts
CHANGED
|
@@ -21,9 +21,6 @@ export interface IWhitelistMatcherData {
|
|
|
21
21
|
export interface IInSegmentMatcherData {
|
|
22
22
|
segmentName: string;
|
|
23
23
|
}
|
|
24
|
-
export interface IInLargeSegmentMatcherData {
|
|
25
|
-
largeSegmentName: string;
|
|
26
|
-
}
|
|
27
24
|
export interface IDependencyMatcherData {
|
|
28
25
|
split: string;
|
|
29
26
|
treatments: string[];
|
|
@@ -36,7 +33,6 @@ interface ISplitMatcherBase {
|
|
|
36
33
|
attribute: string | null;
|
|
37
34
|
};
|
|
38
35
|
userDefinedSegmentMatcherData?: null | IInSegmentMatcherData;
|
|
39
|
-
userDefinedLargeSegmentMatcherData?: null | IInLargeSegmentMatcherData;
|
|
40
36
|
whitelistMatcherData?: null | IWhitelistMatcherData;
|
|
41
37
|
unaryNumericMatcherData?: null | IUnaryNumericMatcherData;
|
|
42
38
|
betweenMatcherData?: null | IBetweenMatcherData;
|
|
@@ -52,10 +48,6 @@ interface IInSegmentMatcher extends ISplitMatcherBase {
|
|
|
52
48
|
matcherType: 'IN_SEGMENT';
|
|
53
49
|
userDefinedSegmentMatcherData: IInSegmentMatcherData;
|
|
54
50
|
}
|
|
55
|
-
interface IInLargeSegmentMatcher extends ISplitMatcherBase {
|
|
56
|
-
matcherType: 'IN_LARGE_SEGMENT';
|
|
57
|
-
userDefinedLargeSegmentMatcherData: IInLargeSegmentMatcherData;
|
|
58
|
-
}
|
|
59
51
|
interface IWhitelistMatcher extends ISplitMatcherBase {
|
|
60
52
|
matcherType: 'WHITELIST';
|
|
61
53
|
whitelistMatcherData: IWhitelistMatcherData;
|
|
@@ -136,7 +128,7 @@ interface IInListSemverMatcher extends ISplitMatcherBase {
|
|
|
136
128
|
matcherType: 'IN_LIST_SEMVER';
|
|
137
129
|
whitelistMatcherData: IWhitelistMatcherData;
|
|
138
130
|
}
|
|
139
|
-
export declare type ISplitMatcher = IAllKeysMatcher | IInSegmentMatcher | IWhitelistMatcher | IEqualToMatcher | IGreaterThanOrEqualToMatcher | ILessThanOrEqualToMatcher | IBetweenMatcher | IEqualToSetMatcher | IContainsAnyOfSetMatcher | IContainsAllOfSetMatcher | IPartOfSetMatcher | IStartsWithMatcher | IEndsWithMatcher | IContainsStringMatcher | IInSplitTreatmentMatcher | IEqualToBooleanMatcher | IMatchesStringMatcher | IEqualToSemverMatcher | IGreaterThanOrEqualToSemverMatcher | ILessThanOrEqualToSemverMatcher | IBetweenSemverMatcher | IInListSemverMatcher
|
|
131
|
+
export declare type ISplitMatcher = IAllKeysMatcher | IInSegmentMatcher | IWhitelistMatcher | IEqualToMatcher | IGreaterThanOrEqualToMatcher | ILessThanOrEqualToMatcher | IBetweenMatcher | IEqualToSetMatcher | IContainsAnyOfSetMatcher | IContainsAllOfSetMatcher | IPartOfSetMatcher | IStartsWithMatcher | IEndsWithMatcher | IContainsStringMatcher | IInSplitTreatmentMatcher | IEqualToBooleanMatcher | IMatchesStringMatcher | IEqualToSemverMatcher | IGreaterThanOrEqualToSemverMatcher | ILessThanOrEqualToSemverMatcher | IBetweenSemverMatcher | IInListSemverMatcher;
|
|
140
132
|
/** Split object */
|
|
141
133
|
export interface ISplitPartition {
|
|
142
134
|
treatment: string;
|
|
@@ -181,16 +173,13 @@ export interface ISegmentChangesResponse {
|
|
|
181
173
|
since: number;
|
|
182
174
|
till: number;
|
|
183
175
|
}
|
|
176
|
+
export interface IMySegmentsResponseItem {
|
|
177
|
+
id: string;
|
|
178
|
+
name: string;
|
|
179
|
+
}
|
|
180
|
+
/** Interface of the parsed JSON response of `/mySegments/{userKey}` */
|
|
184
181
|
export interface IMySegmentsResponse {
|
|
185
|
-
|
|
186
|
-
k?: {
|
|
187
|
-
n: string;
|
|
188
|
-
}[];
|
|
189
|
-
}
|
|
190
|
-
/** Interface of the parsed JSON response of `/memberships/{userKey}` */
|
|
191
|
-
export interface IMembershipsResponse {
|
|
192
|
-
ms?: IMySegmentsResponse;
|
|
193
|
-
ls?: IMySegmentsResponse;
|
|
182
|
+
mySegments: IMySegmentsResponseItem[];
|
|
194
183
|
}
|
|
195
184
|
/** Metadata internal type for storages */
|
|
196
185
|
export interface IMetadata {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IInSegmentMatcherData
|
|
1
|
+
import { IInSegmentMatcherData } from '../../dtos/types';
|
|
2
2
|
/**
|
|
3
3
|
* Extract segment name as a plain string.
|
|
4
4
|
*/
|
|
5
|
-
export declare function segmentTransform(segment?: IInSegmentMatcherData
|
|
5
|
+
export declare function segmentTransform(segment?: IInSegmentMatcherData): string | undefined;
|
|
@@ -77,7 +77,7 @@ export declare const WARN_SPLITS_FILTER_IGNORED = 219;
|
|
|
77
77
|
export declare const WARN_SPLITS_FILTER_INVALID = 220;
|
|
78
78
|
export declare const WARN_SPLITS_FILTER_EMPTY = 221;
|
|
79
79
|
export declare const WARN_SDK_KEY = 222;
|
|
80
|
-
export declare const
|
|
80
|
+
export declare const STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = 223;
|
|
81
81
|
export declare const STREAMING_PARSING_SPLIT_UPDATE = 224;
|
|
82
82
|
export declare const WARN_INVALID_FLAGSET = 225;
|
|
83
83
|
export declare const WARN_LOWERCASE_FLAGSET = 226;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IEventEmitter
|
|
1
|
+
import { IEventEmitter } from '../types';
|
|
2
2
|
import { IReadinessManager, ISplitsEventEmitter } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Factory of readiness manager, which handles the ready / update event propagation.
|
|
5
5
|
*/
|
|
6
|
-
export declare function readinessManagerFactory(EventEmitter: new () => IEventEmitter,
|
|
6
|
+
export declare function readinessManagerFactory(EventEmitter: new () => IEventEmitter, readyTimeout?: number, splits?: ISplitsEventEmitter): IReadinessManager;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ISdkReadinessManager } from './types';
|
|
2
|
-
import { IEventEmitter
|
|
2
|
+
import { IEventEmitter } from '../types';
|
|
3
|
+
import { ILogger } from '../logger/types';
|
|
3
4
|
/**
|
|
4
5
|
* SdkReadinessManager factory, which provides the public status API of SDK clients and manager: ready promise, readiness event emitter and constants (SDK_READY, etc).
|
|
5
6
|
* It also updates logs related warnings and errors.
|
|
@@ -7,4 +8,4 @@ import { IEventEmitter, ISettings } from '../types';
|
|
|
7
8
|
* @param readyTimeout time in millis to emit SDK_READY_TIME_OUT event
|
|
8
9
|
* @param readinessManager optional readinessManager to use. only used internally for `shared` method
|
|
9
10
|
*/
|
|
10
|
-
export declare function sdkReadinessManagerFactory(EventEmitter: new () => IEventEmitter,
|
|
11
|
+
export declare function sdkReadinessManagerFactory(log: ILogger, EventEmitter: new () => IEventEmitter, readyTimeout?: number, readinessManager?: import("./types").IReadinessManager): ISdkReadinessManager;
|
|
@@ -46,9 +46,8 @@ export interface IReadinessManager {
|
|
|
46
46
|
timeout(): void;
|
|
47
47
|
setDestroyed(): void;
|
|
48
48
|
destroy(): void;
|
|
49
|
-
init(): void;
|
|
50
49
|
/** for client-side */
|
|
51
|
-
shared(): IReadinessManager;
|
|
50
|
+
shared(readyTimeout?: number): IReadinessManager;
|
|
52
51
|
}
|
|
53
52
|
/** SDK readiness manager */
|
|
54
53
|
export interface ISdkReadinessManager {
|
|
@@ -60,6 +59,6 @@ export interface ISdkReadinessManager {
|
|
|
60
59
|
*/
|
|
61
60
|
incInternalReadyCbCount(): void;
|
|
62
61
|
/** for client-side */
|
|
63
|
-
shared(): ISdkReadinessManager;
|
|
62
|
+
shared(readyTimeout?: number): ISdkReadinessManager;
|
|
64
63
|
}
|
|
65
64
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SplitIO } from '../types';
|
|
2
2
|
import { ISdkFactoryContext } from '../sdkFactory/types';
|
|
3
3
|
/**
|
|
4
|
-
* Factory of client method for server-side SDKs
|
|
4
|
+
* Factory of client method for server-side SDKs (ISDK and IAsyncSDK)
|
|
5
5
|
*/
|
|
6
6
|
export declare function sdkClientMethodFactory(params: ISdkFactoryContext): () => SplitIO.IClient | SplitIO.IAsyncClient;
|
|
@@ -8,7 +8,7 @@ import { IStorageAsync, IStorageSync, IStorageFactoryParams } from '../storages/
|
|
|
8
8
|
import { ISyncManager } from '../sync/types';
|
|
9
9
|
import { IImpressionObserver } from '../trackers/impressionObserver/types';
|
|
10
10
|
import { IImpressionsTracker, IEventTracker, ITelemetryTracker, IFilterAdapter, IUniqueKeysTracker } from '../trackers/types';
|
|
11
|
-
import { SplitIO, ISettings, IEventEmitter
|
|
11
|
+
import { SplitIO, ISettings, IEventEmitter } from '../types';
|
|
12
12
|
/**
|
|
13
13
|
* Environment related dependencies.
|
|
14
14
|
*/
|
|
@@ -47,8 +47,6 @@ export interface ISdkFactoryContext {
|
|
|
47
47
|
signalListener?: ISignalListener;
|
|
48
48
|
splitApi?: ISplitApi;
|
|
49
49
|
syncManager?: ISyncManager;
|
|
50
|
-
clients: Record<string, IBasicClient>;
|
|
51
|
-
whenInit(cb: () => void): void;
|
|
52
50
|
}
|
|
53
51
|
export interface ISdkFactoryContextSync extends ISdkFactoryContext {
|
|
54
52
|
storage: IStorageSync;
|
|
@@ -64,7 +62,6 @@ export interface ISdkFactoryContextAsync extends ISdkFactoryContext {
|
|
|
64
62
|
* Object parameter with the modules required to create an SDK factory instance
|
|
65
63
|
*/
|
|
66
64
|
export interface ISdkFactoryParams {
|
|
67
|
-
isPure?: boolean;
|
|
68
65
|
settings: ISettings;
|
|
69
66
|
platform: IPlatform;
|
|
70
67
|
storageFactory: (params: IStorageFactoryParams) => IStorageSync | IStorageAsync;
|
|
@@ -9,4 +9,4 @@ import { ITelemetryTracker } from '../trackers/types';
|
|
|
9
9
|
* @param platform object containing environment-specific dependencies
|
|
10
10
|
* @param telemetryTracker telemetry tracker
|
|
11
11
|
*/
|
|
12
|
-
export declare function splitApiFactory(settings: ISettings, platform:
|
|
12
|
+
export declare function splitApiFactory(settings: ISettings, platform: IPlatform, telemetryTracker: ITelemetryTracker): ISplitApi;
|
|
@@ -7,4 +7,4 @@ import { IPlatform } from '../sdkFactory/types';
|
|
|
7
7
|
* @param settings SDK settings, used to access authorizationKey, logger instance and metadata (SDK version, ip and hostname) to set additional headers
|
|
8
8
|
* @param platform object containing environment-specific dependencies
|
|
9
9
|
*/
|
|
10
|
-
export declare function splitHttpClientFactory(settings: ISettings, { getOptions, getFetch }:
|
|
10
|
+
export declare function splitHttpClientFactory(settings: ISettings, { getOptions, getFetch }: IPlatform): ISplitHttpClient;
|
|
@@ -18,7 +18,7 @@ export declare type ISplitHttpClient = (url: string, options?: IRequestOptions,
|
|
|
18
18
|
export declare type IFetchAuth = (userKeys?: string[]) => Promise<IResponse>;
|
|
19
19
|
export declare type IFetchSplitChanges = (since: number, noCache?: boolean, till?: number) => Promise<IResponse>;
|
|
20
20
|
export declare type IFetchSegmentChanges = (since: number, segmentName: string, noCache?: boolean, till?: number) => Promise<IResponse>;
|
|
21
|
-
export declare type
|
|
21
|
+
export declare type IFetchMySegments = (userMatchingKey: string, noCache?: boolean) => Promise<IResponse>;
|
|
22
22
|
export declare type IPostEventsBulk = (body: string, headers?: Record<string, string>) => Promise<IResponse>;
|
|
23
23
|
export declare type IPostUniqueKeysBulkCs = (body: string, headers?: Record<string, string>) => Promise<IResponse>;
|
|
24
24
|
export declare type IPostUniqueKeysBulkSs = (body: string, headers?: Record<string, string>) => Promise<IResponse>;
|
|
@@ -32,7 +32,7 @@ export interface ISplitApi {
|
|
|
32
32
|
fetchAuth: IFetchAuth;
|
|
33
33
|
fetchSplitChanges: IFetchSplitChanges;
|
|
34
34
|
fetchSegmentChanges: IFetchSegmentChanges;
|
|
35
|
-
|
|
35
|
+
fetchMySegments: IFetchMySegments;
|
|
36
36
|
postEventsBulk: IPostEventsBulk;
|
|
37
37
|
postUniqueKeysBulkCs: IPostUniqueKeysBulkCs;
|
|
38
38
|
postUniqueKeysBulkSs: IPostUniqueKeysBulkSs;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { IMySegmentsResponse } from '../dtos/types';
|
|
2
|
-
import { MySegmentsData } from '../sync/polling/types';
|
|
3
1
|
import { ISegmentsCacheSync } from './types';
|
|
4
2
|
/**
|
|
5
3
|
* This class provides a skeletal implementation of the ISegmentsCacheSync interface
|
|
@@ -24,7 +22,7 @@ export declare abstract class AbstractSegmentsCacheSync implements ISegmentsCach
|
|
|
24
22
|
/**
|
|
25
23
|
* clear the cache.
|
|
26
24
|
*/
|
|
27
|
-
clear(): void;
|
|
25
|
+
abstract clear(): void;
|
|
28
26
|
/**
|
|
29
27
|
* For server-side synchronizer: add the given list of segments to the cache, with an empty list of keys. The segments that already exist are not modified.
|
|
30
28
|
* For client-side synchronizer: the method is not used.
|
|
@@ -41,14 +39,18 @@ export declare abstract class AbstractSegmentsCacheSync implements ISegmentsCach
|
|
|
41
39
|
*/
|
|
42
40
|
abstract getKeysCount(): number;
|
|
43
41
|
/**
|
|
44
|
-
* For server-side synchronizer: change number of `name` segment.
|
|
45
|
-
* For client-side synchronizer:
|
|
42
|
+
* For server-side synchronizer: set the change number of `name` segment.
|
|
43
|
+
* For client-side synchronizer: the method is not used.
|
|
44
|
+
*/
|
|
45
|
+
setChangeNumber(name: string, changeNumber: number): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* For server-side synchronizer: get the change number of `name` segment.
|
|
48
|
+
* For client-side synchronizer: the method is not used.
|
|
46
49
|
*/
|
|
47
|
-
|
|
48
|
-
abstract getChangeNumber(name: string): number;
|
|
50
|
+
getChangeNumber(name: string): number | undefined;
|
|
49
51
|
/**
|
|
50
52
|
* For server-side synchronizer: the method is not used.
|
|
51
|
-
* For client-side synchronizer:
|
|
53
|
+
* For client-side synchronizer: reset the cache with the given list of segments.
|
|
52
54
|
*/
|
|
53
|
-
resetSegments(
|
|
55
|
+
resetSegments(names: string[]): boolean;
|
|
54
56
|
}
|
|
@@ -19,6 +19,11 @@ export declare abstract class AbstractSplitsCacheAsync implements ISplitsCacheAs
|
|
|
19
19
|
abstract trafficTypeExists(trafficType: string): Promise<boolean>;
|
|
20
20
|
abstract clear(): Promise<boolean | void>;
|
|
21
21
|
usesSegments(): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Check if the splits information is already stored in cache.
|
|
24
|
+
* Noop, just keeping the interface. This is used by client-side implementations only.
|
|
25
|
+
*/
|
|
26
|
+
checkCache(): Promise<boolean>;
|
|
22
27
|
/**
|
|
23
28
|
* Kill `name` split and set `defaultTreatment` and `changeNumber`.
|
|
24
29
|
* Used for SPLIT_KILL push notifications.
|
|
@@ -12,13 +12,18 @@ export declare abstract class AbstractSplitsCacheSync implements ISplitsCacheSyn
|
|
|
12
12
|
removeSplits(names: string[]): boolean[];
|
|
13
13
|
abstract getSplit(name: string): ISplit | null;
|
|
14
14
|
getSplits(names: string[]): Record<string, ISplit | null>;
|
|
15
|
-
abstract setChangeNumber(changeNumber: number): boolean
|
|
15
|
+
abstract setChangeNumber(changeNumber: number): boolean;
|
|
16
16
|
abstract getChangeNumber(): number;
|
|
17
17
|
getAll(): ISplit[];
|
|
18
18
|
abstract getSplitNames(): string[];
|
|
19
19
|
abstract trafficTypeExists(trafficType: string): boolean;
|
|
20
20
|
abstract usesSegments(): boolean;
|
|
21
21
|
abstract clear(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Check if the splits information is already stored in cache. This data can be preloaded.
|
|
24
|
+
* It is used as condition to emit SDK_SPLITS_CACHE_LOADED, and then SDK_READY_FROM_CACHE.
|
|
25
|
+
*/
|
|
26
|
+
checkCache(): boolean;
|
|
22
27
|
/**
|
|
23
28
|
* Kill `name` split and set `defaultTreatment` and `changeNumber`.
|
|
24
29
|
* Used for SPLIT_KILL push notifications.
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { KeyBuilder } from './KeyBuilder';
|
|
2
|
-
export
|
|
3
|
-
buildSegmentNameKey(segmentName: string): string;
|
|
4
|
-
extractSegmentName(builtSegmentKeyName: string): string | undefined;
|
|
5
|
-
extractOldSegmentKey(builtSegmentKeyName: string): string | undefined;
|
|
6
|
-
buildTillKey(): string;
|
|
7
|
-
}
|
|
8
|
-
export declare class KeyBuilderCS extends KeyBuilder implements MySegmentsKeyBuilder {
|
|
2
|
+
export declare class KeyBuilderCS extends KeyBuilder {
|
|
9
3
|
protected readonly regexSplitsCacheKey: RegExp;
|
|
10
4
|
protected readonly matchingKey: string;
|
|
11
5
|
constructor(prefix: string, matchingKey: string);
|
|
@@ -14,9 +8,8 @@ export declare class KeyBuilderCS extends KeyBuilder implements MySegmentsKeyBui
|
|
|
14
8
|
*/
|
|
15
9
|
buildSegmentNameKey(segmentName: string): string;
|
|
16
10
|
extractSegmentName(builtSegmentKeyName: string): string | undefined;
|
|
11
|
+
buildOldSegmentNameKey(segmentName: string): string;
|
|
17
12
|
extractOldSegmentKey(builtSegmentKeyName: string): string | undefined;
|
|
18
13
|
buildLastUpdatedKey(): string;
|
|
19
14
|
isSplitsCacheKey(key: string): boolean;
|
|
20
|
-
buildTillKey(): string;
|
|
21
15
|
}
|
|
22
|
-
export declare function myLargeSegmentsKeyBuilder(prefix: string, matchingKey: string): MySegmentsKeyBuilder;
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import { SplitIO } from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import { DataLoader } from './types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* (https://github.com/godaddy/split-javascript-data-loader/blob/master/src/load-data.js)
|
|
4
|
+
* Factory of client-side storage loader
|
|
6
5
|
*
|
|
7
|
-
* @param preloadedData validated data following the format proposed in https://github.com/godaddy/split-javascript-data-loader
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
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
|
|
6
|
+
* @param preloadedData validated data following the format proposed in https://github.com/godaddy/split-javascript-data-loader
|
|
7
|
+
* and extended with a `mySegmentsData` property.
|
|
8
|
+
* @returns function to preload the storage
|
|
15
9
|
*/
|
|
16
|
-
export declare function
|
|
17
|
-
splits?: ISplitsCacheSync;
|
|
18
|
-
segments: ISegmentsCacheSync;
|
|
19
|
-
largeSegments?: ISegmentsCacheSync;
|
|
20
|
-
}, matchingKey?: string): void;
|
|
21
|
-
export declare function getSnapshot(storage: IStorageSync, userKeys?: SplitIO.SplitKey[]): SplitIO.PreloadedData;
|
|
10
|
+
export declare function dataLoaderFactory(preloadedData: SplitIO.PreloadedData): DataLoader;
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { ILogger } from '../../logger/types';
|
|
2
2
|
import { AbstractSegmentsCacheSync } from '../AbstractSegmentsCacheSync';
|
|
3
|
-
import
|
|
3
|
+
import { KeyBuilderCS } from '../KeyBuilderCS';
|
|
4
4
|
export declare class MySegmentsCacheInLocal extends AbstractSegmentsCacheSync {
|
|
5
5
|
private readonly keys;
|
|
6
6
|
private readonly log;
|
|
7
|
-
constructor(log: ILogger, keys:
|
|
7
|
+
constructor(log: ILogger, keys: KeyBuilderCS);
|
|
8
|
+
/**
|
|
9
|
+
* Removes list of segments from localStorage
|
|
10
|
+
* @NOTE this method is not being used at the moment.
|
|
11
|
+
*/
|
|
12
|
+
clear(): void;
|
|
8
13
|
addToSegment(name: string): boolean;
|
|
9
14
|
removeFromSegment(name: string): boolean;
|
|
10
15
|
isInSegment(name: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Reset (update) the cached list of segments with the given list, removing and adding segments if necessary.
|
|
18
|
+
*
|
|
19
|
+
* @param {string[]} segmentNames list of segment names
|
|
20
|
+
* @returns boolean indicating if the cache was updated (i.e., given list was different from the cached one)
|
|
21
|
+
*/
|
|
22
|
+
resetSegments(names: string[]): boolean;
|
|
11
23
|
getRegisteredSegments(): string[];
|
|
12
24
|
getKeysCount(): number;
|
|
13
|
-
setChangeNumber(name?: string, changeNumber?: number): void;
|
|
14
|
-
getChangeNumber(): number;
|
|
15
25
|
}
|
|
@@ -35,6 +35,12 @@ 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;
|
|
38
44
|
/**
|
|
39
45
|
* Clean Splits cache if its `lastUpdated` timestamp is older than the given `expirationTimestamp`,
|
|
40
46
|
*
|
|
@@ -5,12 +5,18 @@ import { AbstractSegmentsCacheSync } from '../AbstractSegmentsCacheSync';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class MySegmentsCacheInMemory extends AbstractSegmentsCacheSync {
|
|
7
7
|
private segmentCache;
|
|
8
|
-
|
|
8
|
+
clear(): void;
|
|
9
9
|
addToSegment(name: string): boolean;
|
|
10
10
|
removeFromSegment(name: string): boolean;
|
|
11
11
|
isInSegment(name: string): boolean;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Reset (update) the cached list of segments with the given list, removing and adding segments if necessary.
|
|
14
|
+
* @NOTE based on the way we use segments in the browser, this way is the best option
|
|
15
|
+
*
|
|
16
|
+
* @param {string[]} names list of segment names
|
|
17
|
+
* @returns boolean indicating if the cache was updated (i.e., given list was different from the cached one)
|
|
18
|
+
*/
|
|
19
|
+
resetSegments(names: string[]): boolean;
|
|
14
20
|
getRegisteredSegments(): string[];
|
|
15
21
|
getKeysCount(): number;
|
|
16
22
|
}
|
|
@@ -15,5 +15,5 @@ export declare class SegmentsCacheInMemory extends AbstractSegmentsCacheSync {
|
|
|
15
15
|
getRegisteredSegments(): string[];
|
|
16
16
|
getKeysCount(): number;
|
|
17
17
|
setChangeNumber(name: string, changeNumber: number): boolean;
|
|
18
|
-
getChangeNumber(name: string): number;
|
|
18
|
+
getChangeNumber(name: string): number | undefined;
|
|
19
19
|
}
|
|
@@ -10,7 +10,7 @@ export declare class SplitsCacheInMemory extends AbstractSplitsCacheSync {
|
|
|
10
10
|
private splitsCache;
|
|
11
11
|
private ttCache;
|
|
12
12
|
private changeNumber;
|
|
13
|
-
private
|
|
13
|
+
private splitsWithSegmentsCount;
|
|
14
14
|
private flagSetsCache;
|
|
15
15
|
constructor(splitFiltersValidation?: ISplitFiltersValidation);
|
|
16
16
|
clear(): void;
|