import express from 'express';
import { wrapAsync } from '@/api/http/request';
import * as content_catalog from '@/api/controllers/content_catalog.controller';

const router = express.Router();

/**
 * @openapi
 * /api/content-catalog:
 *   get:
 *     tags: [Content Catalog]
 *     summary: List managed content-catalog entries
 *     responses:
 *       200:
 *         description: Catalog entries.
 *         content:
 *           application/json:
 *             schema: { $ref: '#/components/schemas/ListResponse' }
 *       401: { $ref: '#/components/responses/UnauthorizedError' }
 *   post:
 *     tags: [Content Catalog]
 *     summary: Create a content-catalog entry (manager-only; service-gated)
 *     responses:
 *       200: { description: Created. }
 *       403: { $ref: '#/components/responses/ForbiddenError' }
 * /api/content-catalog/{contentType}:
 *   get:
 *     tags: [Content Catalog]
 *     summary: Get managed entries for a content type
 *     parameters:
 *       - in: path
 *         name: contentType
 *         required: true
 *         schema: { type: string }
 *     responses:
 *       200: { description: Entries for the type. }
 *   put:
 *     tags: [Content Catalog]
 *     summary: Update entries for a content type (manager-only; service-gated)
 *     parameters:
 *       - in: path
 *         name: contentType
 *         required: true
 *         schema: { type: string }
 *     responses:
 *       200: { description: Updated. }
 *       403: { $ref: '#/components/responses/ForbiddenError' }
 *   delete:
 *     tags: [Content Catalog]
 *     summary: Delete entries for a content type (manager-only; service-gated)
 *     parameters:
 *       - in: path
 *         name: contentType
 *         required: true
 *         schema: { type: string }
 *     responses:
 *       200: { description: Deleted. }
 *       403: { $ref: '#/components/responses/ForbiddenError' }
 */
router.get('/', wrapAsync(content_catalog.list));
router.post('/', wrapAsync(content_catalog.create));
router.get('/:contentType', wrapAsync(content_catalog.findManagedByType));
router.put('/:contentType', wrapAsync(content_catalog.update));
router.delete('/:contentType', wrapAsync(content_catalog.remove));

export default router;
