UNPKG

company-cafeteria-shared-demo

Version:

Package partagé pour l'écosystème Cafétéria Entreprise

146 lines 4.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DEPARTMENT_LABELS = exports.DEPARTMENTS = exports.ROLE_HIERARCHY = exports.ROLE_DESCRIPTIONS = exports.ROLE_LABELS = exports.ROLE_PERMISSIONS = exports.USER_ROLES = void 0; exports.hasPermission = hasPermission; exports.hasRoleLevel = hasRoleLevel; exports.getRolePermissions = getRolePermissions; exports.canManageOrder = canManageOrder; /** * Rôles d'utilisateur dans le système */ exports.USER_ROLES = { AGENT: 'agent', ADMIN: 'admin', KITCHEN: 'kitchen', MANAGER: 'manager' }; /** * Permissions par rôle */ exports.ROLE_PERMISSIONS = { [exports.USER_ROLES.AGENT]: [ 'view_menu', 'create_order', 'view_own_orders', 'cancel_own_order', 'update_profile', 'view_recommendations' ], [exports.USER_ROLES.KITCHEN]: [ 'view_menu', 'view_all_orders', 'update_order_status', 'manage_inventory', 'view_kitchen_analytics' ], [exports.USER_ROLES.MANAGER]: [ 'view_menu', 'manage_menu', 'view_all_orders', 'view_analytics', 'manage_promotions', 'export_data' ], [exports.USER_ROLES.ADMIN]: [ 'view_menu', 'manage_menu', 'view_all_orders', 'update_order_status', 'manage_inventory', 'view_analytics', 'manage_users', 'manage_promotions', 'system_settings', 'export_data', 'manage_ai_settings' ] }; /** * Libellés d'affichage pour les rôles */ exports.ROLE_LABELS = { [exports.USER_ROLES.AGENT]: 'Agent', [exports.USER_ROLES.ADMIN]: 'Administrateur', [exports.USER_ROLES.KITCHEN]: 'Équipe Cuisine', [exports.USER_ROLES.MANAGER]: 'Manager' }; /** * Descriptions des rôles */ exports.ROLE_DESCRIPTIONS = { [exports.USER_ROLES.AGENT]: 'Employé standard - peut commander et gérer son profil', [exports.USER_ROLES.ADMIN]: 'Administrateur système - accès complet à toutes les fonctionnalités', [exports.USER_ROLES.KITCHEN]: 'Équipe cuisine - gestion des commandes et de la préparation', [exports.USER_ROLES.MANAGER]: 'Manager - accès aux analytics et gestion du menu' }; /** * Hiérarchie des rôles (du plus bas au plus élevé) */ exports.ROLE_HIERARCHY = [ exports.USER_ROLES.AGENT, exports.USER_ROLES.KITCHEN, exports.USER_ROLES.MANAGER, exports.USER_ROLES.ADMIN ]; /** * Vérifie si un utilisateur a une permission spécifique */ function hasPermission(userRole, permission) { return exports.ROLE_PERMISSIONS[userRole]?.includes(permission) ?? false; } /** * Vérifie si un rôle a un niveau hiérarchique supérieur ou égal à un autre */ function hasRoleLevel(userRole, requiredRole) { const userLevel = exports.ROLE_HIERARCHY.indexOf(userRole); const requiredLevel = exports.ROLE_HIERARCHY.indexOf(requiredRole); return userLevel >= requiredLevel; } /** * Obtient toutes les permissions d'un rôle */ function getRolePermissions(userRole) { return exports.ROLE_PERMISSIONS[userRole] ?? []; } /** * Vérifie si un utilisateur peut effectuer une action sur une commande */ function canManageOrder(userRole, orderUserId, currentUserId) { // Les admins et la cuisine peuvent gérer toutes les commandes if (userRole === exports.USER_ROLES.ADMIN || userRole === exports.USER_ROLES.KITCHEN) { return true; } // Les agents ne peuvent gérer que leurs propres commandes if (userRole === exports.USER_ROLES.AGENT) { return orderUserId === currentUserId; } // Les managers peuvent voir toutes les commandes mais pas les modifier return false; } /** * Départements disponibles pour les agents */ exports.DEPARTMENTS = { IT: 'IT', MARKETING: 'Marketing', SALES: 'Commercial', HR: 'Ressources Humaines', FINANCE: 'Finance', OPERATIONS: 'Opérations', DESIGN: 'Design', LEGAL: 'Juridique' }; /** * Libellés des départements */ exports.DEPARTMENT_LABELS = { [exports.DEPARTMENTS.IT]: 'Informatique', [exports.DEPARTMENTS.MARKETING]: 'Marketing', [exports.DEPARTMENTS.SALES]: 'Commercial', [exports.DEPARTMENTS.HR]: 'Ressources Humaines', [exports.DEPARTMENTS.FINANCE]: 'Finance', [exports.DEPARTMENTS.OPERATIONS]: 'Opérations', [exports.DEPARTMENTS.DESIGN]: 'Design', [exports.DEPARTMENTS.LEGAL]: 'Juridique' }; //# sourceMappingURL=userRoles.js.map