import { AccessControl, Role, Statements } from '../access/index.js'; import * as better_call from 'better-call'; import * as z from 'zod/v4'; import { I as InferOptionSchema, S as Session, U as User, G as GenericEndpointContext, H as HookEndpointContext } from '../../shared/better-auth.UgZtsmr9.js'; import '../../shared/better-auth.ZSfSbnQT.js'; import 'kysely'; import '../../shared/better-auth.BVGuK4ar.js'; import 'jose'; import 'zod/v4/core'; import 'zod'; import 'better-sqlite3'; import 'bun:sqlite'; declare const schema: { user: { fields: { role: { type: "string"; required: false; input: false; }; banned: { type: "boolean"; defaultValue: false; required: false; input: false; }; banReason: { type: "string"; required: false; input: false; }; banExpires: { type: "date"; required: false; input: false; }; }; }; session: { fields: { impersonatedBy: { type: "string"; required: false; }; }; }; }; type AdminSchema = typeof schema; interface UserWithRole extends User { role?: string; banned?: boolean | null; banReason?: string | null; banExpires?: Date | null; } interface SessionWithImpersonatedBy extends Session { impersonatedBy?: string; } interface AdminOptions { /** * The default role for a user * * @default "user" */ defaultRole?: string; /** * Roles that are considered admin roles. * * Any user role that isn't in this list, even if they have the permission, * will not be considered an admin. * * @default ["admin"] */ adminRoles?: string | string[]; /** * A default ban reason * * By default, no reason is provided */ defaultBanReason?: string; /** * Number of seconds until the ban expires * * By default, the ban never expires */ defaultBanExpiresIn?: number; /** * Duration of the impersonation session in seconds * * By default, the impersonation session lasts 1 hour */ impersonationSessionDuration?: number; /** * Custom schema for the admin plugin */ schema?: InferOptionSchema; /** * Configure the roles and permissions for the admin * plugin. */ ac?: AccessControl; /** * Custom permissions for roles. */ roles?: { [key in string]?: Role; }; /** * List of user ids that should have admin access * * If this is set, the `adminRole` option is ignored */ adminUserIds?: string[]; /** * Message to show when a user is banned * * By default, the message is "You have been banned from this application" */ bannedUserMessage?: string; } type InferAdminRolesFromOption = O extends { roles: Record; } ? keyof O["roles"] : "user" | "admin"; declare const admin: (options?: O) => { id: "admin"; init(): { options: { databaseHooks: { user: { create: { before(user: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | null | undefined; }): Promise<{ data: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | null | undefined; role: string; }; }>; }; }; session: { create: { before(session: { id: string; userId: string; expiresAt: Date; createdAt: Date; updatedAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | null | undefined; }, ctx: GenericEndpointContext | undefined): Promise; }; }; }; }; }; hooks: { after: { matcher(context: HookEndpointContext): boolean; handler: (inputContext: better_call.MiddlewareInputContext) => Promise; }[]; }; endpoints: { /** * ### Endpoint * * POST `/admin/set-role` * * ### API Methods * * **server:** * `auth.api.setRole` * * **client:** * `authClient.admin.setRole` * * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/admin#api-method-admin-set-role) */ setRole: { (inputCtx_0: { body: { userId: string; role: InferAdminRolesFromOption | InferAdminRolesFromOption[]; }; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { user: UserWithRole; }; } : { user: UserWithRole; }>; options: { method: "POST"; body: z.ZodObject<{ userId: z.ZodCoercedString; role: z.ZodUnion]>; }, z.core.$strip>; requireHeaders: true; use: ((inputContext: better_call.MiddlewareInputContext) => Promise<{ session: { user: UserWithRole; session: Session; }; }>)[]; metadata: { openapi: { operationId: string; summary: string; description: string; responses: { 200: { description: string; content: { "application/json": { schema: { type: "object"; properties: { user: { $ref: string; }; }; }; }; }; }; }; }; $Infer: { body: { userId: string; role: InferAdminRolesFromOption | InferAdminRolesFromOption[]; }; }; }; } & { use: any[]; }; path: "/admin/set-role"; }; /** * ### Endpoint * * POST `/admin/create-user` * * ### API Methods * * **server:** * `auth.api.createUser` * * **client:** * `authClient.admin.createUser` * * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/admin#api-method-admin-create-user) */ createUser: { (inputCtx_0: { body: { email: string; password: string; name: string; role?: InferAdminRolesFromOption | InferAdminRolesFromOption[]; data?: Record; }; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers?: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { user: UserWithRole; }; } : { user: UserWithRole; }>; options: { method: "POST"; body: z.ZodObject<{ email: z.ZodString; password: z.ZodString; name: z.ZodString; role: z.ZodOptional]>>; data: z.ZodOptional>; }, z.core.$strip>; metadata: { openapi: { operationId: string; summary: string; description: string; responses: { 200: { description: string; content: { "application/json": { schema: { type: "object"; properties: { user: { $ref: string; }; }; }; }; }; }; }; }; $Infer: { body: { email: string; password: string; name: string; role?: InferAdminRolesFromOption | InferAdminRolesFromOption[]; data?: Record; }; }; }; } & { use: any[]; }; path: "/admin/create-user"; }; adminUpdateUser: { (inputCtx_0: { body: { userId: unknown; data: Record; }; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers?: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: UserWithRole; } : UserWithRole>; options: { method: "POST"; body: z.ZodObject<{ userId: z.ZodCoercedString; data: z.ZodRecord; }, z.core.$strip>; use: ((inputContext: better_call.MiddlewareInputContext) => Promise<{ session: { user: UserWithRole; session: Session; }; }>)[]; metadata: { openapi: { operationId: string; summary: string; description: string; responses: { 200: { description: string; content: { "application/json": { schema: { type: "object"; properties: { user: { $ref: string; }; }; }; }; }; }; }; }; }; } & { use: any[]; }; path: "/admin/update-user"; }; listUsers: { (inputCtx_0: { body?: undefined; } & { method?: "GET" | undefined; } & { query: { searchValue?: string | undefined; searchField?: "name" | "email" | undefined; searchOperator?: "contains" | "starts_with" | "ends_with" | undefined; limit?: string | number | undefined; offset?: string | number | undefined; sortBy?: string | undefined; sortDirection?: "asc" | "desc" | undefined; filterField?: string | undefined; filterValue?: string | number | boolean | undefined; filterOperator?: "lt" | "eq" | "ne" | "lte" | "gt" | "gte" | "contains" | undefined; }; } & { params?: Record; } & { request?: Request; } & { headers?: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { users: UserWithRole[]; total: number; limit: number | undefined; offset: number | undefined; } | { users: never[]; total: number; }; } : { users: UserWithRole[]; total: number; limit: number | undefined; offset: number | undefined; } | { users: never[]; total: number; }>; options: { method: "GET"; use: ((inputContext: better_call.MiddlewareInputContext) => Promise<{ session: { user: UserWithRole; session: Session; }; }>)[]; query: z.ZodObject<{ searchValue: z.ZodOptional; searchField: z.ZodOptional>; searchOperator: z.ZodOptional>; limit: z.ZodOptional>; offset: z.ZodOptional>; sortBy: z.ZodOptional; sortDirection: z.ZodOptional>; filterField: z.ZodOptional; filterValue: z.ZodOptional, z.ZodBoolean]>>; filterOperator: z.ZodOptional>; }, z.core.$strip>; metadata: { openapi: { operationId: string; summary: string; description: string; responses: { 200: { description: string; content: { "application/json": { schema: { type: "object"; properties: { users: { type: string; items: { $ref: string; }; }; total: { type: string; }; limit: { type: string; }; offset: { type: string; }; }; required: string[]; }; }; }; }; }; }; }; } & { use: any[]; }; path: "/admin/list-users"; }; /** * ### Endpoint * * POST `/admin/list-user-sessions` * * ### API Methods * * **server:** * `auth.api.listUserSessions` * * **client:** * `authClient.admin.listUserSessions` * * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/admin#api-method-admin-list-user-sessions) */ listUserSessions: { (inputCtx_0: { body: { userId: unknown; }; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers?: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { sessions: { id: string; userId: string; expiresAt: Date; createdAt: Date; updatedAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | null | undefined; }[]; }; } : { sessions: { id: string; userId: string; expiresAt: Date; createdAt: Date; updatedAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | null | undefined; }[]; }>; options: { method: "POST"; use: ((inputContext: better_call.MiddlewareInputContext) => Promise<{ session: { user: UserWithRole; session: Session; }; }>)[]; body: z.ZodObject<{ userId: z.ZodCoercedString; }, z.core.$strip>; metadata: { openapi: { operationId: string; summary: string; description: string; responses: { 200: { description: string; content: { "application/json": { schema: { type: "object"; properties: { sessions: { type: string; items: { $ref: string; }; }; }; }; }; }; }; }; }; }; } & { use: any[]; }; path: "/admin/list-user-sessions"; }; /** * ### Endpoint * * POST `/admin/unban-user` * * ### API Methods * * **server:** * `auth.api.unbanUser` * * **client:** * `authClient.admin.unbanUser` * * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/admin#api-method-admin-unban-user) */ unbanUser: { (inputCtx_0: { body: { userId: unknown; }; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers?: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { user: any; }; } : { user: any; }>; options: { method: "POST"; body: z.ZodObject<{ userId: z.ZodCoercedString; }, z.core.$strip>; use: ((inputContext: better_call.MiddlewareInputContext) => Promise<{ session: { user: UserWithRole; session: Session; }; }>)[]; metadata: { openapi: { operationId: string; summary: string; description: string; responses: { 200: { description: string; content: { "application/json": { schema: { type: "object"; properties: { user: { $ref: string; }; }; }; }; }; }; }; }; }; } & { use: any[]; }; path: "/admin/unban-user"; }; /** * ### Endpoint * * POST `/admin/ban-user` * * ### API Methods * * **server:** * `auth.api.banUser` * * **client:** * `authClient.admin.banUser` * * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/admin#api-method-admin-ban-user) */ banUser: { (inputCtx_0: { body: { userId: unknown; banReason?: string | undefined; banExpiresIn?: number | undefined; }; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers?: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { user: any; }; } : { user: any; }>; options: { method: "POST"; body: z.ZodObject<{ userId: z.ZodCoercedString; banReason: z.ZodOptional; banExpiresIn: z.ZodOptional; }, z.core.$strip>; use: ((inputContext: better_call.MiddlewareInputContext) => Promise<{ session: { user: UserWithRole; session: Session; }; }>)[]; metadata: { openapi: { operationId: string; summary: string; description: string; responses: { 200: { description: string; content: { "application/json": { schema: { type: "object"; properties: { user: { $ref: string; }; }; }; }; }; }; }; }; }; } & { use: any[]; }; path: "/admin/ban-user"; }; /** * ### Endpoint * * POST `/admin/impersonate-user` * * ### API Methods * * **server:** * `auth.api.impersonateUser` * * **client:** * `authClient.admin.impersonateUser` * * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/admin#api-method-admin-impersonate-user) */ impersonateUser: { (inputCtx_0: { body: { userId: unknown; }; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers?: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { session: { id: string; userId: string; expiresAt: Date; createdAt: Date; updatedAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | null | undefined; }; user: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | null | undefined; }; }; } : { session: { id: string; userId: string; expiresAt: Date; createdAt: Date; updatedAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | null | undefined; }; user: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | null | undefined; }; }>; options: { method: "POST"; body: z.ZodObject<{ userId: z.ZodCoercedString; }, z.core.$strip>; use: ((inputContext: better_call.MiddlewareInputContext) => Promise<{ session: { user: UserWithRole; session: Session; }; }>)[]; metadata: { openapi: { operationId: string; summary: string; description: string; responses: { 200: { description: string; content: { "application/json": { schema: { type: "object"; properties: { session: { $ref: string; }; user: { $ref: string; }; }; }; }; }; }; }; }; }; } & { use: any[]; }; path: "/admin/impersonate-user"; }; /** * ### Endpoint * * POST `/admin/stop-impersonating` * * ### API Methods * * **server:** * `auth.api.stopImpersonating` * * **client:** * `authClient.admin.stopImpersonating` * * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/admin#api-method-admin-stop-impersonating) */ stopImpersonating: { (inputCtx_0: { body?: undefined; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { session: Session & Record; user: User & Record; }; } : { session: Session & Record; user: User & Record; }>; options: { method: "POST"; requireHeaders: true; } & { use: any[]; }; path: "/admin/stop-impersonating"; }; /** * ### Endpoint * * POST `/admin/revoke-user-session` * * ### API Methods * * **server:** * `auth.api.revokeUserSession` * * **client:** * `authClient.admin.revokeUserSession` * * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/admin#api-method-admin-revoke-user-session) */ revokeUserSession: { (inputCtx_0: { body: { sessionToken: string; }; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers?: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { success: boolean; }; } : { success: boolean; }>; options: { method: "POST"; body: z.ZodObject<{ sessionToken: z.ZodString; }, z.core.$strip>; use: ((inputContext: better_call.MiddlewareInputContext) => Promise<{ session: { user: UserWithRole; session: Session; }; }>)[]; metadata: { openapi: { operationId: string; summary: string; description: string; responses: { 200: { description: string; content: { "application/json": { schema: { type: "object"; properties: { success: { type: string; }; }; }; }; }; }; }; }; }; } & { use: any[]; }; path: "/admin/revoke-user-session"; }; /** * ### Endpoint * * POST `/admin/revoke-user-sessions` * * ### API Methods * * **server:** * `auth.api.revokeUserSessions` * * **client:** * `authClient.admin.revokeUserSessions` * * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/admin#api-method-admin-revoke-user-sessions) */ revokeUserSessions: { (inputCtx_0: { body: { userId: unknown; }; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers?: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { success: boolean; }; } : { success: boolean; }>; options: { method: "POST"; body: z.ZodObject<{ userId: z.ZodCoercedString; }, z.core.$strip>; use: ((inputContext: better_call.MiddlewareInputContext) => Promise<{ session: { user: UserWithRole; session: Session; }; }>)[]; metadata: { openapi: { operationId: string; summary: string; description: string; responses: { 200: { description: string; content: { "application/json": { schema: { type: "object"; properties: { success: { type: string; }; }; }; }; }; }; }; }; }; } & { use: any[]; }; path: "/admin/revoke-user-sessions"; }; /** * ### Endpoint * * POST `/admin/remove-user` * * ### API Methods * * **server:** * `auth.api.removeUser` * * **client:** * `authClient.admin.removeUser` * * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/admin#api-method-admin-remove-user) */ removeUser: { (inputCtx_0: { body: { userId: unknown; }; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers?: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { success: boolean; }; } : { success: boolean; }>; options: { method: "POST"; body: z.ZodObject<{ userId: z.ZodCoercedString; }, z.core.$strip>; use: ((inputContext: better_call.MiddlewareInputContext) => Promise<{ session: { user: UserWithRole; session: Session; }; }>)[]; metadata: { openapi: { operationId: string; summary: string; description: string; responses: { 200: { description: string; content: { "application/json": { schema: { type: "object"; properties: { success: { type: string; }; }; }; }; }; }; }; }; }; } & { use: any[]; }; path: "/admin/remove-user"; }; /** * ### Endpoint * * POST `/admin/set-user-password` * * ### API Methods * * **server:** * `auth.api.setUserPassword` * * **client:** * `authClient.admin.setUserPassword` * * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/admin#api-method-admin-set-user-password) */ setUserPassword: { (inputCtx_0: { body: { newPassword: string; userId: unknown; }; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers?: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { status: boolean; }; } : { status: boolean; }>; options: { method: "POST"; body: z.ZodObject<{ newPassword: z.ZodString; userId: z.ZodCoercedString; }, z.core.$strip>; use: ((inputContext: better_call.MiddlewareInputContext) => Promise<{ session: { user: UserWithRole; session: Session; }; }>)[]; metadata: { openapi: { operationId: string; summary: string; description: string; responses: { 200: { description: string; content: { "application/json": { schema: { type: "object"; properties: { status: { type: string; }; }; }; }; }; }; }; }; }; } & { use: any[]; }; path: "/admin/set-user-password"; }; /** * ### Endpoint * * POST `/admin/has-permission` * * ### API Methods * * **server:** * `auth.api.userHasPermission` * * **client:** * `authClient.admin.hasPermission` * * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/admin#api-method-admin-has-permission) */ userHasPermission: { (inputCtx_0: { body: ({ /** * @deprecated Use `permissions` instead */ permission: { [key in keyof (O["ac"] extends AccessControl ? S : { readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "update"]; readonly session: readonly ["list", "revoke", "delete"]; })]?: ((O["ac"] extends AccessControl ? S : { readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "update"]; readonly session: readonly ["list", "revoke", "delete"]; })[key] extends readonly unknown[] ? (O["ac"] extends AccessControl ? S : { readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "update"]; readonly session: readonly ["list", "revoke", "delete"]; })[key][number] : never)[] | undefined; }; permissions?: never; } | { permissions: { [key in keyof (O["ac"] extends AccessControl ? S : { readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "update"]; readonly session: readonly ["list", "revoke", "delete"]; })]?: ((O["ac"] extends AccessControl ? S : { readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "update"]; readonly session: readonly ["list", "revoke", "delete"]; })[key] extends readonly unknown[] ? (O["ac"] extends AccessControl ? S : { readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "update"]; readonly session: readonly ["list", "revoke", "delete"]; })[key][number] : never)[] | undefined; }; permission?: never; }) & { userId?: string; role?: InferAdminRolesFromOption; }; } & { method?: "POST" | undefined; } & { query?: Record | undefined; } & { params?: Record; } & { request?: Request; } & { headers?: HeadersInit; } & { asResponse?: boolean; returnHeaders?: boolean; use?: better_call.Middleware[]; path?: string; } & { asResponse?: AsResponse | undefined; returnHeaders?: ReturnHeaders | undefined; }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? { headers: Headers; response: { error: null; success: boolean; }; } : { error: null; success: boolean; }>; options: { method: "POST"; body: z.ZodIntersection>; role: z.ZodOptional; }, z.core.$strip>, z.ZodUnion>; permissions: z.ZodUndefined; }, z.core.$strip>, z.ZodObject<{ permission: z.ZodUndefined; permissions: z.ZodRecord>; }, z.core.$strip>]>>; metadata: { openapi: { description: string; requestBody: { content: { "application/json": { schema: { type: "object"; properties: { permission: { type: string; description: string; deprecated: boolean; }; permissions: { type: string; description: string; }; }; required: string[]; }; }; }; }; responses: { "200": { description: string; content: { "application/json": { schema: { type: "object"; properties: { error: { type: string; }; success: { type: string; }; }; required: string[]; }; }; }; }; }; }; $Infer: { body: ({ /** * @deprecated Use `permissions` instead */ permission: { [key in keyof (O["ac"] extends AccessControl ? S : { readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "update"]; readonly session: readonly ["list", "revoke", "delete"]; })]?: ((O["ac"] extends AccessControl ? S : { readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "update"]; readonly session: readonly ["list", "revoke", "delete"]; })[key] extends readonly unknown[] ? (O["ac"] extends AccessControl ? S : { readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "update"]; readonly session: readonly ["list", "revoke", "delete"]; })[key][number] : never)[] | undefined; }; permissions?: never; } | { permissions: { [key in keyof (O["ac"] extends AccessControl ? S : { readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "update"]; readonly session: readonly ["list", "revoke", "delete"]; })]?: ((O["ac"] extends AccessControl ? S : { readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "update"]; readonly session: readonly ["list", "revoke", "delete"]; })[key] extends readonly unknown[] ? (O["ac"] extends AccessControl ? S : { readonly user: readonly ["create", "list", "set-role", "ban", "impersonate", "delete", "set-password", "update"]; readonly session: readonly ["list", "revoke", "delete"]; })[key][number] : never)[] | undefined; }; permission?: never; }) & { userId?: string; role?: InferAdminRolesFromOption; }; }; }; } & { use: any[]; }; path: "/admin/has-permission"; }; }; $ERROR_CODES: { readonly FAILED_TO_CREATE_USER: "Failed to create user"; readonly USER_ALREADY_EXISTS: "User already exists"; readonly YOU_CANNOT_BAN_YOURSELF: "You cannot ban yourself"; readonly YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE: "You are not allowed to change users role"; readonly YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS: "You are not allowed to create users"; readonly YOU_ARE_NOT_ALLOWED_TO_LIST_USERS: "You are not allowed to list users"; readonly YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS: "You are not allowed to list users sessions"; readonly YOU_ARE_NOT_ALLOWED_TO_BAN_USERS: "You are not allowed to ban users"; readonly YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS: "You are not allowed to impersonate users"; readonly YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS: "You are not allowed to revoke users sessions"; readonly YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS: "You are not allowed to delete users"; readonly YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD: "You are not allowed to set users password"; readonly BANNED_USER: "You have been banned from this application"; readonly NO_DATA_TO_UPDATE: "No data to update"; readonly YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS: "You are not allowed to update users"; }; schema: { user: { fields: { role: { type: "string"; required: false; input: false; }; banned: { type: "boolean"; defaultValue: false; required: false; input: false; }; banReason: { type: "string"; required: false; input: false; }; banExpires: { type: "date"; required: false; input: false; }; }; }; session: { fields: { impersonatedBy: { type: "string"; required: false; }; }; }; }; options: any; }; export { admin }; export type { AdminOptions, InferAdminRolesFromOption, SessionWithImpersonatedBy, UserWithRole };