@larksuiteoapi/node-sdk 1.57.0-beta.1 → 1.58.0

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
@@ -83983,17 +83983,16 @@ class Client extends Client$1 {
83983
83983
  const helpDeskCredential = string2Base64(`${this.helpDeskId}:${this.helpDeskToken}`);
83984
83984
  targetOptions.headers['X-Lark-Helpdesk-Authorization'] = `Bearer ${helpDeskCredential}`;
83985
83985
  }
83986
- const payloadData = Object.assign(Object.assign({}, ((payload === null || payload === void 0 ? void 0 : payload.data) || {})), targetOptions.data);
83987
83986
  return {
83988
83987
  params: Object.assign(Object.assign({}, ((payload === null || payload === void 0 ? void 0 : payload.params) || {})), targetOptions.params),
83989
83988
  headers: Object.assign(Object.assign({ 'User-Agent': 'oapi-node-sdk/1.0.0' }, ((payload === null || payload === void 0 ? void 0 : payload.headers) || {})), targetOptions.headers),
83990
- // @ts-ignore
83991
- data: Object.keys(payloadData).length === 0 ? undefined : payloadData,
83989
+ data: Object.assign(Object.assign({}, ((payload === null || payload === void 0 ? void 0 : payload.data) || {})), targetOptions.data),
83992
83990
  path: Object.assign(Object.assign({}, ((payload === null || payload === void 0 ? void 0 : payload.path) || {})), targetOptions.path),
83993
83991
  };
83994
83992
  });
83995
83993
  }
