Source: RouterEvents/eventGroup.js

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

/**
 * Event Group Router
 * 
 * This router manages the association between events and groups through
 * gentry objects, participant lists, and access control.
 * 
 * @swagger
 * components:
 *   schemas:
 *     EventGroup:
 *       type: object
 *       properties:
 *         UID:
 *           type: string
 *           format: uuid
 *           description: Group entry (gentry) unique identifier
 *         UIDBelongsTo:
 *           type: string
 *           format: uuid
 *           description: Parent group UID
 *         Title:
 *           type: string
 *           description: Group title
 *         Display:
 *           type: string
 *           description: Display name
 *         SortName:
 *           type: string
 *         hierarchie:
 *           type: number
 *         stage:
 *           type: string
 *         gender:
 *           type: string
 *         dindex:
 *           type: number
 *         UIDgroup:
 *           type: string
 *           format: uuid
 *           description: Parent group reference
 *         pGroup:
 *           type: string
 *           description: Parent group display text
 * 
 * tags:
 *   - name: Event Groups
 *     description: Group association management for events
 */

import express from 'express';
import * as eventGroupController from './eventGroup/controller.js';

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

// Export helper function for use by other modules
export { addParticipantList } from './eventGroup/service.js';

/**
 * @swagger
 * /api/eventGroup/{UIDevent}:
 *   put:
 *     summary: Add a group to an event
 *     description: Associates a group with an event by creating a gentry object and participant list
 *     tags:
 *       - Event Groups
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: UIDevent
 *         required: true
 *         schema:
 *           type: string
 *           format: uuid
 *         description: Event UUID
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             required:
 *               - UID
 *             properties:
 *               UID:
 *                 type: string
 *                 format: uuid
 *                 description: Group UUID to associate with event
 *     responses:
 *       200:
 *         description: Group added to event successfully
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                 result:
 *                   $ref: '#/components/schemas/EventGroup'
 *       300:
 *         description: Error adding group
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 */
// @ts-ignore
// @ts-ignore
api.put('/:UIDevent', eventGroupController.addGroupToEventController);

/**
 * @swagger
 * /api/eventGroup/{UIDevent}/{UIDgroup}:
 *   delete:
 *     summary: Remove a group from an event
 *     description: Deletes the gentry association, participant list, and filters
 *     tags:
 *       - Event Groups
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: UIDevent
 *         required: true
 *         schema:
 *           type: string
 *           format: uuid
 *         description: Event UUID
 *       - in: path
 *         name: UIDgroup
 *         required: true
 *         schema:
 *           type: string
 *           format: uuid
 *         description: Group UUID to remove from event
 *     responses:
 *       200:
 *         description: Group removed from event successfully
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *       300:
 *         description: Error removing group
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 */
// @ts-ignore
// @ts-ignore
api.delete('/:UIDevent/:UIDgroup', eventGroupController.deleteGroupFromEventController);

/**
 * @swagger
 * /api/eventGroup/{UID}:
 *   get:
 *     summary: Get list of groups associated with an event
 *     description: Retrieves all gentries (group entries) for an event with optional custom data fields
 *     tags:
 *       - Event Groups
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: UID
 *         required: true
 *         schema:
 *           type: string
 *           format: uuid
 *         description: Event UUID
 *       - in: query
 *         name: __page
 *         schema:
 *           type: integer
 *         description: Page number for pagination (optional)
 *       - in: query
 *         name: Data
 *         schema:
 *           type: string
 *         description: "Either 'all'/'full' for complete data, or JSON string of field paths"
 *     responses:
 *       200:
 *         description: List of event groups retrieved successfully
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                 result:
 *                   type: array
 *                   items:
 *                     $ref: '#/components/schemas/EventGroup'
 *       500:
 *         description: Internal server error
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: false
 *                 message:
 *                   type: string
 */
// @ts-ignore
api.get('/:UID', eventGroupController.listEventGroupsController);

export default api;