@splitsoftware/splitio-commons 1.16.1-rc.8 → 1.17.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 (167) hide show
  1. package/CHANGES.txt +2 -1
  2. package/cjs/evaluator/matchers/index.js +1 -3
  3. package/cjs/evaluator/matchers/matcherTypes.js +0 -1
  4. package/cjs/evaluator/matchersTransform/index.js +1 -1
  5. package/cjs/logger/constants.js +4 -3
  6. package/cjs/logger/messages/info.js +2 -1
  7. package/cjs/readiness/readinessManager.js +10 -14
  8. package/cjs/readiness/sdkReadinessManager.js +6 -5
  9. package/cjs/sdkClient/sdkClientMethodCS.js +2 -2
  10. package/cjs/sdkClient/sdkClientMethodCSWithTT.js +2 -2
  11. package/cjs/sdkFactory/index.js +1 -1
  12. package/cjs/services/decorateHeaders.js +42 -0
  13. package/cjs/services/splitApi.js +0 -4
  14. package/cjs/services/splitHttpClient.js +5 -4
  15. package/cjs/storages/AbstractSplitsCacheAsync.js +2 -2
  16. package/cjs/storages/AbstractSplitsCacheSync.js +6 -5
  17. package/cjs/storages/KeyBuilder.js +0 -3
  18. package/cjs/storages/KeyBuilderCS.js +5 -17
  19. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +4 -16
  20. package/cjs/storages/inLocalStorage/index.js +2 -6
  21. package/cjs/storages/inMemory/InMemoryStorageCS.js +0 -5
  22. package/cjs/storages/inMemory/SplitsCacheInMemory.js +11 -20
  23. package/cjs/storages/inMemory/TelemetryCacheInMemory.js +10 -7
  24. package/cjs/storages/pluggable/inMemoryWrapper.js +1 -1
  25. package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +1 -5
  26. package/cjs/sync/polling/pollingManagerCS.js +33 -51
  27. package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +2 -2
  28. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +21 -20
  29. package/cjs/sync/streaming/SSEClient/index.js +0 -4
  30. package/cjs/sync/streaming/SSEHandler/index.js +0 -1
  31. package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +9 -23
  32. package/cjs/sync/streaming/constants.js +1 -2
  33. package/cjs/sync/streaming/parseUtils.js +8 -3
  34. package/cjs/sync/streaming/pushManager.js +68 -99
  35. package/cjs/sync/submitters/telemetrySubmitter.js +0 -4
  36. package/cjs/sync/syncManagerOnline.js +14 -24
  37. package/cjs/utils/constants/index.js +2 -4
  38. package/cjs/utils/settingsValidation/index.js +2 -7
  39. package/esm/evaluator/matchers/index.js +1 -3
  40. package/esm/evaluator/matchers/matcherTypes.js +0 -1
  41. package/esm/evaluator/matchersTransform/index.js +1 -1
  42. package/esm/logger/constants.js +1 -0
  43. package/esm/logger/messages/info.js +2 -1
  44. package/esm/readiness/readinessManager.js +10 -14
  45. package/esm/readiness/sdkReadinessManager.js +6 -5
  46. package/esm/sdkClient/sdkClientMethodCS.js +2 -2
  47. package/esm/sdkClient/sdkClientMethodCSWithTT.js +2 -2
  48. package/esm/sdkFactory/index.js +1 -1
  49. package/esm/services/decorateHeaders.js +38 -0
  50. package/esm/services/splitApi.js +1 -5
  51. package/esm/services/splitHttpClient.js +5 -4
  52. package/esm/storages/AbstractSplitsCacheAsync.js +2 -2
  53. package/esm/storages/AbstractSplitsCacheSync.js +4 -3
  54. package/esm/storages/KeyBuilder.js +0 -3
  55. package/esm/storages/KeyBuilderCS.js +4 -15
  56. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +5 -17
  57. package/esm/storages/inLocalStorage/index.js +3 -7
  58. package/esm/storages/inMemory/InMemoryStorageCS.js +0 -5
  59. package/esm/storages/inMemory/SplitsCacheInMemory.js +12 -21
  60. package/esm/storages/inMemory/TelemetryCacheInMemory.js +10 -7
  61. package/esm/storages/pluggable/inMemoryWrapper.js +1 -1
  62. package/esm/sync/polling/fetchers/mySegmentsFetcher.js +1 -5
  63. package/esm/sync/polling/pollingManagerCS.js +34 -52
  64. package/esm/sync/polling/syncTasks/mySegmentsSyncTask.js +2 -2
  65. package/esm/sync/polling/updaters/mySegmentsUpdater.js +19 -18
  66. package/esm/sync/streaming/SSEClient/index.js +1 -5
  67. package/esm/sync/streaming/SSEHandler/index.js +1 -2
  68. package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +9 -23
  69. package/esm/sync/streaming/constants.js +0 -1
  70. package/esm/sync/streaming/parseUtils.js +8 -3
  71. package/esm/sync/streaming/pushManager.js +69 -99
  72. package/esm/sync/submitters/telemetrySubmitter.js +0 -4
  73. package/esm/sync/syncManagerOnline.js +15 -25
  74. package/esm/utils/constants/index.js +1 -3
  75. package/esm/utils/settingsValidation/index.js +2 -7
  76. package/package.json +1 -1
  77. package/src/dtos/types.ts +7 -17
  78. package/src/evaluator/matchers/index.ts +0 -2
  79. package/src/evaluator/matchers/matcherTypes.ts +0 -1
  80. package/src/evaluator/matchersTransform/index.ts +1 -1
  81. package/src/logger/constants.ts +1 -0
  82. package/src/logger/messages/info.ts +2 -1
  83. package/src/readiness/readinessManager.ts +9 -13
  84. package/src/readiness/sdkReadinessManager.ts +7 -7
  85. package/src/readiness/types.ts +2 -3
  86. package/src/sdkClient/sdkClientMethodCS.ts +2 -2
  87. package/src/sdkClient/sdkClientMethodCSWithTT.ts +2 -2
  88. package/src/sdkFactory/index.ts +1 -1
  89. package/src/services/decorateHeaders.ts +40 -0
  90. package/src/services/splitApi.ts +2 -7
  91. package/src/services/splitHttpClient.ts +6 -5
  92. package/src/services/types.ts +0 -1
  93. package/src/storages/AbstractSplitsCacheAsync.ts +2 -2
  94. package/src/storages/AbstractSplitsCacheSync.ts +5 -4
  95. package/src/storages/KeyBuilder.ts +0 -3
  96. package/src/storages/KeyBuilderCS.ts +5 -25
  97. package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +3 -3
  98. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +5 -20
  99. package/src/storages/inLocalStorage/index.ts +4 -8
  100. package/src/storages/inMemory/InMemoryStorageCS.ts +0 -5
  101. package/src/storages/inMemory/SplitsCacheInMemory.ts +10 -15
  102. package/src/storages/inMemory/TelemetryCacheInMemory.ts +11 -7
  103. package/src/storages/pluggable/inMemoryWrapper.ts +1 -1
  104. package/src/storages/types.ts +5 -7
  105. package/src/sync/polling/fetchers/mySegmentsFetcher.ts +2 -6
  106. package/src/sync/polling/pollingManagerCS.ts +29 -61
  107. package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +10 -10
  108. package/src/sync/polling/types.ts +3 -4
  109. package/src/sync/polling/updaters/mySegmentsUpdater.ts +20 -17
  110. package/src/sync/streaming/SSEClient/index.ts +7 -10
  111. package/src/sync/streaming/SSEHandler/index.ts +1 -2
  112. package/src/sync/streaming/SSEHandler/types.ts +2 -14
  113. package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +10 -26
  114. package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
  115. package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +1 -1
  116. package/src/sync/streaming/UpdateWorkers/types.ts +2 -2
  117. package/src/sync/streaming/constants.ts +0 -1
  118. package/src/sync/streaming/parseUtils.ts +10 -6
  119. package/src/sync/streaming/pushManager.ts +67 -103
  120. package/src/sync/streaming/types.ts +3 -5
  121. package/src/sync/submitters/telemetrySubmitter.ts +0 -4
  122. package/src/sync/submitters/types.ts +4 -11
  123. package/src/sync/syncManagerOnline.ts +11 -19
  124. package/src/types.ts +9 -28
  125. package/src/utils/constants/index.ts +1 -3
  126. package/src/utils/settingsValidation/index.ts +3 -8
  127. package/src/utils/settingsValidation/types.ts +1 -1
  128. package/types/dtos/types.d.ts +6 -14
  129. package/types/logger/constants.d.ts +1 -0
  130. package/types/readiness/readinessManager.d.ts +2 -2
  131. package/types/readiness/sdkReadinessManager.d.ts +3 -2
  132. package/types/readiness/types.d.ts +2 -3
  133. package/types/services/decorateHeaders.d.ts +2 -0
  134. package/types/services/splitApi.d.ts +1 -1
  135. package/types/services/splitHttpClient.d.ts +1 -1
  136. package/types/services/types.d.ts +0 -1
  137. package/types/storages/AbstractSplitsCacheAsync.d.ts +1 -1
  138. package/types/storages/AbstractSplitsCacheSync.d.ts +3 -3
  139. package/types/storages/KeyBuilder.d.ts +0 -1
  140. package/types/storages/KeyBuilderCS.d.ts +2 -7
  141. package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +2 -2
  142. package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +1 -1
  143. package/types/storages/inMemory/SplitsCacheInMemory.d.ts +2 -3
  144. package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +6 -4
  145. package/types/storages/pluggable/inMemoryWrapper.d.ts +1 -1
  146. package/types/storages/types.d.ts +3 -4
  147. package/types/sync/polling/syncTasks/mySegmentsSyncTask.d.ts +3 -2
  148. package/types/sync/polling/types.d.ts +3 -10
  149. package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +4 -4
  150. package/types/sync/streaming/SSEClient/index.d.ts +0 -1
  151. package/types/sync/streaming/SSEHandler/types.d.ts +2 -13
  152. package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +2 -3
  153. package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +1 -2
  154. package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +2 -3
  155. package/types/sync/streaming/UpdateWorkers/types.d.ts +2 -2
  156. package/types/sync/streaming/constants.d.ts +0 -1
  157. package/types/sync/streaming/parseUtils.d.ts +4 -2
  158. package/types/sync/streaming/pushManager.d.ts +0 -2
  159. package/types/sync/streaming/types.d.ts +4 -5
  160. package/types/sync/submitters/types.d.ts +3 -10
  161. package/types/types.d.ts +11 -26
  162. package/types/utils/constants/index.d.ts +1 -3
  163. package/types/utils/settingsValidation/index.d.ts +0 -2
  164. package/types/utils/settingsValidation/types.d.ts +1 -1
  165. package/cjs/evaluator/matchers/large_segment.js +0 -16
  166. package/esm/evaluator/matchers/large_segment.js +0 -12
  167. package/src/evaluator/matchers/large_segment.ts +0 -18
package/types/types.d.ts CHANGED
@@ -80,7 +80,6 @@ export interface ISettings {
80
80
  metricsRefreshRate?: number;
81
81
  telemetryRefreshRate: number;
82
82
  segmentsRefreshRate: number;
83
- largeSegmentsRefreshRate: number;
84
83
  offlineRefreshRate: number;
85
84
  eventsPushRate: number;
86
85
  eventsQueueSize: number;
@@ -91,7 +90,6 @@ export interface ISettings {
91
90
  requestTimeoutBeforeReady: number;
92
91
  retriesOnFailureBeforeReady: number;
93
92
  eventsFirstPushWindow: number;
94
- waitForLargeSegments: boolean;
95
93
  };
96
94
  readonly storage: IStorageSyncFactory | IStorageAsyncFactory;
97
95
  readonly integrations: Array<{
@@ -115,8 +113,12 @@ export interface ISettings {
115
113
  __splitFiltersValidation: ISplitFiltersValidation;
116
114
  localhostMode?: SplitIO.LocalhostFactory;
117
115
  enabled: boolean;
118
- largeSegmentsEnabled: boolean;
119
116
  flagSpecVersion: string;
117
+ requestOptions?: {
118
+ getHeaderOverrides?: (context: {
119
+ headers: Record<string, string>;
120
+ }) => Record<string, string>;
121
+ };
120
122
  };
121
123
  readonly runtime: {
122
124
  ip: string | false;
@@ -215,7 +217,12 @@ interface ISharedSettings {
215
217
  * Enables synchronization.
216
218
  * @property {boolean} enabled
217
219
  */
218
- enabled: boolean;
220
+ enabled?: boolean;
221
+ requestOptions?: {
222
+ getHeaderOverrides?: (context: {
223
+ headers: Record<string, string>;
224
+ }) => Record<string, string>;
225
+ };
219
226
  };
220
227
  }
221
228
  /**
@@ -813,13 +820,6 @@ export declare namespace SplitIO {
813
820
  * @default 10
814
821
  */
815
822
  eventsFirstPushWindow?: number;
816
- /**
817
- * Whether the SDK should wait for large segments to be ready before emitting SDK_READY event.
818
- * It only applies if largeSegmentsEnabled is true.
819
- * @property {number} waitForLargeSegments
820
- * @default true
821
- */
822
- waitForLargeSegments?: boolean;
823
823
  };
824
824
  /**
825
825
  * SDK scheduler settings.
@@ -864,13 +864,6 @@ export declare namespace SplitIO {
864
864
  * @default 60
865
865
  */
866
866
  segmentsRefreshRate?: number;
867
- /**
868
- * The SDK polls Split servers for changes to large segment definitions. This parameter controls this polling period in seconds.
869
- * It only applies if largeSegmentsEnabled is true.
870
- * @property {number} largeSegmentsRefreshRate
871
- * @default 60
872
- */
873
- largeSegmentsRefreshRate?: number;
874
867
  /**
875
868
  * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
876
869
  * @property {number} eventsPushRate
@@ -943,14 +936,6 @@ export declare namespace SplitIO {
943
936
  * @property {Object} urls
944
937
  */
945
938
  urls?: UrlSettings;
946
- sync?: ISharedSettings['sync'] & {
947
- /**
948
- * Enables synchronization of large segments.
949
- * @property {boolean} largeSegmentsEnabled
950
- * @default false
951
- */
952
- largeSegmentsEnabled?: boolean;
953
- };
954
939
  }