83996
83994
  request(payload, options) {
83995
+ var _a;
83997
83996
  return __awaiter(this, void 0, void 0, function* () {
83998
83997
  const { data, params, headers, url } = payload, rest = __rest(payload, ["data", "params", "headers", "url"]);
83999
83998
  const formatPayload = yield this.formatPayload({
@@ -84001,6 +84000,8 @@ class Client extends Client$1 {
84001
84000
  params,
84002
84001
  headers,
84003
84002
  }, options);
84003
+ // fix: #153
84004
+ const targetData = (((_a = payload.method) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'get' && Object.keys(formatPayload.data).length === 0) ? undefined : formatPayload.data;
84004
84005
  this.logger.trace(`send request [${payload.method}]: ${payload.url}`);
84005
84006
  const res = yield this.httpInstance
84006
84007
  .request(Object.assign(Object.assign({}, rest), {
@@ -84008,7 +84009,7 @@ class Client extends Client$1 {
84008
84009
  ? url
84009
84010
  : `${this.domain}/${formatUrl(url)}`,
84010
84011
  headers: formatPayload.headers,
84011
- data: formatPayload.data,
84012
+ data: targetData,
84012
84013
  params: formatPayload.params,
84013
84014
  }))
84014
84015
  .catch((e) => {
@@ -85570,6 +85571,35 @@ class WSClient {
85570
85571
  getReconnectInfo() {
85571
85572
  return this.reconnectInfo;
85572
85573
  }
85574
+ /**
85575
+ * close connection
85576
+ * @param params close params
85577
+ * @param params.force whether force close (use terminate instead of close)
85578
+ */
85579
+ close(params = {}) {
85580
+ const { force = false } = params;
85581
+ if (this.pingInterval) {
85582
+ clearTimeout(this.pingInterval);
85583
+ this.pingInterval = undefined;
85584
+ }
85585
+ if (this.reconnectInterval) {
85586
+ clearTimeout(this.reconnectInterval);
85587
+ this.reconnectInterval = undefined;
85588
+ }
85589
+ this.isConnecting = false;
85590
+ const wsInstance = this.wsConfig.getWSInstance();
85591
+ if (wsInstance) {
85592
+ wsInstance.removeAllListeners();
85593
+ if (force) {
85594
+ wsInstance.terminate();
85595
+ }
85596
+ else {
85597
+ wsInstance.close();
85598
+ }
85599
+ this.wsConfig.setWSInstance(null);
85600
+ }
85601
+ this.logger.info('[ws]', `ws client closed manually${force ? ' (force)' : ''}`);
85602
+ }
85573
85603
  start(params) {
85574
85604
  return __awaiter(this, void 0, void 0, function* () {
85575
85605
  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
@@ -83998,17 +83998,16 @@ class Client extends Client$1 {
83998
83998
  const helpDeskCredential = string2Base64(`${this.helpDeskId}:${this.helpDeskToken}`);
83999
83999
  targetOptions.headers['X-Lark-Helpdesk-Authorization'] = `Bearer ${helpDeskCredential}`;
84000
84000
  }
84001
- const payloadData = Object.assign(Object.assign({}, ((payload === null || payload === void 0 ? void 0 : payload.data) || {})), targetOptions.data);
84002
84001
  return {
84003
84002
  params: Object.assign(Object.assign({}, ((payload === null || payload === void 0 ? void 0 : payload.params) || {})), targetOptions.params),
84004
84003
  headers: Object.assign(Object.assign({ 'User-Agent': 'oapi-node-sdk/1.0.0' }, ((payload === null || payload === void 0 ? void 0 : payload.headers) || {})), targetOptions.headers),
84005
- // @ts-ignore
84006
- data: Object.keys(payloadData).length === 0 ? undefined : payloadData,
84004
+ data: Object.assign(Object.assign({}, ((payload === null || payload === void 0 ? void 0 : payload.data) || {})), targetOptions.data),
84007
84005
  path: Object.assign(Object.assign({}, ((payload === null || payload === void 0 ? void 0 : payload.path) || {})), targetOptions.path),
84008
84006
  };
84009
84007
  });
84010
84008
  }
84011
84009
  request(payload, options) {
84010
+ var _a;
84012
84011
  return __awaiter(this, void 0, void 0, function* () {
84013
84012
  const { data, params, headers, url } = payload, rest = __rest(payload, ["data", "params", "headers", "url"]);
84014
84013
  const formatPayload = yield this.formatPayload({
@@ -84016,6 +84015,8 @@ class Client extends Client$1 {
84016
84015
  params,
84017
84016
  headers,
84018
84017
  }, options);
84018
+ // fix: #153
84019
+ const targetData = (((_a = payload.method) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'get' && Object.keys(formatPayload.data).length === 0) ? undefined : formatPayload.data;
84019
84020
  this.logger.trace(`send request [${payload.method}]: ${payload.url}`);
84020
84021
  const res = yield this.httpInstance
84021
84022
  .request(Object.assign(Object.assign({}, rest), {
@@ -84023,7 +84024,7 @@ class Client extends Client$1 {
84023
84024
  ? url
84024
84025
  : `${this.domain}/${formatUrl(url)}`,
84025
84026
  headers: formatPayload.headers,
84026
- data: formatPayload.data,
84027
+ data: targetData,
84027
84028
  params: formatPayload.params,
84028
84029
  }))
84029
84030
  .catch((e) => {
@@ -85585,6 +85586,35 @@ class WSClient {
85585
85586
  getReconnectInfo() {
85586
85587
  return this.reconnectInfo;
85587
85588
  }
85589
+ /**
85590
+ * close connection
85591
+ * @param params close params
85592
+ * @param params.force whether force close (use terminate instead of close)
85593
+ */
85594
+ close(params = {}) {
85595
+ const { force = false } = params;
85596
+ if (this.pingInterval) {
85597
+ clearTimeout(this.pingInterval);
85598
+ this.pingInterval = undefined;
85599
+ }
85600
+ if (this.reconnectInterval) {
85601
+ clearTimeout(this.reconnectInterval);
85602
+ this.reconnectInterval = undefined;
85603
+ }
85604
+ this.isConnecting = false;
85605
+ const wsInstance = this.wsConfig.getWSInstance();
85606
+ if (wsInstance) {
85607
+ wsInstance.removeAllListeners();
85608
+ if (force) {
85609
+ wsInstance.terminate();
85610
+ }
85611
+ else {
85612
+ wsInstance.close();
85613
+ }
85614
+ this.wsConfig.setWSInstance(null);
85615
+ }
85616
+ this.logger.info('[ws]', `ws client closed manually${force ? ' (force)' : ''}`);
85617
+ }
85588
85618
  start(params) {
85589
85619
  return __awaiter(this, void 0, void 0, function* () {
85590
85620
  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.57.0-beta.1",
3
+ "version": "1.58.0",
4
4
  "description": "larksuite open sdk for nodejs",
5
5
  "keywords": [
6
6
  "feishu",
package/types/index.d.ts CHANGED
@@ -293072,6 +293072,14 @@ declare class WSClient {
293072
293072
  lastConnectTime: number;
293073
293073
  nextConnectTime: number;
293074
293074
  };
293075
+ /**
293076
+ * close connection
293077
+ * @param params close params
293078
+ * @param params.force whether force close (use terminate instead of close)
293079
+ */
293080
+ close(params?: {
293081
+ force?: boolean;
293082
+ }): void;
293075
293083
  start(params: {
293076
293084
  eventDispatcher: EventDispatcher;
293077
293085
  }): Promise<void>;