Skip to main content

Workflows as code

FluidGrids workflows can be written as code as well as drawn on the canvas. Both forms describe the same workflow definition and run on the same engine, so you can start on the canvas and continue in code, or the other way round, without rebuilding anything.

You write a workflow in code with:

  • The graph builder (tier 1). TypeScript or Python that constructs a canvas workflow: triggers, nodes, branches and loops. Exporting a canvas workflow produces this form, and pushing it back produces the same workflow. Nothing changes at run time; the code is a typed, reviewable view of the canvas.

  • Durable functions (tier 2). An async function that the engine runs by replaying its event history, in the style of Temporal. Use it for logic that does not fit a static graph: loops with data-dependent exits, waiting for arbitrary events, timers that last days, and compensation when a step fails.

Workflow code lives in a project on your machine or in Git, next to your other code, and the fluidgrids CLI moves it between the project and your workspace.

What you can do​

  • Export any workflow as TypeScript or Python, with a fidelity report that proves the export is exact.

  • Edit, review and test the code, then push it back as a new version of the workflow.

  • Write durable functions that run canvas nodes as activities, start other workflows as child runs, sleep for days and wait for signals.

  • Embed a durable function in a canvas workflow as a Code workflow node, and wait for it from the canvas with Wait for Signal.

  • Replay a recorded run against your local code to prove a change is safe before you ship it.

  • Run your own activities, and workflow tasks, on self-hosted workers through task queues.

  • Query, update, reset and batch-control running workflows with run control, find them by search attributes, and control schedules with schedule policies.

How the pieces fit​

PieceWhat it is
@fluidgrids/workflowsThe TypeScript package: the graph builder, typed node clients and testing
fluidgrids-workflowsThe same surface for Python, including durable functions
@fluidgrids/workflows/worker, fluidgrids_workflows.workerThe self-hosted worker, for TypeScript and Python
@fluidgrids/clifluidgrids init, codegen, pull, push, diff, validate, test, worker run and the run commands
The builderA Code view of every workflow

Durable functions add the durable-function API, replay and the run commands to these packages, and the Code workflow and Wait for Signal nodes and the run History tab to the builder.

Where to start​

  1. Read Canvas or code? to pick the right form for a workflow.
  2. Follow the CLI page to create a project and pull an existing workflow as code.
  3. Learn the two tiers in The IR and the two tiers, then the graph builder and durable functions.
  4. Before you go to production, read Versioning and hotfixes and Testing and replay.