workflow 5.0.0-beta.2 → 5.0.0-beta.20
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/dist/api-workflow.d.ts +1 -1
- package/dist/api-workflow.d.ts.map +1 -1
- package/dist/api-workflow.js +2 -2
- package/dist/api.d.ts +5 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +14 -2
- package/dist/internal/builtins.d.ts +17 -0
- package/dist/internal/builtins.d.ts.map +1 -1
- package/dist/internal/builtins.js +65 -1
- package/dist/observability.d.ts +1 -1
- package/dist/observability.js +2 -2
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +2 -2
- package/docs/ai/index.mdx +27 -23
- package/docs/api-reference/index.mdx +24 -0
- package/docs/api-reference/meta.json +8 -0
- package/docs/api-reference/vitest/index.mdx +28 -7
- package/docs/api-reference/workflow/create-hook.mdx +38 -0
- package/docs/api-reference/workflow/create-webhook.mdx +1 -0
- package/docs/api-reference/workflow/experimental-set-attributes.mdx +65 -0
- package/docs/api-reference/workflow/fetch.mdx +5 -0
- package/docs/api-reference/workflow/index.mdx +3 -0
- package/docs/api-reference/workflow-ai/durable-agent.mdx +7 -45
- package/docs/api-reference/workflow-api/get-hook-by-token.mdx +7 -0
- package/docs/api-reference/workflow-api/get-run.mdx +6 -0
- package/docs/api-reference/workflow-api/index.mdx +6 -8
- package/docs/api-reference/workflow-api/resume-hook.mdx +57 -0
- package/docs/api-reference/workflow-api/start.mdx +13 -5
- 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/hook-conflict-error.mdx +60 -0
- package/docs/api-reference/workflow-errors/index.mdx +85 -0
- package/docs/api-reference/workflow-errors/meta.json +5 -0
- package/docs/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
- package/docs/api-reference/workflow-errors/workflow-error.mdx +52 -0
- package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +16 -6
- package/docs/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
- package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
- package/docs/api-reference/workflow-nest/configure-workflow-controller.mdx +33 -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 +40 -0
- package/docs/api-reference/workflow-nest/workflow-module.mdx +74 -0
- package/docs/api-reference/workflow-next/with-workflow.mdx +34 -2
- package/docs/api-reference/workflow-nitro/index.mdx +59 -0
- package/docs/api-reference/workflow-nuxt/index.mdx +47 -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 +64 -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 +7 -10
- package/docs/api-reference/workflow-runtime/health-check.mdx +50 -0
- package/docs/api-reference/workflow-runtime/index.mdx +43 -0
- package/docs/api-reference/workflow-runtime/meta.json +12 -0
- package/docs/api-reference/workflow-runtime/set-world.mdx +49 -0
- package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +42 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/index.mdx +5 -8
- package/docs/api-reference/workflow-runtime/world/meta.json +4 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/queue.mdx +2 -2
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/storage.mdx +11 -4
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/streams.mdx +2 -2
- 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/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 +380 -0
- package/docs/changelog/eager-processing.mdx +269 -0
- package/docs/changelog/index.mdx +2 -1
- package/docs/changelog/lazy-event-creation.md +127 -0
- package/docs/changelog/meta.json +6 -1
- package/docs/changelog/resilient-start.mdx +31 -283
- package/docs/cookbook/advanced/child-workflows.mdx +315 -0
- package/docs/cookbook/advanced/meta.json +2 -3
- package/docs/cookbook/advanced/publishing-libraries.mdx +87 -29
- package/docs/cookbook/advanced/serializable-steps.mdx +17 -5
- package/docs/cookbook/advanced/upgrading-workflows.mdx +195 -0
- package/docs/cookbook/agent-patterns/agent-cancellation.mdx +156 -0
- package/docs/cookbook/agent-patterns/durable-agent.mdx +11 -184
- package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +150 -173
- package/docs/cookbook/agent-patterns/meta.json +1 -7
- package/docs/cookbook/common-patterns/batching.mdx +44 -118
- package/docs/cookbook/common-patterns/idempotency.mdx +36 -52
- package/docs/cookbook/common-patterns/meta.json +4 -4
- package/docs/cookbook/common-patterns/rate-limiting.mdx +1 -1
- package/docs/cookbook/common-patterns/saga.mdx +128 -33
- package/docs/cookbook/common-patterns/scheduling.mdx +77 -193
- package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +155 -0
- package/docs/cookbook/common-patterns/timeouts.mdx +100 -0
- package/docs/cookbook/common-patterns/workflow-composition.mdx +117 -0
- package/docs/cookbook/index.mdx +14 -17
- package/docs/cookbook/integrations/ai-sdk.mdx +330 -142
- package/docs/cookbook/integrations/chat-sdk.mdx +264 -151
- package/docs/cookbook/integrations/sandbox.mdx +482 -81
- package/docs/cookbook/meta.json +1 -1
- package/docs/deploying/building-a-world.mdx +1 -1
- package/docs/deploying/world/postgres-world.mdx +5 -3
- package/docs/deploying/world/vercel-world.mdx +2 -0
- package/docs/errors/abort-signal-timeout-in-workflow.mdx +80 -0
- package/docs/errors/corrupted-event-log.mdx +5 -5
- package/docs/errors/hook-conflict.mdx +56 -4
- package/docs/errors/index.mdx +9 -0
- package/docs/errors/replay-divergence.mdx +27 -0
- package/docs/errors/runtime-decryption-failed.mdx +77 -0
- package/docs/errors/step-executed-multiple-times.mdx +23 -0
- package/docs/errors/step-not-registered.mdx +1 -1
- package/docs/foundations/cancellation.mdx +459 -0
- package/docs/foundations/errors-and-retries.mdx +7 -3
- package/docs/foundations/hooks.mdx +29 -0
- package/docs/foundations/idempotency.mdx +236 -11
- package/docs/foundations/index.mdx +3 -3
- package/docs/foundations/meta.json +3 -2
- package/docs/foundations/serialization.mdx +78 -42
- package/docs/foundations/starting-workflows.mdx +6 -2
- package/docs/foundations/streaming.mdx +14 -23
- package/docs/foundations/versioning.mdx +263 -0
- package/docs/getting-started/astro.mdx +6 -0
- package/docs/getting-started/index.mdx +6 -7
- package/docs/getting-started/meta.json +1 -0
- package/docs/getting-started/nestjs.mdx +9 -0
- package/docs/getting-started/next.mdx +5 -3
- package/docs/getting-started/nitro.mdx +22 -0
- package/docs/getting-started/sveltekit.mdx +6 -0
- package/docs/getting-started/tanstack-start.mdx +241 -0
- package/docs/how-it-works/cancellation.mdx +287 -0
- package/docs/how-it-works/code-transform.mdx +2 -2
- package/docs/how-it-works/encryption.mdx +2 -2
- package/docs/how-it-works/event-sourcing.mdx +2 -2
- package/docs/how-it-works/meta.json +2 -1
- package/docs/internal/index.mdx +21 -0
- package/docs/internal/meta.json +10 -0
- 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 +148 -0
- package/docs/migration-guides/migrating-from-aws-step-functions.mdx +63 -16
- package/docs/migration-guides/migrating-from-inngest.mdx +44 -22
- package/docs/migration-guides/migrating-from-temporal.mdx +43 -14
- package/docs/migration-guides/migrating-from-trigger-dev.mdx +59 -27
- package/docs/observability/attributes.mdx +87 -0
- package/docs/observability/index.mdx +25 -1
- package/docs/observability/meta.json +1 -1
- package/docs/observability/tracing.mdx +106 -0
- package/docs/testing/index.mdx +2 -2
- package/package.json +14 -13
- package/docs/api-reference/workflow-api/world/meta.json +0 -4
- package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
- package/docs/cookbook/advanced/custom-serialization.mdx +0 -168
- package/docs/cookbook/advanced/durable-objects.mdx +0 -148
- package/docs/cookbook/advanced/isomorphic-packages.mdx +0 -145
- package/docs/cookbook/agent-patterns/stop-workflow.mdx +0 -216
- package/docs/cookbook/agent-patterns/tool-orchestration.mdx +0 -255
- package/docs/cookbook/agent-patterns/tool-streaming.mdx +0 -181
- package/docs/cookbook/common-patterns/child-workflows.mdx +0 -372
- package/docs/cookbook/common-patterns/content-router.mdx +0 -207
- package/docs/cookbook/common-patterns/fan-out.mdx +0 -208
- package/docs/foundations/common-patterns.mdx +0 -265
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: setWorld
|
|
3
|
+
description: Override or reset the cached World instance used by the workflow runtime.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Use setWorld to inject a custom World instance or reset the cache after environment configuration changes.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/api-reference/workflow-runtime/get-world
|
|
8
|
+
related:
|
|
9
|
+
- /docs/api-reference/workflow-runtime/create-world
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Overrides the cached [World](/docs/api-reference/workflow-runtime/world) instance that [`getWorld()`](/docs/api-reference/workflow-runtime/get-world) returns. Use it to inject a World constructed with explicit configuration (rather than environment variables), or pass `undefined` to clear the cache so the next `getWorld()` call reinitializes from the current environment.
|
|
13
|
+
|
|
14
|
+
```typescript lineNumbers
|
|
15
|
+
import { setWorld, getWorld } from "workflow/runtime";
|
|
16
|
+
import type { World } from "@workflow/world";
|
|
17
|
+
declare const customWorld: World; // @setup
|
|
18
|
+
|
|
19
|
+
setWorld(customWorld); // [!code highlight]
|
|
20
|
+
const world = await getWorld(); // resolves customWorld
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## API Signature
|
|
24
|
+
|
|
25
|
+
### Parameters
|
|
26
|
+
|
|
27
|
+
| Parameter | Type | Description |
|
|
28
|
+
|-----------|------|-------------|
|
|
29
|
+
| `world` | `World \| undefined` | The World instance to use, or `undefined` to reset the cache and reinitialize from environment variables on next access |
|
|
30
|
+
|
|
31
|
+
### Returns
|
|
32
|
+
|
|
33
|
+
This function does not return a value.
|
|
34
|
+
|
|
35
|
+
## Example: Reset After Environment Changes
|
|
36
|
+
|
|
37
|
+
```typescript lineNumbers
|
|
38
|
+
import { setWorld, getWorld } from "workflow/runtime";
|
|
39
|
+
|
|
40
|
+
process.env.WORKFLOW_TARGET_WORLD = "@workflow/world-local";
|
|
41
|
+
setWorld(undefined); // clear the cached instance // [!code highlight]
|
|
42
|
+
|
|
43
|
+
const world = await getWorld(); // reinitialized with new configuration
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Related Functions
|
|
47
|
+
|
|
48
|
+
- [`getWorld()`](/docs/api-reference/workflow-runtime/get-world) - Resolve the cached World instance.
|
|
49
|
+
- [`createWorld()`](/docs/api-reference/workflow-runtime/create-world) - Construct a fresh World from environment configuration.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: workflowEntrypoint
|
|
3
|
+
description: Create the HTTP route handler that executes workflow runs from a workflow bundle.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Use workflowEntrypoint to wire a compiled workflow bundle into an HTTP route in custom server environments.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/how-it-works/code-transform
|
|
8
|
+
related:
|
|
9
|
+
- /docs/api-reference/workflow-runtime/health-check
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Creates the HTTP route handler that executes workflow runs. The handler receives queue messages, replays the workflow from its event log, executes steps inline where possible, and suspends when the workflow waits on sleeps or hooks.
|
|
13
|
+
|
|
14
|
+
Framework adapters (Next.js, Nitro, SvelteKit, etc.) call this for you and mount the result at `/.well-known/workflow/v1/flow` — you only need it when wiring workflow support into a custom server environment.
|
|
15
|
+
|
|
16
|
+
```typescript lineNumbers
|
|
17
|
+
import { workflowEntrypoint } from "workflow/runtime";
|
|
18
|
+
declare const workflowBundleCode: string; // @setup
|
|
19
|
+
|
|
20
|
+
const handler = workflowEntrypoint(workflowBundleCode); // [!code highlight]
|
|
21
|
+
|
|
22
|
+
// Mount on your server, e.g. a fetch-style route:
|
|
23
|
+
export const POST = (req: Request) => handler(req);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API Signature
|
|
27
|
+
|
|
28
|
+
### Parameters
|
|
29
|
+
|
|
30
|
+
| Parameter | Type | Description |
|
|
31
|
+
|-----------|------|-------------|
|
|
32
|
+
| `workflowCode` | `string` | The compiled workflow bundle code containing all workflow functions |
|
|
33
|
+
| `options` | `{ namespace?: string }` | Optional. `namespace` scopes the queue topics this handler consumes. |
|
|
34
|
+
|
|
35
|
+
### Returns
|
|
36
|
+
|
|
37
|
+
Returns a fetch-style request handler: `(req: Request) => Promise<Response>`.
|
|
38
|
+
|
|
39
|
+
## Related Functions
|
|
40
|
+
|
|
41
|
+
- [`getWorldHandlers()`](/docs/api-reference/workflow-runtime/get-world-handlers) - The build-time World access this handler is built on.
|
|
42
|
+
- [`healthCheck()`](/docs/api-reference/workflow-runtime/health-check) - Verify the entrypoint processes queue messages end-to-end.
|
|
@@ -4,7 +4,7 @@ description: Low-level API for inspecting and managing workflow runs, steps, eve
|
|
|
4
4
|
type: overview
|
|
5
5
|
summary: Access workflow infrastructure via await getWorld() for building observability dashboards, admin tools, and custom integrations.
|
|
6
6
|
prerequisites:
|
|
7
|
-
- /docs/api-reference/workflow-
|
|
7
|
+
- /docs/api-reference/workflow-runtime/get-world
|
|
8
8
|
keywords:
|
|
9
9
|
- getWorld
|
|
10
10
|
- World SDK
|
|
@@ -25,18 +25,15 @@ const world = await getWorld(); // [!code highlight]
|
|
|
25
25
|
## Interfaces
|
|
26
26
|
|
|
27
27
|
<Cards>
|
|
28
|
-
<Card href="/docs/api-reference/workflow-
|
|
28
|
+
<Card href="/docs/api-reference/workflow-runtime/world/storage" title="Storage">
|
|
29
29
|
Query runs, steps, hooks, and the underlying event log.
|
|
30
30
|
</Card>
|
|
31
|
-
<Card href="/docs/api-reference/workflow-
|
|
31
|
+
<Card href="/docs/api-reference/workflow-runtime/world/streams" title="Streams">
|
|
32
32
|
Read, write, and manage real-time data streams for workflow runs.
|
|
33
33
|
</Card>
|
|
34
|
-
<Card href="/docs/api-reference/workflow-
|
|
34
|
+
<Card href="/docs/api-reference/workflow-runtime/world/queue" title="Queue">
|
|
35
35
|
Low-level queue dispatch (internal SDK infrastructure).
|
|
36
36
|
</Card>
|
|
37
|
-
<Card href="/docs/api-reference/workflow-api/world/observability" title="Observability Utilities">
|
|
38
|
-
Hydrate step I/O, parse display names, and decrypt workflow data.
|
|
39
|
-
</Card>
|
|
40
37
|
</Cards>
|
|
41
38
|
|
|
42
39
|
<Callout type="info">
|
|
@@ -55,4 +52,4 @@ const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highl
|
|
|
55
52
|
console.log(hydrated.input, hydrated.output);
|
|
56
53
|
```
|
|
57
54
|
|
|
58
|
-
See [
|
|
55
|
+
See [`workflow/observability`](/docs/api-reference/workflow-observability) for the full API.
|
|
@@ -4,7 +4,7 @@ description: Low-level queue interface for dispatching workflow and step invocat
|
|
|
4
4
|
type: reference
|
|
5
5
|
summary: "Methods: getDeploymentId(), queue(), createQueueHandler(). Internal queue dispatch — normally handled by the SDK."
|
|
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/start
|
|
10
10
|
- /docs/foundations/starting-workflows
|
|
@@ -83,4 +83,4 @@ const handler = world.createQueueHandler(prefix, callback); // [!code highlight]
|
|
|
83
83
|
|
|
84
84
|
- [start()](/docs/api-reference/workflow-api/start) — The standard way to start workflow runs
|
|
85
85
|
- [Starting Workflows](/docs/foundations/starting-workflows) — Core concepts for workflow invocation
|
|
86
|
-
- [Storage](/docs/api-reference/workflow-
|
|
86
|
+
- [Storage](/docs/api-reference/workflow-runtime/world/storage) — Create events that trigger queue dispatch
|
|
@@ -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
|
|
@@ -116,6 +116,7 @@ const result = await world.events.listByCorrelationId({ // [!code highlight]
|
|
|
116
116
|
| Category | Types |
|
|
117
117
|
|----------|-------|
|
|
118
118
|
| Run | `run_created`, `run_started`, `run_completed`, `run_failed`, `run_cancelled` |
|
|
119
|
+
| Attribute | `attr_set` |
|
|
119
120
|
| Step | `step_created`, `step_started`, `step_completed`, `step_failed`, `step_retrying` |
|
|
120
121
|
| Hook | `hook_created`, `hook_received`, `hook_disposed`, `hook_conflict` |
|
|
121
122
|
| Wait | `wait_created`, `wait_completed` |
|
|
@@ -229,7 +230,7 @@ const result = await world.steps.list({ // [!code highlight]
|
|
|
229
230
|
| `retryAfter` | `string \| null` | ISO timestamp for next retry attempt |
|
|
230
231
|
|
|
231
232
|
<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 [
|
|
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).
|
|
233
234
|
</Callout>
|
|
234
235
|
|
|
235
236
|
<Callout type="warn">
|
|
@@ -258,6 +259,12 @@ const hook = await world.hooks.get(hookId); // [!code highlight]
|
|
|
258
259
|
|
|
259
260
|
Look up a hook by its token. Useful in webhook resume flows where you receive a token in the callback URL.
|
|
260
261
|
|
|
262
|
+
<Callout type="info">
|
|
263
|
+
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.
|
|
264
|
+
|
|
265
|
+
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).
|
|
266
|
+
</Callout>
|
|
267
|
+
|
|
261
268
|
```typescript lineNumbers
|
|
262
269
|
const hook = await world.hooks.getByToken(token); // [!code highlight]
|
|
263
270
|
```
|
|
@@ -402,7 +409,7 @@ for (const event of events.data) {
|
|
|
402
409
|
|
|
403
410
|
- [Event Sourcing](/docs/how-it-works/event-sourcing) — How the event log powers workflow replay and state
|
|
404
411
|
- [getRun()](/docs/api-reference/workflow-api/get-run) — Higher-level API for working with individual runs
|
|
405
|
-
- [
|
|
412
|
+
- [`workflow/observability`](/docs/api-reference/workflow-observability) — Hydrate step I/O and parse display names
|
|
406
413
|
- [resumeHook()](/docs/api-reference/workflow-api/resume-hook) — Resume a workflow by sending a payload to a hook
|
|
407
414
|
- [Hooks](/docs/foundations/hooks) — Core concepts for hooks and pause points
|
|
408
415
|
- [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
|
|
@@ -213,4 +213,4 @@ do {
|
|
|
213
213
|
|
|
214
214
|
- [Streaming](/docs/foundations/streaming) — Core concepts for streaming data from workflows
|
|
215
215
|
- [getWritable()](/docs/api-reference/workflow/get-writable) — The standard way to write to streams from within steps
|
|
216
|
-
- [Storage](/docs/api-reference/workflow-
|
|
216
|
+
- [Storage](/docs/api-reference/workflow-runtime/world/storage) — Query runs, steps, hooks, and events
|
|
@@ -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";
|
|
@@ -26,7 +25,7 @@ class Point {
|
|
|
26
25
|
|
|
27
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
|
|
@@ -6,7 +6,6 @@ A symbol used to define custom serialization for user-defined class instances. T
|
|
|
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";
|
|
@@ -26,7 +25,7 @@ class Point {
|
|
|
26
25
|
|
|
27
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
|
|
@@ -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 — helps stay under the Vercel 250MB 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 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'` (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 — helps stay under the Vercel 250MB 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.
|