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

Add missing Events API payload types #2155

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Changes from all 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
124 changes: 112 additions & 12 deletions src/types/events/base-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { MessageEvent as AllMessageEvents, MessageMetadataEvent as AllMessageMet
*/
export type SlackEvent =
| AppRequestedEvent
| AppInstalledEvent
| AppDeletedEvent
| AppUninstalledTeamEvent
| AppHomeOpenedEvent
| AppMentionEvent
| AppRateLimitedEvent
Expand Down Expand Up @@ -59,14 +62,15 @@ export type SlackEvent =
| PinRemovedEvent
| ReactionAddedEvent
| ReactionRemovedEvent
| SharedChannelInviteReceived
| SharedChannelInviteAccepted
| SharedChannelInviteApproved
| SharedChannelInviteDeclined
| SharedChannelInviteReceivedEvent
| SharedChannelInviteAcceptedEvent
| SharedChannelInviteApprovedEvent
| SharedChannelInviteDeclinedEvent
| SharedChannelInviteRequestedEvent
| StarAddedEvent
| StarRemovedEvent
| SubteamCreated
| SubteamMembersChanged
| SubteamCreatedEvent
| SubteamMembersChangedEvent
| SubteamSelfAddedEvent
| SubteamSelfRemovedEvent
| SubteamUpdatedEvent
Expand Down Expand Up @@ -182,6 +186,38 @@ export interface AppHomeOpenedEvent {
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;
}

// NOTE: 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 {
Expand Down Expand Up @@ -740,7 +776,7 @@ export interface SharedChannelItem {
is_im: boolean;
name: string;
}
export interface SharedChannelInviteAccepted {
export interface SharedChannelInviteAcceptedEvent {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consisteny, renaming all the ones that do not have "Event" suffix

type: 'shared_channel_invite_accepted';
approval_required: boolean;
invite: SharedChannelInviteItem;
Expand All @@ -749,8 +785,13 @@ export interface SharedChannelInviteAccepted {
accepting_user: SharedChannelUserItem;
event_ts: string;
}
// TODO: (breaking change) for backward-compatibility; remove non-Event-suffix type in next major version.
/**
* @deprecated Will be removed in next major version. Use the `SharedChannelInviteAcceptedEvent` interface instead.
*/
export type SharedChannelInviteAccepted = SharedChannelInviteAcceptedEvent;

export interface SharedChannelInviteApproved {
export interface SharedChannelInviteApprovedEvent {
type: 'shared_channel_invite_approved';
invite: SharedChannelInviteItem;
channel: SharedChannelItem;
Expand All @@ -759,8 +800,13 @@ export interface SharedChannelInviteApproved {
approving_user: SharedChannelUserItem;
event_ts: string;
}
// TODO: (breaking change) for backward-compatibility; remove non-Event-suffix type in next major version.
/**
* @deprecated Will be removed in next major version. Use the `SharedChannelInviteApprovedEvent` interface instead.
*/
export type SharedChannelInviteApproved = SharedChannelInviteApprovedEvent;

export interface SharedChannelInviteDeclined {
export interface SharedChannelInviteDeclinedEvent {
type: 'shared_channel_invite_declined';
invite: SharedChannelInviteItem;
channel: SharedChannelItem;
Expand All @@ -769,13 +815,57 @@ export interface SharedChannelInviteDeclined {
declining_user: SharedChannelUserItem;
event_ts: string;
}
// TODO: (breaking change) for backward-compatibility; remove non-Event-suffix type in next major version.
/**
* @deprecated Will be removed in next major version. Use the `SharedChannelInviteDeclinedEvent` interface instead.
*/
export type SharedChannelInviteDeclined = SharedChannelInviteDeclinedEvent;

export interface SharedChannelInviteReceived {
export interface SharedChannelInviteReceivedEvent {
type: 'shared_channel_invite_received';
invite: SharedChannelInviteItem;
channel: SharedChannelItem;
event_ts: string;
}
// TODO: (breaking change) for backward-compatibility; remove non-Event-suffix type in next major version.
/**
* @deprecated Will be removed in next major version. Use the `SharedChannelInviteReceivedEvent` interface instead.
*/
export type SharedChannelInviteReceived = SharedChannelInviteReceivedEvent;

export interface SharedChannelInviteRequestedEvent {
type: 'shared_channel_invite_requested';
actor: {
id: string;
name: string;
is_bot: boolean;
team_id: string;
timezone: string;
real_name: string;
display_name: string;
};
channel_id: string;
event_type: 'slack#/events/shared_channel_invite_requested';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested all aboev app_ events but I haven't checked how this goes not on automation platform. This may be nullable or optional.

channel_name: string;
channel_type: 'public' | 'private';
target_users: [{ email: string; invite_id: string }];
teams_in_channel: [
{
id: string;
icon: { image_34: string; image_default: boolean };
name: string;
domain: string;
is_verified: boolean;
date_created: number;
avatar_base_url: string;
requires_sponsorship: boolean;
},
];
is_external_limited: boolean;
channel_date_created: number;
channel_message_latest_counted_timestamp: number;
event_ts: string;
}

export interface StarAddedEvent {
type: 'star_added';
Expand Down Expand Up @@ -820,13 +910,18 @@ interface Subteam {
channel_count?: number;
}

export interface SubteamCreated {
export interface SubteamCreatedEvent {
type: 'subteam_created';
subteam: Subteam;
event_ts: string;
}
// TODO: (breaking change) for backward-compatibility; remove non-Event-suffix type in next major version.
/**
* @deprecated Will be removed in next major version. Use the `SubteamCreatedEvent` interface instead.
*/
export type SubteamCreated = SubteamCreatedEvent;

export interface SubteamMembersChanged {
export interface SubteamMembersChangedEvent {
type: 'subteam_members_changed';
subteam_id: string;
team_id: string;
Expand All @@ -838,6 +933,11 @@ export interface SubteamMembersChanged {
removed_users_count?: number;
event_ts: string;
}
// TODO: (breaking change) for backward-compatibility; remove non-Event-suffix type in next major version.
/**
* @deprecated Will be removed in next major version. Use the `SubteamMembersChangedEvent` interface instead.
*/
export type SubteamMembersChanged = SubteamMembersChangedEvent;

export interface SubteamSelfAddedEvent {
type: 'subteam_self_added';
Expand Down