|
| 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 | +} |
0 commit comments