Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/grumpy-jobs-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@slack/web-api": minor
---

feat: add support for apps.user.connection.update
14 changes: 14 additions & 0 deletions packages/web-api/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import type {
AppsManifestUpdateArguments,
AppsManifestValidateArguments,
AppsUninstallArguments,
AppsUserConnectionUpdateArguments,
AssistantThreadsSetStatusArguments,
AssistantThreadsSetSuggestedPromptsArguments,
AssistantThreadsSetTitleArguments,
Expand Down Expand Up @@ -379,6 +380,7 @@ import type {
AppsManifestUpdateResponse,
AppsManifestValidateResponse,
AppsUninstallResponse,
AppsUserConnectionUpdateResponse,
AssistantThreadsSetStatusResponse,
AssistantThreadsSetSuggestedPromptsResponse,
AssistantThreadsSetTitleResponse,
Expand Down Expand Up @@ -1469,6 +1471,18 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
* @see {@link https://docs.slack.dev/reference/methods/apps.uninstall `apps.uninstall` API reference}.
*/
uninstall: bindApiCall<AppsUninstallArguments, AppsUninstallResponse>(this, 'apps.uninstall'),
user: {
connection: {
/**
* @description Updates the connection status between a user and an app.
* @see {@link https://docs.slack.dev/reference/methods/apps.user.connection.update `apps.user.connection.update` API reference}.
*/
update: bindApiCall<AppsUserConnectionUpdateArguments, AppsUserConnectionUpdateResponse>(
this,
'apps.user.connection.update',
),
},
},
};

public readonly auth = {
Expand Down
8 changes: 8 additions & 0 deletions packages/web-api/src/types/request/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ export interface AppsManifestValidateArguments extends Partial<AppID>, TokenOver
manifest: Manifest;
}

// https://docs.slack.dev/reference/methods/apps.user.connection.update
export interface AppsUserConnectionUpdateArguments extends TokenOverridable {
/** @description The identifier for the user receiving the status update. */
user_id: string;
/** @description The connection status value to assign to the user. `connected` or `disconnected`. */
status: string;
}

// https://docs.slack.dev/reference/methods/apps.uninstall
export interface AppsUninstallArguments
extends Pick<OAuthCredentials, 'client_id' | 'client_secret'>,
Expand Down
1 change: 1 addition & 0 deletions packages/web-api/src/types/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export type {
AppsManifestUpdateArguments,
AppsManifestValidateArguments,
AppsUninstallArguments,
AppsUserConnectionUpdateArguments,
} from './apps';
export type {
AssistantThreadsSetStatusArguments,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! 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 AppsUserConnectionUpdateResponse = WebAPICallResult & {
error?: string;
needed?: string;
ok?: boolean;
provided?: string;
warning?: 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 @@ -116,6 +116,7 @@ export { AppsPermissionsScopesListResponse } from './AppsPermissionsScopesListRe
export { AppsPermissionsUsersListResponse } from './AppsPermissionsUsersListResponse';
export { AppsPermissionsUsersRequestResponse } from './AppsPermissionsUsersRequestResponse';
export { AppsUninstallResponse } from './AppsUninstallResponse';
export { AppsUserConnectionUpdateResponse } from './AppsUserConnectionUpdateResponse';
export { AssistantThreadsSetStatusResponse } from './AssistantThreadsSetStatusResponse';
export { AssistantThreadsSetSuggestedPromptsResponse } from './AssistantThreadsSetSuggestedPromptsResponse';
export { AssistantThreadsSetTitleResponse } from './AssistantThreadsSetTitleResponse';
Expand Down
28 changes: 28 additions & 0 deletions packages/web-api/test/types/methods/apps.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,34 @@ expectAssignable<Parameters<typeof web.apps.manifest.validate>>([
},
]);

// apps.user.connection.update
// -- sad path
expectError(web.apps.user.connection.update()); // lacking argument
expectError(web.apps.user.connection.update({})); // empty argument
expectError(
web.apps.user.connection.update({
user_id: 'U1234', // missing status
}),
);
expectError(
web.apps.user.connection.update({
status: 'connected', // missing user_id
}),
);
// -- happy path
expectAssignable<Parameters<typeof web.apps.user.connection.update>>([
{
user_id: 'U1234',
status: 'connected',
},
]);
expectAssignable<Parameters<typeof web.apps.user.connection.update>>([
{
user_id: 'U1234',
status: 'disconnected',
},
]);

// apps.uninstall
// -- sad path
expectError(web.apps.uninstall()); // lacking argument
Expand Down