Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding event payloads from bolt-js as a starting point #1907

Merged
merged 4 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/types/src/common/bot-profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface BotProfile {
filmaj marked this conversation as resolved.
Show resolved Hide resolved
id: string;
name: string;
app_id: string;
team_id: string;
icons: {
[size: string]: string;
};
updated: number;
deleted: boolean;
}
5 changes: 5 additions & 0 deletions packages/types/src/common/status-emoji-display-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface StatusEmojiDisplayInfo {
emoji_name?: string;
display_alias?: string;
display_url?: string;
}
166 changes: 166 additions & 0 deletions packages/types/src/events/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import { Block, KnownBlock } from '../block-kit/blocks';
import { BotProfile } from '../common/bot-profile';
import { MessageAttachment } from '../message-attachments';
import { View } from '../views';

export interface AppRequestedEvent {
type: 'app_requested';
app_request: {
id: string;
app: {
id: string;
name: string;
description: string;
help_url: string;
privacy_policy_url: string;
app_homepage_url: string;
app_directory_url: string;
is_app_directory_approved: boolean;
is_internal: boolean;
additional_info: string;
icons?: {
image_32?: string;
image_36?: string;
image_48?: string;
image_64?: string;
image_72?: string;
image_96?: string;
image_128?: string;
image_192?: string;
image_512?: string;
image_1024?: string;
image_original?: string;
}
};
};
previous_resolution: {
status: 'approved' | 'restricted';
scopes: {
name: string;
description: string;
is_dangerous: boolean;
token_type: 'bot' | 'user' | 'app' | null;
};
} | null;
is_user_app_collaborator: boolean;
user: {
id: string;
name: string;
email: string;
};
team: {
id: string;
name: string;
domain: string;
};
scopes: {
name: string;
description: string;
is_dangerous: boolean;
token_type: 'bot' | 'user' | 'app' | null;
};
message: string;
date_created: number;
}

export interface AppHomeOpenedEvent {
type: 'app_home_opened';
user: string;
channel: string;
tab?: 'home' | 'messages';
view?: View;
event_ts: string;
}

export interface AppInstalledEvent {
type: 'app_installed';
app_id: string;
app_name: string;
app_owner_id: string;
user_id: string;
team_id: string;
team_domain: string;
event_ts: string;
}

export interface AppDeletedEvent {
type: 'app_deleted';
app_id: string;
app_name: string;
app_owner_id: string;
team_id: string;
team_domain: string;
event_ts: string;
}

export interface AppUninstalledTeamEvent {
type: 'app_uninstalled_team';
app_id: string;
app_name: string;
app_owner_id: string;
team_id: string;
team_domain: string;
user_id: string;
event_ts: string;
}

// TODO: this is essentially the same as the `message` event, except for the type and that this uses `event_ts` instead
// of `ts`
export interface AppMentionEvent {
type: 'app_mention';
subtype?: string;
bot_id?: string;
bot_profile?: BotProfile;
username?: string;
team?: string;
// user_team, source_team, and user_profile
// can exist when the user who mentioned this bot is in a different workspace/org
user_team?: string;
source_team?: string;
user_profile?: {
name: string;
first_name: string;
real_name: string;
display_name: string;
team: string;
is_restricted?: boolean;
is_ultra_restricted?: boolean;
avatar_hash?: string;
image_72?: string;
};
user?: string;
text: string;
attachments?: MessageAttachment[];
blocks?: (KnownBlock | Block)[];
// TODO: Add more properties once the types library has a file object definition
files?: { id: string }[];
upload?: boolean;
display_as_bot?: boolean;
edited?: {
user: string;
ts: string;
};
ts: string;
channel: string;
event_ts: string;
thread_ts?: string;
client_msg_id?: string;
}

export interface AppRateLimitedEvent {
type: 'app_rate_limited';
token: string;
team_id: string;
minute_rate_limited: number;
api_app_id: string;
}

// TODO: this event doesn't use the envelope. write test cases to make sure its works without breaking, and figure out
// what exceptions need to be made to the related types to make this work
// https://api.slack.com/events/app_rate_limited
// export interface AppRateLimitedEvent {
// }

