Manta Developers
GitHub
Menu

Run a plan

Execute an action plan from React or from a backend.

A plan runs only when something calls executeActionPlan. A dry run validates the plan without applying it.

What it is

useActionPlanExecution starts a run for one plan. ExecutePlanDialog asks for confirmation and includes a dry-run checkbox.

The mutation defaults dryRun to true when the field is omitted. execute() defaults its argument to false, so a call with no argument runs the plan. The dialog’s checkbox starts unchecked, so confirming it passes false until someone checks it.

Import

import { useActionPlanExecution } from "@manta-eu/react/hooks/useActionPlanExecution";
import { ExecutePlanDialog } from "@manta-eu/react/components/planning/ExecutePlanDialog";

Example

const execution = useActionPlanExecution(planGraphIri);

return <ExecutePlanDialog onConfirm={(dryRun) => execution.execute(dryRun)} />;

From a backend:

mutation RunPlan($input: ExecuteActionPlanInput!) {
  executeActionPlan(input: $input) {
    success
    workflowId
    error
  }
}
{ "input": { "namedGraphIri": "<the plan's IRI>", "dryRun": true } }

Set dryRun to false to run it for real. The response’s workflowId identifies the run.

Request

useActionPlanExecution(planGraphIri, chatIri?) returns execute(dryRun?). The hook sends namedGraphIri and shaclShapeIri as that plan IRI, dryRun from the argument, and chatIri when you passed one.

ExecutePlanDialog takes:

  • onConfirm(dryRun)
  • trigger (omit it for the default button; null hides the button)
  • open and onOpenChange
  • action: execute (the default) or rerun

The mutation call above sends namedGraphIri and dryRun.

Response

execute resolves to { success: true, workflowId } or { success: false, error }.

The hook also returns isTriggered, triggeredAtMs, dryRun, workflowId, triggerError, and reset.

The mutation returns success, workflowId, and error.