Skip to content

Commit d857511

Browse files
author
Fil Maj
authored
feat: adding event payloads from bolt-js as a starting point (#1907)
1 parent be8cb4e commit d857511

29 files changed

+2013
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export interface BotProfile {
2+
id: string;
3+
name: string;
4+
app_id: string;
5+
team_id: string;
6+
icons: {
7+
[size: string]: string;
8+
};
9+
updated: number;
10+
deleted: boolean;
11+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface StatusEmojiDisplayInfo {
2+
emoji_name?: string;
3+
display_alias?: string;
4+
display_url?: string;
5+
}

packages/types/src/events/app.ts

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
import { Block, KnownBlock } from '../block-kit/blocks';
2+
import { BotProfile } from '../common/bot-profile';
3+
import { MessageAttachment } from '../message-attachments';
4+
import { View } from '../views';
5+
6+
export interface AppRequestedEvent {
7+
type: 'app_requested';
8+
app_request: {
9+
id: string;
10+
app: {
11+
id: string;
12+
name: string;
13+
description: string;
14+
help_url: string;
15+
privacy_policy_url: string;
16+
app_homepage_url: string;
17+
app_directory_url: string;
18+
is_app_directory_approved: boolean;
19+
is_internal: boolean;
20+
additional_info: string;
21+
icons?: {
22+
image_32?: string;
23+
image_36?: string;
24+
image_48?: string;
25+
image_64?: string;
26+
image_72?: string;
27+
image_96?: string;
28+
image_128?: string;
29+
image_192?: string;
30+
image_512?: string;
31+
image_1024?: string;
32+
image_original?: string;
33+
}
34+
};
35+
};
36+
previous_resolution: {
37+
status: 'approved' | 'restricted';
38+
scopes: {
39+
name: string;
40+
description: string;
41+
is_dangerous: boolean;
42+
token_type: 'bot' | 'user' | 'app' | null;
43+
};
44+
} | null;
45+
is_user_app_collaborator: boolean;
46+
user: {
47+
id: string;
48+
name: string;
49+
email: string;
50+
};
51+
team: {
52+
id: string;
53+
name: string;
54+
domain: string;
55+
};
56+
scopes: {
57+
name: string;
58+
description: string;
59+
is_dangerous: boolean;
60+
token_type: 'bot' | 'user' | 'app' | null;
61+
};
62+
message: string;
63+
date_created: number;
64+
}
65+
66+
export interface AppHomeOpenedEvent {
67+
type: 'app_home_opened';
68+
user: string;
69+
channel: string;
70+
tab?: 'home' | 'messages';
71+
view?: View;
72+
event_ts: string;
73+
}
74+
75+
export interface AppInstalledEvent {
76+
type: 'app_installed';
77+
app_id: string;
78+
app_name: string;
79+
app_owner_id: string;
80+
user_id: string;
81+
team_id: string;
82+
team_domain: string;
83+
event_ts: string;
84+
}
85+
86+
export interface AppDeletedEvent {
87+
type: 'app_deleted';
88+
app_id: string;
89+
app_name: string;
90+
app_owner_id: string;
91+
team_id: string;
92+
team_domain: string;
93+
event_ts: string;
94+
}
95+
96+
export interface AppUninstalledTeamEvent {
97+
type: 'app_uninstalled_team';
98+
app_id: string;
99+
app_name: string;
100+
app_owner_id: string;
101+
team_id: string;
102+
team_domain: string;
103+
user_id: string;
104+
event_ts: string;
105+
}
106+
107+
// TODO: this is essentially the same as the `message` event, except for the type and that this uses `event_ts` instead
108+
// of `ts`
109+
export interface AppMentionEvent {
110+
type: 'app_mention';
111+
subtype?: string;
112+
bot_id?: string;
113+
bot_profile?: BotProfile;
114+
username?: string;
115+
team?: string;
116+
// user_team, source_team, and user_profile
117+
// can exist when the user who mentioned this bot is in a different workspace/org
118+
user_team?: string;
119+
source_team?: string;
120+
user_profile?: {
121+
name: string;
122+
first_name: string;
123+
real_name: string;
124+
display_name: string;
125+
team: string;
126+
is_restricted?: boolean;
127+
is_ultra_restricted?: boolean;
128+
avatar_hash?: string;
129+
image_72?: string;
130+
};
131+
user?: string;
132+
text: string;
133+
attachments?: MessageAttachment[];
134+
blocks?: (KnownBlock | Block)[];
135+
// TODO: Add more properties once the types library has a file object definition
136+
files?: { id: string }[];
137+
upload?: boolean;
138+
display_as_bot?: boolean;
139+
edited?: {
140+
user: string;
141+
ts: string;
142+
};
143+
ts: string;
144+
channel: string;
145+
event_ts: string;
146+
thread_ts?: string;
147+
client_msg_id?: string;
148+
}
149+
150+
export interface AppRateLimitedEvent {
151+
type: 'app_rate_limited';
152+
token: string;
153+
team_id: string;
154+
minute_rate_limited: number;
155+
api_app_id: string;
156+
}
157+
158+
// TODO: this event doesn't use the envelope. write test cases to make sure its works without breaking, and figure out
159+
// what exceptions need to be made to the related types to make this work
160+
// https://api.slack.com/events/app_rate_limited
161+
// export interface AppRateLimitedEvent {
162+
// }
163+
164+
export interface AppUninstalledEvent {
165+
type: 'app_uninstalled';
166+
}

packages/types/src/events/call.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface CallRejectedEvent {
2+
type: 'call_rejected';
3+
call_id: string;
4+
user_id: string;
5+
channel_id: string;
6+
external_unique_id: string;
7+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
export interface ChannelArchiveEvent {
2+
type: 'channel_archive';
3+
channel: string;
4+
user: string;
5+
is_moved?: number;
6+
event_ts: string;
7+
}
8+
9+
export interface ChannelCreatedEvent {
10+
type: 'channel_created';
11+
event_ts: string;
12+
channel: {
13+
id: string;
14+
is_channel: boolean;
15+
name: string;
16+
name_normalized: string;
17+
created: number;
18+
creator: string; // user ID
19+
is_shared: boolean;
20+
is_org_shared: boolean;
21+
context_team_id: string,
22+
is_archived: boolean;
23+
is_frozen: boolean,
24+
is_general: boolean,
25+
is_group: boolean,
26+
is_private: boolean,
27+
is_ext_shared: boolean,
28+
is_im: boolean,
29+
is_mpim: boolean,
30+
is_pending_ext_shared: boolean,
31+
};
32+
}
33+
34+
export interface ChannelDeletedEvent {
35+
type: 'channel_deleted';
36+
channel: string;
37+
}
38+
39+
export interface ChannelHistoryChangedEvent {
40+
type: 'channel_history_changed';
41+
latest: string;
42+
ts: string;
43+
event_ts: string;
44+
}
45+
46+
export interface ChannelIDChangedEvent {
47+
type: 'channel_id_changed';
48+
old_channel_id: string;
49+
new_channel_id: string;
50+
event_ts: string;
51+
}
52+
53+
export interface ChannelLeftEvent {
54+
type: 'channel_left';
55+
channel: string;
56+
actor_id: string;
57+
event_ts: string;
58+
}
59+
60+
export interface ChannelRenameEvent {
61+
type: 'channel_rename';
62+
channel: {
63+
id: string;
64+
name: string;
65+
name_normalized: string;
66+
created: number;
67+
is_channel: boolean;
68+
is_mpim: boolean;
69+
};
70+
event_ts: string;
71+
}
72+
73+
export interface ChannelSharedEvent {
74+
type: 'channel_shared';
75+
connected_team_id: string;
76+
channel: string;
77+
event_ts: string;
78+
}
79+
80+
export interface ChannelUnarchiveEvent {
81+
type: 'channel_unarchive';
82+
channel: string;
83+
user: string;
84+
event_ts: string;
85+
}
86+
87+
export interface ChannelUnsharedEvent {
88+
type: 'channel_unshared';
89+
previously_connected_team_id: string;
90+
channel: string;
91+
is_ext_shared: boolean;
92+
event_ts: string;
93+
}

packages/types/src/events/dnd.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export interface DNDUpdatedEvent {
2+
type: 'dnd_updated';
3+
user: string;
4+
dnd_status: {
5+
dnd_enabled: boolean;
6+
next_dnd_start_ts: number;
7+
next_dnd_end_ts: number;
8+
snooze_enabled: boolean;
9+
snooze_endtime: number;
10+
snooze_remaining: number;
11+
};
12+
event_ts: string;
13+
}
14+
15+
export interface DNDUpdatedUserEvent {
16+
type: 'dnd_updated_user';
17+
user: string;
18+
dnd_status: {
19+
dnd_enabled: boolean;
20+
next_dnd_start_ts: number;
21+
next_dnd_end_ts: number;
22+
};
23+
event_ts: string;
24+
}

packages/types/src/events/email.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface EmailDomainChangedEvent {
2+
type: 'email_domain_changed';
3+
email_domain: string;
4+
event_ts: string;
5+
}

packages/types/src/events/emoji.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// TODO: breaking change: this should probably be broken into its two subtypes
2+
export interface EmojiChangedEvent {
3+
type: 'emoji_changed';
4+
subtype: 'add' | 'remove' | 'rename';
5+
names?: string[]; // only for remove
6+
name?: string; // only for add
7+
value?: string; // only for add
8+
old_name?: string;
9+
new_name?: string;
10+
event_ts: string;
11+
}

packages/types/src/events/file.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// NOTE: `file_comment_added` and `file_comment_edited` are left out because they are discontinued
2+
3+
export interface FileChangeEvent {
4+
type: 'file_change';
5+
file_id: string;
6+
file: {
7+
id: string;
8+
};
9+
}
10+
11+
export interface FileCommentDeletedEvent {
12+
type: 'file_comment_deleted';
13+
comment: string; // this is an ID
14+
file_id: string;
15+
file: {
16+
id: string;
17+
};
18+
}
19+
20+
export interface FileCreatedEvent {
21+
type: 'file_created';
22+
file_id: string;
23+
user_id: string;
24+
file: {
25+
id: string;
26+
};
27+
event_ts: string;
28+
}
29+
30+
export interface FileDeletedEvent {
31+
type: 'file_deleted';
32+
file_id: string;
33+
channel_ids?: string[];
34+
event_ts: string;
35+
}
36+
37+
export interface FilePublicEvent {
38+
type: 'file_public';
39+
file_id: string;
40+
user_id: string;
41+
file: {
42+
id: string;
43+
};
44+
event_ts: string;
45+
}
46+
47+
export interface FileSharedEvent {
48+
type: 'file_shared';
49+
file_id: string;
50+
user_id: string;
51+
file: {
52+
id: string;
53+
};
54+
channel_id: string;
55+
event_ts: string;
56+
}
57+
58+
export interface FileUnsharedEvent {
59+
type: 'file_unshared';
60+
file_id: string;
61+
user_id: string;
62+
file: {
63+
id: string;
64+
};
65+
channel_id: string;
66+
event_ts: string;
67+
}

0 commit comments

Comments
 (0)