Skip to content
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

feat (web-api): add support for teams.externalTeams.disconnect API #1837

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/web-api/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ import type {
TeamAccessLogsArguments,
TeamBillableInfoArguments,
TeamBillingInfoArguments,
TeamExternalTeamsDisconnectArguments,
TeamExternalTeamsListArguments,
TeamInfoArguments,
TeamIntegrationLogsArguments,
Expand Down Expand Up @@ -462,6 +463,7 @@ import type {
TeamAccessLogsResponse,
TeamBillableInfoResponse,
TeamBillingInfoResponse,
TeamExternalTeamsDisconnectResponse,
TeamExternalTeamsListResponse,
TeamInfoResponse,
TeamIntegrationLogsResponse,
Expand Down Expand Up @@ -1944,11 +1946,16 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
info: bindApiCall<TeamBillingInfoArguments, TeamBillingInfoResponse>(this, 'team.billing.info'),
},
externalTeams: {
/**
* @description Disconnect an external organization.
* @see {@link https://api.slack.com/methods/team.externalTeams.disconnect `team.externalTeams.disconnect` API reference}.
*/
disconnect: bindApiCall<TeamExternalTeamsDisconnectArguments, TeamExternalTeamsDisconnectResponse>(this, 'team.externalTeams.disconnect'),
/**
* @description Returns a list of all the external teams connected and details about the connection.
* @see {@link https://api.slack.com/methods/team.externalTeams.list `team.externalTeams.list` API reference}.
*/
lookup: bindApiCall<TeamExternalTeamsListArguments, TeamExternalTeamsListResponse>(this, 'team.externalTeams.list'),
list: bindApiCall<TeamExternalTeamsListArguments, TeamExternalTeamsListResponse>(this, 'team.externalTeams.list'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a booboo here previously 😞 😢

},
/**
* @description Gets information about the current team.
Expand Down
6 changes: 5 additions & 1 deletion packages/web-api/src/types/request/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,21 @@ export interface LocaleAware {

/**
* Some API methods take a `team_id` - different interfaces here so that we can provide a different JSDoc.
* Unfortunately some of our APIs don't use a consistent team ID parameter name.
*/

export interface TeamID {
/** @description The encoded team ID. */
team_id: string;
}

export interface OptionalTeamAssignable {
/** @description If using an org token, `team_id` is required. */
team_id?: string;
}
export interface TargetTeam {
/** @description The team or enterprise id of the other party. */
target_team?: string;
}

// Some APIs (admin.teams.settings.setDefaultChannels, admin.conversations.*) require a minimum-1-item channel array

Expand Down
5 changes: 1 addition & 4 deletions packages/web-api/src/types/request/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
CursorPaginationEnabled,
LocaleAware,
OptionalTeamAssignable,
TargetTeam,
TimelinePaginationEnabled,
TokenOverridable,
} from './common';
Expand Down Expand Up @@ -37,10 +38,6 @@ interface Message extends Channel {
/** @description Unique identifier of message. */
ts: string;
}
interface TargetTeam {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Factored this out into common.js as it's also used for various team.* APIs.

/** @description The team or enterprise id of the other party involved in the invitation. */
target_team?: string;
}
interface UserIDs {
/** List of user IDs to receive this invite. Either `emails` or `user_ids` must be provided. */
user_ids: string[];
Expand Down
3 changes: 3 additions & 0 deletions packages/web-api/src/types/request/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CursorPaginationEnabled,
OptionalTeamAssignable,
SortDir,
TargetTeam,
TokenOverridable,
TraditionalPagingEnabled,
} from './common';
Expand All @@ -25,6 +26,8 @@ OptionalTeamAssignable & {
}>;
// https://api.slack.com/methods/team.billing.info
export type TeamBillingInfoArguments = OptionalArgument<TokenOverridable>;
// https://api.slack.com/methods/team.externalTeams.disconnect
export type TeamExternalTeamsDisconnectArguments = TokenOverridable & Required<TargetTeam>;
// https://api.slack.com/methods/team.externalTeams.list
export type TeamExternalTeamsListArguments = OptionalArgument<TokenOverridable & CursorPaginationEnabled & {
/** @description Status of the connected team. */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* 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 TeamExternalTeamsDisconnectResponse = WebAPICallResult & {
error?: string;
needed?: string;
ok?: boolean;
provided?: string;
response_metadata?: ResponseMetadata;
};

export interface ResponseMetadata {
messages?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@
import { WebAPICallResult } from '../../WebClient';
export type UsersDiscoverableContactsLookupResponse = WebAPICallResult & {
error?: string;
is_discoverable?: boolean;
needed?: string;
ok?: boolean;
provided?: string;
response_metadata?: ResponseMetadata;
user?: User;
};

export interface ResponseMetadata {
messages?: string[];
}

export interface User {
is_discoverable?: boolean;
}
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 @@ -266,6 +266,7 @@ export { StarsRemoveResponse } from './StarsRemoveResponse';
export { TeamAccessLogsResponse } from './TeamAccessLogsResponse';
export { TeamBillableInfoResponse } from './TeamBillableInfoResponse';
export { TeamBillingInfoResponse } from './TeamBillingInfoResponse';
export { TeamExternalTeamsDisconnectResponse } from './TeamExternalTeamsDisconnectResponse';
export { TeamExternalTeamsListResponse } from './TeamExternalTeamsListResponse';
export { TeamInfoResponse } from './TeamInfoResponse';
export { TeamIntegrationLogsResponse } from './TeamIntegrationLogsResponse';
Expand Down
18 changes: 16 additions & 2 deletions packages/web-api/test/types/methods/team.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expectAssignable } from 'tsd';
import { expectAssignable, expectError } from 'tsd';

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

const web = new WebClient('TOKEN');
Expand All @@ -19,7 +20,20 @@ expectAssignable<Parameters<typeof web.team.billableInfo>>([]); // no arg is fin
// -- sad path
// -- happy path
expectAssignable<Parameters<typeof web.team.billing.info>>([{}]); // all optional arguments
expectAssignable<Parameters<typeof web.team.billing.info>>([]); // no arg is fine

// team.externalTeams.disconnect
// -- sad path
expectError(web.team.externalTeams.disconnect()); // lacking argument
expectError(web.team.externalTeams.disconnect({})); // missing `target_team`
// -- happy path
expectAssignable<Parameters<typeof web.team.externalTeams.disconnect>>([{
target_team: 'T1234',
}]);

// team.externalTeams.list
// -- sad path
// -- happy path
expectAssignable<Parameters<typeof web.team.externalTeams.list>>([{}]); // all optional args

// team.info
// -- sad path
Expand Down