feat(examples): runnable Temporal Code Exchange sample - #146
dawidaksamski wants to merge 21 commits into
Conversation
|
|
||
| Run a workflow drawn in the Workflow Builder editor as a durable Temporal Workflow Execution: every node becomes an Activity, retries and history come from Temporal, and the canvas shows each node's status live. | ||
|
|
||
| This sample wires the [`@workflowbuilder/temporal`](https://www.npmjs.com/package/@workflowbuilder/temporal) plugin into a Temporal Worker and executes a five-node diagram authored in the [Workflow Builder](https://www.workflowbuilder.io) editor. One node fails on its first attempt on purpose, so the retry you see in Event History is a real one, and a decision node routes each run down one of two branches while the other is pruned. An optional editor lets you change the diagram and watch nodes light up while Temporal runs them. |
There was a problem hiding this comment.
This links to an npm page that does not exist yet, and line 41 says so. A reviewer will click it in the first paragraph. Until publish day, point it at https://github.com/synergycodes/workflowbuilder/tree/main/packages/temporal, and add "swap the two npm links (README lines 5 and 168)" to the publish-day list in worker/vendor/README.md.
|
|
||
| ## Learn more | ||
|
|
||
| - [`@workflowbuilder/temporal` on npm](https://www.npmjs.com/package/@workflowbuilder/temporal): profiles, node labels in Event History, versioning and replay. |
There was a problem hiding this comment.
Same dead link. The plugin README in the repo covers profiles, labels and replay today, so link there for now.
| Terminal 1, a local Temporal server: | ||
|
|
||
| ```bash | ||
| temporal server start-dev |
There was a problem hiding this comment.
Anyone who already runs Temporal locally has probably 7233 taken. The fallback belongs right here, since config.ts already reads the variables:
temporal server start-dev --port 7234 --ui-port 8234and then TEMPORAL_ADDRESS=127.0.0.1:7234 TEMPORAL_UI_ORIGIN=http://localhost:8234 in front of npm start and npm run workflow.
What
A self-contained sample for Temporal's Code Exchange
that demonstrates
@workflowbuilder/temporal: a diagram drawn in the Workflow Buildereditor runs as a durable Temporal Workflow Execution, every node becomes an Activity, and
the canvas shows each node's status live. It lives at
examples/workflow-builder-temporal/alongside the starter, outside the pnpm workspace, so
degitfetches a folder that standson its own.
Everything is new except a two-line pointer in the root README.
What's in it
Three folders, each with one job:
shared/— what both processes agree on: the diagram, the wire types, the coin flip.worker/— the Temporal Worker with the plugin, the HTTP/SSE bridge the editor talks to,and a CLI client. Its own npm project.
editor/— the optional browser app. Its own npm project.The diagram is five nodes: a trigger, an action that fails on its first attempt on purpose,
a decision, and one action per branch. Two things a reader can see and not just read about:
Event History shows a real retry on Send email, and the branch the runner pruned schedules
no Activity at all — on the canvas it dims out and reports
node_skipped. The amount isdrawn at random per run, so roughly every other run takes the other branch.
Six places carry the whole integration and the README names each one: the workflow
re-export, the plugin handed to
Worker.create, the executors, branch evaluation, thestore port, and the snapshot-to-definition mapper.
Why this is a draft
@workflowbuilder/temporalis not on npm yet, soworker/installs it from a packed buildcommitted under
worker/vendor/and the manifest points at that file. The tarball is abuild of source already public in this repo, so it discloses nothing new, but it is a
stopgap and the sample cannot be submitted to Code Exchange until the package ships.
On publish day (see
worker/vendor/README.md, code markertemporal-sample-npm-dependency):worker/vendor/.worker/package-lock.json.!/worker/vendor/*.tgzexception from the sample's.gitignore.Then re-run the clean-machine check against npm — that run is the one that counts, since
the README's
degitone-liner only resolves once this is onmain.CI
New
temporal-samplejob inpr-check.yml, modelled on the existing Starter build:npm ciplus typecheck for the worker,
npm ciplus build for the editor. No pnpm and no workspaceinstall, since neither project is a workspace member. It also guards the vendored tarball —
a refreshed build that breaks the sample fails here.
Not covered: ESLint over the sample. Prettier reaches it through the global format job and
the sample's lint-staged config catches it on commit, but a hook-bypassing push would not be
linted. Happy to add a step if reviewers want it.
How it was verified
git archiveinto a clean directory — exactly what thisPR carries, nothing untracked — then
npm ciin both projects, worker typecheck, editorbuild, and a full run end to end. The sample is self-sufficient.
confirms two attempts on Send email only, and no Activity for the pruned node.
diagram restoring the shipped diagram.
Deliberately not here
own suite lives in
packages/temporal.temporal-docs-guide).temporal-sample-submission); the README carries thetext to paste and the pitch fits the form's 256-character limit.
published version (
temporal-sample-approval-node).For reviewers
The README is the deliverable — if the instructions don't work, the sample doesn't work, so
that's the thing to read critically. The two screenshots, the expected output blocks, and
every relative link were taken from or checked against real runs.