Skip to content

Commit

Permalink
web-api: add new conversations.externalInvitePermissions.set API (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
filmaj authored Jul 2, 2024
1 parent e527b43 commit 4ef80b7
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 43 deletions.
10 changes: 10 additions & 0 deletions packages/web-api/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ import type {
ConversationsCloseArguments,
ConversationsCreateArguments,
ConversationsDeclineSharedInviteArguments,
ConversationsExternalInvitePermissionsSetArguments,
ConversationsHistoryArguments,
ConversationsInfoArguments,
ConversationsInviteArguments,
Expand Down Expand Up @@ -390,6 +391,7 @@ import type {
ConversationsCloseResponse,
ConversationsCreateResponse,
ConversationsDeclineSharedInviteResponse,
ConversationsExternalInvitePermissionsSetResponse,
ConversationsHistoryResponse,
ConversationsInfoResponse,
ConversationsInviteResponse,
Expand Down Expand Up @@ -1505,6 +1507,14 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
this,
'conversations.declineSharedInvite',
),
externalInvitePermissions: {
/**
* @description Convert a team in a shared channel from an External Limited channel to a fully shared Slack
* Connect channel or vice versa.
* @see {@link https://api.slack.com/methods/conversations.externalInvitePermissions.set `conversations.externalInvitePermissions.set` API reference}.
*/
set: bindApiCall<ConversationsExternalInvitePermissionsSetArguments, ConversationsExternalInvitePermissionsSetResponse>(this, 'conversations.externalInvitePermissions.set'),
},
/**
* @description Fetches a conversation's history of messages and events.
* @see {@link https://api.slack.com/methods/conversations.history `conversations.history` API reference}.
Expand Down
11 changes: 10 additions & 1 deletion packages/web-api/src/types/request/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,22 @@ export interface ConversationsCreateArguments extends IsPrivate, TokenOverridabl
// https://api.slack.com/methods/conversations.declineSharedInvite
export interface ConversationsDeclineSharedInviteArguments extends InviteID, TargetTeam, TokenOverridable {}

// https://api.slack.com/methods/conversations.externalInvitePermissions.set
export interface ConversationsExternalInvitePermissionsSetArguments extends Channel, Required<TargetTeam>,
TokenOverridable {
/** @description The type of action be taken: `upgrade` or `downgrade`. */
action: 'downgrade' | 'upgrade';
}

// https://api.slack.com/methods/conversations.history
export interface ConversationsHistoryArguments extends Channel, IncludeAllMetadata, TokenOverridable,
CursorPaginationEnabled, TimelinePaginationEnabled {}

// https://api.slack.com/methods/conversations.info
export interface ConversationsInfoArguments extends Channel, TokenOverridable, LocaleAware {
/** @description Set to `true` to include the member count for the specified conversation. Defaults to `false`. */
/**
@description Set to `true` to include the member count for the specified conversation. Defaults to `false`.
*/
include_num_members?: boolean;
}

Expand Down
84 changes: 42 additions & 42 deletions packages/web-api/src/types/request/index.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
export type { WorkflowsStepCompletedArguments, WorkflowsStepFailedArguments, WorkflowsUpdateStepArguments } from './workflows';
export type { ViewsUpdateArguments, ViewsOpenArguments, ViewsPushArguments, ViewsPublishArguments } from './views';
export type { UsersConversationsArguments, UsersDiscoverableContactsLookupArguments, UsersInfoArguments, UsersListArguments, UsersIdentityArguments, UsersSetPhotoArguments, UsersProfileGetArguments, UsersProfileSetArguments, UsersDeletePhotoArguments, UsersGetPresenceArguments, UsersSetPresenceArguments, UsersLookupByEmailArguments } from './users';
export type { ToolingTokensRotateArguments } from './tooling';
export type { SearchAllArguments, SearchFilesArguments, SearchMessagesArguments } from './search';
export type { UsergroupsCreateArguments, UsergroupsDisableArguments, UsergroupsEnableArguments, UsergroupsListArguments, UsergroupsUpdateArguments, UsergroupsUsersListArguments, UsergroupsUsersUpdateArguments } from './usergroups';
export type { TeamAccessLogsArguments, TeamBillableInfoArguments, TeamBillingInfoArguments, TeamExternalTeamsListArguments, TeamInfoArguments, TeamIntegrationLogsArguments, TeamPreferencesListArguments, TeamProfileGetArguments } from './team';
export type { StarsAddRemoveArguments, StarsListArguments } from './stars';
export type { RTMConnectArguments, RTMStartArguments } from './rtm';
export type { RemindersAddArguments, RemindersInfoArguments, RemindersListArguments, RemindersDeleteArguments, RemindersCompleteArguments } from './reminders';
export type { ReactionsAddArguments, ReactionsGetArguments, ReactionsListArguments, ReactionsRemoveArguments } from './reactions';
export type { PinsAddArguments, PinsListArguments, PinsRemoveArguments } from './pins';
export type { OpenIDConnectTokenArguments, OpenIDConnectUserInfoArguments } from './openid';
export type { OAuthAccessArguments, OAuthV2AccessArguments, OAuthV2ExchangeArguments } from './oauth';
export type { MigrationExchangeArguments } from './migration';
export type { FilesDeleteArguments, FilesInfoArguments, FilesListArguments, FilesRevokePublicURLArguments, FilesSharedPublicURLArguments, FilesUploadArguments, FilesUploadV2Arguments, FilesCompleteUploadExternalArguments, FilesGetUploadURLExternalArguments, FilesCommentsDeleteArguments, FilesRemoteUpdateArguments, FilesRemoteRemoveArguments, FilesRemoteShareArguments, FilesRemoteListArguments, FilesRemoteInfoArguments, FilesRemoteAddArguments } from './files';
export type { EmojiListArguments } from './emoji';
export type { DndEndDndArguments, DndEndSnoozeArguments, DndInfoArguments, DndSetSnoozeArguments, DndTeamInfoArguments } from './dnd';
export type { DialogOpenArguments } from './dialog';
export type { ConversationsAcceptSharedInviteArguments, ConversationsApproveSharedInviteArguments, ConversationsArchiveArguments, ConversationsCloseArguments, ConversationsCreateArguments, ConversationsDeclineSharedInviteArguments, ConversationsHistoryArguments, ConversationsInfoArguments, ConversationsInviteArguments, ConversationsInviteSharedArguments, ConversationsJoinArguments, ConversationsKickArguments, ConversationsLeaveArguments, ConversationsListArguments, ConversationsListConnectInvitesArguments, ConversationsMarkArguments, ConversationsMembersArguments, ConversationsOpenArguments, ConversationsRenameArguments, ConversationsRepliesArguments, ConversationsSetPurposeArguments, ConversationsSetTopicArguments, ConversationsUnarchiveArguments } from './conversations';
export type { ChatDeleteArguments, ChatDeleteScheduledMessageArguments, ChatGetPermalinkArguments, ChatMeMessageArguments, ChatPostEphemeralArguments, ChatPostMessageArguments, ChatScheduleMessageArguments, ChatScheduledMessagesListArguments, ChatUnfurlArguments, ChatUpdateArguments } from './chat';
export type { CanvasesAccessDeleteArguments, CanvasesAccessSetArguments, CanvasesCreateArguments, CanvasesDeleteArguments, CanvasesEditArguments, CanvasesSectionsLookupArguments, ConversationsCanvasesCreateArguments } from './canvas';
export type { CallsAddArguments, CallsEndArguments, CallsInfoArguments, CallsUpdateArguments, CallsParticipantsAddArguments, CallsParticipantsRemoveArguments } from './calls';
export type { BotsInfoArguments } from './bots';
export type { BookmarksAddArguments, BookmarksEditArguments, BookmarksListArguments, BookmarksRemoveArguments } from './bookmarks';
export type { AuthRevokeArguments, AuthTestArguments, AuthTeamsListArguments } from './auth';
export type { AppsConnectionsOpenArguments, AppsEventAuthorizationsListArguments, AppsManifestCreateArguments, AppsManifestDeleteArguments, AppsManifestExportArguments, AppsManifestUpdateArguments, AppsManifestValidateArguments, AppsUninstallArguments } from './apps';
export type { APITestArguments } from './api';
export type { AdminAnalyticsGetFileArguments } from './admin/analytics';
export type { AdminAppsActivitiesListArguments, AdminAppsApproveArguments, AdminAppsApprovedListArguments, AdminAppsClearResolutionArguments, AdminAppsConfigLookupArguments, AdminAppsConfigSetArguments, AdminAppsRequestsCancelArguments, AdminAppsRequestsListArguments, AdminAppsRestrictArguments, AdminAppsRestrictedListArguments, AdminAppsUninstallArguments } from './admin/apps';
export type { AdminAuthPolicyAssignEntitiesArguments, AdminAuthPolicyGetEntitiesArguments, AdminAuthPolicyRemoveEntitiesArguments } from './admin/auth';
export type { AdminBarriersCreateArguments, AdminBarriersDeleteArguments, AdminBarriersListArguments, AdminBarriersUpdateArguments } from './admin/barriers';
export type { AdminConversationsArchiveArguments, AdminConversationsBulkArchiveArguments, AdminConversationsBulkDeleteArguments, AdminConversationsBulkMoveArguments, AdminConversationsConvertToPrivateArguments, AdminConversationsConvertToPublicArguments, AdminConversationsCreateArguments, AdminConversationsDeleteArguments, AdminConversationsDisconnectSharedArguments, AdminConversationsEKMListOriginalConnectedChannelInfoArguments, AdminConversationsGetConversationPrefsArguments, AdminConversationsGetCustomRetentionArguments, AdminConversationsGetTeamsArguments, AdminConversationsInviteArguments, AdminConversationsLookupArguments, AdminConversationsRemoveCustomRetentionArguments, AdminConversationsRenameArguments, AdminConversationsRestrictAccessAddGroupArguments, AdminConversationsRestrictAccessListGroupsArguments, AdminConversationsRestrictAccessRemoveGroupArguments, AdminConversationsSearchArguments, AdminConversationsSetConversationPrefsArguments, AdminConversationsSetCustomRetentionArguments, AdminConversationsSetTeamsArguments, AdminConversationsUnarchiveArguments } from './admin/conversations';
export type { AdminEmojiAddArguments, AdminEmojiAddAliasArguments, AdminEmojiListArguments, AdminEmojiRemoveArguments, AdminEmojiRenameArguments } from './admin/emoji';
export type { AdminFunctionsListArguments, AdminFunctionsPermissionsLookupArguments, AdminFunctionsPermissionsSetArguments } from './admin/functions';
export type { FunctionsCompleteErrorArguments, FunctionsCompleteSuccessArguments } from './functions';
export type { AdminInviteRequestsApproveArguments, AdminInviteRequestsApprovedListArguments, AdminInviteRequestsDeniedListArguments, AdminInviteRequestsDenyArguments, AdminInviteRequestsListArguments } from './admin/inviteRequests';
export type { AdminRolesAddAssignmentsArguments, AdminRolesListAssignmentsArguments, AdminRolesRemoveAssignmentsArguments } from './admin/roles';
export type { AdminTeamsAdminsListArguments, AdminTeamsCreateArguments, AdminTeamsListArguments, AdminTeamsOwnersListArguments, AdminTeamsSettingsInfoArguments, AdminTeamsSettingsSetDefaultChannelsArguments, AdminTeamsSettingsSetDescriptionArguments, AdminTeamsSettingsSetDiscoverabilityArguments, AdminTeamsSettingsSetIconArguments, AdminTeamsSettingsSetNameArguments } from './admin/teams';
export type { AdminUsergroupsAddChannelsArguments, AdminUsergroupsAddTeamsArguments, AdminUsergroupsListChannelsArguments, AdminUsergroupsRemoveChannelsArguments } from './admin/usergroups';
export type { AdminUsersAssignArguments, AdminUsersInviteArguments, AdminUsersListArguments, AdminUsersRemoveArguments, AdminUsersSessionListArguments, AdminUsersSessionClearSettingsArguments, AdminUsersSessionGetSettingsArguments, AdminUsersSessionInvalidateArguments, AdminUsersSessionResetArguments, AdminUsersSessionResetBulkArguments, AdminUsersSessionSetSettingsArguments, AdminUsersSetAdminArguments, AdminUsersSetExpirationArguments, AdminUsersSetOwnerArguments, AdminUsersSetRegularArguments, AdminUsersUnsupportedVersionsExportArguments } from './admin/users';
export type { AdminWorkflowsCollaboratorsAddArguments, AdminWorkflowsCollaboratorsRemoveArguments, AdminWorkflowsPermissionsLookupArguments, AdminWorkflowsSearchArguments, AdminWorkflowsUnpublishArguments } from './admin/workflows';
export type * from './workflows';
export type * from './views';
export type * from './users';
export type * from './tooling';
export type * from './search';
export type * from './usergroups';
export type * from './team';
export type * from './stars';
export type * from './rtm';
export type * from './reminders';
export type * from './reactions';
export type * from './pins';
export type * from './openid';
export type * from './oauth';
export type * from './migration';
export type * from './files';
export type * from './emoji';
export type * from './dnd';
export type * from './dialog';
export type * from './conversations';
export type * from './chat';
export type * from './canvas';
export type * from './calls';
export type * from './bots';
export type * from './bookmarks';
export type * from './auth';
export type * from './apps';
export type * from './api';
export type * from './admin/analytics';
export type * from './admin/apps';
export type * from './admin/auth';
export type * from './admin/barriers';
export type * from './admin/conversations';
export type * from './admin/emoji';
export type * from './admin/functions';
export type * from './functions';
export type * from './admin/inviteRequests';
export type * from './admin/roles';
export type * from './admin/teams';
export type * from './admin/usergroups';
export type * from './admin/users';
export type * from './admin/workflows';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! 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 { WebAPICallResult } from '../../WebClient';
export type ConversationsExternalInvitePermissionsSetResponse = WebAPICallResult & {
error?: string;
needed?: string;
ok?: boolean;
provided?: string;
};
1 change: 1 addition & 0 deletions packages/web-api/src/types/response/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export { ConversationsCanvasesCreateResponse } from './ConversationsCanvasesCrea
export { ConversationsCloseResponse } from './ConversationsCloseResponse';
export { ConversationsCreateResponse } from './ConversationsCreateResponse';
export { ConversationsDeclineSharedInviteResponse } from './ConversationsDeclineSharedInviteResponse';
export { ConversationsExternalInvitePermissionsSetResponse } from './ConversationsExternalInvitePermissionsSetResponse';
export { ConversationsHistoryResponse } from './ConversationsHistoryResponse';
export { ConversationsInfoResponse } from './ConversationsInfoResponse';
export { ConversationsInviteResponse } from './ConversationsInviteResponse';
Expand Down
18 changes: 18 additions & 0 deletions packages/web-api/test/types/methods/conversations.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expectAssignable, expectError } from 'tsd';

