@evergis/api 3.0.128 → 3.0.130
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/dist/Api.d.ts +2 -1
- package/dist/api.cjs.development.js +28 -3
- package/dist/api.cjs.development.js.map +1 -1
- package/dist/api.cjs.production.min.js +1 -1
- package/dist/api.cjs.production.min.js.map +1 -1
- package/dist/api.esm.js +28 -3
- package/dist/api.esm.js.map +1 -1
- package/dist/services/Notification.d.ts +4 -1
- package/package.json +2 -2
package/dist/Api.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Print } from './services/Print';
|
|
|
8
8
|
export declare type ApiParams = {
|
|
9
9
|
url: string;
|
|
10
10
|
wsUrl?: string;
|
|
11
|
+
wsKeepAlive?: boolean;
|
|
11
12
|
snappingHubUrl?: string;
|
|
12
13
|
http?: HttpClient;
|
|
13
14
|
httpOptions?: KyOptions;
|
|
@@ -54,7 +55,7 @@ export declare class Api extends EventEmitter {
|
|
|
54
55
|
readonly feedback: Feedback;
|
|
55
56
|
readonly snappingHub: HubConnection | null;
|
|
56
57
|
readonly vectorTiles: VectorTiles;
|
|
57
|
-
constructor({ url, wsUrl, snappingHubUrl, http, urlPath, httpOptions, }: ApiParams);
|
|
58
|
+
constructor({ url, wsUrl, wsKeepAlive, snappingHubUrl, http, urlPath, httpOptions, }: ApiParams);
|
|
58
59
|
init({ authParams, connectWs, initScheduler, fetchSettings, fetchUser, }: {
|
|
59
60
|
authParams?: LoginDc;
|
|
60
61
|
connectWs?: boolean;
|
|
@@ -941,26 +941,43 @@ let NotificationService = /*#__PURE__*/function (_Service) {
|
|
|
941
941
|
})(exports.ConnectionStatus || (exports.ConnectionStatus = {}));
|
|
942
942
|
|
|
943
943
|
const SUBSCRIPTION_DELAY = 500;
|
|
944
|
+
const KEEP_ALIVE_INTERVAL = 5 * 1000;
|
|
944
945
|
let Notification = /*#__PURE__*/function (_NotificationService) {
|
|
945
946
|
_inherits(Notification, _NotificationService);
|
|
946
947
|
|
|
947
948
|
var _super = /*#__PURE__*/_createSuper(Notification);
|
|
948
949
|
|
|
949
|
-
function Notification(http, api) {
|
|
950
|
+
function Notification(http, api, keepAlive) {
|
|
950
951
|
var _this;
|
|
951
952
|
|
|
953
|
+
if (keepAlive === void 0) {
|
|
954
|
+
keepAlive = false;
|
|
955
|
+
}
|
|
956
|
+
|
|
952
957
|
_classCallCheck(this, Notification);
|
|
953
958
|
|
|
954
959
|
_this = _super.call(this, http);
|
|
955
960
|
_this.api = api;
|
|
956
961
|
_this.MAX_WS_RECONNECT_TRIES = 10;
|
|
962
|
+
_this.keepAlive = false;
|
|
957
963
|
_this.reconnectTries = 0;
|
|
958
964
|
_this.subscriptions = [];
|
|
959
965
|
_this._connectStatus = exports.ConnectionStatus.Initialized;
|
|
960
966
|
|
|
961
967
|
_this.onWsConnected = () => {
|
|
962
|
-
_this.connectStatus = exports.ConnectionStatus.Connected;
|
|
968
|
+
_this.connectStatus = exports.ConnectionStatus.Connected;
|
|
969
|
+
|
|
970
|
+
if (_this.keepAlive) {
|
|
971
|
+
_this.keepAliveTimeout = setInterval(() => {
|
|
972
|
+
if (_this.ws) {
|
|
973
|
+
_this.ws.send(JSON.stringify({
|
|
974
|
+
keepAlive: true
|
|
975
|
+
}));
|
|
976
|
+
}
|
|
977
|
+
}, KEEP_ALIVE_INTERVAL);
|
|
978
|
+
} // TODO: comment for now. it launch endless flow of reconnections
|
|
963
979
|
// this.reconnectTries = 0;
|
|
980
|
+
|
|
964
981
|
};
|
|
965
982
|
|
|
966
983
|
_this.onWsClosed = event => {
|
|
@@ -981,6 +998,7 @@ let Notification = /*#__PURE__*/function (_NotificationService) {
|
|
|
981
998
|
_this.ws = void 0;
|
|
982
999
|
}
|
|
983
1000
|
|
|
1001
|
+
_this.keepAliveTimeout && clearInterval(_this.keepAliveTimeout);
|
|
984
1002
|
setTimeout(() => {
|
|
985
1003
|
_this.connect();
|
|
986
1004
|
}, 0);
|
|
@@ -1008,6 +1026,7 @@ let Notification = /*#__PURE__*/function (_NotificationService) {
|
|
|
1008
1026
|
};
|
|
1009
1027
|
|
|
1010
1028
|
_this.emitter = new eventEmitter.EventEmitter();
|
|
1029
|
+
_this.keepAlive = keepAlive;
|
|
1011
1030
|
return _this;
|
|
1012
1031
|
} // @ts-ignore
|
|
1013
1032
|
|
|
@@ -1024,6 +1043,11 @@ let Notification = /*#__PURE__*/function (_NotificationService) {
|
|
|
1024
1043
|
, new NotificationEvent(connectStatus));
|
|
1025
1044
|
this._connectStatus = connectStatus;
|
|
1026
1045
|
}
|
|
1046
|
+
}, {
|
|
1047
|
+
key: "currentWs",
|
|
1048
|
+
get: function get() {
|
|
1049
|
+
return this.ws;
|
|
1050
|
+
}
|
|
1027
1051
|
}, {
|
|
1028
1052
|
key: "on",
|
|
1029
1053
|
value: function on(tag, handler) {
|
|
@@ -6088,6 +6112,7 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
|
|
|
6088
6112
|
let {
|
|
6089
6113
|
url,
|
|
6090
6114
|
wsUrl,
|
|
6115
|
+
wsKeepAlive,
|
|
6091
6116
|
snappingHubUrl,
|
|
6092
6117
|
http,
|
|
6093
6118
|
urlPath,
|
|
@@ -6129,7 +6154,7 @@ let Api = /*#__PURE__*/function (_EventEmitter) {
|
|
|
6129
6154
|
_this.accountPreview = new AccountPreview(_this.http, _this.account);
|
|
6130
6155
|
_this.bulk = new BulkOperations(_this.http);
|
|
6131
6156
|
_this.security = new Security(_this.http, _this.account);
|
|
6132
|
-
_this.notification = new Notification(_this.http, _assertThisInitialized(_this));
|
|
6157
|
+
_this.notification = new Notification(_this.http, _assertThisInitialized(_this), wsKeepAlive);
|
|
6133
6158
|
_this.scheduler = new Scheduler(_this.http);
|
|
6134
6159
|
_this.file = new FileUpload(_this.http);
|
|
6135
6160
|
_this.filters = new Filters(_this.http);
|