@satorijs/adapter-lark 3.6.0 → 3.6.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/lib/http.d.ts +5 -5
- package/lib/index.cjs +265 -103
- package/lib/index.cjs.map +2 -2
- package/lib/message.d.ts +9 -9
- package/lib/types/api.d.ts +2 -0
- package/lib/types/message/content.d.ts +386 -22
- package/lib/types/message/index.d.ts +18 -16
- package/lib/utils.d.ts +3 -3
- package/package.json +3 -3
- package/src/http.ts +6 -6
- package/src/message.ts +261 -114
- package/src/types/api.ts +2 -0
- package/src/types/message/content.ts +477 -42
- package/src/types/message/index.ts +18 -19
- package/src/utils.ts +21 -6
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace JSX {
|
|
3
|
+
interface IntrinsicElements {
|
|
4
|
+
'lark:share-chat': {
|
|
5
|
+
'chat-id': string;
|
|
6
|
+
};
|
|
7
|
+
'lark:share-user': {
|
|
8
|
+
'user-id': string;
|
|
9
|
+
};
|
|
10
|
+
'lark:system': {
|
|
11
|
+
'need-rollup'?: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export interface MessageContent {
|
|
17
|
+
text: MessageContent.Text;
|
|
18
|
+
post: MessageContent.RichText;
|
|
19
|
+
image: MessageContent.Image;
|
|
20
|
+
file: MessageContent.File;
|
|
21
|
+
audio: MessageContent.Audio;
|
|
22
|
+
media: MessageContent.Media;
|
|
23
|
+
sticker: MessageContent.Sticker;
|
|
24
|
+
share_chat: MessageContent.ShareChat;
|
|
25
|
+
share_user: MessageContent.ShareUser;
|
|
26
|
+
system: MessageContent.System;
|
|
27
|
+
}
|
|
1
28
|
export declare namespace MessageContent {
|
|
2
|
-
type Contents = Text | Image | ShareChat | ShareUser | Audio | Media | File | Sticker | RichText;
|
|
3
|
-
type MediaContents = Image | Audio | Media | File;
|
|
4
29
|
interface Text {
|
|
5
30
|
text: string;
|
|
6
31
|
}
|
|
@@ -18,7 +43,7 @@ export declare namespace MessageContent {
|
|
|
18
43
|
}
|
|
19
44
|
interface Media {
|
|
20
45
|
file_key: string;
|
|
21
|
-
image_key
|
|
46
|
+
image_key?: string;
|
|
22
47
|
}
|
|
23
48
|
interface File {
|
|
24
49
|
file_key: string;
|
|
@@ -26,44 +51,383 @@ export declare namespace MessageContent {
|
|
|
26
51
|
interface Sticker {
|
|
27
52
|
file_key: string;
|
|
28
53
|
}
|
|
54
|
+
interface System {
|
|
55
|
+
type: 'divider';
|
|
56
|
+
params: {
|
|
57
|
+
divider_text: {
|
|
58
|
+
text: string;
|
|
59
|
+
i18n_text?: Record<string, string>;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
options?: {
|
|
63
|
+
need_rollup?: boolean;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
29
66
|
interface RichText {
|
|
30
67
|
[locale: string]: {
|
|
31
|
-
title
|
|
68
|
+
title?: string;
|
|
32
69
|
content: RichText.Paragraph[];
|
|
33
70
|
};
|
|
34
71
|
}
|
|
35
72
|
namespace RichText {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
tag: string;
|
|
73
|
+
type Style = 'bold' | 'italic' | 'underline' | 'lineThrough';
|
|
74
|
+
interface BaseElement<T extends string = string> {
|
|
75
|
+
tag: T;
|
|
40
76
|
}
|
|
41
|
-
interface
|
|
42
|
-
tag: 'text';
|
|
77
|
+
interface TextElement extends BaseElement<'text'> {
|
|
43
78
|
text: string;
|
|
44
79
|
un_escape?: boolean;
|
|
80
|
+
style?: Style[];
|
|
45
81
|
}
|
|
46
|
-
interface
|
|
47
|
-
tag: 'a';
|
|
82
|
+
interface LinkElement extends BaseElement<'a'> {
|
|
48
83
|
text: string;
|
|
49
84
|
href: string;
|
|
85
|
+
style?: Style[];
|
|
50
86
|
}
|
|
51
|
-
interface
|
|
52
|
-
tag: 'at';
|
|
87
|
+
interface AtElement extends BaseElement<'at'> {
|
|
53
88
|
user_id: string;
|
|
54
|
-
|
|
89
|
+
style?: Style[];
|
|
55
90
|
}
|
|
56
|
-
interface
|
|
57
|
-
tag: 'img';
|
|
91
|
+
interface ImageElement extends BaseElement<'img'> {
|
|
58
92
|
image_key: string;
|
|
59
|
-
height?: number;
|
|
60
|
-
width?: number;
|
|
61
93
|
}
|
|
62
|
-
interface
|
|
63
|
-
tag: 'media';
|
|
94
|
+
interface MediaElement extends BaseElement<'media'> {
|
|
64
95
|
file_key: string;
|
|
65
96
|
image_key?: string;
|
|
66
97
|
}
|
|
67
|
-
|
|
98
|
+
interface EmotionElement extends BaseElement<'emoji'> {
|
|
99
|
+
emoji_type: string;
|
|
100
|
+
}
|
|
101
|
+
interface CodeBlockElement extends BaseElement<'code_block'> {
|
|
102
|
+
language?: string;
|
|
103
|
+
text: string;
|
|
104
|
+
}
|
|
105
|
+
interface HRElement extends BaseElement<'hr'> {
|
|
106
|
+
}
|
|
107
|
+
interface MarkdownElement extends BaseElement<'md'> {
|
|
108
|
+
text: string;
|
|
109
|
+
}
|
|
110
|
+
type InlineElement = TextElement | LinkElement | AtElement | EmotionElement | MarkdownElement;
|
|
111
|
+
type BlockElement = ImageElement | MediaElement | CodeBlockElement | HRElement;
|
|
112
|
+
type Paragraph = InlineElement[] | [BlockElement];
|
|
113
|
+
}
|
|
114
|
+
interface Card {
|
|
115
|
+
config?: Card.Config;
|
|
116
|
+
card_link?: Card.URLs;
|
|
117
|
+
header?: Card.Header;
|
|
118
|
+
elements: Card.Element[];
|
|
119
|
+
}
|
|
120
|
+
namespace Card {
|
|
121
|
+
/** @see https://open.larksuite.com/document/common-capabilities/message-card/getting-started/card-structure/card-configuration */
|
|
122
|
+
interface Config {
|
|
123
|
+
enable_forward?: boolean;
|
|
124
|
+
update_multi?: boolean;
|
|
125
|
+
}
|
|
126
|
+
interface URLs {
|
|
127
|
+
url: string;
|
|
128
|
+
pc_url?: string;
|
|
129
|
+
ios_url?: string;
|
|
130
|
+
android_url?: string;
|
|
131
|
+
}
|
|
132
|
+
/** @see https://open.larksuite.com/document/common-capabilities/message-card/message-cards-content/card-header */
|
|
133
|
+
interface Header {
|
|
134
|
+
title: I18nPlainTextElement;
|
|
135
|
+
subtitle?: I18nPlainTextElement;
|
|
136
|
+
template?: Header.Template;
|
|
137
|
+
icon?: CustomIconElement;
|
|
138
|
+
ud_icon?: StandardIconElement;
|
|
139
|
+
text_tag_list?: TextTagElement[];
|
|
140
|
+
i18n_text_tag_list?: Record<string, TextTagElement[]>;
|
|
141
|
+
}
|
|
142
|
+
namespace Header {
|
|
143
|
+
type Template = 'blue' | 'wathet' | 'turquoise' | 'green' | 'yellow' | 'orange' | 'red' | 'carmine' | 'violet' | 'purple' | 'indigo' | 'grey' | 'default';
|
|
144
|
+
}
|
|
145
|
+
interface BaseElement<T extends string = string> {
|
|
146
|
+
tag: T;
|
|
147
|
+
}
|
|
148
|
+
type TextSize = 'heading-0' | 'heading-1' | 'heading-2' | 'heading-3' | 'heading-4' | 'heading' | 'normal' | 'notation' | 'xxxx-large' | 'xxx-large' | 'xx-large' | 'x-large' | 'large' | 'medium' | 'small' | 'x-small';
|
|
149
|
+
type TextAlign = 'left' | 'center' | 'right';
|
|
150
|
+
interface PlainTextElement extends BaseElement<'plain_text'> {
|
|
151
|
+
content: string;
|
|
152
|
+
}
|
|
153
|
+
interface I18nPlainTextElement extends PlainTextElement {
|
|
154
|
+
i18n?: Record<string, string>;
|
|
155
|
+
}
|
|
156
|
+
interface DivPlainTextElement extends PlainTextElement {
|
|
157
|
+
text_size?: TextSize;
|
|
158
|
+
text_color?: string;
|
|
159
|
+
text_align?: TextAlign;
|
|
160
|
+
lines?: number;
|
|
161
|
+
icon?: IconElement;
|
|
162
|
+
}
|
|
163
|
+
type IconElement = StandardIconElement | CustomIconElement;
|
|
164
|
+
interface CustomIconElement extends BaseElement<'custom_icon'> {
|
|
165
|
+
img_key: string;
|
|
166
|
+
}
|
|
167
|
+
interface StandardIconElement extends BaseElement<'standard_icon'> {
|
|
168
|
+
token: string;
|
|
169
|
+
color?: string;
|
|
170
|
+
}
|
|
171
|
+
interface TextTagElement extends BaseElement<'text_tag'> {
|
|
172
|
+
text: PlainTextElement;
|
|
173
|
+
color: TextTagElement.Color;
|
|
174
|
+
}
|
|
175
|
+
namespace TextTagElement {
|
|
176
|
+
type Color = 'neutral' | 'blue' | 'torqoise' | 'lime' | 'orange' | 'violet' | 'indigo' | 'wathet' | 'green' | 'yellow' | 'red' | 'purple' | 'carmine';
|
|
177
|
+
}
|
|
178
|
+
interface BaseImageElement extends BaseElement<'image'> {
|
|
179
|
+
img_key: string;
|
|
180
|
+
alt?: PlainTextElement;
|
|
181
|
+
}
|
|
182
|
+
interface ImageElement extends BaseImageElement {
|
|
183
|
+
title?: PlainTextElement;
|
|
184
|
+
transparent?: string;
|
|
185
|
+
preview?: boolean;
|
|
186
|
+
corner_radius?: string;
|
|
187
|
+
scale_type?: 'crop_center' | 'fit_horizontal' | 'crop_top';
|
|
188
|
+
size?: 'large' | 'medium' | 'small' | 'tiny' | 'stretch_without_padding' | 'stretch' | string;
|
|
189
|
+
/** @deprecated */
|
|
190
|
+
custom_width?: number;
|
|
191
|
+
/** @deprecated */
|
|
192
|
+
compact_width?: boolean;
|
|
193
|
+
/** @deprecated */
|
|
194
|
+
mode?: 'crop_center' | 'fit_horizontal' | 'large' | 'medium' | 'small' | 'tiny';
|
|
195
|
+
}
|
|
196
|
+
interface HRElement extends BaseElement<'hr'> {
|
|
197
|
+
}
|
|
198
|
+
interface DivElement extends BaseElement<'div'> {
|
|
199
|
+
text?: DivPlainTextElement;
|
|
200
|
+
}
|
|
201
|
+
interface MarkdownElement extends BaseElement<'markdown'> {
|
|
202
|
+
content: string;
|
|
203
|
+
text_size?: TextSize;
|
|
204
|
+
text_align?: TextAlign;
|
|
205
|
+
href?: Record<string, URLs>;
|
|
206
|
+
}
|
|
207
|
+
interface PersonElement extends BaseElement<'person'> {
|
|
208
|
+
user_id: string;
|
|
209
|
+
size?: 'large' | 'medium' | 'small' | 'extra_small';
|
|
210
|
+
}
|
|
211
|
+
interface PersonListElement extends BaseElement<'person_list'> {
|
|
212
|
+
persons: {
|
|
213
|
+
id: string;
|
|
214
|
+
}[];
|
|
215
|
+
size?: 'large' | 'medium' | 'small' | 'extra_small';
|
|
216
|
+
show_name?: boolean;
|
|
217
|
+
show_avatar?: boolean;
|
|
218
|
+
}
|
|
219
|
+
interface ChartElement extends BaseElement<'chart'> {
|
|
220
|
+
chart_spec: {};
|
|
221
|
+
aspect_ratio?: '1:1' | '2:1' | '4:3' | '16:9';
|
|
222
|
+
color_theme?: 'brand' | 'rainbow' | 'complementary' | 'converse' | 'primary';
|
|
223
|
+
preview?: boolean;
|
|
224
|
+
height?: 'auto' | string;
|
|
225
|
+
}
|
|
226
|
+
interface TableElement extends BaseElement<'table'> {
|
|
227
|
+
page_size?: number;
|
|
228
|
+
row_height?: 'low' | 'medium' | 'high' | string;
|
|
229
|
+
header_style?: TableElement.HeaderStyle;
|
|
230
|
+
columns: TableElement.Column[];
|
|
231
|
+
rows: object[];
|
|
232
|
+
}
|
|
233
|
+
namespace TableElement {
|
|
234
|
+
interface HeaderStyle {
|
|
235
|
+
text_align?: TextAlign;
|
|
236
|
+
text_size?: TextSize;
|
|
237
|
+
background_style?: 'grey' | 'none';
|
|
238
|
+
text_color?: 'default' | 'grey';
|
|
239
|
+
bold?: boolean;
|
|
240
|
+
lines?: number;
|
|
241
|
+
}
|
|
242
|
+
interface Column {
|
|
243
|
+
name: string;
|
|
244
|
+
display_name?: string;
|
|
245
|
+
width?: 'auto' | string;
|
|
246
|
+
horizontal_align?: 'left' | 'center' | 'right';
|
|
247
|
+
data_type?: 'text' | 'lark_md' | 'options' | 'number' | 'persons' | 'date' | 'markdown';
|
|
248
|
+
format?: {
|
|
249
|
+
percision?: number;
|
|
250
|
+
symbol?: string;
|
|
251
|
+
separator?: string;
|
|
252
|
+
};
|
|
253
|
+
date_format?: string;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
interface NoteElement extends BaseElement<'note'> {
|
|
257
|
+
elements: NoteElement.InnerElement[];
|
|
258
|
+
}
|
|
259
|
+
namespace NoteElement {
|
|
260
|
+
type InnerElement = IconElement | PlainTextElement | BaseImageElement;
|
|
261
|
+
}
|
|
262
|
+
interface FormElement extends BaseElement<'form'> {
|
|
263
|
+
name: string;
|
|
264
|
+
elements: Element[];
|
|
265
|
+
confirm?: ConfirmElement;
|
|
266
|
+
}
|
|
267
|
+
interface ActionElement extends BaseElement<'action'> {
|
|
268
|
+
actions: Element[];
|
|
269
|
+
layout?: 'bisected' | 'trisection' | 'flow';
|
|
270
|
+
}
|
|
271
|
+
type ActionBehavior = OpenURLBehavior | CallbackBehavior;
|
|
272
|
+
interface OpenURLBehavior {
|
|
273
|
+
type: 'open_url';
|
|
274
|
+
default_url: string;
|
|
275
|
+
pc_url?: string;
|
|
276
|
+
ios_url?: string;
|
|
277
|
+
android_url?: string;
|
|
278
|
+
}
|
|
279
|
+
interface CallbackBehavior {
|
|
280
|
+
type: 'callback';
|
|
281
|
+
value: Record<string, string>;
|
|
282
|
+
}
|
|
283
|
+
interface BaseButtonElement extends BaseElement<'button'> {
|
|
284
|
+
text: PlainTextElement;
|
|
285
|
+
size?: ButtonElement.Size;
|
|
286
|
+
icon?: IconElement;
|
|
287
|
+
disabled?: boolean;
|
|
288
|
+
behaviors?: ActionBehavior[];
|
|
289
|
+
}
|
|
290
|
+
interface ButtonElement extends BaseButtonElement {
|
|
291
|
+
type?: ButtonElement.Type;
|
|
292
|
+
width?: ButtonElement.Width;
|
|
293
|
+
hover_tips?: PlainTextElement;
|
|
294
|
+
disabled_tips?: PlainTextElement;
|
|
295
|
+
confirm?: {
|
|
296
|
+
title: PlainTextElement;
|
|
297
|
+
text: PlainTextElement;
|
|
298
|
+
};
|
|
299
|
+
name?: string;
|
|
300
|
+
required?: boolean;
|
|
301
|
+
action_type?: 'link' | 'request' | 'multi' | 'form_submit' | 'form_reset';
|
|
302
|
+
}
|
|
303
|
+
interface ConfirmElement {
|
|
304
|
+
title: PlainTextElement;
|
|
305
|
+
text: PlainTextElement;
|
|
306
|
+
}
|
|
307
|
+
interface InputElement extends BaseElement<'input'> {
|
|
308
|
+
name: string;
|
|
309
|
+
required?: boolean;
|
|
310
|
+
placeholder?: PlainTextElement;
|
|
311
|
+
default_value?: string;
|
|
312
|
+
disabled?: boolean;
|
|
313
|
+
width?: 'default' | 'fill' | string;
|
|
314
|
+
max_length?: number;
|
|
315
|
+
input_type?: 'text' | 'multiline_text' | 'password';
|
|
316
|
+
show_icon?: boolean;
|
|
317
|
+
rows?: number;
|
|
318
|
+
auto_resize?: boolean;
|
|
319
|
+
max_rows?: number;
|
|
320
|
+
label?: PlainTextElement;
|
|
321
|
+
label_position?: 'top' | 'left';
|
|
322
|
+
value?: string | object;
|
|
323
|
+
behaviors?: ActionBehavior[];
|
|
324
|
+
confirm?: ConfirmElement;
|
|
325
|
+
fallback?: {
|
|
326
|
+
tag?: string;
|
|
327
|
+
text?: PlainTextElement;
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
interface OverflowElement extends BaseElement<'overflow'> {
|
|
331
|
+
width?: 'default' | 'fill' | string;
|
|
332
|
+
options: OverflowElement.Option[];
|
|
333
|
+
value?: object;
|
|
334
|
+
confirm?: ConfirmElement;
|
|
335
|
+
}
|
|
336
|
+
namespace OverflowElement {
|
|
337
|
+
interface Option {
|
|
338
|
+
text?: PlainTextElement;
|
|
339
|
+
multi_url?: URLs;
|
|
340
|
+
value?: string;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
interface BaseSelectElement<T extends string = string> extends BaseElement<T> {
|
|
344
|
+
type?: 'default' | 'text';
|
|
345
|
+
name?: string;
|
|
346
|
+
required?: boolean;
|
|
347
|
+
disabled?: boolean;
|
|
348
|
+
placeholder?: PlainTextElement;
|
|
349
|
+
width?: 'default' | 'fill' | string;
|
|
350
|
+
confirm?: ConfirmElement;
|
|
351
|
+
}
|
|
352
|
+
interface OptionElement {
|
|
353
|
+
text: PlainTextElement;
|
|
354
|
+
icon?: IconElement;
|
|
355
|
+
value: string;
|
|
356
|
+
}
|
|
357
|
+
interface SelectElement extends BaseSelectElement<'select_static'> {
|
|
358
|
+
options: OptionElement[];
|
|
359
|
+
initial_option?: string;
|
|
360
|
+
}
|
|
361
|
+
interface MultiSelectElement extends BaseSelectElement<'multi_select_static'> {
|
|
362
|
+
options: OptionElement[];
|
|
363
|
+
selected_values?: string[];
|
|
364
|
+
}
|
|
365
|
+
interface SelectPersonElement extends BaseSelectElement<'select_person'> {
|
|
366
|
+
options?: {
|
|
367
|
+
value: string;
|
|
368
|
+
}[];
|
|
369
|
+
}
|
|
370
|
+
interface MultiSelectPersonElement extends BaseSelectElement<'multi_select_person'> {
|
|
371
|
+
options?: {
|
|
372
|
+
value: string;
|
|
373
|
+
}[];
|
|
374
|
+
selected_values?: string[];
|
|
375
|
+
}
|
|
376
|
+
interface DatePickerElement extends BaseSelectElement<'date_picker'> {
|
|
377
|
+
initial_date?: string;
|
|
378
|
+
value?: object;
|
|
379
|
+
}
|
|
380
|
+
interface TimePickerElement extends BaseSelectElement<'picker_time'> {
|
|
381
|
+
initial_time?: string;
|
|
382
|
+
value?: object;
|
|
383
|
+
}
|
|
384
|
+
interface DateTimePickerElement extends BaseSelectElement<'picker_datetime'> {
|
|
385
|
+
initial_datetime?: string;
|
|
386
|
+
value?: object;
|
|
387
|
+
}
|
|
388
|
+
interface CheckerElement extends BaseElement<'checker'> {
|
|
389
|
+
name?: string;
|
|
390
|
+
checked?: boolean;
|
|
391
|
+
disabled?: boolean;
|
|
392
|
+
text?: CheckerElement.TextElement;
|
|
393
|
+
overall_checkable?: boolean;
|
|
394
|
+
button_area?: {
|
|
395
|
+
pc_display_rule?: 'always' | 'on_hover';
|
|
396
|
+
buttons?: CheckerElement.ButtonElement[];
|
|
397
|
+
};
|
|
398
|
+
checked_style?: {
|
|
399
|
+
show_strikethrough?: boolean;
|
|
400
|
+
opacity?: number;
|
|
401
|
+
};
|
|
402
|
+
margin?: string;
|
|
403
|
+
padding?: string;
|
|
404
|
+
confirm?: ConfirmElement;
|
|
405
|
+
behaviors?: ActionBehavior[];
|
|
406
|
+
hover_tips?: PlainTextElement;
|
|
407
|
+
disable_tips?: PlainTextElement;
|
|
408
|
+
}
|
|
409
|
+
namespace CheckerElement {
|
|
410
|
+
interface TextElement extends PlainTextElement {
|
|
411
|
+
text_size?: 'normal' | 'heading' | 'notation';
|
|
412
|
+
text_color?: string;
|
|
413
|
+
text_align?: TextAlign;
|
|
414
|
+
}
|
|
415
|
+
interface ButtonElement extends BaseButtonElement {
|
|
416
|
+
type: 'text' | 'primary_text' | 'danger_text';
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
namespace ButtonElement {
|
|
420
|
+
type Size = 'tiny' | 'small' | 'medium' | 'large';
|
|
421
|
+
type Width = 'default' | 'fill' | string;
|
|
422
|
+
type Type = 'default' | 'primary' | 'danger' | 'text' | 'primary_text' | 'danger_text' | 'primary_filled' | 'danger_filled' | 'laser';
|
|
423
|
+
}
|
|
424
|
+
type Element = DivElement | MarkdownElement | HRElement | ActionElement | NoteElement | ChartElement | TableElement | ImageElement | FormElement | InputElement | ButtonElement;
|
|
425
|
+
}
|
|
426
|
+
interface Template {
|
|
427
|
+
type: 'template';
|
|
428
|
+
data: {
|
|
429
|
+
template_id: string;
|
|
430
|
+
template_variable: object;
|
|
431
|
+
};
|
|
68
432
|
}
|
|
69
433
|
}
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
import { Lark } from '..';
|
|
2
|
-
import { MessageContent } from './content';
|
|
1
|
+
import { Lark, MessageContent } from '..';
|
|
3
2
|
export * from './content';
|
|
4
|
-
export type MessageType = 'text' | 'post' | 'image' | 'file' | 'audio' | 'media' | 'sticker' | 'interactive' | 'share_chat' | 'share_user';
|
|
5
|
-
export interface MessageContentMap {
|
|
6
|
-
'text': MessageContent.Text;
|
|
7
|
-
'post': MessageContent.RichText;
|
|
8
|
-
'image': MessageContent.Image;
|
|
9
|
-
'file': MessageContent.File;
|
|
10
|
-
'audio': MessageContent.Audio;
|
|
11
|
-
'media': MessageContent.Media;
|
|
12
|
-
'sticker': MessageContent.Sticker;
|
|
13
|
-
'share_chat': MessageContent.ShareChat;
|
|
14
|
-
'share_user': MessageContent.ShareUser;
|
|
15
|
-
}
|
|
16
|
-
export type MessageContentType<T extends MessageType> = T extends keyof MessageContentMap ? MessageContentMap[T] : any;
|
|
17
3
|
declare module '../event' {
|
|
18
4
|
interface Events {
|
|
19
5
|
/**
|
|
@@ -33,7 +19,7 @@ declare module '../event' {
|
|
|
33
19
|
create_time: string;
|
|
34
20
|
chat_id: string;
|
|
35
21
|
chat_type: string;
|
|
36
|
-
message_type:
|
|
22
|
+
message_type: keyof MessageContent;
|
|
37
23
|
content: string;
|
|
38
24
|
mentions: {
|
|
39
25
|
key: string;
|
|
@@ -88,5 +74,21 @@ declare module '../event' {
|
|
|
88
74
|
open_chat_id: string;
|
|
89
75
|
};
|
|
90
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* 机器人自定义菜单事件
|
|
79
|
+
* @see https://open.feishu.cn/document/client-docs/bot-v3/events/menu
|
|
80
|
+
*/
|
|
81
|
+
'application.bot.menu_v6': {
|
|
82
|
+
operator: {
|
|
83
|
+
operator_name: string;
|
|
84
|
+
operator_id: {
|
|
85
|
+
union_id: string;
|
|
86
|
+
user_id: string;
|
|
87
|
+
open_id: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
event_key: string;
|
|
91
|
+
timestamp: number;
|
|
92
|
+
};
|
|
91
93
|
}
|
|
92
94
|
}
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, Session, Universal } from '@satorijs/core';
|
|
2
|
-
import {
|
|
2
|
+
import { LarkBot } from './bot';
|
|
3
3
|
import { EventPayload, Events, GetImChatResponse, Lark } from './types';
|
|
4
4
|
export type Sender = {
|
|
5
5
|
sender_id: Lark.UserIds;
|
|
@@ -10,8 +10,8 @@ export type Sender = {
|
|
|
10
10
|
tenant_key: string;
|
|
11
11
|
});
|
|
12
12
|
export declare function adaptSender(sender: Sender, session: Session): Session;
|
|
13
|
-
export declare function adaptMessage(bot:
|
|
14
|
-
export declare function adaptSession<C extends Context>(bot:
|
|
13
|
+
export declare function adaptMessage(bot: LarkBot, data: Events['im.message.receive_v1'], session: Session, details?: boolean): Promise<Session>;
|
|
14
|
+
export declare function adaptSession<C extends Context>(bot: LarkBot<C>, body: EventPayload): Promise<C[typeof import("cordis").Context.session]>;
|
|
15
15
|
export declare function decodeMessage(bot: LarkBot, body: Lark.Message, details?: boolean): Promise<Universal.Message>;
|
|
16
16
|
/**
|
|
17
17
|
* Get ID type from id string
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@satorijs/adapter-lark",
|
|
3
3
|
"description": "Lark (飞书) Adapter for Satorijs",
|
|
4
|
-
"version": "3.6.
|
|
4
|
+
"version": "3.6.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
],
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@cordisjs/plugin-server": "^0.2.4",
|
|
38
|
-
"@satorijs/core": "^4.2.
|
|
38
|
+
"@satorijs/core": "^4.2.10",
|
|
39
39
|
"cordis": "^3.18.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@satorijs/core": "^4.2.
|
|
42
|
+
"@satorijs/core": "^4.2.10"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/src/http.ts
CHANGED
|
@@ -3,29 +3,29 @@ import { ReadableStream } from 'node:stream/web'
|
|
|
3
3
|
import { Adapter, Context, Logger, Schema } from '@satorijs/core'
|
|
4
4
|
import {} from '@cordisjs/plugin-server'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { LarkBot } from './bot'
|
|
7
7
|
import { EventPayload } from './types'
|
|
8
8
|
import { adaptSession, Cipher } from './utils'
|
|
9
9
|
|
|
10
|
-
export class HttpServer<C extends Context = Context> extends Adapter<C,
|
|
10
|
+
export class HttpServer<C extends Context = Context> extends Adapter<C, LarkBot<C>> {
|
|
11
11
|
static inject = ['server']
|
|
12
12
|
|
|
13
13
|
private logger: Logger
|
|
14
14
|
private ciphers: Record<string, Cipher> = {}
|
|
15
15
|
|
|
16
|
-
constructor(ctx: C, bot:
|
|
16
|
+
constructor(ctx: C, bot: LarkBot<C>) {
|
|
17
17
|
super(ctx)
|
|
18
18
|
this.logger = ctx.logger('lark')
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
fork(ctx: C, bot:
|
|
21
|
+
fork(ctx: C, bot: LarkBot<C>) {
|
|
22
22
|
super.fork(ctx, bot)
|
|
23
23
|
|
|
24
24
|
this._refreshCipher()
|
|
25
25
|
return bot.initialize()
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async connect(bot:
|
|
28
|
+
async connect(bot: LarkBot) {
|
|
29
29
|
const { path } = bot.config
|
|
30
30
|
bot.ctx.server.post(path, (ctx) => {
|
|
31
31
|
this._refreshCipher()
|
|
@@ -72,10 +72,10 @@ export class HttpServer<C extends Context = Context> extends Adapter<C, FeishuBo
|
|
|
72
72
|
|
|
73
73
|
// dispatch message
|
|
74
74
|
bot.logger.debug('received decryped event: %o', body)
|
|
75
|
-
// @TODO: need await?
|
|
76
75
|
this.dispatchSession(body)
|
|
77
76
|
|
|
78
77
|
// Lark requires 200 OK response to make sure event is received
|
|
78
|
+
ctx.body = {}
|
|
79
79
|
return ctx.status = 200
|
|
80
80
|
})
|
|
81
81
|
|