955
940
  /**
956
941
  * Settings interface for SDK instances created on NodeJS.
@@ -53,7 +53,6 @@ export declare const TELEMETRY = "te";
53
53
  export declare const TOKEN = "to";
54
54
  export declare const SEGMENT = "se";
55
55
  export declare const MY_SEGMENT = "ms";
56
- export declare const MY_LARGE_SEGMENT = "mls";
57
56
  export declare const TREATMENT = "t";
58
57
  export declare const TREATMENTS = "ts";
59
58
  export declare const TREATMENT_WITH_CONFIG = "tc";
@@ -79,6 +78,5 @@ export declare const NON_REQUESTED = 1;
79
78
  export declare const DISABLED = 0;
80
79
  export declare const ENABLED = 1;
81
80
  export declare const PAUSED = 2;
82
- export declare const FLAG_SPEC_VERSION = "1.2";
81
+ export declare const FLAG_SPEC_VERSION = "1.1";
83
82
  export declare const IN_SEGMENT = "IN_SEGMENT";
84
- export declare const IN_LARGE_SEGMENT = "IN_LARGE_SEGMENT";
@@ -12,7 +12,6 @@ export declare const base: {
12
12
  scheduler: {
13
13
  featuresRefreshRate: number;
14
14
  segmentsRefreshRate: number;
15
- largeSegmentsRefreshRate: number;
16
15
  telemetryRefreshRate: number;
17
16
  impressionsRefreshRate: number;
18
17
  offlineRefreshRate: number;
@@ -40,7 +39,6 @@ export declare const base: {
40
39
  localhostMode: undefined;
41
40
  enabled: boolean;
42
41
  flagSpecVersion: string;
43
- largeSegmentsEnabled: boolean;
44
42
  };
45
43
  log: undefined;
46
44
  };
@@ -28,7 +28,7 @@ export interface ISettingsValidationParams {
28
28
  /** Localhost mode validator (`settings.sync.localhostMode`) */
