@larksuiteoapi/node-sdk 1.62.1 → 1.62.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 CHANGED
@@ -89149,7 +89149,7 @@ function dispatchConvert(raw, msgType, ctx) {
89149
89149
  });
89150
89150
  }
89151
89151
 
89152
- function normalizeCardAction(event) {
89152
+ function normalizeCardAction(event, opts) {
89153
89153
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
89154
89154
  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
89155
  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 +89170,11 @@ function normalizeCardAction(event) {
89170
89170
  name: (_l = event.action) === null || _l === void 0 ? void 0 : _l.name,
89171
89171
  option: (_m = event.action) === null || _m === void 0 ? void 0 : _m.option,
89172
89172
  },
89173
+ raw: (opts === null || opts === void 0 ? void 0 : opts.includeRaw) ? event : undefined,
89173
89174
  };
89174
89175
  }
89175
89176
 
89176
- function normalizeReaction(event, action) {
89177
+ function normalizeReaction(event, action, opts) {
89177
89178
  var _a, _b, _c, _d;
89178
89179
  const messageId = event.message_id;
89179
89180
  const emojiType = (_a = event.reaction_type) === null || _a === void 0 ? void 0 : _a.emoji_type;
@@ -89191,6 +89192,7 @@ function normalizeReaction(event, action) {
89191
89192
  emojiType,
89192
89193
  action,
89193
89194
  actionTime: actionTime != null && Number.isFinite(actionTime) ? actionTime : undefined,
89195
+ raw: (opts === null || opts === void 0 ? void 0 : opts.includeRaw) ? event : undefined,
89194
89196
  };
89195
89197
  }
89196
89198
 
@@ -89637,6 +89639,7 @@ class LarkChannel {
89637
89639
  });
89638
89640
  }
