@splitsoftware/splitio-commons 1.17.1-rc.3 → 2.0.0-rc.0

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.
Files changed (216) hide show
  1. package/CHANGES.txt +7 -3
  2. package/cjs/evaluator/index.js +2 -2
  3. package/cjs/evaluator/matchers/semver_inlist.js +1 -2
  4. package/cjs/evaluator/matchers/whitelist.js +1 -2
  5. package/cjs/listeners/browser.js +1 -2
  6. package/cjs/logger/browser/DebugLogger.js +1 -2
  7. package/cjs/logger/browser/ErrorLogger.js +1 -2
  8. package/cjs/logger/browser/InfoLogger.js +1 -2
  9. package/cjs/logger/browser/WarnLogger.js +1 -2
  10. package/cjs/logger/index.js +1 -2
  11. package/cjs/readiness/readinessManager.js +5 -7
  12. package/cjs/sdkClient/clientCS.js +5 -8
  13. package/cjs/sdkClient/sdkClientMethodCS.js +5 -8
  14. package/cjs/sdkFactory/index.js +10 -33
  15. package/cjs/services/decorateHeaders.js +1 -2
  16. package/cjs/storages/AbstractSplitsCacheAsync.js +7 -0
  17. package/cjs/storages/AbstractSplitsCacheSync.js +7 -0
  18. package/cjs/storages/KeyBuilderCS.js +0 -9
  19. package/cjs/storages/dataLoader.js +32 -64
  20. package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
  21. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +14 -7
  22. package/cjs/storages/inLocalStorage/index.js +1 -6
  23. package/cjs/storages/inMemory/InMemoryStorageCS.js +4 -16
  24. package/cjs/storages/inMemory/SegmentsCacheInMemory.js +3 -4
  25. package/cjs/storages/inMemory/SplitsCacheInMemory.js +2 -3
  26. package/cjs/storages/inMemory/UniqueKeysCacheInMemory.js +2 -3
  27. package/cjs/storages/inMemory/UniqueKeysCacheInMemoryCS.js +2 -3
  28. package/cjs/storages/inRedis/RedisAdapter.js +3 -4
  29. package/cjs/storages/inRedis/SplitsCacheInRedis.js +1 -1
  30. package/cjs/storages/inRedis/TelemetryCacheInRedis.js +3 -4
  31. package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +1 -2
  32. package/cjs/storages/pluggable/SplitsCachePluggable.js +1 -1
  33. package/cjs/storages/pluggable/TelemetryCachePluggable.js +6 -7
  34. package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +1 -2
  35. package/cjs/storages/pluggable/inMemoryWrapper.js +7 -8
  36. package/cjs/storages/pluggable/index.js +32 -37
  37. package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +7 -2
  38. package/cjs/sync/polling/pollingManagerSS.js +3 -3
  39. package/cjs/sync/polling/updaters/splitChangesUpdater.js +13 -5
  40. package/cjs/sync/streaming/parseUtils.js +0 -1
  41. package/cjs/sync/streaming/pushManager.js +2 -3
  42. package/cjs/trackers/eventTracker.js +9 -11
  43. package/cjs/trackers/impressionsTracker.js +13 -15
  44. package/cjs/trackers/uniqueKeysTracker.js +3 -5
  45. package/cjs/utils/LRUCache/index.js +1 -2
  46. package/cjs/utils/constants/browser.js +1 -4
  47. package/cjs/utils/lang/index.js +6 -9
  48. package/cjs/utils/lang/objectAssign.js +12 -77
  49. package/cjs/utils/lang/sets.js +3 -110
  50. package/cjs/utils/settingsValidation/index.js +0 -9
  51. package/cjs/utils/settingsValidation/logger/builtinLogger.js +1 -2
  52. package/cjs/utils/settingsValidation/storage/storageCS.js +12 -1
  53. package/esm/evaluator/index.js +3 -3
  54. package/esm/evaluator/matchers/semver_inlist.js +1 -2
  55. package/esm/evaluator/matchers/whitelist.js +1 -2
  56. package/esm/listeners/browser.js +1 -2
  57. package/esm/logger/browser/DebugLogger.js +1 -2
  58. package/esm/logger/browser/ErrorLogger.js +1 -2
  59. package/esm/logger/browser/InfoLogger.js +1 -2
  60. package/esm/logger/browser/WarnLogger.js +1 -2
  61. package/esm/logger/index.js +1 -2
  62. package/esm/readiness/readinessManager.js +5 -7
  63. package/esm/sdkClient/clientCS.js +5 -8
  64. package/esm/sdkClient/sdkClientMethodCS.js +5 -8
  65. package/esm/sdkFactory/index.js +11 -34
  66. package/esm/services/decorateHeaders.js +1 -2
  67. package/esm/storages/AbstractSplitsCacheAsync.js +7 -0
  68. package/esm/storages/AbstractSplitsCacheSync.js +7 -0
  69. package/esm/storages/KeyBuilderCS.js +0 -9
  70. package/esm/storages/dataLoader.js +30 -61
  71. package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
  72. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +14 -7
  73. package/esm/storages/inLocalStorage/index.js +2 -7
  74. package/esm/storages/inMemory/InMemoryStorageCS.js +4 -16
  75. package/esm/storages/inMemory/SegmentsCacheInMemory.js +3 -4
  76. package/esm/storages/inMemory/SplitsCacheInMemory.js +2 -3
  77. package/esm/storages/inMemory/UniqueKeysCacheInMemory.js +2 -3
  78. package/esm/storages/inMemory/UniqueKeysCacheInMemoryCS.js +2 -3
  79. package/esm/storages/inRedis/RedisAdapter.js +3 -4
  80. package/esm/storages/inRedis/SplitsCacheInRedis.js +2 -2
  81. package/esm/storages/inRedis/TelemetryCacheInRedis.js +3 -4
  82. package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -2
  83. package/esm/storages/pluggable/SplitsCachePluggable.js +2 -2
  84. package/esm/storages/pluggable/TelemetryCachePluggable.js +6 -7
  85. package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -2
  86. package/esm/storages/pluggable/inMemoryWrapper.js +7 -8
  87. package/esm/storages/pluggable/index.js +32 -37
  88. package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +8 -3
  89. package/esm/sync/polling/pollingManagerSS.js +3 -3
  90. package/esm/sync/polling/updaters/splitChangesUpdater.js +14 -6
  91. package/esm/sync/streaming/parseUtils.js +0 -1
  92. package/esm/sync/streaming/pushManager.js +2 -3
  93. package/esm/trackers/eventTracker.js +9 -11
  94. package/esm/trackers/impressionsTracker.js +13 -15
  95. package/esm/trackers/uniqueKeysTracker.js +3 -5
  96. package/esm/utils/LRUCache/index.js +1 -2
  97. package/esm/utils/constants/browser.js +0 -3
  98. package/esm/utils/lang/index.js +6 -9
  99. package/esm/utils/lang/objectAssign.js +12 -77
  100. package/esm/utils/lang/sets.js +2 -107
  101. package/esm/utils/settingsValidation/index.js +0 -9
  102. package/esm/utils/settingsValidation/logger/builtinLogger.js +1 -2
  103. package/esm/utils/settingsValidation/storage/storageCS.js +10 -0
  104. package/package.json +2 -2
  105. package/src/evaluator/index.ts +5 -5
  106. package/src/evaluator/matchers/semver_inlist.ts +1 -2
  107. package/src/evaluator/matchers/whitelist.ts +1 -3
  108. package/src/listeners/browser.ts +1 -2
  109. package/src/logger/browser/DebugLogger.ts +1 -2
  110. package/src/logger/browser/ErrorLogger.ts +1 -2
  111. package/src/logger/browser/InfoLogger.ts +1 -2
  112. package/src/logger/browser/WarnLogger.ts +1 -2
  113. package/src/logger/index.ts +3 -4
  114. package/src/readiness/readinessManager.ts +7 -9
  115. package/src/readiness/types.ts +0 -1
  116. package/src/sdkClient/clientCS.ts +5 -8
  117. package/src/sdkClient/sdkClientMethodCS.ts +3 -6
  118. package/src/sdkFactory/index.ts +12 -37
  119. package/src/sdkFactory/types.ts +1 -4
  120. package/src/services/decorateHeaders.ts +1 -2
  121. package/src/storages/AbstractSplitsCacheAsync.ts +9 -2
  122. package/src/storages/AbstractSplitsCacheSync.ts +9 -2
  123. package/src/storages/KeyBuilderCS.ts +0 -13
  124. package/src/storages/dataLoader.ts +32 -62
  125. package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +1 -21
  126. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +16 -8
  127. package/src/storages/inLocalStorage/index.ts +2 -8
  128. package/src/storages/inMemory/InMemoryStorageCS.ts +4 -19
  129. package/src/storages/inMemory/SegmentsCacheInMemory.ts +4 -5
  130. package/src/storages/inMemory/SplitsCacheInMemory.ts +4 -5
  131. package/src/storages/inMemory/UniqueKeysCacheInMemory.ts +4 -5
  132. package/src/storages/inMemory/UniqueKeysCacheInMemoryCS.ts +4 -5
  133. package/src/storages/inRedis/RedisAdapter.ts +4 -5
  134. package/src/storages/inRedis/SplitsCacheInRedis.ts +3 -3
  135. package/src/storages/inRedis/TelemetryCacheInRedis.ts +3 -4
  136. package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +1 -2
  137. package/src/storages/pluggable/SegmentsCachePluggable.ts +0 -1
  138. package/src/storages/pluggable/SplitsCachePluggable.ts +3 -3
  139. package/src/storages/pluggable/TelemetryCachePluggable.ts +6 -7
  140. package/src/storages/pluggable/UniqueKeysCachePluggable.ts +1 -2
  141. package/src/storages/pluggable/inMemoryWrapper.ts +8 -9
  142. package/src/storages/pluggable/index.ts +33 -38
  143. package/src/storages/types.ts +9 -6
  144. package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +7 -3
  145. package/src/sync/polling/pollingManagerSS.ts +2 -3
  146. package/src/sync/polling/updaters/splitChangesUpdater.ts +15 -8
  147. package/src/sync/streaming/parseUtils.ts +0 -1
  148. package/src/sync/streaming/pushManager.ts +3 -4
  149. package/src/sync/submitters/types.ts +3 -4
  150. package/src/trackers/eventTracker.ts +7 -10
  151. package/src/trackers/impressionsTracker.ts +9 -12
  152. package/src/trackers/types.ts +0 -1
  153. package/src/trackers/uniqueKeysTracker.ts +4 -6
  154. package/src/types.ts +9 -18
  155. package/src/utils/LRUCache/index.ts +2 -3
  156. package/src/utils/constants/browser.ts +0 -4
  157. package/src/utils/lang/index.ts +6 -7
  158. package/src/utils/lang/objectAssign.ts +13 -92
  159. package/src/utils/lang/sets.ts +3 -125
  160. package/src/utils/settingsValidation/index.ts +0 -10
  161. package/src/utils/settingsValidation/logger/builtinLogger.ts +1 -2
  162. package/src/utils/settingsValidation/storage/storageCS.ts +13 -0
  163. package/src/utils/settingsValidation/types.ts +0 -2
  164. package/types/logger/index.d.ts +1 -2
  165. package/types/readiness/types.d.ts +0 -1
  166. package/types/sdkClient/clientCS.d.ts +2 -3
  167. package/types/sdkFactory/types.d.ts +1 -3
  168. package/types/storages/AbstractSplitsCacheAsync.d.ts +6 -2
  169. package/types/storages/AbstractSplitsCacheSync.d.ts +6 -2
  170. package/types/storages/KeyBuilderCS.d.ts +0 -2
  171. package/types/storages/dataLoader.d.ts +6 -17
  172. package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +7 -2
  173. package/types/storages/inMemory/SplitsCacheInMemory.d.ts +1 -2
  174. package/types/storages/inMemory/UniqueKeysCacheInMemory.d.ts +2 -3
  175. package/types/storages/inRedis/SplitsCacheInRedis.d.ts +1 -2
  176. package/types/storages/pluggable/SplitsCachePluggable.d.ts +1 -2
  177. package/types/storages/pluggable/inMemoryWrapper.d.ts +1 -2
  178. package/types/storages/types.d.ts +7 -6
  179. package/types/sync/polling/updaters/splitChangesUpdater.d.ts +1 -2
  180. package/types/sync/submitters/types.d.ts +3 -4
  181. package/types/trackers/eventTracker.d.ts +1 -1
  182. package/types/trackers/impressionsTracker.d.ts +1 -1
  183. package/types/trackers/types.d.ts +0 -1
  184. package/types/types.d.ts +9 -17
  185. package/types/utils/LRUCache/index.d.ts +1 -2
  186. package/types/utils/constants/browser.d.ts +0 -2
  187. package/types/utils/lang/objectAssign.d.ts +3 -0
  188. package/types/utils/lang/sets.d.ts +1 -61
  189. package/types/utils/settingsValidation/index.d.ts +0 -1
  190. package/types/utils/settingsValidation/storage/storageCS.d.ts +5 -0
  191. package/types/utils/settingsValidation/types.d.ts +0 -2
  192. package/cjs/integrations/browser.js +0 -31
  193. package/cjs/integrations/ga/GaToSplit.js +0 -257
  194. package/cjs/integrations/ga/GoogleAnalyticsToSplit.js +0 -14
  195. package/cjs/integrations/ga/SplitToGa.js +0 -123
  196. package/cjs/integrations/ga/SplitToGoogleAnalytics.js +0 -14
  197. package/cjs/integrations/ga/types.js +0 -2
  198. package/cjs/sdkClient/sdkClientMethodCSWithTT.js +0 -79
  199. package/cjs/utils/lang/maps.js +0 -96
  200. package/esm/integrations/browser.js +0 -27
  201. package/esm/integrations/ga/GaToSplit.js +0 -250
  202. package/esm/integrations/ga/GoogleAnalyticsToSplit.js +0 -10
  203. package/esm/integrations/ga/SplitToGa.js +0 -120
  204. package/esm/integrations/ga/SplitToGoogleAnalytics.js +0 -10
  205. package/esm/integrations/ga/types.js +0 -1
  206. package/esm/sdkClient/sdkClientMethodCSWithTT.js +0 -75
  207. package/esm/utils/lang/maps.js +0 -92
  208. package/src/integrations/browser.ts +0 -35
  209. package/src/integrations/ga/GaToSplit.ts +0 -299
  210. package/src/integrations/ga/GoogleAnalyticsToSplit.ts +0 -14
  211. package/src/integrations/ga/SplitToGa.ts +0 -135
  212. package/src/integrations/ga/SplitToGoogleAnalytics.ts +0 -14
  213. package/src/integrations/ga/autoRequire.js +0 -33
  214. package/src/integrations/ga/types.ts +0 -153
  215. package/src/sdkClient/sdkClientMethodCSWithTT.ts +0 -101
  216. package/src/utils/lang/maps.ts +0 -108
