workflow 5.0.0-beta.9 → 5.0.1

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.
Files changed (265) hide show
  1. package/README.md +68 -23
  2. package/dist/api-workflow.d.ts +3 -1
  3. package/dist/api-workflow.d.ts.map +1 -1
  4. package/dist/api-workflow.js +2 -1
  5. package/dist/api.d.ts +5 -4
  6. package/dist/api.d.ts.map +1 -1
  7. package/dist/api.js +6 -7
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +6 -1
  11. package/dist/internal/builtins.d.ts +4 -4
  12. package/dist/internal/builtins.js +6 -6
  13. package/dist/internal/errors.d.ts +1 -1
  14. package/dist/internal/errors.d.ts.map +1 -1
  15. package/dist/internal/errors.js +2 -2
  16. package/dist/nest-builder.d.ts +2 -0
  17. package/dist/nest-builder.d.ts.map +1 -0
  18. package/dist/nest-builder.js +2 -0
  19. package/dist/nest-vercel-builder.d.ts +2 -0
  20. package/dist/nest-vercel-builder.d.ts.map +1 -0
  21. package/dist/nest-vercel-builder.js +2 -0
  22. package/dist/runtime.d.ts +2 -1
  23. package/dist/runtime.d.ts.map +1 -1
  24. package/dist/runtime.js +4 -1
  25. package/docs/advanced/dynamic-workflows.mdx +227 -0
  26. package/docs/advanced/index.mdx +13 -0
  27. package/docs/advanced/meta.json +5 -0
  28. package/docs/ai/chat-session-modeling.mdx +176 -422
  29. package/docs/ai/defining-tools.mdx +6 -7
  30. package/docs/ai/human-in-the-loop.mdx +16 -12
  31. package/docs/ai/index.mdx +67 -72
  32. package/docs/ai/message-queueing.mdx +71 -110
  33. package/docs/ai/meta.json +1 -0
  34. package/docs/ai/resumable-streams.mdx +40 -28
  35. package/docs/ai/sleep-and-delays.mdx +10 -10
  36. package/docs/ai/streaming-updates-from-tools.mdx +6 -6
  37. package/docs/api-reference/index.mdx +25 -1
  38. package/docs/api-reference/meta.json +8 -0
  39. package/docs/api-reference/vitest/index.mdx +68 -15
  40. package/docs/api-reference/workflow/create-hook.mdx +170 -10
  41. package/docs/api-reference/workflow/create-webhook.mdx +16 -15
  42. package/docs/api-reference/workflow/define-hook.mdx +41 -33
  43. package/docs/api-reference/workflow/fatal-error.mdx +30 -8
  44. package/docs/api-reference/workflow/fetch.mdx +14 -10
  45. package/docs/api-reference/workflow/get-step-metadata.mdx +2 -2
  46. package/docs/api-reference/workflow/get-workflow-metadata.mdx +3 -3
  47. package/docs/api-reference/workflow/get-writable.mdx +7 -7
  48. package/docs/api-reference/workflow/index.mdx +3 -3
  49. package/docs/api-reference/workflow/retryable-error.mdx +1 -1
  50. package/docs/api-reference/workflow/set-attributes.mdx +63 -0
  51. package/docs/api-reference/workflow/sleep.mdx +4 -4
  52. package/docs/api-reference/workflow-ai/durable-agent.mdx +63 -101
  53. package/docs/api-reference/workflow-ai/index.mdx +5 -5
  54. package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +67 -24
  55. package/docs/api-reference/workflow-api/get-hook-by-token.mdx +37 -15
  56. package/docs/api-reference/workflow-api/get-run.mdx +43 -8
  57. package/docs/api-reference/workflow-api/index.mdx +8 -9
  58. package/docs/api-reference/workflow-api/register-lifecycle-hooks.mdx +87 -0
  59. package/docs/api-reference/workflow-api/resume-hook.mdx +77 -12
  60. package/docs/api-reference/workflow-api/resume-webhook.mdx +15 -9
  61. package/docs/api-reference/workflow-api/start.mdx +107 -12
  62. package/docs/api-reference/workflow-astro/index.mdx +18 -0
  63. package/docs/api-reference/workflow-astro/meta.json +4 -0
  64. package/docs/api-reference/workflow-astro/workflow.mdx +45 -0
  65. package/docs/api-reference/workflow-errors/entity-conflict-error.mdx +4 -4
  66. package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
  67. package/docs/api-reference/workflow-errors/hook-force-claimed-error.mdx +70 -0
  68. package/docs/api-reference/workflow-errors/hook-not-found-error.mdx +8 -8
  69. package/docs/api-reference/workflow-errors/index.mdx +91 -0
  70. package/docs/api-reference/workflow-errors/meta.json +7 -0
  71. package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +68 -0
  72. package/docs/api-reference/workflow-errors/run-expired-error.mdx +2 -2
  73. package/docs/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
  74. package/docs/api-reference/workflow-errors/step-not-registered-error.mdx +5 -5
  75. package/docs/api-reference/workflow-errors/throttle-error.mdx +2 -2
  76. package/docs/api-reference/workflow-errors/too-early-error.mdx +2 -2
  77. package/docs/api-reference/workflow-errors/workflow-error.mdx +52 -0
  78. package/docs/api-reference/workflow-errors/workflow-not-registered-error.mdx +5 -6
  79. package/docs/api-reference/workflow-errors/workflow-run-cancelled-error.mdx +13 -6
  80. package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +12 -5
  81. package/docs/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
  82. package/docs/api-reference/workflow-errors/workflow-run-not-found-error.mdx +4 -4
  83. package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
  84. package/docs/api-reference/workflow-errors/workflow-world-error.mdx +8 -8
  85. package/docs/api-reference/workflow-globals.mdx +19 -11
  86. package/docs/api-reference/workflow-nest/configure-workflow-controller.mdx +37 -0
  87. package/docs/api-reference/workflow-nest/index.mdx +31 -0
  88. package/docs/api-reference/workflow-nest/meta.json +9 -0
  89. package/docs/api-reference/workflow-nest/nest-local-builder.mdx +64 -0
  90. package/docs/api-reference/workflow-nest/workflow-controller.mdx +46 -0
  91. package/docs/api-reference/workflow-nest/workflow-module.mdx +134 -0
  92. package/docs/api-reference/workflow-next/with-workflow.mdx +39 -17
  93. package/docs/api-reference/workflow-nitro/index.mdx +60 -0
  94. package/docs/api-reference/workflow-nuxt/index.mdx +48 -0
  95. package/docs/api-reference/workflow-observability/hydrate-data.mdx +35 -0
  96. package/docs/api-reference/workflow-observability/hydrate-resource-io.mdx +62 -0
  97. package/docs/api-reference/workflow-observability/index.mdx +62 -0
  98. package/docs/api-reference/workflow-observability/meta.json +11 -0
  99. package/docs/api-reference/workflow-observability/observability-revivers.mdx +50 -0
  100. package/docs/api-reference/workflow-observability/parse-class-name.mdx +41 -0
  101. package/docs/api-reference/workflow-observability/parse-step-name.mdx +40 -0
  102. package/docs/api-reference/workflow-observability/parse-workflow-name.mdx +55 -0
  103. package/docs/api-reference/workflow-runtime/create-world.mdx +39 -0
  104. package/docs/api-reference/workflow-runtime/get-world-handlers.mdx +44 -0
  105. package/docs/api-reference/{workflow-api → workflow-runtime}/get-world.mdx +11 -14
  106. package/docs/api-reference/workflow-runtime/health-check.mdx +51 -0
  107. package/docs/api-reference/workflow-runtime/index.mdx +41 -0
  108. package/docs/api-reference/workflow-runtime/meta.json +12 -0
  109. package/docs/api-reference/workflow-runtime/set-world.mdx +51 -0
  110. package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +43 -0
  111. package/docs/api-reference/workflow-runtime/world/analytics.mdx +315 -0
  112. package/docs/api-reference/workflow-runtime/world/index.mdx +60 -0
  113. package/docs/api-reference/workflow-runtime/world/meta.json +4 -0
  114. package/docs/api-reference/workflow-runtime/world/queue.mdx +88 -0
  115. package/docs/api-reference/{workflow-api → workflow-runtime}/world/storage.mdx +133 -35
  116. package/docs/api-reference/{workflow-api → workflow-runtime}/world/streams.mdx +8 -8
  117. package/docs/api-reference/workflow-serde/index.mdx +1 -2
  118. package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +3 -4
  119. package/docs/api-reference/workflow-serde/workflow-serialize.mdx +8 -8
  120. package/docs/api-reference/workflow-sveltekit/index.mdx +18 -0
  121. package/docs/api-reference/workflow-sveltekit/meta.json +4 -0
  122. package/docs/api-reference/workflow-sveltekit/workflow-plugin.mdx +42 -0
  123. package/docs/api-reference/workflow-vite/index.mdx +18 -0
  124. package/docs/api-reference/workflow-vite/meta.json +4 -0
  125. package/docs/api-reference/workflow-vite/workflow.mdx +48 -0
  126. package/docs/changelog/attributes-mvp.mdx +53 -41
  127. package/docs/changelog/batched-event-writes.mdx +79 -0
  128. package/docs/changelog/eager-processing.mdx +110 -436
  129. package/docs/changelog/index.mdx +4 -2
  130. package/docs/changelog/lazy-event-creation.md +127 -0
  131. package/docs/changelog/lazy-hook-resume.mdx +78 -0
  132. package/docs/changelog/meta.json +11 -1
  133. package/docs/changelog/resilient-resume.mdx +32 -0
  134. package/docs/changelog/resilient-start.mdx +33 -285
  135. package/docs/changelog/step-message-ownership.mdx +360 -0
  136. package/docs/changelog/turbo-mode.md +87 -0
  137. package/docs/comparisons/index.mdx +66 -0
  138. package/docs/comparisons/meta.json +11 -0
  139. package/docs/comparisons/workflow-sdk-vs-aws-agentcore.mdx +55 -0
  140. package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +111 -0
  141. package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +71 -0
  142. package/docs/comparisons/workflow-sdk-vs-inngest.mdx +102 -0
  143. package/docs/comparisons/workflow-sdk-vs-temporal.mdx +123 -0
  144. package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +104 -0
  145. package/docs/configuration/build-and-diagnostics.mdx +89 -0
  146. package/docs/configuration/cli-and-web-ui.mdx +241 -0
  147. package/docs/configuration/framework-options.mdx +165 -0
  148. package/docs/configuration/index.mdx +32 -0
  149. package/docs/configuration/meta.json +12 -0
  150. package/docs/configuration/runtime-tuning.mdx +424 -0
  151. package/docs/configuration/worlds.mdx +341 -0
  152. package/docs/cookbook/advanced/child-workflows.mdx +33 -25
  153. package/docs/cookbook/advanced/publishing-libraries.mdx +65 -56
  154. package/docs/cookbook/advanced/serializable-steps.mdx +48 -68
  155. package/docs/cookbook/advanced/upgrading-workflows.mdx +35 -31
  156. package/docs/cookbook/agent-patterns/agent-cancellation.mdx +78 -60
  157. package/docs/cookbook/agent-patterns/durable-agent.mdx +23 -135
  158. package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +180 -195
  159. package/docs/cookbook/common-patterns/batching.mdx +20 -14
  160. package/docs/cookbook/common-patterns/idempotency.mdx +41 -53
  161. package/docs/cookbook/common-patterns/rate-limiting.mdx +8 -4
  162. package/docs/cookbook/common-patterns/saga.mdx +23 -19
  163. package/docs/cookbook/common-patterns/scheduling.mdx +30 -22
  164. package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +29 -25
  165. package/docs/cookbook/common-patterns/timeouts.mdx +26 -21
  166. package/docs/cookbook/common-patterns/webhooks.mdx +12 -7
  167. package/docs/cookbook/common-patterns/workflow-composition.mdx +27 -17
  168. package/docs/cookbook/index.mdx +22 -22
  169. package/docs/cookbook/integrations/ai-sdk.mdx +63 -48
  170. package/docs/cookbook/integrations/chat-sdk.mdx +46 -33
  171. package/docs/cookbook/integrations/sandbox.mdx +58 -45
  172. package/docs/deploying.mdx +106 -0
  173. package/docs/errors/abort-signal-timeout-in-workflow.mdx +16 -12
  174. package/docs/errors/corrupted-event-log.mdx +39 -18
  175. package/docs/errors/deployment-mismatch.mdx +71 -0
  176. package/docs/errors/fetch-in-workflow.mdx +15 -14
  177. package/docs/errors/hook-conflict.mdx +38 -11
  178. package/docs/errors/hook-force-claimed.mdx +96 -0
  179. package/docs/errors/index.mdx +24 -37
  180. package/docs/errors/node-js-module-in-workflow.mdx +9 -5
  181. package/docs/errors/replay-divergence.mdx +27 -0
  182. package/docs/errors/run-expired.mdx +85 -0
  183. package/docs/errors/runtime-decryption-failed.mdx +77 -0
  184. package/docs/errors/serialization-failed.mdx +44 -12
  185. package/docs/errors/start-invalid-workflow-function.mdx +9 -5
  186. package/docs/errors/step-executed-multiple-times.mdx +23 -0
  187. package/docs/errors/step-not-registered.mdx +6 -6
  188. package/docs/errors/timeout-in-workflow.mdx +12 -8
  189. package/docs/errors/webhook-invalid-respond-with-value.mdx +18 -18
  190. package/docs/errors/webhook-response-not-sent.mdx +20 -16
  191. package/docs/errors/workflow-not-registered.mdx +5 -5
  192. package/docs/foundations/cancellation.mdx +31 -32
  193. package/docs/foundations/errors-and-retries.mdx +54 -11
  194. package/docs/foundations/hooks.mdx +187 -36
  195. package/docs/foundations/idempotency.mdx +267 -12
  196. package/docs/foundations/index.mdx +1 -26
  197. package/docs/foundations/serialization.mdx +22 -22
  198. package/docs/foundations/starting-workflows.mdx +104 -30
  199. package/docs/foundations/streaming.mdx +108 -60
  200. package/docs/foundations/versioning.mdx +4 -4
  201. package/docs/foundations/workflows-and-steps.mdx +10 -10
  202. package/docs/getting-started/astro.mdx +22 -18
  203. package/docs/getting-started/express.mdx +15 -11
  204. package/docs/getting-started/fastify.mdx +15 -11
  205. package/docs/getting-started/hono.mdx +15 -11
  206. package/docs/getting-started/index.mdx +10 -3
  207. package/docs/getting-started/meta.json +3 -1
  208. package/docs/getting-started/nestjs.mdx +264 -21
  209. package/docs/getting-started/next.mdx +18 -14
  210. package/docs/getting-started/nitro.mdx +22 -18
  211. package/docs/getting-started/nuxt.mdx +15 -11
  212. package/docs/getting-started/python.mdx +190 -41
  213. package/docs/getting-started/react-router/index.mdx +33 -0
  214. package/docs/getting-started/react-router/meta.json +5 -0
  215. package/docs/getting-started/react-router/v7.mdx +237 -0
  216. package/docs/getting-started/react-router/v8.mdx +232 -0
  217. package/docs/getting-started/sveltekit.mdx +20 -16
  218. package/docs/getting-started/tanstack-start.mdx +17 -13
  219. package/docs/getting-started/vite.mdx +15 -11
  220. package/docs/how-it-works/cancellation.mdx +63 -63
  221. package/docs/how-it-works/code-transform.mdx +82 -66
  222. package/docs/how-it-works/encryption.mdx +30 -26
  223. package/docs/how-it-works/event-sourcing.mdx +132 -35
  224. package/docs/how-it-works/framework-integrations.mdx +96 -337
  225. package/docs/how-it-works/understanding-directives.mdx +22 -22
  226. package/docs/internal/index.mdx +6 -4
  227. package/docs/internal/meta.json +6 -1
  228. package/docs/internal/nitro-native-build.mdx +38 -0
  229. package/docs/internal/nitro-web-ui.mdx +24 -0
  230. package/docs/internal/serializable-abort-controller.mdx +7 -7
  231. package/docs/meta.json +4 -2
  232. package/docs/observability/attributes.mdx +91 -21
  233. package/docs/observability/index.mdx +29 -15
  234. package/docs/observability/lifecycle-hooks.mdx +95 -0
  235. package/docs/observability/meta.json +1 -1
  236. package/docs/observability/retention.mdx +95 -0
  237. package/docs/observability/tracing.mdx +124 -0
  238. package/docs/testing/index.mdx +118 -38
  239. package/docs/testing/server-based.mdx +10 -10
  240. package/docs/whats-new.mdx +196 -0
  241. package/docs/worlds/building-a-world.mdx +600 -0
  242. package/docs/worlds/local.mdx +129 -0
  243. package/docs/worlds/meta.json +10 -0
  244. package/docs/worlds/postgres.mdx +428 -0
  245. package/docs/worlds/upgrading-to-v5.mdx +183 -0
  246. package/docs/worlds/vercel.mdx +389 -0
  247. package/package.json +17 -14
  248. package/docs/api-reference/workflow/experimental-set-attributes.mdx +0 -63
  249. package/docs/api-reference/workflow-api/world/index.mdx +0 -58
  250. package/docs/api-reference/workflow-api/world/meta.json +0 -4
  251. package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
  252. package/docs/api-reference/workflow-api/world/queue.mdx +0 -86
  253. package/docs/deploying/building-a-world.mdx +0 -251
  254. package/docs/deploying/index.mdx +0 -95
  255. package/docs/deploying/meta.json +0 -4
  256. package/docs/deploying/world/local-world.mdx +0 -84
  257. package/docs/deploying/world/meta.json +0 -4
  258. package/docs/deploying/world/postgres-world.mdx +0 -224
  259. package/docs/deploying/world/vercel-world.mdx +0 -181
  260. package/docs/migration-guides/index.mdx +0 -34
  261. package/docs/migration-guides/meta.json +0 -9
  262. package/docs/migration-guides/migrating-from-aws-step-functions.mdx +0 -358
  263. package/docs/migration-guides/migrating-from-inngest.mdx +0 -304
  264. package/docs/migration-guides/migrating-from-temporal.mdx +0 -313
  265. package/docs/migration-guides/migrating-from-trigger-dev.mdx +0 -328
