workflow 5.0.0-beta.43 → 5.0.0-beta.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/internal/builtins.d.ts +4 -4
- package/dist/internal/builtins.js +6 -6
- package/docs/ai/chat-session-modeling.mdx +23 -24
- package/docs/ai/defining-tools.mdx +5 -6
- package/docs/ai/human-in-the-loop.mdx +11 -11
- package/docs/ai/index.mdx +20 -20
- package/docs/ai/message-queueing.mdx +6 -6
- package/docs/ai/meta.json +1 -0
- package/docs/ai/resumable-streams.mdx +28 -28
- package/docs/ai/sleep-and-delays.mdx +9 -9
- package/docs/ai/streaming-updates-from-tools.mdx +4 -4
- package/docs/api-reference/vitest/index.mdx +8 -8
- package/docs/api-reference/workflow/create-hook.mdx +15 -15
- package/docs/api-reference/workflow/create-webhook.mdx +15 -15
- package/docs/api-reference/workflow/define-hook.mdx +10 -10
- package/docs/api-reference/workflow/fatal-error.mdx +2 -2
- package/docs/api-reference/workflow/fetch.mdx +7 -7
- package/docs/api-reference/workflow/get-step-metadata.mdx +2 -2
- package/docs/api-reference/workflow/get-workflow-metadata.mdx +3 -3
- package/docs/api-reference/workflow/get-writable.mdx +7 -7
- package/docs/api-reference/workflow/index.mdx +1 -1
- package/docs/api-reference/workflow/retryable-error.mdx +1 -1
- package/docs/api-reference/workflow/set-attributes.mdx +2 -2
- package/docs/api-reference/workflow/sleep.mdx +3 -3
- package/docs/api-reference/workflow-ai/durable-agent.mdx +42 -42
- package/docs/api-reference/workflow-ai/index.mdx +3 -3
- package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +28 -28
- package/docs/api-reference/workflow-api/get-hook-by-token.mdx +11 -11
- package/docs/api-reference/workflow-api/get-run.mdx +10 -10
- package/docs/api-reference/workflow-api/index.mdx +2 -4
- package/docs/api-reference/workflow-api/resume-hook.mdx +14 -14
- package/docs/api-reference/workflow-api/resume-webhook.mdx +3 -3
- package/docs/api-reference/workflow-api/start.mdx +16 -15
- package/docs/api-reference/workflow-astro/workflow.mdx +3 -3
- package/docs/api-reference/workflow-errors/entity-conflict-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/hook-not-found-error.mdx +8 -8
- package/docs/api-reference/workflow-errors/index.mdx +6 -6
- package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +9 -9
- package/docs/api-reference/workflow-errors/run-expired-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/run-not-supported-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/step-not-registered-error.mdx +5 -5
- package/docs/api-reference/workflow-errors/throttle-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/too-early-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/workflow-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/workflow-not-registered-error.mdx +5 -6
- package/docs/api-reference/workflow-errors/workflow-run-cancelled-error.mdx +6 -6
- package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +5 -5
- package/docs/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/workflow-run-not-found-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/workflow-world-error.mdx +8 -8
- package/docs/api-reference/workflow-globals.mdx +12 -11
- package/docs/api-reference/workflow-nest/configure-workflow-controller.mdx +2 -2
- package/docs/api-reference/workflow-nest/nest-local-builder.mdx +4 -4
- package/docs/api-reference/workflow-nest/workflow-controller.mdx +1 -1
- package/docs/api-reference/workflow-nest/workflow-module.mdx +4 -4
- package/docs/api-reference/workflow-next/with-workflow.mdx +16 -16
- package/docs/api-reference/workflow-nitro/index.mdx +6 -6
- package/docs/api-reference/workflow-nuxt/index.mdx +4 -4
- package/docs/api-reference/workflow-observability/hydrate-data.mdx +5 -5
- package/docs/api-reference/workflow-observability/hydrate-resource-io.mdx +4 -4
- package/docs/api-reference/workflow-observability/index.mdx +6 -8
- package/docs/api-reference/workflow-observability/observability-revivers.mdx +2 -2
- package/docs/api-reference/workflow-observability/parse-class-name.mdx +3 -3
- package/docs/api-reference/workflow-observability/parse-step-name.mdx +4 -4
- package/docs/api-reference/workflow-observability/parse-workflow-name.mdx +4 -4
- package/docs/api-reference/workflow-runtime/create-world.mdx +8 -8
- package/docs/api-reference/workflow-runtime/get-world-handlers.mdx +6 -6
- package/docs/api-reference/workflow-runtime/get-world.mdx +4 -4
- package/docs/api-reference/workflow-runtime/health-check.mdx +1 -1
- package/docs/api-reference/workflow-runtime/index.mdx +2 -4
- package/docs/api-reference/workflow-runtime/set-world.mdx +15 -13
- package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +6 -5
- package/docs/api-reference/workflow-runtime/world/analytics.mdx +9 -9
- package/docs/api-reference/workflow-runtime/world/index.mdx +5 -3
- package/docs/api-reference/workflow-runtime/world/queue.mdx +11 -11
- package/docs/api-reference/workflow-runtime/world/storage.mdx +62 -28
- package/docs/api-reference/workflow-runtime/world/streams.mdx +7 -7
- package/docs/api-reference/workflow-serde/index.mdx +1 -1
- package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +2 -2
- package/docs/api-reference/workflow-serde/workflow-serialize.mdx +7 -7
- package/docs/api-reference/workflow-sveltekit/workflow-plugin.mdx +3 -3
- package/docs/api-reference/workflow-vite/workflow.mdx +5 -5
- package/docs/changelog/attributes-mvp.mdx +39 -39
- package/docs/changelog/batched-event-writes.mdx +12 -12
- package/docs/changelog/eager-processing.mdx +63 -63
- package/docs/changelog/index.mdx +3 -3
- package/docs/changelog/lazy-event-creation.md +27 -27
- package/docs/changelog/resilient-resume.mdx +5 -5
- package/docs/changelog/resilient-start.mdx +14 -14
- package/docs/changelog/step-message-ownership.mdx +47 -47
- package/docs/changelog/turbo-mode.md +20 -20
- package/docs/comparisons/index.mdx +13 -13
- package/docs/comparisons/workflow-sdk-vs-aws-agentcore.mdx +15 -15
- package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +12 -12
- package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +11 -11
- package/docs/comparisons/workflow-sdk-vs-inngest.mdx +19 -19
- package/docs/comparisons/workflow-sdk-vs-temporal.mdx +23 -23
- package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +18 -17
- package/docs/configuration/build-and-diagnostics.mdx +5 -5
- package/docs/configuration/cli-and-web-ui.mdx +4 -4
- package/docs/configuration/runtime-tuning.mdx +86 -23
- package/docs/configuration/worlds.mdx +28 -14
- package/docs/cookbook/advanced/child-workflows.mdx +25 -25
- package/docs/cookbook/advanced/publishing-libraries.mdx +40 -40
- package/docs/cookbook/advanced/serializable-steps.mdx +21 -21
- package/docs/cookbook/advanced/upgrading-workflows.mdx +31 -31
- package/docs/cookbook/agent-patterns/agent-cancellation.mdx +20 -20
- package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +22 -22
- package/docs/cookbook/common-patterns/batching.mdx +14 -14
- package/docs/cookbook/common-patterns/idempotency.mdx +9 -9
- package/docs/cookbook/common-patterns/rate-limiting.mdx +3 -3
- package/docs/cookbook/common-patterns/saga.mdx +19 -19
- package/docs/cookbook/common-patterns/scheduling.mdx +23 -23
- package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +26 -26
- package/docs/cookbook/common-patterns/timeouts.mdx +23 -23
- package/docs/cookbook/common-patterns/webhooks.mdx +6 -6
- package/docs/cookbook/common-patterns/workflow-composition.mdx +19 -19
- package/docs/cookbook/index.mdx +22 -22
- package/docs/cookbook/integrations/ai-sdk.mdx +43 -41
- package/docs/cookbook/integrations/chat-sdk.mdx +34 -34
- package/docs/cookbook/integrations/sandbox.mdx +46 -46
- package/docs/deploying.mdx +15 -15
- package/docs/errors/abort-signal-timeout-in-workflow.mdx +12 -12
- package/docs/errors/corrupted-event-log.mdx +11 -11
- package/docs/errors/deployment-mismatch.mdx +14 -14
- package/docs/errors/fetch-in-workflow.mdx +8 -8
- package/docs/errors/hook-conflict.mdx +11 -11
- package/docs/errors/index.mdx +1 -1
- package/docs/errors/node-js-module-in-workflow.mdx +5 -5
- package/docs/errors/replay-divergence.mdx +2 -2
- package/docs/errors/runtime-decryption-failed.mdx +12 -12
- package/docs/errors/serialization-failed.mdx +40 -12
- package/docs/errors/start-invalid-workflow-function.mdx +5 -5
- package/docs/errors/step-executed-multiple-times.mdx +2 -2
- package/docs/errors/step-not-registered.mdx +5 -5
- package/docs/errors/timeout-in-workflow.mdx +8 -8
- package/docs/errors/webhook-invalid-respond-with-value.mdx +18 -18
- package/docs/errors/webhook-response-not-sent.mdx +16 -16
- package/docs/errors/workflow-not-registered.mdx +5 -5
- package/docs/foundations/cancellation.mdx +31 -31
- package/docs/foundations/errors-and-retries.mdx +42 -11
- package/docs/foundations/hooks.mdx +35 -35
- package/docs/foundations/idempotency.mdx +9 -9
- package/docs/foundations/serialization.mdx +21 -22
- package/docs/foundations/starting-workflows.mdx +36 -37
- package/docs/foundations/streaming.mdx +46 -41
- package/docs/foundations/versioning.mdx +3 -3
- package/docs/foundations/workflows-and-steps.mdx +9 -9
- package/docs/getting-started/astro.mdx +16 -16
- package/docs/getting-started/express.mdx +8 -8
- package/docs/getting-started/fastify.mdx +8 -8
- package/docs/getting-started/hono.mdx +8 -8
- package/docs/getting-started/nestjs.mdx +18 -17
- package/docs/getting-started/next.mdx +11 -11
- package/docs/getting-started/nitro.mdx +16 -16
- package/docs/getting-started/nuxt.mdx +8 -8
- package/docs/getting-started/python.mdx +4 -4
- package/docs/getting-started/react-router/v7.mdx +1 -1
- package/docs/getting-started/react-router/v8.mdx +1 -1
- package/docs/getting-started/sveltekit.mdx +14 -14
- package/docs/getting-started/tanstack-start.mdx +12 -12
- package/docs/getting-started/vite.mdx +8 -8
- package/docs/how-it-works/cancellation.mdx +62 -62
- package/docs/how-it-works/code-transform.mdx +66 -54
- package/docs/how-it-works/encryption.mdx +25 -21
- package/docs/how-it-works/event-sourcing.mdx +53 -35
- package/docs/how-it-works/framework-integrations.mdx +12 -12
- package/docs/how-it-works/understanding-directives.mdx +21 -21
- package/docs/internal/index.mdx +6 -6
- package/docs/internal/nitro-native-build.mdx +2 -2
- package/docs/internal/nitro-web-ui.mdx +4 -4
- package/docs/internal/serializable-abort-controller.mdx +7 -7
- package/docs/observability/attributes.mdx +3 -3
- package/docs/observability/index.mdx +14 -10
- package/docs/observability/tracing.mdx +10 -10
- package/docs/testing/index.mdx +33 -33
- package/docs/testing/server-based.mdx +10 -10
- package/docs/whats-new.mdx +185 -0
- package/package.json +12 -12
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Nitro
|
|
3
|
-
description:
|
|
3
|
+
description: Set up your first durable workflow in a Nitro v3 project.
|
|
4
4
|
type: guide
|
|
5
5
|
summary: Set up Workflow SDK in a Nitro app.
|
|
6
6
|
prerequisites:
|
|
@@ -16,9 +16,9 @@ related:
|
|
|
16
16
|
<Steps>
|
|
17
17
|
|
|
18
18
|
<Step>
|
|
19
|
-
## Create
|
|
19
|
+
## Create your Nitro project
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Create a [Nitro v3](https://v3.nitro.build/) project in a new directory named `nitro-app`:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
npx create-nitro-app
|
|
@@ -38,7 +38,7 @@ npm i workflow
|
|
|
38
38
|
|
|
39
39
|
### Configure Nitro
|
|
40
40
|
|
|
41
|
-
Add `workflow/nitro` module to your `nitro.config.ts
|
|
41
|
+
Add the `workflow/nitro` module to your `nitro.config.ts`. This enables the `"use workflow"` and `"use step"` directives.
|
|
42
42
|
|
|
43
43
|
```typescript title="nitro.config.ts" lineNumbers
|
|
44
44
|
import { defineConfig } from "nitro";
|
|
@@ -70,15 +70,15 @@ export default defineConfig({
|
|
|
70
70
|
| --- | --- | --- | --- |
|
|
71
71
|
| `dirs` | `string[]` | — | Directories to scan for workflows and steps. By default, `workflows/` is scanned from the project root and all layer source directories. |
|
|
72
72
|
| `runtime` | `string` | `'nodejs22.x'` | Node.js runtime version for Vercel Functions (e.g. `'nodejs22.x'`, `'nodejs24.x'`). |
|
|
73
|
-
| `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Defaults to `'inline'` in development and `false` in production (smaller function bundles
|
|
73
|
+
| `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Defaults to `'inline'` in development and `false` in production (smaller function bundles, which helps stay under the Vercel 250 MB function size limit). Set it explicitly, or use the `WORKFLOW_SOURCEMAP` environment variable, to override in either environment. |
|
|
74
74
|
|
|
75
75
|
<Accordion type="single" collapsible>
|
|
76
76
|
<AccordionItem value="typescript-intellisense" className="[&_h3]:my-0">
|
|
77
77
|
<AccordionTrigger className="[&_p]:my-0 text-lg [&_p]:text-foreground">
|
|
78
|
-
|
|
78
|
+
Set up IntelliSense for TypeScript (optional)
|
|
79
79
|
</AccordionTrigger>
|
|
80
80
|
<AccordionContent className="[&_p]:my-2">
|
|
81
|
-
To enable helpful hints in your IDE,
|
|
81
|
+
To enable helpful hints in your IDE, set up the workflow plugin in `tsconfig.json`:
|
|
82
82
|
|
|
83
83
|
```json title="tsconfig.json" lineNumbers
|
|
84
84
|
{
|
|
@@ -102,7 +102,7 @@ To enable helpful hints in your IDE, setup the workflow plugin in `tsconfig.json
|
|
|
102
102
|
|
|
103
103
|
<Step>
|
|
104
104
|
|
|
105
|
-
## Create
|
|
105
|
+
## Create your first workflow
|
|
106
106
|
|
|
107
107
|
Create a new file for our first workflow:
|
|
108
108
|
|
|
@@ -124,14 +124,14 @@ export async function handleUserSignup(email: string) {
|
|
|
124
124
|
}
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
We'll fill in those functions next, but
|
|
127
|
+
We'll fill in those functions next, but first review this code:
|
|
128
128
|
|
|
129
129
|
- We define a **workflow** function with the directive `"use workflow"`. Think of the workflow function as the _orchestrator_ of individual **steps**.
|
|
130
130
|
- The Workflow SDK's `sleep` function allows us to suspend execution of the workflow without using up any resources. A sleep can be a few seconds, hours, days, or even months long.
|
|
131
131
|
|
|
132
|
-
## Create
|
|
132
|
+
## Create your workflow steps
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
Define the missing functions.
|
|
135
135
|
|
|
136
136
|
```typescript title="workflows/user-signup.ts" lineNumbers
|
|
137
137
|
import { FatalError } from "workflow";
|
|
@@ -185,7 +185,7 @@ Taking a look at this code:
|
|
|
185
185
|
|
|
186
186
|
<Step>
|
|
187
187
|
|
|
188
|
-
## Create
|
|
188
|
+
## Create your route handler
|
|
189
189
|
|
|
190
190
|
To invoke your new workflow, we'll create a new API route handler at `server/api/signup.post.ts` with the following code:
|
|
191
191
|
|
|
@@ -204,7 +204,7 @@ export default defineEventHandler(async ({ req }) => {
|
|
|
204
204
|
});
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
-
This
|
|
207
|
+
This route handler creates a `POST` request endpoint at `/api/signup` that triggers your workflow.
|
|
208
208
|
|
|
209
209
|
<Callout>
|
|
210
210
|
Workflows can be triggered from API routes or any server-side
|
|
@@ -248,7 +248,7 @@ npx workflow inspect runs
|
|
|
248
248
|
|
|
249
249
|
## Deploying to production
|
|
250
250
|
|
|
251
|
-
Workflow SDK apps currently work best when deployed to [Vercel](https://vercel.com/home) and
|
|
251
|
+
Workflow SDK apps currently work best when deployed to [Vercel](https://vercel.com/home) and need no special configuration.
|
|
252
252
|
|
|
253
253
|
<FluidComputeCallout />
|
|
254
254
|
|
|
@@ -260,7 +260,7 @@ Check the [Deploying](/docs/deploying) section to learn how your workflows can b
|
|
|
260
260
|
|
|
261
261
|
If you see this error:
|
|
262
262
|
|
|
263
|
-
```
|
|
263
|
+
```text
|
|
264
264
|
'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.
|
|
265
265
|
```
|
|
266
266
|
|
|
@@ -271,7 +271,7 @@ Check both of these first:
|
|
|
271
271
|
|
|
272
272
|
See [start-invalid-workflow-function](/docs/errors/start-invalid-workflow-function) for full examples and fixes.
|
|
273
273
|
|
|
274
|
-
## Next
|
|
274
|
+
## Next steps
|
|
275
275
|
|
|
276
276
|
- Learn more about the [Foundations](/docs/foundations).
|
|
277
277
|
- Check [Errors](/docs/errors) if you encounter issues.
|
|
@@ -16,7 +16,7 @@ related:
|
|
|
16
16
|
<Steps>
|
|
17
17
|
|
|
18
18
|
<Step>
|
|
19
|
-
## Create
|
|
19
|
+
## Create your Nuxt project
|
|
20
20
|
|
|
21
21
|
Start by creating a new Nuxt project. This command will create a new directory named `nuxt-app` and setup a Nuxt project inside it.
|
|
22
22
|
|
|
@@ -79,7 +79,7 @@ export default defineNuxtConfig({
|
|
|
79
79
|
|
|
80
80
|
<Step>
|
|
81
81
|
|
|
82
|
-
## Create
|
|
82
|
+
## Create your first workflow
|
|
83
83
|
|
|
84
84
|
Create a new file for our first workflow:
|
|
85
85
|
|
|
@@ -101,14 +101,14 @@ export async function handleUserSignup(email: string) {
|
|
|
101
101
|
}
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
We'll fill in those functions next
|
|
104
|
+
We'll fill in those functions next. The current code does the following:
|
|
105
105
|
|
|
106
106
|
- We define a **workflow** function with the directive `"use workflow"`. Think of the workflow function as the _orchestrator_ of individual **steps**.
|
|
107
107
|
- The Workflow SDK's `sleep` function allows us to suspend execution of the workflow without using up any resources. A sleep can be a few seconds, hours, days, or even months long.
|
|
108
108
|
|
|
109
|
-
## Create
|
|
109
|
+
## Create your workflow steps
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
Define the missing functions.
|
|
112
112
|
|
|
113
113
|
```typescript title="server/workflows/user-signup.ts" lineNumbers
|
|
114
114
|
import { FatalError } from "workflow";
|
|
@@ -162,7 +162,7 @@ Taking a look at this code:
|
|
|
162
162
|
|
|
163
163
|
<Step>
|
|
164
164
|
|
|
165
|
-
## Create
|
|
165
|
+
## Create your API route
|
|
166
166
|
|
|
167
167
|
To invoke your new workflow, we'll create a new API route handler at `server/api/signup.post.ts` with the following code:
|
|
168
168
|
|
|
@@ -239,7 +239,7 @@ Check the [Deploying](/docs/deploying) section to learn how your workflows can b
|
|
|
239
239
|
|
|
240
240
|
If you see this error:
|
|
241
241
|
|
|
242
|
-
```
|
|
242
|
+
```text
|
|
243
243
|
'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.
|
|
244
244
|
```
|
|
245
245
|
|
|
@@ -250,7 +250,7 @@ Check both of these first:
|
|
|
250
250
|
|
|
251
251
|
See [start-invalid-workflow-function](/docs/errors/start-invalid-workflow-function) for full examples and fixes.
|
|
252
252
|
|
|
253
|
-
## Next
|
|
253
|
+
## Next steps
|
|
254
254
|
|
|
255
255
|
- Learn more about the [Foundations](/docs/foundations).
|
|
256
256
|
- Check [Errors](/docs/errors) if you encounter issues.
|
|
@@ -20,7 +20,7 @@ The Python SDK is currently in **beta**. APIs and behavior may change. For the l
|
|
|
20
20
|
|
|
21
21
|
You can build durable workflows in Python using the [`vercel` Python SDK](https://pypi.org/project/vercel/). Your workflow code can pause, resume, and maintain state, just like the JavaScript and TypeScript Workflow SDK.
|
|
22
22
|
|
|
23
|
-
## Getting
|
|
23
|
+
## Getting started
|
|
24
24
|
|
|
25
25
|
Add the `vercel` package and workflow entrypoint to `pyproject.toml`:
|
|
26
26
|
|
|
@@ -93,7 +93,7 @@ async def summarize_draft(*, draft: str):
|
|
|
93
93
|
return summary
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
Each step
|
|
96
|
+
Each step executes separately from the workflow orchestrator. While the step executes, the workflow suspends without consuming resources. When the step completes, the workflow resumes automatically where it left off.
|
|
97
97
|
|
|
98
98
|
## Sleep
|
|
99
99
|
|
|
@@ -160,11 +160,11 @@ async def resume(approval: Approval):
|
|
|
160
160
|
|
|
161
161
|
When a hook receives data, the workflow resumes automatically. You don't need polling, message queues, or manual state management.
|
|
162
162
|
|
|
163
|
-
## Learn
|
|
163
|
+
## Learn more
|
|
164
164
|
|
|
165
165
|
For comprehensive documentation, examples, and the latest updates, visit the [official Vercel Workflow Python documentation](https://vercel.com/docs/workflows/python).
|
|
166
166
|
|
|
167
|
-
## Next
|
|
167
|
+
## Next steps
|
|
168
168
|
|
|
169
169
|
- Learn more about the [Foundations](/docs/foundations).
|
|
170
170
|
- Check [Errors](/docs/errors) if you encounter issues.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: SvelteKit
|
|
3
|
-
description:
|
|
3
|
+
description: Set up your first durable workflow in a SvelteKit app.
|
|
4
4
|
type: guide
|
|
5
5
|
summary: Set up Workflow SDK in a SvelteKit app.
|
|
6
6
|
prerequisites:
|
|
@@ -16,9 +16,9 @@ related:
|
|
|
16
16
|
<Steps>
|
|
17
17
|
|
|
18
18
|
<Step>
|
|
19
|
-
## Create
|
|
19
|
+
## Create your SvelteKit project
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Create a minimal SvelteKit project in a new directory named `my-workflow-app`:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
npx sv create my-workflow-app --template=minimal --types=ts --no-add-ons
|
|
@@ -54,16 +54,16 @@ export default defineConfig({
|
|
|
54
54
|
|
|
55
55
|
| Option | Type | Default | Description |
|
|
56
56
|
| --- | --- | --- | --- |
|
|
57
|
-
| `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Defaults to `'inline'` in development and `false` in production (smaller function bundles
|
|
57
|
+
| `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Defaults to `'inline'` in development and `false` in production (smaller function bundles, which helps stay under the Vercel 250 MB function size limit). Set it explicitly, or use the `WORKFLOW_SOURCEMAP` environment variable, to override in either environment. |
|
|
58
58
|
|
|
59
59
|
<Accordion type="single" collapsible>
|
|
60
60
|
<AccordionItem value="typescript-intellisense" className="[&_h3]:my-0">
|
|
61
61
|
<AccordionTrigger className="text-sm">
|
|
62
|
-
###
|
|
62
|
+
### Set up IntelliSense for TypeScript (optional)
|
|
63
63
|
</AccordionTrigger>
|
|
64
64
|
<AccordionContent className="[&_p]:my-2">
|
|
65
65
|
|
|
66
|
-
To enable helpful hints in your IDE,
|
|
66
|
+
To enable helpful hints in your IDE, set up the workflow plugin in `tsconfig.json`:
|
|
67
67
|
|
|
68
68
|
```json title="tsconfig.json" lineNumbers
|
|
69
69
|
{
|
|
@@ -86,7 +86,7 @@ To enable helpful hints in your IDE, setup the workflow plugin in `tsconfig.json
|
|
|
86
86
|
|
|
87
87
|
<Step>
|
|
88
88
|
|
|
89
|
-
## Create
|
|
89
|
+
## Create your first workflow
|
|
90
90
|
|
|
91
91
|
Create a new file for our first workflow:
|
|
92
92
|
|
|
@@ -109,14 +109,14 @@ export async function handleUserSignup(email: string) {
|
|
|
109
109
|
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
We'll fill in those functions next, but
|
|
112
|
+
We'll fill in those functions next, but first review this code:
|
|
113
113
|
|
|
114
114
|
* We define a **workflow** function with the directive `"use workflow"`. Think of the workflow function as the _orchestrator_ of individual **steps**.
|
|
115
115
|
* The Workflow SDK's `sleep` function allows us to suspend execution of the workflow without using up any resources. A sleep can be a few seconds, hours, days, or even months long.
|
|
116
116
|
|
|
117
|
-
## Create
|
|
117
|
+
## Create your workflow steps
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
Define the missing functions.
|
|
120
120
|
|
|
121
121
|
```typescript title="workflows/user-signup.ts" lineNumbers
|
|
122
122
|
import { FatalError } from "workflow"
|
|
@@ -169,7 +169,7 @@ We'll dive deeper into workflows, steps, and other ways to suspend or handle eve
|
|
|
169
169
|
|
|
170
170
|
<Step>
|
|
171
171
|
|
|
172
|
-
## Create
|
|
172
|
+
## Create your route handler
|
|
173
173
|
|
|
174
174
|
To invoke your new workflow, we'll have to add your workflow to a `POST` API route handler, `src/routes/api/signup/+server.ts` with the following code:
|
|
175
175
|
|
|
@@ -232,7 +232,7 @@ npx workflow inspect runs
|
|
|
232
232
|
|
|
233
233
|
## Deploying to production
|
|
234
234
|
|
|
235
|
-
Workflow SDK apps currently work best when deployed to [Vercel](https://vercel.com/home) and
|
|
235
|
+
Workflow SDK apps currently work best when deployed to [Vercel](https://vercel.com/home) and need no special configuration.
|
|
236
236
|
|
|
237
237
|
<FluidComputeCallout />
|
|
238
238
|
|
|
@@ -244,7 +244,7 @@ Check the [Deploying](/docs/deploying) section to learn how your workflows can b
|
|
|
244
244
|
|
|
245
245
|
If you see this error:
|
|
246
246
|
|
|
247
|
-
```
|
|
247
|
+
```text
|
|
248
248
|
'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.
|
|
249
249
|
```
|
|
250
250
|
|
|
@@ -255,7 +255,7 @@ Check both of these first:
|
|
|
255
255
|
|
|
256
256
|
See [start-invalid-workflow-function](/docs/errors/start-invalid-workflow-function) for full examples and fixes.
|
|
257
257
|
|
|
258
|
-
## Next
|
|
258
|
+
## Next steps
|
|
259
259
|
|
|
260
260
|
* Learn more about the [Foundations](/docs/foundations).
|
|
261
261
|
* Check [Errors](/docs/errors) if you encounter issues.
|
|
@@ -13,14 +13,14 @@ related:
|
|
|
13
13
|
text="In this TanStack Start app, run `npm i workflow`. In `vite.config.ts`, import `workflow` from `workflow/vite` and add `workflow()` first in the existing `plugins` array before `tanstackStart()`, `nitro()`, or other plugins. Add `{ "name": "workflow" }` to `compilerOptions.plugins` in `tsconfig.json` if TypeScript is used. Create `src/workflows/user-signup.ts` with `handleUserSignup(email)`, `"use workflow"`, `sleep`, and `"use step"` helpers. Add `src/routes/api/signup.ts` using `createFileRoute("/api/signup")`, a POST server handler, `start` from `workflow/api`, and `json` from `@tanstack/react-start`. Run `npm run dev`, call `curl -X POST --json '{"email":"hello@example.com"}' http://localhost:3000/api/signup`, and inspect with `npx workflow web` or `npx workflow inspect runs`."
|
|
14
14
|
/>
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Set up your first durable workflow in a TanStack Start app and learn the core Workflow SDK concepts.
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
20
|
<Steps>
|
|
21
21
|
|
|
22
22
|
<Step>
|
|
23
|
-
## Create
|
|
23
|
+
## Create your TanStack Start project
|
|
24
24
|
|
|
25
25
|
Start by creating a new TanStack Start project:
|
|
26
26
|
|
|
@@ -42,7 +42,7 @@ npm i workflow
|
|
|
42
42
|
|
|
43
43
|
### Configure TanStack Start
|
|
44
44
|
|
|
45
|
-
TanStack Start runs on Vite, so the Workflow SDK is wired in via the same `workflow/vite` plugin. Add `workflow()` to the existing `plugins` array in your Vite config
|
|
45
|
+
TanStack Start runs on Vite, so the Workflow SDK is wired in via the same `workflow/vite` plugin. Add `workflow()` to the existing `plugins` array in your Vite config. List it first so the `"use workflow"` and `"use step"` transforms run before any other plugin processes the file.
|
|
46
46
|
|
|
47
47
|
```typescript title="vite.config.ts" lineNumbers
|
|
48
48
|
import { defineConfig } from "vite";
|
|
@@ -60,11 +60,11 @@ export default defineConfig({
|
|
|
60
60
|
<Accordion type="single" collapsible>
|
|
61
61
|
<AccordionItem value="typescript-intellisense" className="[&_h3]:my-0">
|
|
62
62
|
<AccordionTrigger className="text-sm">
|
|
63
|
-
###
|
|
63
|
+
### Set up IntelliSense for TypeScript (optional)
|
|
64
64
|
</AccordionTrigger>
|
|
65
65
|
<AccordionContent className="[&_p]:my-2">
|
|
66
66
|
|
|
67
|
-
To enable helpful hints in your IDE,
|
|
67
|
+
To enable helpful hints in your IDE, set up the workflow plugin in `tsconfig.json`:
|
|
68
68
|
|
|
69
69
|
```json title="tsconfig.json" lineNumbers
|
|
70
70
|
{
|
|
@@ -87,7 +87,7 @@ To enable helpful hints in your IDE, setup the workflow plugin in `tsconfig.json
|
|
|
87
87
|
|
|
88
88
|
<Step>
|
|
89
89
|
|
|
90
|
-
## Create
|
|
90
|
+
## Create your first workflow
|
|
91
91
|
|
|
92
92
|
Create a new file for our first workflow:
|
|
93
93
|
|
|
@@ -107,14 +107,14 @@ export async function handleUserSignup(email: string) {
|
|
|
107
107
|
}
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
We'll fill in those functions next, but
|
|
110
|
+
We'll fill in those functions next, but first review this code:
|
|
111
111
|
|
|
112
112
|
* We define a **workflow** function with the directive `"use workflow"`. Think of the workflow function as the _orchestrator_ of individual **steps**.
|
|
113
113
|
* The Workflow SDK's `sleep` function allows us to suspend execution of the workflow without using up any resources. A sleep can be a few seconds, hours, days, or even months long.
|
|
114
114
|
|
|
115
|
-
## Create
|
|
115
|
+
## Create your workflow steps
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
Define the missing functions.
|
|
118
118
|
|
|
119
119
|
```typescript title="src/workflows/user-signup.ts" lineNumbers
|
|
120
120
|
import { FatalError } from "workflow"
|
|
@@ -167,7 +167,7 @@ We'll dive deeper into workflows, steps, and other ways to suspend or handle eve
|
|
|
167
167
|
|
|
168
168
|
<Step>
|
|
169
169
|
|
|
170
|
-
## Create
|
|
170
|
+
## Create your route handler
|
|
171
171
|
|
|
172
172
|
To invoke your new workflow, add a server handler at `src/routes/api/signup.ts`:
|
|
173
173
|
|
|
@@ -232,13 +232,13 @@ npx workflow inspect runs
|
|
|
232
232
|
|
|
233
233
|
## Deploying to production
|
|
234
234
|
|
|
235
|
-
Workflow SDK apps currently work best when deployed to [Vercel](https://vercel.com/home) and
|
|
235
|
+
Workflow SDK apps currently work best when deployed to [Vercel](https://vercel.com/home) and need no special configuration.
|
|
236
236
|
|
|
237
237
|
<FluidComputeCallout />
|
|
238
238
|
|
|
239
239
|
Check the [Deploying](/docs/deploying) section to learn how your workflows can be deployed elsewhere.
|
|
240
240
|
|
|
241
|
-
## Next
|
|
241
|
+
## Next steps
|
|
242
242
|
|
|
243
243
|
* Learn more about the [Foundations](/docs/foundations).
|
|
244
244
|
* Check [Errors](/docs/errors) if you encounter issues.
|
|
@@ -20,7 +20,7 @@ This guide will walk through setting up your first workflow in a Vite app. Along
|
|
|
20
20
|
<Steps>
|
|
21
21
|
|
|
22
22
|
<Step>
|
|
23
|
-
## Create
|
|
23
|
+
## Create your Vite project
|
|
24
24
|
|
|
25
25
|
Start by creating a new Vite project. This command will create a new directory named `my-workflow-app` with a minimal setup and setup a Vite project inside it.
|
|
26
26
|
|
|
@@ -91,7 +91,7 @@ To enable helpful hints in your IDE, setup the workflow plugin in `tsconfig.json
|
|
|
91
91
|
|
|
92
92
|
<Step>
|
|
93
93
|
|
|
94
|
-
## Create
|
|
94
|
+
## Create your first workflow
|
|
95
95
|
|
|
96
96
|
Create a new file for our first workflow:
|
|
97
97
|
|
|
@@ -112,14 +112,14 @@ export async function handleUserSignup(email: string) {
|
|
|
112
112
|
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
We'll fill in those functions next
|
|
115
|
+
We'll fill in those functions next. The current code does the following:
|
|
116
116
|
|
|
117
117
|
* We define a **workflow** function with the directive `"use workflow"`. Think of the workflow function as the _orchestrator_ of individual **steps**.
|
|
118
118
|
* The Workflow SDK's `sleep` function allows us to suspend execution of the workflow without using up any resources. A sleep can be a few seconds, hours, days, or even months long.
|
|
119
119
|
|
|
120
|
-
## Create
|
|
120
|
+
## Create your workflow steps
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
Define the missing functions.
|
|
123
123
|
|
|
124
124
|
```typescript title="workflows/user-signup.ts" lineNumbers
|
|
125
125
|
import { FatalError } from "workflow"
|
|
@@ -172,7 +172,7 @@ We'll dive deeper into workflows, steps, and other ways to suspend or handle eve
|
|
|
172
172
|
|
|
173
173
|
<Step>
|
|
174
174
|
|
|
175
|
-
## Create
|
|
175
|
+
## Create your route handler
|
|
176
176
|
|
|
177
177
|
To invoke your new workflow, we'll have to add your workflow to a `POST` API route handler, `api/signup.post.ts` with the following code:
|
|
178
178
|
|
|
@@ -244,7 +244,7 @@ Check the [Deploying](/docs/deploying) section to learn how your workflows can b
|
|
|
244
244
|
|
|
245
245
|
If you see this error:
|
|
246
246
|
|
|
247
|
-
```
|
|
247
|
+
```text
|
|
248
248
|
'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.
|
|
249
249
|
```
|
|
250
250
|
|
|
@@ -255,7 +255,7 @@ Check both of these first:
|
|
|
255
255
|
|
|
256
256
|
See [start-invalid-workflow-function](/docs/errors/start-invalid-workflow-function) for full examples and fixes.
|
|
257
257
|
|
|
258
|
-
## Next
|
|
258
|
+
## Next steps
|
|
259
259
|
|
|
260
260
|
* Learn more about the [Foundations](/docs/foundations).
|
|
261
261
|
* Check [Errors](/docs/errors) if you encounter issues.
|