@@ -2,7 +2,6 @@ import { KeyBuilder } from './KeyBuilder';
2
2
  export interface MySegmentsKeyBuilder {
3
3
  buildSegmentNameKey(segmentName: string): string;
4
4
  extractSegmentName(builtSegmentKeyName: string): string | undefined;
5
- extractOldSegmentKey(builtSegmentKeyName: string): string | undefined;
6
5
  buildTillKey(): string;
7
6
  }
8
7
  export declare class KeyBuilderCS extends KeyBuilder implements MySegmentsKeyBuilder {
@@ -14,7 +13,6 @@ export declare class KeyBuilderCS extends KeyBuilder implements MySegmentsKeyBui
14
13
  */
15
14
  buildSegmentNameKey(segmentName: string): string;
16
15
  extractSegmentName(builtSegmentKeyName: string): string | undefined;
17
- extractOldSegmentKey(builtSegmentKeyName: string): string | undefined;
18
16
  buildLastUpdatedKey(): string;
19
17
  isSplitsCacheKey(key: string): boolean;
20
18
  buildTillKey(): string;
@@ -1,21 +1,10 @@
1
1
  import { SplitIO } from '../types';
2
- import { ISegmentsCacheSync, ISplitsCacheSync, IStorageSync } from './types';
2
+ import { DataLoader } from './types';
3
3
  /**
4
- * Storage-agnostic adaptation of `loadDataIntoLocalStorage` function
5
- * (https://github.com/godaddy/split-javascript-data-loader/blob/master/src/load-data.js)
4
+ * Factory of client-side storage loader
6
5
  *
7
- * @param preloadedData validated data following the format proposed in https://github.com/godaddy/split-javascript-data-loader and extended with a `mySegmentsData` property.
8
- * @param storage object containing `splits` and `segments` cache (client-side variant)
9
- * @param userKey user key (matching key) of the provided MySegmentsCache
10
- *
11
- * @TODO extend to load largeSegments
12
- * @TODO extend to load data on shared mySegments storages. Be specific when emitting SDK_READY_FROM_CACHE on shared clients. Maybe the serializer should provide the `useSegments` flag.
13
- * @TODO add logs, and input validation in this module, in favor of size reduction.
14
- * @TODO unit tests
6
+ * @param preloadedData validated data following the format proposed in https://github.com/godaddy/split-javascript-data-loader
7
+ * and extended with a `mySegmentsData` property.
8
+ * @returns function to preload the storage
15
9
  */
16
- export declare function loadData(preloadedData: SplitIO.PreloadedData, storage: {
17
- splits?: ISplitsCacheSync;
18
- segments: ISegmentsCacheSync;
19
- largeSegments?: ISegmentsCacheSync;
20
- }, matchingKey?: string): void;
21
- export declare function getSnapshot(storage: IStorageSync, userKeys?: SplitIO.SplitKey[]): SplitIO.PreloadedData;
10
+ export declare function dataLoaderFactory(preloadedData: SplitIO.PreloadedData): DataLoader;
@@ -1,7 +1,6 @@
1
1
  import { ISplit } from '../../dtos/types';
2
2
  import { AbstractSplitsCacheSync } from '../AbstractSplitsCacheSync';
3
3
  import { KeyBuilderCS } from '../KeyBuilderCS';
4
- import { ISet } from '../../utils/lang/sets';
5
4
  import { ISettings } from '../../types';
6
5
  /**
7
6
  * ISplitsCacheSync implementation that stores split definitions in browser LocalStorage.
@@ -35,6 +34,12 @@ export declare class SplitsCacheInLocal extends AbstractSplitsCacheSync {
35
34
  getSplitNames(): string[];
36
35
  trafficTypeExists(trafficType: string): boolean;
37
36
  usesSegments(): boolean;
37
+ /**
38
+ * Check if the splits information is already stored in browser LocalStorage.
39
+ * In this function we could add more code to check if the data is valid.
40
+ * @override
41
+ */
42
+ checkCache(): boolean;
38
43
  /**
39
44
  * Clean Splits cache if its `lastUpdated` timestamp is older than the given `expirationTimestamp`,
40
45
  *
@@ -42,7 +47,7 @@ export declare class SplitsCacheInLocal extends AbstractSplitsCacheSync {
42
47
  */
43
48
  private _checkExpiration;
44
49
  private _checkFilterQuery;
45
- getNamesByFlagSets(flagSets: string[]): ISet<string>[];
50
+ getNamesByFlagSets(flagSets: string[]): Set<string>[];
46
51
  private addToFlagSets;
47
52
  private removeFromFlagSets;
48
53
  private removeNames;
@@ -1,6 +1,5 @@
1
1
  import { ISplit, ISplitFiltersValidation } from '../../dtos/types';
2
2
  import { AbstractSplitsCacheSync } from '../AbstractSplitsCacheSync';
3
- import { ISet } from '../../utils/lang/sets';
4
3
  /**
5
4
  * Default ISplitsCacheSync implementation that stores split definitions in memory.
6
5
  * Supported by all JS runtimes.
@@ -22,7 +21,7 @@ export declare class SplitsCacheInMemory extends AbstractSplitsCacheSync {
22
21
  getSplitNames(): string[];
23
22
  trafficTypeExists(trafficType: string): boolean;
24
23
  usesSegments(): boolean;
25
- getNamesByFlagSets(flagSets: string[]): ISet<string>[];
24
+ getNamesByFlagSets(flagSets: string[]): Set<string>[];
26
25
  private addToFlagSets;
27
26
  private removeFromFlagSets;
28
27
  private removeNames;
@@ -1,18 +1,17 @@
1
1
  import { IUniqueKeysCacheBase } from '../types';
2
- import { ISet } from '../../utils/lang/sets';
3
2
  import { UniqueKeysPayloadSs } from '../../sync/submitters/types';
4
3
  /**
5
4
  * Converts `uniqueKeys` data from cache into request payload for SS.
6
5
  */
7
6
  export declare function fromUniqueKeysCollector(uniqueKeys: {
8
- [featureName: string]: ISet<string>;
7
+ [featureName: string]: Set<string>;
9
8
  }): UniqueKeysPayloadSs;
10
9
  export declare class UniqueKeysCacheInMemory implements IUniqueKeysCacheBase {
11
10
  protected onFullQueue?: () => void;
12
11
  private readonly maxStorage;
13
12
  private uniqueTrackerSize;
14
13
  protected uniqueKeysTracker: {
15
- [featureName: string]: ISet<string>;
14
+ [featureName: string]: Set<string>;
16
15
  };
17
16
  constructor(uniqueKeysQueueSize?: number);
18
17
  setOnFullQueueCb(cb: () => void): void;
@@ -2,7 +2,6 @@ import { KeyBuilderSS } from '../KeyBuilderSS';
2
2
  import { ILogger } from '../../logger/types';
3
3
  import { ISplit, ISplitFiltersValidation } from '../../dtos/types';
4
4
  import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync';
5
- import { ISet } from '../../utils/lang/sets';
6
5
  import type { RedisAdapter } from './RedisAdapter';
7
6
  /**
8
7
  * ISplitsCacheAsync implementation that stores split definitions in Redis.
@@ -79,7 +78,7 @@ export declare class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
79
78
  * The returned promise is resolved with the list of feature flag names per flag set,
80
79
  * or rejected if the pipelined redis operation fails (e.g., timeout).
81
80
  */
82
- getNamesByFlagSets(flagSets: string[]): Promise<ISet<string>[]>;
81
+ getNamesByFlagSets(flagSets: string[]): Promise<Set<string>[]>;
83
82
  /**
84
83
  * Check traffic type existence.
85
84
  * The returned promise is resolved with a boolean indicating whether the TT exist or not.
@@ -3,7 +3,6 @@ import { IPluggableStorageWrapper } from '../types';
3
3
  import { ILogger } from '../../logger/types';
4
4
  import { ISplit, ISplitFiltersValidation } from '../../dtos/types';
5
5
  import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync';
6
- import { ISet } from '../../utils/lang/sets';
7
6
  /**
8
7
  * ISplitsCacheAsync implementation for pluggable storages.
9
8
  */
@@ -75,7 +74,7 @@ export declare class SplitsCachePluggable extends AbstractSplitsCacheAsync {
75
74
  * The returned promise is resolved with the list of feature flag names per flag set.
76
75
  * It never rejects (If there is a wrapper error for some flag set, an empty set is returned for it).
77
76
  */
78
- getNamesByFlagSets(flagSets: string[]): Promise<ISet<string>[]>;
77
+ getNamesByFlagSets(flagSets: string[]): Promise<Set<string>[]>;
79
78
  /**
80
79
  * Check traffic type existence.
81
80
  * The returned promise is resolved with a boolean indicating whether the TT exist or not.
@@ -1,5 +1,4 @@
1
1
  import { IPluggableStorageWrapper } from '../types';
2
- import { ISet } from '../../utils/lang/sets';
3
2
  /**
4
3
  * Creates a IPluggableStorageWrapper implementation that stores items in memory.
5
4
  * The `_cache` property is the object were items are stored.
@@ -8,6 +7,6 @@ import { ISet } from '../../utils/lang/sets';
8
7
  * @param connDelay delay in millis for `connect` resolve. If not provided, `connect` resolves immediately.
9
8
  */
10
9
  export declare function inMemoryWrapperFactory(connDelay?: number): IPluggableStorageWrapper & {
11
- _cache: Record<string, string | string[] | ISet<string>>;
10
+ _cache: Record<string, string | string[] | Set<string>>;
12
11
  _setConnDelay(connDelay: number): void;
13
12
  };
@@ -2,7 +2,6 @@ import { MaybeThenable, ISplit, IMySegmentsResponse } from '../dtos/types';
2
2
  import { MySegmentsData } from '../sync/polling/types';
3
3
  import { EventDataType, HttpErrors, HttpLatencies, ImpressionDataType, LastSync, Method, MethodExceptions, MethodLatencies, MultiMethodExceptions, MultiMethodLatencies, MultiConfigs, OperationType, StoredEventWithMetadata, StoredImpressionWithMetadata, StreamingEvent, UniqueKeysPayloadCs, UniqueKeysPayloadSs, TelemetryUsageStatsPayload, UpdatesFromSSEEnum } from '../sync/submitters/types';
4
4
  import { SplitIO, ImpressionDTO, ISettings } from '../types';
5
- import { ISet } from '../utils/lang/sets';
6
5
  /**
7
6
  * Interface of a pluggable storage wrapper.
8
7
  */
@@ -192,8 +191,9 @@ export interface ISplitsCacheBase {
192
191
  trafficTypeExists(trafficType: string): MaybeThenable<boolean>;
193
192
  usesSegments(): MaybeThenable<boolean>;
194
193
  clear(): MaybeThenable<boolean | void>;
194
+ checkCache(): MaybeThenable<boolean>;
195
195
  killLocally(name: string, defaultTreatment: string, changeNumber: number): MaybeThenable<boolean>;
196
- getNamesByFlagSets(flagSets: string[]): MaybeThenable<ISet<string>[]>;
196
+ getNamesByFlagSets(flagSets: string[]): MaybeThenable<Set<string>[]>;
197
197
  }
198
198
  export interface ISplitsCacheSync extends ISplitsCacheBase {
199
199
  addSplits(entries: [string, ISplit][]): boolean[];
@@ -207,8 +207,9 @@ export interface ISplitsCacheSync extends ISplitsCacheBase {
207
207
  trafficTypeExists(trafficType: string): boolean;
208
208
  usesSegments(): boolean;
209
209
  clear(): void;
210
+ checkCache(): boolean;
210
211
  killLocally(name: string, defaultTreatment: string, changeNumber: number): boolean;
211
- getNamesByFlagSets(flagSets: string[]): ISet<string>[];
212
+ getNamesByFlagSets(flagSets: string[]): Set<string>[];
212
213
  }
213
214
  export interface ISplitsCacheAsync extends ISplitsCacheBase {
214
215
  addSplits(entries: [string, ISplit][]): Promise<boolean[] | void>;
@@ -222,8 +223,9 @@ export interface ISplitsCacheAsync extends ISplitsCacheBase {
222
223
  trafficTypeExists(trafficType: string): Promise<boolean>;
223
224
  usesSegments(): Promise<boolean>;
224
225
  clear(): Promise<boolean | void>;
226
+ checkCache(): Promise<boolean>;
225
227
  killLocally(name: string, defaultTreatment: string, changeNumber: number): Promise<boolean>;
226
- getNamesByFlagSets(flagSets: string[]): Promise<ISet<string>[]>;
228
+ getNamesByFlagSets(flagSets: string[]): Promise<Set<string>[]>;
227
229
  }
228
230
  /** Segments cache */
229
231
  export interface ISegmentsCacheBase {
@@ -382,7 +384,6 @@ export interface IStorageBase<TSplitsCache extends ISplitsCacheBase, TSegmentsCa
382
384
  events: TEventsCache;
383
385
  telemetry?: TTelemetryCache;
384
386
  uniqueKeys?: TUniqueKeysCache;
385
- init?: () => void | Promise<void>;
386
387
  destroy(): void | Promise<void>;
387
388
  shared?: (matchingKey: string, onReadyCb: (error?: any) => void) => this;
388
389
  }
@@ -392,6 +393,7 @@ export interface IStorageSync extends IStorageBase<ISplitsCacheSync, ISegmentsCa
392
393
  export interface IStorageAsync extends IStorageBase<ISplitsCacheAsync, ISegmentsCacheAsync, IImpressionsCacheAsync | IImpressionsCacheSync, IImpressionCountsCacheBase, IEventsCacheAsync | IEventsCacheSync, ITelemetryCacheAsync | ITelemetryCacheSync, IUniqueKeysCacheBase> {
393
394
  }
394
395
  /** StorageFactory */
396
+ export declare type DataLoader = (storage: IStorageSync, matchingKey: string) => void;
395
397
  export interface IStorageFactoryParams {
396
398
  settings: ISettings;
397
399
  /**
@@ -399,7 +401,6 @@ export interface IStorageFactoryParams {
399
401
  * It is meant for emitting SDK_READY event in consumer mode, and waiting before using the storage in the synchronizer.
400
402
  */
401
403
  onReadyCb: (error?: any) => void;
402
- onReadyFromCacheCb: (error?: any) => void;
403
404
  }
404
405
  export declare type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS' | 'PLUGGABLE';
405
406
  export declare type IStorageSyncFactory = {
@@ -1,4 +1,3 @@
1
- import { ISet } from '../../../utils/lang/sets';
2
1
  import { ISegmentsCacheBase, ISplitsCacheBase } from '../../../storages/types';
3
2
  import { ISplitChangesFetcher } from '../fetchers/types';
4
3
  import { ISplit, ISplitFiltersValidation } from '../../../dtos/types';
@@ -12,7 +11,7 @@ declare type ISplitChangesUpdater = (noCache?: boolean, till?: number, splitUpda
12
11
  * Collect segments from a raw split definition.
13
12
  * Exported for testing purposes.
14
13
  */
15
- export declare function parseSegments({ conditions }: ISplit): ISet<string>;
14
+ export declare function parseSegments({ conditions }: ISplit): Set<string>;
16
15
  interface ISplitMutations {
17
16
  added: [string, ISplit][];
18
17
  removed: string[];
@@ -1,6 +1,5 @@
1
1
  import { IMetadata } from '../../dtos/types';
2
2
  import { SplitIO } from '../../types';
3
- import { IMap } from '../../utils/lang/maps';
4
3
  import { ISyncTask } from '../types';
5
4
  export declare type ImpressionsPayload = {
6
5
  /** Split name */
@@ -79,9 +78,9 @@ export declare type StoredEventWithMetadata = {
79
78
  /** Stored event */
80
79
  e: SplitIO.EventData;
81
80
  };
82
- export declare type MultiMethodLatencies = IMap<string, MethodLatencies>;
83
- export declare type MultiMethodExceptions = IMap<string, MethodExceptions>;
84
- export declare type MultiConfigs = IMap<string, TelemetryConfigStats>;
81
+ export declare type MultiMethodLatencies = Map<string, MethodLatencies>;
82
+ export declare type MultiMethodExceptions = Map<string, MethodExceptions>;
83
+ export declare type MultiConfigs = Map<string, TelemetryConfigStats>;
85
84
  /**
86
85
  * Telemetry usage stats
87
86
  */
@@ -7,4 +7,4 @@ import { ISettings } from '../types';
7
7
  * @param eventsCache cache to save events
8
8
  * @param integrationsManager optional event handler used for integrations
9
9
  */
10
- export declare function eventTrackerFactory(settings: ISettings, eventsCache: IEventsCacheBase, whenInit: (cb: () => void) => void, integrationsManager?: IEventsHandler, telemetryCache?: ITelemetryCacheSync | ITelemetryCacheAsync): IEventTracker;
10
+ export declare function eventTrackerFactory(settings: ISettings, eventsCache: IEventsCacheBase, integrationsManager?: IEventsHandler, telemetryCache?: ITelemetryCacheSync | ITelemetryCacheAsync): IEventTracker;
@@ -10,4 +10,4 @@ import { ISettings } from '../types';
10
10
  * @param integrationsManager optional integrations manager
11
11
  * @param strategy strategy for impressions tracking.
12
12
  */
13
- export declare function impressionsTrackerFactory(settings: ISettings, impressionsCache: IImpressionsCacheBase, strategy: IStrategy, whenInit: (cb: () => void) => void, integrationsManager?: IImpressionsHandler, telemetryCache?: ITelemetryCacheSync | ITelemetryCacheAsync): IImpressionsTracker;
13
+ export declare function impressionsTrackerFactory(settings: ISettings, impressionsCache: IImpressionsCacheBase, strategy: IStrategy, integrationsManager?: IImpressionsHandler, telemetryCache?: ITelemetryCacheSync | ITelemetryCacheAsync): IImpressionsTracker;
@@ -54,7 +54,6 @@ export interface IImpressionSenderAdapter {
54
54
  }
55
55
  /** Unique keys tracker */
56
56
  export interface IUniqueKeysTracker {
57
- start(): void;
58
57
  stop(): void;
59
58
  track(key: string, featureName: string): void;
60
59
  }
package/types/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ISplit, ISplitFiltersValidation } from './dtos/types';
1
+ import { ISplitFiltersValidation } from './dtos/types';
2
2
  import { IIntegration, IIntegrationFactoryParams } from './integrations/types';
3
3
  import { ILogger } from './logger/types';
4
4
  import { ISdkFactoryContext } from './sdkFactory/types';
@@ -65,7 +65,6 @@ export interface ISettings {
65
65
  readonly core: {
66
66
  authorizationKey: string;
67
67
  key: SplitIO.SplitKey;
68
- trafficType?: string;
69
68
  labelsEnabled: boolean;
70
69
  IPAddressesEnabled: boolean;
71
70
  };
@@ -92,7 +91,6 @@ export interface ISettings {
92
91
  eventsFirstPushWindow: number;
93
92
  };
94
93
  readonly storage: IStorageSyncFactory | IStorageAsyncFactory;
95
- readonly preloadedData?: SplitIO.PreloadedData;
96
94
  readonly integrations: Array<{
97
95
  readonly type: string;
98
96
  (params: IIntegrationFactoryParams): IIntegration | void;
@@ -771,19 +769,21 @@ export declare namespace SplitIO {
771
769
  * If this value is older than 10 days ago (expiration time policy), the data is not used to update the storage content.
772
770
  * @TODO configurable expiration time policy?
773
771
  */
772
+ lastUpdated: number;
774
773
  /**
775
774
  * Change number of the preloaded data.
776
775
  * If this value is older than the current changeNumber at the storage, the data is not used to update the storage content.
777
776
  */
778
777
  since: number;
779
778
  /**
780
- * List of feature flag definitions.
781
- * @TODO rename to flags
779
+ * Map of feature flags to their stringified definitions.
782
780
  */
783
- splitsData: ISplit[];
781
+ splitsData: {
782
+ [splitName: string]: string;
783
+ };
784
784
  /**
785
785
  * Optional map of user keys to their list of segments.
786
- * @TODO rename to memberships
786
+ * @TODO remove when releasing first version
787
787
  */
788
788
  mySegmentsData?: {
789
789
  [key: string]: string[];
@@ -791,10 +791,9 @@ export declare namespace SplitIO {
791
791
  /**
792
792
  * Optional map of segments to their stringified definitions.
793
793
  * This property is ignored if `mySegmentsData` was provided.
794
- * @TODO rename to segments
795
794
  */
796
795
  segmentsData?: {
797
- [segmentName: string]: string[];
796
+ [segmentName: string]: string;
798
797
  };
799
798
  }
800
799
  /**
@@ -922,12 +921,6 @@ export declare namespace SplitIO {
922
921
  * @property {SplitKey} key
923
922
  */
924
923
  key: SplitKey;
925
- /**
926
- * Traffic type associated with the customer identifier. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
927
- * If no provided as a setting it will be required on the client.track() calls.
928
- * @property {string} trafficType
929
- */
930
- trafficType?: string;
931
924
  /**
932
925
  * Disable labels from being sent to Split backend. Labels may contain sensitive information.
933
926
  * @property {boolean} labelsEnabled
@@ -1036,10 +1029,9 @@ export declare namespace SplitIO {
1036
1029
  * Returns a shared client of the SDK, with the given key and optional traffic type.
1037
1030
  * @function client
1038
1031
  * @param {SplitKey} key The key for the new client instance.
1039
- * @param {string=} trafficType The traffic type of the provided key.
1040
1032
  * @returns {ICsClient} The client instance.
1041
1033
  */
1042
- client(key: SplitKey, trafficType?: string): ICsClient;
1034
+ client(key: SplitKey): ICsClient;
1043
1035
  /**
1044
1036
  * Returns a manager instance of the SDK to explore available information.
1045
1037
  * @function manager
@@ -1,8 +1,7 @@
1
- import { IMap } from '../lang/maps';
2
1
  import { LinkedList, Node } from './LinkedList';
3
2
  export declare class LRUCache<K, V> {
4
3
  maxLen: number;
5
- items: IMap<K, Node<{
4
+ items: Map<K, Node<{
6
5
  key: K;
7
6
  value: V;
8
7
  }>>;
@@ -1,3 +1 @@
1
- export declare const GOOGLE_ANALYTICS_TO_SPLIT = "GOOGLE_ANALYTICS_TO_SPLIT";
2
- export declare const SPLIT_TO_GOOGLE_ANALYTICS = "SPLIT_TO_GOOGLE_ANALYTICS";
3
1
  export declare const DEFAULT_CACHE_EXPIRATION_IN_MILLIS = 864000000;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * A tiny polyfill for Object.assign
3
+ */
1
4
  declare type ObjectAssign = (<T, U>(target: T, source: U) => T & U) & (<T, U, V>(target: T, source1: U, source2: V) => T & U & V) & (<T, U, V, W>(target: T, source1: U, source2: V, source3: W) => T & U & V & W) & (<T, U, V, W, Q>(target: T, source1: U, source2: V, source3: W, source4: Q) => T & U & V & W & Q) & (<T, U, V, W, Q, R>(target: T, source1: U, source2: V, source3: W, source4: Q, source5: R) => T & U & V & W & Q & R) & ((target: any, ...sources: any[]) => any);
2
5
  export declare const objectAssign: ObjectAssign;
3
6
  export {};
@@ -1,62 +1,2 @@
1
- /**
2
- * Set implementation based on es6-set polyfill (https://github.com/medikoo/es6-set/blob/master/polyfill.js),
3
- * with the minimal features used by the SDK.
4
-
5
- Copyright (C) 2013 Mariusz Nowak (www.medikoo.com)
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in
15
- all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- THE SOFTWARE.
24
- **/
25
- export interface ISet<T> {
26
- add(value: T): this;
27
- clear(): void;
28
- delete(value: T): boolean;
29
- forEach(callbackfn: (value: T, value2: T, set: ISet<T>) => void, thisArg?: any): void;
30
- has(value: T): boolean;
31
- readonly size: number;
32
- }
33
- export declare class SetPoly<T> implements ISet<T> {
34
- __setData__: T[];
35
- constructor(values?: readonly T[] | null);
36
- clear(): void;
37
- add(value: T): this;
38
- delete(value: T): boolean;
39
- has(value: T): boolean;
40
- forEach(callbackfn: (value: T, value2: T, set: SetPoly<T>) => void, thisArg?: any): void;
41
- get size(): number;
42
- }
43
- /**
44
- * return an array containing the items of the given set.
45
- * @param set Set or SetPoly instance
46
- */
47
- export declare function setToArray<T>(set: ISet<T>): T[];
48
- interface ISetConstructor {
49
- new <T = any>(values?: readonly T[] | null): ISet<T>;
50
- readonly prototype: ISet<any>;
51
- }
52
- /**
53
- * return the Set constructor to use. If `Array.from` built-in or native Set is not available or it doesn't support the required features,
54
- * a ponyfill with minimal features is returned instead.
55
- *
56
- * Exported for testing purposes only.
57
- */
58
- export declare function __getSetConstructor(): ISetConstructor;
59
- export declare const _Set: ISetConstructor;
60
- export declare function returnSetsUnion<T>(set: ISet<T>, set2: ISet<T>): ISet<T>;
1
+ export declare function returnSetsUnion<T>(set: Set<T>, set2: Set<T>): Set<T>;
61
2
  export declare function returnDifference<T>(list?: T[], list2?: T[]): T[];
62
- export {};
@@ -5,7 +5,6 @@ export declare const base: {
5
5
  core: {
6
6
  authorizationKey: undefined;
7
7
  key: undefined;
8
- trafficType: undefined;
9
8
  labelsEnabled: boolean;
10
9
  IPAddressesEnabled: undefined;
11
10
  };
@@ -1,5 +1,10 @@
1
1
  import { ISettings, SDKMode } from '../../../types';
2
2
  import { ILogger } from '../../../logger/types';
3
+ import { IStorageFactoryParams, IStorageSync } from '../../../storages/types';
4
+ export declare function __InLocalStorageMockFactory(params: IStorageFactoryParams): IStorageSync;
5
+ export declare namespace __InLocalStorageMockFactory {
6
+ var type: import("../../../storages/types").StorageType;
7
+ }
3
8
  /**
4
9
  * This function validates `settings.storage` object
5
10
  *
@@ -15,8 +15,6 @@ export interface ISettingsValidationParams {
15
15
  };
16
16
  /** If true, validates core.key */
17
17
  acceptKey?: boolean;
18
- /** If true, validates core.trafficType */
19
- acceptTT?: boolean;
20
18
  /** Define runtime values (`settings.runtime`) */
21
19
  runtime: (settings: ISettings) => ISettings['runtime'];
22
20
  /** Storage validator (`settings.storage`) */
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.integrationsManagerFactory = void 0;
4
- var browser_1 = require("../utils/constants/browser");
5
- var pluggable_1 = require("./pluggable");
6
- var GoogleAnalyticsToSplit_1 = require("./ga/GoogleAnalyticsToSplit");
7
- var SplitToGoogleAnalytics_1 = require("./ga/SplitToGoogleAnalytics");
8
- /**
9
- * IntegrationsManager factory for the browser variant of the isomorphic JS SDK.
10
- * The integrations manager instantiates integration modules, and bypass tracked events and impressions to them.
11
- *
12
- * @param integrations valid integration settings object for browser sdk
13
- * @param params information of the Sdk factory instance that integrations can access to
14
- *
15
- * @returns integration manager or undefined if `integrations` are not present in settings.
16
- */
17
- function integrationsManagerFactory(integrations, params) {
18
- // maps integration config items into integration factories to reuse the pluggable integration manager
19
- var integrationFactories = integrations
20
- .map(function (integrationOptions) {
21
- switch (integrationOptions.type) {
22
- case browser_1.GOOGLE_ANALYTICS_TO_SPLIT: return (0, GoogleAnalyticsToSplit_1.GoogleAnalyticsToSplit)(integrationOptions);
23
- case browser_1.SPLIT_TO_GOOGLE_ANALYTICS: return (0, SplitToGoogleAnalytics_1.SplitToGoogleAnalytics)(integrationOptions);
24
- }
25
- })
26
- .filter(function (integrationFactory) {
27
- return integrationFactory && typeof integrationFactory === 'function';
28
- });
29
- return (0, pluggable_1.pluggableIntegrationsManagerFactory)(integrationFactories, params);
30
- }
31
- exports.integrationsManagerFactory = integrationsManagerFactory;