// @ts-check
/**
* @import {ExpressRequestAuthorized, ExpressResponse} from '../types.js'
*/
/**
* Event Job Router
*
* This router manages job assignments in events - linking persons to events
* with specific roles, responsibilities, and qualifications.
*
* @swagger
* components:
* schemas:
* EventJob:
* type: object
* properties:
* UID:
* type: string
* format: uuid
* UIDBelongsTo:
* type: string
* format: uuid
* description: Person UID
* Title:
* type: string
* Display:
* type: string
* qualified:
* type: number
* description: 1 if qualified, 0 if not
* UIDTemplate:
* type: string
* format: uuid
* description: Job template UID
* isRole:
* type: boolean
* isResponsible:
* type: boolean
* isMandatory:
* type: boolean
* UIDgroup:
* type: string
* format: uuid
* pGroup:
* type: string
* email:
* type: string
*
* tags:
* - name: Event Jobs
* description: Job assignment management for events
*/
import express from 'express';
import { checkAdmin, checkObjectAdmin, checkVisible } from '../utils/authChecks.js';
import * as eventJobController from './eventJob/controller.js';
/** @type {express.Express} */
const api = express();
// Export helper functions for use by other modules
export { jobQualified, recreateJobsGroup, recreateJobsFunction, requalify } from './eventJob/service.js';
export { putMemberFunctionTemplate } from './eventJob/service.js';
/**
* @swagger
* /api/eventJob/recreate:
* get:
* summary: Recreate all jobs for organization
* description: Re-renders all job objects based on their templates
* tags:
* - Event Jobs
* security:
* - bearerAuth: []
* responses:
* 200:
* description: Jobs recreated successfully
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
*/
// @ts-ignore
api.get('/recreate', checkAdmin, eventJobController.recreateAllJobsController);
/**
* @swagger
* /api/eventJob/recreate/{UIDperson}:
* get:
* summary: Recreate jobs for a person
* description: Re-renders all job objects for a specific person
* tags:
* - Event Jobs
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: UIDperson
* required: true
* schema:
* type: string
* format: uuid
* responses:
* 200:
* description: Person jobs recreated successfully
*/
// @ts-ignore
api.get('/recreate/:UIDperson', checkObjectAdmin, eventJobController.recreatePersonJobsController);
/**
* @swagger
* /api/eventJob/{member}/{event}/{function}:
* put:
* summary: Create job with function template
* description: Assigns a person to an event with a specific job function template
* tags:
* - Event Jobs
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: member
* required: true
* schema:
* type: string
* format: uuid
* description: Person/member UUID
* - in: path
* name: event
* required: true
* schema:
* type: string
* format: uuid
* description: Event UUID
* - in: path
* name: function
* required: true
* schema:
* type: string
* format: uuid
* description: Job function template UUID
* requestBody:
* content:
* application/json:
* schema:
* type: object
* properties:
* UID:
* type: string
* format: uuid
* description: Optional job UID (auto-generated if not provided)
* responses:
* 200:
* description: Job created successfully
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* $ref: '#/components/schemas/EventJob'
*/
// @ts-ignore
api.put('/:member/:event/:function', eventJobController.createJobWithTemplateController);
/**
* @swagger
* /api/eventJob/{member}/{event}:
* put:
* summary: Create free job without template
* description: Creates a custom job assignment without a predefined template
* tags:
* - Event Jobs
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: member
* required: true
* schema:
* type: string
* format: uuid
* - in: path
* name: event
* required: true
* schema:
* type: string
* format: uuid
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - name
* properties:
* name:
* type: string
* description: Job name/title
* UID:
* type: string
* format: uuid
* responses:
* 200:
* description: Free job created successfully
*/
// @ts-ignore
api.put('/:member/:event', eventJobController.createFreeJobController);
/**
* @swagger
* /api/eventJob/{UID}:
* post:
* summary: Update job template assignment
* description: Changes the function template for an existing job
* tags:
* - Event Jobs
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: UID
* required: true
* schema:
* type: string
* format: uuid
* description: Job UUID
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - UIDTemplate
* properties:
* UIDTemplate:
* type: string
* format: uuid
* description: New function template UUID
* responses:
* 200:
* description: Job updated successfully
*/
// @ts-ignore
api.post('/:UID', eventJobController.updateJobController);
/**
* @swagger
* /api/eventJob/responsible/{event}:
* post:
* summary: Set responsible person for event
* description: Assigns a person as responsible/leader for an event
* tags:
* - Event Jobs
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: event
* required: true
* schema:
* type: string
* format: uuid
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - UID
* properties:
* UID:
* type: string
* format: uuid
* description: Person UUID to set as responsible
* responses:
* 200:
* description: Responsible person set successfully
*/
// @ts-ignore
api.post('/responsible/:event', checkObjectAdmin, eventJobController.setResponsibleController);
/**
* @swagger
* /api/eventJob/{UID}:
* delete:
* summary: Delete a job
* description: Removes a job assignment from an event
* tags:
* - Event Jobs
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: UID
* required: true
* schema:
* type: string
* format: uuid
* description: Job UUID to delete
* responses:
* 200:
* description: Job deleted successfully
*/
// @ts-ignore
api.delete('/:UID', checkObjectAdmin, eventJobController.deleteJobController);
/**
* @swagger
* /api/eventJob/leader/{UIDevent}/{UIDperson}:
* delete:
* summary: Delete all jobs for person in event
* description: Removes all job assignments for a specific person in an event
* tags:
* - Event Jobs
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: UIDevent
* required: true
* schema:
* type: string
* format: uuid
* - in: path
* name: UIDperson
* required: true
* schema:
* type: string
* format: uuid
* responses:
* 200:
* description: Jobs deleted successfully
*/
// @ts-ignore
api.delete('/leader/:UIDevent/:UIDperson', checkObjectAdmin, eventJobController.deleteLeaderJobsController);
/**
* @swagger
* /api/eventJob/{UID}:
* get:
* summary: Get single job details
* description: Retrieves detailed information about a specific job
* tags:
* - Event Jobs
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: UID
* required: true
* schema:
* type: string
* format: uuid
* responses:
* 200:
* description: Job details retrieved successfully
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* $ref: '#/components/schemas/EventJob'
*/
// @ts-ignore
api.get('/:UID', eventJobController.getJobController);
/**
* @swagger
* /api/eventJob/jobs/{UID}:
* get:
* summary: Get list of jobs for an event
* description: Retrieves all job assignments for a specific event
* tags:
* - Event Jobs
* 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
* - in: query
* name: Data
* schema:
* type: string
* description: "'all' for complete data or JSON field paths"
* responses:
* 200:
* description: List of jobs retrieved successfully
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* type: array
* items:
* $ref: '#/components/schemas/EventJob'
*/
// @ts-ignore
api.get('/jobs/:UID', checkVisible, eventJobController.listJobsController);
export default api;