// @ts-check
/**
* @import {ExpressRequestAuthorized, ExpressResponse} from '../types.js'
*/
/**
* Event Template Router
*
* Manages event templates including creation, update, deletion, and retrieval.
* Event templates define the structure and configuration for events in the system.
*
* @swagger
* components:
* schemas:
* EventTemplate:
* type: object
* properties:
* UID:
* type: string
* format: uuid
* Display:
* type: string
* SortName:
* type: string
* Data:
* type: object
* properties:
* templateVisibility:
* type: object
* description: Filter definition for template visibility
* templateAdministration:
* type: object
* description: Filter definition for template administration
* EventTemplateInput:
* type: object
* properties:
* UID:
* type: string
* format: uuid
* description: Optional UID for updates
* templateVisibility:
* type: object
* templateAdministration:
* type: object
*
* tags:
* - name: Event Templates
* description: Event template management operations
*/
import express from 'express';
import { checkObjectAdmin } from '../utils/authChecks.js';
import * as eventTemplateController from './eventTemplate/controller.js';
/** @type {express.Express} */
const api = express();
/**
* @swagger
* /api/eventTemplate:
* put:
* summary: Create or update an event template
* description: Creates a new event template or updates an existing one. Requires admin rights for the organization to create new templates, or object admin rights to update existing templates.
* tags:
* - Event Templates
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/EventTemplateInput'
* responses:
* 200:
* description: Successfully created or updated template
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* $ref: '#/components/schemas/EventTemplate'
* 500:
* description: Server error
*/
// @ts-ignore
api.put('/', eventTemplateController.createOrUpdateEventTemplateController);
/**
* @swagger
* /api/eventTemplate/{UID}:
* post:
* summary: Update an existing event template
* description: Updates an existing event template. User must have object admin rights for this template.
* tags:
* - Event Templates
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: UID
* required: true
* schema:
* type: string
* format: uuid
* description: Event template UID
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* responses:
* 200:
* description: Successfully updated template
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* type: object
* description: Diff object showing changes
* 404:
* description: Template not found
* 500:
* description: Server error
*/
// @ts-ignore
api.post('/:UID', checkObjectAdmin, eventTemplateController.updateEventTemplateController);
/**
* @swagger
* /api/eventTemplate/{UID}:
* delete:
* summary: Delete an event template
* description: Deletes an event template. User must have object admin rights for this template.
* tags:
* - Event Templates
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: UID
* required: true
* schema:
* type: string
* format: uuid
* description: Event template UID
* responses:
* 200:
* description: Successfully deleted template
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* 500:
* description: Server error
*/
// @ts-ignore
api.delete('/:UID', eventTemplateController.deleteEventTemplateController);
/**
* @swagger
* /api/eventTemplate:
* get:
* summary: Get all event templates
* description: Returns all event templates for the organization that are visible to the user.
* tags:
* - Event Templates
* security:
* - bearerAuth: []
* responses:
* 200:
* description: Successfully retrieved templates
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* type: array
* items:
* type: object
* properties:
* UID:
* type: string
* format: uuid
* Display:
* type: string
* SortName:
* type: string
* 500:
* description: Server error
*/
// @ts-ignore
api.get('/', eventTemplateController.getAllEventTemplatesController);
/**
* @swagger
* /api/eventTemplate/Data:
* get:
* summary: Get all event templates with data
* description: Returns all event templates for the organization with full data that are visible to the user.
* tags:
* - Event Templates
* security:
* - bearerAuth: []
* responses:
* 200:
* description: Successfully retrieved templates with data
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* type: array
* items:
* $ref: '#/components/schemas/EventTemplate'
* 500:
* description: Server error
*/
// @ts-ignore
api.get('/Data', eventTemplateController.getAllEventTemplatesWithDataController);
/**
* @swagger
* /api/eventTemplate/admin:
* get:
* summary: Get administrable event templates
* description: Returns all event templates that the user can administer.
* tags:
* - Event Templates
* security:
* - bearerAuth: []
* responses:
* 200:
* description: Successfully retrieved administrable templates
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* type: array
* items:
* $ref: '#/components/schemas/EventTemplate'
* 500:
* description: Server error
*/
// @ts-ignore
api.get('/admin', eventTemplateController.getAdminEventTemplatesController);
/**
* @swagger
* /api/eventTemplate/{UID}:
* get:
* summary: Get a specific event template
* description: Returns a specific event template by UID if the user has visibility rights.
* tags:
* - Event Templates
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: UID
* required: true
* schema:
* type: string
* format: uuid
* description: Event template UID
* responses:
* 200:
* description: Successfully retrieved template
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* $ref: '#/components/schemas/EventTemplate'
* 403:
* description: Not authorized
* 500:
* description: Server error
*/
// @ts-ignore
api.get('/:UID', eventTemplateController.getEventTemplateByUIDController);
/**
* @swagger
* /api/eventTemplate/event/{UID}:
* get:
* summary: Get template for an event
* description: Returns the event template associated with a specific event UID.
* tags:
* - Event Templates
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: UID
* required: true
* schema:
* type: string
* format: uuid
* description: Event UID
* responses:
* 200:
* description: Successfully retrieved template
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* $ref: '#/components/schemas/EventTemplate'
* 403:
* description: Not authorized
* 500:
* description: Server error
*/
// @ts-ignore
api.get('/event/:UID', eventTemplateController.getEventTemplateByEventUIDController);
export default api;