Skip to content

Generated API ​

One file per BPMN process, a typed projection of the process model, plus one file per kind of shared definition, generated once for all processes of a run. The examples show the MiraVelo bike-leasing process (shared/bpmn/zeebe/bike-leasing.bpmn) generated for Zeebe.

Structure ​

The Process API is an object (Kotlin), final class (Java), static class (C#) or as const object next to one class per element (TypeScript), named after the process id: bikeLeasing becomes BikeLeasingProcessApi.

MemberContents
PROCESS_IDThe process id (ProcessId)
PROCESS_ENGINEThe engine the API was generated for (BpmnEngine: ZEEBE, CAMUNDA_7, OPERATON)
FlowNodesOne node per element, carrying the element's own data and its successors

Element ids, variables, timers and call-activity mappings have no section of their own: they live on the node that declares them.

Shared definitions ​

Job types, message and signal names, errors, escalations and variable names identify something across process boundaries: two processes subscribing to the same message use the same value. They are generated once per run, each kind in its own file next to the Process APIs.

FileContents
ServiceTasksOne String constant per distinct job type: the constant for @JobWorker(type = …)
MessagesMessage names (MessageName)
SignalsSignal names (SignalName)
ErrorsError definitions with name and code (BpmnErrorDefinition)
EscalationsEscalation definitions with name and code (BpmnEscalationDefinition)
ProcessVariablesOne String constant per distinct variable name: the constant for @Variable(name = …)
  • A file is only generated when at least one process contains a matching element.
  • Each value appears once, however many processes use it.
  • Constants are named after the name, not the id: the message miravelo.contractSigned is MIRAVELO_CONTRACT_SIGNED. This holds for errors and escalations too; the code is a value of the definition, not part of its name. Two different definitions that lead to the same constant fail generation with the shared-definition-collision rule.
  • Names that are a FEEL expression (Zeebe, starting with =) are resolved at runtime and get no constant. A FlowNode that uses one carries the expression as its value.
  • Every file lists its values: Kotlin ServiceTasks.all, Java ServiceTasks.all(), C# ServiceTasks.All, TypeScript ServiceTasks.all. That turns "every job type has a registered worker" into a loop in a test.

One packagePath per generation run

The shared files are named after their kind, not after a process. Two runs (Gradle tasks or Maven executions) writing into the same package overwrite each other's ServiceTasks, Messages, … and remove each other's Process APIs as stale. Give each run its own packagePath, or generate all related BPMN files in one run.

Stale files are removed

Before writing, the generator deletes the files it owns but no longer produces, such as the API of a renamed process. It owns the files directly in the packagePath directory that carry the // Generated by bpmn-to-code header. Hand-written files are never touched, so don't keep that header on a file you maintain yourself.

Full Example ​

Abridged; blank lines and KDoc removed.

kotlin
// Generated by bpmn-to-code
@file:Suppress("unused")

package com.example.process

import io.miragon.bpmn.runtime.AbstractFlowNode
import io.miragon.bpmn.runtime.BpmnElementType
// … one import per runtime type used

object BikeLeasingProcessApi {
  val PROCESS_ID: ProcessId = ProcessId("bikeLeasing")
  val PROCESS_ENGINE: BpmnEngine = BpmnEngine.ZEEBE

  object FlowNodes {
    val all: List<FlowNode> = listOf(BoundaryApplicationInvalid, /* … */ UserTaskUpdateDeliveryAddress)

    object ServiceTaskSendContract : AbstractFlowNode(
      id = ElementId(ServiceTaskSendContract.ELEMENT_ID),
      elementType = BpmnElementType.SERVICE_TASK,
      name = "Send contract",
    ), HasSuccessors<ServiceTaskSendContract.Next>, HasJobType, HasVariables {
      const val ELEMENT_ID: String = "serviceTask_sendContract"
      override val jobType: String = ServiceTasks.MIRAVELO_SEND_CONTRACT
      override val variables: Variables = Variables
      override val next: Next = Next

      object Variables : RegisteredVariableDefinitions() {
        val APPLICATION_ID: VariableName.Input = input(ProcessVariables.APPLICATION_ID)
        val CONTRACT_ID: VariableName.Output = output(ProcessVariables.CONTRACT_ID)
      }

      object Next {
        val gatewayAwaitSignature: SequenceFlows<GatewayAwaitSignature>
          get() = SequenceFlows.single(
            flowId = ElementId("flow_sendContractToAwaitSignature"),
            target = GatewayAwaitSignature,
          )
      }
    }

    object TimerSignatureReminder : AbstractFlowNode(
      id = ElementId(TimerSignatureReminder.ELEMENT_ID),
      elementType = BpmnElementType.BOUNDARY_EVENT,
      name = "7 days passed",
    ), HasSuccessors<TimerSignatureReminder.Next>, BoundaryEvent<SubProcessConcludeContract>, TimerEvent {
      override val eventType: BpmnEventType = BpmnEventType.TIMER
      const val ELEMENT_ID: String = "timer_signatureReminder"
      override val timer: BpmnTimer = BpmnTimer(type = TimerType.DURATION, timerValue = "P7D")
      override val attachedTo: SubProcessConcludeContract get() = SubProcessConcludeContract
      override val isInterrupting: Boolean = false
      // next …
    }

    object EndEventLeasingActive : AbstractFlowNode(
      id = ElementId(EndEventLeasingActive.ELEMENT_ID),
      elementType = BpmnElementType.END_EVENT,
      name = "Leasing active",
    ), Event {
      override val eventType: BpmnEventType = BpmnEventType.NONE
      const val ELEMENT_ID: String = "endEvent_leasingActive"
    }
    // … one object per element, including those inside subprocesses
  }
}

// ServiceTasks.kt
object ServiceTasks {
  const val MIRAVELO_SEND_CONTRACT: String = "miravelo.sendContract"
  // …
  val all: List<String> = listOf(/* … */)
}

// Messages.kt
object Messages {
  val MIRAVELO_CONTRACT_SIGNED: MessageName = MessageName("miravelo.contractSigned")
  // …
}

// Errors.kt
object Errors {
  val MIRAVELO_APPLICATION_INVALID: BpmnErrorDefinition = BpmnErrorDefinition(
    name = "miravelo.applicationInvalid",
    code = "applicationInvalid",
  )
}

// ProcessVariables.kt
object ProcessVariables {
  const val APPLICATION_ID: String = "applicationId"
  const val CONTRACT_ID: String = "contractId"
  // …
}
java
// Generated by bpmn-to-code
package com.example.process;

import io.miragon.bpmn.runtime.AbstractFlowNode;
// … one import per runtime type used
import java.util.List;

public final class BikeLeasingProcessApi {
  public static final ProcessId PROCESS_ID = new ProcessId("bikeLeasing");
  public static final BpmnEngine PROCESS_ENGINE = BpmnEngine.ZEEBE;

  public static final class FlowNodes {
    public static ServiceTaskSendContract serviceTaskSendContract() { return ServiceTaskSendContract.INSTANCE; }
    // … one static accessor per element
    public static List<FlowNode> all() { /* … */ }

    public static final class ServiceTaskSendContract extends AbstractFlowNode
        implements HasSuccessors<ServiceTaskSendContract.Next>, HasJobType, HasVariables {
      public static final String ELEMENT_ID = "serviceTask_sendContract";
      public static final ServiceTaskSendContract INSTANCE = new ServiceTaskSendContract();

      @Override public String getJobType() { return ServiceTasks.MIRAVELO_SEND_CONTRACT; }
      @Override public Variables getVariables() { return VARIABLES; }
      @Override public Next getNext() { return new Next(); }

      public static final class Variables extends VariableDefinitions {
        public static final VariableName.Input APPLICATION_ID = new VariableName.Input(ProcessVariables.APPLICATION_ID);
        public static final VariableName.Output CONTRACT_ID = new VariableName.Output(ProcessVariables.CONTRACT_ID);

        @Override public List<VariableName> getAll() { return List.of(APPLICATION_ID, CONTRACT_ID); }
      }

      public static final class Next {
        public SequenceFlows<GatewayAwaitSignature> gatewayAwaitSignature() {
          return SequenceFlows.single(new ElementId("flow_sendContractToAwaitSignature"), GatewayAwaitSignature.INSTANCE);
        }
      }
    }
  }
}

// Errors.java
public final class Errors {
  public static final BpmnErrorDefinition MIRAVELO_APPLICATION_INVALID = new BpmnErrorDefinition("miravelo.applicationInvalid", "applicationInvalid");

  public static List<BpmnErrorDefinition> all() { return List.of(MIRAVELO_APPLICATION_INVALID); }
}
csharp
// <auto-generated/>
// Generated by bpmn-to-code
#nullable enable
#pragma warning disable CS1591
namespace MiraVelo.Process;

// Runtime.X stands for global::Miragon.BpmnToCode.Runtime.X, as the file writes it
public static class BikeLeasingProcessApi
{
    public const string ProcessId = "bikeLeasing";
    public const Runtime.BpmnEngine ProcessEngine = Runtime.BpmnEngine.Zeebe;

    public static class FlowNodes
    {
        public static ServiceTaskSendContractNode ServiceTaskSendContract => ServiceTaskSendContractNode.Instance;

        public sealed class ServiceTaskSendContractNode : Runtime.IFlowNode, Runtime.IHasSuccessors<ServiceTaskSendContractNode.Successors>, Runtime.IHasJobType, Runtime.IHasVariables
        {
            // …
            public const string ElementId = "serviceTask_sendContract";
            public Runtime.ElementId Id { get; } = new(ElementId);
            public Runtime.BpmnElementType ElementType => Runtime.BpmnElementType.ServiceTask;
            public string? Name => "Send contract";
            public string JobType { get; } = ServiceTasks.MiraveloSendContract;

            public NodeVariables Variables { get; } = new();
            public sealed class NodeVariables : Runtime.VariableDefinitions
            {
                public Runtime.VariableName.Input ApplicationId { get; } = new(ProcessVariables.ApplicationId);
                public Runtime.VariableName.Output ContractId { get; } = new(ProcessVariables.ContractId);
                // All …
            }

            public Successors Next { get; } = new();
            public sealed class Successors
            {
                public Runtime.SequenceFlows<GatewayAwaitSignatureNode> GatewayAwaitSignature => _gatewayAwaitSignature ??= Runtime.SequenceFlows.Single(new("flow_sendContractToAwaitSignature"), FlowNodes.GatewayAwaitSignature);
                // …
            }
        }
    }
}

// Errors.cs
public static class Errors
{
    public static class MiraveloApplicationInvalid
    {
        public const string Reference = "miravelo.applicationInvalid";
        public const string Code = "applicationInvalid";
    }
}

FlowNodes: the process as typed nodes ​

FlowNodes holds one node per element, and every node is a direct child of FlowNodes whatever its subprocess depth: FlowNodes.StartEventCustomerEligible is addressed by its own name although it sits inside subProcess_concludeContract. Node names derive from element ids (serviceTask_sendContract → ServiceTaskSendContract); see Modeling.

Each node extends AbstractFlowNode and implements one runtime interface per facet it has:

Member, interfacePresent onTypeIn the JSON
id, elementType, nameevery nodeElementId, BpmnElementType, String?id, type, name
eventType, EventeventsBpmnEventType (NONE, TIMER, MESSAGE, …, MULTIPLE)eventDefinitions[]
jobType, HasJobTypetasks and events with an implementationString, the ServiceTasks constantimplementation
variables, HasVariablesnodes declaring variablesthe node's VariablesioMapping, multiInstance
calledProcess, CallActivity; Inputs, Outputscall activitiesProcessId; InputOutputMappingcalledElement, ioMapping
timer, TimerEventtimer eventsBpmnTimer (type: DATE, DURATION, CYCLE; timerValue)eventDefinitions[]
message, HasMessagemessage events, send and receive tasksMessageName, the Messages constanteventDefinitions[], messageRef
signal / error / escalation; SignalEvent / ErrorEvent / EscalationEventevents with that definitionthe Signals / Errors / Escalations constanteventDefinitions[]
CompensationThrowEventintermediate throw and end events throwing a compensationmarker without memberseventDefinitions[]
attachedTo, BoundaryEvent<Host>boundary eventsthe host nodeattachedToRef
isInterruptingboundary events, event-subprocess start eventsBooleancancelActivity / isInterrupting
next, HasSuccessors<Next>nodes with successorssee Navigationoutgoing, boundaryEventRefs, compensationHandlerRef
startEvents, FlowScope<Start>subprocessesthe interior's start eventsflowNodes[] of the subprocess

Kotlin reaches a node as FlowNodes.ServiceTaskSendContract, Java through an accessor and getters (FlowNodes.serviceTaskSendContract().getJobType()), C# through a property as well (FlowNodes.ServiceTaskSendContract.JobType, typed FlowNodes.ServiceTaskSendContractNode; the interfaces are Runtime.IHasJobType, Runtime.ITimerEvent, …).

Because every facet is an interface, generic code can pick the nodes that carry it:

kotlin
val timers: List<TimerEvent> = FlowNodes.all.filterIsInstance<TimerEvent>()
timers.forEach { println("${it.id}: ${it.timer.timerValue}") }

Naming rule ​

Kotlin follows its coding conventions: constants are UPPER_SNAKE (ELEMENT_ID, Variables.APPLICATION_ID), members of the runtime interfaces camelCase (jobType, timer, next). Java exposes the per-node constants ELEMENT_ID and INSTANCE as static final fields and everything else through getters.

Raw names for annotations and when / switch ​

The typed wrappers are no compile-time constants, so each has a raw String constant:

TypedRaw constant (Kotlin / Java)C#
FlowNodes.X.idFlowNodes.X.ELEMENT_IDFlowNodes.X.ElementId
FlowNodes.X.variables.APPLICATION_IDProcessVariables.APPLICATION_IDProcessVariables.ApplicationId
FlowNodes.X.jobTypeServiceTasks.MIRAVELO_SEND_CONTRACTServiceTasks.MiraveloSendContract
kotlin
@JobWorker(type = ServiceTasks.MIRAVELO_SEND_CONTRACT)
fun sendContract(@Variable(name = ProcessVariables.APPLICATION_ID) applicationId: String) { … }

Annotate workers with ServiceTasks.X rather than a node's jobType: several elements, also of different processes, can share one job type, and find-usages on the constant leads to all of them. A node's jobType, message, signal, error and escalation refer to these same constants and answer the opposite question: what does this element use.

Sequence flows ​

Every entry of a node's Next is named after the element it leads to, so a condition is found by where it goes, not by a flow id. An entry reached by sequence flows is a SequenceFlows<Target>. Its flow is a SequenceFlow<Target> with the flow's id, name, raw conditionExpression, isDefault and typed target.

kotlin
object GatewayIsSolvent : /* … */ HasSuccessors<GatewayIsSolvent.Next> {
  override val next: Next = Next

  object Next {
    val gatewayCollectRejections: SequenceFlows<GatewayCollectRejections>
      get() = SequenceFlows.single(
        flowId = ElementId("flow_isSolventToCollectRejections"),
        name = "No",
        conditionExpression = "=not(solvent)",
        target = GatewayCollectRejections,
      )
    val subProcessConcludeContract: SequenceFlows<SubProcessConcludeContract>
      get() = SequenceFlows.single(
        flowId = ElementId("flow_isSolventToConcludeContract"),
        name = "Yes",
        isDefault = true,
        target = SubProcessConcludeContract,
      )
  }
}
kotlin
val next = FlowNodes.GatewayIsSolvent.next

assertThat(next.gatewayCollectRejections.flow.conditionExpression).isEqualTo("=not(solvent)")
assertThat(next.gatewayCollectRejections.target).isEqualTo(FlowNodes.GatewayCollectRejections)
assertThat(next.subProcessConcludeContract.flow.isDefault).isTrue()
java
var next = FlowNodes.gatewayIsSolvent().getNext();

assertThat(next.gatewayCollectRejections().getFlow().getConditionExpression()).isEqualTo("=not(solvent)");
assertThat(next.subProcessConcludeContract().getFlow().isDefault()).isTrue();

The expression is the one in the model: FEEL (=…) on Zeebe, ${…} on Camunda 7 and Operaton.

When several sequence flows lead to the same element, the entry keeps its name and holds all of them in flows. flow then fails and asks you to pick one.

next returns the node's Next. Its entries are everything reachable from the node, each a Successor<Target>:

SuccessorLeads to
SequenceFlows<Target>an element reached by one or more sequence flows
AttachedBoundaryEvent<Target>a boundary event attached to this node
AssociatedCompensationHandler<Target>the handler of a compensation boundary event, which BPMN connects by an association
kotlin
object SubProcessConcludeContract : /* … */
    HasSuccessors<SubProcessConcludeContract.Next>, FlowScope<SubProcessConcludeContract.Start> {
  override val next: Next = Next
  override val startEvents: Start = Start

  object Next {
    val gatewayFork: SequenceFlows<GatewayFork>
      get() = SequenceFlows.single(flowId = ElementId("flow_concludeContractToFork"), target = GatewayFork)
    val timerSignatureReminder: AttachedBoundaryEvent<TimerSignatureReminder>
      get() = AttachedBoundaryEvent(target = TimerSignatureReminder)
    val boundaryCompensateContract: AttachedBoundaryEvent<BoundaryCompensateContract>
      get() = AttachedBoundaryEvent(target = BoundaryCompensateContract)
    // …
  }

  object Start {
    val startEventCustomerEligible: StartEventCustomerEligible get() = StartEventCustomerEligible
  }
}

The target type is fixed per entry, so code that follows an edge the model no longer has stops compiling. A subprocess additionally implements FlowScope and opens its interior through startEvents. On a compensation boundary event, isInterrupting carries no meaning: BPMN does not define cancelActivity for it.

Successor is a sealed interface; an exhaustive when over it needs a branch for each of the three kinds and for a single SequenceFlow.

Asserting flow in process tests: ProcessPath ​

The runtime's path builder walks this graph and returns the element ids for your engine's flow assertions. It has a page of its own: ProcessPath.

Enumerating elements ​

For tests about every element of a process (every node id exists in the deployed model, every user task has a form), FlowNodes lists its nodes: Kotlin FlowNodes.all, Java FlowNodes.all(), C# FlowNodes.All.

kotlin
@Test
fun `every node of the model is deployed`() {
    val deployedIds = deployedModel.flowNodeIds()
    assertThat(FlowNodes.all.map { it.id.value }).allMatch { it in deployedIds }
}

Variables with Direction ​

Every variable sits on the node that declares it, and its direction is its type: VariableName.Input when the element reads it, VariableName.Output when it writes it, VariableName.InOut when it does both. An API taking VariableName.Output therefore rejects an input at compile time. Which model elements declare a variable, and in which direction, depends on the engine.

kotlin
object Variables : RegisteredVariableDefinitions() {
  val APPLICATION_ID: VariableName.Input = input(ProcessVariables.APPLICATION_ID)
  val CONTRACT_ID: VariableName.Output = output(ProcessVariables.CONTRACT_ID)
}

Variables is only generated on nodes that declare at least one variable. Such a node implements HasVariables and lists all its variables, those it reads (inputs) and those it writes (outputs); an InOut is in both.

KotlinJavaC#
One variableServiceTaskSendContract.variables.APPLICATION_IDServiceTaskSendContract.Variables.APPLICATION_IDServiceTaskSendContract.Variables.ApplicationId
All / read / writtenvariables.all / .inputs / .outputsgetVariables().getAll() / .getInputs() / .getOutputs()Variables.All / .Inputs / .Outputs
kotlin
val workers = FlowNodes.all.filterIsInstance<HasJobType>()
workers.forEach { task ->
    val readVariables = (task as? HasVariables)?.variables?.inputs.orEmpty()
    client.newWorker().jobType(task.jobType).fetchVariables(readVariables.map { it.value }) // …
}

val variablesOfTheProcess: List<String> = HasVariables.distinctVariablesOf(FlowNodes.all)

Call-Activity Variable Mappings ​

A call activity node carries the called process and the mapping between parent and child: Inputs (passed into the child) and Outputs (returned to the parent). Each entry is an InputOutputMapping with the target (the name the variable gets in the receiving scope) and its origin. Constants are named after the target.

kotlin
object CallActivityCancelBikeOrder : /* … */ CallActivity, HasVariables {
  override val calledProcess: ProcessId = ProcessId("cancelBikeOrder")

  object Inputs {
    val APPLICATION_ID: InputOutputMapping = InputOutputMapping(target = "applicationId", source = "=applicationId")
    val ORDER_IDS: InputOutputMapping = InputOutputMapping(target = "orderIds", source = "=orderIds")
  }

  object Outputs {
    val CANCELLATION_COSTS: InputOutputMapping = InputOutputMapping(target = "cancellationCosts", source = "=cancellationCosts")
  }
}
EnginesourcesourceExpression
Zeebethe FEEL expression of zeebe:input / zeebe:outputalways null
Camunda 7, Operatonthe source variable of camunda:in / camunda:outits sourceExpression, e.g. ${applicationId}

The same model for Camunda 7 yields InputOutputMapping(target = "applicationId", sourceExpression = "\${applicationId}"). The "pass all variables" modes (variables="all", propagateAllParentVariables / propagateAllChildVariables) produce no constants.

Several files, one process id ​

Two files declaring the same process id would be generated under one name, so generation fails. A variantName extension property on the process tells them apart: corporate turns BikeLeasingProcessApi into CorporateBikeLeasingProcessApi, while PROCESS_ID stays bikeLeasing. Nothing is merged between the files. See Modeling for the XML and the rules.

C# specifics ​

  • The runtime types come from Miragon.BpmnToCode.Runtime, the NuGet package of the generator's version; Miragon.BpmnToCode.MSBuild adds it. The generated code names them as global::Miragon.BpmnToCode.Runtime.IFlowNode and so on, so no type or namespace of your own can shadow them. A library can type against IFlowNode or take a ProcessPath whatever Process API it is used with. ElementId, ProcessId, MessageName, SignalName and VariableName convert implicitly to string. The process path lives in the package too.
  • Shared definitions are plain const strings. Errors and escalations are a nested class with Reference and Code; their All lists (Reference, Code) tuples.
  • Nodes are properties of FlowNodes: FlowNodes.ServiceTaskSendContract, navigated through Next.X.Target, Next.X.Flow.ConditionExpression and Start.X. Their type carries a Node suffix (FlowNodes.ServiceTaskSendContractNode), so no member has to make way for the type's name. Elements task and taskNode cannot both be generated: the type of task would be named like the property of taskNode, so generation fails. Next and Start are created with the node, every successor on first read.
  • The namespace is the package path in PascalCase: io.miravelo.process becomes Io.Miravelo.Process; the files still go to io/miravelo/process.
  • Constants versus properties. ServiceTasks.X, ProcessVariables.X and a node's ElementId (FlowNodes.ServiceTaskSendContractNode.ElementId) are const string and usable in attributes and switch labels. Id, Name, JobType and the other facets are instance properties and are not.
  • Some names fail generation instead of being renamed. A variable named all, inputs, outputs, processVariables or nodeVariables, a call-activity mapping into inputMappings or outputMappings, and a message, signal, job type or variable named like its shared class (Messages, …) would clash with a member C# declares itself. Generation names the element or definition to rename.
  • No distinctVariablesOf. Collect the variables of the process with LINQ: FlowNodes.All.OfType<IHasVariables>().SelectMany(node => node.Variables.All).Distinct().
  • Each file is marked <auto-generated/>, enables nullable annotations itself and suppresses CS1591, so it compiles under any consumer settings.

A .NET project generates C# during dotnet build with the MSBuild package; the web app, the command line and the Gradle and Maven plugins accept CSHARP as well.

TypeScript specifics ​

Experimental

TypeScript output is experimental. It may change in a minor release. Feedback welcome.

Node projects get it through the npm package. TypeScript gets the same API as Kotlin: constants, one class per element, navigation through next and a process path. That covers a worker that needs its job types and variable names, a frontend that shows the name of a step and what follows it, and a process test that asserts the route an instance took.

ts
import { BikeLeasingProcessApi } from "./process/BikeLeasingProcessApi.js";
import { ServiceTasks } from "./process/ServiceTasks.js";

const nodes = BikeLeasingProcessApi.FlowNodes;
const sendContract = nodes.ServiceTaskSendContract;
sendContract.id; // "serviceTask_sendContract"
sendContract.name; // "Send contract"
sendContract.jobType === ServiceTasks.MIRAVELO_SEND_CONTRACT; // true

const solvent = nodes.StartEventLeasingRequestReceived
  .next.serviceTaskValidateApplication.target
  .next.businessRuleTaskCheckCreditRating.target
  .next.gatewayIsSolvent.target;
const approved = solvent.next.subProcessConcludeContract;
approved.target.name; // "Conclude contract"
approved.flow.isDefault; // true
solvent.next.gatewayFork; // compile error: the gateway does not lead there
  • One exported singleton class per element, reached as FlowNodes.ServiceTaskSendContract and listed in FlowNodes.all. A class implements the interfaces of the runtime package that fit it (HasJobType, BoundaryEvent<Host>, …), so code that handles nodes generically takes a FlowNode. The class name works as a type: function show(node: ServiceTaskSendContract). The classes are top-level exports of their module, so re-exporting two Process APIs with export * from one barrel file clashes on elements both processes have; import from each module instead.
  • Literal types. Every value has its literal type ("serviceTask_sendContract", "P14D", true), and the shared definitions are as const objects: a worker can be typed as (typeof ServiceTasks)[Exclude<keyof typeof ServiceTasks, "all">].
  • A node carries ELEMENT_ID and id, elementType, eventType for events, name (null when the model has none) and its own data: jobType, calledProcess, timer, message, signal, error, escalation, isInterrupting, throwsCompensation, variables, Inputs, Outputs.
  • Navigation is the one of Kotlin. next holds the successors under the name of their element: next.x.target is the element, next.x.flow the sequence flow when exactly one leads there, next.x.flows all of them. A boundary event is Runtime.AttachedBoundaryEvent, the handler of a compensation boundary event Runtime.AssociatedCompensationHandler; kind tells them apart. A subprocess opens its interior through startEvents, a boundary event names its host as attachedTo. These are getters, so the module loads in any order of its classes.
  • variables holds a Runtime.VariableName<"INPUT" | "OUTPUT" | "IN_OUT"> per variable plus all, inputs and outputs. A VariableName converts to its name in a template string.
  • The runtime types come from @miragon/bpmn-to-code-runtime, the npm package of the generator's version, which the generated files import as Runtime. A library can type against FlowNode or take a ProcessPath whatever Process API it is used with. The process path lives in the package too; Setup shows how the versions are kept together.
  • Imports end in .js, which moduleResolution nodenext requires and bundler accepts.
  • packagePath names the directory below outputFolderPath, with dots as separators, as for the other languages.