bolt-js icon indicating copy to clipboard operation
bolt-js copied to clipboard

Export types for Workflows

Open culli opened this issue 2 years ago • 3 comments

To make it a little more convenient to work with workflows, expose WorkflowStepEditMiddlewareArgs, WorkflowStepSaveMiddlewareArgs, and WorkflowStepExecuteMiddlewareArgs types. This would be much like SlackCommandMiddlewareArgs and SlackActionMiddlewareArgs are exposed.

I'm just looking to make code a little cleaner when handling workflow step events. Sure I can alias and introduce types to hide away some of this, but I just wanted it to work the way I can use SlackCommandMiddlewareArgs.

My use case looks like:

export const createWorkflowStep = () => {
  return new WorkflowStep(`my_step_name`, {
    edit: async ({ ack, configure }) => {},
    save: async ({ ack, view, update }) => {},
    execute: async (args) => {
      handleExec(args);  //I can't actually do this and keep type information about args
    }
...

How I'd like to use it:

handleExec(args: WorkflowStepSaveMiddlewareArgs) {
  ...
}

Workaround:

...
    execute: async (args) => {
      const { step, body, complete, fail, context, client } = args;
      handleExec({
          workflowId: step.workflow_id,
          incomingUserId: step.inputs.userId.value,
          incomingChannelId: step.inputs.slackChannelId.value,
          teamId: body.team_id,
          context,
          client,
    }
...

handleExec(args: {
    workflowId: string;
    incomingUserId: string;
    incomingChannelId: string;
    teamId: string;
    context: Context & StringIndexed;
    client: WebClient;
  }) {
...
}

Thanks!

culli avatar Aug 22 '23 18:08 culli

Hi @culli, thanks for writing! We are always happy to enhance the type exports for better TS dev experience.

However, I have to mention that our platform just announced the deprecation of Steps from Apps: https://api.slack.com/changelog/2023-08-workflow-steps-from-apps-step-back

I understand this could be a disappointing news for the developers leveraging the feature (like you), but we hope the new automation platform works better for you.

seratch avatar Aug 22 '23 23:08 seratch

I was actually aware of the deprecation, and asked support for clarification on timelines and whatnot. The gist of what they said on Aug 15 is the (deno-based) new platform is not feature complete and Bolt will be supported for some time to come, with no specific sunset date for any part of it.

I guess news takes a while to travel through a big company or the decision was reached since then!

I'll limp this along until I get time to convert to the new shiny deno stuff.

culli avatar Aug 23 '23 15:08 culli

Just wanted to jump in and clarify one thing: there are NO plans to deprecate the Bolt framework or any other legacy platform features other than Steps From Apps. The deprecation @seratch mentioned is solely scoped to the Steps From Apps feature of the legacy platform.

filmaj avatar Aug 23 '23 15:08 filmaj