Skip to content

Commit 16bd88e

Browse files
authored
web-api(fix):Update SearchMessagesArguments to support cursor pagination (#2361)
1 parent 7c60024 commit 16bd88e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

packages/web-api/src/types/request/search.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,23 @@ interface Searchable extends OptionalTeamAssignable, SortDir {
1212
sort?: 'score' | 'timestamp';
1313
}
1414

15+
interface SearchMessagesCursorPagination {
16+
/**
17+
* @description Paginate through collections of data by setting the `cursor` parameter to `*` for the first "page"
18+
* or a `next_cursor` attribute returned by a previous request's `response_metadata`.
19+
* Use the `count` parameter to set the number of items to return per page rather than `limit`.
20+
* @see {@link https://docs.slack.dev/apis/web-api/pagination pagination} for more detail.
21+
*/
22+
cursor?: string;
23+
}
24+
1525
// https://docs.slack.dev/reference/methods/search.all
1626
export interface SearchAllArguments extends TokenOverridable, TraditionalPagingEnabled, Searchable {}
1727
// https://docs.slack.dev/reference/methods/search.files
1828
export interface SearchFilesArguments extends TokenOverridable, TraditionalPagingEnabled, Searchable {}
1929
// https://docs.slack.dev/reference/methods/search.messages
20-
export interface SearchMessagesArguments extends TokenOverridable, TraditionalPagingEnabled, Searchable {}
30+
export interface SearchMessagesArguments
31+
extends TokenOverridable,
32+
TraditionalPagingEnabled,
33+
Searchable,
34+
SearchMessagesCursorPagination {}

packages/web-api/test/types/methods/search.test-d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,10 @@ expectAssignable<Parameters<typeof web.search.messages>>([
3535
query: '1234', // must specify query
3636
},
3737
]);
38+
expectAssignable<Parameters<typeof web.search.messages>>([
39+
{
40+
query: '1234',
41+
cursor: '*', // optional: enable cursor pagination
42+
count: 30, // optional: the number of results to return per page
43+
},
44+
]);

0 commit comments

Comments
 (0)