import { createAccessControl } from "better-auth/plugins/access";
import {
  defaultStatements,
  adminAc,
} from "better-auth/plugins/admin/access";

// 合并默认权限语句与自定义业务权限语句
const statements = {
  ...defaultStatements,
  // 自定义业务权限资源，按需扩展
  // project: ["create", "share", "update", "delete"],
} as const;

export const ac = createAccessControl(statements);

// admin 角色：拥有全部管理权限
export const adminRole = ac.newRole({
  ...adminAc.statements,
});

// user 角色：无管理权限（仅拥有默认业务权限）
export const userRole = ac.newRole({
  // project: ["create"],
});

export type Roles = {
  admin: typeof adminRole;
  user: typeof userRole;
};
