workflow 4.2.0-beta.75 → 4.2.0-beta.76

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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Nuxt
3
- description: This guide will walk through setting up your first workflow in a Nuxt app. Along the way, you'll learn more about the concepts that are fundamental to using the development kit in your own projects.
3
+ description: This guide will walk through setting up your first workflow in a Nuxt app. Along the way, you'll learn more about the concepts that are fundamental to using the Workflow SDK in your own projects.
4
4
  type: guide
5
5
  summary: Set up Workflow SDK in a Nuxt app.
6
6
  prerequisites:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: SvelteKit
3
- description: This guide will walk through setting up your first workflow in a SvelteKit app. Along the way, you'll learn more about the concepts that are fundamental to using the development kit in your own projects.
3
+ description: This guide will walk through setting up your first workflow in a SvelteKit app. Along the way, you'll learn more about the concepts that are fundamental to using the Workflow SDK in your own projects.
4
4
  type: guide
5
5
  summary: Set up Workflow SDK in a SvelteKit app.
6
6
  prerequisites:
@@ -9,7 +9,7 @@ related:
9
9
  - /docs/foundations/workflows-and-steps
10
10
  ---
11
11
 
12
- This guide will walk through setting up your first workflow in a Vite app. Along the way, you'll learn more about the concepts that are fundamental to using the development kit in your own projects.
12
+ This guide will walk through setting up your first workflow in a Vite app. Along the way, you'll learn more about the concepts that are fundamental to using the Workflow SDK in your own projects.
13
13
 
14
14
  ---
15
15
 
@@ -15,7 +15,7 @@ import { File, Folder, Files } from "fumadocs-ui/components/files";
15
15
  This guide explores how JavaScript directives enable the Workflow SDK's execution model. For getting started with workflows, see the [getting started](/docs/getting-started) guides for your framework.
16
16
  </Callout>
17
17
 
18
- The Workflow Development Kit uses JavaScript directives (`"use workflow"` and `"use step"`) as the foundation for its durable execution model. Directives provide the compile-time semantic boundary necessary for workflows to suspend, resume, and maintain deterministic behavior across replays.
18
+ The Workflow SDK uses JavaScript directives (`"use workflow"` and `"use step"`) as the foundation for its durable execution model. Directives provide the compile-time semantic boundary necessary for workflows to suspend, resume, and maintain deterministic behavior across replays.
19
19
 
20
20
  This page explores how directives enable this execution model and the design principles that led us here.
21
21
 
@@ -339,7 +339,7 @@ This approach requires:
339
339
  - Storing/mutating class properties was not obvious (similar closure/mutation issues as the runtime-only approach)
340
340
  - Class-based syntax that doesn't feel "JavaScript native" to developers used to functional patterns
341
341
 
