From 6dc31a9d4f9d3a06afdccfe9f457c6662ea93eae Mon Sep 17 00:00:00 2001 From: Kacper Wojciechowski <39823706+jog1t@users.noreply.github.com> Date: Fri, 18 Sep 2026 03:43:15 +0200 Subject: [PATCH] docs: migrate workflows example to @rivet-dev/workflows --- docs/content/docs/workflows.mdx | 4 ++-- examples/apps-workflows/README.md | 9 ++++++--- .../apps-workflows/fixtures/app/package.json | 1 + .../apps-workflows/fixtures/app/src/index.ts | 9 ++++----- examples/apps-workflows/package.json | 1 + pnpm-lock.yaml | 18 ++++++++++++++++++ 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/docs/content/docs/workflows.mdx b/docs/content/docs/workflows.mdx index 063c0220b..fcfbf9786 100644 --- a/docs/content/docs/workflows.mdx +++ b/docs/content/docs/workflows.mdx @@ -17,5 +17,5 @@ Deploy the app, then connect to its actors from your own system: -See [Workflows in Rivet Actors](/workflows/docs/) for -steps, loops, queues, and error handling. +The app defines its actor with `@rivet-dev/workflows`. See the +[Workflows docs](/workflows/docs/) for steps, loops, queues, and error handling. diff --git a/examples/apps-workflows/README.md b/examples/apps-workflows/README.md index dd73f046a..79a3e6bbe 100644 --- a/examples/apps-workflows/README.md +++ b/examples/apps-workflows/README.md @@ -1,7 +1,10 @@ # Dynamic Apps: Workflows -The deployed app defines a keyed job actor whose durable workflow starts when -the actor is created, sleeps, and resumes before marking the job complete. +The deployed app defines an `order` actor with +[`@rivet-dev/workflows`](https://rivet.dev/workflows/docs/). Its durable +workflow starts when the actor is created, charges and ships the order, sleeps +while it is in transit, and resumes to mark it delivered. The client deploys the +app as `order-workflow` and polls the order's status until it is delivered. Run the example with Node.js 22 or newer: @@ -12,4 +15,4 @@ pnpm --dir examples/apps-workflows client ``` The app's ordinary HTTP handler is available at -`http://localhost:3000/apps/durable-workflow/`. +`http://localhost:3000/apps/order-workflow/`. diff --git a/examples/apps-workflows/fixtures/app/package.json b/examples/apps-workflows/fixtures/app/package.json index f2abde44a..ada58db73 100644 --- a/examples/apps-workflows/fixtures/app/package.json +++ b/examples/apps-workflows/fixtures/app/package.json @@ -5,6 +5,7 @@ "type": "module", "main": "src/index.ts", "dependencies": { + "@rivet-dev/workflows": "1.0.0", "hono": "4.13.5", "rivetkit": "2.3.11" } diff --git a/examples/apps-workflows/fixtures/app/src/index.ts b/examples/apps-workflows/fixtures/app/src/index.ts index b1b24032a..df47fd020 100644 --- a/examples/apps-workflows/fixtures/app/src/index.ts +++ b/examples/apps-workflows/fixtures/app/src/index.ts @@ -1,17 +1,16 @@ +import { setup, workflow } from "@rivet-dev/workflows"; import { Hono } from "hono"; -import { actor, setup } from "rivetkit"; -import { workflow } from "rivetkit/workflow"; type Status = "placed" | "paid" | "shipped" | "delivered"; // The workflow runs when the actor is created. Each step is durable, so the // actor can sleep, scale to zero, and resume exactly where it left off. -const order = actor({ +const order = workflow({ state: { status: "placed" as Status }, actions: { status: (c) => c.state.status, }, - run: workflow(async (wf) => { + run: async (wf) => { await wf.step("charge", async (c) => { c.state.status = "paid"; }); @@ -22,7 +21,7 @@ const order = actor({ await wf.step("deliver", async (c) => { c.state.status = "delivered"; }); - }), + }, }); export const registry = setup({ use: { order } }); diff --git a/examples/apps-workflows/package.json b/examples/apps-workflows/package.json index 3aad4d328..6cc4fa905 100644 --- a/examples/apps-workflows/package.json +++ b/examples/apps-workflows/package.json @@ -11,6 +11,7 @@ "dependencies": { "@hono/node-server": "^2.1.1", "@rivet-dev/dynamic-apps": "workspace:*", + "@rivet-dev/workflows": "1.0.0", "hono": "^4.13.5", "rivetkit": "2.3.11" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2d6860e51..d789c179b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -223,6 +223,9 @@ importers: '@rivet-dev/dynamic-apps': specifier: workspace:* version: link:../../packages/dynamic-apps + '@rivet-dev/workflows': + specifier: 1.0.0 + version: 1.0.0(rivetkit@2.3.11(better-sqlite3@12.11.1)(ws@8.21.3)) hono: specifier: ^4.13.5 version: 4.13.5 @@ -1461,6 +1464,12 @@ packages: resolution: {integrity: sha512-fYtRK4VlJzJGLPnKrGzlRJYQnTcO2YeL1jEn1N2MB4FtAxc1BIbszPC70oCE9g8JcdEbhQ8+aPYBKR3VoVAePQ==} hasBin: true + '@rivet-dev/workflows@1.0.0': + resolution: {integrity: sha512-FKuG0l716jImDlR3NaobFx0pifd0zDf/oeNXi25yHGiFWWwxQMePmS7OT04Onn2JmJw1+dqnTALot/UfXn10oA==} + engines: {node: '>=22'} + peerDependencies: + rivetkit: 2.3.11 + '@rivetkit/bare-ts@0.6.2': resolution: {integrity: sha512-3qndQUQXLdwafMEqfhz24hUtDPcsf1Bu3q52Kb8MqeH8JUh3h6R4HYW3ZJXiQsLcyYyFM68PuIwlLRlg1xDEpg==} engines: {node: ^14.18.0 || >=16.0.0} @@ -4867,6 +4876,15 @@ snapshots: dependencies: '@rivetkit/bare-ts': 0.6.2 + '@rivet-dev/workflows@1.0.0(rivetkit@2.3.11(better-sqlite3@12.11.1)(ws@8.21.3))': + dependencies: + '@rivetkit/bare-ts': 0.6.2 + cbor-x: 1.6.5 + fdb-tuple: 1.0.0 + pino: 9.14.0 + rivetkit: 2.3.11(better-sqlite3@12.11.1)(ws@8.21.3) + vbare: 0.0.4 + '@rivetkit/bare-ts@0.6.2': {} '@rivetkit/engine-cli-darwin-arm64@2.3.11':