UNPKG

@nangazaki/vue-rbac

Version:

Role-Based Access Control (RBAC) implementation for Vue.js

3 lines (2 loc) 878 B
import{CONFIG_MODE as r}from"../types/config.types.js";const i=[r.STATIC,r.DYNAMIC,r.HYBRID];function o(o){const e={...o};if(o.mode&&!i.includes(o.mode))throw new Error(`Invalid Mode: ${o.mode}. Use 'static', 'dynamic' or 'hybrid'.`);return o.mode!==r.DYNAMIC&&o.mode!==r.HYBRID||o.apiEndpoint||console.warn("Dynamic/hybrid mode requires an apiEndpoint. Using default: /api/rbac/permissions"),o.roles&&Object.entries(o.roles).forEach((([r,i])=>{if(!Array.isArray(i.permissions))throw new Error(`Permissions for role '${r}' must be an array.`);if(i.inherits){if(!Array.isArray(i.inherits))throw new Error(`'inherits' for role '${r}' must be an array.`);i.inherits.forEach((i=>{var e;if(!(null===(e=o.roles)||void 0===e?void 0:e[i]))throw new Error(`Role '${r}' inherits from '${i}' which is not defined.`)}))}})),e}export{o as validateConfig}; //# sourceMappingURL=schema.js.map