342
- As the JavaScript ecosystem has moved toward function-forward programming (exemplified by React's shift from class components to functions and hooks), requiring developers to use classes felt like a step backward and also didn't match our own personal taste as authors of the DevKit.
342
+ As the JavaScript ecosystem has moved toward function-forward programming (exemplified by React's shift from class components to functions and hooks), requiring developers to use classes felt like a step backward and also didn't match our own personal taste as authors of the SDK.
343
343
 
344
344
  **The core problem: Presents workflows as regular runtime code**
345
345
 
@@ -615,4 +615,4 @@ As TC39 members, we at Vercel are actively working with the standards body and b
615
615
 
616
616
  Directives aren't about syntax preference, they're about expressing semantic boundaries. `"use workflow"` tells the compiler, developer, and runtime that this code is deterministic, resumable, and sandboxed.
617
617
 
618
- This clarity enables the Workflow Development Kit to provide durable execution with familiar JavaScript patterns, while maintaining the compile-time guarantees necessary for reliable workflow orchestration.
618
+ This clarity enables the Workflow SDK to provide durable execution with familiar JavaScript patterns, while maintaining the compile-time guarantees necessary for reliable workflow orchestration.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workflow",
3
- "version": "4.2.0-beta.75",
3
+ "version": "4.2.0-beta.76",
4
4
  "description": "Workflow SDK - Build durable, resilient, and observable workflows",
5
5
  "main": "dist/typescript-plugin.cjs",
6
6
  "type": "module",
@@ -57,18 +57,18 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "ms": "2.1.3",
60
- "@workflow/astro": "4.0.0-beta.49",
61
- "@workflow/cli": "4.2.0-beta.75",
62
- "@workflow/core": "4.2.0-beta.75",
60
+ "@workflow/astro": "4.0.0-beta.50",
61
+ "@workflow/cli": "4.2.0-beta.76",
62
+ "@workflow/core": "4.2.0-beta.76",
63
63
  "@workflow/errors": "4.1.0-beta.20",
64
64
  "@workflow/typescript-plugin": "4.0.1-beta.5",
65
65
  "@workflow/utils": "4.1.0-beta.13",
66
- "@workflow/next": "4.0.1-beta.71",
67
- "@workflow/nest": "0.0.0-beta.24",
68
- "@workflow/nitro": "4.0.1-beta.70",
69
- "@workflow/nuxt": "4.0.1-beta.59",
70
- "@workflow/sveltekit": "4.0.0-beta.64",
71
- "@workflow/rollup": "4.0.0-beta.32"
66
+ "@workflow/next": "4.0.1-beta.72",
67
+ "@workflow/nest": "0.0.0-beta.25",
68
+ "@workflow/nitro": "4.0.1-beta.71",
69
+ "@workflow/nuxt": "4.0.1-beta.60",
70
+ "@workflow/sveltekit": "4.0.0-beta.65",
71
+ "@workflow/rollup": "4.0.0-beta.33"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@types/ms": "2.1.0",
@@ -1,227 +0,0 @@
1
- ---
2
- title: world.events
3
- description: Query the append-only event log for workflow state changes, audit trails, and run cancellation.
4
- type: reference
5
- summary: "Methods: create(), get(), list(), listByCorrelationId(). The event log is the source of truth for all workflow state."
6
- prerequisites:
7
- - /docs/api-reference/workflow-api/get-world
8
- related:
9
- - /docs/api-reference/workflow-api/world/runs
10
- - /docs/api-reference/workflow-api/world/steps
11
- keywords:
12
- - world.events
13
- - world.events.create
14
- - world.events.get
15
- - world.events.list
16
- - world.events.listByCorrelationId
17
- - event log
18
- - audit trail
19
- - run_cancelled
20
- - event types
21
- - correlation ID
22
- - cancel workflow run
23
- ---
24
-
25
- The `world.events` interface provides access to the append-only event log that drives all workflow state. Runs, steps, and hooks are materialized views derived from events. Use this interface for audit trails, debugging, and programmatic run cancellation.
26
-
27
- ## Import
28
-
29
- ```typescript lineNumbers
30
- import { getWorld } from "workflow/runtime";
31
-
32
- const world = getWorld();
33
- const events = world.events; // [!code highlight]
34
- ```
35
-
36
- ## Methods
37
-
38
- ### create()
39
-
40
- Create a new event for a workflow run. Most commonly used to cancel a run.
41
-
42
- ```typescript lineNumbers
43
- await world.events.create(runId, { // [!code highlight]
44
- eventType: "run_cancelled", // [!code highlight]
45
- }); // [!code highlight]
46
- ```
47
-
48
- **Parameters:**
49
-
50
- | Parameter | Type | Description |
51
- |-----------|------|-------------|
52
- | `runId` | `string` | The workflow run ID |
53
- | `data` | `object` | Event data including `eventType` |
54
- | `params` | `object` | Optional parameters |
55
-
56
- **Returns:** `Event`
57
-
58
- ### get()
59
-
60
- Retrieve a single event by run ID and event ID.
61
-
62
- ```typescript lineNumbers
63
- const event = await world.events.get(runId, eventId); // [!code highlight]
64
- ```
65
-
66
- **Parameters:**
67
-
68
- | Parameter | Type | Description |
69
- |-----------|------|-------------|
70
- | `runId` | `string` | The workflow run ID |
71
- | `eventId` | `string` | The event ID |
72
- | `params` | `object` | Optional parameters |
73
-
74
- **Returns:** `Event`
75
-
76
- ### list()
77
-
78
- List events with cursor pagination.
79
-
80
- ```typescript lineNumbers
81
- const result = await world.events.list({ // [!code highlight]
82
- runId,
83
- pagination: { cursor },
84
- }); // [!code highlight]
85
- ```
86
-
87
- **Parameters:**
88
-
89
- | Parameter | Type | Description |
90
- |-----------|------|-------------|
91
- | `params.runId` | `string` | Filter events by run ID |
92
- | `params.pagination.cursor` | `string` | Cursor for the next page |
93
-
94
- **Returns:** `{ data: Event[], cursor?: string }`
95
-
96
- ### listByCorrelationId()
97
-
98
- List events that share a correlation ID, useful for tracing related events across runs.
99
-
100
- ```typescript lineNumbers
101
- const result = await world.events.listByCorrelationId({ // [!code highlight]
102
- correlationId: "order-123",
103
- }); // [!code highlight]
104
- ```
105
-
106
- **Parameters:**
107
-
108
- | Parameter | Type | Description |
109
- |-----------|------|-------------|
110
- | `params.correlationId` | `string` | The correlation ID to filter by |
111
- | `params.pagination.cursor` | `string` | Cursor for the next page |
112
-
113
- **Returns:** `{ data: Event[], cursor?: string }`
114
-
115
- ## Event Types
116
-
117
- Events are grouped by the entity they affect:
118
-
119
- ### Run Events
120
-
121
- | Event Type | Description |
122
- |-----------|-------------|
123
- | `run_created` | Workflow run was created |
124
- | `run_started` | Workflow run execution began |
125
- | `run_completed` | Workflow run completed successfully |
126
- | `run_failed` | Workflow run failed with an error |
127
- | `run_cancelled` | Workflow run was cancelled |
128
-
129
- ### Step Events
130
-
131
- | Event Type | Description |
132
- |-----------|-------------|
133
- | `step_created` | Step was created |
134
- | `step_started` | Step execution began |
135
- | `step_completed` | Step completed successfully |
136
- | `step_failed` | Step failed with an error |
137
- | `step_retrying` | Step scheduled for retry |
138
-
139
- ### Hook Events
140
-
141
- | Event Type | Description |
142
- |-----------|-------------|
143
- | `hook_created` | Hook was created (workflow paused) |
144
- | `hook_received` | Hook received a payload |
145
- | `hook_disposed` | Hook was disposed (workflow reached terminal state) |
146
- | `hook_conflict` | Hook token conflict detected |
147
-
148
- ### Wait Events
149
-
150
- | Event Type | Description |
151
- |-----------|-------------|
152
- | `wait_created` | Workflow entered a wait state (e.g., `sleep()`) |
153
- | `wait_completed` | Wait state completed |
154
-
155
- <Callout type="info">
156
- Events are the append-only source of truth for all workflow state. `WorkflowRun`, `Step`, and `Hook` objects are materialized views derived from these events.
157
- </Callout>
158
-
159
- ## Examples
160
-
161
- ### List Events for a Run as Audit Trail
162
-
163
- ```typescript lineNumbers
164
- // app/api/workflow-events/route.ts
165
- import { getWorld } from "workflow/runtime";
166
-
167
- export async function GET(req: Request) {
168
- const url = new URL(req.url);
169
- const runId = url.searchParams.get("runId");
170
-
171
- if (!runId) {
172
- return Response.json({ error: "runId required" }, { status: 400 });
173
- }
174
-
175
- const world = getWorld();
176
- const events = await world.events.list({ runId }); // [!code highlight]
177
-
178
- return Response.json(events);
179
- }
180
- ```
181
-
182
- ### Cancel a Run via Event Creation
183
-
184
- Cancelling a run is done by creating a `run_cancelled` event:
185
-
186
- ```typescript lineNumbers
187
- // app/api/workflow-runs/cancel/route.ts
188
- import { getWorld } from "workflow/runtime";
189
-
190
- export async function POST(req: Request) {
191
- const { runId } = await req.json();
192
-
193
- const world = getWorld();
194
- await world.events.create(runId, { // [!code highlight]
195
- eventType: "run_cancelled", // [!code highlight]
196
- }); // [!code highlight]
197
-
198
- return Response.json({ cancelled: true });
199
- }
200
- ```
201
-
202
- <Callout type="info">
203
- `world.runs.cancel(runId)` is a convenience wrapper around this event creation pattern. Use `world.events.create()` directly when you need to attach custom data to the cancellation event.
204
- </Callout>
205
-
206
- ### List Events by Correlation ID
207
-
208
- Trace related events across workflow runs using a shared correlation ID:
209
-
210
- ```typescript lineNumbers
211
- import { getWorld } from "workflow/runtime";
212
-
213
- const world = getWorld();
214
- const events = await world.events.listByCorrelationId({ // [!code highlight]
215
- correlationId: "order-123", // [!code highlight]
216
- }); // [!code highlight]
217
-
218
- for (const event of events.data) {
219
- console.log(event.eventType, event.runId, event.createdAt);
220
- }
221
- ```
222
-
223
- ## Related
224
-
225
- - [world.runs](/docs/api-reference/workflow-api/world/runs) — Inspect runs (materialized from events)
226
- - [world.steps](/docs/api-reference/workflow-api/world/steps) — Inspect steps (materialized from events)
227
- - [world.hooks](/docs/api-reference/workflow-api/world/hooks) — Inspect hooks (materialized from events)
@@ -1,181 +0,0 @@
1
- ---
2
- title: world.hooks
3
- description: Look up workflow hooks by ID or token for webhook resume flows and metadata inspection.
4
- type: reference
5
- summary: "Methods: get(), getByToken(), list(). Query hook details for resume flows."
6
- prerequisites:
7
- - /docs/api-reference/workflow-api/get-world
8
- related:
9
- - /docs/api-reference/workflow-api/world/events
10
- - /docs/api-reference/workflow-api/resume-hook
11
- - /docs/api-reference/workflow-api/resume-webhook
12
- keywords:
13
- - world.hooks
14
- - world.hooks.get
15
- - world.hooks.getByToken
16
- - world.hooks.list
17
- - Hook
18
- - webhook token
19
- - hook metadata
20
- - resume flow
21
- - pending approvals
22
- ---
23
-
24
- The `world.hooks` interface provides access to workflow hook data. 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 admin UIs for pending approvals.
25
-
26
- ## Import
27
-
28
- ```typescript lineNumbers
29
- import { getWorld } from "workflow/runtime";
30
-
31
- const world = getWorld();
32
- const hooks = world.hooks; // [!code highlight]
33
- ```
34
-
35
- ## Methods
36
-
37
- ### get()
38
-
39
- Retrieve a hook by its ID.
40
-
41
- ```typescript lineNumbers
42
- const hook = await world.hooks.get(hookId); // [!code highlight]
43
- ```
44
-
45
- **Parameters:**
46
-
47
- | Parameter | Type | Description |
48
- |-----------|------|-------------|
49
- | `hookId` | `string` | The hook ID |
50
- | `params` | `object` | Optional parameters |
51
-
52
- **Returns:** `Hook`
53
-
54
- ### getByToken()
55
-
56
- Look up a hook by its token. Useful in webhook resume flows where you receive a token in the callback URL.
57
-
58
- ```typescript lineNumbers
59
- const hook = await world.hooks.getByToken(token); // [!code highlight]
60
- ```
61
-
62
- **Parameters:**
63
-
64
- | Parameter | Type | Description |
65
- |-----------|------|-------------|
66
- | `token` | `string` | The hook token |
67
- | `params` | `object` | Optional parameters |
68
-
69
- **Returns:** `Hook`
70
-
71
- ### list()
72
-
73
- List hooks with cursor pagination.
74
-
75
- ```typescript lineNumbers
76
- const result = await world.hooks.list({ // [!code highlight]
77
- pagination: { cursor },
78
- }); // [!code highlight]
79
- ```
80
-
81
- **Parameters:**
82
-
83
- | Parameter | Type | Description |
84
- |-----------|------|-------------|
85
- | `params.pagination.cursor` | `string` | Cursor for the next page |
86
-
87
- **Returns:** `{ data: Hook[], cursor?: string }`
88
-
89
- ## Types
90
-
91
- ### Hook
92
-
93
- | Field | Type | Description |
94
- |-------|------|-------------|
95
- | `runId` | `string` | Parent workflow run ID |
96
- | `hookId` | `string` | Unique hook identifier |
97
- | `token` | `string` | Hook token for resuming |
98
- | `ownerId` | `string` | Owner (team/user) ID |
99
- | `projectId` | `string` | Project ID |
100
- | `environment` | `string` | Deployment environment |
101
- | `metadata` | `object` | Custom metadata attached to the hook |
102
- | `isWebhook` | `boolean` | Whether this is a webhook-style hook |
103
-
104
- ## Examples
105
-
106
- ### Look Up Hook by ID
107
-
108
- ```typescript lineNumbers
109
- // app/api/workflow-hooks/route.ts
110
- import { getWorld } from "workflow/runtime";
111
-
112
- export async function GET(req: Request) {
113
- const url = new URL(req.url);
114
- const hookId = url.searchParams.get("hookId");
115
-
116
- if (!hookId) {
117
- return Response.json({ error: "hookId required" }, { status: 400 });
118
- }
119
-
120
- const world = getWorld();
121
- const hook = await world.hooks.get(hookId); // [!code highlight]
122
-
123
- return Response.json({
124
- hookId: hook.hookId,
125
- runId: hook.runId,
126
- token: hook.token,
127
- metadata: hook.metadata,
128
- });
129
- }
130
- ```
131
-
132
- ### Look Up Hook by Token for Webhook Resume
133
-
134
- When you receive a webhook callback with a token, look up the hook to inspect metadata before resuming:
135
-
136
- ```typescript lineNumbers
137
- // app/api/workflow-hooks/resume/route.ts
138
- import { getWorld } from "workflow/runtime";
139
-
140
- export async function POST(req: Request) {
141
- const { token } = await req.json();
142
-
143
- const world = getWorld();
144
- const hook = await world.hooks.getByToken(token); // [!code highlight]
145
-
146
- // Inspect hook metadata before deciding to resume
147
- console.log(hook.runId, hook.metadata); // [!code highlight]
148
-
149
- return Response.json({
150
- runId: hook.runId,
151
- hookId: hook.hookId,
152
- metadata: hook.metadata,
153
- });
154
- }
155
- ```
156
-
157
- ### List All Hooks for Pending Approvals Dashboard
158
-
159
- ```typescript lineNumbers
160
- // app/api/workflow-hooks/pending/route.ts
161
- import { getWorld } from "workflow/runtime";
162
-
163
- export async function GET(req: Request) {
164
- const url = new URL(req.url);
165
- const cursor = url.searchParams.get("cursor") ?? undefined;
166
-
167
- const world = getWorld();
168
- const hooks = await world.hooks.list({ // [!code highlight]
169
- pagination: { cursor },
170
- }); // [!code highlight]
171
-
172
- return Response.json(hooks);
173
- }
174
- ```
175
-
176
- ## Related
177
-
178
- - [resumeHook()](/docs/api-reference/workflow-api/resume-hook) — Resume a workflow by sending a payload to a hook
179
- - [resumeWebhook()](/docs/api-reference/workflow-api/resume-webhook) — Resume a workflow via webhook
180
- - [getHookByToken()](/docs/api-reference/workflow-api/get-hook-by-token) — Higher-level API for hook lookup
181
- - [Hooks](/docs/foundations/hooks) — Core concepts for hooks and pause points