@brickkit/cli/workflows
Load and build the `"use workflow"` and `"use step"` files of a Brick application, for tests and scripts that run workflows without `brick dev`.
@brickkit/cli/workflows exports 4 names: 4 functions.
import { buildAppWorkflows, buildWorkflows, registerWorkflowTransform } from "@brickkit/cli/workflows";Functions
| Function | Description |
|---|---|
buildAppWorkflows | Build the workflow bundle an app needs, if it has workflow listeners. |
buildWorkflows | Build the bundle that runs an app's workflows: flow.mjs and manifest.json in <root>/.well-known/workflow/v1, from every file under root marked `"use wo… |
registerWorkflowTransform | Make files marked "use workflow" or "use step" load as workflows and steps. |
workflowTransformPlugin | The plugin that turns "use workflow" and "use step" files into workflows and steps. |
buildAppWorkflows
function buildAppWorkflows(
app: BrickApp,
options: { reuse?: boolean } = {},
): Promise<boolean>Build the workflow bundle an app needs, if it has workflow listeners.
Parameters
| Name | Type | Description |
|---|---|---|
app | BrickApp | The loaded app. |
options? | { reuse?: boolean } default {} | reuse: keep the last bundle when its sources have not changed. |
Returns Promise<boolean> — Whether the app has a bundle, built now or kept from the last build.
Source: packages/cli/src/workflows.ts:425
buildWorkflows
function buildWorkflows(
options: { root?: string; reuse?: boolean } = {},
): Promise<boolean>Build the bundle that runs an app's workflows: flow.mjs and manifest.json
in <root>/.well-known/workflow/v1, from every file under root marked
"use workflow" or "use step".
brick dev and brick start call it before events start. Call it in a script
or test before starting events.
Parameters
| Name | Type | Description |
|---|---|---|
options? | { root?: string; reuse?: boolean } default {} | root: the project root. Default: the working directory. reuse: keep the bundle of the last build when nothing it was built from has changed, which saves about a second on each reload of brick dev. Default: false, always build. |
Returns Promise<boolean> — Whether it built the bundle; false when it kept the last one.
Throws
- When
@workflow/buildersis not installed in the project.
Source: packages/cli/src/workflows.ts:343
registerWorkflowTransform
function registerWorkflowTransform(
root: string = process.cwd(),
): Promise<boolean>Make files marked "use workflow" or "use step" load as workflows and steps.
A workflow function gets the workflowId that defineListener({ workflow })
needs, and a step registers itself so the runtime can run it in this process.
brick dev, brick start and brick worker call it before they load the app.
Call it in a script or test before importing the files, with the project root.
It does nothing, and returns false, when the Workflow SDK and its builders are
not installed in the project. Bun allows plugins once per process, so a second
call is ignored.
Parameters
| Name | Type | Description |
|---|---|---|
root? | string default process.cwd() | The project root, where the SDK is installed. Default: the working directory. |
Returns Promise<boolean> — Whether the transform is active.
Source: packages/cli/src/workflows.ts:121
workflowTransformPlugin
function workflowTransformPlugin(
root: string = process.cwd(),
): Promise<BunPlugin | undefined>The plugin that turns "use workflow" and "use step" files into workflows and
steps. registerWorkflowTransform installs it for the running process;
brick build hands it to Bun.build.
Parameters
| Name | Type | Description |
|---|---|---|
root? | string default process.cwd() | The project root, where the SDK is installed. Default: the working directory. |
Returns Promise<BunPlugin \| undefined> — The plugin, or undefined when the Workflow SDK and its builders are not
installed in the project.
Source: packages/cli/src/workflows.ts:73