Skip to content

Commit dd797cf

Browse files
zimegvegeris
andauthored
feat(web-api): add workflows.featured.{add|list|remove|set} methods (#2303)
Co-authored-by: Elaine Vegeris <[email protected]>
1 parent a40348c commit dd797cf

File tree

11 files changed

+244
-1
lines changed

11 files changed

+244
-1
lines changed

packages/web-api/src/WebClient.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,24 @@ describe('WebClient', () => {
326326
assert.fail('Should have logged a warning and info when files.upload is used');
327327
}
328328
});
329+
330+
it('warns when user is accessing a deprecated method', async () => {
331+
const client = new WebClient(token, { logLevel: LogLevel.INFO, logger });
332+
await client.apiCall('workflows.stepCompleted', {});
333+
334+
let warnedAboutDeprecatedMethod = false;
335+
for (const call of (logger.warn as sinon.SinonStub).getCalls()) {
336+
if (
337+
call.args[0] ===
338+
'workflows.stepCompleted is deprecated. Please check on https://docs.slack.dev/reference/methods for an alternative.'
339+
) {
340+
warnedAboutDeprecatedMethod = true;
341+
}
342+
}
343+
if (!warnedAboutDeprecatedMethod) {
344+
assert.fail('Should have logged a warning when a deprecated method is used');
345+
}
346+
});
329347
});
330348

331349
describe('with OAuth scopes in the response headers', () => {

packages/web-api/src/WebClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ function parseRetryHeaders(response: AxiosResponse): number | undefined {
964964
* @param logger instance of web clients logger
965965
*/
966966
function warnDeprecations(method: string, logger: Logger): void {
967-
const deprecatedMethods = ['workflows.'];
967+
const deprecatedMethods = ['workflows.stepCompleted', 'workflows.stepFailed', 'workflows.updateStep'];
968968

969969
const isDeprecated = deprecatedMethods.some((depMethod) => {
970970
const re = new RegExp(`^${depMethod}`);

packages/web-api/src/methods.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ import type {
250250
ViewsPublishArguments,
251251
ViewsPushArguments,
252252
ViewsUpdateArguments,
253+
WorkflowsFeaturedAddArguments,
254+
WorkflowsFeaturedListArguments,
255+
WorkflowsFeaturedRemoveArguments,
256+
WorkflowsFeaturedSetArguments,
253257
WorkflowsStepCompletedArguments,
254258
WorkflowsStepFailedArguments,
255259
WorkflowsUpdateStepArguments,
@@ -503,6 +507,10 @@ import type {
503507
ViewsPublishResponse,
504508
ViewsPushResponse,
505509
ViewsUpdateResponse,
510+
WorkflowsFeaturedAddResponse,
511+
WorkflowsFeaturedListResponse,
512+
WorkflowsFeaturedRemoveResponse,
513+
WorkflowsFeaturedSetResponse,
506514
WorkflowsStepCompletedResponse,
507515
WorkflowsStepFailedResponse,
508516
WorkflowsUpdateStepResponse,
@@ -2380,6 +2388,31 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
23802388
};
23812389

23822390
public readonly workflows = {
2391+
featured: {
2392+
/**
2393+
* @description Add featured workflows to a channel.
2394+
* @see {@link https://docs.slack.dev/reference/methods/workflows.featured.add `workflows.featured.add` API reference}.
2395+
*/
2396+
add: bindApiCall<WorkflowsFeaturedAddArguments, WorkflowsFeaturedAddResponse>(this, 'workflows.featured.add'),
2397+
/**
2398+
* @description List the featured workflows for specified channels.
2399+
* @see {@link https://docs.slack.dev/reference/methods/workflows.featured.list `workflows.featured.list` API reference}.
2400+
*/
2401+
list: bindApiCall<WorkflowsFeaturedListArguments, WorkflowsFeaturedListResponse>(this, 'workflows.featured.list'),
2402+
/**
2403+
* @description Remove featured workflows from a channel.
2404+
* @see {@link https://docs.slack.dev/reference/methods/workflows.featured.remove `workflows.featured.remove` API reference}.
2405+
*/
2406+
remove: bindApiCall<WorkflowsFeaturedRemoveArguments, WorkflowsFeaturedRemoveResponse>(
2407+
this,
2408+
'workflows.featured.remove',
2409+
),
2410+
/**
2411+
* @description Set featured workflows for a channel.
2412+
* @see {@link https://docs.slack.dev/reference/methods/workflows.featured.set `workflows.featured.set` API reference}.
2413+
*/
2414+
set: bindApiCall<WorkflowsFeaturedSetArguments, WorkflowsFeaturedSetResponse>(this, 'workflows.featured.set'),
2415+
},
23832416
/**
23842417
* @description Indicate that an app's step in a workflow completed execution.
23852418
* @deprecated Steps from Apps is deprecated.

packages/web-api/src/types/request/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ export type {
317317
ViewsUpdateArguments,
318318
} from './views';
319319
export type {
320+
WorkflowsFeaturedAddArguments,
321+
WorkflowsFeaturedListArguments,
322+
WorkflowsFeaturedRemoveArguments,
323+
WorkflowsFeaturedSetArguments,
320324
WorkflowsStepCompletedArguments,
321325
WorkflowsStepFailedArguments,
322326
WorkflowsUpdateStepArguments,

packages/web-api/src/types/request/workflows.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
import type { TokenOverridable } from './common';
22

3+
// https://docs.slack.dev/reference/methods/workflows.featured.add
4+
export interface WorkflowsFeaturedAddArguments extends TokenOverridable {
5+
/**
6+
* @description Channel to add featured workflow in.
7+
*/
8+
channel_id: string;
9+
/**
10+
* @description Comma-separated array of trigger IDs to add; max 15
11+
* @example ["Ft012345", "Ft012346"]
12+
*/
13+
trigger_ids: string[];
14+
}
15+
16+
// https://docs.slack.dev/reference/methods/workflows.featured.list
17+
export interface WorkflowsFeaturedListArguments extends TokenOverridable {
18+
/**
19+
* @description Comma-separated array of channel IDs to list featured workflows for.
20+
* @example ["C012345678", "C987654321"]
21+
*/
22+
channel_ids: string[];
23+
}
24+
25+
// https://docs.slack.dev/reference/methods/workflows.featured.remove
26+
export interface WorkflowsFeaturedRemoveArguments extends TokenOverridable {
27+
/**
28+
* @description Channel to remove featured workflow from.
29+
*/
30+
channel_id: string;
31+
/**
32+
* @description Comma-separated array of trigger IDs to remove; max 15
33+
* @example ["Ft012345", "Ft012346"]
34+
*/
35+
trigger_ids: string[];
36+
}
37+
38+
// https://docs.slack.dev/reference/methods/workflows.featured.set
39+
export interface WorkflowsFeaturedSetArguments extends TokenOverridable {
40+
/**
41+
* @description Channel to set featured workflow in.
42+
*/
43+
channel_id: string;
44+
/**
45+
* @description Comma-separated array of trigger IDs that will replace any existing featured workflows in the channel; max 15
46+
* @example ["Ft012345", "Ft012346"]
47+
*/
48+
trigger_ids: string[];
49+
}
50+
351
// TODO: breaking change: to be removed after Sep 12 2024
452
// https://docs.slack.dev/changelog/2023-08-workflow-steps-from-apps-step-back
553

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type { WebAPICallResult } from '../../WebClient';
2+
3+
export type WorkflowsFeaturedAddResponse = WebAPICallResult & {};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { WebAPICallResult } from '../../WebClient';
2+
3+
export type WorkflowsFeaturedListResponse = WebAPICallResult & {
4+
featured_workflows: {
5+
channel_id: string;
6+
triggers: {
7+
id: string;
8+
title: string;
9+
}[];
10+
}[];
11+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type { WebAPICallResult } from '../../WebClient';
2+
3+
export type WorkflowsFeaturedRemoveResponse = WebAPICallResult & {};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type { WebAPICallResult } from '../../WebClient';
2+
3+
export type WorkflowsFeaturedSetResponse = WebAPICallResult & {};

packages/web-api/src/types/response/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ export { ViewsOpenResponse } from './ViewsOpenResponse';
308308
export { ViewsPublishResponse } from './ViewsPublishResponse';
309309
export { ViewsPushResponse } from './ViewsPushResponse';
310310
export { ViewsUpdateResponse } from './ViewsUpdateResponse';
311+
export { WorkflowsFeaturedAddResponse } from './WorkflowsFeaturedAddResponse';
312+
export { WorkflowsFeaturedListResponse } from './WorkflowsFeaturedListResponse';
313+
export { WorkflowsFeaturedRemoveResponse } from './WorkflowsFeaturedRemoveResponse';
314+
export { WorkflowsFeaturedSetResponse } from './WorkflowsFeaturedSetResponse';
311315
export { WorkflowsStepCompletedResponse } from './WorkflowsStepCompletedResponse';
312316
export { WorkflowsStepFailedResponse } from './WorkflowsStepFailedResponse';
313317
export { WorkflowsUpdateStepResponse } from './WorkflowsUpdateStepResponse';

0 commit comments

Comments
 (0)