feat: Add support for scheduled workflows (#7651)

We still need to:
But wanted to open the PR for early feedback on the approach
This commit is contained in:
Stevche Radevski
2024-06-10 16:49:52 +02:00
committed by GitHub
parent 7f53fe06b6
commit 69410162f6
20 changed files with 465 additions and 44 deletions

View File

@@ -0,0 +1,23 @@
import { SchedulerOptions } from "@medusajs/orchestration"
import {
createStep,
createWorkflow,
StepResponse,
} from "@medusajs/workflows-sdk"
export const createScheduled = (name: string, schedule?: SchedulerOptions) => {
const workflowScheduledStepInvoke = jest.fn((input, context) => {
return new StepResponse({})
})
const step = createStep("step_1", workflowScheduledStepInvoke)
createWorkflow(
{ name, schedule: schedule ?? "* * * * * *" },
function (input) {
return step(input)
}
)
return workflowScheduledStepInvoke
}