@splitsoftware/splitio-commons 1.17.0-rc.3 → 1.17.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 -1
- package/cjs/readiness/readinessManager.js +2 -1
- package/cjs/readiness/sdkReadinessManager.js +2 -2
- package/cjs/sync/streaming/SSEClient/index.js +9 -7
- package/esm/readiness/readinessManager.js +2 -1
- package/esm/readiness/sdkReadinessManager.js +2 -2
- package/esm/sync/streaming/SSEClient/index.js +9 -7
- package/package.json +1 -1
- package/src/readiness/readinessManager.ts +2 -1
- package/src/readiness/sdkReadinessManager.ts +2 -2
- package/src/readiness/types.ts +1 -0
- package/src/sync/streaming/SSEClient/index.ts +12 -7
- package/src/types.ts +11 -0
- package/types/readiness/types.d.ts +1 -0
- package/types/types.d.ts +9 -0
package/CHANGES.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
1.17.0 (September 6, 2024)
|
|
2
2
|
- Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance SDK HTTP request Headers for Authorization Frameworks.
|
|
3
|
-
- Added lastUpdate
|
|
3
|
+
- Added `isTimedout` and `lastUpdate` properties to IStatusInterface to keep track of the timestamp of the last SDK event, used on React and Redux SDKs.
|
|
4
4
|
- Updated some transitive dependencies for vulnerability fixes.
|
|
5
5
|
|
|
6
6
|
1.16.0 (June 13, 2024)
|
|
@@ -129,8 +129,9 @@ function readinessManagerFactory(EventEmitter, readyTimeout, splits) {
|
|
|
129
129
|
splits.removeAllListeners();
|
|
130
130
|
},
|
|
131
131
|
isReady: function () { return isReady; },
|
|
132
|
-
hasTimedout: function () { return hasTimedout; },
|
|
133
132
|
isReadyFromCache: function () { return isReadyFromCache; },
|
|
133
|
+
isTimedout: function () { return hasTimedout && !isReady; },
|
|
134
|
+
hasTimedout: function () { return hasTimedout; },
|
|
134
135
|
isDestroyed: function () { return isDestroyed; },
|
|
135
136
|
isOperational: function () { return (isReady || isReadyFromCache) && !isDestroyed; },
|
|
136
137
|
lastUpdate: function () { return lastUpdate; }
|
|
@@ -107,14 +107,14 @@ function sdkReadinessManagerFactory(log, EventEmitter, readyTimeout, readinessMa
|
|
|
107
107
|
}
|
|
108
108
|
return readyPromise;
|
|
109
109
|
},
|
|
110
|
-
// Expose status for internal purposes only. Not considered part of the public API, and might be updated eventually.
|
|
111
110
|
__getStatus: function () {
|
|
112
111
|
return {
|
|
113
112
|
isReady: readinessManager.isReady(),
|
|
114
113
|
isReadyFromCache: readinessManager.isReadyFromCache(),
|
|
115
|
-
|
|
114
|
+
isTimedout: readinessManager.isTimedout(),
|
|
116
115
|
hasTimedout: readinessManager.hasTimedout(),
|
|
117
116
|
isDestroyed: readinessManager.isDestroyed(),
|
|
117
|
+
isOperational: readinessManager.isOperational(),
|
|
118
118
|
lastUpdate: readinessManager.lastUpdate(),
|
|
119
119
|
};
|
|
120
120
|
},
|
|
@@ -63,14 +63,16 @@ var SSEClient = /** @class */ (function () {
|
|
|
63
63
|
return encodeURIComponent(params + channel);
|
|
64
64
|
}).join(',');
|
|
65
65
|
var url = this.settings.urls.streaming + "/sse?channels=" + channelsQueryParam + "&accessToken=" + authToken.token + "&v=" + ABLY_API_VERSION + "&heartbeats=true"; // same results using `&heartbeats=false`
|
|
66
|
-
|
|
67
|
-
var useHeaders = !this.settings.core.key || ((_a = this.settings.sync.requestOptions) === null || _a === void 0 ? void 0 : _a.getHeaderOverrides);
|
|
66
|
+
var isServerSide = !this.settings.core.key;
|
|
68
67
|
this.connection = new this.eventSource(
|
|
69
|
-
// For client-side SDKs,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
// For client-side SDKs, metadata is passed as query param to avoid CORS issues and because native EventSource implementations in browsers do not support headers
|
|
69
|
+
isServerSide ? url : url + ("&SplitSDKVersion=" + this.headers.SplitSDKVersion + "&SplitSDKClientKey=" + this.headers.SplitSDKClientKey),
|
|
70
|
+
// For server-side SDKs, metadata is passed via headers. For NodeJS, the SDK uses an EventSource that support headers
|
|
71
|
+
(0, objectAssign_1.objectAssign)(isServerSide ?
|
|
72
|
+
{ headers: (0, decorateHeaders_1.decorateHeaders)(this.settings, this.headers) } :
|
|
73
|
+
((_a = this.settings.sync.requestOptions) === null || _a === void 0 ? void 0 : _a.getHeaderOverrides) ?
|
|
74
|
+
{ headers: (0, decorateHeaders_1.decorateHeaders)(this.settings, {}) } : // Assuming the user is providing a window.EventSource polyfill that supports headers
|
|
75
|
+
{}, this.options));
|
|
74
76
|
if (this.handler) { // no need to check if SSEClient is used only by PushManager
|
|
75
77
|
this.connection.addEventListener('open', this.handler.handleOpen);
|
|
76
78
|
this.connection.addEventListener('message', this.handler.handleMessage);
|
|
@@ -126,8 +126,9 @@ export function readinessManagerFactory(EventEmitter, readyTimeout, splits) {
|
|
|
126
126
|
splits.removeAllListeners();
|
|
127
127
|
},
|
|
128
128
|
isReady: function () { return isReady; },
|
|
129
|
-
hasTimedout: function () { return hasTimedout; },
|
|
130
129
|
isReadyFromCache: function () { return isReadyFromCache; },
|
|
130
|
+
isTimedout: function () { return hasTimedout && !isReady; },
|
|
131
|
+
hasTimedout: function () { return hasTimedout; },
|
|
131
132
|
isDestroyed: function () { return isDestroyed; },
|
|
132
133
|
isOperational: function () { return (isReady || isReadyFromCache) && !isDestroyed; },
|
|
133
134
|
lastUpdate: function () { return lastUpdate; }
|
|
@@ -104,14 +104,14 @@ export function sdkReadinessManagerFactory(log, EventEmitter, readyTimeout, read
|
|
|
104
104
|
}
|
|
105
105
|
return readyPromise;
|
|
106
106
|
},
|
|
107
|
-
// Expose status for internal purposes only. Not considered part of the public API, and might be updated eventually.
|
|
108
107
|
__getStatus: function () {
|
|
109
108
|
return {
|
|
110
109
|
isReady: readinessManager.isReady(),
|
|
111
110
|
isReadyFromCache: readinessManager.isReadyFromCache(),
|
|
112
|
-
|
|
111
|
+
isTimedout: readinessManager.isTimedout(),
|
|
113
112
|
hasTimedout: readinessManager.hasTimedout(),
|
|
114
113
|
isDestroyed: readinessManager.isDestroyed(),
|
|
114
|
+
isOperational: readinessManager.isOperational(),
|
|
115
115
|
lastUpdate: readinessManager.lastUpdate(),
|
|
116
116
|
};
|
|
117
117
|
},
|
|
@@ -60,14 +60,16 @@ var SSEClient = /** @class */ (function () {
|
|
|
60
60
|
return encodeURIComponent(params + channel);
|
|
61
61
|
}).join(',');
|
|
62
62
|
var url = this.settings.urls.streaming + "/sse?channels=" + channelsQueryParam + "&accessToken=" + authToken.token + "&v=" + ABLY_API_VERSION + "&heartbeats=true"; // same results using `&heartbeats=false`
|
|
63
|
-
|
|
64
|
-
var useHeaders = !this.settings.core.key || ((_a = this.settings.sync.requestOptions) === null || _a === void 0 ? void 0 : _a.getHeaderOverrides);
|
|
63
|
+
var isServerSide = !this.settings.core.key;
|
|
65
64
|
this.connection = new this.eventSource(
|
|
66
|
-
// For client-side SDKs,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
// For client-side SDKs, metadata is passed as query param to avoid CORS issues and because native EventSource implementations in browsers do not support headers
|
|
66
|
+
isServerSide ? url : url + ("&SplitSDKVersion=" + this.headers.SplitSDKVersion + "&SplitSDKClientKey=" + this.headers.SplitSDKClientKey),
|
|
67
|
+
// For server-side SDKs, metadata is passed via headers. For NodeJS, the SDK uses an EventSource that support headers
|
|
68
|
+
objectAssign(isServerSide ?
|
|
69
|
+
{ headers: decorateHeaders(this.settings, this.headers) } :
|
|
70
|
+
((_a = this.settings.sync.requestOptions) === null || _a === void 0 ? void 0 : _a.getHeaderOverrides) ?
|
|
71
|
+
{ headers: decorateHeaders(this.settings, {}) } : // Assuming the user is providing a window.EventSource polyfill that supports headers
|
|
72
|
+
{}, this.options));
|
|
71
73
|
if (this.handler) { // no need to check if SSEClient is used only by PushManager
|
|
72
74
|
this.connection.addEventListener('open', this.handler.handleOpen);
|
|
73
75
|
this.connection.addEventListener('message', this.handler.handleMessage);
|
package/package.json
CHANGED
|
@@ -143,8 +143,9 @@ export function readinessManagerFactory(
|
|
|
143
143
|
},
|
|
144
144
|
|
|
145
145
|
isReady() { return isReady; },
|
|
146
|
-
hasTimedout() { return hasTimedout; },
|
|
147
146
|
isReadyFromCache() { return isReadyFromCache; },
|
|
147
|
+
isTimedout() { return hasTimedout && !isReady; },
|
|
148
|
+
hasTimedout() { return hasTimedout; },
|
|
148
149
|
isDestroyed() { return isDestroyed; },
|
|
149
150
|
isOperational() { return (isReady || isReadyFromCache) && !isDestroyed; },
|
|
150
151
|
lastUpdate() { return lastUpdate; }
|
|
@@ -121,14 +121,14 @@ export function sdkReadinessManagerFactory(
|
|
|
121
121
|
return readyPromise;
|
|
122
122
|
},
|
|
123
123
|
|
|
124
|
-
// Expose status for internal purposes only. Not considered part of the public API, and might be updated eventually.
|
|
125
124
|
__getStatus() {
|
|
126
125
|
return {
|
|
127
126
|
isReady: readinessManager.isReady(),
|
|
128
127
|
isReadyFromCache: readinessManager.isReadyFromCache(),
|
|
129
|
-
|
|
128
|
+
isTimedout: readinessManager.isTimedout(),
|
|
130
129
|
hasTimedout: readinessManager.hasTimedout(),
|
|
131
130
|
isDestroyed: readinessManager.isDestroyed(),
|
|
131
|
+
isOperational: readinessManager.isOperational(),
|
|
132
132
|
lastUpdate: readinessManager.lastUpdate(),
|
|
133
133
|
};
|
|
134
134
|
},
|
package/src/readiness/types.ts
CHANGED
|
@@ -78,15 +78,20 @@ export class SSEClient implements ISSEClient {
|
|
|
78
78
|
}
|
|
79
79
|
).join(',');
|
|
80
80
|
const url = `${this.settings.urls.streaming}/sse?channels=${channelsQueryParam}&accessToken=${authToken.token}&v=${ABLY_API_VERSION}&heartbeats=true`; // same results using `&heartbeats=false`
|
|
81
|
-
|
|
82
|
-
const useHeaders = !this.settings.core.key || this.settings.sync.requestOptions?.getHeaderOverrides;
|
|
81
|
+
const isServerSide = !this.settings.core.key;
|
|
83
82
|
|
|
84
83
|
this.connection = new this.eventSource!(
|
|
85
|
-
// For client-side SDKs,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
// For client-side SDKs, metadata is passed as query param to avoid CORS issues and because native EventSource implementations in browsers do not support headers
|
|
85
|
+
isServerSide ? url : url + `&SplitSDKVersion=${this.headers.SplitSDKVersion}&SplitSDKClientKey=${this.headers.SplitSDKClientKey}`,
|
|
86
|
+
// For server-side SDKs, metadata is passed via headers. For NodeJS, the SDK uses an EventSource that support headers
|
|
87
|
+
objectAssign(
|
|
88
|
+
isServerSide ?
|
|
89
|
+
{ headers: decorateHeaders(this.settings, this.headers) } :
|
|
90
|
+
this.settings.sync.requestOptions?.getHeaderOverrides ?
|
|
91
|
+
{ headers: decorateHeaders(this.settings, {}) } : // Assuming the user is providing a window.EventSource polyfill that supports headers
|
|
92
|
+
{},
|
|
93
|
+
this.options
|
|
94
|
+
)
|
|
90
95
|
);
|
|
91
96
|
|
|
92
97
|
if (this.handler) { // no need to check if SSEClient is used only by PushManager
|
package/src/types.ts
CHANGED
|
@@ -409,6 +409,17 @@ export interface IStatusInterface extends IEventEmitter {
|
|
|
409
409
|
* @returns {Promise<void>}
|
|
410
410
|
*/
|
|
411
411
|
ready(): Promise<void>
|
|
412
|
+
|
|
413
|
+
// Expose status for internal purposes only. Not considered part of the public API, and might be updated eventually.
|
|
414
|
+
__getStatus(): {
|
|
415
|
+
isReady: boolean;
|
|
416
|
+
isReadyFromCache: boolean;
|
|
417
|
+
isTimedout: boolean;
|
|
418
|
+
hasTimedout: boolean;
|
|
419
|
+
isDestroyed: boolean;
|
|
420
|
+
isOperational: boolean;
|
|
421
|
+
lastUpdate: number;
|
|
422
|
+
}
|
|
412
423
|
}
|
|
413
424
|
/**
|
|
414
425
|
* Common definitions between clients for different environments interface.
|
package/types/types.d.ts
CHANGED
|
@@ -407,6 +407,15 @@ export interface IStatusInterface extends IEventEmitter {
|
|
|
407
407
|
* @returns {Promise<void>}
|
|
408
408
|
*/
|
|
409
409
|
ready(): Promise<void>;
|
|
410
|
+
__getStatus(): {
|
|
411
|
+
isReady: boolean;
|
|
412
|
+
isReadyFromCache: boolean;
|
|
413
|
+
isTimedout: boolean;
|
|
414
|
+
hasTimedout: boolean;
|
|
415
|
+
isDestroyed: boolean;
|
|
416
|
+
isOperational: boolean;
|
|
417
|
+
lastUpdate: number;
|
|
418
|
+
};
|
|
410
419
|
}
|
|
411
420
|
/**
|
|
412
421
|
* Common definitions between clients for different environments interface.
|