diff --git a/packages/better-auth/src/plugins/organization/organization.ts b/packages/better-auth/src/plugins/organization/organization.ts index 6075c91c16..ec6b9b34c4 100644 --- a/packages/better-auth/src/plugins/organization/organization.ts +++ b/packages/better-auth/src/plugins/organization/organization.ts @@ -72,11 +72,42 @@ declare module "@better-auth/core" { // biome-ignore lint/correctness/noUnusedVariables: Auth and Context need to be same as declared in the module interface BetterAuthPluginRegistry { organization: { - creator: typeof organization; + creator: OrganizationCreator; }; } } +export type DefaultOrganizationPlugin = { + id: "organization"; + endpoints: OrganizationEndpoints; + schema: OrganizationSchema; + $Infer: { + Organization: InferOrganization; + Invitation: InferInvitation; + Member: InferMember; + Team: Options["teams"] extends { enabled: true } ? Team : any; + TeamMember: Options["teams"] extends { enabled: true } ? TeamMember : any; + ActiveOrganization: Options["teams"] extends { enabled: true } + ? { + members: InferMember[]; + invitations: InferInvitation[]; + teams: InferTeam[]; + } & InferOrganization + : { + members: InferMember[]; + invitations: InferInvitation[]; + } & InferOrganization; + }; + $ERROR_CODES: typeof ORGANIZATION_ERROR_CODES; + options: NoInfer; +}; + +export interface OrganizationCreator { + ( + options?: Options | undefined, + ): DefaultOrganizationPlugin; +} + export function parseRoles(roles: string | string[]): string { return Array.isArray(roles) ? roles.join(",") : roles; } @@ -405,30 +436,7 @@ export function organization< }; export function organization( options?: O | undefined, -): { - id: "organization"; - endpoints: OrganizationEndpoints; - schema: OrganizationSchema; - $Infer: { - Organization: InferOrganization; - Invitation: InferInvitation; - Member: InferMember; - Team: O["teams"] extends { enabled: true } ? Team : any; - TeamMember: O["teams"] extends { enabled: true } ? TeamMember : any; - ActiveOrganization: O["teams"] extends { enabled: true } - ? { - members: InferMember[]; - invitations: InferInvitation[]; - teams: InferTeam[]; - } & InferOrganization - : { - members: InferMember[]; - invitations: InferInvitation[]; - } & InferOrganization; - }; - $ERROR_CODES: typeof ORGANIZATION_ERROR_CODES; - options: NoInfer; -}; +): DefaultOrganizationPlugin; export function organization(options?: O): any { const opts = (options || {}) as O; let endpoints = { diff --git a/packages/stripe/src/index.ts b/packages/stripe/src/index.ts index 248cfcf9a8..15d04d65b4 100644 --- a/packages/stripe/src/index.ts +++ b/packages/stripe/src/index.ts @@ -1,10 +1,6 @@ import type { BetterAuthPlugin, User } from "better-auth"; import { APIError } from "better-auth"; -import type { - Organization, - OrganizationOptions, - OrganizationPlugin, -} from "better-auth/plugins/organization"; +import type { Organization } from "better-auth/plugins/organization"; import { defu } from "defu"; import type Stripe from "stripe"; import { STRIPE_ERROR_CODES } from "./error-codes"; @@ -64,10 +60,7 @@ export const stripe = (options: O) => { }, init(ctx) { if (options.organization?.enabled) { - const orgPlugin = - ctx.getPlugin>( - "organization", - ); + const orgPlugin = ctx.getPlugin("organization"); if (!orgPlugin) { ctx.logger.error(`Organization plugin not found`); return;