@jibb-open/jssdk 3.15.9 → 3.15.11
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/api/meeting.js +1 -1
- package/package.json +1 -1
- package/ws/retry_connection.js +1 -1
package/api/meeting.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createMeeting=createMeeting,exports.createShare=createShare,exports.createTemporaryShare=createTemporaryShare,exports.deleteMeeting=deleteMeeting,exports.deleteMeetingImages=deleteMeetingImages,exports.deleteShare=deleteShare,exports.endMeeting=endMeeting,exports.getIncomingShares=getIncomingShares,exports.getMeetingDetails=getMeetingDetails,exports.getMeetingImage=getMeetingImage,exports.getMeetingImages=getMeetingImages,exports.getMeetingList=getMeetingList,exports.getMeetingToken=getMeetingToken,exports.getMeetingTokenFromTempShareId=getMeetingTokenFromTempShareId,exports.getOutgoingShares=getOutgoingShares,exports.isMeetingOwner=isMeetingOwner,exports.startMeeting=startMeeting,exports.updateMeeting=updateMeeting,exports.updateShare=updateShare,require("core-js/modules/es.promise.js"),require("core-js/modules/es.json.stringify.js");var _config=require("../config.js"),_auth=require("./auth.js"),_index=require("../utils/logger/index.js"),_exceptions=require("../types/exceptions.js"),_index2=require("../utils/http/index.js"),_types=require("../types/types.js");async function createMeeting(a){let{title:b,isTemporary:c,capacity:d,meetingType:e}=a,f={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},g={title:b||"",isTemporary:c||!1,capacity:d||2,meetingType:e||_types.MeetingTypes.DEFAULT},h=await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings"),g,f);return h.data.meetingId}async function createTemporaryShare(a){let{meetingId:b,permission:c,expiry:d,auxData:e}=a,f={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},g=await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/temp-shares"),{permission:c,expiry:{seconds:d||3600},auxilary:e||{}},f);return g.data.shareId}async function getMeetingTokenFromTempShareId(a){let{meetingId:b,shareId:c}=a,d=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/temp-shares/").concat(c),{"Content-Type":"application/json",Accept:"application/json"});return d.data.token}async function deleteMeetingImages(a){let{meetingId:b,mtoken:c}=a,d={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)(),"x-jibb-meeting-jwt":c};return _index2.http.delete("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/images"),d)}async function getMeetingImages(a){let{meetingId:b,meetingToken:c}=a,d={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)(),"x-jibb-meeting-jwt":c},e=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/images"),d);return e.data}async function getMeetingImage(a){let{meetingId:b,meetingToken:c,imageId:d}=a,e={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)(),"x-jibb-meeting-jwt":c},f=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/images/").concat(d),e);return f.data}async function startMeeting(a){let{meetingId:b,meetingToken:c}=a;try{return await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/actions/start"),{},{"Content-Type":"application/json",Accept:"application/json","x-jibb-meeting-jwt":c})}catch(a){var d;if(404==(null===a||void 0===a||null===(d=a.response)||void 0===d?void 0:d.status))throw new _exceptions.NotFoundError;else throw a}}async function endMeeting(a){let{meetingId:b,meetingToken:c}=a;return _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/actions/end"),{},{"Content-Type":"application/json",Accept:"application/json","x-jibb-meeting-jwt":c})}async function deleteMeeting(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()};return _index2.http.delete("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(a),b)}async function getMeetingToken(a){let b,{meetingId:c,permission:d,expiry:e=3600}=a;try{b=await(0,_auth.getUserToken)()}catch(a){throw _index.logger.error({err:a}),new _exceptions.PermissionDeniedError("user is not authenticated")}try{let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":b},f=await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(c,"/token"),{permission:d,expiry:{seconds:e}},a);return f.data.token}catch(a){var f;if(404==(null===a||void 0===a||null===(f=a.response)||void 0===f?void 0:f.status))throw new _exceptions.NotFoundError("meeting not found");else throw a}}async function getMeetingList(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()};void 0!==a&&(b["x-jibb-pagination"]=JSON.stringify(a));let c=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings"),b);return a=c.headers["x-jibb-pagination"],a=a&&JSON.parse(a),{meetings:c.data.meetings,pagination:a}}async function getMeetingDetails(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},c=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(a),b);return c.data}async function updateMeeting(a){let{meetingId:b,title:c,capacity:d}=a,e={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},f={};return c&&(f.title=c),d&&(f.capacity=d),_index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b),f,e)}async function isMeetingOwner(a){try{let b=new _types.MeetingClaims(a),c=new _types.UserClaims(await(0,_auth.getUserToken)());return c.userId===b.ownerId}catch(a){return!1}}async function createShare(a){let{email:b,meetingId:c,permission:d,meetingToken:e}=a,f={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)(),"x-jibb-meeting-jwt":e},g=await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(c,"/shares"),{email:b,permission:d},f);return g.data}async function getIncomingShares(){let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},b=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/shares?incoming=true"),a);return b.data.shares}async function getOutgoingShares(){let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},b=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/shares?outgoing=true"),a);return b.data.shares}async function deleteShare(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()};return _index2.http.delete("".concat(_config.Config.apiBaseURL,"/v1/meetings/shares/").concat(a),b)}async function updateShare(a){let{shareId:b,permission:c}=a,d={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()};return _index2.http.patch("".concat(_config.Config.apiBaseURL,"/v1/meetings/shares/").concat(b),{permission:c},d)}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createMeeting=createMeeting,exports.createShare=createShare,exports.createShortUrl=createShortUrl,exports.createTemporaryShare=createTemporaryShare,exports.deleteMeeting=deleteMeeting,exports.deleteMeetingImages=deleteMeetingImages,exports.deleteShare=deleteShare,exports.endMeeting=endMeeting,exports.getFullUrl=getFullUrl,exports.getIncomingShares=getIncomingShares,exports.getMeetingDetails=getMeetingDetails,exports.getMeetingImage=getMeetingImage,exports.getMeetingImages=getMeetingImages,exports.getMeetingList=getMeetingList,exports.getMeetingToken=getMeetingToken,exports.getMeetingTokenFromTempShareId=getMeetingTokenFromTempShareId,exports.getOutgoingShares=getOutgoingShares,exports.isMeetingOwner=isMeetingOwner,exports.startMeeting=startMeeting,exports.updateMeeting=updateMeeting,exports.updateShare=updateShare,require("core-js/modules/es.promise.js"),require("core-js/modules/es.json.stringify.js");var _config=require("../config.js"),_auth=require("./auth.js"),_index=require("../utils/logger/index.js"),_exceptions=require("../types/exceptions.js"),_index2=require("../utils/http/index.js"),_types=require("../types/types.js");async function createMeeting(a){let{title:b,isTemporary:c,capacity:d,meetingType:e}=a,f={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},g={title:b||"",isTemporary:c||!1,capacity:d||2,meetingType:e||_types.MeetingTypes.DEFAULT},h=await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings"),g,f);return h.data.meetingId}async function createTemporaryShare(a){let{meetingId:b,permission:c,expiry:d,auxData:e}=a,f={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},g=await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/temp-shares"),{permission:c,expiry:{seconds:d||3600},auxilary:e||{}},f);return g.data.shareId}async function getMeetingTokenFromTempShareId(a){let{meetingId:b,shareId:c}=a,d=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/temp-shares/").concat(c),{"Content-Type":"application/json",Accept:"application/json"});return d.data.token}async function deleteMeetingImages(a){let{meetingId:b,mtoken:c}=a,d={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)(),"x-jibb-meeting-jwt":c};return _index2.http.delete("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/images"),d)}async function getMeetingImages(a){let{meetingId:b,meetingToken:c}=a,d={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)(),"x-jibb-meeting-jwt":c},e=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/images"),d);return e.data}async function getMeetingImage(a){let{meetingId:b,meetingToken:c,imageId:d}=a,e={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)(),"x-jibb-meeting-jwt":c},f=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/images/").concat(d),e);return f.data}async function startMeeting(a){let{meetingId:b,meetingToken:c}=a;try{return await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/actions/start"),{},{"Content-Type":"application/json",Accept:"application/json","x-jibb-meeting-jwt":c})}catch(a){var d;if(404==(null===a||void 0===a||null===(d=a.response)||void 0===d?void 0:d.status))throw new _exceptions.NotFoundError;else throw a}}async function endMeeting(a){let{meetingId:b,meetingToken:c}=a;return _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b,"/actions/end"),{},{"Content-Type":"application/json",Accept:"application/json","x-jibb-meeting-jwt":c})}async function deleteMeeting(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()};return _index2.http.delete("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(a),b)}async function getMeetingToken(a){let b,{meetingId:c,permission:d,expiry:e=3600}=a;try{b=await(0,_auth.getUserToken)()}catch(a){throw _index.logger.error({err:a}),new _exceptions.PermissionDeniedError("user is not authenticated")}try{let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":b},f=await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(c,"/token"),{permission:d,expiry:{seconds:e}},a);return f.data.token}catch(a){var f;if(404==(null===a||void 0===a||null===(f=a.response)||void 0===f?void 0:f.status))throw new _exceptions.NotFoundError("meeting not found");else throw a}}async function getMeetingList(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()};void 0!==a&&(b["x-jibb-pagination"]=JSON.stringify(a));let c=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings"),b);return a=c.headers["x-jibb-pagination"],a=a&&JSON.parse(a),{meetings:c.data.meetings,pagination:a}}async function getMeetingDetails(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},c=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(a),b);return c.data}async function updateMeeting(a){let{meetingId:b,title:c,capacity:d}=a,e={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},f={};return c&&(f.title=c),d&&(f.capacity=d),_index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(b),f,e)}async function isMeetingOwner(a){try{let b=new _types.MeetingClaims(a),c=new _types.UserClaims(await(0,_auth.getUserToken)());return c.userId===b.ownerId}catch(a){return!1}}async function createShare(a){let{email:b,meetingId:c,permission:d,meetingToken:e}=a,f={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)(),"x-jibb-meeting-jwt":e},g=await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/").concat(c,"/shares"),{email:b,permission:d},f);return g.data}async function getIncomingShares(){let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},b=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/shares?incoming=true"),a);return b.data.shares}async function getOutgoingShares(){let a={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()},b=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/shares?outgoing=true"),a);return b.data.shares}async function deleteShare(a){let b={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()};return _index2.http.delete("".concat(_config.Config.apiBaseURL,"/v1/meetings/shares/").concat(a),b)}async function updateShare(a){let{shareId:b,permission:c}=a,d={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)()};return _index2.http.patch("".concat(_config.Config.apiBaseURL,"/v1/meetings/shares/").concat(b),{permission:c},d)}async function createShortUrl(a){let{meetingToken:b,url:c}=a,d={"Content-Type":"application/json",Accept:"application/json","x-jibb-user-jwt":await(0,_auth.getUserToken)(),"x-jibb-meeting-jwt":b},e=await _index2.http.post("".concat(_config.Config.apiBaseURL,"/v1/meetings/url-shortener"),{url:c},d);return e.data}async function getFullUrl(a){let b=await _index2.http.get("".concat(_config.Config.apiBaseURL,"/v1/meetings/url-shortener/").concat(a),{"Content-Type":"application/json",Accept:"application/json"});return b.data.fullUrl}
|
package/package.json
CHANGED
package/ws/retry_connection.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RetryConnection=void 0,require("core-js/modules/es.weak-map.js"),require("core-js/modules/web.dom-collections.iterator.js");var _exceptions=require("../types/exceptions.js"),_index=require("../utils/logger/index.js"),_connection_base=require("./connection_base.js");function _classPrivateMethodInitSpec(a,b){_checkPrivateRedeclaration(a,b),b.add(a)}function _classPrivateFieldInitSpec(a,b,c){_checkPrivateRedeclaration(a,b),b.set(a,c)}function _checkPrivateRedeclaration(a,b){if(b.has(a))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateFieldGet(a,b){var c=_classExtractFieldDescriptor(a,b,"get");return _classApplyDescriptorGet(a,c)}function _classApplyDescriptorGet(a,b){return b.get?b.get.call(a):b.value}function _classPrivateMethodGet(a,b,c){if(!b.has(a))throw new TypeError("attempted to get private field on non-instance");return c}function _classPrivateFieldSet(a,b,c){var d=_classExtractFieldDescriptor(a,b,"set");return _classApplyDescriptorSet(a,d,c),c}function _classExtractFieldDescriptor(a,b,c){if(!b.has(a))throw new TypeError("attempted to "+c+" private field on non-instance");return b.get(a)}function _classApplyDescriptorSet(a,b,c){if(b.set)b.set.call(a,c);else{if(!b.writable)throw new TypeError("attempted to set read only private field");b.value=c}}var _started=/*#__PURE__*/new WeakMap,_connectionTimer=/*#__PURE__*/new WeakMap,_resetCountersTimer=/*#__PURE__*/new WeakMap,_reconnect=/*#__PURE__*/new WeakSet,_resetCounters=/*#__PURE__*/new WeakSet;class RetryConnection extends _connection_base.ConnectionBase{constructor(a){let b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{maxRetryCount:10,minRetryIntervalMs:500,maxRetryIntervalMs:32e3};super(a),_classPrivateMethodInitSpec(this,_resetCounters),_classPrivateMethodInitSpec(this,_reconnect),_classPrivateFieldInitSpec(this,_started,{writable:!0,value:void 0}),_classPrivateFieldInitSpec(this,_connectionTimer,{writable:!0,value:void 0}),_classPrivateFieldInitSpec(this,_resetCountersTimer,{writable:!0,value:void 0}),this.maxRetryCount=b.maxRetryCount||10,this.minRetryIntervalMs=b.minRetryIntervalMs||500,this.maxRetryIntervalMs=b.maxRetryIntervalMs||32e3,_classPrivateFieldSet(this,_connectionTimer,null),_classPrivateFieldSet(this,_resetCountersTimer,null),_classPrivateFieldSet(this,_started,!1),_classPrivateMethodGet(this,_resetCounters,_resetCounters2).call(this)}start(){this.isStarted()||(_index.logger.info("".concat(this.name,": starting...")),_classPrivateFieldSet(this,_started,!0),_classPrivateMethodGet(this,_resetCounters,_resetCounters2).call(this),_classPrivateMethodGet(this,_reconnect,_reconnect2).call(this),this.onStarted())}stop(){_index.logger.info("".concat(this.name,": stopping...")),_classPrivateFieldSet(this,_started,!1),this.disconnect(),this.onStopped()}isStarted(){return _classPrivateFieldGet(this,_started)}onDisconnected(){super.onDisconnected(),_classPrivateMethodGet(this,_reconnect,_reconnect2).call(this)}onStarted(){}onStopped(){}onError(a){super.onError(a),(a instanceof _exceptions.TooManyConnectionsError||a instanceof _exceptions.PermissionDeniedError||a instanceof _exceptions.SessionTimeoutError)&&this.stop()}disconnect(){clearTimeout(_classPrivateFieldGet(this,_connectionTimer)),clearTimeout(_classPrivateFieldGet(this,_resetCountersTimer)),super.disconnect()}}exports.RetryConnection=RetryConnection;function _reconnect2(){if(this.isStarted()){if(this.retryCount>this.maxRetryCount)return void this.stop();let a=Math.max(this.nexRetryTime-Date.now(),0);0<a&&(_index.logger.debug(this),_index.logger.info("".concat(this.name,": retrying connection in ").concat(this.retryIntervalMs,"ms]"))),clearTimeout(_classPrivateFieldGet(this,_resetCountersTimer)),this.retryIntervalMs=Math.min(2*this.retryIntervalMs,this.maxRetryIntervalMs),++this.retryCount,this.nexRetryTime=Date.now()+this.retryIntervalMs,_classPrivateFieldSet(this,_connectionTimer,setTimeout(()=>{this.connect().catch(a=>{this.onError(a)})},a)),_classPrivateFieldSet(this,_resetCountersTimer,setTimeout(()=>{_classPrivateMethodGet(this,_resetCounters,_resetCounters2).call(this)},6e4))}}function _resetCounters2(){this.retryCount=0,this.retryIntervalMs=this.minRetryIntervalMs,this.nexRetryTime=Date.now()}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RetryConnection=void 0,require("core-js/modules/es.weak-map.js"),require("core-js/modules/web.dom-collections.iterator.js");var _exceptions=require("../types/exceptions.js"),_index=require("../utils/logger/index.js"),_connection_base=require("./connection_base.js");function _classPrivateMethodInitSpec(a,b){_checkPrivateRedeclaration(a,b),b.add(a)}function _classPrivateFieldInitSpec(a,b,c){_checkPrivateRedeclaration(a,b),b.set(a,c)}function _checkPrivateRedeclaration(a,b){if(b.has(a))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateFieldGet(a,b){var c=_classExtractFieldDescriptor(a,b,"get");return _classApplyDescriptorGet(a,c)}function _classApplyDescriptorGet(a,b){return b.get?b.get.call(a):b.value}function _classPrivateMethodGet(a,b,c){if(!b.has(a))throw new TypeError("attempted to get private field on non-instance");return c}function _classPrivateFieldSet(a,b,c){var d=_classExtractFieldDescriptor(a,b,"set");return _classApplyDescriptorSet(a,d,c),c}function _classExtractFieldDescriptor(a,b,c){if(!b.has(a))throw new TypeError("attempted to "+c+" private field on non-instance");return b.get(a)}function _classApplyDescriptorSet(a,b,c){if(b.set)b.set.call(a,c);else{if(!b.writable)throw new TypeError("attempted to set read only private field");b.value=c}}var _started=/*#__PURE__*/new WeakMap,_connectionTimer=/*#__PURE__*/new WeakMap,_resetCountersTimer=/*#__PURE__*/new WeakMap,_reconnect=/*#__PURE__*/new WeakSet,_resetCounters=/*#__PURE__*/new WeakSet;class RetryConnection extends _connection_base.ConnectionBase{constructor(a){let b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{maxRetryCount:10,minRetryIntervalMs:500,maxRetryIntervalMs:32e3};super(a),_classPrivateMethodInitSpec(this,_resetCounters),_classPrivateMethodInitSpec(this,_reconnect),_classPrivateFieldInitSpec(this,_started,{writable:!0,value:void 0}),_classPrivateFieldInitSpec(this,_connectionTimer,{writable:!0,value:void 0}),_classPrivateFieldInitSpec(this,_resetCountersTimer,{writable:!0,value:void 0}),this.maxRetryCount=b.maxRetryCount||10,this.minRetryIntervalMs=b.minRetryIntervalMs||500,this.maxRetryIntervalMs=b.maxRetryIntervalMs||32e3,_classPrivateFieldSet(this,_connectionTimer,null),_classPrivateFieldSet(this,_resetCountersTimer,null),_classPrivateFieldSet(this,_started,!1),_classPrivateMethodGet(this,_resetCounters,_resetCounters2).call(this)}start(){this.isStarted()||(_index.logger.info("".concat(this.name,": starting...")),_classPrivateFieldSet(this,_started,!0),_classPrivateMethodGet(this,_resetCounters,_resetCounters2).call(this),_classPrivateMethodGet(this,_reconnect,_reconnect2).call(this),this.onStarted())}stop(){_index.logger.info("".concat(this.name,": stopping...")),_classPrivateFieldSet(this,_started,!1),this.disconnect(),this.onStopped()}isStarted(){return _classPrivateFieldGet(this,_started)}onDisconnected(){super.onDisconnected(),_classPrivateMethodGet(this,_reconnect,_reconnect2).call(this)}onStarted(){}onStopped(){}onError(a){super.onError(a),(a instanceof _exceptions.TooManyConnectionsError||a instanceof _exceptions.PermissionDeniedError||a instanceof _exceptions.SessionTimeoutError)&&this.stop()}disconnect(){clearTimeout(_classPrivateFieldGet(this,_connectionTimer)),clearTimeout(_classPrivateFieldGet(this,_resetCountersTimer)),super.disconnect()}setCounters(){let a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{maxRetryCount:10,minRetryIntervalMs:500,maxRetryIntervalMs:32e3};this.maxRetryCount=a.maxRetryCount||10,this.minRetryIntervalMs=a.minRetryIntervalMs||500,this.maxRetryIntervalMs=a.maxRetryIntervalMs||32e3}}exports.RetryConnection=RetryConnection;function _reconnect2(){if(this.isStarted()){if(this.retryCount>this.maxRetryCount)return void this.stop();let a=Math.max(this.nexRetryTime-Date.now(),0);0<a&&(_index.logger.debug(this),_index.logger.info("".concat(this.name,": retrying connection in ").concat(this.retryIntervalMs,"ms]"))),clearTimeout(_classPrivateFieldGet(this,_resetCountersTimer)),this.retryIntervalMs=Math.min(2*this.retryIntervalMs,this.maxRetryIntervalMs),++this.retryCount,this.nexRetryTime=Date.now()+this.retryIntervalMs,_classPrivateFieldSet(this,_connectionTimer,setTimeout(()=>{this.connect().catch(a=>{this.onError(a)})},a)),_classPrivateFieldSet(this,_resetCountersTimer,setTimeout(()=>{_classPrivateMethodGet(this,_resetCounters,_resetCounters2).call(this)},6e4))}}function _resetCounters2(){this.retryCount=0,this.retryIntervalMs=this.minRetryIntervalMs,this.nexRetryTime=Date.now()}
|