workflow 5.0.0-beta.9 → 5.0.0
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 +68 -23
- package/dist/api-workflow.d.ts +3 -1
- package/dist/api-workflow.d.ts.map +1 -1
- package/dist/api-workflow.js +2 -1
- package/dist/api.d.ts +5 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +6 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/internal/builtins.d.ts +4 -4
- package/dist/internal/builtins.js +6 -6
- package/dist/internal/errors.d.ts +1 -1
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/errors.js +2 -2
- package/dist/nest-builder.d.ts +2 -0
- package/dist/nest-builder.d.ts.map +1 -0
- package/dist/nest-builder.js +2 -0
- package/dist/nest-vercel-builder.d.ts +2 -0
- package/dist/nest-vercel-builder.d.ts.map +1 -0
- package/dist/nest-vercel-builder.js +2 -0
- package/dist/runtime.d.ts +2 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +4 -1
- package/docs/advanced/dynamic-workflows.mdx +224 -0
- package/docs/ai/chat-session-modeling.mdx +176 -422
- package/docs/ai/defining-tools.mdx +6 -7
- package/docs/ai/human-in-the-loop.mdx +11 -11
- package/docs/ai/index.mdx +67 -72
- package/docs/ai/message-queueing.mdx +71 -110
- package/docs/ai/meta.json +1 -0
- package/docs/ai/resumable-streams.mdx +40 -28
- package/docs/ai/sleep-and-delays.mdx +10 -10
- package/docs/ai/streaming-updates-from-tools.mdx +6 -6
- package/docs/api-reference/index.mdx +25 -1
- package/docs/api-reference/meta.json +8 -0
- package/docs/api-reference/vitest/index.mdx +68 -15
- package/docs/api-reference/workflow/create-hook.mdx +166 -10
- package/docs/api-reference/workflow/create-webhook.mdx +16 -15
- package/docs/api-reference/workflow/define-hook.mdx +37 -33
- package/docs/api-reference/workflow/fatal-error.mdx +30 -8
- package/docs/api-reference/workflow/fetch.mdx +14 -10
- 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 +3 -3
- package/docs/api-reference/workflow/retryable-error.mdx +1 -1
- package/docs/api-reference/workflow/set-attributes.mdx +63 -0
- package/docs/api-reference/workflow/sleep.mdx +4 -4
- package/docs/api-reference/workflow-ai/durable-agent.mdx +63 -101
- package/docs/api-reference/workflow-ai/index.mdx +5 -5
- package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +67 -24
- package/docs/api-reference/workflow-api/get-hook-by-token.mdx +28 -12
- package/docs/api-reference/workflow-api/get-run.mdx +43 -8
- package/docs/api-reference/workflow-api/index.mdx +8 -9
- package/docs/api-reference/workflow-api/register-lifecycle-hooks.mdx +87 -0
- package/docs/api-reference/workflow-api/resume-hook.mdx +73 -12
- package/docs/api-reference/workflow-api/resume-webhook.mdx +11 -9
- package/docs/api-reference/workflow-api/start.mdx +107 -12
- package/docs/api-reference/workflow-astro/index.mdx +18 -0
- package/docs/api-reference/workflow-astro/meta.json +4 -0
- package/docs/api-reference/workflow-astro/workflow.mdx +45 -0
- package/docs/api-reference/workflow-errors/entity-conflict-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
- package/docs/api-reference/workflow-errors/hook-force-claimed-error.mdx +70 -0
- package/docs/api-reference/workflow-errors/hook-not-found-error.mdx +8 -8
- package/docs/api-reference/workflow-errors/index.mdx +91 -0
- package/docs/api-reference/workflow-errors/meta.json +7 -0
- package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +68 -0
- package/docs/api-reference/workflow-errors/run-expired-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
- 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 +52 -0
- package/docs/api-reference/workflow-errors/workflow-not-registered-error.mdx +5 -6
- package/docs/api-reference/workflow-errors/workflow-run-cancelled-error.mdx +13 -6
- package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +12 -5
- package/docs/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
- package/docs/api-reference/workflow-errors/workflow-run-not-found-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
- package/docs/api-reference/workflow-errors/workflow-world-error.mdx +8 -8
- package/docs/api-reference/workflow-globals.mdx +15 -11
- package/docs/api-reference/workflow-nest/configure-workflow-controller.mdx +37 -0
- package/docs/api-reference/workflow-nest/index.mdx +31 -0
- package/docs/api-reference/workflow-nest/meta.json +9 -0
- package/docs/api-reference/workflow-nest/nest-local-builder.mdx +64 -0
- package/docs/api-reference/workflow-nest/workflow-controller.mdx +46 -0
- package/docs/api-reference/workflow-nest/workflow-module.mdx +134 -0
- package/docs/api-reference/workflow-next/with-workflow.mdx +39 -17
- package/docs/api-reference/workflow-nitro/index.mdx +60 -0
- package/docs/api-reference/workflow-nuxt/index.mdx +48 -0
- package/docs/api-reference/workflow-observability/hydrate-data.mdx +35 -0
- package/docs/api-reference/workflow-observability/hydrate-resource-io.mdx +62 -0
- package/docs/api-reference/workflow-observability/index.mdx +62 -0
- package/docs/api-reference/workflow-observability/meta.json +11 -0
- package/docs/api-reference/workflow-observability/observability-revivers.mdx +50 -0
- package/docs/api-reference/workflow-observability/parse-class-name.mdx +41 -0
- package/docs/api-reference/workflow-observability/parse-step-name.mdx +40 -0
- package/docs/api-reference/workflow-observability/parse-workflow-name.mdx +55 -0
- package/docs/api-reference/workflow-runtime/create-world.mdx +39 -0
- package/docs/api-reference/workflow-runtime/get-world-handlers.mdx +44 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/get-world.mdx +11 -14
- package/docs/api-reference/workflow-runtime/health-check.mdx +51 -0
- package/docs/api-reference/workflow-runtime/index.mdx +41 -0
- package/docs/api-reference/workflow-runtime/meta.json +12 -0
- package/docs/api-reference/workflow-runtime/set-world.mdx +51 -0
- package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +43 -0
- package/docs/api-reference/workflow-runtime/world/analytics.mdx +315 -0
- package/docs/api-reference/workflow-runtime/world/index.mdx +60 -0
- package/docs/api-reference/workflow-runtime/world/meta.json +4 -0
- package/docs/api-reference/workflow-runtime/world/queue.mdx +88 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/storage.mdx +104 -35
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/streams.mdx +8 -8
- package/docs/api-reference/workflow-serde/index.mdx +1 -2
- package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +3 -4
- package/docs/api-reference/workflow-serde/workflow-serialize.mdx +8 -8
- package/docs/api-reference/workflow-sveltekit/index.mdx +18 -0
- package/docs/api-reference/workflow-sveltekit/meta.json +4 -0
- package/docs/api-reference/workflow-sveltekit/workflow-plugin.mdx +42 -0
- package/docs/api-reference/workflow-vite/index.mdx +18 -0
- package/docs/api-reference/workflow-vite/meta.json +4 -0
- package/docs/api-reference/workflow-vite/workflow.mdx +48 -0
- package/docs/changelog/attributes-mvp.mdx +53 -41
- package/docs/changelog/batched-event-writes.mdx +79 -0
- package/docs/changelog/eager-processing.mdx +110 -436
- package/docs/changelog/index.mdx +4 -2
- package/docs/changelog/lazy-event-creation.md +127 -0
- package/docs/changelog/lazy-hook-resume.mdx +78 -0
- package/docs/changelog/meta.json +11 -1
- package/docs/changelog/resilient-resume.mdx +32 -0
- package/docs/changelog/resilient-start.mdx +33 -285
- package/docs/changelog/step-message-ownership.mdx +360 -0
- package/docs/changelog/turbo-mode.md +87 -0
- package/docs/comparisons/index.mdx +66 -0
- package/docs/comparisons/meta.json +11 -0
- package/docs/comparisons/workflow-sdk-vs-aws-agentcore.mdx +55 -0
- package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +111 -0
- package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +71 -0
- package/docs/comparisons/workflow-sdk-vs-inngest.mdx +102 -0
- package/docs/comparisons/workflow-sdk-vs-temporal.mdx +123 -0
- package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +104 -0
- package/docs/configuration/build-and-diagnostics.mdx +79 -0
- package/docs/configuration/cli-and-web-ui.mdx +241 -0
- package/docs/configuration/framework-options.mdx +165 -0
- package/docs/configuration/index.mdx +32 -0
- package/docs/configuration/meta.json +12 -0
- package/docs/configuration/runtime-tuning.mdx +399 -0
- package/docs/configuration/worlds.mdx +315 -0
- package/docs/cookbook/advanced/child-workflows.mdx +33 -25
- package/docs/cookbook/advanced/publishing-libraries.mdx +65 -56
- package/docs/cookbook/advanced/serializable-steps.mdx +48 -68
- package/docs/cookbook/advanced/upgrading-workflows.mdx +35 -31
- package/docs/cookbook/agent-patterns/agent-cancellation.mdx +78 -60
- package/docs/cookbook/agent-patterns/durable-agent.mdx +23 -135
- package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +180 -195
- package/docs/cookbook/common-patterns/batching.mdx +20 -14
- package/docs/cookbook/common-patterns/idempotency.mdx +41 -53
- package/docs/cookbook/common-patterns/rate-limiting.mdx +8 -4
- package/docs/cookbook/common-patterns/saga.mdx +23 -19
- package/docs/cookbook/common-patterns/scheduling.mdx +30 -22
- package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +29 -25
- package/docs/cookbook/common-patterns/timeouts.mdx +26 -21
- package/docs/cookbook/common-patterns/webhooks.mdx +10 -6
- package/docs/cookbook/common-patterns/workflow-composition.mdx +27 -17
- package/docs/cookbook/index.mdx +22 -22
- package/docs/cookbook/integrations/ai-sdk.mdx +63 -48
- package/docs/cookbook/integrations/chat-sdk.mdx +46 -33
- package/docs/cookbook/integrations/sandbox.mdx +58 -45
- package/docs/deploying.mdx +106 -0
- package/docs/errors/abort-signal-timeout-in-workflow.mdx +16 -12
- package/docs/errors/corrupted-event-log.mdx +39 -18
- package/docs/errors/deployment-mismatch.mdx +71 -0
- package/docs/errors/fetch-in-workflow.mdx +15 -14
- package/docs/errors/hook-conflict.mdx +38 -11
- package/docs/errors/hook-force-claimed.mdx +96 -0
- package/docs/errors/index.mdx +24 -37
- package/docs/errors/node-js-module-in-workflow.mdx +9 -5
- package/docs/errors/replay-divergence.mdx +27 -0
- package/docs/errors/run-expired.mdx +85 -0
- package/docs/errors/runtime-decryption-failed.mdx +77 -0
- package/docs/errors/serialization-failed.mdx +44 -12
- package/docs/errors/start-invalid-workflow-function.mdx +9 -5
- package/docs/errors/step-executed-multiple-times.mdx +23 -0
- package/docs/errors/step-not-registered.mdx +6 -6
- package/docs/errors/timeout-in-workflow.mdx +12 -8
- package/docs/errors/webhook-invalid-respond-with-value.mdx +18 -18
- package/docs/errors/webhook-response-not-sent.mdx +20 -16
- package/docs/errors/workflow-not-registered.mdx +5 -5
- package/docs/foundations/cancellation.mdx +31 -32
- package/docs/foundations/errors-and-retries.mdx +54 -11
- package/docs/foundations/hooks.mdx +98 -35
- package/docs/foundations/idempotency.mdx +267 -12
- package/docs/foundations/index.mdx +1 -26
- package/docs/foundations/serialization.mdx +22 -22
- package/docs/foundations/starting-workflows.mdx +104 -30
- package/docs/foundations/streaming.mdx +108 -60
- package/docs/foundations/versioning.mdx +4 -4
- package/docs/foundations/workflows-and-steps.mdx +9 -9
- package/docs/getting-started/astro.mdx +22 -18
- package/docs/getting-started/express.mdx +15 -11
- package/docs/getting-started/fastify.mdx +15 -11
- package/docs/getting-started/hono.mdx +15 -11
- package/docs/getting-started/index.mdx +10 -3
- package/docs/getting-started/meta.json +3 -1
- package/docs/getting-started/nestjs.mdx +264 -21
- package/docs/getting-started/next.mdx +18 -14
- package/docs/getting-started/nitro.mdx +22 -18
- package/docs/getting-started/nuxt.mdx +15 -11
- package/docs/getting-started/python.mdx +190 -41
- package/docs/getting-started/react-router/index.mdx +33 -0
- package/docs/getting-started/react-router/meta.json +5 -0
- package/docs/getting-started/react-router/v7.mdx +237 -0
- package/docs/getting-started/react-router/v8.mdx +232 -0
- package/docs/getting-started/sveltekit.mdx +20 -16
- package/docs/getting-started/tanstack-start.mdx +17 -13
- package/docs/getting-started/vite.mdx +15 -11
- package/docs/how-it-works/cancellation.mdx +63 -63
- package/docs/how-it-works/code-transform.mdx +82 -66
- package/docs/how-it-works/encryption.mdx +30 -26
- package/docs/how-it-works/event-sourcing.mdx +132 -35
- package/docs/how-it-works/framework-integrations.mdx +96 -337
- package/docs/how-it-works/understanding-directives.mdx +22 -22
- package/docs/internal/index.mdx +6 -4
- package/docs/internal/meta.json +6 -1
- package/docs/internal/nitro-native-build.mdx +38 -0
- package/docs/internal/nitro-web-ui.mdx +24 -0
- package/docs/internal/serializable-abort-controller.mdx +7 -7
- package/docs/meta.json +4 -2
- package/docs/observability/attributes.mdx +91 -21
- package/docs/observability/index.mdx +29 -15
- package/docs/observability/lifecycle-hooks.mdx +95 -0
- package/docs/observability/meta.json +1 -1
- package/docs/observability/retention.mdx +95 -0
- package/docs/observability/tracing.mdx +124 -0
- package/docs/testing/index.mdx +120 -38
- package/docs/testing/server-based.mdx +10 -10
- package/docs/whats-new.mdx +190 -0
- package/docs/worlds/building-a-world.mdx +538 -0
- package/docs/worlds/local.mdx +129 -0
- package/docs/worlds/meta.json +10 -0
- package/docs/worlds/postgres.mdx +424 -0
- package/docs/worlds/upgrading-to-v5.mdx +162 -0
- package/docs/worlds/vercel.mdx +345 -0
- package/package.json +17 -14
- package/docs/api-reference/workflow/experimental-set-attributes.mdx +0 -63
- package/docs/api-reference/workflow-api/world/index.mdx +0 -58
- package/docs/api-reference/workflow-api/world/meta.json +0 -4
- package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
- package/docs/api-reference/workflow-api/world/queue.mdx +0 -86
- package/docs/deploying/building-a-world.mdx +0 -251
- package/docs/deploying/index.mdx +0 -95
- package/docs/deploying/meta.json +0 -4
- package/docs/deploying/world/local-world.mdx +0 -84
- package/docs/deploying/world/meta.json +0 -4
- package/docs/deploying/world/postgres-world.mdx +0 -224
- package/docs/deploying/world/vercel-world.mdx +0 -181
- package/docs/migration-guides/index.mdx +0 -34
- package/docs/migration-guides/meta.json +0 -9
- package/docs/migration-guides/migrating-from-aws-step-functions.mdx +0 -358
- package/docs/migration-guides/migrating-from-inngest.mdx +0 -304
- package/docs/migration-guides/migrating-from-temporal.mdx +0 -313
- package/docs/migration-guides/migrating-from-trigger-dev.mdx +0 -328
|
@@ -4,11 +4,11 @@ description: Query workflow runs, steps, hooks, and the underlying event log via
|
|
|
4
4
|
type: reference
|
|
5
5
|
summary: "Interfaces: world.events, world.runs, world.steps, world.hooks. Events are the source of truth; runs, steps, and hooks are materialized views."
|
|
6
6
|
prerequisites:
|
|
7
|
-
- /docs/api-reference/workflow-
|
|
7
|
+
- /docs/api-reference/workflow-runtime/get-world
|
|
8
8
|
related:
|
|
9
9
|
- /docs/api-reference/workflow-api/get-run
|
|
10
10
|
- /docs/how-it-works/event-sourcing
|
|
11
|
-
- /docs/api-reference/workflow-
|
|
11
|
+
- /docs/api-reference/workflow-observability
|
|
12
12
|
keywords:
|
|
13
13
|
- world.events
|
|
14
14
|
- world.runs
|
|
@@ -23,6 +23,7 @@ keywords:
|
|
|
23
23
|
- Event
|
|
24
24
|
- cursor pagination
|
|
25
25
|
- resolveData
|
|
26
|
+
- skip-step-inputs
|
|
26
27
|
- run_cancelled
|
|
27
28
|
- correlation ID
|
|
28
29
|
- parseStepName
|
|
@@ -31,8 +32,8 @@ keywords:
|
|
|
31
32
|
|
|
32
33
|
The World storage interface exposes four sub-interfaces for querying workflow data:
|
|
33
34
|
|
|
34
|
-
- **`world.events
|
|
35
|
-
- **`world.runs`**, **`world.steps`**, **`world.hooks
|
|
35
|
+
- **`world.events`**: The append-only event log. This is the source of truth for all workflow state. See [Event Sourcing](/docs/how-it-works/event-sourcing) for background.
|
|
36
|
+
- **`world.runs`**, **`world.steps`**, **`world.hooks`**: Materialized views derived from the event log, provided as convenience accessors for the most common query patterns.
|
|
36
37
|
|
|
37
38
|
```typescript lineNumbers
|
|
38
39
|
import { getWorld } from "workflow/runtime";
|
|
@@ -62,7 +63,7 @@ await world.events.create(runId, { // [!code highlight]
|
|
|
62
63
|
| `data` | `CreateEventRequest` | Event data including `eventType` |
|
|
63
64
|
| `params` | `object` | Optional parameters |
|
|
64
65
|
|
|
65
|
-
**Returns:** `EventResult
|
|
66
|
+
**Returns:** `EventResult`, the created event and the affected entity (run/step/hook)
|
|
66
67
|
|
|
67
68
|
### events.get()
|
|
68
69
|
|
|
@@ -81,7 +82,8 @@ const event = await world.events.get(runId, eventId); // [!code highlight]
|
|
|
81
82
|
|
|
82
83
|
### events.list()
|
|
83
84
|
|
|
84
|
-
List events for a run
|
|
85
|
+
List events for a run. Omit `pagination.limit` to return every remaining event,
|
|
86
|
+
or set it to return one bounded page.
|
|
85
87
|
|
|
86
88
|
```typescript lineNumbers
|
|
87
89
|
const result = await world.events.list({ runId, pagination: { cursor } }); // [!code highlight]
|
|
@@ -91,31 +93,39 @@ const result = await world.events.list({ runId, pagination: { cursor } }); // [!
|
|
|
91
93
|
|-----------|------|-------------|
|
|
92
94
|
| `params.runId` | `string` | Filter events by run ID |
|
|
93
95
|
| `params.pagination.cursor` | `string` | Cursor for the next page |
|
|
96
|
+
| `params.pagination.limit` | `number` | Maximum events to return. When omitted, returns every remaining event up to the World's event ceiling. |
|
|
97
|
+
| `params.pagination.sortOrder` | `"asc" \| "desc"` | Event order |
|
|
98
|
+
| `params.resolveData` | `"all" \| "none" \| "skip-step-inputs"` | Include or omit event payload data. `"skip-step-inputs"` is `"all"` without the `input` of `step_created` and `step_started` events, which replay does not read. |
|
|
94
99
|
|
|
95
|
-
**Returns:** `{ data: Event[], cursor
|
|
100
|
+
**Returns:** `{ data: Event[], cursor: string | null, hasMore: boolean }`
|
|
96
101
|
|
|
97
102
|
### events.listByCorrelationId()
|
|
98
103
|
|
|
99
|
-
List events that share a correlation ID, useful for tracing
|
|
104
|
+
List one run's events that share a correlation ID, useful for tracing a single step, hook or wait through its lifecycle.
|
|
105
|
+
|
|
106
|
+
A correlation ID is unique within its run, not across runs: two runs can each hold a `step_…`, `hook_…` or `wait_…` ID that reads the same. `runId` is therefore required, and it is also what makes the pagination cursor unambiguous.
|
|
100
107
|
|
|
101
108
|
```typescript lineNumbers
|
|
102
109
|
const result = await world.events.listByCorrelationId({ // [!code highlight]
|
|
110
|
+
runId,
|
|
103
111
|
correlationId: "order-123",
|
|
104
112
|
}); // [!code highlight]
|
|
105
113
|
```
|
|
106
114
|
|
|
107
115
|
| Parameter | Type | Description |
|
|
108
116
|
|-----------|------|-------------|
|
|
117
|
+
| `params.runId` | `string` | The run the correlation ID belongs to |
|
|
109
118
|
| `params.correlationId` | `string` | The correlation ID to filter by |
|
|
110
119
|
| `params.pagination.cursor` | `string` | Cursor for the next page |
|
|
111
120
|
|
|
112
121
|
**Returns:** `{ data: Event[], cursor?: string }`
|
|
113
122
|
|
|
114
|
-
### Event
|
|
123
|
+
### Event types
|
|
115
124
|
|
|
116
125
|
| Category | Types |
|
|
117
126
|
|----------|-------|
|
|
118
127
|
| Run | `run_created`, `run_started`, `run_completed`, `run_failed`, `run_cancelled` |
|
|
128
|
+
| Attribute | `attr_set` |
|
|
119
129
|
| Step | `step_created`, `step_started`, `step_completed`, `step_failed`, `step_retrying` |
|
|
120
130
|
| Hook | `hook_created`, `hook_received`, `hook_disposed`, `hook_conflict` |
|
|
121
131
|
| Wait | `wait_created`, `wait_completed` |
|
|
@@ -124,7 +134,10 @@ const result = await world.events.listByCorrelationId({ // [!code highlight]
|
|
|
124
134
|
|
|
125
135
|
## world.runs
|
|
126
136
|
|
|
127
|
-
Materialized from run events. Use it
|
|
137
|
+
Materialized from run events. Use it for canonical operational reads, including
|
|
138
|
+
reads that require workflow input or output data. For observability dashboards,
|
|
139
|
+
inspection tools, and historical listings, use
|
|
140
|
+
[`world.analytics.runs.list()`](/docs/api-reference/workflow-runtime/world/analytics#runslist).
|
|
128
141
|
|
|
129
142
|
### runs.get()
|
|
130
143
|
|
|
@@ -139,31 +152,78 @@ const run = await world.runs.get(runId); // [!code highlight]
|
|
|
139
152
|
|
|
140
153
|
**Returns:** `WorkflowRun` (or `WorkflowRunWithoutData` when `resolveData: 'none'`)
|
|
141
154
|
|
|
155
|
+
### runs.waitForTerminalStatus()
|
|
156
|
+
|
|
157
|
+
Optional. Long poll for a run to reach a terminal status (`completed`,
|
|
158
|
+
`failed`, or `cancelled`) instead of re-reading it on an interval. This is what
|
|
159
|
+
`await run.returnValue` uses, so a run's result reaches the awaiting side as
|
|
160
|
+
soon as it finishes rather than at the next poll tick.
|
|
161
|
+
|
|
162
|
+
```typescript lineNumbers
|
|
163
|
+
const run = await world.runs.waitForTerminalStatus?.(runId, { // [!code highlight]
|
|
164
|
+
timeoutMs: 25_000, // [!code highlight]
|
|
165
|
+
}); // [!code highlight]
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
| Parameter | Type | Description |
|
|
169
|
+
|-----------|------|-------------|
|
|
170
|
+
| `runId` | `string` | The workflow run ID |
|
|
171
|
+
| `params.timeoutMs` | `number` | Upper bound on the wait. The call returns earlier, the moment the run is terminal |
|
|
172
|
+
| `params.signal` | `AbortSignal` | Abandons the wait |
|
|
173
|
+
| `params.resolveData` | `'all' \| 'none'` | Whether to include input/output data. Default: `'all'` |
|
|
174
|
+
|
|
175
|
+
**Returns:** the same `WorkflowRun` as `runs.get()`: terminal if the run
|
|
176
|
+
finished within the budget, otherwise the latest snapshot. An expired budget is
|
|
177
|
+
a normal return, not an error, and a missing run throws
|
|
178
|
+
`WorkflowRunNotFoundError` exactly as `runs.get()` does.
|
|
179
|
+
|
|
180
|
+
<Callout>
|
|
181
|
+
Not every backend can hold a read open, so this method is optional and may
|
|
182
|
+
also return a non-terminal snapshot before `timeoutMs` is up. Callers pace
|
|
183
|
+
their own retries (`await run.returnValue` keeps consecutive non-terminal
|
|
184
|
+
observations at least one `WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS` apart), and
|
|
185
|
+
worlds that omit the method are polled on that interval instead. Set
|
|
186
|
+
`WORKFLOW_RETURN_VALUE_LONG_POLL=0` to force interval polling everywhere.
|
|
187
|
+
</Callout>
|
|
188
|
+
|
|
142
189
|
### runs.list()
|
|
143
190
|
|
|
144
191
|
```typescript lineNumbers
|
|
145
192
|
const result = await world.runs.list({ // [!code highlight]
|
|
193
|
+
status: "running", // [!code highlight]
|
|
146
194
|
pagination: { cursor },
|
|
147
195
|
}); // [!code highlight]
|
|
148
196
|
```
|
|
149
197
|
|
|
150
198
|
| Parameter | Type | Description |
|
|
151
199
|
|-----------|------|-------------|
|
|
200
|
+
| `params.workflowName` | `string` | Only return runs of this workflow |
|
|
201
|
+
| `params.status` | `WorkflowRunStatus \| WorkflowRunStatus[]` | Only return runs in this status. Pass an array to match any of the listed statuses; an empty array matches no runs. `@workflow/world-vercel` accepts a single status only and throws `WorkflowWorldError` (`INVALID_ARGUMENT`) for an array |
|
|
152
202
|
| `params.pagination.cursor` | `string` | Cursor for the next page |
|
|
153
203
|
| `params.resolveData` | `'all' \| 'none'` | Whether to include input/output data |
|
|
154
204
|
|
|
155
205
|
**Returns:** `{ data: WorkflowRun[], cursor?: string }`
|
|
156
206
|
|
|
157
|
-
|
|
207
|
+
<Callout type="warn">
|
|
208
|
+
Observability and inspection usage of `world.runs.list()` is deprecated. Use
|
|
209
|
+
[`world.analytics.runs.list()`](/docs/api-reference/workflow-runtime/world/analytics#runslist)
|
|
210
|
+
for metadata-only, plan-aware queries backed by the observability pipeline.
|
|
211
|
+
`world.runs.list()` remains supported for operational and payload-bearing
|
|
212
|
+
reads.
|
|
213
|
+
</Callout>
|
|
214
|
+
|
|
215
|
+
### Cancelling runs
|
|
158
216
|
|
|
159
|
-
To cancel a run, create a `run_cancelled` event
|
|
217
|
+
To cancel a run, create a `run_cancelled` event through `world.events.create()` (see [world.events](#worldevents) above), or use the Workflow CLI or web interface helpers.
|
|
160
218
|
|
|
161
|
-
|
|
219
|
+
To cancel a batch in one call, a world may implement the optional `runs.cancelMany({ runIds })`. It returns a summary plus a per-run outcome (`cancelled`, `already_cancelled`, `not_cancellable`, `not_found`, or `failed`). Backends that omit it fall back to per-run cancellation automatically.
|
|
220
|
+
|
|
221
|
+
### WorkflowRun type
|
|
162
222
|
|
|
163
223
|
| Field | Type | Description |
|
|
164
224
|
|-------|------|-------------|
|
|
165
225
|
| `runId` | `string` | Unique run identifier |
|
|
166
|
-
| `status` | `string` | `'running'`, `'completed'`, `'failed'`, `'cancelled'` |
|
|
226
|
+
| `status` | `string` | `'pending'`, `'running'`, `'completed'`, `'failed'`, `'cancelled'` |
|
|
167
227
|
| `workflowName` | `string` | Machine-readable workflow identifier |
|
|
168
228
|
| `input` | `any` | Workflow input data (when `resolveData: 'all'`) |
|
|
169
229
|
| `output` | `any` | Workflow output data (when `resolveData: 'all'`) |
|
|
@@ -189,7 +249,7 @@ const step = await world.steps.get(runId, stepId); // [!code highlight]
|
|
|
189
249
|
|
|
190
250
|
| Parameter | Type | Description |
|
|
191
251
|
|-----------|------|-------------|
|
|
192
|
-
| `runId` | `string
|
|
252
|
+
| `runId` | `string` | The workflow run ID that owns the step |
|
|
193
253
|
| `stepId` | `string` | The step ID |
|
|
194
254
|
| `params.resolveData` | `'all' \| 'none'` | Whether to include input/output data. Default: `'all'` |
|
|
195
255
|
|
|
@@ -212,7 +272,7 @@ const result = await world.steps.list({ // [!code highlight]
|
|
|
212
272
|
|
|
213
273
|
**Returns:** `{ data: Step[], cursor?: string }`
|
|
214
274
|
|
|
215
|
-
### Step
|
|
275
|
+
### Step type
|
|
216
276
|
|
|
217
277
|
| Field | Type | Description |
|
|
218
278
|
|-------|------|-------------|
|
|
@@ -229,11 +289,11 @@ const result = await world.steps.list({ // [!code highlight]
|
|
|
229
289
|
| `retryAfter` | `string \| null` | ISO timestamp for next retry attempt |
|
|
230
290
|
|
|
231
291
|
<Callout type="info">
|
|
232
|
-
Step I/O is serialized using the [devalue](https://github.com/Rich-Harris/devalue) format. Use `hydrateResourceIO()` from `workflow/observability` to deserialize it for display. See [
|
|
292
|
+
Step input/output (I/O) is serialized using the [devalue](https://github.com/Rich-Harris/devalue) format. Use `hydrateResourceIO()` from `workflow/observability` to deserialize it for display. See [`hydrateResourceIO()`](/docs/api-reference/workflow-observability/hydrate-resource-io).
|
|
233
293
|
</Callout>
|
|
234
294
|
|
|
235
295
|
<Callout type="warn">
|
|
236
|
-
`stepName` is a machine-readable identifier like `step//./src/workflows/order//processPayment`. Use `parseStepName()` from `workflow/observability` to extract the `shortName` for
|
|
296
|
+
`stepName` is a machine-readable identifier like `step//./src/workflows/order//processPayment`. Use `parseStepName()` from `workflow/observability` to extract the `shortName` for display in a user interface.
|
|
237
297
|
</Callout>
|
|
238
298
|
|
|
239
299
|
---
|
|
@@ -258,6 +318,12 @@ const hook = await world.hooks.get(hookId); // [!code highlight]
|
|
|
258
318
|
|
|
259
319
|
Look up a hook by its token. Useful in webhook resume flows where you receive a token in the callback URL.
|
|
260
320
|
|
|
321
|
+
<Callout type="info">
|
|
322
|
+
For runtime application code, prefer [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token). Use `world.hooks.getByToken()` when you are working directly with the World storage interface for custom tooling, admin views, or low-level integrations.
|
|
323
|
+
|
|
324
|
+
Hook-token lookup is the low-level form of the recommended idempotency flow: if a hook is already registered for your business key, reuse the hook's `runId` or resume that hook instead of starting another run. If no hook exists yet, start a workflow that creates the deterministic hook near the beginning and checks `await hook.getConflict()` to detect whether another run claimed the token first. On a conflict it resolves with the run that owns the token. See [Run idempotency](/docs/foundations/idempotency#run-idempotency).
|
|
325
|
+
</Callout>
|
|
326
|
+
|
|
261
327
|
```typescript lineNumbers
|
|
262
328
|
const hook = await world.hooks.getByToken(token); // [!code highlight]
|
|
263
329
|
```
|
|
@@ -282,7 +348,7 @@ const result = await world.hooks.list({ // [!code highlight]
|
|
|
282
348
|
|
|
283
349
|
**Returns:** `{ data: Hook[], cursor?: string }`
|
|
284
350
|
|
|
285
|
-
### Hook
|
|
351
|
+
### Hook type
|
|
286
352
|
|
|
287
353
|
| Field | Type | Description |
|
|
288
354
|
|-------|------|-------------|
|
|
@@ -294,12 +360,13 @@ const result = await world.hooks.list({ // [!code highlight]
|
|
|
294
360
|
| `environment` | `string` | Deployment environment |
|
|
295
361
|
| `metadata` | `object` | Custom metadata attached to the hook |
|
|
296
362
|
| `isWebhook` | `boolean` | Whether this is a webhook-style hook |
|
|
363
|
+
| `claimedFrom` | `{ runId: string; hookId: string } \| undefined` | Set when this hook took its token from another run with [`experimental_force`](/docs/api-reference/workflow/create-hook#take-over-a-token-another-run-holds). Names that run and its hook |
|
|
297
364
|
|
|
298
365
|
---
|
|
299
366
|
|
|
300
367
|
## Examples
|
|
301
368
|
|
|
302
|
-
### List
|
|
369
|
+
### List runs with pagination
|
|
303
370
|
|
|
304
371
|
```typescript lineNumbers
|
|
305
372
|
import { getWorld } from "workflow/runtime";
|
|
@@ -314,23 +381,23 @@ const runs = await world.runs.list({ // [!code highlight]
|
|
|
314
381
|
cursor = runs.cursor; // pass to next call for pagination
|
|
315
382
|
```
|
|
316
383
|
|
|
317
|
-
### Get a
|
|
384
|
+
### Get a run: full data vs. metadata only
|
|
318
385
|
|
|
319
386
|
```typescript lineNumbers
|
|
320
387
|
import { getWorld } from "workflow/runtime";
|
|
321
388
|
|
|
322
389
|
const world = await getWorld();
|
|
323
390
|
|
|
324
|
-
// Full data (default)
|
|
391
|
+
// Full data (default): includes serialized input/output
|
|
325
392
|
const run = await world.runs.get(runId); // [!code highlight]
|
|
326
393
|
|
|
327
|
-
// Metadata only
|
|
394
|
+
// Metadata only: lighter, no I/O loaded
|
|
328
395
|
const lightweight = await world.runs.get(runId, { // [!code highlight]
|
|
329
396
|
resolveData: "none", // [!code highlight]
|
|
330
397
|
}); // [!code highlight]
|
|
331
398
|
```
|
|
332
399
|
|
|
333
|
-
### List
|
|
400
|
+
### List steps for a progress dashboard
|
|
334
401
|
|
|
335
402
|
```typescript lineNumbers
|
|
336
403
|
import { getWorld } from "workflow/runtime";
|
|
@@ -352,7 +419,7 @@ const progress = steps.data.map((step) => {
|
|
|
352
419
|
});
|
|
353
420
|
```
|
|
354
421
|
|
|
355
|
-
### Hydrate
|
|
422
|
+
### Hydrate step I/O
|
|
356
423
|
|
|
357
424
|
```typescript lineNumbers
|
|
358
425
|
import { getWorld } from "workflow/runtime";
|
|
@@ -364,7 +431,7 @@ const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highl
|
|
|
364
431
|
console.log(hydrated.input, hydrated.output);
|
|
365
432
|
```
|
|
366
433
|
|
|
367
|
-
### Cancel a
|
|
434
|
+
### Cancel a run
|
|
368
435
|
|
|
369
436
|
```typescript lineNumbers
|
|
370
437
|
import { getWorld } from "workflow/runtime";
|
|
@@ -375,17 +442,19 @@ await world.events.create(runId, { // [!code highlight]
|
|
|
375
442
|
}); // [!code highlight]
|
|
376
443
|
```
|
|
377
444
|
|
|
378
|
-
### Look
|
|
445
|
+
### Look up hook by token
|
|
379
446
|
|
|
380
447
|
```typescript lineNumbers
|
|
381
448
|
import { getWorld } from "workflow/runtime";
|
|
382
449
|
|
|
383
450
|
const world = await getWorld();
|
|
384
451
|
const hook = await world.hooks.getByToken(token); // [!code highlight]
|
|
385
|
-
console.log(hook.runId
|
|
452
|
+
console.log(hook.runId); // [!code highlight]
|
|
386
453
|
```
|
|
387
454
|
|
|
388
|
-
|
|
455
|
+
The World-level `Hook` carries `metadata` as the raw serialized (and, on encrypting Worlds, encrypted) value, not the object the workflow passed to `createHook()`. To read the decoded value, use [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token), whose `hook.metadata` is a Promise that hydrates it on first access.
|
|
456
|
+
|
|
457
|
+
### List events for audit trail
|
|
389
458
|
|
|
390
459
|
```typescript lineNumbers
|
|
391
460
|
import { getWorld } from "workflow/runtime";
|
|
@@ -400,9 +469,9 @@ for (const event of events.data) {
|
|
|
400
469
|
|
|
401
470
|
## Related
|
|
402
471
|
|
|
403
|
-
- [Event
|
|
404
|
-
- [getRun()](/docs/api-reference/workflow-api/get-run)
|
|
405
|
-
- [
|
|
406
|
-
- [resumeHook()](/docs/api-reference/workflow-api/resume-hook)
|
|
407
|
-
- [Hooks](/docs/foundations/hooks)
|
|
408
|
-
- [Workflows and
|
|
472
|
+
- [Event sourcing](/docs/how-it-works/event-sourcing): How the event log powers workflow replay and state
|
|
473
|
+
- [`getRun()`](/docs/api-reference/workflow-api/get-run): Higher-level API for working with individual runs
|
|
474
|
+
- [`workflow/observability`](/docs/api-reference/workflow-observability): Hydrate step I/O and parse display names
|
|
475
|
+
- [`resumeHook()`](/docs/api-reference/workflow-api/resume-hook): Resume a workflow by sending a payload to a hook
|
|
476
|
+
- [Hooks](/docs/foundations/hooks): Core concepts for hooks and pause points
|
|
477
|
+
- [Workflows and steps](/docs/foundations/workflows-and-steps): Core concepts for steps
|
|
@@ -4,7 +4,7 @@ description: Read, write, and manage real-time data streams for workflow runs.
|
|
|
4
4
|
type: reference
|
|
5
5
|
summary: "Methods: streams.write(), streams.writeMulti(), streams.get(), streams.close(), streams.list(), streams.getChunks(), streams.getInfo(). Stream methods live on world.streams."
|
|
6
6
|
prerequisites:
|
|
7
|
-
- /docs/api-reference/workflow-
|
|
7
|
+
- /docs/api-reference/workflow-runtime/get-world
|
|
8
8
|
related:
|
|
9
9
|
- /docs/foundations/streaming
|
|
10
10
|
- /docs/api-reference/workflow/get-writable
|
|
@@ -33,7 +33,7 @@ Stream methods live on `world.streams` (the `streams` sub-object of the `World`
|
|
|
33
33
|
import { getWorld } from "workflow/runtime";
|
|
34
34
|
|
|
35
35
|
const world = await getWorld(); // [!code highlight]
|
|
36
|
-
// Stream methods are called on world.streams
|
|
36
|
+
// Stream methods are called on world.streams, e.g. world.streams.write()
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
## Methods
|
|
@@ -56,7 +56,7 @@ await world.streams.write(runId, "default", chunk); // [!code highlight]
|
|
|
56
56
|
|
|
57
57
|
### writeMulti()
|
|
58
58
|
|
|
59
|
-
Write multiple chunks in a single operation. Optional optimization
|
|
59
|
+
Write multiple chunks in a single operation. Optional optimization: not all World implementations support it. Falls back to sequential `write()` calls if unavailable.
|
|
60
60
|
|
|
61
61
|
```typescript lineNumbers
|
|
62
62
|
await world.streams.writeMulti?.(runId, "default", [chunk1, chunk2]); // [!code highlight]
|
|
@@ -173,7 +173,7 @@ const info = await world.streams.getInfo(runId, "default"); // [!code highlight]
|
|
|
173
173
|
|
|
174
174
|
## Examples
|
|
175
175
|
|
|
176
|
-
### Read a
|
|
176
|
+
### Read a stream as a response
|
|
177
177
|
|
|
178
178
|
```typescript lineNumbers
|
|
179
179
|
// app/api/workflow-streams/read/route.ts
|
|
@@ -192,7 +192,7 @@ export async function GET(req: Request) {
|
|
|
192
192
|
}
|
|
193
193
|
```
|
|
194
194
|
|
|
195
|
-
### Paginate
|
|
195
|
+
### Paginate through stream chunks
|
|
196
196
|
|
|
197
197
|
```typescript lineNumbers
|
|
198
198
|
import { getWorld } from "workflow/runtime";
|
|
@@ -211,6 +211,6 @@ do {
|
|
|
211
211
|
|
|
212
212
|
## Related
|
|
213
213
|
|
|
214
|
-
- [Streaming](/docs/foundations/streaming)
|
|
215
|
-
- [getWritable()](/docs/api-reference/workflow/get-writable)
|
|
216
|
-
- [Storage](/docs/api-reference/workflow-
|
|
214
|
+
- [Streaming](/docs/foundations/streaming): Core concepts for streaming data from workflows
|
|
215
|
+
- [`getWritable()`](/docs/api-reference/workflow/get-writable): The standard way to write to streams from within steps
|
|
216
|
+
- [Storage](/docs/api-reference/workflow-runtime/world/storage): Query runs, steps, hooks, and events
|
|
@@ -27,9 +27,8 @@ The `@workflow/serde` package provides two symbols that allow you to define cust
|
|
|
27
27
|
</Card>
|
|
28
28
|
</Cards>
|
|
29
29
|
|
|
30
|
-
## Quick
|
|
30
|
+
## Quick example
|
|
31
31
|
|
|
32
|
-
{/* @expect-error:2351 */}
|
|
33
32
|
|
|
34
33
|
```typescript lineNumbers
|
|
35
34
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from "@workflow/serde";
|
|
@@ -6,7 +6,6 @@ A symbol used to define custom deserialization for user-defined class instances.
|
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
|
-
{/* @expect-error:2351 */}
|
|
10
9
|
|
|
11
10
|
```typescript lineNumbers
|
|
12
11
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from "@workflow/serde";
|
|
@@ -24,9 +23,9 @@ class Point {
|
|
|
24
23
|
}
|
|
25
24
|
```
|
|
26
25
|
|
|
27
|
-
## API
|
|
26
|
+
## API signature
|
|
28
27
|
|
|
29
|
-
{/* @skip-typecheck */}
|
|
28
|
+
{/* @skip-typecheck: type-only signature snippet, not compilable code */}
|
|
30
29
|
|
|
31
30
|
```typescript
|
|
32
31
|
static [WORKFLOW_DESERIALIZE](data: SerializableData): T
|
|
@@ -66,5 +65,5 @@ This method runs inside the workflow context and is subject to the same constrai
|
|
|
66
65
|
- No non-deterministic operations (like `Math.random()` or `Date.now()`)
|
|
67
66
|
- No external network calls
|
|
68
67
|
|
|
69
|
-
Keep this method
|
|
68
|
+
Keep this method focused on reconstructing the instance from the provided data.
|
|
70
69
|
</Callout>
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
title: WORKFLOW_SERIALIZE
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`WORKFLOW_SERIALIZE` defines custom serialization for user-defined class instances. The static method accepts an instance and returns serializable data.
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
|
-
{/* @expect-error:2351 */}
|
|
10
9
|
|
|
11
10
|
```typescript lineNumbers
|
|
12
11
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from "@workflow/serde";
|
|
@@ -24,9 +23,9 @@ class Point {
|
|
|
24
23
|
}
|
|
25
24
|
```
|
|
26
25
|
|
|
27
|
-
## API
|
|
26
|
+
## API signature
|
|
28
27
|
|
|
29
|
-
{/* @skip-typecheck */}
|
|
28
|
+
{/* @skip-typecheck: type-only signature snippet, not compilable code */}
|
|
30
29
|
|
|
31
30
|
```typescript
|
|
32
31
|
static [WORKFLOW_SERIALIZE](instance: T): SerializableData
|
|
@@ -61,15 +60,16 @@ The method should return serializable data. This can be:
|
|
|
61
60
|
The method must be implemented as a **static** method on the class. Instance methods are not supported.
|
|
62
61
|
</Callout>
|
|
63
62
|
|
|
64
|
-
- Both `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` must be implemented together
|
|
65
|
-
- The returned data must itself be serializable
|
|
66
|
-
- The SWC compiler plugin automatically detects and registers classes that implement these symbols
|
|
63
|
+
- Both `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` must be implemented together.
|
|
64
|
+
- The returned data must itself be serializable.
|
|
65
|
+
- The SWC compiler plugin automatically detects and registers classes that implement these symbols.
|
|
67
66
|
|
|
68
67
|
<Callout type="warn">
|
|
69
68
|
This method runs inside the workflow context and is subject to the same constraints as `"use workflow"` functions:
|
|
70
69
|
- No Node.js-specific APIs (like `fs`, `path`, `crypto`, etc.)
|
|
71
70
|
- No non-deterministic operations (like `Math.random()` or `Date.now()`)
|
|
72
71
|
- No external network calls
|
|
72
|
+
- No side effects on workflow state: the method may run outside deterministic replay, so mutations would not be reconstructed
|
|
73
73
|
|
|
74
|
-
Keep this method
|
|
74
|
+
Keep this method focused on extracting data from the instance.
|
|
75
75
|
</Callout>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "workflow/sveltekit"
|
|
3
|
+
description: SvelteKit integration for automatic workflow bundling via Vite.
|
|
4
|
+
type: overview
|
|
5
|
+
summary: Explore the SvelteKit integration for automatic workflow bundling and runtime support.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/getting-started/sveltekit
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
SvelteKit integration for Workflow SDK that configures Vite to transform workflow code and build the workflow bundles.
|
|
11
|
+
|
|
12
|
+
## Functions
|
|
13
|
+
|
|
14
|
+
<Cards>
|
|
15
|
+
<Card title="workflowPlugin()" href="/docs/api-reference/workflow-sveltekit/workflow-plugin">
|
|
16
|
+
Vite plugin that transforms workflow code (`"use step"`/`"use workflow"` directives) in SvelteKit apps
|
|
17
|
+
</Card>
|
|
18
|
+
</Cards>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: workflowPlugin
|
|
3
|
+
description: Configure Vite to transform workflow directives in SvelteKit.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Add workflowPlugin to your Vite config to enable workflow directive transformation in SvelteKit apps.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/getting-started/sveltekit
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Returns the Vite plugins that transform workflow code (`"use step"`/`"use workflow"` directives) and build the workflow bundles in a SvelteKit app.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
To enable `"use step"` and `"use workflow"` directives while developing locally or deploying to production, add `workflowPlugin()` to the `plugins` array of your Vite config.
|
|
15
|
+
|
|
16
|
+
```typescript title="vite.config.ts" lineNumbers
|
|
17
|
+
import { sveltekit } from "@sveltejs/kit/vite";
|
|
18
|
+
import { defineConfig } from "vite";
|
|
19
|
+
import { workflowPlugin } from "workflow/sveltekit"; // [!code highlight]
|
|
20
|
+
|
|
21
|
+
export default defineConfig({
|
|
22
|
+
plugins: [sveltekit(), workflowPlugin()], // [!code highlight]
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API signature
|
|
27
|
+
|
|
28
|
+
### Parameters
|
|
29
|
+
|
|
30
|
+
| Parameter | Type | Description |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| `options` | `WorkflowPluginOptions` | Optional. Configures the workflow build. |
|
|
33
|
+
|
|
34
|
+
#### WorkflowPluginOptions
|
|
35
|
+
|
|
36
|
+
| Option | Type | Default | Description |
|
|
37
|
+
| --- | --- | --- | --- |
|
|
38
|
+
| `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. |
|
|
39
|
+
|
|
40
|
+
### Returns
|
|
41
|
+
|
|
42
|
+
Returns an array of Vite `Plugin` objects. Spread or pass the array directly to the `plugins` option of your Vite config. Vite flattens nested plugin arrays automatically.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "workflow/vite"
|
|
3
|
+
description: Vite plugin for automatic workflow bundling in Vite + Nitro apps.
|
|
4
|
+
type: overview
|
|
5
|
+
summary: Explore the Vite plugin for automatic workflow bundling and runtime support.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/getting-started/vite
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Vite integration for Workflow SDK. It wraps the [`workflow/nitro`](/docs/api-reference/workflow-nitro) module as a Vite plugin, for apps using Nitro's Vite plugin (`nitro/vite`).
|
|
11
|
+
|
|
12
|
+
## Functions
|
|
13
|
+
|
|
14
|
+
<Cards>
|
|
15
|
+
<Card title="workflow()" href="/docs/api-reference/workflow-vite/workflow">
|
|
16
|
+
Vite plugin that transforms workflow code (`"use step"`/`"use workflow"` directives) and configures the Nitro server
|
|
17
|
+
</Card>
|
|
18
|
+
</Cards>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: workflow
|
|
3
|
+
description: Configure Vite and Nitro to transform workflow directives.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Add the workflow plugin to your Vite config to enable workflow directive transformation in Vite + Nitro apps.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/getting-started/vite
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Returns the Vite plugins that transform workflow code (`"use step"`/`"use workflow"` directives) and configure the [`workflow/nitro`](/docs/api-reference/workflow-nitro) module on the Nitro server. It is designed to be used alongside `nitro()` from `nitro/vite`, which provides the server framework for API routes and deployment.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
To enable `"use step"` and `"use workflow"` directives while developing locally or deploying to production, add `workflow()` to the `plugins` array of your Vite config, together with `nitro()`.
|
|
15
|
+
|
|
16
|
+
```typescript title="vite.config.ts" lineNumbers
|
|
17
|
+
import { nitro } from "nitro/vite";
|
|
18
|
+
import { defineConfig } from "vite";
|
|
19
|
+
import { workflow } from "workflow/vite"; // [!code highlight]
|
|
20
|
+
|
|
21
|
+
export default defineConfig({
|
|
22
|
+
plugins: [nitro(), workflow()], // [!code highlight]
|
|
23
|
+
nitro: {
|
|
24
|
+
serverDir: "./",
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## API signature
|
|
30
|
+
|
|
31
|
+
### Parameters
|
|
32
|
+
|
|
33
|
+
| Parameter | Type | Description |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
| `options` | `ModuleOptions` | Optional. Forwarded to the `workflow/nitro` module as its module options. |
|
|
36
|
+
|
|
37
|
+
#### ModuleOptions
|
|
38
|
+
|
|
39
|
+
| Option | Type | Default | Description |
|
|
40
|
+
| --- | --- | --- | --- |
|
|
41
|
+
| `dirs` | `string[]` | — | Directories to scan for workflows and steps. By default, the `workflows/` directory is scanned from the project root and all layer source directories. |
|
|
42
|
+
| `typescriptPlugin` | `boolean` | `false` | Adds the `workflow` TypeScript plugin to the generated `tsconfig.json` for integrated development environment (IDE) IntelliSense. |
|
|
43
|
+
| `runtime` | `string` | — | Node.js runtime version for Vercel Functions (for example, `'nodejs22.x'` or `'nodejs24.x'`). Only applies when deploying to Vercel. |
|
|
44
|
+
| `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. |
|
|
45
|
+
|
|
46
|
+
### Returns
|
|
47
|
+
|
|
48
|
+
Returns an array of Vite `Plugin` objects. Spread or pass the array directly to the `plugins` option of your Vite config. Vite flattens nested plugin arrays automatically.
|