@larksuiteoapi/node-sdk 1.48.0-alpha.1 → 1.48.0-alpha.2
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 +9 -4
- package/lib/index.js +9 -4
- 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,6 +81540,8 @@ 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) {
|
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,6 +81555,8 @@ 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) {
|
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;
|