@splitsoftware/splitio-commons 1.16.1-rc.4 → 1.16.1-rc.6

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.
@@ -47,6 +47,7 @@ var SSEClient = /** @class */ (function () {
47
47
  this.useHeaders = useHeaders;
48
48
  this.headers = buildSSEHeaders(settings);
49
49
  this.options = getOptions && getOptions(settings);
50
+ this.lse = settings.sync.largeSegmentsEnabled;
50
51
  }
51
52
  SSEClient.prototype.setEventHandler = function (handler) {
52
53
  this.handler = handler;
@@ -58,10 +59,13 @@ var SSEClient = /** @class */ (function () {
58
59
  * @throws {TypeError} Will throw an error if `authToken` is undefined
59
60
  */
60
61
  SSEClient.prototype.open = function (authToken) {
62
+ var _this = this;
61
63
  this.close(); // it closes connection if previously opened
62
64
  var channelsQueryParam = Object.keys(authToken.channels).map(function (channel) {
63
65
  var params = CONTROL_CHANNEL_REGEX.test(channel) ? '[?occupancy=metrics.publishers]' : '';
64
66
  return encodeURIComponent(params + channel);
67
+ }).filter(function (channel) {
68
+ return _this.lse || !(0, lang_1.endsWith)(channel, 'myLargeSegments');
65
69
  }).join(',');
66
70
  var url = this.streamingUrl + "?channels=" + channelsQueryParam + "&accessToken=" + authToken.token + "&v=" + ABLY_API_VERSION + "&heartbeats=true"; // same results using `&heartbeats=false`
67
71
  this.connection = new this.eventSource(
@@ -70,6 +70,7 @@ function MySegmentsUpdateWorker(mySegmentsSyncTask, telemetryTracker, updateType
70
70
  },
71
71
  stop: function () {
72
72
  clearTimeout(_delayTimeoutID);
73
+ _delay = undefined;
73
74
  isHandlingEvent = false;
74
75
  backoff.reset();
75
76
  }
@@ -91,7 +91,7 @@ exports.NON_REQUESTED = 1;
91
91
  exports.DISABLED = 0;
92
92
  exports.ENABLED = 1;
93
93
  exports.PAUSED = 2;
94
- exports.FLAG_SPEC_VERSION = '1.1';
94
+ exports.FLAG_SPEC_VERSION = '1.2';
95
95
  // Matcher types
96
96
  exports.IN_SEGMENT = 'IN_SEGMENT';
97
97
  exports.IN_LARGE_SEGMENT = 'IN_LARGE_SEGMENT';
@@ -1,4 +1,4 @@
1
- import { isString } from '../../../utils/lang';
1
+ import { endsWith, isString } from '../../../utils/lang';
2
2
  import { objectAssign } from '../../../utils/lang/objectAssign';
3
3
  var ABLY_API_VERSION = '1.1';
4
4
  var CONTROL_CHANNEL_REGEX = /^control_/;
@@ -44,6 +44,7 @@ var SSEClient = /** @class */ (function () {
44
44
  this.useHeaders = useHeaders;
45
45
  this.headers = buildSSEHeaders(settings);
46
46
  this.options = getOptions && getOptions(settings);
47
+ this.lse = settings.sync.largeSegmentsEnabled;
47
48
  }
48
49
  SSEClient.prototype.setEventHandler = function (handler) {
49
50
  this.handler = handler;
@@ -55,10 +56,13 @@ var SSEClient = /** @class */ (function () {
55
56
  * @throws {TypeError} Will throw an error if `authToken` is undefined
56
57
  */
57
58
  SSEClient.prototype.open = function (authToken) {
59
+ var _this = this;
58
60
  this.close(); // it closes connection if previously opened
59
61
  var channelsQueryParam = Object.keys(authToken.channels).map(function (channel) {
60
62
  var params = CONTROL_CHANNEL_REGEX.test(channel) ? '[?occupancy=metrics.publishers]' : '';
61
63
  return encodeURIComponent(params + channel);
64
+ }).filter(function (channel) {
65
+ return _this.lse || !endsWith(channel, 'myLargeSegments');
62
66
  }).join(',');
63
67
  var url = this.streamingUrl + "?channels=" + channelsQueryParam + "&accessToken=" + authToken.token + "&v=" + ABLY_API_VERSION + "&heartbeats=true"; // same results using `&heartbeats=false`
64
68
  this.connection = new this.eventSource(
@@ -67,6 +67,7 @@ export function MySegmentsUpdateWorker(mySegmentsSyncTask, telemetryTracker, upd
67
67
  },
68
68
  stop: function () {
69
69
  clearTimeout(_delayTimeoutID);
70
+ _delay = undefined;
70
71
  isHandlingEvent = false;
71
72
  backoff.reset();
72
73
  }
@@ -87,7 +87,7 @@ export var NON_REQUESTED = 1;
87
87
  export var DISABLED = 0;
88
88
  export var ENABLED = 1;
89
89
  export var PAUSED = 2;
90
- export var FLAG_SPEC_VERSION = '1.1';
90
+ export var FLAG_SPEC_VERSION = '1.2';
91
91
  // Matcher types
92
92
  export var IN_SEGMENT = 'IN_SEGMENT';
93
93
  export var IN_LARGE_SEGMENT = 'IN_LARGE_SEGMENT';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.16.1-rc.4",
3
+ "version": "1.16.1-rc.6",
4
4
  "description": "Split JavaScript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -1,7 +1,7 @@
1
1
  import { IPlatform } from '../../../sdkFactory/types';
2
2
  import { IEventSourceConstructor } from '../../../services/types';
3
3
  import { ISettings } from '../../../types';
4
- import { isString } from '../../../utils/lang';
4
+ import { endsWith, isString } from '../../../utils/lang';
5
5
  import { objectAssign } from '../../../utils/lang/objectAssign';
6
6
  import { IAuthTokenPushEnabled } from '../AuthClient/types';
7
7
  import { ISSEClient, ISseEventHandler } from './types';
@@ -42,6 +42,7 @@ export class SSEClient implements ISSEClient {
42
42
  useHeaders?: boolean;
43
43
  headers: Record<string, string>;
44
44
  options?: object;
45
+ lse?: boolean;
45
46
 
46
47
  /**
47
48
  * SSEClient constructor.
@@ -61,6 +62,7 @@ export class SSEClient implements ISSEClient {
61
62
  this.useHeaders = useHeaders;
62
63
  this.headers = buildSSEHeaders(settings);
63
64
  this.options = getOptions && getOptions(settings);
65
+ this.lse = settings.sync.largeSegmentsEnabled;
64
66
  }
65
67
 
66
68
  setEventHandler(handler: ISseEventHandler) {
@@ -76,12 +78,13 @@ export class SSEClient implements ISSEClient {
76
78
  open(authToken: IAuthTokenPushEnabled) {
77
79
  this.close(); // it closes connection if previously opened
78
80
 
79
- const channelsQueryParam = Object.keys(authToken.channels).map(
80
- function (channel) {
81
- const params = CONTROL_CHANNEL_REGEX.test(channel) ? '[?occupancy=metrics.publishers]' : '';
82
- return encodeURIComponent(params + channel);
83
- }
84
- ).join(',');
81
+ const channelsQueryParam = Object.keys(authToken.channels).map((channel) => {
82
+ const params = CONTROL_CHANNEL_REGEX.test(channel) ? '[?occupancy=metrics.publishers]' : '';
83
+ return encodeURIComponent(params + channel);
84
+ }).filter(channel => {
85
+ return this.lse || !endsWith(channel, 'myLargeSegments');
86
+ }).join(',');
87
+
85
88
  const url = `${this.streamingUrl}?channels=${channelsQueryParam}&accessToken=${authToken.token}&v=${ABLY_API_VERSION}&heartbeats=true`; // same results using `&heartbeats=false`
86
89
 
87
90
  this.connection = new this.eventSource!(
@@ -74,6 +74,7 @@ export function MySegmentsUpdateWorker(mySegmentsSyncTask: IMySegmentsSyncTask,
74
74
 
75
75
  stop() {
76
76
  clearTimeout(_delayTimeoutID);
77
+ _delay = undefined;
77
78
  isHandlingEvent = false;
78
79
  backoff.reset();
79
80
  }
@@ -106,7 +106,7 @@ export const DISABLED = 0;
106
106
  export const ENABLED = 1;
107
107
  export const PAUSED = 2;
108
108
 
109
- export const FLAG_SPEC_VERSION = '1.1';
109
+ export const FLAG_SPEC_VERSION = '1.2';
110
110
 
111
111
  // Matcher types
112
112
  export const IN_SEGMENT = 'IN_SEGMENT';
@@ -14,6 +14,7 @@ export declare class SSEClient implements ISSEClient {
14
14
  useHeaders?: boolean;
15
15
  headers: Record<string, string>;
16
16
  options?: object;
17
+ lse?: boolean;
17
18
  /**
18
19
  * SSEClient constructor.
19
20
  *
@@ -79,6 +79,6 @@ export declare const NON_REQUESTED = 1;
79
79
  export declare const DISABLED = 0;
80
80
  export declare const ENABLED = 1;
81
81
  export declare const PAUSED = 2;
82
- export declare const FLAG_SPEC_VERSION = "1.1";
82
+ export declare const FLAG_SPEC_VERSION = "1.2";
83
83
  export declare const IN_SEGMENT = "IN_SEGMENT";
84
84
  export declare const IN_LARGE_SEGMENT = "IN_LARGE_SEGMENT";