@larksuiteoapi/node-sdk 1.49.0-alpha.0 → 1.49.0-alpha.1

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/es/index.js CHANGED
@@ -82742,6 +82742,10 @@ class WSClient {
82742
82742
  constructor(params) {
82743
82743
  this.wsConfig = new WSConfig();
82744
82744
  this.isConnecting = false;
82745
+ this.reconnectInfo = {
82746
+ lastConnectTime: 0,
82747
+ nextConnectTime: 0,
82748
+ };
82745
82749
  const { appId, appSecret, domain = Domain.Feishu, httpInstance = defaultHttpInstance, loggerLevel = LoggerLevel.info, logger = defaultLogger, autoReconnect = true } = params;
82746
82750
  this.logger = new LoggerProxy(loggerLevel, logger);
82747
82751
  assert(!appId, () => this.logger.error('appId is needed'));
@@ -82822,6 +82826,7 @@ class WSClient {
82822
82826
  }
82823
82827
  this.isConnecting = true;
82824
82828
  const tryConnect = () => {
82829
+ this.reconnectInfo.lastConnectTime = Date.now();
82825
82830
  return this.pullConnectConfig()
82826
82831
  .then(isSuccess => isSuccess ? this.connect() : Promise.resolve(false))
82827
82832
  .then(isSuccess => {
@@ -82866,6 +82871,7 @@ class WSClient {
82866
82871
  wsInstance === null || wsInstance === void 0 ? void 0 : wsInstance.terminate();
82867
82872
  }
82868
82873
  this.wsConfig.setWSInstance(null);
82874
+ const reconnectNonceTime = reconnectNonce ? reconnectNonce * Math.random() : 0;
82869
82875
  this.reconnectInterval = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
82870
82876
  (function loopReConnect(count) {
82871
82877
  return __awaiter(this, void 0, void 0, function* () {
@@ -82885,9 +82891,11 @@ class WSClient {
82885
82891
  this.reconnectInterval = setTimeout(() => {
82886
82892
  loopReConnect.bind(this)(count);
82887
82893
  }, reconnectInterval);
82894
+ this.reconnectInfo.nextConnectTime = Date.now() + reconnectInterval;
82888
82895
  });
82889
82896
  }).bind(this)(0);
82890
- }), reconnectNonce ? reconnectNonce * Math.random() : 0);
82897
+ }), reconnectNonceTime);
82898
+ this.reconnectInfo.nextConnectTime = Date.now() + reconnectInterval;
82891
82899
  });
82892
82900
  }
82893
82901
  pingLoop() {
@@ -83004,6 +83012,9 @@ class WSClient {
83004
83012
  });
83005
83013
  }
83006
83014
  }
83015
+ getReconnectInfo() {
83016
+ return this.reconnectInfo;
83017
+ }
83007
83018
  start(params) {
83008
83019
  return __awaiter(this, void 0, void 0, function* () {
83009
83020
  this.logger.info('[ws]', `receive events or callbacks through persistent connection only available in self-build & Feishu app, Configured in:
package/lib/index.js CHANGED
@@ -82757,6 +82757,10 @@ class WSClient {
82757
82757
  constructor(params) {
82758
82758
  this.wsConfig = new WSConfig();
82759
82759
  this.isConnecting = false;
82760
+ this.reconnectInfo = {
82761
+ lastConnectTime: 0,
82762
+ nextConnectTime: 0,
82763
+ };
82760
82764
  const { appId, appSecret, domain = exports.Domain.Feishu, httpInstance = defaultHttpInstance, loggerLevel = exports.LoggerLevel.info, logger = defaultLogger, autoReconnect = true } = params;
82761
82765
  this.logger = new LoggerProxy(loggerLevel, logger);
82762
82766
  assert(!appId, () => this.logger.error('appId is needed'));
@@ -82837,6 +82841,7 @@ class WSClient {
82837
82841
  }
82838
82842
  this.isConnecting = true;
82839
82843
  const tryConnect = () => {
82844
+ this.reconnectInfo.lastConnectTime = Date.now();
82840
82845
  return this.pullConnectConfig()
82841
82846
  .then(isSuccess => isSuccess ? this.connect() : Promise.resolve(false))
82842
82847
  .then(isSuccess => {
@@ -82881,6 +82886,7 @@ class WSClient {
82881
82886
  wsInstance === null || wsInstance === void 0 ? void 0 : wsInstance.terminate();
82882
82887
  }
82883
82888
  this.wsConfig.setWSInstance(null);
82889
+ const reconnectNonceTime = reconnectNonce ? reconnectNonce * Math.random() : 0;
82884
82890
  this.reconnectInterval = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
82885
82891
  (function loopReConnect(count) {
82886
82892
  return __awaiter(this, void 0, void 0, function* () {
@@ -82900,9 +82906,11 @@ class WSClient {
82900
82906
  this.reconnectInterval = setTimeout(() => {
82901
82907
  loopReConnect.bind(this)(count);
82902
82908
  }, reconnectInterval);
82909
+ this.reconnectInfo.nextConnectTime = Date.now() + reconnectInterval;
82903
82910
  });
82904
82911
  }).bind(this)(0);
82905
- }), reconnectNonce ? reconnectNonce * Math.random() : 0);
82912
+ }), reconnectNonceTime);
82913
+ this.reconnectInfo.nextConnectTime = Date.now() + reconnectInterval;
82906
82914
  });
82907
82915
  }
82908
82916
  pingLoop() {
@@ -83019,6 +83027,9 @@ class WSClient {
83019
83027
  });
83020
83028
  }
83021
83029
  }
83030
+ getReconnectInfo() {
83031
+ return this.reconnectInfo;
83032
+ }
83022
83033
  start(params) {
83023
83034
  return __awaiter(this, void 0, void 0, function* () {
83024
83035
  this.logger.info('[ws]', `receive events or callbacks through persistent connection only available in self-build & Feishu app, Configured in:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@larksuiteoapi/node-sdk",
3
- "version": "1.49.0-alpha.0",
3
+ "version": "1.49.0-alpha.1",
4
4
  "description": "larksuite open sdk for nodejs",
5
5
  "keywords": [
6
6
  "feishu",
package/types/index.d.ts CHANGED
@@ -265919,6 +265919,7 @@ declare class WSClient {
265919
265919
  private pingInterval?;
265920
265920
  private reconnectInterval?;
265921
265921
  private isConnecting;
265922
+ private reconnectInfo;
265922
265923
  constructor(params: IConstructorParams);
265923
265924
  private pullConnectConfig;
265924
265925
  private connect;
@@ -265928,6 +265929,10 @@ declare class WSClient {
265928
265929
  private handleControlData;
265929
265930
  private handleEventData;
265930
265931
  private sendMessage;
265932
+ getReconnectInfo(): {
265933
+ lastConnectTime: number;
265934
+ nextConnectTime: number;
265935
+ };
265931
265936
  start(params: {
265932
265937
  eventDispatcher: EventDispatcher;
265933
265938
  }): Promise<void>;