|
| 1 | +export type ClientConfig = { |
| 2 | + channelAccessToken: string; |
| 3 | +}; |
| 4 | + |
| 5 | +export type MiddlewareConfig = { |
| 6 | + channelSecret: string; |
| 7 | +}; |
| 8 | + |
| 9 | +export type Config = ClientConfig | MiddlewareConfig; |
| 10 | + |
| 11 | +export type Profile = { |
| 12 | + displayName: string; |
| 13 | + userId: string; |
| 14 | + pictureUrl: string; |
| 15 | + statusMessage: string; |
| 16 | +}; |
| 17 | + |
| 18 | +export type WebhookEvent = |
| 19 | + | MessageEvent |
| 20 | + | FollowEvent |
| 21 | + | UnfollowEvent |
| 22 | + | JoinEvent |
| 23 | + | LeaveEvent |
| 24 | + | PostbackEvent |
| 25 | + | BeaconEvent; |
| 26 | + |
| 27 | +export type EventBase = { |
| 28 | + timestamp: number; |
| 29 | + source: EventSource; |
| 30 | +}; |
| 31 | + |
| 32 | +export type EventSource = User | Group | Room; |
| 33 | + |
| 34 | +export type User = { type: "user"; userId: string }; |
| 35 | + |
| 36 | +export type Group = { type: "group"; groupId: string; userId?: string }; |
| 37 | + |
| 38 | +export type Room = { type: "room"; roomId: string; userId?: string }; |
| 39 | + |
| 40 | +export type ReplyableEvent = EventBase & { replyToken: string }; |
| 41 | + |
| 42 | +export type MessageEvent = { |
| 43 | + type: "message"; |
| 44 | + message: EventMessage; |
| 45 | +} & ReplyableEvent; |
| 46 | + |
| 47 | +export type FollowEvent = { type: "follow" } & ReplyableEvent; |
| 48 | + |
| 49 | +export type UnfollowEvent = { type: "unfollow" } & EventBase; |
| 50 | + |
| 51 | +export type JoinEvent = { type: "join" } & ReplyableEvent; |
| 52 | + |
| 53 | +export type LeaveEvent = { type: "leave" } & EventBase; |
| 54 | + |
| 55 | +export type PostbackEvent = { |
| 56 | + type: "postback"; |
| 57 | + postback: Postback; |
| 58 | +} & ReplyableEvent; |
| 59 | + |
| 60 | +export type BeaconEvent = ReplyableEvent & { |
| 61 | + type: "beacon"; |
| 62 | + beacon: { |
| 63 | + type: "enter" | "leave" | "banner"; |
| 64 | + hwid: string; |
| 65 | + dm?: string; |
| 66 | + }; |
| 67 | +}; |
| 68 | + |
| 69 | +export type EventMessage = |
| 70 | + | TextEventMessage |
| 71 | + | ImageEventMessage |
| 72 | + | VideoEventMessage |
| 73 | + | AudioEventMessage |
| 74 | + | LocationEventMessage |
| 75 | + | StickerEventMessage; |
| 76 | + |
| 77 | +export type EventMessageBase = { id: string }; |
| 78 | + |
| 79 | +export type TextEventMessage = { |
| 80 | + type: "text"; |
| 81 | + text: string; |
| 82 | +} & EventMessageBase; |
| 83 | + |
| 84 | +export type ImageEventMessage = { type: "image" } & EventMessageBase; |
| 85 | + |
| 86 | +export type VideoEventMessage = { type: "video" } & EventMessageBase; |
| 87 | + |
| 88 | +export type AudioEventMessage = { type: "audio" } & EventMessageBase; |
| 89 | + |
| 90 | +export type FileEventMessage = { |
| 91 | + type: "file"; |
| 92 | + fileName: string; |
| 93 | + fileSize: string; |
| 94 | +} & EventMessageBase; |
| 95 | + |
| 96 | +export type LocationEventMessage = { |
| 97 | + type: "location"; |
| 98 | + title: string; |
| 99 | + address: string; |
| 100 | + latitude: number; |
| 101 | + longitude: number; |
| 102 | +} & EventMessageBase; |
| 103 | + |
| 104 | +export type StickerEventMessage = { |
| 105 | + type: "sticker"; |
| 106 | + packageId: string; |
| 107 | + stickerId: string; |
| 108 | +} & EventMessageBase; |
| 109 | + |
| 110 | +export type Postback = { |
| 111 | + data: string; |
| 112 | + params?: { |
| 113 | + date?: string; |
| 114 | + time?: string; |
| 115 | + datetime?: string; |
| 116 | + }; |
| 117 | +}; |
| 118 | + |
| 119 | +export type Message = |
| 120 | + | TextMessage |
| 121 | + | ImageMessage |
| 122 | + | VideoMessage |
| 123 | + | AudioMessage |
| 124 | + | LocationMessage |
| 125 | + | StickerMessage |
| 126 | + | ImageMapMessage |
| 127 | + | TemplateMessage; |
| 128 | + |
| 129 | +export type TextMessage = { |
| 130 | + type: "text"; |
| 131 | + text: string; |
| 132 | +}; |
| 133 | + |
| 134 | +export type ImageMessage = { |
| 135 | + type: "image"; |
| 136 | + originalContentUrl: string; |
| 137 | + previewImageUrl: string; |
| 138 | +}; |
| 139 | + |
| 140 | +export type VideoMessage = { |
| 141 | + type: "video"; |
| 142 | + originalContentUrl: string; |
| 143 | + previewImageUrl: string; |
| 144 | +}; |
| 145 | + |
| 146 | +export type AudioMessage = { |
| 147 | + type: "audio"; |
| 148 | + originalContentUrl: string; |
| 149 | + duration: string; |
| 150 | +}; |
| 151 | + |
| 152 | +export type LocationMessage = { |
| 153 | + type: "location"; |
| 154 | + title: string; |
| 155 | + address: string; |
| 156 | + latitude: number; |
| 157 | + longitude: number; |
| 158 | +}; |
| 159 | + |
| 160 | +export type StickerMessage = { |
| 161 | + type: "sticker"; |
| 162 | + packageId: string; |
| 163 | + stickerId: string; |
| 164 | +}; |
| 165 | + |
| 166 | +export type ImageMapMessage = { |
| 167 | + type: "image"; |
| 168 | + baseUrl: string; |
| 169 | + altText: string; |
| 170 | + baseSize: { width: number; height: number }; |
| 171 | + actions: ImageMapAction[]; |
| 172 | +}; |
| 173 | + |
| 174 | +export type TemplateMessage = { |
| 175 | + type: "template"; |
| 176 | + altText: string; |
| 177 | + template: TemplateContent; |
| 178 | +}; |
| 179 | + |
| 180 | +export type ImageMapAction = ImageMapURIAction | ImageMapMessageAction; |
| 181 | + |
| 182 | +export type ImageMapActionBase = { area: ImageMapArea }; |
| 183 | + |
| 184 | +export type ImageMapURIAction = { |
| 185 | + type: "uri"; |
| 186 | + linkUri: string; |
| 187 | +} & ImageMapActionBase; |
| 188 | + |
| 189 | +export type ImageMapMessageAction = { |
| 190 | + type: "message"; |
| 191 | + text: string; |
| 192 | +} & ImageMapActionBase; |
| 193 | + |
| 194 | +export type ImageMapArea = { |
| 195 | + x: number; |
| 196 | + y: number; |
| 197 | + width: number; |
| 198 | + height: number; |
| 199 | +}; |
| 200 | + |
| 201 | +export type TemplateContent = |
| 202 | + | TemplateButtons |
| 203 | + | TemplateConfirm |
| 204 | + | TemplateCarousel |
| 205 | + | TemplateImageCarousel; |
| 206 | + |
| 207 | +export type TemplateButtons = { |
| 208 | + type: "buttons"; |
| 209 | + thumbnailImageUrl?: string; |
| 210 | + title?: string; |
| 211 | + text: string; |
| 212 | + actions: TemplateAction<{ label: string }>[]; |
| 213 | +}; |
| 214 | + |
| 215 | +export type TemplateConfirm = { |
| 216 | + type: "confirm"; |
| 217 | + text: string; |
| 218 | + actions: TemplateAction<{ label: string }>[]; |
| 219 | +}; |
| 220 | + |
| 221 | +export type TemplateCarousel = { type: "carousel"; columns: TemplateColumn[] }; |
| 222 | + |
| 223 | +export type TemplateColumn = { |
| 224 | + thumbnailImageUrl?: string; |
| 225 | + title?: string; |
| 226 | + text: string; |
| 227 | + actions: TemplateAction<{ label: string }>[]; |
| 228 | +}; |
| 229 | + |
| 230 | +export type TemplateImageCarousel = { |
| 231 | + type: "image_carousel"; |
| 232 | + columns: TemplateImageColumn; |
| 233 | +}; |
| 234 | + |
| 235 | +export type TemplateImageColumn = { |
| 236 | + imageUrl: string; |
| 237 | + action: TemplateAction<{ label?: string }>; |
| 238 | +}; |
| 239 | + |
| 240 | +export type TemplateAction<Label> = |
| 241 | + | TemplatePostbackAction & Label |
| 242 | + | TemplateMessageAction & Label |
| 243 | + | TemplateURIAction & Label |
| 244 | + | TemplateDatetimePickerAction & Label; |
| 245 | + |
| 246 | +export type TemplatePostbackAction = { |
| 247 | + type: "postback"; |
| 248 | + data: string; |
| 249 | + text?: string; |
| 250 | +}; |
| 251 | + |
| 252 | +export type TemplateMessageAction = { |
| 253 | + type: "message"; |
| 254 | + text: string; |
| 255 | +}; |
| 256 | + |
| 257 | +export type TemplateURIAction = { |
| 258 | + type: "uri"; |
| 259 | + uri: string; |
| 260 | +}; |
| 261 | + |
| 262 | +export type TemplateDatetimePickerAction = { |
| 263 | + type: "datetimepicker"; |
| 264 | + data: string; |
| 265 | + mode: "date" | "time" | "datetime"; |
| 266 | + initial?: string; |
| 267 | + max?: string; |
| 268 | + min?: string; |
| 269 | +}; |
0 commit comments