File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/**
22 * @description Application-specific data to attach to a Slack message.
33 */
4- export interface MessageMetadata extends EventMetadata , EntitiesMetadata { }
4+ export type MessageMetadata = EventMetadata | EntitiesMetadata ;
55
66/**
77 * @description Metadata that represents an event in Slack.
@@ -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 3636 },
3737 "dependencies" : {
3838 "@slack/logger" : " ^4.0.0" ,
39- "@slack/types" : " ^2.9.0 " ,
39+ "@slack/types" : " file:../types " ,
4040 "@types/node" : " >=18.0.0" ,
4141 "@types/retry" : " 0.12.0" ,
4242 "axios" : " ^1.8.3" ,
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 @@ -399,6 +399,21 @@ expectAssignable<Parameters<typeof web.chat.postMessage>>([
399399 reply_broadcast : false , // can send a threaded message and explicitly not broadcast it
400400 } ,
401401] ) ;
402+ expectAssignable < Parameters < typeof web . chat . postMessage > > ( [
403+ {
404+ channel : 'C1234' ,
405+ text : 'hello' ,
406+ thread_ts : '1234.56' ,
407+ metadata : {
408+ entities : [
409+ {
410+ entity_type : 'slack#/entities/file' ,
411+ entity_payload : { } ,
412+ } ,
413+ ] ,
414+ } ,
415+ } ,
416+ ] ) ;
402417// adding a test for when `reply_broadcast` specific boolean value is not known ahead of time
403418// https://github.com/slackapi/node-slack-sdk/issues/1859
404419function wideBooleanTest ( b : boolean ) {
@@ -546,7 +561,7 @@ expectError(
546561) ;
547562expectError (
548563 web . chat . unfurl ( {
549- channel : 'C1234' , // missing unfurls
564+ channel : 'C1234' , // missing both unfurls and metadata
550565 ts : '1234.56' ,
551566 } ) ,
552567) ;
@@ -600,6 +615,21 @@ expectAssignable<Parameters<typeof web.chat.unfurl>>([
600615 ts : '1234.56' ,
601616 } ,
602617] ) ;
618+ expectAssignable < Parameters < typeof web . chat . unfurl > > ( [
619+ {
620+ channel : 'C1234' ,
621+ ts : '1234.56' ,
622+ metadata : {
623+ entities : [
624+ {
625+ entity_type : 'slack#/entities/file' ,
626+ entity_payload : { } ,
627+ app_unfurl_url : 'https://google.com' ,
628+ } ,
629+ ] ,
630+ } ,
631+ } ,
632+ ] ) ;
603633
604634// chat.update
605635// -- sad path
You can’t perform that action at this time.
0 commit comments