import { WebClient } from '../../../src/WebClient';

const web = new WebClient('TOKEN');
Expand Down Expand Up @@ -71,6 +72,23 @@ expectAssignable<Parameters<typeof web.conversations.declineSharedInvite>>([{
invite_id: 'I1234',
}]);

// conversations.externalInvitePermissions.set
// -- sad path
expectError(web.conversations.externalInvitePermissions.set()); // lacking argument
expectError(web.conversations.externalInvitePermissions.set({})); // empty argument
expectError(web.conversations.externalInvitePermissions.set({ action: 'upgrade' })); // missing target_team, channel
expectError(web.conversations.externalInvitePermissions.set({ channel: 'C1234' })); // missing target_team, action
expectError(web.conversations.externalInvitePermissions.set({ target_team: 'T1234' })); // missing channel, action
expectError(web.conversations.externalInvitePermissions.set({ action: 'upgrade', channel: 'C1234' })); // missing target_team
expectError(web.conversations.externalInvitePermissions.set({ channel: 'C1234', target_team: 'T1234' })); // missing action
expectError(web.conversations.externalInvitePermissions.set({ target_team: 'T1234', action: 'downgrade' })); // missing channel
// -- happy path
expectAssignable<Parameters<typeof web.conversations.externalInvitePermissions.set>>([{
channel: 'C1234',
target_team: 'T1234',
action: 'upgrade',
}]);

// conversations.history
// -- sad path
expectError(web.conversations.history()); // lacking argument
Expand Down

0 comments on commit 4ef80b7

Please sign in to comment.