@@ -0,0 +1,37 @@
1
+ ---
2
+ title: configureWorkflowController
3
+ description: Point WorkflowController at the generated workflow bundles.
4
+ type: reference
5
+ summary: Configure the directory WorkflowController loads workflow bundles from.
6
+ prerequisites:
7
+ - /docs/getting-started/nestjs
8
+ ---
9
+
10
+ Configures the output directory that [`WorkflowController`](/docs/api-reference/workflow-nest/workflow-controller) loads the generated workflow bundles (`steps.mjs`, `workflows.mjs`, `webhook.mjs`, `manifest.json`) from.
11
+
12
+ <Callout type="warn">
13
+ Deprecated. [`WorkflowModule.forRoot()`](/docs/api-reference/workflow-nest/workflow-module) provides the output directory through dependency injection, which this function predates. It writes process-global state, so two applications in one process (the usual `Test.createTestingModule` setup) overwrite each other's configuration. It is kept only so existing callers keep working.
14
+ </Callout>
15
+
16
+ `WorkflowModule.forRoot()` still calls this for you, and injected options take precedence over it. Call it yourself only when registering `WorkflowController` without the module. A controller with no configuration at all answers `503` with an explanatory message.
17
+
18
+ ## Usage
19
+
20
+ ```typescript title="src/app.module.ts" lineNumbers
21
+ import { join } from "node:path";
22
+ import { configureWorkflowController } from "workflow/nest"; // [!code highlight]
23
+
24
+ configureWorkflowController(join(process.cwd(), ".nestjs/workflow")); // [!code highlight]
25
+ ```
26
+
27
+ ## API signature
28
+
29
+ ### Parameters
30
+
31
+ | Parameter | Type | Description |
32
+ | --- | --- | --- |
33
+ | `outDir` | `string` | Directory containing the generated workflow bundles. Should match the `outDir` used by the builder (default: `.nestjs/workflow` in the working directory). |
34
+
35
+ ### Returns
36
+
37
+ Returns `void`.
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: "workflow/nest"
3
+ description: NestJS integration for workflow bundling and HTTP routing.
4
+ type: overview
5
+ summary: Explore the NestJS integration for workflow bundle building and runtime routing.
6
+ related:
7
+ - /docs/getting-started/nestjs
8
+ ---
9
+
10
+ NestJS integration for Workflow SDK. The `WorkflowModule` builds the workflow bundles on application startup and registers the controller that serves the workflow runtime routes.
11
+
12
+ <Callout>
13
+ NestJS integration is experimental and not yet supported for deployment to Vercel. The same exports are also available from the `@workflow/nest` package.
14
+ </Callout>
15
+
16
+ ## Exports
17
+
18
+ <Cards>
19
+ <Card title="WorkflowModule" href="/docs/api-reference/workflow-nest/workflow-module">
20
+ NestJS module that builds workflow bundles on startup and registers the workflow controller
21
+ </Card>
22
+ <Card title="NestLocalBuilder" href="/docs/api-reference/workflow-nest/nest-local-builder">
23
+ Builder that compiles workflow files into step, workflow, and webhook bundles
24
+ </Card>
25
+ <Card title="WorkflowController" href="/docs/api-reference/workflow-nest/workflow-controller">
26
+ Controller that serves the workflow runtime routes under `.well-known/workflow/v1`
27
+ </Card>
28
+ <Card title="configureWorkflowController()" href="/docs/api-reference/workflow-nest/configure-workflow-controller">
29
+ Points `WorkflowController` at the directory containing the generated workflow bundles
30
+ </Card>
31
+ </Cards>
@@ -0,0 +1,9 @@
1
+ {
2
+ "title": "workflow/nest",
3
+ "pages": [
4
+ "workflow-module",
5
+ "nest-local-builder",
6
+ "workflow-controller",
7
+ "configure-workflow-controller"
8
+ ]
9
+ }
@@ -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()` through `createRequire`, avoiding ECMAScript module (ESM) and CommonJS (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,46 @@
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
+ The conversion preserves bytes in both directions: request bodies come from `req.rawBody` when the app is created with `{ rawBody: true }`, from a `Buffer`/string body left by a parser, or read directly from the request stream when no parser claimed the content type. Responses are written as bytes, and every `set-cookie` value is kept. See [Raw request bodies](/docs/getting-started/nestjs#raw-request-bodies).
13
+
14
+ Handlers take `@Res()`, so the application's interceptors and exception filters do not wrap these routes. That is deliberate: the queue and third-party webhook senders key off the exact status and body the workflow runtime produces.
15
+
16
+ [`WorkflowModule.forRoot()`](/docs/api-reference/workflow-nest/workflow-module) registers this controller automatically. You only register it yourself if you are not using `WorkflowModule`.
17
+
18
+ ## Usage
19
+
20
+ 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.
21
+
22
+ ```typescript title="src/app.module.ts" lineNumbers
23
+ import { join } from "node:path";
24
+ import { Module } from "@nestjs/common";
25
+ import {
26
+ configureWorkflowController, // [!code highlight]
27
+ WorkflowController, // [!code highlight]
28
+ } from "workflow/nest";
29
+
30
+ configureWorkflowController(join(process.cwd(), ".nestjs/workflow")); // [!code highlight]
31
+
32
+ @Module({
33
+ controllers: [WorkflowController], // [!code highlight]
34
+ })
35
+ export class AppModule {}
36
+ ```
37
+
38
+ ## Routes
39
+
40
+ | Route | Method | Description |
41
+ | --- | --- | --- |
42
+ | `/.well-known/workflow/v1/flow` | `POST`, `GET`, `HEAD`, `OPTIONS` | Executes workflow and step work items via the combined handler in `workflows.mjs` (step registrations are imported from `steps.mjs` first). `HEAD` is what local port detection probes to identify a workflow server, so all four methods are served. |
43
+ | `/.well-known/workflow/v1/webhook/:token` | Any | Forwards webhook requests to the handler in `webhook.mjs`. |
44
+ | `/.well-known/workflow/v1/manifest.json` | `GET` | Serves the workflow manifest. Responds with `404` unless the `WORKFLOW_PUBLIC_MANIFEST=1` environment variable is set. |
45
+
46
+ A route whose bundle cannot be loaded answers `503` with a message naming the missing file and the build command that produces it, rather than surfacing a raw `ERR_MODULE_NOT_FOUND`.
@@ -0,0 +1,134 @@
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 provides the resolved options under the `WORKFLOW_MODULE_OPTIONS` token, 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
+ #### `forRootAsync(options)`
52
+
53
+ Same as `forRoot`, with the options produced by a factory so they can come from other providers.
54
+
55
+ {/* @skip-typecheck - config snippet, WorkflowModule imported above */}
56
+
57
+ ```typescript title="src/app.module.ts" lineNumbers
58
+ WorkflowModule.forRootAsync({
59
+ imports: [ConfigModule],
60
+ inject: [ConfigService],
61
+ useFactory: (config: ConfigService) => ({
62
+ basePath: config.get("API_PREFIX"),
63
+ }),
64
+ });
65
+ ```
66
+
67
+ | Parameter | Type | Description |
68
+ | --- | --- | --- |
69
+ | `imports` | `unknown[]` | Optional. Modules whose exported providers the factory injects. |
70
+ | `inject` | `unknown[]` | Optional. Providers passed to `useFactory`, in order. |
71
+ | `useFactory` | `(...args) => WorkflowModuleOptions \| Promise<WorkflowModuleOptions>` | Returns the module options. |
72
+
73
+ ### Parameters
74
+
75
+ | Parameter | Type | Description |
76
+ | --- | --- | --- |
77
+ | `options` | `WorkflowModuleOptions` | Optional. Configures the workflow build. |
78
+
79
+ #### WorkflowModuleOptions
80
+
81
+ Extends [`NestBuilderOptions`](/docs/api-reference/workflow-nest/nest-local-builder#nestbuilderoptions): all builder options are accepted, plus `skipBuild`:
82
+
83
+ | Option | Type | Default | Description |
84
+ | --- | --- | --- | --- |
85
+ | `skipBuild` | `boolean` | `true` when `VERCEL` is set, else `false` | Skip building workflow bundles on startup. The bundles must already exist; startup fails with an explicit error if they do not. |
86
+ | `basePath` | `string` | adopted from `app.setGlobalPrefix()` | Route prefix the workflow endpoints are served under, applied to generated callback and webhook URLs. Set it when a reverse proxy mounts the app on a sub-path NestJS cannot see. |
87
+ | `manageWorldLifecycle` | `boolean` | `false` | Start the target World's background workers with the app and close them on shutdown. Required for self-hosted Worlds, which otherwise never pick up runs. |
88
+ | `preloadBundles` | `boolean` | `false` when `VERCEL` is set, else `true` | Load the generated bundles during startup instead of on the first request. On Vercel, dedicated functions serve the bundles, so there is nothing to preload. |
89
+ | `workingDir` | `string` | `process.cwd()` | Working directory for the NestJS application. |
90
+ | `dirs` | `string[]` | `['src']` | Directories to scan for workflow files. |
91
+ | `outDir` | `string` | `'.nestjs/workflow'` (relative to `workingDir`) | Output directory for generated workflow bundles. |
92
+ | `watch` | `boolean` | `false` | Deprecated and ignored. Watch mode is not implemented for this builder. Use `nest start --watch`, which re-runs the startup build. |
93
+ | `moduleType` | `'es6' \| 'commonjs'` | `'es6'` | SWC module compilation type. Set to `'commonjs'` if your NestJS project compiles to CommonJS (CJS) through SWC. |
94
+ | `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`. |
95
+ | `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. |
96
+
97
+ ### Returns
98
+
99
+ `forRoot()` and `forRootAsync()` return a `DynamicModule` to include in the `imports` array of your root module.
100
+
101
+ ## Injecting the resolved options
102
+
103
+ Both factories export the resolved options under `WORKFLOW_MODULE_OPTIONS`:
104
+
105
+ {/* @skip-typecheck - NestJS decorators require special TypeScript config */}
106
+
107
+ ```typescript title="src/some.service.ts" lineNumbers
108
+ import { Inject, Injectable } from "@nestjs/common";
109
+ import {
110
+ WORKFLOW_MODULE_OPTIONS,
111
+ type WorkflowModuleOptions,
112
+ } from "workflow/nest";
113
+
114
+ @Injectable()
115
+ export class SomeService {
116
+ constructor(
117
+ @Inject(WORKFLOW_MODULE_OPTIONS)
118
+ private readonly options: WorkflowModuleOptions
119
+ ) {}
120
+ }
121
+ ```
122
+
123
+ The older `WORKFLOW_OPTIONS` token resolves to the same value and is kept for compatibility.
124
+
125
+ ## Lifecycle
126
+
127
+ | Hook | Behaviour |
128
+ | --- | --- |
129
+ | `onModuleInit` | Reconciles the base path against `app.setGlobalPrefix()`, builds the bundles (or verifies they exist when `skipBuild` is set), optionally starts the World, and preloads the bundles. |
130
+ | `onApplicationShutdown` | Closes the World when `manageWorldLifecycle` is set. Call `app.enableShutdownHooks()` so this runs on a signal. |
131
+
132
+ <Callout type="warn">
133
+ Workflows and steps run outside the NestJS injector, so providers cannot be injected into `"use workflow"` or `"use step"` code. See [NestJS dependency injection is not available in workflows and steps](/docs/getting-started/nestjs#nestjs-dependency-injection-is-not-available-in-workflows-and-steps).
134
+ </Callout>
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  title: withWorkflow
3
- description: Configure webpack/turbopack to transform workflow directives in Next.js.
3
+ description: Configure webpack and Turbopack to transform workflow directives in Next.js.
4
4
  type: reference
5
5
  summary: Wrap your Next.js config with withWorkflow to enable workflow directive transformation.
6
6
  prerequisites:
7
7
  - /docs/getting-started/next
8
8
  ---
9
9
 
10
- Configures webpack/turbopack loaders to transform workflow code (`"use step"`/`"use workflow"` directives)
10
+ Configures webpack and Turbopack loaders to transform workflow code (`"use step"` and `"use workflow"` directives).
11
11
 
12
12
  ## Usage
13
13
 
@@ -16,13 +16,13 @@ To enable `"use step"` and `"use workflow"` directives while developing locally
16
16
  ```typescript title="next.config.ts" lineNumbers
17
17
  import { withWorkflow } from "workflow/next"; // [!code highlight]
18
18
  import type { NextConfig } from "next";
19
-
19
+
20
20
  const nextConfig: NextConfig = {
21
21
  // … rest of your Next.js config
22
22
  };
23
23
 
24
24
  // not required but allows configuring workflow options
25
- const workflowConfig = {}
25
+ const workflowConfig = {};
26
26
 
27
27
  export default withWorkflow(nextConfig, workflowConfig); // [!code highlight]
28
28
  ```
@@ -31,12 +31,36 @@ export default withWorkflow(nextConfig, workflowConfig); // [!code highlight]
31
31
  If a package in `serverExternalPackages` contains workflow code (`"use step"`,
32
32
  `"use workflow"`, or serialization classes), `withWorkflow()` automatically
33
33
  removes it from `serverExternalPackages` for the current build and prints a
34
- warning. This ensures the package still gets transformed by the Workflow
35
- compiler. Remove that package from `serverExternalPackages` in your
34
+ warning. Workflow still compiles the package so its directives are transformed.
35
+ Remove that package from `serverExternalPackages` in your
36
36
  `next.config` to silence the warning.
37
37
  </Callout>
38
38
 
39
- ### Monorepos and Workspace Imports
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, which 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
+
63
+ ### Monorepos and workspace imports
40
64
 
41
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:
42
66
 
@@ -68,7 +92,6 @@ const nextConfig: NextConfig = {};
68
92
 
69
93
  export default withWorkflow(nextConfig, {
70
94
  workflows: {
71
- lazyDiscovery: false,
72
95
  local: {
73
96
  port: 4000,
74
97
  },
@@ -79,35 +102,34 @@ export default withWorkflow(nextConfig, {
79
102
 
80
103
  | Option | Type | Default | Description |
81
104
  | --- | --- | --- | --- |
82
- | `workflows.lazyDiscovery` | `boolean` | `true` | Defers workflow discovery until files are requested instead of scanning eagerly at startup. Set to `false` to force eager discovery (scanning the project up front). Requires a Next.js version that supports deferred entries; older versions fall back to eager discovery automatically. |
83
105
  | `workflows.local.port` | `number` | — | Overrides the `PORT` environment variable for local development. Has no effect when deployed to Vercel. |
84
- | `workflows.sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` | Controls source maps on generated workflow bundles. See [Source maps](#source-maps) below. |
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. |
85
107
 
86
108
  ### Source maps
87
109
 
88
- The step bundle and intermediate workflow bundle default to `'inline'` source maps so that stack traces from step errors and workflow VM errors point at your source files. The `sourcemap` option lets you change that:
110
+ The step bundle and intermediate workflow bundle default to `'inline'` source maps **in development** (so stack traces from step errors and workflow virtual machine (VM) errors point at your source files) and to **`false` in production**, so function bundles stay small. The `sourcemap` option lets you change that:
89
111
 
90
112
  | Value | Behavior |
91
113
  | --- | --- |
92
- | `true` / `'inline'` | Base64-encode the source map and append it to the bundle (default). |
114
+ | `true` / `'inline'` | Base64-encode the source map and append it to the bundle (default in development). |
93
115
  | `'linked'` | Write a separate `.map` file and add a `sourceMappingURL` comment. |
94
116
  | `'external'` | Write a separate `.map` file without the comment. |
95
117
  | `'both'` | Emit both inline and external source maps. |
96
118
  | `false` | Omit source maps entirely. |
97
119
 
98
- Setting `sourcemap: false` is the main escape hatch for users hitting the Vercel 250MB function size limit — it drops the inline source map from every bundle and also skips the source-map-support runtime shim on the Vercel step function. The tradeoff is that workflow VM stack traces will reference generated code (e.g. `evalmachine.<anonymous>`) rather than your source files.
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 250 MB function size limit. The tradeoff is that workflow VM stack traces will reference generated code (for example, `evalmachine.<anonymous>`) rather than your source files.
99
121
 
100
122
  <Callout type="info">
101
- 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.
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.
102
124
  </Callout>
103
125
 
104
- 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` > per-bundle default.
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.
105
127
 
106
128
  <Callout type="info">
107
129
  The `workflows.local` options only affect local development. When deployed to Vercel, the runtime ignores `local` settings and uses the Vercel world automatically.
108
130
  </Callout>
109
131
 
110
- ## Exporting a Function
132
+ ## Exporting a function
111
133
 
112
134
 
113
135
  If you are exporting a function in your `next.config` you will need to ensure you call the function returned from `withWorkflow`.
@@ -136,4 +158,4 @@ export default async function config(
136
158
  }
137
159
  return nextConfig;
138
160
  }
139
- ```
161
+ ```
@@ -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 function rules for Vercel Functions (queue triggers and `maxDuration`) on 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 integrated development environment (IDE) IntelliSense. |
55
+ | `runtime` | `string` | — | Node.js runtime version for Vercel Functions (for example, `'nodejs22.x'` or `'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, which helps stay under the Vercel 250 MB function size limit). Set it explicitly, or use the `WORKFLOW_SOURCEMAP` environment variable, to override in either environment. |
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 server-side rendering (SSR) mode so workflow code is transformed correctly.
27
+ - Enables the `workflow` TypeScript plugin by default for integrated development environment (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, and `null`) are returned unchanged.