diff --git a/.changeset/slack-lists-message-field.md b/.changeset/slack-lists-message-field.md new file mode 100644 index 000000000..1340d972e --- /dev/null +++ b/.changeset/slack-lists-message-field.md @@ -0,0 +1,5 @@ +--- +"@slack/web-api": patch +--- + +Fix Slack Lists message field types to allow returned message metadata objects while preserving URL-array request values. diff --git a/packages/web-api/src/types/request/slackLists.ts b/packages/web-api/src/types/request/slackLists.ts index 21cc8d431..d032f5f1e 100644 --- a/packages/web-api/src/types/request/slackLists.ts +++ b/packages/web-api/src/types/request/slackLists.ts @@ -58,11 +58,49 @@ export interface SlackListsItemFieldLink { } /** - * @description Message field with message URLs. + * @description Message metadata returned for Slack Lists message fields. + */ +export interface SlackListsItemMessage { + /** + * @description URL value for the referenced message. + */ + value?: string; + /** + * @description Channel containing the referenced message. + */ + channel_id?: string; + /** + * @description Timestamp of the referenced message. + */ + ts?: string; + /** + * @description Thread timestamp of the referenced message. + */ + thread_ts?: string; + /** + * @description Plain text fallback returned by some message field responses. + */ + text?: string; + /** + * @description User ID associated with the referenced message. + */ + user?: string; + /** + * @description Team ID associated with the referenced message. + */ + team?: string; + /** + * @description Message type returned by the API. + */ + type?: string; +} + +/** + * @description Message field with request message URLs or returned message metadata. */ export interface SlackListsItemFieldMessage { column_id: string; - message: string[]; + message: string[] | SlackListsItemMessage | SlackListsItemMessage[]; } /** diff --git a/packages/web-api/test/types/methods/slacklists.test-d.ts b/packages/web-api/test/types/methods/slacklists.test-d.ts index 0f8a02274..5ef48226d 100644 --- a/packages/web-api/test/types/methods/slacklists.test-d.ts +++ b/packages/web-api/test/types/methods/slacklists.test-d.ts @@ -3,6 +3,8 @@ import { expectAssignable, expectError } from 'tsd'; import { WebClient } from '../../../src/WebClient'; const web = new WebClient('TOKEN'); +type SlackListsItemsListResponse = Awaited>; +type SlackListsItemField = NonNullable[number]['fields'][number]; // slackLists.access.delete // -- sad path @@ -77,9 +79,35 @@ expectError(web.slackLists.items.create({})); // missing list_id expectAssignable>([ { list_id: 'L1234567890', + initial_fields: [ + { + column_id: 'Col1234567890', + message: ['https://example.slack.com/archives/C1234567890/p1234567890123456'], + }, + ], }, ]); +expectAssignable({ + column_id: 'Col1234567890', + message: { + text: 'hello', + ts: '123.456', + user: 'U0123456789', + }, +}); + +expectAssignable({ + column_id: 'Col1234567890', + message: [ + { + value: 'https://example.slack.com/archives/C1234567890/p1234567890123456', + channel_id: 'C1234567890', + ts: '1234567890.123456', + }, + ], +}); + // slackLists.items.delete // -- sad path expectError(web.slackLists.items.delete()); // lacking argument