@satorijs/adapter-lark 3.11.5 → 3.11.7
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/content.d.ts +4 -4
- package/lib/index.cjs +56 -7
- package/lib/message.d.ts +1 -1
- package/package.json +1 -1
- package/src/content.ts +4 -4
- package/src/message.ts +56 -7
package/lib/content.d.ts
CHANGED
|
@@ -124,11 +124,11 @@ export declare namespace MessageContent {
|
|
|
124
124
|
interface Config {
|
|
125
125
|
streaming_mode?: boolean;
|
|
126
126
|
streaming_config?: StreamingConfig;
|
|
127
|
-
summary
|
|
127
|
+
summary?: {
|
|
128
128
|
content: string;
|
|
129
129
|
i18n_content?: Record<string, string>;
|
|
130
130
|
};
|
|
131
|
-
locales
|
|
131
|
+
locales?: string[];
|
|
132
132
|
enable_forward?: boolean;
|
|
133
133
|
update_multi?: boolean;
|
|
134
134
|
width_mode?: 'compact' | 'fill';
|
|
@@ -290,7 +290,7 @@ export declare namespace MessageContent {
|
|
|
290
290
|
/** @see https://open.feishu.cn/document/feishu-cards/card-json-v2-components/content-components/image */
|
|
291
291
|
interface ImageElement extends BaseImageElement {
|
|
292
292
|
title?: TextElement;
|
|
293
|
-
transparent?:
|
|
293
|
+
transparent?: boolean;
|
|
294
294
|
preview?: boolean;
|
|
295
295
|
corner_radius?: string;
|
|
296
296
|
scale_type?: 'crop_center' | 'fit_horizontal' | 'crop_top';
|
|
@@ -542,7 +542,7 @@ export declare namespace MessageContent {
|
|
|
542
542
|
confirm?: ConfirmElement;
|
|
543
543
|
behaviors?: ActionBehavior[];
|
|
544
544
|
hover_tips?: TextElement;
|
|
545
|
-
|
|
545
|
+
disabled_tips?: TextElement;
|
|
546
546
|
}
|
|
547
547
|
namespace CheckerElement {
|
|
548
548
|
interface Text extends Card.TextElement<'plain_text' | 'lark_md'> {
|
package/lib/index.cjs
CHANGED
|
@@ -770,7 +770,7 @@ var LarkMessageEncoder = class extends import_core3.MessageEncoder {
|
|
|
770
770
|
richContent = [];
|
|
771
771
|
card;
|
|
772
772
|
elements = [];
|
|
773
|
-
|
|
773
|
+
inline = false;
|
|
774
774
|
editMessageIds;
|
|
775
775
|
async post(data) {
|
|
776
776
|
try {
|
|
@@ -966,6 +966,20 @@ var LarkMessageEncoder = class extends import_core3.MessageEncoder {
|
|
|
966
966
|
} else if (["video", "audio", "file"].includes(type)) {
|
|
967
967
|
await this.flush();
|
|
968
968
|
await this.sendFile(type, attrs);
|
|
969
|
+
} else if (type === "lark:img") {
|
|
970
|
+
this.flushText();
|
|
971
|
+
this.elements.push({
|
|
972
|
+
tag: "img",
|
|
973
|
+
alt: attrs.alt,
|
|
974
|
+
img_key: attrs.imgKey,
|
|
975
|
+
transparent: attrs.transparent,
|
|
976
|
+
preview: attrs.preview,
|
|
977
|
+
corner_radius: attrs.cornerRadius,
|
|
978
|
+
scale_type: attrs.scaleType,
|
|
979
|
+
size: attrs.size,
|
|
980
|
+
mode: attrs.mode,
|
|
981
|
+
margin: attrs.margin
|
|
982
|
+
});
|
|
969
983
|
} else if (type === "figure" || type === "message") {
|
|
970
984
|
await this.flush();
|
|
971
985
|
await this.render(children, true);
|
|
@@ -981,9 +995,7 @@ var LarkMessageEncoder = class extends import_core3.MessageEncoder {
|
|
|
981
995
|
name: attrs.name || "Form",
|
|
982
996
|
elements: this.elements = []
|
|
983
997
|
});
|
|
984
|
-
this.isForm = true;
|
|
985
998
|
await this.render(children);
|
|
986
|
-
this.isForm = false;
|
|
987
999
|
this.elements = parent;
|
|
988
1000
|
} else if (type === "input") {
|
|
989
1001
|
if (attrs.type === "checkbox") {
|
|
@@ -997,6 +1009,14 @@ var LarkMessageEncoder = class extends import_core3.MessageEncoder {
|
|
|
997
1009
|
text: {
|
|
998
1010
|
tag: "lark_md",
|
|
999
1011
|
content: this.textContent
|
|
1012
|
+
},
|
|
1013
|
+
hover_tips: attrs.hoverTips && {
|
|
1014
|
+
tag: "plain_text",
|
|
1015
|
+
content: attrs.hoverTips
|
|
1016
|
+
},
|
|
1017
|
+
disabled_tips: attrs.disabledTips && {
|
|
1018
|
+
tag: "plain_text",
|
|
1019
|
+
content: attrs.disabledTips
|
|
1000
1020
|
}
|
|
1001
1021
|
});
|
|
1002
1022
|
this.textContent = "";
|
|
@@ -1029,6 +1049,10 @@ var LarkMessageEncoder = class extends import_core3.MessageEncoder {
|
|
|
1029
1049
|
tag: "plain_text",
|
|
1030
1050
|
content: attrs.placeholder
|
|
1031
1051
|
},
|
|
1052
|
+
disabled_tips: attrs.disabledTips && {
|
|
1053
|
+
tag: "plain_text",
|
|
1054
|
+
content: attrs.disabledTips
|
|
1055
|
+
},
|
|
1032
1056
|
default_value: attrs.value,
|
|
1033
1057
|
disabled: attrs.disabled,
|
|
1034
1058
|
required: attrs.required,
|
|
@@ -1083,20 +1107,22 @@ var LarkMessageEncoder = class extends import_core3.MessageEncoder {
|
|
|
1083
1107
|
token: attrs["lark:icon"],
|
|
1084
1108
|
color: attrs["lark:icon-color"]
|
|
1085
1109
|
},
|
|
1086
|
-
hover_tips: attrs
|
|
1110
|
+
hover_tips: attrs.hoverTips && {
|
|
1087
1111
|
tag: "plain_text",
|
|
1088
|
-
content: attrs
|
|
1112
|
+
content: attrs.hoverTips
|
|
1089
1113
|
},
|
|
1090
|
-
disabled_tips: attrs
|
|
1114
|
+
disabled_tips: attrs.disabledTips && {
|
|
1091
1115
|
tag: "plain_text",
|
|
1092
|
-
content: attrs
|
|
1116
|
+
content: attrs.disabledTips
|
|
1093
1117
|
},
|
|
1094
1118
|
behaviors: this.createBehaviors(attrs)
|
|
1095
1119
|
});
|
|
1096
1120
|
this.textContent = "";
|
|
1097
1121
|
} else if (type === "div") {
|
|
1098
1122
|
this.flushText();
|
|
1123
|
+
this.inline = true;
|
|
1099
1124
|
await this.render(children);
|
|
1125
|
+
this.inline = false;
|
|
1100
1126
|
this.elements.push({
|
|
1101
1127
|
tag: "markdown",
|
|
1102
1128
|
text_align: attrs.align,
|
|
@@ -1140,6 +1166,15 @@ var LarkMessageEncoder = class extends import_core3.MessageEncoder {
|
|
|
1140
1166
|
await this.flush();
|
|
1141
1167
|
this.card = {
|
|
1142
1168
|
schema: "2.0",
|
|
1169
|
+
config: {
|
|
1170
|
+
summary: attrs.summary && {
|
|
1171
|
+
content: attrs.summary
|
|
1172
|
+
},
|
|
1173
|
+
enable_forward: attrs.enableForward,
|
|
1174
|
+
update_multi: attrs.updateMulti,
|
|
1175
|
+
enable_forward_interaction: attrs.enableForwardInteraction,
|
|
1176
|
+
style: typeof attrs.style === "string" ? JSON.parse(attrs.style) : attrs.style
|
|
1177
|
+
},
|
|
1143
1178
|
header: attrs.title && {
|
|
1144
1179
|
template: attrs.color,
|
|
1145
1180
|
icon: attrs.icon && {
|
|
@@ -1157,6 +1192,12 @@ var LarkMessageEncoder = class extends import_core3.MessageEncoder {
|
|
|
1157
1192
|
}
|
|
1158
1193
|
},
|
|
1159
1194
|
body: {
|
|
1195
|
+
direction: attrs.direction,
|
|
1196
|
+
padding: attrs.padding,
|
|
1197
|
+
horizontal_spacing: attrs.horizontalSpacing,
|
|
1198
|
+
horizontal_align: attrs.horizontalAlign,
|
|
1199
|
+
vertical_spacing: attrs.verticalSpacing,
|
|
1200
|
+
vertical_align: attrs.verticalAlign,
|
|
1160
1201
|
elements: this.elements = []
|
|
1161
1202
|
}
|
|
1162
1203
|
};
|
|
@@ -1181,6 +1222,14 @@ var LarkMessageEncoder = class extends import_core3.MessageEncoder {
|
|
|
1181
1222
|
border_color: attrs.borderColor,
|
|
1182
1223
|
corner_radius: attrs.cornerRadius,
|
|
1183
1224
|
elements: this.elements = [],
|
|
1225
|
+
hover_tips: attrs.hoverTips && {
|
|
1226
|
+
tag: "plain_text",
|
|
1227
|
+
content: attrs.hoverTips
|
|
1228
|
+
},
|
|
1229
|
+
disabled_tips: attrs.disabledTips && {
|
|
1230
|
+
tag: "plain_text",
|
|
1231
|
+
content: attrs.disabledTips
|
|
1232
|
+
},
|
|
1184
1233
|
behaviors: this.createBehaviors(attrs)
|
|
1185
1234
|
});
|
|
1186
1235
|
await this.render(children);
|
package/lib/message.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class LarkMessageEncoder<C extends Context = Context> extends Mes
|
|
|
8
8
|
private richContent;
|
|
9
9
|
private card;
|
|
10
10
|
private elements;
|
|
11
|
-
private
|
|
11
|
+
private inline;
|
|
12
12
|
editMessageIds: string[] | undefined;
|
|
13
13
|
post(data?: any): Promise<void>;
|
|
14
14
|
private flushText;
|
package/package.json
CHANGED
package/src/content.ts
CHANGED
|
@@ -164,11 +164,11 @@ export namespace MessageContent {
|
|
|
164
164
|
export interface Config {
|
|
165
165
|
streaming_mode?: boolean
|
|
166
166
|
streaming_config?: StreamingConfig
|
|
167
|
-
summary
|
|
167
|
+
summary?: {
|
|
168
168
|
content: string
|
|
169
169
|
i18n_content?: Record<string, string>
|
|
170
170
|
}
|
|
171
|
-
locales
|
|
171
|
+
locales?: string[]
|
|
172
172
|
enable_forward?: boolean
|
|
173
173
|
update_multi?: boolean
|
|
174
174
|
width_mode?: 'compact' | 'fill'
|
|
@@ -355,7 +355,7 @@ export namespace MessageContent {
|
|
|
355
355
|
/** @see https://open.feishu.cn/document/feishu-cards/card-json-v2-components/content-components/image */
|
|
356
356
|
export interface ImageElement extends BaseImageElement {
|
|
357
357
|
title?: TextElement
|
|
358
|
-
transparent?:
|
|
358
|
+
transparent?: boolean
|
|
359
359
|
preview?: boolean
|
|
360
360
|
corner_radius?: string
|
|
361
361
|
scale_type?: 'crop_center' | 'fit_horizontal' | 'crop_top'
|
|
@@ -633,7 +633,7 @@ export namespace MessageContent {
|
|
|
633
633
|
confirm?: ConfirmElement
|
|
634
634
|
behaviors?: ActionBehavior[]
|
|
635
635
|
hover_tips?: TextElement
|
|
636
|
-
|
|
636
|
+
disabled_tips?: TextElement
|
|
637
637
|
}
|
|
638
638
|
|
|
639
639
|
export namespace CheckerElement {
|
package/src/message.ts
CHANGED
|
@@ -12,7 +12,7 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
|
|
|
12
12
|
private richContent: MessageContent.RichText.Paragraph[] = []
|
|
13
13
|
private card: MessageContent.Card | undefined
|
|
14
14
|
private elements: MessageContent.Card.Element[] = []
|
|
15
|
-
private
|
|
15
|
+
private inline = false
|
|
16
16
|
|
|
17
17
|
public editMessageIds: string[] | undefined
|
|
18
18
|
|
|
@@ -230,6 +230,20 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
|
|
|
230
230
|
} else if (['video', 'audio', 'file'].includes(type)) {
|
|
231
231
|
await this.flush()
|
|
232
232
|
await this.sendFile(type as any, attrs)
|
|
233
|
+
} else if (type === 'lark:img') {
|
|
234
|
+
this.flushText()
|
|
235
|
+
this.elements.push({
|
|
236
|
+
tag: 'img',
|
|
237
|
+
alt: attrs.alt,
|
|
238
|
+
img_key: attrs.imgKey,
|
|
239
|
+
transparent: attrs.transparent,
|
|
240
|
+
preview: attrs.preview,
|
|
241
|
+
corner_radius: attrs.cornerRadius,
|
|
242
|
+
scale_type: attrs.scaleType,
|
|
243
|
+
size: attrs.size,
|
|
244
|
+
mode: attrs.mode,
|
|
245
|
+
margin: attrs.margin,
|
|
246
|
+
})
|
|
233
247
|
} else if (type === 'figure' || type === 'message') {
|
|
234
248
|
await this.flush()
|
|
235
249
|
await this.render(children, true)
|
|
@@ -245,9 +259,7 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
|
|
|
245
259
|
name: attrs.name || 'Form',
|
|
246
260
|
elements: this.elements = [],
|
|
247
261
|
})
|
|
248
|
-
this.isForm = true
|
|
249
262
|
await this.render(children)
|
|
250
|
-
this.isForm = false
|
|
251
263
|
this.elements = parent
|
|
252
264
|
} else if (type === 'input') {
|
|
253
265
|
if (attrs.type === 'checkbox') {
|
|
@@ -262,6 +274,14 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
|
|
|
262
274
|
tag: 'lark_md',
|
|
263
275
|
content: this.textContent,
|
|
264
276
|
},
|
|
277
|
+
hover_tips: attrs.hoverTips && {
|
|
278
|
+
tag: 'plain_text',
|
|
279
|
+
content: attrs.hoverTips,
|
|
280
|
+
},
|
|
281
|
+
disabled_tips: attrs.disabledTips && {
|
|
282
|
+
tag: 'plain_text',
|
|
283
|
+
content: attrs.disabledTips,
|
|
284
|
+
},
|
|
265
285
|
})
|
|
266
286
|
this.textContent = ''
|
|
267
287
|
} else if (attrs.type === 'submit') {
|
|
@@ -293,6 +313,10 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
|
|
|
293
313
|
tag: 'plain_text',
|
|
294
314
|
content: attrs.placeholder,
|
|
295
315
|
},
|
|
316
|
+
disabled_tips: attrs.disabledTips && {
|
|
317
|
+
tag: 'plain_text',
|
|
318
|
+
content: attrs.disabledTips,
|
|
319
|
+
},
|
|
296
320
|
default_value: attrs.value,
|
|
297
321
|
disabled: attrs.disabled,
|
|
298
322
|
required: attrs.required,
|
|
@@ -347,20 +371,22 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
|
|
|
347
371
|
token: attrs['lark:icon'],
|
|
348
372
|
color: attrs['lark:icon-color'],
|
|
349
373
|
},
|
|
350
|
-
hover_tips: attrs
|
|
374
|
+
hover_tips: attrs.hoverTips && {
|
|
351
375
|
tag: 'plain_text',
|
|
352
|
-
content: attrs
|
|
376
|
+
content: attrs.hoverTips,
|
|
353
377
|
},
|
|
354
|
-
disabled_tips: attrs
|
|
378
|
+
disabled_tips: attrs.disabledTips && {
|
|
355
379
|
tag: 'plain_text',
|
|
356
|
-
content: attrs
|
|
380
|
+
content: attrs.disabledTips,
|
|
357
381
|
},
|
|
358
382
|
behaviors: this.createBehaviors(attrs),
|
|
359
383
|
})
|
|
360
384
|
this.textContent = ''
|
|
361
385
|
} else if (type === 'div') {
|
|
362
386
|
this.flushText()
|
|
387
|
+
this.inline = true
|
|
363
388
|
await this.render(children)
|
|
389
|
+
this.inline = false
|
|
364
390
|
this.elements.push({
|
|
365
391
|
tag: 'markdown',
|
|
366
392
|
text_align: attrs.align,
|
|
@@ -404,6 +430,15 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
|
|
|
404
430
|
await this.flush()
|
|
405
431
|
this.card = {
|
|
406
432
|
schema: '2.0',
|
|
433
|
+
config: {
|
|
434
|
+
summary: attrs.summary && {
|
|
435
|
+
content: attrs.summary,
|
|
436
|
+
},
|
|
437
|
+
enable_forward: attrs.enableForward,
|
|
438
|
+
update_multi: attrs.updateMulti,
|
|
439
|
+
enable_forward_interaction: attrs.enableForwardInteraction,
|
|
440
|
+
style: typeof attrs.style === 'string' ? JSON.parse(attrs.style) : attrs.style,
|
|
441
|
+
},
|
|
407
442
|
header: attrs.title && {
|
|
408
443
|
template: attrs.color,
|
|
409
444
|
icon: attrs.icon && {
|
|
@@ -421,6 +456,12 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
|
|
|
421
456
|
},
|
|
422
457
|
},
|
|
423
458
|
body: {
|
|
459
|
+
direction: attrs.direction,
|
|
460
|
+
padding: attrs.padding,
|
|
461
|
+
horizontal_spacing: attrs.horizontalSpacing,
|
|
462
|
+
horizontal_align: attrs.horizontalAlign,
|
|
463
|
+
vertical_spacing: attrs.verticalSpacing,
|
|
464
|
+
vertical_align: attrs.verticalAlign,
|
|
424
465
|
elements: this.elements = [],
|
|
425
466
|
},
|
|
426
467
|
}
|
|
@@ -445,6 +486,14 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
|
|
|
445
486
|
border_color: attrs.borderColor,
|
|
446
487
|
corner_radius: attrs.cornerRadius,
|
|
447
488
|
elements: this.elements = [],
|
|
489
|
+
hover_tips: attrs.hoverTips && {
|
|
490
|
+
tag: 'plain_text',
|
|
491
|
+
content: attrs.hoverTips,
|
|
492
|
+
},
|
|
493
|
+
disabled_tips: attrs.disabledTips && {
|
|
494
|
+
tag: 'plain_text',
|
|
495
|
+
content: attrs.disabledTips,
|
|
496
|
+
},
|
|
448
497
|
behaviors: this.createBehaviors(attrs),
|
|
449
498
|
})
|
|
450
499
|
await this.render(children)
|