Skip to content

Teach codegen to consume adapter packages: serverPackage entries, setupFn, and manifest routes - #4729

Draft
FranjoMindek wants to merge 1 commit into
franjo/auth2-5-capability-gatingfrom
franjo/auth2-6-adapter-codegen
Draft

Teach codegen to consume adapter packages: serverPackage entries, setupFn, and manifest routes#4729
FranjoMindek wants to merge 1 commit into
franjo/auth2-5-capability-gatingfrom
franjo/auth2-6-adapter-codegen

Conversation

@FranjoMindek

Copy link
Copy Markdown
Contributor

Description

Stack 6/7. Codegen learns to consume adapter packages, and the contract gains the adapter-package surface together with its consumers:

  • @wasp.sh/auth-contract grows WaspServerRuntime (db, dbProvider, validated env, URLs — the adapter's only window into the app), ServerAdapter, ServerAdapterExtensions { setupFn } and ServerAdapterFactory. Adapters must not import generated code or read process.env; this boundary is what lets an adapter package typecheck and version independently of any app.
  • genAuthProviderIndexTs final form: for server: { package } manifests it emits the createServerAdapter(runtime, options, extensions) call with the manifest's options delivered verbatim and the app's setupFn (the prismaSetupFn-convention escape hatch) passed through a new RegisteredAuthProviderSetupFn virtual module.
  • The server mounts a package adapter's routeHandler at the manifest's declared basePath, with rawBody: true routes exempted from the JSON body parser (Better Auth reads its own stream).
  • Wasp-auth-only hooks module suppressed under external providers.

No app in the repo uses a package entry until 7/7, so golden churn here is minimal; the shape is exercised by two real packages one PR later.

Type of change

  • 🔧 Just code/docs improvement
  • 🐞 Bug fix
  • 🚀 New/improved feature
  • 💥 Breaking change

Checklist

  • I tested my change in a Wasp app to verify that it works as intended.

  • 🧪 Tests and apps:

    • I added unit tests for my change.
    • (if you fixed a bug) I added a regression test for the bug I fixed.
    • (if you added/updated a feature) I added/updated e2e tests in examples/kitchen-sink/e2e-tests.
    • (if you added/updated a feature) I updated the starter templates in waspc/data/Cli/templates, as needed.
    • (if you added/updated a feature) I updated the example apps in examples/, as needed.
      • (if you updated examples/tutorials) I updated the tutorial in the docs (and vice versa).
  • 📜 Documentation:

    • (if you added/updated a feature) I added/updated the documentation in web/docs/.
  • 🆕 Changelog: (if change is more than just code/docs improvement)

    • I updated waspc/ChangeLog.md with a user-friendly description of the change.
    • (if you did a breaking change) I added a step to the current migration guide in web/docs/migration-guides/.
    • I bumped the version in waspc/waspc.cabal to reflect the changes I introduced.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploying wasp-docs-on-main with  Cloudflare Pages  Cloudflare Pages

Latest commit: 39de0f6
Status: ✅  Deploy successful!
Preview URL: https://267fb9f7.wasp-docs-on-main.pages.dev
Branch Preview URL: https://franjo-auth2-6-adapter-codeg.wasp-docs-on-main.pages.dev

View logs

@FranjoMindek
FranjoMindek force-pushed the franjo/auth2-6-adapter-codegen branch from 8bc71eb to a4736f3 Compare August 14, 2026 16:31
@FranjoMindek
FranjoMindek force-pushed the franjo/auth2-6-adapter-codegen branch from a4736f3 to 3076119 Compare August 14, 2026 19:16
@pkg-pr-new

pkg-pr-new Bot commented Aug 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

@wasp.sh/spec

npx https://pkg.pr.new/wasp-lang/wasp/@wasp.sh/spec@4729

@wasp.sh/wasp-cli

npx https://pkg.pr.new/wasp-lang/wasp/@wasp.sh/wasp-cli@4729

@wasp.sh/wasp-cli-darwin-arm64-unknown

npx https://pkg.pr.new/wasp-lang/wasp/@wasp.sh/wasp-cli-darwin-arm64-unknown@4729

@wasp.sh/wasp-cli-darwin-x64-unknown

npx https://pkg.pr.new/wasp-lang/wasp/@wasp.sh/wasp-cli-darwin-x64-unknown@4729

@wasp.sh/wasp-cli-linux-arm64-glibc

npx https://pkg.pr.new/wasp-lang/wasp/@wasp.sh/wasp-cli-linux-arm64-glibc@4729

@wasp.sh/wasp-cli-linux-x64-glibc

npx https://pkg.pr.new/wasp-lang/wasp/@wasp.sh/wasp-cli-linux-x64-glibc@4729

@wasp.sh/wasp-cli-linux-x64-musl

npx https://pkg.pr.new/wasp-lang/wasp/@wasp.sh/wasp-cli-linux-x64-musl@4729

commit: ca9ab7c

@FranjoMindek
FranjoMindek force-pushed the franjo/auth2-6-adapter-codegen branch from 3076119 to dbe0cc4 Compare August 14, 2026 21:57
@FranjoMindek
FranjoMindek force-pushed the franjo/auth2-6-adapter-codegen branch from dbe0cc4 to 577d9d4 Compare August 15, 2026 08:28
@FranjoMindek
FranjoMindek force-pushed the franjo/auth2-6-adapter-codegen branch from 577d9d4 to 0fea5a2 Compare August 15, 2026 09:40
@FranjoMindek
FranjoMindek force-pushed the franjo/auth2-6-adapter-codegen branch from 0fea5a2 to 40c7c3e Compare August 15, 2026 14:43
@FranjoMindek

Copy link
Copy Markdown
Contributor Author

New since last review: the runtime window gains an optional eager-provisioning channel, onAuthUserCreated(authUser). An in-process adapter that can observe its own signup moment reports it, and Wasp provisions the local User right then instead of at the first authenticated request. It's the same provisioning code path as JIT, called sooner — idempotent by the same unique constraint, with JIT remaining the backstop (a crash between the provider's insert and the report heals on first login). Hosted providers can't observe signups and simply never call it.

@FranjoMindek
FranjoMindek force-pushed the franjo/auth2-6-adapter-codegen branch from 39de0f6 to 8d191da Compare August 17, 2026 08:43
@FranjoMindek
FranjoMindek force-pushed the franjo/auth2-6-adapter-codegen branch from 8d191da to ca9ab7c Compare August 18, 2026 16:54
@FranjoMindek

Copy link
Copy Markdown
Contributor Author

Dropped the authProviderSetupFn Register key. Its virtual module is now declared as AuthProviderSetupFn = NonNullable<ServerAdapterExtensions['setupFn']> — the adapter package types the parameter precisely; the SDK only needs a function to hand to the factory.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request is now stale.
That means that it hasn't seen any activity for a while, and needs to be updated or addressed before it can be merged.

Next steps if the PR is still relevant, and you are able to devote time to it:

  • If you received any questions or feedback, please address them.
  • Merge the latest main into your branch to ensure that you are up to date.
  • If you are still working on the changes, please leave a comment telling us so.
  • Otherwise, just leave a comment explaining why the PR is still relevant.

If no action is taken, this PR will be automatically closed in 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants