/** * Singles Detail API Route Handlers for Next.js * * These route handlers can be re-exported in your Next.js application to provide * individual Single management endpoints at /api/singles/[slug]. * * Services are auto-initialized on first request using environment variables: * - DB_DIALECT: Database dialect ("postgresql" | "mysql" | "sqlite") * - DATABASE_URL: Database connection string * * @example * ```typescript * // In your Next.js app: app/api/singles/[slug]/route.ts * export { GET, PATCH } from 'nextly/api/singles-detail'; * ``` * * @module api/singles-detail */ /** * Context object for dynamic route handlers. * Next.js 15+ requires params to be a Promise. */ interface RouteContext { params: Promise<{ slug: string; }>; } /** * GET handler for retrieving a Single document by slug. * * This is a public endpoint - no authentication required. * If the Single document doesn't exist, it will be auto-created with default * field values. * * Query Parameters: * - depth: Relationship expansion depth (reserved for future use) * - locale: Locale for localized fields (reserved for future use) * - richTextFormat: Output format for rich text fields ("json" | "html" | "both") * - "json" (default): Return Lexical JSON structure only * - "html": Return HTML string only * - "both": Return object with both { json, html } properties * * Response: * - 200 OK: bare document object (canonical `respondDoc` shape). * - On error: `application/problem+json` per spec §10.1. */ declare const GET: (request: Request, context: RouteContext) => Promise; /** * PATCH handler for updating a Single document. * * Requires a verified session or API key with update access to the Single, * matching the dispatcher's `updateSingleDocument` authorization. If the * Single document doesn't exist, it will be auto-created first, then * updated with the provided data. * * Note: Singles cannot be deleted. They represent persistent site-wide * configuration that always exists once accessed. * * Request Body: * - Any fields defined in the Single schema * - System fields (id, createdAt) are ignored if included * * Response: * - 200 OK: `{ "message": "...", "item": { ... } }` (updated document). * - On error: `application/problem+json` per spec §10.1. */ declare const PATCH: (request: Request, context: RouteContext) => Promise; /** * GET handler for retrieving Single schema/metadata by slug. * * This endpoint returns the Single's schema configuration, not the document data. * Useful for Admin UI to understand the field structure. * * Requires a verified session or API key with read access to the Single, * matching the dispatcher's `getSingleSchema` authorization. * * Response: * - 200 OK: bare schema object (canonical `respondDoc` shape). * - 401 / 404 / 500: `application/problem+json` per spec §10.1. * * @example * ```bash * curl -H "Authorization: Bearer " \ * "http://localhost:3000/api/singles/site-settings/schema" * # => {"slug":"site-settings","label":"Site Settings","fields":[...]} * ``` */ declare function getSchema(request: Request, slug: string): Promise; export { GET, PATCH, getSchema };