Skip to content

Commit

Permalink
Add five missing admin APIs (#1602)
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch authored Apr 7, 2023
1 parent 1c72709 commit 71b1803
Show file tree
Hide file tree
Showing 40 changed files with 478 additions and 72 deletions.
3 changes: 3 additions & 0 deletions packages/web-api/src/WebClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,9 @@ export function buildThreadTsWarningMessage(method: string): string {
* @param body
* @returns
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function redact(body: any): any {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const flattened = Object.entries(body).map<[string, any] | []>(([key, value]) => {
// no value provided
if (value === undefined || value === null) {
Expand All @@ -924,6 +926,7 @@ function redact(body: any): any {
});

// return as object
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const initialValue: { [key: string]: any; } = {};
return flattened.reduce(
(accumulator, [key, value]) => {
Expand Down
45 changes: 45 additions & 0 deletions packages/web-api/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ import {
BookmarksEditResponse,
BookmarksListResponse,
BookmarksRemoveResponse,
AdminConversationsConvertToPublicResponse,
AdminConversationsLookupResponse,
AdminRolesAddAssignmentsResponse,
AdminRolesListAssignmentsResponse,
AdminRolesRemoveAssignmentsResponse,
} from './response';

// NOTE: could create a named type alias like data types like `SlackUserID: string`
Expand Down Expand Up @@ -302,6 +307,10 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
bindApiCall<AdminConversationsConvertToPrivateArguments, AdminConversationsConvertToPrivateResponse>(
this, 'admin.conversations.convertToPrivate',
),
convertToPublic:
bindApiCall<AdminConversationsConvertToPublicArguments, AdminConversationsConvertToPublicResponse>(
this, 'admin.conversations.convertToPublic',
),
create: bindApiCall<AdminConversationsCreateArguments, AdminConversationsCreateResponse>(this, 'admin.conversations.create'),
delete: bindApiCall<AdminConversationsDeleteArguments, AdminConversationsDeleteResponse>(this, 'admin.conversations.delete'),
disconnectShared:
Expand Down Expand Up @@ -352,6 +361,7 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
bindApiCall<AdminConversationsRemoveCustomRetentionArguments, AdminConversationsRemoveCustomRetentionResponse>(
this, 'admin.conversations.removeCustomRetention',
),
lookup: bindApiCall<AdminConversationsLookupArguments, AdminConversationsLookupResponse>(this, 'admin.conversations.lookup'),
search: bindApiCall<AdminConversationsSearchArguments, AdminConversationsSearchResponse>(this, 'admin.conversations.search'),
setConversationPrefs:
bindApiCall<AdminConversationsSetConversationPrefsArguments, AdminConversationsSetConversationPrefsResponse>(
Expand Down Expand Up @@ -420,6 +430,11 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
),
},
},
roles: {
addAssignments: bindApiCall<AdminRolesAddAssignmentsArguments, AdminRolesAddAssignmentsResponse>(this, 'admin.roles.addAssignments'),
listAssignments: bindApiCall<AdminRolesListAssignmentsArguments, AdminRolesListAssignmentsResponse>(this, 'admin.roles.listAssignments'),
removeAssignments: bindApiCall<AdminRolesRemoveAssignmentsArguments, AdminRolesRemoveAssignmentsResponse>(this, 'admin.roles.removeAssignments'),
},
usergroups: {
addChannels: bindApiCall<AdminUsergroupsAddChannelsArguments, AdminUsergroupsAddChannelsResponse>(
this, 'admin.usergroups.addChannels',
Expand Down Expand Up @@ -977,6 +992,9 @@ export interface AdminConversationsBulkMoveArguments extends WebAPICallOptions,
export interface AdminConversationsConvertToPrivateArguments extends WebAPICallOptions, TokenOverridable {
channel_id: string;
}
export interface AdminConversationsConvertToPublicArguments extends WebAPICallOptions, TokenOverridable {
channel_id: string;
}
export interface AdminConversationsCreateArguments extends WebAPICallOptions, TokenOverridable {
is_private: boolean;
name: string;
Expand All @@ -991,6 +1009,13 @@ export interface AdminConversationsDisconnectSharedArguments extends WebAPICallO
channel_id: string;
leaving_team_ids?: string[];
}
export interface AdminConversationsLookupArguments
extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled {
last_message_activity_before: number;
team_ids: string[];
max_member_count?: number;
}
cursorPaginationEnabledMethods.add('admin.conversations.lookup');
export interface AdminConversationsEKMListOriginalConnectedChannelInfoArguments
extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled {
channel_ids?: string[];
Expand Down Expand Up @@ -1101,6 +1126,26 @@ export interface AdminInviteRequestsListArguments
team_id: string;
}
cursorPaginationEnabledMethods.add('admin.inviteRequests.list');
export interface AdminRolesAddAssignmentsArguments
extends WebAPICallOptions, TokenOverridable {
role_id: string;
entity_ids: string[];
user_ids: string[];
}
export interface AdminRolesListAssignmentsArguments
extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled {
entity_ids?: string[];
role_ids?: string[];
sort_dir?: string;
}
cursorPaginationEnabledMethods.add('admin.roles.listAssignments');
export interface AdminRolesRemoveAssignmentsArguments
extends WebAPICallOptions, TokenOverridable {
role_id: string;
entity_ids: string[];
user_ids: string[];
}
cursorPaginationEnabledMethods.add('admin.inviteRequests.list');
export interface AdminTeamsAdminsListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled {
team_id: string;
}
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 AdminConversationsConvertToPublicResponse = WebAPICallResult & {
error?: string;
needed?: string;
ok?: boolean;
provided?: string;
response_metadata?: ResponseMetadata;
};

export interface ResponseMetadata {
messages?: string[];
}
23 changes: 23 additions & 0 deletions packages/web-api/src/response/AdminConversationsLookupResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* 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 AdminConversationsLookupResponse = WebAPICallResult & {
channel_ids?: string[];
error?: string;
needed?: string;
ok?: boolean;
provided?: string;
response_metadata?: ResponseMetadata;
};

export interface ResponseMetadata {
next_cursor?: string;
}
23 changes: 23 additions & 0 deletions packages/web-api/src/response/AdminRolesAddAssignmentsResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* 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 AdminRolesAddAssignmentsResponse = WebAPICallResult & {
error?: string;
needed?: string;
ok?: boolean;
provided?: string;
rejected_users?: RejectedUser[];
};

export interface RejectedUser {
error?: string;
id?: string;
}
31 changes: 31 additions & 0 deletions packages/web-api/src/response/AdminRolesListAssignmentsResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* 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 AdminRolesListAssignmentsResponse = WebAPICallResult & {
error?: string;
needed?: string;
ok?: boolean;
provided?: string;
response_metadata?: ResponseMetadata;
role_assignments?: RoleAssignment[];
};

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

export interface RoleAssignment {
date_create?: number;
entity_id?: string;
role_id?: string;
user_id?: string;
}
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 AdminRolesRemoveAssignmentsResponse = WebAPICallResult & {
error?: string;
needed?: string;
ok?: boolean;
provided?: string;
};
12 changes: 12 additions & 0 deletions packages/web-api/src/response/AuthTeamsListResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ export interface ResponseMetadata {
}

export interface Team {
icon?: Icon;
id?: string;
name?: string;
}

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;
}
1 change: 1 addition & 0 deletions packages/web-api/src/response/BookmarksAddResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type BookmarksAddResponse = WebAPICallResult & {
};

export interface Bookmark {
app_action_id?: string;
app_id?: string;
channel_id?: string;
date_created?: number;
Expand Down
1 change: 1 addition & 0 deletions packages/web-api/src/response/BookmarksEditResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type BookmarksEditResponse = WebAPICallResult & {
};

export interface Bookmark {
app_action_id?: string;
app_id?: string;
channel_id?: string;
date_created?: number;
Expand Down
1 change: 1 addition & 0 deletions packages/web-api/src/response/BookmarksListResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type BookmarksListResponse = WebAPICallResult & {
};

export interface Bookmark {
app_action_id?: string;
app_id?: string;
channel_id?: string;
date_created?: number;
Expand Down
6 changes: 6 additions & 0 deletions packages/web-api/src/response/ChatPostMessageResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface Attachment {
callback_id?: string;
channel_id?: string;
channel_name?: string;
channel_team?: string;
color?: string;
fallback?: string;
fields?: Field[];
Expand Down Expand Up @@ -237,6 +238,7 @@ export interface AccessoryElement {
indent?: number;
offset?: number;
style?: string;
text?: string;
type?: string;
}

Expand Down Expand Up @@ -356,6 +358,7 @@ export interface BlockFile {
from?: Cc[];
groups?: string[];
has_more?: boolean;
has_more_shares?: boolean;
has_rich_preview?: boolean;
headers?: Headers;
hls?: string;
Expand Down Expand Up @@ -397,6 +400,7 @@ export interface BlockFile {
shares?: Shares;
simplified_html?: string;
size?: number;
source_team?: string;
subject?: string;
subtype?: string;
thumb_1024?: string;
Expand Down Expand Up @@ -547,6 +551,7 @@ export interface FileElement {
from?: Cc[];
groups?: string[];
has_more?: boolean;
has_more_shares?: boolean;
has_rich_preview?: boolean;
headers?: Headers;
hls?: string;
Expand Down Expand Up @@ -588,6 +593,7 @@ export interface FileElement {
shares?: Shares;
simplified_html?: string;
size?: number;
source_team?: string;
subject?: string;
subtype?: string;
thumb_1024?: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/web-api/src/response/ChatScheduleMessageResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export interface File {
from?: Cc[];
groups?: string[];
has_more?: boolean;
has_more_shares?: boolean;
has_rich_preview?: boolean;
headers?: Headers;
hls?: string;
Expand Down Expand Up @@ -298,6 +299,7 @@ export interface File {
shares?: Shares;
simplified_html?: string;
size?: number;
source_team?: string;
subject?: string;
subtype?: string;
thumb_1024?: string;
Expand Down
4 changes: 4 additions & 0 deletions packages/web-api/src/response/ChatUpdateResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export interface BlockFile {
from?: Cc[];
groups?: string[];
has_more?: boolean;
has_more_shares?: boolean;
has_rich_preview?: boolean;
headers?: Headers;
hls?: string;
Expand Down Expand Up @@ -303,6 +304,7 @@ export interface BlockFile {
shares?: Shares;
simplified_html?: string;
size?: number;
source_team?: string;
subject?: string;
subtype?: string;
thumb_1024?: string;
Expand Down Expand Up @@ -468,6 +470,7 @@ export interface FileElement {
from?: Cc[];
groups?: string[];
has_more?: boolean;
has_more_shares?: boolean;
has_rich_preview?: boolean;
headers?: Headers;
hls?: string;
Expand Down Expand Up @@ -509,6 +512,7 @@ export interface FileElement {
shares?: Shares;
simplified_html?: string;
size?: number;
source_team?: string;
subject?: string;
subtype?: string;
thumb_1024?: string;
Expand Down
Loading

0 comments on commit 71b1803

Please sign in to comment.