2017-07-09 13:41:53 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-07-26 19:42:05 +00:00
|
|
|
const entityTypes = {
|
|
|
|
namespace: {
|
|
|
|
entitiesTable: 'namespaces',
|
|
|
|
sharesTable: 'shares_namespace',
|
|
|
|
permissionsTable: 'permissions_namespace'
|
|
|
|
},
|
|
|
|
report: {
|
|
|
|
entitiesTable: 'reports',
|
|
|
|
sharesTable: 'shares_report',
|
|
|
|
permissionsTable: 'permissions_report'
|
|
|
|
},
|
|
|
|
reportTemplate: {
|
|
|
|
entitiesTable: 'report_templates',
|
|
|
|
sharesTable: 'shares_report_template',
|
|
|
|
permissionsTable: 'permissions_report_template'
|
2017-07-09 13:41:53 +00:00
|
|
|
}
|
2017-07-24 04:03:32 +00:00
|
|
|
};
|
|
|
|
|
2017-07-26 19:42:05 +00:00
|
|
|
function getEntityTypes() {
|
|
|
|
return entityTypes;
|
2017-07-09 13:41:53 +00:00
|
|
|
}
|
|
|
|
|
2017-07-26 19:42:05 +00:00
|
|
|
function getEntityType(entityTypeId) {
|
|
|
|
const entityType = entityTypes[entityTypeId];
|
2017-07-09 13:41:53 +00:00
|
|
|
|
2017-07-26 19:42:05 +00:00
|
|
|
if (!entityType) {
|
|
|
|
throw new Error(`Unknown entity type ${entityTypeId}`);
|
2017-07-09 13:41:53 +00:00
|
|
|
}
|
|
|
|
|
2017-07-26 19:42:05 +00:00
|
|
|
return entityType
|
2017-07-09 13:41:53 +00:00
|
|
|
}
|
|
|
|
|
2017-07-24 04:03:32 +00:00
|
|
|
module.exports = {
|
2017-07-26 19:42:05 +00:00
|
|
|
getEntityTypes,
|
|
|
|
getEntityType
|
2017-07-24 04:03:32 +00:00
|
|
|
}
|