@larksuiteoapi/node-sdk 1.48.0-alpha.1 → 1.48.0-alpha.3
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 +13 -5
- package/lib/index.js +13 -5
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
package/es/index.js
CHANGED
|
@@ -98,10 +98,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
98
98
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
const defaultHttpInstance = axios.create(
|
|
102
|
-
maxBodyLength: Infinity,
|
|
103
|
-
maxContentLength: Infinity,
|
|
104
|
-
});
|
|
101
|
+
const defaultHttpInstance = axios.create();
|
|
105
102
|
defaultHttpInstance.interceptors.request.use((req) => {
|
|
106
103
|
if (req.headers) {
|
|
107
104
|
req.headers['User-Agent'] = 'oapi-node-sdk/1.0.0';
|
|
@@ -81454,6 +81451,7 @@ var HttpStatusCode;
|
|
|
81454
81451
|
class WSClient {
|
|
81455
81452
|
constructor(params) {
|
|
81456
81453
|
this.wsConfig = new WSConfig();
|
|
81454
|
+
this.isConnecting = false;
|
|
81457
81455
|
const { appId, appSecret, domain = Domain.Feishu, httpInstance = defaultHttpInstance, loggerLevel = LoggerLevel.info, logger = defaultLogger, autoReconnect = true } = params;
|
|
81458
81456
|
this.logger = new LoggerProxy(loggerLevel, logger);
|
|
81459
81457
|
assert(!appId, () => this.logger.error('appId is needed'));
|
|
@@ -81528,6 +81526,11 @@ class WSClient {
|
|
|
81528
81526
|
}
|
|
81529
81527
|
reConnect(isStart = false) {
|
|
81530
81528
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81529
|
+
if (this.isConnecting) {
|
|
81530
|
+
this.logger.debug('[ws]', 'repeat connection');
|
|
81531
|
+
return;
|
|
81532
|
+
}
|
|
81533
|
+
this.isConnecting = true;
|
|
81531
81534
|
const tryConnect = () => {
|
|
81532
81535
|
return this.pullConnectConfig()
|
|
81533
81536
|
.then(isSuccess => isSuccess ? this.connect() : Promise.resolve(false))
|
|
@@ -81537,12 +81540,18 @@ class WSClient {
|
|
|
81537
81540
|
return Promise.resolve(true);
|
|
81538
81541
|
}
|
|
81539
81542
|
return Promise.resolve(false);
|
|
81543
|
+
}).finally(() => {
|
|
81544
|
+
this.isConnecting = false;
|
|
81540
81545
|
});
|
|
81541
81546
|
};
|
|
81542
81547
|
if (this.pingInterval) {
|
|
81543
81548
|
clearTimeout(this.pingInterval);
|
|
81544
81549
|
}
|
|
81550
|
+
const wsInstance = this.wsConfig.getWSInstance();
|
|
81545
81551
|
if (isStart) {
|
|
81552
|
+
if (wsInstance) {
|
|
81553
|
+
wsInstance === null || wsInstance === void 0 ? void 0 : wsInstance.terminate();
|
|
81554
|
+
}
|
|
81546
81555
|
const isSuccess = yield tryConnect();
|
|
81547
81556
|
if (!isSuccess) {
|
|
81548
81557
|
this.logger.error('[ws]', 'connect failed');
|
|
@@ -81551,7 +81560,6 @@ class WSClient {
|
|
|
81551
81560
|
this.logger.info('[ws]', 'ws client ready');
|
|
81552
81561
|
return;
|
|
81553
81562
|
}
|
|
81554
|
-
const wsInstance = this.wsConfig.getWSInstance();
|
|
81555
81563
|
const { autoReconnect, reconnectNonce, reconnectCount, reconnectInterval } = this.wsConfig.getWS();
|
|
81556
81564
|
if (!autoReconnect) {
|
|
81557
81565
|
return;
|
package/lib/index.js
CHANGED
|
@@ -113,10 +113,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
113
113
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
-
const defaultHttpInstance = axios__default["default"].create(
|
|
117
|
-
maxBodyLength: Infinity,
|
|
118
|
-
maxContentLength: Infinity,
|
|
119
|
-
});
|
|
116
|
+
const defaultHttpInstance = axios__default["default"].create();
|
|
120
117
|
defaultHttpInstance.interceptors.request.use((req) => {
|
|
121
118
|
if (req.headers) {
|
|
122
119
|
req.headers['User-Agent'] = 'oapi-node-sdk/1.0.0';
|
|
@@ -81469,6 +81466,7 @@ var HttpStatusCode;
|
|
|
81469
81466
|
class WSClient {
|
|
81470
81467
|
constructor(params) {
|
|
81471
81468
|
this.wsConfig = new WSConfig();
|
|
81469
|
+
this.isConnecting = false;
|
|
81472
81470
|
const { appId, appSecret, domain = exports.Domain.Feishu, httpInstance = defaultHttpInstance, loggerLevel = exports.LoggerLevel.info, logger = defaultLogger, autoReconnect = true } = params;
|
|
81473
81471
|
this.logger = new LoggerProxy(loggerLevel, logger);
|
|
81474
81472
|
assert(!appId, () => this.logger.error('appId is needed'));
|
|
@@ -81543,6 +81541,11 @@ class WSClient {
|
|
|
81543
81541
|
}
|
|
81544
81542
|
reConnect(isStart = false) {
|
|
81545
81543
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81544
|
+
if (this.isConnecting) {
|
|
81545
|
+
this.logger.debug('[ws]', 'repeat connection');
|
|
81546
|
+
return;
|
|
81547
|
+
}
|
|
81548
|
+
this.isConnecting = true;
|
|
81546
81549
|
const tryConnect = () => {
|
|
81547
81550
|
return this.pullConnectConfig()
|
|
81548
81551
|
.then(isSuccess => isSuccess ? this.connect() : Promise.resolve(false))
|
|
@@ -81552,12 +81555,18 @@ class WSClient {
|
|
|
81552
81555
|
return Promise.resolve(true);
|
|
81553
81556
|
}
|
|
81554
81557
|
return Promise.resolve(false);
|
|
81558
|
+
}).finally(() => {
|
|
81559
|
+
this.isConnecting = false;
|
|
81555
81560
|
});
|
|
81556
81561
|
};
|
|
81557
81562
|
if (this.pingInterval) {
|
|
81558
81563
|
clearTimeout(this.pingInterval);
|
|
81559
81564
|
}
|
|
81565
|
+
const wsInstance = this.wsConfig.getWSInstance();
|
|
81560
81566
|
if (isStart) {
|
|
81567
|
+
if (wsInstance) {
|
|
81568
|
+
wsInstance === null || wsInstance === void 0 ? void 0 : wsInstance.terminate();
|
|
81569
|
+
}
|
|
81561
81570
|
const isSuccess = yield tryConnect();
|
|
81562
81571
|
if (!isSuccess) {
|
|
81563
81572
|
this.logger.error('[ws]', 'connect failed');
|
|
@@ -81566,7 +81575,6 @@ class WSClient {
|
|
|
81566
81575
|
this.logger.info('[ws]', 'ws client ready');
|
|
81567
81576
|
return;
|
|
81568
81577
|
}
|
|
81569
|
-
const wsInstance = this.wsConfig.getWSInstance();
|
|
81570
81578
|
const { autoReconnect, reconnectNonce, reconnectCount, reconnectInterval } = this.wsConfig.getWS();
|
|
81571
81579
|
if (!autoReconnect) {
|
|
81572
81580
|
return;
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -259732,6 +259732,7 @@ declare class WSClient {
|
|
|
259732
259732
|
private httpInstance;
|
|
259733
259733
|
private eventDispatcher?;
|
|
259734
259734
|
private pingInterval?;
|
|
259735
|
+
private isConnecting;
|
|
259735
259736
|
constructor(params: IConstructorParams);
|
|
259736
259737
|
private pullConnectConfig;
|
|
259737
259738
|
private connect;
|