29
29
  localhost?: (settings: ISettings) => ISettings['sync']['localhostMode'];
30
30
  /** User consent validator (`settings.userConsent`) */
31
- consent?: (settings: ISettings) => ISettings['userConsent'];
31
+ consent: (settings: ISettings) => ISettings['userConsent'];
32
32
  /** Flag spec version validation. Configurable by the JS Synchronizer but not by the SDKs */
33
33
  flagSpec?: (settings: ISettings) => ISettings['sync']['flagSpecVersion'];
34
34
  }
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.largeSegmentMatcherContext = void 0;
4
- var thenable_1 = require("../../utils/promise/thenable");
5
- function largeSegmentMatcherContext(largeSegmentName, storage) {
6
- return function largeSegmentMatcher(key) {
7
- var isInLargeSegment = storage.largeSegments ? storage.largeSegments.isInSegment(largeSegmentName, key) : false;
8
- if ((0, thenable_1.thenable)(isInLargeSegment)) {
9
- isInLargeSegment.then(function (result) {
10
- return result;
11
- });
12
- }
13
- return isInLargeSegment;
14
- };
15
- }
16
- exports.largeSegmentMatcherContext = largeSegmentMatcherContext;
@@ -1,12 +0,0 @@
1
- import { thenable } from '../../utils/promise/thenable';
2
- export function largeSegmentMatcherContext(largeSegmentName, storage) {
3
- return function largeSegmentMatcher(key) {
4
- var isInLargeSegment = storage.largeSegments ? storage.largeSegments.isInSegment(largeSegmentName, key) : false;
5
- if (thenable(isInLargeSegment)) {
6
- isInLargeSegment.then(function (result) {
7
- return result;
8
- });
9
- }
10
- return isInLargeSegment;
11
- };
12
- }
@@ -1,18 +0,0 @@
1
- import { MaybeThenable } from '../../dtos/types';
2
- import { ISegmentsCacheBase } from '../../storages/types';
3
- import { thenable } from '../../utils/promise/thenable';
4
-
5
- export function largeSegmentMatcherContext(largeSegmentName: string, storage: { largeSegments?: ISegmentsCacheBase }) {
6
-
7
- return function largeSegmentMatcher(key: string): MaybeThenable<boolean> {
8
- const isInLargeSegment = storage.largeSegments ? storage.largeSegments.isInSegment(largeSegmentName, key) : false;
9
-
10
- if (thenable(isInLargeSegment)) {
11
- isInLargeSegment.then(result => {
12
- return result;
13
- });
14
- }
15
-
16
- return isInLargeSegment;
17
- };
18
- }