You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO: breaking changes, use discriminated union for `fallback`, `text` and `block` properties, maybe LegacyAttachment
5
-
// vs. BlocksAttachment? as per https://api.slack.com/reference/messaging/attachments#legacy_fields
6
-
// "these fields are optional if you're including blocks as above. If you aren't, one of fallback or text are required"
7
-
// also further nested discriminated union types that could be helpful here:
8
-
// - LegacyAttachmentWithAuthor: if author_name is present, then author_icon and author_link are optional fields
9
-
// - LegacyAttachmentWithFooter: if footer is present, then footer_icon is an optional field
10
-
// - image_url and thumb_url cannot be used together
11
4
/**
12
5
* Add {@link https://api.slack.com/messaging/composing/layouts#attachments secondary attachments} to your messages in Slack.
13
6
* Message attachments are considered a legacy part of messaging functionality. They are not deprecated per se, but they may change in the future, in ways that reduce their visibility or utility. We recommend moving to Block Kit instead. Read more about {@link https://api.slack.com/messaging/composing/layouts#when-to-use-attachments when to use message attachments}.
* @description Field names that should be {@link https://api.slack.com/reference/surfaces/formatting#basics formatted by `mrkdwn` syntax}.
113
-
* The fields that can be formatted in this way include the names of the `fields` property, or
114
-
* the `text` or `pretext` properties.
115
-
*/
116
-
mrkdwn_in?: ('pretext'|'text'|'fields')[];// TODO: I think `fields` here is wrong? instead they should reference field names from `fields`
117
-
app_unfurl_url?: string;// TODO: not documented in https://api.slack.com/reference/messaging/attachments
118
-
is_app_unfurl?: boolean;// TODO: not documented in https://api.slack.com/reference/messaging/attachments
119
-
app_id?: string;// TODO: not documented in https://api.slack.com/reference/messaging/attachments
120
-
bot_id?: string;// TODO: not documented in https://api.slack.com/reference/messaging/attachments
121
-
preview?: MessageAttachmentPreview;// https://api.slack.com/methods/chat.unfurl#markdown TODO: not documented in https://api.slack.com/reference/messaging/attachments, also unclear why this links to chat.unfurl?
122
-
}
148
+
};
123
149
124
150
/**
125
151
* @description A field object to include in a {@link MessageAttachment}.
// Either specify both callback_id and actions, or neither.
181
+
typeAttachmentActions={
182
+
/**
183
+
* @deprecated Legacy attachments with buttons are deprecated. See {@link https://api.slack.com/messaging/attachments-to-blocks transitioning to blocks}.
184
+
* @see {@link https://api.slack.com/legacy/message-buttons#crafting_your_message Legacy "Crafting messages with buttons documentation}
* @deprecated Legacy attachments with buttons are deprecated. See {@link https://api.slack.com/messaging/attachments-to-blocks transitioning to blocks}.
189
+
* @see {@link https://api.slack.com/legacy/message-buttons#crafting_your_message Legacy "Crafting messages with buttons documentation}
expectError<MessageAttachment>({});// if no blocks, either text or fallback is required.
6
+
expectError<MessageAttachment>({fallback: 'hi',author_link: 'https://slack.com'});// use of author_link requires author_name.
7
+
expectError<MessageAttachment>({fallback: 'hi',author_icon: 'https://slack.com'});// use of author_icon requires author_name.
8
+
expectError<MessageAttachment>({fallback: 'hi',footer_icon: 'https://slack.com'});// use of footer_icon requires footer.
9
+
expectError<MessageAttachment>({fallback: 'hi',thumb_url: 'https://slack.com',image_url: 'https://slack.com'});// cant use both image_url and thumb_url.
10
+
expectError<MessageAttachment>({fallback: 'hi',callback_id: 'hollah'});// cant use callback_id without actions.
11
+
expectError<MessageAttachment>({fallback: 'hi',actions: [{name: 'sup',text: 'sup',type: 'button'}]});// cant use callback_id without actions.
12
+
expectError<MessageAttachment>({fallback: 'hi',callback_id: 'hi',actions: []});// must specify at least one action.
13
+
14
+
// -- happy path
15
+
expectAssignable<MessageAttachment>({text: 'hi'});// if no blocks, either text or fallback is required.
16
+
expectAssignable<MessageAttachment>({fallback: 'hi'});// if no blocks, either text or fallback is required.
17
+
expectAssignable<MessageAttachment>({fallback: 'hi',author_name: 'filmaj',author_icon: 'https://slack.com'});// use of author_icon requires author_name.
18
+
expectAssignable<MessageAttachment>({fallback: 'hi',author_name: 'filmaj',author_link: 'https://slack.com'});// use of author_link requires author_name.
19
+
expectAssignable<MessageAttachment>({fallback: 'hi',footer: 'filmaj',footer_icon: 'https://slack.com'});// use of footer_icon requires footer.
0 commit comments