import { Hono } from 'hono' import * as z from 'zod/mini' import * as OpenApi from '../../internal/OpenApi.js' import * as Scope from '../../Scope.js' import type * as App from '../App.js' /** Zod schemas owned by the admin scope catalog handler. */ export namespace schema { /** Schemas for the getAdminScopes operation. */ export namespace getScopes { /** A single issuable API-key scope. */ export const Scope = z .object({ description: z .string() .check(z.describe('Human-readable explanation of what the scope grants.')), scope: z .string() .check(z.describe('Scope identifier used in API-key grants and route policies.')), selfServe: z .boolean() .check(z.describe('Whether a session may self-mint this scope (else super-admin-only).')), }) .check(z.describe('A single issuable API-key scope.')) /** Response body for the scope catalog. */ export const Response = z .object({ data: z.array(Scope).check(z.describe('Issuable API-key scopes.')), }) .check(z.describe('Response body for the scope catalog.')) } } /** Catalog of API-key scopes, including dynamic scope templates. */ export function scopes() { return new Hono().get( '/', OpenApi.describeRoute({ operationId: 'getAdminScopes', responses: OpenApi.responses({ success: { description: 'Issuable scope catalog.', schema: schema.getScopes.Response }, }), summary: 'List scopes', tags: ['Scopes'], }), (c) => c.json({ data: Scope.extend() }), ) }