@gakr-gakr/line 0.1.0
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/api.ts +11 -0
- package/autobot.plugin.json +15 -0
- package/channel-plugin-api.ts +1 -0
- package/contract-api.ts +5 -0
- package/index.ts +54 -0
- package/package.json +60 -0
- package/runtime-api.ts +182 -0
- package/secret-contract-api.ts +4 -0
- package/setup-api.ts +2 -0
- package/setup-entry.ts +9 -0
- package/src/account-helpers.ts +16 -0
- package/src/accounts.ts +187 -0
- package/src/actions.ts +61 -0
- package/src/auto-reply-delivery.ts +200 -0
- package/src/bindings.ts +65 -0
- package/src/bot-access.ts +30 -0
- package/src/bot-handlers.ts +620 -0
- package/src/bot-message-context.ts +586 -0
- package/src/bot.ts +70 -0
- package/src/card-command.ts +347 -0
- package/src/channel-access-token.ts +14 -0
- package/src/channel-api.ts +17 -0
- package/src/channel-shared.ts +48 -0
- package/src/channel.runtime.ts +3 -0
- package/src/channel.setup.ts +11 -0
- package/src/channel.ts +155 -0
- package/src/config-adapter.ts +29 -0
- package/src/config-schema.ts +81 -0
- package/src/download.ts +34 -0
- package/src/flex-templates/basic-cards.ts +395 -0
- package/src/flex-templates/common.ts +20 -0
- package/src/flex-templates/media-control-cards.ts +555 -0
- package/src/flex-templates/message.ts +13 -0
- package/src/flex-templates/schedule-cards.ts +467 -0
- package/src/flex-templates/types.ts +22 -0
- package/src/flex-templates.ts +32 -0
- package/src/gateway.ts +129 -0
- package/src/group-keys.ts +65 -0
- package/src/group-policy.ts +22 -0
- package/src/markdown-to-line.ts +416 -0
- package/src/monitor-durable.ts +37 -0
- package/src/monitor.runtime.ts +1 -0
- package/src/monitor.ts +507 -0
- package/src/outbound-media.ts +120 -0
- package/src/outbound.runtime.ts +12 -0
- package/src/outbound.ts +427 -0
- package/src/probe.runtime.ts +1 -0
- package/src/probe.ts +34 -0
- package/src/quick-reply-fallback.ts +10 -0
- package/src/reply-chunks.ts +110 -0
- package/src/reply-payload-transform.ts +317 -0
- package/src/rich-menu.ts +326 -0
- package/src/runtime.ts +32 -0
- package/src/send-receipt.ts +32 -0
- package/src/send.ts +531 -0
- package/src/setup-core.ts +149 -0
- package/src/setup-runtime-api.ts +9 -0
- package/src/setup-surface.ts +229 -0
- package/src/signature.ts +24 -0
- package/src/status.ts +37 -0
- package/src/template-messages.ts +333 -0
- package/src/types.ts +130 -0
- package/src/webhook-node.ts +155 -0
- package/src/webhook-utils.ts +10 -0
- package/src/webhook.ts +135 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildChannelConfigSchema,
|
|
3
|
+
requireOpenAllowFrom,
|
|
4
|
+
} from "autobot/plugin-sdk/channel-config-schema";
|
|
5
|
+
import { requireChannelOpenAllowFrom } from "autobot/plugin-sdk/extension-shared";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
|
|
8
|
+
const DmPolicySchema = z.enum(["open", "allowlist", "pairing", "disabled"]);
|
|
9
|
+
const GroupPolicySchema = z.enum(["open", "allowlist", "disabled"]);
|
|
10
|
+
const ThreadBindingsSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
enabled: z.boolean().optional(),
|
|
13
|
+
idleHours: z.number().optional(),
|
|
14
|
+
maxAgeHours: z.number().optional(),
|
|
15
|
+
spawnSessions: z.boolean().optional(),
|
|
16
|
+
defaultSpawnContext: z.enum(["isolated", "fork"]).optional(),
|
|
17
|
+
spawnSubagentSessions: z.boolean().optional(),
|
|
18
|
+
spawnAcpSessions: z.boolean().optional(),
|
|
19
|
+
})
|
|
20
|
+
.strict();
|
|
21
|
+
|
|
22
|
+
const LineCommonConfigSchemaBase = z.object({
|
|
23
|
+
enabled: z.boolean().optional(),
|
|
24
|
+
channelAccessToken: z.string().optional(),
|
|
25
|
+
channelSecret: z.string().optional(),
|
|
26
|
+
tokenFile: z.string().optional(),
|
|
27
|
+
secretFile: z.string().optional(),
|
|
28
|
+
name: z.string().optional(),
|
|
29
|
+
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
30
|
+
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
31
|
+
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
|
32
|
+
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
|
33
|
+
responsePrefix: z.string().optional(),
|
|
34
|
+
mediaMaxMb: z.number().optional(),
|
|
35
|
+
webhookPath: z.string().optional(),
|
|
36
|
+
threadBindings: ThreadBindingsSchema.optional(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const LineGroupConfigSchema = z
|
|
40
|
+
.object({
|
|
41
|
+
enabled: z.boolean().optional(),
|
|
42
|
+
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
43
|
+
requireMention: z.boolean().optional(),
|
|
44
|
+
systemPrompt: z.string().optional(),
|
|
45
|
+
skills: z.array(z.string()).optional(),
|
|
46
|
+
})
|
|
47
|
+
.strict();
|
|
48
|
+
|
|
49
|
+
const LineAccountConfigSchema = LineCommonConfigSchemaBase.extend({
|
|
50
|
+
groups: z.record(z.string(), LineGroupConfigSchema.optional()).optional(),
|
|
51
|
+
})
|
|
52
|
+
.strict()
|
|
53
|
+
.superRefine((value, ctx) => {
|
|
54
|
+
requireChannelOpenAllowFrom({
|
|
55
|
+
channel: "line",
|
|
56
|
+
policy: value.dmPolicy,
|
|
57
|
+
allowFrom: value.allowFrom,
|
|
58
|
+
ctx,
|
|
59
|
+
requireOpenAllowFrom,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const LineConfigSchema = LineCommonConfigSchemaBase.extend({
|
|
64
|
+
accounts: z.record(z.string(), LineAccountConfigSchema.optional()).optional(),
|
|
65
|
+
defaultAccount: z.string().optional(),
|
|
66
|
+
groups: z.record(z.string(), LineGroupConfigSchema.optional()).optional(),
|
|
67
|
+
})
|
|
68
|
+
.strict()
|
|
69
|
+
.superRefine((value, ctx) => {
|
|
70
|
+
requireChannelOpenAllowFrom({
|
|
71
|
+
channel: "line",
|
|
72
|
+
policy: value.dmPolicy,
|
|
73
|
+
allowFrom: value.allowFrom,
|
|
74
|
+
ctx,
|
|
75
|
+
requireOpenAllowFrom,
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export const LineChannelConfigSchema = buildChannelConfigSchema(LineConfigSchema);
|
|
80
|
+
|
|
81
|
+
export type LineConfigSchemaType = z.infer<typeof LineConfigSchema>;
|
package/src/download.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { messagingApi } from "@line/bot-sdk";
|
|
2
|
+
import { saveMediaStream } from "autobot/plugin-sdk/media-store";
|
|
3
|
+
import { logVerbose } from "autobot/plugin-sdk/runtime-env";
|
|
4
|
+
|
|
5
|
+
interface DownloadResult {
|
|
6
|
+
path: string;
|
|
7
|
+
contentType?: string;
|
|
8
|
+
size: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function downloadLineMedia(
|
|
12
|
+
messageId: string,
|
|
13
|
+
channelAccessToken: string,
|
|
14
|
+
maxBytes = 10 * 1024 * 1024,
|
|
15
|
+
): Promise<DownloadResult> {
|
|
16
|
+
const client = new messagingApi.MessagingApiBlobClient({
|
|
17
|
+
channelAccessToken,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const response = await client.getMessageContent(messageId);
|
|
21
|
+
const saved = await saveMediaStream(
|
|
22
|
+
response as AsyncIterable<Buffer>,
|
|
23
|
+
undefined,
|
|
24
|
+
"inbound",
|
|
25
|
+
maxBytes,
|
|
26
|
+
);
|
|
27
|
+
logVerbose(`line: persisted media ${messageId} to ${saved.path} (${saved.size} bytes)`);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
path: saved.path,
|
|
31
|
+
contentType: saved.contentType,
|
|
32
|
+
size: saved.size,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { attachFooterText } from "./common.js";
|
|
2
|
+
import type {
|
|
3
|
+
Action,
|
|
4
|
+
CardAction,
|
|
5
|
+
FlexBox,
|
|
6
|
+
FlexBubble,
|
|
7
|
+
FlexButton,
|
|
8
|
+
FlexCarousel,
|
|
9
|
+
FlexComponent,
|
|
10
|
+
FlexImage,
|
|
11
|
+
FlexText,
|
|
12
|
+
ListItem,
|
|
13
|
+
} from "./types.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Create an info card with title, body, and optional footer
|
|
17
|
+
*
|
|
18
|
+
* Editorial design: Clean hierarchy with accent bar, generous spacing,
|
|
19
|
+
* and subtle background zones for visual separation.
|
|
20
|
+
*/
|
|
21
|
+
export function createInfoCard(title: string, body: string, footer?: string): FlexBubble {
|
|
22
|
+
const bubble: FlexBubble = {
|
|
23
|
+
type: "bubble",
|
|
24
|
+
size: "mega",
|
|
25
|
+
body: {
|
|
26
|
+
type: "box",
|
|
27
|
+
layout: "vertical",
|
|
28
|
+
contents: [
|
|
29
|
+
// Title with accent bar
|
|
30
|
+
{
|
|
31
|
+
type: "box",
|
|
32
|
+
layout: "horizontal",
|
|
33
|
+
contents: [
|
|
34
|
+
{
|
|
35
|
+
type: "box",
|
|
36
|
+
layout: "vertical",
|
|
37
|
+
contents: [],
|
|
38
|
+
width: "4px",
|
|
39
|
+
backgroundColor: "#06C755",
|
|
40
|
+
cornerRadius: "2px",
|
|
41
|
+
} as FlexBox,
|
|
42
|
+
{
|
|
43
|
+
type: "text",
|
|
44
|
+
text: title,
|
|
45
|
+
weight: "bold",
|
|
46
|
+
size: "xl",
|
|
47
|
+
color: "#111111",
|
|
48
|
+
wrap: true,
|
|
49
|
+
flex: 1,
|
|
50
|
+
margin: "lg",
|
|
51
|
+
} as FlexText,
|
|
52
|
+
],
|
|
53
|
+
} as FlexBox,
|
|
54
|
+
// Body text in subtle container
|
|
55
|
+
{
|
|
56
|
+
type: "box",
|
|
57
|
+
layout: "vertical",
|
|
58
|
+
contents: [
|
|
59
|
+
{
|
|
60
|
+
type: "text",
|
|
61
|
+
text: body,
|
|
62
|
+
size: "md",
|
|
63
|
+
color: "#444444",
|
|
64
|
+
wrap: true,
|
|
65
|
+
lineSpacing: "6px",
|
|
66
|
+
} as FlexText,
|
|
67
|
+
],
|
|
68
|
+
margin: "xl",
|
|
69
|
+
paddingAll: "lg",
|
|
70
|
+
backgroundColor: "#F8F9FA",
|
|
71
|
+
cornerRadius: "lg",
|
|
72
|
+
} as FlexBox,
|
|
73
|
+
],
|
|
74
|
+
paddingAll: "xl",
|
|
75
|
+
backgroundColor: "#FFFFFF",
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
if (footer) {
|
|
80
|
+
attachFooterText(bubble, footer);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return bubble;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Create a list card with title and multiple items
|
|
88
|
+
*
|
|
89
|
+
* Editorial design: Numbered/bulleted list with clear visual hierarchy,
|
|
90
|
+
* accent dots for each item, and generous spacing.
|
|
91
|
+
*/
|
|
92
|
+
export function createListCard(title: string, items: ListItem[]): FlexBubble {
|
|
93
|
+
const itemContents: FlexComponent[] = items.slice(0, 8).map((item, index) => {
|
|
94
|
+
const itemContents: FlexComponent[] = [
|
|
95
|
+
{
|
|
96
|
+
type: "text",
|
|
97
|
+
text: item.title,
|
|
98
|
+
size: "md",
|
|
99
|
+
weight: "bold",
|
|
100
|
+
color: "#1a1a1a",
|
|
101
|
+
wrap: true,
|
|
102
|
+
} as FlexText,
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
if (item.subtitle) {
|
|
106
|
+
itemContents.push({
|
|
107
|
+
type: "text",
|
|
108
|
+
text: item.subtitle,
|
|
109
|
+
size: "sm",
|
|
110
|
+
color: "#888888",
|
|
111
|
+
wrap: true,
|
|
112
|
+
margin: "xs",
|
|
113
|
+
} as FlexText);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const itemBox: FlexBox = {
|
|
117
|
+
type: "box",
|
|
118
|
+
layout: "horizontal",
|
|
119
|
+
contents: [
|
|
120
|
+
// Accent dot
|
|
121
|
+
{
|
|
122
|
+
type: "box",
|
|
123
|
+
layout: "vertical",
|
|
124
|
+
contents: [
|
|
125
|
+
{
|
|
126
|
+
type: "box",
|
|
127
|
+
layout: "vertical",
|
|
128
|
+
contents: [],
|
|
129
|
+
width: "8px",
|
|
130
|
+
height: "8px",
|
|
131
|
+
backgroundColor: index === 0 ? "#06C755" : "#DDDDDD",
|
|
132
|
+
cornerRadius: "4px",
|
|
133
|
+
} as FlexBox,
|
|
134
|
+
],
|
|
135
|
+
width: "20px",
|
|
136
|
+
alignItems: "center",
|
|
137
|
+
paddingTop: "sm",
|
|
138
|
+
} as FlexBox,
|
|
139
|
+
// Item content
|
|
140
|
+
{
|
|
141
|
+
type: "box",
|
|
142
|
+
layout: "vertical",
|
|
143
|
+
contents: itemContents,
|
|
144
|
+
flex: 1,
|
|
145
|
+
} as FlexBox,
|
|
146
|
+
],
|
|
147
|
+
margin: index > 0 ? "lg" : undefined,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
if (item.action) {
|
|
151
|
+
itemBox.action = item.action;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return itemBox;
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
type: "bubble",
|
|
159
|
+
size: "mega",
|
|
160
|
+
body: {
|
|
161
|
+
type: "box",
|
|
162
|
+
layout: "vertical",
|
|
163
|
+
contents: [
|
|
164
|
+
{
|
|
165
|
+
type: "text",
|
|
166
|
+
text: title,
|
|
167
|
+
weight: "bold",
|
|
168
|
+
size: "xl",
|
|
169
|
+
color: "#111111",
|
|
170
|
+
wrap: true,
|
|
171
|
+
} as FlexText,
|
|
172
|
+
{
|
|
173
|
+
type: "separator",
|
|
174
|
+
margin: "lg",
|
|
175
|
+
color: "#EEEEEE",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
type: "box",
|
|
179
|
+
layout: "vertical",
|
|
180
|
+
contents: itemContents,
|
|
181
|
+
margin: "lg",
|
|
182
|
+
} as FlexBox,
|
|
183
|
+
],
|
|
184
|
+
paddingAll: "xl",
|
|
185
|
+
backgroundColor: "#FFFFFF",
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Create an image card with image, title, and optional body text
|
|
192
|
+
*/
|
|
193
|
+
export function createImageCard(
|
|
194
|
+
imageUrl: string,
|
|
195
|
+
title: string,
|
|
196
|
+
body?: string,
|
|
197
|
+
options?: {
|
|
198
|
+
aspectRatio?: "1:1" | "1.51:1" | "1.91:1" | "4:3" | "16:9" | "20:13" | "2:1" | "3:1";
|
|
199
|
+
aspectMode?: "cover" | "fit";
|
|
200
|
+
action?: Action;
|
|
201
|
+
},
|
|
202
|
+
): FlexBubble {
|
|
203
|
+
const bubble: FlexBubble = {
|
|
204
|
+
type: "bubble",
|
|
205
|
+
hero: {
|
|
206
|
+
type: "image",
|
|
207
|
+
url: imageUrl,
|
|
208
|
+
size: "full",
|
|
209
|
+
aspectRatio: options?.aspectRatio ?? "20:13",
|
|
210
|
+
aspectMode: options?.aspectMode ?? "cover",
|
|
211
|
+
action: options?.action,
|
|
212
|
+
} as FlexImage,
|
|
213
|
+
body: {
|
|
214
|
+
type: "box",
|
|
215
|
+
layout: "vertical",
|
|
216
|
+
contents: [
|
|
217
|
+
{
|
|
218
|
+
type: "text",
|
|
219
|
+
text: title,
|
|
220
|
+
weight: "bold",
|
|
221
|
+
size: "xl",
|
|
222
|
+
wrap: true,
|
|
223
|
+
} as FlexText,
|
|
224
|
+
],
|
|
225
|
+
paddingAll: "lg",
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
if (body && bubble.body) {
|
|
230
|
+
bubble.body.contents.push({
|
|
231
|
+
type: "text",
|
|
232
|
+
text: body,
|
|
233
|
+
size: "md",
|
|
234
|
+
wrap: true,
|
|
235
|
+
margin: "md",
|
|
236
|
+
color: "#666666",
|
|
237
|
+
} as FlexText);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return bubble;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Create an action card with title, body, and action buttons
|
|
245
|
+
*/
|
|
246
|
+
export function createActionCard(
|
|
247
|
+
title: string,
|
|
248
|
+
body: string,
|
|
249
|
+
actions: CardAction[],
|
|
250
|
+
options?: {
|
|
251
|
+
imageUrl?: string;
|
|
252
|
+
aspectRatio?: "1:1" | "1.51:1" | "1.91:1" | "4:3" | "16:9" | "20:13" | "2:1" | "3:1";
|
|
253
|
+
},
|
|
254
|
+
): FlexBubble {
|
|
255
|
+
const bubble: FlexBubble = {
|
|
256
|
+
type: "bubble",
|
|
257
|
+
body: {
|
|
258
|
+
type: "box",
|
|
259
|
+
layout: "vertical",
|
|
260
|
+
contents: [
|
|
261
|
+
{
|
|
262
|
+
type: "text",
|
|
263
|
+
text: title,
|
|
264
|
+
weight: "bold",
|
|
265
|
+
size: "xl",
|
|
266
|
+
wrap: true,
|
|
267
|
+
} as FlexText,
|
|
268
|
+
{
|
|
269
|
+
type: "text",
|
|
270
|
+
text: body,
|
|
271
|
+
size: "md",
|
|
272
|
+
wrap: true,
|
|
273
|
+
margin: "md",
|
|
274
|
+
color: "#666666",
|
|
275
|
+
} as FlexText,
|
|
276
|
+
],
|
|
277
|
+
paddingAll: "lg",
|
|
278
|
+
},
|
|
279
|
+
footer: {
|
|
280
|
+
type: "box",
|
|
281
|
+
layout: "vertical",
|
|
282
|
+
contents: actions.slice(0, 4).map(
|
|
283
|
+
(action, index) =>
|
|
284
|
+
({
|
|
285
|
+
type: "button",
|
|
286
|
+
action: action.action,
|
|
287
|
+
style: index === 0 ? "primary" : "secondary",
|
|
288
|
+
margin: index > 0 ? "sm" : undefined,
|
|
289
|
+
}) as FlexButton,
|
|
290
|
+
),
|
|
291
|
+
paddingAll: "md",
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
if (options?.imageUrl) {
|
|
296
|
+
bubble.hero = {
|
|
297
|
+
type: "image",
|
|
298
|
+
url: options.imageUrl,
|
|
299
|
+
size: "full",
|
|
300
|
+
aspectRatio: options.aspectRatio ?? "20:13",
|
|
301
|
+
aspectMode: "cover",
|
|
302
|
+
} as FlexImage;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return bubble;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Create a carousel container from multiple bubbles
|
|
310
|
+
* LINE allows max 12 bubbles in a carousel
|
|
311
|
+
*/
|
|
312
|
+
export function createCarousel(bubbles: FlexBubble[]): FlexCarousel {
|
|
313
|
+
return {
|
|
314
|
+
type: "carousel",
|
|
315
|
+
contents: bubbles.slice(0, 12),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Create a notification bubble (for alerts, status updates)
|
|
321
|
+
*
|
|
322
|
+
* Editorial design: Bold status indicator with accent color,
|
|
323
|
+
* clear typography, optional icon for context.
|
|
324
|
+
*/
|
|
325
|
+
export function createNotificationBubble(
|
|
326
|
+
text: string,
|
|
327
|
+
options?: {
|
|
328
|
+
icon?: string;
|
|
329
|
+
type?: "info" | "success" | "warning" | "error";
|
|
330
|
+
title?: string;
|
|
331
|
+
},
|
|
332
|
+
): FlexBubble {
|
|
333
|
+
// Color based on notification type
|
|
334
|
+
const colors = {
|
|
335
|
+
info: { accent: "#3B82F6", bg: "#EFF6FF" },
|
|
336
|
+
success: { accent: "#06C755", bg: "#F0FDF4" },
|
|
337
|
+
warning: { accent: "#F59E0B", bg: "#FFFBEB" },
|
|
338
|
+
error: { accent: "#EF4444", bg: "#FEF2F2" },
|
|
339
|
+
};
|
|
340
|
+
const typeColors = colors[options?.type ?? "info"];
|
|
341
|
+
|
|
342
|
+
const contents: FlexComponent[] = [];
|
|
343
|
+
|
|
344
|
+
// Accent bar
|
|
345
|
+
contents.push({
|
|
346
|
+
type: "box",
|
|
347
|
+
layout: "vertical",
|
|
348
|
+
contents: [],
|
|
349
|
+
width: "4px",
|
|
350
|
+
backgroundColor: typeColors.accent,
|
|
351
|
+
cornerRadius: "2px",
|
|
352
|
+
} as FlexBox);
|
|
353
|
+
|
|
354
|
+
// Content section
|
|
355
|
+
const textContents: FlexComponent[] = [];
|
|
356
|
+
|
|
357
|
+
if (options?.title) {
|
|
358
|
+
textContents.push({
|
|
359
|
+
type: "text",
|
|
360
|
+
text: options.title,
|
|
361
|
+
size: "md",
|
|
362
|
+
weight: "bold",
|
|
363
|
+
color: "#111111",
|
|
364
|
+
wrap: true,
|
|
365
|
+
} as FlexText);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
textContents.push({
|
|
369
|
+
type: "text",
|
|
370
|
+
text,
|
|
371
|
+
size: options?.title ? "sm" : "md",
|
|
372
|
+
color: options?.title ? "#666666" : "#333333",
|
|
373
|
+
wrap: true,
|
|
374
|
+
margin: options?.title ? "sm" : undefined,
|
|
375
|
+
} as FlexText);
|
|
376
|
+
|
|
377
|
+
contents.push({
|
|
378
|
+
type: "box",
|
|
379
|
+
layout: "vertical",
|
|
380
|
+
contents: textContents,
|
|
381
|
+
flex: 1,
|
|
382
|
+
paddingStart: "lg",
|
|
383
|
+
} as FlexBox);
|
|
384
|
+
|
|
385
|
+
return {
|
|
386
|
+
type: "bubble",
|
|
387
|
+
body: {
|
|
388
|
+
type: "box",
|
|
389
|
+
layout: "horizontal",
|
|
390
|
+
contents,
|
|
391
|
+
paddingAll: "xl",
|
|
392
|
+
backgroundColor: typeColors.bg,
|
|
393
|
+
},
|
|
394
|
+
};
|
|
395
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FlexBox, FlexBubble, FlexText } from "./types.js";
|
|
2
|
+
|
|
3
|
+
export function attachFooterText(bubble: FlexBubble, footer: string) {
|
|
4
|
+
bubble.footer = {
|
|
5
|
+
type: "box",
|
|
6
|
+
layout: "vertical",
|
|
7
|
+
contents: [
|
|
8
|
+
{
|
|
9
|
+
type: "text",
|
|
10
|
+
text: footer,
|
|
11
|
+
size: "xs",
|
|
12
|
+
color: "#AAAAAA",
|
|
13
|
+
wrap: true,
|
|
14
|
+
align: "center",
|
|
15
|
+
} as FlexText,
|
|
16
|
+
],
|
|
17
|
+
paddingAll: "lg",
|
|
18
|
+
backgroundColor: "#FAFAFA",
|
|
19
|
+
} as FlexBox;
|
|
20
|
+
}
|