@splitsoftware/splitio-commons 1.16.1-rc.5 → 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.
- package/cjs/sync/streaming/SSEClient/index.js +4 -0
- package/cjs/utils/constants/index.js +1 -1
- package/esm/sync/streaming/SSEClient/index.js +5 -1
- package/esm/utils/constants/index.js +1 -1
- package/package.json +1 -1
- package/src/sync/streaming/SSEClient/index.ts +6 -1
- package/src/utils/constants/index.ts +1 -1
- package/types/sync/streaming/SSEClient/index.d.ts +1 -0
- package/types/utils/constants/index.d.ts +1 -1
|
@@ -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(
|
|
@@ -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.
|
|
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(
|
|
@@ -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.
|
|
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,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) {
|
|
@@ -79,7 +81,10 @@ export class SSEClient implements ISSEClient {
|
|
|
79
81
|
const channelsQueryParam = Object.keys(authToken.channels).map((channel) => {
|
|
80
82
|
const params = CONTROL_CHANNEL_REGEX.test(channel) ? '[?occupancy=metrics.publishers]' : '';
|
|
81
83
|
return encodeURIComponent(params + channel);
|
|
84
|
+
}).filter(channel => {
|
|
85
|
+
return this.lse || !endsWith(channel, 'myLargeSegments');
|
|
82
86
|
}).join(',');
|
|
87
|
+
|
|
83
88
|
const url = `${this.streamingUrl}?channels=${channelsQueryParam}&accessToken=${authToken.token}&v=${ABLY_API_VERSION}&heartbeats=true`; // same results using `&heartbeats=false`
|
|
84
89
|
|
|
85
90
|
this.connection = new this.eventSource!(
|
|
@@ -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.
|
|
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";
|