Skip to content

feat(core): extend UserFrom type inference support#191

Merged
halvaradop merged 1 commit into
masterfrom
feat/improve-coverage
Jun 17, 2026
Merged

feat(core): extend UserFrom type inference support#191
halvaradop merged 1 commit into
masterfrom
feat/improve-coverage

Conversation

@halvaradop

@halvaradop halvaradop commented Jun 17, 2026

Copy link
Copy Markdown
Member

Description

This pull request extends the type inference capabilities of the UserFrom utility type to support additional schema providers.

Previously, UserFrom only supported inferring user types from Zod schemas. This PR expands its coverage to also support ArkType and Valibot schemas, providing a consistent type inference experience across all supported schema libraries.

Note

UserFrom is an alternative to InferUser.

  • UserFrom infers the user type directly from a schema definition.
  • InferUser infers the user type from an authentication instance created with createAuth().

Usage

const schema = UserIdentity.extend({
  isAdmin: z.boolean(),
  role: z.enum(["admin", "user"]),
})

const auth = createAuth({
  oauth: [],
  identity: {
    schema,
  },
})

// Infer from the auth instance
type User = InferUser<typeof auth>

// Infer directly from the schema
type SchemaUser = UserFrom<typeof schema>

Both utilities infer the same user shape, but from different sources:

  • InferUser derives the type from a configured authentication instance.
  • UserFrom derives the type directly from a schema definition.

This makes UserFrom particularly useful when working with schemas independently of a createAuth() instance.

@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
auth Skipped Skipped Jun 17, 2026 11:36pm

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/improve-coverage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/core/src/@types/utility.ts (1)

154-177: ⚡ Quick win

Update JSDoc wording to reflect schema-agnostic support.

The docs for UserFrom/SessionFrom still describe Zod-only inference, but these types now accept SchemaTypes. Updating the descriptions/examples will keep the public type docs accurate.

✏️ Suggested doc update
- * Infers the user type from a Zod identity schema, or falls back to {`@link` User}.
+ * Infers the user type from a supported identity schema (Zod, Valibot, ArkType, TypeBox).

...
- * Infers the session type from a Zod identity schema.
+ * Infers the session type from a supported identity schema.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/`@types/utility.ts around lines 154 - 177, The JSDoc
comments for the UserFrom and SessionFrom types incorrectly state they infer
from "Zod identity schema" when they actually work with any SchemaTypes. Update
the documentation text in both JSDoc blocks to remove Zod-specific references
and clarify that these types accept schema-agnostic SchemaTypes. The
descriptions should indicate general schema inference capability rather than
being limited to Zod schemas.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/CHANGELOG.md`:
- Around line 13-14: The CHANGELOG.md file currently only documents the UserFrom
type inference changes but is missing documentation for the SessionFrom type
composition path changes that are also part of this PR. Add a second bullet
point in the Unreleased section to document the SessionFrom exported composition
path change, matching the format and detail level of the existing UserFrom entry
to ensure the release notes are complete for consumers tracking public typing
changes.

---

Nitpick comments:
In `@packages/core/src/`@types/utility.ts:
- Around line 154-177: The JSDoc comments for the UserFrom and SessionFrom types
incorrectly state they infer from "Zod identity schema" when they actually work
with any SchemaTypes. Update the documentation text in both JSDoc blocks to
remove Zod-specific references and clarify that these types accept
schema-agnostic SchemaTypes. The descriptions should indicate general schema
inference capability rather than being limited to Zod schemas.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0aee1ab9-d3c7-43b3-b1c3-7cf4e3315dd1

📥 Commits

Reviewing files that changed from the base of the PR and between e1e3db9 and 28b610c.

📒 Files selected for processing (4)
  • packages/core/CHANGELOG.md
  • packages/core/src/@types/utility.ts
  • packages/core/test/client/client.test-d.ts
  • packages/core/test/identity.test.ts

Comment thread packages/core/CHANGELOG.md
@halvaradop halvaradop merged commit 39e2b93 into master Jun 17, 2026
7 checks passed
@halvaradop halvaradop deleted the feat/improve-coverage branch June 17, 2026 23:42
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.

1 participant