Skip to content

Conversation

@TooTallNate
Copy link
Member

The Standard Schema docs explicitly say that it should be a regular dep, not a dev dep: https://standardschema.dev/#can-i-add-it-as-a-dev-dependency

The Standard Schema docs explicitly say that it should be a regular dep,
not a dev dep: https://standardschema.dev/#can-i-add-it-as-a-dev-dependency
@changeset-bot
Copy link

changeset-bot bot commented Nov 5, 2025

🦋 Changeset detected

Latest commit: eca41b9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@workflow/core Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/web-shared Patch
workflow Patch
@workflow/sveltekit Patch
@workflow/world-testing Patch
@workflow/ai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Contributor

vercel bot commented Nov 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview Comment Nov 5, 2025 8:33pm
example-nextjs-workflow-webpack Ready Ready Preview Comment Nov 5, 2025 8:33pm
example-workflow Ready Ready Preview Comment Nov 5, 2025 8:33pm
workbench-nitro-workflow Ready Ready Preview Comment Nov 5, 2025 8:33pm
workbench-nuxt-workflow Ready Ready Preview Comment Nov 5, 2025 8:33pm
workbench-sveltekit-workflow Ready Ready Preview Comment Nov 5, 2025 8:33pm
workbench-vite-workflow Ready Ready Preview Comment Nov 5, 2025 8:33pm
workflow-docs Ready Ready Preview Comment Nov 5, 2025 8:33pm

Copy link
Member

@VaguelySerious VaguelySerious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving since it seems harmless, but we're not actually using @standard-schema/spec anywhere. What's the point of having it as a dependency?

@TooTallNate
Copy link
Member Author

We are using it. See 5c0268b

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

The hard-coded TypeScript interface in the documentation still shows a single type parameter DefineHook<T>, but the actual function implementation now supports two type parameters defineHook<TInput, TOutput = TInput>. This creates a mismatch between the documented and actual API.

View Details
📝 Patch Details
diff --git a/docs/content/docs/api-reference/workflow/define-hook.mdx b/docs/content/docs/api-reference/workflow/define-hook.mdx
index 56e8a07..c8a273c 100644
--- a/docs/content/docs/api-reference/workflow/define-hook.mdx
+++ b/docs/content/docs/api-reference/workflow/define-hook.mdx
@@ -48,18 +48,18 @@ showSections={['parameters']}
 <TSDoc
 definition={generateDefinition({
   code: `
-interface DefineHook<T> {
+interface DefineHook<TInput, TOutput = TInput> {
   /**
 
-* Creates a new hook with the defined payload type.
+* Creates a new hook with the defined output type.
   */
-  create: (options?: HookOptions) => Hook<T>;
+  create: (options?: HookOptions) => Hook<TOutput>;
 
   /**
 
-* Resumes a hook by sending a payload with the defined type.
+* Resumes a hook by sending a payload with the defined input type.
    */
-  resume: (token: string, payload: T) => Promise<HookEntity | null>;
+  resume: (token: string, payload: TInput) => Promise<HookEntity | null>;
 }
 export default DefineHook;`
 })}

Analysis

Documentation shows outdated TypeScript interface for defineHook

What fails: The documentation in docs/content/docs/api-reference/workflow/define-hook.mdx (lines 51-62) displays an incorrect DefineHook interface signature that doesn't match the actual implementation.

How to reproduce:

  1. View the documentation at docs/content/docs/api-reference/workflow/define-hook.mdx lines 51-62
  2. Compare the documented interface with the actual implementation in packages/core/src/define-hook.ts
  3. Observe the type parameter mismatch

Expected vs Actual:

Documentation shows:

interface DefineHook<T> {
  create: (options?: HookOptions) => Hook<T>;
  resume: (token: string, payload: T) => Promise<HookEntity | null>;
}

Actual implementation signature:

export function defineHook<TInput, TOutput = TInput>({schema}: {schema?: StandardSchemaV1<TInput, TOutput>} = {}) {
  return {
    create(_options?: HookOptions): Hook<TOutput> { ... }
    resume(token: string, payload: TInput): Promise<HookEntity | null> { ... }
  }
}

The actual API supports schema-based transformations where input and output types can differ (via StandardSchemaV1<TInput, TOutput>). This is demonstrated in the code's own example at lines 73-100 where a Zod schema transforms the input payload.

Root cause: The documentation interface was not updated when the defineHook function signature evolved to support separate input and output type parameters.

Fix on Vercel

@VaguelySerious
Copy link
Member

Ah, was looking at an outdated branch, LGTM

@TooTallNate
Copy link
Member Author

re: Vade's comment - I think we actually do want to document it as only one generic because if the user is typing the hook manually (without a schema) then there would be no transformation and the input = the output.

@TooTallNate TooTallNate merged commit a28bc37 into main Nov 5, 2025
32 checks passed
@TooTallNate TooTallNate deleted the standard-schema-follow-up branch November 5, 2025 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants