diff --git a/packages/better-auth/src/db/with-hooks.ts b/packages/better-auth/src/db/with-hooks.ts index bcefafa7..c7ec1e6c 100644 --- a/packages/better-auth/src/db/with-hooks.ts +++ b/packages/better-auth/src/db/with-hooks.ts @@ -1,4 +1,4 @@ -import type { Models } from "../types"; +import type { DBPreservedModels } from "@better-auth/core/db"; import type { BetterAuthOptions } from "@better-auth/core"; import type { DBAdapter, Where } from "@better-auth/core/db/adapter"; import { getCurrentAdapter } from "../context/transaction"; @@ -13,7 +13,7 @@ export function getWithHooks( ) { const hooks = ctx.hooks; type BaseModels = Extract< - Models, + DBPreservedModels, "user" | "account" | "session" | "verification" >; async function createWithHooks>( diff --git a/packages/better-auth/src/types/models.ts b/packages/better-auth/src/types/models.ts index a30cae88..a282c6fb 100644 --- a/packages/better-auth/src/types/models.ts +++ b/packages/better-auth/src/types/models.ts @@ -5,19 +5,6 @@ import type { StripEmptyObjects, UnionToIntersection } from "./helper"; import type { BetterAuthPlugin } from "@better-auth/core"; import type { User, Session } from "@better-auth/core/db"; -export type Models = - | "user" - | "account" - | "session" - | "verification" - | "rate-limit" - | "organization" - | "member" - | "invitation" - | "jwks" - | "passkey" - | "two-factor"; - export type AdditionalUserFieldsInput = InferFieldsFromPlugins & InferFieldsFromOptions; diff --git a/packages/core/src/db/index.ts b/packages/core/src/db/index.ts index 12828fdc..4379d02c 100644 --- a/packages/core/src/db/index.ts +++ b/packages/core/src/db/index.ts @@ -4,6 +4,7 @@ import type { DBFieldType, DBPrimitive, BetterAuthDBSchema, + DBPreservedModels, } from "./type"; import type { BetterAuthPluginDBSchema } from "./plugin"; export type { BetterAuthPluginDBSchema } from "./plugin"; @@ -21,6 +22,7 @@ export type { DBFieldType, DBPrimitive, BetterAuthDBSchema, + DBPreservedModels, }; /** diff --git a/packages/core/src/db/type.ts b/packages/core/src/db/type.ts index fcb2363a..59205a6f 100644 --- a/packages/core/src/db/type.ts +++ b/packages/core/src/db/type.ts @@ -1,16 +1,7 @@ import type { ZodType } from "zod"; import type { LiteralString } from "../types"; -declare module "../index" { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - interface BetterAuthMutators { - "better-auth/db": { - // todo: we should infer the schema from the adapter - }; - } -} - -export type Models = +export type DBPreservedModels = | "user" | "account" | "session" diff --git a/packages/core/src/types/context.ts b/packages/core/src/types/context.ts index 45579e49..2a80b5ac 100644 --- a/packages/core/src/types/context.ts +++ b/packages/core/src/types/context.ts @@ -10,7 +10,7 @@ import type { OAuthProvider } from "../oauth2"; import { createLogger } from "../env"; import type { DBAdapter, Where } from "../db/adapter"; import type { BetterAuthCookies } from "./cookie"; -import type { Models } from "../db/type"; +import type { DBPreservedModels } from "../db/type"; import type { LiteralUnion } from "./helper"; import type { CookieOptions, EndpointContext } from "better-call"; import type { @@ -247,7 +247,7 @@ export type AuthContext = freshAge: number; }; generateId: (options: { - model: LiteralUnion; + model: LiteralUnion; size?: number; }) => string | false; secondaryStorage: SecondaryStorage | undefined; diff --git a/packages/core/src/types/init-options.ts b/packages/core/src/types/init-options.ts index 6031325f..adb5dd74 100644 --- a/packages/core/src/types/init-options.ts +++ b/packages/core/src/types/init-options.ts @@ -2,7 +2,11 @@ import type { Dialect, Kysely, MysqlPool, PostgresPool } from "kysely"; import type { Database } from "better-sqlite3"; import type { CookieOptions } from "better-call"; import type { LiteralUnion } from "./helper"; -import type { DBFieldAttribute, Models, SecondaryStorage } from "../db/type"; +import type { + DBFieldAttribute, + DBPreservedModels, + SecondaryStorage, +} from "../db/type"; import type { Account, RateLimit, Session, User, Verification } from "../db"; import type { Database as BunDatabase } from "bun:sqlite"; import type { DatabaseSync } from "node:sqlite"; @@ -17,7 +21,7 @@ type KyselyDatabaseType = "postgres" | "mysql" | "sqlite" | "mssql"; type OmitId = Omit; export type GenerateIdFn = (options: { - model: LiteralUnion; + model: LiteralUnion; size?: number; }) => string | false;