@larksuiteoapi/node-sdk 1.62.0 → 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 +37 -31
- package/lib/index.js +37 -31
- package/package.json +1 -1
- package/types/index.d.ts +21 -2
package/es/index.js
CHANGED
|
@@ -146,19 +146,21 @@ function getSdkVersion() {
|
|
|
146
146
|
function sanitizeSource(raw) {
|
|
147
147
|
return raw.replace(/[^a-zA-Z0-9._-]/g, '_').slice(0, 64);
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
149
|
+
function buildUserAgent(source, opts) {
|
|
150
|
+
let ua = `oapi-node-sdk/${getSdkVersion()}`;
|
|
151
|
+
if (source) {
|
|
152
|
+
const clean = sanitizeSource(source);
|
|
153
|
+
if (clean)
|
|
154
|
+
ua += ` source/${clean}`;
|
|
155
|
+
}
|
|
156
|
+
if (opts === null || opts === void 0 ? void 0 : opts.extraTags) {
|
|
157
|
+
for (const t of opts.extraTags) {
|
|
158
|
+
const clean = sanitizeSource(t);
|
|
159
|
+
if (clean)
|
|
160
|
+
ua += ` ${clean}`;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return ua;
|
|
162
164
|
}
|
|
163
165
|
|
|
164
166
|
const defaultHttpInstance = axios.create();
|
|
@@ -83993,7 +83995,7 @@ class Client extends Client$1 {
|
|
|
83993
83995
|
this.appId = params.appId;
|
|
83994
83996
|
this.appSecret = params.appSecret;
|
|
83995
83997
|
this.disableTokenCache = params.disableTokenCache;
|
|
83996
|
-
this.userAgent = buildUserAgent(params.source);
|
|
83998
|
+
this.userAgent = buildUserAgent(params.source, { extraTags: params.extraUaTags });
|
|
83997
83999
|
assert(!this.appId, () => this.logger.error('appId is needed'));
|
|
83998
84000
|
assert(!this.appSecret, () => this.logger.error('appSecret is needed'));
|
|
83999
84001
|
this.helpDeskId = params.helpDeskId;
|
|
@@ -85362,8 +85364,8 @@ class WSClient {
|
|
|
85362
85364
|
/** True if the WS has ever connected successfully in this client's
|
|
85363
85365
|
* lifetime — used to distinguish first-connect from reconnect. */
|
|
85364
85366
|
this.hasEverConnected = false;
|
|
85365
|
-
const { appId, appSecret, agent, domain = Domain.Feishu, httpInstance = defaultHttpInstance, loggerLevel = LoggerLevel.info, logger = defaultLogger, autoReconnect = true, source, onReady, onError, onReconnecting, onReconnected, } = params;
|
|
85366
|
-
this.userAgent = buildUserAgent(source);
|
|
85367
|
+
const { appId, appSecret, agent, domain = Domain.Feishu, httpInstance = defaultHttpInstance, loggerLevel = LoggerLevel.info, logger = defaultLogger, autoReconnect = true, source, extraUaTags, onReady, onError, onReconnecting, onReconnected, } = params;
|
|
85368
|
+
this.userAgent = buildUserAgent(source, { extraTags: extraUaTags });
|
|
85367
85369
|
this.logger = new LoggerProxy(loggerLevel, logger);
|
|
85368
85370
|
assert(!appId, () => this.logger.error('appId is needed'));
|
|
85369
85371
|
assert(!appSecret, () => this.logger.error('appSecret is needed'));
|
|
@@ -89147,7 +89149,7 @@ function dispatchConvert(raw, msgType, ctx) {
|
|
|
89147
89149
|
});
|
|
89148
89150
|
}
|
|
89149
89151
|
|
|
89150
|
-
function normalizeCardAction(event) {
|
|
89152
|
+
function normalizeCardAction(event, opts) {
|
|
89151
89153
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
89152
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;
|
|
89153
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;
|
|
@@ -89168,10 +89170,11 @@ function normalizeCardAction(event) {
|
|
|
89168
89170
|
name: (_l = event.action) === null || _l === void 0 ? void 0 : _l.name,
|
|
89169
89171
|
option: (_m = event.action) === null || _m === void 0 ? void 0 : _m.option,
|
|
89170
89172
|
},
|
|
89173
|
+
raw: (opts === null || opts === void 0 ? void 0 : opts.includeRaw) ? event : undefined,
|
|
89171
89174
|
};
|
|
89172
89175
|
}
|
|
89173
89176
|
|
|
89174
|
-
function normalizeReaction(event, action) {
|
|
89177
|
+
function normalizeReaction(event, action, opts) {
|
|
89175
89178
|
var _a, _b, _c, _d;
|
|
89176
89179
|
const messageId = event.message_id;
|
|
89177
89180
|
const emojiType = (_a = event.reaction_type) === null || _a === void 0 ? void 0 : _a.emoji_type;
|
|
@@ -89189,6 +89192,7 @@ function normalizeReaction(event, action) {
|
|
|
89189
89192
|
emojiType,
|
|
89190
89193
|
action,
|
|
89191
89194
|
actionTime: actionTime != null && Number.isFinite(actionTime) ? actionTime : undefined,
|
|
89195
|
+
raw: (opts === null || opts === void 0 ? void 0 : opts.includeRaw) ? event : undefined,
|
|
89192
89196
|
};
|
|
89193
89197
|
}
|
|
89194
89198
|
|
|
@@ -89328,6 +89332,7 @@ class LarkChannel {
|
|
|
89328
89332
|
logger: opts.logger,
|
|
89329
89333
|
loggerLevel: opts.loggerLevel,
|
|
89330
89334
|
source: opts.source,
|
|
89335
|
+
extraUaTags: ['channel'],
|
|
89331
89336
|
});
|
|
89332
89337
|
this.dispatcher = new EventDispatcher({
|
|
89333
89338
|
verificationToken: (_d = opts.webhook) === null || _d === void 0 ? void 0 : _d.verificationToken,
|
|
@@ -89405,6 +89410,7 @@ class LarkChannel {
|
|
|
89405
89410
|
httpInstance: this.opts.httpInstance,
|
|
89406
89411
|
autoReconnect: true,
|
|
89407
89412
|
source: this.opts.source,
|
|
89413
|
+
extraUaTags: ['channel'],
|
|
89408
89414
|
onReady: () => {
|
|
89409
89415
|
if (settled)
|
|
89410
89416
|
return;
|
|
@@ -89633,6 +89639,7 @@ class LarkChannel {
|
|
|
89633
89639
|
});
|
|
89634
89640
|
}
|
|
89635
89641
|
registerDispatcherHandlers() {
|
|
89642
|
+
var _a, _b;
|
|
89636
89643
|
// `im.v1.message.get(mid)` on a merge_forward message returns
|
|
89637
89644
|
// `data.items[]` as a flat list: the parent message first (no
|
|
89638
89645
|
// `upper_message_id`) followed by every descendant, each with
|
|
@@ -89643,23 +89650,26 @@ class LarkChannel {
|
|
|
89643
89650
|
// `container_id_type: 'message'`, which Feishu rejects — 'message'
|
|
89644
89651
|
// isn't a valid container type.)
|
|
89645
89652
|
const fetchSubMessages = (mid) => __awaiter(this, void 0, void 0, function* () {
|
|
89646
|
-
var
|
|
89653
|
+
var _c, _d, _e, _f;
|
|
89647
89654
|
try {
|
|
89648
89655
|
const r = yield this.rawClient.im.v1.message.get({
|
|
89649
89656
|
path: { message_id: mid },
|
|
89650
89657
|
});
|
|
89651
|
-
const items = (
|
|
89658
|
+
const items = (_d = (_c = r.data) === null || _c === void 0 ? void 0 : _c.items) !== null && _d !== void 0 ? _d : [];
|
|
89652
89659
|
return items;
|
|
89653
89660
|
}
|
|
89654
89661
|
catch (e) {
|
|
89655
|
-
(
|
|
89662
|
+
(_f = (_e = this.logger).warn) === null || _f === void 0 ? void 0 : _f.call(_e, 'channel: fetchSubMessages failed', e);
|
|
89656
89663
|
return [];
|
|
89657
89664
|
}
|
|
89658
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;
|
|
89659
89669
|
const normalizeOpts = {
|
|
89660
89670
|
botIdentity: this.botIdentity,
|
|
89661
89671
|
stripBotMentions: true,
|
|
89662
|
-
includeRaw
|
|
89672
|
+
includeRaw,
|
|
89663
89673
|
fetchSubMessages,
|
|
89664
89674
|
};
|
|
89665
89675
|
this.dispatcher.register({
|
|
@@ -89679,7 +89689,7 @@ class LarkChannel {
|
|
|
89679
89689
|
// collapsed by the dedup cache. A genuine Feishu re-delivery
|
|
89680
89690
|
// of the same click still hashes to the same key.
|
|
89681
89691
|
'card.action.trigger': (raw) => __awaiter(this, void 0, void 0, function* () {
|
|
89682
|
-
const evt = normalizeCardAction(raw);
|
|
89692
|
+
const evt = normalizeCardAction(raw, { includeRaw });
|
|
89683
89693
|
if (!evt)
|
|
89684
89694
|
return;
|
|
89685
89695
|
const actionId = cardActionId(evt.action);
|
|
@@ -89691,14 +89701,14 @@ class LarkChannel {
|
|
|
89691
89701
|
}),
|
|
89692
89702
|
// Reactions — dedup only
|
|
89693
89703
|
'im.message.reaction.created_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
|
|
89694
|
-
const evt = normalizeReaction(raw, 'added');
|
|
89704
|
+
const evt = normalizeReaction(raw, 'added', { includeRaw });
|
|
89695
89705
|
if (!evt)
|
|
89696
89706
|
return;
|
|
89697
89707
|
const key = reactionKey(evt);
|
|
89698
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); });
|
|
89699
89709
|
}),
|
|
89700
89710
|
'im.message.reaction.deleted_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
|
|
89701
|
-
const evt = normalizeReaction(raw, 'removed');
|
|
89711
|
+
const evt = normalizeReaction(raw, 'removed', { includeRaw });
|
|
89702
89712
|
if (!evt)
|
|
89703
89713
|
return;
|
|
89704
89714
|
const key = reactionKey(evt);
|
|
@@ -89707,9 +89717,7 @@ class LarkChannel {
|
|
|
89707
89717
|
// Bot added — direct fire, no safety
|
|
89708
89718
|
'im.chat.member.bot.added_v1': (raw) => {
|
|
89709
89719
|
var _a, _b;
|
|
89710
|
-
const evt = normalizeBotAdded(raw, {
|
|
89711
|
-
includeRaw: this.opts.includeRawInMessage,
|
|
89712
|
-
});
|
|
89720
|
+
const evt = normalizeBotAdded(raw, { includeRaw });
|
|
89713
89721
|
if (!evt)
|
|
89714
89722
|
return;
|
|
89715
89723
|
try {
|
|
@@ -89721,9 +89729,7 @@ class LarkChannel {
|
|
|
89721
89729
|
},
|
|
89722
89730
|
// Drive comments — dedup + lock + queue (by fileToken)
|
|
89723
89731
|
'drive.notice.comment_add_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
|
|
89724
|
-
const evt = normalizeComment(raw, {
|
|
89725
|
-
includeRaw: this.opts.includeRawInMessage,
|
|
89726
|
-
});
|
|
89732
|
+
const evt = normalizeComment(raw, { includeRaw });
|
|
89727
89733
|
if (!evt)
|
|
89728
89734
|
return;
|
|
89729
89735
|
yield this.safety.pushAction(`comment:${evt.fileToken}:${evt.commentId}`, evt.fileToken, () => __awaiter(this, void 0, void 0, function* () {
|
package/lib/index.js
CHANGED
|
@@ -164,19 +164,21 @@ function getSdkVersion() {
|
|
|
164
164
|
function sanitizeSource(raw) {
|
|
165
165
|
return raw.replace(/[^a-zA-Z0-9._-]/g, '_').slice(0, 64);
|
|
166
166
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
167
|
+
function buildUserAgent(source, opts) {
|
|
168
|
+
let ua = `oapi-node-sdk/${getSdkVersion()}`;
|
|
169
|
+
if (source) {
|
|
170
|
+
const clean = sanitizeSource(source);
|
|
171
|
+
if (clean)
|
|
172
|
+
ua += ` source/${clean}`;
|
|
173
|
+
}
|
|
174
|
+
if (opts === null || opts === void 0 ? void 0 : opts.extraTags) {
|
|
175
|
+
for (const t of opts.extraTags) {
|
|
176
|
+
const clean = sanitizeSource(t);
|
|
177
|
+
if (clean)
|
|
178
|
+
ua += ` ${clean}`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return ua;
|
|
180
182
|
}
|
|
181
183
|
|
|
182
184
|
const defaultHttpInstance = axios__default["default"].create();
|
|
@@ -84011,7 +84013,7 @@ class Client extends Client$1 {
|
|
|
84011
84013
|
this.appId = params.appId;
|
|
84012
84014
|
this.appSecret = params.appSecret;
|
|
84013
84015
|
this.disableTokenCache = params.disableTokenCache;
|
|
84014
|
-
this.userAgent = buildUserAgent(params.source);
|
|
84016
|
+
this.userAgent = buildUserAgent(params.source, { extraTags: params.extraUaTags });
|
|
84015
84017
|
assert(!this.appId, () => this.logger.error('appId is needed'));
|
|
84016
84018
|
assert(!this.appSecret, () => this.logger.error('appSecret is needed'));
|
|
84017
84019
|
this.helpDeskId = params.helpDeskId;
|
|
@@ -85380,8 +85382,8 @@ class WSClient {
|
|
|
85380
85382
|
/** True if the WS has ever connected successfully in this client's
|
|
85381
85383
|
* lifetime — used to distinguish first-connect from reconnect. */
|
|
85382
85384
|
this.hasEverConnected = false;
|
|
85383
|
-
const { appId, appSecret, agent, domain = exports.Domain.Feishu, httpInstance = defaultHttpInstance, loggerLevel = exports.LoggerLevel.info, logger = defaultLogger, autoReconnect = true, source, onReady, onError, onReconnecting, onReconnected, } = params;
|
|
85384
|
-
this.userAgent = buildUserAgent(source);
|
|
85385
|
+
const { appId, appSecret, agent, domain = exports.Domain.Feishu, httpInstance = defaultHttpInstance, loggerLevel = exports.LoggerLevel.info, logger = defaultLogger, autoReconnect = true, source, extraUaTags, onReady, onError, onReconnecting, onReconnected, } = params;
|
|
85386
|
+
this.userAgent = buildUserAgent(source, { extraTags: extraUaTags });
|
|
85385
85387
|
this.logger = new LoggerProxy(loggerLevel, logger);
|
|
85386
85388
|
assert(!appId, () => this.logger.error('appId is needed'));
|
|
85387
85389
|
assert(!appSecret, () => this.logger.error('appSecret is needed'));
|
|
@@ -89165,7 +89167,7 @@ function dispatchConvert(raw, msgType, ctx) {
|
|
|
89165
89167
|
});
|
|
89166
89168
|
}
|
|
89167
89169
|
|
|
89168
|
-
function normalizeCardAction(event) {
|
|
89170
|
+
function normalizeCardAction(event, opts) {
|
|
89169
89171
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
89170
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;
|
|
89171
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;
|
|
@@ -89186,10 +89188,11 @@ function normalizeCardAction(event) {
|
|
|
89186
89188
|
name: (_l = event.action) === null || _l === void 0 ? void 0 : _l.name,
|
|
89187
89189
|
option: (_m = event.action) === null || _m === void 0 ? void 0 : _m.option,
|
|
89188
89190
|
},
|
|
89191
|
+
raw: (opts === null || opts === void 0 ? void 0 : opts.includeRaw) ? event : undefined,
|
|
89189
89192
|
};
|
|
89190
89193
|
}
|
|
89191
89194
|
|
|
89192
|
-
function normalizeReaction(event, action) {
|
|
89195
|
+
function normalizeReaction(event, action, opts) {
|
|
89193
89196
|
var _a, _b, _c, _d;
|
|
89194
89197
|
const messageId = event.message_id;
|
|
89195
89198
|
const emojiType = (_a = event.reaction_type) === null || _a === void 0 ? void 0 : _a.emoji_type;
|
|
@@ -89207,6 +89210,7 @@ function normalizeReaction(event, action) {
|
|
|
89207
89210
|
emojiType,
|
|
89208
89211
|
action,
|
|
89209
89212
|
actionTime: actionTime != null && Number.isFinite(actionTime) ? actionTime : undefined,
|
|
89213
|
+
raw: (opts === null || opts === void 0 ? void 0 : opts.includeRaw) ? event : undefined,
|
|
89210
89214
|
};
|
|
89211
89215
|
}
|
|
89212
89216
|
|
|
@@ -89346,6 +89350,7 @@ class LarkChannel {
|
|
|
89346
89350
|
logger: opts.logger,
|
|
89347
89351
|
loggerLevel: opts.loggerLevel,
|
|
89348
89352
|
source: opts.source,
|
|
89353
|
+
extraUaTags: ['channel'],
|
|
89349
89354
|
});
|
|
89350
89355
|
this.dispatcher = new EventDispatcher({
|
|
89351
89356
|
verificationToken: (_d = opts.webhook) === null || _d === void 0 ? void 0 : _d.verificationToken,
|
|
@@ -89423,6 +89428,7 @@ class LarkChannel {
|
|
|
89423
89428
|
httpInstance: this.opts.httpInstance,
|
|
89424
89429
|
autoReconnect: true,
|
|
89425
89430
|
source: this.opts.source,
|
|
89431
|
+
extraUaTags: ['channel'],
|
|
89426
89432
|
onReady: () => {
|
|
89427
89433
|
if (settled)
|
|
89428
89434
|
return;
|
|
@@ -89651,6 +89657,7 @@ class LarkChannel {
|
|
|
89651
89657
|
});
|
|
89652
89658
|
}
|
|
89653
89659
|
registerDispatcherHandlers() {
|
|
89660
|
+
var _a, _b;
|
|
89654
89661
|
// `im.v1.message.get(mid)` on a merge_forward message returns
|
|
89655
89662
|
// `data.items[]` as a flat list: the parent message first (no
|
|
89656
89663
|
// `upper_message_id`) followed by every descendant, each with
|
|
@@ -89661,23 +89668,26 @@ class LarkChannel {
|
|
|
89661
89668
|
// `container_id_type: 'message'`, which Feishu rejects — 'message'
|
|
89662
89669
|
// isn't a valid container type.)
|
|
89663
89670
|
const fetchSubMessages = (mid) => __awaiter(this, void 0, void 0, function* () {
|
|
89664
|
-
var
|
|
89671
|
+
var _c, _d, _e, _f;
|
|
89665
89672
|
try {
|
|
89666
89673
|
const r = yield this.rawClient.im.v1.message.get({
|
|
89667
89674
|
path: { message_id: mid },
|
|
89668
89675
|
});
|
|
89669
|
-
const items = (
|
|
89676
|
+
const items = (_d = (_c = r.data) === null || _c === void 0 ? void 0 : _c.items) !== null && _d !== void 0 ? _d : [];
|
|
89670
89677
|
return items;
|
|
89671
89678
|
}
|
|
89672
89679
|
catch (e) {
|
|
89673
|
-
(
|
|
89680
|
+
(_f = (_e = this.logger).warn) === null || _f === void 0 ? void 0 : _f.call(_e, 'channel: fetchSubMessages failed', e);
|
|
89674
89681
|
return [];
|
|
89675
89682
|
}
|
|
89676
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;
|
|
89677
89687
|
const normalizeOpts = {
|
|
89678
89688
|
botIdentity: this.botIdentity,
|
|
89679
89689
|
stripBotMentions: true,
|
|
89680
|
-
includeRaw
|
|
89690
|
+
includeRaw,
|
|
89681
89691
|
fetchSubMessages,
|
|
89682
89692
|
};
|
|
89683
89693
|
this.dispatcher.register({
|
|
@@ -89697,7 +89707,7 @@ class LarkChannel {
|
|
|
89697
89707
|
// collapsed by the dedup cache. A genuine Feishu re-delivery
|
|
89698
89708
|
// of the same click still hashes to the same key.
|
|
89699
89709
|
'card.action.trigger': (raw) => __awaiter(this, void 0, void 0, function* () {
|
|
89700
|
-
const evt = normalizeCardAction(raw);
|
|
89710
|
+
const evt = normalizeCardAction(raw, { includeRaw });
|
|
89701
89711
|
if (!evt)
|
|
89702
89712
|
return;
|
|
89703
89713
|
const actionId = cardActionId(evt.action);
|
|
@@ -89709,14 +89719,14 @@ class LarkChannel {
|
|
|
89709
89719
|
}),
|
|
89710
89720
|
// Reactions — dedup only
|
|
89711
89721
|
'im.message.reaction.created_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
|
|
89712
|
-
const evt = normalizeReaction(raw, 'added');
|
|
89722
|
+
const evt = normalizeReaction(raw, 'added', { includeRaw });
|
|
89713
89723
|
if (!evt)
|
|
89714
89724
|
return;
|
|
89715
89725
|
const key = reactionKey(evt);
|
|
89716
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); });
|
|
89717
89727
|
}),
|
|
89718
89728
|
'im.message.reaction.deleted_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
|
|
89719
|
-
const evt = normalizeReaction(raw, 'removed');
|
|
89729
|
+
const evt = normalizeReaction(raw, 'removed', { includeRaw });
|
|
89720
89730
|
if (!evt)
|
|
89721
89731
|
return;
|
|
89722
89732
|
const key = reactionKey(evt);
|
|
@@ -89725,9 +89735,7 @@ class LarkChannel {
|
|
|
89725
89735
|
// Bot added — direct fire, no safety
|
|
89726
89736
|
'im.chat.member.bot.added_v1': (raw) => {
|
|
89727
89737
|
var _a, _b;
|
|
89728
|
-
const evt = normalizeBotAdded(raw, {
|
|
89729
|
-
includeRaw: this.opts.includeRawInMessage,
|
|
89730
|
-
});
|
|
89738
|
+
const evt = normalizeBotAdded(raw, { includeRaw });
|
|
89731
89739
|
if (!evt)
|
|
89732
89740
|
return;
|
|
89733
89741
|
try {
|
|
@@ -89739,9 +89747,7 @@ class LarkChannel {
|
|
|
89739
89747
|
},
|
|
89740
89748
|
// Drive comments — dedup + lock + queue (by fileToken)
|
|
89741
89749
|
'drive.notice.comment_add_v1': (raw) => __awaiter(this, void 0, void 0, function* () {
|
|
89742
|
-
const evt = normalizeComment(raw, {
|
|
89743
|
-
includeRaw: this.opts.includeRawInMessage,
|
|
89744
|
-
});
|
|
89750
|
+
const evt = normalizeComment(raw, { includeRaw });
|
|
89745
89751
|
if (!evt)
|
|
89746
89752
|
return;
|
|
89747
89753
|
yield this.safety.pushAction(`comment:${evt.fileToken}:${evt.commentId}`, evt.fileToken, () => __awaiter(this, void 0, void 0, function* () {
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -112,6 +112,8 @@ interface IClientParams {
|
|
|
112
112
|
httpInstance?: HttpInstance;
|
|
113
113
|
/** Caller tag appended to User-Agent as `source/<name>`. */
|
|
114
114
|
source?: string;
|
|
115
|
+
/** @internal Extra bare tokens appended to User-Agent, set by sub-modules. */
|
|
116
|
+
extraUaTags?: string[];
|
|
115
117
|
}
|
|
116
118
|
interface IPayload {
|
|
117
119
|
params?: Record<string, any>;
|
|
@@ -293052,6 +293054,8 @@ interface IConstructorParams {
|
|
|
293052
293054
|
agent?: any;
|
|
293053
293055
|
/** Caller tag appended to User-Agent as `source/<name>`. */
|
|
293054
293056
|
source?: string;
|
|
293057
|
+
/** @internal Extra bare tokens appended to User-Agent, set by sub-modules. */
|
|
293058
|
+
extraUaTags?: string[];
|
|
293055
293059
|
/** Fires once when the first WebSocket handshake succeeds. */
|
|
293056
293060
|
onReady?: () => void;
|
|
293057
293061
|
/**
|
|
@@ -293407,6 +293411,7 @@ interface CardActionEvent {
|
|
|
293407
293411
|
name?: string;
|
|
293408
293412
|
option?: string;
|
|
293409
293413
|
};
|
|
293414
|
+
raw?: unknown;
|
|
293410
293415
|
}
|
|
293411
293416
|
interface ReactionEvent {
|
|
293412
293417
|
messageId: string;
|
|
@@ -293417,6 +293422,7 @@ interface ReactionEvent {
|
|
|
293417
293422
|
emojiType: string;
|
|
293418
293423
|
action: 'added' | 'removed';
|
|
293419
293424
|
actionTime?: number;
|
|
293425
|
+
raw?: unknown;
|
|
293420
293426
|
}
|
|
293421
293427
|
interface BotAddedEvent {
|
|
293422
293428
|
chatId: string;
|
|
@@ -293476,6 +293482,15 @@ interface LarkChannelOptions {
|
|
|
293476
293482
|
httpInstance?: HttpInstance;
|
|
293477
293483
|
/** Caller tag appended to User-Agent as `source/<name>`. */
|
|
293478
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. */
|
|
293479
293494
|
includeRawInMessage?: boolean;
|
|
293480
293495
|
}
|
|
293481
293496
|
interface WebhookOptions {
|
|
@@ -293699,7 +293714,9 @@ interface RawCardActionEvent {
|
|
|
293699
293714
|
timezone?: string;
|
|
293700
293715
|
};
|
|
293701
293716
|
}
|
|
293702
|
-
declare function normalizeCardAction(event: RawCardActionEvent
|
|
293717
|
+
declare function normalizeCardAction(event: RawCardActionEvent, opts?: {
|
|
293718
|
+
includeRaw?: boolean;
|
|
293719
|
+
}): CardActionEvent | null;
|
|
293703
293720
|
|
|
293704
293721
|
interface RawReactionEvent {
|
|
293705
293722
|
message_id?: string;
|
|
@@ -293714,7 +293731,9 @@ interface RawReactionEvent {
|
|
|
293714
293731
|
};
|
|
293715
293732
|
action_time?: string;
|
|
293716
293733
|
}
|
|
293717
|
-
declare function normalizeReaction(event: RawReactionEvent, action: 'added' | 'removed'
|
|
293734
|
+
declare function normalizeReaction(event: RawReactionEvent, action: 'added' | 'removed', opts?: {
|
|
293735
|
+
includeRaw?: boolean;
|
|
293736
|
+
}): ReactionEvent | null;
|
|
293718
293737
|
|
|
293719
293738
|
interface RawBotAddedEvent {
|
|
293720
293739
|
chat_id?: string;
|