@larksuiteoapi/node-sdk 1.62.1 → 1.63.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
@@ -85418,10 +85418,16 @@ class WSClient {
85418
85418
  timeout: 15000,
85419
85419
  });
85420
85420
  if (code !== ErrorCode.ok) {
85421
- this.logger.error('[ws]', `code: ${code}, ${code === ErrorCode.system_busy ? msg : 'system busy'}`);
85422
- if (code === ErrorCode.system_busy || code === ErrorCode.internal_error) {
85423
- return false;
85421
+ const reason = code === ErrorCode.system_busy ? 'system busy' : msg;
85422
+ this.logger.error('[ws]', `code: ${code}, ${reason}`);
85423
+ if (code === ErrorCode.internal_error) {
85424
+ return { ok: false, retryable: true };
85424
85425
  }
85426
+ return {
85427
+ ok: false,
85428
+ retryable: false,
85429
+ error: `pullConnectConfig failed: code=${code}, msg=${reason}`,
85430
+ };
85425
85431
  }
85426
85432
  const { device_id, service_id } = qs.parse(URL);
85427
85433
  this.wsConfig.updateWs({
@@ -85434,11 +85440,11 @@ class WSClient {
85434
85440
  reconnectNonce: ClientConfig.ReconnectNonce * 1000
85435
85441
  });
85436
85442
  this.logger.debug('[ws]', `get connect config success, ws url: ${URL}`);
85437
- return true;
85443
+ return { ok: true };
85438
85444
  }
85439
85445
  catch (e) {
85440
85446
  this.logger.error('[ws]', (e === null || e === void 0 ? void 0 : e.message) || 'system busy');
85441
- return false;
85447
+ return { ok: false, retryable: true };
85442
85448
  }
85443
85449
  });
85444
85450
  }
