File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export interface MessageMetadataEventPayloadObject {
2727}
2828
2929/**
30- * @description Metadata that represents an entity .
30+ * @description An array of entities .
3131 */
3232export interface EntitiesMetadata {
3333 entities : EntityMetadata [ ] ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import type { OptionalArgument } from '../helpers';
22
33import type {
44 Block , // TODO: these will be combined into one in a new types release
5- EntitiesMetadata ,
5+ EntityMetadata ,
66 KnownBlock ,
77 LinkUnfurls ,
88 MessageAttachment ,
@@ -221,25 +221,31 @@ export interface SourceAndUnfurlID {
221221}
222222type UnfurlTarget = ChannelAndTS | SourceAndUnfurlID ;
223223
224- type ChatUnfurlEntitiesMetadata = EntitiesMetadata & {
225- /**
226- * @description The unfurl URL for the entity.
227- */
228- app_unfurl_url ?: string ;
229- } ;
230-
231- // https://api.slack.com/methods/chat.unfurl
232- export type ChatUnfurlArguments = {
224+ type ChatUnfurlArgumentUnfurls = {
233225 /**
234226 * @description Object with keys set to URLs featured in the message, pointing to their unfurl
235227 * blocks or message attachments.
236228 */
237- unfurls ?: LinkUnfurls ;
229+ unfurls : LinkUnfurls ;
230+ } ;
231+
232+ type ChatUnfurlArgumentMetadata = {
238233 /**
239234 * @description Array of entities to attach to the message based on URLs featured in the message.
240235 */
241- metadata ?: ChatUnfurlEntitiesMetadata ;
242- } & UnfurlTarget &
236+ metadata : {
237+ entities : ( EntityMetadata & {
238+ /**
239+ * @description The unfurl URL for the entity.
240+ */
241+ app_unfurl_url : string ;
242+ } ) [ ] ;
243+ } ;
244+ } ;
245+
246+ // https://api.slack.com/methods/chat.unfurl
247+ export type ChatUnfurlArguments = ( ChatUnfurlArgumentUnfurls | ChatUnfurlArgumentMetadata ) &
248+ UnfurlTarget &
243249 TokenOverridable & {
244250 /**
245251 * @description Provide a simply-formatted string to send as an ephemeral message to the user as invitation to
Original file line number Diff line number Diff line change @@ -546,7 +546,7 @@ expectError(
546546) ;
547547expectError (
548548 web . chat . unfurl ( {
549- channel : 'C1234' , // missing unfurls
549+ channel : 'C1234' , // missing both unfurls and metadata
550550 ts : '1234.56' ,
551551 } ) ,
552552) ;
@@ -600,6 +600,37 @@ expectAssignable<Parameters<typeof web.chat.unfurl>>([
600600 ts : '1234.56' ,
601601 } ,
602602] ) ;
603+ expectAssignable < Parameters < typeof web . chat . unfurl > > ( [
604+ {
605+ channel : 'C1234' ,
606+ ts : '1234.56' ,
607+ metadata : {
608+ entities : [
609+ {
610+ entity_type : '' ,
611+ entity_payload : { } ,
612+ app_unfurl_url : 'https://google.com' ,
613+ } ,
614+ ] ,
615+ } ,
616+ } ,
617+ ] ) ;
618+ expectAssignable < Parameters < typeof web . chat . unfurl > > ( [
619+ {
620+ channel : 'C1234' ,
621+ ts : '1234.56' ,
622+ unfurls : { } , // Accepts both unfurl and metadata attachments
623+ metadata : {
624+ entities : [
625+ {
626+ entity_type : '' ,
627+ entity_payload : { } ,
628+ app_unfurl_url : 'https://google.com' ,
629+ } ,
630+ ] ,
631+ } ,
632+ } ,
633+ ] ) ;
603634
604635// chat.update
605636// -- sad path
You can’t perform that action at this time.
0 commit comments