From ca64314bcf9a2adcea277f45d78e148964fc1eab Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Tue, 2 Jul 2024 15:51:18 +0900 Subject: [PATCH 1/2] Add missing Events API payload types --- src/types/events/base-events.ts | 106 ++++++++++++++++++++++++++++---- 1 file changed, 94 insertions(+), 12 deletions(-) diff --git a/src/types/events/base-events.ts b/src/types/events/base-events.ts index b5ad2a2bd..c765ec18e 100644 --- a/src/types/events/base-events.ts +++ b/src/types/events/base-events.ts @@ -9,6 +9,9 @@ import { MessageEvent as AllMessageEvents, MessageMetadataEvent as AllMessageMet */ export type SlackEvent = | AppRequestedEvent + | AppInstalledEvent + | AppDeletedEvent + | AppUninstalledTeamEvent | AppHomeOpenedEvent | AppMentionEvent | AppRateLimitedEvent @@ -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 @@ -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 { @@ -740,7 +776,7 @@ export interface SharedChannelItem { is_im: boolean; name: string; } -export interface SharedChannelInviteAccepted { +export interface SharedChannelInviteAcceptedEvent { type: 'shared_channel_invite_accepted'; approval_required: boolean; invite: SharedChannelInviteItem; @@ -749,8 +785,10 @@ export interface SharedChannelInviteAccepted { accepting_user: SharedChannelUserItem; event_ts: string; } +// for backward-compatibility +export type SharedChannelInviteAccepted = SharedChannelInviteAcceptedEvent; -export interface SharedChannelInviteApproved { +export interface SharedChannelInviteApprovedEvent { type: 'shared_channel_invite_approved'; invite: SharedChannelInviteItem; channel: SharedChannelItem; @@ -759,8 +797,10 @@ export interface SharedChannelInviteApproved { approving_user: SharedChannelUserItem; event_ts: string; } +// for backward-compatibility +export type SharedChannelInviteApproved = SharedChannelInviteApprovedEvent; -export interface SharedChannelInviteDeclined { +export interface SharedChannelInviteDeclinedEvent { type: 'shared_channel_invite_declined'; invite: SharedChannelInviteItem; channel: SharedChannelItem; @@ -769,13 +809,51 @@ export interface SharedChannelInviteDeclined { declining_user: SharedChannelUserItem; event_ts: string; } +// for backward-compatibility +export type SharedChannelInviteDeclined = SharedChannelInviteDeclinedEvent; -export interface SharedChannelInviteReceived { +export interface SharedChannelInviteReceivedEvent { type: 'shared_channel_invite_received'; invite: SharedChannelInviteItem; channel: SharedChannelItem; event_ts: string; } +// for backward-compatibility +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'; + 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'; @@ -820,13 +898,15 @@ interface Subteam { channel_count?: number; } -export interface SubteamCreated { +export interface SubteamCreatedEvent { type: 'subteam_created'; subteam: Subteam; event_ts: string; } +// for backward-compatibility +export type SubteamCreated = SubteamCreatedEvent; -export interface SubteamMembersChanged { +export interface SubteamMembersChangedEvent { type: 'subteam_members_changed'; subteam_id: string; team_id: string; @@ -838,6 +918,8 @@ export interface SubteamMembersChanged { removed_users_count?: number; event_ts: string; } +// for backward-compatibility +export type SubteamMembersChanged = SubteamMembersChangedEvent; export interface SubteamSelfAddedEvent { type: 'subteam_self_added'; From 8319003026959898992338c0de586120cd293379 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Wed, 3 Jul 2024 11:34:00 +0900 Subject: [PATCH 2/2] Update comments --- src/types/events/base-events.ts | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/types/events/base-events.ts b/src/types/events/base-events.ts index c765ec18e..e31f92d75 100644 --- a/src/types/events/base-events.ts +++ b/src/types/events/base-events.ts @@ -785,7 +785,10 @@ export interface SharedChannelInviteAcceptedEvent { accepting_user: SharedChannelUserItem; event_ts: string; } -// for backward-compatibility +// 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 SharedChannelInviteApprovedEvent { @@ -797,7 +800,10 @@ export interface SharedChannelInviteApprovedEvent { approving_user: SharedChannelUserItem; event_ts: string; } -// for backward-compatibility +// 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 SharedChannelInviteDeclinedEvent { @@ -809,7 +815,10 @@ export interface SharedChannelInviteDeclinedEvent { declining_user: SharedChannelUserItem; event_ts: string; } -// for backward-compatibility +// 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 SharedChannelInviteReceivedEvent { @@ -818,7 +827,10 @@ export interface SharedChannelInviteReceivedEvent { channel: SharedChannelItem; event_ts: string; } -// for backward-compatibility +// 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 { @@ -903,7 +915,10 @@ export interface SubteamCreatedEvent { subteam: Subteam; event_ts: string; } -// for backward-compatibility +// 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 SubteamMembersChangedEvent { @@ -918,7 +933,10 @@ export interface SubteamMembersChangedEvent { removed_users_count?: number; event_ts: string; } -// for backward-compatibility +// 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 {