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/apps-managed-permissions-set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@slack/web-api": minor
---

feat(web-api): add [`apps.managed.permissions.set`](https://docs.slack.dev/reference/methods/apps.managed.permissions.set) method
14 changes: 14 additions & 0 deletions packages/web-api/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ import type {
AppsConnectionsOpenArguments,
AppsEventAuthorizationsListArguments,
AppsIconSetArguments,
AppsManagedPermissionsSetArguments,
AppsManifestCreateArguments,
AppsManifestDeleteArguments,
AppsManifestExportArguments,
Expand Down Expand Up @@ -420,6 +421,7 @@ import type {
AppsConnectionsOpenResponse,
AppsEventAuthorizationsListResponse,
AppsIconSetResponse,
AppsManagedPermissionsSetResponse,
AppsManifestCreateResponse,
AppsManifestDeleteResponse,
AppsManifestExportResponse,
Expand Down Expand Up @@ -1661,6 +1663,18 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
*/
set: bindApiCall<AppsIconSetArguments, AppsIconSetResponse>(this, 'apps.icon.set'),
},
managed: {
permissions: {
/**
* @description Set who can interact with a managed app.
* @see {@link https://docs.slack.dev/reference/methods/apps.managed.permissions.set `apps.managed.permissions.set` API reference}.
*/
set: bindApiCall<AppsManagedPermissionsSetArguments, AppsManagedPermissionsSetResponse>(
this,
'apps.managed.permissions.set',
),
},
},
manifest: {
/**
* @description Create an app from an app manifest.
Expand Down
9 changes: 9 additions & 0 deletions packages/web-api/src/types/request/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ export interface AppsIconSetArguments extends AppID, TokenOverridable {
url?: string;
}

// https://docs.slack.dev/reference/methods/apps.managed.permissions.set
export interface AppsManagedPermissionsSetArguments extends AppID, TokenOverridable {
/**
* @description Who can interact with the app. Use `everyone` to allow all members, or `app_owner` to restrict access
* to the app's owner.
*/
Comment on lines +26 to +29

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🪓 suggestion (non-blocking): Could we drop this JSDoc? The 'app_owner' | 'everyone' union already says it, and the method's @see link covers the rest, so this copy can drift from the docs page. Same for the @description on the method in methods.ts.

Suggested change
/**
* @description Who can interact with the app. Use everyone to allow all members, or app_owner to restrict access to
* the app's owner.
*/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

📚 note: Thanks @WilliamBergamin! I'd favor keeping these for now, since this package keeps an @description on public API arguments and methods that mirrors the docs page, so it shows in editor hints. The values are in backticks now too, from Michael's suggestion.

permissions: 'app_owner' | 'everyone';
}

// https://docs.slack.dev/reference/methods/apps.manifest.create
export interface AppsManifestCreateArguments extends TokenOverridable {
manifest: Manifest;
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 @@ -145,6 +145,7 @@ export type {
AppsConnectionsOpenArguments,
AppsEventAuthorizationsListArguments,
AppsIconSetArguments,
AppsManagedPermissionsSetArguments,
AppsManifestCreateArguments,
AppsManifestDeleteArguments,
AppsManifestExportArguments,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! 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 AppsManagedPermissionsSetResponse = WebAPICallResult & {
channel_restriction_mode?: string;
error?: string;
needed?: string;
ok?: boolean;
permission_type?: string;
provided?: string;
response_metadata?: ResponseMetadata;
user_ids?: string[];
warning?: string;
};

export interface ResponseMetadata {
messages?: 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 @@ -124,6 +124,7 @@ export { ApiTestResponse } from './ApiTestResponse';
export { AppsConnectionsOpenResponse } from './AppsConnectionsOpenResponse';
export { AppsEventAuthorizationsListResponse } from './AppsEventAuthorizationsListResponse';
export { AppsIconSetResponse } from './AppsIconSetResponse';
export { AppsManagedPermissionsSetResponse } from './AppsManagedPermissionsSetResponse';
Comment thread
zimeg marked this conversation as resolved.
Resolved
export { AppsManifestCreateResponse } from './AppsManifestCreateResponse';
export { AppsManifestDeleteResponse } from './AppsManifestDeleteResponse';
export { AppsManifestExportResponse } from './AppsManifestExportResponse';
Expand Down
34 changes: 34 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 @@ -43,6 +43,40 @@ expectAssignable<Parameters<typeof web.apps.icon.set>>([
},
]);

// apps.managed.permissions.set
// -- sad path
expectError(web.apps.managed.permissions.set()); // lacking argument
expectError(web.apps.managed.permissions.set({})); // empty argument
expectError(
web.apps.managed.permissions.set({
app_id: 'A1234', // missing permissions
}),
);
expectError(
web.apps.managed.permissions.set({
permissions: 'everyone', // missing app_id
}),
);
expectError(
web.apps.managed.permissions.set({
app_id: 'A1234',
permissions: 'no_one', // invalid permissions
}),
);
Comment on lines +60 to +65

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💯 praise: This invalid-value case fails as soon as permissions widens to string, so the union can't quietly loosen.

// -- happy path
expectAssignable<Parameters<typeof web.apps.managed.permissions.set>>([
{
app_id: 'A1234',
permissions: 'everyone',
},
]);
expectAssignable<Parameters<typeof web.apps.managed.permissions.set>>([
{
app_id: 'A1234',
permissions: 'app_owner',
},
]);

// apps.manifest.create
// -- sad path
expectError(web.apps.manifest.create()); // lacking argument
Expand Down
Loading