@splitsoftware/splitio-commons 2.0.0-rc.3 → 2.0.0-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 +1 -0
- package/cjs/integrations/pluggable.js +2 -2
- package/cjs/logger/sdkLogger.js +2 -2
- package/cjs/readiness/sdkReadinessManager.js +2 -21
- package/cjs/sdkClient/client.js +0 -1
- package/cjs/sdkClient/clientAttributesDecoration.js +9 -9
- package/cjs/sdkClient/clientCS.js +2 -2
- package/cjs/services/splitApi.js +13 -13
- package/cjs/services/splitHttpClient.js +2 -2
- package/cjs/storages/AbstractSplitsCacheAsync.js +1 -4
- package/cjs/storages/AbstractSplitsCacheSync.js +1 -4
- package/cjs/storages/dataLoader.js +5 -6
- package/cjs/storages/findLatencyIndex.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +1 -6
- package/cjs/storages/inMemory/AttributesCacheInMemory.js +10 -10
- package/cjs/storages/inMemory/EventsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/ImpressionsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +1 -1
- package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/cjs/storages/inMemory/UniqueKeysCacheInMemoryCS.js +1 -1
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +1 -3
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +3 -3
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/cjs/storages/pluggable/EventsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/ImpressionsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SegmentsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SplitsCachePluggable.js +3 -3
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +3 -3
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/cjs/storages/pluggable/inMemoryWrapper.js +1 -1
- package/cjs/storages/pluggable/index.js +1 -1
- package/cjs/storages/pluggable/wrapperAdapter.js +2 -2
- package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +1 -1
- package/cjs/sync/offline/syncManagerOffline.js +1 -1
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +8 -8
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +13 -13
- package/cjs/sync/streaming/AuthClient/index.js +2 -2
- package/cjs/sync/streaming/SSEClient/index.js +4 -7
- package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
- package/cjs/sync/streaming/SSEHandler/NotificationParser.js +5 -4
- package/cjs/sync/streaming/SSEHandler/index.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +3 -3
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
- package/cjs/sync/streaming/parseUtils.js +13 -13
- package/cjs/sync/syncManagerOnline.js +2 -2
- package/cjs/sync/syncTask.js +4 -4
- package/cjs/trackers/eventTracker.js +2 -2
- package/cjs/trackers/impressionsTracker.js +5 -5
- package/cjs/trackers/strategy/strategyDebug.js +1 -1
- package/cjs/trackers/strategy/strategyNone.js +2 -2
- package/cjs/trackers/strategy/strategyOptimized.js +2 -2
- package/cjs/trackers/uniqueKeysTracker.js +3 -3
- package/cjs/utils/Backoff.js +0 -4
- package/cjs/utils/Semver.js +1 -1
- package/cjs/utils/base64/index.js +2 -2
- package/cjs/utils/decompress/index.js +4 -4
- package/cjs/utils/lang/binarySearch.js +2 -2
- package/cjs/utils/murmur3/murmur3_128.js +1 -1
- package/cjs/utils/murmur3/murmur3_128_x86.js +1 -1
- package/cjs/utils/murmur3/murmur3_64.js +1 -1
- package/cjs/utils/murmur3/utfx.js +10 -17
- package/cjs/utils/promise/wrapper.js +2 -2
- package/cjs/utils/settingsValidation/index.js +2 -2
- package/cjs/utils/settingsValidation/integrations/common.js +4 -4
- package/cjs/utils/settingsValidation/integrations/configurable.js +3 -3
- package/cjs/utils/settingsValidation/integrations/pluggable.js +2 -2
- package/cjs/utils/settingsValidation/logger/builtinLogger.js +1 -1
- package/cjs/utils/settingsValidation/logger/commons.js +1 -1
- package/cjs/utils/settingsValidation/logger/pluggableLogger.js +1 -1
- package/cjs/utils/settingsValidation/splitFilters.js +8 -11
- package/cjs/utils/settingsValidation/storage/storageCS.js +2 -2
- package/cjs/utils/settingsValidation/url.js +3 -3
- package/esm/integrations/pluggable.js +2 -2
- package/esm/logger/sdkLogger.js +2 -2
- package/esm/readiness/sdkReadinessManager.js +2 -21
- package/esm/sdkClient/client.js +0 -1
- package/esm/sdkClient/clientAttributesDecoration.js +9 -9
- package/esm/sdkClient/clientCS.js +2 -2
- package/esm/services/splitApi.js +13 -13
- package/esm/services/splitHttpClient.js +2 -2
- package/esm/storages/AbstractSplitsCacheAsync.js +1 -4
- package/esm/storages/AbstractSplitsCacheSync.js +1 -4
- package/esm/storages/dataLoader.js +5 -6
- package/esm/storages/findLatencyIndex.js +1 -1
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +1 -6
- package/esm/storages/inMemory/AttributesCacheInMemory.js +10 -10
- package/esm/storages/inMemory/EventsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/ImpressionsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/InMemoryStorage.js +1 -1
- package/esm/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/esm/storages/inMemory/UniqueKeysCacheInMemoryCS.js +1 -1
- package/esm/storages/inRedis/SplitsCacheInRedis.js +1 -3
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +3 -3
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/esm/storages/pluggable/EventsCachePluggable.js +1 -1
- package/esm/storages/pluggable/ImpressionsCachePluggable.js +1 -1
- package/esm/storages/pluggable/SegmentsCachePluggable.js +1 -1
- package/esm/storages/pluggable/SplitsCachePluggable.js +3 -3
- package/esm/storages/pluggable/TelemetryCachePluggable.js +3 -3
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/esm/storages/pluggable/inMemoryWrapper.js +1 -1
- package/esm/storages/pluggable/index.js +1 -1
- package/esm/storages/pluggable/wrapperAdapter.js +2 -2
- package/esm/sync/offline/splitsParser/splitsParserFromSettings.js +1 -1
- package/esm/sync/offline/syncManagerOffline.js +1 -1
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +8 -8
- package/esm/sync/polling/updaters/splitChangesUpdater.js +13 -13
- package/esm/sync/streaming/AuthClient/index.js +2 -2
- package/esm/sync/streaming/SSEClient/index.js +4 -7
- package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
- package/esm/sync/streaming/SSEHandler/NotificationParser.js +5 -4
- package/esm/sync/streaming/SSEHandler/index.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +3 -3
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
- package/esm/sync/streaming/parseUtils.js +13 -13
- package/esm/sync/syncManagerOnline.js +2 -2
- package/esm/sync/syncTask.js +4 -4
- package/esm/trackers/eventTracker.js +2 -2
- package/esm/trackers/impressionsTracker.js +5 -5
- package/esm/trackers/strategy/strategyDebug.js +1 -1
- package/esm/trackers/strategy/strategyNone.js +2 -2
- package/esm/trackers/strategy/strategyOptimized.js +2 -2
- package/esm/trackers/uniqueKeysTracker.js +3 -3
- package/esm/utils/Backoff.js +0 -4
- package/esm/utils/Semver.js +1 -1
- package/esm/utils/base64/index.js +2 -2
- package/esm/utils/decompress/index.js +4 -4
- package/esm/utils/lang/binarySearch.js +2 -2
- package/esm/utils/murmur3/murmur3_128.js +1 -1
- package/esm/utils/murmur3/murmur3_128_x86.js +1 -1
- package/esm/utils/murmur3/murmur3_64.js +1 -1
- package/esm/utils/murmur3/utfx.js +10 -17
- package/esm/utils/promise/wrapper.js +2 -2
- package/esm/utils/settingsValidation/index.js +2 -2
- package/esm/utils/settingsValidation/integrations/common.js +4 -4
- package/esm/utils/settingsValidation/integrations/configurable.js +3 -3
- package/esm/utils/settingsValidation/integrations/pluggable.js +2 -2
- package/esm/utils/settingsValidation/logger/builtinLogger.js +1 -1
- package/esm/utils/settingsValidation/logger/commons.js +1 -1
- package/esm/utils/settingsValidation/logger/pluggableLogger.js +1 -1
- package/esm/utils/settingsValidation/splitFilters.js +8 -11
- package/esm/utils/settingsValidation/storage/storageCS.js +2 -2
- package/esm/utils/settingsValidation/url.js +3 -3
- package/package.json +5 -3
- package/src/dtos/types.ts +1 -1
- package/src/evaluator/Engine.ts +1 -1
- package/src/evaluator/combiners/ifelseif.ts +1 -1
- package/src/evaluator/condition/index.ts +1 -1
- package/src/evaluator/index.ts +1 -1
- package/src/evaluator/parser/index.ts +1 -1
- package/src/evaluator/types.ts +1 -1
- package/src/evaluator/value/index.ts +1 -1
- package/src/evaluator/value/sanitize.ts +1 -1
- package/src/integrations/pluggable.ts +3 -3
- package/src/integrations/types.ts +3 -2
- package/src/listeners/browser.ts +3 -2
- package/src/logger/index.ts +6 -6
- package/src/logger/sdkLogger.ts +4 -4
- package/src/logger/types.ts +11 -13
- package/src/readiness/readinessManager.ts +5 -4
- package/src/readiness/sdkReadinessManager.ts +6 -23
- package/src/readiness/types.ts +5 -4
- package/src/sdkClient/client.ts +7 -8
- package/src/sdkClient/clientAttributesDecoration.ts +11 -11
- package/src/sdkClient/clientCS.ts +5 -5
- package/src/sdkClient/clientInputValidation.ts +3 -2
- package/src/sdkClient/identity.ts +1 -1
- package/src/sdkClient/sdkClient.ts +3 -3
- package/src/sdkClient/sdkClientMethod.ts +2 -2
- package/src/sdkClient/sdkClientMethodCS.ts +5 -5
- package/src/sdkFactory/index.ts +3 -3
- package/src/sdkFactory/types.ts +7 -6
- package/src/sdkManager/index.ts +2 -1
- package/src/services/splitApi.ts +13 -13
- package/src/services/splitHttpClient.ts +2 -2
- package/src/storages/AbstractMySegmentsCacheSync.ts +1 -1
- package/src/storages/AbstractSplitsCacheAsync.ts +1 -4
- package/src/storages/AbstractSplitsCacheSync.ts +1 -4
- package/src/storages/dataLoader.ts +7 -8
- package/src/storages/findLatencyIndex.ts +1 -1
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +1 -6
- package/src/storages/inMemory/AttributesCacheInMemory.ts +11 -11
- package/src/storages/inMemory/EventsCacheInMemory.ts +2 -2
- package/src/storages/inMemory/ImpressionsCacheInMemory.ts +5 -5
- package/src/storages/inMemory/InMemoryStorage.ts +1 -1
- package/src/storages/inMemory/InMemoryStorageCS.ts +1 -1
- package/src/storages/inMemory/UniqueKeysCacheInMemoryCS.ts +1 -1
- package/src/storages/inRedis/EventsCacheInRedis.ts +1 -1
- package/src/storages/inRedis/ImpressionsCacheInRedis.ts +2 -2
- package/src/storages/inRedis/SplitsCacheInRedis.ts +1 -3
- package/src/storages/inRedis/TelemetryCacheInRedis.ts +3 -3
- package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +1 -1
- package/src/storages/pluggable/EventsCachePluggable.ts +2 -2
- package/src/storages/pluggable/ImpressionsCachePluggable.ts +3 -3
- package/src/storages/pluggable/SegmentsCachePluggable.ts +1 -1
- package/src/storages/pluggable/SplitsCachePluggable.ts +3 -3
- package/src/storages/pluggable/TelemetryCachePluggable.ts +3 -3
- package/src/storages/pluggable/UniqueKeysCachePluggable.ts +1 -1
- package/src/storages/pluggable/inMemoryWrapper.ts +1 -1
- package/src/storages/pluggable/index.ts +1 -1
- package/src/storages/pluggable/wrapperAdapter.ts +2 -2
- package/src/storages/types.ts +51 -68
- package/src/storages/utils.ts +3 -2
- package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +3 -3
- package/src/sync/offline/syncManagerOffline.ts +1 -1
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +3 -3
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +8 -8
- package/src/sync/polling/updaters/splitChangesUpdater.ts +13 -13
- package/src/sync/streaming/AuthClient/index.ts +2 -2
- package/src/sync/streaming/SSEClient/index.ts +4 -7
- package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +1 -1
- package/src/sync/streaming/SSEHandler/NotificationParser.ts +5 -4
- package/src/sync/streaming/SSEHandler/index.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +3 -3
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +4 -4
- package/src/sync/streaming/parseUtils.ts +13 -13
- package/src/sync/streaming/types.ts +2 -2
- package/src/sync/submitters/impressionsSubmitter.ts +2 -2
- package/src/sync/submitters/telemetrySubmitter.ts +4 -3
- package/src/sync/submitters/types.ts +1 -1
- package/src/sync/syncManagerOnline.ts +2 -2
- package/src/sync/syncTask.ts +4 -4
- package/src/trackers/eventTracker.ts +4 -3
- package/src/trackers/impressionObserver/ImpressionObserver.ts +4 -4
- package/src/trackers/impressionObserver/buildKey.ts +2 -2
- package/src/trackers/impressionObserver/impressionObserverCS.ts +2 -2
- package/src/trackers/impressionObserver/impressionObserverSS.ts +2 -2
- package/src/trackers/impressionObserver/types.ts +2 -2
- package/src/trackers/impressionsTracker.ts +8 -7
- package/src/trackers/strategy/strategyDebug.ts +3 -3
- package/src/trackers/strategy/strategyNone.ts +4 -4
- package/src/trackers/strategy/strategyOptimized.ts +5 -5
- package/src/trackers/types.ts +5 -5
- package/src/trackers/uniqueKeysTracker.ts +3 -3
- package/src/types.ts +37 -1355
- package/src/utils/Backoff.ts +0 -4
- package/src/utils/MinEventEmitter.ts +2 -3
- package/src/utils/MinEvents.ts +2 -2
- package/src/utils/Semver.ts +1 -1
- package/src/utils/base64/index.ts +2 -2
- package/src/utils/constants/index.ts +9 -10
- package/src/utils/decompress/index.ts +4 -4
- package/src/utils/inputValidation/attributes.ts +1 -1
- package/src/utils/inputValidation/eventProperties.ts +1 -1
- package/src/utils/inputValidation/key.ts +1 -1
- package/src/utils/inputValidation/preloadedData.ts +1 -2
- package/src/utils/inputValidation/trafficTypeExistence.ts +2 -2
- package/src/utils/key/index.ts +1 -1
- package/src/utils/lang/binarySearch.ts +2 -2
- package/src/utils/murmur3/murmur3_128.ts +1 -1
- package/src/utils/murmur3/murmur3_128_x86.ts +1 -1
- package/src/utils/murmur3/murmur3_64.ts +1 -1
- package/src/utils/murmur3/utfx.ts +10 -17
- package/src/utils/promise/wrapper.ts +2 -2
- package/src/utils/settingsValidation/consent.ts +2 -2
- package/src/utils/settingsValidation/impressionsMode.ts +1 -1
- package/src/utils/settingsValidation/index.ts +2 -2
- package/src/utils/settingsValidation/integrations/common.ts +4 -4
- package/src/utils/settingsValidation/integrations/configurable.ts +3 -3
- package/src/utils/settingsValidation/integrations/pluggable.ts +2 -2
- package/src/utils/settingsValidation/logger/builtinLogger.ts +3 -3
- package/src/utils/settingsValidation/logger/commons.ts +3 -3
- package/src/utils/settingsValidation/logger/pluggableLogger.ts +3 -3
- package/src/utils/settingsValidation/splitFilters.ts +9 -12
- package/src/utils/settingsValidation/storage/storageCS.ts +5 -4
- package/src/utils/settingsValidation/url.ts +3 -3
- package/types/index.d.ts +5 -5
- package/types/splitio.d.ts +1941 -0
- package/types/consent/index.d.ts +0 -2
- package/types/consent/sdkUserConsent.d.ts +0 -13
- package/types/dtos/types.d.ts +0 -209
- package/types/evaluator/Engine.d.ts +0 -15
- package/types/evaluator/combiners/and.d.ts +0 -4
- package/types/evaluator/combiners/ifelseif.d.ts +0 -3
- package/types/evaluator/condition/engineUtils.d.ts +0 -11
- package/types/evaluator/condition/index.d.ts +0 -6
- package/types/evaluator/convertions/index.d.ts +0 -2
- package/types/evaluator/index.d.ts +0 -8
- package/types/evaluator/matchers/all.d.ts +0 -1
- package/types/evaluator/matchers/between.d.ts +0 -2
- package/types/evaluator/matchers/boolean.d.ts +0 -1
- package/types/evaluator/matchers/cont_all.d.ts +0 -1
- package/types/evaluator/matchers/cont_any.d.ts +0 -1
- package/types/evaluator/matchers/cont_str.d.ts +0 -1
- package/types/evaluator/matchers/dependency.d.ts +0 -5
- package/types/evaluator/matchers/eq.d.ts +0 -1
- package/types/evaluator/matchers/eq_set.d.ts +0 -1
- package/types/evaluator/matchers/ew.d.ts +0 -1
- package/types/evaluator/matchers/gte.d.ts +0 -1
- package/types/evaluator/matchers/index.d.ts +0 -7
- package/types/evaluator/matchers/large_segment.d.ts +0 -5
- package/types/evaluator/matchers/lte.d.ts +0 -1
- package/types/evaluator/matchers/matcherTypes.d.ts +0 -10
- package/types/evaluator/matchers/part_of.d.ts +0 -1
- package/types/evaluator/matchers/segment.d.ts +0 -5
- package/types/evaluator/matchers/semver_between.d.ts +0 -2
- package/types/evaluator/matchers/semver_eq.d.ts +0 -1
- package/types/evaluator/matchers/semver_gte.d.ts +0 -1
- package/types/evaluator/matchers/semver_inlist.d.ts +0 -1
- package/types/evaluator/matchers/semver_lte.d.ts +0 -1
- package/types/evaluator/matchers/string.d.ts +0 -1
- package/types/evaluator/matchers/sw.d.ts +0 -1
- package/types/evaluator/matchers/whitelist.d.ts +0 -1
- package/types/evaluator/matchersTransform/index.d.ts +0 -6
- package/types/evaluator/matchersTransform/segment.d.ts +0 -5
- package/types/evaluator/matchersTransform/unaryNumeric.d.ts +0 -5
- package/types/evaluator/matchersTransform/whitelist.d.ts +0 -5
- package/types/evaluator/parser/index.d.ts +0 -5
- package/types/evaluator/treatments/index.d.ts +0 -8
- package/types/evaluator/types.d.ts +0 -28
- package/types/evaluator/value/index.d.ts +0 -7
- package/types/evaluator/value/sanitize.d.ts +0 -7
- package/types/integrations/pluggable.d.ts +0 -11
- package/types/integrations/types.d.ts +0 -18
- package/types/listeners/browser.d.ts +0 -40
- package/types/listeners/node.d.ts +0 -22
- package/types/listeners/types.d.ts +0 -4
- package/types/logger/browser/DebugLogger.d.ts +0 -2
- package/types/logger/browser/ErrorLogger.d.ts +0 -2
- package/types/logger/browser/InfoLogger.d.ts +0 -2
- package/types/logger/browser/WarnLogger.d.ts +0 -2
- package/types/logger/constants.d.ts +0 -134
- package/types/logger/index.d.ts +0 -21
- package/types/logger/messages/debug.d.ts +0 -1
- package/types/logger/messages/error.d.ts +0 -1
- package/types/logger/messages/info.d.ts +0 -1
- package/types/logger/messages/warn.d.ts +0 -1
- package/types/logger/sdkLogger.d.ts +0 -8
- package/types/logger/types.d.ts +0 -17
- package/types/readiness/constants.d.ts +0 -7
- package/types/readiness/readinessManager.d.ts +0 -6
- package/types/readiness/sdkReadinessManager.d.ts +0 -10
- package/types/readiness/types.d.ts +0 -67
- package/types/sdkClient/client.d.ts +0 -6
- package/types/sdkClient/clientAttributesDecoration.d.ts +0 -55
- package/types/sdkClient/clientCS.d.ts +0 -9
- package/types/sdkClient/clientInputValidation.d.ts +0 -7
- package/types/sdkClient/identity.d.ts +0 -2
- package/types/sdkClient/sdkClient.d.ts +0 -6
- package/types/sdkClient/sdkClientMethod.d.ts +0 -6
- package/types/sdkClient/sdkClientMethodCS.d.ts +0 -7
- package/types/sdkFactory/index.d.ts +0 -6
- package/types/sdkFactory/types.d.ts +0 -85
- package/types/sdkManager/index.d.ts +0 -4
- package/types/services/decorateHeaders.d.ts +0 -2
- package/types/services/splitApi.d.ts +0 -12
- package/types/services/splitHttpClient.d.ts +0 -10
- package/types/services/types.d.ts +0 -54
- package/types/storages/AbstractMySegmentsCacheSync.d.ts +0 -39
- package/types/storages/AbstractSplitsCacheAsync.d.ts +0 -38
- package/types/storages/AbstractSplitsCacheSync.d.ts +0 -43
- package/types/storages/KeyBuilder.d.ts +0 -22
- package/types/storages/KeyBuilderCS.d.ts +0 -20
- package/types/storages/KeyBuilderSS.d.ts +0 -20
- package/types/storages/dataLoader.d.ts +0 -10
- package/types/storages/findLatencyIndex.d.ts +0 -7
- package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +0 -15
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +0 -54
- package/types/storages/inLocalStorage/constants.d.ts +0 -2
- package/types/storages/inLocalStorage/index.d.ts +0 -8
- package/types/storages/inMemory/AttributesCacheInMemory.d.ts +0 -44
- package/types/storages/inMemory/EventsCacheInMemory.d.ts +0 -35
- package/types/storages/inMemory/ImpressionCountsCacheInMemory.d.ts +0 -28
- package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +0 -30
- package/types/storages/inMemory/InMemoryStorage.d.ts +0 -10
- package/types/storages/inMemory/InMemoryStorageCS.d.ts +0 -10
- package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +0 -16
- package/types/storages/inMemory/SegmentsCacheInMemory.d.ts +0 -17
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +0 -27
- package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +0 -71
- package/types/storages/inMemory/UniqueKeysCacheInMemory.d.ts +0 -34
- package/types/storages/inMemory/UniqueKeysCacheInMemoryCS.d.ts +0 -35
- package/types/storages/inRedis/EventsCacheInRedis.d.ts +0 -32
- package/types/storages/inRedis/ImpressionCountsCacheInRedis.d.ts +0 -17
- package/types/storages/inRedis/ImpressionsCacheInRedis.d.ts +0 -17
- package/types/storages/inRedis/RedisAdapter.d.ts +0 -24
- package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +0 -21
- package/types/storages/inRedis/SplitsCacheInRedis.d.ts +0 -95
- package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +0 -35
- package/types/storages/inRedis/UniqueKeysCacheInRedis.d.ts +0 -22
- package/types/storages/inRedis/constants.d.ts +0 -4
- package/types/storages/inRedis/index.d.ts +0 -10
- package/types/storages/pluggable/EventsCachePluggable.d.ts +0 -38
- package/types/storages/pluggable/ImpressionCountsCachePluggable.d.ts +0 -16
- package/types/storages/pluggable/ImpressionsCachePluggable.d.ts +0 -34
- package/types/storages/pluggable/SegmentsCachePluggable.d.ts +0 -42
- package/types/storages/pluggable/SplitsCachePluggable.d.ts +0 -98
- package/types/storages/pluggable/TelemetryCachePluggable.d.ts +0 -34
- package/types/storages/pluggable/UniqueKeysCachePluggable.d.ts +0 -20
- package/types/storages/pluggable/constants.d.ts +0 -1
- package/types/storages/pluggable/inMemoryWrapper.d.ts +0 -12
- package/types/storages/pluggable/index.d.ts +0 -9
- package/types/storages/pluggable/wrapperAdapter.d.ts +0 -12
- package/types/storages/types.d.ts +0 -407
- package/types/storages/utils.d.ts +0 -8
- package/types/sync/offline/LocalhostFromObject.d.ts +0 -1
- package/types/sync/offline/splitsParser/parseCondition.d.ts +0 -7
- package/types/sync/offline/splitsParser/splitsParserFromSettings.d.ts +0 -3
- package/types/sync/offline/splitsParser/types.d.ts +0 -3
- package/types/sync/offline/syncManagerOffline.d.ts +0 -10
- package/types/sync/offline/syncTasks/fromObjectSyncTask.d.ts +0 -17
- package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +0 -7
- package/types/sync/polling/fetchers/segmentChangesFetcher.d.ts +0 -7
- package/types/sync/polling/fetchers/splitChangesFetcher.d.ts +0 -7
- package/types/sync/polling/fetchers/types.d.ts +0 -5
- package/types/sync/polling/pollingManagerCS.d.ts +0 -7
- package/types/sync/polling/pollingManagerSS.d.ts +0 -6
- package/types/sync/polling/syncTasks/mySegmentsSyncTask.d.ts +0 -9
- package/types/sync/polling/syncTasks/segmentsSyncTask.d.ts +0 -9
- package/types/sync/polling/syncTasks/splitsSyncTask.d.ts +0 -9
- package/types/sync/polling/types.d.ts +0 -33
- package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +0 -14
- package/types/sync/polling/updaters/segmentChangesUpdater.d.ts +0 -18
- package/types/sync/polling/updaters/splitChangesUpdater.d.ts +0 -41
- package/types/sync/streaming/AuthClient/index.d.ts +0 -12
- package/types/sync/streaming/AuthClient/types.d.ts +0 -17
- package/types/sync/streaming/SSEClient/index.d.ts +0 -34
- package/types/sync/streaming/SSEClient/types.d.ts +0 -11
- package/types/sync/streaming/SSEHandler/NotificationKeeper.d.ts +0 -14
- package/types/sync/streaming/SSEHandler/NotificationParser.d.ts +0 -20
- package/types/sync/streaming/SSEHandler/index.d.ts +0 -11
- package/types/sync/streaming/SSEHandler/types.d.ts +0 -72
- package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +0 -9
- package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +0 -9
- package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +0 -14
- package/types/sync/streaming/UpdateWorkers/constants.d.ts +0 -3
- package/types/sync/streaming/UpdateWorkers/types.d.ts +0 -4
- package/types/sync/streaming/constants.d.ts +0 -34
- package/types/sync/streaming/parseUtils.d.ts +0 -34
- package/types/sync/streaming/pushManager.d.ts +0 -9
- package/types/sync/streaming/types.d.ts +0 -35
- package/types/sync/submitters/eventsSubmitter.d.ts +0 -5
- package/types/sync/submitters/impressionCountsSubmitter.d.ts +0 -10
- package/types/sync/submitters/impressionsSubmitter.d.ts +0 -11
- package/types/sync/submitters/submitter.d.ts +0 -12
- package/types/sync/submitters/submitterManager.d.ts +0 -3
- package/types/sync/submitters/telemetrySubmitter.d.ts +0 -17
- package/types/sync/submitters/types.d.ts +0 -217
- package/types/sync/submitters/uniqueKeysSubmitter.d.ts +0 -5
- package/types/sync/syncManagerOnline.d.ts +0 -13
- package/types/sync/syncTask.d.ts +0 -13
- package/types/sync/types.d.ts +0 -43
- package/types/trackers/eventTracker.d.ts +0 -10
- package/types/trackers/impressionObserver/ImpressionObserver.d.ts +0 -8
- package/types/trackers/impressionObserver/buildKey.d.ts +0 -2
- package/types/trackers/impressionObserver/impressionObserverCS.d.ts +0 -4
- package/types/trackers/impressionObserver/impressionObserverSS.d.ts +0 -4
- package/types/trackers/impressionObserver/types.d.ts +0 -4
- package/types/trackers/impressionsTracker.d.ts +0 -13
- package/types/trackers/strategy/strategyDebug.d.ts +0 -9
- package/types/trackers/strategy/strategyNone.d.ts +0 -10
- package/types/trackers/strategy/strategyOptimized.d.ts +0 -11
- package/types/trackers/telemetryTracker.d.ts +0 -3
- package/types/trackers/types.d.ts +0 -68
- package/types/trackers/uniqueKeysTracker.d.ts +0 -13
- package/types/types.d.ts +0 -1398
- package/types/utils/Backoff.d.ts +0 -25
- package/types/utils/LRUCache/LinkedList.d.ts +0 -34
- package/types/utils/LRUCache/index.d.ts +0 -15
- package/types/utils/MinEventEmitter.d.ts +0 -12
- package/types/utils/MinEvents.d.ts +0 -4
- package/types/utils/Semver.d.ts +0 -15
- package/types/utils/base64/index.d.ts +0 -30
- package/types/utils/constants/browser.d.ts +0 -1
- package/types/utils/constants/index.d.ts +0 -83
- package/types/utils/decompress/index.d.ts +0 -16
- package/types/utils/env/isLocalStorageAvailable.d.ts +0 -1
- package/types/utils/env/isNode.d.ts +0 -5
- package/types/utils/inputValidation/apiKey.d.ts +0 -7
- package/types/utils/inputValidation/attribute.d.ts +0 -2
- package/types/utils/inputValidation/attributes.d.ts +0 -4
- package/types/utils/inputValidation/event.d.ts +0 -2
- package/types/utils/inputValidation/eventProperties.d.ts +0 -6
- package/types/utils/inputValidation/eventValue.d.ts +0 -2
- package/types/utils/inputValidation/index.d.ts +0 -13
- package/types/utils/inputValidation/isOperational.d.ts +0 -4
- package/types/utils/inputValidation/key.d.ts +0 -3
- package/types/utils/inputValidation/preloadedData.d.ts +0 -3
- package/types/utils/inputValidation/split.d.ts +0 -2
- package/types/utils/inputValidation/splitExistence.d.ts +0 -7
- package/types/utils/inputValidation/splits.d.ts +0 -2
- package/types/utils/inputValidation/trafficType.d.ts +0 -2
- package/types/utils/inputValidation/trafficTypeExistence.d.ts +0 -9
- package/types/utils/jwt/index.d.ts +0 -5
- package/types/utils/jwt/types.d.ts +0 -5
- package/types/utils/key/index.d.ts +0 -8
- package/types/utils/labels/index.d.ts +0 -8
- package/types/utils/lang/binarySearch.d.ts +0 -9
- package/types/utils/lang/getFnName.d.ts +0 -4
- package/types/utils/lang/getGlobal.d.ts +0 -4
- package/types/utils/lang/index.d.ts +0 -105
- package/types/utils/lang/objectAssign.d.ts +0 -6
- package/types/utils/lang/sets.d.ts +0 -3
- package/types/utils/murmur3/common.d.ts +0 -12
- package/types/utils/murmur3/legacy.d.ts +0 -2
- package/types/utils/murmur3/murmur3.d.ts +0 -2
- package/types/utils/murmur3/murmur3_128.d.ts +0 -6
- package/types/utils/murmur3/murmur3_128_x86.d.ts +0 -7
- package/types/utils/murmur3/murmur3_64.d.ts +0 -10
- package/types/utils/murmur3/utfx.d.ts +0 -27
- package/types/utils/promise/thenable.d.ts +0 -1
- package/types/utils/promise/timeout.d.ts +0 -1
- package/types/utils/promise/wrapper.d.ts +0 -21
- package/types/utils/settingsValidation/consent.d.ts +0 -6
- package/types/utils/settingsValidation/impressionsMode.d.ts +0 -3
- package/types/utils/settingsValidation/index.d.ts +0 -50
- package/types/utils/settingsValidation/integrations/common.d.ts +0 -14
- package/types/utils/settingsValidation/integrations/configurable.d.ts +0 -13
- package/types/utils/settingsValidation/integrations/pluggable.d.ts +0 -13
- package/types/utils/settingsValidation/logger/builtinLogger.d.ts +0 -10
- package/types/utils/settingsValidation/logger/commons.d.ts +0 -9
- package/types/utils/settingsValidation/logger/pluggableLogger.d.ts +0 -11
- package/types/utils/settingsValidation/mode.d.ts +0 -5
- package/types/utils/settingsValidation/runtime.d.ts +0 -2
- package/types/utils/settingsValidation/splitFilters.d.ts +0 -17
- package/types/utils/settingsValidation/storage/storageCS.d.ts +0 -21
- package/types/utils/settingsValidation/types.d.ts +0 -30
- package/types/utils/settingsValidation/url.d.ts +0 -10
- package/types/utils/time/index.d.ts +0 -4
- package/types/utils/timeTracker/now/browser.d.ts +0 -1
- package/types/utils/timeTracker/now/node.d.ts +0 -1
- package/types/utils/timeTracker/timer.d.ts +0 -1
package/src/readiness/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IStatusInterface } from '../types';
|
|
2
|
+
import SplitIO from '../../types/splitio';
|
|
2
3
|
|
|
3
4
|
/** Splits data emitter */
|
|
4
5
|
|
|
@@ -6,7 +7,7 @@ type SDK_SPLITS_ARRIVED = 'state::splits-arrived'
|
|
|
6
7
|
type SDK_SPLITS_CACHE_LOADED = 'state::splits-cache-loaded'
|
|
7
8
|
type ISplitsEvent = SDK_SPLITS_ARRIVED | SDK_SPLITS_CACHE_LOADED
|
|
8
9
|
|
|
9
|
-
export interface ISplitsEventEmitter extends IEventEmitter {
|
|
10
|
+
export interface ISplitsEventEmitter extends SplitIO.IEventEmitter {
|
|
10
11
|
emit(event: ISplitsEvent, ...args: any[]): boolean
|
|
11
12
|
on(event: ISplitsEvent, listener: (...args: any[]) => void): this;
|
|
12
13
|
once(event: ISplitsEvent, listener: (...args: any[]) => void): this;
|
|
@@ -21,7 +22,7 @@ export interface ISplitsEventEmitter extends IEventEmitter {
|
|
|
21
22
|
type SDK_SEGMENTS_ARRIVED = 'state::segments-arrived'
|
|
22
23
|
type ISegmentsEvent = SDK_SEGMENTS_ARRIVED
|
|
23
24
|
|
|
24
|
-
export interface ISegmentsEventEmitter extends IEventEmitter {
|
|
25
|
+
export interface ISegmentsEventEmitter extends SplitIO.IEventEmitter {
|
|
25
26
|
emit(event: ISegmentsEvent, ...args: any[]): boolean
|
|
26
27
|
on(event: ISegmentsEvent, listener: (...args: any[]) => void): this;
|
|
27
28
|
once(event: ISegmentsEvent, listener: (...args: any[]) => void): this;
|
|
@@ -37,7 +38,7 @@ export type SDK_UPDATE = 'state::update'
|
|
|
37
38
|
export type SDK_DESTROY = 'state::destroy'
|
|
38
39
|
export type IReadinessEvent = SDK_READY_TIMED_OUT | SDK_READY | SDK_READY_FROM_CACHE | SDK_UPDATE | SDK_DESTROY
|
|
39
40
|
|
|
40
|
-
export interface IReadinessEventEmitter extends IEventEmitter {
|
|
41
|
+
export interface IReadinessEventEmitter extends SplitIO.IEventEmitter {
|
|
41
42
|
emit(event: IReadinessEvent, ...args: any[]): boolean
|
|
42
43
|
}
|
|
43
44
|
|
package/src/sdkClient/client.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { validateTrafficTypeExistence } from '../utils/inputValidation/trafficTy
|
|
|
6
6
|
import { SDK_NOT_READY } from '../utils/labels';
|
|
7
7
|
import { CONTROL, TREATMENT, TREATMENTS, TREATMENT_WITH_CONFIG, TREATMENTS_WITH_CONFIG, TRACK, TREATMENTS_WITH_CONFIG_BY_FLAGSETS, TREATMENTS_BY_FLAGSETS, TREATMENTS_BY_FLAGSET, TREATMENTS_WITH_CONFIG_BY_FLAGSET, GET_TREATMENTS_WITH_CONFIG, GET_TREATMENTS_BY_FLAG_SETS, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS, GET_TREATMENTS_BY_FLAG_SET, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET, GET_TREATMENT_WITH_CONFIG, GET_TREATMENT, GET_TREATMENTS, TRACK_FN_LABEL } from '../utils/constants';
|
|
8
8
|
import { IEvaluationResult } from '../evaluator/types';
|
|
9
|
-
import
|
|
9
|
+
import SplitIO from '../../types/splitio';
|
|
10
10
|
import { IMPRESSION, IMPRESSION_QUEUEING } from '../logger/constants';
|
|
11
11
|
import { ISdkFactoryContext } from '../sdkFactory/types';
|
|
12
12
|
import { isConsumerMode } from '../utils/settingsValidation/mode';
|
|
@@ -25,7 +25,7 @@ function treatmentsNotReady(featureFlagNames: string[]) {
|
|
|
25
25
|
/**
|
|
26
26
|
* Creator of base client with getTreatments and track methods.
|
|
27
27
|
*/
|
|
28
|
-
export function clientFactory(params: ISdkFactoryContext): SplitIO.
|
|
28
|
+
export function clientFactory(params: ISdkFactoryContext): SplitIO.INodeClient | SplitIO.INodeAsyncClient {
|
|
29
29
|
const { sdkReadinessManager: { readinessManager }, storage, settings, impressionsTracker, eventTracker, telemetryTracker } = params;
|
|
30
30
|
const { log, mode } = settings;
|
|
31
31
|
const isAsync = isConsumerMode(mode);
|
|
@@ -34,7 +34,7 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
|
|
|
34
34
|
const stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? TREATMENT_WITH_CONFIG : TREATMENT);
|
|
35
35
|
|
|
36
36
|
const wrapUp = (evaluationResult: IEvaluationResult) => {
|
|
37
|
-
const queue: ImpressionDTO[] = [];
|
|
37
|
+
const queue: SplitIO.ImpressionDTO[] = [];
|
|
38
38
|
const treatment = processEvaluation(evaluationResult, featureFlagName, key, attributes, withConfig, methodName, queue);
|
|
39
39
|
impressionsTracker.track(queue, attributes);
|
|
40
40
|
|
|
@@ -59,7 +59,7 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
|
|
|
59
59
|
const stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? TREATMENTS_WITH_CONFIG : TREATMENTS);
|
|
60
60
|
|
|
61
61
|
const wrapUp = (evaluationResults: Record<string, IEvaluationResult>) => {
|
|
62
|
-
const queue: ImpressionDTO[] = [];
|
|
62
|
+
const queue: SplitIO.ImpressionDTO[] = [];
|
|
63
63
|
const treatments: Record<string, SplitIO.Treatment | SplitIO.TreatmentWithConfig> = {};
|
|
64
64
|
Object.keys(evaluationResults).forEach(featureFlagName => {
|
|
65
65
|
treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, attributes, withConfig, methodName, queue);
|
|
@@ -87,7 +87,7 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
|
|
|
87
87
|
const stopTelemetryTracker = telemetryTracker.trackEval(method);
|
|
88
88
|
|
|
89
89
|
const wrapUp = (evaluationResults: Record<string, IEvaluationResult>) => {
|
|
90
|
-
const queue: ImpressionDTO[] = [];
|
|
90
|
+
const queue: SplitIO.ImpressionDTO[] = [];
|
|
91
91
|
const treatments: Record<string, SplitIO.Treatment | SplitIO.TreatmentWithConfig> = {};
|
|
92
92
|
const evaluations = evaluationResults;
|
|
93
93
|
Object.keys(evaluations).forEach(featureFlagName => {
|
|
@@ -128,7 +128,7 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
|
|
|
128
128
|
attributes: SplitIO.Attributes | undefined,
|
|
129
129
|
withConfig: boolean,
|
|
130
130
|
invokingMethodName: string,
|
|
131
|
-
queue: ImpressionDTO[]
|
|
131
|
+
queue: SplitIO.ImpressionDTO[]
|
|
132
132
|
): SplitIO.Treatment | SplitIO.TreatmentWithConfig {
|
|
133
133
|
const matchingKey = getMatching(key);
|
|
134
134
|
const bucketingKey = getBucketing(key);
|
|
@@ -199,6 +199,5 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
|
|
|
199
199
|
getTreatmentsByFlagSet,
|
|
200
200
|
getTreatmentsWithConfigByFlagSet,
|
|
201
201
|
track,
|
|
202
|
-
|
|
203
|
-
} as SplitIO.IClient | SplitIO.IAsyncClient;
|
|
202
|
+
} as SplitIO.INodeClient | SplitIO.INodeAsyncClient;
|
|
204
203
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AttributesCacheInMemory } from '../storages/inMemory/AttributesCacheInMemory';
|
|
2
2
|
import { validateAttributesDeep } from '../utils/inputValidation/attributes';
|
|
3
|
-
import
|
|
3
|
+
import SplitIO from '../../types/splitio';
|
|
4
4
|
import { ILogger } from '../logger/types';
|
|
5
5
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Add in memory attributes storage methods and combine them with any attribute received from the getTreatment/s call
|
|
9
9
|
*/
|
|
10
|
-
export function clientAttributesDecoration<TClient extends SplitIO.
|
|
10
|
+
export function clientAttributesDecoration<TClient extends SplitIO.INodeClient | SplitIO.INodeAsyncClient>(log: ILogger, client: TClient) {
|
|
11
11
|
|
|
12
12
|
const attributeStorage = new AttributesCacheInMemory();
|
|
13
13
|
|
|
@@ -80,9 +80,9 @@ export function clientAttributesDecoration<TClient extends SplitIO.IClient | Spl
|
|
|
80
80
|
/**
|
|
81
81
|
* Add an attribute to client's in memory attributes storage
|
|
82
82
|
*
|
|
83
|
-
* @param
|
|
84
|
-
* @param
|
|
85
|
-
* @returns
|
|
83
|
+
* @param attributeName - Attribute name
|
|
84
|
+
* @param attributeValue - Attribute value
|
|
85
|
+
* @returns true if the attribute was stored and false otherways
|
|
86
86
|
*/
|
|
87
87
|
setAttribute(attributeName: string, attributeValue: SplitIO.AttributeType) {
|
|
88
88
|
const attribute: Record<string, Object> = {};
|
|
@@ -95,8 +95,8 @@ export function clientAttributesDecoration<TClient extends SplitIO.IClient | Spl
|
|
|
95
95
|
/**
|
|
96
96
|
* Returns the attribute with the given name
|
|
97
97
|
*
|
|
98
|
-
* @param
|
|
99
|
-
* @returns
|
|
98
|
+
* @param attributeName - Attribute name
|
|
99
|
+
* @returns Attribute with the given name
|
|
100
100
|
*/
|
|
101
101
|
getAttribute(attributeName: string) {
|
|
102
102
|
log.debug(`retrieved attribute ${attributeName}`);
|
|
@@ -106,7 +106,7 @@ export function clientAttributesDecoration<TClient extends SplitIO.IClient | Spl
|
|
|
106
106
|
/**
|
|
107
107
|
* Add to client's in memory attributes storage the attributes in 'attributes'
|
|
108
108
|
*
|
|
109
|
-
* @param
|
|
109
|
+
* @param attributes - Object with attributes to store
|
|
110
110
|
* @returns true if attributes were stored an false otherways
|
|
111
111
|
*/
|
|
112
112
|
setAttributes(attributes: Record<string, Object>) {
|
|
@@ -117,7 +117,7 @@ export function clientAttributesDecoration<TClient extends SplitIO.IClient | Spl
|
|
|
117
117
|
/**
|
|
118
118
|
* Return all the attributes stored in client's in memory attributes storage
|
|
119
119
|
*
|
|
120
|
-
* @returns
|
|
120
|
+
* @returns returns all the stored attributes
|
|
121
121
|
*/
|
|
122
122
|
getAttributes() {
|
|
123
123
|
return attributeStorage.getAll();
|
|
@@ -126,8 +126,8 @@ export function clientAttributesDecoration<TClient extends SplitIO.IClient | Spl
|
|
|
126
126
|
/**
|
|
127
127
|
* Removes from client's in memory attributes storage the attribute with the given name
|
|
128
128
|
*
|
|
129
|
-
* @param
|
|
130
|
-
* @returns
|
|
129
|
+
* @param attributeName - Attribute name
|
|
130
|
+
* @returns true if attribute was removed and false otherways
|
|
131
131
|
*/
|
|
132
132
|
removeAttribute(attributeName: string) {
|
|
133
133
|
log.debug(`removed attribute ${attributeName}`);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
2
|
import { ILogger } from '../logger/types';
|
|
3
|
-
import
|
|
3
|
+
import SplitIO from '../../types/splitio';
|
|
4
4
|
import { clientAttributesDecoration } from './clientAttributesDecoration';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Decorator that binds a key to client methods
|
|
9
9
|
*
|
|
10
|
-
* @param client sync client instance
|
|
11
|
-
* @param key validated split key
|
|
10
|
+
* @param client - sync client instance
|
|
11
|
+
* @param key - validated split key
|
|
12
12
|
*/
|
|
13
|
-
export function clientCSDecorator(log: ILogger, client: SplitIO.
|
|
13
|
+
export function clientCSDecorator(log: ILogger, client: SplitIO.INodeClient, key: SplitIO.SplitKey): SplitIO.IClient {
|
|
14
14
|
|
|
15
15
|
let clientCS = clientAttributesDecoration(log, client);
|
|
16
16
|
|
|
@@ -30,5 +30,5 @@ export function clientCSDecorator(log: ILogger, client: SplitIO.IClient, key: Sp
|
|
|
30
30
|
// Not part of the public API. These properties are used to support other modules (e.g., Split Suite)
|
|
31
31
|
isClientSide: true,
|
|
32
32
|
key
|
|
33
|
-
}) as SplitIO.
|
|
33
|
+
}) as SplitIO.IClient;
|
|
34
34
|
}
|
|
@@ -15,7 +15,8 @@ import { startsWith } from '../utils/lang';
|
|
|
15
15
|
import { CONTROL, CONTROL_WITH_CONFIG, GET_TREATMENT, GET_TREATMENTS, GET_TREATMENTS_BY_FLAG_SET, GET_TREATMENTS_BY_FLAG_SETS, GET_TREATMENTS_WITH_CONFIG, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS, GET_TREATMENT_WITH_CONFIG, TRACK_FN_LABEL } from '../utils/constants';
|
|
16
16
|
import { IReadinessManager } from '../readiness/types';
|
|
17
17
|
import { MaybeThenable } from '../dtos/types';
|
|
18
|
-
import { ISettings
|
|
18
|
+
import { ISettings } from '../types';
|
|
19
|
+
import SplitIO from '../../types/splitio';
|
|
19
20
|
import { isConsumerMode } from '../utils/settingsValidation/mode';
|
|
20
21
|
import { validateFlagSets } from '../utils/settingsValidation/splitFilters';
|
|
21
22
|
|
|
@@ -23,7 +24,7 @@ import { validateFlagSets } from '../utils/settingsValidation/splitFilters';
|
|
|
23
24
|
* Decorator that validates the input before actually executing the client methods.
|
|
24
25
|
* We should "guard" the client here, while not polluting the "real" implementation of those methods.
|
|
25
26
|
*/
|
|
26
|
-
export function clientInputValidationDecorator<TClient extends SplitIO.
|
|
27
|
+
export function clientInputValidationDecorator<TClient extends SplitIO.INodeClient | SplitIO.INodeAsyncClient>(settings: ISettings, client: TClient, readinessManager: IReadinessManager): TClient {
|
|
27
28
|
|
|
28
29
|
const { log, mode } = settings;
|
|
29
30
|
const isAsync = isConsumerMode(mode);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import SplitIO from '../../types/splitio';
|
|
2
2
|
|
|
3
3
|
export function buildInstanceId(key: SplitIO.SplitKey, trafficType?: string) { // @ts-ignore
|
|
4
4
|
return `${key.matchingKey ? key.matchingKey : key}-${key.bucketingKey ? key.bucketingKey : key}-${trafficType ? trafficType : ''}`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
|
-
import
|
|
2
|
+
import SplitIO from '../../types/splitio';
|
|
3
3
|
import { releaseApiKey } from '../utils/inputValidation/apiKey';
|
|
4
4
|
import { clientFactory } from './client';
|
|
5
5
|
import { clientInputValidationDecorator } from './clientInputValidation';
|
|
@@ -10,7 +10,7 @@ const COOLDOWN_TIME_IN_MILLIS = 1000;
|
|
|
10
10
|
/**
|
|
11
11
|
* Creates an Sdk client, i.e., a base client with status and destroy interface
|
|
12
12
|
*/
|
|
13
|
-
export function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: boolean): SplitIO.
|
|
13
|
+
export function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: boolean): SplitIO.INodeClient | SplitIO.INodeAsyncClient {
|
|
14
14
|
const { sdkReadinessManager, syncManager, storage, signalListener, settings, telemetryTracker, uniqueKeysTracker } = params;
|
|
15
15
|
|
|
16
16
|
let lastActionTime = 0;
|
|
@@ -37,7 +37,7 @@ export function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: bo
|
|
|
37
37
|
|
|
38
38
|
return objectAssign(
|
|
39
39
|
// Proto-linkage of the readiness Event Emitter
|
|
40
|
-
Object.create(sdkReadinessManager.sdkStatus) as IStatusInterface,
|
|
40
|
+
Object.create(sdkReadinessManager.sdkStatus) as SplitIO.IStatusInterface,
|
|
41
41
|
|
|
42
42
|
// Client API (getTreatment* & track methods)
|
|
43
43
|
clientInputValidationDecorator(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import SplitIO from '../../types/splitio';
|
|
2
2
|
import { sdkClientFactory } from './sdkClient';
|
|
3
3
|
import { RETRIEVE_CLIENT_DEFAULT } from '../logger/constants';
|
|
4
4
|
import { ISdkFactoryContext } from '../sdkFactory/types';
|
|
@@ -6,7 +6,7 @@ import { ISdkFactoryContext } from '../sdkFactory/types';
|
|
|
6
6
|
/**
|
|
7
7
|
* Factory of client method for server-side SDKs
|
|
8
8
|
*/
|
|
9
|
-
export function sdkClientMethodFactory(params: ISdkFactoryContext): () => SplitIO.
|
|
9
|
+
export function sdkClientMethodFactory(params: ISdkFactoryContext): () => SplitIO.INodeClient | SplitIO.INodeAsyncClient {
|
|
10
10
|
const log = params.settings.log;
|
|
11
11
|
const clientInstance = sdkClientFactory(params);
|
|
12
12
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { clientCSDecorator } from './clientCS';
|
|
2
|
-
import
|
|
2
|
+
import SplitIO from '../../types/splitio';
|
|
3
3
|
import { validateKey } from '../utils/inputValidation/key';
|
|
4
4
|
import { getMatching, keyParser } from '../utils/key';
|
|
5
5
|
import { sdkClientFactory } from './sdkClient';
|
|
@@ -14,12 +14,12 @@ import { buildInstanceId } from './identity';
|
|
|
14
14
|
* Factory of client method for the client-side API variant where TT is ignored.
|
|
15
15
|
* Therefore, clients don't have a bound TT for the track method.
|
|
16
16
|
*/
|
|
17
|
-
export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: SplitIO.SplitKey) => SplitIO.
|
|
17
|
+
export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: SplitIO.SplitKey) => SplitIO.IClient {
|
|
18
18
|
const { clients, storage, syncManager, sdkReadinessManager, settings: { core: { key }, log } } = params;
|
|
19
19
|
|
|
20
20
|
const mainClientInstance = clientCSDecorator(
|
|
21
21
|
log,
|
|
22
|
-
sdkClientFactory(params) as SplitIO.
|
|
22
|
+
sdkClientFactory(params) as SplitIO.INodeClient,
|
|
23
23
|
key
|
|
24
24
|
);
|
|
25
25
|
|
|
@@ -71,7 +71,7 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl
|
|
|
71
71
|
sdkReadinessManager: sharedSdkReadiness,
|
|
72
72
|
storage: sharedStorage || storage,
|
|
73
73
|
syncManager: sharedSyncManager,
|
|
74
|
-
}), true) as SplitIO.
|
|
74
|
+
}), true) as SplitIO.INodeClient,
|
|
75
75
|
validKey
|
|
76
76
|
);
|
|
77
77
|
|
|
@@ -80,6 +80,6 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl
|
|
|
80
80
|
log.debug(RETRIEVE_CLIENT_EXISTING);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
return clients[instanceId] as SplitIO.
|
|
83
|
+
return clients[instanceId] as SplitIO.IClient;
|
|
84
84
|
};
|
|
85
85
|
}
|
package/src/sdkFactory/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { sdkReadinessManagerFactory } from '../readiness/sdkReadinessManager';
|
|
|
3
3
|
import { impressionsTrackerFactory } from '../trackers/impressionsTracker';
|
|
4
4
|
import { eventTrackerFactory } from '../trackers/eventTracker';
|
|
5
5
|
import { telemetryTrackerFactory } from '../trackers/telemetryTracker';
|
|
6
|
-
import
|
|
6
|
+
import SplitIO from '../../types/splitio';
|
|
7
7
|
import { validateAndTrackApiKey } from '../utils/inputValidation/apiKey';
|
|
8
8
|
import { createLoggerAPI } from '../logger/sdkLogger';
|
|
9
9
|
import { NEW_FACTORY, RETRIEVE_MANAGER } from '../logger/constants';
|
|
@@ -18,7 +18,7 @@ import { NONE, OPTIMIZED } from '../utils/constants';
|
|
|
18
18
|
/**
|
|
19
19
|
* Modular SDK factory
|
|
20
20
|
*/
|
|
21
|
-
export function sdkFactory(params: ISdkFactoryParams): SplitIO.
|
|
21
|
+
export function sdkFactory(params: ISdkFactoryParams): SplitIO.INodeSDK | SplitIO.INodeAsyncSDK | SplitIO.ISDK | SplitIO.IAsyncSDK {
|
|
22
22
|
|
|
23
23
|
const { settings, platform, storageFactory, splitApiFactory, extraProps,
|
|
24
24
|
syncManagerFactory, SignalListener, impressionsObserverFactory,
|
|
@@ -54,7 +54,7 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
|
|
|
54
54
|
},
|
|
55
55
|
});
|
|
56
56
|
// @TODO add support for dataloader: `if (params.dataLoader) params.dataLoader(storage);`
|
|
57
|
-
const clients: Record<string, IBasicClient> = {};
|
|
57
|
+
const clients: Record<string, SplitIO.IBasicClient> = {};
|
|
58
58
|
const telemetryTracker = telemetryTrackerFactory(storage.telemetry, platform.now);
|
|
59
59
|
const integrationsManager = integrationsManagerFactory && integrationsManagerFactory({ settings, storage, telemetryTracker });
|
|
60
60
|
|
package/src/sdkFactory/types.ts
CHANGED
|
@@ -8,7 +8,8 @@ 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 {
|
|
11
|
+
import { ISettings } from '../types';
|
|
12
|
+
import SplitIO from '../../types/splitio';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Environment related dependencies.
|
|
@@ -29,7 +30,7 @@ export interface IPlatform {
|
|
|
29
30
|
/**
|
|
30
31
|
* EventEmitter constructor, like NodeJS.EventEmitter or a polyfill.
|
|
31
32
|
*/
|
|
32
|
-
EventEmitter: new () => IEventEmitter,
|
|
33
|
+
EventEmitter: new () => SplitIO.IEventEmitter,
|
|
33
34
|
/**
|
|
34
35
|
* Function used to track latencies for telemetry.
|
|
35
36
|
*/
|
|
@@ -49,7 +50,7 @@ export interface ISdkFactoryContext {
|
|
|
49
50
|
signalListener?: ISignalListener
|
|
50
51
|
splitApi?: ISplitApi
|
|
51
52
|
syncManager?: ISyncManager,
|
|
52
|
-
clients: Record<string, IBasicClient>,
|
|
53
|
+
clients: Record<string, SplitIO.IBasicClient>,
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
export interface ISdkFactoryContextSync extends ISdkFactoryContext {
|
|
@@ -78,7 +79,7 @@ export interface ISdkFactoryParams {
|
|
|
78
79
|
platform: IPlatform,
|
|
79
80
|
|
|
80
81
|
// Storage factory. The result storage type implies the type of the SDK:
|
|
81
|
-
// sync SDK (`ISDK`
|
|
82
|
+
// sync SDK (`ISDK` and `INodeSDK`) with `IStorageSync`, and async SDK (`IAsyncSDK` and `INodeAsyncSDK`) with `IStorageAsync`
|
|
82
83
|
storageFactory: (params: IStorageFactoryParams) => IStorageSync | IStorageAsync,
|
|
83
84
|
|
|
84
85
|
// Factory of Split Api (HTTP Client Service).
|
|
@@ -94,8 +95,8 @@ export interface ISdkFactoryParams {
|
|
|
94
95
|
sdkManagerFactory: typeof sdkManagerFactory,
|
|
95
96
|
|
|
96
97
|
// Sdk client method factory (ISDK::client method).
|
|
97
|
-
// It Allows to distinguish SDK clients with the client-side API (`
|
|
98
|
-
sdkClientMethodFactory: (params: ISdkFactoryContext) => ({ (): SplitIO.
|
|
98
|
+
// It Allows to distinguish SDK clients with the client-side API (`ISDK` and `IAsyncSDK`) or server-side API (`INodeSDK` and `INodeAsyncSDK`).
|
|
99
|
+
sdkClientMethodFactory: (params: ISdkFactoryContext) => ({ (): SplitIO.IClient; (key: SplitIO.SplitKey): SplitIO.IClient; } | (() => SplitIO.INodeClient) | (() => SplitIO.INodeAsyncClient))
|
|
99
100
|
|
|
100
101
|
// Impression observer factory.
|
|
101
102
|
impressionsObserverFactory: () => IImpressionObserver
|
package/src/sdkManager/index.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { validateSplit, validateSplitExistence, validateIfNotDestroyed, validate
|
|
|
5
5
|
import { ISplitsCacheAsync, ISplitsCacheSync } from '../storages/types';
|
|
6
6
|
import { ISdkReadinessManager } from '../readiness/types';
|
|
7
7
|
import { ISplit } from '../dtos/types';
|
|
8
|
-
import { ISettings
|
|
8
|
+
import { ISettings } from '../types';
|
|
9
|
+
import SplitIO from '../../types/splitio';
|
|
9
10
|
import { isConsumerMode } from '../utils/settingsValidation/mode';
|
|
10
11
|
import { SPLIT_FN_LABEL, SPLITS_FN_LABEL, NAMES_FN_LABEL } from '../utils/constants';
|
|
11
12
|
|
package/src/services/splitApi.ts
CHANGED
|
@@ -16,9 +16,9 @@ function userKeyToQueryParam(userKey: string) {
|
|
|
16
16
|
/**
|
|
17
17
|
* Factory of SplitApi objects, which group the collection of Split HTTP endpoints used by the SDK
|
|
18
18
|
*
|
|
19
|
-
* @param settings validated settings object
|
|
20
|
-
* @param platform object containing environment-specific dependencies
|
|
21
|
-
* @param telemetryTracker telemetry tracker
|
|
19
|
+
* @param settings - validated settings object
|
|
20
|
+
* @param platform - object containing environment-specific dependencies
|
|
21
|
+
* @param telemetryTracker - telemetry tracker
|
|
22
22
|
*/
|
|
23
23
|
export function splitApiFactory(
|
|
24
24
|
settings: ISettings,
|
|
@@ -81,8 +81,8 @@ export function splitApiFactory(
|
|
|
81
81
|
/**
|
|
82
82
|
* Post events.
|
|
83
83
|
*
|
|
84
|
-
* @param body Events bulk payload
|
|
85
|
-
* @param headers Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
84
|
+
* @param body - Events bulk payload
|
|
85
|
+
* @param headers - Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
86
86
|
*/
|
|
87
87
|
postEventsBulk(body: string, headers?: Record<string, string>) {
|
|
88
88
|
const url = `${urls.events}/events/bulk`;
|
|
@@ -92,8 +92,8 @@ export function splitApiFactory(
|
|
|
92
92
|
/**
|
|
93
93
|
* Post impressions.
|
|
94
94
|
*
|
|
95
|
-
* @param body Impressions bulk payload
|
|
96
|
-
* @param headers Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
95
|
+
* @param body - Impressions bulk payload
|
|
96
|
+
* @param headers - Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
97
97
|
*/
|
|
98
98
|
postTestImpressionsBulk(body: string, headers?: Record<string, string>) {
|
|
99
99
|
const url = `${urls.events}/testImpressions/bulk`;
|
|
@@ -106,8 +106,8 @@ export function splitApiFactory(
|
|
|
106
106
|
/**
|
|
107
107
|
* Post impressions counts.
|
|
108
108
|
*
|
|
109
|
-
* @param body Impressions counts payload
|
|
110
|
-
* @param headers Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
109
|
+
* @param body - Impressions counts payload
|
|
110
|
+
* @param headers - Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
111
111
|
*/
|
|
112
112
|
postTestImpressionsCount(body: string, headers?: Record<string, string>) {
|
|
113
113
|
const url = `${urls.events}/testImpressions/count`;
|
|
@@ -117,8 +117,8 @@ export function splitApiFactory(
|
|
|
117
117
|
/**
|
|
118
118
|
* Post unique keys for client side.
|
|
119
119
|
*
|
|
120
|
-
* @param body unique keys payload
|
|
121
|
-
* @param headers Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
120
|
+
* @param body - unique keys payload
|
|
121
|
+
* @param headers - Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
122
122
|
*/
|
|
123
123
|
postUniqueKeysBulkCs(body: string, headers?: Record<string, string>) {
|
|
124
124
|
const url = `${urls.telemetry}/v1/keys/cs`;
|
|
@@ -128,8 +128,8 @@ export function splitApiFactory(
|
|
|
128
128
|
/**
|
|
129
129
|
* Post unique keys for server side.
|
|
130
130
|
*
|
|
131
|
-
* @param body unique keys payload
|
|
132
|
-
* @param headers Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
131
|
+
* @param body - unique keys payload
|
|
132
|
+
* @param headers - Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
133
133
|
*/
|
|
134
134
|
postUniqueKeysBulkSs(body: string, headers?: Record<string, string>) {
|
|
135
135
|
const url = `${urls.telemetry}/v1/keys/ss`;
|
|
@@ -10,8 +10,8 @@ const messageNoFetch = 'Global fetch API is not available.';
|
|
|
10
10
|
/**
|
|
11
11
|
* Factory of Split HTTP clients, which are HTTP clients with predefined headers for Split endpoints.
|
|
12
12
|
*
|
|
13
|
-
* @param settings SDK settings, used to access authorizationKey, logger instance and metadata (SDK version, ip and hostname) to set additional headers
|
|
14
|
-
* @param platform object containing environment-specific dependencies
|
|
13
|
+
* @param settings - SDK settings, used to access authorizationKey, logger instance and metadata (SDK version, ip and hostname) to set additional headers
|
|
14
|
+
* @param platform - object containing environment-specific dependencies
|
|
15
15
|
*/
|
|
16
16
|
export function splitHttpClientFactory(settings: ISettings, { getOptions, getFetch }: Pick<IPlatform, 'getOptions' | 'getFetch'>): ISplitHttpClient {
|
|
17
17
|
|
|
@@ -38,8 +38,8 @@ export abstract class AbstractMySegmentsCacheSync implements ISegmentsCacheSync
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Only used for the `skC`(segment keys count) telemetry stat: 1 for client-side, and total count of keys in server-side.
|
|
41
|
-
* @TODO for client-side it should be the number of clients, but it requires a refactor of MySegments caches to simplify the code.
|
|
42
41
|
*/
|
|
42
|
+
// @TODO for client-side it should be the number of clients, but it requires a refactor of MySegments caches to simplify the code.
|
|
43
43
|
abstract getKeysCount(): number
|
|
44
44
|
|
|
45
45
|
abstract getChangeNumber(name: string): number
|
|
@@ -39,10 +39,7 @@ export abstract class AbstractSplitsCacheAsync implements ISplitsCacheAsync {
|
|
|
39
39
|
* Kill `name` split and set `defaultTreatment` and `changeNumber`.
|
|
40
40
|
* Used for SPLIT_KILL push notifications.
|
|
41
41
|
*
|
|
42
|
-
* @
|
|
43
|
-
* @param {string} defaultTreatment
|
|
44
|
-
* @param {number} changeNumber
|
|
45
|
-
* @returns {Promise} a promise that is resolved once the split kill operation is performed. The fulfillment value is a boolean: `true` if the operation successed updating the split or `false` if no split is updated,
|
|
42
|
+
* @returns a promise that is resolved once the split kill operation is performed. The fulfillment value is a boolean: `true` if the operation successed updating the split or `false` if no split is updated,
|
|
46
43
|
* for instance, if the `changeNumber` is old, or if the split is not found (e.g., `/splitchanges` hasn't been fetched yet), or if the storage fails to apply the update.
|
|
47
44
|
* The promise will never be rejected.
|
|
48
45
|
*/
|
|
@@ -59,10 +59,7 @@ export abstract class AbstractSplitsCacheSync implements ISplitsCacheSync {
|
|
|
59
59
|
* Kill `name` split and set `defaultTreatment` and `changeNumber`.
|
|
60
60
|
* Used for SPLIT_KILL push notifications.
|
|
61
61
|
*
|
|
62
|
-
* @
|
|
63
|
-
* @param {string} defaultTreatment
|
|
64
|
-
* @param {number} changeNumber
|
|
65
|
-
* @returns {boolean} `true` if the operation successed updating the split, or `false` if no split is updated,
|
|
62
|
+
* @returns `true` if the operation successed updating the split, or `false` if no split is updated,
|
|
66
63
|
* for instance, if the `changeNumber` is old, or if the split is not found (e.g., `/splitchanges` hasn't been fetched yet), or if the storage fails to apply the update.
|
|
67
64
|
*/
|
|
68
65
|
killLocally(name: string, defaultTreatment: string, changeNumber: number): boolean {
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PreloadedData } from '../types';
|
|
2
2
|
import { DEFAULT_CACHE_EXPIRATION_IN_MILLIS } from '../utils/constants/browser';
|
|
3
3
|
import { DataLoader, ISegmentsCacheSync, ISplitsCacheSync } from './types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Factory of client-side storage loader
|
|
7
7
|
*
|
|
8
|
-
* @param preloadedData validated data following the format proposed in https://github.com/godaddy/split-javascript-data-loader
|
|
8
|
+
* @param preloadedData - validated data following the format proposed in https://github.com/godaddy/split-javascript-data-loader
|
|
9
9
|
* and extended with a `mySegmentsData` property.
|
|
10
10
|
* @returns function to preload the storage
|
|
11
11
|
*/
|
|
12
|
-
export function dataLoaderFactory(preloadedData:
|
|
12
|
+
export function dataLoaderFactory(preloadedData: PreloadedData): DataLoader {
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Storage-agnostic adaptation of `loadDataIntoLocalStorage` function
|
|
16
16
|
* (https://github.com/godaddy/split-javascript-data-loader/blob/master/src/load-data.js)
|
|
17
17
|
*
|
|
18
|
-
* @param storage object containing `splits` and `segments` cache (client-side variant)
|
|
19
|
-
* @param userId user key string of the provided MySegmentsCache
|
|
20
|
-
*
|
|
21
|
-
* @TODO extend to support SegmentsCache (server-side variant) by making `userId` optional and adding the corresponding logic.
|
|
22
|
-
* @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.
|
|
18
|
+
* @param storage - object containing `splits` and `segments` cache (client-side variant)
|
|
19
|
+
* @param userId - user key string of the provided MySegmentsCache
|
|
23
20
|
*/
|
|
21
|
+
// @TODO extend to support SegmentsCache (server-side variant) by making `userId` optional and adding the corresponding logic.
|
|
22
|
+
// @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.
|
|
24
23
|
return function loadData(storage: { splits: ISplitsCacheSync, segments: ISegmentsCacheSync }, userId: string) {
|
|
25
24
|
// Do not load data if current preloadedData is empty
|
|
26
25
|
if (Object.keys(preloadedData).length === 0) return;
|
|
@@ -7,7 +7,7 @@ const BASE = 1.5;
|
|
|
7
7
|
/**
|
|
8
8
|
* Calculates buckets from latency in milliseconds
|
|
9
9
|
*
|
|
10
|
-
* @param latencyInMs
|
|
10
|
+
* @param latencyInMs - latency in milliseconds
|
|
11
11
|
* @returns a bucket index from 0 to 22 inclusive
|
|
12
12
|
*/
|
|
13
13
|
export function findLatencyIndex(latencyInMs: number): number {
|
|
@@ -20,11 +20,6 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
|
|
|
20
20
|
private hasSync?: boolean;
|
|
21
21
|
private updateNewFilter?: boolean;
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* @param {KeyBuilderCS} keys
|
|
25
|
-
* @param {number | undefined} expirationTimestamp
|
|
26
|
-
* @param {ISplitFiltersValidation} splitFiltersValidation
|
|
27
|
-
*/
|
|
28
23
|
constructor(settings: ISettings, keys: KeyBuilderCS, expirationTimestamp?: number) {
|
|
29
24
|
super();
|
|
30
25
|
this.keys = keys;
|
|
@@ -229,7 +224,7 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
|
|
|
229
224
|
/**
|
|
230
225
|
* Clean Splits cache if its `lastUpdated` timestamp is older than the given `expirationTimestamp`,
|
|
231
226
|
*
|
|
232
|
-
* @param
|
|
227
|
+
* @param expirationTimestamp - if the value is not a number, data will not be cleaned
|
|
233
228
|
*/
|
|
234
229
|
private _checkExpiration(expirationTimestamp?: number) {
|
|
235
230
|
let value: string | number | null = localStorage.getItem(this.keys.buildLastUpdatedKey());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import SplitIO from '../../../types/splitio';
|
|
2
2
|
import { objectAssign } from '../../utils/lang/objectAssign';
|
|
3
3
|
|
|
4
4
|
export class AttributesCacheInMemory {
|
|
@@ -9,9 +9,9 @@ export class AttributesCacheInMemory {
|
|
|
9
9
|
/**
|
|
10
10
|
* Create or update the value for the given attribute
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @returns
|
|
12
|
+
* @param attributeName - attribute name
|
|
13
|
+
* @param attributeValue - attribute value
|
|
14
|
+
* @returns the attribute was stored
|
|
15
15
|
*/
|
|
16
16
|
setAttribute(attributeName: string, attributeValue: SplitIO.AttributeType) {
|
|
17
17
|
this.attributesCache[attributeName] = attributeValue;
|
|
@@ -21,8 +21,8 @@ export class AttributesCacheInMemory {
|
|
|
21
21
|
/**
|
|
22
22
|
* Retrieves the value of a given attribute
|
|
23
23
|
*
|
|
24
|
-
* @param
|
|
25
|
-
* @returns
|
|
24
|
+
* @param attributeName - attribute name
|
|
25
|
+
* @returns stored attribute value
|
|
26
26
|
*/
|
|
27
27
|
getAttribute(attributeName: string) {
|
|
28
28
|
return this.attributesCache[attributeName];
|
|
@@ -31,8 +31,8 @@ export class AttributesCacheInMemory {
|
|
|
31
31
|
/**
|
|
32
32
|
* Create or update all the given attributes
|
|
33
33
|
*
|
|
34
|
-
* @param
|
|
35
|
-
* @returns
|
|
34
|
+
* @param attributes - attributes to create or update
|
|
35
|
+
* @returns attributes were stored
|
|
36
36
|
*/
|
|
37
37
|
setAttributes(attributes: Record<string, Object>) {
|
|
38
38
|
this.attributesCache = objectAssign(this.attributesCache, attributes);
|
|
@@ -42,7 +42,7 @@ export class AttributesCacheInMemory {
|
|
|
42
42
|
/**
|
|
43
43
|
* Retrieve the full attributes map
|
|
44
44
|
*
|
|
45
|
-
* @returns
|
|
45
|
+
* @returns stored attributes
|
|
46
46
|
*/
|
|
47
47
|
getAll() {
|
|
48
48
|
return this.attributesCache;
|
|
@@ -51,8 +51,8 @@ export class AttributesCacheInMemory {
|
|
|
51
51
|
/**
|
|
52
52
|
* Removes a given attribute from the map
|
|
53
53
|
*
|
|
54
|
-
* @param
|
|
55
|
-
* @returns
|
|
54
|
+
* @param attributeName - attribute to remove
|
|
55
|
+
* @returns attribute removed
|
|
56
56
|
*/
|
|
57
57
|
removeAttribute(attributeName: string) {
|
|
58
58
|
if (Object.keys(this.attributesCache).indexOf(attributeName) >= 0) {
|