workflow 4.3.1 → 4.5.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/docs/api-reference/index.mdx +24 -0
- package/docs/api-reference/meta.json +8 -0
- package/docs/api-reference/vitest/index.mdx +0 -6
- package/docs/api-reference/workflow/create-hook.mdx +32 -0
- package/docs/api-reference/workflow/create-webhook.mdx +1 -0
- package/docs/api-reference/workflow-api/index.mdx +6 -8
- package/docs/api-reference/workflow-errors/meta.json +5 -0
- package/docs/api-reference/workflow-serde/index.mdx +0 -1
- package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +1 -2
- package/docs/api-reference/workflow-serde/workflow-serialize.mdx +1 -2
- package/docs/deploying/building-a-world.mdx +1 -1
- package/docs/deploying/world/vercel-world.mdx +2 -0
- package/docs/errors/hook-conflict.mdx +56 -4
- package/docs/errors/index.mdx +6 -0
- package/docs/foundations/hooks.mdx +29 -0
- package/docs/foundations/streaming.mdx +7 -1
- package/docs/foundations/versioning.mdx +1 -1
- package/docs/how-it-works/encryption.mdx +2 -2
- package/docs/how-it-works/event-sourcing.mdx +2 -2
- package/docs/v4/api-reference/workflow-astro/index.mdx +18 -0
- package/docs/v4/api-reference/workflow-astro/meta.json +4 -0
- package/docs/v4/api-reference/workflow-astro/workflow.mdx +37 -0
- package/docs/v4/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
- package/docs/v4/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
- package/docs/v4/api-reference/workflow-errors/workflow-error.mdx +52 -0
- package/docs/v4/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
- package/docs/v4/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
- package/docs/v4/api-reference/workflow-nest/configure-workflow-controller.mdx +33 -0
- package/docs/v4/api-reference/workflow-nest/index.mdx +31 -0
- package/docs/v4/api-reference/workflow-nest/meta.json +9 -0
- package/docs/v4/api-reference/workflow-nest/nest-local-builder.mdx +63 -0
- package/docs/v4/api-reference/workflow-nest/workflow-controller.mdx +40 -0
- package/docs/v4/api-reference/workflow-nest/workflow-module.mdx +73 -0
- package/docs/v4/api-reference/workflow-nitro/index.mdx +57 -0
- package/docs/v4/api-reference/workflow-nuxt/index.mdx +47 -0
- package/docs/v4/api-reference/workflow-observability/hydrate-data.mdx +35 -0
- package/docs/v4/api-reference/workflow-observability/hydrate-resource-io.mdx +62 -0
- package/docs/v4/api-reference/workflow-observability/index.mdx +64 -0
- package/docs/v4/api-reference/workflow-observability/meta.json +11 -0
- package/docs/v4/api-reference/workflow-observability/observability-revivers.mdx +50 -0
- package/docs/v4/api-reference/workflow-observability/parse-class-name.mdx +41 -0
- package/docs/v4/api-reference/workflow-observability/parse-step-name.mdx +40 -0
- package/docs/v4/api-reference/workflow-observability/parse-workflow-name.mdx +55 -0
- package/docs/v4/api-reference/workflow-runtime/create-world.mdx +43 -0
- package/docs/v4/api-reference/workflow-runtime/get-world-handlers.mdx +44 -0
- package/docs/v4/api-reference/workflow-runtime/get-world.mdx +124 -0
- package/docs/v4/api-reference/workflow-runtime/health-check.mdx +50 -0
- package/docs/v4/api-reference/workflow-runtime/index.mdx +46 -0
- package/docs/v4/api-reference/workflow-runtime/meta.json +13 -0
- package/docs/v4/api-reference/workflow-runtime/set-world.mdx +49 -0
- package/docs/v4/api-reference/workflow-runtime/step-entrypoint.mdx +39 -0
- package/docs/v4/api-reference/workflow-runtime/workflow-entrypoint.mdx +42 -0
- package/docs/{api-reference/workflow-api → v4/api-reference/workflow-runtime}/world/index.mdx +5 -8
- package/docs/v4/api-reference/workflow-runtime/world/meta.json +4 -0
- package/docs/v4/api-reference/workflow-runtime/world/queue.mdx +86 -0
- package/docs/{api-reference/workflow-api → v4/api-reference/workflow-runtime}/world/storage.mdx +4 -4
- package/docs/v4/api-reference/workflow-runtime/world/streams.mdx +216 -0
- package/docs/v4/api-reference/workflow-sveltekit/index.mdx +18 -0
- package/docs/v4/api-reference/workflow-sveltekit/meta.json +4 -0
- package/docs/v4/api-reference/workflow-sveltekit/workflow-plugin.mdx +34 -0
- package/docs/v4/api-reference/workflow-vite/index.mdx +18 -0
- package/docs/v4/api-reference/workflow-vite/meta.json +4 -0
- package/docs/v4/api-reference/workflow-vite/workflow.mdx +47 -0
- package/docs/v4/errors/runtime-decryption-failed.mdx +77 -0
- package/docs/v4/errors/step-executed-multiple-times.mdx +23 -0
- package/docs/v5/api-reference/workflow-astro/index.mdx +18 -0
- package/docs/v5/api-reference/workflow-astro/meta.json +4 -0
- package/docs/v5/api-reference/workflow-astro/workflow.mdx +45 -0
- package/docs/v5/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
- package/docs/v5/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
- package/docs/v5/api-reference/workflow-errors/workflow-error.mdx +52 -0
- package/docs/v5/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
- package/docs/v5/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
- package/docs/v5/api-reference/workflow-nest/configure-workflow-controller.mdx +33 -0
- package/docs/v5/api-reference/workflow-nest/index.mdx +31 -0
- package/docs/v5/api-reference/workflow-nest/meta.json +9 -0
- package/docs/v5/api-reference/workflow-nest/nest-local-builder.mdx +64 -0
- package/docs/v5/api-reference/workflow-nest/workflow-controller.mdx +40 -0
- package/docs/v5/api-reference/workflow-nest/workflow-module.mdx +74 -0
- package/docs/v5/api-reference/workflow-nitro/index.mdx +59 -0
- package/docs/v5/api-reference/workflow-nuxt/index.mdx +47 -0
- package/docs/v5/api-reference/workflow-observability/hydrate-data.mdx +35 -0
- package/docs/v5/api-reference/workflow-observability/hydrate-resource-io.mdx +62 -0
- package/docs/v5/api-reference/workflow-observability/index.mdx +64 -0
- package/docs/v5/api-reference/workflow-observability/meta.json +11 -0
- package/docs/v5/api-reference/workflow-observability/observability-revivers.mdx +50 -0
- package/docs/v5/api-reference/workflow-observability/parse-class-name.mdx +41 -0
- package/docs/v5/api-reference/workflow-observability/parse-step-name.mdx +40 -0
- package/docs/v5/api-reference/workflow-observability/parse-workflow-name.mdx +55 -0
- package/docs/v5/api-reference/workflow-runtime/create-world.mdx +39 -0
- package/docs/v5/api-reference/workflow-runtime/get-world-handlers.mdx +44 -0
- package/docs/{api-reference/workflow-api → v5/api-reference/workflow-runtime}/get-world.mdx +7 -10
- package/docs/v5/api-reference/workflow-runtime/health-check.mdx +50 -0
- package/docs/v5/api-reference/workflow-runtime/index.mdx +43 -0
- package/docs/v5/api-reference/workflow-runtime/meta.json +12 -0
- package/docs/v5/api-reference/workflow-runtime/set-world.mdx +49 -0
- package/docs/v5/api-reference/workflow-runtime/workflow-entrypoint.mdx +42 -0
- package/docs/v5/api-reference/workflow-runtime/world/index.mdx +55 -0
- package/docs/v5/api-reference/workflow-runtime/world/meta.json +4 -0
- package/docs/{api-reference/workflow-api → v5/api-reference/workflow-runtime}/world/queue.mdx +2 -2
- package/docs/v5/api-reference/workflow-runtime/world/storage.mdx +409 -0
- package/docs/{api-reference/workflow-api → v5/api-reference/workflow-runtime}/world/streams.mdx +2 -2
- package/docs/v5/api-reference/workflow-sveltekit/index.mdx +18 -0
- package/docs/v5/api-reference/workflow-sveltekit/meta.json +4 -0
- package/docs/v5/api-reference/workflow-sveltekit/workflow-plugin.mdx +42 -0
- package/docs/v5/api-reference/workflow-vite/index.mdx +18 -0
- package/docs/v5/api-reference/workflow-vite/meta.json +4 -0
- package/docs/v5/api-reference/workflow-vite/workflow.mdx +48 -0
- package/docs/v5/errors/index.mdx +59 -0
- package/docs/v5/errors/runtime-decryption-failed.mdx +77 -0
- package/docs/v5/errors/step-executed-multiple-times.mdx +23 -0
- package/package.json +13 -13
- package/docs/api-reference/workflow-api/world/meta.json +0 -4
- package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Storage
|
|
3
|
+
description: Query workflow runs, steps, hooks, and the underlying event log via the World storage interface.
|
|
4
|
+
type: reference
|
|
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
|
+
prerequisites:
|
|
7
|
+
- /docs/api-reference/workflow-runtime/get-world
|
|
8
|
+
related:
|
|
9
|
+
- /docs/api-reference/workflow-api/get-run
|
|
10
|
+
- /docs/how-it-works/event-sourcing
|
|
11
|
+
- /docs/api-reference/workflow-observability
|
|
12
|
+
keywords:
|
|
13
|
+
- world.events
|
|
14
|
+
- world.runs
|
|
15
|
+
- world.steps
|
|
16
|
+
- world.hooks
|
|
17
|
+
- event log
|
|
18
|
+
- event sourcing
|
|
19
|
+
- materialized views
|
|
20
|
+
- WorkflowRun
|
|
21
|
+
- Step
|
|
22
|
+
- Hook
|
|
23
|
+
- Event
|
|
24
|
+
- cursor pagination
|
|
25
|
+
- resolveData
|
|
26
|
+
- run_cancelled
|
|
27
|
+
- correlation ID
|
|
28
|
+
- parseStepName
|
|
29
|
+
- parseWorkflowName
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
The World storage interface exposes four sub-interfaces for querying workflow data:
|
|
33
|
+
|
|
34
|
+
- **`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.
|
|
35
|
+
- **`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
|
+
```typescript lineNumbers
|
|
38
|
+
import { getWorld } from "workflow/runtime";
|
|
39
|
+
|
|
40
|
+
const world = await getWorld(); // [!code highlight]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## world.events
|
|
46
|
+
|
|
47
|
+
The event log drives all workflow state. Use it for audit trails, debugging, and programmatic run cancellation.
|
|
48
|
+
|
|
49
|
+
### events.create()
|
|
50
|
+
|
|
51
|
+
Create a new event for a workflow run. Most commonly used to cancel a run.
|
|
52
|
+
|
|
53
|
+
```typescript lineNumbers
|
|
54
|
+
await world.events.create(runId, { // [!code highlight]
|
|
55
|
+
eventType: "run_cancelled", // [!code highlight]
|
|
56
|
+
}); // [!code highlight]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Parameter | Type | Description |
|
|
60
|
+
|-----------|------|-------------|
|
|
61
|
+
| `runId` | `string \| null` | The workflow run ID (`null` only for `run_created` events, where the server generates an ID) |
|
|
62
|
+
| `data` | `CreateEventRequest` | Event data including `eventType` |
|
|
63
|
+
| `params` | `object` | Optional parameters |
|
|
64
|
+
|
|
65
|
+
**Returns:** `EventResult` — The created event and the affected entity (run/step/hook)
|
|
66
|
+
|
|
67
|
+
### events.get()
|
|
68
|
+
|
|
69
|
+
Retrieve a single event by run ID and event ID.
|
|
70
|
+
|
|
71
|
+
```typescript lineNumbers
|
|
72
|
+
const event = await world.events.get(runId, eventId); // [!code highlight]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
| Parameter | Type | Description |
|
|
76
|
+
|-----------|------|-------------|
|
|
77
|
+
| `runId` | `string` | The workflow run ID |
|
|
78
|
+
| `eventId` | `string` | The event ID |
|
|
79
|
+
|
|
80
|
+
**Returns:** `Event`
|
|
81
|
+
|
|
82
|
+
### events.list()
|
|
83
|
+
|
|
84
|
+
List events for a run with cursor pagination.
|
|
85
|
+
|
|
86
|
+
```typescript lineNumbers
|
|
87
|
+
const result = await world.events.list({ runId, pagination: { cursor } }); // [!code highlight]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
| Parameter | Type | Description |
|
|
91
|
+
|-----------|------|-------------|
|
|
92
|
+
| `params.runId` | `string` | Filter events by run ID |
|
|
93
|
+
| `params.pagination.cursor` | `string` | Cursor for the next page |
|
|
94
|
+
|
|
95
|
+
**Returns:** `{ data: Event[], cursor?: string }`
|
|
96
|
+
|
|
97
|
+
### events.listByCorrelationId()
|
|
98
|
+
|
|
99
|
+
List events that share a correlation ID, useful for tracing related events across runs.
|
|
100
|
+
|
|
101
|
+
```typescript lineNumbers
|
|
102
|
+
const result = await world.events.listByCorrelationId({ // [!code highlight]
|
|
103
|
+
correlationId: "order-123",
|
|
104
|
+
}); // [!code highlight]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
| Parameter | Type | Description |
|
|
108
|
+
|-----------|------|-------------|
|
|
109
|
+
| `params.correlationId` | `string` | The correlation ID to filter by |
|
|
110
|
+
| `params.pagination.cursor` | `string` | Cursor for the next page |
|
|
111
|
+
|
|
112
|
+
**Returns:** `{ data: Event[], cursor?: string }`
|
|
113
|
+
|
|
114
|
+
### Event Types
|
|
115
|
+
|
|
116
|
+
| Category | Types |
|
|
117
|
+
|----------|-------|
|
|
118
|
+
| Run | `run_created`, `run_started`, `run_completed`, `run_failed`, `run_cancelled` |
|
|
119
|
+
| Attribute | `attr_set` |
|
|
120
|
+
| Step | `step_created`, `step_started`, `step_completed`, `step_failed`, `step_retrying` |
|
|
121
|
+
| Hook | `hook_created`, `hook_received`, `hook_disposed`, `hook_conflict` |
|
|
122
|
+
| Wait | `wait_created`, `wait_completed` |
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## world.runs
|
|
127
|
+
|
|
128
|
+
Materialized from run events. Use it to list and inspect workflow runs.
|
|
129
|
+
|
|
130
|
+
### runs.get()
|
|
131
|
+
|
|
132
|
+
```typescript lineNumbers
|
|
133
|
+
const run = await world.runs.get(runId); // [!code highlight]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
| Parameter | Type | Description |
|
|
137
|
+
|-----------|------|-------------|
|
|
138
|
+
| `runId` | `string` | The workflow run ID |
|
|
139
|
+
| `params.resolveData` | `'all' \| 'none'` | Whether to include input/output data. Default: `'all'` |
|
|
140
|
+
|
|
141
|
+
**Returns:** `WorkflowRun` (or `WorkflowRunWithoutData` when `resolveData: 'none'`)
|
|
142
|
+
|
|
143
|
+
### runs.list()
|
|
144
|
+
|
|
145
|
+
```typescript lineNumbers
|
|
146
|
+
const result = await world.runs.list({ // [!code highlight]
|
|
147
|
+
pagination: { cursor },
|
|
148
|
+
}); // [!code highlight]
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
| Parameter | Type | Description |
|
|
152
|
+
|-----------|------|-------------|
|
|
153
|
+
| `params.pagination.cursor` | `string` | Cursor for the next page |
|
|
154
|
+
| `params.resolveData` | `'all' \| 'none'` | Whether to include input/output data |
|
|
155
|
+
|
|
156
|
+
**Returns:** `{ data: WorkflowRun[], cursor?: string }`
|
|
157
|
+
|
|
158
|
+
### Cancelling Runs
|
|
159
|
+
|
|
160
|
+
To cancel a run, create a `run_cancelled` event via `world.events.create()` (see [world.events](#worldevents) above), or use the CLI or Web UI helpers.
|
|
161
|
+
|
|
162
|
+
### WorkflowRun Type
|
|
163
|
+
|
|
164
|
+
| Field | Type | Description |
|
|
165
|
+
|-------|------|-------------|
|
|
166
|
+
| `runId` | `string` | Unique run identifier |
|
|
167
|
+
| `status` | `string` | `'running'`, `'completed'`, `'failed'`, `'cancelled'` |
|
|
168
|
+
| `workflowName` | `string` | Machine-readable workflow identifier |
|
|
169
|
+
| `input` | `any` | Workflow input data (when `resolveData: 'all'`) |
|
|
170
|
+
| `output` | `any` | Workflow output data (when `resolveData: 'all'`) |
|
|
171
|
+
| `error` | `any` | Error data if the run failed |
|
|
172
|
+
| `startedAt` | `string` | ISO timestamp when the run started |
|
|
173
|
+
| `completedAt` | `string \| null` | ISO timestamp when the run completed |
|
|
174
|
+
|
|
175
|
+
<Callout type="warn">
|
|
176
|
+
`workflowName` is a machine-readable identifier like `workflow//./src/workflows/order//processOrder`. Use `parseWorkflowName()` from `workflow/observability` to extract a display-friendly name.
|
|
177
|
+
</Callout>
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## world.steps
|
|
182
|
+
|
|
183
|
+
Materialized from step events. Use it to list steps, inspect their input/output, and build progress dashboards.
|
|
184
|
+
|
|
185
|
+
### steps.get()
|
|
186
|
+
|
|
187
|
+
```typescript lineNumbers
|
|
188
|
+
const step = await world.steps.get(runId, stepId); // [!code highlight]
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
| Parameter | Type | Description |
|
|
192
|
+
|-----------|------|-------------|
|
|
193
|
+
| `runId` | `string \| undefined` | The workflow run ID |
|
|
194
|
+
| `stepId` | `string` | The step ID |
|
|
195
|
+
| `params.resolveData` | `'all' \| 'none'` | Whether to include input/output data. Default: `'all'` |
|
|
196
|
+
|
|
197
|
+
**Returns:** `Step` (or `StepWithoutData` when `resolveData: 'none'`)
|
|
198
|
+
|
|
199
|
+
### steps.list()
|
|
200
|
+
|
|
201
|
+
```typescript lineNumbers
|
|
202
|
+
const result = await world.steps.list({ // [!code highlight]
|
|
203
|
+
runId,
|
|
204
|
+
pagination: { cursor },
|
|
205
|
+
}); // [!code highlight]
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
| Parameter | Type | Description |
|
|
209
|
+
|-----------|------|-------------|
|
|
210
|
+
| `params.runId` | `string` | Filter steps by run ID |
|
|
211
|
+
| `params.pagination.cursor` | `string` | Cursor for the next page |
|
|
212
|
+
| `params.resolveData` | `'all' \| 'none'` | Whether to include input/output data |
|
|
213
|
+
|
|
214
|
+
**Returns:** `{ data: Step[], cursor?: string }`
|
|
215
|
+
|
|
216
|
+
### Step Type
|
|
217
|
+
|
|
218
|
+
| Field | Type | Description |
|
|
219
|
+
|-------|------|-------------|
|
|
220
|
+
| `runId` | `string` | Parent workflow run ID |
|
|
221
|
+
| `stepId` | `string` | Unique step identifier |
|
|
222
|
+
| `stepName` | `string` | Machine-readable step identifier |
|
|
223
|
+
| `status` | `string` | `'running'`, `'completed'`, `'failed'` |
|
|
224
|
+
| `input` | `any` | Step input data (when `resolveData: 'all'`) |
|
|
225
|
+
| `output` | `any` | Step output data (when `resolveData: 'all'`) |
|
|
226
|
+
| `error` | `any` | Error data if the step failed |
|
|
227
|
+
| `attempt` | `number` | Current retry attempt number |
|
|
228
|
+
| `startedAt` | `string` | ISO timestamp when the step started |
|
|
229
|
+
| `completedAt` | `string \| null` | ISO timestamp when the step completed |
|
|
230
|
+
| `retryAfter` | `string \| null` | ISO timestamp for next retry attempt |
|
|
231
|
+
|
|
232
|
+
<Callout type="info">
|
|
233
|
+
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 [`hydrateResourceIO()`](/docs/api-reference/workflow-observability/hydrate-resource-io).
|
|
234
|
+
</Callout>
|
|
235
|
+
|
|
236
|
+
<Callout type="warn">
|
|
237
|
+
`stepName` is a machine-readable identifier like `step//./src/workflows/order//processPayment`. Use `parseStepName()` from `workflow/observability` to extract the `shortName` for UI display.
|
|
238
|
+
</Callout>
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## world.hooks
|
|
243
|
+
|
|
244
|
+
Materialized from hook events. Hooks are pause points in workflows that wait for external input. Use this interface to look up hooks by ID or token, inspect metadata, and build UIs for pending approvals.
|
|
245
|
+
|
|
246
|
+
### hooks.get()
|
|
247
|
+
|
|
248
|
+
```typescript lineNumbers
|
|
249
|
+
const hook = await world.hooks.get(hookId); // [!code highlight]
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
| Parameter | Type | Description |
|
|
253
|
+
|-----------|------|-------------|
|
|
254
|
+
| `hookId` | `string` | The hook ID |
|
|
255
|
+
|
|
256
|
+
**Returns:** `Hook`
|
|
257
|
+
|
|
258
|
+
### hooks.getByToken()
|
|
259
|
+
|
|
260
|
+
Look up a hook by its token. Useful in webhook resume flows where you receive a token in the callback URL.
|
|
261
|
+
|
|
262
|
+
```typescript lineNumbers
|
|
263
|
+
const hook = await world.hooks.getByToken(token); // [!code highlight]
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
| Parameter | Type | Description |
|
|
267
|
+
|-----------|------|-------------|
|
|
268
|
+
| `token` | `string` | The hook token |
|
|
269
|
+
|
|
270
|
+
**Returns:** `Hook`
|
|
271
|
+
|
|
272
|
+
### hooks.list()
|
|
273
|
+
|
|
274
|
+
```typescript lineNumbers
|
|
275
|
+
const result = await world.hooks.list({ // [!code highlight]
|
|
276
|
+
pagination: { cursor },
|
|
277
|
+
}); // [!code highlight]
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
| Parameter | Type | Description |
|
|
281
|
+
|-----------|------|-------------|
|
|
282
|
+
| `params.pagination.cursor` | `string` | Cursor for the next page |
|
|
283
|
+
|
|
284
|
+
**Returns:** `{ data: Hook[], cursor?: string }`
|
|
285
|
+
|
|
286
|
+
### Hook Type
|
|
287
|
+
|
|
288
|
+
| Field | Type | Description |
|
|
289
|
+
|-------|------|-------------|
|
|
290
|
+
| `runId` | `string` | Parent workflow run ID |
|
|
291
|
+
| `hookId` | `string` | Unique hook identifier |
|
|
292
|
+
| `token` | `string` | Hook token for resuming |
|
|
293
|
+
| `ownerId` | `string` | Owner (team/user) ID |
|
|
294
|
+
| `projectId` | `string` | Project ID |
|
|
295
|
+
| `environment` | `string` | Deployment environment |
|
|
296
|
+
| `metadata` | `object` | Custom metadata attached to the hook |
|
|
297
|
+
| `isWebhook` | `boolean` | Whether this is a webhook-style hook |
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Examples
|
|
302
|
+
|
|
303
|
+
### List Runs with Pagination
|
|
304
|
+
|
|
305
|
+
```typescript lineNumbers
|
|
306
|
+
import { getWorld } from "workflow/runtime";
|
|
307
|
+
|
|
308
|
+
const world = await getWorld();
|
|
309
|
+
let cursor: string | undefined;
|
|
310
|
+
|
|
311
|
+
const runs = await world.runs.list({ // [!code highlight]
|
|
312
|
+
pagination: { cursor },
|
|
313
|
+
}); // [!code highlight]
|
|
314
|
+
|
|
315
|
+
cursor = runs.cursor; // pass to next call for pagination
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Get a Run — Full Data vs. Metadata Only
|
|
319
|
+
|
|
320
|
+
```typescript lineNumbers
|
|
321
|
+
import { getWorld } from "workflow/runtime";
|
|
322
|
+
|
|
323
|
+
const world = await getWorld();
|
|
324
|
+
|
|
325
|
+
// Full data (default) — includes serialized input/output
|
|
326
|
+
const run = await world.runs.get(runId); // [!code highlight]
|
|
327
|
+
|
|
328
|
+
// Metadata only — lighter, no I/O loaded
|
|
329
|
+
const lightweight = await world.runs.get(runId, { // [!code highlight]
|
|
330
|
+
resolveData: "none", // [!code highlight]
|
|
331
|
+
}); // [!code highlight]
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### List Steps for a Progress Dashboard
|
|
335
|
+
|
|
336
|
+
```typescript lineNumbers
|
|
337
|
+
import { getWorld } from "workflow/runtime";
|
|
338
|
+
import { parseStepName } from "workflow/observability"; // [!code highlight]
|
|
339
|
+
|
|
340
|
+
const world = await getWorld();
|
|
341
|
+
const steps = await world.steps.list({ // [!code highlight]
|
|
342
|
+
runId,
|
|
343
|
+
resolveData: "none",
|
|
344
|
+
}); // [!code highlight]
|
|
345
|
+
|
|
346
|
+
const progress = steps.data.map((step) => {
|
|
347
|
+
const parsed = parseStepName(step.stepName); // [!code highlight]
|
|
348
|
+
return {
|
|
349
|
+
stepId: step.stepId,
|
|
350
|
+
displayName: parsed?.shortName ?? step.stepName, // [!code highlight]
|
|
351
|
+
status: step.status,
|
|
352
|
+
};
|
|
353
|
+
});
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Hydrate Step I/O
|
|
357
|
+
|
|
358
|
+
```typescript lineNumbers
|
|
359
|
+
import { getWorld } from "workflow/runtime";
|
|
360
|
+
import { hydrateResourceIO, observabilityRevivers } from "workflow/observability"; // [!code highlight]
|
|
361
|
+
|
|
362
|
+
const world = await getWorld();
|
|
363
|
+
const step = await world.steps.get(runId, stepId); // [!code highlight]
|
|
364
|
+
const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highlight]
|
|
365
|
+
console.log(hydrated.input, hydrated.output);
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Cancel a Run
|
|
369
|
+
|
|
370
|
+
```typescript lineNumbers
|
|
371
|
+
import { getWorld } from "workflow/runtime";
|
|
372
|
+
|
|
373
|
+
const world = await getWorld();
|
|
374
|
+
await world.events.create(runId, { // [!code highlight]
|
|
375
|
+
eventType: "run_cancelled", // [!code highlight]
|
|
376
|
+
}); // [!code highlight]
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### Look Up Hook by Token
|
|
380
|
+
|
|
381
|
+
```typescript lineNumbers
|
|
382
|
+
import { getWorld } from "workflow/runtime";
|
|
383
|
+
|
|
384
|
+
const world = await getWorld();
|
|
385
|
+
const hook = await world.hooks.getByToken(token); // [!code highlight]
|
|
386
|
+
console.log(hook.runId, hook.metadata); // [!code highlight]
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### List Events for Audit Trail
|
|
390
|
+
|
|
391
|
+
```typescript lineNumbers
|
|
392
|
+
import { getWorld } from "workflow/runtime";
|
|
393
|
+
|
|
394
|
+
const world = await getWorld();
|
|
395
|
+
const events = await world.events.list({ runId }); // [!code highlight]
|
|
396
|
+
|
|
397
|
+
for (const event of events.data) {
|
|
398
|
+
console.log(event.eventType, event.createdAt);
|
|
399
|
+
}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
## Related
|
|
403
|
+
|
|
404
|
+
- [Event Sourcing](/docs/how-it-works/event-sourcing) — How the event log powers workflow replay and state
|
|
405
|
+
- [getRun()](/docs/api-reference/workflow-api/get-run) — Higher-level API for working with individual runs
|
|
406
|
+
- [`workflow/observability`](/docs/api-reference/workflow-observability) — Hydrate step I/O and parse display names
|
|
407
|
+
- [resumeHook()](/docs/api-reference/workflow-api/resume-hook) — Resume a workflow by sending a payload to a hook
|
|
408
|
+
- [Hooks](/docs/foundations/hooks) — Core concepts for hooks and pause points
|
|
409
|
+
- [Workflows and Steps](/docs/foundations/workflows-and-steps) — Core concepts for steps
|
package/docs/{api-reference/workflow-api → v5/api-reference/workflow-runtime}/world/streams.mdx
RENAMED
|
@@ -4,7 +4,7 @@ description: Read, write, and manage real-time data streams for workflow runs.
|
|
|
4
4
|
type: reference
|
|
5
5
|
summary: "Methods: writeToStream(), writeToStreamMulti(), readFromStream(), closeStream(), listStreamsByRunId(), getStreamChunks(), getStreamInfo(). Stream methods live directly on the world object."
|
|
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
|
|
@@ -211,4 +211,4 @@ do {
|
|
|
211
211
|
|
|
212
212
|
- [Streaming](/docs/foundations/streaming) — Core concepts for streaming data from workflows
|
|
213
213
|
- [getWritable()](/docs/api-reference/workflow/get-writable) — The standard way to write to streams from within steps
|
|
214
|
-
- [Storage](/docs/api-reference/workflow-
|
|
214
|
+
- [Storage](/docs/api-reference/workflow-runtime/world/storage) — Query runs, steps, hooks, and events
|
|
@@ -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'` | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Set to `false` for smaller function bundles (useful for staying under the Vercel 250MB function size limit) at the cost of stack traces pointing at generated code. Can also be set via the `WORKFLOW_SOURCEMAP` environment variable. |
|
|
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 IDE IntelliSense. |
|
|
43
|
+
| `runtime` | `string` | — | Node.js runtime version for Vercel Functions (e.g. `'nodejs22.x'`, `'nodejs24.x'`). Only applies when deploying to Vercel. |
|
|
44
|
+
| `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Set to `false` for smaller function bundles (useful for staying under the Vercel 250MB function size limit) at the cost of stack traces pointing at generated code. Can also be set via the `WORKFLOW_SOURCEMAP` environment variable. |
|
|
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.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Errors
|
|
3
|
+
description: Fix common mistakes when creating and executing workflows.
|
|
4
|
+
type: overview
|
|
5
|
+
summary: Browse and resolve common workflow errors.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/foundations/errors-and-retries
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Fix common mistakes when creating and executing workflows in the **Workflow SDK**.
|
|
11
|
+
|
|
12
|
+
<Cards>
|
|
13
|
+
<Card href="/docs/errors/fetch-in-workflow" title="fetch-in-workflow">
|
|
14
|
+
Learn how to use fetch in workflow functions.
|
|
15
|
+
</Card>
|
|
16
|
+
<Card href="/docs/errors/hook-conflict" title="hook-conflict">
|
|
17
|
+
Learn how to handle hook token conflicts between workflows.
|
|
18
|
+
</Card>
|
|
19
|
+
<Card href="/docs/errors/node-js-module-in-workflow" title="node-js-module-in-workflow">
|
|
20
|
+
Learn how to use Node.js modules in workflows.
|
|
21
|
+
</Card>
|
|
22
|
+
<Card href="/docs/errors/serialization-failed" title="serialization-failed">
|
|
23
|
+
Learn how to handle serialization failures in workflows.
|
|
24
|
+
</Card>
|
|
25
|
+
<Card href="/docs/errors/start-invalid-workflow-function" title="start-invalid-workflow-function">
|
|
26
|
+
Learn how to start an invalid workflow function.
|
|
27
|
+
</Card>
|
|
28
|
+
<Card href="/docs/errors/timeout-in-workflow" title="timeout-in-workflow">
|
|
29
|
+
Learn how to handle timing delays in workflow functions.
|
|
30
|
+
</Card>
|
|
31
|
+
<Card href="/docs/errors/webhook-invalid-respond-with-value" title="webhook-invalid-respond-with-value">
|
|
32
|
+
Learn how to use the correct `respondWith` values for webhooks.
|
|
33
|
+
</Card>
|
|
34
|
+
<Card href="/docs/errors/webhook-response-not-sent" title="webhook-response-not-sent">
|
|
35
|
+
Learn how to send responses when using manual webhook response mode.
|
|
36
|
+
</Card>
|
|
37
|
+
<Card href="/docs/errors/corrupted-event-log" title="corrupted-event-log">
|
|
38
|
+
Learn how to handle corrupted or invalid event logs.
|
|
39
|
+
</Card>
|
|
40
|
+
<Card href="/docs/errors/step-not-registered" title="step-not-registered">
|
|
41
|
+
Resolve step not registered errors caused by deployment mismatches.
|
|
42
|
+
</Card>
|
|
43
|
+
<Card href="/docs/errors/step-executed-multiple-times" title="Step executed multiple times">
|
|
44
|
+
Diagnose duplicate step_started events from function crashes, timeouts, or OOMs.
|
|
45
|
+
</Card>
|
|
46
|
+
<Card href="/docs/errors/workflow-not-registered" title="workflow-not-registered">
|
|
47
|
+
Resolve workflow not registered errors caused by deployment mismatches.
|
|
48
|
+
</Card>
|
|
49
|
+
<Card href="/docs/errors/runtime-decryption-failed" title="runtime-decryption-failed">
|
|
50
|
+
Resolve runtime decryption failures from the SDK's encryption layer.
|
|
51
|
+
</Card>
|
|
52
|
+
</Cards>
|
|
53
|
+
|
|
54
|
+
## Learn More
|
|
55
|
+
|
|
56
|
+
* [API Reference](/docs/api-reference) - Complete API documentation
|
|
57
|
+
* [Foundations](/docs/foundations) - Architecture and core concepts
|
|
58
|
+
* [Examples](https://github.com/vercel/workflow) - Sample implementations
|
|
59
|
+
* [GitHub Issues](https://github.com/vercel/workflow/issues) - Report bugs and request features
|