@@ -85477,18 +85483,17 @@ class WSClient {
85477
85483
  this.isConnecting = true;
85478
85484
  // Invalidate any in-flight reconnect loops from previous sessions
85479
85485
  const currentGeneration = ++this.reconnectGeneration;
85480
- const tryConnect = () => {
85486
+ const tryConnect = () => __awaiter(this, void 0, void 0, function* () {
85481
85487
  this.reconnectInfo.lastConnectTime = Date.now();
85482
- return this.pullConnectConfig()
85483
- .then(isSuccess => isSuccess ? this.connect() : Promise.resolve(false))
85484
- .then(isSuccess => {
85485
- if (isSuccess) {
85486
- this.communicate();
85487
- return Promise.resolve(true);
85488
- }
85489
- return Promise.resolve(false);
85490
- });
85491
- };
85488
+ const pullResult = yield this.pullConnectConfig();
85489
+ if (!pullResult.ok)
85490
+ return pullResult;
85491
+ const connected = yield this.connect();
85492
+ if (!connected)
85493
+ return { ok: false, retryable: true };
85494
+ this.communicate();
85495
+ return { ok: true };
85496
+ });
85492
85497
  if (this.pingInterval) {
85493
85498
  clearTimeout(this.pingInterval);
85494
85499
  }
@@ -85500,17 +85505,25 @@ class WSClient {
85500
85505
  if (wsInstance) {
85501
85506
  wsInstance === null || wsInstance === void 0 ? void 0 : wsInstance.terminate();
85502
85507
  }
85503
- let isSuccess = false;
85508
+ let result = { ok: false, retryable: true };
85504
85509
  try {
85505
- isSuccess = yield tryConnect();
85510
+ result = yield tryConnect();
85506
85511
  }
85507
85512
  finally {
85508
85513
  this.isConnecting = false;
85509
85514
  }
85510
- if (isSuccess) {
85515
+ if (result.ok) {
85511
85516
  this.hasEverConnected = true;
85512
85517
  this.safeInvoke('onReady', this.onReady);
85513
85518
  }
85519
+ else if (!result.retryable) {
85520
+ // Non-recoverable error from pullConnectConfig — bail out without retry.
85521
+ // Reset hasEverConnected so a subsequent start() is treated as a fresh
85522
+ // session (onReady fires, not onReconnected).
85523
+ this.hasEverConnected = false;
85524
+ this.safeInvoke('onError', this.onError, new Error(result.error));
85525
+ return;
85526
+ }
85514
85527
  else {
85515
85528
  this.logger.error('[ws]', 'connect failed');
85516
85529
  yield this.reConnect();
@@ -85542,13 +85555,13 @@ class WSClient {
85542
85555
  return;
85543
85556
  }
85544
85557
  count++;
85545
- const isSuccess = yield tryConnect();
85558
+ const result = yield tryConnect();
85546
85559
  // Re-check after async operation in case a new session started
85547
85560
  if (currentGeneration !== this.reconnectGeneration) {
85548
85561
  return;
85549
85562
  }
85550
85563
  // if reconnectCount < 0, the reconnect time is infinite
85551
- if (isSuccess) {
85564
+ if (result.ok) {
85552
85565
  this.logger.debug('[ws]', 'reconnect success');
85553
85566
  if (this.hasEverConnected) {
85554
85567
  this.safeInvoke('onReconnected', this.onReconnected);
@@ -85560,6 +85573,15 @@ class WSClient {
85560
85573
  this.isConnecting = false;
85561
85574
  return;
85562
85575
  }
85576
+ if (!result.retryable) {
85577
+ // Non-recoverable error — abort the loop, do not schedule another attempt.
85578
+ // Reset hasEverConnected so a subsequent start() is treated as a fresh
85579
+ // session (onReady fires, not onReconnected).
85580
+ this.isConnecting = false;
85581
+ this.hasEverConnected = false;
85582
+ this.safeInvoke('onError', this.onError, new Error(result.error));
85583
+ return;
85584
+ }
85563
85585
  this.logger.info('ws', `unable to connect to the server after trying ${count} times")`);
85564
85586
  if (reconnectCount >= 0 && count >= reconnectCount) {
85565
85587
  this.isConnecting = false;
@@ -89149,7 +89171,7 @@ function dispatchConvert(raw, msgType, ctx) {
89149
89171
  });
89150
89172
  }
89151
89173
 
89152
- function normalizeCardAction(event) {
89174
+ function normalizeCardAction(event, opts) {
89153
89175
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
89154
89176
  const messageId = (_b = (_a = event.context) === null || _a === void 0 ? void 0 : _a.open_message_id) !== null && _b !== void 0 ? _b : event.open_message_id;
89155
89177
  const chatId = (_d = (_c = event.context) === null || _c === void 0 ? void 0 : _c.open_chat_id) !== null && _d !== void 0 ? _d : event.open_chat_id;
@@ -89170,10 +89192,11 @@ function normalizeCardAction(event) {
89170
89192
  name: (_l = event.action) === null || _l === void 0 ? void 0 : _l.name,
89171
89193
  option: (_m = event.action) === null || _m === void 0 ? void 0 : _m.option,
89172
89194
  },
89195
+ raw: (opts === null || opts === void 0 ? void 0 : opts.includeRaw) ? event : undefined,
89173
89196
  };
89174
89197
  }
89175
89198
 
89176
- function normalizeReaction(event, action) {
89199
+ function normalizeReaction(event, action, opts) {
89177
89200
  var _a, _b, _c, _d;
89178
89201
  const messageId = event.message_id;
89179
89202
  const emojiType = (_a = event.reaction_type) === null || _a === void 0 ? void 0 : _a.emoji_type;
@@ -89191,6 +89214,7 @@ function normalizeReaction(event, action) {
89191
89214
  emojiType,
89192
89215
  action,
89193
89216
  actionTime: actionTime != null && Number.isFinite(actionTime) ? actionTime : undefined,
89217
+ raw: (opts === null || opts === void 0 ? void 0 : opts.includeRaw) ? event : undefined,
89194
89218
  };
89195
89219
  }
89196
89220
 
@@ -89637,6 +89661,7 @@ class LarkChannel {
89637
89661
  });
89638
89662
  }
89639
89663
  registerDispatcherHandlers() {
89664
+ var _a, _b;
89640
89665
  // `im.v1.message.get(mid)` on a merge_forward message returns
89641
89666
  // `data.items[]` as a flat list: the parent message first (no
89642
89667
  // `upper_message_id`) followed by every descendant, each with
@@ -89647,23 +89672,26 @@ class LarkChannel {
89647
89672
  // `container_id_type: 'message'`, which Feishu rejects — 'message'
89648
89673
  // isn't a valid container type.)
89649
89674
  const fetchSubMessages = (mid) => __awaiter(this, void 0, void 0, function* () {
89650
- var _a, _b, _c, _d;
89675
+ var _c, _d, _e, _f;
89651
89676
  try {
89652
89677
  const r = yield this.rawClient.im.v1.message.get({
89653
89678
  path: { message_id: mid },
89654
89679
  });
89655
- const items = (_b = (_a = r.data) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : [];
89680
+ const items = (_d = (_c = r.data) === null || _c === void 0 ? void 0 : _c.items) !== null && _d !== void 0 ? _d : [];
89656
89681
  return items;
89657
89682
  }
89658
89683
  catch (e) {
89659
- (_d = (_c = this.logger).warn) === null || _d === void 0 ? void 0 : _d.call(_c, 'channel: fetchSubMessages failed', e);
89684
+ (_f = (_e = this.logger).warn) === null || _f === void 0 ? void 0 : _f.call(_e, 'channel: fetchSubMessages failed', e);
89660
89685
  return [];
89661
89686
  }
89662
89687
  });
89688
+ // Unified raw-event flag: prefer the new `includeRawEvent` option,
89689
+ // fall back to the legacy `includeRawInMessage` for back-compat.
89690
+ const includeRaw = (_b = (_a = this.opts.includeRawEvent) !== null && _a !== void 0 ? _a : this.opts.includeRawInMessage) !== null && _b !== void 0 ? _b : false;
89663
89691
  const normalizeOpts = {
89664
89692
  botIdentity: this.botIdentity,
89665
89693
  stripBotMentions: true,
89666
- includeRaw: this.opts.includeRawInMessage,
89694
+ includeRaw,
89667
89695
  fetchSubMessages,
89668
89696
  };
89669
89697
  this.dispatcher.register({
@@ -89683,7 +89711,7 @@ class LarkChannel {
89683
89711
  // collapsed by the dedup cache. A genuine Feishu re-delivery
89684
89712
  // of the same click still hashes to the same key.
89685
89713
  'card.action.trigger': (raw) => __awaiter(this, void 0, void 0, function* () {
89686
- const evt = normalizeCardAction(raw);
89714
+ const evt = normalizeCardAction(raw, { includeRaw });
89687
89715
  if (!evt)
89688
89716
  return;
89689
89717
  const actionId = cardActionId(evt.action);
@@ -89695,14 +89723,14 @@ class LarkChannel {
89695
89723
  }),
89696
89724
  // Reactions — dedup only
89697
89725
  'im.message.reaction.created_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
89698
- const evt = normalizeReaction(raw, 'added');
89726
+ const evt = normalizeReaction(raw, 'added', { includeRaw });
89699
89727
  if (!evt)
89700
89728
  return;
89701
89729
  const key = reactionKey(evt);
89702
89730
  yield this.safety.pushLight(key, () => { var _a, _b; return (_b = (_a = this.handlers).reaction) === null || _b === void 0 ? void 0 : _b.call(_a, evt); });
89703
89731
  }),
89704
89732
  'im.message.reaction.deleted_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
89705
- const evt = normalizeReaction(raw, 'removed');
89733
+ const evt = normalizeReaction(raw, 'removed', { includeRaw });
89706
89734
  if (!evt)
89707
89735
  return;
89708
89736
  const key = reactionKey(evt);
@@ -89711,9 +89739,7 @@ class LarkChannel {
89711
89739
  // Bot added — direct fire, no safety
89712
89740
  'im.chat.member.bot.added_v1': (raw) => {
89713
89741
  var _a, _b;
89714
- const evt = normalizeBotAdded(raw, {
89715
- includeRaw: this.opts.includeRawInMessage,
89716
- });
89742
+ const evt = normalizeBotAdded(raw, { includeRaw });
89717
89743
  if (!evt)
89718
89744
  return;
89719
89745
  try {
@@ -89725,9 +89751,7 @@ class LarkChannel {
89725
89751
  },
89726
89752
  // Drive comments — dedup + lock + queue (by fileToken)
89727
89753
  'drive.notice.comment_add_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
89728
- const evt = normalizeComment(raw, {
89729
- includeRaw: this.opts.includeRawInMessage,
89730
- });
89754
+ const evt = normalizeComment(raw, { includeRaw });
89731
89755
  if (!evt)
89732
89756
  return;
89733
89757
  yield this.safety.pushAction(`comment:${evt.fileToken}:${evt.commentId}`, evt.fileToken, () => __awaiter(this, void 0, void 0, function* () {
package/lib/index.js CHANGED
@@ -85436,10 +85436,16 @@ class WSClient {
85436
85436
  timeout: 15000,
85437
85437
  });
85438
85438
  if (code !== ErrorCode.ok) {
85439
- this.logger.error('[ws]', `code: ${code}, ${code === ErrorCode.system_busy ? msg : 'system busy'}`);
85440
- if (code === ErrorCode.system_busy || code === ErrorCode.internal_error) {
85441
- return false;
85439
+ const reason = code === ErrorCode.system_busy ? 'system busy' : msg;
85440
+ this.logger.error('[ws]', `code: ${code}, ${reason}`);
85441
+ if (code === ErrorCode.internal_error) {
85442
+ return { ok: false, retryable: true };
85442
85443
  }
85444
+ return {
85445
+ ok: false,
85446
+ retryable: false,
85447
+ error: `pullConnectConfig failed: code=${code}, msg=${reason}`,
85448
+ };
85443
85449
  }
85444
85450
  const { device_id, service_id } = qs__default["default"].parse(URL);
85445
85451
  this.wsConfig.updateWs({
@@ -85452,11 +85458,11 @@ class WSClient {
85452
85458
  reconnectNonce: ClientConfig.ReconnectNonce * 1000
85453
85459
  });
85454
85460
  this.logger.debug('[ws]', `get connect config success, ws url: ${URL}`);
85455
- return true;
85461
+ return { ok: true };
85456
85462
  }
85457
85463
  catch (e) {
85458
85464
  this.logger.error('[ws]', (e === null || e === void 0 ? void 0 : e.message) || 'system busy');
85459
- return false;
85465
+ return { ok: false, retryable: true };
85460
85466
  }
85461
85467
  });
85462
85468
  }
@@ -85495,18 +85501,17 @@ class WSClient {
85495
85501
  this.isConnecting = true;
85496
85502
  // Invalidate any in-flight reconnect loops from previous sessions
85497
85503
  const currentGeneration = ++this.reconnectGeneration;
85498
- const tryConnect = () => {
85504
+ const tryConnect = () => __awaiter(this, void 0, void 0, function* () {
85499
85505
  this.reconnectInfo.lastConnectTime = Date.now();
85500
- return this.pullConnectConfig()
85501
- .then(isSuccess => isSuccess ? this.connect() : Promise.resolve(false))
85502
- .then(isSuccess => {
85503
- if (isSuccess) {
85504
- this.communicate();
85505
- return Promise.resolve(true);
85506
- }
85507
- return Promise.resolve(false);
85508
- });
85509
- };
85506
+ const pullResult = yield this.pullConnectConfig();
85507
+ if (!pullResult.ok)
85508
+ return pullResult;
85509
+ const connected = yield this.connect();
85510
+ if (!connected)
85511
+ return { ok: false, retryable: true };
85512
+ this.communicate();
85513
+ return { ok: true };
85514
+ });
85510
85515
  if (this.pingInterval) {
85511
85516
  clearTimeout(this.pingInterval);
85512
85517
  }
@@ -85518,17 +85523,25 @@ class WSClient {
85518
85523
  if (wsInstance) {
85519
85524
  wsInstance === null || wsInstance === void 0 ? void 0 : wsInstance.terminate();
85520
85525
  }
85521
- let isSuccess = false;
85526
+ let result = { ok: false, retryable: true };
85522
85527
  try {
85523
- isSuccess = yield tryConnect();
85528
+ result = yield tryConnect();
85524
85529
  }
85525
85530
  finally {
85526
85531
  this.isConnecting = false;
85527
85532
  }
85528
- if (isSuccess) {
85533
+ if (result.ok) {
85529
85534
  this.hasEverConnected = true;
85530
85535
  this.safeInvoke('onReady', this.onReady);
85531
85536
  }
85537
+ else if (!result.retryable) {
85538
+ // Non-recoverable error from pullConnectConfig — bail out without retry.
85539
+ // Reset hasEverConnected so a subsequent start() is treated as a fresh
85540
+ // session (onReady fires, not onReconnected).
85541
+ this.hasEverConnected = false;
85542
+ this.safeInvoke('onError', this.onError, new Error(result.error));
85543
+ return;
85544
+ }
85532
85545
  else {
85533
85546
  this.logger.error('[ws]', 'connect failed');
85534
85547
  yield this.reConnect();
@@ -85560,13 +85573,13 @@ class WSClient {
85560
85573
  return;
85561
85574
  }
85562
85575
  count++;
85563
- const isSuccess = yield tryConnect();
85576
+ const result = yield tryConnect();
85564
85577
  // Re-check after async operation in case a new session started
85565
85578
  if (currentGeneration !== this.reconnectGeneration) {
85566
85579
  return;
85567
85580
  }
85568
85581
  // if reconnectCount < 0, the reconnect time is infinite
85569
- if (isSuccess) {
85582
+ if (result.ok) {
85570
85583
  this.logger.debug('[ws]', 'reconnect success');
85571
85584
  if (this.hasEverConnected) {
85572
85585
  this.safeInvoke('onReconnected', this.onReconnected);
@@ -85578,6 +85591,15 @@ class WSClient {
85578
85591
  this.isConnecting = false;
85579
85592
  return;
85580
85593
  }
85594
+ if (!result.retryable) {
85595
+ // Non-recoverable error — abort the loop, do not schedule another attempt.
85596
+ // Reset hasEverConnected so a subsequent start() is treated as a fresh
85597
+ // session (onReady fires, not onReconnected).
85598
+ this.isConnecting = false;
85599
+ this.hasEverConnected = false;
85600
+ this.safeInvoke('onError', this.onError, new Error(result.error));
85601
+ return;
85602
+ }
85581
85603
  this.logger.info('ws', `unable to connect to the server after trying ${count} times")`);
85582
85604
  if (reconnectCount >= 0 && count >= reconnectCount) {
85583
85605
  this.isConnecting = false;
@@ -89167,7 +89189,7 @@ function dispatchConvert(raw, msgType, ctx) {
89167
89189
  });
89168
89190
  }
89169
89191
 
89170
- function normalizeCardAction(event) {
89192
+ function normalizeCardAction(event, opts) {
89171
89193
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
89172
89194
  const messageId = (_b = (_a = event.context) === null || _a === void 0 ? void 0 : _a.open_message_id) !== null && _b !== void 0 ? _b : event.open_message_id;
89173
89195
  const chatId = (_d = (_c = event.context) === null || _c === void 0 ? void 0 : _c.open_chat_id) !== null && _d !== void 0 ? _d : event.open_chat_id;
@@ -89188,10 +89210,11 @@ function normalizeCardAction(event) {
89188
89210
  name: (_l = event.action) === null || _l === void 0 ? void 0 : _l.name,
89189
89211
  option: (_m = event.action) === null || _m === void 0 ? void 0 : _m.option,
89190
89212
  },
89213
+ raw: (opts === null || opts === void 0 ? void 0 : opts.includeRaw) ? event : undefined,
89191
89214
  };
89192
89215
  }
89193
89216
 
89194
- function normalizeReaction(event, action) {
89217
+ function normalizeReaction(event, action, opts) {
89195
89218
  var _a, _b, _c, _d;
89196
89219
  const messageId = event.message_id;
89197
89220
  const emojiType = (_a = event.reaction_type) === null || _a === void 0 ? void 0 : _a.emoji_type;
@@ -89209,6 +89232,7 @@ function normalizeReaction(event, action) {
89209
89232
  emojiType,
89210
89233
  action,
89211
89234
  actionTime: actionTime != null && Number.isFinite(actionTime) ? actionTime : undefined,
89235
+ raw: (opts === null || opts === void 0 ? void 0 : opts.includeRaw) ? event : undefined,
89212
89236
  };
89213
89237
  }
89214
89238
 
@@ -89655,6 +89679,7 @@ class LarkChannel {
89655
89679
  });
89656
89680
  }
89657
89681
  registerDispatcherHandlers() {
89682
+ var _a, _b;
89658
89683
  // `im.v1.message.get(mid)` on a merge_forward message returns
89659
89684
  // `data.items[]` as a flat list: the parent message first (no
89660
89685
  // `upper_message_id`) followed by every descendant, each with
@@ -89665,23 +89690,26 @@ class LarkChannel {
89665
89690
  // `container_id_type: 'message'`, which Feishu rejects — 'message'
89666
89691
  // isn't a valid container type.)
89667
89692
  const fetchSubMessages = (mid) => __awaiter(this, void 0, void 0, function* () {
89668
- var _a, _b, _c, _d;
89693
+ var _c, _d, _e, _f;
89669
89694
  try {
89670
89695
  const r = yield this.rawClient.im.v1.message.get({
89671
89696
  path: { message_id: mid },
89672
89697
  });
89673
- const items = (_b = (_a = r.data) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : [];
89698
+ const items = (_d = (_c = r.data) === null || _c === void 0 ? void 0 : _c.items) !== null && _d !== void 0 ? _d : [];
89674
89699
  return items;
89675
89700
  }
89676
89701
  catch (e) {
89677
- (_d = (_c = this.logger).warn) === null || _d === void 0 ? void 0 : _d.call(_c, 'channel: fetchSubMessages failed', e);
89702
+ (_f = (_e = this.logger).warn) === null || _f === void 0 ? void 0 : _f.call(_e, 'channel: fetchSubMessages failed', e);
89678
89703
  return [];
89679
89704
  }
89680
89705
  });
89706
+ // Unified raw-event flag: prefer the new `includeRawEvent` option,
89707
+ // fall back to the legacy `includeRawInMessage` for back-compat.
89708
+ const includeRaw = (_b = (_a = this.opts.includeRawEvent) !== null && _a !== void 0 ? _a : this.opts.includeRawInMessage) !== null && _b !== void 0 ? _b : false;
89681
89709
  const normalizeOpts = {
89682
89710
  botIdentity: this.botIdentity,
89683
89711
  stripBotMentions: true,
89684
- includeRaw: this.opts.includeRawInMessage,
89712
+ includeRaw,
89685
89713
  fetchSubMessages,
89686
89714
  };
89687
89715
  this.dispatcher.register({
@@ -89701,7 +89729,7 @@ class LarkChannel {
89701
89729
  // collapsed by the dedup cache. A genuine Feishu re-delivery
89702
89730
  // of the same click still hashes to the same key.
89703
89731
  'card.action.trigger': (raw) => __awaiter(this, void 0, void 0, function* () {
89704
- const evt = normalizeCardAction(raw);
89732
+ const evt = normalizeCardAction(raw, { includeRaw });
89705
89733
  if (!evt)
89706
89734
  return;
89707
89735
  const actionId = cardActionId(evt.action);
@@ -89713,14 +89741,14 @@ class LarkChannel {
89713
89741
  }),
89714
89742
  // Reactions — dedup only
89715
89743
  'im.message.reaction.created_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
89716
- const evt = normalizeReaction(raw, 'added');
89744
+ const evt = normalizeReaction(raw, 'added', { includeRaw });
89717
89745
  if (!evt)
89718
89746
  return;
89719
89747
  const key = reactionKey(evt);
89720
89748
  yield this.safety.pushLight(key, () => { var _a, _b; return (_b = (_a = this.handlers).reaction) === null || _b === void 0 ? void 0 : _b.call(_a, evt); });
89721
89749
  }),
89722
89750
  'im.message.reaction.deleted_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
89723
- const evt = normalizeReaction(raw, 'removed');
89751
+ const evt = normalizeReaction(raw, 'removed', { includeRaw });
89724
89752
  if (!evt)
89725
89753
  return;
89726
89754
  const key = reactionKey(evt);
@@ -89729,9 +89757,7 @@ class LarkChannel {
89729
89757
  // Bot added — direct fire, no safety
89730
89758
  'im.chat.member.bot.added_v1': (raw) => {
89731
89759
  var _a, _b;
89732
- const evt = normalizeBotAdded(raw, {
89733
- includeRaw: this.opts.includeRawInMessage,
89734
- });
89760
+ const evt = normalizeBotAdded(raw, { includeRaw });
89735
89761
  if (!evt)
89736
89762
  return;
89737
89763
  try {
@@ -89743,9 +89769,7 @@ class LarkChannel {
89743
89769
  },
89744
89770
  // Drive comments — dedup + lock + queue (by fileToken)
89745
89771
  'drive.notice.comment_add_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
89746
- const evt = normalizeComment(raw, {
89747
- includeRaw: this.opts.includeRawInMessage,
89748
- });
89772
+ const evt = normalizeComment(raw, { includeRaw });
89749
89773
  if (!evt)
89750
89774
  return;
89751
89775
  yield this.safety.pushAction(`comment:${evt.fileToken}:${evt.commentId}`, evt.fileToken, () => __awaiter(this, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@larksuiteoapi/node-sdk",
3
- "version": "1.62.1",
3
+ "version": "1.63.0",
4
4
  "description": "larksuite open sdk for nodejs",
5
5
  "keywords": [
6
6
  "feishu",
package/types/index.d.ts CHANGED
@@ -293069,6 +293069,7 @@ interface IConstructorParams {
293069
293069
  /** Fires after the reconnect loop successfully re-establishes the connection. */
293070
293070
  onReconnected?: () => void;
293071
293071
  }
293072
+
293072
293073
  declare class WSClient {
293073
293074
  private wsConfig;
293074
293075
  private logger;
@@ -293411,6 +293412,7 @@ interface CardActionEvent {
293411
293412
  name?: string;
293412
293413
  option?: string;
293413
293414
  };
293415
+ raw?: unknown;
293414
293416
  }
293415
293417
  interface ReactionEvent {
293416
293418
  messageId: string;
@@ -293421,6 +293423,7 @@ interface ReactionEvent {
293421
293423
  emojiType: string;
293422
293424
  action: 'added' | 'removed';
293423
293425
  actionTime?: number;
293426
+ raw?: unknown;
293424
293427
  }
293425
293428
  interface BotAddedEvent {
293426
293429
  chatId: string;
@@ -293480,6 +293483,15 @@ interface LarkChannelOptions {
293480
293483
  httpInstance?: HttpInstance;
293481
293484
  /** Caller tag appended to User-Agent as `source/<name>`. */
293482
293485
  source?: string;
293486
+ /**
293487
+ * Attach the raw Feishu event body on every normalized event
293488
+ * (`message`, `cardAction`, `reaction`, `botAdded`, `comment`) as
293489
+ * `evt.raw`. Useful when a handler needs fields that the normalizer
293490
+ * dropped (e.g. `tenant_key`, `host`, `event_id`, vendor-specific
293491
+ * extensions). Off by default — payloads are smaller and stricter.
293492
+ */
293493
+ includeRawEvent?: boolean;
293494
+ /** @deprecated Use `includeRawEvent` instead. Retained for backward compatibility. */
293483
293495
  includeRawInMessage?: boolean;
293484
293496
  }
293485
293497
  interface WebhookOptions {
@@ -293703,7 +293715,9 @@ interface RawCardActionEvent {
293703
293715
  timezone?: string;
293704
293716
  };
293705
293717
  }
293706
- declare function normalizeCardAction(event: RawCardActionEvent): CardActionEvent | null;
293718
+ declare function normalizeCardAction(event: RawCardActionEvent, opts?: {
293719
+ includeRaw?: boolean;
293720
+ }): CardActionEvent | null;
293707
293721
 
293708
293722
  interface RawReactionEvent {
293709
293723
  message_id?: string;
@@ -293718,7 +293732,9 @@ interface RawReactionEvent {
293718
293732
  };
293719
293733
  action_time?: string;
293720
293734
  }
293721
- declare function normalizeReaction(event: RawReactionEvent, action: 'added' | 'removed'): ReactionEvent | null;
293735
+ declare function normalizeReaction(event: RawReactionEvent, action: 'added' | 'removed', opts?: {
293736
+ includeRaw?: boolean;
293737
+ }): ReactionEvent | null;
293722
293738
 
293723
293739
  interface RawBotAddedEvent {
293724
293740
  chat_id?: string;