Skip to content

Commit

Permalink
Merge pull request #546 from selfcontained/bradh-workflow-extension-s…
Browse files Browse the repository at this point in the history
…upport

Bradh workflow extension support
  • Loading branch information
stevengill authored Jul 20, 2020
2 parents 8b12e3c + 22bcdfb commit 92edcab
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function getTypeAndConversation(body: any): { type?: IncomingEventType, c
conversationId: optionsBody.channel !== undefined ? optionsBody.channel.id : undefined,
};
}
if (body.actions !== undefined || body.type === 'dialog_submission') {
if (body.actions !== undefined || body.type === 'dialog_submission' || body.type === 'workflow_step_edit') {
const actionBody = (body as SlackActionMiddlewareArgs<SlackAction>['body']);
return {
type: IncomingEventType.Action,
Expand Down
5 changes: 3 additions & 2 deletions src/types/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './dialog-action';

import { BlockAction } from './block-action';
import { InteractiveMessage } from './interactive-message';
import { WorkflowStepEdit } from './workflow-step-edit';
import { DialogSubmitAction, DialogValidation } from './dialog-action';
import { SayFn, SayArguments, RespondFn, AckFn } from '../utilities';

Expand All @@ -21,7 +22,7 @@ import { SayFn, SayArguments, RespondFn, AckFn } from '../utilities';
* offered when no generic parameter is bound would be limited to BasicElementAction rather than the union of known
* actions - ElementAction.
*/
export type SlackAction = BlockAction | InteractiveMessage | DialogSubmitAction;
export type SlackAction = BlockAction | InteractiveMessage | DialogSubmitAction | WorkflowStepEdit;

/**
* Arguments which listeners and middleware receive to process an action from Slack's Block Kit interactive components,
Expand All @@ -40,7 +41,7 @@ export interface SlackActionMiddlewareArgs<Action extends SlackAction = SlackAct
action: this['payload'];
body: Action;
// all action types except dialog submission have a channel context
say: Action extends Exclude<SlackAction, DialogSubmitAction> ? SayFn : never;
say: Action extends Exclude<SlackAction, DialogSubmitAction | WorkflowStepEdit> ? SayFn : never;
respond: RespondFn;
ack: ActionAckFn<Action>;
}
Expand Down
33 changes: 33 additions & 0 deletions src/types/actions/workflow-step-edit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* A Slack workflow step action wrapped in the standard metadata.
*
* This describes the entire JSON-encoded body of a request from Slack workflow step actions.
*/
export interface WorkflowStepEdit {
type: 'workflow_step_edit';
callback_id: string;
trigger_id: string;
user: {
id: string;
username: string;
team_id?: string; // undocumented
};
team: {
id: string;
domain: string;
enterprise_id?: string; // undocumented
enterprise_name?: string; // undocumented
};
channel?: {
id?: string;
name?: string;
};
token: string;
action_ts: string; // undocumented
workflow_step: {
workflow_id: string;
step_id: string;
inputs: object;
outputs: [];
};
}
21 changes: 20 additions & 1 deletion src/types/events/base-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export type SlackEvent =
| TeamJoinEvent
| TeamRenameEvent
| TokensRevokedEvent
| UserChangeEvent;
| UserChangeEvent
| WorkflowStepExecuteEvent;

/**
* Any event in Slack's Events API
Expand Down Expand Up @@ -752,5 +753,23 @@ export interface UserChangeEvent extends StringIndexed {
};
}

export interface WorkflowStepExecuteEvent extends StringIndexed {
type: 'workflow_step_execute';
callback_id: string;
workflow_step: {
workflow_step_execute_id: string;
workflow_id: string;
workflow_instance_id: string;
step_id: string;
inputs: object;
outputs: {
name: string;
type: string;
label: string;
}[];
};
event_ts: string;
}

// NOTE: `user_resourced_denied`, `user_resource_granted`, `user_resourced_removed` are left out because they are
// deprecated as part of the Workspace Apps Developer Preview

0 comments on commit 92edcab

Please sign in to comment.