Source: RouterEvents/eventPersons.js

// @ts-check
/**
 * @import {ExpressRequestAuthorized, ExpressResponse} from '../types.js'
 */

/**
 * Event Persons Router
 * 
 * Manages event participant lists and list updates.
 * 
 * @swagger
 * components:
 *   schemas:
 *     EventList:
 *       type: object
 *       properties:
 *         UID:
 *           type: string
 *           format: uuid
 *         Data:
 *           type: object
 *         UIDowner:
 *           type: string
 *           format: uuid
 *         TitleOwner:
 *           type: string
 *         DisplayOwner:
 *           type: string
 *         visible:
 *           type: boolean
 *         participants:
 *           type: array
 *           items:
 *             type: object
 * 
 * tags:
 *   - name: Event Persons
 *     description: Event participant list management
 */

import express from 'express';
import { checkObjectAdmin, checkVisible } from '../utils/authChecks.js';
import * as eventPersonsController from './eventPersons/controller.js';

/** @type {express.Express} */
const eventList = express();

// Export helper functions for use by other modules
export { nameReplace } from './eventPersons/service.js';

/**
 * @swagger
 * /api/events/persons/list/{UID}:
 *   post:
 *     summary: Update an event participant list
 *     description: Updates the list of participants for an event. User must be an admin of the event or a system admin.
 *     tags:
 *       - Event Persons
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: UID
 *         required: true
 *         schema:
 *           type: string
 *           format: uuid
 *         description: The list UID to update
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             description: List update data
 *     responses:
 *       200:
 *         description: List update result
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                 result:
 *                   type: object
 *       401:
 *         description: User not authorized
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 *                   example: user not authorized
 */
// @ts-ignore
eventList.post('/list/:UID', checkObjectAdmin, eventPersonsController.updateEventListController);

/**
 * @swagger
 * /api/events/persons/{UID}:
 *   get:
 *     summary: Get event participant lists
 *     description: Retrieves all participant lists for an event along with their participants. User must have visibility rights to the event.
 *     tags:
 *       - Event Persons
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: UID
 *         required: true
 *         schema:
 *           type: string
 *           format: uuid
 *         description: The event UID
 *       - in: query
 *         name: guest
 *         schema:
 *           type: boolean
 *         description: Include guest participants
 *       - in: query
 *         name: ExtraData
 *         schema:
 *           type: string
 *         description: JSON string of extra data fields to include
 *     responses:
 *       200:
 *         description: Event participant lists retrieved successfully
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                 result:
 *                   type: array
 *                   items:
 *                     $ref: '#/components/schemas/EventList'
 *       400:
 *         description: Invalid UID supplied
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 */
// @ts-ignore
eventList.get('/:UID', checkVisible, eventPersonsController.getEventListsController);

export default eventList;