workflow 5.0.0-beta.4 → 5.0.0-beta.41
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 +63 -20
- package/dist/api-workflow.d.ts +1 -1
- package/dist/api-workflow.d.ts.map +1 -1
- package/dist/api-workflow.js +1 -1
- package/dist/api.d.ts +5 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +12 -2
- 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 +17 -0
- package/dist/internal/builtins.d.ts.map +1 -1
- package/dist/internal/builtins.js +65 -1
- 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/observability.d.ts +1 -1
- package/dist/observability.js +2 -2
- package/dist/runtime.d.ts +2 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +5 -2
- package/docs/ai/chat-session-modeling.mdx +7 -3
- package/docs/ai/defining-tools.mdx +2 -2
- package/docs/ai/index.mdx +30 -25
- package/docs/ai/message-queueing.mdx +10 -10
- package/docs/ai/resumable-streams.mdx +9 -1
- 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 +79 -0
- package/docs/api-reference/workflow/create-webhook.mdx +1 -0
- package/docs/api-reference/workflow/define-hook.mdx +26 -24
- package/docs/api-reference/workflow/fatal-error.mdx +29 -7
- package/docs/api-reference/workflow/fetch.mdx +8 -4
- package/docs/api-reference/workflow/index.mdx +3 -0
- package/docs/api-reference/workflow/set-attributes.mdx +61 -0
- package/docs/api-reference/workflow/sleep.mdx +1 -1
- package/docs/api-reference/workflow-ai/durable-agent.mdx +7 -45
- package/docs/api-reference/workflow-ai/index.mdx +2 -2
- package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +44 -1
- package/docs/api-reference/workflow-api/get-hook-by-token.mdx +9 -0
- package/docs/api-reference/workflow-api/get-run.mdx +25 -0
- package/docs/api-reference/workflow-api/index.mdx +6 -8
- package/docs/api-reference/workflow-api/resume-hook.mdx +60 -1
- package/docs/api-reference/workflow-api/resume-webhook.mdx +6 -4
- package/docs/api-reference/workflow-api/start.mdx +39 -6
- 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 +88 -0
- package/docs/api-reference/workflow-errors/meta.json +6 -0
- package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +68 -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-globals.mdx +4 -1
- 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 +56 -2
- 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 +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-runtime/world/analytics.mdx +138 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/index.mdx +10 -10
- package/docs/api-reference/workflow-runtime/world/meta.json +4 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/queue.mdx +8 -6
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/storage.mdx +24 -7
- 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 +2 -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 +3 -1
- package/docs/changelog/lazy-event-creation.md +127 -0
- package/docs/changelog/meta.json +9 -1
- package/docs/changelog/resilient-resume.mdx +22 -0
- package/docs/changelog/resilient-start.mdx +31 -283
- 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 +103 -0
- package/docs/configuration/build-and-diagnostics.mdx +70 -0
- package/docs/configuration/cli-and-web-ui.mdx +182 -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 +281 -0
- package/docs/configuration/worlds.mdx +283 -0
- package/docs/cookbook/advanced/child-workflows.mdx +203 -256
- package/docs/cookbook/advanced/meta.json +1 -1
- package/docs/cookbook/advanced/publishing-libraries.mdx +33 -24
- package/docs/cookbook/advanced/serializable-steps.mdx +12 -4
- package/docs/cookbook/advanced/upgrading-workflows.mdx +199 -0
- package/docs/cookbook/agent-patterns/agent-cancellation.mdx +34 -75
- package/docs/cookbook/agent-patterns/durable-agent.mdx +14 -142
- package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +11 -3
- package/docs/cookbook/common-patterns/batching.mdx +4 -0
- package/docs/cookbook/common-patterns/idempotency.mdx +40 -52
- package/docs/cookbook/common-patterns/rate-limiting.mdx +5 -1
- package/docs/cookbook/common-patterns/saga.mdx +6 -2
- package/docs/cookbook/common-patterns/scheduling.mdx +12 -0
- package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +4 -0
- package/docs/cookbook/common-patterns/timeouts.mdx +6 -1
- package/docs/cookbook/common-patterns/webhooks.mdx +4 -0
- package/docs/cookbook/common-patterns/workflow-composition.mdx +19 -16
- package/docs/cookbook/index.mdx +3 -3
- package/docs/cookbook/integrations/ai-sdk.mdx +64 -28
- package/docs/cookbook/integrations/chat-sdk.mdx +17 -0
- package/docs/cookbook/integrations/sandbox.mdx +17 -0
- package/docs/{deploying/index.mdx → deploying.mdx} +7 -7
- package/docs/errors/abort-signal-timeout-in-workflow.mdx +84 -0
- package/docs/errors/corrupted-event-log.mdx +11 -8
- package/docs/errors/deployment-mismatch.mdx +71 -0
- package/docs/errors/fetch-in-workflow.mdx +4 -0
- package/docs/errors/hook-conflict.mdx +60 -4
- package/docs/errors/index.mdx +1 -35
- package/docs/errors/node-js-module-in-workflow.mdx +4 -0
- package/docs/errors/replay-divergence.mdx +27 -0
- package/docs/errors/runtime-decryption-failed.mdx +77 -0
- package/docs/errors/serialization-failed.mdx +4 -0
- package/docs/errors/start-invalid-workflow-function.mdx +4 -0
- package/docs/errors/step-executed-multiple-times.mdx +23 -0
- package/docs/errors/step-not-registered.mdx +1 -1
- package/docs/errors/timeout-in-workflow.mdx +4 -0
- package/docs/errors/webhook-response-not-sent.mdx +4 -0
- 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 +243 -11
- package/docs/foundations/index.mdx +1 -23
- package/docs/foundations/meta.json +3 -1
- package/docs/foundations/serialization.mdx +77 -41
- package/docs/foundations/starting-workflows.mdx +79 -2
- package/docs/foundations/streaming.mdx +14 -23
- package/docs/foundations/versioning.mdx +263 -0
- package/docs/getting-started/astro.mdx +12 -2
- package/docs/getting-started/express.mdx +6 -2
- package/docs/getting-started/fastify.mdx +6 -2
- package/docs/getting-started/hono.mdx +6 -2
- package/docs/getting-started/index.mdx +16 -10
- package/docs/getting-started/meta.json +4 -1
- package/docs/getting-started/nestjs.mdx +77 -3
- package/docs/getting-started/next.mdx +12 -6
- package/docs/getting-started/nitro.mdx +28 -2
- package/docs/getting-started/nuxt.mdx +6 -2
- package/docs/getting-started/python.mdx +24 -18
- 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 +12 -2
- package/docs/getting-started/tanstack-start.mdx +245 -0
- package/docs/getting-started/vite.mdx +6 -2
- package/docs/how-it-works/cancellation.mdx +287 -0
- package/docs/how-it-works/code-transform.mdx +21 -17
- package/docs/how-it-works/encryption.mdx +5 -5
- package/docs/how-it-works/event-sourcing.mdx +17 -9
- package/docs/how-it-works/framework-integrations.mdx +96 -337
- 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/meta.json +2 -2
- package/docs/observability/attributes.mdx +112 -0
- package/docs/observability/index.mdx +20 -1
- package/docs/observability/meta.json +1 -1
- package/docs/observability/tracing.mdx +124 -0
- package/docs/testing/index.mdx +2 -2
- package/package.json +17 -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/distributed-abort-controller.mdx +0 -318
- package/docs/deploying/building-a-world.mdx +0 -251
- 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 -222
- package/docs/deploying/world/vercel-world.mdx +0 -179
- 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 -363
- package/docs/migration-guides/migrating-from-inngest.mdx +0 -314
- package/docs/migration-guides/migrating-from-temporal.mdx +0 -318
- package/docs/migration-guides/migrating-from-trigger-dev.mdx +0 -337
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: NestLocalBuilder
|
|
3
|
+
description: Builder that compiles workflow files into bundles for NestJS apps.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Use NestLocalBuilder to build workflow bundles programmatically in a NestJS project.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/getting-started/nestjs
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Builder that scans a NestJS project for workflow files and compiles them into the step, workflow, and webhook bundles plus a manifest. [`WorkflowModule.forRoot()`](/docs/api-reference/workflow-nest/workflow-module) creates and runs one automatically on startup — instantiate it yourself only when you need to build bundles outside the module lifecycle (e.g. a custom build script for production with `skipBuild`).
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```typescript title="scripts/build-workflows.ts" lineNumbers
|
|
15
|
+
import { NestLocalBuilder } from "workflow/nest/builder"; // [!code highlight]
|
|
16
|
+
|
|
17
|
+
const builder = new NestLocalBuilder({
|
|
18
|
+
dirs: ["src"],
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
await builder.build(); // [!code highlight]
|
|
22
|
+
|
|
23
|
+
console.log(`Workflow bundles written to ${builder.outDir}`);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API Signature
|
|
27
|
+
|
|
28
|
+
### Constructor
|
|
29
|
+
|
|
30
|
+
`new NestLocalBuilder(options?)` creates a builder for the given options.
|
|
31
|
+
|
|
32
|
+
### Parameters
|
|
33
|
+
|
|
34
|
+
| Parameter | Type | Description |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| `options` | `NestBuilderOptions` | Optional. Configures the workflow build. |
|
|
37
|
+
|
|
38
|
+
#### NestBuilderOptions
|
|
39
|
+
|
|
40
|
+
| Option | Type | Default | Description |
|
|
41
|
+
| --- | --- | --- | --- |
|
|
42
|
+
| `workingDir` | `string` | `process.cwd()` | Working directory for the NestJS application. |
|
|
43
|
+
| `dirs` | `string[]` | `['src']` | Directories to scan for workflow files. |
|
|
44
|
+
| `outDir` | `string` | `'.nestjs/workflow'` (relative to `workingDir`) | Output directory for generated workflow bundles. |
|
|
45
|
+
| `watch` | `boolean` | `false` | Enable watch mode for development. |
|
|
46
|
+
| `moduleType` | `'es6' \| 'commonjs'` | `'es6'` | SWC module compilation type. When `'commonjs'`, the builder rewrites externalized imports in the steps bundle to use `require()` via `createRequire`, avoiding ESM/CJS named-export interop issues with SWC's output. |
|
|
47
|
+
| `distDir` | `string` | `'dist'` | Directory where NestJS compiles `.ts` source files to `.js` (relative to `workingDir`). Used when `moduleType` is `'commonjs'` to resolve compiled file paths. Should match the `outDir` in your `tsconfig.json`. |
|
|
48
|
+
| `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. Can also be set via the `WORKFLOW_SOURCEMAP` environment variable. |
|
|
49
|
+
|
|
50
|
+
### Methods
|
|
51
|
+
|
|
52
|
+
#### `build()`
|
|
53
|
+
|
|
54
|
+
Builds the workflow bundles. Writes `steps.mjs`, `workflows.mjs`, `webhook.mjs`, and `manifest.json` to the output directory (plus a `.gitignore` covering the generated files when not deploying to Vercel). Returns `Promise<void>`.
|
|
55
|
+
|
|
56
|
+
### Properties
|
|
57
|
+
|
|
58
|
+
#### `outDir`
|
|
59
|
+
|
|
60
|
+
Read-only getter that returns the output directory for generated workflow bundles — the `outDir` option as passed, or the default `.nestjs/workflow` resolved against `workingDir`.
|
|
61
|
+
|
|
62
|
+
### Returns
|
|
63
|
+
|
|
64
|
+
The constructor returns a `NestLocalBuilder` instance.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: WorkflowController
|
|
3
|
+
description: NestJS controller that serves the workflow runtime routes.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: WorkflowController handles the well-known workflow endpoints in a NestJS app.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/getting-started/nestjs
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
NestJS controller that handles the well-known workflow endpoints under `.well-known/workflow/v1`. It dynamically imports the generated workflow bundles and converts between Express/Fastify requests and the Web API `Request`/`Response` objects the workflow runtime expects. Both the Express and Fastify HTTP adapters are supported.
|
|
11
|
+
|
|
12
|
+
[`WorkflowModule.forRoot()`](/docs/api-reference/workflow-nest/workflow-module) registers this controller automatically — you only register it yourself if you are not using `WorkflowModule`.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
When registering the controller manually, call [`configureWorkflowController`](/docs/api-reference/workflow-nest/configure-workflow-controller) first so it can locate the generated bundles; its route handlers throw otherwise.
|
|
17
|
+
|
|
18
|
+
```typescript title="src/app.module.ts" lineNumbers
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
import { Module } from "@nestjs/common";
|
|
21
|
+
import {
|
|
22
|
+
configureWorkflowController, // [!code highlight]
|
|
23
|
+
WorkflowController, // [!code highlight]
|
|
24
|
+
} from "workflow/nest";
|
|
25
|
+
|
|
26
|
+
configureWorkflowController(join(process.cwd(), ".nestjs/workflow")); // [!code highlight]
|
|
27
|
+
|
|
28
|
+
@Module({
|
|
29
|
+
controllers: [WorkflowController], // [!code highlight]
|
|
30
|
+
})
|
|
31
|
+
export class AppModule {}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Routes
|
|
35
|
+
|
|
36
|
+
| Route | Method | Description |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| `/.well-known/workflow/v1/flow` | `POST` | Executes workflow and step work items via the combined handler in `workflows.mjs` (step registrations are imported from `steps.mjs` first). |
|
|
39
|
+
| `/.well-known/workflow/v1/webhook/:token` | Any | Forwards webhook requests to the handler in `webhook.mjs`. |
|
|
40
|
+
| `/.well-known/workflow/v1/manifest.json` | `GET` | Serves the workflow manifest. Responds with `404` unless the `WORKFLOW_PUBLIC_MANIFEST=1` environment variable is set. |
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: WorkflowModule
|
|
3
|
+
description: NestJS module that builds workflow bundles and registers the workflow controller.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Import WorkflowModule.forRoot() in your AppModule to enable workflows in a NestJS app.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/getting-started/nestjs
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
NestJS module that provides workflow functionality. It builds the workflow bundles on module initialization (`onModuleInit`) and registers the [`WorkflowController`](/docs/api-reference/workflow-nest/workflow-controller) that serves the workflow runtime routes.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
Add `WorkflowModule.forRoot()` to the `imports` array of your root module.
|
|
15
|
+
|
|
16
|
+
```typescript title="src/app.module.ts" lineNumbers
|
|
17
|
+
import { Module } from "@nestjs/common";
|
|
18
|
+
import { WorkflowModule } from "workflow/nest"; // [!code highlight]
|
|
19
|
+
|
|
20
|
+
@Module({
|
|
21
|
+
imports: [WorkflowModule.forRoot()], // [!code highlight]
|
|
22
|
+
})
|
|
23
|
+
export class AppModule {}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If your NestJS project compiles to CommonJS via SWC, pass `moduleType` and `distDir` so the builder can rewrite imports in the generated bundles:
|
|
27
|
+
|
|
28
|
+
```typescript title="src/app.module.ts" lineNumbers
|
|
29
|
+
import { Module } from "@nestjs/common";
|
|
30
|
+
import { WorkflowModule } from "workflow/nest";
|
|
31
|
+
|
|
32
|
+
@Module({
|
|
33
|
+
imports: [
|
|
34
|
+
WorkflowModule.forRoot({
|
|
35
|
+
moduleType: "commonjs", // [!code highlight]
|
|
36
|
+
distDir: "dist", // [!code highlight]
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
})
|
|
40
|
+
export class AppModule {}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API Signature
|
|
44
|
+
|
|
45
|
+
### Static Methods
|
|
46
|
+
|
|
47
|
+
#### `forRoot(options?)`
|
|
48
|
+
|
|
49
|
+
Configures the module and returns a NestJS `DynamicModule` registered as `global`. It calls [`configureWorkflowController`](/docs/api-reference/workflow-nest/configure-workflow-controller) with the resolved output directory, and (unless `skipBuild` is set) creates a [`NestLocalBuilder`](/docs/api-reference/workflow-nest/nest-local-builder) that builds the workflow bundles when the module initializes.
|
|
50
|
+
|
|
51
|
+
### Parameters
|
|
52
|
+
|
|
53
|
+
| Parameter | Type | Description |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| `options` | `WorkflowModuleOptions` | Optional. Configures the workflow build. |
|
|
56
|
+
|
|
57
|
+
#### WorkflowModuleOptions
|
|
58
|
+
|
|
59
|
+
Extends [`NestBuilderOptions`](/docs/api-reference/workflow-nest/nest-local-builder#nestbuilderoptions) — all builder options are accepted, plus `skipBuild`:
|
|
60
|
+
|
|
61
|
+
| Option | Type | Default | Description |
|
|
62
|
+
| --- | --- | --- | --- |
|
|
63
|
+
| `skipBuild` | `boolean` | `false` | Skip building workflow bundles on startup. Useful in production when the bundles are pre-built. |
|
|
64
|
+
| `workingDir` | `string` | `process.cwd()` | Working directory for the NestJS application. |
|
|
65
|
+
| `dirs` | `string[]` | `['src']` | Directories to scan for workflow files. |
|
|
66
|
+
| `outDir` | `string` | `'.nestjs/workflow'` (relative to `workingDir`) | Output directory for generated workflow bundles. |
|
|
67
|
+
| `watch` | `boolean` | `false` | Enable watch mode for development. |
|
|
68
|
+
| `moduleType` | `'es6' \| 'commonjs'` | `'es6'` | SWC module compilation type. Set to `'commonjs'` if your NestJS project compiles to CJS via SWC. |
|
|
69
|
+
| `distDir` | `string` | `'dist'` | Directory where NestJS compiles `.ts` source files to `.js` (relative to `workingDir`). Used when `moduleType` is `'commonjs'`. Should match the `outDir` in your `tsconfig.json`. |
|
|
70
|
+
| `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. Defaults to `'inline'` in development and `false` in production. Can also be set via the `WORKFLOW_SOURCEMAP` environment variable. |
|
|
71
|
+
|
|
72
|
+
### Returns
|
|
73
|
+
|
|
74
|
+
`forRoot()` returns a `DynamicModule` to include in the `imports` array of your root module.
|
|
@@ -27,6 +27,39 @@ const workflowConfig = {}
|
|
|
27
27
|
export default withWorkflow(nextConfig, workflowConfig); // [!code highlight]
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
<Callout type="warn">
|
|
31
|
+
If a package in `serverExternalPackages` contains workflow code (`"use step"`,
|
|
32
|
+
`"use workflow"`, or serialization classes), `withWorkflow()` automatically
|
|
33
|
+
removes it from `serverExternalPackages` for the current build and prints a
|
|
34
|
+
warning. Workflow still compiles the package so its directives are transformed.
|
|
35
|
+
Remove that package from `serverExternalPackages` in your
|
|
36
|
+
`next.config` to silence the warning.
|
|
37
|
+
</Callout>
|
|
38
|
+
|
|
39
|
+
### Workflow Discovery in Next.js
|
|
40
|
+
|
|
41
|
+
`withWorkflow()` discovers workflows by scanning your Next.js entrypoints — App
|
|
42
|
+
Router `route`, `page`, and `layout` files (under `app/` or `src/app/`) and any
|
|
43
|
+
file under `pages/` or `src/pages/` — for `start()` calls imported from
|
|
44
|
+
`workflow/api`. The workflow and step files themselves can live anywhere (for
|
|
45
|
+
example `src/workflows/`); they are discovered transitively through imports, as
|
|
46
|
+
long as a `start()` call in an entrypoint statically reaches them.
|
|
47
|
+
|
|
48
|
+
<Callout type="info">
|
|
49
|
+
Call `start()` from server-side entrypoints, including Route Handlers and Server
|
|
50
|
+
Actions. Don't call workflow functions directly — that bypasses the workflow
|
|
51
|
+
runtime.
|
|
52
|
+
</Callout>
|
|
53
|
+
|
|
54
|
+
### Next.js Server Actions and `"use server"`
|
|
55
|
+
|
|
56
|
+
Don't put a top-level `"use server"` directive in modules imported by workflow
|
|
57
|
+
or step functions. Workflow transformation wraps imported modules in synchronous
|
|
58
|
+
initializers, and Next.js rejects a `"use server"` directive inside that wrapper
|
|
59
|
+
with errors like `Server Actions must be async functions`. Keep `"use server"`
|
|
60
|
+
on the files that define your Server Actions, and move shared logic into
|
|
61
|
+
separate modules that don't carry the directive.
|
|
62
|
+
|
|
30
63
|
### Monorepos and Workspace Imports
|
|
31
64
|
|
|
32
65
|
By default, Next.js detects the correct workspace root automatically. If your Next.js app lives in a subdirectory such as `apps/web` and workspace resolution is not working correctly, you can set `outputFileTracingRoot` as a workaround:
|
|
@@ -59,18 +92,38 @@ const nextConfig: NextConfig = {};
|
|
|
59
92
|
|
|
60
93
|
export default withWorkflow(nextConfig, {
|
|
61
94
|
workflows: {
|
|
62
|
-
lazyDiscovery: true,
|
|
63
95
|
local: {
|
|
64
96
|
port: 4000,
|
|
65
97
|
},
|
|
98
|
+
sourcemap: false,
|
|
66
99
|
},
|
|
67
100
|
});
|
|
68
101
|
```
|
|
69
102
|
|
|
70
103
|
| Option | Type | Default | Description |
|
|
71
104
|
| --- | --- | --- | --- |
|
|
72
|
-
| `workflows.lazyDiscovery` | `boolean` | `false` | When `true`, defers workflow discovery until files are requested instead of scanning eagerly at startup. Useful for large projects where startup time matters. |
|
|
73
105
|
| `workflows.local.port` | `number` | — | Overrides the `PORT` environment variable for local development. Has no effect when deployed to Vercel. |
|
|
106
|
+
| `workflows.sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. See [Source maps](#source-maps) below. |
|
|
107
|
+
|
|
108
|
+
### Source maps
|
|
109
|
+
|
|
110
|
+
The step bundle and intermediate workflow bundle default to `'inline'` source maps **in development** — so stack traces from step errors and workflow VM errors point at your source files — and to **`false` in production**, so function bundles stay small. The `sourcemap` option lets you change that:
|
|
111
|
+
|
|
112
|
+
| Value | Behavior |
|
|
113
|
+
| --- | --- |
|
|
114
|
+
| `true` / `'inline'` | Base64-encode the source map and append it to the bundle (default in development). |
|
|
115
|
+
| `'linked'` | Write a separate `.map` file and add a `sourceMappingURL` comment. |
|
|
116
|
+
| `'external'` | Write a separate `.map` file without the comment. |
|
|
117
|
+
| `'both'` | Emit both inline and external source maps. |
|
|
118
|
+
| `false` | Omit source maps entirely. |
|
|
119
|
+
|
|
120
|
+
In production, source maps are already off by default. Setting `sourcemap: false` explicitly also turns them off in development, and it drops the inline source map from every bundle while skipping the source-map-support runtime shim on the Vercel step function (the same behavior production gets by default) — the main lever for staying under the Vercel 250MB function size limit. The tradeoff is that workflow VM stack traces will reference generated code (e.g. `evalmachine.<anonymous>`) rather than your source files.
|
|
121
|
+
|
|
122
|
+
<Callout type="info">
|
|
123
|
+
Setting `sourcemap` explicitly affects **all** generated bundles (steps, workflows, webhook). The legacy `WORKFLOW_EMIT_SOURCEMAPS_FOR_DEBUGGING=1` environment variable is narrower — it only toggles source maps on the final workflow wrapper and webhook bundle (which default to off). It continues to work, but new code should use the `sourcemap` option or the `WORKFLOW_SOURCEMAP` environment variable instead.
|
|
124
|
+
</Callout>
|
|
125
|
+
|
|
126
|
+
The option can also be set via the `WORKFLOW_SOURCEMAP` environment variable, which accepts the same values plus `'0'` / `'1'` as aliases for `false` / `true`. Precedence is: explicit config > `WORKFLOW_SOURCEMAP` > the environment-aware default (`'inline'` in development, `false` in production). Development is detected from `next dev` / `NODE_ENV=development`, so the config option and the env var both let you force either behavior in either environment.
|
|
74
127
|
|
|
75
128
|
<Callout type="info">
|
|
76
129
|
The `workflows.local` options only affect local development. When deployed to Vercel, the runtime ignores `local` settings and uses the Vercel world automatically.
|
|
@@ -78,6 +131,7 @@ The `workflows.local` options only affect local development. When deployed to Ve
|
|
|
78
131
|
|
|
79
132
|
## Exporting a Function
|
|
80
133
|
|
|
134
|
+
|
|
81
135
|
If you are exporting a function in your `next.config` you will need to ensure you call the function returned from `withWorkflow`.
|
|
82
136
|
|
|
83
137
|
```typescript title="next.config.ts" lineNumbers
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "workflow/nitro"
|
|
3
|
+
description: Nitro module for automatic workflow bundling and route registration.
|
|
4
|
+
type: overview
|
|
5
|
+
summary: Explore the Nitro module that enables workflow directive transformation in Nitro apps.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/getting-started/nitro
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Nitro integration for Workflow SDK. The `workflow/nitro` entry point's default export is a [Nitro module](https://v3.nitro.build/guide/modules) — it has no callable API. You enable it by adding it to the `modules` array of your Nitro config and configure it via the `workflow` key.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```typescript title="nitro.config.ts" lineNumbers
|
|
15
|
+
import { defineConfig } from "nitro";
|
|
16
|
+
|
|
17
|
+
export default defineConfig({
|
|
18
|
+
serverDir: "./server",
|
|
19
|
+
modules: ["workflow/nitro"], // [!code highlight]
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
When enabled, the module:
|
|
24
|
+
|
|
25
|
+
- Transforms `"use workflow"` and `"use step"` directives during bundling.
|
|
26
|
+
- Builds the workflow, step, and webhook bundles, and rebuilds them on file changes in development.
|
|
27
|
+
- Registers the workflow runtime routes under `/.well-known/workflow/v1/`.
|
|
28
|
+
- Serves a redirect to the local observability dashboard at `/_workflow` in development.
|
|
29
|
+
- Configures Vercel function rules (queue triggers and `maxDuration`) for the workflow routes when deploying to Vercel.
|
|
30
|
+
- Uses Nitro's `workspaceDir` as the workflow project root so monorepo apps can import sibling workspace packages without extra workflow config.
|
|
31
|
+
|
|
32
|
+
## Module Options
|
|
33
|
+
|
|
34
|
+
Options are read from the `workflow` key of your Nitro config. The option type is exported as `ModuleOptions`:
|
|
35
|
+
|
|
36
|
+
```typescript title="nitro.config.ts" lineNumbers
|
|
37
|
+
import { defineConfig } from "nitro";
|
|
38
|
+
import type { ModuleOptions } from "workflow/nitro"; // [!code highlight]
|
|
39
|
+
|
|
40
|
+
const workflow: ModuleOptions = {
|
|
41
|
+
runtime: "nodejs22.x",
|
|
42
|
+
sourcemap: "inline",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default defineConfig({
|
|
46
|
+
modules: ["workflow/nitro"],
|
|
47
|
+
workflow, // [!code highlight]
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
| Option | Type | Default | Description |
|
|
52
|
+
| --- | --- | --- | --- |
|
|
53
|
+
| `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. |
|
|
54
|
+
| `typescriptPlugin` | `boolean` | `false` | Adds the `workflow` TypeScript plugin to the generated `tsconfig.json` for IDE IntelliSense. |
|
|
55
|
+
| `runtime` | `string` | — | Node.js runtime version for Vercel Functions (e.g. `'nodejs22.x'`, `'nodejs24.x'`). Only applies when deploying to Vercel. |
|
|
56
|
+
| `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. |
|
|
57
|
+
|
|
58
|
+
## Vite-based Nitro
|
|
59
|
+
|
|
60
|
+
If you use Nitro through its Vite plugin (`nitro/vite`) instead of a standalone `nitro.config.ts`, use the [`workflow/vite`](/docs/api-reference/workflow-vite) entry point, which wraps this module as a Vite plugin and accepts the same `ModuleOptions`.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "workflow/nuxt"
|
|
3
|
+
description: Nuxt module for automatic workflow bundling and runtime configuration.
|
|
4
|
+
type: overview
|
|
5
|
+
summary: Explore the Nuxt module that enables workflow directive transformation in Nuxt apps.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/getting-started/nuxt
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Nuxt integration for Workflow SDK. The `workflow/nuxt` entry point's default export is a Nuxt module — it has no callable API. You enable it by adding it to the `modules` array of your Nuxt config and configure it via the `workflow` key.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```typescript title="nuxt.config.ts" lineNumbers
|
|
15
|
+
import { defineNuxtConfig } from "nuxt/config";
|
|
16
|
+
|
|
17
|
+
export default defineNuxtConfig({
|
|
18
|
+
modules: ["workflow/nuxt"], // [!code highlight]
|
|
19
|
+
compatibilityDate: "latest",
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
When enabled, the module:
|
|
24
|
+
|
|
25
|
+
- Registers the [`workflow/nitro`](/docs/api-reference/workflow-nitro) module on Nuxt's Nitro server, which transforms `"use workflow"` and `"use step"` directives, builds the workflow bundles, and registers the workflow runtime routes under `/.well-known/workflow/v1/`.
|
|
26
|
+
- Configures Vite to bundle (rather than externalize) the Workflow SDK packages in SSR mode so workflow code is transformed correctly.
|
|
27
|
+
- Enables the `workflow` TypeScript plugin by default for IDE IntelliSense.
|
|
28
|
+
- Uses Nuxt/Nitro's detected `workspaceDir` so monorepo apps can import sibling workspace packages without extra workflow config.
|
|
29
|
+
|
|
30
|
+
## Module Options
|
|
31
|
+
|
|
32
|
+
Options are read from the `workflow` key of your Nuxt config. The option type is exported as `ModuleOptions`:
|
|
33
|
+
|
|
34
|
+
```typescript title="nuxt.config.ts" lineNumbers
|
|
35
|
+
import { defineNuxtConfig } from "nuxt/config";
|
|
36
|
+
|
|
37
|
+
export default defineNuxtConfig({
|
|
38
|
+
modules: ["workflow/nuxt"],
|
|
39
|
+
workflow: {
|
|
40
|
+
typescriptPlugin: false, // [!code highlight]
|
|
41
|
+
},
|
|
42
|
+
compatibilityDate: "latest",
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
| Option | Type | Default | Description |
|
|
47
|
+
| --- | --- | --- | --- |
|
|
48
|
+
| `typescriptPlugin` | `boolean` | `true` | Adds the `workflow` TypeScript plugin to the generated `tsconfig.json` for IDE IntelliSense. Set to `false` to disable it. |
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: hydrateData
|
|
3
|
+
description: Hydrate a single serialized value from workflow storage into a plain JavaScript value.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Use hydrateData to deserialize a single value when hydrateResourceIO's field mapping doesn't apply.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/api-reference/workflow-observability/hydrate-resource-io
|
|
8
|
+
- /docs/api-reference/workflow-observability/observability-revivers
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Hydrates (deserializes) a single value that was stored by the workflow runtime. This is the lower-level building block behind [`hydrateResourceIO()`](/docs/api-reference/workflow-observability/hydrate-resource-io) — use it when you have a raw serialized value rather than a whole resource, such as a single field from an event payload.
|
|
12
|
+
|
|
13
|
+
```typescript lineNumbers
|
|
14
|
+
import { hydrateData, observabilityRevivers } from "workflow/observability"; // [!code highlight]
|
|
15
|
+
declare const serialized: unknown; // @setup
|
|
16
|
+
|
|
17
|
+
const value = hydrateData(serialized, observabilityRevivers); // [!code highlight]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## API Signature
|
|
21
|
+
|
|
22
|
+
### Parameters
|
|
23
|
+
|
|
24
|
+
| Parameter | Type | Description |
|
|
25
|
+
|-----------|------|-------------|
|
|
26
|
+
| `value` | `unknown` | The serialized value from workflow storage |
|
|
27
|
+
| `revivers` | `Revivers` | Reviver functions for deserialization. Use [`observabilityRevivers`](/docs/api-reference/workflow-observability/observability-revivers) for standard use. |
|
|
28
|
+
|
|
29
|
+
### Returns
|
|
30
|
+
|
|
31
|
+
The hydrated plain JavaScript value. The input is handled by shape:
|
|
32
|
+
|
|
33
|
+
- Format-prefixed binary data (`Uint8Array`) is decoded and parsed from the [devalue](https://github.com/Rich-Harris/devalue) format
|
|
34
|
+
- Encrypted data is returned as-is (a raw `Uint8Array`) — see [Encrypted Data](/docs/api-reference/workflow-observability#encrypted-data)
|
|
35
|
+
- Already-plain values (numbers, strings, `null`) are returned unchanged
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: hydrateResourceIO
|
|
3
|
+
description: Hydrate the serialized data fields of a run, step, hook, or event for display.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Use hydrateResourceIO with observabilityRevivers to deserialize step input/output for display in observability tools.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/api-reference/workflow-runtime/get-world
|
|
8
|
+
related:
|
|
9
|
+
- /docs/api-reference/workflow-observability/observability-revivers
|
|
10
|
+
- /docs/api-reference/workflow-runtime/world/storage
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
Hydrates (deserializes) the data fields of a resource returned by the [World SDK](/docs/api-reference/workflow-runtime/world) — a workflow run, step, hook, or event. Workflow data is serialized using the [devalue](https://github.com/Rich-Harris/devalue) format, so this is required before displaying step input/output in a UI.
|
|
14
|
+
|
|
15
|
+
The function dispatches on the resource shape: steps get `input`/`output` hydrated, hooks get `metadata`, events get `eventData`, and runs get `input`/`output`.
|
|
16
|
+
|
|
17
|
+
```typescript lineNumbers
|
|
18
|
+
import { getWorld } from "workflow/runtime";
|
|
19
|
+
import { hydrateResourceIO, observabilityRevivers } from "workflow/observability"; // [!code highlight]
|
|
20
|
+
declare const runId: string; // @setup
|
|
21
|
+
declare const stepId: string; // @setup
|
|
22
|
+
|
|
23
|
+
const world = await getWorld();
|
|
24
|
+
const step = await world.steps.get(runId, stepId);
|
|
25
|
+
const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highlight]
|
|
26
|
+
console.log(hydrated.input, hydrated.output);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## API Signature
|
|
30
|
+
|
|
31
|
+
### Parameters
|
|
32
|
+
|
|
33
|
+
| Parameter | Type | Description |
|
|
34
|
+
|-----------|------|-------------|
|
|
35
|
+
| `resource` | `WorkflowRun \| Step \| Hook \| Event` | The resource with serialized data fields |
|
|
36
|
+
| `revivers` | `Revivers` | Reviver functions for deserialization. Use [`observabilityRevivers`](/docs/api-reference/workflow-observability/observability-revivers) for standard use. |
|
|
37
|
+
|
|
38
|
+
### Returns
|
|
39
|
+
|
|
40
|
+
The same resource with its data fields hydrated into plain JavaScript values.
|
|
41
|
+
|
|
42
|
+
<Callout type="info">
|
|
43
|
+
Encrypted data fields pass through as raw `Uint8Array` values rather than being decrypted — see [Encrypted Data](/docs/api-reference/workflow-observability#encrypted-data).
|
|
44
|
+
</Callout>
|
|
45
|
+
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
### Display a Run's Steps with Hydrated I/O
|
|
49
|
+
|
|
50
|
+
```typescript lineNumbers
|
|
51
|
+
import { getWorld } from "workflow/runtime";
|
|
52
|
+
import { hydrateResourceIO, observabilityRevivers } from "workflow/observability"; // [!code highlight]
|
|
53
|
+
declare const runId: string; // @setup
|
|
54
|
+
|
|
55
|
+
const world = await getWorld();
|
|
56
|
+
const steps = await world.steps.list({ runId, resolveData: "all" });
|
|
57
|
+
|
|
58
|
+
for (const step of steps.data) {
|
|
59
|
+
const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highlight]
|
|
60
|
+
console.log(step.stepName, hydrated.input, hydrated.output);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "workflow/observability"
|
|
3
|
+
description: Utilities to hydrate serialized step I/O and parse machine-readable workflow names for display.
|
|
4
|
+
type: overview
|
|
5
|
+
summary: Explore utilities for hydrating serialized workflow data and parsing display names in observability tools.
|
|
6
|
+
keywords:
|
|
7
|
+
- workflow/observability
|
|
8
|
+
- hydrateResourceIO
|
|
9
|
+
- observabilityRevivers
|
|
10
|
+
- hydrateData
|
|
11
|
+
- parseStepName
|
|
12
|
+
- parseWorkflowName
|
|
13
|
+
- parseClassName
|
|
14
|
+
- data hydration
|
|
15
|
+
- devalue deserialization
|
|
16
|
+
- display name parsing
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
API reference for observability utilities from the `workflow/observability` package.
|
|
20
|
+
|
|
21
|
+
The observability package provides utilities for working with workflow data in observability and debugging tools — hydrating serialized step I/O for display, and parsing machine-readable names into display-friendly formats.
|
|
22
|
+
|
|
23
|
+
```typescript lineNumbers
|
|
24
|
+
import { // [!code highlight]
|
|
25
|
+
hydrateResourceIO, // [!code highlight]
|
|
26
|
+
observabilityRevivers, // [!code highlight]
|
|
27
|
+
hydrateData, // [!code highlight]
|
|
28
|
+
parseStepName, // [!code highlight]
|
|
29
|
+
parseWorkflowName, // [!code highlight]
|
|
30
|
+
parseClassName, // [!code highlight]
|
|
31
|
+
} from "workflow/observability"; // [!code highlight]
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Data Hydration
|
|
35
|
+
|
|
36
|
+
<Cards>
|
|
37
|
+
<Card href="/docs/api-reference/workflow-observability/hydrate-resource-io" title="hydrateResourceIO()">
|
|
38
|
+
Hydrate the serialized data fields of a run, step, hook, or event for display.
|
|
39
|
+
</Card>
|
|
40
|
+
<Card href="/docs/api-reference/workflow-observability/observability-revivers" title="observabilityRevivers">
|
|
41
|
+
Standard revivers for deserializing workflow data types (Date, Map, Set, streams, etc.).
|
|
42
|
+
</Card>
|
|
43
|
+
<Card href="/docs/api-reference/workflow-observability/hydrate-data" title="hydrateData()">
|
|
44
|
+
Hydrate a single serialized value (lower-level than hydrateResourceIO).
|
|
45
|
+
</Card>
|
|
46
|
+
</Cards>
|
|
47
|
+
|
|
48
|
+
## Name Parsing
|
|
49
|
+
|
|
50
|
+
<Cards>
|
|
51
|
+
<Card href="/docs/api-reference/workflow-observability/parse-step-name" title="parseStepName()">
|
|
52
|
+
Parse a machine-readable step name into display-friendly components.
|
|
53
|
+
</Card>
|
|
54
|
+
<Card href="/docs/api-reference/workflow-observability/parse-workflow-name" title="parseWorkflowName()">
|
|
55
|
+
Parse a machine-readable workflow name into display-friendly components.
|
|
56
|
+
</Card>
|
|
57
|
+
<Card href="/docs/api-reference/workflow-observability/parse-class-name" title="parseClassName()">
|
|
58
|
+
Parse a machine-readable class ID into display-friendly components.
|
|
59
|
+
</Card>
|
|
60
|
+
</Cards>
|
|
61
|
+
|
|
62
|
+
## Encrypted Data
|
|
63
|
+
|
|
64
|
+
When a [World](/docs/api-reference/workflow-runtime/world) stores encrypted data, the hydration utilities intentionally leave encrypted values untouched: [`hydrateData()`](/docs/api-reference/workflow-observability/hydrate-data) and [`hydrateResourceIO()`](/docs/api-reference/workflow-observability/hydrate-resource-io) return encrypted fields as raw `Uint8Array` values so observability tools can detect them and decide how to render them (for example, the Workflow CLI shows an "Encrypted" placeholder). Decryption is handled by the runtime and the World implementation — see [Encryption](/docs/how-it-works/encryption) for how keys are managed.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: observabilityRevivers
|
|
3
|
+
description: Standard reviver functions for deserializing workflow data types in observability tools.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Pass observabilityRevivers to hydrateResourceIO or hydrateData to deserialize standard workflow data types.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/api-reference/workflow-observability/hydrate-resource-io
|
|
8
|
+
- /docs/api-reference/workflow-observability/hydrate-data
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
A set of reviver functions that handle the workflow serialization format's workflow-specific types — streams, step/workflow function references, class instances, `AbortController`/`AbortSignal`, and `DOMException` — reviving them as display-friendly marker objects or strings. Built-in JavaScript types (`Date`, `Map`, `Set`, `RegExp`, etc.) are handled by the devalue format itself and need no revivers.
|
|
12
|
+
|
|
13
|
+
Pass it as the `revivers` argument to [`hydrateResourceIO()`](/docs/api-reference/workflow-observability/hydrate-resource-io) or [`hydrateData()`](/docs/api-reference/workflow-observability/hydrate-data).
|
|
14
|
+
|
|
15
|
+
```typescript lineNumbers
|
|
16
|
+
import { hydrateResourceIO, observabilityRevivers } from "workflow/observability"; // [!code highlight]
|
|
17
|
+
import type { Step } from "@workflow/world";
|
|
18
|
+
declare const step: Step; // @setup
|
|
19
|
+
|
|
20
|
+
const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highlight]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## API Signature
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import type { Revivers } from "workflow/observability";
|
|
27
|
+
|
|
28
|
+
declare const observabilityRevivers: Revivers;
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Where `Revivers` is:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
type Revivers = Record<string, (value: any) => any>;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Each key is a serialized type tag, and each function revives a serialized value of that type. You can spread `observabilityRevivers` into a custom reviver map to override how specific types are displayed:
|
|
38
|
+
|
|
39
|
+
```typescript lineNumbers
|
|
40
|
+
import { hydrateData, observabilityRevivers } from "workflow/observability";
|
|
41
|
+
declare const value: unknown; // @setup
|
|
42
|
+
|
|
43
|
+
const customRevivers = {
|
|
44
|
+
...observabilityRevivers,
|
|
45
|
+
// Render stream references as plain strings instead of marker objects
|
|
46
|
+
ReadableStream: () => "<stream>",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const hydrated = hydrateData(value, customRevivers);
|
|
50
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: parseClassName
|
|
3
|
+
description: Parse a machine-readable class ID into display-friendly components.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Use parseClassName to extract a display-friendly class name from a serialized class instance identifier.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/api-reference/workflow-observability/parse-step-name
|
|
8
|
+
- /docs/api-reference/workflow-observability/parse-workflow-name
|
|
9
|
+
- /docs/api-reference/workflow-serde
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Serialized class instances reference their class with machine-readable IDs like `class//./src/models//User`. This function parses them into components suitable for display in a UI.
|
|
13
|
+
|
|
14
|
+
```typescript lineNumbers
|
|
15
|
+
import { parseClassName } from "workflow/observability"; // [!code highlight]
|
|
16
|
+
|
|
17
|
+
const parsed = parseClassName("class//./src/models//User"); // [!code highlight]
|
|
18
|
+
// parsed?.shortName → "User"
|
|
19
|
+
// parsed?.moduleSpecifier → "./src/models"
|
|
20
|
+
// parsed?.functionName → "User"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## API Signature
|
|
24
|
+
|
|
25
|
+
### Parameters
|
|
26
|
+
|
|
27
|
+
| Parameter | Type | Description |
|
|
28
|
+
|-----------|------|-------------|
|
|
29
|
+
| `name` | `string` | The machine-readable class ID |
|
|
30
|
+
|
|
31
|
+
### Returns
|
|
32
|
+
|
|
33
|
+
`{ shortName: string; moduleSpecifier: string; functionName: string } | null`
|
|
34
|
+
|
|
35
|
+
| Property | Description |
|
|
36
|
+
|----------|-------------|
|
|
37
|
+
| `shortName` | The display name of the class (e.g. `"User"`). |
|
|
38
|
+
| `moduleSpecifier` | The module the class is defined in — a relative path (`./src/models`) or a package specifier (`point@0.0.1`). |
|
|
39
|
+
| `functionName` | The class name as recorded by the compiler. |
|
|
40
|
+
|
|
41
|
+
Returns `null` when the input is not a valid class ID.
|