Skip to main content

Overview

@reelevant-tech/workflows-sdk is the library the Workflow editor is built on. It holds a Workflow in memory, lets you change it through node builders, and type checks every change against the Datasources and Contents the Workflow uses. The example below adds a locale URL parameter to the draft of a Workflow, and saves it only if the result is valid.
The SDK never saves anything itself. You read a version through the Workflow API, hand its definition to the SDK, and send sdk.workflow back through the API once sdk.typecheck() returns no error.

How the SDK works

Constructor

apis holds three generated clients, keyed by the API they call: The SDK caches successful responses to identical requests for the lifetime of the instance, so loading a large Workflow fetches each Datasource and Content once. Send the x-rlvt-sdk-no-cache header on a request to bypass the cache.

Node builders

A Node is never written as raw JSON. You ask the SDK for the builder of a Node type, set its options, and add it:
The builder validates each option against the Node’s schema and knows which upstream Nodes can feed each property. To change an existing Node, load it into a builder with await builder.from(nodeId), set the new values, then call sdk.nodes.update(nodeId, builder). Removing a Node or an edge leaves dependent Nodes in place and reports them through typecheck(), so you decide how to repair them. Entrypoints (sdk.entrypoints.add({ type: 'email', format: 'content-image' })) and edges (sdk.edges.add(fromId, toId)) complete the graph. An edge starts from an entrypoint, a Node, or one path of a Logic Node.

Type checking

sdk.typecheck() returns every problem of the current definition as a WorkflowError: the Node id, the pathId for a Logic Node path, the error type and a payload with the details. An empty list means the Workflow will run as configured. Some Node types add their own error types (for example a Datagraph Object that no longer exists). Log type and payload rather than matching a closed list.

Saving and publishing

A live version is never modified: every change to production goes through a new draft and a publish.

Errors