@splitsoftware/splitio-commons 1.17.1-rc.4 → 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 -29
- 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 +8 -18
- 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 +15 -9
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +15 -9
- package/cjs/sdkFactory/index.js +10 -32
- 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 +33 -0
- package/cjs/storages/AbstractSplitsCacheSync.js +1 -2
- package/cjs/storages/KeyBuilderCS.js +5 -23
- package/cjs/storages/dataLoader.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +56 -33
- package/cjs/storages/inLocalStorage/index.js +2 -6
- package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -6
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +44 -13
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +28 -14
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +9 -8
- package/cjs/storages/inMemory/TelemetryCacheInMemory.js +10 -7
- package/cjs/storages/inRedis/SegmentsCacheInRedis.js +21 -15
- package/cjs/storages/inRedis/index.js +11 -5
- package/cjs/storages/pluggable/SegmentsCachePluggable.js +34 -13
- package/cjs/storages/pluggable/inMemoryWrapper.js +1 -1
- package/cjs/sync/offline/syncManagerOffline.js +11 -18
- 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/syncTasks/mySegmentsSyncTask.js +2 -2
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +21 -15
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +28 -12
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +1 -1
- 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/syncManagerOnline.js +21 -20
- package/cjs/sync/syncTask.js +2 -2
- package/cjs/trackers/eventTracker.js +10 -12
- package/cjs/trackers/impressionsTracker.js +14 -16
- package/cjs/trackers/uniqueKeysTracker.js +3 -5
- package/cjs/utils/constants/index.js +4 -5
- package/cjs/utils/settingsValidation/index.js +1 -2
- 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 +8 -18
- 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 +13 -7
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +13 -7
- package/esm/sdkFactory/index.js +10 -32
- 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 +30 -0
- package/esm/storages/AbstractSplitsCacheSync.js +2 -3
- package/esm/storages/KeyBuilderCS.js +4 -21
- package/esm/storages/dataLoader.js +1 -1
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +56 -33
- package/esm/storages/inLocalStorage/index.js +3 -7
- package/esm/storages/inMemory/InMemoryStorageCS.js +1 -6
- package/esm/storages/inMemory/MySegmentsCacheInMemory.js +44 -13
- package/esm/storages/inMemory/SegmentsCacheInMemory.js +28 -14
- package/esm/storages/inMemory/SplitsCacheInMemory.js +9 -8
- package/esm/storages/inMemory/TelemetryCacheInMemory.js +10 -7
- package/esm/storages/inRedis/SegmentsCacheInRedis.js +21 -15
- package/esm/storages/inRedis/index.js +11 -5
- package/esm/storages/pluggable/SegmentsCachePluggable.js +34 -13
- package/esm/storages/pluggable/inMemoryWrapper.js +1 -1
- package/esm/sync/offline/syncManagerOffline.js +11 -18
- 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/syncTasks/mySegmentsSyncTask.js +2 -2
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +21 -15
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +28 -12
- package/esm/sync/polling/updaters/splitChangesUpdater.js +1 -1
- 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/syncManagerOnline.js +21 -20
- package/esm/sync/syncTask.js +2 -2
- package/esm/trackers/eventTracker.js +10 -12
- package/esm/trackers/impressionsTracker.js +14 -16
- package/esm/trackers/uniqueKeysTracker.js +3 -5
- package/esm/utils/constants/index.js +2 -3
- package/esm/utils/settingsValidation/index.js +1 -2
- 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 +8 -19
- package/src/readiness/sdkReadinessManager.ts +7 -7
- package/src/readiness/types.ts +2 -5
- package/src/sdkClient/sdkClient.ts +5 -5
- package/src/sdkClient/sdkClientMethod.ts +1 -4
- package/src/sdkClient/sdkClientMethodCS.ts +15 -7
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +15 -7
- package/src/sdkFactory/index.ts +12 -35
- package/src/sdkFactory/types.ts +1 -4
- 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 +68 -0
- package/src/storages/AbstractSplitsCacheSync.ts +3 -4
- package/src/storages/KeyBuilderCS.ts +5 -34
- package/src/storages/dataLoader.ts +1 -1
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +63 -33
- package/src/storages/inLocalStorage/index.ts +4 -8
- package/src/storages/inMemory/InMemoryStorageCS.ts +1 -6
- package/src/storages/inMemory/MySegmentsCacheInMemory.ts +47 -13
- package/src/storages/inMemory/SegmentsCacheInMemory.ts +27 -13
- package/src/storages/inMemory/SplitsCacheInMemory.ts +9 -7
- package/src/storages/inMemory/TelemetryCacheInMemory.ts +11 -7
- package/src/storages/inRedis/SegmentsCacheInRedis.ts +24 -15
- package/src/storages/inRedis/index.ts +12 -6
- package/src/storages/pluggable/SegmentsCachePluggable.ts +37 -13
- package/src/storages/pluggable/inMemoryWrapper.ts +1 -1
- package/src/storages/types.ts +17 -15
- package/src/sync/offline/syncManagerOffline.ts +13 -21
- 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/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 +29 -13
- package/src/sync/polling/updaters/splitChangesUpdater.ts +1 -1
- 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/syncManagerOnline.ts +17 -17
- package/src/sync/syncTask.ts +2 -2
- package/src/sync/types.ts +1 -1
- package/src/trackers/eventTracker.ts +8 -11
- package/src/trackers/impressionsTracker.ts +10 -13
- package/src/trackers/types.ts +0 -1
- package/src/trackers/uniqueKeysTracker.ts +4 -6
- package/src/types.ts +1 -7
- package/src/utils/constants/index.ts +2 -3
- package/src/utils/settingsValidation/index.ts +2 -3
- 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 -5
- package/types/sdkClient/sdkClientMethod.d.ts +1 -1
- package/types/sdkFactory/types.d.ts +1 -3
- 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/AbstractSplitsCacheSync.d.ts +1 -1
- package/types/storages/KeyBuilderCS.d.ts +2 -9
- package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +18 -8
- package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +13 -7
- package/types/storages/inMemory/SegmentsCacheInMemory.d.ts +8 -6
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +2 -1
- package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +6 -4
- package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +4 -7
- package/types/storages/inRedis/index.d.ts +1 -1
- package/types/storages/pluggable/SegmentsCachePluggable.d.ts +17 -5
- package/types/storages/pluggable/inMemoryWrapper.d.ts +1 -1
- package/types/storages/types.d.ts +15 -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/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 +0 -1
- package/types/types.d.ts +1 -7
- package/types/utils/constants/index.d.ts +2 -3
- 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/cjs/storages/AbstractMySegmentsCacheSync.js +0 -60
- package/esm/evaluator/matchers/large_segment.js +0 -12
- package/esm/sdkClient/identity.js +0 -3
- package/esm/storages/AbstractMySegmentsCacheSync.js +0 -57
- package/src/evaluator/matchers/large_segment.ts +0 -18
- package/src/sdkClient/identity.ts +0 -5
- package/src/storages/AbstractMySegmentsCacheSync.ts +0 -94
- 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
|
@@ -103,7 +103,7 @@ export type DROPPED = 1;
|
|
|
103
103
|
export type DEDUPED = 2;
|
|
104
104
|
export type ImpressionDataType = QUEUED | DROPPED | DEDUPED
|
|
105
105
|
export type EventDataType = QUEUED | DROPPED;
|
|
106
|
-
export type UpdatesFromSSEEnum = SPLITS |
|
|
106
|
+
export type UpdatesFromSSEEnum = SPLITS | MY_SEGMENT;
|
|
107
107
|
|
|
108
108
|
export type SPLITS = 'sp';
|
|
109
109
|
export type IMPRESSIONS = 'im';
|
|
@@ -112,8 +112,8 @@ export type EVENTS = 'ev';
|
|
|
112
112
|
export type TELEMETRY = 'te';
|
|
113
113
|
export type TOKEN = 'to';
|
|
114
114
|
export type SEGMENT = 'se';
|
|
115
|
-
export type
|
|
116
|
-
export type OperationType = SPLITS | IMPRESSIONS | IMPRESSIONS_COUNT | EVENTS | TELEMETRY | TOKEN | SEGMENT |
|
|
115
|
+
export type MY_SEGMENT = 'ms';
|
|
116
|
+
export type OperationType = SPLITS | IMPRESSIONS | IMPRESSIONS_COUNT | EVENTS | TELEMETRY | TOKEN | SEGMENT | MY_SEGMENT;
|
|
117
117
|
|
|
118
118
|
export type LastSync = Partial<Record<OperationType, number | undefined>>
|
|
119
119
|
export type HttpErrors = Partial<Record<OperationType, { [statusCode: string]: number }>>
|
|
@@ -158,9 +158,8 @@ export type TelemetryUsageStats = {
|
|
|
158
158
|
|
|
159
159
|
// amount of instant updates that we are doing by avoiding fetching to Split servers
|
|
160
160
|
export type UpdatesFromSSE = {
|
|
161
|
-
sp
|
|
161
|
+
sp: number, // splits
|
|
162
162
|
ms?: number, // my segments
|
|
163
|
-
mls?: number // my large segments
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
// 'metrics/usage' JSON request body
|
|
@@ -176,14 +175,12 @@ export type TelemetryUsageStatsPayload = TelemetryUsageStats & {
|
|
|
176
175
|
spC?: number, // splitCount
|
|
177
176
|
seC?: number, // segmentCount
|
|
178
177
|
skC?: number, // segmentKeyCount
|
|
179
|
-
lsC?: number, // largeSegmentCount
|
|
180
|
-
lskC?: number, // largeSegmentKeyCount
|
|
181
178
|
sL?: number, // sessionLengthMs
|
|
182
179
|
eQ: number, // eventsQueued
|
|
183
180
|
eD: number, // eventsDropped
|
|
184
181
|
sE: Array<StreamingEvent>, // streamingEvents
|
|
185
182
|
t?: Array<string>, // tags
|
|
186
|
-
ufs?: UpdatesFromSSE, //
|
|
183
|
+
ufs?: UpdatesFromSSE, //UpdatesFromSSE
|
|
187
184
|
}
|
|
188
185
|
|
|
189
186
|
/**
|
|
@@ -143,27 +143,27 @@ export function syncManagerOnlineFactory(
|
|
|
143
143
|
|
|
144
144
|
const mySegmentsSyncTask = (pollingManager as IPollingManagerCS).add(matchingKey, readinessManager, storage);
|
|
145
145
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (
|
|
146
|
+
return {
|
|
147
|
+
isRunning: mySegmentsSyncTask.isRunning,
|
|
148
|
+
start() {
|
|
149
|
+
if (syncEnabled) {
|
|
150
|
+
if (pushManager) {
|
|
151
|
+
if (pollingManager!.isRunning()) {
|
|
152
|
+
// if doing polling, we must start the periodic fetch of data
|
|
153
|
+
if (storage.splits.usesSegments()) mySegmentsSyncTask.start();
|
|
154
|
+
} else {
|
|
155
|
+
// if not polling, we must execute the sync task for the initial fetch
|
|
156
|
+
// of segments since `syncAll` was already executed when starting the main client
|
|
157
|
+
mySegmentsSyncTask.execute();
|
|
158
|
+
}
|
|
159
|
+
pushManager.add(matchingKey, mySegmentsSyncTask);
|
|
152
160
|
} else {
|
|
153
|
-
|
|
154
|
-
// of segments since `syncAll` was already executed when starting the main client
|
|
155
|
-
mySegmentsSyncTask.execute();
|
|
161
|
+
if (storage.splits.usesSegments()) mySegmentsSyncTask.start();
|
|
156
162
|
}
|
|
157
|
-
pushManager.add(matchingKey, mySegmentsSyncTask);
|
|
158
163
|
} else {
|
|
159
|
-
if (
|
|
164
|
+
if (!readinessManager.isReady()) mySegmentsSyncTask.execute();
|
|
160
165
|
}
|
|
161
|
-
}
|
|
162
|
-
if (!readinessManager.isReady()) mySegmentsSyncTask.execute();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return {
|
|
166
|
+
},
|
|
167
167
|
stop() {
|
|
168
168
|
// check in case `client.destroy()` has been invoked more than once for the same client
|
|
169
169
|
const mySegmentsSyncTask = (pollingManager as IPollingManagerCS).get(matchingKey);
|
package/src/sync/syncTask.ts
CHANGED
|
@@ -68,8 +68,8 @@ export function syncTaskFactory<Input extends any[], Output = any>(log: ILogger,
|
|
|
68
68
|
},
|
|
69
69
|
|
|
70
70
|
stop() {
|
|
71
|
-
running
|
|
72
|
-
|
|
71
|
+
if (running) {
|
|
72
|
+
running = false;
|
|
73
73
|
log.debug(SYNC_TASK_STOP, [taskName]);
|
|
74
74
|
clearTimeout(timeoutID);
|
|
75
75
|
timeoutID = undefined;
|
package/src/sync/types.ts
CHANGED
|
@@ -44,5 +44,5 @@ export interface ISyncManager extends ITask {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface ISyncManagerCS extends ISyncManager {
|
|
47
|
-
shared(matchingKey: string, readinessManager: IReadinessManager, storage: IStorageSync):
|
|
47
|
+
shared(matchingKey: string, readinessManager: IReadinessManager, storage: IStorageSync): ISyncManager | undefined
|
|
48
48
|
}
|
|
@@ -16,7 +16,6 @@ import { isConsumerMode } from '../utils/settingsValidation/mode';
|
|
|
16
16
|
export function eventTrackerFactory(
|
|
17
17
|
settings: ISettings,
|
|
18
18
|
eventsCache: IEventsCacheBase,
|
|
19
|
-
whenInit: (cb: () => void) => void,
|
|
20
19
|
integrationsManager?: IEventsHandler,
|
|
21
20
|
telemetryCache?: ITelemetryCacheSync | ITelemetryCacheAsync
|
|
22
21
|
): IEventTracker {
|
|
@@ -32,16 +31,14 @@ export function eventTrackerFactory(
|
|
|
32
31
|
if (tracked) {
|
|
33
32
|
log.info(EVENTS_TRACKER_SUCCESS, [msg]);
|
|
34
33
|
if (integrationsManager) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
});
|
|
34
|
+
// Wrap in a timeout because we don't want it to be blocking.
|
|
35
|
+
setTimeout(function () {
|
|
36
|
+
// copy of event, to avoid unexpected behaviour if modified by integrations
|
|
37
|
+
const eventDataCopy = objectAssign({}, eventData);
|
|
38
|
+
if (properties) eventDataCopy.properties = objectAssign({}, properties);
|
|
39
|
+
// integrationsManager does not throw errors (they are internally handled by each integration module)
|
|
40
|
+
integrationsManager.handleEvent(eventDataCopy);
|
|
41
|
+
}, 0);
|
|
45
42
|
}
|
|
46
43
|
} else {
|
|
47
44
|
log.error(ERROR_EVENTS_TRACKER, [msg]);
|
|
@@ -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 {
|
|
@@ -67,19 +66,17 @@ export function impressionsTrackerFactory(
|
|
|
67
66
|
sdkLanguageVersion: version
|
|
68
67
|
};
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (integrationsManager) integrationsManager.handleImpression(impressionData);
|
|
69
|
+
// Wrap in a timeout because we don't want it to be blocking.
|
|
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
|
@@ -426,7 +426,7 @@ export interface IStatusInterface extends IEventEmitter {
|
|
|
426
426
|
* @interface IBasicClient
|
|
427
427
|
* @extends IStatusInterface
|
|
428
428
|
*/
|
|
429
|
-
|
|
429
|
+
interface IBasicClient extends IStatusInterface {
|
|
430
430
|
/**
|
|
431
431
|
* Flush data
|
|
432
432
|
* @function flush
|
|
@@ -459,12 +459,6 @@ interface IBasicSDK {
|
|
|
459
459
|
* @property Logger
|
|
460
460
|
*/
|
|
461
461
|
Logger: ILoggerAPI
|
|
462
|
-
/**
|
|
463
|
-
* Destroy all the clients created by this factory.
|
|
464
|
-
* @function destroy
|
|
465
|
-
* @returns {Promise<void>}
|
|
466
|
-
*/
|
|
467
|
-
destroy(): Promise<void>
|
|
468
462
|
}
|
|
469
463
|
/****** Exposed namespace ******/
|
|
470
464
|
/**
|
|
@@ -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
|
}
|
|
@@ -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;
|
|
@@ -9,8 +9,6 @@ export interface ISplitsEventEmitter extends IEventEmitter {
|
|
|
9
9
|
once(event: ISplitsEvent, listener: (...args: any[]) => void): this;
|
|
10
10
|
splitsArrived: boolean;
|
|
11
11
|
splitsCacheLoaded: boolean;
|
|
12
|
-
initialized: boolean;
|
|
13
|
-
initCallbacks: (() => void)[];
|
|
14
12
|
}
|
|
15
13
|
/** Segments data emitter */
|
|
16
14
|
declare type SDK_SEGMENTS_ARRIVED = 'state::segments-arrived';
|
|
@@ -48,9 +46,8 @@ export interface IReadinessManager {
|
|
|
48
46
|
timeout(): void;
|
|
49
47
|
setDestroyed(): void;
|
|
50
48
|
destroy(): void;
|
|
51
|
-
init(): void;
|
|
52
49
|
/** for client-side */
|
|
53
|
-
shared(): IReadinessManager;
|
|
50
|
+
shared(readyTimeout?: number): IReadinessManager;
|
|
54
51
|
}
|
|
55
52
|
/** SDK readiness manager */
|
|
56
53
|
export interface ISdkReadinessManager {
|
|
@@ -62,6 +59,6 @@ export interface ISdkReadinessManager {
|
|
|
62
59
|
*/
|
|
63
60
|
incInternalReadyCbCount(): void;
|
|
64
61
|
/** for client-side */
|
|
65
|
-
shared(): ISdkReadinessManager;
|
|
62
|
+
shared(readyTimeout?: number): ISdkReadinessManager;
|
|
66
63
|
}
|
|
67
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,7 +47,6 @@ export interface ISdkFactoryContext {
|
|
|
47
47
|
signalListener?: ISignalListener;
|
|
48
48
|
splitApi?: ISplitApi;
|
|
49
49
|
syncManager?: ISyncManager;
|
|
50
|
-
clients: Record<string, IBasicClient>;
|
|
51
50
|
}
|
|
52
51
|
export interface ISdkFactoryContextSync extends ISdkFactoryContext {
|
|
53
52
|
storage: IStorageSync;
|
|
@@ -63,7 +62,6 @@ export interface ISdkFactoryContextAsync extends ISdkFactoryContext {
|
|
|
63
62
|
* Object parameter with the modules required to create an SDK factory instance
|
|
64
63
|
*/
|
|
65
64
|
export interface ISdkFactoryParams {
|
|
66
|
-
lazyInit?: boolean;
|
|
67
65
|
settings: ISettings;
|
|
68
66
|
platform: IPlatform;
|
|
69
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
|
}
|
|
@@ -12,7 +12,7 @@ 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[];
|
|
@@ -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,15 +1,25 @@
|
|
|
1
1
|
import { ILogger } from '../../logger/types';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
export declare class MySegmentsCacheInLocal extends
|
|
2
|
+
import { AbstractSegmentsCacheSync } from '../AbstractSegmentsCacheSync';
|
|
3
|
+
import { KeyBuilderCS } from '../KeyBuilderCS';
|
|
4
|
+
export declare class MySegmentsCacheInLocal extends AbstractSegmentsCacheSync {
|
|
5
5
|
private readonly keys;
|
|
6
6
|
private readonly log;
|
|
7
|
-
constructor(log: ILogger, keys:
|
|
8
|
-
|
|
9
|
-
|
|
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;
|
|
13
|
+
addToSegment(name: string): boolean;
|
|
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
|
-
protected setChangeNumber(changeNumber?: number): void;
|
|
14
|
-
getChangeNumber(): number;
|
|
15
25
|
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbstractSegmentsCacheSync } from '../AbstractSegmentsCacheSync';
|
|
2
2
|
/**
|
|
3
3
|
* Default MySegmentsCacheInMemory implementation that stores MySegments in memory.
|
|
4
4
|
* Supported by all JS runtimes.
|
|
5
5
|
*/
|
|
6
|
-
export declare class MySegmentsCacheInMemory extends
|
|
6
|
+
export declare class MySegmentsCacheInMemory extends AbstractSegmentsCacheSync {
|
|
7
7
|
private segmentCache;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
clear(): void;
|
|
9
|
+
addToSegment(name: string): boolean;
|
|
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
|
}
|