mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-31 03:16:42 -05:00
chore(organization): rename InferRolesFromOption to InferOrganizationRolesFromOption (#2053)
This commit is contained in:
@@ -3,7 +3,7 @@ import { createAuthEndpoint } from "../../../api/call";
|
||||
import { getSessionFromCtx } from "../../../api/routes";
|
||||
import { getOrgAdapter } from "../adapter";
|
||||
import { orgMiddleware, orgSessionMiddleware } from "../call";
|
||||
import { type InferRolesFromOption } from "../schema";
|
||||
import { type InferOrganizationRolesFromOption } from "../schema";
|
||||
import { APIError } from "better-call";
|
||||
import { parseRoles, type OrganizationOptions } from "../organization";
|
||||
import { ORGANIZATION_ERROR_CODES } from "../error-codes";
|
||||
@@ -59,7 +59,9 @@ export const createInvitation = <O extends OrganizationOptions | undefined>(
|
||||
/**
|
||||
* The role to assign to the user
|
||||
*/
|
||||
role: InferRolesFromOption<O> | InferRolesFromOption<O>[];
|
||||
role:
|
||||
| InferOrganizationRolesFromOption<O>
|
||||
| InferOrganizationRolesFromOption<O>[];
|
||||
/**
|
||||
* The organization ID to invite
|
||||
* the user to
|
||||
|
||||
@@ -2,7 +2,7 @@ import { z } from "zod";
|
||||
import { createAuthEndpoint } from "../../../api/call";
|
||||
import { getOrgAdapter } from "../adapter";
|
||||
import { orgMiddleware, orgSessionMiddleware } from "../call";
|
||||
import type { InferRolesFromOption, Member } from "../schema";
|
||||
import type { InferOrganizationRolesFromOption, Member } from "../schema";
|
||||
import { APIError } from "better-call";
|
||||
import { generateId } from "../../../utils";
|
||||
import { parseRoles, type OrganizationOptions } from "../organization";
|
||||
@@ -27,7 +27,9 @@ export const addMember = <O extends OrganizationOptions>() =>
|
||||
$Infer: {
|
||||
body: {} as {
|
||||
userId: string;
|
||||
role: InferRolesFromOption<O> | InferRolesFromOption<O>[];
|
||||
role:
|
||||
| InferOrganizationRolesFromOption<O>
|
||||
| InferOrganizationRolesFromOption<O>[];
|
||||
organizationId?: string;
|
||||
} & (O extends { teams: { enabled: true } }
|
||||
? { teamId?: string }
|
||||
@@ -293,7 +295,9 @@ export const updateMemberRole = <O extends OrganizationOptions>(option: O) =>
|
||||
metadata: {
|
||||
$Infer: {
|
||||
body: {} as {
|
||||
role: InferRolesFromOption<O> | InferRolesFromOption<O>[];
|
||||
role:
|
||||
| InferOrganizationRolesFromOption<O>
|
||||
| InferOrganizationRolesFromOption<O>[];
|
||||
memberId: string;
|
||||
/**
|
||||
* If not provided, the active organization will be used
|
||||
|
||||
@@ -55,18 +55,20 @@ export type InvitationInput = z.input<typeof invitationSchema>;
|
||||
export type MemberInput = z.input<typeof memberSchema>;
|
||||
export type OrganizationInput = z.input<typeof organizationSchema>;
|
||||
export type TeamInput = z.infer<typeof teamSchema>;
|
||||
export type InferZodRolesFromOption<O extends OrganizationOptions | undefined> =
|
||||
ZodLiteral<
|
||||
O extends {
|
||||
roles: {
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
? keyof O["roles"] | (keyof O["roles"])[]
|
||||
: "admin" | "member" | "owner" | ("admin" | "member" | "owner")[]
|
||||
>;
|
||||
export type InferRolesFromOption<O extends OrganizationOptions | undefined> =
|
||||
O extends { roles: any } ? keyof O["roles"] : "admin" | "member" | "owner";
|
||||
export type InferOrganizationZodRolesFromOption<
|
||||
O extends OrganizationOptions | undefined,
|
||||
> = ZodLiteral<
|
||||
O extends {
|
||||
roles: {
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
? keyof O["roles"] | (keyof O["roles"])[]
|
||||
: "admin" | "member" | "owner" | ("admin" | "member" | "owner")[]
|
||||
>;
|
||||
export type InferOrganizationRolesFromOption<
|
||||
O extends OrganizationOptions | undefined,
|
||||
> = O extends { roles: any } ? keyof O["roles"] : "admin" | "member" | "owner";
|
||||
|
||||
export type InvitationStatus = "pending" | "accepted" | "rejected" | "canceled";
|
||||
|
||||
@@ -76,7 +78,7 @@ export type InferMember<O extends OrganizationOptions> = O["teams"] extends {
|
||||
? {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
role: InferRolesFromOption<O>;
|
||||
role: InferOrganizationRolesFromOption<O>;
|
||||
createdAt: Date;
|
||||
userId: string;
|
||||
user: {
|
||||
@@ -89,7 +91,7 @@ export type InferMember<O extends OrganizationOptions> = O["teams"] extends {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
createdAt: Date;
|
||||
role: InferRolesFromOption<O>;
|
||||
role: InferOrganizationRolesFromOption<O>;
|
||||
teamId?: string;
|
||||
userId: string;
|
||||
user: {
|
||||
@@ -107,7 +109,7 @@ export type InferInvitation<O extends OrganizationOptions> =
|
||||
id: string;
|
||||
organizationId: string;
|
||||
email: string;
|
||||
role: InferRolesFromOption<O>;
|
||||
role: InferOrganizationRolesFromOption<O>;
|
||||
status: InvitationStatus;
|
||||
inviterId: string;
|
||||
expiresAt: Date;
|
||||
@@ -116,7 +118,7 @@ export type InferInvitation<O extends OrganizationOptions> =
|
||||
id: string;
|
||||
organizationId: string;
|
||||
email: string;
|
||||
role: InferRolesFromOption<O>;
|
||||
role: InferOrganizationRolesFromOption<O>;
|
||||
status: InvitationStatus;
|
||||
inviterId: string;
|
||||
expiresAt: Date;
|
||||
|
||||
Reference in New Issue
Block a user