@larksuiteoapi/node-sdk 1.4.0 → 1.4.1
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/README.md +9 -1
- package/README.zh.md +9 -1
- package/package.json +1 -1
- package/types/index.d.ts +134 -1
package/README.md
CHANGED
|
@@ -430,19 +430,26 @@ router.post(
|
|
|
430
430
|
```
|
|
431
431
|
|
|
432
432
|
### [Message Card](https://open.feishu.cn/document/ukTMukTMukTM/uczM3QjL3MzN04yNzcDN)
|
|
433
|
+
|
|
433
434
|
The processing of the Message Card is also a kind of Event processing. The only difference between the two is that the processor of the Message Card is used to respond to the events generated by the interaction between the user and the Message Card. If the processor has a return value (*the value structure should be in line with the structure defined by [Message Card Structure](https://open.feishu.cn/document/ukTMukTMukTM/uEjNwUjLxYDM14SM2ATN)*), then the return value is used to update the responded message card:
|
|
434
435
|
|
|
435
436
|
```typescript
|
|
436
437
|
import http from 'http';
|
|
437
438
|
import * as lark from '@larksuiteoapi/node-sdk';
|
|
439
|
+
import type { InteractiveCardActionEvent, InteractiveCard } from '@larksuiteoapi/node-sdk';
|
|
438
440
|
|
|
439
441
|
const cardDispatcher = new lark.CardActionHandler(
|
|
440
442
|
{
|
|
441
443
|
encryptKey: 'encrypt key',
|
|
442
444
|
verificationToken: 'verification token'
|
|
443
445
|
},
|
|
444
|
-
async(data) => {
|
|
446
|
+
async (data: InteractiveCardActionEvent) => {
|
|
445
447
|
console.log(data);
|
|
448
|
+
const newCard: InteractiveCard = {
|
|
449
|
+
// your new interactive card content
|
|
450
|
+
header: {},
|
|
451
|
+
elements: []
|
|
452
|
+
};
|
|
446
453
|
return newCard;
|
|
447
454
|
}
|
|
448
455
|
);
|
|
@@ -451,6 +458,7 @@ const server = http.createServer();
|
|
|
451
458
|
server.on('request', lark.adaptDefault('/webhook/card', cardDispatcher));
|
|
452
459
|
server.listen(3000);
|
|
453
460
|
````
|
|
461
|
+
|
|
454
462
|
#### `CardActionHandler` construction parameters
|
|
455
463
|
|
|
456
464
|
| Parameter | Description | Type | Required | Default |
|
package/README.zh.md
CHANGED
|
@@ -429,19 +429,26 @@ router.post(
|
|
|
429
429
|
```
|
|
430
430
|
|
|
431
431
|
### [消息卡片](https://open.feishu.cn/document/ukTMukTMukTM/uczM3QjL3MzN04yNzcDN)
|
|
432
|
+
|
|
432
433
|
对消息卡片的处理亦是对事件处理的一种,两者的不同点仅在于消息卡片的处理器用于响应用户与消息卡片交互所产生的事件,若处理器有返回值(*返回值的数据结构理应为符合[消息卡片结构](https://open.feishu.cn/document/ukTMukTMukTM/uEjNwUjLxYDM14SM2ATN)所定义的结构*),则返回值被用来更新被响应的消息卡片:
|
|
433
434
|
|
|
434
435
|
```typescript
|
|
435
436
|
import http from 'http';
|
|
436
437
|
import * as lark from '@larksuiteoapi/node-sdk';
|
|
438
|
+
import type { InteractiveCardActionEvent, InteractiveCard } from '@larksuiteoapi/node-sdk';
|
|
437
439
|
|
|
438
440
|
const cardDispatcher = new lark.CardActionHandler(
|
|
439
441
|
{
|
|
440
442
|
encryptKey: 'encrypt key',
|
|
441
443
|
verificationToken: 'verification token'
|
|
442
444
|
},
|
|
443
|
-
async (data) => {
|
|
445
|
+
async (data: InteractiveCardActionEvent) => {
|
|
444
446
|
console.log(data);
|
|
447
|
+
const newCard: InteractiveCard = {
|
|
448
|
+
// your new interactive card content
|
|
449
|
+
header: {},
|
|
450
|
+
elements: []
|
|
451
|
+
};
|
|
445
452
|
return newCard;
|
|
446
453
|
}
|
|
447
454
|
);
|
|
@@ -450,6 +457,7 @@ const server = http.createServer();
|
|
|
450
457
|
server.on('request', lark.adaptDefault('/webhook/card', cardDispatcher));
|
|
451
458
|
server.listen(3000);
|
|
452
459
|
```
|
|
460
|
+
|
|
453
461
|
#### `CardActionHandler`构造参数
|
|
454
462
|
|
|
455
463
|
| 参数 | 描述 | 类型 | 必须 | 默认 |
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -53361,4 +53361,137 @@ declare const adaptKoaRouter: (dispatcher: EventDispatcher | CardActionHandler,
|
|
|
53361
53361
|
autoChallenge?: boolean;
|
|
53362
53362
|
}) => (ctx: any, next: any) => Promise<void>;
|
|
53363
53363
|
|
|
53364
|
-
|
|
53364
|
+
interface InteractiveCardActionEvent {
|
|
53365
|
+
open_id: string;
|
|
53366
|
+
user_id?: string;
|
|
53367
|
+
tenant_key: string;
|
|
53368
|
+
open_message_id: string;
|
|
53369
|
+
token: string;
|
|
53370
|
+
action: {
|
|
53371
|
+
value: Record<string, any>;
|
|
53372
|
+
tag: string;
|
|
53373
|
+
option?: string;
|
|
53374
|
+
timezone?: string;
|
|
53375
|
+
};
|
|
53376
|
+
}
|
|
53377
|
+
interface InteractiveCard {
|
|
53378
|
+
config?: InteractiveCardConfig;
|
|
53379
|
+
header?: InteractiveCardHeader;
|
|
53380
|
+
elements?: InteractiveCardElement[];
|
|
53381
|
+
i18n_elements?: Record<string, InteractiveCardElement[]>;
|
|
53382
|
+
card_link?: InteractiveCardUrlItem;
|
|
53383
|
+
}
|
|
53384
|
+
interface InteractiveCardConfig {
|
|
53385
|
+
enable_forward?: boolean;
|
|
53386
|
+
update_multi?: boolean;
|
|
53387
|
+
wide_screen_mode?: boolean;
|
|
53388
|
+
}
|
|
53389
|
+
declare type InteractiveCardHeaderTemplate = 'blue' | 'wathet' | 'turquoise' | 'green' | 'yellow' | 'orange' | 'red' | 'carmine' | 'violet' | 'purple' | 'indigo' | 'grey';
|
|
53390
|
+
interface InteractiveCardHeader {
|
|
53391
|
+
title: InteractiveCardTitle;
|
|
53392
|
+
template?: InteractiveCardHeaderTemplate;
|
|
53393
|
+
}
|
|
53394
|
+
declare type InteractiveCardElement = InteractiveCardDivElement | InteractiveCardMarkdownElement | InteractiveCardDividerElement | InteractiveCardImageElement | InteractiveCardNoteElement | InterfaceCardActionElement;
|
|
53395
|
+
interface InteractiveCardTitle extends Omit<InteractiveCardPlainTextItem, 'lines'> {
|
|
53396
|
+
i18n?: Record<string, string>;
|
|
53397
|
+
}
|
|
53398
|
+
declare type InteractiveCardTextItem = InteractiveCardPlainTextItem | InteractiveCardLarkMdItem;
|
|
53399
|
+
interface InteractiveCardPlainTextItem {
|
|
53400
|
+
tag: 'plain_text';
|
|
53401
|
+
content?: string;
|
|
53402
|
+
lines?: number;
|
|
53403
|
+
}
|
|
53404
|
+
interface InteractiveCardLarkMdItem {
|
|
53405
|
+
tag: 'lark_md';
|
|
53406
|
+
content?: string;
|
|
53407
|
+
}
|
|
53408
|
+
interface InteractiveCardImageItem {
|
|
53409
|
+
tag: 'img';
|
|
53410
|
+
img_key: string;
|
|
53411
|
+
alt: InteractiveCardPlainTextItem;
|
|
53412
|
+
preview?: boolean;
|
|
53413
|
+
}
|
|
53414
|
+
interface InteractiveCardUrlItem {
|
|
53415
|
+
url: string;
|
|
53416
|
+
android_url?: string;
|
|
53417
|
+
ios_url?: string;
|
|
53418
|
+
pc_url?: string;
|
|
53419
|
+
}
|
|
53420
|
+
interface InteractiveCardField {
|
|
53421
|
+
is_short: boolean;
|
|
53422
|
+
text: InteractiveCardTextItem;
|
|
53423
|
+
}
|
|
53424
|
+
interface InteractiveCardDivElement {
|
|
53425
|
+
tag: 'div';
|
|
53426
|
+
text: InteractiveCardTextItem;
|
|
53427
|
+
fields?: InteractiveCardField[];
|
|
53428
|
+
extra?: any;
|
|
53429
|
+
}
|
|
53430
|
+
interface InteractiveCardMarkdownElement {
|
|
53431
|
+
tag: 'markdown';
|
|
53432
|
+
content: string;
|
|
53433
|
+
text_align?: 'left' | 'center' | 'right';
|
|
53434
|
+
href?: Record<string, InteractiveCardUrlItem>;
|
|
53435
|
+
}
|
|
53436
|
+
interface InteractiveCardDividerElement {
|
|
53437
|
+
tag: 'hr';
|
|
53438
|
+
}
|
|
53439
|
+
interface InteractiveCardImageElement extends InteractiveCardImageItem {
|
|
53440
|
+
title?: InteractiveCardTextItem;
|
|
53441
|
+
custom_width?: number;
|
|
53442
|
+
compact_width?: boolean;
|
|
53443
|
+
mode?: 'crop_center' | 'fit_horizontal';
|
|
53444
|
+
}
|
|
53445
|
+
interface InteractiveCardNoteElement {
|
|
53446
|
+
tag: 'note';
|
|
53447
|
+
elements: (InteractiveCardTextItem | InteractiveCardImageItem)[];
|
|
53448
|
+
}
|
|
53449
|
+
interface InterfaceCardActionElement {
|
|
53450
|
+
tag: 'action';
|
|
53451
|
+
actions: InteractiveCardActionItem[];
|
|
53452
|
+
layout?: 'bisected' | 'trisection' | 'flow';
|
|
53453
|
+
}
|
|
53454
|
+
declare type InteractiveCardActionItem = InteractiveCardDatePickerActionItem | InteractiveCardButtonActionItem | InteractiveCardOverflowActionItem | InteractiveCardSelectMenuActionItem;
|
|
53455
|
+
interface InteractiveCardActionBaseItem {
|
|
53456
|
+
confirm?: {
|
|
53457
|
+
title: InteractiveCardPlainTextItem;
|
|
53458
|
+
text: InteractiveCardPlainTextItem;
|
|
53459
|
+
};
|
|
53460
|
+
}
|
|
53461
|
+
interface InteractiveCardActionOptionItem {
|
|
53462
|
+
text?: InteractiveCardPlainTextItem;
|
|
53463
|
+
value?: string;
|
|
53464
|
+
}
|
|
53465
|
+
interface InteractiveCardDatePickerActionItem extends InteractiveCardActionBaseItem {
|
|
53466
|
+
tag: 'date_picker' | 'picker_time' | 'picker_datetime';
|
|
53467
|
+
initial_date?: string;
|
|
53468
|
+
initial_time?: string;
|
|
53469
|
+
initial_datetime?: string;
|
|
53470
|
+
placeholder?: InteractiveCardPlainTextItem;
|
|
53471
|
+
value?: Record<string, any>;
|
|
53472
|
+
}
|
|
53473
|
+
interface InteractiveCardButtonActionItem extends InteractiveCardActionBaseItem {
|
|
53474
|
+
tag: 'button';
|
|
53475
|
+
text?: InteractiveCardTextItem;
|
|
53476
|
+
url?: string;
|
|
53477
|
+
multi_utl?: InteractiveCardUrlItem;
|
|
53478
|
+
type?: 'default' | 'primary' | 'danger';
|
|
53479
|
+
value?: Record<string, any>;
|
|
53480
|
+
}
|
|
53481
|
+
interface InteractiveCardOverflowActionItem extends InteractiveCardActionBaseItem {
|
|
53482
|
+
tag: 'overflow';
|
|
53483
|
+
options?: (InteractiveCardActionOptionItem & {
|
|
53484
|
+
url?: string;
|
|
53485
|
+
multi_utl?: InteractiveCardUrlItem;
|
|
53486
|
+
})[];
|
|
53487
|
+
value?: Record<string, any>;
|
|
53488
|
+
}
|
|
53489
|
+
interface InteractiveCardSelectMenuActionItem extends InteractiveCardActionBaseItem {
|
|
53490
|
+
tag: 'select_static' | 'select_person';
|
|
53491
|
+
placeholder?: InteractiveCardPlainTextItem;
|
|
53492
|
+
initial_option?: string;
|
|
53493
|
+
option?: InteractiveCardActionOptionItem[];
|
|
53494
|
+
value?: Record<string, any>;
|
|
53495
|
+
}
|
|
53496
|
+
|
|
53497
|
+
export { AESCipher, AppType, CAppTicket, CardActionHandler, Client, Domain, EventDispatcher, IHandles as EventHandles, InteractiveCard, InteractiveCardActionEvent, InteractiveCardActionItem, InteractiveCardButtonActionItem, InteractiveCardDatePickerActionItem, InteractiveCardDivElement, InteractiveCardDividerElement, InteractiveCardElement, InteractiveCardField, InteractiveCardImageElement, InteractiveCardImageItem, InteractiveCardLarkMdItem, InteractiveCardMarkdownElement, InteractiveCardNoteElement, InteractiveCardOverflowActionItem, InteractiveCardPlainTextItem, InteractiveCardSelectMenuActionItem, InteractiveCardTextItem, InteractiveCardTitle, InteractiveCardUrlItem, InterfaceCardActionElement, LoggerLevel, adaptDefault, adaptExpress, adaptKoa, adaptKoaRouter, withAll, withHelpDeskCredential, withTenantKey, withTenantToken, withUserAccessToken };
|