From b71ce19fb3615edebb4fba5275efee17866a4b24 Mon Sep 17 00:00:00 2001 From: Marcos Candeia Date: Fri, 3 Nov 2023 18:32:15 -0300 Subject: [PATCH] Add delete alarm Signed-off-by: Marcos Candeia --- src/workflow.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/workflow.ts b/src/workflow.ts index b26a829..d6ef4e0 100644 --- a/src/workflow.ts +++ b/src/workflow.ts @@ -36,6 +36,9 @@ export const buildRoutes = (wkflow: Workflow): Routes => { "POST": async (req: Request) => { const body: WorkflowExecution = await req.json(); const shouldRestart = new URL(req.url).searchParams.has("restart"); + const deleteAlarmPromise = shouldRestart + ? wkflow.state.storage.deleteAlarm() + : Promise.resolve(); const pendingAndHistory = shouldRestart ? Promise.all([ wkflow.execution.pending.get(), @@ -48,6 +51,7 @@ export const buildRoutes = (wkflow: Workflow): Routes => { wkflow.execution.pending.del(...pending), wkflow.execution.history.del(...history), createPromise, + deleteAlarmPromise, ]); wkflow.workflowExecution = body; return new Response(JSON.stringify(body), { status: 201 });