Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bradh workflow extension support #546

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
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;
Copy link
Contributor

Choose a reason for hiding this comment

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

This was changed from name to username based on the payloads

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching and fixes all of those 😄

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

workflow_step also has keys for inputs and outputs in either case (add vs. edit)

misscoded marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -736,5 +737,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