Skip to content

Incorrect documentation #285

@ericwooley

Description

@ericwooley

Expected Behavior

https://github.com/openworkflowdev/openworkflow/blob/d828d640c7538abc01381932f3a431064e7f29bc/packages/docs/docs/workflows.mdx#running-a-workflow

Specifies you can define a workflow like this:

import { defineWorkflow } from "openworkflow";

export const sendWelcomeEmail = defineWorkflow(
  { name: "send-welcome-email" },
  async ({ input, step }) => {
    const user = await step.run({ name: "fetch-user" }, async () => {
      return await db.users.findOne({ id: input.userId });
    });

    await step.run({ name: "send-email" }, async () => {
      await emailService.send({
        to: user.email,
        subject: "Welcome!",
        body: "Thanks for signing up.",
      });
    });

    return { sent: true };
  },
);

and run it like this:

import { sendWelcomeEmail } from "./workflows/send-welcome-email";

const handle = await sendWelcomeEmail.run({ userId: "user_123" });

Actual Behavior

however, when I do that, i get an error that run is not defined. I looked at the code, and that appears to be correct:

export interface Workflow<Input, Output, RawInput> {

I don't see a run function anywhere. I suspect this might be documentation for an old version?

Steps to Reproduce

  1. Install openworkflow with these versions
pnpm ls | grep openworkflow
@openworkflow/backend-postgres 0.6.0
openworkflow 0.6.7
@openworkflow/cli 0.4.0
  1. Write out the example.
  2. See the error: Property 'run' does not exist on type 'Workflow<...>'.ts(2339)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions