agents defs from DB

This commit is contained in:
STEINNI
2025-10-12 19:45:18 +00:00
parent f62a7176d4
commit a38d2da3e4
11 changed files with 64 additions and 1014 deletions
-24
View File
@@ -32,30 +32,6 @@ class EICModel extends Model {
this.setPrivileges(resource, privileges);
}
/**
*
* @param {*} action
* @param {*} resource
* @returns {object}
*/
getApiEndpoint(action, resource=null) {
resource = resource || this.resource;
for(let ApiBizObj of Object.keys(app.config.api)) {
//If called without real ids
if(ApiBizObj==resource) return(JSON.parse(JSON.stringify(app.config.api[ApiBizObj][action])));
//If called with real ids
let re = new RegExp('^'+ApiBizObj.replace(/\//g,'\\/').replace(/\{\w+\}/gi,'([0-9a-zA-Z]+)')+'$', 'm')
if(resource.match(re)) {
if(app.config.api[ApiBizObj].hasOwnProperty(action)) return(JSON.parse(JSON.stringify(app.config.api[ApiBizObj][action])));
else console.error(`No API endpoint for action "${action}" on resource "${resource}"`)
}
}
console.error(`No API service for resource:${resource}`)
return({ "method":null, "uri": null });
}
setPrivileges(resource, privileges) {
this.resource = resource;
this.privileges = privileges || [];