@@ -22,33 +22,33 @@ declare namespace Line {
22
22
statusMessage : string ,
23
23
} ;
24
24
25
- export type Typed = { type : string } ;
26
-
27
25
export type WebhookEvent =
28
26
MessageEvent | FollowEvent | UnfollowEvent | JoinEvent |
29
27
LeaveEvent | PostbackEvent | BeaconEvent ;
30
28
31
- export type EventBase = Typed & {
29
+ export type EventBase = {
32
30
timestamp : number ,
33
31
source : EventSource ,
34
32
} ;
35
33
36
34
export type EventSource = User | Group | Room ;
37
35
38
- export type User = Typed & { userId : string } ;
39
- export type Group = Typed & { groupId : string , userId ?: string } ;
40
- export type Room = Typed & { roomId : string , userId ?: string } ;
36
+ export type User = { type : "user" , userId : string } ;
37
+ export type Group = { type : "group" , groupId : string , userId ?: string } ;
38
+ export type Room = { type : "room" , roomId : string , userId ?: string } ;
41
39
42
40
export type ReplyableEvent = EventBase & { replyToken : string } ;
43
41
44
- export type MessageEvent = ReplyableEvent & { message : EventMessage } ;
45
- export type FollowEvent = ReplyableEvent ;
46
- export type UnfollowEvent = EventBase ;
47
- export type JoinEvent = ReplyableEvent ;
48
- export type LeaveEvent = EventBase ;
49
- export type PostbackEvent = ReplyableEvent & { postback : { data : string } } ;
42
+ export type MessageEvent = { type : "message" , message : EventMessage } & ReplyableEvent ;
43
+ export type FollowEvent = { type : "follow" } & ReplyableEvent ;
44
+ export type UnfollowEvent = { type : "unfollow" } & EventBase ;
45
+ export type JoinEvent = { type : "join" } & ReplyableEvent ;
46
+ export type LeaveEvent = { type : "leave" } & EventBase ;
47
+ export type PostbackEvent = { type : "postback" , postback : { data : string } } & ReplyableEvent ;
50
48
export type BeaconEvent = ReplyableEvent & {
51
- beacon : Typed & {
49
+ type : "beacon" ,
50
+ beacon : {
51
+ type : "enter" | "leave" | "banner" ,
52
52
hwid : string ,
53
53
dm ?: string ,
54
54
} ,
@@ -58,80 +58,94 @@ declare namespace Line {
58
58
TextEventMessage | ImageEventMessage | VideoEventMessage |
59
59
AudioEventMessage | LocationEventMessage | StickerEventMessage ;
60
60
61
- export type EventMessageBase = Typed & { id : string } ;
62
- export type TextEventMessage = EventMessageBase & { text : string } ;
63
- export type ImageEventMessage = EventMessageBase ;
64
- export type VideoEventMessage = EventMessageBase ;
65
- export type AudioEventMessage = EventMessageBase ;
66
- export type LocationEventMessage = EventMessageBase & {
61
+ export type EventMessageBase = { id : string } ;
62
+ export type TextEventMessage = { type : "text" , text : string } & EventMessageBase ;
63
+ export type ImageEventMessage = { type : "image" } & EventMessageBase ;
64
+ export type VideoEventMessage = { type : "video" } & EventMessageBase ;
65
+ export type AudioEventMessage = { type : "audio" } & EventMessageBase ;
66
+ export type LocationEventMessage = {
67
+ type : "location"
67
68
title : string ,
68
69
address : string ,
69
70
latitude : number ,
70
71
longitude : number ,
71
- } ;
72
- export type StickerEventMessage = EventMessageBase & {
72
+ } & EventMessageBase ;
73
+ export type StickerEventMessage = {
74
+ type : "sticker" ,
73
75
packageId : string ,
74
76
stickerId : string ,
75
- } ;
77
+ } & EventMessageBase ;
76
78
77
79
export type Message =
78
80
TextMessage | ImageMessage | VideoMessage | AudioMessage |
79
81
LocationMessage | StickerMessage | ImageMapMessage |
80
82
TemplateMessage ;
81
83
82
- export type TextMessage = Typed & { text : string } ;
83
- export type ImageMessage = Typed & {
84
+ export type TextMessage = {
85
+ type : "text" ,
86
+ text : string
87
+ } ;
88
+ export type ImageMessage = {
89
+ type : "image" ,
84
90
originalContentUrl : string ,
85
91
previewImageUrl : string ,
86
92
} ;
87
- export type VideoMessage = Typed & {
93
+ export type VideoMessage = {
94
+ type : "video" ,
88
95
originalContentUrl : string ,
89
96
previewImageUrl : string ,
90
97
} ;
91
- export type AudioMessage = Typed & {
98
+ export type AudioMessage = {
99
+ type : "audio" ,
92
100
originalContentUrl : string ,
93
101
duration : string ,
94
102
} ;
95
- export type LocationMessage = Typed & {
103
+ export type LocationMessage = {
104
+ type : "location" ,
96
105
title : string ,
97
106
address : string ,
98
107
latitude : number ,
99
108
longitude : number ,
100
109
} ;
101
- export type StickerMessage = Typed & {
110
+ export type StickerMessage = {
111
+ type : "sticker" ,
102
112
packageId : string ,
103
113
stickerId : string ,
104
114
} ;
105
- export type ImageMapMessage = Typed & {
115
+ export type ImageMapMessage = {
116
+ type : "image" ,
106
117
baseUrl : string ,
107
118
altText : string ,
108
119
baseSize : { width : number , height : number } ,
109
120
actions : ImageMapAction [ ] ,
110
121
} ;
111
- export type TemplateMessage = Typed & {
122
+ export type TemplateMessage = {
123
+ type : "template" ,
112
124
altText : string ,
113
125
template : TemplateContent ,
114
126
} ;
115
127
116
128
export type ImageMapAction = ImageMapURIAction | ImageMapMessageAction ;
117
- export type ImageMapActionBase = Typed & { area : ImageMapArea } ;
118
- export type ImageMapURIAction = ImageMapActionBase & { linkUri : string } ;
119
- export type ImageMapMessageAction = ImageMapActionBase & { text : string } ;
129
+ export type ImageMapActionBase = { area : ImageMapArea } ;
130
+ export type ImageMapURIAction = { type : "uri" , linkUri : string } & ImageMapActionBase ;
131
+ export type ImageMapMessageAction = { type : "message" , text : string } & ImageMapActionBase ;
120
132
121
133
export type ImageMapArea = { x : number , y : number , width : number , height : number } ;
122
134
123
135
export type TemplateContent = TemplateButtons | TemplateConfirm | TemplateCarousel ;
124
- export type TemplateButtons = Typed & {
136
+ export type TemplateButtons = {
137
+ type : "buttons" ,
125
138
thumbnailImageUrl ?: string ,
126
139
title ?: string ,
127
140
text : string ,
128
141
actions : TemplateAction [ ] ,
129
142
} ;
130
- export type TemplateConfirm = Typed & {
143
+ export type TemplateConfirm = {
144
+ type : "confirm" ,
131
145
text : string ,
132
146
actions : TemplateAction [ ] ,
133
147
} ;
134
- export type TemplateCarousel = Typed & { columns : TemplateColumn [ ] } ;
148
+ export type TemplateCarousel = { type : "carousel" , columns : TemplateColumn [ ] } ;
135
149
136
150
export type TemplateColumn = {
137
151
thumbnailImageUrl ?: string ,
@@ -141,8 +155,18 @@ declare namespace Line {
141
155
} ;
142
156
143
157
export type TemplateAction = TemplatePostbackAction | TemplateMessageAction | TemplateURIAction ;
144
- export type TemplateActionBase = Typed & { label : string } ;
145
- export type TemplatePostbackAction = TemplateActionBase & { data : string , text ?: string } ;
146
- export type TemplateMessageAction = TemplateActionBase & { text : string } ;
147
- export type TemplateURIAction = TemplateActionBase & { uri : string } ;
158
+ export type TemplateActionBase = { label : string } ;
159
+ export type TemplatePostbackAction = {
160
+ type : "postback" ,
161
+ data : string ,
162
+ text ?: string ,
163
+ } & TemplateActionBase ;
164
+ export type TemplateMessageAction = {
165
+ type : "message" ,
166
+ text : string ,
167
+ } & TemplateActionBase ;
168
+ export type TemplateURIAction = {
169
+ type : "template" ,
170
+ uri : string ,
171
+ } & TemplateActionBase ;
148
172
}
0 commit comments