89639
89641
  registerDispatcherHandlers() {
89642
+ var _a, _b;
89640
89643
  // `im.v1.message.get(mid)` on a merge_forward message returns
89641
89644
  // `data.items[]` as a flat list: the parent message first (no
89642
89645
  // `upper_message_id`) followed by every descendant, each with
@@ -89647,23 +89650,26 @@ class LarkChannel {
89647
89650
  // `container_id_type: 'message'`, which Feishu rejects — 'message'
89648
89651
  // isn't a valid container type.)
89649
89652
  const fetchSubMessages = (mid) => __awaiter(this, void 0, void 0, function* () {
89650
- var _a, _b, _c, _d;
89653
+ var _c, _d, _e, _f;
89651
89654
  try {
89652
89655
  const r = yield this.rawClient.im.v1.message.get({
89653
89656
  path: { message_id: mid },
89654
89657
  });
89655
- const items = (_b = (_a = r.data) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : [];
89658
+ const items = (_d = (_c = r.data) === null || _c === void 0 ? void 0 : _c.items) !== null && _d !== void 0 ? _d : [];
89656
89659
  return items;
89657
89660
  }
89658
89661
  catch (e) {
89659
- (_d = (_c = this.logger).warn) === null || _d === void 0 ? void 0 : _d.call(_c, 'channel: fetchSubMessages failed', e);
89662
+ (_f = (_e = this.logger).warn) === null || _f === void 0 ? void 0 : _f.call(_e, 'channel: fetchSubMessages failed', e);
89660
89663
  return [];
89661
89664
  }
89662
89665
  });
89666
+ // Unified raw-event flag: prefer the new `includeRawEvent` option,
89667
+ // fall back to the legacy `includeRawInMessage` for back-compat.
89668
+ const includeRaw = (_b = (_a = this.opts.includeRawEvent) !== null && _a !== void 0 ? _a : this.opts.includeRawInMessage) !== null && _b !== void 0 ? _b : false;
89663
89669
  const normalizeOpts = {
89664
89670
  botIdentity: this.botIdentity,
89665
89671
  stripBotMentions: true,
89666
- includeRaw: this.opts.includeRawInMessage,
89672
+ includeRaw,
89667
89673
  fetchSubMessages,
89668
89674
  };
89669
89675
  this.dispatcher.register({
@@ -89683,7 +89689,7 @@ class LarkChannel {
89683
89689
  // collapsed by the dedup cache. A genuine Feishu re-delivery
89684
89690
  // of the same click still hashes to the same key.
89685
89691
  'card.action.trigger': (raw) => __awaiter(this, void 0, void 0, function* () {
89686
- const evt = normalizeCardAction(raw);
89692
+ const evt = normalizeCardAction(raw, { includeRaw });
89687
89693
  if (!evt)
89688
89694
  return;
89689
89695
  const actionId = cardActionId(evt.action);
@@ -89695,14 +89701,14 @@ class LarkChannel {
89695
89701
  }),
89696
89702
  // Reactions — dedup only
89697
89703
  'im.message.reaction.created_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
89698
- const evt = normalizeReaction(raw, 'added');
89704
+ const evt = normalizeReaction(raw, 'added', { includeRaw });
89699
89705
  if (!evt)
89700
89706
  return;
89701
89707
  const key = reactionKey(evt);
89702
89708
  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
89709
  }),
89704
89710
  'im.message.reaction.deleted_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
89705
- const evt = normalizeReaction(raw, 'removed');
89711
+ const evt = normalizeReaction(raw, 'removed', { includeRaw });
89706
89712
  if (!evt)
89707
89713
  return;
89708
89714
  const key = reactionKey(evt);
@@ -89711,9 +89717,7 @@ class LarkChannel {
89711
89717
  // Bot added — direct fire, no safety
89712
89718
  'im.chat.member.bot.added_v1': (raw) => {
89713
89719
  var _a, _b;
89714
- const evt = normalizeBotAdded(raw, {
89715
- includeRaw: this.opts.includeRawInMessage,
89716
- });
89720
+ const evt = normalizeBotAdded(raw, { includeRaw });
89717
89721
  if (!evt)
89718
89722
  return;
89719
89723
  try {
@@ -89725,9 +89729,7 @@ class LarkChannel {
89725
89729
  },
89726
89730
  // Drive comments — dedup + lock + queue (by fileToken)
89727
89731
  'drive.notice.comment_add_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
89728
- const evt = normalizeComment(raw, {
89729
- includeRaw: this.opts.includeRawInMessage,
89730
- });
89732
+ const evt = normalizeComment(raw, { includeRaw });
89731
89733
  if (!evt)
89732
89734
  return;
89733
89735
  yield this.safety.pushAction(`comment:${evt.fileToken}:${evt.commentId}`, evt.fileToken, () => __awaiter(this, void 0, void 0, function* () {
package/lib/index.js CHANGED
@@ -89167,7 +89167,7 @@ function dispatchConvert(raw, msgType, ctx) {
89167
89167
  });
89168
89168
  }
89169
89169
 
89170
- function normalizeCardAction(event) {
89170
+ function normalizeCardAction(event, opts) {
89171
89171
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
89172
89172
  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
89173
  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 +89188,11 @@ function normalizeCardAction(event) {
89188
89188
  name: (_l = event.action) === null || _l === void 0 ? void 0 : _l.name,
89189
89189
  option: (_m = event.action) === null || _m === void 0 ? void 0 : _m.option,
89190
89190
  },
89191
+ raw: (opts === null || opts === void 0 ? void 0 : opts.includeRaw) ? event : undefined,
89191
89192
  };
89192
89193
  }
89193
89194
 
89194
- function normalizeReaction(event, action) {
89195
+ function normalizeReaction(event, action, opts) {
89195
89196
  var _a, _b, _c, _d;
89196
89197
  const messageId = event.message_id;
89197
89198
  const emojiType = (_a = event.reaction_type) === null || _a === void 0 ? void 0 : _a.emoji_type;
@@ -89209,6 +89210,7 @@ function normalizeReaction(event, action) {
89209
89210
  emojiType,
89210
89211
  action,
89211
89212
  actionTime: actionTime != null && Number.isFinite(actionTime) ? actionTime : undefined,
89213
+ raw: (opts === null || opts === void 0 ? void 0 : opts.includeRaw) ? event : undefined,
89212
89214
  };
89213
89215
  }
89214
89216
 
@@ -89655,6 +89657,7 @@ class LarkChannel {
89655
89657
  });
89656
89658
  }
89657
89659
  registerDispatcherHandlers() {
89660
+ var _a, _b;
89658
89661
  // `im.v1.message.get(mid)` on a merge_forward message returns
89659
89662
  // `data.items[]` as a flat list: the parent message first (no
89660
89663
  // `upper_message_id`) followed by every descendant, each with
@@ -89665,23 +89668,26 @@ class LarkChannel {
89665
89668
  // `container_id_type: 'message'`, which Feishu rejects — 'message'
89666
89669
  // isn't a valid container type.)
89667
89670
  const fetchSubMessages = (mid) => __awaiter(this, void 0, void 0, function* () {
89668
- var _a, _b, _c, _d;
89671
+ var _c, _d, _e, _f;
89669
89672
  try {
89670
89673
  const r = yield this.rawClient.im.v1.message.get({
89671
89674
  path: { message_id: mid },
89672
89675
  });
89673
- const items = (_b = (_a = r.data) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : [];
89676
+ const items = (_d = (_c = r.data) === null || _c === void 0 ? void 0 : _c.items) !== null && _d !== void 0 ? _d : [];
89674
89677
  return items;
89675
89678
  }
89676
89679
  catch (e) {
89677
- (_d = (_c = this.logger).warn) === null || _d === void 0 ? void 0 : _d.call(_c, 'channel: fetchSubMessages failed', e);
89680
+ (_f = (_e = this.logger).warn) === null || _f === void 0 ? void 0 : _f.call(_e, 'channel: fetchSubMessages failed', e);
89678
89681
  return [];
89679
89682
  }
89680
89683
  });
89684
+ // Unified raw-event flag: prefer the new `includeRawEvent` option,
89685
+ // fall back to the legacy `includeRawInMessage` for back-compat.
89686
+ const includeRaw = (_b = (_a = this.opts.includeRawEvent) !== null && _a !== void 0 ? _a : this.opts.includeRawInMessage) !== null && _b !== void 0 ? _b : false;
89681
89687
  const normalizeOpts = {
89682
89688
  botIdentity: this.botIdentity,
89683
89689
  stripBotMentions: true,
89684
- includeRaw: this.opts.includeRawInMessage,
89690
+ includeRaw,
89685
89691
  fetchSubMessages,
89686
89692
  };
89687
89693
  this.dispatcher.register({
@@ -89701,7 +89707,7 @@ class LarkChannel {
89701
89707
  // collapsed by the dedup cache. A genuine Feishu re-delivery
89702
89708
  // of the same click still hashes to the same key.
89703
89709
  'card.action.trigger': (raw) => __awaiter(this, void 0, void 0, function* () {
89704
- const evt = normalizeCardAction(raw);
89710
+ const evt = normalizeCardAction(raw, { includeRaw });
89705
89711
  if (!evt)
89706
89712
  return;
89707
89713
  const actionId = cardActionId(evt.action);
@@ -89713,14 +89719,14 @@ class LarkChannel {
89713
89719
  }),
89714
89720
  // Reactions — dedup only
89715
89721
  'im.message.reaction.created_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
89716
- const evt = normalizeReaction(raw, 'added');
89722
+ const evt = normalizeReaction(raw, 'added', { includeRaw });
89717
89723
  if (!evt)
89718
89724
  return;
89719
89725
  const key = reactionKey(evt);
89720
89726
  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
89727
  }),
89722
89728
  'im.message.reaction.deleted_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
89723
- const evt = normalizeReaction(raw, 'removed');
89729
+ const evt = normalizeReaction(raw, 'removed', { includeRaw });
89724
89730
  if (!evt)
89725
89731
  return;
89726
89732
  const key = reactionKey(evt);
@@ -89729,9 +89735,7 @@ class LarkChannel {
89729
89735
  // Bot added — direct fire, no safety
89730
89736
  'im.chat.member.bot.added_v1': (raw) => {
89731
89737
  var _a, _b;
89732
- const evt = normalizeBotAdded(raw, {
89733
- includeRaw: this.opts.includeRawInMessage,
89734
- });
89738
+ const evt = normalizeBotAdded(raw, { includeRaw });
89735
89739
  if (!evt)
89736
89740
  return;
89737
89741
  try {
@@ -89743,9 +89747,7 @@ class LarkChannel {
89743
89747
  },
89744
89748
  // Drive comments — dedup + lock + queue (by fileToken)
89745
89749
  'drive.notice.comment_add_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
89746
- const evt = normalizeComment(raw, {
89747
- includeRaw: this.opts.includeRawInMessage,
89748
- });
89750
+ const evt = normalizeComment(raw, { includeRaw });
89749
89751
  if (!evt)
89750
89752
  return;
89751
89753
  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.62.2",
4
4
  "description": "larksuite open sdk for nodejs",
5
5
  "keywords": [
6
6
  "feishu",
package/types/index.d.ts CHANGED
@@ -293411,6 +293411,7 @@ interface CardActionEvent {
293411
293411
  name?: string;
293412
293412
  option?: string;
293413
293413
  };
293414
+ raw?: unknown;
293414
293415
  }
293415
293416
  interface ReactionEvent {
293416
293417
  messageId: string;
@@ -293421,6 +293422,7 @@ interface ReactionEvent {
293421
293422
  emojiType: string;
293422
293423
  action: 'added' | 'removed';
293423
293424
  actionTime?: number;
293425
+ raw?: unknown;
293424
293426
  }
293425
293427
  interface BotAddedEvent {
293426
293428
  chatId: string;
@@ -293480,6 +293482,15 @@ interface LarkChannelOptions {
293480
293482
  httpInstance?: HttpInstance;
293481
293483
  /** Caller tag appended to User-Agent as `source/<name>`. */
293482
293484
  source?: string;
293485
+ /**
293486
+ * Attach the raw Feishu event body on every normalized event
293487
+ * (`message`, `cardAction`, `reaction`, `botAdded`, `comment`) as
293488
+ * `evt.raw`. Useful when a handler needs fields that the normalizer
293489
+ * dropped (e.g. `tenant_key`, `host`, `event_id`, vendor-specific
293490
+ * extensions). Off by default — payloads are smaller and stricter.
293491
+ */
293492
+ includeRawEvent?: boolean;
293493
+ /** @deprecated Use `includeRawEvent` instead. Retained for backward compatibility. */
293483
293494
  includeRawInMessage?: boolean;
293484
293495
  }
293485
293496
  interface WebhookOptions {
@@ -293703,7 +293714,9 @@ interface RawCardActionEvent {
293703
293714
  timezone?: string;
293704
293715
  };
293705
293716
  }
293706
- declare function normalizeCardAction(event: RawCardActionEvent): CardActionEvent | null;
293717
+ declare function normalizeCardAction(event: RawCardActionEvent, opts?: {
293718
+ includeRaw?: boolean;
293719
+ }): CardActionEvent | null;
293707
293720
 
293708
293721
  interface RawReactionEvent {
293709
293722
  message_id?: string;
@@ -293718,7 +293731,9 @@ interface RawReactionEvent {
293718
293731
  };
293719
293732
  action_time?: string;
293720
293733
  }
293721
- declare function normalizeReaction(event: RawReactionEvent, action: 'added' | 'removed'): ReactionEvent | null;
293734
+ declare function normalizeReaction(event: RawReactionEvent, action: 'added' | 'removed', opts?: {
293735
+ includeRaw?: boolean;
293736
+ }): ReactionEvent | null;
293722
293737
 
293723
293738
  interface RawBotAddedEvent {
293724
293739
  chat_id?: string;