-
Notifications
You must be signed in to change notification settings - Fork 674
feat: add support to @slack/web-api for work objects #2231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 41 commits
c8c3482
a3f8922
dde54aa
5813ae6
6892aef
9e8988b
c3cef1f
67cc8b6
da092d5
d4231dd
d889e07
e6bd2ac
c54c9b3
24ecda6
ba79b81
02e5360
b983ca5
8201026
e4284e3
bb49dd5
480cb1f
c4992f6
d2a9d93
c4cb46c
ec18401
6f56034
eeef76d
a44d4b3
1d4325b
019cfd3
fae7b17
a2eaa71
26e3aa5
4eaeed8
6d2ebc4
a9c5d4e
c0cc1f6
d974164
9b5ecf1
5c174bd
de9e02a
3ae9720
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import type { | ||
| Block, // TODO: these will be combined into one in a new types release | ||
| EntityMetadata, | ||
| KnownBlock, | ||
| LinkUnfurls, | ||
| MessageAttachment, | ||
|
|
@@ -104,6 +105,19 @@ export interface BroadcastedThreadReply extends ThreadTS { | |
| // or not broadcasted. Broadcasted replies are necessarily threaded, so `thread_ts` becomes required. | ||
| type ReplyInThread = WithinThreadReply | BroadcastedThreadReply; | ||
|
|
||
| export interface ChatPostMessageMetadata { | ||
| /** | ||
| * @description Object representing message metadata, entity and/or event data to attach to a Slack message. | ||
| * Provide 'entities' to set work object entity metadata. | ||
| * Provide 'event_type' and 'event_payload' to set event metadata. | ||
| */ | ||
| metadata?: Partial<MessageMetadata> & { | ||
| /** | ||
| * @description An array of work object entities. | ||
| */ | ||
| entities?: EntityMetadata[]; | ||
| }; | ||
| } | ||
|
vegeris marked this conversation as resolved.
|
||
| export interface Metadata { | ||
| /** @description Object representing message metadata, which will be made accessible to any user or app. */ | ||
| metadata?: MessageMetadata; | ||
|
|
@@ -191,7 +205,7 @@ export type ChatPostMessageArguments = TokenOverridable & | |
| Authorship & | ||
| Parse & | ||
| LinkNames & | ||
| Metadata & | ||
| ChatPostMessageMetadata & | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Just want to validate that I'm understanding correctly, this updates interface ChatPostMessageArguments {
...
metadata?: {
event_type: string;
event_payload: {
[key: string]: string | number | boolean | MessageMetadataEventPayloadObject | MessageMetadataEventPayloadObject[];
};
}To interface ChatPostMessageArguments {
...
metadata?: {
event_type?: string;
event_payload?: {
[key: string]: string | number | boolean | MessageMetadataEventPayloadObject | MessageMetadataEventPayloadObject[];
};
entities?: EntityMetadata[];
}Since this type is used to define and input for a function, making
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup; what I'm trying to show is that one can provide event and / or entity metadata in
Passing an object into the metadata param with just event_type and event_payload is still valid and should still be accepted by the SDK; if users are typing the object as
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The the Java SDK I need to take a look there might be a way around this |
||
| Unfurls & { | ||
| /** @description Disable Slack markup parsing by setting to `false`. Enabled by default. */ | ||
| mrkdwn?: boolean; | ||
|
|
@@ -256,13 +270,8 @@ export interface SourceAndUnfurlID { | |
| type UnfurlTarget = ChannelAndTS | SourceAndUnfurlID; | ||
|
|
||
| // https://docs.slack.dev/reference/methods/chat.unfurl | ||
| export type ChatUnfurlArguments = { | ||
| /** | ||
| * @description URL-encoded JSON map with keys set to URLs featured in the the message, pointing to their unfurl | ||
| * blocks or message attachments. | ||
| */ | ||
| unfurls: LinkUnfurls; | ||
| } & UnfurlTarget & | ||
| export type ChatUnfurlArguments = (ChatUnfurlUnfurls | ChatUnfurlMetadata) & | ||
| UnfurlTarget & | ||
| TokenOverridable & { | ||
| /** | ||
| * @description Provide a simply-formatted string to send as an ephemeral message to the user as invitation to | ||
|
|
@@ -286,6 +295,29 @@ export type ChatUnfurlArguments = { | |
| user_auth_blocks?: (KnownBlock | Block)[]; | ||
| }; | ||
|
|
||
| /** | ||
| * @description The `unfurls` param of the `chat.unfurl` API. | ||
| */ | ||
| interface ChatUnfurlUnfurls { | ||
| /** | ||
| * @description Object with keys set to URLs featured in the message, pointing to their unfurl | ||
| * blocks or message attachments. | ||
| */ | ||
| unfurls: LinkUnfurls; | ||
| } | ||
|
|
||
| /** | ||
| * @description The `metadata` param of the `chat.unfurl` API. | ||
| */ | ||
| interface ChatUnfurlMetadata { | ||
| /** | ||
| * @description Unfurl metadata featuring an array of entities to attach to the message based on URLs featured in the message. | ||
| */ | ||
| metadata: Partial<MessageMetadata> & { | ||
| entities: EntityMetadata[]; | ||
| }; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (One can also provide event metadata in chat.unfurl and it'll be persisted on the message but it's not a main use case)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. QQ: In
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, if |
||
| } | ||
|
|
||
| // https://docs.slack.dev/reference/methods/chat.update | ||
| export type ChatUpdateArguments = MessageContents & { | ||
| /** @description Timestamp of the message to be updated. */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import type { EntityActionButton, EntityMetadata } from '@slack/types'; | ||
| import type { TokenOverridable } from './common'; | ||
|
|
||
| // https://docs.slack.dev/reference/methods/entity.presentDetails | ||
| export type EntityPresentDetailsArguments = TokenOverridable & { | ||
| /** | ||
| * @description Entity metadata to be presented in the flexpane. | ||
| * */ | ||
| metadata?: EntityMetadata; | ||
| /** | ||
| * @description A reference to the original user action that initated the request. | ||
| * */ | ||
| trigger_id: string; | ||
| /** | ||
| * @description Set user_auth_required to true to indicate that the user must authenticate to view the full | ||
| * flexpane data. Defaults to false. | ||
| * */ | ||
| user_auth_required?: boolean; | ||
| /** | ||
| * @description A custom URL to which users are directed for authentication if required. | ||
| * Example: "https://example.com/onboarding?user_id=xxx" | ||
| * */ | ||
| user_auth_url?: string; | ||
| /** @description Error response preventing flexpane data from being returned. */ | ||
| error?: { | ||
| /** | ||
| * @description Error status indicating why the entity could not be presented. | ||
| * */ | ||
| status: string; | ||
| /** | ||
| * @description If status is 'custom', you can use this field to provide a message to the client. | ||
| * */ | ||
| custom_message?: string; | ||
| /** | ||
| * @description String format, eg. 'markdown'. | ||
| * */ | ||
| message_format?: string; | ||
| /** | ||
| * @description If status is 'custom', you can use this field to provide a title to the client. | ||
| * */ | ||
| custom_title?: string; | ||
| /** | ||
| * @description Set of action buttons to be shown in case of a specific error. | ||
| * */ | ||
| actions?: EntityActionButton[]; | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| ///////////////////////////////////////////////////////////////////////////////////////// | ||
| // // | ||
| // !!! DO NOT EDIT THIS FILE !!! // | ||
| // // | ||
| // This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // | ||
| // Please refer to the script code to learn how to update the source data. // | ||
| // // | ||
| ///////////////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| import type { WebAPICallResult } from '../../WebClient'; | ||
| export type EntityPresentDetailsResponse = WebAPICallResult & { | ||
| error?: string; | ||
| needed?: string; | ||
| ok?: boolean; | ||
| provided?: string; | ||
| warning?: string; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 💯