From 3d0e9db3e1ba4d47d7dc7dfa3639f3673a989e4a Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Mon, 7 Oct 2024 15:13:59 -0400 Subject: [PATCH 1/2] web-api(feat): add support for `conversations.requestShared.list` API. --- packages/web-api/src/methods.ts | 10 ++ .../src/types/request/conversations.ts | 21 ++++- packages/web-api/src/types/request/index.ts | 1 + ...rsationsRequestSharedInviteListResponse.ts | 93 +++++++++++++++++++ packages/web-api/src/types/response/index.ts | 1 + 5 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 packages/web-api/src/types/response/ConversationsRequestSharedInviteListResponse.ts diff --git a/packages/web-api/src/methods.ts b/packages/web-api/src/methods.ts index 8675ba739..2f6fb0982 100644 --- a/packages/web-api/src/methods.ts +++ b/packages/web-api/src/methods.ts @@ -165,6 +165,7 @@ import type { ConversationsRepliesArguments, ConversationsRequestSharedInviteApproveArguments, ConversationsRequestSharedInviteDenyArguments, + ConversationsRequestSharedInviteListArguments, ConversationsSetPurposeArguments, ConversationsSetTopicArguments, ConversationsUnarchiveArguments, @@ -417,6 +418,7 @@ import type { ConversationsRepliesResponse, ConversationsRequestSharedInviteApproveResponse, ConversationsRequestSharedInviteDenyResponse, + ConversationsRequestSharedInviteListResponse, ConversationsSetPurposeResponse, ConversationsSetTopicResponse, ConversationsUnarchiveResponse, @@ -1772,6 +1774,14 @@ export abstract class Methods extends EventEmitter { this, 'conversations.requestSharedInvite.deny', ), + /** + * @description Lists requests to add external users to channels with ability to filter. + * @see {@link https://api.slack.com/methods/conversations.requestSharedInvite.list `conversations.requestSharedInvite.list` API reference}. + */ + list: bindApiCall( + this, + 'conversations.requestSharedInvite.list', + ), }, /** * @description Sets the purpose for a conversation. diff --git a/packages/web-api/src/types/request/conversations.ts b/packages/web-api/src/types/request/conversations.ts index 27abe5593..0565f3c9c 100644 --- a/packages/web-api/src/types/request/conversations.ts +++ b/packages/web-api/src/types/request/conversations.ts @@ -192,7 +192,10 @@ export interface ConversationsRepliesArguments TimelinePaginationEnabled {} // https://api.slack.com/methods/conversations.requestSharedInvite.approve -export interface ConversationsRequestSharedInviteApproveArguments extends InviteID, Partial { +export interface ConversationsRequestSharedInviteApproveArguments + extends InviteID, + Partial, + TokenOverridable { /** * @description Whether the invited team will have post-only permissions in the channel. * Will override the value on the requested invite. @@ -211,7 +214,21 @@ export interface ConversationsRequestSharedInviteApproveArguments extends Invite } // https://api.slack.com/methods/conversations.requestSharedInvite.deny -export interface ConversationsRequestSharedInviteDenyArguments extends InviteID, Message {} +export interface ConversationsRequestSharedInviteDenyArguments extends InviteID, Message, TokenOverridable {} + +// https://api.slack.com/methods/conversations.requestSharedInvite.list +export interface ConversationsRequestSharedInviteListArguments extends CursorPaginationEnabled, TokenOverridable { + /** @description When `true` approved invitation requests will be returned, otherwise they will be excluded. */ + include_approved?: boolean; + /** @description When `true` denied invitation requests will be returned, otherwise they will be excluded. */ + include_denied?: boolean; + /** @description When `true` expired invitation requests will be returned, otherwise they will be excluded. */ + include_expired?: boolean; + /** @description An optional list of invitation ids to look up. */ + invite_ids?: string[]; + /** @description Optional filter to return invitation requests for the inviting user. */ + user_id?: string; +} // https://api.slack.com/methods/conversations.setPurpose export interface ConversationsSetPurposeArguments extends Channel, TokenOverridable { diff --git a/packages/web-api/src/types/request/index.ts b/packages/web-api/src/types/request/index.ts index ebef7cdac..e7639fb4b 100644 --- a/packages/web-api/src/types/request/index.ts +++ b/packages/web-api/src/types/request/index.ts @@ -110,6 +110,7 @@ export type { ConversationsRepliesArguments, ConversationsRequestSharedInviteApproveArguments, ConversationsRequestSharedInviteDenyArguments, + ConversationsRequestSharedInviteListArguments, ConversationsSetPurposeArguments, ConversationsSetTopicArguments, ConversationsUnarchiveArguments, diff --git a/packages/web-api/src/types/response/ConversationsRequestSharedInviteListResponse.ts b/packages/web-api/src/types/response/ConversationsRequestSharedInviteListResponse.ts new file mode 100644 index 000000000..65f4d5b96 --- /dev/null +++ b/packages/web-api/src/types/response/ConversationsRequestSharedInviteListResponse.ts @@ -0,0 +1,93 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! 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 ConversationsRequestSharedInviteListResponse = WebAPICallResult & { + invite_requests?: InviteRequest[]; + ok?: boolean; +}; + +export interface InviteRequest { + channel?: Channel; + date_created?: number; + date_last_updated?: number; + expires_at?: number; + id?: string; + inviting_team?: Team; + inviting_user?: InvitingUser; + is_external_limited?: boolean; + target_user?: TargetUser; +} + +export interface Channel { + connections?: Connection[]; + date_created?: number; + id?: string; + is_im?: boolean; + is_private?: boolean; + name?: string; + pending_connections?: any[]; + previous_connections?: any[]; +} + +export interface Connection { + is_private?: boolean; + team?: Team; +} + +export interface Team { + avatar_base_url?: string; + date_created?: number; + domain?: string; + icon?: Icon; + id?: string; + is_verified?: boolean; + name?: string; + requires_sponsorship?: boolean; +} + +export interface Icon { + image_102?: string; + image_132?: string; + image_230?: string; + image_34?: string; + image_44?: string; + image_68?: string; + image_88?: string; + image_default?: boolean; +} + +export interface InvitingUser { + id?: string; + name?: string; + profile?: Profile; + team_id?: string; + updated?: number; + who_can_share_contact_card?: string; +} + +export interface Profile { + avatar_hash?: string; + display_name?: string; + display_name_normalized?: string; + email?: string; + image_192?: string; + image_24?: string; + image_32?: string; + image_48?: string; + image_512?: string; + image_72?: string; + real_name?: string; + real_name_normalized?: string; + team?: string; +} + +export interface TargetUser { + recipient_email?: string; +} diff --git a/packages/web-api/src/types/response/index.ts b/packages/web-api/src/types/response/index.ts index 37216c3f1..0a5f259ad 100644 --- a/packages/web-api/src/types/response/index.ts +++ b/packages/web-api/src/types/response/index.ts @@ -188,6 +188,7 @@ export { ConversationsRenameResponse } from './ConversationsRenameResponse'; export { ConversationsRepliesResponse } from './ConversationsRepliesResponse'; export { ConversationsRequestSharedInviteApproveResponse } from './ConversationsRequestSharedInviteApproveResponse'; export { ConversationsRequestSharedInviteDenyResponse } from './ConversationsRequestSharedInviteDenyResponse'; +export { ConversationsRequestSharedInviteListResponse } from './ConversationsRequestSharedInviteListResponse'; export { ConversationsSetPurposeResponse } from './ConversationsSetPurposeResponse'; export { ConversationsSetTopicResponse } from './ConversationsSetTopicResponse'; export { ConversationsUnarchiveResponse } from './ConversationsUnarchiveResponse'; From 542dc033e6e5fbd7e3fb7aaba1498904bdf7ca52 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Mon, 7 Oct 2024 15:22:39 -0400 Subject: [PATCH 2/2] list api has optional arguments. add some type tests. --- packages/web-api/src/methods.ts | 8 +++--- .../src/types/request/conversations.ts | 27 ++++++++++--------- .../types/methods/conversations.test-d.ts | 6 +++++ 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/packages/web-api/src/methods.ts b/packages/web-api/src/methods.ts index 2f6fb0982..fd54cf253 100644 --- a/packages/web-api/src/methods.ts +++ b/packages/web-api/src/methods.ts @@ -1778,10 +1778,10 @@ export abstract class Methods extends EventEmitter { * @description Lists requests to add external users to channels with ability to filter. * @see {@link https://api.slack.com/methods/conversations.requestSharedInvite.list `conversations.requestSharedInvite.list` API reference}. */ - list: bindApiCall( - this, - 'conversations.requestSharedInvite.list', - ), + list: bindApiCallWithOptionalArgument< + ConversationsRequestSharedInviteListArguments, + ConversationsRequestSharedInviteListResponse + >(this, 'conversations.requestSharedInvite.list'), }, /** * @description Sets the purpose for a conversation. diff --git a/packages/web-api/src/types/request/conversations.ts b/packages/web-api/src/types/request/conversations.ts index 0565f3c9c..25882035b 100644 --- a/packages/web-api/src/types/request/conversations.ts +++ b/packages/web-api/src/types/request/conversations.ts @@ -217,18 +217,21 @@ export interface ConversationsRequestSharedInviteApproveArguments export interface ConversationsRequestSharedInviteDenyArguments extends InviteID, Message, TokenOverridable {} // https://api.slack.com/methods/conversations.requestSharedInvite.list -export interface ConversationsRequestSharedInviteListArguments extends CursorPaginationEnabled, TokenOverridable { - /** @description When `true` approved invitation requests will be returned, otherwise they will be excluded. */ - include_approved?: boolean; - /** @description When `true` denied invitation requests will be returned, otherwise they will be excluded. */ - include_denied?: boolean; - /** @description When `true` expired invitation requests will be returned, otherwise they will be excluded. */ - include_expired?: boolean; - /** @description An optional list of invitation ids to look up. */ - invite_ids?: string[]; - /** @description Optional filter to return invitation requests for the inviting user. */ - user_id?: string; -} +export type ConversationsRequestSharedInviteListArguments = OptionalArgument< + CursorPaginationEnabled & + TokenOverridable & { + /** @description When `true` approved invitation requests will be returned, otherwise they will be excluded. */ + include_approved?: boolean; + /** @description When `true` denied invitation requests will be returned, otherwise they will be excluded. */ + include_denied?: boolean; + /** @description When `true` expired invitation requests will be returned, otherwise they will be excluded. */ + include_expired?: boolean; + /** @description An optional list of invitation ids to look up. */ + invite_ids?: string[]; + /** @description Optional filter to return invitation requests for the inviting user. */ + user_id?: string; + } +>; // https://api.slack.com/methods/conversations.setPurpose export interface ConversationsSetPurposeArguments extends Channel, TokenOverridable { diff --git a/packages/web-api/test/types/methods/conversations.test-d.ts b/packages/web-api/test/types/methods/conversations.test-d.ts index 40eca0c08..30effdd1c 100644 --- a/packages/web-api/test/types/methods/conversations.test-d.ts +++ b/packages/web-api/test/types/methods/conversations.test-d.ts @@ -378,6 +378,12 @@ expectAssignable>( }, ]); +// conversations.requestSharedInvite.list +// -- sad path +// -- happy path +expectAssignable>([{}]); // all optional args +expectAssignable>([]); // no arg is fine + // conversations.setPurpose // -- sad path expectError(web.conversations.setPurpose()); // lacking argument