export interface AppUninstalledEvent {
type: 'app_uninstalled';
}
7 changes: 7 additions & 0 deletions packages/types/src/events/call.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface CallRejectedEvent {
type: 'call_rejected';
call_id: string;
user_id: string;
channel_id: string;
external_unique_id: string;
}
18 changes: 18 additions & 0 deletions packages/types/src/events/channel-membership.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export interface MemberJoinedChannelEvent {
filmaj marked this conversation as resolved.
Show resolved Hide resolved
type: 'member_joined_channel';
user: string;
channel: string;
channel_type: string;
team: string;
inviter?: string;
event_ts: string;
}

export interface MemberLeftChannelEvent {
type: 'member_left_channel';
user: string;
channel: string;
channel_type: string;
team: string;
event_ts: string;
}
93 changes: 93 additions & 0 deletions packages/types/src/events/channel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
export interface ChannelArchiveEvent {
type: 'channel_archive';
channel: string;
user: string;
is_moved?: number;
event_ts: string;
}

export interface ChannelCreatedEvent {
type: 'channel_created';
event_ts: string;
channel: {
id: string;
is_channel: boolean;
name: string;
name_normalized: string;
created: number;
creator: string; // user ID
is_shared: boolean;
is_org_shared: boolean;
context_team_id: string,
is_archived: boolean;
is_frozen: boolean,
is_general: boolean,
is_group: boolean,
is_private: boolean,
is_ext_shared: boolean,
is_im: boolean,
is_mpim: boolean,
is_pending_ext_shared: boolean,
};
}

export interface ChannelDeletedEvent {
type: 'channel_deleted';
channel: string;
}

export interface ChannelHistoryChangedEvent {
type: 'channel_history_changed';
latest: string;
ts: string;
event_ts: string;
}

export interface ChannelIDChangedEvent {
type: 'channel_id_changed';
old_channel_id: string;
new_channel_id: string;
event_ts: string;
}

export interface ChannelLeftEvent {
type: 'channel_left';
channel: string;
actor_id: string;
event_ts: string;
}

export interface ChannelRenameEvent {
type: 'channel_rename';
channel: {
id: string;
name: string;
name_normalized: string;
created: number;
is_channel: boolean;
is_mpim: boolean;
};
event_ts: string;
}

export interface ChannelSharedEvent {
type: 'channel_shared';
connected_team_id: string;
channel: string;
event_ts: string;
}

export interface ChannelUnarchiveEvent {
type: 'channel_unarchive';
channel: string;
user: string;
event_ts: string;
}

export interface ChannelUnsharedEvent {
type: 'channel_unshared';
previously_connected_team_id: string;
channel: string;
is_ext_shared: boolean;
event_ts: string;
}
24 changes: 24 additions & 0 deletions packages/types/src/events/dnd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export interface DNDUpdatedEvent {
type: 'dnd_updated';
user: string;
dnd_status: {
dnd_enabled: boolean;
next_dnd_start_ts: number;
next_dnd_end_ts: number;
snooze_enabled: boolean;
snooze_endtime: number;
snooze_remaining: number;
};
event_ts: string;
}

export interface DNDUpdatedUserEvent {
type: 'dnd_updated_user';
user: string;
dnd_status: {
dnd_enabled: boolean;
next_dnd_start_ts: number;
next_dnd_end_ts: number;
};
event_ts: string;
}
5 changes: 5 additions & 0 deletions packages/types/src/events/email.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface EmailDomainChangedEvent {
type: 'email_domain_changed';
email_domain: string;
event_ts: string;
}
11 changes: 11 additions & 0 deletions packages/types/src/events/emoji.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// TODO: breaking change: this should probably be broken into its two subtypes
export interface EmojiChangedEvent {
type: 'emoji_changed';
subtype: 'add' | 'remove' | 'rename';
names?: string[]; // only for remove
name?: string; // only for add
value?: string; // only for add
old_name?: string;
new_name?: string;
event_ts: string;
}
Loading