An OpenWorkflow backend implementation for PocketBase.
npm install openworkflow-pocketbase openworkflow pocketbaseopenworkflow and pocketbase are peer dependencies (ESM-only, Node ≥ 20).
import { OpenWorkflow } from "openworkflow";
import { BackendPocketBase } from "openworkflow-pocketbase";
const backend = new BackendPocketBase({
url: "http://localhost:8090",
email: process.env.PB_SUPERUSER_EMAIL!,
password: process.env.PB_SUPERUSER_PASSWORD!,
namespaceId: "default", // optional; defaults to "default"
});
const ow = new OpenWorkflow({ backend });
// defineWorkflow / run / newWorker exactly as with BackendSqlite / BackendPostgres —
// the Worker + replay engine are unchanged.Advanced — pass a pre-authed client you own (e.g. one shared across namespaces):
import PocketBase from "pocketbase";
const pb = new PocketBase("http://localhost:8090");
await pb.collection("_superusers").authWithPassword(email, password);
const backend = new BackendPocketBase({ client: pb, namespaceId: "team-a" });The binding sets autoCancellation(false) (workers poll repeatedly), authenticates lazily,
and re-authenticates once on a 401.
- Targets PocketBase's OpenWorkflow plugin schema v5.
npm install
npm run build # tsc -> dist/ (ESM + .d.ts)
npm run test:unit # unit tests only (no server needed)Conformance runs OpenWorkflow's shared backend suite against a live PocketBase instnace. Start a server and point the tests at it:
# from a PocketBase checkout (with the openworkflow plugin):
go build -o /tmp/pocketbase ./examples/base
/tmp/pocketbase superuser upsert test@example.com openworkflow-test-pw --dir /tmp/pb_data
/tmp/pocketbase serve --dir /tmp/pb_data --http 127.0.0.1:8090 &
PB_URL=http://127.0.0.1:8090 \
PB_SUPERUSER_EMAIL=test@example.com \
PB_SUPERUSER_PASSWORD=openworkflow-test-pw \
npm testCI does the same against a published release binary (.github/workflows/conformance.yml).
test/backend.testsuite.vendored.ts is a copy of OpenWorkflow's
packages/openworkflow/testing/backend.testsuite.ts. Re-sync it on each openworkflow
release. Only three edits vs upstream:
- imports rewritten to the public
openworkflow/internalsurface; DEFAULT_WORKFLOW_RETRY_POLICYinlined (it is not publicly exported);- one clock-mocked test (
…older than the idempotency period) is.skipped — itsvi.spyOn(Date,"now")cannot affect the remote server's clock.