-
Notifications
You must be signed in to change notification settings - Fork 223
docs: audit and align API reference with source #1516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
johnlindquist
wants to merge
13
commits into
main
Choose a base branch
from
api-reference-audit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0a94450
docs: align hook API reference docs
johnlindquist b4600dd
docs: align workflow runtime API docs
johnlindquist 11544c5
docs: align resumeHook reference
johnlindquist e61679c
docs: sync workflow API reference docs
johnlindquist 5ca19f7
docs: correct fatal error and fetch references
johnlindquist 92c8b06
docs: correct fetch example
johnlindquist 0d3bf12
ploop: iteration 1 checkpoint
johnlindquist 448de1e
docs: sync withWorkflow reference
johnlindquist d62d858
docs: align withWorkflow reference
johnlindquist 2410601
docs: sync workflow API reference
johnlindquist 52b3e48
docs: clarify workflow API overview
johnlindquist 8c1b72f
docs: align hook API references
johnlindquist 4bf191c
docs: align api reference exports
johnlindquist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,33 @@ | ||
| --- | ||
| title: "workflow/api" | ||
| description: Runtime functions to inspect runs, start workflows, and access world data. | ||
| description: Runtime functions for starting workflows, inspecting runs, resuming hooks, and accessing world data. | ||
| type: overview | ||
| summary: Explore runtime functions for starting workflows, inspecting runs, and managing hooks. | ||
| summary: Explore runtime functions across the workflow/api and workflow/runtime entrypoints. | ||
| --- | ||
|
|
||
| API reference for runtime functions from the `workflow/api` package. | ||
| API reference for runtime functions from the `workflow/api` and `workflow/runtime` entrypoints. | ||
|
|
||
| ## Functions | ||
|
|
||
| The API package is for access and introspection of workflow data to inspect runs, start new runs, or access anything else directly accessible by the world. | ||
| Most functions in this section are imported from `workflow/api`. `getWorld()` is imported from `workflow/runtime`. | ||
|
|
||
| <Cards> | ||
| <Card href="/docs/api-reference/workflow-api/start" title="start()"> | ||
| Start/enqueue a new workflow run. | ||
| </Card> | ||
| <Card href="/docs/api-reference/workflow-api/resume-hook" title="resumeHook()"> | ||
| Resume a workflow by sending a payload to a hook. | ||
| Resume a hook created with `createHook()` by sending an arbitrary payload. | ||
| </Card> | ||
| <Card href="/docs/api-reference/workflow-api/resume-webhook" title="resumeWebhook()"> | ||
| Resume a workflow by sending a `Request` to a webhook. | ||
| Resume a webhook created with `createWebhook()` by forwarding an HTTP `Request`. | ||
| </Card> | ||
| <Card href="/docs/api-reference/workflow-api/get-hook-by-token" title="getHookByToken()"> | ||
| Get hook details and metadata by its token. | ||
| Retrieve hook details, metadata, and run information by token. | ||
| </Card> | ||
| <Card href="/docs/api-reference/workflow-api/get-run" title="getRun()"> | ||
| Get workflow run status and metadata without waiting for completion. | ||
| </Card> | ||
| <Card href="/docs/api-reference/workflow-api/get-world" title="getWorld()"> | ||
| Get direct access to workflow storage, queuing, and streaming backends. | ||
| Get direct access to workflow storage, queuing, and streaming backends from `workflow/runtime`. | ||
| </Card> | ||
| </Cards> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,46 @@ prerequisites: | |
|
|
||
| Configures webpack/turbopack loaders to transform workflow code (`"use step"`/`"use workflow"` directives) | ||
|
|
||
| ## API Signature | ||
|
|
||
| ### Parameters | ||
|
|
||
| <TSDoc | ||
| definition={` | ||
| import { withWorkflow } from "workflow/next"; | ||
| export default withWorkflow;`} | ||
| showSections={["parameters"]} | ||
| /> | ||
|
|
||
| #### Options | ||
|
|
||
| The second parameter accepts an optional configuration object: | ||
|
|
||
| | Property | Type | Description | | ||
| |---|---|---| | ||
| | `workflows.lazyDiscovery` | `boolean` | Enable lazy discovery mode. Sets the `WORKFLOW_NEXT_LAZY_DISCOVERY` flag. Deferred discovery only activates on Next.js `>= 16.2.0-canary.48`; on older versions, Workflow logs a warning and falls back to eager scanning. | | ||
| | `workflows.local.port` | `number` | Override the local development server port. Sets the `PORT` environment variable when running locally (no `VERCEL_DEPLOYMENT_ID`). | | ||
| | `workflows.local.dataDir` | `string` | Currently typed but ignored by `withWorkflow()`. In local mode, when `WORKFLOW_TARGET_WORLD` is unset, the implementation hardcodes `WORKFLOW_LOCAL_DATA_DIR` to `'.next/workflow-data'`. | | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AI Review: NoteDocumenting a parameter as "typed but ignored" with the hardcoded path exposed may confuse users. Consider either omitting |
||
|
|
||
| ### Returns | ||
|
|
||
| Returns an async function `(phase: string, ctx: { defaultConfig: NextConfig }) => Promise<NextConfig>` compatible with the `next.config.ts` default export. | ||
|
|
||
| ### Environment Behavior | ||
|
|
||
| When running locally (no `VERCEL_DEPLOYMENT_ID`) and `WORKFLOW_TARGET_WORLD` is not already set: | ||
| - Sets `WORKFLOW_TARGET_WORLD` to `'local'` | ||
| - Sets `WORKFLOW_LOCAL_DATA_DIR` to `'.next/workflow-data'` | ||
|
|
||
| When running locally (no `VERCEL_DEPLOYMENT_ID`): | ||
| - If `workflows.local.port` is provided, sets `PORT` to that value | ||
|
|
||
| When running on Vercel (`VERCEL_DEPLOYMENT_ID` is present) and `WORKFLOW_TARGET_WORLD` is not already set: | ||
| - Sets `WORKFLOW_TARGET_WORLD` to `'vercel'` | ||
|
|
||
| During the development server phase (`phase-development-server`): | ||
| - Sets `WORKFLOW_PUBLIC_MANIFEST` to `'1'` if not already set | ||
|
|
||
| ## Usage | ||
|
|
||
| To enable `"use step"` and `"use workflow"` directives while developing locally or deploying to production, wrap your `nextConfig` with `withWorkflow`. | ||
|
|
@@ -21,8 +61,14 @@ const nextConfig: NextConfig = { | |
| // … rest of your Next.js config | ||
| }; | ||
|
|
||
| // not required but allows configuring workflow options | ||
| const workflowConfig = {} | ||
| // optional, but this shows the actual supported shape | ||
| const workflowConfig = { | ||
| workflows: { | ||
| local: { | ||
| port: 3001, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export default withWorkflow(nextConfig, workflowConfig); // [!code highlight] | ||
| ``` | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI Review: Note
HookNotFoundErroris exported fromworkflow/errorsand has a staticHookNotFoundError.is(error)method (the idiomatic pattern per its own JSDoc). The string-basederror.name === "HookNotFoundError"check used here (and in 3 other examples) is fragile. Consider: