import type { AnyElysia } from 'elysia'
import type { ControllerMeta } from './meta'

export type CrudRouteOptionsInput = {
  public?: boolean
  /** CRUD / serviceApi 名，用于自动权限码 */
  action?: string
  /** OpenAPI 备注（侧栏：`action 备注`） */
  summary?: string
}

/** 宿主挂载快速 CRUD 路由（Drizzle / BaseService） */
export type CrudRegistrar = (
  plugin: AnyElysia,
  meta: ControllerMeta,
  ctx: {
    controller: object
    /** 给自动路由挂 adminAuth + 权限码 */
    routeOptions: (opts?: boolean | CrudRouteOptionsInput) => Record<string, unknown> | undefined
  },
) => AnyElysia
